@holoscript/framework 6.0.3 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/CHANGELOG.md +1 -2
  2. package/ROADMAP.md +68 -66
  3. package/dist/{InvisibleWallet-BB6tFvRA.d.cts → InvisibleWallet-EFiuaLn3.d.cts} +1 -1
  4. package/dist/{OrchestratorAgent-BvWgf9uw.d.cts → OrchestratorAgent-CrLDGNL6.d.cts} +1 -1
  5. package/dist/agents/index.cjs +11 -10
  6. package/dist/agents/index.d.cts +4 -16
  7. package/dist/ai/index.cjs +2 -2
  8. package/dist/behavior.cjs +10 -0
  9. package/dist/economy/index.cjs +4 -4
  10. package/dist/economy/index.d.cts +2 -2
  11. package/dist/index.cjs +33 -11
  12. package/dist/index.d.cts +3 -3
  13. package/dist/swarm/index.cjs +3 -0
  14. package/package.json +14 -9
  15. package/src/__tests__/bounty-marketplace.test.ts +53 -21
  16. package/src/__tests__/delegation.test.ts +1 -4
  17. package/src/__tests__/done-log-audit.test.ts +38 -46
  18. package/src/__tests__/framework.test.ts +172 -53
  19. package/src/__tests__/goal-synthesizer.test.ts +9 -6
  20. package/src/__tests__/presence.test.ts +1 -1
  21. package/src/__tests__/protocol-agent.test.ts +12 -11
  22. package/src/__tests__/revenue-splitter.test.ts +22 -15
  23. package/src/__tests__/scenario-driven-todo.test.ts +55 -35
  24. package/src/__tests__/self-improve.test.ts +28 -9
  25. package/src/__tests__/service-lifecycle.test.ts +9 -3
  26. package/src/__tests__/skill-router.test.ts +3 -3
  27. package/src/agents/CulturalMemory.ts +6 -6
  28. package/src/agents/DelegationTraceHooks.ts +560 -0
  29. package/src/agents/FederatedRegistryAdapter.ts +1 -1
  30. package/src/agents/NormEngine.ts +3 -8
  31. package/src/agents/OrchestratorAgent.ts +1 -1
  32. package/src/agents/TaskDelegationService.ts +5 -9
  33. package/src/agents/__tests__/AgentWalletRegistry.test.ts +5 -4
  34. package/src/agents/__tests__/CrossRealityHandoff.test.ts +9 -3
  35. package/src/agents/__tests__/DelegationTraceHooks.test.ts +390 -0
  36. package/src/agents/__tests__/TaskDelegationService.test.ts +4 -2
  37. package/src/agents/spatial-comms/Layer1RealTime.ts +36 -19
  38. package/src/agents/spatial-comms/Layer2A2A.ts +1 -3
  39. package/src/agents/spatial-comms/Layer3MCP.ts +13 -4
  40. package/src/agents/spatial-comms/ProtocolTypes.ts +5 -2
  41. package/src/agents/spatial-comms/examples/multi-agent-world-creation.ts +2 -2
  42. package/src/ai/HoloScriptGenerator.ts +2 -2
  43. package/src/ai/__tests__/PerceptionSystem.prod.test.ts +1 -1
  44. package/src/ai/__tests__/PerceptionSystem.test.ts +14 -14
  45. package/src/ai/__tests__/SteeringBehaviors.prod.test.ts +1 -1
  46. package/src/ai/index.ts +5 -1
  47. package/src/board/audit.ts +17 -6
  48. package/src/board/board-ops.ts +45 -15
  49. package/src/board/board-types.ts +94 -20
  50. package/src/delegation.ts +5 -3
  51. package/src/distributed-claimer.ts +13 -2
  52. package/src/economy/BountyManager.ts +40 -18
  53. package/src/economy/KnowledgeMarketplace.ts +27 -8
  54. package/src/economy/PaymentWebhookService.ts +0 -1
  55. package/src/economy/RevenueSplitter.ts +2 -4
  56. package/src/economy/UnifiedBudgetOptimizer.ts +8 -9
  57. package/src/economy/_core-stubs.ts +1 -1
  58. package/src/economy/x402-facilitator.ts +17 -8
  59. package/src/index.ts +16 -12
  60. package/src/knowledge/__tests__/knowledge-consolidator.test.ts +138 -89
  61. package/src/knowledge/__tests__/knowledge-store-vector.test.ts +59 -16
  62. package/src/knowledge/brain.ts +7 -7
  63. package/src/knowledge/consolidation.ts +16 -16
  64. package/src/knowledge/knowledge-consolidator.ts +60 -30
  65. package/src/knowledge/knowledge-store.ts +83 -45
  66. package/src/learning/ProceduralCompiler.ts +6 -1
  67. package/src/learning/learning/MemoryConsolidator.ts +102 -0
  68. package/src/learning/learning/MemoryScorer.ts +69 -0
  69. package/src/learning/learning/ProceduralCompiler.ts +45 -0
  70. package/src/learning/learning/SemanticClusterer.ts +66 -0
  71. package/src/llm/llm-adapter.ts +24 -10
  72. package/src/mesh/index.ts +37 -17
  73. package/src/protocol/goal-synthesizer.ts +24 -34
  74. package/src/protocol/implementations.ts +91 -22
  75. package/src/protocol/micro-phase-decomposer.ts +25 -17
  76. package/src/protocol/micro-step-decomposer.test.ts +104 -39
  77. package/src/protocol-agent.test.ts +17 -7
  78. package/src/protocol-agent.ts +45 -42
  79. package/src/self-improve/absorb-scanner.ts +9 -6
  80. package/src/self-improve/evolution-engine.ts +36 -18
  81. package/src/self-improve/framework-absorber.ts +21 -16
  82. package/src/self-improve/index.ts +2 -10
  83. package/src/self-improve/prompt-optimizer.ts +31 -19
  84. package/src/self-improve/test-generator.ts +16 -12
  85. package/src/skill-router.ts +7 -6
  86. package/src/swarm/messaging/GossipProtocol.ts +1 -1
  87. package/src/swarm/messaging/__tests__/BroadcastChannel.prod.test.ts +31 -9
  88. package/src/swarm/messaging/__tests__/GossipProtocol.prod.test.ts +21 -7
  89. package/src/swarm/messaging/__tests__/SwarmEventBus.prod.test.ts +24 -8
  90. package/src/swarm/messaging/__tests__/SwarmEventBus.test.ts +6 -2
  91. package/src/team.ts +277 -122
  92. package/src/training/scripts/generate-spatial-dataset.ts +1 -1
  93. package/src/training/training/LRScheduler.ts +377 -0
  94. package/src/training/training/QualityScoringPipeline.ts +139 -0
  95. package/src/training/training/SoftDedup.ts +461 -0
  96. package/src/training/training/SparsityMonitor.ts +685 -0
  97. package/src/training/training/SparsityMonitorTypes.ts +209 -0
  98. package/src/training/training/SpatialTrainingDataGenerator.ts +1526 -0
  99. package/src/training/training/SpatialTrainingDataTypes.ts +216 -0
  100. package/src/training/training/TrainingPipelineConfig.ts +215 -0
  101. package/src/training/training/__tests__/CorpusValidation.test.ts +87 -0
  102. package/src/training/training/__tests__/LRScheduler.test.ts +592 -0
  103. package/src/training/training/__tests__/SoftDedup.test.ts +415 -0
  104. package/src/training/training/__tests__/SparsityMonitor.test.ts +1623 -0
  105. package/src/training/training/__tests__/SpatialCorpusValidation.test.ts +72 -0
  106. package/src/training/training/__tests__/SpatialTrainingDataGenerator.test.ts +1244 -0
  107. package/src/training/training/__tests__/TrainingMonkeyIntegration.test.ts +897 -0
  108. package/src/training/training/__tests__/TrainingPipelineConfig.test.ts +202 -0
  109. package/src/training/training/__tests__/schema.test.ts +72 -0
  110. package/src/training/training/__tests__/training-constants.test.ts +106 -0
  111. package/src/training/training/__tests__/trait-mappings.test.ts +81 -0
  112. package/src/training/training/constants.ts +94 -0
  113. package/src/training/training/index.ts +17 -0
  114. package/src/training/training/schema.ts +147 -0
  115. package/src/training/training/scripts/generate-novel-use-cases-dataset.ts +272 -0
  116. package/src/training/training/scripts/generate-spatial-dataset.ts +521 -0
  117. package/src/training/training/trainingmonkey/TrainingMonkeyIntegration.ts +477 -0
  118. package/src/training/training/trainingmonkey/TrainingMonkeyTypes.ts +230 -0
  119. package/src/training/training/trainingmonkey/index.ts +26 -0
  120. package/src/training/training/trait-mappings.ts +157 -0
  121. package/src/types.ts +2 -7
  122. package/ALL-test-results.json +0 -1
  123. package/LICENSE +0 -21
  124. package/dist/AgentManifest-CB4xM-Ma.d.ts +0 -704
  125. package/dist/BehaviorTree-BrBFECv5.d.ts +0 -103
  126. package/dist/InvisibleWallet-rtRrBOA8.d.ts +0 -1732
  127. package/dist/OrchestratorAgent-Q_CbVTmO.d.ts +0 -798
  128. package/dist/agents/index.d.ts +0 -1788
  129. package/dist/agents/index.js +0 -4695
  130. package/dist/ai/index.d.ts +0 -1753
  131. package/dist/ai/index.js +0 -5244
  132. package/dist/behavior.d.ts +0 -130
  133. package/dist/behavior.js +0 -407
  134. package/dist/economy/index.d.ts +0 -747
  135. package/dist/economy/index.js +0 -3617
  136. package/dist/implementations-D9T3un9D.d.ts +0 -236
  137. package/dist/index.d.ts +0 -1729
  138. package/dist/index.js +0 -24277
  139. package/dist/learning/index.d.ts +0 -104
  140. package/dist/learning/index.js +0 -189
  141. package/dist/negotiation/index.d.ts +0 -610
  142. package/dist/negotiation/index.js +0 -931
  143. package/dist/skills/index.d.ts +0 -289
  144. package/dist/skills/index.js +0 -1079
  145. package/dist/swarm/index.d.ts +0 -2433
  146. package/dist/swarm/index.js +0 -5221
  147. package/dist/training/index.d.ts +0 -1734
  148. package/dist/training/index.js +0 -2687
  149. package/extract-failures.js +0 -10
  150. package/src/training/training/data/novel-use-cases.jsonl +0 -153
  151. package/src/training/training/data/spatial-reasoning-10k.jsonl +0 -9354
  152. package/src/types/core-stubs.d.ts +0 -113
  153. package/test-output.txt +0 -0
  154. package/test-result.json +0 -1
  155. package/tsc-errors.txt +0 -4
  156. package/tsc_output.txt +0 -0
  157. package/typescript-errors-2.txt +0 -0
  158. package/typescript-errors.txt +0 -22
  159. package/vitest-log-utf8.txt +0 -268
  160. package/vitest-log.txt +0 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * SparsityMonitorTypes.ts
