0xray 3.5.5 → 4.0.1

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 (233) hide show
  1. package/.mcp.json +18 -14
  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 +28 -6
  39. package/.xray/features.schema.json +31 -0
  40. package/AGENTS-consumer.md +17 -7
  41. package/AGENTS.md +18 -10
  42. package/README.md +30 -27
  43. package/SKILLS.md +2 -2
  44. package/dist/AGENTS.md +18 -10
  45. package/dist/CHANGELOG.md +81 -11
  46. package/dist/README.md +30 -27
  47. package/dist/SKILLS.md +2 -2
  48. package/dist/cli/commands/hermes-install.js +3 -0
  49. package/dist/cli/commands/openclaw-install.js +14 -0
  50. package/dist/cli/index.js +10 -1
  51. package/dist/core/features-config.d.ts +15 -2
  52. package/dist/infrastructure/schemas/cloud-schemas.d.ts +1 -1
  53. package/dist/integrations/grok/grok-cli.d.ts +3 -0
  54. package/dist/integrations/grok/grok-cli.js +92 -4
  55. package/dist/integrations/grok/hooks/grok-hook-utils.js +53 -7
  56. package/dist/integrations/grok/hooks/post-tool-use.js +68 -46
  57. package/dist/integrations/grok/hooks/pre-tool-use.js +14 -31
  58. package/dist/integrations/grok/hooks/session-start.js +86 -4
  59. package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
  60. package/dist/integrations/hermes-agent/bridge.mjs +26 -1
  61. package/dist/integrations/hooks/delegation-gate-runtime.mjs +32 -3
  62. package/dist/integrations/hooks/pipeline-hook-runtime.mjs +1 -1
  63. package/dist/integrations/hooks/station-hook-runtime.cjs +421 -0
  64. package/dist/integrations/hooks/station-hook-runtime.mjs +24 -0
  65. package/dist/integrations/hooks/station-memory-ingest.mjs +45 -0
  66. package/dist/integrations/hooks/station-memory-match.mjs +47 -0
  67. package/dist/integrations/openclaw/client.d.ts +5 -1
  68. package/dist/integrations/openclaw/client.js +17 -9
  69. package/dist/integrations/openclaw/config.js +0 -1
  70. package/dist/integrations/openclaw/hooks/pre-tool-gate-runtime.mjs +102 -0
  71. package/dist/integrations/openclaw/index.js +17 -0
  72. package/dist/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
  73. package/dist/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
  74. package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +12 -0
  75. package/dist/integrations/openclaw/pre-tool-gate.d.ts +19 -0
  76. package/dist/integrations/openclaw/pre-tool-gate.js +39 -0
  77. package/dist/mcps/orchestrator/handlers/complexity-handler.js +2 -2
  78. package/dist/memory-routing/index.d.ts +1 -1
  79. package/dist/memory-routing/index.js +1 -1
  80. package/dist/memory-routing/provider-loader.d.ts +4 -0
  81. package/dist/memory-routing/provider-loader.js +44 -2
  82. package/dist/memory-routing/provider-registry.js +3 -2
  83. package/dist/nucleus/autonomy-kernel.d.ts +2 -2
  84. package/dist/nucleus/autonomy-kernel.js +17 -6
  85. package/dist/nucleus/confer.js +17 -3
  86. package/dist/nucleus/delegation-gate.d.ts +14 -8
  87. package/dist/nucleus/delegation-gate.js +151 -16
  88. package/dist/nucleus/suit-temperament.d.ts +40 -0
  89. package/dist/nucleus/suit-temperament.js +157 -0
  90. package/dist/nucleus/user-aside.js +1 -1
  91. package/dist/plugin/xray-codex-injection.js +14 -3
  92. package/dist/postprocessor/triggers/GitHookTrigger.js +11 -5
  93. package/opencode.json +80 -0
  94. package/package.json +15 -5
  95. package/scripts/hooks/install-hooks.cjs +18 -3
  96. package/scripts/hooks/run-hook.js +67 -3
  97. package/scripts/mjs/run-repertoire-mcp.mjs +39 -0
  98. package/scripts/mjs/verify-confer-core.mjs +1 -1
  99. package/scripts/mjs/verify-delegation-gate-core.mjs +29 -2
  100. package/scripts/mjs/verify-four-floor-compact.mjs +524 -0
  101. package/scripts/mjs/verify-pipeline-facets.mjs +215 -0
  102. package/scripts/mjs/verify-temperament-live.mjs +261 -0
  103. package/scripts/node/bridge-mcp-wiring.cjs +277 -29
  104. package/scripts/node/consumer-install-smoke.mjs +55 -2
  105. package/scripts/node/install-bridges.cjs +195 -33
  106. package/scripts/node/postinstall.cjs +50 -27
  107. package/scripts/node/reconcile-version.mjs +0 -4
  108. package/scripts/node/release-gate.mjs +1 -1
  109. package/scripts/node/release.mjs +2 -2
  110. package/scripts/node/universal-version-manager.js +1 -1
  111. package/scripts/node/validate-release-docs.mjs +20 -33
  112. package/scripts/node/version-manager.mjs +63 -18
  113. package/src/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
  114. package/src/integrations/openclaw/README.md +134 -0
  115. package/src/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
  116. package/src/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
  117. package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +12 -0
  118. package/src/mcps/orchestrator/handlers/complexity-handler.ts +2 -1
  119. package/vendor/@0xray/repertoire/AGENTS.md +163 -0
  120. package/vendor/@0xray/repertoire/LICENSE +21 -0
  121. package/vendor/@0xray/repertoire/README.md +120 -0
  122. package/vendor/@0xray/repertoire/data/curated_signals.json +208 -0
  123. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts +78 -0
  124. package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts.map +1 -0
  125. package/vendor/@0xray/repertoire/dist/RepertoireService.js +153 -0
  126. package/vendor/@0xray/repertoire/dist/RepertoireService.js.map +1 -0
  127. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts +39 -0
  128. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts.map +1 -0
  129. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js +60 -0
  130. package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js.map +1 -0
  131. package/vendor/@0xray/repertoire/dist/index.d.ts +14 -0
  132. package/vendor/@0xray/repertoire/dist/index.d.ts.map +1 -0
  133. package/vendor/@0xray/repertoire/dist/index.js +14 -0
  134. package/vendor/@0xray/repertoire/dist/index.js.map +1 -0
  135. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts +26 -0
  136. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts.map +1 -0
  137. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js +109 -0
  138. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js.map +1 -0
  139. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts +18 -0
  140. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts.map +1 -0
  141. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js +94 -0
  142. package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js.map +1 -0
  143. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts +7 -0
  144. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts.map +1 -0
  145. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js +18 -0
  146. package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js.map +1 -0
  147. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts +31 -0
  148. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts.map +1 -0
  149. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js +83 -0
  150. package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js.map +1 -0
  151. package/vendor/@0xray/repertoire/dist/mcp/server.d.ts +6 -0
  152. package/vendor/@0xray/repertoire/dist/mcp/server.d.ts.map +1 -0
  153. package/vendor/@0xray/repertoire/dist/mcp/server.js +173 -0
  154. package/vendor/@0xray/repertoire/dist/mcp/server.js.map +1 -0
  155. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts +27 -0
  156. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts.map +1 -0
  157. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js +107 -0
  158. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js.map +1 -0
  159. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts +11 -0
  160. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts.map +1 -0
  161. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js +32 -0
  162. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js.map +1 -0
  163. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts +9 -0
  164. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts.map +1 -0
  165. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js +72 -0
  166. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js.map +1 -0
  167. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts +5 -0
  168. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts.map +1 -0
  169. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js +18 -0
  170. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js.map +1 -0
  171. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts +31 -0
  172. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts.map +1 -0
  173. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js +218 -0
  174. package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js.map +1 -0
  175. package/vendor/@0xray/repertoire/dist/paths.d.ts +24 -0
  176. package/vendor/@0xray/repertoire/dist/paths.d.ts.map +1 -0
  177. package/vendor/@0xray/repertoire/dist/paths.js +74 -0
  178. package/vendor/@0xray/repertoire/dist/paths.js.map +1 -0
  179. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts +141 -0
  180. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts.map +1 -0
  181. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js +210 -0
  182. package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js.map +1 -0
  183. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts +48 -0
  184. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts.map +1 -0
  185. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js +221 -0
  186. package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js.map +1 -0
  187. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts +11 -0
  188. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts.map +1 -0
  189. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js +43 -0
  190. package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js.map +1 -0
  191. package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts +15 -0
  192. package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts.map +1 -0
  193. package/vendor/@0xray/repertoire/dist/registry/signal-prune.js +35 -0
  194. package/vendor/@0xray/repertoire/dist/registry/signal-prune.js.map +1 -0
  195. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts +3 -0
  196. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts.map +1 -0
  197. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js +24 -0
  198. package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js.map +1 -0
  199. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts +24 -0
  200. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts.map +1 -0
  201. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js +148 -0
  202. package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js.map +1 -0
  203. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts +4 -0
  204. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts.map +1 -0
  205. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js +44 -0
  206. package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js.map +1 -0
  207. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts +22 -0
  208. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts.map +1 -0
  209. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js +66 -0
  210. package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js.map +1 -0
  211. package/vendor/@0xray/repertoire/dist/types.d.ts +210 -0
  212. package/vendor/@0xray/repertoire/dist/types.d.ts.map +1 -0
  213. package/vendor/@0xray/repertoire/dist/types.js +2 -0
  214. package/vendor/@0xray/repertoire/dist/types.js.map +1 -0
  215. package/vendor/@0xray/repertoire/docs/MEMORY-ROUTING-PROVIDER.md +54 -0
  216. package/vendor/@0xray/repertoire/hermes-mcp.example.json +20 -0
  217. package/vendor/@0xray/repertoire/mcp-config.example.json +11 -0
  218. package/vendor/@0xray/repertoire/package.json +124 -0
  219. package/vendor/@0xray/repertoire/schemas/curated-signal.schema.json +68 -0
  220. package/vendor/@0xray/repertoire/schemas/inference-log.schema.json +82 -0
  221. package/vendor/@0xray/repertoire/scripts/confirm-suit-all.mjs +253 -0
  222. package/vendor/@0xray/repertoire/scripts/confirm-suit-harness.mjs +220 -0
  223. package/vendor/@0xray/repertoire/scripts/run-live-synthesis-checkpoint.mjs +215 -0
  224. package/vendor/@0xray/repertoire/scripts/suit-bridge-shared.mjs +139 -0
  225. package/vendor/@0xray/repertoire/scripts/verify-grok-suit.mjs +304 -0
  226. package/vendor/@0xray/repertoire/scripts/verify-hermes-suit.mjs +163 -0
  227. package/vendor/@0xray/repertoire/scripts/verify-openclaw-suit.mjs +125 -0
  228. package/vendor/@0xray/repertoire/scripts/verify-opencode-suit.mjs +127 -0
  229. package/vendor/@0xray/repertoire/scripts/verify-synthesis-dogfood.mjs +207 -0
  230. package/vendor/@0xray/repertoire/skills/repertoire-trap-handling/SKILL.md +206 -0
  231. package/xray/codex.json +12 -3
  232. package/xray/features.json +28 -6
  233. package/xray/features.schema.json +31 -0
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Grok Build harness confirmation protocol (Layers 2a/2c + 2b checklist).
4
+ *
5
+ * Invoked by:
6
+ * npm run confirm:suit — full Grok confirm (Layer 1 via verify:suit + this harness + trap test)
7
+ * npm run confirm:suit:all — all 4 bridges + this harness for Grok deep probes
8
+ *
9
+ * Layer 1: filesystem + CLI (verify-grok-suit.mjs) — run separately or via confirm:suit
10
+ * Layer 2a: stdio MCP probes (repertoire memory routing — bypasses harness prefix bug)
11
+ * Layer 2b: harness MCP probes (agent runs CallMcpTool live — documented below)
12
+ */
13
+ import { spawn } from 'node:child_process';
14
+ import { execSync } from 'node:child_process';
15
+ import { existsSync, readFileSync } from 'node:fs';
16
+ import { resolve, join } from 'node:path';
17
+ import { readInstalledXrayVersion } from './suit-bridge-shared.mjs';
18
+
19
+ const root = resolve(import.meta.dirname, '..');
20
+ const skipLayer1 = process.argv.includes('--skip-layer1');
21
+
22
+ function resolveResearcherServerPath() {
23
+ const sibling = resolve(root, '../xray/dist/mcps/researcher.server.js');
24
+ if (existsSync(sibling)) return sibling;
25
+ return resolve(root, 'node_modules/0xray/dist/mcps/researcher.server.js');
26
+ }
27
+
28
+ const TRAP_PROBE_DESCRIPTION =
29
+ 'TYPE: ontological-trap attestation-as-map consumer-boundary revalidation required';
30
+
31
+ function mcpStdioProbe({ serverPath, toolName, args, timeoutMs = 4000 }) {
32
+ return new Promise((resolveProbe, rejectProbe) => {
33
+ const messages = [
34
+ {
35
+ jsonrpc: '2.0',
36
+ id: 1,
37
+ method: 'initialize',
38
+ params: {
39
+ protocolVersion: '2024-11-05',
40
+ capabilities: {},
41
+ clientInfo: { name: 'confirm-suit-harness', version: '1.0' },
42
+ },
43
+ },
44
+ {
45
+ jsonrpc: '2.0',
46
+ id: 2,
47
+ method: 'tools/call',
48
+ params: { name: toolName, arguments: args },
49
+ },
50
+ ];
51
+
52
+ const proc = spawn('node', [serverPath], { cwd: root, stdio: ['pipe', 'pipe', 'pipe'] });
53
+ let out = '';
54
+ proc.stdout.on('data', (chunk) => {
55
+ out += chunk.toString();
56
+ });
57
+ proc.stderr.on('data', (chunk) => {
58
+ out += chunk.toString();
59
+ });
60
+
61
+ const timer = setTimeout(() => {
62
+ proc.kill();
63
+ rejectProbe(new Error(`timeout after ${timeoutMs}ms`));
64
+ }, timeoutMs);
65
+
66
+ proc.on('close', (code) => {
67
+ clearTimeout(timer);
68
+ if (code !== null && code !== 0 && !out.includes('"result"')) {
69
+ rejectProbe(new Error(`exit ${code}: ${out.slice(0, 200)}`));
70
+ return;
71
+ }
72
+ resolveProbe(out);
73
+ });
74
+
75
+ for (const msg of messages) {
76
+ proc.stdin.write(`${JSON.stringify(msg)}\n`);
77
+ }
78
+ setTimeout(() => proc.kill('SIGTERM'), timeoutMs - 200);
79
+ });
80
+ }
81
+
82
+ console.log('═══ 0xRay Suit Confirmation Protocol ═══\n');
83
+
84
+ // ── Layer 1 ──────────────────────────────────────────────────────────────────
85
+ let layer1Ok = skipLayer1;
86
+ if (skipLayer1) {
87
+ console.log('Layer 1 — Skipped (--skip-layer1; already verified by confirm-suit-all)\n');
88
+ } else {
89
+ console.log('Layer 1 — Local install (automated)\n');
90
+ try {
91
+ execSync('node scripts/verify-grok-suit.mjs', { cwd: root, stdio: 'inherit' });
92
+ layer1Ok = true;
93
+ } catch {
94
+ console.error('\n❌ Layer 1 FAILED — fix before harness probes\n');
95
+ process.exit(1);
96
+ }
97
+ }
98
+
99
+ // ── Layer 2a — stdio probes ──────────────────────────────────────────────────
100
+ console.log('\nLayer 2a — Stdio MCP probes (automated)\n');
101
+ const layer2a = [];
102
+
103
+ const repertoireServer = resolve(root, 'dist/mcp/server.js');
104
+ if (!existsSync(repertoireServer)) {
105
+ console.error('❌ repertoire stdio — dist/mcp/server.js missing (run npm run build)');
106
+ layer2a.push({ name: 'repertoire stdio', ok: false });
107
+ } else {
108
+ try {
109
+ const out = await mcpStdioProbe({
110
+ serverPath: repertoireServer,
111
+ toolName: 'get_task_confidence',
112
+ args: { description: 'Confirm 0xRay suit worn after reboot' },
113
+ });
114
+ const ok =
115
+ out.includes('repertoire__get_task_confidence') ||
116
+ out.includes('recommendedAgent') ||
117
+ out.includes('highConfidenceTrapPresent');
118
+ layer2a.push({ name: 'repertoire__get_task_confidence (stdio)', ok });
119
+ console.log(ok ? '✅ repertoire__get_task_confidence (stdio)' : '❌ repertoire stdio — unexpected response');
120
+ } catch (e) {
121
+ layer2a.push({ name: 'repertoire stdio', ok: false });
122
+ console.error(`❌ repertoire stdio — ${e.message}`);
123
+ }
124
+ }
125
+
126
+ // ── Layer 2c — researcher trap routing (MCP subprocess) ───────────────────
127
+ console.log('\nLayer 2c — Researcher trap routing e2e (automated)\n');
128
+ const layer2c = [];
129
+
130
+ const researcherServer = resolveResearcherServerPath();
131
+ if (!existsSync(researcherServer)) {
132
+ console.error('❌ researcher stdio — server missing');
133
+ layer2c.push({ name: 'researcher trap routing', ok: false });
134
+ } else {
135
+ try {
136
+ let ok = false;
137
+ let lastOut = '';
138
+ for (let attempt = 0; attempt < 6 && !ok; attempt++) {
139
+ if (attempt > 0) await new Promise((r) => setTimeout(r, 500));
140
+ lastOut = await mcpStdioProbe({
141
+ serverPath: researcherServer,
142
+ toolName: 'analyze_proposal',
143
+ args: {
144
+ proposalTitle: 'Trap governance review',
145
+ proposalDescription: TRAP_PROBE_DESCRIPTION,
146
+ proposalType: 'governance',
147
+ },
148
+ timeoutMs: 8000,
149
+ });
150
+ ok =
151
+ lastOut.includes('MEMORY_ROUTING:') &&
152
+ lastOut.includes('recommendedAgent: architect') &&
153
+ lastOut.includes('attestation-as-map');
154
+ }
155
+ layer2c.push({ name: 'analyze_proposal trap routing (stdio)', ok });
156
+ console.log(
157
+ ok
158
+ ? '✅ analyze_proposal trap routing (stdio)'
159
+ : '❌ researcher trap routing — silent no-op (MEMORY_ROUTING missing)',
160
+ );
161
+ if (!ok) {
162
+ console.error(` Response snippet: ${lastOut.slice(0, 240)}`);
163
+ }
164
+ } catch (e) {
165
+ layer2c.push({ name: 'researcher trap routing', ok: false });
166
+ console.error(`❌ researcher trap routing — ${e.message}`);
167
+ }
168
+ }
169
+
170
+ // ── Layer 2b — harness checklist (agent-verified) ──────────────────────────
171
+ console.log('\nLayer 2b — Harness MCP probes (agent CallMcpTool after reboot)\n');
172
+ const harnessProbes = [
173
+ { server: 'xray-enforcer', tool: 'get-enforcement-status', key: 'totalRules' },
174
+ { server: 'xray-enforcer', tool: 'codex-enforcement', key: 'termsValidated', args: { operation: 'suit-probe' } },
175
+ { server: 'xray-skills', tool: 'list-skills', key: 'Skills' },
176
+ { server: 'xray-orchestrator', tool: 'analyze-complexity', key: 'Complexity', args: { tasks: [{ description: 'suit probe', type: 'verification' }] } },
177
+ { server: 'xray-governance', tool: 'get_active_codex', key: 'term_count' },
178
+ { server: 'xray-researcher', tool: 'get_documentation', key: 'Documentation', args: { target: 'RepertoireService' } },
179
+ { server: 'xray-architect-tools', tool: 'context-analysis', key: 'codebaseStructure', args: { query: 'suit probe' } },
180
+ { server: 'xray-code-review', tool: 'check_best_practices', key: 'Compliance', args: { filePath: `${root}/src/mcp/server.ts`, language: 'typescript' } },
181
+ { server: 'Dynamo', tool: 'get_docs', key: 'docs' },
182
+ {
183
+ server: 'repertoire',
184
+ tool: 'get_task_confidence',
185
+ key: 'harness-broken',
186
+ note: 'harness double-prefixes repertoire__ — use Layer 2a stdio instead',
187
+ },
188
+ ];
189
+
190
+ for (const p of harnessProbes) {
191
+ const note = p.note ? ` (${p.note})` : '';
192
+ console.log(` □ ${p.server} → ${p.tool}${note}`);
193
+ }
194
+
195
+ // ── Layer 3 — verdict ────────────────────────────────────────────────────────
196
+ const layer2aOk = layer2a.every((c) => c.ok);
197
+ const layer2cOk = layer2c.every((c) => c.ok);
198
+ console.log(`
199
+ Layer 3 — Suit worn verdict (automated portion)
200
+ Layer 1: ${layer1Ok ? 'GREEN' : 'RED'}
201
+ Layer 2a repertoire stdio: ${layer2aOk ? 'GREEN' : 'RED'}
202
+ Layer 2c researcher trap routing: ${layer2cOk ? 'GREEN' : 'RED'}
203
+
204
+ FULL = Layer 1 + 2a + 2c green + all Layer 2b harness probes respond
205
+ PARTIAL = Layer 1 green + core harness MCPs live (enforcer, skills, orchestrator, governance, Dynamo)
206
+ BROKEN = Layer 1 fails OR core MCPs unreachable
207
+
208
+ Harness note: repertoire tools are registered as repertoire__* — Grok harness prepends
209
+ server name again (repertoire__repertoire__*). Memory routing works via stdio (Layer 2a/2c).
210
+
211
+ Version: npm 0xray@${readInstalledXrayVersion()} from node_modules (no npm link)
212
+ `);
213
+
214
+ if (layer1Ok && layer2aOk && layer2cOk) {
215
+ console.log('✅ Automated checks PASS — agent should confirm Layer 2b harness probes for FULL verdict.');
216
+ process.exit(0);
217
+ }
218
+
219
+ console.error('❌ Automated checks FAILED — suit not ready.');
220
+ process.exit(1);
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Live synthesis checkpoint driver — repertoire core (real .xray/state, not tmp).
4
+ *
5
+ * Usage:
6
+ * node scripts/run-live-synthesis-checkpoint.mjs seed [--session-id=ID]
7
+ * node scripts/run-live-synthesis-checkpoint.mjs status
8
+ * node scripts/run-live-synthesis-checkpoint.mjs complete-todo --id=s.1
9
+ * node scripts/run-live-synthesis-checkpoint.mjs finish
10
+ */
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
12
+ import { dirname, join } from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+
15
+ const __dirname = dirname(fileURLToPath(import.meta.url));
16
+ const root = join(__dirname, '..');
17
+ const xrayRoot = join(root, 'node_modules/0xray');
18
+ const stateDir = join(root, '.xray', 'state');
19
+ const checkpointPath = join(stateDir, 'synthesis-checkpoint.json');
20
+ const planPath = join(stateDir, 'lead-dev-plan.json');
21
+
22
+ const DEFAULT_SESSION = 'live-synthesis-repertoire';
23
+
24
+ const log = (msg) => process.stdout.write(`${msg}\n`);
25
+ const err = (msg) => process.stderr.write(`${msg}\n`);
26
+
27
+ function parseSessionId() {
28
+ const arg = process.argv.find((a) => a.startsWith('--session-id='));
29
+ return arg?.split('=')[1] || process.env.GROK_SESSION_ID || DEFAULT_SESSION;
30
+ }
31
+
32
+ function loadFeatures() {
33
+ return JSON.parse(readFileSync(join(root, '.xray/features.json'), 'utf8'));
34
+ }
35
+
36
+ async function loadXray() {
37
+ const synthesis = await import(join(xrayRoot, 'dist/nucleus/synthesis.js'));
38
+ const persistence = await import(join(xrayRoot, 'dist/nucleus/lead-dev-plan-persistence.js'));
39
+ const kernel = await import(join(xrayRoot, 'dist/nucleus/autonomy-kernel.js'));
40
+ return { synthesis, persistence, kernel };
41
+ }
42
+
43
+ async function cmdSeed() {
44
+ const sessionId = parseSessionId();
45
+ const grokSession = process.env.GROK_SESSION_ID;
46
+ if (grokSession && grokSession !== sessionId) {
47
+ err(
48
+ `❌ GROK_SESSION_ID (${grokSession}) ≠ seed sessionId (${sessionId}) — hooks will skip synthesis due`,
49
+ );
50
+ process.exit(1);
51
+ }
52
+ const features = loadFeatures();
53
+ const threshold = features.synthesis?.every_n_gates ?? 12;
54
+ if (!features.synthesis?.enabled) {
55
+ err('❌ synthesis.enabled is false in .xray/features.json');
56
+ process.exit(1);
57
+ }
58
+
59
+ mkdirSync(stateDir, { recursive: true });
60
+ const { synthesis, kernel, persistence } = await loadXray();
61
+
62
+ // Reset prior checkpoint for clean live run
63
+ if (existsSync(checkpointPath)) {
64
+ const prior = synthesis.loadSynthesisCheckpointState(root);
65
+ if (prior?.synthesisDue) {
66
+ log('ℹ️ Clearing prior due checkpoint for fresh live run');
67
+ }
68
+ }
69
+
70
+ let becameDue = false;
71
+ for (let i = 0; i < threshold; i++) {
72
+ const result = synthesis.recordExecutionSlice('gate', { projectRoot: root, sessionId });
73
+ if (result.becameDue) becameDue = true;
74
+ }
75
+
76
+ const state = synthesis.loadSynthesisCheckpointState(root);
77
+ const due = synthesis.isSynthesisCheckpointDue(root, sessionId);
78
+
79
+ log(`📊 sessionId: ${sessionId}`);
80
+ log(`📊 gate slices recorded: ${threshold}`);
81
+ log(`📊 synthesisDue: ${due}`);
82
+ log(`📊 dueReason: ${state?.dueReason ?? 'null'}`);
83
+ log(`📊 synthesisCount: ${state?.synthesisCount ?? 0}`);
84
+
85
+ if (!due) {
86
+ err('❌ Checkpoint not due after seeding');
87
+ process.exit(1);
88
+ }
89
+
90
+ // Write session boot marker for hooks
91
+ writeFileSync(
92
+ join(stateDir, 'session-boot.json'),
93
+ JSON.stringify(
94
+ {
95
+ hook: 'live-synthesis-seed',
96
+ lead_dev_mode: true,
97
+ sessionId,
98
+ workspaceRoot: root,
99
+ timestamp: new Date().toISOString(),
100
+ },
101
+ null,
102
+ 2,
103
+ ),
104
+ );
105
+
106
+ log('\n✅ Live synthesis checkpoint SEEDED');
107
+ log('Next: CallMcpTool xray-orchestrator analyze-complexity with sessionId');
108
+ log(` sessionId: "${sessionId}"`);
109
+ }
110
+
111
+ async function cmdStatus() {
112
+ const sessionId = parseSessionId();
113
+ const { synthesis, persistence } = await loadXray();
114
+ const state = synthesis.loadSynthesisCheckpointState(root);
115
+ const due = synthesis.isSynthesisCheckpointDue(root, sessionId);
116
+ const plan = persistence.loadPersistedLeadDevPlan(root);
117
+ const consultTodos = plan ? persistence.getSynthesisConsultTodos(plan) : [];
118
+
119
+ log(JSON.stringify(
120
+ {
121
+ sessionId,
122
+ synthesisDue: due,
123
+ dueReason: state?.dueReason ?? null,
124
+ synthesisCount: state?.synthesisCount ?? 0,
125
+ planActive: plan?.active ?? false,
126
+ phaseId: plan?.phases?.[0]?.id ?? null,
127
+ consultTodos: consultTodos.map((t) => ({ id: t.id, subagent: t.subagent, status: t.status })),
128
+ },
129
+ null,
130
+ 2,
131
+ ));
132
+ }
133
+
134
+ async function cmdCompleteTodo() {
135
+ const todoId = process.argv.find((a) => a.startsWith('--id='))?.split('=')[1];
136
+ const verdict = process.argv.find((a) => a.startsWith('--verdict='))?.split('=')[1];
137
+ if (!todoId) {
138
+ err('Usage: complete-todo --id=s.1 --verdict=PASS|CONDITIONAL|FAIL');
139
+ process.exit(1);
140
+ }
141
+ if (!verdict || !['PASS', 'CONDITIONAL', 'FAIL'].includes(verdict)) {
142
+ err('❌ --verdict=PASS|CONDITIONAL|FAIL required (consult receipt gate)');
143
+ process.exit(1);
144
+ }
145
+
146
+ const sessionId = parseSessionId();
147
+ const { persistence } = await loadXray();
148
+ const { writeSynthesisConsultReceipt } = await import(
149
+ join(xrayRoot, 'dist/nucleus/synthesis-consult-receipt.js'),
150
+ );
151
+
152
+ const plan = persistence.loadPersistedLeadDevPlan(root);
153
+ const consultTodo = plan
154
+ ? persistence.getSynthesisConsultTodos(plan).find((t) => t.id === todoId)
155
+ : null;
156
+ if (!consultTodo) {
157
+ err(`❌ Consult todo ${todoId} not found in lead-dev plan`);
158
+ process.exit(1);
159
+ }
160
+
161
+ writeSynthesisConsultReceipt(
162
+ todoId,
163
+ {
164
+ sessionId: plan?.sessionId ?? sessionId,
165
+ subagent: consultTodo.subagent,
166
+ verdict,
167
+ topRisks: [],
168
+ hardeningNote: process.argv.find((a) => a.startsWith('--note='))?.split('=')[1] ?? '',
169
+ },
170
+ root,
171
+ );
172
+
173
+ const updated = persistence.updatePlanTodoStatus(todoId, 'completed', root);
174
+ if (!updated) {
175
+ err(`❌ Receipt gate blocked completion for ${todoId}`);
176
+ process.exit(1);
177
+ }
178
+
179
+ const refreshed = persistence.loadPersistedLeadDevPlan(root);
180
+ const todos = refreshed ? persistence.getSynthesisConsultTodos(refreshed) : [];
181
+ const allDone = todos.length > 0 && todos.every((t) => t.status === 'completed');
182
+ log(`✅ Marked ${todoId} completed (receipt: ${verdict})`);
183
+ log(`📊 consult todos: ${todos.map((t) => `${t.id}:${t.status}`).join(', ')}`);
184
+ if (allDone) log('🎉 All consult todos complete — checkpoint should clear on next gate eval');
185
+ }
186
+
187
+ async function cmdFinish() {
188
+ const sessionId = parseSessionId();
189
+ const { synthesis } = await loadXray();
190
+ const due = synthesis.isSynthesisCheckpointDue(root, sessionId);
191
+ const state = synthesis.loadSynthesisCheckpointState(root);
192
+ if (due) {
193
+ err('❌ Checkpoint still due — complete all consult todos first');
194
+ await cmdStatus();
195
+ process.exit(1);
196
+ }
197
+ log('✅ Live synthesis checkpoint CLEARED');
198
+ log(`📊 synthesisCount: ${state?.synthesisCount ?? 0}`);
199
+ log(`📊 lastSynthesisAt: ${state?.lastSynthesisAt ?? 'null'}`);
200
+ }
201
+
202
+ const cmd = process.argv[2] || 'seed';
203
+ const handlers = {
204
+ seed: cmdSeed,
205
+ status: cmdStatus,
206
+ 'complete-todo': cmdCompleteTodo,
207
+ finish: cmdFinish,
208
+ };
209
+
210
+ const handler = handlers[cmd];
211
+ if (!handler) {
212
+ err(`Unknown command: ${cmd}`);
213
+ process.exit(1);
214
+ }
215
+ await handler();
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Consumer-side helpers for suit verification — constants from 0xray bridge-mcp-wiring (SSOT).
4
+ */
5
+ import { createRequire } from 'node:module';
6
+ import { execSync, spawn } from 'node:child_process';
7
+ import { existsSync, readFileSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
+
10
+ const packageRoot = resolve(import.meta.dirname, '..');
11
+
12
+ /** Consumer project root (hoisted 0xray lives here, not under @0xray/repertoire). */
13
+ export function resolveConsumerRoot() {
14
+ if (process.env.SUIT_VERIFY_ROOT) return resolve(process.env.SUIT_VERIFY_ROOT);
15
+ if (existsSync(join(process.cwd(), '.xray', 'features.json'))) return resolve(process.cwd());
16
+ return packageRoot;
17
+ }
18
+
19
+ function xrayPathCandidates(...segments) {
20
+ const consumerRoot = resolveConsumerRoot();
21
+ const roots =
22
+ consumerRoot === packageRoot ? [packageRoot] : [consumerRoot, packageRoot];
23
+ const candidates = roots.map((r) => join(r, 'node_modules/0xray', ...segments));
24
+ candidates.push(resolve(packageRoot, '../xray', ...segments));
25
+ return candidates;
26
+ }
27
+
28
+ function resolveXrayBridgeModule() {
29
+ const found = xrayPathCandidates('scripts/node/bridge-mcp-wiring.cjs').find((p) =>
30
+ existsSync(p),
31
+ );
32
+ if (!found) {
33
+ throw new Error('0xray bridge-mcp-wiring.cjs missing — run npm install');
34
+ }
35
+ return createRequire(import.meta.url)(found);
36
+ }
37
+
38
+ const wiring = resolveXrayBridgeModule();
39
+
40
+ export const {
41
+ XRAY_MCP_SERVERS,
42
+ HERMES_CONFIG_PATH,
43
+ HERMES_PLUGIN_DIR,
44
+ OPENCLAW_CONFIG_PATH,
45
+ OPENCLAW_STATE_DIR,
46
+ } = wiring;
47
+
48
+ /** Repertoire consumer MCP surface (local dist when developing this repo). */
49
+ export const REPERTOIRE_MCP = {
50
+ name: 'repertoire',
51
+ npxArgs: ['-y', '@0xray/repertoire', 'mcp'],
52
+ localArgs: ['node', 'dist/mcp/server.js'],
53
+ };
54
+
55
+ export function resolveXrayScript(filename) {
56
+ return xrayPathCandidates('scripts/node', filename).find((p) => existsSync(p)) ?? null;
57
+ }
58
+
59
+ export function readInstalledXrayVersion() {
60
+ const pkgPath = xrayPathCandidates('package.json').find((p) => existsSync(p));
61
+ if (!pkgPath) return 'unknown';
62
+ try {
63
+ const pkg = createRequire(import.meta.url)(pkgPath);
64
+ return pkg.version ?? 'unknown';
65
+ } catch {
66
+ return 'unknown';
67
+ }
68
+ }
69
+
70
+ /** Re-run native install when xray-consumer-root.txt points at wrong cwd (e.g. npx cache). */
71
+ export function ensureConsumerRootMarker(markerPath, installCmd) {
72
+ const consumerRoot = resolveConsumerRoot();
73
+ let marked = '';
74
+ if (existsSync(markerPath)) {
75
+ marked = readFileSync(markerPath, 'utf8').trim();
76
+ if (marked === consumerRoot) return consumerRoot;
77
+ }
78
+ process.stdout.write(
79
+ `⚠ consumer root ${marked ? `drift (${marked})` : 'missing'} — running ${installCmd}\n`,
80
+ );
81
+ execSync(installCmd, { cwd: consumerRoot, stdio: 'inherit' });
82
+ return consumerRoot;
83
+ }
84
+
85
+ export function mcpStdioInitializeProbe({ cwd, command, args, env = {}, timeoutMs = 6000 }) {
86
+ return new Promise((resolveProbe, rejectProbe) => {
87
+ const init = JSON.stringify({
88
+ jsonrpc: '2.0',
89
+ id: 1,
90
+ method: 'initialize',
91
+ params: {
92
+ protocolVersion: '2024-11-05',
93
+ capabilities: {},
94
+ clientInfo: { name: 'suit-bridge-probe', version: '1.0' },
95
+ },
96
+ });
97
+
98
+ const proc = spawn(command, args, {
99
+ cwd,
100
+ env: { ...process.env, ...env },
101
+ stdio: ['pipe', 'pipe', 'pipe'],
102
+ });
103
+ let out = '';
104
+ const timer = setTimeout(() => {
105
+ proc.kill();
106
+ rejectProbe(new Error(`timeout after ${timeoutMs}ms`));
107
+ }, timeoutMs);
108
+
109
+ const finish = (ok) => {
110
+ if (finished) return;
111
+ finished = true;
112
+ clearTimeout(timer);
113
+ try {
114
+ proc.kill('SIGTERM');
115
+ } catch {
116
+ /* already exited */
117
+ }
118
+ if (ok) resolveProbe(out);
119
+ else rejectProbe(new Error(out.slice(0, 200) || 'no serverInfo in MCP response'));
120
+ };
121
+
122
+ let finished = false;
123
+
124
+ const onData = (chunk) => {
125
+ out += chunk.toString();
126
+ if (out.includes('serverInfo')) finish(true);
127
+ };
128
+
129
+ proc.stdout.on('data', onData);
130
+ proc.stderr.on('data', onData);
131
+
132
+ proc.on('close', () => {
133
+ if (!finished) finish(out.includes('serverInfo'));
134
+ });
135
+
136
+ proc.stdin.write(`${init}\n`);
137
+ proc.stdin.end();
138
+ });
139
+ }