harness-everything 0.54.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -1
- package/CHANGELOG.md +25 -0
- package/README.md +1 -0
- package/ci/action-gate.test.js +1 -1
- package/ci/mechanism-2at-fable-execution-phases.test.js +38 -0
- package/ci/mechanism-codex-hook-results.test.js +145 -0
- package/ci/mechanism-error-ledger-oracle.test.js +222 -0
- package/ci/mechanism-error-ledger-promote.test.js +520 -0
- package/ci/mechanism-error-ledger-scan.test.js +640 -0
- package/ci/mechanism-errors-sync-root.test.js +215 -0
- package/ci/openai-plugin-package.test.js +1 -1
- package/ci/openai-plugin-runtime.test.js +2 -1
- package/ci/prompt-contract-regressions.test.js +6 -2
- package/docs/platform-capabilities.md +17 -0
- package/docs/workflows/error-ledger-bootstrap.md +23 -0
- package/error-ledger-bootstrap/SKILL.md +33 -0
- package/error-ledger-bootstrap/references/workflow.md +79 -0
- package/error-ledger-bootstrap/scripts/promote.js +613 -0
- package/error-ledger-bootstrap/scripts/scan.js +654 -0
- package/evals/error-ledger-bootstrap/eval.yaml +26 -0
- package/evals/error-ledger-bootstrap/tasks/negative-error-handling-map.yaml +16 -0
- package/evals/error-ledger-bootstrap/tasks/negative-trigger.yaml +16 -0
- package/evals/error-ledger-bootstrap/tasks/positive-trigger.yaml +15 -0
- package/fable-mode/SKILL.md +5 -5
- package/fable-mode/execution-guardrails/SKILL.md +1 -1
- package/fable-mode/fable-haiku/SKILL.md +1 -1
- package/fable-mode/fable-opus/SKILL.md +1 -1
- package/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/fable-mode/references/execution-phases.md +26 -4
- package/harness-everything/SKILL.md +1 -1
- package/harness-everything/references/skill-registry.md +1 -0
- package/harness-everything/scripts/routing-keywords.json +11 -0
- package/hooks/scripts/action-gate.js +5 -0
- package/hooks/scripts/codex-action-gate-post.js +3 -12
- package/hooks/scripts/contract-test.js +17 -7
- package/hooks/scripts/lib/codex-tool-outcome.js +28 -0
- package/hooks/scripts/rule-of-3-tracker.js +11 -4
- package/hooks/scripts/state-persist.js +15 -9
- package/hooks/scripts/subagent-scope-guard.js +32 -25
- package/hooks/scripts/subagent-start.js +1 -1
- package/hooks/scripts/subagent-stop.js +14 -3
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/hooks.json +6 -6
- package/plugins/harness-everything/hooks/scripts/action-gate.js +5 -0
- package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +3 -12
- package/plugins/harness-everything/hooks/scripts/contract-test.js +17 -7
- package/plugins/harness-everything/hooks/scripts/lib/codex-tool-outcome.js +28 -0
- package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +11 -4
- package/plugins/harness-everything/hooks/scripts/state-persist.js +15 -9
- package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +32 -25
- package/plugins/harness-everything/hooks/scripts/subagent-start.js +1 -1
- package/plugins/harness-everything/hooks/scripts/subagent-stop.js +14 -3
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +33 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +79 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +613 -0
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +654 -0
- package/plugins/harness-everything/skills/fable-mode/SKILL.md +5 -5
- package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
- package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +26 -4
- package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
- package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +1 -0
- package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +11 -0
- package/sbom.cdx.json +7 -7
- package/scripts/error-ledger-oracle.js +257 -0
- package/scripts/errors-sync.js +175 -12
|
@@ -143,15 +143,15 @@
|
|
|
143
143
|
},
|
|
144
144
|
{
|
|
145
145
|
"type": "command",
|
|
146
|
-
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/rule-of-3-tracker.js\"",
|
|
147
|
-
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\rule-of-3-tracker.js\"",
|
|
146
|
+
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/rule-of-3-tracker.js\" --codex",
|
|
147
|
+
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\rule-of-3-tracker.js\" --codex",
|
|
148
148
|
"timeout": 15,
|
|
149
149
|
"statusMessage": "Recording Harness failure evidence"
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"type": "command",
|
|
153
|
-
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/state-persist.js\"",
|
|
154
|
-
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\state-persist.js\"",
|
|
153
|
+
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/state-persist.js\" --codex",
|
|
154
|
+
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\state-persist.js\" --codex",
|
|
155
155
|
"timeout": 15,
|
|
156
156
|
"statusMessage": "Saving Harness state and observed mutation"
|
|
157
157
|
}
|
|
@@ -174,8 +174,8 @@
|
|
|
174
174
|
"hooks": [
|
|
175
175
|
{
|
|
176
176
|
"type": "command",
|
|
177
|
-
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/contract-test.js\"",
|
|
178
|
-
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\contract-test.js\"",
|
|
177
|
+
"command": "node \"${PLUGIN_ROOT}/hooks/scripts/contract-test.js\" --codex",
|
|
178
|
+
"commandWindows": "node \"${PLUGIN_ROOT}\\hooks\\scripts\\contract-test.js\" --codex",
|
|
179
179
|
"timeout": 15,
|
|
180
180
|
"statusMessage": "Checking Harness stage contract"
|
|
181
181
|
}
|
|
@@ -547,6 +547,11 @@ function finalizeExecution(payload, outcome, options = {}) {
|
|
|
547
547
|
record.disposition = 'integrity-violation';
|
|
548
548
|
record.integrityViolation = 'executed-payload-hash-differs-from-approved-payload';
|
|
549
549
|
} else {
|
|
550
|
+
// A replay without status cannot replace an already observed outcome.
|
|
551
|
+
const known = record.executionOutcome === 'success' || record.executionOutcome === 'failure';
|
|
552
|
+
if (record.disposition === 'executed' && known && outcome === 'unknown') {
|
|
553
|
+
return { kind: 'audit', exitCode: 0, record };
|
|
554
|
+
}
|
|
550
555
|
record.disposition = 'executed';
|
|
551
556
|
record.executionOutcome = outcome;
|
|
552
557
|
}
|
|
@@ -3,19 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
const { finalizeExecution } = require('./action-gate');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const response = (payload && (payload.tool_response || payload.toolResponse)) || {};
|
|
8
|
-
const rawExitCode = response.exitCode ?? response.exit_code ?? payload?.exitCode ?? payload?.exit_code;
|
|
9
|
-
if (typeof rawExitCode === 'number') return rawExitCode === 0 ? 'success' : 'failure';
|
|
10
|
-
if (response.success === false || response.ok === false) return 'failure';
|
|
6
|
+
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (/\b(error|fail|failed|failure|exception|fatal|panic|traceback|denied|refused|cannot|unable)\b/i.test(stderr)) {
|
|
15
|
-
return 'failure';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return 'success';
|
|
8
|
+
function inferOutcome(payload) {
|
|
9
|
+
return readCodexToolOutcome(payload).outcome;
|
|
19
10
|
}
|
|
20
11
|
|
|
21
12
|
function processPayload(payload) {
|
|
@@ -24,8 +24,14 @@ const {
|
|
|
24
24
|
} = require('./lib/fable-contracts');
|
|
25
25
|
const { loadWorkflow, matchingRun } = require('./lib/workflow-runtime');
|
|
26
26
|
const { createLearningOpportunity } = require('./lib/learning-opportunity');
|
|
27
|
+
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
28
|
+
const codex = process.argv.includes('--codex');
|
|
27
29
|
|
|
28
30
|
function resultState(payload) {
|
|
31
|
+
if (codex) {
|
|
32
|
+
const { outcome, exitCode, stdout, stderr } = readCodexToolOutcome(payload);
|
|
33
|
+
return { outcome, exitCode, evidence: (stderr.trim() || stdout).slice(-1000).trim() };
|
|
34
|
+
}
|
|
29
35
|
const toolResponse = payload.tool_response || payload.tool_result || {};
|
|
30
36
|
const stdout = toolResponse.stdout ?? payload.stdout ?? '';
|
|
31
37
|
const stderr = toolResponse.stderr ?? payload.stderr ?? '';
|
|
@@ -36,7 +42,7 @@ function resultState(payload) {
|
|
|
36
42
|
(exitCode !== undefined && exitCode !== 0) ||
|
|
37
43
|
(exitCode === undefined && stderrSignal);
|
|
38
44
|
const evidence = ((stderrSignal ? stderr : stdout) || '').slice(-1000).trim();
|
|
39
|
-
return { failed, exitCode, evidence };
|
|
45
|
+
return { outcome: failed ? 'failure' : 'success', exitCode, evidence };
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
function unresolvedBindings(contract) {
|
|
@@ -46,8 +52,9 @@ function unresolvedBindings(contract) {
|
|
|
46
52
|
: !['loaded', 'not-needed'].includes(binding.status));
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
function updateRunContract(entry, payload, command, sessionId) {
|
|
50
|
-
const {
|
|
55
|
+
function updateRunContract(entry, payload, command, sessionId, result) {
|
|
56
|
+
const { outcome, exitCode, evidence } = result;
|
|
57
|
+
const failed = outcome === 'failure';
|
|
51
58
|
const unresolved = unresolvedBindings(entry.contract);
|
|
52
59
|
const status = failed ? 'fail' : unresolved.length ? 'binding-unresolved' : 'pass';
|
|
53
60
|
const observedAt = new Date().toISOString();
|
|
@@ -93,7 +100,7 @@ function activeFableStages(runRoot) {
|
|
|
93
100
|
return [];
|
|
94
101
|
}
|
|
95
102
|
|
|
96
|
-
function resolveLegacyContract(stateRoot, command,
|
|
103
|
+
function resolveLegacyContract(stateRoot, command, result) {
|
|
97
104
|
const contractsDir = path.join(stateRoot, 'contracts');
|
|
98
105
|
let files = [];
|
|
99
106
|
try { files = fs.readdirSync(contractsDir).filter(file => file.endsWith('.json')); } catch (_) { return null; }
|
|
@@ -106,7 +113,8 @@ function resolveLegacyContract(stateRoot, command, payload) {
|
|
|
106
113
|
matches.push({ manifest, filePath });
|
|
107
114
|
}
|
|
108
115
|
if (matches.length !== 1) return matches.length > 1 ? { ambiguous: true } : null;
|
|
109
|
-
const {
|
|
116
|
+
const { outcome, evidence } = result;
|
|
117
|
+
const failed = outcome === 'failure';
|
|
110
118
|
const match = matches[0];
|
|
111
119
|
match.manifest.status = failed ? 'fail' : 'pass';
|
|
112
120
|
match.manifest.evidence = evidence;
|
|
@@ -124,6 +132,8 @@ process.stdin.on('end', () => {
|
|
|
124
132
|
|
|
125
133
|
const command = ((payload.tool_input && payload.tool_input.command) || '').trim();
|
|
126
134
|
if (!command) process.exit(0);
|
|
135
|
+
const result = resultState(payload);
|
|
136
|
+
if (result.outcome === 'unknown') process.exit(0);
|
|
127
137
|
|
|
128
138
|
const root = getWorkspaceRoot(payload);
|
|
129
139
|
const stateRoot = getStateRoot(root, payload);
|
|
@@ -161,7 +171,7 @@ process.stdin.on('end', () => {
|
|
|
161
171
|
}
|
|
162
172
|
const previousStatus = entry.contract.status;
|
|
163
173
|
const previousVerifiedAt = entry.contract.verifiedAt || entry.contract.updatedAt || null;
|
|
164
|
-
const contract = updateRunContract(entry, payload, command, sessionId);
|
|
174
|
+
const contract = updateRunContract(entry, payload, command, sessionId, result);
|
|
165
175
|
if (previousStatus === 'fail' && contract.status === 'pass') {
|
|
166
176
|
try {
|
|
167
177
|
createLearningOpportunity(payload, {
|
|
@@ -199,7 +209,7 @@ process.stdin.on('end', () => {
|
|
|
199
209
|
|
|
200
210
|
// Temporary compatibility with pre-Phase-3 manifests. New orchestration
|
|
201
211
|
// must use run-scoped contracts; legacy manifests have no plan/run link.
|
|
202
|
-
const legacy = resolveLegacyContract(stateRoot, command,
|
|
212
|
+
const legacy = resolveLegacyContract(stateRoot, command, result);
|
|
203
213
|
if (legacy && legacy.ambiguous) {
|
|
204
214
|
console.error(`[Contract Test] Ambiguous legacy stage contracts matched: ${command}`);
|
|
205
215
|
process.exit(0);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Codex PostToolUse runs for both zero and nonzero exits. A string response
|
|
4
|
+
// can contain arbitrary command output and is never evidence of an exit code.
|
|
5
|
+
function readCodexToolOutcome(payload) {
|
|
6
|
+
const raw = payload?.tool_response ?? payload?.toolResponse;
|
|
7
|
+
const response = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
8
|
+
const codes = [response.exitCode, response.exit_code, payload?.exitCode, payload?.exit_code]
|
|
9
|
+
.filter(Number.isInteger);
|
|
10
|
+
const exitCode = codes.find(code => code !== 0) ?? codes[0];
|
|
11
|
+
const stdout = typeof raw === 'string' ? raw : response.stdout ?? payload?.stdout;
|
|
12
|
+
const stderr = response.stderr ?? payload?.stderr;
|
|
13
|
+
const shell = ['Bash', 'PowerShell', 'exec_command'].includes(payload?.tool_name);
|
|
14
|
+
const failed = exitCode !== undefined && exitCode !== 0 ||
|
|
15
|
+
response.isError === true || response.is_error === true ||
|
|
16
|
+
response.success === false || response.ok === false;
|
|
17
|
+
const succeeded = exitCode === 0 || (!shell &&
|
|
18
|
+
(response.isError === false || response.is_error === false ||
|
|
19
|
+
response.success === true || response.ok === true));
|
|
20
|
+
return {
|
|
21
|
+
outcome: failed ? 'failure' : succeeded ? 'success' : 'unknown',
|
|
22
|
+
exitCode,
|
|
23
|
+
stdout: typeof stdout === 'string' ? stdout : '',
|
|
24
|
+
stderr: typeof stderr === 'string' ? stderr : '',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = { readCodexToolOutcome };
|
|
@@ -4,6 +4,8 @@ const path = require('path');
|
|
|
4
4
|
const crypto = require('crypto');
|
|
5
5
|
const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
|
|
6
6
|
const { createLearningOpportunity } = require('./lib/learning-opportunity');
|
|
7
|
+
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
8
|
+
const codex = process.argv.includes('--codex');
|
|
7
9
|
|
|
8
10
|
// PostToolUse/PostToolUseFailure hooks in Claude Code receive their payload via stdin
|
|
9
11
|
let inputData = '';
|
|
@@ -15,12 +17,14 @@ process.stdin.on('data', chunk => {
|
|
|
15
17
|
process.stdin.on('end', () => {
|
|
16
18
|
try {
|
|
17
19
|
const payload = JSON.parse(inputData);
|
|
20
|
+
const codexResult = codex ? readCodexToolOutcome(payload) : null;
|
|
21
|
+
if (codexResult?.outcome === 'unknown') return;
|
|
18
22
|
const hookEventName = payload.hook_event_name || payload.hookEventName || '';
|
|
19
23
|
const isFailureEvent = hookEventName === 'PostToolUseFailure';
|
|
20
24
|
const isSuccessEvent = hookEventName === 'PostToolUse';
|
|
21
25
|
const toolResponse = payload.tool_response || {};
|
|
22
|
-
const stdout = toolResponse.stdout ?? payload.stdout ?? '';
|
|
23
|
-
const stderr = toolResponse.stderr ?? payload.stderr ?? '';
|
|
26
|
+
const stdout = codexResult?.stdout ?? toolResponse.stdout ?? payload.stdout ?? '';
|
|
27
|
+
const stderr = codexResult?.stderr ?? toolResponse.stderr ?? payload.stderr ?? '';
|
|
24
28
|
const failureText = typeof payload.error === 'string' ? payload.error : '';
|
|
25
29
|
const rawExitCode = toolResponse.exitCode ?? toolResponse.exit_code ?? payload.exitCode ?? payload.exit_code;
|
|
26
30
|
const exitCode = typeof rawExitCode === 'number' ? rawExitCode : undefined;
|
|
@@ -33,11 +37,14 @@ process.stdin.on('end', () => {
|
|
|
33
37
|
const explicitFailure = exitCode !== undefined && exitCode !== 0;
|
|
34
38
|
const stderrSignal = typeof stderr === 'string' && stderr.trim().length > 0;
|
|
35
39
|
const looksLikeError = /\b(error|fail|failed|failure|exception|fatal|panic|traceback|denied|refused|cannot|unable)\b/i.test(stderr);
|
|
36
|
-
const isFailure = isFailureEvent || explicitFailure ||
|
|
40
|
+
const isFailure = codex ? codexResult.outcome === 'failure' : isFailureEvent || explicitFailure ||
|
|
37
41
|
(!isSuccessEvent && exitCode === undefined && stderrSignal && looksLikeError);
|
|
38
|
-
const
|
|
42
|
+
const reportedError = isFailureEvent
|
|
39
43
|
? (failureText || (stderrSignal ? stderr : stdout) || '')
|
|
40
44
|
: ((stderrSignal ? stderr : stdout) || failureText || '');
|
|
45
|
+
const errorText = reportedError || (codexResult?.outcome === 'failure'
|
|
46
|
+
? (codexResult.exitCode === undefined ? 'Tool reported failure' : `Tool exited with code ${codexResult.exitCode}`)
|
|
47
|
+
: '');
|
|
41
48
|
|
|
42
49
|
const root = getWorkspaceRoot(payload);
|
|
43
50
|
const stateFile = path.join(getSessionDir(root, payload.session_id || payload.sessionId), 'rule-of-3-state.json');
|
|
@@ -4,6 +4,8 @@ const path = require('path');
|
|
|
4
4
|
const { getWorkspaceRoot, getSessionDir } = require('./lib/harness-state');
|
|
5
5
|
const { cwdOf, classifyShell, isVerificationShell, directMutationInWorkspace } = require('./lib/workflow-isolation');
|
|
6
6
|
const { observeTool } = require('./lib/telemetry');
|
|
7
|
+
const { readCodexToolOutcome } = require('./lib/codex-tool-outcome');
|
|
8
|
+
const codex = process.argv.includes('--codex');
|
|
7
9
|
|
|
8
10
|
function isSuccessfulMetadataStep(command, cwd) {
|
|
9
11
|
// A line break starts a second shell command, so it can never be metadata-only.
|
|
@@ -77,22 +79,26 @@ function processState(payload) {
|
|
|
77
79
|
process.exit(0);
|
|
78
80
|
}
|
|
79
81
|
const toolResponse = payload.tool_response || {};
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
+
const codexResult = codex ? readCodexToolOutcome(payload) : null;
|
|
83
|
+
const stdout = codexResult?.stdout ?? toolResponse.stdout ?? payload.stdout ?? '';
|
|
84
|
+
const stderr = codexResult?.stderr ?? toolResponse.stderr ?? payload.stderr ?? payload.error ?? '';
|
|
82
85
|
const rawExitCode = toolResponse.exitCode ?? toolResponse.exit_code ?? payload.exitCode;
|
|
83
|
-
const exitCode = typeof rawExitCode === 'number' ? rawExitCode : undefined;
|
|
86
|
+
const exitCode = codex ? codexResult.exitCode : typeof rawExitCode === 'number' ? rawExitCode : undefined;
|
|
84
87
|
const stderrSignal = typeof stderr === 'string' && stderr.trim().length > 0;
|
|
85
88
|
const hookEvent = captureEventName;
|
|
86
89
|
const isSuccessEvent = hookEvent === 'PostToolUse';
|
|
87
|
-
const isFailed =
|
|
90
|
+
const isFailed = codex ? codexResult.outcome === 'failure' :
|
|
91
|
+
hookEvent === 'PostToolUseFailure' || (exitCode !== undefined && exitCode !== 0) ||
|
|
92
|
+
(!isSuccessEvent && exitCode === undefined && stderrSignal);
|
|
93
|
+
const verifiedSuccess = codex ? codexResult.outcome === 'success' : !isFailed && (isSuccessEvent || exitCode === 0);
|
|
88
94
|
const toolName = payload.tool_name || payload.tool || 'command';
|
|
89
95
|
let editAfterCapture = false;
|
|
90
96
|
let stateOnlyCandidate = false;
|
|
91
97
|
if (isFailed) {
|
|
92
|
-
let output = (stderrSignal ? stderr : stdout) || payload.output
|
|
98
|
+
let output = (stderrSignal ? stderr : stdout) || (typeof payload.output === 'string' ? payload.output : '');
|
|
93
99
|
if (output.length > 500) output = '...' + output.slice(-500);
|
|
94
100
|
state.status = 'failed'; state.timestamp = new Date().toISOString(); state.tool = toolName; state.exitCode = exitCode; state.errorSummary = output.trim();
|
|
95
|
-
} else if (state.status === 'failed') {
|
|
101
|
+
} else if ((!codex || verifiedSuccess) && state.status === 'failed') {
|
|
96
102
|
state.lastResolved = { tool: state.tool, timestamp: state.timestamp }; state.status = 'idle'; state.timestamp = new Date().toISOString(); delete state.exitCode; delete state.errorSummary;
|
|
97
103
|
}
|
|
98
104
|
const isDirectTool = toolName === 'Edit' || toolName === 'Write' || toolName === 'apply_patch';
|
|
@@ -106,13 +112,13 @@ function processState(payload) {
|
|
|
106
112
|
stateOnlyCandidate = Boolean(docCheck && typeof payload.cwd === 'string' && payload.cwd
|
|
107
113
|
&& docCheck.isW6StateCommand(command, payload.cwd, root,
|
|
108
114
|
{ toolName, sessionId, agentId: payload.agent_id }));
|
|
109
|
-
const metadataStep = !stateOnlyCandidate &&
|
|
115
|
+
const metadataStep = !stateOnlyCandidate && verifiedSuccess
|
|
110
116
|
&& isSuccessfulMetadataStep(command, cwdOf(payload, root));
|
|
111
117
|
if (!metadataStep && commandClass !== 'read-only' && commandClass !== 'worktree-setup') {
|
|
112
118
|
if (stateOnlyCandidate) editAfterCapture = true;
|
|
113
119
|
else state.lastEditAt = Date.now();
|
|
114
120
|
}
|
|
115
|
-
//
|
|
121
|
+
// The host-specific outcome must confirm success before verification advances.
|
|
116
122
|
// Pilot ON only: a registered, argv-validated doc-check that resolves to this install's own runtime is the document
|
|
117
123
|
// verification evidence, and only at the shipped pin (R3-02). Any other path earns no verification evidence. OFF stays legacy.
|
|
118
124
|
const installedCheck = docCheck && docCheck.registeredInstalledCheck(command, cwdOf(payload, root));
|
|
@@ -123,7 +129,7 @@ function processState(payload) {
|
|
|
123
129
|
const verifies = stateOnlyCandidate ? false : docCheckCandidate
|
|
124
130
|
? Boolean(pinCheckable) && docCheck.fileDigest(installedCheck.installed) === docCheck.SHIPPED_DOC_CHECK_DIGEST
|
|
125
131
|
: !(pilotEnabled && docCheck.trustRisk(command)) && isVerificationShell(command, { cwd: cwdOf(payload, root), root });
|
|
126
|
-
if (
|
|
132
|
+
if (verifiedSuccess && verifies) {
|
|
127
133
|
const verifiedAt = Date.now();
|
|
128
134
|
const verifiedExitCode = exitCode ?? null;
|
|
129
135
|
state.lastVerifyAt = verifiedAt;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* newly changed paths as declared, ambiguous, or out-of-scope. Machine-
|
|
9
9
|
* readable write sets may therefore clear expected changes without weakening
|
|
10
10
|
* the conservative legacy path: when no stage contract exists, any new
|
|
11
|
-
* change still
|
|
11
|
+
* change still emits a reminder and requires explicit review.
|
|
12
12
|
*
|
|
13
13
|
* `writeSet: []` means read-only. Worker attribution is used when the host
|
|
14
14
|
* exposes a worker/subagent id and the stage contract records the same id;
|
|
@@ -106,15 +106,13 @@ function classifyChanges(newlyChanged, declaredContracts, payload) {
|
|
|
106
106
|
return { workerId: workerId || null, expected, ambiguous, outOfScope };
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
process.stdin.on('data', chunk => { inputData += chunk; });
|
|
111
|
-
process.stdin.on('end', () => {
|
|
109
|
+
function inspectScope(inputData, { info, warn }) {
|
|
112
110
|
try {
|
|
113
111
|
const payload = JSON.parse(inputData);
|
|
114
112
|
const event = payload.hook_event_name;
|
|
115
113
|
const toolName = payload.tool_name || payload.tool;
|
|
116
114
|
const isSubagentEvent = event === 'SubagentStart' || event === 'SubagentStop';
|
|
117
|
-
if (!isSubagentEvent && toolName !== 'Task' && toolName !== 'Agent')
|
|
115
|
+
if (!isSubagentEvent && toolName !== 'Task' && toolName !== 'Agent') return;
|
|
118
116
|
|
|
119
117
|
const root = getWorkspaceRoot(payload);
|
|
120
118
|
const sessionId = getSessionId(payload);
|
|
@@ -134,17 +132,17 @@ process.stdin.on('end', () => {
|
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
|
-
|
|
135
|
+
return;
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
if (event === 'PostToolUse' || event === 'SubagentStop') {
|
|
141
139
|
accountWorker(payload, event);
|
|
142
|
-
if (!fs.existsSync(stateFile))
|
|
140
|
+
if (!fs.existsSync(stateFile)) return;
|
|
143
141
|
|
|
144
142
|
let state;
|
|
145
|
-
try { state = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch (_) {
|
|
143
|
+
try { state = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch (_) { return; }
|
|
146
144
|
const current = gitStatus(root);
|
|
147
|
-
if (current === null)
|
|
145
|
+
if (current === null) return;
|
|
148
146
|
|
|
149
147
|
const baselineLines = new Set(String(state.baseline || '').split('\n').filter(Boolean));
|
|
150
148
|
const currentLines = current.split('\n').filter(Boolean);
|
|
@@ -161,20 +159,20 @@ process.stdin.on('end', () => {
|
|
|
161
159
|
atomicWriteJson(path.join(sessionDir, 'subagent-scope-last.json'), audit);
|
|
162
160
|
|
|
163
161
|
if (newlyChanged.length === 0) {
|
|
164
|
-
|
|
162
|
+
info('[Subagent Scope Reminder] No new changed files detected during the subagent burst.');
|
|
165
163
|
} else if (declaredContracts.length === 0) {
|
|
166
|
-
|
|
167
|
-
newlyChanged.forEach(line =>
|
|
168
|
-
|
|
164
|
+
warn(`[Subagent Scope Reminder] ${newlyChanged.length} file(s) changed with no machine-readable writeSet contract:`);
|
|
165
|
+
newlyChanged.forEach(line => warn(` ${line}`));
|
|
166
|
+
warn('Semantic MUST: reconcile every changed path against the declared scope before trusting or committing this output.');
|
|
169
167
|
} else {
|
|
170
168
|
for (const entry of classified.expected) {
|
|
171
|
-
|
|
169
|
+
info(`[Subagent Scope Reminder] in-scope ${entry.statusLine} -> ${entry.planId}/${entry.runId}/${entry.stageId}${entry.workerId ? ` worker=${entry.workerId}` : ''}`);
|
|
172
170
|
}
|
|
173
171
|
for (const entry of classified.ambiguous) {
|
|
174
|
-
|
|
172
|
+
warn(`[Subagent Scope Reminder] ambiguous scope ${entry.statusLine}; matches ${entry.stages.map(stage => `${stage.runId}/${stage.stageId}`).join(', ')}`);
|
|
175
173
|
}
|
|
176
174
|
for (const entry of classified.outOfScope) {
|
|
177
|
-
|
|
175
|
+
warn(`[Subagent Scope Reminder] OUT-OF-SCOPE ${entry.statusLine}${entry.workerId ? ` worker=${entry.workerId}` : ''}; MUST reconcile/revert or explicitly re-authorize scope before accepting the result.`);
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -188,24 +186,33 @@ process.stdin.on('end', () => {
|
|
|
188
186
|
? newlyChanged.length > 0
|
|
189
187
|
: classified.ambiguous.length > 0 || classified.outOfScope.length > 0;
|
|
190
188
|
if (violated) {
|
|
191
|
-
|
|
192
|
-
process.exit(0);
|
|
189
|
+
warn('Do not "git add -A"; stage files explicitly so unexpected paths stay visible.');
|
|
193
190
|
}
|
|
194
|
-
process.exit(0);
|
|
195
191
|
}
|
|
196
|
-
|
|
197
|
-
process.exit(0);
|
|
198
192
|
} catch (error) {
|
|
199
193
|
if (error && error.code === 'HARNESS_WORKFLOW_BUDGET') {
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
warn(`[Subagent Scope Reminder] ${error.message}`);
|
|
195
|
+
return;
|
|
202
196
|
}
|
|
203
197
|
// This is otherwise a post-execution visibility gate. Runtime errors fail open;
|
|
204
198
|
// actionGate has a stricter fail-ask policy for side effects.
|
|
205
|
-
|
|
199
|
+
return;
|
|
206
200
|
}
|
|
207
|
-
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function run({ info = console.log, warn = console.error, complete = () => {} } = {}) {
|
|
204
|
+
let inputData = '';
|
|
205
|
+
process.stdin.setEncoding('utf8');
|
|
206
|
+
process.stdin.on('data', chunk => { inputData += chunk; });
|
|
207
|
+
process.stdin.on('end', () => {
|
|
208
|
+
inspectScope(inputData, { info, warn });
|
|
209
|
+
complete();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (require.main === module) run();
|
|
208
214
|
|
|
209
215
|
module.exports = {
|
|
210
216
|
classifyChanges,
|
|
217
|
+
run,
|
|
211
218
|
};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const { run } = require('./subagent-scope-guard');
|
|
5
|
+
|
|
6
|
+
// Codex accepts warnings through systemMessage on SubagentStop. Keep the
|
|
7
|
+
// audit advisory and leave stdout empty when there is nothing to reconcile.
|
|
8
|
+
const warnings = [];
|
|
9
|
+
run({
|
|
10
|
+
info() {},
|
|
11
|
+
warn(message) { warnings.push(message); },
|
|
12
|
+
complete() {
|
|
13
|
+
if (warnings.length > 0) {
|
|
14
|
+
process.stdout.write(JSON.stringify({ systemMessage: warnings.join('\n') }) + '\n');
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "harness-everything",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.55.0",
|
|
5
5
|
"description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Miya Daniel",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: error-ledger-bootstrap
|
|
3
|
+
description: "Bootstrap a local error ledger for an existing repository by inventorying candidate lessons, obtaining item-level owner approval, and promoting approved entries."
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: Miya Daniel
|
|
7
|
+
version: 0.55.0
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Error Ledger Bootstrap
|
|
11
|
+
|
|
12
|
+
## Skill Contract
|
|
13
|
+
|
|
14
|
+
| Component | Specification |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| Trigger / Input | An existing repository that needs an initial error-ledger inventory. |
|
|
17
|
+
| Expected Output | A local candidate report and, after approval, ledger records plus index. |
|
|
18
|
+
| Mutation | Inventory is read-only; write only owner-approved items. |
|
|
19
|
+
| Privacy | Keep memory, instructions, and reports local; never upload them. |
|
|
20
|
+
|
|
21
|
+
## USE FOR:
|
|
22
|
+
- Inventory candidate lessons for an existing repository's error ledger.
|
|
23
|
+
- Promote individually owner-approved candidates into that repository's ledger.
|
|
24
|
+
|
|
25
|
+
## DO NOT USE FOR:
|
|
26
|
+
- Persisting one lesson after a fix (use `self-evolve`).
|
|
27
|
+
- Explaining or changing the general Error Handling map or A–G flow.
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
Scan → classify candidates locally (`UNVERIFIED` when uncertain) → obtain owner approval per item → promote → index.
|
|
32
|
+
|
|
33
|
+
Deep dive: <this-skill-dir>/references/workflow.md
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Error Ledger Bootstrap Workflow
|
|
2
|
+
|
|
3
|
+
## Inventory sources and privacy
|
|
4
|
+
|
|
5
|
+
Run `node "<this-skill-dir>/scripts/scan.js" --root "<target repo>"` with only the source options you intend to use. The scanner reads local Git history, repository `AGENTS.md` / `CLAUDE.md` instructions, and selected local memory or instruction files. Automatic memory is used only when the local memory directory can be associated with the target repository. Global instructions are included only when named with `--instructions <path>`.
|
|
6
|
+
At least two distinct `fix`/`revert` commits touching `*.md` or `docs/**` paths create documentation candidates.
|
|
7
|
+
`--tracker <file.json>` accepts a top-level JSON array saved offline, for example `gh issue list --json number,title,labels,body > issues.json`. The scanner never calls GitHub.
|
|
8
|
+
Bug/regression/flake labels or `fix`/`bug` title prefixes qualify; reports keep the issue reference and matching repo-existing paths, never issue bodies.
|
|
9
|
+
|
|
10
|
+
- `--memory <path>` selects local memory files; repeat it to select more paths.
|
|
11
|
+
- `--instructions <path>` explicitly selects local instruction files; repeat as needed.
|
|
12
|
+
- `--tracker <file.json>` selects an offline issue export; repeat it for additional files.
|
|
13
|
+
- `--no-memory` disables memory and instruction sources; docs and tracker sources remain enabled.
|
|
14
|
+
- `--hide-ledger` excludes existing error-ledger files from the scan.
|
|
15
|
+
- `--home <dir>` changes the local home used to resolve automatic memory.
|
|
16
|
+
|
|
17
|
+
Treat memory and instructions as private input. A local report may include opaque source IDs, a neutral generated title or a short summary the operator reviewed locally, and only site paths verified to exist in the target repository. Keep raw source text, excerpts, private filenames and paths, credentials, and personal identifiers out of both report formats. The scanner emits reports outside the target repository: by default, into a private temporary directory; `--out <dir>` must also resolve outside the target, including through symlinks. Keep both reports local, including for company repositories.
|
|
18
|
+
|
|
19
|
+
## Classify candidates locally
|
|
20
|
+
|
|
21
|
+
The report is an inventory of leads, not a ledger. Candidates start as `UNVERIFIED`; retain that status until evidence establishes an actual error class. During local classification, an operator may add a short reviewed summary. For each candidate, record the expected and observed behavior, affected sites, root-cause rule, and evidence that supports the classification. A recurring class needs independent occurrences, such as distinct commits or sources; repeated references to the same incident do not establish recurrence. Linked tests are attachments that may help locate evidence, not incidents themselves. Keep missing history unknown rather than treating it as zero. Do not write a record or index entry while classifying.
|
|
22
|
+
|
|
23
|
+
## Owner approval and promotion
|
|
24
|
+
|
|
25
|
+
Obtain explicit owner approval for each candidate. Bind the approval to the exact report with `candidateId` (the candidate's 20-character report ID) and `reportSha256` (the SHA-256 of the report file's exact bytes). A private-memory lead cannot be promoted based only on the memory note or an uncorroborated site: require independent durable provenance. Keep opaque local IDs and uncorroborated sites out of the E-record and index; write only record content from the owner-reviewed approval payload.
|
|
26
|
+
|
|
27
|
+
The top-level approval JSON has `schemaVersion: 1`, a 20-character hexadecimal `candidateId`, a 64-character hexadecimal `reportSha256` of the exact report bytes, an absolute canonical `targetRoot` matching `--target`, a non-empty `approvedBy`, and a parseable `approvedAt` timestamp. Its `record` object has a kebab-case `signature`; non-empty `class`, `title`, `violates`, and `sourcesNote`; `scope` of `in`, `out`, or `unresolved`; `status` of `open`, `lesson`, or `mechanism`; and `sites`, an array of existing target-repository files named by relative paths without absolute paths or `.` or `..` components. Do not put absolute paths in `approvedBy`, `approvedAt`, or the record text fields. The approved candidate must occur exactly once in the report, and the selected and approved site files must exist in the target.
|
|
28
|
+
|
|
29
|
+
Use this complete example as the approval file structure, replacing the sample candidate ID and digest with the exact report values, `targetRoot` with the target's absolute canonical path, and the approver, timestamp, and reviewed record content with the owner's approval:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"schemaVersion": 1,
|
|
34
|
+
"candidateId": "0123456789abcdef0123",
|
|
35
|
+
"reportSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
|
36
|
+
"targetRoot": "/absolute/path/to/target",
|
|
37
|
+
"approvedBy": "Owner Name",
|
|
38
|
+
"approvedAt": "2026-11-20T00:00:00.000Z",
|
|
39
|
+
"record": {
|
|
40
|
+
"signature": "documented-fixture-bootstrap",
|
|
41
|
+
"class": "process",
|
|
42
|
+
"title": "Documented fixture bootstrap",
|
|
43
|
+
"violates": "Describe the observed expected-versus-actual behavior",
|
|
44
|
+
"scope": "in",
|
|
45
|
+
"status": "lesson",
|
|
46
|
+
"sites": ["README.md"],
|
|
47
|
+
"sourcesNote": "Summarize the owner-reviewed evidence and lesson."
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Do not promote an unapproved, changed, or stale candidate. Keep full candidate reports and private inputs out of E-records, PRs, shared logs, and uploads.
|
|
53
|
+
|
|
54
|
+
Promotion requires the target to already contain `.agents/harness-everything/errors/`. Before the first promotion, create that directory once:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
mkdir -p "<target repo>/.agents/harness-everything/errors"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Promotion refuses when the directory is absent. No index file is needed beforehand; successful promotion updates the index through the sync command below.
|
|
61
|
+
|
|
62
|
+
Before promotion, resolve a trusted local Harness checkout containing `scripts/errors-sync.js` and verify its Node dependencies are installed. The current sync script requires `js-yaml`; a read-only preflight is:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
test -f "<Harness checkout>/scripts/errors-sync.js"
|
|
66
|
+
node -e "require.resolve('js-yaml', {paths: [process.argv[1]]})" "<Harness checkout>"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Promote with the packaged script:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
node "<this-skill-dir>/scripts/promote.js" --target "<target repo>" --report "<report.json>" --approval "<approval.json>" --harness "<Harness checkout>"
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Promotion writes one approved `E-xxxx-<slug>.md` record and updates the target index by running `node "<Harness checkout>/scripts/errors-sync.js" --root "<target repo>"`. The checkout's `--root` option is required so the target index, not the Harness checkout's own index, is regenerated. If no trusted checkout or dependency set is available, stop before promotion and leave the report local. Recover by checking out the trusted Harness source locally, running `npm ci` in that checkout, repeating the read-only preflight, then retrying the approved promotion.
|
|
76
|
+
|
|
77
|
+
## Windows paths
|
|
78
|
+
|
|
79
|
+
Quote paths passed to Node, especially when they contain spaces, and use the full repository path for `--root`. Keep explicit report output outside the target repository; the scanner resolves symlinks and checks containment. Do not determine containment with a bare `path.relative(...).startsWith('..')`: another drive can produce an absolute relative result, and a child named `..cache` is still inside. When writing path tests, use the same canonical root as the product and exercise Windows rules with `path.win32` on every host.
|