harness-everything 0.55.3 → 0.55.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/AGENTS.md +1 -1
  4. package/BENCHMARK_SOP.md +2 -2
  5. package/CHANGELOG.md +13 -0
  6. package/README.md +15 -16
  7. package/SECURITY.md +1 -1
  8. package/VERIFICATION.md +4 -8
  9. package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
  10. package/behavioral-evals/README.md +21 -65
  11. package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
  12. package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
  13. package/behavioral-evals/paired-benchmark.js +3 -40
  14. package/behavioral-evals/run.js +2 -3
  15. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
  16. package/ci/invariant-routing.test.js +26 -5
  17. package/ci/lib/opencode-verification-loader.js +3 -5
  18. package/ci/mechanism-2a-rule-of-3.test.js +111 -97
  19. package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
  20. package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
  21. package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
  22. package/ci/mechanism-32-paired-benchmark.test.js +1 -2
  23. package/ci/mechanism-33-issues-205-207.test.js +1 -1
  24. package/ci/mechanism-338-opencode-async.test.js +18 -49
  25. package/ci/mechanism-36-verify-timeout.test.js +3 -189
  26. package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
  27. package/ci/mechanism-397-opencode-observations.test.js +6 -7
  28. package/ci/mechanism-codex-hook-results.test.js +9 -5
  29. package/ci/mechanism-prb-outline-review.test.js +1 -13
  30. package/ci/mechanism-system-one-router.test.js +1 -1
  31. package/ci/openai-plugin-package.test.js +30 -7
  32. package/ci/openai-plugin-runtime.test.js +64 -32
  33. package/ci/prompt-contract-regressions.test.js +1 -5
  34. package/ci/self-evolve-loop.test.js +51 -51
  35. package/ci/workflow-execution-contract.test.js +3 -6
  36. package/docker-verify.sh +1 -117
  37. package/docs/architecture.md +9 -7
  38. package/docs/document-lifecycle.md +1 -1
  39. package/docs/enforcement-locks.md +12 -10
  40. package/docs/mechanism-first-skill-mesh.md +2 -2
  41. package/docs/openai-plugin.md +3 -3
  42. package/docs/philosophy.md +1 -1
  43. package/docs/platform-capabilities.md +2 -2
  44. package/docs/platform-compatibility.json +2 -2
  45. package/docs/reflection.md +1 -1
  46. package/docs/routing.md +2 -2
  47. package/docs/system-one-suggestion-gates.md +4 -4
  48. package/docs/troubleshooting.md +9 -35
  49. package/docs/workflow-runtime.md +19 -18
  50. package/docs/workflows/environment-detection.md +11 -9
  51. package/docs/workflows/fable-discipline.md +6 -5
  52. package/docs/workflows/fable-mode.md +6 -5
  53. package/docs/workflows/harness-everything.md +5 -5
  54. package/docs/workflows/improve-codebase-architecture.md +10 -8
  55. package/docs/workflows/install-cognitive-os.md +5 -5
  56. package/docs/workflows/tdd.md +9 -9
  57. package/docs/workflows/zoom-out.md +20 -30
  58. package/environment-detection/SKILL.md +2 -2
  59. package/environment-detection/references/shell-syntax-rules.md +1 -1
  60. package/eval-harness/SKILL.md +1 -1
  61. package/eval-harness/references/scoring-rubric.md +3 -3
  62. package/evals/zoom-out/eval.yaml +2 -2
  63. package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
  64. package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
  65. package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
  66. package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
  67. package/fable-discipline/SKILL.md +3 -3
  68. package/fable-discipline/references/discipline-rules.md +1 -1
  69. package/fable-mode/SKILL.md +1 -1
  70. package/fable-mode/execution-guardrails/SKILL.md +2 -4
  71. package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  72. package/fable-mode/fable-haiku/SKILL.md +1 -1
  73. package/fable-mode/fable-opus/SKILL.md +2 -2
  74. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  75. package/fable-mode/references/execution-phases.md +2 -2
  76. package/harness-everything/SKILL.md +3 -3
  77. package/harness-everything/references/router-workflow-plan.md +2 -2
  78. package/harness-everything/references/skill-registry.md +2 -2
  79. package/harness-everything/references/triage-and-tiers.md +5 -5
  80. package/harness-everything/scripts/bootstrap.js +1 -26
  81. package/harness-everything/scripts/kernel-router-core.js +2 -3
  82. package/harness-everything/scripts/kernel-router.js +1 -1
  83. package/harness-everything/scripts/router-contract-core.js +1 -1
  84. package/harness-everything/scripts/routing-keywords.json +0 -2
  85. package/hooks/hooks.json +0 -33
  86. package/hooks/scripts/lib/harness-state.js +5 -6
  87. package/hooks/scripts/lib/learning-opportunity.js +3 -13
  88. package/hooks/scripts/openai-session-start.js +2 -4
  89. package/improve-codebase-architecture/SKILL.md +3 -3
  90. package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  91. package/install-cognitive-os/SKILL.md +3 -3
  92. package/opencode-plugin/README.md +12 -43
  93. package/opencode-plugin/index.mjs +21 -368
  94. package/opencode-plugin/plugin.json +1 -1
  95. package/package.json +1 -4
  96. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  97. package/plugins/harness-everything/hooks/hooks.json +0 -14
  98. package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
  99. package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
  100. package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
  101. package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
  102. package/plugins/harness-everything/hooks/session-start.js +2 -4
  103. package/plugins/harness-everything/plugin.json +1 -1
  104. package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
  105. package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
  106. package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
  107. package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
  108. package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
  109. package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
  110. package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
  111. package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
  112. package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
  113. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
  114. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
  115. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  116. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
  117. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  118. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
  119. package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
  120. package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
  121. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
  122. package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
  123. package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
  124. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
  125. package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
  126. package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
  127. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
  128. package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
  129. package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
  130. package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
  131. package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
  132. package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
  133. package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  134. package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
  135. package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
  136. package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
  137. package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
  138. package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
  139. package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
  140. package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
  141. package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
  142. package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
  143. package/references/platform-advisory-template.md +3 -9
  144. package/sbom.cdx.json +7 -7
  145. package/scripts/lib/advisory-text.js +2 -2
  146. package/scripts/lib/workspace.js +2 -2
  147. package/self-evolve/SKILL.md +1 -1
  148. package/self-evolve/references/memory-resolution.md +3 -3
  149. package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
  150. package/self-evolve/scripts/lesson-candidate.js +1 -0
  151. package/skill-creator/SKILL.md +1 -1
  152. package/skill-creator/references/quality-checklist.md +1 -1
  153. package/skill-creator/references/quality-principles.md +4 -4
  154. package/submission/openai/test-cases.json +5 -5
  155. package/tdd/SKILL.md +2 -2
  156. package/tdd/references/core-discipline.md +3 -5
  157. package/todo-driven-workflow/SKILL.md +2 -2
  158. package/zoom-out/SKILL.md +14 -26
  159. package/zoom-out/references/circuit-breaker.md +18 -62
  160. package/behavioral-evals/opencode-hardlock-live.js +0 -17
  161. package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
  162. package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
  163. package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
  164. package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
  165. package/hooks/scripts/reset-circuit-breaker.js +0 -30
  166. package/hooks/scripts/rule-of-3-tracker.js +0 -165
  167. package/hooks/scripts/rule-of-3.js +0 -171
  168. package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
  169. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
  170. package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
