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.
Files changed (72) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +2 -1
  3. package/CHANGELOG.md +25 -0
  4. package/README.md +1 -0
  5. package/ci/action-gate.test.js +1 -1
  6. package/ci/mechanism-2at-fable-execution-phases.test.js +38 -0
  7. package/ci/mechanism-codex-hook-results.test.js +145 -0
  8. package/ci/mechanism-error-ledger-oracle.test.js +222 -0
  9. package/ci/mechanism-error-ledger-promote.test.js +520 -0
  10. package/ci/mechanism-error-ledger-scan.test.js +640 -0
  11. package/ci/mechanism-errors-sync-root.test.js +215 -0
  12. package/ci/openai-plugin-package.test.js +1 -1
  13. package/ci/openai-plugin-runtime.test.js +2 -1
  14. package/ci/prompt-contract-regressions.test.js +6 -2
  15. package/docs/platform-capabilities.md +17 -0
  16. package/docs/workflows/error-ledger-bootstrap.md +23 -0
  17. package/error-ledger-bootstrap/SKILL.md +33 -0
  18. package/error-ledger-bootstrap/references/workflow.md +79 -0
  19. package/error-ledger-bootstrap/scripts/promote.js +613 -0
  20. package/error-ledger-bootstrap/scripts/scan.js +654 -0
  21. package/evals/error-ledger-bootstrap/eval.yaml +26 -0
  22. package/evals/error-ledger-bootstrap/tasks/negative-error-handling-map.yaml +16 -0
  23. package/evals/error-ledger-bootstrap/tasks/negative-trigger.yaml +16 -0
  24. package/evals/error-ledger-bootstrap/tasks/positive-trigger.yaml +15 -0
  25. package/fable-mode/SKILL.md +5 -5
  26. package/fable-mode/execution-guardrails/SKILL.md +1 -1
  27. package/fable-mode/fable-haiku/SKILL.md +1 -1
  28. package/fable-mode/fable-opus/SKILL.md +1 -1
  29. package/fable-mode/fable-sonnet/SKILL.md +1 -1
  30. package/fable-mode/references/execution-phases.md +26 -4
  31. package/harness-everything/SKILL.md +1 -1
  32. package/harness-everything/references/skill-registry.md +1 -0
  33. package/harness-everything/scripts/routing-keywords.json +11 -0
  34. package/hooks/scripts/action-gate.js +5 -0
  35. package/hooks/scripts/codex-action-gate-post.js +3 -12
  36. package/hooks/scripts/contract-test.js +17 -7
  37. package/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  38. package/hooks/scripts/rule-of-3-tracker.js +11 -4
  39. package/hooks/scripts/state-persist.js +15 -9
  40. package/hooks/scripts/subagent-scope-guard.js +32 -25
  41. package/hooks/scripts/subagent-start.js +1 -1
  42. package/hooks/scripts/subagent-stop.js +14 -3
  43. package/opencode-plugin/plugin.json +1 -1
  44. package/package.json +1 -1
  45. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  46. package/plugins/harness-everything/hooks/hooks.json +6 -6
  47. package/plugins/harness-everything/hooks/scripts/action-gate.js +5 -0
  48. package/plugins/harness-everything/hooks/scripts/codex-action-gate-post.js +3 -12
  49. package/plugins/harness-everything/hooks/scripts/contract-test.js +17 -7
  50. package/plugins/harness-everything/hooks/scripts/lib/codex-tool-outcome.js +28 -0
  51. package/plugins/harness-everything/hooks/scripts/rule-of-3-tracker.js +11 -4
  52. package/plugins/harness-everything/hooks/scripts/state-persist.js +15 -9
  53. package/plugins/harness-everything/hooks/scripts/subagent-scope-guard.js +32 -25
  54. package/plugins/harness-everything/hooks/scripts/subagent-start.js +1 -1
  55. package/plugins/harness-everything/hooks/scripts/subagent-stop.js +14 -3
  56. package/plugins/harness-everything/plugin.json +1 -1
  57. package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +33 -0
  58. package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +79 -0
  59. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +613 -0
  60. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +654 -0
  61. package/plugins/harness-everything/skills/fable-mode/SKILL.md +5 -5
  62. package/plugins/harness-everything/skills/fable-mode/execution-guardrails/SKILL.md +1 -1
  63. package/plugins/harness-everything/skills/fable-mode/fable-haiku/SKILL.md +1 -1
  64. package/plugins/harness-everything/skills/fable-mode/fable-opus/SKILL.md +1 -1
  65. package/plugins/harness-everything/skills/fable-mode/fable-sonnet/SKILL.md +1 -1
  66. package/plugins/harness-everything/skills/fable-mode/references/execution-phases.md +26 -4
  67. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  68. package/plugins/harness-everything/skills/harness-everything/references/skill-registry.md +1 -0
  69. package/plugins/harness-everything/skills/harness-everything/scripts/routing-keywords.json +11 -0
  70. package/sbom.cdx.json +7 -7
  71. package/scripts/error-ledger-oracle.js +257 -0
  72. 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, 27, 'canonical suite should contain 27 skills');
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);
@@ -170,6 +170,7 @@ const subagentStop = runHook('hooks/scripts/subagent-stop.js', {
170
170
  agent_type: 'worker'
171
171
  }, stateHome);