3
+ *
4
+ * Type definitions for SNN (Spiking Neural Network) sparsity monitoring
5
+ * in the self-improvement pipeline. Tracks spike rates, activation sparsity,
6
+ * energy efficiency metrics, and detects sparsity regime violations.
7
+ *
8
+ * Key threshold (W.041): SNN layers must maintain >= 93% activation sparsity
9
+ * to preserve the energy efficiency advantages of spike-based computation.
10
+ *
11
+ * @module training/SparsityMonitorTypes
12
+ */
13
+
14
+ // =============================================================================
15
+ // LAYER-LEVEL METRICS
16
+ // =============================================================================
17
+
18
+ /**
19
+ * Metrics for a single SNN layer during a simulation timestep or batch.
20
+ */
21
+ export interface SNNLayerMetrics {
22
+ /** Unique layer identifier (e.g., "lif_hidden_1", "snn_output") */
23
+ layerId: string;
24
+ /** Total number of neurons in this layer */
25
+ neuronCount: number;
26
+ /** Number of neurons that spiked (fired) in this timestep/batch */
27
+ spikeCount: number;
28
+ /** Spike rate = spikeCount / neuronCount (0-1) */
29
+ spikeRate: number;
30
+ /** Activation sparsity = 1 - spikeRate (0-1); higher = sparser = better */
31
+ activationSparsity: number;
32
+ /** Average membrane potential across neurons (for LIF models) */
33
+ avgMembranePotential?: number;
34
+ /** Simulation timestep index */
35
+ timestep: number;
36
+ }
37
+
38
+ // =============================================================================
39
+ // SNAPSHOT (POINT-IN-TIME MEASUREMENT)
40
+ // =============================================================================
41
+
42
+ /**
43
+ * A point-in-time snapshot of sparsity metrics across all SNN layers.
44
+ */
45
+ export interface SparsitySnapshot {
46
+ /** ISO 8601 timestamp of measurement */
47
+ timestamp: string;
48
+ /** Per-layer metrics at this point in time */
49
+ layers: SNNLayerMetrics[];
50
+ /** Aggregate sparsity across all layers (weighted by neuron count) */
51
+ aggregateSparsity: number;
52
+ /** Aggregate spike rate across all layers */
53
+ aggregateSpikeRate: number;
54
+ /** Total neurons across all layers */
55
+ totalNeurons: number;
56
+ /** Total spikes across all layers */
57
+ totalSpikes: number;
58
+ /** Energy efficiency metrics at this snapshot */
59
+ energyEfficiency: EnergyEfficiencyMetrics;
60
+ /** Any violations detected at this snapshot */
61
+ violations: SparsityViolation[];
62
+ }
63
+
64
+ // =============================================================================
65
+ // ENERGY EFFICIENCY METRICS
66
+ // =============================================================================
67
+
68
+ /**
69
+ * Theoretical energy efficiency metrics comparing SNN spike-based
70
+ * computation vs. equivalent dense (ANN) computation.
71
+ *
72
+ * The key insight: in an SNN, only spiking neurons perform multiply-accumulate
73
+ * (MAC) operations on their synaptic connections. Silent neurons contribute
74
+ * zero computation. This is the source of SNN energy efficiency.
75
+ */
76
+ export interface EnergyEfficiencyMetrics {
77
+ /** Total theoretical operations if all neurons were active (dense ANN baseline) */
78
+ denseOps: number;
79
+ /** Actual operations performed (only spiking neurons contribute) */
80
+ sparseOps: number;
81
+ /** Operations saved = denseOps - sparseOps */
82
+ opsSaved: number;
83
+ /** Efficiency ratio = opsSaved / denseOps (0-1); higher = more efficient */
84
+ efficiencyRatio: number;
85
+ /** Estimated energy savings factor (relative to dense baseline = 1.0) */
86
+ energySavingsFactor: number;
87
+ }
88
+
89
+ // =============================================================================
90
+ // SPARSITY VIOLATION
91
+ // =============================================================================
92
+
93
+ /**
94
+ * A detected violation of the sparsity threshold.
95
+ *
96
+ * Per W.041 from SNN research: SNN layers must maintain >= 93% activation
97
+ * sparsity. Below this threshold, the energy efficiency advantage of
98
+ * spike-based computation degrades significantly.
99
+ */
100
+ export interface SparsityViolation {
101
+ /** The layer that violated the threshold */
102
+ layerId: string;
103
+ /** The measured activation sparsity (0-1) */
104
+ measuredSparsity: number;
105
+ /** The required minimum sparsity threshold (default: 0.93) */
106
+ requiredThreshold: number;
107
+ /** How far below the threshold: threshold - measured */
108
+ deficit: number;
109
+ /** Severity classification */
110
+ severity: 'warning' | 'critical';
111
+ /** ISO 8601 timestamp of violation detection */
112
+ detectedAt: string;
113
+ /** Timestep at which the violation was detected */
114
+ timestep: number;
115
+ }
116
+
117
+ // =============================================================================
118
+ // CONFIGURATION
119
+ // =============================================================================
120
+
121
+ /**
122
+ * Configuration for the SparsityMonitor.
123
+ */
124
+ export interface SparsityMonitorConfig {
125
+ /** Minimum activation sparsity threshold (default: 0.93 per W.041) */
126
+ sparsityThreshold: number;
127
+ /** Window size for rolling average calculations (default: 50 timesteps) */
128
+ windowSize: number;
129
+ /** Whether to track per-layer detailed metrics (default: true) */
130
+ perLayerTracking: boolean;
131
+ /** Whether energy efficiency calculation is enabled (default: true) */
132
+ energyMetricsEnabled: boolean;
133
+ /** Average synaptic connections per neuron (for ops calculation, default: 100) */
134
+ avgSynapsesPerNeuron: number;
135
+ /** MAC operations per synaptic event (default: 2 - multiply + accumulate) */
136
+ opsPerSynapse: number;
137
+ /** Critical severity threshold: sparsity below this is critical (default: 0.85) */
138
+ criticalThreshold: number;
139
+ /** Maximum violations to retain in history (default: 1000) */
140
+ maxViolationHistory: number;
141
+ }
142
+
143
+ // =============================================================================
144
+ // STATISTICS
145
+ // =============================================================================
146
+
147
+ /**
148
+ * Aggregate statistics from the SparsityMonitor.
149
+ */
150
+ export interface SparsityMonitorStats {
151
+ /** Total number of timesteps recorded */
152
+ totalTimesteps: number;
153
+ /** Total number of snapshots taken */
154
+ totalSnapshots: number;
155
+ /** Number of layers being tracked */
156
+ trackedLayers: number;
157
+ /** Overall mean sparsity across all timesteps and layers */
158
+ meanSparsity: number;
159
+ /** Minimum sparsity observed */
160
+ minSparsity: number;
161
+ /** Maximum sparsity observed */
162
+ maxSparsity: number;
163
+ /** Standard deviation of sparsity measurements */
164
+ stdDevSparsity: number;
165
+ /** Total violations detected */
166
+ totalViolations: number;
167
+ /** Violations by severity */
168
+ violationsBySeverity: { warning: number; critical: number };
169
+ /** Per-layer mean sparsity */
170
+ perLayerMeanSparsity: Record<string, number>;
171
+ /** Mean energy efficiency ratio */
172
+ meanEnergyEfficiency: number;
173
+ /** Whether the system is currently in compliance (no active violations) */
174
+ inCompliance: boolean;
175
+ }
176
+
177
+ // =============================================================================
178
+ // QUALITY HISTORY ENTRY (compatible with quality-history.json)
179
+ // =============================================================================
180
+
181
+ /**
182
+ * An entry compatible with the quality-history.json format used by the
183
+ * self-improvement pipeline. Allows sparsity metrics to be tracked
184
+ * alongside existing quality metrics.
185
+ */
186
+ export interface SparsityQualityHistoryEntry {
187
+ /** ISO 8601 timestamp */
188
+ timestamp: string;
189
+ /** Monitoring cycle number */
190
+ cycle: number;
191
+ /** Aggregate sparsity as composite score (0-1) */
192
+ composite: number;
193
+ /** Grade based on sparsity compliance */
194
+ grade: 'A' | 'B' | 'C' | 'D' | 'F';
195
+ /** Focus area identifier */
196
+ focus: 'snn-sparsity';
197
+ /** Human-readable summary */
198
+ summary: string;
199
+ /** Detailed sparsity metrics */
200
+ sparsityMetrics: {
201
+ aggregateSparsity: number;
202
+ aggregateSpikeRate: number;
203
+ energyEfficiencyRatio: number;
204
+ violationCount: number;
205
+ layerCount: number;
206
+ totalNeurons: number;
207
+ inCompliance: boolean;
208
+ };
209
+ }