harness-everything 1.5.3 → 1.6.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 (61) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.github/ISSUE_TEMPLATE/bug_report.yml +68 -0
  4. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +33 -0
  6. package/.github/ISSUE_TEMPLATE/platform_compatibility.yml +80 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +19 -0
  8. package/.github/dependabot.yml +13 -0
  9. package/.github/workflows/ci.yml +2 -2
  10. package/.github/workflows/release.yml +1 -1
  11. package/CHANGELOG.md +24 -0
  12. package/PRIVACY.md +34 -14
  13. package/README.md +76 -311
  14. package/ROADMAP.md +50 -0
  15. package/SECURITY.md +29 -8
  16. package/SUPPORT.md +4 -4
  17. package/TERMS.md +3 -3
  18. package/benchmarks/results/live-host/agy-2026-12-02-linux-loader/README.md +33 -0
  19. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/README.md +20 -0
  20. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/lifecycle.sanitized.jsonl +14 -0
  21. package/benchmarks/results/live-host/opencode-2026-12-02-450-steering/observations.sanitized.json +20 -0
  22. package/bin/cli.js +30 -7
  23. package/ci/action-gate.test.js +186 -0
  24. package/ci/installer-roundtrip.test.js +20 -0
  25. package/ci/lib/opencode-v2-driver.js +3 -1
  26. package/ci/mechanism-2aa-codex-action-gate-policy.test.js +21 -0
  27. package/ci/mechanism-2ap-sbom.test.js +6 -6
  28. package/ci/mechanism-2x-release-commit-message.test.js +34 -23
  29. package/ci/mechanism-341-opencode-lane.test.js +5 -1
  30. package/ci/mechanism-397-cycle-import.test.js +5 -1
  31. package/ci/mechanism-397-opencode-observations.test.js +260 -24
  32. package/ci/mechanism-548-bigint-identity.test.js +252 -5
  33. package/ci/mechanism-552-ledger-pairs.test.js +2 -0
  34. package/ci/mechanism-error-ledger-promote.test.js +122 -1
  35. package/ci/mechanism-system-one-install.test.js +50 -0
  36. package/ci/mechanism-task-git-authorization.test.js +14 -0
  37. package/docs/README.md +81 -0
  38. package/docs/codex-action-gate.md +1 -1
  39. package/docs/platform-capabilities.md +17 -5
  40. package/docs/platform-compatibility.json +6 -6
  41. package/docs/system-one-cycle.md +2 -1
  42. package/harness-everything/SKILL.md +1 -1
  43. package/harness-everything/scripts/system-one/cua_adapter.py +4 -2
  44. package/harness-everything/scripts/system-one/install.js +1 -5
  45. package/harness-everything/scripts/system-one/manifest.js +7 -3
  46. package/harness-everything/scripts/system-one/provider.js +3 -4
  47. package/hooks/scripts/action-gate.js +82 -2
  48. package/opencode-plugin/index.mjs +97 -35
  49. package/opencode-plugin/plugin.json +1 -1
  50. package/package.json +15 -2
  51. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  52. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  53. package/plugins/harness-everything/hooks/scripts/action-gate.js +82 -2
  54. package/plugins/harness-everything/plugin.json +1 -1
  55. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  56. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +4 -2
  57. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +1 -5
  58. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +7 -3
  59. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +3 -4
  60. package/sbom.cdx.json +7 -7
  61. package/scripts/system-one-cycle/package.js +2 -2
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const assert = require('node:assert/strict');
4
+ const crypto = require('node:crypto');
4
5
  const fs = require('node:fs');
5
6
  const os = require('node:os');
6
7
  const path = require('node:path');
@@ -12,6 +13,8 @@ const walk = require('acorn-walk');
12
13
  const ROOT = path.resolve(__dirname, '..');
13
14
  const REPORT_WRITER = path.join(ROOT, 'scripts', 'report-writer.js');
14
15
  const ERRORS_SYNC = path.join(ROOT, 'scripts', 'errors-sync.js');
16
+ const PROMOTE = path.join(ROOT, 'error-ledger-bootstrap', 'scripts', 'promote.js');
17
+ const SCAN = path.join(ROOT, 'error-ledger-bootstrap', 'scripts', 'scan.js');
15
18
  const LARGE = 2n ** 60n;
16
19
 
17
20
  function canonical(file) {
@@ -246,6 +249,197 @@ test('548 errors-sync detects a swapped index whose 64-bit ino collides as Numbe
246
249
  assert.match(swapCheck.stderr, /target index changed while it was being read/);
247
250
  });
248
251
 