172
172
  assert.strictEqual(subagentStop.status, 0, subagentStop.stderr);
173
- assert.match(subagentStop.stderr, /Subagent Scope Reminder/);
173
+ assert.strictEqual(subagentStop.stderr, '');
174
+ assert.match(JSON.parse(subagentStop.stdout).systemMessage, /Subagent Scope Reminder.*[\s\S]*unplanned-change\.txt/);
174
175
 
175
176
  console.log('OpenAI plugin runtime compatibility verified.');
@@ -18,8 +18,12 @@ for (const [canonical, packaged] of [
18
18
  ]) {
19
19
  const body = read(canonical);
20
20
  assert.strictEqual(read(packaged), body, canonical + ' packaged contract matches');
21
- assert.ok(/advisory replan/i.test(body), canonical + ' must describe replans as advisory');
22
- assert.ok(/Rule-of-3/i.test(body), canonical + ' must preserve same-signature failure reflection');
21
+ // #476: fable-mode moved the planning rules into the execution-phases reference its Workflow points to.
22
+ const phases = canonical === 'fable-mode/SKILL.md' && body.includes('references/execution-phases.md')
23
+ ? read('fable-mode/references/execution-phases.md') : '';
24
+ const contract = body + '\n' + phases;
25
+ assert.ok(/advisory replan|replans are advisory/i.test(contract), canonical + ' must describe replans as advisory');
26
+ assert.ok(/Rule-of-3/i.test(contract), canonical + ' must preserve same-signature failure reflection');
23
27
  assert.ok(!/at most two (?:full )?replans/i.test(body), canonical + ' must not imply a two-replan hard cap');
24
28
  }
25
29
  for (const rel of [
@@ -21,6 +21,23 @@ Codex and OpenCode are `Partial` in `liveHostVerification`. The Codex artifact v
21
21
 
22
22
  Exact title/body-only `update_pull_request` calls are Codex-only host-deferred mutations after an argument allowlist check; explicit required Gate hints and all additional fields retain the existing Gate. Native task scope, permissions and GitHub authorization remain authoritative. Canonical/package mechanism tests cover hashes, audit provenance, outcomes and negative controls; this does not establish candidate live-host coverage. See [Codex policy](codex-action-gate.md#codex-pr-titlebody-updates-host-deferred).
23
23
 
24
+ ### Codex post-tool and subagent-stop hooks
25
+
26
+ Codex emits `PostToolUse` for both successful and failed shell commands. Harness
27
+ requires a structured zero exit status to credit shell verification or clear a
28
+ tracked shell failure. Text-only or missing status leaves verification and
29
+ recovery state intact and is audited as `unknown` for observed gated actions.
30
+ Edits are still tracked when the outcome is unknown because side effects may
31
+ already have occurred.
32
+
33
+ Codex `SubagentStop` uses the documented JSON `systemMessage` field for a UI-only
34
+ warning when the scope audit detects a new violation. Each audit advances the
35
+ Git status baseline and replaces `subagent-scope-last.json`. A later silent stop
36
+ can therefore coexist with unresolved changes. The coordinator owns
37
+ [scope reconciliation before accepting the result](../fable-mode/references/execution-phases.md#verification-and-handoff),
38
+ even when the hook is silent. The source and package fixtures cover these
39
+ behaviors. Windows host delivery remains to be verified.
40
+
24
41
  ### Routing contract vs. host evidence
25
42
 
26
43
  The workflow plan controller rejects present non-array required/optional binding declarations before recording a requirement plan. This input-validation contract is covered by deterministic mechanism tests and does not change live-host evidence status.
@@ -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.