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.
- 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 +13 -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 +26 -5
- package/ci/lib/opencode-verification-loader.js +3 -5
- package/ci/mechanism-2a-rule-of-3.test.js +111 -97
- package/ci/mechanism-2n-opencode-plugin.test.js +68 -206
- package/ci/mechanism-2p-opencode-v2-entrypoint.test.js +47 -28
- package/ci/mechanism-2w-platform-compatibility.test.js +1 -0
- package/ci/mechanism-32-paired-benchmark.test.js +1 -2
- package/ci/mechanism-33-issues-205-207.test.js +1 -1
- package/ci/mechanism-338-opencode-async.test.js +18 -49
- package/ci/mechanism-36-verify-timeout.test.js +3 -189
- package/ci/mechanism-39-opencode-verify-outcomes.test.js +56 -323
- package/ci/mechanism-397-opencode-observations.test.js +6 -7
- package/ci/mechanism-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/self-evolve-loop.test.js +51 -51
- package/ci/workflow-execution-contract.test.js +3 -6
- package/docker-verify.sh +1 -117
- package/docs/architecture.md +9 -7
- package/docs/document-lifecycle.md +1 -1
- package/docs/enforcement-locks.md +12 -10
- package/docs/mechanism-first-skill-mesh.md +2 -2
- package/docs/openai-plugin.md +3 -3
- package/docs/philosophy.md +1 -1
- package/docs/platform-capabilities.md +2 -2
- package/docs/platform-compatibility.json +2 -2
- package/docs/reflection.md +1 -1
- package/docs/routing.md +2 -2
- package/docs/system-one-suggestion-gates.md +4 -4
- package/docs/troubleshooting.md +9 -35
- package/docs/workflow-runtime.md +19 -18
- package/docs/workflows/environment-detection.md +11 -9
- package/docs/workflows/fable-discipline.md +6 -5
- package/docs/workflows/fable-mode.md +6 -5
- package/docs/workflows/harness-everything.md +5 -5
- package/docs/workflows/improve-codebase-architecture.md +10 -8
- package/docs/workflows/install-cognitive-os.md +5 -5
- package/docs/workflows/tdd.md +9 -9
- package/docs/workflows/zoom-out.md +20 -30
- package/environment-detection/SKILL.md +2 -2
- package/environment-detection/references/shell-syntax-rules.md +1 -1
- package/eval-harness/SKILL.md +1 -1
- package/eval-harness/references/scoring-rubric.md +3 -3
- package/evals/zoom-out/eval.yaml +2 -2
- package/evals/zoom-out/tasks/negative-productive-iteration.yaml +15 -0
- package/evals/zoom-out/tasks/negative-trivial-edit.yaml +6 -6
- package/evals/zoom-out/tasks/positive-first-failure.yaml +15 -0
- package/evals/zoom-out/tasks/positive-repair-loop.yaml +1 -1
- package/fable-discipline/SKILL.md +3 -3
- package/fable-discipline/references/discipline-rules.md +1 -1
- package/fable-mode/SKILL.md +1 -1
- package/fable-mode/execution-guardrails/SKILL.md +2 -4
- package/fable-mode/execution-guardrails/references/guardrail-rules.md +3 -3
- package/fable-mode/fable-haiku/SKILL.md +1 -1
- package/fable-mode/fable-opus/SKILL.md +2 -2
- package/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/fable-mode/references/execution-phases.md +2 -2
- package/harness-everything/SKILL.md +3 -3
- package/harness-everything/references/router-workflow-plan.md +2 -2
- package/harness-everything/references/skill-registry.md +2 -2
- package/harness-everything/references/triage-and-tiers.md +5 -5
- package/harness-everything/scripts/bootstrap.js +1 -26
- package/harness-everything/scripts/kernel-router-core.js +2 -3
- package/harness-everything/scripts/kernel-router.js +1 -1
- package/harness-everything/scripts/router-contract-core.js +1 -1
- package/harness-everything/scripts/routing-keywords.json +0 -2
- package/hooks/hooks.json +0 -33
- package/hooks/scripts/lib/harness-state.js +5 -6
- package/hooks/scripts/lib/learning-opportunity.js +3 -13
- package/hooks/scripts/openai-session-start.js +2 -4
- package/improve-codebase-architecture/SKILL.md +3 -3
- package/improve-codebase-architecture/guides/refactoring-workflow.md +5 -4
- package/install-cognitive-os/SKILL.md +3 -3
- package/opencode-plugin/README.md +12 -43
- package/opencode-plugin/index.mjs +21 -368
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +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/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/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
|
@@ -4,367 +4,100 @@ const crypto = require('crypto');
|
|
|
4
4
|
const { pathToFileURL } = require('url');
|
|
5
5
|
const helper = require('./test-helper');
|
|
6
6
|
|
|
7
|
-
console.log('\n[39] opencode verification outcomes
|
|
7
|
+
console.log('\n[39] opencode verification outcomes and reminders with the real plugin...');
|
|
8
8
|
|
|
9
9
|
(async () => {
|
|
10
10
|
const workspace = helper.tempDir('.mechanism-test-verify-outcomes-workspace');
|
|
11
11
|
fs.mkdirSync(workspace, { recursive: true });
|
|
12
12
|
const stateHome = process.env.HARNESS_STATE_HOME;
|
|
13
|
-
|
|
14
|
-
// Mirrors the plugin's getWorkspaceKey(directory) (same derivation as the
|
|
15
|
-
// 2n test) so this harness can read the state files the real hooks write.
|
|
16
13
|
const realWorkspace = fs.realpathSync(path.resolve(workspace));
|
|
17
14
|
const slug = path.basename(realWorkspace).toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'workspace';
|
|
18
15
|
const hashInput = process.platform === 'win32' ? realWorkspace.toLowerCase() : realWorkspace;
|
|
19
16
|
const hash = crypto.createHash('sha1').update(hashInput).digest('hex').slice(0, 12);
|
|
20
17
|
const sessionsRoot = path.join(stateHome, 'workspaces', `${slug}-${hash}`, 'state', 'sessions');
|
|
21
|
-
|
|
22
18
|
const fixtureFile = path.join(workspace, 'fixture.js');
|
|
23
|
-
fs.writeFileSync(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
const setFixture = (lines) => fs.writeFileSync(fixtureFile, `${lines.join('\n')}\n`);
|
|
28
|
-
const markerFailure = (name) => [
|
|
29
|
-
"console.log('> harness-everything@0.34.0 test');",
|
|
30
|
-
"console.log('> node self-evolve/scripts/self-regression.js');",
|
|
31
|
-
`console.log('\u2716 ${name} (1.2ms)');`,
|
|
32
|
-
`console.log('AssertionError [ERR_ASSERTION]: ${name} boom');`,
|
|
33
|
-
'process.exit(1);',
|
|
34
|
-
];
|
|
19
|
+
fs.writeFileSync(path.join(workspace, 'package.json'), JSON.stringify({
|
|
20
|
+
name: 'fixture', version: '0.0.0', scripts: { test: 'node fixture.js' }
|
|
21
|
+
}, null, 2));
|
|
22
|
+
const setFixture = (source) => fs.writeFileSync(fixtureFile, `${source}\n`);
|
|
35
23
|
|
|
36
24
|
const promptCalls = [];
|
|
37
25
|
const client = { session: { prompt: async (opts) => { promptCalls.push(opts); return {}; } } };
|
|
38
26
|
const { HarnessEnforcement } = await import(pathToFileURL(path.join(helper.root, 'opencode-plugin', 'index.mjs')).href);
|
|
39
27
|
const hooks = await HarnessEnforcement({ client, directory: workspace });
|
|
40
|
-
|
|
41
|
-
const stateFile = (sessionID, name) => path.join(sessionsRoot, sessionID, name);
|
|
42
|
-
const readBreaker = (sessionID) => JSON.parse(fs.readFileSync(stateFile(sessionID, 'circuit-breaker.json'), 'utf8'));
|
|
43
|
-
const readEditState = (sessionID) => JSON.parse(fs.readFileSync(stateFile(sessionID, 'edit-state.json'), 'utf8'));
|
|
44
28
|
let callCounter = 0;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
29
|
+
const sessionID = 'repeated-failures';
|
|
30
|
+
const edit = async (id = sessionID) => {
|
|
31
|
+
await hooks['tool.execute.before']({ tool: 'edit', sessionID: id, callID: `before-${++callCounter}` }, { args: {} });
|
|
32
|
+
await hooks['tool.execute.after'](
|
|
33
|
+
{ tool: 'edit', sessionID: id, callID: `after-${callCounter}` },
|
|
34
|
+
{ title: '', output: '', metadata: {}, args: { filePath: path.join(workspace, 'code.js') } },
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
const idle = async (id = sessionID) => hooks.event({ event: { type: 'session.idle', properties: { sessionID: id } } });
|
|
38
|
+
const stateFile = (id, name) => path.join(sessionsRoot, id, name);
|
|
50
39
|
const lastPrompt = () => promptCalls[promptCalls.length - 1].body.parts[0].text;
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
setFixture("console.error('AssertionError [ERR_ASSERTION]: stable fixture failure');process.exit(1);");
|
|
42
|
+
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
43
|
+
let allowed = true;
|
|
44
|
+
try {
|
|
45
|
+
await edit();
|
|
46
|
+
} catch {
|
|
47
|
+
allowed = false;
|
|
48
|
+
}
|
|
49
|
+
if (!allowed) break;
|
|
50
|
+
await idle();
|
|
59
51
|
}
|
|
60
|
-
|
|
61
|
-
const timeoutPrompts = promptCalls.slice(0, 3).map((call) => call.body.parts[0].text);
|
|
52
|
+
const failedPrompts = promptCalls.map((call) => call.body.parts[0].text);
|
|
62
53
|
helper.check(
|
|
63
|
-
'39.
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
'39. four identical test failures each produce a reminder and do not block the next edit',
|
|
55
|
+
failedPrompts.length === 4 && failedPrompts.every((text) => /verification failed/i.test(text)
|
|
56
|
+
&& !/reflection token|## Goal|forced reflection|retries before/i.test(text)),
|
|
57
|
+
JSON.stringify(failedPrompts),
|
|
66
58
|
);
|
|
67
59
|
helper.check(
|
|
68
|
-
'39.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
!timeoutPrompts.some((text) => /reflection token|## Goal/.test(text)),
|
|
72
|
-
timeoutPrompts[0],
|
|
60
|
+
'39. repeated test failures create no recurrence state',
|
|
61
|
+
!fs.existsSync(stateFile(sessionID, 'circuit-breaker.json')),
|
|
62
|
+
stateFile(sessionID, 'circuit-breaker.json'),
|
|
73
63
|
);
|
|
64
|
+
let readAllowed = true;
|
|
65
|
+
try {
|
|
66
|
+
await hooks['tool.execute.before']({ tool: 'read', sessionID, callID: 'read-after-failures' }, { args: {} });
|
|
67
|
+
} catch {
|
|
68
|
+
readAllowed = false;
|
|
69
|
+
}
|
|
70
|
+
helper.check('39. a permitted read remains available after repeated failures', readAllowed);
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
const timeoutSession = 'timeout';
|
|
73
|
+
setFixture('setTimeout(() => {}, 3000);');
|
|
74
|
+
process.env.HARNESS_VERIFY_TIMEOUT_MS = '100';
|
|
76
75
|
await edit(timeoutSession);
|
|
77
76
|
await idle(timeoutSession);
|
|
78
|
-
|
|
79
|
-
let entries = Object.values(breaker.failures);
|
|
80
|
-
helper.check(
|
|
81
|
-
'39. a real failing check after three timeouts counts once, with no reflection',
|
|
82
|
-
entries.length === 1 && entries[0].count === 1 && breaker.reflectionPending === false,
|
|
83
|
-
JSON.stringify(breaker),
|
|
84
|
-
);
|
|
85
|
-
helper.check(
|
|
86
|
-
'39. the post-timeout failure prompt offers retries instead of reflection',
|
|
87
|
-
/2 retries before a forced reflection/.test(lastPrompt()),
|
|
88
|
-
lastPrompt(),
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// --- distinct failures sharing a banner stay distinct -----------------
|
|
92
|
-
const distinctSession = 'distinct';
|
|
93
|
-
for (const name of ['alpha', 'beta', 'gamma']) {
|
|
94
|
-
setFixture(markerFailure(name));
|
|
95
|
-
await edit(distinctSession);
|
|
96
|
-
await idle(distinctSession);
|
|
97
|
-
}
|
|
98
|
-
breaker = readBreaker(distinctSession);
|
|
99
|
-
entries = Object.values(breaker.failures);
|
|
100
|
-
helper.check(
|
|
101
|
-
'39. distinct failures behind a common banner stay three separate signatures',
|
|
102
|
-
Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
|
|
103
|
-
JSON.stringify(breaker),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// --- identical stdout, different stderr assertions stay distinct ------
|
|
107
|
-
// P1 regression: the old classifier kept only stdout, so three assertion
|
|
108
|
-
// failures printed to stderr behind the same npm banner collapsed into one
|
|
109
|
-
// signature and forced a reflection for healthy retries.
|
|
110
|
-
const stderrSession = 'stderr-distinct';
|
|
111
|
-
const stderrFailure = (name) => [
|
|
112
|
-
`console.error('AssertionError [ERR_ASSERTION]: ${name} boom');`,
|
|
113
|
-
'process.exit(1);',
|
|
114
|
-
];
|
|
115
|
-
for (const name of ['alpha', 'beta', 'gamma']) {
|
|
116
|
-
setFixture(stderrFailure(name));
|
|
117
|
-
await edit(stderrSession);
|
|
118
|
-
await idle(stderrSession);
|
|
119
|
-
}
|
|
120
|
-
breaker = readBreaker(stderrSession);
|
|
121
|
-
entries = Object.values(breaker.failures);
|
|
122
|
-
helper.check(
|
|
123
|
-
'39. identical stdout with different stderr assertions stays three separate signatures',
|
|
124
|
-
Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
|
|
125
|
-
JSON.stringify(breaker),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
// --- >2 KiB shared prefix, different markerless tails stay distinct ---
|
|
129
|
-
// P1 regression: the old 2 KiB leading-prefix truncation hashed the same
|
|
130
|
-
// prefix for all three runs, so different markerless failures collided.
|
|
131
|
-
const prefixSession = 'prefix-distinct';
|
|
132
|
-
const markerlessFailure = (token) => [
|
|
133
|
-
"console.log('progress '.repeat(400));",
|
|
134
|
-
`console.log('HARNESS-UNIQUE-${token}');`,
|
|
135
|
-
'process.exit(1);',
|
|
136
|
-
];
|
|
137
|
-
for (const token of ['ALPHA', 'BETA', 'GAMMA']) {
|
|
138
|
-
setFixture(markerlessFailure(token));
|
|
139
|
-
await edit(prefixSession);
|
|
140
|
-
await idle(prefixSession);
|
|
141
|
-
}
|
|
142
|
-
breaker = readBreaker(prefixSession);
|
|
143
|
-
entries = Object.values(breaker.failures);
|
|
144
|
-
helper.check(
|
|
145
|
-
'39. a shared >2 KiB markerless prefix with different tails stays three separate signatures',
|
|
146
|
-
Object.keys(breaker.failures).length === 3 &&
|
|
147
|
-
entries.every((entry) => entry.count === 1) &&
|
|
148
|
-
Object.keys(breaker.failures).every((signature) => /unrecognized-output/.test(signature)) &&
|
|
149
|
-
breaker.reflectionPending === false,
|
|
150
|
-
JSON.stringify(breaker),
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// --- Jest suite output: FAIL <file> is context, not identity -----------
|
|
154
|
-
// P1 regression: the old classifier returned the first matching line, so
|
|
155
|
-
// `FAIL src/parser.test.js` made three different test failures in the same
|
|
156
|
-
// file one signature and forced a reflection.
|
|
157
|
-
const jestSession = 'jest-distinct';
|
|
158
|
-
const jestFailure = (name) => [
|
|
159
|
-
"console.log('FAIL src/parser.test.js');",
|
|
160
|
-
`console.log(' ● parser › accepts ${name}');`,
|
|
161
|
-
`console.log(' AssertionError: ${name}');`,
|
|
162
|
-
'process.exit(1);',
|
|
163
|
-
];
|
|
164
|
-
for (const name of ['alpha', 'beta', 'gamma']) {
|
|
165
|
-
setFixture(jestFailure(name));
|
|
166
|
-
await edit(jestSession);
|
|
167
|
-
await idle(jestSession);
|
|
168
|
-
}
|
|
169
|
-
breaker = readBreaker(jestSession);
|
|
170
|
-
entries = Object.values(breaker.failures);
|
|
171
|
-
helper.check(
|
|
172
|
-
'39. different Jest failures from one file stay three separate signatures',
|
|
173
|
-
Object.keys(breaker.failures).length === 3 && entries.every((entry) => entry.count === 1) && breaker.reflectionPending === false,
|
|
174
|
-
JSON.stringify(breaker),
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
const jestIdenticalSession = 'jest-identical';
|
|
178
|
-
setFixture(jestFailure('stable'));
|
|
179
|
-
for (let i = 0; i < 3; i += 1) {
|
|
180
|
-
await edit(jestIdenticalSession);
|
|
181
|
-
await idle(jestIdenticalSession);
|
|
182
|
-
}
|
|
183
|
-
breaker = readBreaker(jestIdenticalSession);
|
|
184
|
-
entries = Object.values(breaker.failures);
|
|
185
|
-
helper.check(
|
|
186
|
-
'39. three identical Jest failures still force the Rule-of-3 reflection',
|
|
187
|
-
Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
|
|
188
|
-
JSON.stringify(breaker),
|
|
189
|
-
);
|
|
190
|
-
helper.check(
|
|
191
|
-
'39. the Jest-identical reflection prompt names the token',
|
|
192
|
-
/reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
|
|
193
|
-
lastPrompt(),
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
// --- indented Mocha tests: true identity survives volatile diagnostics ---
|
|
198
|
-
// P2 regression: the old unindented regex missed " 1) test", then the
|
|
199
|
-
// markerless digest changed on every stack-line number even for the same
|
|
200
|
-
// failing check, preventing Rule-of-3 from reaching reflection.
|
|
201
|
-
const mochaFailure = (name, frameLine) => [
|
|
202
|
-
`console.log(' 1) should parse ${name}');`,
|
|
203
|
-
"console.error(' AssertionError: expected true to equal false');",
|
|
204
|
-
`console.log(' at Context.<anonymous> (fixture.test.js:${frameLine}:7)');`,
|
|
205
|
-
'process.exit(1);',
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
const mochaDistinctSession = 'mocha-distinct';
|
|
209
|
-
for (const name of ['alpha', 'beta', 'gamma']) {
|
|
210
|
-
setFixture(mochaFailure(name, 19));
|
|
211
|
-
await edit(mochaDistinctSession);
|
|
212
|
-
await idle(mochaDistinctSession);
|
|
213
|
-
}
|
|
214
|
-
breaker = readBreaker(mochaDistinctSession);
|
|
215
|
-
entries = Object.values(breaker.failures);
|
|
216
|
-
helper.check(
|
|
217
|
-
'39. different indented Mocha checks never count as one repeated failure',
|
|
218
|
-
Object.keys(breaker.failures).length === 3 &&
|
|
219
|
-
entries.every((entry) => entry.count === 1) &&
|
|
220
|
-
breaker.reflectionPending === false,
|
|
221
|
-
JSON.stringify(breaker),
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
const mochaIdenticalSession = 'mocha-identical';
|
|
225
|
-
for (const frameLine of [19, 27, 35]) {
|
|
226
|
-
setFixture(mochaFailure('stable', frameLine));
|
|
227
|
-
await edit(mochaIdenticalSession);
|
|
228
|
-
await idle(mochaIdenticalSession);
|
|
229
|
-
}
|
|
230
|
-
breaker = readBreaker(mochaIdenticalSession);
|
|
231
|
-
entries = Object.values(breaker.failures);
|
|
232
|
-
helper.check(
|
|
233
|
-
'39. same indented Mocha check with changing stack output still triggers Rule-of-3',
|
|
234
|
-
Object.keys(breaker.failures).length === 1 &&
|
|
235
|
-
entries[0].count === 3 &&
|
|
236
|
-
breaker.reflectionPending === true,
|
|
237
|
-
JSON.stringify(breaker),
|
|
238
|
-
);
|
|
239
|
-
helper.check(
|
|
240
|
-
'39. Mocha Rule-of-3 reflection includes a token',
|
|
241
|
-
/reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
|
|
242
|
-
lastPrompt(),
|
|
243
|
-
);
|
|
244
|
-
|
|
245
|
-
// --- Console payload noise: logged Error lines are not failure identity ---
|
|
246
|
-
// Regression guard for the indented-error pattern: a Jest Console payload
|
|
247
|
-
// (logged output, volatile run to run) must not become the marker, or the
|
|
248
|
-
// same failing check stops accumulating toward the Rule of 3.
|
|
249
|
-
const consoleNoisyFailure = [
|
|
250
|
-
"console.log('PASS src/loggy.test.js');",
|
|
251
|
-
"console.log(' ● Console');",
|
|
252
|
-
"console.log('');",
|
|
253
|
-
"console.log(' console.error');",
|
|
254
|
-
"console.log(' Error: connection refused at ' + Date.now());",
|
|
255
|
-
"console.log('');",
|
|
256
|
-
"console.log('FAIL src/parser.test.js');",
|
|
257
|
-
"console.log(' ● parser › accepts stable');",
|
|
258
|
-
'process.exit(1);',
|
|
259
|
-
];
|
|
260
|
-
const consoleNoiseSession = 'console-noise';
|
|
261
|
-
for (let i = 0; i < 3; i += 1) {
|
|
262
|
-
setFixture(consoleNoisyFailure);
|
|
263
|
-
await edit(consoleNoiseSession);
|
|
264
|
-
await idle(consoleNoiseSession);
|
|
265
|
-
}
|
|
266
|
-
breaker = readBreaker(consoleNoiseSession);
|
|
267
|
-
entries = Object.values(breaker.failures);
|
|
268
|
-
helper.check(
|
|
269
|
-
'39. volatile Console payload noise never breaks the failing check identity',
|
|
270
|
-
Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
|
|
271
|
-
JSON.stringify(breaker),
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
// --- nested Jest Console bullets are payload, not test-level markers ---
|
|
275
|
-
// The previous fix only excluded indented Error lines. A logged "●" used
|
|
276
|
-
// to terminate the Console section regardless of indentation, causing
|
|
277
|
-
// either false reflection (shared console text) or missed Rule-of-3
|
|
278
|
-
// (volatile console text) for actual Jest failures.
|
|
279
|
-
const consoleBulletFailure = (name, noise) => [
|
|
280
|
-
"console.log('PASS src/loggy.test.js');",
|
|
281
|
-
"console.log(' ● Console');",
|
|
282
|
-
"console.log('');",
|
|
283
|
-
"console.log(' console.log');",
|
|
284
|
-
`console.log(' ● ${noise}');`,
|
|
285
|
-
"console.log(' ● Console');",
|
|
286
|
-
"console.log('');",
|
|
287
|
-
"console.log('FAIL src/parser.test.js');",
|
|
288
|
-
`console.log(' ● parser › accepts ${name}');`,
|
|
289
|
-
'process.exit(1);',
|
|
290
|
-
];
|
|
291
|
-
|
|
292
|
-
const consoleBulletDistinctSession = 'console-bullet-distinct';
|
|
293
|
-
for (const name of ['alpha', 'beta', 'gamma']) {
|
|
294
|
-
setFixture(consoleBulletFailure(name, 'preparing runtime'));
|
|
295
|
-
await edit(consoleBulletDistinctSession);
|
|
296
|
-
await idle(consoleBulletDistinctSession);
|
|
297
|
-
}
|
|
298
|
-
breaker = readBreaker(consoleBulletDistinctSession);
|
|
299
|
-
entries = Object.values(breaker.failures);
|
|
300
|
-
helper.check(
|
|
301
|
-
'39. shared nested Console bullet with different Jest failures never causes false Rule-of-3',
|
|
302
|
-
Object.keys(breaker.failures).length === 3 &&
|
|
303
|
-
entries.every((entry) => entry.count === 1) &&
|
|
304
|
-
breaker.reflectionPending === false,
|
|
305
|
-
JSON.stringify(breaker),
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
const consoleBulletIdenticalSession = 'console-bullet-identical';
|
|
309
|
-
for (const noise of ['preparing runtime', 'loading plugins', 'initialization complete']) {
|
|
310
|
-
setFixture(consoleBulletFailure('stable', noise));
|
|
311
|
-
await edit(consoleBulletIdenticalSession);
|
|
312
|
-
await idle(consoleBulletIdenticalSession);
|
|
313
|
-
}
|
|
314
|
-
breaker = readBreaker(consoleBulletIdenticalSession);
|
|
315
|
-
entries = Object.values(breaker.failures);
|
|
316
|
-
helper.check(
|
|
317
|
-
'39. differing nested Console bullets do not stop the same Jest failure from reaching Rule-of-3',
|
|
318
|
-
Object.keys(breaker.failures).length === 1 &&
|
|
319
|
-
entries[0].count === 3 &&
|
|
320
|
-
breaker.reflectionPending === true,
|
|
321
|
-
JSON.stringify(breaker),
|
|
322
|
-
);
|
|
323
|
-
helper.check(
|
|
324
|
-
'39. nested Console bullet Rule-of-3 produces a reflection token',
|
|
325
|
-
/reflection token: [A-Za-z0-9]+/.test(lastPrompt()),
|
|
326
|
-
lastPrompt(),
|
|
327
|
-
);
|
|
328
|
-
|
|
329
|
-
// --- genuinely identical failures keep the Rule of 3 ------------------
|
|
330
|
-
const identicalSession = 'identical';
|
|
331
|
-
setFixture(markerFailure('stable check'));
|
|
332
|
-
for (let i = 0; i < 3; i += 1) {
|
|
333
|
-
await edit(identicalSession);
|
|
334
|
-
await idle(identicalSession);
|
|
335
|
-
}
|
|
336
|
-
breaker = readBreaker(identicalSession);
|
|
337
|
-
entries = Object.values(breaker.failures);
|
|
338
|
-
helper.check(
|
|
339
|
-
'39. three genuinely identical failures still force the Rule-of-3 reflection',
|
|
340
|
-
Object.keys(breaker.failures).length === 1 && entries[0].count === 3 && breaker.reflectionPending === true,
|
|
341
|
-
JSON.stringify(breaker),
|
|
342
|
-
);
|
|
77
|
+
delete process.env.HARNESS_VERIFY_TIMEOUT_MS;
|
|
343
78
|
helper.check(
|
|
344
|
-
'39.
|
|
345
|
-
/
|
|
79
|
+
'39. a timeout is reported as incomplete verification without reflection or a counter',
|
|
80
|
+
/did not complete/.test(lastPrompt()) && /timed out/.test(lastPrompt())
|
|
81
|
+
&& !/reflection token|## Goal|does NOT count|retries before/i.test(lastPrompt())
|
|
82
|
+
&& !fs.existsSync(stateFile(timeoutSession, 'circuit-breaker.json')),
|
|
346
83
|
lastPrompt(),
|
|
347
84
|
);
|
|
348
85
|
|
|
349
|
-
// --- success after failure clears pending state -----------------------
|
|
350
86
|
const recoverSession = 'recover';
|
|
351
|
-
setFixture(
|
|
87
|
+
setFixture("console.error('AssertionError [ERR_ASSERTION]: recoverable failure');process.exit(1);");
|
|
352
88
|
await edit(recoverSession);
|
|
353
89
|
await idle(recoverSession);
|
|
354
90
|
const promptsBeforeSuccess = promptCalls.length;
|
|
355
|
-
setFixture(
|
|
91
|
+
setFixture('process.exit(0);');
|
|
356
92
|
await edit(recoverSession);
|
|
357
93
|
await idle(recoverSession);
|
|
358
|
-
const recoveredState =
|
|
359
|
-
breaker = readBreaker(recoverSession);
|
|
360
|
-
entries = Object.values(breaker.failures);
|
|
94
|
+
const recoveredState = JSON.parse(fs.readFileSync(stateFile(recoverSession, 'edit-state.json'), 'utf8'));
|
|
361
95
|
helper.check(
|
|
362
|
-
'39. a passing
|
|
363
|
-
recoveredState.verificationPending === false &&
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
JSON.stringify({ recoveredState, breaker }),
|
|
96
|
+
'39. a passing verification clears pending state without an extra reminder',
|
|
97
|
+
recoveredState.verificationPending === false && recoveredState.editsSinceVerification === 0
|
|
98
|
+
&& promptCalls.length === promptsBeforeSuccess
|
|
99
|
+
&& !fs.existsSync(stateFile(recoverSession, 'circuit-breaker.json')),
|
|
100
|
+
JSON.stringify(recoveredState),
|
|
368
101
|
);
|
|
369
102
|
|
|
370
103
|
helper.finish();
|
|
@@ -1112,9 +1112,9 @@ test('V2 consumers α3: both completion orders and a post-completion counterpart
|
|
|
1112
1112
|
}
|
|
1113
1113
|
});
|
|
1114
1114
|
|
|
1115
|
-
test('V2 consumers α3: duplicate completion notifications do not
|
|
1115
|
+
test('V2 consumers α3: duplicate completion notifications do not duplicate verification', { concurrency: false }, async () => {
|
|
1116
1116
|
const f = fixture('off');
|
|
1117
|
-
const sessionID = 'v2-
|
|
1117
|
+
const sessionID = 'v2-duplicate-completion';
|
|
1118
1118
|
const checkLog = path.join(f.dir, 'check-runs.txt');
|
|
1119
1119
|
writeVerificationPackage(f, `const fs=require('node:fs');fs.appendFileSync(${JSON.stringify(checkLog)},'x\\n');console.error('AssertionError [ERR_ASSERTION]: stable fixture failure');process.exit(1)`);
|
|
1120
1120
|
let dispose;
|
|
@@ -1139,12 +1139,11 @@ test('V2 consumers α3: duplicate completion notifications do not advance Rule-o
|
|
|
1139
1139
|
assert.equal(await waitUntil(() => fs.existsSync(editStateArtifact(f.workspace, sessionID))
|
|
1140
1140
|
&& readJson(editStateArtifact(f.workspace, sessionID)).followUpPending === true), true,
|
|
1141
1141
|
`revision ${i + 1} recorded one completed failing check`);
|
|
1142
|
-
const breaker = readJson(path.join(stateDir(f.workspace, sessionID), 'circuit-breaker.json'));
|
|
1143
|
-
const count = Object.values(breaker.failures)[0]?.count;
|
|
1144
|
-
assert.equal(count, i + 1, `duplicate completion for revision ${i + 1} does not add a failure`);
|
|
1145
|
-
assert.equal(breaker.reflectionPending, i === 2, 'reflection is forced only on the third separate failed revision');
|
|
1146
1142
|
assert.equal(fs.readFileSync(checkLog, 'utf8').trim().split(/\r?\n/).length, i + 1, 'one check ran per edit revision');
|
|
1147
|
-
assert.equal(
|
|
1143
|
+
assert.equal(fs.existsSync(path.join(stateDir(f.workspace, sessionID), 'circuit-breaker.json')), false,
|
|
1144
|
+
'verification failure does not create recurrence state');
|
|
1145
|
+
assert.equal(readJson(path.join(stateDir(f.workspace, sessionID), 'compliance.json')).totalEdits, i + 1,
|
|
1146
|
+
'each new edit is recorded once');
|
|
1148
1147
|
}
|
|
1149
1148
|
} finally {
|
|
1150
1149
|
if (dispose) await dispose();
|
|
@@ -11,6 +11,9 @@ const pluginRoot = path.join(root, 'plugins', 'harness-everything');
|
|
|
11
11
|
const manifest = require('../plugins/harness-everything/hooks/hooks.json');
|
|
12
12
|
const { getSessionDir, getStateRoot } = require('../hooks/scripts/lib/harness-state');
|
|
13
13
|
|
|
14
|
+
assert.doesNotMatch(JSON.stringify(manifest.hooks), /rule-of-3(?:-tracker)?\.js|reset-circuit-breaker\.js/,
|
|
15
|
+
'packaged Codex hooks must not register retired breaker entry points');
|
|
16
|
+
|
|
14
17
|
function registeredHook(event, script) {
|
|
15
18
|
const handler = manifest.hooks[event].flatMap(group => group.hooks)
|
|
16
19
|
.find(hook => hook.command.includes('/' + script + '"'));
|
|
@@ -61,22 +64,22 @@ try {
|
|
|
61
64
|
}));
|
|
62
65
|
function read(file) { return JSON.parse(fs.readFileSync(file, 'utf8')); }
|
|
63
66
|
function post(response) {
|
|
64
|
-
for (const script of ['state-persist.js', '
|
|
67
|
+
for (const script of ['state-persist.js', 'contract-test.js']) {
|
|
65
68
|
hook('PostToolUse', script, { ...shell, tool_response: response });
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
const handoff = path.join(session, 'handoff-state.json');
|
|
70
|
-
const tracker = path.join(session, 'rule-of-3-state.json');
|
|
71
73
|
post({ exit_code: 1, stderr: 'test failed' });
|
|
72
74
|
assert.equal(read(handoff).status, 'failed');
|
|
73
|
-
assert.equal(
|
|
75
|
+
assert.equal(fs.existsSync(path.join(session, 'rule-of-3-state.json')), false,
|
|
76
|
+
'failure result capture must not create retired breaker state');
|
|
74
77
|
assert.equal(read(contract).status, 'fail');
|
|
75
78
|
function evidenceSnapshot() {
|
|
76
79
|
// Test commands can themselves write files, so the edit timestamp is
|
|
77
80
|
// independent of whether the host confirmed success.
|
|
78
81
|
const { lastEditAt, ...verification } = read(handoff);
|
|
79
|
-
return [verification, ...[
|
|
82
|
+
return [verification, ...[contract, evidence].map(read)];
|
|
80
83
|
}
|
|
81
84
|
const snapshots = evidenceSnapshot();
|
|
82
85
|
|
|
@@ -91,7 +94,8 @@ try {
|
|
|
91
94
|
post({ exitCode: 0, stderr: 'benign test warning' });
|
|
92
95
|
assert.equal(read(handoff).status, 'idle');
|
|
93
96
|
assert.ok(read(handoff).lastVerifyAt > 0);
|
|
94
|
-
assert.equal(
|
|
97
|
+
assert.equal(fs.existsSync(path.join(session, 'rule-of-3-state.json')), false,
|
|
98
|
+
'successful result capture must not create retired breaker state');
|
|
95
99
|
assert.equal(read(contract).status, 'pass');
|
|
96
100
|
|
|
97
101
|
const priorEdit = read(handoff).lastEditAt;
|
|
@@ -3248,18 +3248,8 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3248
3248
|
tool_name: 'Agent', tool_use_id: 'pilot-alias-capture', agent_type: 'worker',
|
|
3249
3249
|
tool_input: { prompt: 'alias capture probe' },
|
|
3250
3250
|
}, true);
|
|
3251
|
-
writeJson(path.join(aliasSessionDir, 'rule-of-3-state.json'), {
|
|
3252
|
-
count: 3, threshold: 3, lastHash: 'alias-keying-control', lastFailureAt: 0,
|
|
3253
|
-
});
|
|
3254
|
-
const breaker = runHook('hooks/scripts/rule-of-3.js', {
|
|
3255
|
-
hook_event_name: 'PreToolUse', session_id: sessionId, cwd: aliasRoot,
|
|
3256
|
-
tool_name: 'apply_patch', tool_input: { patch: '*** Update File: unrelated.txt\n@@\n-old\n+new\n' },
|
|
3257
|
-
});
|
|
3258
3251
|
assert.strictEqual(legacy.status, 0, `pilot-OFF state-persist must remain fail-open: ${legacy.stderr}`);
|
|
3259
3252
|
assert.strictEqual(pilot.status, 0, `pilot capture must remain fail-open: ${pilot.stderr}`);
|
|
3260
|
-
assert.strictEqual(breaker.status, 2, `rule-of-3 must find the tripped alias session: ${breaker.stderr}`);
|
|
3261
|
-
assert.match(breaker.stderr, /RULE OF 3 CIRCUIT BREAKER TRIGGERED/);
|
|
3262
|
-
console.log('PASS rule-of-3 alias-root positive control blocks at exit 2');
|
|
3263
3253
|
return {
|
|
3264
3254
|
legacyExit: legacy.status,
|
|
3265
3255
|
pilotOffCaptureCount,
|
|
@@ -3267,7 +3257,6 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3267
3257
|
handoffInCanonicalSession: fs.existsSync(path.join(canonicalSessionDir, 'handoff-state.json')),
|
|
3268
3258
|
pilotCaptureInAliasSession: provider.readCaptureView(aliasSessionDir).records.some(item => item.tool_use_id === 'pilot-alias-capture'),
|
|
3269
3259
|
pilotCaptureInCanonicalSession: provider.readCaptureView(canonicalSessionDir).records.some(item => item.tool_use_id === 'pilot-alias-capture'),
|
|
3270
|
-
breakerExit: breaker.status,
|
|
3271
3260
|
};
|
|
3272
3261
|
} finally {
|
|
3273
3262
|
fs.rmSync(stateHome, { recursive: true, force: true });
|
|
@@ -3281,7 +3270,6 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3281
3270
|
assert.deepStrictEqual(first, second, 'identical alias-root inputs must produce the same normalized state and exits');
|
|
3282
3271
|
assert.strictEqual(first.legacyExit, 0, 'pilot OFF remains fail-open');
|
|
3283
3272
|
assert.strictEqual(first.pilotOffCaptureCount, 0, 'pilot OFF writes no capture record');
|
|
3284
|
-
assert.strictEqual(first.breakerExit, 2, 'the aliased rule-of-3 positive control blocks');
|
|
3285
3273
|
assert.deepStrictEqual({
|
|
3286
3274
|
handoffInAliasSession: first.handoffInAliasSession,
|
|
3287
3275
|
handoffInCanonicalSession: first.handoffInCanonicalSession,
|
|
@@ -3292,7 +3280,7 @@ test('legacy session-dir keying stays aligned through an aliased workspace root'
|
|
|
3292
3280
|
handoffInCanonicalSession: false,
|
|
3293
3281
|
pilotCaptureInAliasSession: true,
|
|
3294
3282
|
pilotCaptureInCanonicalSession: false,
|
|
3295
|
-
}, `legacy handoff and pilot capture must stay in
|
|
3283
|
+
}, `legacy handoff and pilot capture must stay in the bound alias session directory: ${JSON.stringify(first)}`);
|
|
3296
3284
|
});
|
|
3297
3285
|
|
|
3298
3286
|
test('no final D stays incomplete and hand-authored JSON without a host seam earns no outline credit', () => {
|
|
@@ -59,7 +59,7 @@ test('S1-R04 integrated accepted route preserves policy and explicit model choic
|
|
|
59
59
|
assert.notEqual(risky.workflowPlan.memory.write, 'none');
|
|
60
60
|
const explicit = run('use fable-staged without subagents');
|
|
61
61
|
assert.notEqual(explicit.workflowPlan.strategy, 'direct-single');
|
|
62
|
-
assert.ok(explicit.workflowPlan.requiredInvariants.includes('replan-after-repeated-failure'));
|
|
62
|
+
assert.ok(!explicit.workflowPlan.requiredInvariants.includes('replan-after-repeated-failure'));
|
|
63
63
|
const normal = run('unusual bounded wording');
|
|
64
64
|
assert.equal(normal.workflowPlan.tier, 'tier1');
|
|
65
65
|
} finally { provider.score = original; console.log = log; if (env === undefined) delete process.env.HARNESS_SYSTEM_ONE_MODE; else process.env.HARNESS_SYSTEM_ONE_MODE = env; }
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
6
7
|
const path = require('path');
|
|
7
8
|
const { spawnSync } = require('child_process');
|
|
8
9
|
|
|
@@ -43,6 +44,33 @@ function assertTreesEqual(source, packaged, name) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
const sessionFixture = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'harness-openai-session-start-'));
|
|
48
|
+
try {
|
|
49
|
+
const session = spawnSync(process.execPath, [path.join(ROOT, 'hooks', 'scripts', 'openai-session-start.js')], {
|
|
50
|
+
cwd: sessionFixture,
|
|
51
|
+
input: JSON.stringify({
|
|
52
|
+
hook_event_name: 'SessionStart',
|
|
53
|
+
session_id: 'openai-package-session-start',
|
|
54
|
+
cwd: sessionFixture,
|
|
55
|
+
source: 'startup'
|
|
56
|
+
}),
|
|
57
|
+
encoding: 'utf8',
|
|
58
|
+
env: { ...process.env, HARNESS_STATE_HOME: path.join(sessionFixture, 'state-home') }
|
|
59
|
+
});
|
|
60
|
+
assert.strictEqual(session.status, 0, session.stderr);
|
|
61
|
+
const sessionOutput = JSON.parse(session.stdout);
|
|
62
|
+
const sessionContext = sessionOutput.hookSpecificOutput.additionalContext;
|
|
63
|
+
assert.strictEqual(sessionOutput.hookSpecificOutput.hookEventName, 'SessionStart');
|
|
64
|
+
assert.match(sessionContext, /Cognitive OS policy is active/);
|
|
65
|
+
assert.match(sessionContext, /Route before execution/);
|
|
66
|
+
assert.match(sessionContext, /Verify before claim/);
|
|
67
|
+
assert.match(sessionContext, /first meaningful signal/i);
|
|
68
|
+
assert.match(sessionContext, /productive iteration may continue/i);
|
|
69
|
+
assert.doesNotMatch(sessionContext, /after 3 same-signature failures|third matching failure|Rule[- ]of[- ]3|forced reflection|compulsory report|reset|unlock/i);
|
|
70
|
+
} finally {
|
|
71
|
+
fs.rmSync(sessionFixture, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
|
|
46
74
|
assert.strictEqual(PLUGIN_MANIFEST.name, 'harness-everything');
|
|
47
75
|
assert.strictEqual(PLUGIN_MANIFEST.version, SOURCE_MANIFEST.version, 'OpenAI plugin version must match canonical plugin version');
|
|
48
76
|
assert.strictEqual(PLUGIN_MANIFEST.skills, './skills/');
|
|
@@ -164,13 +192,8 @@ assert.match(hookText, /PLUGIN_ROOT/, 'plugin hooks must resolve from PLUGIN_ROO
|
|
|
164
192
|
assert.match(hookText, /commandWindows/, 'plugin hooks need a Windows command override');
|
|
165
193
|
assert.match(hookText, /workflow-gate\.js/, 'plugin hooks must package workflow contract observation');
|
|
166
194
|
assert.match(hookText, /workflow-stop-gate\.js/, 'plugin hooks must package workflow completion reminders');
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
assert.strictEqual(session.status, 0, session.stderr);
|
|
170
|
-
assert.match(session.stdout, /Cognitive OS policy is active/);
|
|
171
|
-
assert.match(session.stdout, /Route before execution/);
|
|
172
|
-
assert.match(session.stdout, /Verify before claim/);
|
|
173
|
-
assert.match(session.stdout, /3 same-signature failures/);
|
|
195
|
+
assert.doesNotMatch(hookText, /rule-of-3(?:-tracker)?\.js|reset-circuit-breaker\.js/,
|
|
196
|
+
'OpenAI package must not register retired breaker entry points');
|
|
174
197
|
|
|
175
198
|
const kernel = path.join(PLUGIN, 'skills', 'harness-everything', 'scripts', 'kernel-router.js');
|
|
176
199
|
function route(prompt) {
|