harness-everything 1.2.2 → 1.3.1
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/CHANGELOG.md +29 -0
- package/ci/archive/325-prep/README.md +9 -2
- package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
- package/ci/fixtures/468-dispatch/agy-quota-PROVENANCE.md +19 -0
- package/ci/fixtures/468-dispatch/agy-quota-direct-individual.stderr +2 -0
- package/ci/fixtures/468-dispatch/agy-quota-direct-third-party.stderr +2 -0
- package/ci/fixtures/468-dispatch/agy-quota-exec-individual.log +3 -0
- package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
- package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
- package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
- package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
- package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
- package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
- package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
- package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
- package/ci/fixtures/stop/fail-session-writes.js +109 -0
- package/ci/fixtures/workflow-contract/cases.json +3355 -0
- package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
- package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
- package/ci/mechanism-2an-workflow-replay.test.js +324 -0
- package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
- package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
- package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
- package/ci/mechanism-325-3b-preparation.test.js +208 -49
- package/ci/mechanism-325-3b-s1-review.test.js +20 -828
- package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
- package/ci/mechanism-325-f3-derived-views.test.js +140 -0
- package/ci/mechanism-341-opencode-lane.test.js +164 -284
- package/ci/mechanism-35-verification-contract.test.js +246 -0
- package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
- package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
- package/ci/mechanism-397-opencode-observations.test.js +151 -18
- package/ci/mechanism-468-dispatch-cli.test.js +1496 -4
- package/ci/mechanism-548-bigint-identity.test.js +531 -0
- package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
- package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
- package/ci/mechanism-553-p3-plan-start.test.js +212 -0
- package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
- package/ci/mechanism-553-stop.test.js +427 -0
- package/ci/mechanism-553-t2a-derive.test.js +110 -0
- package/ci/mechanism-553-t2c-derive.test.js +94 -0
- package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
- package/ci/mechanism-error-ledger-oracle.test.js +786 -3
- package/ci/mechanism-error-ledger-scan.test.js +981 -0
- package/ci/mechanism-outline-sanitizer.test.js +0 -8
- package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
- package/ci/mechanism-prb-outline-review.test.js +101 -3283
- package/ci/mechanism-report-writer.test.js +45 -0
- package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
- package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
- package/docs/doc-workflow-reconciliation.md +17 -2
- package/docs/document-lifecycle.md +6 -2
- package/docs/error-handling/details/c8-dispatch-cli.md +109 -13
- package/docs/platform-capabilities.md +35 -5
- package/error-ledger-bootstrap/SKILL.md +1 -1
- package/error-ledger-bootstrap/references/workflow.md +42 -7
- package/error-ledger-bootstrap/scripts/promote.js +8 -6
- package/error-ledger-bootstrap/scripts/scan.js +525 -12
- package/hooks/hooks.json +0 -46
- package/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/hooks/scripts/state-persist.js +7 -95
- package/hooks/scripts/workflow-disposition.js +0 -2
- package/hooks/scripts/workflow-stop-gate.js +17 -30
- package/opencode-plugin/index.mjs +6 -70
- package/opencode-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
- package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
- package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
- package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
- package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
- package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
- package/plugins/harness-everything/plugin.json +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +1 -1
- package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +42 -7
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +8 -6
- package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +525 -12
- package/sbom.cdx.json +7 -7
- package/scripts/dispatch.js +499 -87
- package/scripts/error-ledger-oracle.js +521 -27
- package/scripts/errors-sync.js +4 -3
- package/scripts/report-writer.js +4 -3
- package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
- package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
- package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
- package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
- package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
- package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
- package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
- package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
- package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
- package/ci/lib/doc-reconciliation-file-spy.js +0 -23
- package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
- package/ci/lib/doc-reconciliation-replay.js +0 -104
- package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
- package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
- package/ci/mechanism-325-3b-s1.test.js +0 -188
- package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
- package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
- package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
- package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
- package/ci/mechanism-325-f4-invariants.test.js +0 -606
- package/ci/mechanism-325-f4-projections.test.js +0 -392
- package/ci/mechanism-325-f4-qualification.test.js +0 -228
- package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
- package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
- package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/hooks/scripts/w6-state-operations.js +0 -239
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
- package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
- package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
- package/scripts/system-one-eval-laya.js +0 -112
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
- /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
|
@@ -61,14 +61,8 @@ function isSuccessfulMetadataStep(command, cwd) {
|
|
|
61
61
|
&& (disposition === 'pass' ? reason === undefined : /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(unquote(reason)));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
// contract"): pilot-only, fail-open to the host, and gated on the exact
|
|
67
|
-
// switch value `1` before any collector logic runs. OFF must return to the
|
|
68
|
-
// existing legacy path before pilot collection; capture never executes a
|
|
69
|
-
// command, verifier or generator and never blocks a tool or Stop.
|
|
70
|
-
const PILOT_CAPTURE_EVENT_NAMES = ['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'SubagentStart', 'SubagentStop'];
|
|
71
|
-
// Task/Agent results were never routed here before S2b, so they stay capture-only: the legacy handoff path does not run for them.
|
|
64
|
+
// Old Claude manifests may still route retired E1 capture callbacks here.
|
|
65
|
+
// Ignore them before state resolution or any provider work.
|
|
72
66
|
const CAPTURE_ONLY_TOOLS = ['Task', 'Agent'];
|
|
73
67
|
let inputData = '';
|
|
74
68
|
const timeout = setTimeout(() => processState(null), 200);
|
|
@@ -82,25 +76,11 @@ function processState(payload) {
|
|
|
82
76
|
const captureOnly = captureEventName === 'SubagentStart' || captureEventName === 'SubagentStop'
|
|
83
77
|
|| captureEventName === 'PreToolUse'
|
|
84
78
|
|| (captureEventName === 'PostToolUse' && CAPTURE_ONLY_TOOLS.indexOf(captureToolName) !== -1);
|
|
85
|
-
if (captureOnly
|
|
79
|
+
if (captureOnly) {
|
|
86
80
|
process.exit(0);
|
|
87
81
|
return;
|
|
88
82
|
}
|
|
89
83
|
const root = getWorkspaceRoot(payload);
|
|
90
|
-
// SubagentStart/SubagentStop were never routed to this script before S2b.
|
|
91
|
-
// They are capture-only events: the legacy handoff state path stays
|
|
92
|
-
// untouched for them, so wiring them while OFF adds no writes at all.
|
|
93
|
-
if (captureEventName === 'SubagentStart' || captureEventName === 'SubagentStop') {
|
|
94
|
-
persistPilotCapture(payload, captureEventName, sessionId, root);
|
|
95
|
-
process.exit(0);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// Pre-tool launch capture and Task/Agent result capture: capture-only, no legacy handoff state is written.
|
|
99
|
-
if (captureEventName === 'PreToolUse' || (captureEventName === 'PostToolUse' && CAPTURE_ONLY_TOOLS.indexOf(captureToolName) !== -1)) {
|
|
100
|
-
persistPilotCapture(payload, captureEventName, sessionId, root);
|
|
101
|
-
process.exit(0);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
84
|
const stateFile = path.join(getSessionDir(root, sessionId), 'handoff-state.json');
|
|
105
85
|
let state = { status: 'idle', timestamp: new Date().toISOString() };
|
|
106
86
|
if (fs.existsSync(stateFile)) { try { state = JSON.parse(fs.readFileSync(stateFile, 'utf8')); } catch (_) {} }
|
|
@@ -127,8 +107,6 @@ function processState(payload) {
|
|
|
127
107
|
: agy ? (!isFailed && exitCode === 0)
|
|
128
108
|
: !isFailed && (isSuccessEvent || exitCode === 0);
|
|
129
109
|
const toolName = payload.tool_name || payload.tool || 'command';
|
|
130
|
-
let editAfterCapture = false;
|
|
131
|
-
let stateOnlyCandidate = false;
|
|
132
110
|
if (isFailed) {
|
|
133
111
|
let output = (stderrSignal ? stderr : stdout) || (typeof payload.output === 'string' ? payload.output : '');
|
|
134
112
|
if (output.length > 500) output = '...' + output.slice(-500);
|
|
@@ -155,92 +133,26 @@ function processState(payload) {
|
|
|
155
133
|
command === '$PSVersionTable.PSVersion; Get-Command pwsh -ErrorAction SilentlyContinue'
|
|
156
134
|
|| /^git grep (?:-n )?(?:"[\w][\w.-]*"|'[\w][\w.-]*'|[\w][\w.-]*)(?: --(?: [\w.][\w./-]*)+)?$/.test(command)
|
|
157
135
|
);
|
|
158
|
-
const
|
|
159
|
-
const docCheck = pilotEnabled ? require('./lib/doc-reconciliation-provider') : null;
|
|
160
|
-
stateOnlyCandidate = Boolean(docCheck && typeof payload.cwd === 'string' && payload.cwd
|
|
161
|
-
&& docCheck.isW6StateCommand(command, payload.cwd, root,
|
|
162
|
-
{ toolName, sessionId, agentId: payload.agent_id }));
|
|
163
|
-
const metadataStep = !stateOnlyCandidate && verifiedSuccess
|
|
136
|
+
const metadataStep = verifiedSuccess
|
|
164
137
|
&& isSuccessfulMetadataStep(command, cwdOf(payload, root));
|
|
165
138
|
// The host-specific outcome must confirm success before verification advances.
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
const installedCheck = docCheck && docCheck.registeredInstalledCheck(command, cwdOf(payload, root));
|
|
169
|
-
const docCheckCandidate = installedCheck && installedCheck.kind !== 'not-candidate';
|
|
170
|
-
const pinCheckable = installedCheck && installedCheck.installed
|
|
171
|
-
&& (installedCheck.kind === 'accepted' || installedCheck.reason === 'implementation-pin-mismatch');
|
|
172
|
-
// A non-candidate that is compound or names the checker is not generic verification (trustRisk); the scanner miss does not clear it.
|
|
173
|
-
const verifies = stateOnlyCandidate ? false : docCheckCandidate
|
|
174
|
-
? Boolean(pinCheckable) && docCheck.fileDigest(installedCheck.installed) === docCheck.SHIPPED_DOC_CHECK_DIGEST
|
|
175
|
-
: !(pilotEnabled && docCheck.trustRisk(command)) && isVerificationShell(command, { cwd: cwdOf(payload, root), root });
|
|
139
|
+
// Retired document-check evidence no longer changes generic handoff verification.
|
|
140
|
+
const verifies = isVerificationShell(command, { cwd: cwdOf(payload, root), root });
|
|
176
141
|
// On AGY hosts that omit shell error/exitCode, an unconfirmed verification-only command must not advance lastEditAt
|
|
177
142
|
// and defeat agy-stop.js's bounded continuation fingerprint.
|
|
178
143
|
const agyUnknownOutcomeVerify = agy && !verifiedSuccess && !isFailed && verifies;
|
|
179
144
|
if (!metadataStep && !agyUnknownOutcomeVerify && !agyReadOnlyProbe && commandClass !== 'read-only' && commandClass !== 'worktree-setup') {
|
|
180
|
-
|
|
181
|
-
else state.lastEditAt = Date.now();
|
|
145
|
+
state.lastEditAt = Date.now();
|
|
182
146
|
}
|
|
183
147
|
if (verifiedSuccess && verifies) {
|
|
184
148
|
const verifiedAt = Date.now();
|
|
185
149
|
const verifiedExitCode = exitCode ?? null;
|
|
186
150
|
state.lastVerifyAt = verifiedAt;
|
|
187
151
|
state.lastVerifyExitCode = verifiedExitCode;
|
|
188
|
-
if (pilotEnabled) {
|
|
189
|
-
const source = docCheckCandidate ? 'Doc' : 'Generic';
|
|
190
|
-
state[`last${source}VerifyAt`] = verifiedAt;
|
|
191
|
-
state[`last${source}VerifyExitCode`] = verifiedExitCode;
|
|
192
|
-
}
|
|
193
152
|
}
|
|
194
153
|
}
|
|
195
154
|
fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
|
|
196
155
|
observeTool(payload);
|
|
197
|
-
persistPilotCapture(payload, captureEventName, sessionId, root);
|
|
198
|
-
if (editAfterCapture) {
|
|
199
|
-
const pilotEnabled = process.env.HARNESS_DOC_RECONCILIATION_PILOT === '1';
|
|
200
|
-
const docCheck = pilotEnabled ? require('./lib/doc-reconciliation-provider') : null;
|
|
201
|
-
const captures = docCheck && docCheck.readCaptureView(getSessionDir(root, sessionId));
|
|
202
|
-
const verifiedStateOnly = stateOnlyCandidate && docCheck && captures && !captures.tampered
|
|
203
|
-
&& docCheck.isVerifiedW6StateOperation(captures.records, getSessionDir(root, sessionId), payload.tool_use_id);
|
|
204
|
-
if (!verifiedStateOnly) {
|
|
205
|
-
state.lastEditAt = Date.now();
|
|
206
|
-
fs.writeFileSync(stateFile, JSON.stringify(state, null, 2), 'utf8');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
156
|
} catch (_) {}
|
|
210
157
|
process.exit(0);
|
|
211
158
|
}
|
|
212
|
-
|
|
213
|
-
// Pilot-only capture journaling. Every guard is placed before any collector
|
|
214
|
-
// work; any failure is swallowed (fail-open), and the hook output/exit is
|
|
215
|
-
// never changed by capture.
|
|
216
|
-
function persistPilotCapture(payload, eventName, sessionId, root) {
|
|
217
|
-
try {
|
|
218
|
-
if (!payload || process.env.HARNESS_DOC_RECONCILIATION_PILOT !== '1') return;
|
|
219
|
-
if (PILOT_CAPTURE_EVENT_NAMES.indexOf(eventName) === -1) return;
|
|
220
|
-
const provider = require('./lib/doc-reconciliation-provider');
|
|
221
|
-
const sessionDir = getSessionDir(root, sessionId);
|
|
222
|
-
const entry = provider.buildCaptureRecord(payload, eventName, root, { sessionDir });
|
|
223
|
-
if (!entry) return;
|
|
224
|
-
// Observation-time identity: the workflow and pin in force when the host event was captured.
|
|
225
|
-
const observed = provider.observedIdentityFor(sessionDir);
|
|
226
|
-
if (observed) entry.observedIdentity = observed;
|
|
227
|
-
// #341 step 1: O's identity is taken at launch records, so a reviewer's identity predates its review.
|
|
228
|
-
if (eventName === 'SubagentStart') {
|
|
229
|
-
const outlineIdentity = provider.captureOutlineStartIdentity({ sessionDir });
|
|
230
|
-
if (outlineIdentity) entry.outlineIdentity = outlineIdentity;
|
|
231
|
-
}
|
|
232
|
-
if (eventName === 'PreToolUse' && (entry.tool_name === 'Agent' || entry.tool_name === 'Task')) {
|
|
233
|
-
try {
|
|
234
|
-
const existing = provider.readCaptureView(sessionDir);
|
|
235
|
-
entry.outlineDispatch = existing.tampered
|
|
236
|
-
? { schema: 'harness.outline-dispatch.v1', state: 'unresolved', reasons: ['capture-view-tampered'] }
|
|
237
|
-
: provider.captureOutlineDispatch({ payload, capture: entry, sessionDir, workspaceRoot: root, captures: existing.records });
|
|
238
|
-
} catch {
|
|
239
|
-
entry.outlineDispatch = { schema: 'harness.outline-dispatch.v1', state: 'unresolved', reasons: ['dispatch-capture-failed'] };
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
// Each capture is one exclusively created event file; the compatibility journal is rebuilt from them (not tamper-proof).
|
|
243
|
-
provider.writeImmutableEvent(sessionDir, entry);
|
|
244
|
-
provider.rebuildJournalView(sessionDir);
|
|
245
|
-
} catch (_) { /* fail-open: capture failures never reach the host */ }
|
|
246
|
-
}
|
|
@@ -173,7 +173,6 @@ function main() {
|
|
|
173
173
|
if (!['pending', 'active'].includes(workflow.state)) throw new Error('requirements/workflow composition belongs before execution starts');
|
|
174
174
|
const selectedPlan = recomposePlan(workflow, args.strategy);
|
|
175
175
|
const result = recordPlanning(context, args.requirementsJson, selectedPlan, args.strategy, args.evidence);
|
|
176
|
-
require('./lib/doc-reconciliation-pilot').captureBaseline(context);
|
|
177
176
|
saveWorkflow(context);
|
|
178
177
|
process.stdout.write(JSON.stringify({
|
|
179
178
|
state: workflow.state,
|
|
@@ -193,7 +192,6 @@ function main() {
|
|
|
193
192
|
const unresolvedPlanning = planningUnresolved(context, plan);
|
|
194
193
|
if (unresolvedPlanning.length) throw new Error('resolve requirement decomposition/workflow selection first: ' + unresolvedPlanning.join(', '));
|
|
195
194
|
|
|
196
|
-
require('./lib/doc-reconciliation-pilot').captureBaseline(context);
|
|
197
195
|
if (!String(plan.strategy || '').startsWith('fable-')) {
|
|
198
196
|
activatePlan(workflow, plan);
|
|
199
197
|
workflow.revision++;
|
|
@@ -9,6 +9,14 @@ const STEP_TYPE_REGISTRY_UNAVAILABLE = 'STEP_TYPE_REGISTRY_UNAVAILABLE';
|
|
|
9
9
|
|
|
10
10
|
function warn(message) { console.error('[Workflow Reminder] ' + message); }
|
|
11
11
|
|
|
12
|
+
function lastGenericVerificationAt(handoff) {
|
|
13
|
+
if (!Number.isFinite(handoff?.lastDocVerifyAt)) return handoff?.lastVerifyAt || 0;
|
|
14
|
+
const genericAt = Number.isFinite(handoff.lastGenericVerifyAt) ? handoff.lastGenericVerifyAt : 0;
|
|
15
|
+
const newerAggregateAt = Number.isFinite(handoff.lastVerifyAt) && handoff.lastVerifyAt > handoff.lastDocVerifyAt
|
|
16
|
+
? handoff.lastVerifyAt : 0;
|
|
17
|
+
return Math.max(genericAt, newerAggregateAt);
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
function decide(payload) {
|
|
13
21
|
if (!payload) return;
|
|
14
22
|
try {
|
|
@@ -18,7 +26,7 @@ function decide(payload) {
|
|
|
18
26
|
const { workflow, sessionDir } = context;
|
|
19
27
|
if (!workflow || workflow.state === 'deferred') return;
|
|
20
28
|
const handoffFile = path.join(sessionDir, 'handoff-state.json');
|
|
21
|
-
|
|
29
|
+
const handoff = readJson(handoffFile);
|
|
22
30
|
const unresolved = [];
|
|
23
31
|
const diagnostics = [];
|
|
24
32
|
let requiredFault = false;
|
|
@@ -38,17 +46,18 @@ function decide(payload) {
|
|
|
38
46
|
|
|
39
47
|
required(() => planningUnresolved(context));
|
|
40
48
|
if (String(workflow.strategy || '').startsWith('fable-')) {
|
|
41
|
-
if (!unresolved.length) {
|
|
42
|
-
require('./lib/doc-reconciliation-pilot').assess(context, null);
|
|
43
|
-
}
|
|
44
49
|
const match = matchingRun(context);
|
|
45
50
|
unresolved.push(...(match ? unresolvedStages(match, workflow, handoff?.lastEditAt || 0) : ['correlated-run-missing']));
|
|
46
51
|
} else {
|
|
47
52
|
required(() => unresolvedObligations(context));
|
|
48
|
-
// Assessment can withdraw stale document verification; read the current aggregate afterward.
|
|
49
|
-
handoff = readJson(handoffFile);
|
|
50
53
|
const lastEdit = Math.max(workflow.lastMutationAt || 0, handoff?.lastEditAt || 0);
|
|
51
|
-
if (lastEdit && (handoff
|
|
54
|
+
if (lastEdit && lastGenericVerificationAt(handoff) < lastEdit) {
|
|
55
|
+
unresolved.push('verification-after-edit-missing');
|
|
56
|
+
if (Number.isFinite(handoff?.lastDocVerifyAt) && workflow.state === 'satisfied') {
|
|
57
|
+
workflow.state = 'running';
|
|
58
|
+
delete workflow.resolvedAt;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
const pending = [...new Set(unresolved)];
|
|
@@ -59,29 +68,7 @@ function decide(payload) {
|
|
|
59
68
|
// A failed required validation leaves the workflow file as recorded; it is never marked satisfied.
|
|
60
69
|
if (!requiredFault) {
|
|
61
70
|
workflow.unresolved = pending;
|
|
62
|
-
|
|
63
|
-
// best-effort. A failing saveWorkflow() must not swallow the decision or leak exception
|
|
64
|
-
// text: record the withhold-persist-failed diagnostic on the shared context diagnostics
|
|
65
|
-
// (also when the earlier obligations write already failed) and still emit the reminder
|
|
66
|
-
// below. Stop stays non-blocking: exit 0, no retry loop, no lock.
|
|
67
|
-
// Scope of the recovery (PR #351 re-review): the local recovery and the
|
|
68
|
-
// withhold-persist-failed diagnostic apply only when this Stop run made an actual ON,
|
|
69
|
-
// supported, withheld pilot decision (`withholdPilotVerification` sets the transient
|
|
70
|
-
// per-run marker on the context). On switch-OFF, Fable and persisted-untyped paths the
|
|
71
|
-
// marker is never set, so the error is rethrown and reaches Stop's outer handler exactly
|
|
72
|
-
// as the pre-S1 legacy reference: same stderr, same exit 0, no pilot diagnostic.
|
|
73
|
-
try {
|
|
74
|
-
saveWorkflow(context);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
if (context.docReconciliationWithheldRun !== true) throw error;
|
|
77
|
-
if (!Array.isArray(context.workflow.docReconciliationDiagnostics)) {
|
|
78
|
-
context.workflow.docReconciliationDiagnostics = [];
|
|
79
|
-
}
|
|
80
|
-
if (!context.workflow.docReconciliationDiagnostics.includes('withhold-persist-failed')) {
|
|
81
|
-
context.workflow.docReconciliationDiagnostics.push('withhold-persist-failed');
|
|
82
|
-
}
|
|
83
|
-
warn('Pending-workflow persistence failed (withhold-persist-failed); the unresolved evidence below is still binding.');
|
|
84
|
-
}
|
|
71
|
+
saveWorkflow(context);
|
|
85
72
|
}
|
|
86
73
|
warn('Unresolved workflow evidence: ' + pending.join(', ') + '. Resolve/verify before claiming completion.');
|
|
87
74
|
return;
|
|
@@ -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": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
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",
|
|
@@ -14,13 +14,26 @@ Bug/regression/flake labels or `fix`/`bug` title prefixes qualify; reports keep
|
|
|
14
14
|
- `--hide-ledger` excludes existing error-ledger files from the scan.
|
|
15
15
|
- `--home <dir>` changes the local home used to resolve automatic memory.
|
|
16
16
|
|
|
17
|
+
- **Redaction scope:** the opaque-ref/no-excerpt rules below apply only to fields derived from local-store rows. Git, doc and tracker fields in the same report keep their own sanitization (repo-existing sites, issue reference only); local-store redaction does not rewrite them. The whole combined report still follows the privacy rules below and stays local.
|
|
18
|
+
|
|
17
19
|
## Optional local error store
|
|
18
20
|
|
|
19
|
-
Local observations are opt-in: `--source local-store --destination harness
|
|
21
|
+
Local observations are opt-in: `--source local-store --destination <harness-or-project>`. With no `--source` option, the scanner keeps the legacy report bytes and source set. `--destination` is required with this source and accepts exactly one of `harness` or `project` (the `harness|project` notation is not a literal value); it is the operator's declaration for the canonical Git `--root`, not a router to another repository.
|
|
22
|
+
|
|
23
|
+
The scanner derives the workspace key from that root, calls the supported reader as `listRecords({ workspaceRoot, workspaceKey })`, and accepts only returned rows carrying that key. A bound host workspace that disagrees fails closed. The report binds the resolved destination to an opaque `workspaceRef`; each record ref is `p-local-<sha256>` over the workspace key and validated stored provisional ID. Raw provisional IDs are never reported.
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
| Reader condition | Source status / reason | Recovery |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| Reader module missing (the packaged Skills-only copy has no `hooks/scripts/lib/local-errors.js`) | `unavailable` / `reader-unavailable` | Re-scan from a trusted full Harness checkout with the command below. |
|
|
28
|
+
| Reader module present but its contract/API is incomplete (for example a missing `DESTINATIONS` export) | `unavailable` / `reader-contract-incomplete` | Repair that checkout's reader, then re-scan. |
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
Both conditions yield zero local leads, keep the other sources, and fail closed; neither implies routing to another repository. Full-checkout recovery command (choose one destination value, not the literal `harness|project`):
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
node "<Harness checkout>/error-ledger-bootstrap/scripts/scan.js" --root "<target>" --no-memory --source local-store --destination harness --out "<private dir outside target>" --json
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The `local-store` source status is `used`, `missing`, `unverified`, or `unavailable`. Missing local-store indexes use `index-missing`; unreadable or corrupt input uses a sanitized reason such as `store-unreadable`, `store-corrupt`, or `store-unsupported`. A missing destination ledger directory or `index.jsonl` reports `ledgerStatus: unverified` / `ledgerReason: ledger-missing`; unreadable or corrupt ledger uses `ledger-unreadable` / `ledger-corrupt`. An empty reader result is `unverified` (`empty-reader-result`) because the reader returns an empty array for both an empty workspace and several read failures. Invalid rows are skipped and counted as `malformed`; they are never quoted. The report separately counts valid rows assigned to another destination and rows whose destination is `unknown`.
|
|
24
37
|
|
|
25
38
|
Each valid destination-matched provisional lesson yields one neutral local lead. Occurrences are grouped by exact signature and suppressed when a selected lesson covers that signature. JSON and Markdown contain only opaque refs, validated destination/kind/command-class metadata, signatures, counts, and dedupe/evidence results. They never include excerpts, cues, lesson text, issue URLs, paths, session IDs, or tool-use IDs. Keep the reports local; the local store and destination ledger are read-only during scan.
|
|
26
39
|
|
|
@@ -38,9 +51,9 @@ Obtain explicit owner approval for each candidate. Bind the approval to the exac
|
|
|
38
51
|
|
|
39
52
|
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.
|
|
40
53
|
|
|
41
|
-
For a candidate with a `local-store` source, also include top-level `destination: harness` or `destination: project` in the approval
|
|
54
|
+
For a candidate with a `local-store` source, also include exactly one top-level `destination: harness` or `destination: project` in the approval, matching the report's `--destination`. Promotion requires one `used` workspace binding whose opaque ref resolves to canonical `--target` through the trusted Harness checkout's local-store reader; every candidate ref must still resolve to a row for that workspace and destination. The report's exact-dedupe result must be eligible, and the candidate must carry a verified Git or documentation commit source that exists in the target repository on that same candidate. Promotion rechecks exact signature and whole-rule dedupe against the current destination ledger while holding the promotion lock. Missing, unknown, mismatched, stale, or unreadable local bindings fail closed before ledger changes. Legacy reports without a local-store source keep their existing approval shape. A stored issue URL is only a local lead and never satisfies the durable-source requirement.
|
|
42
55
|
|
|
43
|
-
Use this
|
|
56
|
+
Use this example as the approval 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. A local-store approval includes the top-level `destination` shown here; a legacy approval omits that field.
|
|
44
57
|
|
|
45
58
|
```json
|
|
46
59
|
{
|
|
@@ -48,6 +61,7 @@ Use this complete example as the approval file structure, replacing the sample c
|
|
|
48
61
|
"candidateId": "0123456789abcdef0123",
|
|
49
62
|
"reportSha256": "0000000000000000000000000000000000000000000000000000000000000000",
|
|
50
63
|
"targetRoot": "/absolute/path/to/target",
|
|
64
|
+
"destination": "harness",
|
|
51
65
|
"approvedBy": "Owner Name",
|
|
52
66
|
"approvedAt": "2026-11-20T00:00:00.000Z",
|
|
53
67
|
"record": {
|
|
@@ -65,13 +79,34 @@ Use this complete example as the approval file structure, replacing the sample c
|
|
|
65
79
|
|
|
66
80
|
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.
|
|
67
81
|
|
|
68
|
-
Promotion requires the target to already contain `.agents/harness-everything/errors
|
|
82
|
+
Promotion requires the target to already contain `.agents/harness-everything/errors/`; it refuses when the directory is absent. Create that directory once:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
mkdir -p "<target repo>/.agents/harness-everything/errors"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
| Candidate source | Index precondition before scan and approval |
|
|
89
|
+
| --- | --- |
|
|
90
|
+
| Legacy (no `local-store` source) | No index file needed beforehand; the first promotion creates it through the sync command below. |
|
|
91
|
+
| `local-store` | `index.jsonl` must already exist and be current in the target. Create/refresh it from the trusted checkout with `node "<Harness checkout>/scripts/errors-sync.js" --root "<target repo>"`. A missing index leaves scan dedupe `unverified` (`ledger-missing`). Scan does not detect a stale index; promotion rechecks it under lock and fails closed (`destination ledger index is stale or unavailable`). Never bypass either; refresh, rescan and reapprove. |
|
|
92
|
+
|
|
93
|
+
Copyable first-promotion sequence for a `local-store` lead:
|
|
69
94
|
|
|
70
95
|
```sh
|
|
96
|
+
# 1. Target ledger directory and index (an empty ledger is fine)
|
|
71
97
|
mkdir -p "<target repo>/.agents/harness-everything/errors"
|
|
98
|
+
node "<Harness checkout>/scripts/errors-sync.js" --root "<target repo>"
|
|
99
|
+
|
|
100
|
+
# 2. Scan from the trusted full checkout, not the packaged Skills-only copy
|
|
101
|
+
node "<Harness checkout>/error-ledger-bootstrap/scripts/scan.js" \
|
|
102
|
+
--root "<target repo>" --no-memory --source local-store --destination harness \
|
|
103
|
+
--out "<private dir outside target>" --json
|
|
104
|
+
|
|
105
|
+
# 3. Classify locally; obtain fresh per-item approval bound to the exact report bytes
|
|
106
|
+
# 4. Promote with the packaged script below
|
|
72
107
|
```
|
|
73
108
|
|
|
74
|
-
|
|
109
|
+
If the index was missing or stale, re-run step 1 **before** step 2, then rescan and reapprove the new `reportSha256`; an approval bound to earlier report bytes is stale.
|
|
75
110
|
|
|
76
111
|
Before promotion, resolve a trusted local Harness checkout containing `scripts/errors-sync.js` and verify its Node dependencies are installed. Local-store candidates also require `hooks/scripts/lib/local-errors.js` in that checkout. The current sync script requires `js-yaml`; a read-only preflight is:
|
|
77
112
|
|
|
@@ -515,10 +515,11 @@ function savedIndex(index) {
|
|
|
515
515
|
function indexState(index) {
|
|
516
516
|
let fd;
|
|
517
517
|
try {
|
|
518
|
-
|
|
518
|
+
// Keep 64-bit device/file IDs exact (Windows IDs can exceed Number's safe integer range).
|
|
519
|
+
const current = fs.lstatSync(index, { bigint: true });
|
|
519
520
|
if (current.isSymbolicLink() || !current.isFile()) throw new Error('index was replaced with a non-regular file');
|
|
520
521
|
fd = fs.openSync(index, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
|
|
521
|
-
const opened = fs.fstatSync(fd);
|
|
522
|
+
const opened = fs.fstatSync(fd, { bigint: true });
|
|
522
523
|
if (!opened.isFile() || opened.dev !== current.dev || opened.ino !== current.ino) {
|
|
523
524
|
throw new Error('index changed while it was being read');
|
|
524
525
|
}
|
|
@@ -544,13 +545,14 @@ function writePreviousIndex(index, saved, current, expected) {
|
|
|
544
545
|
}
|
|
545
546
|
|
|
546
547
|
const dir = path.dirname(index);
|
|
548
|
+
const mode = Number(saved.stat.mode) & 0o777;
|
|
547
549
|
let temporary;
|
|
548
550
|
let fd;
|
|
549
551
|
try {
|
|
550
552
|
for (let attempt = 0; attempt < 5; attempt++) {
|
|
551
553
|
temporary = path.join(dir, `.${INDEX}.${process.pid}.${crypto.randomBytes(8).toString('hex')}.tmp`);
|
|
552
554
|
try {
|
|
553
|
-
fd = fs.openSync(temporary, 'wx',
|
|
555
|
+
fd = fs.openSync(temporary, 'wx', mode);
|
|
554
556
|
break;
|
|
555
557
|
} catch (error) {
|
|
556
558
|
temporary = undefined;
|
|
@@ -558,7 +560,7 @@ function writePreviousIndex(index, saved, current, expected) {
|
|
|
558
560
|
}
|
|
559
561
|
}
|
|
560
562
|
if (fd === undefined) throw new Error('could not allocate a temporary rollback index');
|
|
561
|
-
fs.fchmodSync(fd,
|
|
563
|
+
fs.fchmodSync(fd, mode);
|
|
562
564
|
fs.writeFileSync(fd, saved.bytes);
|
|
563
565
|
const openFd = fd;
|
|
564
566
|
fd = undefined;
|
|
@@ -615,7 +617,7 @@ function rollback(context, saved, destination, identity, beforeNames) {
|
|
|
615
617
|
}
|
|
616
618
|
if (identity) {
|
|
617
619
|
try {
|
|
618
|
-
const current = fs.lstatSync(destination);
|
|
620
|
+
const current = fs.lstatSync(destination, { bigint: true });
|
|
619
621
|
if (current.dev !== identity.dev || current.ino !== identity.ino || current.isSymbolicLink()) {
|
|
620
622
|
problems.push('new record was replaced by another writer');
|
|
621
623
|
} else fs.unlinkSync(destination);
|
|
@@ -662,7 +664,7 @@ function promote(context) {
|
|
|
662
664
|
let recordFd;
|
|
663
665
|
try {
|
|
664
666
|
recordFd = fs.openSync(destination.destination, 'wx', 0o644);
|
|
665
|
-
identity = fs.fstatSync(recordFd);
|
|
667
|
+
identity = fs.fstatSync(recordFd, { bigint: true });
|
|
666
668
|
fs.writeFileSync(recordFd, text, 'utf8');
|
|
667
669
|
fs.closeSync(recordFd);
|
|
668
670
|
recordFd = undefined;
|