0xray 3.5.5 → 4.0.0

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 (229) hide show
  1. package/.mcp.json +51 -7
  2. package/.opencode/skills/api-design/SKILL.md +1 -1
  3. package/.opencode/skills/architect-tools/SKILL.md +1 -1
  4. package/.opencode/skills/architecture-patterns/SKILL.md +1 -1
  5. package/.opencode/skills/auto-format/SKILL.md +1 -1
  6. package/.opencode/skills/boot-orchestrator/SKILL.md +2 -6
  7. package/.opencode/skills/bug-triage/SKILL.md +1 -1
  8. package/.opencode/skills/code-analyzer/SKILL.md +1 -1
  9. package/.opencode/skills/code-review/SKILL.md +1 -1
  10. package/.opencode/skills/enforcer/SKILL.md +1 -1
  11. package/.opencode/skills/framework-compliance-audit/SKILL.md +1 -1
  12. package/.opencode/skills/git-workflow/SKILL.md +1 -1
  13. package/.opencode/skills/hermes-agent/SKILL.md +36 -36
  14. package/.opencode/skills/inference-improve/SKILL.md +1 -1
  15. package/.opencode/skills/lint/SKILL.md +1 -1
  16. package/.opencode/skills/log-monitor/SKILL.md +1 -1
  17. package/.opencode/skills/model-health-check/SKILL.md +1 -1
  18. package/.opencode/skills/multimodal-looker/SKILL.md +1 -1
  19. package/.opencode/skills/orchestrator/SKILL.md +38 -14
  20. package/.opencode/skills/performance-analysis/SKILL.md +1 -1
  21. package/.opencode/skills/performance-optimization/SKILL.md +1 -1
  22. package/.opencode/skills/processor-pipeline/SKILL.md +1 -1
  23. package/.opencode/skills/project-analysis/SKILL.md +1 -1
  24. package/.opencode/skills/refactoring-strategies/SKILL.md +1 -1
  25. package/.opencode/skills/registry.json +65 -0
  26. package/.opencode/skills/researcher/SKILL.md +18 -5
  27. package/.opencode/skills/security-audit/SKILL.md +1 -1
  28. package/.opencode/skills/security-scan/SKILL.md +1 -1
  29. package/.opencode/skills/session-management/SKILL.md +1 -1
  30. package/.opencode/skills/state-manager/SKILL.md +1 -1
  31. package/.opencode/skills/storyteller/SKILL.md +1 -1
  32. package/.opencode/skills/strategist/SKILL.md +12 -0
  33. package/.opencode/skills/testing-best-practices/SKILL.md +37 -0
  34. package/.opencode/skills/testing-strategy/SKILL.md +14 -3
  35. package/.opencode/skills/ui-ux-design/SKILL.md +1 -1
  36. package/.opencode/skills/xray-orchestrator/index.ts +267 -0
  37. package/.xray/codex.json +12 -3
  38. package/.xray/features.json +27 -5
  39. package/.xray/features.schema.json +31 -0
  40. package/AGENTS-consumer.md +16 -6
  41. package/AGENTS.md +11 -3
  42. package/README.md +13 -10
  43. package/SKILLS.md +1 -1
  44. package/dist/AGENTS.md +11 -3
  45. package/dist/CHANGELOG.md +65 -11
  46. package/dist/README.md +13 -10
  47. package/dist/SKILLS.md +1 -1
  48. package/dist/cli/commands/hermes-install.js +3 -0
  49. package/dist/cli/commands/openclaw-install.js +14 -0
  50. package/dist/core/features-config.d.ts +15 -2
  51. package/dist/infrastructure/schemas/cloud-schemas.d.ts +1 -1
  52. package/dist/integrations/grok/grok-cli.d.ts +3 -0
  53. package/dist/integrations/grok/grok-cli.js +92 -4
  54. package/dist/integrations/grok/hooks/grok-hook-utils.js +53 -7
  55. package/dist/integrations/grok/hooks/post-tool-use.js +68 -46
  56. package/dist/integrations/grok/hooks/pre-tool-use.js +14 -31
  57. package/dist/integrations/grok/hooks/session-start.js +86 -4
  58. package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
  59. package/dist/integrations/hermes-agent/bridge.mjs +19 -1
  60. package/dist/integrations/hooks/delegation-gate-runtime.mjs +32 -3
  61. package/dist/integrations/hooks/pipeline-hook-runtime.mjs +1 -1
  62. package/dist/integrations/hooks/station-hook-runtime.cjs +421 -0
  63. package/dist/integrations/hooks/station-hook-runtime.mjs +24 -0
  64. package/dist/integrations/hooks/station-memory-ingest.mjs +45 -0
  65. package/dist/integrations/hooks/station-memory-match.mjs +47 -0
  66. package/dist/integrations/openclaw/client.d.ts +5 -1
  67. package/dist/integrations/openclaw/client.js +17 -9
  68. package/dist/integrations/openclaw/config.js +0 -1
  69. package/dist/integrations/openclaw/hooks/pre-tool-gate-runtime.mjs +102 -0
  70. package/dist/integrations/openclaw/index.js +17 -0
  71. package/dist/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
  72. package/dist/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
  73. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +10 -0
  74. package/dist/integrations/openclaw/pre-tool-gate.d.ts +19 -0
  75. package/dist/integrations/openclaw/pre-tool-gate.js +39 -0
  76. package/dist/mcps/orchestrator/handlers/complexity-handler.js +2 -2
  77. package/dist/memory-routing/index.d.ts +1 -1
  78. package/dist/memory-routing/index.js +1 -1
  79. package/dist/memory-routing/provider-loader.d.ts +4 -0
  80. package/dist/memory-routing/provider-loader.js +44 -2
  81. package/dist/memory-routing/provider-registry.js +3 -2
  82. package/dist/nucleus/autonomy-kernel.d.ts +2 -2
  83. package/dist/nucleus/autonomy-kernel.js +17 -6
  84. package/dist/nucleus/confer.js +17 -3
  85. package/dist/nucleus/delegation-gate.d.ts +14 -8
  86. package/dist/nucleus/delegation-gate.js +151 -16
  87. package/dist/nucleus/suit-temperament.d.ts +40 -0
  88. package/dist/nucleus/suit-temperament.js +157 -0
  89. package/dist/nucleus/user-aside.js +1 -1
  90. package/dist/plugin/xray-codex-injection.js +14 -3
  91. package/dist/postprocessor/triggers/GitHookTrigger.js +11 -5
  92. package/opencode.json +88 -0
  93. package/package.json +14 -4
  94. package/scripts/hooks/install-hooks.cjs +18 -3
  95. package/scripts/hooks/run-hook.js +67 -3
  96. package/scripts/mjs/run-repertoire-mcp.mjs +39 -0
  97. package/scripts/mjs/verify-confer-core.mjs +1 -1
  98. package/scripts/mjs/verify-delegation-gate-core.mjs +29 -2
  99. package/scripts/mjs/verify-four-floor-compact.mjs +524 -0
  100. package/scripts/mjs/verify-pipeline-facets.mjs +215 -0
  101. package/scripts/mjs/verify-temperament-live.mjs +261 -0
  102. package/scripts/node/bridge-mcp-wiring.cjs +277 -29
  103. package/scripts/node/install-bridges.cjs +195 -33
  104. package/scripts/node/postinstall.cjs +50 -27
  105. package/scripts/node/release-gate.mjs +1 -1
  106. package/scripts/node/release.mjs +2 -2
  107. package/scripts/node/validate-release-docs.mjs +20 -33
  108. package/scripts/node/version-manager.mjs +25 -10
  109. package/src/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
  110. package/src/integrations/openclaw/README.md +134 -0
  111. package/src/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
  112. package/src/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
  113. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +10 -0
  114. package/src/mcps/orchestrator/handlers/complexity-handler.ts +2 -1
  115. package/vendor/@0xray/repertoire/AGENTS.md +163 -0
  116. package/vendor/@0xray/repertoire/LICENSE +21 -0
  117. package/vendor/@0xray/repertoire/README.md +120 -0
  118. package/vendor/@0xray/repertoire/data/curated_signals.json +208 -0
  119. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts +78 -0
  120. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts.map +1 -0
  121. package/vendor/@0xray/repertoire/dist/RepertoireService.js +153 -0
  122. package/vendor/@0xray/repertoire/dist/RepertoireService.js.map +1 -0
  123. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts +39 -0
  124. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts.map +1 -0
  125. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js +60 -0
  126. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js.map +1 -0
  127. package/vendor/@0xray/repertoire/dist/index.d.ts +14 -0
  128. package/vendor/@0xray/repertoire/dist/index.d.ts.map +1 -0
  129. package/vendor/@0xray/repertoire/dist/index.js +14 -0
  130. package/vendor/@0xray/repertoire/dist/index.js.map +1 -0
  131. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts +26 -0
  132. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts.map +1 -0
  133. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js +109 -0
  134. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js.map +1 -0
  135. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts +18 -0
  136. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts.map +1 -0
  137. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js +94 -0
  138. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js.map +1 -0
  139. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts +7 -0
  140. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts.map +1 -0
  141. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js +18 -0
  142. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js.map +1 -0
  143. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts +31 -0
  144. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts.map +1 -0
  145. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js +83 -0
  146. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js.map +1 -0
  147. package/vendor/@0xray/repertoire/dist/mcp/server.d.ts +6 -0
  148. package/vendor/@0xray/repertoire/dist/mcp/server.d.ts.map +1 -0
  149. package/vendor/@0xray/repertoire/dist/mcp/server.js +173 -0
  150. package/vendor/@0xray/repertoire/dist/mcp/server.js.map +1 -0
  151. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts +27 -0
  152. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts.map +1 -0
  153. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js +107 -0
  154. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js.map +1 -0
  155. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts +11 -0
  156. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts.map +1 -0
  157. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js +32 -0
  158. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js.map +1 -0
  159. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts +9 -0
  160. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts.map +1 -0
  161. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js +72 -0
  162. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js.map +1 -0
  163. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts +5 -0
  164. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts.map +1 -0
  165. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js +18 -0
  166. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js.map +1 -0
  167. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts +31 -0
  168. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts.map +1 -0
  169. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js +218 -0
  170. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js.map +1 -0
  171. package/vendor/@0xray/repertoire/dist/paths.d.ts +24 -0
  172. package/vendor/@0xray/repertoire/dist/paths.d.ts.map +1 -0
  173. package/vendor/@0xray/repertoire/dist/paths.js +74 -0
  174. package/vendor/@0xray/repertoire/dist/paths.js.map +1 -0
  175. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts +141 -0
  176. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts.map +1 -0
  177. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js +210 -0
  178. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js.map +1 -0
  179. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts +48 -0
  180. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts.map +1 -0
  181. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js +221 -0
  182. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js.map +1 -0
  183. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts +11 -0
  184. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts.map +1 -0
  185. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js +43 -0
  186. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js.map +1 -0
  187. package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts +15 -0
  188. package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts.map +1 -0
  189. package/vendor/@0xray/repertoire/dist/registry/signal-prune.js +35 -0
  190. package/vendor/@0xray/repertoire/dist/registry/signal-prune.js.map +1 -0
  191. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts +3 -0
  192. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts.map +1 -0
  193. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js +24 -0
  194. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js.map +1 -0
  195. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts +24 -0
  196. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts.map +1 -0
  197. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js +148 -0
  198. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js.map +1 -0
  199. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts +4 -0
  200. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts.map +1 -0
  201. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js +44 -0
  202. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js.map +1 -0
  203. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts +22 -0
  204. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts.map +1 -0
  205. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js +66 -0
  206. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js.map +1 -0
  207. package/vendor/@0xray/repertoire/dist/types.d.ts +210 -0
  208. package/vendor/@0xray/repertoire/dist/types.d.ts.map +1 -0
  209. package/vendor/@0xray/repertoire/dist/types.js +2 -0
  210. package/vendor/@0xray/repertoire/dist/types.js.map +1 -0
  211. package/vendor/@0xray/repertoire/docs/MEMORY-ROUTING-PROVIDER.md +54 -0
  212. package/vendor/@0xray/repertoire/hermes-mcp.example.json +20 -0
  213. package/vendor/@0xray/repertoire/mcp-config.example.json +11 -0
  214. package/vendor/@0xray/repertoire/package.json +124 -0
  215. package/vendor/@0xray/repertoire/schemas/curated-signal.schema.json +68 -0
  216. package/vendor/@0xray/repertoire/schemas/inference-log.schema.json +82 -0
  217. package/vendor/@0xray/repertoire/scripts/confirm-suit-all.mjs +253 -0
  218. package/vendor/@0xray/repertoire/scripts/confirm-suit-harness.mjs +220 -0
  219. package/vendor/@0xray/repertoire/scripts/run-live-synthesis-checkpoint.mjs +215 -0
  220. package/vendor/@0xray/repertoire/scripts/suit-bridge-shared.mjs +139 -0
  221. package/vendor/@0xray/repertoire/scripts/verify-grok-suit.mjs +304 -0
  222. package/vendor/@0xray/repertoire/scripts/verify-hermes-suit.mjs +163 -0
  223. package/vendor/@0xray/repertoire/scripts/verify-openclaw-suit.mjs +125 -0
  224. package/vendor/@0xray/repertoire/scripts/verify-opencode-suit.mjs +127 -0
  225. package/vendor/@0xray/repertoire/scripts/verify-synthesis-dogfood.mjs +207 -0
  226. package/vendor/@0xray/repertoire/skills/repertoire-trap-handling/SKILL.md +206 -0
  227. package/xray/codex.json +12 -3
  228. package/xray/features.json +27 -5
  229. package/xray/features.schema.json +31 -0
