harness-everything 1.1.1 → 1.2.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 (24) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +11 -0
  4. package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/README.md +32 -0
  5. package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/claude-records.json +1 -0
  6. package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/codex-hook-trace.txt +24 -0
  7. package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/opencode-records.json +1 -0
  8. package/benchmarks/results/live-host/multi-host-2026-11-25-496-capture/probe.sh +16 -0
  9. package/ci/mechanism-498-local-store-promote.test.js +402 -0
  10. package/ci/mechanism-498-local-store-scan.test.js +570 -0
  11. package/error-ledger-bootstrap/SKILL.md +1 -1
  12. package/error-ledger-bootstrap/references/workflow.md +15 -1
  13. package/error-ledger-bootstrap/scripts/promote.js +145 -9
  14. package/error-ledger-bootstrap/scripts/scan.js +394 -3
  15. package/opencode-plugin/plugin.json +1 -1
  16. package/package.json +1 -1
  17. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  18. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  19. package/plugins/harness-everything/plugin.json +1 -1
  20. package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +1 -1
  21. package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +15 -1
  22. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +145 -9
  23. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +394 -3
  24. package/sbom.cdx.json +7 -7
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
5
5
  "author": {
6
6
  "name": "Miya Daniel",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-everything",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
5
5
  "author": {
6
6
  "name": "Miya Daniel",
@@ -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.1.1",
4
+ "version": "1.2.0",
5
5
  "description": "Invariant-first engineering harness for routing, verification, and failure recovery while preserving agent autonomy.",
6
6
  "author": {
7
7
  "name": "Miya Daniel",
@@ -4,7 +4,7 @@ description: "Bootstrap a local error ledger for an existing repository by inven
4
4
  license: Apache-2.0
5
5
  metadata:
6
6
  author: Miya Daniel
7
- version: 0.55.0
7
+ version: 1.2.0
8
8
  ---
9
9
 
10
10
  # Error Ledger Bootstrap
@@ -14,6 +14,18 @@ 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
+ ## Optional local error store
18
+
19
+ Local observations are opt-in: `--source local-store --destination harness|project`. With no `--source` option, the scanner keeps the legacy report bytes and source set. `--destination` is required with this source and accepts only `harness` or `project`; it is the operator's declaration for the canonical Git `--root`.
20
+
21
+ 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. If the reader contract is absent (including the packaged Skills-only copy), the scan succeeds with source status `unavailable` and reason `reader-unavailable`.
22
+
23
+ The `local-store` source status is `used`, `missing`, `unverified`, or `unavailable`. Missing indexes use `index-missing`; unreadable or corrupt input uses a sanitized reason such as `store-unreadable`, `store-corrupt`, or `store-unsupported`. 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
+
25
+ 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
+
27
+ Each lead's `local` object includes `evidenceReadiness: needs-evidence`, `occurrenceCount`, and `dedupe`. The dedupe object contains `status` (`none`, `existing`, `ambiguous`, or `unverified`), sorted `classIds`, sorted `matchedBy` values (`signature` and/or `whole-rule`), and `newClassEligible`. The scanner checks only the selected destination's `index.jsonl`: a unique exact signature or exact whole-rule match (validated with the existing matcher validator) reports `existing` and its E-ID; matches to multiple E-IDs report `ambiguous`; an unreadable index reports `unverified`; otherwise the status is `none`. Only `none` sets `newClassEligible: true`, and that means only that exact dedupe found no existing class. The local lead still needs independently corroborated Git or documentation evidence and fresh item approval before promotion. Fuzzy matches remain for local classification.
28
+
17
29
  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
30
 
19
31
  ## Classify candidates locally
@@ -26,6 +38,8 @@ Obtain explicit owner approval for each candidate. Bind the approval to the exac
26
38
 
27
39
  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
40
 
41
+ For a candidate with a `local-store` source, also include top-level `destination: harness` or `destination: project` in the approval. 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
+
29
43
  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
44
 
31
45
  ```json
@@ -59,7 +73,7 @@ mkdir -p "<target repo>/.agents/harness-everything/errors"
59
73
 
60
74
  Promotion refuses when the directory is absent. No index file is needed beforehand; successful promotion updates the index through the sync command below.
61
75
 
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:
76
+ 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:
63
77
 
64
78
  ```sh
65
79
  test -f "<Harness checkout>/scripts/errors-sync.js"
@@ -195,19 +195,141 @@ function harnessTool(harnessInput) {
195
195
  catch (error) {
196
196
  problem(`Harness checkout cannot resolve js-yaml; install its Node dependencies and retry with that checkout (${error.message})`);
197
197
  }
198
- return script;
198
+ return { root, syncScript: script };
199
199
  }
200
200
 
201
- function durableSources(candidate) {
201
+ function localStoreTool(harnessRoot) {
202
+ const file = path.join(harnessRoot, 'hooks', 'scripts', 'lib', 'local-errors.js');
203
+ try {
204
+ const store = require(file);
205
+ if (typeof store.resolveWorkspaceKey !== 'function' || typeof store.listRecords !== 'function' ||
206
+ typeof store.validateMatch !== 'function') throw new Error('local-store reader contract is incomplete');
207
+ return store;
208
+ } catch (_) {
209
+ problem('local-store promotion requires hooks/scripts/lib/local-errors.js in the trusted Harness checkout');
210
+ }
211
+ }
212
+
213
+ function workspaceRef(workspaceKey) {
214
+ return `w-local-${hash(workspaceKey)}`;
215
+ }
216
+
217
+ function localStoreRef(workspaceKey, provisionalId) {
218
+ return `p-local-${hash(JSON.stringify([workspaceKey, provisionalId]))}`;
219
+ }
220
+
221
+ function validateLocalLead(report, candidate, approval, targetRoot, harnessRoot) {
222
+ const localSources = Array.isArray(candidate.sources)
223
+ ? candidate.sources.filter(source => source && source.type === 'local-store') : [];
224
+ if (!localSources.length) return null;
225
+
226
+ const bindings = Array.isArray(report.sources)
227
+ ? report.sources.filter(source => source && source.type === 'local-store') : [];
228
+ if (bindings.length !== 1 || bindings[0].origin !== 'workspace' || bindings[0].status !== 'used') {
229
+ problem('local-store report must contain one used workspace binding');
230
+ }
231
+ const binding = bindings[0];
232
+ if (binding.destination === 'unknown' || !['harness', 'project'].includes(binding.destination) ||
233
+ !['harness', 'project'].includes(approval.destination)) {
234
+ problem('local-store promotion requires a known harness or project destination');
235
+ }
236
+ if (binding.destination !== approval.destination ||
237
+ localSources.some(source => source.destination !== binding.destination)) {
238
+ problem('approved destination does not match the local-store report destination');
239
+ }
240
+ if (candidate.local?.evidenceReadiness !== 'needs-evidence' ||
241
+ candidate.local?.dedupe?.status !== 'none' || candidate.local?.dedupe?.newClassEligible !== true ||
242
+ !Array.isArray(candidate.local?.dedupe?.classIds) || candidate.local.dedupe.classIds.length !== 0) {
243
+ problem('local-store candidate is not eligible under its scanned exact-dedupe result');
244
+ }
245
+
246
+ const store = localStoreTool(harnessRoot);
247
+ let workspaceKey;
248
+ try { workspaceKey = store.resolveWorkspaceKey({ workspaceRoot: targetRoot }); }
249
+ catch (_) { problem('cannot resolve the local-store workspace for the canonical --target'); }
250
+ if (!/^w-local-[a-f0-9]{64}$/.test(binding.workspaceRef || '') || binding.workspaceRef !== workspaceRef(workspaceKey)) {
251
+ problem('local-store report workspace binding does not match the canonical --target');
252
+ }
253
+
254
+ let records;
255
+ try { records = store.listRecords({ workspaceRoot: targetRoot, workspaceKey }); }
256
+ catch (_) { problem('cannot read local-store records for the canonical --target'); }
257
+ const seen = new Set();
258
+ const matchedRecords = [];
259
+ for (const source of localSources) {
260
+ if (typeof source.ref !== 'string' || !/^p-local-[a-f0-9]{64}$/.test(source.ref) ||
261
+ source.signature !== candidate.signature || seen.has(source.ref)) {
262
+ problem('local-store candidate contains an invalid or duplicate opaque reference');
263
+ }
264
+ seen.add(source.ref);
265
+ const matches = records.filter(record => localStoreRef(workspaceKey, record.provisionalId) === source.ref);
266
+ if (matches.length !== 1 || matches[0].workspaceKey !== workspaceKey ||
267
+ matches[0].destination !== binding.destination || matches[0].signature !== candidate.signature ||
268
+ matches[0].kind !== source.kind) {
269
+ problem('local-store candidate reference is unavailable or does not match its report binding');
270
+ }
271
+ matchedRecords.push(matches[0]);
272
+ }
273
+ return { store, records: matchedRecords };
274
+ }
275
+
276
+ function hasTargetCommit(targetRoot, sha) {
277
+ const result = childProcess.spawnSync('git', ['-C', targetRoot, 'cat-file', '-e', `${sha}^{commit}`], {
278
+ env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1' },
279
+ stdio: 'ignore'
280
+ });
281
+ return !result.error && result.status === 0;
282
+ }
283
+
284
+ function durableSources(candidate, targetRoot, verifyTarget = false) {
202
285
  const sources = new Set();
203
286
  for (const source of Array.isArray(candidate.sources) ? candidate.sources : []) {
204
- if (source && ['git', 'doc'].includes(source.type) && typeof source.sha === 'string' && COMMIT.test(source.sha)) {
287
+ if (source && ['git', 'doc'].includes(source.type) && typeof source.sha === 'string' &&
288
+ COMMIT.test(source.sha) && (!verifyTarget || hasTargetCommit(targetRoot, source.sha))) {
205
289
  sources.add(`commit ${source.sha.toLowerCase()}`);
206
290
  }
207
291
  }
208
292
  return [...sources].sort();
209
293
  }
210
294
 
295
+ function canonicalMatch(match, store) {
296
+ const validated = store.validateMatch(match);
297
+ const normalized = {};
298
+ for (const phase of ['actions', 'failures']) {
299
+ if (!validated[phase]) continue;
300
+ normalized[phase] = validated[phase].map(rule => ({
301
+ ...rule,
302
+ ...(rule.diagnostics ? { diagnostics: [...rule.diagnostics].sort() } : {})
303
+ })).sort((left, right) => JSON.stringify(left).localeCompare(JSON.stringify(right)));
304
+ }
305
+ return JSON.stringify(normalized);
306
+ }
307
+
308
+ function assertFreshDedupe(context) {
309
+ let rendered;
310
+ try {
311
+ const sync = require(context.syncScript);
312
+ if (typeof sync.render !== 'function') throw new Error('trusted errors-sync does not expose its renderer');
313
+ rendered = sync.render(context.targetRoot);
314
+ } catch (_) {
315
+ problem('destination ledger cannot be read safely for exact dedupe');
316
+ }
317
+ const current = indexState(context.index);
318
+ if (!current.bytes || current.bytes.toString('utf8') !== rendered) {
319
+ problem('destination ledger index is stale or unavailable; refresh it and rescan before promotion');
320
+ }
321
+
322
+ const signatures = new Set([context.candidate.signature, context.approval.record.signature]);
323
+ const rules = new Set(context.localLead.records.filter(record => record.match)
324
+ .map(record => canonicalMatch(record.match, context.localLead.store)));
325
+ const rows = rendered.split(/\r?\n/).filter(Boolean).map(line => JSON.parse(line));
326
+ for (const row of rows) {
327
+ if (signatures.has(row.signature) || (row.match && rules.has(canonicalMatch(row.match, context.localLead.store)))) {
328
+ problem('destination ledger contains an exact duplicate class; rescan and obtain fresh approval');
329
+ }
330
+ }
331
+ }
332
+
211
333
  function assertApprovalUnused(errorsDir, approvalHash) {
212
334
  for (const name of fs.readdirSync(errorsDir)) {
213
335
  if (!RECORD_NAME.test(name)) continue;
@@ -224,10 +346,10 @@ function yaml(value) {
224
346
  return JSON.stringify(value);
225
347
  }
226
348
 
227
- function recordText(approval, candidate, id, reportHash, approvalHash) {
349
+ function recordText(approval, candidate, id, reportHash, approvalHash, targetRoot, verifyTarget) {
228
350
  const record = approval.record;
229
351
  const sources = [...new Set([
230
- ...durableSources(candidate),
352
+ ...durableSources(candidate, targetRoot, verifyTarget),
231
353
  ...record.sites.map(site => `repo/${site.replace(/\\/g, '/')}`)
232
354
  ])].sort();
233
355
  return [
@@ -338,9 +460,18 @@ function preflight(options) {
338
460
  if (!samePath(targetRoot, approval.targetRoot)) problem('approval targetRoot does not match the resolved --target');
339
461
  validateSites(candidate.sites, targetRoot, 'selected report candidate sites');
340
462
  validateSites(approval.record.sites, targetRoot, 'approved record sites');
341
- if (!durableSources(candidate).length) problem('selected report candidate has no durable source evidence');
463
+ const hasLocalSource = Array.isArray(candidate.sources) &&
464
+ candidate.sources.some(source => source && source.type === 'local-store');
465
+ let harness = hasLocalSource ? harnessTool(options.harness) : null;
466
+ const localLead = hasLocalSource
467
+ ? validateLocalLead(report, candidate, approval, targetRoot, harness.root) : null;
468
+ if (!durableSources(candidate, targetRoot, Boolean(localLead)).length) {
469
+ problem(localLead
470
+ ? 'selected report candidate has no verified durable source evidence in the target repository'
471
+ : 'selected report candidate has no durable source evidence');
472
+ }
473
+ if (!harness) harness = harnessTool(options.harness);
342
474
  const { errorsDir, index } = directoryInfo(targetRoot);
343
- const syncScript = harnessTool(options.harness);
344
475
  const lockPath = path.join(errorsDir, LOCK);
345
476
  try {
346
477
  fs.lstatSync(lockPath);
@@ -354,7 +485,10 @@ function preflight(options) {
354
485
  const next = nextId(errorsDir, index);
355
486
  const destination = checkDestination(errorsDir, next.id, approval.record.signature, lockPath);
356
487
  assertApprovalUnused(errorsDir, approvalHash);
357
- return { approval, candidate, targetRoot, errorsDir, index, syncScript, lockPath, destination, reportHash, approvalHash };
488
+ return {
489
+ approval, candidate, targetRoot, errorsDir, index, syncScript: harness.syncScript,
490
+ localLead, lockPath, destination, reportHash, approvalHash
491
+ };
358
492
  }
359
493
 
360
494
  function runSync(script, targetRoot, check) {
@@ -519,10 +653,12 @@ function promote(context) {
519
653
 
520
654
  beforeNames = fs.readdirSync(context.errorsDir).filter(name => name !== LOCK).sort();
521
655
  saved = savedIndex(context.index);
656
+ if (context.localLead) assertFreshDedupe(context);
522
657
  assertApprovalUnused(context.errorsDir, context.approvalHash);
523
658
  const next = nextId(context.errorsDir, context.index);
524
659
  destination = checkDestination(context.errorsDir, next.id, context.approval.record.signature, context.lockPath);
525
- const text = recordText(context.approval, context.candidate, next.id, context.reportHash, context.approvalHash);
660
+ const text = recordText(context.approval, context.candidate, next.id, context.reportHash, context.approvalHash,
661
+ context.targetRoot, Boolean(context.localLead));
526
662
  let recordFd;
527
663
  try {
528
664
  recordFd = fs.openSync(destination.destination, 'wx', 0o644);