252
+ test('548 errors-sync refuses Number-colliding index identity at publication and preserves bytes', t => {
253
+ assert.equal(Number(LARGE), Number(LARGE + 1n), 'fixture IDs must collide when converted to Number');
254
+
255
+ const root = tempDir(t, 'harness-548-publication-');
256
+ const errorsDir = path.join(root, '.agents', 'harness-everything', 'errors');
257
+ fs.mkdirSync(errorsDir, { recursive: true });
258
+ fs.writeFileSync(path.join(errorsDir, 'E-0001-sample.md'), [
259
+ '---', 'id: E-0001', 'signature: sample-error', 'class: test', 'title: "Sample"',
260
+ 'scope: in', 'status: open', '---', '', 'Body.', ''
261
+ ].join('\n'));
262
+ const initial = runNode([ERRORS_SYNC, '--root', root]);
263
+ assert.equal(initial.status, 0, initial.stderr || initial.stdout);
264
+ const indexFile = path.join(errorsDir, 'index.jsonl');
265
+ const originalBytes = fs.readFileSync(indexFile);
266
+
267
+ function publicationPreload(file, collide) {
268
+ return writeStatPreload(file, `
269
+ 'use strict';
270
+ const fs = require('node:fs');
271
+ const path = require('node:path');
272
+ const indexKey = path.resolve(${JSON.stringify(indexFile)});
273
+ const large = ${LARGE}n;
274
+ const collide = ${JSON.stringify(collide)};
275
+ const originalLstat = fs.lstatSync;
276
+ const originalOpen = fs.openSync;
277
+ const originalFstat = fs.fstatSync;
278
+ const indexFds = new Set();
279
+ let indexReads = 0;
280
+ fs.lstatSync = function (file, options) {
281
+ const result = originalLstat.call(this, file, options);
282
+ if (path.resolve(String(file)) === indexKey) {
283
+ indexReads++;
284
+ const ino = collide && indexReads >= 4 ? large + 1n : large;
285
+ const convert = value => options && options.bigint ? value : Number(value);
286
+ result.dev = convert(large);
287
+ result.ino = convert(ino);
288
+ }
289
+ return result;
290
+ };
291
+ fs.openSync = function (file, ...args) {
292
+ const fd = originalOpen.call(this, file, ...args);
293
+ if (path.resolve(String(file)) === indexKey) indexFds.add(fd);
294
+ return fd;
295
+ };
296
+ fs.fstatSync = function (fd, options) {
297
+ const result = originalFstat.call(this, fd, options);
298
+ if (indexFds.has(fd)) {
299
+ const convert = value => options && options.bigint ? value : Number(value);
300
+ result.dev = convert(large);
301
+ result.ino = convert(large);
302
+ }
303
+ return result;
304
+ };
305
+ `);
306
+ }
307
+
308
+ const collision = runNode([ERRORS_SYNC, '--root', root], {
309
+ preload: publicationPreload(path.join(root, 'preload-collision.cjs'), true)
310
+ });
311
+ assert.notEqual(collision.status, 0, 'distinct bigint IDs that collide as Number must refuse publication');
312
+ assert.match(collision.stderr, /target index changed before publication/);
313
+ assert.deepEqual(fs.readFileSync(indexFile), originalBytes, 'refusal preserves the prior index bytes');
314
+ assert.equal(fs.readdirSync(errorsDir).some(name => name.endsWith('.tmp')), false,
315
+ 'refusal removes the unpublished temporary index');
316
+
317
+ const same = runNode([ERRORS_SYNC, '--root', root], {
318
+ preload: publicationPreload(path.join(root, 'preload-same.cjs'), false)
319
+ });
320
+ assert.equal(same.status, 0, `same-ID positive control failed: ${same.stderr || same.stdout}`);
321
+ assert.deepEqual(fs.readFileSync(indexFile), originalBytes, 'positive control publishes the expected index bytes');
322
+ });
323
+
324
+ test('548 promote refuses Number-colliding opened-index identity before changing the ledger', t => {
325
+ assert.equal(Number(LARGE), Number(LARGE + 1n), 'fixture IDs must collide when converted to Number');
326
+ const scratch = tempDir(t, 'harness-548-promote-');
327
+ const target = path.join(scratch, 'target');
328
+ const errorsDir = path.join(target, '.agents', 'harness-everything', 'errors');
329
+ fs.mkdirSync(errorsDir, { recursive: true });
330
+ fs.writeFileSync(path.join(errorsDir, 'E-0001-fixture.md'), [
331
+ '---', 'id: E-0001', 'signature: fixture', 'class: test', 'title: "Fixture"',
332
+ 'scope: in', 'status: lesson', '---', '', 'A synthetic ledger record.', ''
333
+ ].join('\n'));
334
+ fs.mkdirSync(path.join(target, 'src'), { recursive: true });
335
+ const parser = path.join(target, 'src', 'parser.js');
336
+ fs.writeFileSync(parser, 'module.exports = value => value;\n');
337
+ function git(args, seconds = 0) {
338
+ const date = new Date(Date.parse('2024-01-02T03:04:05.000Z') + seconds * 1000).toISOString();
339
+ const result = spawnSync('git', ['-C', target, ...args], {
340
+ encoding: 'utf8',
341
+ env: { ...process.env, GIT_CONFIG_NOSYSTEM: '1', HUSKY: '0',
342
+ GIT_AUTHOR_NAME: '548 Fixture', GIT_AUTHOR_EMAIL: 'fixture@example.invalid',
343
+ GIT_COMMITTER_NAME: '548 Fixture', GIT_COMMITTER_EMAIL: 'fixture@example.invalid',
344
+ GIT_AUTHOR_DATE: date, GIT_COMMITTER_DATE: date }
345
+ });
346
+ assert.equal(result.status, 0, `git ${args.join(' ')} failed: ${result.stderr}`);
347
+ }
348
+ git(['init', '-q']);
349
+ git(['add', '-A']);
350
+ git(['commit', '-q', '-m', 'feat: seed parser fixture']);
351
+ fs.writeFileSync(parser, 'module.exports = value => value == null ? "" : value;\n');
352
+ git(['add', '-A']);
353
+ git(['commit', '-q', '-m', 'fix: preserve parser boundary'], 1);
354
+ fs.writeFileSync(parser, 'module.exports = value => String(value ?? "");\n');
355
+ git(['add', '-A']);
356
+ git(['commit', '-q', '-m', 'fix: handle parser edge case'], 2);
357
+
358
+ const sync = runNode([ERRORS_SYNC, '--root', target]);
359
+ assert.equal(sync.status, 0, sync.stderr || sync.stdout);
360
+ const indexFile = path.join(errorsDir, 'index.jsonl');
361
+ const scanDir = path.join(scratch, 'scan');
362
+ const scanned = runNode([SCAN, '--root', target, '--out', scanDir, '--no-memory', '--json']);
363
+ assert.equal(scanned.status, 0, `scanner failed: ${scanned.stderr || scanned.stdout}`);
364
+ const reportPayload = JSON.parse(scanned.stdout);
365
+ const reportFile = reportPayload.reportJson;
366
+ const reportBytes = fs.readFileSync(reportFile);
367
+ const report = JSON.parse(reportBytes.toString('utf8'));
368
+ const candidate = report.candidates.find(item => item.sites.includes('src/parser.js')
369
+ && item.sources.some(source => source.type === 'git'));
370
+ assert.ok(candidate, 'the real scanner found a durable Git candidate for the target fixture');
371
+ const approvalFile = path.join(scratch, 'approval.json');
372
+ fs.writeFileSync(approvalFile, JSON.stringify({
373
+ schemaVersion: 1,
374
+ candidateId: candidate.id,
375
+ reportSha256: crypto.createHash('sha256').update(reportBytes).digest('hex'),
376
+ targetRoot: fs.realpathSync.native(target),
377
+ approvedBy: 'fixture-owner',
378
+ approvedAt: '2026-11-30T12:00:00.000Z',
379
+ record: {
380
+ signature: 'parser-edge-case', class: 'test-coupling', title: 'Parser edge case regressed',
381
+ violates: 'The parser preserves the approved token boundary.', scope: 'in', status: 'lesson',
382
+ sites: ['src/parser.js'], sourcesNote: 'Synthetic durable source evidence for the collision witness.'
383
+ }
384
+ }, null, 2));
385
+ const before = Object.fromEntries(fs.readdirSync(errorsDir).sort().map(name => [
386
+ name, fs.readFileSync(path.join(errorsDir, name)).toString('base64')
387
+ ]));
388
+
389
+ function promotePreload(file, collide) {
390
+ return writeStatPreload(file, `
391
+ 'use strict';
392
+ const fs = require('node:fs');
393
+ const path = require('node:path');
394
+ const indexKey = path.resolve(${JSON.stringify(indexFile)});
395
+ const large = ${LARGE}n;
396
+ const collide = ${JSON.stringify(collide)};
397
+ const originalLstat = fs.lstatSync;
398
+ const originalOpen = fs.openSync;
399
+ const originalFstat = fs.fstatSync;
400
+ const indexFds = new Set();
401
+ fs.lstatSync = function (file, options) {
402
+ const result = originalLstat.call(this, file, options);
403
+ if (path.resolve(String(file)) === indexKey) {
404
+ const convert = value => options && options.bigint ? value : Number(value);
405
+ result.dev = convert(large);
406
+ result.ino = convert(large);
407
+ }
408
+ return result;
409
+ };
410
+ fs.openSync = function (file, ...args) {
411
+ const fd = originalOpen.call(this, file, ...args);
412
+ if (path.resolve(String(file)) === indexKey) indexFds.add(fd);
413
+ return fd;
414
+ };
415
+ fs.fstatSync = function (fd, options) {
416
+ const result = originalFstat.call(this, fd, options);
417
+ if (indexFds.has(fd)) {
418
+ const convert = value => options && options.bigint ? value : Number(value);
419
+ result.dev = convert(large);
420
+ result.ino = convert(collide ? large + 1n : large);
421
+ }
422
+ return result;
423
+ };
424
+ `);
425
+ }
426
+ function invoke(preload) {
427
+ return runNode([PROMOTE, '--target', target, '--report', reportFile, '--approval', approvalFile,
428
+ '--harness', ROOT, '--json'], { preload });
429
+ }
430
+ const refused = invoke(promotePreload(path.join(scratch, 'preload-collision.cjs'), true));
431
+ assert.notEqual(refused.status, 0, 'a distinct opened index ID must be refused');
432
+ assert.match(refused.stdout, /index changed while it was being read/);
433
+ const afterRefusal = Object.fromEntries(fs.readdirSync(errorsDir).sort().map(name => [
434
+ name, fs.readFileSync(path.join(errorsDir, name)).toString('base64')
435
+ ]));
436
+ assert.deepEqual(afterRefusal, before, 'refusal preserves all ledger names and bytes');
437
+
438
+ const accepted = invoke(promotePreload(path.join(scratch, 'preload-same.cjs'), false));
439
+ assert.equal(accepted.status, 0, `same-ID positive control failed: ${accepted.stderr || accepted.stdout}`);
440
+ assert.equal(JSON.parse(accepted.stdout).ok, true, 'same-ID control reaches successful promotion');
441
+ });
442
+
249
443
  // --- Guard: every non-test JS `.ino` access must originate from a `{ bigint: true }` stat call ---
