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
@@ -11,7 +11,6 @@ const {
11
11
  grade,
12
12
  parseSimpleYaml,
13
13
  } = require('./run');
14
- const { verifyEvidence: verifyOpenCodeReflectionEvidence } = require('./opencode-reflection-gate-live');
15
14
  const { resolveFixtureSetup } = require('./case-validator');
16
15
 
17
16
  const ROOT = path.resolve(__dirname, '..');
@@ -358,7 +357,7 @@ function recursiveFind(root, names) {
358
357
  }
359
358
 
360
359
  function inspectPluginAttribution(stateHome) {
361
- const stateFiles = recursiveFind(stateHome, new Set(['edit-state.json', 'circuit-breaker.json', 'compliance.json']));
360
+ const stateFiles = recursiveFind(stateHome, new Set(['edit-state.json', 'compliance.json']));
362
361
  return {
363
362
  fired: stateFiles.length > 0,
364
363
  state_files: stateFiles.map((file) => path.relative(stateHome, file).split(path.sep).join('/')).sort(),
@@ -547,29 +546,6 @@ function runArm(c, context, arm, pairDir, execute = spawnSync) {
547
546
  return armRecord;
548
547
  }
549
548
 
550
- function validatePreflight(preflightDir) {
551
- if (!preflightDir) return { passed: false, reason: 'plugin-enforcement requires --opencode-preflight <evidence-dir>' };
552
- const absolute = path.resolve(preflightDir);
553
- let verification;
554
- try { verification = verifyOpenCodeReflectionEvidence(absolute); }
555
- catch (error) { return { passed: false, reason: `preflight unreadable: ${error.message}` }; }
556
- if (!verification.passed) return { passed: false, reason: 'OpenCode reflection-gate preflight evidence does not pass verification' };
557
- let metadata;
558
- try { metadata = JSON.parse(fs.readFileSync(path.join(absolute, 'metadata.json'), 'utf8')); }
559
- catch (error) { return { passed: false, reason: `preflight metadata unreadable: ${error.message}` }; }
560
- const currentHash = sha256File(PLUGIN_SOURCE);
561
- if (!metadata.pluginSha256 || metadata.pluginSha256 !== currentHash) {
562
- return { passed: false, reason: 'preflight plugin hash does not match the current canonical OpenCode plugin' };
563
- }
564
- return {
565
- passed: true,
566
- evidence_dir: absolute,
567
- plugin_sha256: currentHash,
568
- repo_commit: metadata.repoCommit || null,
569
- opencode_version: metadata.opencodeVersion || null,
570
- };
571
- }
572
-
573
549
  function validateRunConfig(options) {
574
550
  const problems = [];
575
551
  if (!EFFECT_TYPES.has(options.effect_type)) problems.push('effect must be skill-text, plugin-enforcement, or lesson-retrieval');
@@ -642,12 +618,9 @@ function validatePairRecord(record) {
642
618
  stableJson(treatment.loaded_skills.slice().sort()) !== stableJson(record.contract.loaded_skills)) {
643
619
  return { included: false, reason: 'plugin-skill-text-not-held-constant' };
644
620
  }
645
- if (!record.preflight || record.preflight.passed !== true || !treatment.plugin_attribution || treatment.plugin_attribution.fired !== true) {
621
+ if (!treatment.plugin_attribution || treatment.plugin_attribution.fired !== true) {
646
622
  return { included: false, reason: 'plugin-attribution-missing' };
647
623
  }
648
- if (!treatment.plugin_sha256 || treatment.plugin_sha256 !== record.preflight.plugin_sha256) {
649
- return { included: false, reason: 'plugin-hash-mismatch' };
650
- }
651
624
  } else if (record.effect_type === 'lesson-retrieval') {
652
625
  if (!baseline.intervention.skill_text || !treatment.intervention.skill_text ||
653
626
  baseline.intervention.plugin_enforcement || treatment.intervention.plugin_enforcement ||
@@ -867,12 +840,6 @@ function runExperiment(options) {
867
840
  if (invalid.length) throw new Error(invalid.join('; '));
868
841
  }
869
842
 
870
- let preflight = null;
871
- if (options.effect_type === 'plugin-enforcement') {
872
- preflight = validatePreflight(options.preflight);
873
- if (!preflight.passed) throw new Error(preflight.reason);
874
- }
875
-
876
843
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
877
844
  const experimentId = `${options.effect_type}-${timestamp}-${crypto.randomBytes(4).toString('hex')}`;
878
845
  const experimentDir = path.join(RESULTS_ROOT, experimentId);
@@ -887,7 +854,6 @@ function runExperiment(options) {
887
854
  model: options.model,
888
855
  min_effect_pp: options.min_effect_pp,
889
856
  repeats: options.repeats,
890
- preflight,
891
857
  repo_commit: safeCommand('git', ['rev-parse', 'HEAD'], { cwd: ROOT }),
892
858
  cli_version: safeCommand(options.engine === 'claude' ? 'claude' : 'opencode', ['--version']),
893
859
  node_version: process.version,
@@ -921,7 +887,6 @@ function runExperiment(options) {
921
887
  arm_order: order,
922
888
  contract,
923
889
  contract_sha256: contractHash,
924
- preflight,
925
890
  arms,
926
891
  created_at: new Date().toISOString(),
927
892
  };
@@ -971,7 +936,6 @@ function main(argv = process.argv.slice(2)) {
971
936
  case_id: flag(argv, '--case'),
972
937
  repeats: integerFlag(argv, '--repeats', 1),
973
938
  min_effect_pp: Number(flag(argv, '--min-effect-pp')),
974
- preflight: flag(argv, '--opencode-preflight'),
975
939
  };
976
940
  const { summary } = runExperiment(options);
977
941
  if (summary.fixture_failures) process.exitCode = 1;
@@ -987,7 +951,7 @@ function main(argv = process.argv.slice(2)) {
987
951
  console.log([
988
952
  'Usage:',
989
953
  ' node behavioral-evals/paired-benchmark.js run --effect skill-text --engine claude|opencode --model <model> --min-effect-pp <n> [--case <id>] [--repeats <n>]',
990
- ' node behavioral-evals/paired-benchmark.js run --effect plugin-enforcement --engine opencode --model <model> --min-effect-pp <n> --opencode-preflight <evidence-dir> [--case <id>] [--repeats <n>]',
954
+ ' node behavioral-evals/paired-benchmark.js run --effect plugin-enforcement --engine opencode --model <model> --min-effect-pp <n> [--case <id>] [--repeats <n>]',
991
955
  ' node behavioral-evals/paired-benchmark.js run --effect lesson-retrieval --engine claude|opencode --model <model> --min-effect-pp <n> [--case <lesson-case-id>] [--repeats <n>]',
992
956
  ' node behavioral-evals/paired-benchmark.js summarize <experiment-dir>',
993
957
  ].join('\n'));
@@ -1016,6 +980,5 @@ module.exports = {
1016
980
  summarizePairs,
1017
981
  validateLessonCase,
1018
982
  validatePairRecord,
1019
- validatePreflight,
1020
983
  validateRunConfig,
1021
984
  };
@@ -940,9 +940,8 @@ function grade(c, ws, transcriptPath, engine = 'auto') {
940
940
  results.push({ ...e, pass, status, reason });
941
941
  }
942
942
  // Informational expectations are reported but never gate the outcome:
943
- // they capture context-dependent behavior (e.g. zoom-out only becomes
944
- // obligatory once the breaker actually trips) that would otherwise
945
- // produce meaningless failures.
943
+ // they capture context-dependent behavior that would otherwise produce
944
+ // meaningless failures.
946
945
  const gating = results.filter((r) => !r.informational);
947
946
  const inconclusive = gating.some(result => result.status === 'inconclusive');
948
947
  const passed = gating.length > 0 && !inconclusive && gating.every((g) => g.pass);
@@ -14,7 +14,6 @@
14
14
  "scope-lock",
15
15
  "environment-alignment",
16
16
  "verify-before-claim",
17
- "replan-after-repeated-failure",
18
17
  "visible-status-updates",
19
18
  "loop-awareness",
20
19
  "objective-verification",
@@ -45,7 +44,6 @@
45
44
  "scope-lock",
46
45
  "environment-alignment",
47
46
  "verify-before-claim",
48
- "replan-after-repeated-failure",
49
47
  "visible-status-updates",
50
48
  "loop-awareness",
51
49
  "objective-verification",
@@ -181,7 +179,6 @@
181
179
  "mode": "semantic-contract",
182
180
  "reasoningPolicy": "model-controls-how",
183
181
  "hardBoundaries": [
184
- "rule-of-3-reflection",
185
182
  "user-host-permission"
186
183
  ]
187
184
  },
@@ -350,7 +347,6 @@
350
347
  "scope-lock",
351
348
  "environment-alignment",
352
349
  "verify-before-claim",
353
- "replan-after-repeated-failure",
354
350
  "visible-status-updates",
355
351
  "loop-awareness",
356
352
  "objective-verification",
@@ -381,7 +377,6 @@
381
377
  "scope-lock",
382
378
  "environment-alignment",
383
379
  "verify-before-claim",
384
- "replan-after-repeated-failure",
385
380
  "visible-status-updates",
386
381
  "loop-awareness",
387
382
  "objective-verification",
@@ -517,7 +512,6 @@
517
512
  "mode": "semantic-contract",
518
513
  "reasoningPolicy": "model-controls-how",
519
514
  "hardBoundaries": [
520
- "rule-of-3-reflection",
521
515
  "user-host-permission"
522
516
  ]
523
517
  },
@@ -34,6 +34,16 @@ const tier2=runKernel('add a login endpoint with tests and update the implementa
34
34
  check(tier2.status===0,'kernel router exits successfully');
35
35
  check(/RECOMMENDED TIER:\s*Tier 2/i.test(tier2.stdout),'classifier result is preserved');
36
36
  check(tier2.stdout.includes('"strategy":"iterative-single"'),'Tier 2 selects iterative-single workflow');
37
+ const planMatch=tier2.stdout.match(/ROUTER WORKFLOW PLAN \(JSON\): ([^\r\n]+)/);
38
+ const plan=planMatch?JSON.parse(planMatch[1]):{};
39
+ check(!plan.requiredInvariants?.includes('replan-after-repeated-failure'),'router plan does not require recurrence-triggered replanning');
40
+ check(plan.requiredInvariants?.includes('loop-awareness'),'iterative work retains loop-awareness');
41
+ check(plan.requiredInvariants?.includes('objective-verification'),'iterative work retains objective verification');
42
+ check(!tier2.stdout.includes('MUST stop micro-retrying after 3 same-signature failures'),'emitted prompt omits the Rule-of-3 invariant text');
43
+ check(!tier2.stdout.includes('Rule-of-3 zoom-out'),'emitted prompt omits the forced-reflection boundary');
44
+ check(tier2.stdout.includes('explicit user/host permission boundaries'),'emitted prompt retains the permission boundary');
45
+ const kernelSource=read('harness-everything/scripts/kernel-router.js');
46
+ check(/hardBoundaries:\s*\['user-host-permission'\]/.test(kernelSource),'machine-readable hardBoundaries retain only the permission boundary');
37
47
  check(tier2.stdout.includes('loop-awareness:'),'iterative work exposes loop-awareness instead of a hard budget');
38
48
  check(tier2.stdout.includes('ACTIVE-STEP KNOWLEDGE BINDINGS (MUST)'),'active-step binding resolution is explicitly mandatory');
39
49
  check(tier2.stdout.includes('ORCHESTRATION POLICY: Selected-topology required obligations and applicable skill core contracts are semantic MUSTs'),'orchestration policy preserves semantic MUST obligations');
@@ -63,7 +73,7 @@ check(tier3.stdout.includes('Tier 3 / Fable broad mutation MUST resolve isolatio
63
73
 
64
74
  const hs=read('harness-everything/SKILL.md');
65
75
  check(/required obligations are MUST; tactics MAY adapt/i.test(hs),'Harness skill separates required obligations from adaptable tactics');
66
- check(/only Rule-of-3 reflection and explicit user\/host permission boundaries may block/i.test(hs),'Harness skill names the only intentional blocking boundaries');
76
+ check(/only explicit user\/host permission boundaries may block/i.test(hs)&&!/Rule-of-3|after 3 same-signature failures/i.test(hs),'Harness skill retains permission boundaries without recurrence blocking');
67
77
  check(/Surface status \(MUST\).*Harness Status/i.test(hs)&&/Read \/ Evidence/i.test(hs),'Harness skill requires the readable unified user-visible status');
68
78
  check(read('plugins/harness-everything/skills/harness-everything/SKILL.md')===hs,'Harness skill mirror matches');
69
79
 
@@ -101,7 +111,7 @@ check(!/Applicable workflow is guidance:/i.test(philosophy),'old ambiguous philo
101
111
  const advisory=read('scripts/lib/advisory-text.js');
102
112
  check(/Selected-topology required obligations are MUSTs/i.test(advisory)&&/numeric.*MAY guide planning/i.test(advisory),'instruction-only installer preserves MUST/MAY semantics');
103
113
  check(/USER-VISIBLE STATUS \(MUST\)/i.test(advisory)&&/### 🚦 Harness Status/i.test(advisory)&&/\*\*Read \/ Evidence:\*\*/i.test(advisory),'instruction-only installers carry the readable mandatory status contract');
104
- check(/Rule of 3/i.test(advisory)&&/Permission boundaries are separate/i.test(advisory),'installer text preserves Rule-of-3 and permission boundaries');
114
+ check(/zoom-out.*meaningful signal/i.test(advisory)&&/productive iterations may continue/i.test(advisory)&&/Permission boundaries are separate/i.test(advisory)&&!/after 3 same-signature failures/i.test(advisory),'installer text permits agent-initiated reassessment and preserves permission boundaries');
105
115
  check(read('plugins/harness-everything/scripts/lib/advisory-text.js')===advisory,'OpenAI advisory mirror matches');
106
116
 
107
117
  const agents=read('AGENTS.md');
@@ -110,21 +120,32 @@ check(/User-visible Harness Status is mandatory/i.test(agents)&&/### 🚦 Harnes
110
120
  check(/Tier-3\/Fable isolation disposition is mandatory/i.test(agents)&&/degraded fallback/i.test(agents),'repository worktree rule requires disposition without hard lock');
111
121
 
112
122
  const architectureSkill=read('improve-codebase-architecture/SKILL.md');
113
- check(/3 same-signature failures.*zoom-out/i.test(architectureSkill),'architecture skill aligns rollback with the third same-signature failure');
114
- check(!/>3 cascading errors/i.test(architectureSkill),'architecture skill no longer waits beyond the Rule-of-3 threshold');
123
+ check(/first meaningful signal/i.test(architectureSkill)&&/productive iteration may continue/i.test(architectureSkill),'architecture skill allows voluntary reassessment and productive iteration');
124
+ check(!/(?:3 same-signature failures.*(?:rollback|zoom-out)|>3 cascading errors)/i.test(architectureSkill),'architecture skill has no count-triggered rollback or zoom-out');
115
125
  check(read('plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md')===architectureSkill,'architecture skill mirror matches');
116
126
 
117
127
  const envSkill=read('environment-detection/SKILL.md');
118
128
  check(/semantic \*\*MUST\*\*/i.test(envSkill)&&/environment-sensitive/i.test(envSkill),'environment discovery is a conditional semantic MUST');
119
129
  check(read('plugins/harness-everything/skills/environment-detection/SKILL.md')===envSkill,'environment skill mirror matches');
120
130
 
131
+ const countTriggeredZoomOut = /\b(?:3|three)\b[^.\n;]{0,100}\b(?:zoom-out|circuit breaker)\b|\b(?:zoom-out|circuit breaker)\b[^.\n;]{0,100}\b(?:3|three)\b/i;
132
+ for (const [source, mirror] of [
133
+ ['tdd/SKILL.md', 'plugins/harness-everything/skills/tdd/SKILL.md'],
134
+ ['environment-detection/references/shell-syntax-rules.md', 'plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md'],
135
+ ]) {
136
+ const text = read(source);
137
+ check(!countTriggeredZoomOut.test(text), source + ' has no count-triggered zoom-out instruction');
138
+ check(/agent may (?:invoke|choose) `zoom-out`/i.test(text), source + ' permits voluntary zoom-out reassessment');
139
+ check(/Continue when .{0,100}\bevidence(?:-based)?\b/i.test(text), source + ' permits productive evidence-based continuation');
140
+ check(text === read(mirror), source + ' packaged mirror matches byte for byte');
141
+ }
142
+
121
143
  const commitSkill=read('git-commit/SKILL.md');
122
144
  check(/MUST.*git diff --cached/i.test(commitSkill)&&/SHOULD.*split/i.test(commitSkill),'commit skill separates staged-diff MUST from split SHOULD');
123
145
  check(read('plugins/harness-everything/skills/git-commit/SKILL.md')===commitSkill,'git-commit skill mirror matches');
124
146
 
125
147
  const hooks=JSON.parse(read('hooks/hooks.json'));
126
148
  check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:workflow-gate'),'Claude packages workflow reminder hook');
127
- check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:rule-of-3'),'Claude preserves Rule-of-3 boundary');
128
149
  check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:action-gate'),'Claude preserves action permission gate');
129
150
 
130
151
  console.log('\n'+(failed===0?'PASS':'FAIL')+': semantic contract-strength routing contract ('+failed+' failures)');
@@ -8,10 +8,8 @@ const childProcess = require('child_process');
8
8
  // host-discovery surface. Parsing preserves async declarations and boundaries.
9
9
  module.exports = function loadRunner(root, overrides = {}) {
10
10
  const source = fs.readFileSync(path.join(root, 'opencode-plugin/index.mjs'), 'utf8');
11
- const names = new Set(['FAILURE_MARKER_PATTERNS', 'CONTEXT_MARKER_PATTERNS',
12
- 'VERIFY_TIMEOUT_ENV', 'DEFAULT_VERIFY_TIMEOUT_MS', 'VERIFY_OUTPUT_LIMIT',
13
- 'VERIFY_LINE_LIMIT', 'VERIFY_KILL_GRACE_MS', 'normalizeFailureLine',
14
- 'firstFailureMarker', 'buildFailureSignature', 'getAvailableScripts',
11
+ const names = new Set(['VERIFY_TIMEOUT_ENV', 'DEFAULT_VERIFY_TIMEOUT_MS',
12
+ 'VERIFY_OUTPUT_LIMIT', 'VERIFY_KILL_GRACE_MS', 'getAvailableScripts',
15
13
  'verifyTimeoutMs', 'createVerificationCapture', 'terminateVerificationChild',
16
14
  'runVerificationCommand', 'runVerification']);
17
15
  const ast = acorn.parse(source, { ecmaVersion: 'latest', sourceType: 'module' });
@@ -20,5 +18,5 @@ module.exports = function loadRunner(root, overrides = {}) {
20
18
  createHash: require('crypto').createHash, spawn: childProcess.spawn,
21
19
  existsSync: fs.existsSync, readFileSync: fs.readFileSync, join: path.join, ...overrides };
22
20
  return vm.runInNewContext(declarations.map(node => source.slice(node.start, node.end)).join('\n')
23
- + '\n;({ runVerification, runVerificationCommand, createVerificationCapture, buildFailureSignature, verifyTimeoutMs })', context);
21
+ + '\n;({ runVerification, runVerificationCommand, createVerificationCapture, verifyTimeoutMs })', context);
24
22
  };
@@ -1,116 +1,130 @@
1
- const fs = require('fs');
2
- const path = require('path');
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
- console.log('\n[2a] Rule of 3 circuit breaker...');
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. apply_patch is covered before and after execution',
21
- matcherHas(preRuleHook, 'apply_patch') && matcherHas(successTrackerHook, 'apply_patch') && matcherHas(failureTrackerHook, 'apply_patch'),
22
- JSON.stringify({ preRuleHook, successTrackerHook, failureTrackerHook })
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
- const failure = {
26
- hook_event_name: 'PostToolUseFailure',
27
- tool_name: 'Bash',
28
- tool_input: { command: 'node -e "process.exit(1)"' },
29
- error: 'Exit code 1\ncommand failed',
30
- session_id: helper.SESSION_ID,
31
- };
32
- for (let i = 0; i < 3; i++) helper.runHook('rule-of-3-tracker.js', failure);
33
- let state = helper.readState('rule-of-3-state.json');
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-three. exactly three matching failures arm zoom-out',
36
- state.count === 3 && state.lastHash && state.zoomOutResolved === false && state.threshold === undefined,
37
- JSON.stringify(state)
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-trip. third matching failure blocks mutation for reflection',
43
- trip.code === 2 && trip.stderr.includes('RULE OF 3 CIRCUIT BREAKER TRIGGERED'),
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.writeState('rule-of-3-state.json', { count: 3, lastHash: 'mech-test', zoomOutResolved: false, lastFailureAt: 0, zoomOutCycles: 0 });
48
- fs.writeFileSync(path.join(helper.sessionDir, 'zoom-out-report.md'),
49
- '## Goal\nx\n## Failed Attempts\nx\n## Verified Facts\nx\n## Diagnosis\nx\n## Decision\nRESUME: new approach\n', 'utf8');
50
- const release = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
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-release. valid reflection releases breaker and resets count',
54
- release.code === 0 && state.count === 0 && state.zoomOutResolved === true && state.zoomOutCycles === 1,
55
- JSON.stringify(state)
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-repeat. later three-failure cycle requests another zoom-out, not permanent hard lock',
62
- retrip.code === 2 && retrip.stderr.includes('RULE OF 3 CIRCUIT BREAKER TRIGGERED') && !/hard lock|repeat trip/i.test(retrip.stderr),
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
- helper.writeState('rule-of-3-state.json', { count: 0, lastHash: null, zoomOutResolved: false, zoomOutCycles: 0, lastFailureAt: 0 });
67
- for (let i = 0; i < 2; i++) helper.runHook('rule-of-3-tracker.js', {
68
- hook_event_name: 'PostToolUseFailure', tool_name: 'Bash',
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
- helper.writeState('rule-of-3-state.json', { count: 0, lastHash: null, lastOperationHash: null, zoomOutResolved: false, zoomOutCycles: 0, lastFailureAt: 0 });
85
- const repeatedFailure = {
86
- hook_event_name: 'PostToolUseFailure',
87
- tool_name: 'Bash',
88
- tool_input: { command: 'node flaky.js' },
89
- error: 'Error: flaky failure',
90
- session_id: helper.SESSION_ID,
91
- };
92
- helper.runHook('rule-of-3-tracker.js', repeatedFailure);
93
- helper.runHook('rule-of-3-tracker.js', repeatedFailure);
94
- helper.runHook('rule-of-3-tracker.js', {
95
- hook_event_name: 'PostToolUse',
96
- tool_name: 'Bash',
97
- tool_input: { command: 'git status --short' },
98
- tool_response: { exitCode: 0, stdout: '' },
99
- session_id: helper.SESSION_ID,
100
- });
101
- state = helper.readState('rule-of-3-state.json');
102
- helper.check('2a-interleaved. unrelated success preserves the matching failure count', state.count === 2 && state.lastHash, JSON.stringify(state));
103
- helper.runHook('rule-of-3-tracker.js', repeatedFailure);
104
- state = helper.readState('rule-of-3-state.json');
105
- helper.check('2a-interleaved-three. third matching failure still arms zoom-out after unrelated success', state.count === 3 && state.zoomOutResolved === false, JSON.stringify(state));
106
- helper.runHook('rule-of-3-tracker.js', {
107
- hook_event_name: 'PostToolUse',
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
- state = helper.readState('rule-of-3-state.json');
114
- helper.check('2a-resolved. same-operation success clears the resolved signature', state.count === 0 && state.lastHash === null && state.lastOperationHash === null, JSON.stringify(state));
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();