@@ -0,0 +1,221 @@
1
+ import { readFileSync, writeFileSync, existsSync } from 'node:fs';
2
+ export const DEFAULT_PROMOTION_MIN_CONFIDENCE = 0.55;
3
+ export const DEFAULT_PROMOTION_MIN_OBSERVATIONS = 2;
4
+ export const FEEDBACK_SUCCESS_CONFIDENCE_BOOST = 0.002;
5
+ export const FEEDBACK_FAILURE_CONFIDENCE_PENALTY = 0.005;
6
+ export const FEEDBACK_MIN_CONFIDENCE = DEFAULT_PROMOTION_MIN_CONFIDENCE;
7
+ export class CuratedSignalsManager {
8
+ filePath;
9
+ constructor(filePath = 'data/curated_signals.json') {
10
+ this.filePath = filePath;
11
+ }
12
+ load() {
13
+ if (!existsSync(this.filePath)) {
14
+ return this.createEmptyFile();
15
+ }
16
+ return JSON.parse(readFileSync(this.filePath, 'utf8'));
17
+ }
18
+ save(data) {
19
+ data.last_updated = new Date().toISOString();
20
+ writeFileSync(this.filePath, JSON.stringify(data, null, 2));
21
+ }
22
+ addSignal(signal) {
23
+ const data = this.load();
24
+ const exists = data.signals.some((s) => s.name === signal.name);
25
+ if (!exists) {
26
+ data.signals.push(signal);
27
+ this.save(data);
28
+ }
29
+ }
30
+ getByName(name) {
31
+ return this.load().signals.find((s) => s.name === name);
32
+ }
33
+ getByTag(tag) {
34
+ const normalized = tag.toLowerCase();
35
+ return this.load().signals.filter((s) => s.tags.some((t) => t.toLowerCase() === normalized));
36
+ }
37
+ getHighPrioritySignals() {
38
+ return this.load().signals.filter((s) => s.priority === 'high');
39
+ }
40
+ getByPriority(priority) {
41
+ return this.load().signals.filter((s) => s.priority === priority);
42
+ }
43
+ /**
44
+ * Score text against all signals using name, tags, definition, criteria, and snippet.
45
+ */
46
+ matchByText(text, minScore = 2) {
47
+ const normalized = text.toLowerCase();
48
+ const matches = [];
49
+ for (const signal of this.load().signals) {
50
+ const matchedOn = [];
51
+ let score = 0;
52
+ if (normalized.includes(signal.name.replace(/-/g, ' ')) || normalized.includes(signal.name)) {
53
+ score += 5;
54
+ matchedOn.push('name');
55
+ }
56
+ for (const tag of signal.tags) {
57
+ if (normalized.includes(tag.toLowerCase())) {
58
+ score += 3;
59
+ matchedOn.push('tag');
60
+ break;
61
+ }
62
+ }
63
+ const definitionWords = signal.definition.toLowerCase().split(/\W+/).filter((w) => w.length > 5);
64
+ const definitionHits = definitionWords.filter((w) => normalized.includes(w)).length;
65
+ if (definitionHits >= 2) {
66
+ score += Math.min(definitionHits, 4);
67
+ matchedOn.push('definition');
68
+ }
69
+ if (signal.evaluation_criteria) {
70
+ const criteriaWords = signal.evaluation_criteria.toLowerCase().split(/\W+/).filter((w) => w.length > 5);
71
+ const criteriaHits = criteriaWords.filter((w) => normalized.includes(w)).length;
72
+ if (criteriaHits >= 2) {
73
+ score += Math.min(criteriaHits, 3);
74
+ matchedOn.push('criteria');
75
+ }
76
+ }
77
+ if (signal.example_inference_snippet) {
78
+ const snippet = signal.example_inference_snippet.toLowerCase().slice(0, 80);
79
+ if (normalized.includes(snippet.slice(0, 40))) {
80
+ score += 4;
81
+ matchedOn.push('snippet');
82
+ }
83
+ }
84
+ if (signal.priority === 'high')
85
+ score += 1;
86
+ if (score >= minScore) {
87
+ matches.push({ signal, score, matchedOn });
88
+ }
89
+ }
90
+ return matches.sort((a, b) => b.score - a.score);
91
+ }
92
+ matchInferenceEntry(inference) {
93
+ const typeMatch = inference.match(/TYPE:\s*(\S+)/i);
94
+ const type = typeMatch?.[1]?.toLowerCase();
95
+ const matches = this.matchByText(inference, 2);
96
+ if (type === 'ontological-trap') {
97
+ const trapSignals = this.getByTag('ontological-trap');
98
+ for (const signal of trapSignals) {
99
+ if (!matches.some((m) => m.signal.name === signal.name)) {
100
+ matches.push({ signal, score: 3, matchedOn: ['tag'] });
101
+ }
102
+ }
103
+ }
104
+ return matches.sort((a, b) => b.score - a.score);
105
+ }
106
+ recordPrimitiveObservations(matches, options = {}) {
107
+ const minConfidence = options.minConfidence ?? DEFAULT_PROMOTION_MIN_CONFIDENCE;
108
+ const data = this.load();
109
+ const updated = [];
110
+ const now = new Date().toISOString();
111
+ for (const match of matches) {
112
+ if (match.confidence < minConfidence)
113
+ continue;
114
+ const signal = data.signals.find((entry) => entry.name === match.name);
115
+ if (!signal)
116
+ continue;
117
+ const previous = signal.observation_stats;
118
+ const observationCount = (previous?.observation_count ?? 0) + 1;
119
+ const totalConfidence = (previous?.avg_confidence ?? 0) * (observationCount - 1) + match.confidence;
120
+ signal.observation_stats = {
121
+ observation_count: observationCount,
122
+ avg_confidence: totalConfidence / observationCount,
123
+ max_confidence: Math.max(previous?.max_confidence ?? 0, match.confidence),
124
+ last_seen: now,
125
+ governance_forced_count: (previous?.governance_forced_count ?? 0) + (options.governanceForced ? 1 : 0),
126
+ };
127
+ updated.push(signal.name);
128
+ }
129
+ if (updated.length > 0) {
130
+ this.save(data);
131
+ }
132
+ return updated;
133
+ }
134
+ shouldPromoteSignal(signal, options = {}) {
135
+ const minAvgConfidence = options.minAvgConfidence ?? DEFAULT_PROMOTION_MIN_CONFIDENCE;
136
+ const minObservations = options.minObservations ?? DEFAULT_PROMOTION_MIN_OBSERVATIONS;
137
+ const fromStatus = options.fromStatus ?? 'proposed';
138
+ const stats = signal.observation_stats;
139
+ if ((signal.status ?? 'proposed') !== fromStatus || !stats) {
140
+ return false;
141
+ }
142
+ return (stats.avg_confidence >= minAvgConfidence &&
143
+ stats.observation_count >= minObservations);
144
+ }
145
+ promoteQualifiedSignals(options = {}) {
146
+ const toStatus = options.toStatus ?? 'validated';
147
+ const data = this.load();
148
+ const promoted = [];
149
+ for (const signal of data.signals) {
150
+ if (this.shouldPromoteSignal(signal, options)) {
151
+ signal.status = toStatus;
152
+ promoted.push(signal.name);
153
+ }
154
+ }
155
+ if (promoted.length > 0) {
156
+ this.save(data);
157
+ }
158
+ return promoted;
159
+ }
160
+ getSignalsAboveConfidence(minAvgConfidence = DEFAULT_PROMOTION_MIN_CONFIDENCE) {
161
+ return this.load().signals.filter((signal) => (signal.observation_stats?.avg_confidence ?? 0) >= minAvgConfidence);
162
+ }
163
+ /**
164
+ * Record orchestrator routing outcome against signals used for the task.
165
+ * Successful outcomes nudge avg_confidence up slightly; failures nudge down.
166
+ */
167
+ recordFeedbackOutcome(entry) {
168
+ const data = this.load();
169
+ const now = entry.timestamp || new Date().toISOString();
170
+ const signalNames = [...new Set(entry.repertoireSignals.filter(Boolean))];
171
+ const results = [];
172
+ for (const signalName of signalNames) {
173
+ const signal = data.signals.find((candidate) => candidate.name === signalName);
174
+ if (!signal)
175
+ continue;
176
+ const previousAvg = signal.observation_stats?.avg_confidence ?? null;
177
+ const previousFeedback = signal.feedback_stats;
178
+ const outcomeCount = (previousFeedback?.outcome_count ?? 0) + 1;
179
+ signal.feedback_stats = {
180
+ outcome_count: outcomeCount,
181
+ success_count: (previousFeedback?.success_count ?? 0) + (entry.success ? 1 : 0),
182
+ failure_count: (previousFeedback?.failure_count ?? 0) + (entry.success ? 0 : 1),
183
+ last_outcome: entry.success ? 'success' : 'failure',
184
+ last_task_id: entry.taskId,
185
+ last_assigned_agent: entry.assignedAgent,
186
+ last_duration_ms: entry.durationMs,
187
+ last_seen: now,
188
+ };
189
+ if (signal.observation_stats) {
190
+ const delta = entry.success
191
+ ? FEEDBACK_SUCCESS_CONFIDENCE_BOOST
192
+ : -FEEDBACK_FAILURE_CONFIDENCE_PENALTY;
193
+ const next = Math.max(FEEDBACK_MIN_CONFIDENCE, Math.min(1, signal.observation_stats.avg_confidence + delta));
194
+ signal.observation_stats = {
195
+ ...signal.observation_stats,
196
+ avg_confidence: next,
197
+ last_seen: now,
198
+ };
199
+ }
200
+ results.push({
201
+ signalName,
202
+ previousAvgConfidence: previousAvg,
203
+ updatedAvgConfidence: signal.observation_stats?.avg_confidence ?? null,
204
+ feedbackStats: signal.feedback_stats,
205
+ });
206
+ }
207
+ if (results.length > 0) {
208
+ this.save(data);
209
+ }
210
+ return results;
211
+ }
212
+ createEmptyFile() {
213
+ return {
214
+ description: 'Curated high-signal primitives for Repertoire',
215
+ schema_version: '1.1',
216
+ last_updated: new Date().toISOString(),
217
+ signals: [],
218
+ };
219
+ }
220
+ }
221
+ //# sourceMappingURL=CuratedSignalsManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CuratedSignalsManager.js","sourceRoot":"","sources":["../../src/registry/CuratedSignalsManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAkBlE,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,CAAC;AACrD,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,CAAC;AACvD,MAAM,CAAC,MAAM,mCAAmC,GAAG,KAAK,CAAC;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AASxE,MAAM,OAAO,qBAAqB;IACf,QAAQ,CAAS;IAElC,YAAY,QAAQ,GAAG,2BAA2B;QAChD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;QAChC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAuB,CAAC;IAC/E,CAAC;IAED,IAAI,CAAC,IAAwB;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,IAAI,EAAE,C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AAC;IAEO,eAAe;QACrB,OAAO;YACL,WAAW,EAAE,+CAA+C;YAC5D,cAAc,EAAE,KAAK;YACrB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACtC,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import type { InferenceState } from '../types.js';
2
+ export declare class InferenceStateManager {
3
+ private readonly filePath;
4
+ constructor(filePath?: string);
5
+ load(): InferenceState;
6
+ save(state: InferenceState): void;
7
+ isProcessed(id: string): boolean;
8
+ markProcessed(ids: string[], kind?: 'comment' | 'session'): void;
9
+ private createEmpty;
10
+ }
11
+ //# sourceMappingURL=InferenceStateManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferenceStateManager.d.ts","sourceRoot":"","sources":["../../src/registry/InferenceStateManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,SAA8B;IAEnE,IAAI,IAAI,cAAc;IAYtB,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAMjC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAKhC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,SAAS,GAAG,SAAqB,GAAG,IAAI;IAU3E,OAAO,CAAC,WAAW;CAGpB"}
@@ -0,0 +1,43 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ export class InferenceStateManager {
4
+ filePath;
5
+ constructor(filePath = 'data/inference-state.json') {
6
+ this.filePath = filePath;
7
+ }
8
+ load() {
9
+ if (!existsSync(this.filePath)) {
10
+ return this.createEmpty();
11
+ }
12
+ const raw = JSON.parse(readFileSync(this.filePath, 'utf8'));
13
+ return {
14
+ processedCommentIds: raw.processedCommentIds ?? [],
15
+ processedSessionIds: raw.processedSessionIds ?? [],
16
+ lastRun: raw.lastRun ?? null,
17
+ };
18
+ }
19
+ save(state) {
20
+ const dir = dirname(this.filePath);
21
+ if (!existsSync(dir))
22
+ mkdirSync(dir, { recursive: true });
23
+ writeFileSync(this.filePath, JSON.stringify(state, null, 2));
24
+ }
25
+ isProcessed(id) {
26
+ const state = this.load();
27
+ return state.processedCommentIds.includes(id) || state.processedSessionIds.includes(id);
28
+ }
29
+ markProcessed(ids, kind = 'comment') {
30
+ const state = this.load();
31
+ const target = kind === 'comment' ? state.processedCommentIds : state.processedSessionIds;
32
+ for (const id of ids) {
33
+ if (!target.includes(id))
34
+ target.push(id);
35
+ }
36
+ state.lastRun = new Date().toISOString();
37
+ this.save(state);
38
+ }
39
+ createEmpty() {
40
+ return { processedCommentIds: [], processedSessionIds: [], lastRun: null };
41
+ }
42
+ }
43
+ //# sourceMappingURL=InferenceStateManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InferenceStateManager.js","sourceRoot":"","sources":["../../src/registry/InferenceStateManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,WAAW,2BAA2B;QAAtC,aAAQ,GAAR,QAAQ,CAA8B;IAAG,CAAC;IAEvE,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAA4B,CAAC;QACvF,OAAO;YACL,mBAAmB,EAAE,GAAG,CAA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AAW;QACjB,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7E,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { CuratedSignal } from '../types.js';
2
+ import { CuratedSignalsManager } from './CuratedSignalsManager.js';
3
+ export interface PruneOptions {
4
+ minObservations?: number;
5
+ maxStaleDays?: number;
6
+ dryRun?: boolean;
7
+ }
8
+ export interface PruneResult {
9
+ removed: string[];
10
+ kept: number;
11
+ dryRun: boolean;
12
+ }
13
+ export declare function shouldPruneSignal(signal: CuratedSignal, opts: PruneOptions, now?: Date): boolean;
14
+ export declare function pruneSignals(manager: CuratedSignalsManager, opts?: PruneOptions): PruneResult;
15
+ //# sourceMappingURL=signal-prune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-prune.d.ts","sourceRoot":"","sources":["../../src/registry/signal-prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,WAAW,YAAY;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;CACjB;AAWD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,YAAY,EAClB,GAAG,OAAa,GACf,OAAO,CAMT;AAED,wBAAgB,YAAY,CAC1B,OAAO,EAAE,qBAAqB,EAC9B,IAAI,GAAE,YAAiB,GACtB,WAAW,CAoBb"}
@@ -0,0 +1,35 @@
1
+ const DEFAULT_MIN_OBSERVATIONS = 2;
2
+ const DEFAULT_MAX_STALE_DAYS = 90;
3
+ function daysSince(iso, now) {
4
+ if (!iso)
5
+ return Number.POSITIVE_INFINITY;
6
+ const ms = now.getTime() - new Date(iso).getTime();
7
+ return ms / (1000 * 60 * 60 * 24);
8
+ }
9
+ export function shouldPruneSignal(signal, opts, now = new Date()) {
10
+ const minObs = opts.minObservations ?? DEFAULT_MIN_OBSERVATIONS;
11
+ const maxDays = opts.maxStaleDays ?? DEFAULT_MAX_STALE_DAYS;
12
+ const count = signal.observation_stats?.observation_count ?? 0;
13
+ const lastSeen = signal.observation_stats?.last_seen ?? signal.first_seen;
14
+ return count < minObs || daysSince(lastSeen, now) > maxDays;
15
+ }
16
+ export function pruneSignals(manager, opts = {}) {
17
+ const dryRun = opts.dryRun ?? false;
18
+ const data = manager.load();
19
+ const removed = [];
20
+ const kept = [];
21
+ for (const signal of data.signals) {
22
+ if (shouldPruneSignal(signal, opts)) {
23
+ removed.push(signal.name);
24
+ }
25
+ else {
26
+ kept.push(signal);
27
+ }
28
+ }
29
+ if (!dryRun && removed.length > 0) {
30
+ data.signals = kept;
31
+ manager.save(data);
32
+ }
33
+ return { removed, kept: kept.length, dryRun };
34
+ }
35
+ //# sourceMappingURL=signal-prune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-prune.js","sourceRoot":"","sources":["../../src/registry/signal-prune.ts"],"names":[],"mappings":"AAeA,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC,SAAS,SAAS,CAAC,GAAuB,EAAE,GAAS;IACnD,IAAI,CAAC,GAAG;QAAE,OAAO,MAAM,CAAC,iBAAiB,CAAC;IAC1C,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACnD,OAAO,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAA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,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const MANDATORY_SYNTHESIS_SECTIONS: readonly ["Repeatedly Surfaced Missing Primitives & Invariants", "Concrete Validation Experiments", "System Validation Opportunities (Feats)", "Gap Analysis: Inference Output vs Current System State", "Strategic Recommendations (Actionable Only)"];
2
+ export declare const SYNTHESIS_SECTION_INSTRUCTIONS: string;
3
+ //# sourceMappingURL=concrete-sections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concrete-sections.d.ts","sourceRoot":"","sources":["../../src/synthesis/concrete-sections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,yPAM/B,CAAC;AAEX,eAAO,MAAM,8BAA8B,QAenC,CAAC"}
@@ -0,0 +1,24 @@
1
+ export const MANDATORY_SYNTHESIS_SECTIONS = [
2
+ 'Repeatedly Surfaced Missing Primitives & Invariants',
3
+ 'Concrete Validation Experiments',
4
+ 'System Validation Opportunities (Feats)',
5
+ 'Gap Analysis: Inference Output vs Current System State',
6
+ 'Strategic Recommendations (Actionable Only)',
7
+ ];
8
+ export const SYNTHESIS_SECTION_INSTRUCTIONS = `
9
+ ## 1. Repeatedly Surfaced Missing Primitives & Invariants
10
+ List 5–8 specific primitives or invariants that appear across multiple entries but are not yet tracked in the current Master Index or MCP filters. Rank by confidence-weighted score (avg_confidence × sqrt(occurrences)). For each, give the name + one-sentence definition + avg_confidence + which posts surfaced it.
11
+
12
+ ## 2. Concrete Validation Experiments
13
+ For each of the top 4–5 missing primitives above, propose one specific, executable validation experiment or test that would prove or disprove whether the current system can detect/handle that signal. Make them falsifiable.
14
+
15
+ ## 3. System Validation Opportunities (Feats)
16
+ Extract 4–6 demonstrable "feats" the Groover system should be able to perform based on what the inferences are repeatedly calling for. These should be measurable capabilities, not vague goals.
17
+
18
+ ## 4. Gap Analysis: Inference Output vs Current System State
19
+ Identify the largest observable gaps between what the inference replies are demanding and what the current MCP / Master Index / governance layer actually implements. Be specific.
20
+
21
+ ## 5. Strategic Recommendations (Actionable Only)
22
+ Maximum 5 recommendations. Each must name a concrete next action, not a principle.
23
+ `.trim();
24
+ //# sourceMappingURL=concrete-sections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"concrete-sections.js","sourceRoot":"","sources":["../../src/synthesis/concrete-sections.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,qDAAqD;IACrD,iCAAiC;IACjC,yCAAyC;IACzC,wDAAwD;IACxD,6CAA6C;CACrC,CAAC;AAEX,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;CAe7C,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { SynthesisReport } from '../types.js';
2
+ export interface MetaInferenceEngineOptions {
3
+ logDir?: string;
4
+ statePath?: string;
5
+ reportPath?: string;
6
+ batchSize?: number;
7
+ maxEntries?: number;
8
+ hermesCommand?: (prompt: string) => string;
9
+ }
10
+ export declare class MetaInferenceEngine {
11
+ private readonly logDir;
12
+ private readonly stateManager;
13
+ private readonly reportPath;
14
+ private readonly batchSize;
15
+ private readonly maxEntries;
16
+ private readonly promptBuilder;
17
+ private readonly runHermes;
18
+ constructor(options?: MetaInferenceEngineOptions);
19
+ run(): Promise<SynthesisReport | null>;
20
+ private loadUnprocessedEntries;
21
+ private appendReport;
22
+ private defaultHermesCommand;
23
+ }
24
+ //# sourceMappingURL=meta-inference-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta-inference-engine.d.ts","sourceRoot":"","sources":["../../src/synthesis/meta-inference-engine.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAKD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;gBAE3C,OAAO,GAAE,0BAA+B;IAS9C,GAAG,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAgG5C,OAAO,CAAC,sBAAsB;IA2B9B,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,oBAAoB;CAU7B"}
@@ -0,0 +1,148 @@
1
+ import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync, readdirSync } from 'node:fs';
2
+ import { join, dirname } from 'node:path';
3
+ import { execSync } from 'node:child_process';
4
+ import { SynthesisPromptBuilder } from './synthesis-prompt-builder.js';
5
+ import { InferenceStateManager } from '../registry/InferenceStateManager.js';
6
+ const DEFAULT_BATCH_SIZE = 1;
7
+ const DEFAULT_MAX_ENTRIES = 8;
8
+ export class MetaInferenceEngine {
9
+ logDir;
10
+ stateManager;
11
+ reportPath;
12
+ batchSize;
13
+ maxEntries;
14
+ promptBuilder = new SynthesisPromptBuilder();
15
+ runHermes;
16
+ constructor(options = {}) {
17
+ this.logDir = options.logDir ?? 'logs/groover-inference';
18
+ this.stateManager = new InferenceStateManager(options.statePath ?? 'data/inference-state.json');
19
+ this.reportPath = options.reportPath ?? 'logs/meta-inference/synthesis.md';
20
+ this.batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;
21
+ this.maxEntries = options.maxEntries ?? DEFAULT_MAX_ENTRIES;
22
+ this.runHermes = options.hermesCommand ?? this.defaultHermesCommand;
23
+ }
24
+ async run() {
25
+ const state = this.stateManager.load();
26
+ const processed = new Set([
27
+ ...state.processedCommentIds,
28
+ ...state.processedSessionIds,
29
+ ]);
30
+ if (!existsSync(this.logDir)) {
31
+ return null;
32
+ }
33
+ const newEntries = this.loadUnprocessedEntries(processed);
34
+ if (newEntries.length === 0) {
35
+ return null;
36
+ }
37
+ const entries = newEntries.slice(0, this.maxEntries);
38
+ const batchResults = [];
39
+ let totalPass = 0;
40
+ let totalReject = 0;
41
+ let resonanceSum = 0;
42
+ let resonanceCount = 0;
43
+ for (let i = 0; i < entries.length; i += this.batchSize) {
44
+ const batch = entries.slice(i, i + this.batchSize);
45
+ for (const e of batch) {
46
+ const rec = e.dynamo_result?.result?.recommendation;
47
+ if (rec === 'PASS')
48
+ totalPass++;
49
+ if (rec === 'REJECT')
50
+ totalReject++;
51
+ const res = e.dynamo_result?.result?.resonanceScore;
52
+ if (typeof res === 'number') {
53
+ resonanceSum += res;
54
+ resonanceCount++;
55
+ }
56
+ }
57
+ const avgResonance = resonanceCount > 0 ? (resonanceSum / resonanceCount).toFixed(3) : 'N/A';
58
+ const prompt = this.promptBuilder.buildBatchPrompt({
59
+ batchIndex: Math.floor(i / this.batchSize) + 1,
60
+ totalBatches: Math.ceil(entries.length / this.batchSize),
61
+ entries: batch,
62
+ globalIndex: i,
63
+ dynamoStats: {
64
+ pass: totalPass,
65
+ reject: totalReject,
66
+ avgResonance,
67
+ analyzedSoFar: i + batch.length,
68
+ },
69
+ });
70
+ try {
71
+ batchResults.push(this.runHermes(prompt));
72
+ }
73
+ catch {
74
+ // Continue with remaining batches
75
+ }
76
+ }
77
+ const avgResonance = resonanceCount > 0 ? (resonanceSum / resonanceCount).toFixed(3) : 'N/A';
78
+ const finalPrompt = this.promptBuilder.buildFinalSynthesisPrompt(entries.length, { pass: totalPass, reject: totalReject, avgResonance }, batchResults, entries);
79
+ let finalReport = '';
80
+ try {
81
+ finalReport = this.runHermes(finalPrompt);
82
+ this.appendReport(entries.length, totalPass, resonanceCount > 0 ? resonanceSum / resonanceCount : null, finalReport);
83
+ }
84
+ catch {
85
+ finalReport = batchResults.join('\n\n---\n\n');
86
+ }
87
+ const ids = entries.map((e) => e.comment_id ?? e.post_id ?? e.session_id).filter(Boolean);
88
+ const hasSession = entries.some((e) => e.session_id);
89
+ this.stateManager.markProcessed(ids, hasSession ? 'session' : 'comment');
90
+ return {
91
+ entriesProcessed: entries.length,
92
+ batchResults,
93
+ finalReport,
94
+ timestamp: new Date().toISOString(),
95
+ dynamoStats: {
96
+ pass: totalPass,
97
+ reject: totalReject,
98
+ avgResonance: resonanceCount > 0 ? resonanceSum / resonanceCount : null,
99
+ },
100
+ };
101
+ }
102
+ loadUnprocessedEntries(processed) {
103
+ const files = readdirSync(this.logDir)
104
+ .filter((f) => f.endsWith('.jsonl'))
105
+ .sort();
106
+ const entries = [];
107
+ for (const file of files) {
108
+ const lines = readFileSync(join(this.logDir, file), 'utf8').trim().split('\n');
109
+ for (const line of lines) {
110
+ if (!line)
111
+ continue;
112
+ try {
113
+ const entry = JSON.parse(line);
114
+ const id = entry.comment_id ?? entry.post_id ?? entry.session_id;
115
+ if (id && !processed.has(id)) {
116
+ entries.push(entry);
117
+ processed.add(id);
118
+ }
119
+ }
120
+ catch {
121
+ // skip malformed
122
+ }
123
+ }
124
+ }
125
+ return entries;
126
+ }
127
+ appendReport(entryCount, passCount, avgResonance, report) {
128
+ const dir = dirname(this.reportPath);
129
+ if (!existsSync(dir))
130
+ mkdirSync(dir, { recursive: true });
131
+ const header = `\n\n## Meta-Inference Run — ${new Date().toISOString()}\n` +
132
+ `Entries: ${entryCount} | ` +
133
+ `Dynamo PASS rate: ${passCount}/${entryCount} | ` +
134
+ `Avg resonance: ${avgResonance?.toFixed(3) ?? 'N/A'}\n\n`;
135
+ appendFileSync(this.reportPath, header + report);
136
+ }
137
+ defaultHermesCommand(prompt) {
138
+ const tmpPath = '/tmp/repertoire-meta-inference.txt';
139
+ writeFileSync(tmpPath, prompt);
140
+ const cmd = `hermes -z "$(cat ${tmpPath})" --provider xai-oauth --model grok-4.3`;
141
+ return execSync(cmd, {
142
+ encoding: 'utf8',
143
+ stdio: ['pipe', 'pipe', 'pipe'],
144
+ timeout: 300_000,
145
+ }).trim();
146
+ }
147
+ }
148
+ //# sourceMappingURL=meta-inference-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta-inference-engine.js","sourceRoot":"","sources":["../../src/synthesis/meta-inference-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1G,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAY7E,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,OAAO,mBAAmB;IACb,MAAM,CAAS;IACf,YAAY,CAAwB;IACpC,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,aAAa,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC7C,SAAS,CAA6B;IAEvD,YAAY,UAAsC,EAAE;QAClD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,wBAAwB,CAAC;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAqB,CAAC,OAAO,CAAC,SAAS,IAAI,2BAA2B,CAAC,CAAC;QA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AAO,OAAO,CAAC;IACjB,CAAC;IAEO,YAAY,CAClB,UAAkB,EAClB,SAAiB,EACjB,YAA2B,EAC3B,MAAc;QAEd,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1D,MAAM,MAAM,GACV,+BAA+B,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI;YAC3D,YAAY,UAAU,KAAK;YAC3B,qBAAqB,SAAS,IAAI,UAAU,KAAK;YACjD,kBAAkB,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;QAE5D,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACnD,CAAC;IAEO,oBAAoB,CAAC,MAAc;QACzC,MAAM,OAAO,GAAG,oCAAoC,CAAC;QACrD,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,oBAAoB,OAAO,0CAA0C,CAAC;QAClF,OAAO,QAAQ,CAAC,GAAG,EAAE;YACnB,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { InferenceEntry, WeightedPrimitive } from '../types.js';
2
+ export declare function aggregateWeightedPrimitives(entries: InferenceEntry[]): WeightedPrimitive[];
3
+ export declare function formatWeightedPrimitivesSection(entries: InferenceEntry[], limit?: number): string;
4
+ //# sourceMappingURL=primitive-confidence-aggregator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"primitive-confidence-aggregator.d.ts","sourceRoot":"","sources":["../../src/synthesis/primitive-confidence-aggregator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErE,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,iBAAiB,EAAE,CAwC1F;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,cAAc,EAAE,EACzB,KAAK,SAAI,GACR,MAAM,CAYR"}