harness-everything 1.5.2 → 1.5.4

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 (30) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +12 -0
  4. package/benchmarks/results/live-host/agy-2026-12-02-linux-loader/README.md +33 -0
  5. package/ci/mechanism-468-dispatch-cli.test.js +99 -4
  6. package/ci/mechanism-548-bigint-identity.test.js +252 -5
  7. package/ci/mechanism-error-ledger-promote.test.js +122 -1
  8. package/ci/mechanism-system-one-install.test.js +50 -0
  9. package/docs/error-handling/details/c8-dispatch-cli.md +12 -0
  10. package/docs/platform-capabilities.md +8 -1
  11. package/docs/platform-compatibility.json +3 -3
  12. package/docs/system-one-cycle.md +2 -1
  13. package/harness-everything/SKILL.md +1 -1
  14. package/harness-everything/scripts/system-one/cua_adapter.py +4 -2
  15. package/harness-everything/scripts/system-one/install.js +1 -5
  16. package/harness-everything/scripts/system-one/manifest.js +7 -3
  17. package/harness-everything/scripts/system-one/provider.js +3 -4
  18. package/opencode-plugin/plugin.json +1 -1
  19. package/package.json +1 -1
  20. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  21. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  22. package/plugins/harness-everything/plugin.json +1 -1
  23. package/plugins/harness-everything/skills/harness-everything/SKILL.md +1 -1
  24. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/cua_adapter.py +4 -2
  25. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/install.js +1 -5
  26. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/manifest.js +7 -3
  27. package/plugins/harness-everything/skills/harness-everything/scripts/system-one/provider.js +3 -4
  28. package/sbom.cdx.json +7 -7
  29. package/scripts/dispatch.js +90 -7
  30. package/scripts/system-one-cycle/package.js +2 -2
@@ -10,7 +10,7 @@
10
10
  "name": "harness-everything",
11
11
  "source": "./",
