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
|
@@ -1,116 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { spawnSync } = require('node:child_process');
|
|
3
7
|
const helper = require('./test-helper');
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(helper.root, 'hooks/hooks.json'), 'utf8'));
|
|
10
|
+
const retiredIds = new Set([
|
|
11
|
+
'harness:pre:rule-of-3',
|
|
12
|
+
'harness:post:rule-of-3-tracker',
|
|
13
|
+
'harness:post-failure:rule-of-3-tracker',
|
|
14
|
+
]);
|
|
15
|
+
const entries = Object.entries(manifest.hooks).flatMap(([event, groups]) =>
|
|
16
|
+
groups.map(group => ({ event, ...group })));
|
|
17
|
+
const retiredFiles = [
|
|
18
|
+
'hooks/scripts/rule-of-3.js',
|
|
19
|
+
'hooks/scripts/rule-of-3-tracker.js',
|
|
20
|
+
'hooks/scripts/reset-circuit-breaker.js',
|
|
21
|
+
];
|
|
22
|
+
const registeredRetired = entries.filter(entry => retiredIds.has(entry.id) ||
|
|
23
|
+
(entry.hooks || []).some(hook => /(?:rule-of-3(?:-tracker)?|reset-circuit-breaker)\.js/.test(hook.command)));
|
|
6
24
|
|
|
7
|
-
const hooksConfig = JSON.parse(fs.readFileSync(path.join(helper.root, 'hooks', 'hooks.json'), 'utf8'));
|
|
8
|
-
const preRuleHook = (hooksConfig.hooks.PreToolUse || []).find(entry => entry.id === 'harness:pre:rule-of-3');
|
|
9
|
-
const successTrackerHook = (hooksConfig.hooks.PostToolUse || []).find(entry => entry.id === 'harness:post:rule-of-3-tracker');
|
|
10
|
-
const failureTrackerHook = (hooksConfig.hooks.PostToolUseFailure || []).find(entry => entry.id === 'harness:post-failure:rule-of-3-tracker');
|
|
11
|
-
const matcherHas = (entry, tool) => Boolean(entry && String(entry.matcher || '').split('|').includes(tool));
|
|
12
|
-
helper.check(
|
|
13
|
-
'2a-wiring. PostToolUseFailure invokes the Rule-of-3 tracker',
|
|
14
|
-
matcherHas(failureTrackerHook, 'Bash') && matcherHas(failureTrackerHook, 'PowerShell') &&
|
|
15
|
-
matcherHas(failureTrackerHook, 'apply_patch') &&
|
|
16
|
-
failureTrackerHook.hooks?.some(hook => hook.command.includes('rule-of-3-tracker.js')),
|
|
17
|
-
JSON.stringify(failureTrackerHook)
|
|
18
|
-
);
|
|
19
25
|
helper.check(
|
|
20
|
-
'2a-wiring.
|
|
21
|
-
|
|
22
|
-
JSON.stringify(
|
|
26
|
+
'2a-retirement.wiring. Claude registers no retired blocker, tracker, or reset entry',
|
|
27
|
+
registeredRetired.length === 0,
|
|
28
|
+
JSON.stringify(registeredRetired)
|
|
23
29
|
);
|
|
30
|
+
for (const relative of retiredFiles) {
|
|
31
|
+
helper.check(`2a-retirement.file. ${relative} is retired`, !fs.existsSync(path.join(helper.root, relative)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function runRegisteredRuleHook(event, payload) {
|
|
35
|
+
const entry = entries.find(candidate => candidate.event === event && retiredIds.has(candidate.id));
|
|
36
|
+
if (!entry) return [];
|
|
37
|
+
return (entry.hooks || []).map(hook => {
|
|
38
|
+
const relative = hook.command.match(/\$\{CLAUDE_PLUGIN_ROOT\}\/([^" ]+)/)?.[1];
|
|
39
|
+
if (!relative) return { status: 1, stderr: `unrecognized hook command: ${hook.command}` };
|
|
40
|
+
return spawnSync(process.execPath, [path.join(helper.root, relative)], {
|
|
41
|
+
cwd: helper.root,
|
|
42
|
+
input: JSON.stringify({ cwd: helper.root, session_id: helper.SESSION_ID, ...payload }),
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
env: process.env,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function permittedToolCall() {
|
|
50
|
+
return spawnSync(process.execPath, ['-e', 'process.stdout.write("permitted")'], {
|
|
51
|
+
cwd: helper.root,
|
|
52
|
+
encoding: 'utf8',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const stateFile = path.join(helper.sessionDir, 'rule-of-3-state.json');
|
|
57
|
+
const reportFile = path.join(helper.sessionDir, 'zoom-out-report.md');
|
|
58
|
+
const oldState = { count: 3, lastHash: 'legacy-trip', zoomOutResolved: false, lastFailureAt: 123, zoomOutCycles: 0 };
|
|
59
|
+
const note = 'agent-authored recovery note\n';
|
|
24
60
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
session_id: helper.SESSION_ID,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
helper.writeState('rule-of-3-state.json', oldState);
|
|
62
|
+
fs.writeFileSync(reportFile, note, 'utf8');
|
|
63
|
+
helper.writeState('subagent-scope-state.json', { old: true });
|
|
64
|
+
const bootstrap = spawnSync(process.execPath, [path.join(helper.root, 'harness-everything/scripts/bootstrap.js')], {
|
|
65
|
+
cwd: helper.root,
|
|
66
|
+
input: JSON.stringify({ hook_event_name: 'SessionStart', cwd: helper.root, session_id: helper.SESSION_ID }),
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
env: process.env,
|
|
69
|
+
});
|
|
70
|
+
helper.check('2a-retirement.bootstrap. startup completes', bootstrap.status === 0, bootstrap.stderr);
|
|
34
71
|
helper.check(
|
|
35
|
-
'2a-
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
'2a-retirement.bootstrap. legacy breaker state and optional agent note remain intact',
|
|
73
|
+
fs.existsSync(stateFile) && fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) &&
|
|
74
|
+
fs.existsSync(reportFile) && fs.readFileSync(reportFile, 'utf8') === note
|
|
38
75
|
);
|
|
39
|
-
|
|
40
|
-
const trip = helper.runHook('rule-of-3.js', { hook_event_name: 'PreToolUse', tool_name: 'Bash', session_id: helper.SESSION_ID });
|
|
41
76
|
helper.check(
|
|
42
|
-
'2a-
|
|
43
|
-
|
|
44
|
-
trip.stderr
|
|
77
|
+
'2a-retirement.bootstrap. unrelated subagent scope baseline still resets',
|
|
78
|
+
!fs.existsSync(path.join(helper.sessionDir, 'subagent-scope-state.json'))
|
|
45
79
|
);
|
|
46
|
-
|
|
47
|
-
helper.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
state = helper.readState('rule-of-3-state.json');
|
|
80
|
+
helper.writeState('subagent-scope-state.json', { old: true });
|
|
81
|
+
const startup = helper.runHook('openai-session-start.js', {
|
|
82
|
+
hook_event_name: 'SessionStart', cwd: helper.root, session_id: helper.SESSION_ID,
|
|
83
|
+
});
|
|
84
|
+
helper.check('2a-retirement.startup. Codex startup completes', startup.code === 0, startup.stderr);
|
|
52
85
|
helper.check(
|
|
53
|
-
'2a-
|
|
54
|
-
|
|
55
|
-
|
|
86
|
+
'2a-retirement.startup. legacy breaker state and optional agent note remain intact',
|
|
87
|
+
fs.existsSync(stateFile) && fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) &&
|
|
88
|
+
fs.existsSync(reportFile) && fs.readFileSync(reportFile, 'utf8') === note
|
|
56
89
|
);
|
|
57
|
-
|
|
58
|
-
helper.writeState('rule-of-3-state.json', { count: 3, lastHash: 'mech-test', zoomOutResolved: false, lastFailureAt: Date.now() + 60000, zoomOutCycles: 1 });
|
|
59
|
-
const retrip = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
60
90
|
helper.check(
|
|
61
|
-
'2a-
|
|
62
|
-
|
|
63
|
-
retrip.stderr
|
|
91
|
+
'2a-retirement.startup. unrelated subagent scope baseline still resets',
|
|
92
|
+
!fs.existsSync(path.join(helper.sessionDir, 'subagent-scope-state.json'))
|
|
64
93
|
);
|
|
65
94
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
tool_input: { command: 'cat protected.txt' }, error: 'EACCES: permission denied, open protected.txt',
|
|
70
|
-
session_id: helper.SESSION_ID,
|
|
71
|
-
});
|
|
72
|
-
state = helper.readState('rule-of-3-state.json');
|
|
73
|
-
helper.check('2a-category. permission failures still use the same threshold of three', state.count === 2 && state.category === 'permission' && state.threshold === undefined, JSON.stringify(state));
|
|
74
|
-
const beforeThird = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
75
|
-
helper.check('2a-category-two. two permission failures do not trip early', beforeThird.code === 0, beforeThird.stderr);
|
|
76
|
-
helper.runHook('rule-of-3-tracker.js', {
|
|
77
|
-
hook_event_name: 'PostToolUseFailure', tool_name: 'Bash',
|
|
78
|
-
tool_input: { command: 'cat protected.txt' }, error: 'EACCES: permission denied, open protected.txt',
|
|
79
|
-
session_id: helper.SESSION_ID,
|
|
80
|
-
});
|
|
81
|
-
const third = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
82
|
-
helper.check('2a-category-three. third permission failure trips normally', third.code === 2, third.stderr);
|
|
95
|
+
for (const legacyState of [false, true]) {
|
|
96
|
+
if (fs.existsSync(stateFile)) fs.unlinkSync(stateFile);
|
|
97
|
+
if (legacyState) helper.writeState('rule-of-3-state.json', oldState);
|
|
83
98
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
helper.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
tool_name: 'Bash',
|
|
109
|
-
tool_input: { command: 'node flaky.js' },
|
|
110
|
-
tool_response: { exitCode: 0, stdout: 'recovered' },
|
|
111
|
-
session_id: helper.SESSION_ID,
|
|
99
|
+
const pre = runRegisteredRuleHook('PreToolUse', {
|
|
100
|
+
hook_event_name: 'PreToolUse', tool_name: 'Bash', tool_input: { command: 'node -e process.exit(0)' },
|
|
101
|
+
});
|
|
102
|
+
const call = pre.every(result => result.status === 0) ? permittedToolCall() : null;
|
|
103
|
+
const post = call && call.status === 0 ? runRegisteredRuleHook('PostToolUse', {
|
|
104
|
+
hook_event_name: 'PostToolUse', tool_name: 'Bash', tool_input: { command: 'node -e process.exit(0)' },
|
|
105
|
+
tool_response: { exitCode: 0, stdout: 'permitted' },
|
|
106
|
+
}) : [];
|
|
107
|
+
|
|
108
|
+
helper.check(
|
|
109
|
+
`2a-retirement.tool.${legacyState ? 'legacy' : 'fresh'}. otherwise-permitted tool call runs`,
|
|
110
|
+
pre.every(result => result.status === 0) && call?.status === 0 && post.every(result => result.status === 0),
|
|
111
|
+
JSON.stringify({ pre: pre.map(result => result.status), call: call?.status, post: post.map(result => result.status) })
|
|
112
|
+
);
|
|
113
|
+
helper.check(
|
|
114
|
+
`2a-retirement.tool.${legacyState ? 'legacy' : 'fresh'}. no breaker state is created`,
|
|
115
|
+
legacyState ? fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) : !fs.existsSync(stateFile)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (fs.existsSync(stateFile)) fs.unlinkSync(stateFile);
|
|
120
|
+
const failure = runRegisteredRuleHook('PostToolUseFailure', {
|
|
121
|
+
hook_event_name: 'PostToolUseFailure', tool_name: 'Bash',
|
|
122
|
+
tool_input: { command: 'node -e process.exit(1)' }, error: 'fixture failure',
|
|
112
123
|
});
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
helper.check(
|
|
125
|
+
'2a-retirement.failure. failed tool result creates no breaker state',
|
|
126
|
+
failure.every(result => result.status === 0) && !fs.existsSync(stateFile),
|
|
127
|
+
JSON.stringify(failure.map(result => ({ status: result.status, stderr: result.stderr })))
|
|
128
|
+
);
|
|
115
129
|
|
|
116
130
|
helper.finish();
|
|
@@ -51,8 +51,8 @@ helper.check(
|
|
|
51
51
|
// packages/plugin/src/index.ts and packages/web/.../plugins.mdx in the
|
|
52
52
|
// opencode source - see opencode-plugin/README.md). Two isolations are
|
|
53
53
|
// load-bearing: HOME -> temp, because the plugin persists under
|
|
54
|
-
// ~/.agents/harness-everything/ and an un-redirected run would corrupt
|
|
55
|
-
//
|
|
54
|
+
// ~/.agents/harness-everything/ and an un-redirected run would corrupt real
|
|
55
|
+
// session state; workspace -> temp, with a
|
|
56
56
|
// package.json this test controls, so verification pass/fail is
|
|
57
57
|
// deterministic.
|
|
58
58
|
(async () => {
|
|
@@ -147,263 +147,125 @@ helper.check(
|
|
|
147
147
|
);
|
|
148
148
|
helper.check('2n. no follow-up prompt is sent when verification passes', promptCalls.length === 0, `${promptCalls.length} prompt(s) sent`);
|
|
149
149
|
|
|
150
|
-
//
|
|
150
|
+
// Repeated verification failures keep reminding but never block permitted edits.
|
|
151
151
|
writePackageScript('node -e "process.exit(1)"');
|
|
152
|
-
|
|
153
|
-
for (let i = 1; i <=
|
|
152
|
+
const editAllowedAfterFailures = [];
|
|
153
|
+
for (let i = 1; i <= 4; i++) {
|
|
154
|
+
let allowed = true;
|
|
155
|
+
try {
|
|
156
|
+
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 's1', callID: `retry-${i}` }, { args: {} });
|
|
157
|
+
} catch {
|
|
158
|
+
allowed = false;
|
|
159
|
+
}
|
|
160
|
+
editAllowedAfterFailures.push(allowed);
|
|
161
|
+
if (!allowed) break;
|
|
154
162
|
await hooks['tool.execute.after']({ tool: 'edit', sessionID: 's1', callID: `c${i + 1}` }, { title: '', output: '', metadata: {} });
|
|
155
163
|
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's1' } } });
|
|
156
164
|
}
|
|
157
|
-
let breaker = JSON.parse(fs.readFileSync(breakerFile, 'utf8'));
|
|
158
|
-
const sig = Object.keys(breaker.failures)[0];
|
|
159
165
|
helper.check(
|
|
160
|
-
'2n.
|
|
161
|
-
|
|
162
|
-
JSON.stringify(
|
|
166
|
+
'2n. four edits proceed through repeated failures, including beyond the former threshold',
|
|
167
|
+
editAllowedAfterFailures.every(Boolean),
|
|
168
|
+
JSON.stringify(editAllowedAfterFailures)
|
|
163
169
|
);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// 3rd failure -> force reflection
|
|
167
|
-
await hooks['tool.execute.after']({ tool: 'edit', sessionID: 's1', callID: 'c4' }, { title: '', output: '', metadata: {} });
|
|
168
|
-
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's1' } } });
|
|
169
|
-
breaker = JSON.parse(fs.readFileSync(breakerFile, 'utf8'));
|
|
170
|
-
let compliance = JSON.parse(fs.readFileSync(complianceFile, 'utf8'));
|
|
170
|
+
const failurePrompts = promptCalls.map((call) => call.body.parts[0].text);
|
|
171
171
|
helper.check(
|
|
172
|
-
'2n.
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
'2n. each failed verification sends a reminder without a trip, token, or report demand',
|
|
173
|
+
failurePrompts.length === 4 && failurePrompts.every((text) => /verification failed/i.test(text)
|
|
174
|
+
&& !/reflection token|## Goal|forced reflection|retries before/i.test(text)),
|
|
175
|
+
JSON.stringify(failurePrompts)
|
|
175
176
|
);
|
|
176
177
|
helper.check(
|
|
177
|
-
'2n.
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
'2n. verification failures create no breaker file or trip counters',
|
|
179
|
+
!fs.existsSync(breakerFile)
|
|
180
|
+
&& !Object.hasOwn(JSON.parse(fs.readFileSync(complianceFile, 'utf8')), 'circuitBreakerTrips')
|
|
181
|
+
&& !Object.hasOwn(JSON.parse(fs.readFileSync(complianceFile, 'utf8')), 'reflectionsForced'),
|
|
182
|
+
fs.existsSync(breakerFile) ? fs.readFileSync(breakerFile, 'utf8') : JSON.stringify(JSON.parse(fs.readFileSync(complianceFile, 'utf8')))
|
|
180
183
|
);
|
|
181
184
|
|
|
182
|
-
let pendingEditBlocked = false;
|
|
183
|
-
try {
|
|
184
|
-
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 's1', callID: 'pending-edit' }, { args: {} });
|
|
185
|
-
} catch {
|
|
186
|
-
pendingEditBlocked = true;
|
|
187
|
-
}
|
|
188
|
-
helper.check('2n. pending reflection blocks another code edit', pendingEditBlocked, 'tool.execute.before allowed an edit before the report');
|
|
189
|
-
|
|
190
185
|
let pendingReadAllowed = true;
|
|
191
186
|
try {
|
|
192
187
|
await hooks['tool.execute.before']({ tool: 'read', sessionID: 's1', callID: 'pending-read' }, { args: {} });
|
|
193
188
|
} catch {
|
|
194
189
|
pendingReadAllowed = false;
|
|
195
190
|
}
|
|
196
|
-
helper.check('2n.
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
reflectionFile,
|
|
208
|
-
`RESUME: misplaced\n## Goal\nfix the fixture\n## Failed Attempts\nthree retries\n## Verified Facts\ntest remains red\n## Diagnosis\nthe fixture intentionally fails\n## Decision\nA decision without a directive\nReflection token: ${reflectionToken}\n`,
|
|
209
|
-
'utf8'
|
|
210
|
-
);
|
|
211
|
-
await hooks['tool.execute.after'](
|
|
212
|
-
{ tool: 'write', sessionID: 's1', callID: 'reflection' },
|
|
213
|
-
{ title: '', output: '', metadata: {}, args: { filePath: reflectionFile } }
|
|
214
|
-
);
|
|
215
|
-
breaker = JSON.parse(fs.readFileSync(breakerFile, 'utf8'));
|
|
216
|
-
helper.check(
|
|
217
|
-
'2n. a directive outside the Decision section does not complete reflection',
|
|
218
|
-
breaker.reflectionPending === true && breaker.lastReflection === null,
|
|
219
|
-
JSON.stringify(breaker)
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
fs.writeFileSync(
|
|
223
|
-
reflectionFile,
|
|
224
|
-
`## Goal\nfix the fixture\n## Failed Attempts\nthree retries\n## Verified Facts\ntest remains red\n## Diagnosis\nthe fixture intentionally fails\n## Decision\nRESUME: change the fixture\nReflection token: ${reflectionToken}\n`,
|
|
225
|
-
'utf8'
|
|
226
|
-
);
|
|
227
|
-
await hooks['tool.execute.after'](
|
|
228
|
-
{ tool: 'apply_patch', sessionID: 's1', callID: 'reflection-patch' },
|
|
229
|
-
{
|
|
230
|
-
title: '',
|
|
231
|
-
output: '',
|
|
232
|
-
metadata: {},
|
|
233
|
-
args: { patchText: `*** Begin Patch\n*** Update File: ${reflectionFile}\n@@\n*** End Patch` }
|
|
234
|
-
}
|
|
235
|
-
);
|
|
236
|
-
breaker = JSON.parse(fs.readFileSync(breakerFile, 'utf8'));
|
|
237
|
-
helper.check(
|
|
238
|
-
'2n. apply_patch reflection completes the lifecycle, resets the signature count, and persists lastReflection',
|
|
239
|
-
Number.isFinite(breaker.lastReflection) && breaker.lastReflection > 0 && breaker.reflectionPending === false && breaker.failures[sig].count === 0,
|
|
240
|
-
JSON.stringify(breaker)
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
// A repeated idle event after the follow-up is already pending is a no-op.
|
|
244
|
-
// The breaker must wait for a fresh code edit before counting another try.
|
|
245
|
-
const promptsAfterReflection = promptCalls.length;
|
|
246
|
-
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's1' } } });
|
|
247
|
-
helper.check(
|
|
248
|
-
'2n. repeated idle does not duplicate verification or follow-up prompts',
|
|
249
|
-
promptCalls.length === promptsAfterReflection,
|
|
250
|
-
`${promptCalls.length} prompt(s) sent`
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
const patchSessionDir = path.join(stateRoot, 'sessions', 'patch-only');
|
|
254
|
-
const patchBreakerFile = path.join(patchSessionDir, 'circuit-breaker.json');
|
|
255
|
-
const patchReflectionFile = path.join(patchSessionDir, 'zoom-out-report.md');
|
|
256
|
-
const patchReflectionToken = 'patch-reflection-token';
|
|
257
|
-
fs.mkdirSync(patchSessionDir, { recursive: true });
|
|
258
|
-
fs.writeFileSync(
|
|
259
|
-
patchBreakerFile,
|
|
260
|
-
JSON.stringify({
|
|
261
|
-
failures: { fixture: { count: 3, firstSeen: Date.now() - 1000 } },
|
|
262
|
-
hardLock: false,
|
|
263
|
-
lastReflection: null,
|
|
264
|
-
lastReflectionSignature: null,
|
|
265
|
-
reflectionPending: true,
|
|
266
|
-
reflectionRequestedAt: Date.now(),
|
|
267
|
-
reflectionToken: patchReflectionToken,
|
|
268
|
-
reflectionSignature: 'fixture'
|
|
269
|
-
}, null, 2),
|
|
270
|
-
'utf8'
|
|
271
|
-
);
|
|
272
|
-
fs.writeFileSync(
|
|
273
|
-
patchReflectionFile,
|
|
274
|
-
`## Goal\nfix the fixture\n## Failed Attempts\nthree retries\n## Verified Facts\ntest remains red\n## Diagnosis\nthe fixture intentionally fails\n## Decision\nRESUME: change the fixture\nReflection token: ${patchReflectionToken}\n`,
|
|
275
|
-
'utf8'
|
|
276
|
-
);
|
|
277
|
-
const patchText = `*** Begin Patch\n*** Update File: ${patchReflectionFile}\n@@\n*** End Patch`;
|
|
278
|
-
let patchBeforeAllowed = true;
|
|
191
|
+
helper.check('2n. non-edit tools remain available after repeated failures', pendingReadAllowed, 'tool.execute.before blocked a read');
|
|
192
|
+
|
|
193
|
+
const legacyPendingDir = path.join(stateRoot, 'sessions', 'legacy-pending');
|
|
194
|
+
const legacyBreakerFile = path.join(legacyPendingDir, 'circuit-breaker.json');
|
|
195
|
+
fs.mkdirSync(legacyPendingDir, { recursive: true });
|
|
196
|
+
const legacyPendingState = JSON.stringify({
|
|
197
|
+
failures: { old: { count: 3, firstSeen: 1, lastSeen: 2 } },
|
|
198
|
+
reflectionPending: true, reflectionRequestedAt: 2, reflectionToken: 'old-token', reflectionSignature: 'old'
|
|
199
|
+
}, null, 2);
|
|
200
|
+
fs.writeFileSync(legacyBreakerFile, legacyPendingState);
|
|
201
|
+
let legacyEditAllowed = true;
|
|
279
202
|
try {
|
|
280
|
-
await hooks['tool.execute.before'](
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
);
|
|
284
|
-
} catch (error) {
|
|
285
|
-
patchBeforeAllowed = false;
|
|
203
|
+
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 'legacy-pending', callID: 'legacy-edit' }, { args: {} });
|
|
204
|
+
} catch {
|
|
205
|
+
legacyEditAllowed = false;
|
|
286
206
|
}
|
|
287
207
|
helper.check(
|
|
288
|
-
'2n.
|
|
289
|
-
|
|
290
|
-
|
|
208
|
+
'2n. legacy pending reflection state stays inert and does not block an edit',
|
|
209
|
+
legacyEditAllowed && fs.readFileSync(legacyBreakerFile, 'utf8') === legacyPendingState,
|
|
210
|
+
fs.readFileSync(legacyBreakerFile, 'utf8')
|
|
291
211
|
);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const patchBreaker = JSON.parse(fs.readFileSync(patchBreakerFile, 'utf8'));
|
|
297
|
-
helper.check(
|
|
298
|
-
'2n. apply_patch output args complete a pending reflection',
|
|
299
|
-
patchBreaker.reflectionPending === false && Number.isFinite(patchBreaker.lastReflection),
|
|
300
|
-
JSON.stringify(patchBreaker)
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
const mixedPatchSessionDir = path.join(stateRoot, 'sessions', 'mixed-patch');
|
|
304
|
-
const mixedPatchBreakerFile = path.join(mixedPatchSessionDir, 'circuit-breaker.json');
|
|
305
|
-
const mixedPatchReflectionFile = path.join(mixedPatchSessionDir, 'zoom-out-report.md');
|
|
306
|
-
fs.mkdirSync(mixedPatchSessionDir, { recursive: true });
|
|
307
|
-
fs.writeFileSync(mixedPatchBreakerFile, JSON.stringify({
|
|
308
|
-
failures: { fixture: { count: 3, firstSeen: Date.now() - 1000 } },
|
|
309
|
-
hardLock: false,
|
|
310
|
-
lastReflection: null,
|
|
311
|
-
lastReflectionSignature: null,
|
|
312
|
-
reflectionPending: true,
|
|
313
|
-
reflectionRequestedAt: Date.now(),
|
|
314
|
-
reflectionToken: 'mixed-patch-token',
|
|
315
|
-
reflectionSignature: 'fixture'
|
|
316
|
-
}, null, 2));
|
|
317
|
-
fs.writeFileSync(mixedPatchReflectionFile, [
|
|
318
|
-
'## Goal', 'fix the fixture', '## Failed Attempts', 'three retries',
|
|
319
|
-
'## Verified Facts', 'test remains red', '## Diagnosis', 'the fixture intentionally fails',
|
|
320
|
-
'## Decision', 'RESUME: change the fixture', 'Reflection token: mixed-patch-token', ''
|
|
321
|
-
].join('\n'));
|
|
322
|
-
let mixedPatchBlocked = false;
|
|
323
|
-
try {
|
|
324
|
-
await hooks['tool.execute.before'](
|
|
325
|
-
{ tool: 'apply_patch', sessionID: 'mixed-patch', callID: 'mixed-before' },
|
|
326
|
-
{ args: { patchText: `*** Begin Patch\n*** Update File: ${mixedPatchReflectionFile}\n@@\n*** Update File: ${path.join(workspace, 'unrelated.js')}\n@@\n*** End Patch` } }
|
|
212
|
+
if (legacyEditAllowed) {
|
|
213
|
+
await hooks['tool.execute.after'](
|
|
214
|
+
{ tool: 'edit', sessionID: 'legacy-pending', callID: 'legacy-edit-after' },
|
|
215
|
+
{ title: '', output: '', metadata: {}, args: { filePath: path.join(workspace, 'legacy.js') } }
|
|
327
216
|
);
|
|
328
|
-
} catch {
|
|
329
|
-
mixedPatchBlocked = true;
|
|
330
217
|
}
|
|
331
|
-
helper.check('2n.
|
|
218
|
+
helper.check('2n. legacy pending state permits the full V1 edit lifecycle',
|
|
219
|
+
JSON.parse(fs.readFileSync(path.join(legacyPendingDir, 'edit-state.json'), 'utf8')).verificationPending === true,
|
|
220
|
+
path.join(legacyPendingDir, 'edit-state.json'));
|
|
332
221
|
|
|
333
|
-
// A
|
|
334
|
-
|
|
222
|
+
// A repeated idle event after a follow-up is already pending is a no-op.
|
|
223
|
+
const promptsAfterFailure = promptCalls.length;
|
|
335
224
|
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's1' } } });
|
|
336
|
-
breaker = JSON.parse(fs.readFileSync(breakerFile, 'utf8'));
|
|
337
|
-
helper.check('2n. first post-reflection failure starts again at count=1', breaker.failures[sig].count === 1 && breaker.reflectionPending === false, JSON.stringify(breaker));
|
|
338
|
-
let postReflectionEditAllowed = true;
|
|
339
|
-
try {
|
|
340
|
-
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 's1', callID: 'c6' }, { args: {} });
|
|
341
|
-
} catch {
|
|
342
|
-
postReflectionEditAllowed = false;
|
|
343
|
-
}
|
|
344
|
-
helper.check('2n. no permanent post-reflection hard lock remains', postReflectionEditAllowed, 'tool.execute.before unexpectedly blocked after one fresh failure');
|
|
345
|
-
|
|
346
|
-
// The same workspace can host independent sessions. Session s2 starts with
|
|
347
|
-
// a fresh breaker and cannot inherit s1 state.
|
|
348
|
-
await hooks['tool.execute.after']({ tool: 'edit', sessionID: 's2', callID: 's2-c1', args: {} }, { title: '', output: '', metadata: {} });
|
|
349
|
-
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's2' } } });
|
|
350
|
-
const secondBreaker = JSON.parse(fs.readFileSync(path.join(secondSessionDir, 'circuit-breaker.json'), 'utf8'));
|
|
351
225
|
helper.check(
|
|
352
|
-
'2n.
|
|
353
|
-
|
|
354
|
-
|
|
226
|
+
'2n. repeated idle does not duplicate verification or follow-up prompts',
|
|
227
|
+
promptCalls.length === promptsAfterFailure,
|
|
228
|
+
`${promptCalls.length} prompt(s) sent`
|
|
355
229
|
);
|
|
356
230
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
fs.writeFileSync(corruptBreakerFile, '{not-json', 'utf8');
|
|
361
|
-
let corruptStateBlocked = false;
|
|
362
|
-
let corruptStateMessage = '';
|
|
363
|
-
try {
|
|
364
|
-
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 'corrupt', callID: 'corrupt-edit' }, { args: {} });
|
|
365
|
-
} catch (error) {
|
|
366
|
-
corruptStateBlocked = true;
|
|
367
|
-
corruptStateMessage = String(error && error.message ? error.message : error);
|
|
368
|
-
}
|
|
231
|
+
// The same workspace can host independent sessions.
|
|
232
|
+
await hooks['tool.execute.after']({ tool: 'edit', sessionID: 's2', callID: 's2-c1', args: {} }, { title: '', output: '', metadata: {} });
|
|
233
|
+
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 's2' } } });
|
|
369
234
|
helper.check(
|
|
370
|
-
'2n.
|
|
371
|
-
!
|
|
372
|
-
|
|
235
|
+
'2n. a second session keeps independent edit state',
|
|
236
|
+
fs.existsSync(path.join(secondSessionDir, 'edit-state.json')) && !fs.existsSync(path.join(secondSessionDir, 'circuit-breaker.json')),
|
|
237
|
+
secondSessionDir
|
|
373
238
|
);
|
|
374
239
|
|
|
375
|
-
// A prompt transport failure is retryable without re-running verification
|
|
376
|
-
// or incrementing the circuit-breaker count.
|
|
240
|
+
// A prompt transport failure is retryable without re-running verification.
|
|
377
241
|
const promptsBeforeDeliveryFailure = promptCalls.length;
|
|
378
242
|
rejectNextPrompt = true;
|
|
379
243
|
await hooks['tool.execute.after']({ tool: 'edit', sessionID: 'prompt-retry', callID: 'retry-c1' }, { title: '', output: '', metadata: {} });
|
|
380
244
|
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 'prompt-retry' } } });
|
|
381
245
|
let retryEditState = JSON.parse(fs.readFileSync(path.join(retrySessionDir, 'edit-state.json'), 'utf8'));
|
|
382
|
-
let retryBreaker = JSON.parse(fs.readFileSync(path.join(retrySessionDir, 'circuit-breaker.json'), 'utf8'));
|
|
383
246
|
helper.check(
|
|
384
247
|
'2n. failed prompt delivery remains retryable',
|
|
385
248
|
promptCalls.length === promptsBeforeDeliveryFailure + 1 &&
|
|
386
249
|
retryEditState.followUpPending === false &&
|
|
387
250
|
retryEditState.followUpDeliveryPending === true &&
|
|
388
|
-
|
|
389
|
-
JSON.stringify(
|
|
251
|
+
!fs.existsSync(path.join(retrySessionDir, 'circuit-breaker.json')),
|
|
252
|
+
JSON.stringify(retryEditState)
|
|
390
253
|
);
|
|
391
254
|
await hooks.event({ event: { type: 'session.idle', properties: { sessionID: 'prompt-retry' } } });
|
|
392
255
|
retryEditState = JSON.parse(fs.readFileSync(path.join(retrySessionDir, 'edit-state.json'), 'utf8'));
|
|
393
|
-
retryBreaker = JSON.parse(fs.readFileSync(path.join(retrySessionDir, 'circuit-breaker.json'), 'utf8'));
|
|
394
256
|
helper.check(
|
|
395
257
|
'2n. next idle retries the saved follow-up exactly once',
|
|
396
258
|
promptCalls.length === promptsBeforeDeliveryFailure + 2 &&
|
|
397
259
|
retryEditState.followUpPending === true &&
|
|
398
260
|
retryEditState.followUpDeliveryPending === false &&
|
|
399
|
-
|
|
400
|
-
JSON.stringify(
|
|
261
|
+
!fs.existsSync(path.join(retrySessionDir, 'circuit-breaker.json')),
|
|
262
|
+
JSON.stringify(retryEditState)
|
|
401
263
|
);
|
|
402
264
|
|
|
403
265
|
// A fresh session event is the explicit reset contract for a reused session
|
|
404
266
|
// identity, and it removes only that session's plugin state.
|
|
405
267
|
await hooks.event({ event: { type: 'session.created', properties: { info: { id: 's1' } } } });
|
|
406
|
-
helper.check('2n. session.created resets only the current session state', !fs.existsSync(
|
|
268
|
+
helper.check('2n. session.created resets only the current session state', !fs.existsSync(editStateFile), editStateFile);
|
|
407
269
|
let resetAllowed = true;
|
|
408
270
|
try {
|
|
409
271
|
await hooks['tool.execute.before']({ tool: 'edit', sessionID: 's1', callID: 'after-reset' }, { args: {} });
|
|
@@ -429,7 +291,7 @@ helper.check(
|
|
|
429
291
|
sessionEntries.map((entry) => entry.name).join(', ')
|
|
430
292
|
);
|
|
431
293
|
helper.check('2n. resetting an unsafe session cannot delete an outside sentinel', fs.existsSync(path.join(outsideSentinel, 'keep.txt')), outsideSentinel);
|
|
432
|
-
helper.check('2n. resetting s1 leaves the independent s2 state', fs.existsSync(path.join(secondSessionDir, '
|
|
294
|
+
helper.check('2n. resetting s1 leaves the independent s2 state', fs.existsSync(path.join(secondSessionDir, 'edit-state.json')), secondSessionDir);
|
|
433
295
|
|
|
434
296
|
const workspaceStateRoot = path.dirname(stateRoot);
|
|
435
297
|
helper.check(
|