@@ -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
- fs.writeFileSync(path.join(sessionDir, 'rule-of-3-state.json'), JSON.stringify({
121
- count: 3,
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 mixedPatch = runHook('hooks/scripts/rule-of-3.js', {
137
- hook_event_name: 'PreToolUse',
138
- session_id: 'openai-runtime-test',
139
- cwd: fixture,
140
- tool_name: 'apply_patch',
141
- tool_input: { patch: `*** Update File: ${reportFile}\n@@\n*** Update File: unrelated.txt\n@@` }
142
- }, stateHome);
143
- assert.strictEqual(mixedPatch.status, 2, 'report exemption must not allow a mixed apply_patch');
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 blockedPatch = runHook('hooks/scripts/rule-of-3.js', {
146
- hook_event_name: 'PreToolUse',
147
- session_id: 'openai-runtime-test',
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(blockedPatch.status, 2, 'tripped circuit breaker must block unrelated apply_patch writes');
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
- // Mandatory blocking/reflection remains limited to Rule-of-3 or permission boundaries.
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
- fs.writeFileSync(path.join(ruleSessionDir, 'rule-of-3-state.json'), JSON.stringify({
68
- count: 0,
69
- lastHash: '0123456789abcdef0123456789abcdef',
70
- category: 'test',
71
- threshold: 3,
72
- zoomOutResolved: true,
73
- zoomOutCycles: 1,
74
- lastFailureAt: 1700000000000,
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
- const recovered = run(tracker, {
78
- hook_event_name: 'PostToolUse',
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: ruleCandidate.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(ruleEvaluation.state === 'inconclusive', 'Rule-of-3 linear recovery is not misrepresented as counterfactual replay');
105
- check(ruleEvaluation.evaluation.replayable === false && ruleEvaluation.evaluation.improvementClaim === false, 'non-replayable candidate requires paired/later evidence and makes no improvement claim');
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: ruleCandidate.candidateId,
109
+ candidateId: legacyCandidateId,
110
110
  authorization: 'forged',
111
- }), /only accepted/, 'inconclusive runtime lesson cannot be promoted');
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(sourceHook.includes('createLearningOpportunity') && verifierHook.includes('createLearningOpportunity'), 'negative-control anchors require both runtime emitters');
302
- check(!sourceHook.includes('persistMemory(') && !verifierHook.includes('persistMemory('), 'runtime recovery hooks cannot directly persist memory');
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 >= 3 &&
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') && lessonSchema.properties?.trigger?.properties?.type?.enum?.includes('verifier-fail-pass'), 'versioned lesson schema covers lifecycle and trigger vocabulary');
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','hooks/scripts/rule-of-3.js','hooks/scripts/rule-of-3-tracker.js'])check(runNode(['--check',path.join(ROOT,rel)]).status===0,rel+' parses as valid JavaScript');
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 rule-of-3-err.log boundary-guard-err.log scope-guard-err.log stop-gate-err.log
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!"
@@ -17,7 +17,7 @@ The minimal kernel establishes:
17
17
  - a selected workflow topology as a semantic execution contract when task evidence supports one,
18
18
  - ordered requirement decomposition and step-scoped knowledge bindings,
19
19
  - objective evidence before completion,
20
- - bounded re-plan/recovery after repeated failure,
20
+ - agent-initiated reassessment when evidence warrants it, while productive work can continue,
21
21
  - explicit warnings/degraded/escape evidence instead of silent workflow deletion;
22
22
  - one mandatory user-visible Harness Status protocol for non-trivial work, independent of execution topology.
23
23
 
@@ -122,7 +122,7 @@ Harness aligns to each host's actual lifecycle/tool APIs. Shared skill text defi
122
122
 
123
123
  ### Runtime state vs. skill content
124
124
 
125
- Runtime state includes hook metadata, workflow lifecycle, circuit-breaker counters, handoff/verification evidence, and WAL-style session state. Skill content is independently discoverable and remains useful on instruction-only surfaces.
125
+ Runtime state includes hook metadata, workflow lifecycle, handoff/verification evidence, and WAL-style session state. Skill content is independently discoverable and remains useful on instruction-only surfaces.
126
126
 
127
127
  ### Claude Code — hook observation plus explicit safety boundaries
128
128
 
@@ -130,15 +130,15 @@ The installer configures native lifecycle hooks and project skills.
130
130
 
131
131
  - `SessionStart`: bootstrap/restoration.
132
132
  - `UserPromptSubmit`: kernel routing + semantic workflow contract.
133
- - `PreToolUse`: workflow/boundary/depth/scope reminders (all advisory, fail-open), plus the separate `action-gate.js` permission boundary and the Rule-of-3 same-signature-failure boundary.
134
- - `PostToolUse`: outcomes, state, repeated-failure evidence, stage checks.
133
+ - `PreToolUse`: workflow/boundary/depth/scope reminders (all advisory, fail-open), plus the separate `action-gate.js` permission boundary.
134
+ - `PostToolUse`: outcomes, state, stage checks.
135
135
  - `Stop`: action-gate audit plus non-blocking workflow/verification reminders.
136
136
 
137
- Cognitive workflow contracts (boundary/depth/scope/commit/workflow guards) are made observable, not hard-enforced — [#190](https://github.com/dyphn1/Harness-everything/issues/190) downgraded their `exit(2)` blocking to reminders. `action-gate.js` and the Rule-of-3 zoom-out boundary are the two mechanisms that still hard-block on this hook path; #190 explicitly scoped both out of that downgrade as user/host permission and dangerous-action safety boundaries.
137
+ Cognitive workflow contracts (boundary/depth/scope/commit/workflow guards) are made observable, not hard-enforced — [#190](https://github.com/dyphn1/Harness-everything/issues/190) downgraded their `exit(2)` blocking to reminders. `action-gate.js` remains the explicit user/host permission and dangerous-action safety boundary. The former Rule-of-3 counter and forced zoom-out path are retired under [#394](https://github.com/dyphn1/Harness-everything/issues/394).
138
138
 
139
139
  ### OpenCode — plugin enforcement, scoped live verification
140
140
 
141
- The retained [OpenCode evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md) supports **project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS)**. The final snapshot is **post-reset**. Hard-lock is an **interactive observation** with **no retained blocked-tool trace**; reflection was **operator-seeded** and then agent-rewritten. Global scope, npm-package installation, and other OpenCode versions remain unverified.
141
+ The retained [OpenCode evidence](../benchmarks/results/live-host/opencode-2026-09-16/README.md) supports **project-scope `.js` loading and edit/verification state on OpenCode 1.18.31 (macOS)**. The final snapshot is **post-reset**. The old hard-lock was an **interactive observation** with **no retained blocked-tool trace**; reflection was **operator-seeded** and then agent-rewritten. The former third-failure reflection and hard-lock paths are retired under [#394](https://github.com/dyphn1/Harness-everything/issues/394); the snapshot does not establish current host behavior. Global scope, npm-package installation, and other OpenCode versions remain unverified.
142
142
 
143
143
  This evidence predates #190 and does not establish behavioral effectiveness of the current contract-first lifecycle.
144
144
 
@@ -200,7 +200,9 @@ flowchart LR
200
200
  Y --> S[Summarize]
201
201
  S --> R[Record]
202
202
  S -- insufficient evidence --> T
203
- Y -- same failure x3 --> Z[Zoom Out]
203
+ Y --> A{Would reassessment improve the next step?}
204
+ A -->|yes; agent chooses| Z[Agent-initiated Zoom Out]
205
+ A -->|no; next check is justified| Y
204
206
  Z --> T
205
207
  ```
206
208
 
@@ -58,7 +58,7 @@ default-OFF gate, and F4 (#358) adds limited positive credit for `doc-lint` and
58
58
  - **Minimum trusted producer (3b deliverable):** Phase 3b ships the pilot-local adapter that derives the VCS baseline and candidate identity, active task scope, parsed config bytes (`configDigest` bound rather than presence-checked), PRD root, execution/verification provenance and independent reviewer identity from host state (see *Phase 3b minimum trust boundary* below). `checkDocObligations()` only proves agreement with caller-supplied values; without this producer, a 3b PASS would promote caller-attested claims. Any input the producer cannot establish stays `unknown`/`unavailable` and MUST NOT pass. Phase 3c broadens adversarial H3 validation and adds paired architectural evaluation; it does not supply the minimum producer.
59
59
  - **Pilot topology and unsupported paths:** the pilot is limited to non-Fable typed-step workflows (`stepBindingsEnabled === true`, set when typed steps exist and the strategy is not `fable-*`). Fable stage-contract paths (`fable-staged`, `fable-parallel`, `fable-multi-agent-workspace`) and workflows without the typed-step contract are explicitly **not integrated / unavailable** for doc-MUST reconciliation: a `stage-binding` disposition is never doc verification, and no fallback may mark a doc MUST satisfied. Unsupported paths report that state rather than silently passing.
60
60
  - **Negative acceptance case:** for a doc-governed typed plan whose applicable MUST is failing or unknown, no boundary may report PASS: `step --disposition pass` on the verification step, `obligation --obligation-id execute|verify --disposition pass --evidence 'done'`, and final completion must all fail closed, report the unsatisfied obligation ids, and leave aggregate `verify` pending. A loaded skill plus free-text evidence is not verification. A RED fixture covers ordered `doc-change → review → verification` with reviewer/command evidence missing first and valid later: the authored `doc-change` step advances, aggregate/final PASS stays blocked until the later evidence satisfies the MUST, and neither a premature PASS nor a deadlock occurs.
61
- - **Compatibility:** preserve existing non-document step bindings, authorization/Rule-of-3 semantics, old persisted plans and no new Stop/tool lock. Source and installed plugin copies must behave consistently.
61
+ - **Compatibility:** preserve existing non-document step bindings, authorization and safety boundaries, old persisted plans and no new Stop/tool lock. The former Rule-of-3 counter and forced-reflection path are retired under [#394](https://github.com/dyphn1/Harness-everything/issues/394). Source and installed plugin copies must behave consistently.
62
62
  - **Pre-integration work:** the baseline-bound tombstone/rename-pair evidence required by #335 shipped in #342; the remaining pre-integration work is the reconciliation contract above. #331 / draft PR #333 is a parallel host-config safety correction; neither requires the broad #320 migration.
63
63
 
64
64
  ### Phase 3c — architecture promotion gate for #320 (planned, not shipped)
@@ -16,20 +16,22 @@ Harness deliberately separates **semantic obligation strength** from **mechanica
16
16
  | Subagent declared scope / unexpected writes | **MUST** respect and reconcile | Report ambiguous/out-of-scope changes | No |
17
17
  | Commit scope | Staged diff review **MUST**; split unrelated concerns **SHOULD** | Atomic-commit reminder | No |
18
18
  | Fable stage/check/synthesis/verifier | **MUST** when selected | Record pass/fail/ambiguity/dependency evidence and remind | No |
19
- | Rule of 3 | Third matching failure **MUST** trigger zoom-out | Pause mutation until reflection | **Yes — intentional cognitive boundary** |
19
+ | Zoom-out reassessment | **MAY** reassess at the first meaningful signal or later; productive iteration may continue when attempts add evidence or narrow the cause | Agent-directed guidance | No |
20
20
  | Action/permission gate | Approval **MUST** precede governed side effects | Host/user authorization | **Yes — trust boundary** |
21
21
 
22
- ## Rule of 3
22
+ ## Voluntary reassessment
23
23
 
24
- ```text
25
- same signature #1 -> record
26
- same signature #2 -> record
27
- same signature #3 -> pause mutation and require zoom-out
28
- reflection accepted -> count resets
29
- later #1/#2/#3 -> another zoom-out
24
+ ```mermaid
25
+ flowchart TD
26
+ Signal["First meaningful signal or later"] --> Decide{"Would reassessment improve the next step?"}
27
+ Decide -->|Yes| Review["Revisit goal, assumptions, and evidence"]
28
+ Decide -->|No| Continue["Continue with a justified next check"]
29
+ Review --> Continue
30
30
  ```
31
31
 
32
- There are no category-specific 2/4 thresholds and no second-stage permanent hard lock.
32
+ An agent may reassess at the first meaningful signal or later. A run may
33
+ continue when attempts add evidence, narrow the cause, and justify the next
34
+ check. Neither a failure count nor review history forces a pause.
33
35
 
34
36
  ## Workflow reminders
35
37
 
@@ -50,6 +52,6 @@ The design test is simple:
50
52
  When a Harness message appears:
51
53
 
52
54
  1. If it is a **Reminder**, use the evidence to improve the next action, but there is no Harness reset needed.
53
- 2. If it is the **Rule of 3** third-failure boundary, complete the requested zoom-out report.
55
+ 2. If evidence suggests a fresh diagnosis would improve the next step, an agent may choose zoom-out; productive iteration may continue when attempts add evidence or narrow the cause.
54
56
  3. If it is an **action/permission** decision, follow the host/user approval flow.
55
57
  4. Do not edit Harness state files merely to recover from a numeric workflow limit; those limits are no longer enforced.
@@ -105,7 +105,7 @@ For `fable-*` strategies, Fable owns stage lifecycle: `dependsOn`, `writeSet`, v
105
105
 
106
106
  ### Recovery Gate
107
107
 
108
- Rule-of-3 stops repeated same-signature micro-retries and requires a new diagnosis. Fable verification failures return to bounded re-planning; budget exhaustion becomes blocked instead of endless iteration.
108
+ Zoom-out is agent-initiated: an agent may reassess when evidence contradicts an assumption or reveals an unknown impact boundary, including on the first failure. Productive attempts may continue when they add evidence or narrow the cause. Fable verification failures return to bounded re-planning; budget exhaustion becomes blocked instead of endless iteration.
109
109
 
110
110
  ### Action Gate
111
111
 
@@ -153,7 +153,7 @@ Harness should not become:
153
153
  2. Put applicability/basic flow in `SKILL.md`; deep detail belongs in references.
154
154
  3. Add mechanisms when they make behavior more reliable than prose.
155
155
  4. Make checks failable and evidence-based.
156
- 5. Put gates at real transition boundaries: before mutation/side effects, after repeated failure, before completion, before persistence.
156
+ 5. Put checks at real transition boundaries: before mutation/side effects, when evidence warrants reassessment, before completion, before persistence.
157
157
  6. Let the model choose HOW inside the contract.
158
158
  7. Treat workflow escape as a measured coverage gap, not convenience.
159
159
 
@@ -17,9 +17,9 @@ flowchart TD
17
17
  Q --> V{Objective evidence?}
18
18
  V -->|yes| D[Evidence-backed completion]
19
19
  V -->|no| R[Diagnose and retry]
20
- R --> F{Same-signature failure x3?}
21
- F -->|no| E
22
- F -->|yes| Z[Zoom out / re-plan]
20
+ R --> F{Would reassessment improve the next step?}
21
+ F -->|no; next check is justified| E
22
+ F -->|yes; agent chooses| Z[Agent-initiated Zoom out]
23
23
  Z --> E
24
24
 
25
25
  S[SessionStart hook] --> C[Cognitive OS policy]