250
444
 
251
445
  const STAT_METHODS = new Set(['statSync', 'lstatSync', 'fstatSync']);
@@ -271,6 +465,14 @@ function isStatCall(node) {
271
465
  && STAT_METHODS.has(node.callee.property.name);
272
466
  }
273
467
 
468
+ function inoPropertyName(node) {
469
+ if (!node.computed && node.property.type === 'Identifier') return node.property.name;
470
+ if (node.computed && node.property.type === 'Literal' && typeof node.property.value === 'string') {
471
+ return node.property.value;
472
+ }
473
+ return null;
474
+ }
475
+
274
476
  function hasBigIntTrueOption(callNode) {
275
477
  const opts = callNode.arguments[1];
276
478
  if (!opts || opts.type !== 'ObjectExpression') return false;
@@ -294,7 +496,7 @@ function parseProgram(source, file) {
294
496
  }
295
497
 
296
498
  function findNonBigIntInoViolations(source, label) {
297
- if (!source.includes('.ino')) return [];
499
+ if (!source.includes('.ino') && !/\bino\b/.test(source)) return [];
298
500
  const ast = parseProgram(source, label);
299
501
 
300
502
  // Collect function declarations and expressions by name, plus per-scope variable bindings.
@@ -347,6 +549,9 @@ function findNonBigIntInoViolations(source, label) {
347
549
  },
348
550
  VariableDeclarator(node, ancestors) {
349
551
  if (node.id.type !== 'Identifier') return;
552
+ if (node.init && (node.init.type === 'FunctionExpression' || node.init.type === 'ArrowFunctionExpression')) {
553
+ functions.set(node.id.name, node.init);
554
+ }
350
555
  const decl = ancestors[ancestors.length - 2];
351
556
  const scope = decl && decl.kind === 'var' ? enclosingFn(ancestors) : nearestScope(ancestors);
352
557
  recordBinding(scope, node.id.name, node.init || null);
@@ -411,8 +616,9 @@ function findNonBigIntInoViolations(source, label) {
411
616
  return verifyIdentifier(expr.name, scopeNode, fnNode, propPath, seen);
412
617
  }
413
618
 
414
- if (expr.type === 'MemberExpression' && !expr.computed && expr.property.type === 'Identifier') {
415
- return verifyExpr(expr.object, scopeNode, fnNode, [expr.property.name, ...propPath], seen);
619
+ if (expr.type === 'MemberExpression') {
620
+ const property = inoPropertyName(expr);
621
+ if (property) return verifyExpr(expr.object, scopeNode, fnNode, [property, ...propPath], seen);
416
622
  }
417
623
 
418
624
  if (expr.type === 'CallExpression' && expr.callee.type === 'Identifier') {
@@ -424,6 +630,9 @@ function findNonBigIntInoViolations(source, label) {
424
630
  if (ret.argument) returns.push({ arg: ret.argument, scope: nearestScope(ancestors) });
425
631
  },
426
632
  });
633
+ if (targetFn.type === 'ArrowFunctionExpression' && targetFn.body.type !== 'BlockStatement') {
634
+ returns.push({ arg: targetFn.body, scope: parentOf.get(targetFn) || ast });
635
+ }
427
636
  if (!returns.length) return { ok: false, reason: `${expr.callee.name}() has no return value` };
428
637
  let verifiedStat = false;
429
638
  for (const ret of returns) {
@@ -481,8 +690,19 @@ function findNonBigIntInoViolations(source, label) {
481
690
 
482
691
  const violations = [];
483
692
  walk.ancestor(ast, {
693
+ VariableDeclarator(node, ancestors) {
694
+ if (node.id.type !== 'ObjectPattern' || !node.init) return;
695
+ const hasIno = node.id.properties.some(property => property.type === 'Property'
696
+ && ((property.key.type === 'Identifier' && property.key.name === 'ino')
697
+ || (property.key.type === 'Literal' && property.key.value === 'ino')));
698
+ if (!hasIno) return;
699
+ const scopeNode = nearestScope(ancestors);
700
+ const fnNode = enclosingFn(ancestors);
701
+ const check = verifyExpr(node.init, scopeNode, fnNode, [], new Set());
702
+ if (!check.ok) violations.push(`${label}:${node.loc.start.line}: destructured ino from ${check.reason}`);
703
+ },
484
704
  MemberExpression(node, ancestors) {
485
- if (node.computed || node.property.type !== 'Identifier' || node.property.name !== 'ino') return;
705
+ if (inoPropertyName(node) !== 'ino') return;
486
706
  const scopeNode = nearestScope(ancestors);
487
707
  const fnNode = enclosingFn(ancestors);
488
708
  const check = verifyExpr(node.object, scopeNode, fnNode, [], new Set());
@@ -506,14 +726,41 @@ test('548 guard: every non-test JS .ino access comes from a { bigint: true } sta
506
726
  `;
507
727
  const goodSample = `
508
728
  const fs = require('node:fs');
509
- function same(a, b) {
729
+ const same = (a, b) => {
510
730
  const x = fs.statSync(a, { bigint: true });
511
731
  const y = fs.statSync(b, { bigint: true });
512
732
  return x.ino > 0n && x.dev === y.dev && x.ino === y.ino;
733
+ };
734
+ `;
735
+ const destructuredNumberSample = `
736
+ const fs = require('node:fs');
737
+ function same(a, b) {
738
+ const { ino: left } = fs.statSync(a);
739
+ const { ino: right } = fs.statSync(b);
740
+ return left === right;
741
+ }
742
+ `;
743
+ const computedNumberSample = `
744
+ const fs = require('node:fs');
745
+ function same(a, b) {
746
+ const left = fs.statSync(a);
747
+ const right = fs.statSync(b);
748
+ return left['ino'] === right['ino'];
513
749
  }
514
750
  `;
751
+ const arrowHelperSample = `
752
+ const fs = require('node:fs');
753
+ const stat = file => fs.statSync(file, { bigint: true });
754
+ const same = (a, b) => stat(a).ino === stat(b).ino;
755
+ `;
515
756
  assert.ok(findNonBigIntInoViolations(badSample, 'bad.js').length > 0, 'guard must fail on Number-ino comparison');
757
+ assert.ok(findNonBigIntInoViolations(destructuredNumberSample, 'destructured.js').length > 0,
758
+ 'guard must fail on Number-ino reads through destructuring');
759
+ assert.ok(findNonBigIntInoViolations(computedNumberSample, 'computed.js').length > 0,
760
+ 'guard must fail on Number-ino reads through computed access');
516
761
  assert.deepEqual(findNonBigIntInoViolations(goodSample, 'good.js'), [], 'guard must accept bigint-ino comparison');
762
+ assert.deepEqual(findNonBigIntInoViolations(arrowHelperSample, 'arrow-helper.js'), [],
763
+ 'guard must trace a valid const arrow helper');
517
764
 
518
765
  const files = listNonTestJsFiles(ROOT).sort();
519
766
  const checkedWithIno = [];
@@ -87,6 +87,8 @@ test('OpenCode context probe strips baseline fragment and passes treatment fragm
87
87
  fs.mkdirSync(out);
88
88
  installOpenCodeCarrierProbe(setup, out, arm);
89
89
  const pluginPath = path.join(setup.repo, '.opencode/plugins/zz-ledger-probe.js');
90
+ // Node 22.0.0 needs an explicit module type to import the OpenCode fixture.
91
+ fs.writeFileSync(path.join(path.dirname(pluginPath), 'package.json'), '{"type":"module"}\n');
90
92
  const { default: plugin } = await import(`${pathToFileURL(pluginPath).href}?arm=${arm}`);
91
93
  let contextHook;
92
94
  let toolHook;
@@ -129,10 +129,11 @@ function writeApproval(value, file = path.join(TMP, 'approval.json')) {
129
129
  return file;
130
130
  }
131
131
 
132
- function invoke(target, report, approval, harness = ROOT, extraEnv = {}) {
132
+ function invoke(target, report, approval, harness = ROOT, extraEnv = {}, preload = null) {
133
133
  const env = { ...process.env, ...extraEnv };
134
134
  delete env.HARNESS_SYSTEM_ONE_MODE;
135
135
  return childProcess.spawnSync(process.execPath, [
136
+ ...(preload ? ['-r', preload] : []),
136
137
  SCRIPT, '--target', target, '--report', report,
137
138
  '--approval', approval, '--harness', harness, '--json'
138
139
  ], { cwd: ROOT, encoding: 'utf8', env });
@@ -222,6 +223,83 @@ function makeSyncHarness(name, afterWrite, duringRollback = '') {
222
223
  return harness;
223
224
  }
224
225
 
226
+ function writeRollbackIdentityPreload(fixture, file, { site, mismatch, previousIndex }) {
227
+ const indexFile = path.join(fixture.errorsDir, 'index.jsonl');
228
+ const recordFile = path.join(fixture.errorsDir, 'E-0002-parser-edge-case.md');
229
+ const finalIndexStat = previousIndex ? 4 : 3;
230
+ write(file, `
231
+ 'use strict';
232
+ const fs = require('node:fs');
233
+ const path = require('node:path');
234
+ const indexKey = path.resolve(${JSON.stringify(indexFile)});
235
+ const recordKey = path.resolve(${JSON.stringify(recordFile)});
236
+ const large = 2n ** 60n;
237
+ const mismatch = ${JSON.stringify(mismatch)};
238
+ const site = ${JSON.stringify(site)};
239
+ const finalIndexStat = ${finalIndexStat};
240
+ const originalLstat = fs.lstatSync;
241
+ const originalOpen = fs.openSync;
242
+ const originalFstat = fs.fstatSync;
243
+ const indexFds = new Set();
244
+ const recordFds = new Set();
245
+ let indexStatCount = 0;
246
+ let pendingIndexIno = large;
247
+ fs.lstatSync = function (file, options) {
248
+ const result = originalLstat.call(this, file, options);
249
+ const key = path.resolve(String(file));
250
+ if (options && options.bigint && key === indexKey) {
251
+ indexStatCount++;
252
+ pendingIndexIno = large + (site.startsWith('index-') && mismatch && indexStatCount === finalIndexStat ? 1n : 0n);
253
+ result.dev = large;
254
+ result.ino = pendingIndexIno;
255
+ } else if (options && options.bigint && key === recordKey) {
256
+ result.dev = large;
257
+ result.ino = large + (site === 'new-record' && mismatch ? 1n : 0n);
258
+ }
259
+ return result;
260
+ };
261
+ fs.openSync = function (file, ...args) {
262
+ const fd = originalOpen.call(this, file, ...args);
263
+ const key = path.resolve(String(file));
264
+ if (key === indexKey) indexFds.add(fd);
265
+ if (key === recordKey) recordFds.add(fd);
266
+ return fd;
267
+ };
268
+ fs.fstatSync = function (fd, options) {
269
+ const result = originalFstat.call(this, fd, options);
270
+ if (options && options.bigint && indexFds.has(fd)) {
271
+ result.dev = large;
272
+ result.ino = pendingIndexIno;
273
+ } else if (options && options.bigint && recordFds.has(fd)) {
274
+ result.dev = large;
275
+ result.ino = large;
276
+ }
277
+ return result;
278
+ };
279
+ `);
280
+ return { indexFile, recordFile };
281
+ }
282
+
283
+ function replaceAfterWrite(site, replacementCopy) {
284
+ const errorsDir = "path.join(args[args.indexOf('--root') + 1], '.agents', 'harness-everything', 'errors')";
285
+ if (site === 'new-record') {
286
+ return [
287
+ ` const file = path.join(${errorsDir}, 'E-0002-parser-edge-case.md');`,
288
+ ' const temporary = `${file}.replacement`;',
289
+ " fs.writeFileSync(temporary, Buffer.concat([fs.readFileSync(file), Buffer.from('\\n<!-- replacement record -->\\n')]));",
290
+ ` fs.copyFileSync(temporary, ${JSON.stringify(replacementCopy)});`,
291
+ ' fs.renameSync(temporary, file);'
292
+ ].join('\n');
293
+ }
294
+ return [
295
+ ` const file = path.join(${errorsDir}, 'index.jsonl');`,
296
+ ' const temporary = `${file}.replacement`;',
297
+ ` fs.copyFileSync(file, ${JSON.stringify(replacementCopy)});`,
298
+ ' fs.copyFileSync(file, temporary);',
299
+ ' fs.renameSync(temporary, file);'
300
+ ].join('\n');
301
+ }
302
+
225
303
  try {
226
304
  // The whole happy path uses the real CLI and target-root sync implementation.
227
305
  const success = seedFixture();
@@ -405,6 +483,49 @@ try {
405
483
  `rollback recognizes its own replacement, removes the new record, and restores prior index bytes: ${syncFailureResult.error}`);
406
484
  assert.equal(runSync(syncFailure.root).status, 0, 'the target index remains current after rollback');
407
485
 
486
+ assert.equal(Number(2n ** 60n), Number((2n ** 60n) + 1n),
487
+ 'rollback fixture IDs must be distinct bigint values that collide as Number');
488
+ function checkRollbackIdentity(site, mismatch) {
489
+ const fixture = seedFixture();
490
+ const indexFile = path.join(fixture.errorsDir, 'index.jsonl');
491
+ const previousIndex = site !== 'index-missing';
492
+ if (!previousIndex) fs.unlinkSync(indexFile);
493
+ const before = snapshot(fixture.errorsDir);
494
+ const replacementCopy = path.join(TMP, `rollback-${site}-${mismatch ? 'mismatch' : 'match'}.replacement`);
495
+ const harness = makeSyncHarness(`rollback-${site}-${mismatch ? 'mismatch' : 'match'}-harness`,
496
+ replaceAfterWrite(site, replacementCopy));
497
+ const preload = path.join(TMP, `rollback-${site}-${mismatch ? 'mismatch' : 'match'}.cjs`);
498
+ const { recordFile } = writeRollbackIdentityPreload(fixture, preload, { site, mismatch, previousIndex });
499
+ const result = resultFor(invoke(fixture.root, fixture.report, fixture.approval, harness, {}, preload), 1);
500
+ assert.equal(result.ok, false, 'the injected final check fails after successful publication');
501
+
502
+ const after = snapshot(fixture.errorsDir);
503
+ if (mismatch && site.startsWith('index-')) {
504
+ assert.match(result.error, site === 'index-missing'
505
+ ? /index changed before the owned replacement could be removed/
506
+ : /index changed before the owned replacement could be restored/);
507
+ assert.equal(fs.existsSync(recordFile), false, 'matched record identity lets rollback remove its own record');
508
+ assert.deepEqual(fs.readFileSync(indexFile), fs.readFileSync(replacementCopy),
509
+ 'mismatched index identity preserves the replacement index bytes');
510
+ assert.notDeepEqual(after, before, 'the refusal remains visible as a recovery state');
511
+ } else if (mismatch) {
512
+ assert.match(result.error, /new record was replaced by another writer/);
513
+ assert.deepEqual(fs.readFileSync(recordFile), fs.readFileSync(replacementCopy),
514
+ 'mismatched record identity preserves the replacement record bytes');
515
+ assert.deepEqual(fs.readFileSync(indexFile), Buffer.from(before['index.jsonl'], 'base64'),
516
+ 'the independent matched index identity restores the prior index');
517
+ assert.notDeepEqual(after, before, 'the preserved replacement record remains visible');
518
+ } else {
519
+ assert.match(result.error, /injected final check failure; ledger restored to its pre-promotion state/);
520
+ assert.deepEqual(after, before, 'matched bigint identities allow the same rollback branch to complete');
521
+ }
522
+ }
523
+
524
+ for (const site of ['index-missing', 'index-existing', 'new-record']) {
525
+ checkRollbackIdentity(site, true);
526
+ checkRollbackIdentity(site, false);
527
+ }
528
+
408
529
  const rollbackContention = seedFixture();
409
530
  const secondCandidate = rollbackContention.reportJson.candidates.find(candidate =>
410
531
  candidate.id !== rollbackContention.selected.id && candidate.sources.some(source => source.type === 'git'));
@@ -67,6 +67,56 @@ test('S1-I01 local install copies the manifest-shaped checkpoint without activat
67
67
  } finally { remove(root, home); }
68
68
  });
69
69
 
70
+ test('443 R4: cycle, publish, install, manifest and both runtimes agree on version IDs', t => {
71
+ const root = tempDir('harness-s1-version-repo-');
72
+ const home = tempDir('harness-s1-version-home-');
73
+ t.after(() => remove(root, home));
74
+ const { validateVersion, publishVersion } = require('../scripts/system-one-cycle/package');
75
+ const adapterDir = path.dirname(script);
76
+ const python = process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3');
77
+ const activeFile = path.join(home, 'active.json');
78
+ const loadAdapter = () => spawnSync(python, ['-B', '-c',
79
+ "import sys; sys.path.insert(0,sys.argv[2]); import cua_adapter; b=cua_adapter.load_active_bundle(sys.argv[1], scorer_loader=lambda *_: (lambda _r: [], {})); print(b['version'])",
80
+ activeFile, adapterDir], { encoding: 'utf8' });
81
+ const env = { ...process.env, HARNESS_SYSTEM_ONE_HOME: home };
82
+ const version = 's1-2026-12';
83
+ const source = makeRepo(root, version, '.safetensors');
84
+ const manifestFile = path.join(source, 'manifest.json');
85
+ const manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
86
+ const installed = install.installVersion(root, version, home);
87
+ const pointer = install.activate(version, home);
88
+ assert.equal(validateVersion(version), version);
89
+ assert.equal(validateVersionManifest(manifest).version, version);
90
+ assert.equal(readActive(env)?.version, version);
91
+ const live = loadAdapter();
92
+ assert.equal(live.status, 0, live.stderr);
93
+ assert.equal(live.stdout.trim(), version);
94
+ assert.equal(validateVersion('v' + '1'.repeat(79)).length, 80);
95
+
96
+ for (const invalid of ['S1-2026-12', 'v' + '1'.repeat(80), '', '../model', 'a/b', 'a\\b', '.hidden', 'v1\n']) {
97
+ const witness = JSON.stringify(invalid);
98
+ assert.throws(() => validateVersion(invalid), /invalid --version/, witness);
99
+ assert.throws(() => publishVersion({ dataDir: root, version: invalid }), /invalid --version/, witness);
100
+ assert.throws(() => install.installVersion(root, invalid, home), /invalid-version/, witness);
101
+ assert.throws(() => install.activate(invalid, home), /invalid-version/, witness);
102
+ assert.throws(() => validateVersionManifest({ ...manifest, version: invalid }), /invalid-manifest/, witness);
103
+ assert.deepEqual(JSON.parse(fs.readFileSync(activeFile)), pointer, witness);
104
+
105
+ // A previous version does not participate in manifest validation.
106
+ for (const field of ['previous', 'version']) {
107
+ fs.writeFileSync(activeFile, JSON.stringify({ ...pointer, [field]: invalid }));
108
+ assert.throws(() => install.readActive(home), /invalid-active-pointer/, witness);
109
+ assert.equal(readActive(env), null, witness);
110
+ const rejected = loadAdapter();
111
+ assert.equal(rejected.error, undefined);
112
+ assert.equal(rejected.status, 1, witness);
113
+ assert.match(rejected.stderr, /ValueError: active-pointer/, witness);
114
+ }
115
+ fs.writeFileSync(activeFile, JSON.stringify(pointer));
116
+ }
117
+ assert.equal(readActive(env)?.dir, installed.dir);
118
+ });
119
+
70
120
  test('S1-I02 install rejects a tampered stage hash before copying any version', () => {
71
121
  const root = tempDir('harness-s1-repo-'); const home = tempDir('harness-s1-home-');
72
122
  try {
@@ -143,6 +143,20 @@ try {
143
143
  assert.match(denied.stderr, /structured-mutate/);
144
144
  }
145
145
 
146
+ for (const tool of ['mcp__codex_apps__github__create_issue', 'mcp__codex_apps__github_create_issue', 'mcp__github__create_issue']) {
147
+ const ok = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Track follow-up', body: 'Details' }));
148
+ assert.strictEqual(ok.status, 0, `${tool} routine create_issue stdin payload must be host-deferred`);
149
+ assert.strictEqual(ok.stdout.trim(), '', `${tool} deferral must emit no permission decision`);
150
+ const bad = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Bad extra', state: 'closed' }));
151
+ assert.strictEqual(bad.status, 2, `${tool} with extra key must fail closed`);
152
+ assert.match(bad.stderr, /structured-mutate/);
153
+ }
154
+ for (const tool of ['mcp__demo__create_issue', 'mcp__get_provider__create_issue', 'mcp__demo__create_issues', 'mcp__demo__foo_create_issue', 'create_issue']) {
155
+ const blocked = run(payload(tool, { repository_full_name: 'acme/repo', title: 'Spoofed' }));
156
+ assert.strictEqual(blocked.status, 2, `${tool} must remain a Codex block`);
157
+ assert.match(blocked.stderr, /structured-mutate/, `${tool} must remain a structured-mutate block`);
158
+ }
159
+
146
160
  // Genuine mutations remain blocked, but the fixed-format approval protocol is retired.
147
161
  const legacyMutation = run(payload('mcp__demo__update_issue', { issue_id: 1, title: 'changed' }));
148
162
  assert.strictEqual(legacyMutation.status, 2, 'genuine mutation must remain blocked on Codex');
package/docs/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Harness Documentation
2
+
3
+ Role- and task-oriented navigation portal for Harness. Each section links to the existing canonical documents without duplicating their content.
4
+
5
+ ```mermaid
6
+ flowchart LR
7
+ Start["New to Harness"] --> GS["Getting Started"]
8
+ GS --> UG["User Guide & Workflows"]
9
+ UG --> Arch["Architecture & Philosophy"]
10
+ UG --> Trust["Trust, Security & Evidence"]
11
+ Contrib["Contributing or Operating"] --> Dev["Development & Governance"]
12
+ Research["Exploring Experimental Work"] --> Res["Research & Experimental"]
13
+ ```
14
+
15
+ ## Getting Started
16
+
17
+ | Topic | Document | What it covers |
18
+ | --- | --- | --- |
19
+ | Overview & installation | [README.md](../README.md) | Problem statement, quick start, and install paths |
20
+ | Platform capability matrix | [platform-capabilities.md](platform-capabilities.md) | Supported hosts, install scopes, and live-host evidence boundaries |
21
+ | Machine-readable matrix | [platform-compatibility.json](platform-compatibility.json) | Structured host capability and verification statuses |
22
+ | Troubleshooting | [troubleshooting.md](troubleshooting.md) | Common setup, hook, and host-surface diagnostics |
23
+ | Support & issue reporting | [SUPPORT.md](../SUPPORT.md) | Where to report issues and what diagnostics to include |
24
+
25
+ ## User Guide & Workflows
26
+
27
+ | Topic | Document | What it covers |
28
+ | --- | --- | --- |
29
+ | Routing | [routing.md](routing.md) | Keyword routing signals, tier selection, and turn label line |
30
+ | Workflow runtime | [workflow-runtime.md](workflow-runtime.md) | Ordered requirement steps, bindings, and isolation rules |
31
+ | Audit | [audit.md](audit.md) | Self-audit checks and hook mechanism verification |
32
+ | Enforcement & locks | [enforcement-locks.md](enforcement-locks.md) | Active permission/safety boundaries and retired lock behavior |
33
+ | Contract integrity | [contract-integrity.md](contract-integrity.md) | Workflow and skill contract verification |
34
+ | OpenAI / Codex plugin | [openai-plugin.md](openai-plugin.md) | Local `.codex-plugin` setup vs. public Skills-only submission |
35
+ | Codex action gate | [codex-action-gate.md](codex-action-gate.md) | Codex-specific action-gate rules and deferred PR metadata policy |
36
+
37
+ ## Architecture & Philosophy
38
+
39
+ | Topic | Document | What it covers |
40
+ | --- | --- | --- |
41
+ | Philosophy | [philosophy.md](philosophy.md) | Minimal-rails design and `MUST` / `SHOULD` / `MAY` contract strength |
42
+ | Architecture | [architecture.md](architecture.md) | Core runtime components, hooks, and skill routing architecture |
43
+ | Mechanism-first skill mesh | [mechanism-first-skill-mesh.md](mechanism-first-skill-mesh.md) | Mechanism-first composition of skills and runtime checks |
44
+ | Reflection | [reflection.md](reflection.md) | Agent-initiated reassessment and zoom-out design |
45
+ | Architecture Decision Records | [adr/](adr/) | Accepted, proposed, and superseded ADRs |
46
+
47
+ ## Trust, Security & Evidence
48
+
49
+ | Topic | Document | What it covers |
50
+ | --- | --- | --- |
51
+ | Security policy | [SECURITY.md](../SECURITY.md) | Vulnerability reporting and hook security scope |
52
+ | Security audit | [security-audit.md](security-audit.md) | Repository security review notes and boundaries |
53
+ | Privacy notice | [PRIVACY.md](../PRIVACY.md) | Data handling, local-only state, and observation opt-out |
54
+ | Telemetry | [telemetry.md](telemetry.md) | Telemetry policy and local observation boundaries |
55
+ | System One observations | [system-one-observations.md](system-one-observations.md) | Local turn observation schema and redaction rules |
56
+ | Benchmarks | [benchmarks/README.md](../benchmarks/README.md) | Paired behavioral benchmark status and recording workflow |
57
+ | Release evidence | [release-evidence.md](release-evidence.md) | Observed npm/GitHub release verification ledger |
58
+ | Verifier boundaries | [verifier-boundaries.md](verifier-boundaries.md) | Path containment and exact execution evidence contracts |
59
+
60
+ ## Development & Governance
61
+
62
+ | Topic | Document | What it covers |
63
+ | --- | --- | --- |
64
+ | Contributing | [CONTRIBUTING.md](../CONTRIBUTING.md) | Local dev setup, quality gates, and PR expectations |
65
+ | Agent operating guide | [AGENTS.md](../AGENTS.md) | Repository layout, change rules, and verification commands |
66
+ | Repository contract | [repository-contract.md](repository-contract.md) | Generated Node runtime, workflow, and gate summary |
67
+ | Document lifecycle | [document-lifecycle.md](document-lifecycle.md) | Governance tiers, placement rules, and lifecycle checks |
68
+ | Governed document index | [governed-index.md](governed-index.md) | Active governed documents and ADR status index |
69
+ | Document-evidence boundary | [doc-evidence-boundary.md](doc-evidence-boundary.md) | Read-boundary enforcement for document evidence |
70
+
71
+ ## Research & Experimental
72
+
73
+ | Topic | Document | What it covers |
74
+ | --- | --- | --- |
75
+ | System One cycle | [system-one-cycle.md](system-one-cycle.md) | Monthly local observation, labeling, training, and publish runbook |
76
+ | System One routing | [system-one-routing.md](system-one-routing.md) | Experimental routing model integration and output contract |
77
+ | System One observations | [system-one-observations.md](system-one-observations.md) | Local observation store used by the training cycle |
78
+ | System One training | [system-one-training.md](system-one-training.md) | Classifier training stages and evaluation setup |
79
+ | System One corpus | [system-one-corpus.md](system-one-corpus.md) | Corpus construction and holdout structure |
80
+ | System One intent | [system-one-intent.md](system-one-intent.md) | Intent classification taxonomy and gating |
81
+ | Public roadmap | [ROADMAP.md](../ROADMAP.md) | Maturity tiers and linked GitHub Issues |