harness-everything 0.55.2 → 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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +1 -1
- package/BENCHMARK_SOP.md +2 -2
- package/CHANGELOG.md +22 -0
- package/README.md +15 -16
- package/SECURITY.md +1 -1
- package/VERIFICATION.md +4 -8
- package/behavioral-evals/PAIRED-BENCHMARK.md +12 -27
- package/behavioral-evals/README.md +21 -65
- package/behavioral-evals/cases/breaker-zoom-out-after-3.yaml +26 -33
- package/behavioral-evals/cases/pressure-sunk-cost-retry.yaml +15 -17
- package/behavioral-evals/paired-benchmark.js +3 -40
- package/behavioral-evals/run.js +2 -3
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/legacy-off-golden.json +0 -6
- package/ci/invariant-routing.test.js +32 -6
- package/ci/lib/opencode-verification-loader.js +3 -5
- package/ci/mechanism-2a-rule-of-3.test.js +111 -97
- package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
- package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
- package/ci/mechanism-32-paired-benchmark.test.js +1 -2
- package/ci/mechanism-33-issues-205-207.test.js +1 -1
- package/ci/mechanism-338-opencode-async.test.js +18 -49
- package/ci/mechanism-36-verify-timeout.test.js +3 -189
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
- package/ci/mechanism-397-opencode-observations.test.js +64 -9
- package/ci/mechanism-check-packet-write-set.test.js +163 -8
- package/ci/mechanism-codex-hook-results.test.js +9 -5
- package/ci/mechanism-prb-outline-review.test.js +1 -13
- package/ci/mechanism-system-one-router.test.js +1 -1
- package/ci/openai-plugin-package.test.js +30 -7
- package/ci/openai-plugin-runtime.test.js +64 -32
- package/ci/prompt-contract-regressions.test.js +1 -5
- package/ci/router-workflow-plan.test.js +8 -8
- package/ci/self-evolve-loop.test.js +51 -51
- package/ci/workflow-execution-contract.test.js +3 -6
- package/code-review/SKILL.md +1 -1
- package/code-review/templates/finding.template.md +17 -1
- package/docker-verify.sh +1 -117
- package/docs/architecture.md +9 -7
- package/docs/document-lifecycle.md +1 -1
- package/docs/enforcement-locks.md +12 -10
- package/docs/mechanism-first-skill-mesh.md +2 -2
- package/docs/openai-plugin.md +3 -3
- package/docs/philosophy.md +1 -1
- package/docs/platform-capabilities.md +4 -3
- package/docs/platform-compatibility.json +2 -2
- package/docs/reflection.md +1 -1
- package/docs/routing.md +2 -2
- package/docs/system-one-suggestion-gates.md +4 -4
- package/docs/troubleshooting.md +9 -35
- package/docs/workflow-runtime.md +19 -18
- package/docs/workflows/environment-detection.md +11 -9
- package/docs/workflows/fable-discipline.md +6 -5
- package/docs/workflows/fable-mode.md +6 -5
- package/docs/workflows/harness-everything.md +5 -5
- package/docs/workflows/improve-codebase-architecture.md +10 -8
- package/docs/workflows/install-cognitive-os.md +5 -5
- package/docs/workflows/tdd.md +9 -9
- package/docs/workflows/zoom-out.md +20 -30
- package/environment-detection/SKILL.md +2 -2
- package/environment-detection/references/shell-syntax-rules.md +1 -1
- package/eval-harness/SKILL.md +1 -1
- package/eval-harness/references/scoring-rubric.md +3 -3
- package/evals/zoom-out/eval.yaml +2 -2
- package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
- package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
- package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
- package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
- package/fable-discipline/SKILL.md +3 -3
- package/fable-discipline/references/discipline-rules.md +1 -1
- package/fable-mode/SKILL.md +1 -1
- package/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/fable-mode/fable-haiku/SKILL.md +1 -1
- package/fable-mode/fable-opus/SKILL.md +2 -2
- package/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/fable-mode/references/execution-phases.md +2 -2
- package/harness-everything/SKILL.md +3 -3
- package/harness-everything/references/router-workflow-plan.md +2 -2
- package/harness-everything/references/skill-registry.md +2 -2
- package/harness-everything/references/triage-and-tiers.md +5 -5
- package/harness-everything/scripts/bootstrap.js +1 -26
- package/harness-everything/scripts/kernel-router-core.js +2 -3
- package/harness-everything/scripts/kernel-router.js +1 -1
- package/harness-everything/scripts/router-contract-core.js +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/hooks/hooks.json +0 -33
- package/hooks/scripts/lib/harness-state.js +5 -6
- package/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/hooks/scripts/openai-session-start.js +2 -4
- package/improve-codebase-architecture/SKILL.md +3 -3
- package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/install-cognitive-os/SKILL.md +3 -3
- package/opencode-plugin/README.md +18 -43
- package/opencode-plugin/index.mjs +52 -380
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -4
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/hooks.json +0 -14
- package/plugins/harness-everything/hooks/scripts/lib/harness-state.js +5 -6
- package/plugins/harness-everything/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/plugins/harness-everything/hooks/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/hooks/scripts/openai-session-start.js +2 -4
- package/plugins/harness-everything/hooks/session-start.js +2 -4
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/scripts/lib/advisory-text.js +2 -2
- package/plugins/harness-everything/scripts/lib/workspace.js +2 -2
- package/plugins/harness-everything/skills/code-review/SKILL.md +1 -1
- package/plugins/harness-everything/skills/code-review/templates/finding.template.md +17 -1
- package/plugins/harness-everything/skills/environment-detection/SKILL.md +2 -2
- package/plugins/harness-everything/skills/environment-detection/references/shell-syntax-rules.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/SKILL.md +1 -1
- package/plugins/harness-everything/skills/eval-harness/references/scoring-rubric.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/SKILL.md +3 -3
- package/plugins/harness-everything/skills/fable-discipline/references/discipline-rules.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +2 -2
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +3 -3
- package/plugins/harness-everything/skills/harness-everything/references/router-workflow-plan.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +2 -2
- package/plugins/harness-everything/skills/harness-everything/references/triage-and-tiers.md +5 -5
- package/plugins/harness-everything/skills/harness-everything/scripts/bootstrap.js +1 -26
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router-core.js +2 -3
- package/plugins/harness-everything/skills/harness-everything/scripts/kernel-router.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/router-contract-core.js +1 -1
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +0 -2
- package/plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md +3 -3
- package/plugins/harness-everything/skills/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/plugins/harness-everything/skills/install-cognitive-os/SKILL.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/SKILL.md +1 -1
- package/plugins/harness-everything/skills/self-evolve/references/memory-resolution.md +3 -3
- package/plugins/harness-everything/skills/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/plugins/harness-everything/skills/self-evolve/scripts/lesson-candidate.js +1 -0
- package/plugins/harness-everything/skills/skill-creator/SKILL.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-checklist.md +1 -1
- package/plugins/harness-everything/skills/skill-creator/references/quality-principles.md +4 -4
- package/plugins/harness-everything/skills/tdd/SKILL.md +2 -2
- package/plugins/harness-everything/skills/tdd/references/core-discipline.md +3 -5
- package/plugins/harness-everything/skills/todo-driven-workflow/SKILL.md +2 -2
- package/plugins/harness-everything/skills/zoom-out/SKILL.md +14 -26
- package/plugins/harness-everything/skills/zoom-out/references/circuit-breaker.md +18 -62
- package/references/platform-advisory-template.md +3 -9
- package/sbom.cdx.json +7 -7
- package/scripts/check-packet-write-set.js +76 -1
- package/scripts/lib/advisory-text.js +2 -2
- package/scripts/lib/workspace.js +2 -2
- package/self-evolve/SKILL.md +1 -1
- package/self-evolve/references/memory-resolution.md +3 -3
- package/self-evolve/schemas/lesson-candidate.schema.json +4 -1
- package/self-evolve/scripts/lesson-candidate.js +1 -0
- package/skill-creator/SKILL.md +1 -1
- package/skill-creator/references/quality-checklist.md +1 -1
- package/skill-creator/references/quality-principles.md +4 -4
- package/submission/openai/test-cases.json +5 -5
- package/tdd/SKILL.md +2 -2
- package/tdd/references/core-discipline.md +3 -5
- package/todo-driven-workflow/SKILL.md +2 -2
- package/zoom-out/SKILL.md +14 -26
- package/zoom-out/references/circuit-breaker.md +18 -62
- package/behavioral-evals/opencode-hardlock-live.js +0 -17
- package/behavioral-evals/opencode-reflection-gate-live.js +0 -342
- package/ci/mechanism-31-opencode-hardlock-evidence.test.js +0 -82
- package/evals/zoom-out/tasks/negative-first-edge-case-review.yaml +0 -16
- package/evals/zoom-out/tasks/positive-repeated-failure.yaml +0 -15
- package/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/hooks/scripts/rule-of-3-tracker.js +0 -165
- package/hooks/scripts/rule-of-3.js +0 -171
- package/plugins/harness-everything/hooks/scripts/reset-circuit-breaker.js +0 -30
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +0 -165
- package/plugins/harness-everything/hooks/scripts/rule-of-3.js +0 -171
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
discipline: circuit-breaker
|
|
1
|
+
# Negative: prior attempts narrow the cause and justify a concrete next step.
|
|
2
|
+
id: productive-iteration-negative
|
|
3
|
+
name: Continue when attempts narrow the cause
|
|
4
|
+
discipline: zoom-out
|
|
6
5
|
loaded_skills:
|
|
7
6
|
- zoom-out
|
|
8
7
|
pressure: true
|
|
@@ -11,17 +10,18 @@ fixture:
|
|
|
11
10
|
files:
|
|
12
11
|
- path: package.json
|
|
13
12
|
content: |
|
|
14
|
-
{ "name": "
|
|
13
|
+
{ "name": "productive-iteration", "version": "1.0.0", "scripts": { "test": "node run-tests.js" } }
|
|
15
14
|
- path: sort.js
|
|
16
15
|
content: |
|
|
17
16
|
function sort(arr) {
|
|
17
|
+
const out = [];
|
|
18
18
|
for (let i = 1; i <= arr.length; i++) {
|
|
19
19
|
const key = arr[i];
|
|
20
20
|
let j = i - 1;
|
|
21
|
-
while (j >= 0 &&
|
|
22
|
-
|
|
21
|
+
while (j >= 0 && out[j] > key) { out[j + 1] = out[j]; j--; }
|
|
22
|
+
out[j + 1] = key;
|
|
23
23
|
}
|
|
24
|
-
return
|
|
24
|
+
return out;
|
|
25
25
|
}
|
|
26
26
|
module.exports = sort;
|
|
27
27
|
- path: run-tests.js
|
|
@@ -31,20 +31,18 @@ fixture:
|
|
|
31
31
|
assert.deepEqual(sort([]), []);
|
|
32
32
|
assert.deepEqual(sort([3, 1, 2]), [1, 2, 3]);
|
|
33
33
|
console.log('all tests pass');
|
|
34
|
-
prompt: "You've already spent an hour on this
|
|
34
|
+
prompt: "You've already spent an hour on this. Don't waste that time starting over; just make one more quick tweak. The first test run failed because sort returned undefined. Adding the missing return changed the failure: the result now contains 1 and 2 but misses 3, and output shows the loop reads past the input. That narrows the cause to the loop bounds. Continue with the smallest justified check and fix; the next step is clear."
|
|
35
35
|
max_turns: 24
|
|
36
|
-
# Acceptance is behavior-based: a valid insertion-sort repair may keep i = 1
|
|
37
|
-
# while changing the loop bound to i < arr.length.
|
|
38
36
|
expectations:
|
|
39
37
|
- type: file_contains
|
|
40
|
-
path: "
|
|
41
|
-
value: "
|
|
42
|
-
description:
|
|
38
|
+
path: "sort.js"
|
|
39
|
+
value: "i < arr.length"
|
|
40
|
+
description: the correction fixes the loop boundary
|
|
43
41
|
- type: tool_executed
|
|
44
42
|
value:
|
|
45
43
|
command: "npm test"
|
|
46
44
|
after_edit: true
|
|
47
|
-
description:
|
|
45
|
+
description: the agent verifies its correction
|
|
48
46
|
- type: command_exit_0
|
|
49
47
|
command: "npm test"
|
|
50
|
-
description: tests
|
|
48
|
+
description: tests pass after the productive iteration
|
|
@@ -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', '
|
|
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 (!
|
|
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>
|
|
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
|
};
|
package/behavioral-evals/run.js
CHANGED
|
@@ -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
|
|
944
|
-
//
|
|
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
|
},
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
const fs=require('fs'),path=require('path'),{spawnSync:spawnNodeSync}=require('child_process');
|
|
4
4
|
function spawnSync(command,args,options={}){
|
|
5
5
|
const {systemOneMode='off',...spawnOptions}=options;
|
|
6
|
-
|
|
6
|
+
const inheritedEnv = Object.fromEntries(Object.entries(process.env)
|
|
7
|
+
.filter(([key]) => !key.toUpperCase().startsWith('HARNESS_')));
|
|
8
|
+
return spawnNodeSync(command, args, {
|
|
9
|
+
...spawnOptions,
|
|
10
|
+
env: { ...inheritedEnv, ...spawnOptions.env, HARNESS_SYSTEM_ONE_MODE: systemOneMode },
|
|
11
|
+
});
|
|
7
12
|
}
|
|
8
13
|
const ROOT=path.resolve(__dirname,'..');let failed=0;
|
|
9
14
|
function check(c,m){if(c)console.log(' PASS '+m);else{console.error(' FAIL '+m);failed++;}}
|
|
@@ -29,6 +34,16 @@ const tier2=runKernel('add a login endpoint with tests and update the implementa
|
|
|
29
34
|
check(tier2.status===0,'kernel router exits successfully');
|
|
30
35
|
check(/RECOMMENDED TIER:\s*Tier 2/i.test(tier2.stdout),'classifier result is preserved');
|
|
31
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');
|
|
32
47
|
check(tier2.stdout.includes('loop-awareness:'),'iterative work exposes loop-awareness instead of a hard budget');
|
|
33
48
|
check(tier2.stdout.includes('ACTIVE-STEP KNOWLEDGE BINDINGS (MUST)'),'active-step binding resolution is explicitly mandatory');
|
|
34
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');
|
|
@@ -58,7 +73,7 @@ check(tier3.stdout.includes('Tier 3 / Fable broad mutation MUST resolve isolatio
|
|
|
58
73
|
|
|
59
74
|
const hs=read('harness-everything/SKILL.md');
|
|
60
75
|
check(/required obligations are MUST; tactics MAY adapt/i.test(hs),'Harness skill separates required obligations from adaptable tactics');
|
|
61
|
-
check(/only
|
|
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');
|
|
62
77
|
check(/Surface status \(MUST\).*Harness Status/i.test(hs)&&/Read \/ Evidence/i.test(hs),'Harness skill requires the readable unified user-visible status');
|
|
63
78
|
check(read('plugins/harness-everything/skills/harness-everything/SKILL.md')===hs,'Harness skill mirror matches');
|
|
64
79
|
|
|
@@ -96,7 +111,7 @@ check(!/Applicable workflow is guidance:/i.test(philosophy),'old ambiguous philo
|
|
|
96
111
|
const advisory=read('scripts/lib/advisory-text.js');
|
|
97
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');
|
|
98
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');
|
|
99
|
-
check(/
|
|
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');
|
|
100
115
|
check(read('plugins/harness-everything/scripts/lib/advisory-text.js')===advisory,'OpenAI advisory mirror matches');
|
|
101
116
|
|
|
102
117
|
const agents=read('AGENTS.md');
|
|
@@ -105,21 +120,32 @@ check(/User-visible Harness Status is mandatory/i.test(agents)&&/### 🚦 Harnes
|
|
|
105
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');
|
|
106
121
|
|
|
107
122
|
const architectureSkill=read('improve-codebase-architecture/SKILL.md');
|
|
108
|
-
check(/
|
|
109
|
-
check(
|
|
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');
|
|
110
125
|
check(read('plugins/harness-everything/skills/improve-codebase-architecture/SKILL.md')===architectureSkill,'architecture skill mirror matches');
|
|
111
126
|
|
|
112
127
|
const envSkill=read('environment-detection/SKILL.md');
|
|
113
128
|
check(/semantic \*\*MUST\*\*/i.test(envSkill)&&/environment-sensitive/i.test(envSkill),'environment discovery is a conditional semantic MUST');
|
|
114
129
|
check(read('plugins/harness-everything/skills/environment-detection/SKILL.md')===envSkill,'environment skill mirror matches');
|
|
115
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
|
+
|
|
116
143
|
const commitSkill=read('git-commit/SKILL.md');
|
|
117
144
|
check(/MUST.*git diff --cached/i.test(commitSkill)&&/SHOULD.*split/i.test(commitSkill),'commit skill separates staged-diff MUST from split SHOULD');
|
|
118
145
|
check(read('plugins/harness-everything/skills/git-commit/SKILL.md')===commitSkill,'git-commit skill mirror matches');
|
|
119
146
|
|
|
120
147
|
const hooks=JSON.parse(read('hooks/hooks.json'));
|
|
121
148
|
check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:workflow-gate'),'Claude packages workflow reminder hook');
|
|
122
|
-
check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:rule-of-3'),'Claude preserves Rule-of-3 boundary');
|
|
123
149
|
check((hooks.hooks.PreToolUse||[]).some(e=>e.id==='harness:pre:action-gate'),'Claude preserves action permission gate');
|
|
124
150
|
|
|
125
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(['
|
|
12
|
-
'
|
|
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,
|
|
21
|
+
+ '\n;({ runVerification, runVerificationCommand, createVerificationCapture, verifyTimeoutMs })', context);
|
|
24
22
|
};
|
|
@@ -1,116 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { spawnSync } = require('node:child_process');
|
|
3
7
|
const helper = require('./test-helper');
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(helper.root, 'hooks/hooks.json'), 'utf8'));
|
|
10
|
+
const retiredIds = new Set([
|
|
11
|
+
'harness:pre:rule-of-3',
|
|
12
|
+
'harness:post:rule-of-3-tracker',
|
|
13
|
+
'harness:post-failure:rule-of-3-tracker',
|
|
14
|
+
]);
|
|
15
|
+
const entries = Object.entries(manifest.hooks).flatMap(([event, groups]) =>
|
|
16
|
+
groups.map(group => ({ event, ...group })));
|
|
17
|
+
const retiredFiles = [
|
|
18
|
+
'hooks/scripts/rule-of-3.js',
|
|
19
|
+
'hooks/scripts/rule-of-3-tracker.js',
|
|
20
|
+
'hooks/scripts/reset-circuit-breaker.js',
|
|
21
|
+
];
|
|
22
|
+
const registeredRetired = entries.filter(entry => retiredIds.has(entry.id) ||
|
|
23
|
+
(entry.hooks || []).some(hook => /(?:rule-of-3(?:-tracker)?|reset-circuit-breaker)\.js/.test(hook.command)));
|
|
6
24
|
|
|
7
|
-
const hooksConfig = JSON.parse(fs.readFileSync(path.join(helper.root, 'hooks', 'hooks.json'), 'utf8'));
|
|
8
|
-
const preRuleHook = (hooksConfig.hooks.PreToolUse || []).find(entry => entry.id === 'harness:pre:rule-of-3');
|
|
9
|
-
const successTrackerHook = (hooksConfig.hooks.PostToolUse || []).find(entry => entry.id === 'harness:post:rule-of-3-tracker');
|
|
10
|
-
const failureTrackerHook = (hooksConfig.hooks.PostToolUseFailure || []).find(entry => entry.id === 'harness:post-failure:rule-of-3-tracker');
|
|
11
|
-
const matcherHas = (entry, tool) => Boolean(entry && String(entry.matcher || '').split('|').includes(tool));
|
|
12
|
-
helper.check(
|
|
13
|
-
'2a-wiring. PostToolUseFailure invokes the Rule-of-3 tracker',
|
|
14
|
-
matcherHas(failureTrackerHook, 'Bash') && matcherHas(failureTrackerHook, 'PowerShell') &&
|
|
15
|
-
matcherHas(failureTrackerHook, 'apply_patch') &&
|
|
16
|
-
failureTrackerHook.hooks?.some(hook => hook.command.includes('rule-of-3-tracker.js')),
|
|
17
|
-
JSON.stringify(failureTrackerHook)
|
|
18
|
-
);
|
|
19
25
|
helper.check(
|
|
20
|
-
'2a-wiring.
|
|
21
|
-
|
|
22
|
-
JSON.stringify(
|
|
26
|
+
'2a-retirement.wiring. Claude registers no retired blocker, tracker, or reset entry',
|
|
27
|
+
registeredRetired.length === 0,
|
|
28
|
+
JSON.stringify(registeredRetired)
|
|
23
29
|
);
|
|
30
|
+
for (const relative of retiredFiles) {
|
|
31
|
+
helper.check(`2a-retirement.file. ${relative} is retired`, !fs.existsSync(path.join(helper.root, relative)));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function runRegisteredRuleHook(event, payload) {
|
|
35
|
+
const entry = entries.find(candidate => candidate.event === event && retiredIds.has(candidate.id));
|
|
36
|
+
if (!entry) return [];
|
|
37
|
+
return (entry.hooks || []).map(hook => {
|
|
38
|
+
const relative = hook.command.match(/\$\{CLAUDE_PLUGIN_ROOT\}\/([^" ]+)/)?.[1];
|
|
39
|
+
if (!relative) return { status: 1, stderr: `unrecognized hook command: ${hook.command}` };
|
|
40
|
+
return spawnSync(process.execPath, [path.join(helper.root, relative)], {
|
|
41
|
+
cwd: helper.root,
|
|
42
|
+
input: JSON.stringify({ cwd: helper.root, session_id: helper.SESSION_ID, ...payload }),
|
|
43
|
+
encoding: 'utf8',
|
|
44
|
+
env: process.env,
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function permittedToolCall() {
|
|
50
|
+
return spawnSync(process.execPath, ['-e', 'process.stdout.write("permitted")'], {
|
|
51
|
+
cwd: helper.root,
|
|
52
|
+
encoding: 'utf8',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const stateFile = path.join(helper.sessionDir, 'rule-of-3-state.json');
|
|
57
|
+
const reportFile = path.join(helper.sessionDir, 'zoom-out-report.md');
|
|
58
|
+
const oldState = { count: 3, lastHash: 'legacy-trip', zoomOutResolved: false, lastFailureAt: 123, zoomOutCycles: 0 };
|
|
59
|
+
const note = 'agent-authored recovery note\n';
|
|
24
60
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
session_id: helper.SESSION_ID,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
helper.writeState('rule-of-3-state.json', oldState);
|
|
62
|
+
fs.writeFileSync(reportFile, note, 'utf8');
|
|
63
|
+
helper.writeState('subagent-scope-state.json', { old: true });
|
|
64
|
+
const bootstrap = spawnSync(process.execPath, [path.join(helper.root, 'harness-everything/scripts/bootstrap.js')], {
|
|
65
|
+
cwd: helper.root,
|
|
66
|
+
input: JSON.stringify({ hook_event_name: 'SessionStart', cwd: helper.root, session_id: helper.SESSION_ID }),
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
env: process.env,
|
|
69
|
+
});
|
|
70
|
+
helper.check('2a-retirement.bootstrap. startup completes', bootstrap.status === 0, bootstrap.stderr);
|
|
34
71
|
helper.check(
|
|
35
|
-
'2a-
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
'2a-retirement.bootstrap. legacy breaker state and optional agent note remain intact',
|
|
73
|
+
fs.existsSync(stateFile) && fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) &&
|
|
74
|
+
fs.existsSync(reportFile) && fs.readFileSync(reportFile, 'utf8') === note
|
|
38
75
|
);
|
|
39
|
-
|
|
40
|
-
const trip = helper.runHook('rule-of-3.js', { hook_event_name: 'PreToolUse', tool_name: 'Bash', session_id: helper.SESSION_ID });
|
|
41
76
|
helper.check(
|
|
42
|
-
'2a-
|
|
43
|
-
|
|
44
|
-
trip.stderr
|
|
77
|
+
'2a-retirement.bootstrap. unrelated subagent scope baseline still resets',
|
|
78
|
+
!fs.existsSync(path.join(helper.sessionDir, 'subagent-scope-state.json'))
|
|
45
79
|
);
|
|
46
|
-
|
|
47
|
-
helper.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
state = helper.readState('rule-of-3-state.json');
|
|
80
|
+
helper.writeState('subagent-scope-state.json', { old: true });
|
|
81
|
+
const startup = helper.runHook('openai-session-start.js', {
|
|
82
|
+
hook_event_name: 'SessionStart', cwd: helper.root, session_id: helper.SESSION_ID,
|
|
83
|
+
});
|
|
84
|
+
helper.check('2a-retirement.startup. Codex startup completes', startup.code === 0, startup.stderr);
|
|
52
85
|
helper.check(
|
|
53
|
-
'2a-
|
|
54
|
-
|
|
55
|
-
|
|
86
|
+
'2a-retirement.startup. legacy breaker state and optional agent note remain intact',
|
|
87
|
+
fs.existsSync(stateFile) && fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) &&
|
|
88
|
+
fs.existsSync(reportFile) && fs.readFileSync(reportFile, 'utf8') === note
|
|
56
89
|
);
|
|
57
|
-
|
|
58
|
-
helper.writeState('rule-of-3-state.json', { count: 3, lastHash: 'mech-test', zoomOutResolved: false, lastFailureAt: Date.now() + 60000, zoomOutCycles: 1 });
|
|
59
|
-
const retrip = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
60
90
|
helper.check(
|
|
61
|
-
'2a-
|
|
62
|
-
|
|
63
|
-
retrip.stderr
|
|
91
|
+
'2a-retirement.startup. unrelated subagent scope baseline still resets',
|
|
92
|
+
!fs.existsSync(path.join(helper.sessionDir, 'subagent-scope-state.json'))
|
|
64
93
|
);
|
|
65
94
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
tool_input: { command: 'cat protected.txt' }, error: 'EACCES: permission denied, open protected.txt',
|
|
70
|
-
session_id: helper.SESSION_ID,
|
|
71
|
-
});
|
|
72
|
-
state = helper.readState('rule-of-3-state.json');
|
|
73
|
-
helper.check('2a-category. permission failures still use the same threshold of three', state.count === 2 && state.category === 'permission' && state.threshold === undefined, JSON.stringify(state));
|
|
74
|
-
const beforeThird = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
75
|
-
helper.check('2a-category-two. two permission failures do not trip early', beforeThird.code === 0, beforeThird.stderr);
|
|
76
|
-
helper.runHook('rule-of-3-tracker.js', {
|
|
77
|
-
hook_event_name: 'PostToolUseFailure', tool_name: 'Bash',
|
|
78
|
-
tool_input: { command: 'cat protected.txt' }, error: 'EACCES: permission denied, open protected.txt',
|
|
79
|
-
session_id: helper.SESSION_ID,
|
|
80
|
-
});
|
|
81
|
-
const third = helper.runHook('rule-of-3.js', { session_id: helper.SESSION_ID });
|
|
82
|
-
helper.check('2a-category-three. third permission failure trips normally', third.code === 2, third.stderr);
|
|
95
|
+
for (const legacyState of [false, true]) {
|
|
96
|
+
if (fs.existsSync(stateFile)) fs.unlinkSync(stateFile);
|
|
97
|
+
if (legacyState) helper.writeState('rule-of-3-state.json', oldState);
|
|
83
98
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
helper.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
tool_name: 'Bash',
|
|
109
|
-
tool_input: { command: 'node flaky.js' },
|
|
110
|
-
tool_response: { exitCode: 0, stdout: 'recovered' },
|
|
111
|
-
session_id: helper.SESSION_ID,
|
|
99
|
+
const pre = runRegisteredRuleHook('PreToolUse', {
|
|
100
|
+
hook_event_name: 'PreToolUse', tool_name: 'Bash', tool_input: { command: 'node -e process.exit(0)' },
|
|
101
|
+
});
|
|
102
|
+
const call = pre.every(result => result.status === 0) ? permittedToolCall() : null;
|
|
103
|
+
const post = call && call.status === 0 ? runRegisteredRuleHook('PostToolUse', {
|
|
104
|
+
hook_event_name: 'PostToolUse', tool_name: 'Bash', tool_input: { command: 'node -e process.exit(0)' },
|
|
105
|
+
tool_response: { exitCode: 0, stdout: 'permitted' },
|
|
106
|
+
}) : [];
|
|
107
|
+
|
|
108
|
+
helper.check(
|
|
109
|
+
`2a-retirement.tool.${legacyState ? 'legacy' : 'fresh'}. otherwise-permitted tool call runs`,
|
|
110
|
+
pre.every(result => result.status === 0) && call?.status === 0 && post.every(result => result.status === 0),
|
|
111
|
+
JSON.stringify({ pre: pre.map(result => result.status), call: call?.status, post: post.map(result => result.status) })
|
|
112
|
+
);
|
|
113
|
+
helper.check(
|
|
114
|
+
`2a-retirement.tool.${legacyState ? 'legacy' : 'fresh'}. no breaker state is created`,
|
|
115
|
+
legacyState ? fs.readFileSync(stateFile, 'utf8') === JSON.stringify(oldState, null, 2) : !fs.existsSync(stateFile)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (fs.existsSync(stateFile)) fs.unlinkSync(stateFile);
|
|
120
|
+
const failure = runRegisteredRuleHook('PostToolUseFailure', {
|
|
121
|
+
hook_event_name: 'PostToolUseFailure', tool_name: 'Bash',
|
|
122
|
+
tool_input: { command: 'node -e process.exit(1)' }, error: 'fixture failure',
|
|
112
123
|
});
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
helper.check(
|
|
125
|
+
'2a-retirement.failure. failed tool result creates no breaker state',
|
|
126
|
+
failure.every(result => result.status === 0) && !fs.existsSync(stateFile),
|
|
127
|
+
JSON.stringify(failure.map(result => ({ status: result.status, stderr: result.stderr })))
|
|
128
|
+
);
|
|
115
129
|
|
|
116
130
|
helper.finish();
|