0xray 3.5.4 → 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.
- package/.mcp.json +51 -7
- package/.opencode/skills/api-design/SKILL.md +1 -1
- package/.opencode/skills/architect-tools/SKILL.md +1 -1
- package/.opencode/skills/architecture-patterns/SKILL.md +1 -1
- package/.opencode/skills/auto-format/SKILL.md +1 -1
- package/.opencode/skills/boot-orchestrator/SKILL.md +2 -6
- package/.opencode/skills/bug-triage/SKILL.md +1 -1
- package/.opencode/skills/code-analyzer/SKILL.md +1 -1
- package/.opencode/skills/code-review/SKILL.md +1 -1
- package/.opencode/skills/enforcer/SKILL.md +1 -1
- package/.opencode/skills/framework-compliance-audit/SKILL.md +1 -1
- package/.opencode/skills/git-workflow/SKILL.md +1 -1
- package/.opencode/skills/hermes-agent/SKILL.md +36 -36
- package/.opencode/skills/inference-improve/SKILL.md +1 -1
- package/.opencode/skills/lint/SKILL.md +1 -1
- package/.opencode/skills/log-monitor/SKILL.md +1 -1
- package/.opencode/skills/model-health-check/SKILL.md +1 -1
- package/.opencode/skills/multimodal-looker/SKILL.md +1 -1
- package/.opencode/skills/orchestrator/SKILL.md +38 -14
- package/.opencode/skills/performance-analysis/SKILL.md +1 -1
- package/.opencode/skills/performance-optimization/SKILL.md +1 -1
- package/.opencode/skills/processor-pipeline/SKILL.md +1 -1
- package/.opencode/skills/project-analysis/SKILL.md +1 -1
- package/.opencode/skills/refactoring-strategies/SKILL.md +1 -1
- package/.opencode/skills/registry.json +65 -0
- package/.opencode/skills/researcher/SKILL.md +18 -5
- package/.opencode/skills/security-audit/SKILL.md +1 -1
- package/.opencode/skills/security-scan/SKILL.md +1 -1
- package/.opencode/skills/session-management/SKILL.md +1 -1
- package/.opencode/skills/state-manager/SKILL.md +1 -1
- package/.opencode/skills/storyteller/SKILL.md +1 -1
- package/.opencode/skills/strategist/SKILL.md +12 -0
- package/.opencode/skills/testing-best-practices/SKILL.md +37 -0
- package/.opencode/skills/testing-strategy/SKILL.md +14 -3
- package/.opencode/skills/ui-ux-design/SKILL.md +1 -1
- package/.opencode/skills/xray-orchestrator/index.ts +267 -0
- package/.xray/codex.json +12 -3
- package/.xray/features.json +32 -6
- package/.xray/features.schema.json +87 -0
- package/AGENTS-consumer.md +16 -6
- package/AGENTS.md +21 -3
- package/README.md +13 -10
- package/SKILLS.md +1 -1
- package/dist/AGENTS.md +21 -3
- package/dist/CHANGELOG.md +98 -0
- package/dist/README.md +13 -10
- package/dist/SKILLS.md +1 -1
- package/dist/cli/commands/hermes-install.js +6 -1
- package/dist/cli/commands/openclaw-install.js +14 -0
- package/dist/cli/index.js +0 -0
- package/dist/core/features-config.d.ts +30 -2
- package/dist/governance/governance-service.d.ts +1 -0
- package/dist/governance/governance-service.js +81 -6
- package/dist/infrastructure/schemas/cloud-schemas.d.ts +1 -1
- package/dist/integrations/enforcement-gate.js +15 -5
- package/dist/integrations/grok/grok-cli.d.ts +3 -0
- package/dist/integrations/grok/grok-cli.js +92 -13
- package/dist/integrations/grok/hooks/grok-hook-utils.js +99 -9
- package/dist/integrations/grok/hooks/post-tool-use.js +68 -25
- package/dist/integrations/grok/hooks/pre-tool-use.js +17 -14
- package/dist/integrations/grok/hooks/session-start.js +114 -4
- package/dist/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
- package/dist/integrations/hermes-agent/__init__.py +11 -1
- package/dist/integrations/hermes-agent/__pycache__/__init__.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/schemas.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/__pycache__/tools.cpython-313.pyc +0 -0
- package/dist/integrations/hermes-agent/bridge.mjs +92 -11
- package/dist/integrations/hooks/confer-hook-runtime.mjs +49 -0
- package/dist/integrations/hooks/delegation-gate-runtime.mjs +32 -3
- package/dist/integrations/hooks/pipeline-hook-runtime.mjs +211 -0
- package/dist/integrations/hooks/plan-hook-runtime.mjs +68 -0
- package/dist/integrations/hooks/station-hook-runtime.cjs +421 -0
- package/dist/integrations/hooks/station-hook-runtime.mjs +24 -0
- package/dist/integrations/hooks/station-memory-ingest.mjs +45 -0
- package/dist/integrations/hooks/station-memory-match.mjs +47 -0
- package/dist/integrations/hooks/user-aside-hook-runtime.mjs +49 -0
- package/dist/integrations/openclaw/client.d.ts +5 -1
- package/dist/integrations/openclaw/client.js +17 -9
- package/dist/integrations/openclaw/config.js +0 -1
- package/dist/integrations/openclaw/hooks/pre-tool-gate-runtime.mjs +102 -0
- package/dist/integrations/openclaw/index.js +17 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +10 -0
- package/dist/integrations/openclaw/pre-tool-gate.d.ts +19 -0
- package/dist/integrations/openclaw/pre-tool-gate.js +39 -0
- package/dist/mcps/architect-tools.server.js +6 -1
- package/dist/mcps/orchestrator/handlers/complexity-handler.d.ts +7 -0
- package/dist/mcps/orchestrator/handlers/complexity-handler.js +107 -8
- package/dist/mcps/orchestrator/handlers/task-handler.d.ts +6 -0
- package/dist/mcps/orchestrator/handlers/task-handler.js +75 -0
- package/dist/mcps/orchestrator/server.js +54 -5
- package/dist/memory-routing/index.d.ts +1 -1
- package/dist/memory-routing/index.js +1 -1
- package/dist/memory-routing/provider-loader.d.ts +4 -0
- package/dist/memory-routing/provider-loader.js +74 -4
- package/dist/memory-routing/provider-registry.js +3 -2
- package/dist/nucleus/aside-worktree.d.ts +41 -0
- package/dist/nucleus/aside-worktree.js +164 -0
- package/dist/nucleus/autonomy-kernel.d.ts +2 -2
- package/dist/nucleus/autonomy-kernel.js +17 -6
- package/dist/nucleus/confer.d.ts +57 -0
- package/dist/nucleus/confer.js +322 -0
- package/dist/nucleus/delegation-gate.d.ts +18 -8
- package/dist/nucleus/delegation-gate.js +234 -20
- package/dist/nucleus/lead-dev-plan-persistence.d.ts +27 -3
- package/dist/nucleus/lead-dev-plan-persistence.js +201 -19
- package/dist/nucleus/spawn-plan-resolution.d.ts +20 -0
- package/dist/nucleus/spawn-plan-resolution.js +42 -0
- package/dist/nucleus/suit-temperament.d.ts +40 -0
- package/dist/nucleus/suit-temperament.js +157 -0
- package/dist/nucleus/synthesis-consult-receipt.js +18 -2
- package/dist/nucleus/synthesis-context.js +1 -1
- package/dist/nucleus/user-aside.d.ts +70 -0
- package/dist/nucleus/user-aside.js +393 -0
- package/dist/plugin/xray-codex-injection.js +14 -3
- package/dist/postprocessor/PostProcessor.d.ts +1 -0
- package/dist/postprocessor/PostProcessor.js +11 -0
- package/dist/postprocessor/triggers/GitHookTrigger.js +11 -5
- package/dist/processors/implementations/session-summary-processor.d.ts +1 -1
- package/dist/processors/implementations/session-summary-processor.js +9 -6
- package/opencode.json +88 -0
- package/package.json +25 -6
- package/scripts/hooks/install-hooks.cjs +21 -6
- package/scripts/hooks/run-hook.js +237 -88
- package/scripts/mjs/run-repertoire-mcp.mjs +39 -0
- package/scripts/mjs/verify-confer-core.mjs +103 -0
- package/scripts/mjs/verify-delegation-gate-core.mjs +76 -3
- package/scripts/mjs/verify-four-floor-compact.mjs +524 -0
- package/scripts/mjs/verify-hermes-session-start.mjs +137 -0
- package/scripts/mjs/verify-pipeline-facets.mjs +215 -0
- package/scripts/mjs/verify-pre-push-diff-core.mjs +87 -0
- package/scripts/mjs/verify-temperament-live.mjs +261 -0
- package/scripts/mjs/verify-user-aside-core.mjs +137 -0
- package/scripts/node/bridge-mcp-wiring.cjs +287 -29
- package/scripts/node/install-bridges.cjs +198 -44
- package/scripts/node/load-reflection-config.mjs +2 -2
- package/scripts/node/postinstall.cjs +50 -27
- package/scripts/node/release-gate.mjs +8 -4
- package/scripts/node/release.mjs +2 -2
- package/scripts/node/validate-release-docs.mjs +20 -33
- package/scripts/node/version-manager.mjs +25 -10
- package/src/integrations/grok/plugin/0xray/hooks/hooks.json +31 -24
- package/src/integrations/openclaw/README.md +134 -0
- package/src/integrations/openclaw/plugin/xray-pre-tool/index.js +75 -0
- package/src/integrations/openclaw/plugin/xray-pre-tool/openclaw.plugin.json +10 -0
- package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +10 -0
- package/src/mcps/architect-tools.server.ts +6 -1
- package/src/mcps/orchestrator/handlers/complexity-handler.ts +180 -21
- package/src/mcps/orchestrator/handlers/task-handler.ts +99 -0
- package/src/mcps/orchestrator/server.ts +56 -5
- package/vendor/@0xray/repertoire/AGENTS.md +163 -0
- package/vendor/@0xray/repertoire/LICENSE +21 -0
- package/vendor/@0xray/repertoire/README.md +120 -0
- package/vendor/@0xray/repertoire/data/curated_signals.json +208 -0
- package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts +78 -0
- package/vendor/@0xray/repertoire/dist/RepertoireService.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/RepertoireService.js +153 -0
- package/vendor/@0xray/repertoire/dist/RepertoireService.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts +39 -0
- package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js +60 -0
- package/vendor/@0xray/repertoire/dist/governance/ontological-trap-enforcer.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/index.d.ts +14 -0
- package/vendor/@0xray/repertoire/dist/index.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/index.js +14 -0
- package/vendor/@0xray/repertoire/dist/index.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts +26 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js +109 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-ingester.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts +18 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js +94 -0
- package/vendor/@0xray/repertoire/dist/ingestion/groover-log-parser.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts +7 -0
- package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js +18 -0
- package/vendor/@0xray/repertoire/dist/ingestion/orchestrator-feedback-ingester.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts +31 -0
- package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js +83 -0
- package/vendor/@0xray/repertoire/dist/ingestion/xray-session-ingester.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/mcp/server.d.ts +6 -0
- package/vendor/@0xray/repertoire/dist/mcp/server.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/mcp/server.js +173 -0
- package/vendor/@0xray/repertoire/dist/mcp/server.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts +27 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js +107 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/RepertoireOrchestratorBridge.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts +11 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js +32 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/capability-enhancer.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts +9 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js +72 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/confidence-gate.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts +5 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js +18 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-agent-affinity.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts +31 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js +218 -0
- package/vendor/@0xray/repertoire/dist/orchestrator-bridge/signal-injector.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/paths.d.ts +24 -0
- package/vendor/@0xray/repertoire/dist/paths.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/paths.js +74 -0
- package/vendor/@0xray/repertoire/dist/paths.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts +141 -0
- package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js +210 -0
- package/vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts +48 -0
- package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js +221 -0
- package/vendor/@0xray/repertoire/dist/registry/CuratedSignalsManager.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts +11 -0
- package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js +43 -0
- package/vendor/@0xray/repertoire/dist/registry/InferenceStateManager.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts +15 -0
- package/vendor/@0xray/repertoire/dist/registry/signal-prune.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/registry/signal-prune.js +35 -0
- package/vendor/@0xray/repertoire/dist/registry/signal-prune.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts +3 -0
- package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js +24 -0
- package/vendor/@0xray/repertoire/dist/synthesis/concrete-sections.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts +24 -0
- package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js +148 -0
- package/vendor/@0xray/repertoire/dist/synthesis/meta-inference-engine.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts +4 -0
- package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js +44 -0
- package/vendor/@0xray/repertoire/dist/synthesis/primitive-confidence-aggregator.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts +22 -0
- package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js +66 -0
- package/vendor/@0xray/repertoire/dist/synthesis/synthesis-prompt-builder.js.map +1 -0
- package/vendor/@0xray/repertoire/dist/types.d.ts +210 -0
- package/vendor/@0xray/repertoire/dist/types.d.ts.map +1 -0
- package/vendor/@0xray/repertoire/dist/types.js +2 -0
- package/vendor/@0xray/repertoire/dist/types.js.map +1 -0
- package/vendor/@0xray/repertoire/docs/MEMORY-ROUTING-PROVIDER.md +54 -0
- package/vendor/@0xray/repertoire/hermes-mcp.example.json +20 -0
- package/vendor/@0xray/repertoire/mcp-config.example.json +11 -0
- package/vendor/@0xray/repertoire/package.json +124 -0
- package/vendor/@0xray/repertoire/schemas/curated-signal.schema.json +68 -0
- package/vendor/@0xray/repertoire/schemas/inference-log.schema.json +82 -0
- package/vendor/@0xray/repertoire/scripts/confirm-suit-all.mjs +253 -0
- package/vendor/@0xray/repertoire/scripts/confirm-suit-harness.mjs +220 -0
- package/vendor/@0xray/repertoire/scripts/run-live-synthesis-checkpoint.mjs +215 -0
- package/vendor/@0xray/repertoire/scripts/suit-bridge-shared.mjs +139 -0
- package/vendor/@0xray/repertoire/scripts/verify-grok-suit.mjs +304 -0
- package/vendor/@0xray/repertoire/scripts/verify-hermes-suit.mjs +163 -0
- package/vendor/@0xray/repertoire/scripts/verify-openclaw-suit.mjs +125 -0
- package/vendor/@0xray/repertoire/scripts/verify-opencode-suit.mjs +127 -0
- package/vendor/@0xray/repertoire/scripts/verify-synthesis-dogfood.mjs +207 -0
- package/vendor/@0xray/repertoire/skills/repertoire-trap-handling/SKILL.md +206 -0
- package/xray/codex.json +12 -3
- package/xray/features.json +32 -6
- package/xray/features.schema.json +87 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Four-floor compact survival — validatable scenario.
|
|
4
|
+
*
|
|
5
|
+
* Not TUI /compact on a human session. Drives each floor's real wear binary
|
|
6
|
+
* the way a window-death actually hits the suit:
|
|
7
|
+
* Grok PreCompact + PostCompact → session-start.js
|
|
8
|
+
* Hermes session-start (bridge) twice — new session after the window dies
|
|
9
|
+
* OpenCode plugin boot (writeSuitSessionBoot) then inject-read of STATION.md
|
|
10
|
+
* OpenClaw PreToolUse heat (evaluatePreToolGate) then same-session compact rewrite
|
|
11
|
+
*
|
|
12
|
+
* Pass = intent + git + host + "Do not cold-start" still on the card after the cut.
|
|
13
|
+
*/
|
|
14
|
+
import { execSync, spawnSync } from 'node:child_process';
|
|
15
|
+
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import { homedir, tmpdir } from 'node:os';
|
|
17
|
+
import { dirname, join } from 'node:path';
|
|
18
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
19
|
+
|
|
20
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '../..');
|
|
21
|
+
const grokSession = join(packageRoot, 'dist/integrations/grok/hooks/session-start.js');
|
|
22
|
+
const grokPreTool = join(packageRoot, 'dist/integrations/grok/hooks/pre-tool-use.js');
|
|
23
|
+
const hermesBridge = join(packageRoot, 'dist/integrations/hermes-agent/bridge.mjs');
|
|
24
|
+
const suitJs = join(packageRoot, 'dist/nucleus/suit-temperament.js');
|
|
25
|
+
const gateJs = join(packageRoot, 'dist/nucleus/delegation-gate.js');
|
|
26
|
+
|
|
27
|
+
let failed = 0;
|
|
28
|
+
function pass(n) {
|
|
29
|
+
process.stdout.write(`PASS ${n}\n`);
|
|
30
|
+
}
|
|
31
|
+
function fail(n, d = '') {
|
|
32
|
+
failed++;
|
|
33
|
+
process.stderr.write(`FAIL ${n}${d ? ` — ${d}` : ''}\n`);
|
|
34
|
+
}
|
|
35
|
+
function skip(n) {
|
|
36
|
+
process.stdout.write(`SKIP ${n}\n`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function gitInit(root) {
|
|
40
|
+
execSync('git init', { cwd: root, stdio: 'ignore' });
|
|
41
|
+
execSync('git config user.email "compact@test"', { cwd: root, stdio: 'ignore' });
|
|
42
|
+
execSync('git config user.name "compact"', { cwd: root, stdio: 'ignore' });
|
|
43
|
+
writeFileSync(join(root, 'README.md'), 'four-floor-compact\n');
|
|
44
|
+
execSync('git add README.md', { cwd: root, stdio: 'ignore' });
|
|
45
|
+
execSync('git commit -m "init compact scenario"', { cwd: root, stdio: 'ignore' });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function seedFloor(root) {
|
|
49
|
+
mkdirSync(join(root, '.xray', 'state'), { recursive: true });
|
|
50
|
+
writeFileSync(
|
|
51
|
+
join(root, '.xray', 'features.json'),
|
|
52
|
+
JSON.stringify({
|
|
53
|
+
version: '4.0.0',
|
|
54
|
+
suit_temperament: { profile: 'auto' },
|
|
55
|
+
multi_agent_orchestration: {
|
|
56
|
+
enabled: true,
|
|
57
|
+
lead_dev_mode: true,
|
|
58
|
+
auto_chain_delegations: true,
|
|
59
|
+
no_new_surface: true,
|
|
60
|
+
},
|
|
61
|
+
memory_routing: {
|
|
62
|
+
enabled: true,
|
|
63
|
+
provider: 'repertoire',
|
|
64
|
+
module_path: join(packageRoot, 'vendor/@0xray/repertoire/dist/provider/memory-routing-provider.js'),
|
|
65
|
+
config: {
|
|
66
|
+
signalsPath: join(packageRoot, 'vendor/@0xray/repertoire/data/curated_signals.json'),
|
|
67
|
+
statePath: '.xray/state/repertoire/inference-state.json',
|
|
68
|
+
feedbackDir: '.xray/state/repertoire/feedback',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
gitInit(root);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function readCard(root) {
|
|
77
|
+
const p = join(root, '.xray', 'state', 'STATION.md');
|
|
78
|
+
if (!existsSync(p)) return '';
|
|
79
|
+
return readFileSync(p, 'utf8');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function readBoot(root) {
|
|
83
|
+
return JSON.parse(readFileSync(join(root, '.xray', 'state', 'session-boot.json'), 'utf8'));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function workingPath(root) {
|
|
87
|
+
return join(root, '.xray', 'state', 'repertoire-working.json');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function readWorking(root) {
|
|
91
|
+
const p = workingPath(root);
|
|
92
|
+
if (!existsSync(p)) return null;
|
|
93
|
+
return JSON.parse(readFileSync(p, 'utf8'));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function assertSurvived(root, { host, intent, profile, hotSwap }) {
|
|
97
|
+
const card = readCard(root);
|
|
98
|
+
const boot = readBoot(root);
|
|
99
|
+
const working = readWorking(root);
|
|
100
|
+
if (!card.includes('Do not cold-start')) fail(`${host} card missing Do not cold-start`);
|
|
101
|
+
else pass(`${host} card still says Do not cold-start`);
|
|
102
|
+
if (!card.includes(`Intent: ${intent}`)) {
|
|
103
|
+
fail(`${host} intent lost`, card.split('\n').find((l) => l.startsWith('Intent:')) || 'no Intent line');
|
|
104
|
+
} else pass(`${host} intent survived: ${intent}`);
|
|
105
|
+
if (!card.includes(`Host: ${host} (${profile})`)) {
|
|
106
|
+
fail(`${host} host/profile`, card.split('\n').find((l) => l.startsWith('Host:')) || '');
|
|
107
|
+
} else pass(`${host} still ${profile}`);
|
|
108
|
+
if (!card.includes('Git:')) fail(`${host} git line missing`);
|
|
109
|
+
else pass(`${host} git line present`);
|
|
110
|
+
if (boot.host !== host) fail(`${host} boot.host`, String(boot.host));
|
|
111
|
+
if (hotSwap) {
|
|
112
|
+
const line = `Hot-swap: ${hotSwap.from} → ${hotSwap.to}`;
|
|
113
|
+
if (!card.includes(line)) fail(`${host} hot-swap lost`, line);
|
|
114
|
+
else pass(`${host} kept ${line}`);
|
|
115
|
+
}
|
|
116
|
+
if (!card.includes('Repertoire: on')) fail(`${host} Repertoire off after compact`, card);
|
|
117
|
+
else pass(`${host} Repertoire still on`);
|
|
118
|
+
if (!card.includes('Working:')) fail(`${host} Working line missing`);
|
|
119
|
+
else pass(`${host} Working line present`);
|
|
120
|
+
if (!working || working.memoryRouting !== 'on') fail(`${host} repertoire-working.json memoryRouting`, JSON.stringify(working));
|
|
121
|
+
else pass(`${host} working json memoryRouting=on`);
|
|
122
|
+
const signals = Array.isArray(working?.matchedSignals) ? working.matchedSignals : [];
|
|
123
|
+
if (!signals.length) fail(`${host} no matchedSignals after compact`);
|
|
124
|
+
else pass(`${host} memory signals survived: ${signals.join(', ')}`);
|
|
125
|
+
if (working.intent !== intent) fail(`${host} working.intent`, String(working.intent));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const MEMORY_TAIL =
|
|
129
|
+
'attestation-as-map consumer-boundary revalidation at every trust-transfer boundary';
|
|
130
|
+
|
|
131
|
+
function memoryIntent(host) {
|
|
132
|
+
return `FLOOR-COMPACT-SURVIVE-${host} ${MEMORY_TAIL}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const TYPE_UNSAFE = ['an', 'y'].join('');
|
|
136
|
+
const UNSAFE_TS = `const x: ${TYPE_UNSAFE} = 1`;
|
|
137
|
+
|
|
138
|
+
function runGrokSession(root, hookEvent, extra = {}) {
|
|
139
|
+
const payload = JSON.stringify({
|
|
140
|
+
hookEventName: hookEvent,
|
|
141
|
+
sessionId: extra.sessionId || 'floor-compact-grok',
|
|
142
|
+
workspaceRoot: root,
|
|
143
|
+
cwd: root,
|
|
144
|
+
...(extra.intent ? { prompt: extra.intent } : {}),
|
|
145
|
+
...(extra.compactContext ? { compactContext: extra.compactContext } : {}),
|
|
146
|
+
});
|
|
147
|
+
execSync(`printf '%s' '${payload.replace(/'/g, "'\\''")}' | node "${grokSession}"`, {
|
|
148
|
+
encoding: 'utf8',
|
|
149
|
+
env: {
|
|
150
|
+
...process.env,
|
|
151
|
+
GROK_WORKSPACE_ROOT: root,
|
|
152
|
+
GROK_HOOK_EVENT: hookEvent,
|
|
153
|
+
GROK_SESSION_ID: extra.sessionId || 'floor-compact-grok',
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function runHermesSession(root, sessionId) {
|
|
159
|
+
const json = JSON.stringify({
|
|
160
|
+
command: 'session-start',
|
|
161
|
+
sessionId,
|
|
162
|
+
}).replace(/'/g, "'\\''");
|
|
163
|
+
execSync(`node "${hermesBridge}" session-start --cwd "${root}" '${json}'`, {
|
|
164
|
+
cwd: root,
|
|
165
|
+
encoding: 'utf8',
|
|
166
|
+
env: { ...process.env, XRAY_ROOT: root },
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
process.stdout.write('four-floor compact survival\n\n');
|
|
171
|
+
|
|
172
|
+
function runGrokPreTool(root, fixture) {
|
|
173
|
+
const payload = JSON.stringify(fixture);
|
|
174
|
+
const out = execSync(`printf '%s' '${payload.replace(/'/g, "'\\''")}' | node "${grokPreTool}"`, {
|
|
175
|
+
encoding: 'utf8',
|
|
176
|
+
env: { ...process.env, GROK_WORKSPACE_ROOT: root, GROK_SESSION_ID: 'floor-compact-grok' },
|
|
177
|
+
});
|
|
178
|
+
return JSON.parse(out.trim().split('\n').filter(Boolean).at(-1));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function constitutionBundle(root, host) {
|
|
182
|
+
const feat = loadDelegationGateFeatures(root, host);
|
|
183
|
+
const surfacePath = 'src/mcps/floor-new.server.ts';
|
|
184
|
+
const evalPayload = { path: surfacePath, new_string: 'export {}\n' };
|
|
185
|
+
if (host === 'grok') {
|
|
186
|
+
return {
|
|
187
|
+
spawn: runGrokPreTool(root, {
|
|
188
|
+
toolName: 'spawn_subagent',
|
|
189
|
+
workspaceRoot: root,
|
|
190
|
+
sessionId: 'compact-grok-1',
|
|
191
|
+
toolInput: { prompt: 'explore repo', subagent_type: 'explore' },
|
|
192
|
+
}),
|
|
193
|
+
eleven: runGrokPreTool(root, {
|
|
194
|
+
toolName: 'search_replace',
|
|
195
|
+
workspaceRoot: root,
|
|
196
|
+
sessionId: 'compact-grok-1',
|
|
197
|
+
toolInput: { path: 'src/foo.ts', new_string: UNSAFE_TS },
|
|
198
|
+
}),
|
|
199
|
+
surface: runGrokPreTool(root, {
|
|
200
|
+
toolName: 'search_replace',
|
|
201
|
+
workspaceRoot: root,
|
|
202
|
+
sessionId: 'compact-grok-1',
|
|
203
|
+
toolInput: evalPayload,
|
|
204
|
+
}),
|
|
205
|
+
destructive: runGrokPreTool(root, {
|
|
206
|
+
toolName: 'bash',
|
|
207
|
+
workspaceRoot: root,
|
|
208
|
+
sessionId: 'compact-grok-1',
|
|
209
|
+
toolInput: { command: 'rm -rf /' },
|
|
210
|
+
}),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
if (host === 'hermes') {
|
|
214
|
+
return {
|
|
215
|
+
spawn: runHermesGate(root, {
|
|
216
|
+
tool: 'delegate_task',
|
|
217
|
+
args: { prompt: 'explore repo', subagent_type: 'explore' },
|
|
218
|
+
}),
|
|
219
|
+
eleven: runHermesGate(root, {
|
|
220
|
+
tool: 'write_file',
|
|
221
|
+
args: { path: 'src/foo.ts', content: UNSAFE_TS },
|
|
222
|
+
}),
|
|
223
|
+
surface: runHermesGate(root, {
|
|
224
|
+
tool: 'write_file',
|
|
225
|
+
args: { path: surfacePath, content: 'export {}\n' },
|
|
226
|
+
}),
|
|
227
|
+
destructive: runHermesGate(root, {
|
|
228
|
+
tool: 'bash',
|
|
229
|
+
args: { command: 'rm -rf /' },
|
|
230
|
+
}),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
const sessionId = host === 'opencode' ? 'compact-oc-1' : 'compact-claw-1';
|
|
234
|
+
const writeTool = host === 'opencode' ? 'write' : 'write';
|
|
235
|
+
return {
|
|
236
|
+
spawn: evaluatePreToolGate(
|
|
237
|
+
'Task',
|
|
238
|
+
{ prompt: 'explore repo', subagent_type: 'explore' },
|
|
239
|
+
{ projectRoot: root, sessionId, features: feat, host },
|
|
240
|
+
),
|
|
241
|
+
eleven: evaluatePreToolGate(
|
|
242
|
+
writeTool,
|
|
243
|
+
{ path: 'src/foo.ts', content: UNSAFE_TS },
|
|
244
|
+
{ projectRoot: root, sessionId, features: feat, host },
|
|
245
|
+
),
|
|
246
|
+
surface: evaluatePreToolGate(
|
|
247
|
+
writeTool,
|
|
248
|
+
{ path: surfacePath, content: 'export {}\n' },
|
|
249
|
+
{ projectRoot: root, sessionId, features: feat, host },
|
|
250
|
+
),
|
|
251
|
+
destructive: evaluatePreToolGate(
|
|
252
|
+
'bash',
|
|
253
|
+
{ command: 'rm -rf /' },
|
|
254
|
+
{ projectRoot: root, sessionId, features: feat, host },
|
|
255
|
+
),
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function liveQuotedCard(text, intent) {
|
|
260
|
+
return (
|
|
261
|
+
text.includes('Do not cold-start') ||
|
|
262
|
+
text.includes(`Intent: ${intent}`) ||
|
|
263
|
+
text.includes(intent.slice(0, 28)) ||
|
|
264
|
+
/Host:\s+\w+\s+\((frontier|guided|strict)\)/.test(text)
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function liveAuthBlocked(text) {
|
|
269
|
+
return /403|bad-credentials|unauthenticated|401|spend.?limit|insufficient/i.test(text);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function tryLiveSuccessor(root, host, intent) {
|
|
273
|
+
if (process.env.XRAY_LIVE_SUCCESSOR !== '1') return;
|
|
274
|
+
const relQuote =
|
|
275
|
+
'Read .xray/state/STATION.md. Reply with only the Host line and the Intent line. Do not edit files.';
|
|
276
|
+
const absQuote = `Read ${join(root, '.xray', 'state', 'STATION.md')}. Reply with only the Host line and the Intent line. Do not edit files.`;
|
|
277
|
+
const cmds = {
|
|
278
|
+
grok: ['grok', '-p', relQuote, '--cwd', root, '--always-approve', '--disable-web-search'],
|
|
279
|
+
opencode: ['opencode', 'run', '--dir', root, relQuote],
|
|
280
|
+
hermes: [
|
|
281
|
+
'hermes',
|
|
282
|
+
'-z',
|
|
283
|
+
relQuote,
|
|
284
|
+
'--cli',
|
|
285
|
+
'--provider',
|
|
286
|
+
'xai-oauth',
|
|
287
|
+
'-m',
|
|
288
|
+
'grok-4.5',
|
|
289
|
+
'--yolo',
|
|
290
|
+
'--no-restore-cwd',
|
|
291
|
+
],
|
|
292
|
+
openclaw: [
|
|
293
|
+
'openclaw',
|
|
294
|
+
'agent',
|
|
295
|
+
'--thinking',
|
|
296
|
+
'low',
|
|
297
|
+
'--timeout',
|
|
298
|
+
'90',
|
|
299
|
+
'--model',
|
|
300
|
+
'xai/grok-4.5',
|
|
301
|
+
'--message',
|
|
302
|
+
absQuote,
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
const argv = cmds[host];
|
|
306
|
+
if (!argv) return;
|
|
307
|
+
const which = spawnSync('which', [argv[0]], { encoding: 'utf8' });
|
|
308
|
+
if (which.status !== 0) {
|
|
309
|
+
skip(`${host} live successor (CLI not on PATH)`);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const node24 = join(homedir(), '.local/node24/current/bin');
|
|
313
|
+
const env = {
|
|
314
|
+
...process.env,
|
|
315
|
+
GROK_WORKSPACE_ROOT: root,
|
|
316
|
+
XRAY_ROOT: root,
|
|
317
|
+
PATH: existsSync(join(node24, 'node')) ? `${node24}:${process.env.PATH || ''}` : process.env.PATH,
|
|
318
|
+
};
|
|
319
|
+
const timeoutMs = host === 'openclaw' ? 110000 : 80000;
|
|
320
|
+
const result = spawnSync(argv[0], argv.slice(1), {
|
|
321
|
+
cwd: root,
|
|
322
|
+
encoding: 'utf8',
|
|
323
|
+
timeout: timeoutMs,
|
|
324
|
+
env,
|
|
325
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
326
|
+
});
|
|
327
|
+
const text = `${result.stdout || ''}\n${result.stderr || ''}`;
|
|
328
|
+
const err = result.error ? String(result.error.message || result.error) : '';
|
|
329
|
+
const combined = `${text}\n${err}`;
|
|
330
|
+
if (liveQuotedCard(combined, intent)) {
|
|
331
|
+
pass(`${host} live successor quoted the station card`);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (liveAuthBlocked(combined)) {
|
|
335
|
+
skip(`${host} live successor (host auth)`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
if (/ETIMEDOUT|timed out|TIMEOUT/i.test(combined) || result.error?.code === 'ETIMEDOUT') {
|
|
339
|
+
fail(`${host} live successor timed out`, combined.slice(0, 200));
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
fail(`${host} live successor did not quote the card`, combined.slice(0, 240));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function runHermesGate(root, extra) {
|
|
346
|
+
const json = JSON.stringify({
|
|
347
|
+
command: 'delegation-gate',
|
|
348
|
+
phase: 'pre',
|
|
349
|
+
sessionId: 'floor-compact-hermes',
|
|
350
|
+
host: 'hermes',
|
|
351
|
+
...extra,
|
|
352
|
+
}).replace(/'/g, "'\\''");
|
|
353
|
+
const out = execSync(`node "${hermesBridge}" delegation-gate --cwd "${root}" '${json}'`, {
|
|
354
|
+
cwd: root,
|
|
355
|
+
encoding: 'utf8',
|
|
356
|
+
env: { ...process.env, XRAY_ROOT: root },
|
|
357
|
+
});
|
|
358
|
+
return JSON.parse(out.trim().split('\n').filter(Boolean).at(-1));
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function denied(g) {
|
|
362
|
+
return g && (g.allow === false || g.decision === 'deny');
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function assertConstitutionAndTemperament(root, host, { spawn, eleven, surface, destructive }) {
|
|
366
|
+
if (spawn.allow === false && spawn.gate === 'spawn-plan-missing') {
|
|
367
|
+
pass(`${host} temperament denies spawn without plan (guided)`);
|
|
368
|
+
} else if (host === 'grok' && spawn.decision === 'allow' && spawn.warn === true) {
|
|
369
|
+
pass(`${host} temperament warns spawn without plan (frontier)`);
|
|
370
|
+
} else if (spawn.allow !== false && spawn.warn === true) {
|
|
371
|
+
pass(`${host} temperament warns spawn without plan (frontier)`);
|
|
372
|
+
} else {
|
|
373
|
+
fail(`${host} temperament spawn`, JSON.stringify(spawn));
|
|
374
|
+
}
|
|
375
|
+
if (denied(eleven) && eleven.gate === 'codex-11') pass(`${host} constitution denies Codex 11`);
|
|
376
|
+
else fail(`${host} constitution Codex 11`, JSON.stringify(eleven));
|
|
377
|
+
if (denied(surface) && surface.gate === 'no-new-surface') pass(`${host} constitution denies Codex 69 new surface`);
|
|
378
|
+
else fail(`${host} constitution Codex 69`, JSON.stringify(surface));
|
|
379
|
+
if (denied(destructive) && destructive.gate === 'destructive-shell') {
|
|
380
|
+
pass(`${host} constitution denies destructive shell`);
|
|
381
|
+
} else fail(`${host} constitution destructive shell`, JSON.stringify(destructive));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
for (const p of [grokSession, grokPreTool, hermesBridge, suitJs, gateJs]) {
|
|
385
|
+
if (existsSync(p)) pass(`dist ${p.slice(packageRoot.length + 1)}`);
|
|
386
|
+
else fail('missing dist', p);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
const { writeSuitSessionBoot } = await import(pathToFileURL(suitJs).href);
|
|
390
|
+
const { evaluatePreToolGate, loadDelegationGateFeatures } = await import(pathToFileURL(gateJs).href);
|
|
391
|
+
|
|
392
|
+
{
|
|
393
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-compact-grok-'));
|
|
394
|
+
try {
|
|
395
|
+
seedFloor(tmp);
|
|
396
|
+
const intent = memoryIntent('grok');
|
|
397
|
+
assertConstitutionAndTemperament(tmp, 'grok', constitutionBundle(tmp, 'grok'));
|
|
398
|
+
runGrokSession(tmp, 'session_start', { intent, sessionId: 'compact-grok-1' });
|
|
399
|
+
runGrokSession(tmp, 'pre_compact', { sessionId: 'compact-grok-1' });
|
|
400
|
+
runGrokSession(tmp, 'post_compact', { sessionId: 'compact-grok-1' });
|
|
401
|
+
assertSurvived(tmp, { host: 'grok', intent, profile: 'frontier' });
|
|
402
|
+
const boot = readBoot(tmp);
|
|
403
|
+
pass(`Grok compact source=${boot.source} hookEvent=${boot.hookEvent}`);
|
|
404
|
+
tryLiveSuccessor(tmp, 'grok', intent);
|
|
405
|
+
} finally {
|
|
406
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
{
|
|
411
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-compact-hermes-'));
|
|
412
|
+
try {
|
|
413
|
+
seedFloor(tmp);
|
|
414
|
+
const intent = memoryIntent('hermes');
|
|
415
|
+
assertConstitutionAndTemperament(tmp, 'hermes', constitutionBundle(tmp, 'hermes'));
|
|
416
|
+
writeSuitSessionBoot(tmp, 'hermes', {
|
|
417
|
+
source: '0xray/hermes-user',
|
|
418
|
+
sessionId: 'compact-hermes-1',
|
|
419
|
+
intent,
|
|
420
|
+
});
|
|
421
|
+
runHermesSession(tmp, 'compact-hermes-1');
|
|
422
|
+
const compactJson = JSON.stringify({
|
|
423
|
+
command: 'session-start',
|
|
424
|
+
sessionId: 'compact-hermes-2',
|
|
425
|
+
compact: true,
|
|
426
|
+
}).replace(/'/g, "'\\''");
|
|
427
|
+
execSync(`node "${hermesBridge}" session-start --cwd "${tmp}" '${compactJson}'`, {
|
|
428
|
+
cwd: tmp,
|
|
429
|
+
encoding: 'utf8',
|
|
430
|
+
env: { ...process.env, XRAY_ROOT: tmp },
|
|
431
|
+
});
|
|
432
|
+
assertSurvived(tmp, { host: 'hermes', intent, profile: 'guided' });
|
|
433
|
+
tryLiveSuccessor(tmp, 'hermes', intent);
|
|
434
|
+
} finally {
|
|
435
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
{
|
|
440
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-compact-opencode-'));
|
|
441
|
+
try {
|
|
442
|
+
seedFloor(tmp);
|
|
443
|
+
const intent = memoryIntent('opencode');
|
|
444
|
+
assertConstitutionAndTemperament(tmp, 'opencode', constitutionBundle(tmp, 'opencode'));
|
|
445
|
+
writeSuitSessionBoot(tmp, 'opencode', {
|
|
446
|
+
source: '0xray/opencode-user',
|
|
447
|
+
sessionId: 'compact-oc-1',
|
|
448
|
+
intent,
|
|
449
|
+
});
|
|
450
|
+
writeSuitSessionBoot(tmp, 'opencode', {
|
|
451
|
+
source: '0xray/opencode-plugin',
|
|
452
|
+
hookEvent: 'post_compact',
|
|
453
|
+
});
|
|
454
|
+
assertSurvived(tmp, { host: 'opencode', intent, profile: 'guided' });
|
|
455
|
+
tryLiveSuccessor(tmp, 'opencode', intent);
|
|
456
|
+
const card = readCard(tmp);
|
|
457
|
+
if (card.includes(intent) && card.includes('Do not cold-start')) {
|
|
458
|
+
pass('OpenCode successor would inject STATION.md (plugin system.transform)');
|
|
459
|
+
}
|
|
460
|
+
} finally {
|
|
461
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
{
|
|
466
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-compact-openclaw-'));
|
|
467
|
+
try {
|
|
468
|
+
seedFloor(tmp);
|
|
469
|
+
const intent = memoryIntent('openclaw');
|
|
470
|
+
const feat = loadDelegationGateFeatures(tmp, 'openclaw');
|
|
471
|
+
assertConstitutionAndTemperament(tmp, 'openclaw', constitutionBundle(tmp, 'openclaw'));
|
|
472
|
+
writeSuitSessionBoot(tmp, 'openclaw', {
|
|
473
|
+
source: '0xray/openclaw-user',
|
|
474
|
+
sessionId: 'compact-claw-1',
|
|
475
|
+
intent,
|
|
476
|
+
});
|
|
477
|
+
evaluatePreToolGate(
|
|
478
|
+
'read',
|
|
479
|
+
{ path: 'README.md' },
|
|
480
|
+
{
|
|
481
|
+
projectRoot: tmp,
|
|
482
|
+
sessionId: 'compact-claw-1',
|
|
483
|
+
features: feat,
|
|
484
|
+
host: 'openclaw',
|
|
485
|
+
hookEvent: 'post_compact',
|
|
486
|
+
},
|
|
487
|
+
);
|
|
488
|
+
writeSuitSessionBoot(tmp, 'openclaw', {
|
|
489
|
+
source: '0xray/openclaw-compact',
|
|
490
|
+
sessionId: 'compact-claw-1',
|
|
491
|
+
hookEvent: 'post_compact',
|
|
492
|
+
});
|
|
493
|
+
assertSurvived(tmp, { host: 'openclaw', intent, profile: 'guided' });
|
|
494
|
+
tryLiveSuccessor(tmp, 'openclaw', intent);
|
|
495
|
+
} finally {
|
|
496
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
{
|
|
501
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-compact-swap-'));
|
|
502
|
+
try {
|
|
503
|
+
seedFloor(tmp);
|
|
504
|
+
const intent = memoryIntent('hotswap');
|
|
505
|
+
runGrokSession(tmp, 'session_start', { intent, sessionId: 'swap-1' });
|
|
506
|
+
writeSuitSessionBoot(tmp, 'opencode', { source: '0xray/opencode-plugin', sessionId: 'swap-2' });
|
|
507
|
+
writeSuitSessionBoot(tmp, 'opencode', { source: '0xray/opencode-compact', sessionId: 'swap-2' });
|
|
508
|
+
assertSurvived(tmp, {
|
|
509
|
+
host: 'opencode',
|
|
510
|
+
intent,
|
|
511
|
+
profile: 'guided',
|
|
512
|
+
hotSwap: { from: 'grok', to: 'opencode' },
|
|
513
|
+
});
|
|
514
|
+
} finally {
|
|
515
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (failed) {
|
|
520
|
+
process.stderr.write(`four-floor compact survival failed (${failed})\n`);
|
|
521
|
+
process.exit(1);
|
|
522
|
+
}
|
|
523
|
+
process.stdout.write('four-floor compact survival passed\n');
|
|
524
|
+
process.exit(0);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Hermes session-start bridge — stale plan archival with synthesis exemption.
|
|
4
|
+
*/
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { tmpdir } from 'node:os';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const packageRoot = join(__dirname, '../..');
|
|
13
|
+
const bridge = join(packageRoot, 'dist/integrations/hermes-agent/bridge.mjs');
|
|
14
|
+
|
|
15
|
+
let failed = 0;
|
|
16
|
+
function pass(n) {
|
|
17
|
+
console.log(`✅ ${n}`);
|
|
18
|
+
}
|
|
19
|
+
function fail(n, d = '') {
|
|
20
|
+
failed++;
|
|
21
|
+
console.error(`❌ ${n}${d ? ` — ${d}` : ''}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function runBridge(payload, cwd) {
|
|
25
|
+
const json = JSON.stringify(payload).replace(/'/g, "'\\''");
|
|
26
|
+
const out = execSync(`node "${bridge}" session-start --cwd "${cwd}" '${json}'`, {
|
|
27
|
+
cwd,
|
|
28
|
+
encoding: 'utf8',
|
|
29
|
+
env: { ...process.env, XRAY_ROOT: cwd },
|
|
30
|
+
});
|
|
31
|
+
return JSON.parse(out.trim());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const tmp = mkdtempSync(join(tmpdir(), 'xray-hermes-session-'));
|
|
35
|
+
const planPath = join(tmp, '.xray', 'state', 'lead-dev-plan.json');
|
|
36
|
+
mkdirSync(join(tmp, '.xray', 'state'), { recursive: true });
|
|
37
|
+
writeFileSync(
|
|
38
|
+
join(tmp, '.xray', 'features.json'),
|
|
39
|
+
JSON.stringify({
|
|
40
|
+
multi_agent_orchestration: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
lead_dev_mode: true,
|
|
43
|
+
auto_consult_major_work: true,
|
|
44
|
+
},
|
|
45
|
+
synthesis: { enabled: true, every_n_gates: 1, every_n_turns: 0, every_n_todos_completed: 0 },
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const staleAt = new Date(Date.now() - 10 * 60 * 60 * 1000).toISOString();
|
|
50
|
+
const synthesisPlan = {
|
|
51
|
+
active: true,
|
|
52
|
+
persistedAt: staleAt,
|
|
53
|
+
sessionId: 'hermes-session-start-fixture',
|
|
54
|
+
phases: [
|
|
55
|
+
{
|
|
56
|
+
id: 'phase-synthesis',
|
|
57
|
+
name: 'Reflect & realign',
|
|
58
|
+
goal: 'consult',
|
|
59
|
+
definitionOfDone: 'done',
|
|
60
|
+
todos: [
|
|
61
|
+
{ id: 's.1', task: 'researcher consult', subagent: 'researcher', status: 'pending' },
|
|
62
|
+
{ id: 's.2', task: 'architect consult', subagent: 'architect-tools', status: 'pending' },
|
|
63
|
+
{ id: 's.3', task: 'review consult', subagent: 'code-review', status: 'pending' },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
writeFileSync(planPath, JSON.stringify(synthesisPlan, null, 2));
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const result = runBridge({ command: 'session-start', sessionId: 'hermes-session-start-fixture' }, tmp);
|
|
72
|
+
if (result.ok === true) pass('bridge session-start returns ok');
|
|
73
|
+
else fail('session-start ok', JSON.stringify(result));
|
|
74
|
+
|
|
75
|
+
if (existsSync(planPath)) pass('aged synthesis plan survives session-start archival');
|
|
76
|
+
else fail('synthesis plan preserved', 'lead-dev-plan.json missing');
|
|
77
|
+
|
|
78
|
+
const archived = result.planArchive?.archived === true;
|
|
79
|
+
if (!archived) pass('session-start did not archive protected synthesis plan');
|
|
80
|
+
else fail('synthesis archive skip', JSON.stringify(result.planArchive));
|
|
81
|
+
|
|
82
|
+
const staleTmp = mkdtempSync(join(tmpdir(), 'xray-hermes-stale-'));
|
|
83
|
+
const stalePlanPath = join(staleTmp, '.xray', 'state', 'lead-dev-plan.json');
|
|
84
|
+
mkdirSync(join(staleTmp, '.xray', 'state'), { recursive: true });
|
|
85
|
+
writeFileSync(
|
|
86
|
+
join(staleTmp, '.xray', 'features.json'),
|
|
87
|
+
JSON.stringify({
|
|
88
|
+
multi_agent_orchestration: { enabled: true, lead_dev_mode: true },
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
const staleAt = new Date(Date.now() - 10 * 60 * 60 * 1000).toISOString();
|
|
92
|
+
writeFileSync(
|
|
93
|
+
stalePlanPath,
|
|
94
|
+
JSON.stringify(
|
|
95
|
+
{
|
|
96
|
+
active: true,
|
|
97
|
+
persistedAt: staleAt,
|
|
98
|
+
phases: [
|
|
99
|
+
{
|
|
100
|
+
id: 'phase-1',
|
|
101
|
+
todos: [
|
|
102
|
+
{
|
|
103
|
+
id: '1.1',
|
|
104
|
+
task: 'stale hygiene',
|
|
105
|
+
subagent: 'researcher',
|
|
106
|
+
status: 'pending',
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
null,
|
|
113
|
+
2,
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const staleResult = runBridge(
|
|
118
|
+
{ command: 'session-start', sessionId: 'hermes-stale-archive-fixture' },
|
|
119
|
+
staleTmp,
|
|
120
|
+
);
|
|
121
|
+
if (staleResult.planArchive?.archived === true && !existsSync(stalePlanPath)) {
|
|
122
|
+
pass('session-start archives ordinary stale lead-dev plan');
|
|
123
|
+
} else {
|
|
124
|
+
fail('stale plan archival', JSON.stringify(staleResult.planArchive));
|
|
125
|
+
}
|
|
126
|
+
rmSync(staleTmp, { recursive: true, force: true });
|
|
127
|
+
} finally {
|
|
128
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log(
|
|
132
|
+
'\n' +
|
|
133
|
+
(failed === 0
|
|
134
|
+
? '🎉 Hermes session-start verify passed (4/4).'
|
|
135
|
+
: `⚠️ ${failed} Hermes session-start check(s) failed.`),
|
|
136
|
+
);
|
|
137
|
+
process.exit(failed === 0 ? 0 : 1);
|