12
12
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
13
- "version": "1.5.2",
13
+ "version": "1.5.4",
14
14
  "author": {
15
15
  "name": "Miya Daniel"
16
16
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harness-everything",
3
3
  "description": "Harness OS: an orchestrated agent operating system — tier routing, circuit breaker guardrails, verification gates, WAL session memory, and self-evolving workspace rules.",
4
- "version": "1.5.2",
4
+ "version": "1.5.4",
5
5
  "author": {
6
6
  "name": "Miya Daniel"
7
7
  },
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [1.5.4](https://github.com/dyphn1/Harness-everything/compare/v1.5.3...v1.5.4) (2026-12-02)
6
+
7
+ ### Bug Fixes
8
+
9
+ * **system-one:** unify version ID validation ([678a84b](https://github.com/dyphn1/Harness-everything/commit/678a84b6315bdaecb738efa86d55a5c5773ea310))
10
+
11
+ ## [1.5.3](https://github.com/dyphn1/Harness-everything/compare/v1.5.2...v1.5.3) (2026-12-01)
12
+
13
+ ### Bug Fixes
14
+
15
+ * **dispatch:** report cache-inclusive token budgets ([b8667c7](https://github.com/dyphn1/Harness-everything/commit/b8667c733958f8ec3e3763f1c77aa0721cb16db9)), closes [#466](https://github.com/dyphn1/Harness-everything/issues/466)
16
+
5
17
  ## [1.5.2](https://github.com/dyphn1/Harness-everything/compare/v1.5.1...v1.5.2) (2026-12-01)
6
18
 
7
19
  ### Bug Fixes
@@ -0,0 +1,33 @@
1
+ # Antigravity CLI Linux plugin loading for #514
2
+
3
+ | Field | Observed value |
4
+ | --- | --- |
5
+ | Host | Antigravity CLI 1.5.21 |
6
+ | OS | Debian GNU/Linux 13.7, x86_64, kernel 6.18.64 |
7
+ | Node | 24.22.3 |
8
+ | Harness | 1.5.3 at `970f168455e75a5a42b2181e9074b57c78fd7017` |
9
+ | Scope | Global package in a disposable home. Separate clean home for the project-only probe and its control. |
10
+
11
+ ## Loader checks
12
+
13
+ Commands below use a disposable profile and a local checkout.
14
+
15
+ | Command or check | Observed result |
16
+ | --- | --- |
17
+ | `agy plugin validate --json ./plugins/harness-everything` | Validation succeeded. The host selected `.antigravity-plugin/plugin.json` and found 28 skills, one rule and one hook. It reported two warnings for the other hosts' `hooks/hooks.json` and `plugin.json` plus a no-logo note. |
18
+ | `agy plugin validate --strict --json ./plugins/harness-everything` | Exit 1 with those two warnings. |
19
+ | `agy plugin install <checkout>/plugins/harness-everything` | The CLI installed the package under `<profile>/.gemini/config/plugins/harness-everything`. The installed root `hooks.json` was byte-identical to the source. |
20
+ | `agy plugin list --json` | The installed plugin appeared enabled at version 1.5.3 with the `harness-everything` hook and `AGENTS.md` rule. The separate clean profile listed zero global plugins. |
21
+
22
+ ## Lifecycle evidence
23
+
24
+ A temporary Git workspace carried the package at `.agents/plugins/harness-everything/`. A second Git workspace using the same clean profile had no project plugin. In each workspace, `agy --print-timeout 12s --print "Reply with HELLO, with no tool calls." --output-format json` stopped at Google authentication. Neither run produced a lifecycle trace. Project-only loading and global/project isolation therefore remain open.
25
+
26
+ | Acceptance item | Evidence and disposition |
27
+ | --- | --- |
28
+ | Global loader | Linux CLI 1.5.21 validation, install and list confirmed above. The macOS and Windows lifecycle samples remain scoped to their recorded versions. |
29
+ | Project-only loader and IDE write tools | Earlier macOS CLI evidence covers temporary project-scope hook discovery. Windows CLI 1.5.17 exercised `write_file` inside and outside its subdirectory workspace. Full isolation and IDE-specific `write_to_file`, `replace_file_content` and `multi_replace_file_content` remain unchecked. |
30
+ | `PostToolUse` outcome | Earlier macOS and Windows shell traces lack structured exit status. The Windows trace preserved unset verification timestamps. Verification credit requires a structured success outcome. |
31
+ | `Stop` | The Windows CLI test observed `NO_TOOL_CALL`, with one continuation for a pending edit and a later allow. Live `model_stop` remains unchecked. |
32
+
33
+ Sources: [PR #513 and macOS host evidence](../agy-2026-11-23/README.md), [Windows read-only handoff](../agy-2026-11-26-516-read-only/README.md), [Windows CLI #516 acceptance](https://github.com/dyphn1/Harness-everything/issues/516#issuecomment-7182359426). Upstream outcome and wait-marker tracking continues under [#538](https://github.com/dyphn1/Harness-everything/issues/538).
@@ -43,6 +43,7 @@ const reports = path.join(fixtureRoot, 'reports with spaces');
43
43
  const runnerBin = path.join(fixtureRoot, 'runner bin');
44
44
  const openCodeOnlyBin = path.join(fixtureRoot, 'opencode only bin');
45
45
  const rawOverridePreload = path.join(fixtureRoot, 'raw-override.cjs');
46
+ const usagePreload = path.join(fixtureRoot, 'usage-preload.cjs');
46
47
  const admissionPreload = path.join(fixtureRoot, 'admission-preload.cjs');
47
48
  const agyStubScript = path.join(fixtureRoot, 'agy-stub.cjs');
48
49
  const agyWinPreload = path.join(fixtureRoot, 'agy-win-preload.cjs');
@@ -251,6 +252,7 @@ function cliEnv(testCase, config = {}) {
251
252
  DISPATCH_FIXTURE_EXECUTION: config.execution || 'done',
252
253
  };
253
254
  const preloads = [];
255
+ preloads.push(`--require "${usagePreload.replace(/\\/g, '/')}"`);
254
256
  if (process.platform === 'win32') preloads.push(`--require "${agyWinPreload.replace(/\\/g, '/')}"`);
255
257
  if (config.rawOverride !== undefined) {
256
258
  env.DISPATCH_FIXTURE_RAW_OVERRIDE = config.rawOverride;
@@ -404,6 +406,7 @@ function runSuccessAndArgvMatch(runner, requestedModel = runner === 'codex' ? 'f
404
406
  const result = jsonResponse(cli([...args, '--json'], testCase, config), 0, 'DONE');
405
407
  assert.equal(result.runner, runner);
406
408
  assert.equal(result.model, model);
409
+ assert.ok(result.usage && Number.isSafeInteger(result.usage.totalTokens), 'successful structured runner telemetry is reported');
407
410
  assert.equal(fs.existsSync(testCase.scratch), true);
408
411
  assert.equal(fs.readFileSync(result.evidence.report, 'utf8'), 'Fixture completed the packet.\nSTATUS: DONE\n');
409
412
  const actualEvents = events(testCase);
@@ -458,6 +461,42 @@ if (
458
461
  };
459
462
  }
460
463
  `);
464
+ fs.writeFileSync(usagePreload, `'use strict';
465
+ const path = require('node:path');
466
+ const originalWrite = process.stdout.write.bind(process.stdout);
467
+ const script = path.basename(process.argv[1] || '');
468
+ const runner = script === 'exec' ? 'codex' : script === 'run' ? 'opencode' : script === path.basename(${JSON.stringify(agyStubScript)}) ? 'agy' : null;
469
+ const args = process.argv.slice(2);
470
+ const phase = args.includes('Reply with the single word READY') ? 'readiness' : 'execution';
471
+ if (runner && phase === 'execution') {
472
+ const structured = runner === 'codex' ? args.includes('--json') : runner === 'opencode' ? args.includes('--format') : args.includes('--output-format');
473
+ const option = runner === 'codex' ? null : args[args.indexOf(runner === 'opencode' ? '--format' : '--output-format') + 1];
474
+ if (structured && (runner === 'codex' || option === (runner === 'opencode' ? 'json' : 'json'))) {
475
+ const supplied = process.env.DISPATCH_FIXTURE_USAGE;
476
+ let source = null;
477
+ try { source = supplied ? JSON.parse(supplied) : null; } catch {}
478
+ process.stdout.write = function (chunk, ...rest) {
479
+ if (!String(chunk).includes('fixture child output')) return originalWrite(chunk, ...rest);
480
+ if (supplied === 'missing') return originalWrite('', ...rest);
481
+ if (typeof supplied === 'string' && supplied.startsWith('prose ')) return originalWrite(supplied.slice(6) + '\\n', ...rest);
482
+ if (runner === 'codex') {
483
+ const usage = source || { input_tokens: 10, cached_input_tokens: 8, output_tokens: 4 };
484
+ return originalWrite(JSON.stringify({ type: 'turn.completed', usage }) + '\\n', ...rest);
485
+ }
486
+ if (runner === 'opencode') {
487
+ const totals = source?.totals || [21, 14];
488
+ const lines = totals.map((total, index) => {
489
+ const cacheWrite = source?.cacheWrite || 0;
490
+ return JSON.stringify({ type: 'step_finish', part: { id: 'fixture-step-' + index, reason: index === totals.length - 1 ? 'stop' : 'tool-calls', type: 'step-finish', tokens: { total, input: 1, output: 1, reasoning: 0, cache: { read: Math.max(0, total - 2 - cacheWrite), write: cacheWrite } } } });
491
+ });
492
+ return originalWrite(lines.join('\\n') + '\\n', ...rest);
493
+ }
494
+ const usage = source || { input_tokens: 10, output_tokens: 2, thinking_tokens: 1, cache_read_tokens: 8, total_tokens: 12 };
495
+ return originalWrite(JSON.stringify({ status: 'SUCCESS', response: '', usage }) + '\\n', ...rest);
496
+ };
497
+ }
498
+ }
499
+ `);
461
500
  fs.writeFileSync(admissionPreload, `'use strict';
462
501
  const fs = require('node:fs');
463
502
  const path = require('node:path');
@@ -502,6 +541,58 @@ fs.mkdirSync(path.join(fixtureRoot, `${path.basename(worktree)}-sibling`));
502
541
  fs.symlinkSync(repositoryParent, symlinkedParent, process.platform === 'win32' ? 'junction' : 'dir');
503
542
 
504
543
  try {
544
+ check('468 token usage counts cached input once and marks only totals strictly above 30M', () => {
545
+ const runUsage = (telemetry, label) => {
546
+ const testCase = makeCase(`usage ${label}`);
547
+ const usageText = typeof telemetry === 'string' ? telemetry : JSON.stringify(telemetry);
548
+ const result = jsonResponse(cli([...argsFor(testCase, 'codex'), '--json'], testCase, { extraEnv: { DISPATCH_FIXTURE_USAGE: usageText } }), 0, 'DONE');
549
+ return { testCase, result };
550
+ };
551
+ assert.deepEqual(runUsage({ input_tokens: 29_999_999, cached_input_tokens: 12_000_000, output_tokens: 0 }, 'below').result.usage, { totalTokens: 29_999_999 });
552
+ assert.deepEqual(runUsage({ input_tokens: 30_000_000, cached_input_tokens: 15_000_000, output_tokens: 0 }, 'exact').result.usage, { totalTokens: 30_000_000 });
553
+ const above = runUsage({ input_tokens: 30_000_000, cached_input_tokens: 10_000_000, output_tokens: 1 }, 'above');
554
+ assert.deepEqual(above.result.usage, { totalTokens: 30_000_001, mark: 'OVER-BUDGET' });
555
+ assert.equal(runUsage('prose tokens used: 30000001', 'unknown').result.usage, null);
556
+ assert.equal(runUsage('missing', 'missing').result.usage, null);
557
+ assert.equal(runUsage({ input_tokens: 0, cached_input_tokens: 0, output_tokens: 0 }, 'codex default fallback').result.usage, null);
558
+ assert.equal(events(above.testCase).length, 2, 'the advisory must not change lifecycle calls');
559
+ });
560
+
561
+ check('468 structured usage controls: Codex, OpenCode, malformed and prose telemetry', () => {
562
+ const codex = makeCase('Codex cache-inclusive usage');
563
+ assert.deepEqual(jsonResponse(cli([...argsFor(codex, 'codex'), '--json'], codex, { extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify({ input_tokens: 10, cached_input_tokens: 8, output_tokens: 4 }) } }), 0, 'DONE').usage, { totalTokens: 14 });
564
+ const opencode = makeCase('OpenCode cache-inclusive usage');
565
+ assert.deepEqual(jsonResponse(cli([...argsFor(opencode, 'opencode'), '--json'], opencode, { extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify({ totals: [21, 14] }) } }), 0, 'DONE').usage, { totalTokens: 35 });
566
+ const opencodeCacheWrite = makeCase('OpenCode cache-write usage unknown');
567
+ assert.equal(jsonResponse(cli([...argsFor(opencodeCacheWrite, 'opencode'), '--json'], opencodeCacheWrite, { extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify({ totals: [21], cacheWrite: 3 }) } }), 0, 'DONE').usage, null);
568
+ const malformed = makeCase('malformed usage');
569
+ assert.equal(jsonResponse(cli([...argsFor(malformed, 'codex'), '--json'], malformed, { extraEnv: { DISPATCH_FIXTURE_USAGE: '{"input_tokens":"30M"}' } }), 0, 'DONE').usage, null);
570
+ const prose = makeCase('prose usage');
571
+ assert.equal(jsonResponse(cli([...argsFor(prose, 'opencode'), '--json'], prose, { extraEnv: { DISPATCH_FIXTURE_USAGE: 'prose tokens used: 30000001' } }), 0, 'DONE').usage, null);
572
+ });
573
+
574
+ check('468 human DONE prints the cache-inclusive total without changing exit or report status', () => {
575
+ const testCase = makeCase('human token usage');
576
+ const result = cli(argsFor(testCase, 'codex'), testCase, { extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify({ input_tokens: 10, cached_input_tokens: 8, output_tokens: 4 }) } });
577
+ assert.equal(result.status, 0, result.stderr);
578
+ assert.match(result.stdout, /total tokens incl\. cache: 14/);
579
+ assert.ok(fs.readFileSync(testCase.report, 'utf8').endsWith('STATUS: DONE\n'));
580
+ });
581
+ check('468 completed telemetry is retained when a valid BLOCKED report is delivered', () => {
582
+ const telemetry = { input_tokens: 30_000_000, cached_input_tokens: 12_000_000, output_tokens: 1 };
583
+ const doneCase = makeCase('done report with same usage');
584
+ const done = jsonResponse(cli([...argsFor(doneCase, 'codex'), '--json'], doneCase, {
585
+ extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify(telemetry) },
586
+ }), 0, 'DONE');
587
+ const testCase = makeCase('blocked report with usage');
588
+ const response = jsonResponse(cli([...argsFor(testCase, 'codex'), '--json'], testCase, {
589
+ execution: 'blocked',
590
+ extraEnv: { DISPATCH_FIXTURE_USAGE: JSON.stringify(telemetry) },
591
+ }), 17, 'WORKER_BLOCKED');
592
+ assert.deepEqual(done.usage, { totalTokens: 30_000_001, mark: 'OVER-BUDGET' });
593
+ assert.deepEqual(response.usage, done.usage);
594
+ assert.match(response.message, /valid BLOCKED report/);
595
+ });
505
596
  check('HELP human and JSON', () => {
506
597
  const testCase = makeCase('help');
507
598
  const human = cli(['--help'], testCase);
@@ -758,6 +849,7 @@ try {
758
849
  check(`${runner} execution failure -> RUN_FAILED with no retry/fallback`, () => {
759
850
  const testCase = makeCase(`${runner} run failed`);
760
851
  const response = jsonResponse(cli([...argsFor(testCase, runner), '--json'], testCase, { execution: 'exit-failure' }), 15, 'RUN_FAILED');
852
+ assert.equal(response.usage, null, 'failed telemetry is unknown');
761
853
  const actualEvents = events(testCase);
762
854
  assert.equal(actualEvents.length, 2);
763
855
  assert.ok(actualEvents.every(event => event.runner === runner));
@@ -767,9 +859,10 @@ try {
767
859
 
768
860
  check(`${runner} execution timeout -> RUN_TIMEOUT and child exited`, () => {
769
861
  const testCase = makeCase(`${runner} run timeout`);
770
- jsonResponse(cli([...argsFor(testCase, runner), '--json'], testCase, {
862
+ const response = jsonResponse(cli([...argsFor(testCase, runner), '--json'], testCase, {
771
863
  execution: 'timeout', testTimeoutMs: 300, outerTimeoutMs: 5000,
772
864
  }), 15, 'RUN_TIMEOUT');
865
+ assert.equal(response.usage, null, 'interrupted telemetry is unknown');
773
866
  const actualEvents = events(testCase);
774
867
  assert.equal(actualEvents.length, 2);
775
868
  assert.ok(actualEvents.every(event => event.runner === runner));
@@ -1395,7 +1488,7 @@ try {
1395
1488
  '--report', testCase.reportRel,
1396
1489
  ];
1397
1490
  }
1398
- function assertAgyArgv(argv, model, prompt, timeoutSeconds) {
1491
+ function assertAgyArgv(argv, model, prompt, timeoutSeconds, structured = false) {
1399
1492
  assert.deepEqual(argv, [
1400
1493
  '-p', prompt,
1401
1494
  '--model', model,
@@ -1403,6 +1496,7 @@ try {
1403
1496
  '--sandbox',
1404
1497
  '--settings', agySettings,
1405
1498
  '--print-timeout', `${timeoutSeconds}s`,
1499
+ ...(structured ? ['--output-format', 'json'] : []),
1406
1500
  ]);
1407
1501
  }
1408
1502
  function assertAgyEvent(event, testCase, phase, model = 'gemini-4-neon-medium') {
@@ -1414,7 +1508,7 @@ try {
1414
1508
  const expectedPrompt = phase === 'readiness'
1415
1509
  ? 'Reply with the single word READY'
1416
1510
  : `Execute the packet at ${testCase.packetRel} and write the complete report to ${testCase.reportRel}. Use only paths relative to the current directory.`;
1417
- assertAgyArgv(event.args, model, expectedPrompt, phase === 'readiness' ? 120 : 2700);
1511
+ assertAgyArgv(event.args, model, expectedPrompt, phase === 'readiness' ? 120 : 2700, phase === 'execution');
1418
1512
  if (phase === 'execution') {
1419
1513
  assert.equal(expectedPrompt.includes(worktree), false, 'agy prompt must use cwd-relative paths');
1420
1514
  }
@@ -1430,7 +1524,7 @@ try {
1430
1524
  assertSameCanonicalPath(dryRun.cwd, worktree);
1431
1525
  assert.equal(dryRun.argv[0], 'agy');
1432
1526
  const expectedPrompt = `Execute the packet at ${testCase.packetRel} and write the complete report to ${testCase.reportRel}. Use only paths relative to the current directory.`;
1433
- assertAgyArgv(dryRun.argv.slice(1), 'gemini-4-neon-medium', expectedPrompt, 2700);
1527
+ assertAgyArgv(dryRun.argv.slice(1), 'gemini-4-neon-medium', expectedPrompt, 2700, true);
1434
1528
  assertNoRunner(testCase);
1435
1529
  assertNoScratchOrReport(testCase);
1436
1530
 
@@ -1439,6 +1533,7 @@ try {
1439
1533
  assert.equal(response.runner, 'agy');
1440
1534
  assert.equal(response.model, 'gemini-4-neon-medium');
1441
1535
  assert.equal(response.sandbox, 'requested');
1536
+ assert.deepEqual(response.usage, { totalTokens: 12 });
1442
1537
  assert.equal(fs.readFileSync(response.evidence.report, 'utf8'), 'Fixture completed the packet.\nSTATUS: DONE\n');
1443
1538
  const actualEvents = events(testCase);
1444
1539
  assert.equal(actualEvents.length, 2, 'one readiness and one execution');
@@ -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 = [];