harness-everything 0.55.3 → 0.56.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/BENCHMARK_SOP.md +2 -2
- package/CHANGELOG.md +26 -0
- package/README.md +15 -16
- package/SECURITY.md +1 -1
- package/VERIFICATION.md +4 -8
- package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
- package/behavioral-evals/README.md +21 -65
- package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
- package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
- package/behavioral-evals/paired-benchmark.js +3 -40
- package/behavioral-evals/run.js +2 -3
- package/ci/fixtures/468-dispatch/runner.js +144 -0
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
- package/ci/invariant-routing.test.js +26 -5
- package/ci/lib/opencode-verification-loader.js +3 -5
- package/ci/mechanism-2a-rule-of-3.test.js +111 -97
- package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
- package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
- package/ci/mechanism-32-paired-benchmark.test.js +1 -2
- package/ci/mechanism-33-issues-205-207.test.js +1 -1
- package/ci/mechanism-338-opencode-async.test.js +18 -49
- package/ci/mechanism-36-verify-timeout.test.js +3 -189
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
- package/ci/mechanism-397-opencode-observations.test.js +6 -7
- package/ci/mechanism-468-dispatch-cli.test.js +546 -0
- package/ci/mechanism-codex-hook-results.test.js +9 -5
- package/ci/mechanism-error-handling-map.test.js +14 -12
- package/ci/mechanism-prb-outline-review.test.js +1 -13
- package/ci/mechanism-system-one-router.test.js +1 -1
- package/ci/openai-plugin-package.test.js +30 -7
- package/ci/openai-plugin-runtime.test.js +64 -32
- package/ci/prompt-contract-regressions.test.js +1 -5
- package/ci/self-evolve-loop.test.js +51 -51
- package/ci/workflow-execution-contract.test.js +3 -6
- package/docker-verify.sh +1 -117
- package/docs/architecture.md +9 -7
- package/docs/document-lifecycle.md +1 -1
- package/docs/enforcement-locks.md +12 -10
- package/docs/error-handling/README.md +3 -3
- package/docs/error-handling/actions/c8-action-map.md +41 -0
- package/docs/error-handling/details/c8-dispatch-cli.md +75 -0
- package/docs/error-handling/nodes.yaml +5 -0
- package/docs/error-handling/registry.md +4 -1
- package/docs/mechanism-first-skill-mesh.md +2 -2
- package/docs/openai-plugin.md +3 -3
- package/docs/philosophy.md +1 -1
- package/docs/platform-capabilities.md +2 -2
- package/docs/platform-compatibility.json +2 -2
- package/docs/reflection.md +1 -1
- package/docs/routing.md +2 -2
- package/docs/system-one-suggestion-gates.md +4 -4
- package/docs/troubleshooting.md +9 -35
- package/docs/workflow-runtime.md +19 -18
- package/docs/workflows/environment-detection.md +11 -9
- package/docs/workflows/fable-discipline.md +6 -5
- package/docs/workflows/fable-mode.md +6 -5
- package/docs/workflows/harness-everything.md +5 -5
- package/docs/workflows/improve-codebase-architecture.md +10 -8
- package/docs/workflows/install-cognitive-os.md +5 -5
- package/docs/workflows/tdd.md +9 -9
- package/docs/workflows/zoom-out.md +20 -30
- package/environment-detection/SKILL.md +2 -2
- package/environment-detection/references/shell-syntax-rules.md +1 -1
- package/eval-harness/SKILL.md +1 -1
- package/eval-harness/references/scoring-rubric.md +3 -3
- package/evals/zoom-out/eval.yaml +2 -2
- package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
- package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
- package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
- package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
- package/fable-discipline/SKILL.md +3 -3
- package/fable-discipline/references/discipline-rules.md +1 -1
- package/fable-mode/SKILL.md +1 -1
- package/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/fable-mode/fable-haiku/SKILL.md +1 -1
- package/fable-mode/fable-opus/SKILL.md +2 -2
- package/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/fable-mode/references/execution-phases.md +2 -2
- package/harness-everything/SKILL.md +3 -3
- package/harness-everything/references/router-workflow-plan.md +2 -2
- package/harness-everything/references/skill-registry.md +2 -2
- package/harness-everything/references/triage-and-tiers.md +5 -5
- package/harness-everything/scripts/bootstrap.js +1 -26
- package/harness-everything/scripts/kernel-router-core.js +2 -3
- package/harness-everything/scripts/kernel-router.js +1 -1
- package/harness-everything/scripts/router-contract-core.js +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/hooks/hooks.json +0 -33
- package/hooks/scripts/lib/harness-state.js +5 -6
- package/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/hooks/scripts/openai-session-start.js +2 -4
- package/improve-codebase-architecture/SKILL.md +3 -3
- package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/install-cognitive-os/SKILL.md +3 -3
- package/opencode-plugin/README.md +12 -43
- package/opencode-plugin/index.mjs +21 -368
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +2 -4
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/hooks.json +0 -14
- package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
- package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
- package/plugins/harness-everything/hooks/session-start.js +2 -4
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
- package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
- package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
- package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
- package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
- package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
- package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
- package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
- package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
- package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
- package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
- package/references/platform-advisory-template.md +3 -9
- package/sbom.cdx.json +7 -7
- package/scripts/dispatch.js +340 -0
- package/scripts/lib/advisory-text.js +2 -2
- package/scripts/lib/workspace.js +2 -2
- package/self-evolve/SKILL.md +1 -1
- package/self-evolve/references/memory-resolution.md +3 -3
- package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/self-evolve/scripts/lesson-candidate.js +1 -0
- package/skill-creator/SKILL.md +1 -1
- package/skill-creator/references/quality-checklist.md +1 -1
- package/skill-creator/references/quality-principles.md +4 -4
- package/submission/openai/test-cases.json +5 -5
- package/tdd/SKILL.md +2 -2
- package/tdd/references/core-discipline.md +3 -5
- package/todo-driven-workflow/SKILL.md +2 -2
- package/zoom-out/SKILL.md +14 -26
- package/zoom-out/references/circuit-breaker.md +18 -62
- package/behavioral-evals/opencode-hardlock-live.js +0 -17
- package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
- package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
- package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
- package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
- package/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/hooks/scripts/rule-of-3-tracker.js +0 -165
- package/hooks/scripts/rule-of-3.js +0 -171
- package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
- package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
|
@@ -3248,18 +3248,8 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3248
3248
|
tool_name: 'Agent', tool_use_id: 'pilot-alias-capture', agent_type: 'worker',
|
|
3249
3249
|
tool_input: { prompt: 'alias capture probe' },
|
|
3250
3250
|
}, true);
|
|
3251
|
-
writeJson(path.join(aliasSessionDir, 'rule-of-3-state.json'), {
|
|
3252
|
-
count: 3, threshold: 3, lastHash: 'alias-keying-control', lastFailureAt: 0,
|
|
3253
|
-
});
|
|
3254
|
-
const breaker = runHook('hooks/scripts/rule-of-3.js', {
|
|
3255
|
-
hook_event_name: 'PreToolUse', session_id: sessionId, cwd: aliasRoot,
|
|
3256
|
-
tool_name: 'apply_patch', tool_input: { patch: '*** Update File: unrelated.txt\n@@\n-old\n+new\n' },
|
|
3257
|
-
});
|
|
3258
3251
|
assert.strictEqual(legacy.status, 0, `pilot-OFF state-persist must remain fail-open: ${legacy.stderr}`);
|
|
3259
3252
|
assert.strictEqual(pilot.status, 0, `pilot capture must remain fail-open: ${pilot.stderr}`);
|
|
3260
|
-
assert.strictEqual(breaker.status, 2, `rule-of-3 must find the tripped alias session: ${breaker.stderr}`);
|
|
3261
|
-
assert.match(breaker.stderr, /RULE OF 3 CIRCUIT BREAKER TRIGGERED/);
|
|
3262
|
-
console.log('PASS rule-of-3 alias-root positive control blocks at exit 2');
|
|
3263
3253
|
return {
|
|
3264
3254
|
legacyExit: legacy.status,
|
|
3265
3255
|
pilotOffCaptureCount,
|
|
@@ -3267,7 +3257,6 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3267
3257
|
handoffInCanonicalSession: fs.existsSync(path.join(canonicalSessionDir, 'handoff-state.json')),
|
|
3268
3258
|
pilotCaptureInAliasSession: provider.readCaptureView(aliasSessionDir).records.some(item => item.tool_use_id === 'pilot-alias-capture'),
|
|
3269
3259
|
pilotCaptureInCanonicalSession: provider.readCaptureView(canonicalSessionDir).records.some(item => item.tool_use_id === 'pilot-alias-capture'),
|
|
3270
|
-
breakerExit: breaker.status,
|
|
3271
3260
|
};
|
|
3272
3261
|
} finally {
|
|
3273
3262
|
fs.rmSync(stateHome, { recursive: true, force: true });
|
|
@@ -3281,7 +3270,6 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3281
3270
|
assert.deepStrictEqual(first, second, 'identical alias-root inputs must produce the same normalized state and exits');
|
|
3282
3271
|
assert.strictEqual(first.legacyExit, 0, 'pilot OFF remains fail-open');
|
|
3283
3272
|
assert.strictEqual(first.pilotOffCaptureCount, 0, 'pilot OFF writes no capture record');
|
|
3284
|
-
assert.strictEqual(first.breakerExit, 2, 'the aliased rule-of-3 positive control blocks');
|
|
3285
3273
|
assert.deepStrictEqual({
|
|
3286
3274
|
handoffInAliasSession: first.handoffInAliasSession,
|
|
3287
3275
|
handoffInCanonicalSession: first.handoffInCanonicalSession,
|
|
@@ -3292,7 +3280,7 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3292
3280
|
handoffInCanonicalSession: false,
|
|
3293
3281
|
pilotCaptureInAliasSession: true,
|
|
3294
3282
|
pilotCaptureInCanonicalSession: false,
|
|
3295
|
-
}, `legacy handoff and pilot capture must stay in
|
|
3283
|
+
}, `legacy handoff and pilot capture must stay in the bound alias session directory: ${JSON.stringify(first)}`);
|
|
3296
3284
|
});
|
|
3297
3285
|
|
|
3298
3286
|
test('no final D stays incomplete and hand-authored JSON without a host seam earns no outline credit', () => {
|
|
@@ -59,7 +59,7 @@ test('S1-R04 integrated accepted route preserves policy and explicit model choic
|
|
|
59
59
|
assert.notEqual(risky.workflowPlan.memory.write, 'none');
|
|
60
60
|
const explicit = run('use fable-staged without subagents');
|
|
61
61
|
assert.notEqual(explicit.workflowPlan.strategy, 'direct-single');
|
|
62
|
-
assert.ok(explicit.workflowPlan.requiredInvariants.includes('replan-after-repeated-failure'));
|
|
62
|
+
assert.ok(!explicit.workflowPlan.requiredInvariants.includes('replan-after-repeated-failure'));
|
|
63
63
|
const normal = run('unusual bounded wording');
|
|
64
64
|
assert.equal(normal.workflowPlan.tier, 'tier1');
|
|
65
65
|
} finally { provider.score = original; console.log = log; if (env === undefined) delete process.env.HARNESS_SYSTEM_ONE_MODE; else process.env.HARNESS_SYSTEM_ONE_MODE = env; }
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
6
7
|
const path = require('path');
|
|
7
8
|
const { spawnSync } = require('child_process');
|
|
8
9
|
|
|
@@ -43,6 +44,33 @@ function assertTreesEqual(source, packaged, name) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
const sessionFixture = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'harness-openai-session-start-'));
|
|
48
|
+
try {
|
|
49
|
+
const session = spawnSync(process.execPath, [path.join(ROOT, 'hooks', 'scripts', 'openai-session-start.js')], {
|
|
50
|
+
cwd: sessionFixture,
|
|
51
|
+
input: JSON.stringify({
|
|
52
|
+
hook_event_name: 'SessionStart',
|
|
53
|
+
session_id: 'openai-package-session-start',
|
|
54
|
+
cwd: sessionFixture,
|
|
55
|
+
source: 'startup'
|
|
56
|
+
}),
|
|
57
|
+
encoding: 'utf8',
|
|
58
|
+
env: { ...process.env, HARNESS_STATE_HOME: path.join(sessionFixture, 'state-home') }
|
|
59
|
+
});
|
|
60
|
+
assert.strictEqual(session.status, 0, session.stderr);
|
|
61
|
+
const sessionOutput = JSON.parse(session.stdout);
|
|
62
|
+
const sessionContext = sessionOutput.hookSpecificOutput.additionalContext;
|
|
63
|
+
assert.strictEqual(sessionOutput.hookSpecificOutput.hookEventName, 'SessionStart');
|
|
64
|
+
assert.match(sessionContext, /Cognitive OS policy is active/);
|
|
65
|
+
assert.match(sessionContext, /Route before execution/);
|
|
66
|
+
assert.match(sessionContext, /Verify before claim/);
|
|
67
|
+
assert.match(sessionContext, /first meaningful signal/i);
|
|
68
|
+
assert.match(sessionContext, /productive iteration may continue/i);
|
|
69
|
+
assert.doesNotMatch(sessionContext, /after 3 same-signature failures|third matching failure|Rule[- ]of[- ]3|forced reflection|compulsory report|reset|unlock/i);
|
|
70
|
+
} finally {
|
|
71
|
+
fs.rmSync(sessionFixture, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
|
|
46
74
|
assert.strictEqual(PLUGIN_MANIFEST.name, 'harness-everything');
|
|
47
75
|
assert.strictEqual(PLUGIN_MANIFEST.version, SOURCE_MANIFEST.version, 'OpenAI plugin version must match canonical plugin version');
|
|
48
76
|
assert.strictEqual(PLUGIN_MANIFEST.skills, './skills/');
|
|
@@ -164,13 +192,8 @@ assert.match(hookText, /PLUGIN_ROOT/, 'plugin hooks must resolve from PLUGIN_ROO
|
|
|
164
192
|
assert.match(hookText, /commandWindows/, 'plugin hooks need a Windows command override');
|
|
165
193
|
assert.match(hookText, /workflow-gate\.js/, 'plugin hooks must package workflow contract observation');
|
|
166
194
|
assert.match(hookText, /workflow-stop-gate\.js/, 'plugin hooks must package workflow completion reminders');
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
assert.strictEqual(session.status, 0, session.stderr);
|
|
170
|
-
assert.match(session.stdout, /Cognitive OS policy is active/);
|
|
171
|
-
assert.match(session.stdout, /Route before execution/);
|
|
172
|
-
assert.match(session.stdout, /Verify before claim/);
|
|
173
|
-
assert.match(session.stdout, /3 same-signature failures/);
|
|
195
|
+
assert.doesNotMatch(hookText, /rule-of-3(?:-tracker)?\.js|reset-circuit-breaker\.js/,
|
|
196
|
+
'OpenAI package must not register retired breaker entry points');
|
|
174
197
|
|
|
175
198
|
const kernel = path.join(PLUGIN, 'skills', 'harness-everything', 'scripts', 'kernel-router.js');
|
|
176
199
|
function route(prompt) {
|
|
@@ -61,8 +61,8 @@ assert.ok(fs.existsSync(path.join(PLUGIN, 'scripts', 'lib', 'advisory-text.js'))
|
|
|
61
61
|
const packagedState = fs.readFileSync(path.join(PLUGIN, 'hooks', 'scripts', 'lib', 'harness-state.js'), 'utf8');
|
|
62
62
|
assert.doesNotMatch(packagedState, /\.\.\/\.\.\/\.\.\/scripts[\\/]lib[\\/]workspace/);
|
|
63
63
|
|
|
64
|
-
function runHook(relative, payload, stateHome) {
|
|
65
|
-
return spawnSync(process.execPath, [path.join(PLUGIN, relative)], {
|
|
64
|
+
function runHook(relative, payload, stateHome, args = []) {
|
|
65
|
+
return spawnSync(process.execPath, [path.join(PLUGIN, relative), ...args], {
|
|
66
66
|
input: JSON.stringify(payload),
|
|
67
67
|
encoding: 'utf8',
|
|
68
68
|
cwd: ROOT,
|
|
@@ -70,6 +70,22 @@ function runHook(relative, payload, stateHome) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
function registeredHooks(event, tool) {
|
|
74
|
+
return (hooks[event] || [])
|
|
75
|
+
.filter(group => !group.matcher || group.matcher.split('|').some(pattern =>
|
|
76
|
+
pattern === tool || pattern === '.*' || (pattern.endsWith('.*') && tool.startsWith(pattern.slice(0, -2)))))
|
|
77
|
+
.flatMap(group => group.hooks || []);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function runRegistered(event, tool, payload, stateHome) {
|
|
81
|
+
return registeredHooks(event, tool).map(hook => {
|
|
82
|
+
const match = hook.command.match(/^node "\$\{PLUGIN_ROOT\}\/([^"]+)"(.*)$/);
|
|
83
|
+
assert.ok(match, `unrecognized packaged hook command: ${hook.command}`);
|
|
84
|
+
const args = match[2].trim().split(/\s+/).filter(Boolean);
|
|
85
|
+
return runHook(match[1], { ...payload, hook_event_name: event, tool_name: tool }, stateHome, args);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
73
89
|
const fixture = fs.mkdtempSync(path.join(os.tmpdir(), 'harness-openai-runtime-'));
|
|
74
90
|
const stateHome = path.join(fixture, 'state-home');
|
|
75
91
|
const gitInit = spawnSync('git', ['init', '--quiet'], { cwd: fixture, encoding: 'utf8' });
|
|
@@ -117,39 +133,55 @@ assert.ok(handoff, 'SessionStart/state-persist should create a handoff state fil
|
|
|
117
133
|
assert.ok(JSON.parse(fs.readFileSync(handoff, 'utf8')).lastEditAt, 'apply_patch must count as an edit');
|
|
118
134
|
|
|
119
135
|
const sessionDir = path.dirname(handoff);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
threshold: 3,
|
|
123
|
-
lastHash: 'runtime-test-failure',
|
|
124
|
-
lastFailureAt: 0
|
|
125
|
-
}), 'utf8');
|
|
126
|
-
const reportFile = path.join(sessionDir, 'zoom-out-report.md');
|
|
127
|
-
const reportWrite = runHook('hooks/scripts/rule-of-3.js', {
|
|
128
|
-
hook_event_name: 'PreToolUse',
|
|
129
|
-
session_id: 'openai-runtime-test',
|
|
130
|
-
cwd: fixture,
|
|
131
|
-
tool_name: 'apply_patch',
|
|
132
|
-
tool_input: { patch: `*** Add File: ${reportFile}\n## Goal` }
|
|
133
|
-
}, stateHome);
|
|
134
|
-
assert.strictEqual(reportWrite.status, 0, 'apply_patch must be allowed to write the zoom-out report');
|
|
136
|
+
assert.doesNotMatch(hookText, /rule-of-3(?:-tracker)?\.js|reset-circuit-breaker\.js/,
|
|
137
|
+
'packaged Codex hooks must not register retired breaker entry points');
|
|
135
138
|
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
assert.strictEqual(
|
|
139
|
+
const legacyState = { count: 3, lastHash: 'legacy-trip', zoomOutResolved: false, lastFailureAt: 123, zoomOutCycles: 0 };
|
|
140
|
+
const legacyStateFile = path.join(sessionDir, 'rule-of-3-state.json');
|
|
141
|
+
const reportFile = path.join(sessionDir, 'zoom-out-report.md');
|
|
142
|
+
const note = 'agent-authored recovery note\n';
|
|
143
|
+
fs.writeFileSync(legacyStateFile, JSON.stringify(legacyState), 'utf8');
|
|
144
|
+
fs.writeFileSync(reportFile, note, 'utf8');
|
|
145
|
+
const resumedSession = runHook('hooks/session-start.js', sessionPayload, stateHome);
|
|
146
|
+
assert.strictEqual(resumedSession.status, 0, resumedSession.stderr);
|
|
147
|
+
assert.deepStrictEqual(JSON.parse(fs.readFileSync(legacyStateFile, 'utf8')), legacyState,
|
|
148
|
+
'Codex startup leaves stale breaker state inert and intact');
|
|
149
|
+
assert.strictEqual(fs.readFileSync(reportFile, 'utf8'), note,
|
|
150
|
+
'Codex startup preserves optional agent-authored notes');
|
|
151
|
+
|
|
152
|
+
for (const scenario of [
|
|
153
|
+
{ name: 'fresh', state: null, command: `${process.execPath} -e "process.exit(1)"`, response: { exitCode: 1, stderr: 'fixture failure' } },
|
|
154
|
+
{ name: 'legacy-tripped', state: legacyState, command: `${process.execPath} -e "process.stdout.write('permitted')"`, response: { exitCode: 0, stdout: 'permitted' } },
|
|
155
|
+
]) {
|
|
156
|
+
if (scenario.state) fs.writeFileSync(legacyStateFile, JSON.stringify(scenario.state), 'utf8');
|
|
157
|
+
else fs.rmSync(legacyStateFile, { force: true });
|
|
158
|
+
const payload = {
|
|
159
|
+
host: 'codex', session_id: 'openai-runtime-test', cwd: fixture,
|
|
160
|
+
tool_use_id: `r1-${scenario.name}`, tool_input: { command: scenario.command },
|
|
161
|
+
};
|
|
162
|
+
const before = runRegistered('PreToolUse', 'Bash', payload, stateHome);
|
|
163
|
+
assert.ok(before.every(result => result.status === 0), `${scenario.name} pre-tool hooks should permit this command: ${before.map(item => item.stderr).join('\n')}`);
|
|
164
|
+
const call = spawnSync(process.execPath, ['-e', scenario.name === 'fresh' ? 'process.exit(1)' : 'process.stdout.write("permitted")'], {
|
|
165
|
+
cwd: fixture, encoding: 'utf8',
|
|
166
|
+
});
|
|
167
|
+
assert.strictEqual(call.status, scenario.response.exitCode, `${scenario.name} otherwise-permitted tool call must run`);
|
|
168
|
+
const after = runRegistered('PostToolUse', 'Bash', { ...payload, tool_response: scenario.response }, stateHome);
|
|
169
|
+
assert.ok(after.every(result => result.status === 0), `${scenario.name} result hooks should complete: ${after.map(item => item.stderr).join('\n')}`);
|
|
170
|
+
if (scenario.state) {
|
|
171
|
+
assert.deepStrictEqual(JSON.parse(fs.readFileSync(legacyStateFile, 'utf8')), legacyState,
|
|
172
|
+
'legacy tripped state remains unchanged after the next tool call');
|
|
173
|
+
} else {
|
|
174
|
+
assert.strictEqual(fs.existsSync(legacyStateFile), false, 'fresh tool call creates no breaker state');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
144
177
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
cwd: fixture,
|
|
149
|
-
tool_name: 'apply_patch',
|
|
150
|
-
tool_input: { patch: '*** Update File: unrelated.txt\n@@' }
|
|
178
|
+
const denied = runRegistered('PreToolUse', 'mcp__codex_apps__github__delete_issue', {
|
|
179
|
+
host: 'codex', session_id: 'openai-runtime-test', cwd: fixture, tool_use_id: 'r1-denied-control',
|
|
180
|
+
tool_input: { repository_full_name: 'example/repo', issue_number: 7 },
|
|
151
181
|
}, stateHome);
|
|
152
|
-
assert.strictEqual(
|
|
182
|
+
assert.strictEqual(denied.length, 1);
|
|
183
|
+
assert.strictEqual(denied[0].status, 2, 'the independent Codex action gate still blocks a destructive MCP action');
|
|
184
|
+
assert.match(denied[0].stderr, /no Harness-verified ask-style decision path/);
|
|
153
185
|
|
|
154
186
|
const subagentStart = runHook('hooks/scripts/subagent-start.js', {
|
|
155
187
|
hook_event_name: 'SubagentStart',
|
|
@@ -11,7 +11,6 @@ function read(rel) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// #273: Fable replan counts are advisory, never execution hard-stops.
|
|
14
|
-
// Only repeated same-signature failures invoke mandatory Rule-of-3 reflection.
|
|
15
14
|
for (const [canonical, packaged] of [
|
|
16
15
|
['fable-mode/SKILL.md', 'plugins/harness-everything/skills/fable-mode/SKILL.md'],
|
|
17
16
|
['fable-mode/fable-opus/SKILL.md', 'plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md'],
|
|
@@ -23,7 +22,6 @@ for (const [canonical, packaged] of [
|
|
|
23
22
|
? read('fable-mode/references/execution-phases.md') : '';
|
|
24
23
|
const contract = body + '\n' + phases;
|
|
25
24
|
assert.ok(/advisory replan|replans are advisory/i.test(contract), canonical + ' must describe replans as advisory');
|
|
26
|
-
assert.ok(/Rule-of-3/i.test(contract), canonical + ' must preserve same-signature failure reflection');
|
|
27
25
|
assert.ok(!/at most two (?:full )?replans/i.test(body), canonical + ' must not imply a two-replan hard cap');
|
|
28
26
|
}
|
|
29
27
|
for (const rel of [
|
|
@@ -38,12 +36,11 @@ assert.ok(/maxReplans[\s\S]{0,60}is advisory/i.test(orchestratorContract), 'orch
|
|
|
38
36
|
assert.ok(/do not block execution/i.test(orchestratorContract), 'orchestrator does not block on replan count');
|
|
39
37
|
|
|
40
38
|
// #275: build divergence is a diagnostic signal, not a second hard-stop.
|
|
41
|
-
//
|
|
39
|
+
// Divergent build state remains diagnostic guidance, not a hard stop.
|
|
42
40
|
const fableDiscipline = read('fable-discipline/SKILL.md');
|
|
43
41
|
assert.strictEqual(read('plugins/harness-everything/skills/fable-discipline/SKILL.md'), fableDiscipline, 'fable-discipline packaged contract matches canonical');
|
|
44
42
|
assert.ok(/divergence is a warning signal/i.test(fableDiscipline), 'fable-discipline must classify divergence as warning guidance');
|
|
45
43
|
assert.ok(/does not hard-stop execution/i.test(fableDiscipline), 'divergence must not create an independent hard stop');
|
|
46
|
-
assert.ok(/Rule-of-3 owns mandatory reflection/i.test(fableDiscipline), 'Rule-of-3 remains the mandatory reflection owner');
|
|
47
44
|
assert.ok(!/HALTS execution immediately/i.test(fableDiscipline), 'fable-discipline must not retain the divergent-build hard halt');
|
|
48
45
|
assert.ok(!/If build errors diverge, HALT/i.test(fableDiscipline), 'fable-discipline must not issue an immediate divergence halt');
|
|
49
46
|
|
|
@@ -107,7 +104,6 @@ assert.ok(!/Trigger: Commit Request \/ Task Complete/i.test(gitCommitFlow), 'tas
|
|
|
107
104
|
|
|
108
105
|
// #275 reference surface must agree with the non-blocking divergence contract.
|
|
109
106
|
assert.ok(/divergence alone is not a hard stop/i.test(fableDisciplineRules), 'fable reference keeps divergence advisory');
|
|
110
|
-
assert.ok(/Mandatory reflection remains owned by Rule-of-3/i.test(fableDisciplineRules), 'fable reference keeps Rule-of-3 as reflection owner');
|
|
111
107
|
assert.ok(!/HALT EXECUTION IMMEDIATELY/i.test(fableDisciplineRules), 'fable reference must not retain the old divergence hard halt');
|
|
112
108
|
const fableWorkflow = read('docs/workflows/fable-discipline.md');
|
|
113
109
|
const gitWorkflow = read('docs/workflows/git-commit.md');
|
|
@@ -61,54 +61,61 @@ const { buildReport } = require(path.join(ROOT, 'telemetry/scripts/report.js'));
|
|
|
61
61
|
console.log('=== #141 Self-Evolve Closed Loop Phase 1-4 Mechanism ===');
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
-
const tracker = path.join(ROOT, 'hooks/scripts/rule-of-3-tracker.js');
|
|
65
64
|
const ruleSession = 'lesson-rule-session';
|
|
66
65
|
const ruleSessionDir = getSessionDir(workspace, ruleSession);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
const legacyCandidateId = `lesson-${'a'.repeat(24)}`;
|
|
67
|
+
const candidateDir = path.join(ruleSessionDir, 'learning-candidates');
|
|
68
|
+
const timestamp = new Date().toISOString();
|
|
69
|
+
fs.mkdirSync(candidateDir, { recursive: true });
|
|
70
|
+
fs.writeFileSync(path.join(candidateDir, `${legacyCandidateId}.json`), JSON.stringify({
|
|
71
|
+
schemaVersion: 1,
|
|
72
|
+
candidateId: legacyCandidateId,
|
|
73
|
+
contentHash: null,
|
|
74
|
+
state: 'proposed',
|
|
75
|
+
trigger: {
|
|
76
|
+
type: 'rule-of-3-recovery',
|
|
77
|
+
reasonCodes: ['repeated-failure', 'zoom-out-completed', 'verified-subsequent-success'],
|
|
78
|
+
sourceEventIds: ['legacy-trip', 'legacy-success'],
|
|
79
|
+
evidenceClass: 'runtime-recovery',
|
|
80
|
+
},
|
|
81
|
+
provenance: { sessionId: ruleSession, workflowId: null, runId: null, strategy: null },
|
|
82
|
+
evidence: { failureSignature: 'legacy-signature', failureCategory: 'test', zoomOutCycles: 1, recovered: true },
|
|
83
|
+
generalizedRule: null,
|
|
84
|
+
scope: { task: null, requirement: null, role: null },
|
|
85
|
+
screening: null,
|
|
86
|
+
evaluation: null,
|
|
87
|
+
persistence: null,
|
|
88
|
+
outcome: null,
|
|
89
|
+
history: [],
|
|
90
|
+
createdAt: timestamp,
|
|
91
|
+
updatedAt: timestamp,
|
|
75
92
|
}, null, 2));
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
tool_name: 'Bash',
|
|
80
|
-
tool_use_id: 'recovery-tool-1',
|
|
81
|
-
session_id: ruleSession,
|
|
82
|
-
cwd: workspace,
|
|
83
|
-
tool_input: { command: 'node secret-command-should-not-be-retained.js' },
|
|
84
|
-
tool_response: { exitCode: 0, stdout: 'SECRET_OUTPUT_SHOULD_NOT_BE_RETAINED' },
|
|
85
|
-
});
|
|
86
|
-
check(recovered.status === 0, 'Rule-of-3 recovery tracker stays non-blocking', recovered.stderr);
|
|
87
|
-
|
|
88
|
-
const ruleCandidates = listCandidates({ workspace, sessionId: ruleSession });
|
|
89
|
-
check(ruleCandidates.length === 1, 'zoom-out followed by confirmed success emits one lesson candidate');
|
|
90
|
-
const ruleCandidate = ruleCandidates[0];
|
|
91
|
-
check(ruleCandidate.state === 'proposed' && ruleCandidate.trigger.type === 'rule-of-3-recovery', 'runtime recovery enters observed -> proposed lifecycle');
|
|
92
|
-
const serializedRule = JSON.stringify(ruleCandidate);
|
|
93
|
-
check(!serializedRule.includes('secret-command-should-not-be-retained') && !serializedRule.includes('SECRET_OUTPUT_SHOULD_NOT_BE_RETAINED'), 'runtime candidate excludes raw command/output contents');
|
|
94
|
-
check(!fs.existsSync(path.join(workspace, 'memories', 'repo')), 'automatic opportunity detection never mutates durable memory');
|
|
95
|
-
|
|
96
|
-
const ruleEvaluation = evaluateCandidate({
|
|
93
|
+
const legacyCandidate = loadCandidate({ workspace, sessionId: ruleSession, candidateId: legacyCandidateId }).candidate;
|
|
94
|
+
check(legacyCandidate.trigger.type === 'rule-of-3-recovery', 'historical recovery candidate remains readable');
|
|
95
|
+
const legacyEvaluation = evaluateCandidate({
|
|
97
96
|
workspace,
|
|
98
97
|
sessionId: ruleSession,
|
|
99
|
-
candidateId:
|
|
98
|
+
candidateId: legacyCandidateId,
|
|
100
99
|
rule: 'Always verify recovery.test.js after changing retry strategy',
|
|
101
100
|
scopeTask: 'retry recovery',
|
|
102
101
|
scopeRole: 'coordinator',
|
|
103
102
|
}).candidate;
|
|
104
|
-
check(
|
|
105
|
-
check(
|
|
103
|
+
check(legacyEvaluation.state === 'inconclusive', 'historical linear recovery remains non-replayable');
|
|
104
|
+
check(legacyEvaluation.evaluation.replayable === false && legacyEvaluation.evaluation.improvementClaim === false,
|
|
105
|
+
'historical recovery cannot claim counterfactual replay or improvement');
|
|
106
106
|
expectThrow(() => promoteCandidate({
|
|
107
107
|
workspace,
|
|
108
108
|
sessionId: ruleSession,
|
|
109
|
-
candidateId:
|
|
109
|
+
candidateId: legacyCandidateId,
|
|
110
110
|
authorization: 'forged',
|
|
111
|
-
}), /only accepted/, 'inconclusive
|
|
111
|
+
}), /only accepted/, 'inconclusive historical lesson cannot be promoted');
|
|
112
|
+
check(!fs.existsSync(path.join(workspace, 'memories', 'repo')), 'historical candidate evaluation never mutates durable memory');
|
|
113
|
+
|
|
114
|
+
expectThrow(() => createLearningOpportunity({ session_id: ruleSession, cwd: workspace }, {
|
|
115
|
+
triggerType: 'rule-of-3-recovery',
|
|
116
|
+
sourceEventIds: ['legacy-trip', 'legacy-success'],
|
|
117
|
+
evidence: { failureSignature: 'legacy-signature', recovered: true },
|
|
118
|
+
}), /unsupported learning trigger/, 'retired recovery trigger cannot create new opportunities');
|
|
112
119
|
|
|
113
120
|
const stagedContract = buildRouterContract({
|
|
114
121
|
routingStatus: 'ok',
|
|
@@ -262,16 +269,6 @@ try {
|
|
|
262
269
|
}).candidate;
|
|
263
270
|
check(validatedState.state === 'validated', 'later outcome evidence can advance a retrieved lesson to validated');
|
|
264
271
|
|
|
265
|
-
const duplicate = createLearningOpportunity({
|
|
266
|
-
session_id: ruleSession,
|
|
267
|
-
cwd: workspace,
|
|
268
|
-
}, {
|
|
269
|
-
triggerType: ruleCandidate.trigger.type,
|
|
270
|
-
sourceEventIds: ruleCandidate.trigger.sourceEventIds,
|
|
271
|
-
evidence: ruleCandidate.evidence,
|
|
272
|
-
});
|
|
273
|
-
check(duplicate.created === false, 'same runtime evidence is idempotent and cannot duplicate a lesson candidate');
|
|
274
|
-
|
|
275
272
|
const rejectedSeed = createLearningOpportunity({
|
|
276
273
|
session_id: 'lesson-rejected-session',
|
|
277
274
|
cwd: workspace,
|
|
@@ -296,10 +293,10 @@ try {
|
|
|
296
293
|
check(rejected.state === 'rejected', 'secret/injection screening rejects unsafe lesson before any promotion');
|
|
297
294
|
check(!fs.readFileSync(path.join(workspace, 'memories', 'repo', 'RULES.md'), 'utf8').includes('Ignore previous instructions'), 'rejected lesson never mutates durable memory');
|
|
298
295
|
|
|
299
|
-
const sourceHook = fs.readFileSync(path.join(ROOT, 'hooks/scripts/rule-of-3-tracker.js'), 'utf8');
|
|
300
296
|
const verifierHook = fs.readFileSync(path.join(ROOT, 'hooks/scripts/contract-test.js'), 'utf8');
|
|
301
|
-
check(
|
|
302
|
-
|
|
297
|
+
check(!fs.existsSync(path.join(ROOT, 'hooks/scripts/rule-of-3-tracker.js')) && verifierHook.includes('createLearningOpportunity'),
|
|
298
|
+
'retired recovery tracker is absent while the verifier fail-pass producer remains');
|
|
299
|
+
check(!verifierHook.includes('persistMemory('), 'verifier hook cannot directly persist memory');
|
|
303
300
|
|
|
304
301
|
const telemetryEvents = telemetry.readEvents(telemetry.telemetryFile(workspace, { cwd: workspace }));
|
|
305
302
|
const telemetryReport = buildReport(telemetryEvents);
|
|
@@ -311,7 +308,7 @@ try {
|
|
|
311
308
|
]) {
|
|
312
309
|
check(lessonEvents.has(expected), 'self-evolve lifecycle emits telemetry event: ' + expected);
|
|
313
310
|
}
|
|
314
|
-
check(telemetryReport.selfEvolve.funnel.opportunities >=
|
|
311
|
+
check(telemetryReport.selfEvolve.funnel.opportunities >= 2 &&
|
|
315
312
|
telemetryReport.selfEvolve.funnel.accepted >= 1 &&
|
|
316
313
|
telemetryReport.selfEvolve.funnel.inconclusive >= 1 &&
|
|
317
314
|
telemetryReport.selfEvolve.funnel.rejected >= 1 &&
|
|
@@ -326,11 +323,14 @@ try {
|
|
|
326
323
|
'lesson telemetry excludes generalized rules, evidence refs, and raw runtime output');
|
|
327
324
|
|
|
328
325
|
const lessonSchema = JSON.parse(fs.readFileSync(path.join(ROOT, 'self-evolve/schemas/lesson-candidate.schema.json'), 'utf8'));
|
|
329
|
-
check(lessonSchema.properties?.state?.enum?.includes('inconclusive') &&
|
|
326
|
+
check(lessonSchema.properties?.state?.enum?.includes('inconclusive') &&
|
|
327
|
+
lessonSchema.properties?.trigger?.properties?.type?.enum?.includes('verifier-fail-pass') &&
|
|
328
|
+
lessonSchema.properties?.trigger?.properties?.type?.enum?.includes('rule-of-3-recovery') &&
|
|
329
|
+
lessonSchema.properties?.trigger?.properties?.type?.description?.includes('historical candidates'),
|
|
330
|
+
'versioned lesson schema retains historical triggers while supporting verifier fail-pass');
|
|
330
331
|
|
|
331
332
|
for (const [canonical, mirror] of [
|
|
332
333
|
['hooks/scripts/lib/learning-opportunity.js', 'plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js'],
|
|
333
|
-
['hooks/scripts/rule-of-3-tracker.js', 'plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js'],
|
|
334
334
|
['hooks/scripts/contract-test.js', 'plugins/harness-everything/hooks/scripts/contract-test.js'],
|
|
335
335
|
['self-evolve/scripts/lesson-candidate.js', 'plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js'],
|
|
336
336
|
['multi-agent-workspace/scripts/index_memory.js', 'plugins/harness-everything/skills/multi-agent-workspace/scripts/index_memory.js'],
|
|
@@ -7,7 +7,7 @@ let failed=0;
|
|
|
7
7
|
function check(c,m){if(c)console.log(' PASS '+m);else{console.error(' FAIL '+m);failed++;}}
|
|
8
8
|
function runNode(args){return spawnSync(process.execPath,args,{cwd:ROOT,encoding:'utf8'});}
|
|
9
9
|
console.log('=== Workflow Guidance Contract ===');
|
|
10
|
-
for(const rel of ['harness-everything/scripts/kernel-router.js','hooks/scripts/workflow-gate.js','hooks/scripts/workflow-stop-gate.js','hooks/scripts/workflow-disposition.js','hooks/scripts/state-persist.js'
|
|
10
|
+
for(const rel of ['harness-everything/scripts/kernel-router.js','hooks/scripts/workflow-gate.js','hooks/scripts/workflow-stop-gate.js','hooks/scripts/workflow-disposition.js','hooks/scripts/state-persist.js'])check(runNode(['--check',path.join(ROOT,rel)]).status===0,rel+' parses as valid JavaScript');
|
|
11
11
|
const ctx={workflow:{workflowPlan:{limits:{maxIterations:8,maxRevisionRounds:2,maxReplans:2,maxWorkers:4}}}};
|
|
12
12
|
for(const type of ['iteration','revision','replan','worker-acquire'])check(runtime.recordBudgetEvent(ctx,type,{evidence:'fixture'}).advisory===true,type+' remains a MAY planning hint rather than blocking');
|
|
13
13
|
check(runtime.mutationProbeReservations(ctx)===0,'mutation probes reserve no capacity');
|
|
@@ -20,15 +20,12 @@ check(!rs.includes('budget-exhausted'),'runtime contains no budget-exhausted tra
|
|
|
20
20
|
const gs=fs.readFileSync(path.join(ROOT,'hooks/scripts/workflow-gate.js'),'utf8');
|
|
21
21
|
check(!gs.includes('registerMutationProbe')&&!gs.includes('recordBudgetEvent'),'workflow gate has no probe/budget enforcement');
|
|
22
22
|
check(gs.includes('[Workflow Reminder]'),'workflow gate emits reminders');
|
|
23
|
-
const r3=fs.readFileSync(path.join(ROOT,'hooks/scripts/rule-of-3.js'),'utf8');
|
|
24
|
-
check(r3.includes('state.count >= 3'),'Rule of 3 uses fixed third-failure boundary');
|
|
25
|
-
check(!r3.includes('blockForHumanDecision'),'Rule of 3 has no second-stage permanent hard lock');
|
|
26
|
-
const tr=fs.readFileSync(path.join(ROOT,'hooks/scripts/rule-of-3-tracker.js'),'utf8');
|
|
27
|
-
check(!tr.includes('threshold = 2')&&!tr.includes('threshold = 4'),'Rule of 3 has no category-specific thresholds');
|
|
28
23
|
const oc=fs.readFileSync(path.join(ROOT,'opencode-plugin/index.mjs'),'utf8');
|
|
29
24
|
check(!oc.includes('action: "hard_lock"'),'OpenCode has no permanent hard-lock action');
|
|
30
25
|
const hk=JSON.parse(fs.readFileSync(path.join(ROOT,'hooks/hooks.json'),'utf8'));
|
|
31
26
|
check(!hk.hooks.PermissionDenied,'obsolete mutation-probe PermissionDenied hook is removed');
|
|
27
|
+
check(!JSON.stringify(hk.hooks).match(/rule-of-3(?:-tracker)?\.js|reset-circuit-breaker\.js/), 'Claude hook registrations contain no retired breaker entry point');
|
|
28
|
+
for(const rel of ['hooks/scripts/rule-of-3.js','hooks/scripts/rule-of-3-tracker.js','hooks/scripts/reset-circuit-breaker.js'])check(!fs.existsSync(path.join(ROOT,rel)),rel+' is retired');
|
|
32
29
|
|
|
33
30
|
const freshnessRoot=fs.mkdtempSync(path.join(os.tmpdir(),'harness-fable-freshness-'));
|
|
34
31
|
try{
|
package/docker-verify.sh
CHANGED
|
@@ -25,123 +25,7 @@ npm test
|
|
|
25
25
|
# 3. Mechanism Checks (from VERIFICATION.md Section 2)
|
|
26
26
|
echo -e "\n[Step 3] Running Mechanism Checks..."
|
|
27
27
|
|
|
28
|
-
# 3a. Rule of 3 Circuit Breaker actually blocks
|
|
29
|
-
# Runtime state is resolved once through the same workspace-keyed helper used by
|
|
30
|
-
# the hooks. Invocations with no session_id use the fixed default session.
|
|
31
28
|
STATE_DIR=$(node -e "process.stdout.write(require('./hooks/scripts/lib/harness-state').getSessionDir(null, 'default'))")
|
|
32
|
-
echo -e "\n---> Running 3a: Rule of 3 Circuit Breaker"
|
|
33
|
-
rm -f "$STATE_DIR/zoom-out-report.md"
|
|
34
|
-
echo '{"count":3,"lastHash":"verify-test","zoomOutResolved":false}' > "$STATE_DIR/rule-of-3-state.json"
|
|
35
|
-
|
|
36
|
-
# We expect this to exit with 2 and print CRITICAL trigger message
|
|
37
|
-
set +e
|
|
38
|
-
node hooks/scripts/rule-of-3.js 2>rule-of-3-err.log
|
|
39
|
-
EXIT_CODE=$?
|
|
40
|
-
set -e
|
|
41
|
-
|
|
42
|
-
echo "Exit code: $EXIT_CODE"
|
|
43
|
-
if [ "$EXIT_CODE" -ne 2 ]; then
|
|
44
|
-
echo "❌ FAIL: Rule of 3 did not exit with code 2 (got $EXIT_CODE)"
|
|
45
|
-
exit 1
|
|
46
|
-
fi
|
|
47
|
-
|
|
48
|
-
if ! grep -q "RULE OF 3 CIRCUIT BREAKER TRIGGERED" rule-of-3-err.log; then
|
|
49
|
-
echo "❌ FAIL: Rule of 3 error output did not contain trigger message"
|
|
50
|
-
cat rule-of-3-err.log
|
|
51
|
-
exit 1
|
|
52
|
-
fi
|
|
53
|
-
echo "✅ PASS: Rule of 3 blocked successfully with exit code 2 and correct message."
|
|
54
|
-
|
|
55
|
-
# Reset Rule of 3
|
|
56
|
-
echo "Resetting circuit breaker..."
|
|
57
|
-
npm run harness:reset
|
|
58
|
-
set +e
|
|
59
|
-
node hooks/scripts/rule-of-3.js
|
|
60
|
-
EXIT_CODE=$?
|
|
61
|
-
set -e
|
|
62
|
-
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
63
|
-
echo "❌ FAIL: Rule of 3 reset check failed (expected 0, got $EXIT_CODE)"
|
|
64
|
-
exit 1
|
|
65
|
-
fi
|
|
66
|
-
echo "✅ PASS: Rule of 3 reset check passed."
|
|
67
|
-
|
|
68
|
-
# 3a-bis. Zoom-out reflection report releases the breaker (self-recovery path)
|
|
69
|
-
echo -e "\n---> Running 3a-bis: Zoom-out report releases the breaker"
|
|
70
|
-
echo '{"count":3,"lastHash":"verify-test","zoomOutResolved":false,"lastFailureAt":0,"zoomOutCycles":0}' > "$STATE_DIR/rule-of-3-state.json"
|
|
71
|
-
printf '## Goal\nx\n## Failed Attempts\nx\n## Verified Facts\nx\n## Diagnosis\nx\n## Decision\nRESUME: new approach\n' > "$STATE_DIR/zoom-out-report.md"
|
|
72
|
-
|
|
73
|
-
set +e
|
|
74
|
-
node hooks/scripts/rule-of-3.js
|
|
75
|
-
EXIT_CODE=$?
|
|
76
|
-
set -e
|
|
77
|
-
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
78
|
-
echo "❌ FAIL: Valid reflection report did not release the breaker (expected 0, got $EXIT_CODE)"
|
|
79
|
-
exit 1
|
|
80
|
-
fi
|
|
81
|
-
if ! node -e "const s=require(process.argv[1]); process.exit(s.count===0 && s.zoomOutResolved===true && s.zoomOutCycles===1 ? 0 : 1)" "$STATE_DIR/rule-of-3-state.json"; then
|
|
82
|
-
echo "❌ FAIL: Breaker state not updated after report release"
|
|
83
|
-
cat "$STATE_DIR/rule-of-3-state.json"
|
|
84
|
-
exit 1
|
|
85
|
-
fi
|
|
86
|
-
echo "✅ PASS: Valid reflection report released the breaker (self-recovery)."
|
|
87
|
-
|
|
88
|
-
# 3a-ter. Re-trip: three more failures on the same signature after a released
|
|
89
|
-
# cycle ask for ANOTHER zoom-out. #190 retired the second-stage escalation, so
|
|
90
|
-
# the contract is exit 2 plus the reflection-required message the hook actually
|
|
91
|
-
# prints - never a permanent lock (ci/mechanism-2a-rule-of-3.test.js:58-64).
|
|
92
|
-
echo -e "\n---> Running 3a-ter: Re-trip requests another zoom-out"
|
|
93
|
-
# Seed through the hooks' own resolver in the already resolved workspace-keyed
|
|
94
|
-
# state root.
|
|
95
|
-
RETRIP_AT=$(node -e "process.stdout.write(String(Date.now()))")
|
|
96
|
-
node -e "require('fs').writeFileSync(process.argv[1], JSON.stringify({count:3,lastHash:'verify-test',zoomOutResolved:false,lastFailureAt:Number(process.argv[2]),zoomOutCycles:1}))" "$STATE_DIR/rule-of-3-state.json" "$RETRIP_AT"
|
|
97
|
-
set +e
|
|
98
|
-
node hooks/scripts/rule-of-3.js 2>rule-of-3-err.log
|
|
99
|
-
EXIT_CODE=$?
|
|
100
|
-
set -e
|
|
101
|
-
if [ "$EXIT_CODE" -ne 2 ]; then
|
|
102
|
-
echo "❌ FAIL: Re-trip did not request another zoom-out (expected 2, got $EXIT_CODE)"
|
|
103
|
-
cat rule-of-3-err.log
|
|
104
|
-
exit 1
|
|
105
|
-
fi
|
|
106
|
-
if ! grep -q "RULE OF 3 CIRCUIT BREAKER TRIGGERED" rule-of-3-err.log; then
|
|
107
|
-
echo "❌ FAIL: Re-trip output did not contain the circuit-breaker trigger message"
|
|
108
|
-
cat rule-of-3-err.log
|
|
109
|
-
exit 1
|
|
110
|
-
fi
|
|
111
|
-
if ! grep -q "ACTION REQUIRED (reflect first)" rule-of-3-err.log; then
|
|
112
|
-
echo "❌ FAIL: Re-trip output did not demand reflection"
|
|
113
|
-
cat rule-of-3-err.log
|
|
114
|
-
exit 1
|
|
115
|
-
fi
|
|
116
|
-
# Negative guard: the retired escalation wording must never come back (#190).
|
|
117
|
-
if grep -qi "hard lock" rule-of-3-err.log; then # this must never match
|
|
118
|
-
echo "❌ FAIL: Re-trip printed the retired hard-lock escalation, which no longer exists"
|
|
119
|
-
cat rule-of-3-err.log
|
|
120
|
-
exit 1
|
|
121
|
-
fi
|
|
122
|
-
echo "✅ PASS: Re-trip asked for another zoom-out, with no retired escalation wording."
|
|
123
|
-
|
|
124
|
-
# A fresh report, written after the re-trip failure, releases the breaker again.
|
|
125
|
-
printf '## Goal\nx\n## Failed Attempts\nx\n## Verified Facts\nx\n## Diagnosis\nx\n## Decision\nRESUME: second untried approach\n' > "$STATE_DIR/zoom-out-report.md"
|
|
126
|
-
set +e
|
|
127
|
-
node hooks/scripts/rule-of-3.js
|
|
128
|
-
EXIT_CODE=$?
|
|
129
|
-
set -e
|
|
130
|
-
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
131
|
-
echo "❌ FAIL: Fresh reflection report did not release the re-tripped breaker (expected 0, got $EXIT_CODE)"
|
|
132
|
-
exit 1
|
|
133
|
-
fi
|
|
134
|
-
if ! node -e "const s=JSON.parse(require('fs').readFileSync(process.argv[1],'utf8')); process.exit(s.count===0 && s.zoomOutResolved===true && s.zoomOutCycles===2 ? 0 : 1)" "$STATE_DIR/rule-of-3-state.json"; then
|
|
135
|
-
echo "❌ FAIL: Breaker state not updated after the second report release"
|
|
136
|
-
cat "$STATE_DIR/rule-of-3-state.json"
|
|
137
|
-
exit 1
|
|
138
|
-
fi
|
|
139
|
-
echo "✅ PASS: A fresh report released the re-tripped breaker (advisory re-trip, not an escalation)."
|
|
140
|
-
|
|
141
|
-
# harness:reset stays an optional manual clear, not a required escalation step.
|
|
142
|
-
npm run harness:reset
|
|
143
|
-
|
|
144
|
-
|
|
145
29
|
# 3b. Boundary Guard blocks oversized read
|
|
146
30
|
echo -e "\n---> Running 3b: Boundary Guard Oversized Read"
|
|
147
31
|
node -e "require('fs').writeFileSync('.verify-big.tmp','x'.repeat(600*1024))"
|
|
@@ -294,7 +178,7 @@ rm -f .verify-dirty.tmp "$STATE_DIR/handoff-state.json" "$STATE_DIR/stop-gate-st
|
|
|
294
178
|
echo "✅ PASS: Stop gate bounced once, then respected the batch and loop guards."
|
|
295
179
|
|
|
296
180
|
# Clean up temporary test output logs
|
|
297
|
-
rm -f
|
|
181
|
+
rm -f boundary-guard-err.log scope-guard-err.log stop-gate-err.log
|
|
298
182
|
|
|
299
183
|
echo -e "\n================================================="
|
|
300
184
|
echo " 🎉 ALL HARNESS MECHANISM CHECKS PASSED SUCCESSFULLY!"
|