harness-everything 0.54.1 → 0.55.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 +2 -1
- package/CHANGELOG.md +23 -0
- package/README.md +1 -0
- package/ci/mechanism-2ao-plugin-sync.test.js +18 -2
- package/ci/mechanism-349-ci-change-scope.test.js +68 -7
- package/ci/mechanism-check-packet-write-set.test.js +13 -3
- 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/docs/error-handling/README.md +5 -5
- package/docs/error-handling/details/e0002-report-writer.md +25 -27
- package/docs/error-handling/registry.md +1 -1
- 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/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/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/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/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
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const assert = require('node:assert/strict');
|
|
5
|
+
const crypto = require('node:crypto');
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const os = require('node:os');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const { spawnSync } = require('node:child_process');
|
|
10
|
+
const { render } = require('../scripts/errors-sync');
|
|
11
|
+
|
|
12
|
+
const ROOT = path.resolve(__dirname, '..');
|
|
13
|
+
const SCRIPT = path.join(ROOT, 'scripts', 'errors-sync.js');
|
|
14
|
+
const HARNESS_INDEX = path.join(ROOT, '.agents', 'harness-everything', 'errors', 'index.jsonl');
|
|
15
|
+
const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'errors sync root '));
|
|
16
|
+
const targetRoot = path.join(temp, 'target repo');
|
|
17
|
+
const errorsDir = path.join(targetRoot, '.agents', 'harness-everything', 'errors');
|
|
18
|
+
const targetIndex = path.join(errorsDir, 'index.jsonl');
|
|
19
|
+
|
|
20
|
+
function invoke(args) {
|
|
21
|
+
return spawnSync(process.execPath, [SCRIPT, ...args], { cwd: ROOT, encoding: 'utf8' });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function invokeScript(script, args, cwd, env = process.env) {
|
|
25
|
+
return spawnSync(process.execPath, [script, ...args], { cwd, encoding: 'utf8', env });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function digest(file) {
|
|
29
|
+
return crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isWithin(root, candidate) {
|
|
33
|
+
const relative = path.relative(root, candidate);
|
|
34
|
+
return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function snapshot(file) {
|
|
38
|
+
const stat = fs.lstatSync(file);
|
|
39
|
+
if (stat.isSymbolicLink()) return { type: 'symlink', target: fs.readlinkSync(file) };
|
|
40
|
+
if (stat.isDirectory()) return {
|
|
41
|
+
type: 'directory',
|
|
42
|
+
entries: Object.fromEntries(fs.readdirSync(file).sort().map(name => [name, snapshot(path.join(file, name))]))
|
|
43
|
+
};
|
|
44
|
+
if (stat.isFile()) return { type: 'file', bytes: fs.readFileSync(file).toString('base64') };
|
|
45
|
+
return { type: 'other', mode: stat.mode };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function seedLedger(name) {
|
|
49
|
+
const root = path.join(temp, name);
|
|
50
|
+
const dir = path.join(root, '.agents', 'harness-everything', 'errors');
|
|
51
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
52
|
+
fs.writeFileSync(path.join(dir, 'E-0001-root-test.md'), [
|
|
53
|
+
'---', 'id: E-0001', 'signature: root-test', 'class: test',
|
|
54
|
+
'scope: in', 'status: lesson', '---', 'A target-repository fixture.', ''
|
|
55
|
+
].join('\n'));
|
|
56
|
+
fs.writeFileSync(path.join(dir, 'index.jsonl'), render(root));
|
|
57
|
+
return { root, dir, index: path.join(dir, 'index.jsonl'), record: path.join(dir, 'E-0001-root-test.md') };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function assertUnsafeRefused(target, unchanged, tempDirs) {
|
|
61
|
+
const before = unchanged.map(snapshot);
|
|
62
|
+
const harnessBefore = fs.readFileSync(HARNESS_INDEX);
|
|
63
|
+
for (const args of [[], ['--check']]) {
|
|
64
|
+
const result = invoke([...args, '--root', target.root]);
|
|
65
|
+
assert.notEqual(result.status, 0, `${args.length ? '--check' : 'write'} refuses an unsafe target`);
|
|
66
|
+
assert.ok(result.stderr.trim(), 'unsafe target reports a reason');
|
|
67
|
+
for (const dir of tempDirs) {
|
|
68
|
+
assert.deepEqual(fs.readdirSync(dir).filter(name => /index\.jsonl.*\.tmp$/.test(name)), [],
|
|
69
|
+
'refusal leaves no temporary index file');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
assert.deepEqual(unchanged.map(snapshot), before, 'refusal preserves target records and external sentinels');
|
|
73
|
+
assert.deepEqual(fs.readFileSync(HARNESS_INDEX), harnessBefore, 'target refusal preserves the Harness index');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const harnessIndexDigest = digest(HARNESS_INDEX);
|
|
78
|
+
const harnessIndex = fs.readFileSync(HARNESS_INDEX, 'utf8');
|
|
79
|
+
assert.equal(invoke(['--check']).status, 0, 'the no-root Harness check is the regression control');
|
|
80
|
+
assert.equal(render(), harnessIndex, 'render() defaults to the current Harness root');
|
|
81
|
+
assert.ok(targetRoot.includes(' '), 'the target root must contain a space');
|
|
82
|
+
assert.equal(isWithin(ROOT, targetRoot), false, 'the temporary target must stay outside the Harness root');
|
|
83
|
+
|
|
84
|
+
fs.mkdirSync(errorsDir, { recursive: true });
|
|
85
|
+
fs.writeFileSync(path.join(errorsDir, 'E-0001-root-test.md'), [
|
|
86
|
+
'---',
|
|
87
|
+
'id: E-0001',
|
|
88
|
+
'signature: root-test',
|
|
89
|
+
'class: test',
|
|
90
|
+
'scope: in',
|
|
91
|
+
'status: lesson',
|
|
92
|
+
'---',
|
|
93
|
+
'A target-repository fixture.',
|
|
94
|
+
'',
|
|
95
|
+
].join('\n'));
|
|
96
|
+
|
|
97
|
+
const expectedIndex = `${JSON.stringify({
|
|
98
|
+
id: 'E-0001',
|
|
99
|
+
signature: 'root-test',
|
|
100
|
+
class: 'test',
|
|
101
|
+
title: null,
|
|
102
|
+
scope: 'in',
|
|
103
|
+
status: 'lesson',
|
|
104
|
+
sites: [],
|
|
105
|
+
violates: null,
|
|
106
|
+
mechanism_ref: null,
|
|
107
|
+
episodes: 0,
|
|
108
|
+
rounds: [],
|
|
109
|
+
file: path.posix.join('.agents/harness-everything/errors', 'E-0001-root-test.md'),
|
|
110
|
+
})}\n`;
|
|
111
|
+
fs.writeFileSync(targetIndex, expectedIndex);
|
|
112
|
+
|
|
113
|
+
const isolatedDefault = seedLedger('isolated default repo');
|
|
114
|
+
const isolatedScript = path.join(isolatedDefault.root, 'scripts', 'errors-sync.js');
|
|
115
|
+
fs.mkdirSync(path.dirname(isolatedScript), { recursive: true });
|
|
116
|
+
fs.copyFileSync(SCRIPT, isolatedScript);
|
|
117
|
+
const isolatedInvoke = args => invokeScript(isolatedScript, args, isolatedDefault.root, {
|
|
118
|
+
...process.env,
|
|
119
|
+
NODE_PATH: [path.join(ROOT, 'node_modules'), process.env.NODE_PATH].filter(Boolean).join(path.delimiter),
|
|
120
|
+
});
|
|
121
|
+
assert.equal(isolatedInvoke(['--check']).status, 0, 'no-root check uses its isolated default ledger');
|
|
122
|
+
fs.writeFileSync(isolatedDefault.index, 'deliberately stale default ledger\n');
|
|
123
|
+
const defaultBeforeTypo = snapshot(isolatedDefault.dir);
|
|
124
|
+
const targetBeforeTypo = snapshot(errorsDir);
|
|
125
|
+
const typo = isolatedInvoke(['--rot', targetRoot]);
|
|
126
|
+
assert.deepEqual(snapshot(isolatedDefault.dir), defaultBeforeTypo, 'an unsupported option preserves default ledger bytes');
|
|
127
|
+
assert.deepEqual(snapshot(errorsDir), targetBeforeTypo, 'an unsupported option preserves target ledger bytes');
|
|
128
|
+
assert.notEqual(typo.status, 0, 'unsupported options fail before syncing the default root');
|
|
129
|
+
assert.match(typo.stderr, /unsupported argument.*--rot/i, 'unsupported options report the rejected argument');
|
|
130
|
+
|
|
131
|
+
assert.equal(invoke(['--check', '--root', targetRoot]).status, 0,
|
|
132
|
+
'--check --root must accept a current target index');
|
|
133
|
+
assert.equal(invoke(['--check', `--root=${targetRoot}`]).status, 0,
|
|
134
|
+
'--check --root= must accept a current target index');
|
|
135
|
+
|
|
136
|
+
fs.appendFileSync(targetIndex, '{stale}\n');
|
|
137
|
+
const stale = invoke(['--check', `--root=${targetRoot}`]);
|
|
138
|
+
assert.equal(stale.status, 1, '--check --root= must reject a stale target index');
|
|
139
|
+
assert.match(stale.stderr, /is stale/, 'stale target check must report the stale index');
|
|
140
|
+
|
|
141
|
+
const previousIndexInode = fs.statSync(targetIndex).ino;
|
|
142
|
+
const written = invoke(['--root', targetRoot]);
|
|
143
|
+
assert.equal(written.status, 0, '--root must write the target repository index');
|
|
144
|
+
assert.equal(fs.readFileSync(targetIndex, 'utf8'), expectedIndex, 'target output must use a root-relative posix file path');
|
|
145
|
+
assert.equal(render(targetRoot), expectedIndex, 'render(root) must render the target repository');
|
|
146
|
+
if (process.platform !== 'win32') {
|
|
147
|
+
assert.notEqual(fs.statSync(targetIndex).ino, previousIndexInode, 'publication atomically replaces the index file');
|
|
148
|
+
}
|
|
149
|
+
assert.deepEqual(fs.readdirSync(errorsDir).filter(name => /index\.jsonl.*\.tmp$/.test(name)), [],
|
|
150
|
+
'successful publication removes its temporary file');
|
|
151
|
+
|
|
152
|
+
fs.unlinkSync(targetIndex);
|
|
153
|
+
const missingIndexCheck = invoke(['--check', '--root', targetRoot]);
|
|
154
|
+
assert.equal(missingIndexCheck.status, 1, '--check refuses a missing target index as stale');
|
|
155
|
+
const createMissingIndex = invoke(['--root', targetRoot]);
|
|
156
|
+
assert.equal(createMissingIndex.status, 0, 'write creates a missing regular target index');
|
|
157
|
+
assert.equal(fs.readFileSync(targetIndex, 'utf8'), expectedIndex, 'a newly created index has canonical bytes');
|
|
158
|
+
|
|
159
|
+
const missingErrorsRoot = path.join(temp, 'repo without errors');
|
|
160
|
+
fs.mkdirSync(missingErrorsRoot);
|
|
161
|
+
const missingErrors = invoke(['--check', '--root', missingErrorsRoot]);
|
|
162
|
+
assert.equal(missingErrors.status, 1, 'a root without its errors directory must be refused');
|
|
163
|
+
assert.ok(missingErrors.stderr.includes(JSON.stringify(missingErrorsRoot)), 'missing-directory error must name the resolved root');
|
|
164
|
+
assert.equal(missingErrors.stderr.trimEnd().split(/\r?\n/).length, 1, 'missing-directory error must be one line');
|
|
165
|
+
assert.equal(fs.existsSync(path.join(missingErrorsRoot, '.agents')), false, 'missing errors directory must not be created');
|
|
166
|
+
|
|
167
|
+
const nonexistentRoot = path.join(temp, 'missing repo');
|
|
168
|
+
const missingRoot = invoke(['--check', `--root=${nonexistentRoot}`]);
|
|
169
|
+
assert.equal(missingRoot.status, 1, 'a nonexistent root must be refused');
|
|
170
|
+
assert.ok(missingRoot.stderr.includes(JSON.stringify(nonexistentRoot)), 'missing-root error must name the resolved root');
|
|
171
|
+
assert.equal(fs.existsSync(nonexistentRoot), false, 'a nonexistent root must not be created');
|
|
172
|
+
|
|
173
|
+
const symlinkIndex = seedLedger('symlinked index repo');
|
|
174
|
+
const externalSentinel = path.join(temp, 'external index sentinel');
|
|
175
|
+
fs.writeFileSync(externalSentinel, 'external index bytes\n');
|
|
176
|
+
fs.unlinkSync(symlinkIndex.index);
|
|
177
|
+
fs.symlinkSync(externalSentinel, symlinkIndex.index, 'file');
|
|
178
|
+
assertUnsafeRefused(symlinkIndex, [symlinkIndex.index, symlinkIndex.record, externalSentinel], [symlinkIndex.dir]);
|
|
179
|
+
|
|
180
|
+
const danglingIndex = seedLedger('dangling index repo');
|
|
181
|
+
const danglingTarget = path.join(temp, 'missing external index');
|
|
182
|
+
fs.unlinkSync(danglingIndex.index);
|
|
183
|
+
fs.symlinkSync(danglingTarget, danglingIndex.index, 'file');
|
|
184
|
+
assert.equal(fs.existsSync(danglingTarget), false, 'the dangling-link control target is absent');
|
|
185
|
+
assertUnsafeRefused(danglingIndex, [danglingIndex.index, danglingIndex.record], [danglingIndex.dir]);
|
|
186
|
+
|
|
187
|
+
const nonRegularIndex = seedLedger('nonregular index repo');
|
|
188
|
+
fs.unlinkSync(nonRegularIndex.index);
|
|
189
|
+
fs.mkdirSync(nonRegularIndex.index);
|
|
190
|
+
const nonRegularSentinel = path.join(nonRegularIndex.index, 'keep.txt');
|
|
191
|
+
fs.writeFileSync(nonRegularSentinel, 'directory index sentinel\n');
|
|
192
|
+
assertUnsafeRefused(nonRegularIndex, [nonRegularIndex.index, nonRegularSentinel, nonRegularIndex.record], [nonRegularIndex.dir]);
|
|
193
|
+
|
|
194
|
+
const symlinkErrors = seedLedger('symlinked errors repo');
|
|
195
|
+
const externalErrors = path.join(temp, 'external errors directory');
|
|
196
|
+
fs.renameSync(symlinkErrors.dir, externalErrors);
|
|
197
|
+
fs.mkdirSync(path.dirname(symlinkErrors.dir), { recursive: true });
|
|
198
|
+
fs.symlinkSync(externalErrors, symlinkErrors.dir, process.platform === 'win32' ? 'junction' : 'dir');
|
|
199
|
+
assertUnsafeRefused(symlinkErrors, [symlinkErrors.dir, path.join(externalErrors, 'index.jsonl'),
|
|
200
|
+
path.join(externalErrors, 'E-0001-root-test.md')], [externalErrors]);
|
|
201
|
+
|
|
202
|
+
const symlinkIntermediate = seedLedger('symlinked intermediate repo');
|
|
203
|
+
const intermediate = path.join(symlinkIntermediate.root, '.agents', 'harness-everything');
|
|
204
|
+
const externalIntermediate = path.join(temp, 'external intermediate ledger');
|
|
205
|
+
fs.renameSync(intermediate, externalIntermediate);
|
|
206
|
+
fs.symlinkSync(externalIntermediate, intermediate, process.platform === 'win32' ? 'junction' : 'dir');
|
|
207
|
+
const externalLedger = path.join(externalIntermediate, 'errors');
|
|
208
|
+
assertUnsafeRefused(symlinkIntermediate, [intermediate, path.join(externalLedger, 'index.jsonl'),
|
|
209
|
+
path.join(externalLedger, 'E-0001-root-test.md')], [externalLedger]);
|
|
210
|
+
|
|
211
|
+
assert.equal(digest(HARNESS_INDEX), harnessIndexDigest, 'target sync must not change the Harness index');
|
|
212
|
+
console.log('PASS errors-sync supports target roots without changing the Harness index');
|
|
213
|
+
} finally {
|
|
214
|
+
fs.rmSync(temp, { recursive: true, force: true });
|
|
215
|
+
}
|
|
@@ -104,7 +104,7 @@ const packagedSkillNames = fs.readdirSync(path.join(PLUGIN, 'skills'), { withFil
|
|
|
104
104
|
.filter(entry => entry.isDirectory())
|
|
105
105
|
.map(entry => entry.name)
|
|
106
106
|
.sort();
|
|
107
|
-
assert.strictEqual(skillNames.length,
|
|
107
|
+
assert.strictEqual(skillNames.length, 28, 'canonical suite should contain 28 skills');
|
|
108
108
|
assert.deepStrictEqual(packagedSkillNames, skillNames, 'OpenAI package must contain exactly the canonical skill set');
|
|
109
109
|
for (const entry of SOURCE_MANIFEST.skills) {
|
|
110
110
|
const source = path.resolve(ROOT, entry);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Error Handling — three-view overview
|
|
2
2
|
|
|
3
|
-
> **Canonical map** for [#437](https://github.com/dyphn1/Harness-everything/issues/437) (concept and decisions) and [#402](https://github.com/dyphn1/Harness-everything/issues/402) (implementation). Moved from `discussion/437-*` on 2026-11-18; concept decisions still change only through #437. Action identities live in [nodes.yaml](./nodes.yaml); its `links` must match View 1.
|
|
3
|
+
> **Canonical map** for [#437](https://github.com/dyphn1/Harness-everything/issues/437) (concept and decisions) and [#402](https://github.com/dyphn1/Harness-everything/issues/402) (implementation). Moved from `discussion/437-*` on 2026-11-18; concept decisions still change only through #437. Action identities live in [nodes.yaml](./nodes.yaml); its `links` must match View 1. Levels 1 and 2 describe the proposed workflow. The Level 3 [E-0002 W1 report writer](./details/e0002-report-writer.md) shipped in [#462](https://github.com/dyphn1/Harness-everything/pull/462).
|
|
4
4
|
|
|
5
5
|
An Overview contains **three distinct views**. Their responsibilities must not be merged into a single linear picture:
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ An Overview contains **three distinct views**. Their responsibilities must not b
|
|
|
18
18
|
- **P2-2 · Registry mapping:** use [the lightweight document/relationship registry](./registry.md) to relate Layer → Document → relevant detail while keeping the existing [Action identities](./nodes.yaml). Registry references are for **lookup/lazy loading**, not a second set of workflow arrows or Action IDs.
|
|
19
19
|
- **P2-3 · Action handoff:** do **not** impose mandatory input/output schemas on general Actions or behavior blocks. An Action guides what to do and keeps legitimate Agent discretion; concrete Script/CLI/API boundaries document inputs, outputs and return codes only when required (see the E-0002 [Level 3 report writer contract](./details/e0002-report-writer.md)).
|
|
20
20
|
|
|
21
|
-
This
|
|
21
|
+
This mapping records design decisions. Measure Error Handling effectiveness after the full mechanism, including Hook/Skill delivery, is integrated.
|
|
22
22
|
|
|
23
23
|
## Level 2 — magnified behavior blocks (E-0002 example)
|
|
24
24
|
|
|
@@ -26,16 +26,16 @@ This is a **discussion-only** mapping. No evidence yet establishes View/Level co
|
|
|
26
26
|
|
|
27
27
|
The E-0002 example expands two blocks: **ASSESS (A Capture, B Triage, C Identify)** and **RESPOND (D Decide, E Treat, F Deliver, G Accept)**. It retains Level 1's branching authority, including the distinction **unidentified → Hold** versus **identified/non-blocking → Defer**. Script/CLI return codes let Agent handle unmet constraints **inside the relevant block**; no extra Level 1 control loop is introduced. The Level 1 Action sequence and recurrence boundary remain authoritative.
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
For a required E-0002 report, use the shipped W1 writer/checker (`npm run report -- write` and `npm run report -- check`). Supply the report content and status, then check the finished file. For `codex exec -o`, supply the raw output through `--from-codex-output`. A failed treatment result still reaches **Deliver and Accept** for the current occurrence.
|
|
30
30
|
|
|
31
31
|
## Level 3 — optional procedure, CLI/Script contract and evidence
|
|
32
32
|
|
|
33
33
|
Read only the details required for the current Action/block:
|
|
34
34
|
- [Capture evidence and artifact provenance](./details/e0002-capture-evidence.md): raw report vs final turn, source and unknowns.
|
|
35
|
-
- [Treat report writer and `-o` script contract](./details/e0002-report-writer.md):
|
|
35
|
+
- [Treat report writer and `-o` script contract](./details/e0002-report-writer.md): runnable commands, validation, return codes, negative cases and host-boundary handling.
|
|
36
36
|
- [Existing E-0002 ledger](../../.agents/harness-everything/errors/E-0002-report-missing-terminal-status.md) and [ROUTE-001](../adr/ROUTE-001-error-lesson-delivery.md): existing evidence and delivery background, not duplicated as another store.
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
W1 runs locally through `scripts/report-writer.js`. Hook/Skill disclosure ([#394](https://github.com/dyphn1/Harness-everything/issues/394)) and future node/registry expansion remain proposals. A successful CLI check confirms report structure. Use task evidence to assess the underlying result.
|
|
39
39
|
|
|
40
40
|
## Decision — Error occurrence and recurrence boundary
|
|
41
41
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# E-0002 Treat — Level 3 report-writer contract and test cases
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Shipped W1 CLI.** [#462](https://github.com/dyphn1/Harness-everything/pull/462) added `scripts/report-writer.js`, exposed through `npm run report`. This is the Level 3 contract for the report operation in the proposed [Level 2 Action Map](../actions/e0002-action-map.md) and [Level 1 workflow](../README.md). Hook/Skill disclosure and future node/registry expansion remain proposals.
|
|
4
4
|
|
|
5
5
|
## Problem to prevent
|
|
6
6
|
|
|
7
7
|
**E-0002** (`report-protocol`) recurs when a report lacks its required **raw, column-zero, terminal** `STATUS: DONE` or `STATUS: BLOCKED: <reason>` line, or when a harness-label appears after it. Some failures happen in `codex exec -o` outputs where the report is also the final turn text. Previous instructions and reminders were not enough: the next agent can make the same mistake again.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The agent supplies the report body and an evidence-grounded status. The writer assembles and verifies the final report, including the terminal STATUS line.
|
|
10
10
|
|
|
11
11
|
**Action ownership:** A Capture records facts; B Triage and C Identify establish the case; D Decide chooses treatment. **E Treat defines/applies the mechanical report-writing method**; F Deliver gives the agent a concise instruction and the available CLI; G Accept checks its result. This is an **E-0002-specific Action detail**, not a second Level 1 flow or a claim that all classes have the same treatment.
|
|
12
12
|
|
|
@@ -32,46 +32,52 @@ flowchart TD
|
|
|
32
32
|
F --> G["G · Accept against applicable contract<br/>and separate task evidence"]
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
A nonzero exit leaves the report operation unresolved. Deliver the evidence through F/G and keep the occurrence open until the applicable acceptance conditions are met.
|
|
36
36
|
|
|
37
|
-
## Agent-facing procedure
|
|
37
|
+
## Agent-facing procedure
|
|
38
38
|
|
|
39
39
|
For a step **explicitly required to produce a report**:
|
|
40
40
|
|
|
41
41
|
1. **Perform the work and collect evidence.** The agent must decide the true task/packet status based on observed results. `DONE` is not inferred by the CLI from a successful invocation; `BLOCKED` requires an actual reason. A completed RED experiment is not automatically product GREEN.
|
|
42
|
-
2. **
|
|
43
|
-
3. **Call the report writer** with the
|
|
42
|
+
2. **Choose the input mode.** Use `--body-file` for a staged body, `--context` for inline text, or `--from-codex-output` for the raw file captured by `codex exec -o`. Keep STATUS lines and harness-label comments out of ordinary body inputs.
|
|
43
|
+
3. **Call the report writer** with the chosen input, final output path, and explicit status. The writer publishes the report atomically with one terminal STATUS line.
|
|
44
44
|
4. **Check the written file**, not merely the CLI stdout, and retain the result as evidence. Do not append to the finalized report; to revise, change the body and call the writer again.
|
|
45
|
-
5. **Return the report reference and verified result** to the caller.
|
|
45
|
+
5. **Return the report reference and verified result** to the caller. Keep the raw `-o` file as evidence. A separate final turn follows its applicable host label contract.
|
|
46
46
|
|
|
47
|
-
###
|
|
47
|
+
### Runnable command examples
|
|
48
|
+
|
|
49
|
+
Run these from the repository root. The output directory must already exist. The body file and raw Codex output are inputs from the report-writing task.
|
|
48
50
|
|
|
49
51
|
```bash
|
|
50
52
|
# Positive result: content is provided by the agent; STATUS is written by the tool
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
npm run report -- write --body-file work/report-body.md --output reports/review.md --status DONE
|
|
54
|
+
npm run report -- check --file reports/review.md
|
|
53
55
|
|
|
54
56
|
# Blocked result: same writer; explicit failure reason is required
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
npm run report -- write --context "Verification could not run." --output reports/review.md --status BLOCKED --reason "required verification unavailable"
|
|
58
|
+
npm run report -- check --file reports/review.md
|
|
59
|
+
|
|
60
|
+
# Raw Codex output uses a separate input and final report path
|
|
61
|
+
npm run report -- write --from-codex-output work/codex-raw.md --output reports/review.md --status DONE
|
|
62
|
+
npm run report -- check --file reports/review.md
|
|
57
63
|
```
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
The same subcommands and flags work with `node scripts/report-writer.js`.
|
|
60
66
|
|
|
61
67
|
### Minimal writer and checker contract
|
|
62
68
|
|
|
63
69
|
| Responsibility | Expected behavior |
|
|
64
70
|
| --- | --- |
|
|
65
|
-
| `write` input |
|
|
71
|
+
| `write` input | Exactly one of `--body-file`, `--context`, or `--from-codex-output`, plus `--output` and explicit `--status`. A blocked result requires a nonempty `--reason` or `--error`. |
|
|
66
72
|
| `write` output | Preserve body content, add a single newline-separated terminal control line at **column zero**, write atomically, fail without corrupting the previous target |
|
|
67
73
|
| Structural validation | On the finished output, check exactly one terminal protocol line, nothing after it (including hidden label), and read-back matches what was written |
|
|
68
74
|
| Containing structured fields | Reject conflicting column-zero terminal STATUS lines and harness-label metadata in the submitted body; make the conflict explicit rather than silently discarding unknown content |
|
|
69
75
|
| Artifact roles | `codex exec -o` writes raw output as **script input**; the script converts and verifies the designated final report according to a host-aware contract. If ambiguous, return nonzero; no hidden manual rewrite |
|
|
70
|
-
| Failure outcome | Nonzero exit
|
|
76
|
+
| Failure outcome | Nonzero exit with diagnostics. Validation failures before publication preserve the prior report and raw input. A read-back failure after publication requires coordinator disposition. |
|
|
71
77
|
| Scope | Operate on explicitly designated report output only; do not rewrite unrelated files, judge semantic success, touch the Ledger, or automatically change permissions |
|
|
72
78
|
| Revision | Re-run `write` using the edited body + true status; never mutate the terminal report with ordinary append commands |
|
|
73
79
|
|
|
74
|
-
|
|
80
|
+
In `--from-codex-output` mode, the writer can remove one terminal harness-label comment containing a JSON object. If the raw input already includes a STATUS line, it must match the requested status and be terminal or immediately precede the label. Invalid input returns nonzero and preserves the raw file.
|
|
75
81
|
|
|
76
82
|
## Interaction with other Actions and existing facilities
|
|
77
83
|
|
|
@@ -87,11 +93,11 @@ flowchart LR
|
|
|
87
93
|
The future Hook/Skill reference is **not** a G feedback/recurrence edge, nor does F make future tasks part of this same Error Occurrence. A new recurrence starts as a **new Capture**; a correction after nonzero exit remains within the current local Action block when permitted.
|
|
88
94
|
|
|
89
95
|
- **#359:** existing E-0002 Ledger remains class/history authority; do not create a second database.
|
|
90
|
-
- **#394 / ROUTE-001:** Hook
|
|
91
|
-
- **#437:** scoped
|
|
96
|
+
- **#394 / ROUTE-001:** the proposed Hook/Skill disclosure would surface the available command when relevant. A retired lesson reminder does not remove still-needed operational instructions.
|
|
97
|
+
- **#437:** the scoped writer returns validation failures for the agent to handle in the applicable Action.
|
|
92
98
|
- **Decide/Accept:** when a machine-checkable condition or approval is not met, the script returns nonzero with the unmet requirement. The Agent can revise appropriately or preserve unresolved status. Owner authorization cannot be fabricated by a script, and a zero script exit code never proves substantive task correctness.
|
|
93
99
|
|
|
94
|
-
##
|
|
100
|
+
## Acceptance cases
|
|
95
101
|
|
|
96
102
|
| Test case | Expected observable result |
|
|
97
103
|
| --- | --- |
|
|
@@ -106,11 +112,3 @@ The future Hook/Skill reference is **not** a G feedback/recurrence edge, nor doe
|
|
|
106
112
|
| Writer produces compliant format but underlying result is wrong | Structural PASS only; review/behavior acceptance stays separate |
|
|
107
113
|
|
|
108
114
|
**What to measure:** E-0002 recurrence in later **real report-writing tasks**, whether the agent actually invoked the designated writer, structural violations after invocation, and elapsed/tool/review cost relative to hand-writing. Do not declare E-0002 rooted out merely because a diagram or a one-off check exists.
|
|
109
|
-
|
|
110
|
-
## Owner discussion items
|
|
111
|
-
|
|
112
|
-
1. Should the first implementation be a small Node.js `report write/check` script under the existing repository, rather than a new global CLI? **Recommended: yes.**
|
|
113
|
-
2. For `codex exec -o`, route raw output to a **script**, and let the script generate/check the final report. No manual coordinator rewrite or output-contract exception is assumed.
|
|
114
|
-
3. Define the **script's host-aware input/output and extraction contract** for shared `-o` artifacts; ambiguous input returns nonzero, not guessed normalization.
|
|
115
|
-
|
|
116
|
-
This design leaves A Capture focused on facts and E Treat on the executable operation: the next agent receives a repeatable action, **validated return codes**, and a way to handle a failed condition, not merely an explanation of the last mistake.
|
|
@@ -41,7 +41,7 @@ The [Action identity registry](./nodes.yaml) is the only proposed source for the
|
|
|
41
41
|
| `EH-overview` | `EH-activity-source` | Same Level 1 representation | Open when UML source/notation is needed; not a new Level |
|
|
42
42
|
| `EH-overview` | `E0002-actions` | Context-specific expansion: **E-0002** | Open when handling this Error Class/context, rather than loading all Action Maps |
|
|
43
43
|
| `E0002-actions` | `E0002-capture` | Detail supporting Capture / evidence | Read when raw evidence/provenance is required |
|
|
44
|
-
| `E0002-actions` | `E0002-writer` | Detail supporting Treat / Report CLI | Read when producing or validating a report through the
|
|
44
|
+
| `E0002-actions` | `E0002-writer` | Detail supporting Treat / Report CLI | Read when producing or validating a report through the shipped W1 script |
|
|
45
45
|
| `E0002-actions` | `E0002-ledger` | Existing class evidence / history | Read for Identify/history relevance; do not copy or reclassify the ledger |
|
|
46
46
|
|
|
47
47
|
**Maintenance contract (lightweight):** when a document moves, update its **Table A path**; Table B continues to refer to the same local key. When a new Level 2 behavior block or Level 3 reference is added, add only the relevant row and reference. Removing an obsolete procedure removes its registry relationship without rewriting Level 1. **Do not re-encode Mermaid/PlantUML execution arrows as registry edges**: the source diagrams own flow semantics, while the tables own *navigation/lookup*.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Workflow: Error Ledger Bootstrap
|
|
2
|
+
|
|
3
|
+
> Inventory local evidence for an existing repository and write only owner-approved ledger entries.
|
|
4
|
+
|
|
5
|
+
Detailed source privacy, classification, approval, promotion and Windows guidance lives in [the workflow reference](../../error-ledger-bootstrap/references/workflow.md).
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart TD
|
|
9
|
+
SCAN["Read-only local scan"] --> CLASSIFY["Classify candidates locally"]
|
|
10
|
+
CLASSIFY -->|"uncertain"| UNVERIFIED["Keep UNVERIFIED"]
|
|
11
|
+
CLASSIFY -->|"supported candidate"| OWNER{"Owner approves this item?"}
|
|
12
|
+
OWNER -->|"no"| LOCAL["Keep report local; do not write"]
|
|
13
|
+
OWNER -->|"yes"| PREFLIGHT["Preflight trusted Harness checkout and dependencies"]
|
|
14
|
+
PREFLIGHT --> PROMOTE["Promote the exact approved candidate"]
|
|
15
|
+
PROMOTE --> INDEX["Regenerate the target index with --root"]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The oracle links candidates to ledger records by site-path overlap. In JSON,
|
|
19
|
+
`rates.unmatchedShare` is the unmatched candidate share; Markdown labels it
|
|
20
|
+
**unmatched candidate share (path overlap)**. This is a proxy and may link
|
|
21
|
+
distinct lessons, so it does not estimate semantic precision. Both recall rates
|
|
22
|
+
are path-linked proxies: `recall (all) = linked records / all records` and
|
|
23
|
+
`recall (comparable) = linked records / comparable records`.
|
|
@@ -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.
|