harness-everything 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +29 -0
  4. package/ci/archive/325-prep/README.md +9 -2
  5. package/ci/archive/325-prep/doc-reconciliation-red.js +34 -8
  6. package/ci/fixtures/468-dispatch/agy-quota-PROVENANCE.md +19 -0
  7. package/ci/fixtures/468-dispatch/agy-quota-direct-individual.stderr +2 -0
  8. package/ci/fixtures/468-dispatch/agy-quota-direct-third-party.stderr +2 -0
  9. package/ci/fixtures/468-dispatch/agy-quota-exec-individual.log +3 -0
  10. package/ci/fixtures/553-t2a/body-edit/base/.agents/harness-everything/project-docs.json +11 -0
  11. package/ci/fixtures/553-t2a/body-edit/base/docs/a.md +6 -0
  12. package/ci/fixtures/553-t2a/body-edit/base/docs/b.md +1 -0
  13. package/ci/fixtures/553-t2a/body-edit/candidate/docs/a.md +6 -0
  14. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  15. package/ci/fixtures/553-t2c/derived-regenerate-must/base/docs/governed-index.md +19 -0
  16. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/adr/EVID-001-verify-all-evidence.md +11 -0
  17. package/ci/fixtures/553-t2c/derived-regenerate-must/candidate/docs/governed-index.md +19 -0
  18. package/ci/fixtures/553-t2c/derived-regenerate-must/config.json +17 -0
  19. package/ci/fixtures/doc-obligations/derive/regression-pins.json +153 -0
  20. package/ci/fixtures/state-persist-post-tool-use/harness.js +206 -0
  21. package/ci/fixtures/state-persist-post-tool-use/off-handoff-golden.json +16 -0
  22. package/ci/fixtures/state-persist-post-tool-use/payload-post-tool-use-success.json +13 -0
  23. package/ci/fixtures/stop/fail-session-writes.js +109 -0
  24. package/ci/fixtures/workflow-contract/cases.json +3355 -0
  25. package/ci/fixtures/workflow-contract/wiring-cases.json +560 -0
  26. package/ci/lib/doc-reconciliation-prep-fixtures.js +4 -9
  27. package/ci/mechanism-2an-workflow-replay.test.js +324 -0
  28. package/ci/mechanism-2ax-doc-lifecycle.test.js +132 -0
  29. package/ci/mechanism-325-3a-doc-evidence.test.js +73 -0
  30. package/ci/mechanism-325-3a-doc-obligations.test.js +61 -0
  31. package/ci/mechanism-325-3b-preparation.test.js +208 -49
  32. package/ci/mechanism-325-3b-s1-review.test.js +20 -828
  33. package/ci/mechanism-325-3b-s3-providers.test.js +59 -0
  34. package/ci/mechanism-325-f3-derived-views.test.js +140 -0
  35. package/ci/mechanism-341-opencode-lane.test.js +164 -284
  36. package/ci/mechanism-35-verification-contract.test.js +246 -0
  37. package/ci/mechanism-365-step-edit-accounting.test.js +5 -6
  38. package/ci/mechanism-383-doc-glob-line-terminators.test.js +0 -30
  39. package/ci/mechanism-397-opencode-observations.test.js +151 -18
  40. package/ci/mechanism-468-dispatch-cli.test.js +1496 -4
  41. package/ci/mechanism-548-bigint-identity.test.js +531 -0
  42. package/ci/mechanism-553-e1-unhook-credit.test.js +328 -0
  43. package/ci/mechanism-553-p2a-claude-hooks.test.js +98 -0
  44. package/ci/mechanism-553-p3-plan-start.test.js +212 -0
  45. package/ci/mechanism-553-state-persist-post-tool-use.test.js +307 -0
  46. package/ci/mechanism-553-stop.test.js +427 -0
  47. package/ci/mechanism-553-t2a-derive.test.js +110 -0
  48. package/ci/mechanism-553-t2c-derive.test.js +94 -0
  49. package/ci/mechanism-e1-derived-regenerate.test.js +45 -206
  50. package/ci/mechanism-error-ledger-oracle.test.js +786 -3
  51. package/ci/mechanism-error-ledger-scan.test.js +981 -0
  52. package/ci/mechanism-outline-sanitizer.test.js +0 -8
  53. package/ci/mechanism-pr-a-conflict-check.test.js +38 -305
  54. package/ci/mechanism-prb-outline-review.test.js +101 -3283
  55. package/ci/mechanism-report-writer.test.js +45 -0
  56. package/docs/adr/DOCS-006-reconciliation-pilot.md +4 -2
  57. package/docs/adr/DOCS-008-obligation-abstraction-bounded-consumer.md +3 -3
  58. package/docs/doc-workflow-reconciliation.md +17 -2
  59. package/docs/document-lifecycle.md +6 -2
  60. package/docs/error-handling/details/c8-dispatch-cli.md +109 -13
  61. package/docs/platform-capabilities.md +35 -5
  62. package/error-ledger-bootstrap/SKILL.md +1 -1
  63. package/error-ledger-bootstrap/references/workflow.md +42 -7
  64. package/error-ledger-bootstrap/scripts/promote.js +8 -6
  65. package/error-ledger-bootstrap/scripts/scan.js +525 -12
  66. package/hooks/hooks.json +0 -46
  67. package/hooks/scripts/lib/workflow-obligations.js +0 -55
  68. package/hooks/scripts/state-persist.js +7 -95
  69. package/hooks/scripts/workflow-disposition.js +0 -2
  70. package/hooks/scripts/workflow-stop-gate.js +17 -30
  71. package/opencode-plugin/index.mjs +6 -70
  72. package/opencode-plugin/plugin.json +1 -1
  73. package/package.json +1 -1
  74. package/plugins/harness-everything/.antigravity-plugin/plugin.json +1 -1
  75. package/plugins/harness-everything/.codex-plugin/plugin.json +1 -1
  76. package/plugins/harness-everything/hooks/scripts/lib/workflow-obligations.js +0 -55
  77. package/plugins/harness-everything/hooks/scripts/state-persist.js +7 -95
  78. package/plugins/harness-everything/hooks/scripts/workflow-disposition.js +0 -2
  79. package/plugins/harness-everything/hooks/scripts/workflow-stop-gate.js +17 -30
  80. package/plugins/harness-everything/plugin.json +1 -1
  81. package/plugins/harness-everything/skills/error-ledger-bootstrap/SKILL.md +1 -1
  82. package/plugins/harness-everything/skills/error-ledger-bootstrap/references/workflow.md +42 -7
  83. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/promote.js +8 -6
  84. package/plugins/harness-everything/skills/error-ledger-bootstrap/scripts/scan.js +525 -12
  85. package/sbom.cdx.json +7 -7
  86. package/scripts/dispatch.js +499 -87
  87. package/scripts/error-ledger-oracle.js +521 -27
  88. package/scripts/errors-sync.js +4 -3
  89. package/scripts/report-writer.js +4 -3
  90. package/ci/fixtures/doc-obligations/reconciliation-s1/cases.json +0 -6854
  91. package/ci/fixtures/doc-obligations/reconciliation-s1/fail-session-writes.js +0 -116
  92. package/ci/fixtures/doc-obligations/reconciliation-s2a/harness.js +0 -507
  93. package/ci/fixtures/doc-obligations/reconciliation-s2a/run13-workflow-requirements.json +0 -42
  94. package/ci/fixtures/doc-obligations/reconciliation-s2a/vectors.json +0 -617
  95. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/harness.js +0 -415
  96. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-post-tool-use-success-minimal.json +0 -9
  97. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-start.json +0 -7
  98. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-freetext-reject.json +0 -11
  99. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop-reject.json +0 -11
  100. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-subagent-stop.json +0 -11
  101. package/ci/fixtures/doc-obligations/reconciliation-s2b/capture/payload-task-result.json +0 -19
  102. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-capture-only.json +0 -99
  103. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/off-legacy.json +0 -67
  104. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-concurrent-writers.json +0 -62
  105. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-lookalikes-runtime-mutations.json +0 -67
  106. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-malformed.json +0 -85
  107. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-normal-session.json +0 -74
  108. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-runtime-drift-later-npm-test.json +0 -58
  109. package/ci/fixtures/doc-obligations/reconciliation-s2b/corpus/on-valid-direct-quoted-review.json +0 -85
  110. package/ci/fixtures/doc-obligations/reconciliation-s2b/f4/cases.json +0 -2267
  111. package/ci/fixtures/doc-obligations/reconciliation-s2b/wiring/cases.json +0 -1110
  112. package/ci/lib/doc-reconciliation-file-spy.js +0 -23
  113. package/ci/lib/doc-reconciliation-qualification-preload.js +0 -37
  114. package/ci/lib/doc-reconciliation-replay.js +0 -104
  115. package/ci/lib/doc-reconciliation-staged-tree.js +0 -102
  116. package/ci/mechanism-325-3b-h1-qualification.test.js +0 -206
  117. package/ci/mechanism-325-3b-s1.test.js +0 -188
  118. package/ci/mechanism-325-3b-s2a-core.test.js +0 -840
  119. package/ci/mechanism-325-3b-s2a-producer.test.js +0 -564
  120. package/ci/mechanism-325-3b-s2b-capture.test.js +0 -566
  121. package/ci/mechanism-325-3b-s2b-wiring.test.js +0 -679
  122. package/ci/mechanism-325-f4-invariants.test.js +0 -606
  123. package/ci/mechanism-325-f4-projections.test.js +0 -392
  124. package/ci/mechanism-325-f4-qualification.test.js +0 -228
  125. package/ci/mechanism-325-f4-trust-boundary.test.js +0 -880
  126. package/ci/mechanism-e1-dependency-artifact-scope.test.js +0 -657
  127. package/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  128. package/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  129. package/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  130. package/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  131. package/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  132. package/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  133. package/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  134. package/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  135. package/hooks/scripts/w6-state-operations.js +0 -239
  136. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-capture.sanitized.jsonl +0 -26
  137. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-core.js +0 -336
  138. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-events.js +0 -292
  139. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-outline-capture.sanitized.jsonl +0 -24
  140. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-pilot.js +0 -482
  141. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-producer.js +0 -468
  142. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-provider.js +0 -3304
  143. package/plugins/harness-everything/hooks/scripts/lib/doc-reconciliation-qualification.json +0 -54
  144. package/plugins/harness-everything/hooks/scripts/w6-state-operations.js +0 -239
  145. package/scripts/system-one-eval-laya.js +0 -112
  146. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/capture → state-persist-post-tool-use}/payload-post-tool-use-failure.json +0 -0
  147. /package/ci/fixtures/{doc-obligations/reconciliation-s2b/wiring → workflow-contract}/legacy-off-golden.json +0 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  const assert = require('node:assert/strict');
4
4
  const childProcess = require('node:child_process');
5
+ const crypto = require('node:crypto');
5
6
  const fs = require('node:fs');
6
7
  const os = require('node:os');
7
8
  const path = require('node:path');
@@ -468,6 +469,236 @@ try {
468
469
  'MEMORY.md verifies the hinted directory');
469
470
  fs.rmSync(memoryMarker);
470
471
 
472
+ // I486-memory-discovery: current memory/MEMORY.md marker, index exclusion, unrelated-home isolation, and linked-worktree fallback.
473
+ const unrelatedHome = path.join(TMP, 'PRIVATE_UNRELATED_HOME_SENTINEL');
474
+ const unrelatedSlugDir = path.join(unrelatedHome, '.claude', 'projects', slug, 'memory');
475
+ writeFile(path.join(unrelatedSlugDir, 'MEMORY.md'), '# Unrelated home index\n');
476
+ writeFile(path.join(unrelatedSlugDir, 'lesson-trap.md'),
477
+ '---\ntype: feedback\ntitle: PRIVATE_UNRELATED_HOME_TRAP\n---\n## Cue\nTrap.\n## Lesson\nInspect `src/single.js`.\n');
478
+ writeFile(path.join(home, '.claude', 'projects', '-unrelated-other-repo', 'memory', 'MEMORY.md'), '# Other project index\n');
479
+ writeFile(path.join(home, '.claude', 'projects', '-unrelated-other-repo', 'memory', 'lesson-other.md'),
480
+ '---\ntype: feedback\ntitle: PRIVATE_OTHER_PROJECT_TRAP\n---\n## Cue\nOther.\n## Lesson\nInspect `src/single.js`.\n');
481
+
482
+ const currentMarker = path.join(autoMemoryDir, 'MEMORY.md');
483
+ writeFile(currentMarker, [
484
+ '---',
485
+ 'type: feedback',
486
+ 'title: PRIVATE_INDEX_TITLE_SENTINEL',
487
+ '---',
488
+ '# Memory Index',
489
+ '## Cue',
490
+ 'Index entry should never become a candidate.',
491
+ '## Lesson',
492
+ 'Do not emit `src/parser.js` from the index.',
493
+ ''
494
+ ].join('\n'));
495
+ writeFile(autoMemory, [
496
+ '---',
497
+ 'type: feedback',
498
+ 'title: PRIVATE_TITLE_SENTINEL current marker lesson',
499
+ '---',
500
+ '## Cue',
501
+ 'Current marker verification without repeating repo name.',
502
+ '## Lesson',
503
+ 'Keep testing `src/parser.js`.',
504
+ ''
505
+ ].join('\n'));
506
+
507
+ const currentMarkerOut = path.join(TMP, 'current-marker-reports');
508
+ const currentMarkerPayload = reportFrom(run([
509
+ '--root', repo, '--out', currentMarkerOut, '--hide-ledger', '--home', home
510
+ ], home, null, { HOME: unrelatedHome, USERPROFILE: unrelatedHome }));
511
+ const currentMarkerJson = JSON.parse(fs.readFileSync(currentMarkerPayload.reportJson, 'utf8'));
512
+ const currentMarkerMd = fs.readFileSync(currentMarkerPayload.reportMd, 'utf8');
513
+ const currentMarkerSource = currentMarkerJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
514
+ assert.strictEqual(currentMarkerSource.status, 'used', 'memory/MEMORY.md verifies the auto-memory directory');
515
+ assert.strictEqual(currentMarkerSource.verified, true);
516
+ assert.match(currentMarkerSource.verificationRef, /^local\/[a-f0-9]{64}$/);
517
+ assert.ok(currentMarkerSource.reason.includes('memory marker'));
518
+ const currentMemoryLeads = currentMarkerJson.candidates.filter(item => item.sources.some(source => source.type === 'memory'));
519
+ assert.strictEqual(currentMemoryLeads.length, 1, 'supported legacy lesson reaches report while MEMORY.md index does not');
520
+ assert.deepStrictEqual(currentMemoryLeads[0].sites, ['src/parser.js']);
521
+ assert.ok(!candidate(currentMarkerJson, 'src/single.js', 'memory'), 'unrelated home directories are never traversed');
522
+ assert.doesNotMatch(JSON.stringify(currentMarkerJson), /PRIVATE_INDEX_TITLE_SENTINEL|PRIVATE_UNRELATED_HOME|PRIVATE_OTHER_PROJECT/);
523
+ assert.doesNotMatch(currentMarkerMd, /PRIVATE_INDEX_TITLE_SENTINEL|PRIVATE_UNRELATED_HOME|PRIVATE_OTHER_PROJECT/);
524
+
525
+ // Explicit --memory directory containing MEMORY.md also skips the index.
526
+ const explicitWithIndexDir = path.join(TMP, 'explicit-with-index');
527
+ writeFile(path.join(explicitWithIndexDir, 'MEMORY.md'), [
528
+ '---',
529
+ 'type: feedback',
530
+ 'title: PRIVATE_INDEX_TITLE_SENTINEL',
531
+ '---',
532
+ '## Cue',
533
+ 'Explicit index.',
534
+ '## Lesson',
535
+ 'Ignore `src/single.js` in index.',
536
+ ''
537
+ ].join('\n'));
538
+ writeFile(path.join(explicitWithIndexDir, 'lesson-explicit-real.md'), [
539
+ '---',
540
+ 'type: feedback',
541
+ '---',
542
+ '## Cue',
543
+ 'Explicit real lesson.',
544
+ '## Lesson',
545
+ 'Check `src/parser.js`.',
546
+ ''
547
+ ].join('\n'));
548
+ const explicitIndexOut = path.join(TMP, 'explicit-index-reports');
549
+ const explicitIndexJson = JSON.parse(fs.readFileSync(reportFrom(run([
550
+ '--root', repo, '--out', explicitIndexOut, '--hide-ledger', '--home', home, '--memory', explicitWithIndexDir
551
+ ], home)).reportJson, 'utf8'));
552
+ assert.ok(!candidate(explicitIndexJson, 'src/single.js', 'memory'), 'explicit --memory skips MEMORY.md index');
553
+
554
+ // --no-memory byte-identical check with verified auto-memory present vs absent.
555
+ const freezeTime = path.join(TMP, 'freeze-time.js');
556
+ writeFile(freezeTime, [
557
+ 'const NativeDate = Date;',
558
+ "class FrozenDate extends NativeDate { constructor(...args) { super(...(args.length ? args : ['2026-11-26T00:00:00.000Z'])); } static now() { return NativeDate.parse('2026-11-26T00:00:00.000Z'); } }",
559
+ 'global.Date = FrozenDate;'
560
+ ].join('\n'));
561
+ const emptyHome = path.join(TMP, 'empty-home');
562
+ fs.mkdirSync(emptyHome, { recursive: true });
563
+ const noMemPresentOut = path.join(TMP, 'no-mem-present');
564
+ const noMemAbsentOut = path.join(TMP, 'no-mem-absent');
565
+ const noMemPresent = reportFrom(run(['--root', repo, '--out', noMemPresentOut, '--hide-ledger', '--home', home, '--no-memory'], home, freezeTime));
566
+ const noMemAbsent = reportFrom(run(['--root', repo, '--out', noMemAbsentOut, '--hide-ledger', '--home', emptyHome, '--no-memory'], emptyHome, freezeTime));
567
+ assert.strictEqual(fs.readFileSync(noMemPresent.reportJson, 'utf8'), fs.readFileSync(noMemAbsent.reportJson, 'utf8'),
568
+ '--no-memory JSON stays byte-identical with verified memory present');
569
+ assert.strictEqual(fs.readFileSync(noMemPresent.reportMd, 'utf8'), fs.readFileSync(noMemAbsent.reportMd, 'utf8'),
570
+ '--no-memory Markdown stays byte-identical with verified memory present');
571
+
572
+ // Real fixture linked worktree: verified main-repository slug fallback, then worktree-first precedence.
573
+ const linkedWorktree = path.join(TMP, 'PRIVATE_WT_PARENT_SENTINEL', 'linked-worktree');
574
+ fs.mkdirSync(path.dirname(linkedWorktree), { recursive: true });
575
+ git(repo, ['worktree', 'add', '-q', '-b', 'wt-memory-test', linkedWorktree]);
576
+ const wtSlug = path.resolve(linkedWorktree).replace(/[^a-z0-9]/gi, '-');
577
+ const wtMemoryDir = path.join(home, '.claude', 'projects', wtSlug, 'memory');
578
+
579
+ const wtFallbackOut = path.join(TMP, 'wt-fallback-reports');
580
+ const wtFallbackPayload = reportFrom(run(['--root', linkedWorktree, '--out', wtFallbackOut, '--hide-ledger', '--home', home], home));
581
+ const wtFallbackJson = JSON.parse(fs.readFileSync(wtFallbackPayload.reportJson, 'utf8'));
582
+ const wtFallbackMd = fs.readFileSync(wtFallbackPayload.reportMd, 'utf8');
583
+ const wtFallbackSource = wtFallbackJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
584
+ assert.strictEqual(wtFallbackSource.status, 'used', 'linked worktree falls back to verified main-repository memory');
585
+ assert.strictEqual(wtFallbackSource.verified, true);
586
+ assert.ok(candidate(wtFallbackJson, 'src/parser.js', 'memory'), 'main-repository lesson reaches report from linked worktree');
587
+ assert.strictEqual(wtFallbackJson.candidates.filter(item => item.sources.some(source => source.type === 'memory')).length, 1,
588
+ 'fallback skips MEMORY.md index');
589
+ assert.ok(!JSON.stringify(wtFallbackJson).includes(linkedWorktree) && !wtFallbackMd.includes(linkedWorktree),
590
+ 'linked worktree path is never exposed');
591
+ assert.ok(!JSON.stringify(wtFallbackJson).includes(repo) && !wtFallbackMd.includes(repo),
592
+ 'main repository path is never exposed');
593
+ assert.doesNotMatch(JSON.stringify(wtFallbackJson), /PRIVATE_WT_PARENT_SENTINEL|PRIVATE_INDEX_TITLE_SENTINEL/);
594
+ assert.doesNotMatch(wtFallbackMd, /PRIVATE_WT_PARENT_SENTINEL|PRIVATE_INDEX_TITLE_SENTINEL/);
595
+
596
+ // Unverified worktree memory does not emit leads and still allows verified main-repository fallback.
597
+ const wtLesson = path.join(wtMemoryDir, 'lesson-PRIVATE_FILENAME_SENTINEL-wt.md');
598
+ writeFile(wtLesson, [
599
+ '---',
600
+ 'type: feedback',
601
+ 'title: PRIVATE_WT_TITLE_SENTINEL',
602
+ '---',
603
+ '## Cue',
604
+ 'Worktree note.',
605
+ '## Lesson',
606
+ 'Check `src/single.js`.',
607
+ ''
608
+ ].join('\n'));
609
+ const wtUnverifiedPrimaryOut = path.join(TMP, 'wt-unverified-primary');
610
+ const wtUnverifiedPrimaryJson = JSON.parse(fs.readFileSync(reportFrom(run([
611
+ '--root', linkedWorktree, '--out', wtUnverifiedPrimaryOut, '--hide-ledger', '--home', home
612
+ ], home)).reportJson, 'utf8'));
613
+ assert.ok(candidate(wtUnverifiedPrimaryJson, 'src/parser.js', 'memory'),
614
+ 'verified main-repository fallback is used when worktree memory is unverified');
615
+ assert.ok(!candidate(wtUnverifiedPrimaryJson, 'src/single.js', 'memory'),
616
+ 'unverified worktree memory produces no leads');
617
+
618
+ // Verified worktree-specific marker takes precedence over main-repository fallback.
619
+ writeFile(path.join(wtMemoryDir, 'MEMORY.md'), '# Worktree memory index\n');
620
+ const wtVerifiedOut = path.join(TMP, 'wt-verified-reports');
621
+ const wtVerifiedPayload = reportFrom(run([
622
+ '--root', linkedWorktree, '--out', wtVerifiedOut, '--hide-ledger', '--home', home
623
+ ], home));
624
+ const wtVerifiedJson = JSON.parse(fs.readFileSync(wtVerifiedPayload.reportJson, 'utf8'));
625
+ const wtVerifiedMd = fs.readFileSync(wtVerifiedPayload.reportMd, 'utf8');
626
+ assert.ok(candidate(wtVerifiedJson, 'src/single.js', 'memory'),
627
+ 'verified worktree-specific marker is used first');
628
+ assert.ok(!candidate(wtVerifiedJson, 'src/parser.js', 'memory'),
629
+ 'main-repository fallback is not merged when worktree-specific marker is verified');
630
+ assert.doesNotMatch(JSON.stringify(wtVerifiedJson), /PRIVATE_WT_PARENT_SENTINEL|PRIVATE_WT_TITLE_SENTINEL|PRIVATE_FILENAME_SENTINEL/);
631
+ assert.doesNotMatch(wtVerifiedMd, /PRIVATE_WT_PARENT_SENTINEL|PRIVATE_WT_TITLE_SENTINEL|PRIVATE_FILENAME_SENTINEL/);
632
+
633
+ // Unverified main-repository fallback (when worktree memory is absent) produces no auto-memory leads.
634
+ fs.rmSync(path.join(home, '.claude', 'projects', wtSlug), { recursive: true, force: true });
635
+ fs.rmSync(currentMarker);
636
+ const wtBothUnverifiedOut = path.join(TMP, 'wt-both-unverified');
637
+ const wtBothUnverifiedJson = JSON.parse(fs.readFileSync(reportFrom(run([
638
+ '--root', linkedWorktree, '--out', wtBothUnverifiedOut, '--hide-ledger', '--home', home
639
+ ], home)).reportJson, 'utf8'));
640
+ const wtBothUnverifiedSource = wtBothUnverifiedJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
641
+ assert.strictEqual(wtBothUnverifiedSource.verified, false);
642
+ assert.strictEqual(wtBothUnverifiedSource.status, 'unverified');
643
+ assert.ok(!wtBothUnverifiedJson.candidates.some(item => item.sources.some(source => source.type === 'memory')),
644
+ 'unverified fallback produces no auto-memory leads');
645
+
646
+ // Negative controls: bare-repo worktree and --separate-git-dir worktree must not treat git-common-dir parent as main worktree.
647
+ const bareParent = path.join(TMP, 'bare-parent');
648
+ const bareRepo = path.join(bareParent, 'origin.git');
649
+ const bareSeed = path.join(TMP, 'bare-seed');
650
+ fs.mkdirSync(bareSeed, { recursive: true });
651
+ git(bareSeed, ['init', '-q']);
652
+ git(bareSeed, ['config', 'user.name', 'Scanner Fixture']);
653
+ git(bareSeed, ['config', 'user.email', 'scanner@example.invalid']);
654
+ git(bareSeed, ['config', 'commit.gpgsign', 'false']);
655
+ commit(bareSeed, 'feat: seed bare repo', { 'src/parser.js': 'module.exports = 1;\n' }, 0);
656
+ fs.mkdirSync(bareParent, { recursive: true });
657
+ git(bareSeed, ['clone', '--bare', '-q', bareSeed, bareRepo]);
658
+ const bareWt = path.join(TMP, 'bare-linked-wt');
659
+ git(bareRepo, ['worktree', 'add', '-q', '-b', 'bare-wt-branch', bareWt]);
660
+ for (const bogusRoot of [bareRepo, bareParent]) {
661
+ const bogusSlug = path.resolve(bogusRoot).replace(/[^a-z0-9]/gi, '-');
662
+ writeFile(path.join(home, '.claude', 'projects', bogusSlug, 'memory', 'MEMORY.md'), '# Bogus index\n');
663
+ writeFile(path.join(home, '.claude', 'projects', bogusSlug, 'memory', 'lesson-bogus.md'),
664
+ '---\ntype: feedback\n---\n## Cue\nBogus.\n## Lesson\nCheck `src/parser.js`.\n');
665
+ }
666
+ const bareWtOut = path.join(TMP, 'bare-wt-reports');
667
+ const bareWtJson = JSON.parse(fs.readFileSync(reportFrom(run([
668
+ '--root', bareWt, '--out', bareWtOut, '--hide-ledger', '--home', home
669
+ ], home)).reportJson, 'utf8'));
670
+ const bareWtSource = bareWtJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
671
+ assert.strictEqual(bareWtSource.verified, false, 'bare repo common-dir never establishes a main worktree');
672
+ assert.ok(!bareWtJson.candidates.some(item => item.sources.some(source => source.type === 'memory')),
673
+ 'bare repo worktree emits no fallback auto-memory leads');
674
+
675
+ const sepParent = path.join(TMP, 'sep-git-parent');
676
+ const sepGitDir = path.join(sepParent, 'repo-git');
677
+ const sepRepo = path.join(TMP, 'sep-main-repo');
678
+ fs.mkdirSync(sepParent, { recursive: true });
679
+ fs.mkdirSync(sepRepo, { recursive: true });
680
+ git(sepRepo, ['init', '-q', `--separate-git-dir=${sepGitDir}`]);
681
+ git(sepRepo, ['config', 'user.name', 'Scanner Fixture']);
682
+ git(sepRepo, ['config', 'user.email', 'scanner@example.invalid']);
683
+ git(sepRepo, ['config', 'commit.gpgsign', 'false']);
684
+ commit(sepRepo, 'feat: seed separate git dir', { 'src/parser.js': 'module.exports = 2;\n' }, 0);
685
+ const sepWt = path.join(TMP, 'sep-linked-wt');
686
+ git(sepRepo, ['worktree', 'add', '-q', '-b', 'sep-wt-branch', sepWt]);
687
+ for (const bogusRoot of [sepGitDir, sepParent]) {
688
+ const bogusSlug = path.resolve(bogusRoot).replace(/[^a-z0-9]/gi, '-');
689
+ writeFile(path.join(home, '.claude', 'projects', bogusSlug, 'memory', 'MEMORY.md'), '# Bogus separate index\n');
690
+ writeFile(path.join(home, '.claude', 'projects', bogusSlug, 'memory', 'lesson-sep-bogus.md'),
691
+ '---\ntype: feedback\n---\n## Cue\nBogus sep.\n## Lesson\nCheck `src/parser.js`.\n');
692
+ }
693
+ const sepWtOut = path.join(TMP, 'sep-wt-reports');
694
+ const sepWtJson = JSON.parse(fs.readFileSync(reportFrom(run([
695
+ '--root', sepWt, '--out', sepWtOut, '--hide-ledger', '--home', home
696
+ ], home)).reportJson, 'utf8'));
697
+ const sepWtSource = sepWtJson.sources.find(source => source.type === 'memory' && source.origin === 'auto');
698
+ assert.strictEqual(sepWtSource.verified, false, 'separate-git-dir parent never establishes a main worktree');
699
+ assert.ok(!sepWtJson.candidates.some(item => item.sources.some(source => source.type === 'memory')),
700
+ 'separate-git-dir worktree emits no fallback auto-memory leads');
701
+
471
702
  const insideOut = path.join(repo, 'must-not-be-created');
472
703
  const insideResult = run(['--root', repo, '--out', insideOut, '--hide-ledger', '--home', home], home);
473
704
  const insidePayload = reportFrom(insideResult, 2);
@@ -503,6 +734,756 @@ try {
503
734
  assert.strictEqual(git(repo, ['status', '--porcelain']), statusBefore,
504
735
  'scanner leaves the target repository unchanged');
505
736
 
737
+ // I486-lesson-cues: bounded top-level / direct metadata.type feedback, filename & Why/How cues on untyped notes,
738
+ // negative typed/malformed/conflicting/outside-field controls, instruction boundary, and --no-memory invariance.
739
+ const cueRepo = path.join(TMP, 'PRIVATE_CUE_PARENT_SENTINEL', 'cue-synthetic-harness');
740
+ const cueHome = path.join(TMP, 'PRIVATE_CUE_HOME_SENTINEL');
741
+ const cueSlug = path.resolve(cueRepo).replace(/[^a-z0-9]/gi, '-');
742
+ const cueAutoDir = path.join(cueHome, '.claude', 'projects', cueSlug, 'memory');
743
+ const cueExplicitDir = path.join(TMP, 'cue-explicit-memory');
744
+ const cueInstFile = path.join(cueHome, 'cue-explicit-instructions.md');
745
+ const cueLegacyInstFile = path.join(cueHome, 'cue-legacy-instructions.md');
746
+ fs.mkdirSync(cueRepo, { recursive: true });
747
+ fs.mkdirSync(cueAutoDir, { recursive: true });
748
+ fs.mkdirSync(cueExplicitDir, { recursive: true });
749
+ git(cueRepo, ['init', '-q']);
750
+ git(cueRepo, ['config', 'user.name', 'Scanner Fixture']);
751
+ git(cueRepo, ['config', 'user.email', 'scanner@example.invalid']);
752
+ git(cueRepo, ['config', 'commit.gpgsign', 'false']);
753
+ commit(cueRepo, 'feat: seed lesson cue fixture repo', {
754
+ 'src/alpha.js': 'module.exports = 1;\n',
755
+ 'AGENTS.md': [
756
+ '---',
757
+ 'metadata:',
758
+ ' type: feedback',
759
+ '---',
760
+ '# Repository AGENTS instructions',
761
+ '',
762
+ '**Why:** Memory-only metadata and Why/How cues must not widen instruction classification.',
763
+ '',
764
+ '**How to apply:** Keep AGENTS.md excluded without Cue/Lesson or top-level type: feedback.',
765
+ ''
766
+ ].join('\n'),
767
+ 'CLAUDE.md': [
768
+ '# Repository CLAUDE instructions',
769
+ '',
770
+ '## Lesson',
771
+ 'Keep `src/alpha.js` covered.',
772
+ ''
773
+ ].join('\n')
774
+ }, 0);
775
+ writeFile(cueInstFile, [
776
+ '---',
777
+ 'metadata:',
778
+ ' type: feedback',
779
+ '---',
780
+ '# Explicit instruction with memory-only cues',
781
+ '',
782
+ '**Why:** Should not qualify as an instruction lead.',
783
+ '',
784
+ '**How to apply:** Keep explicit instruction rules unchanged.',
785
+ ''
786
+ ].join('\n'));
787
+ writeFile(cueLegacyInstFile, [
788
+ '---',
789
+ 'type: feedback',
790
+ '---',
791
+ '# Legacy explicit instruction',
792
+ 'Keep `src/alpha.js` checked.',
793
+ ''
794
+ ].join('\n'));
795
+
796
+ const cueCases = [
797
+ {
798
+ name: 'top-unquoted-comment.md',
799
+ expected: true,
800
+ content: '---\ntype: feedback # inline comment\ntitle: PRIVATE_CUE_TITLE_SENTINEL\n---\nPRIVATE_CUE_BODY_SENTINEL `src/alpha.js`.\n'
801
+ },
802
+ {
803
+ name: 'top-single-quoted.md',
804
+ expected: true,
805
+ content: "---\ntype: 'feedback' # single-quoted comment\n---\nCheck `src/alpha.js`.\n"
806
+ },
807
+ {
808
+ name: 'top-double-quoted.md',
809
+ expected: true,
810
+ content: '---\ntype: "feedback" # double-quoted comment\n---\nCheck `src/alpha.js`.\n'
811
+ },
812
+ {
813
+ name: 'convention-metadata-feedback.md',
814
+ expected: true,
815
+ content: [
816
+ '---',
817
+ 'name: convention-check',
818
+ 'metadata:',
819
+ ' # comment inside metadata',
820
+ ' tags:',
821
+ ' - style',
822
+ ' nested:',
823
+ ' type: project',
824
+ ' type: feedback # inline comment',
825
+ '---',
826
+ 'PRIVATE_CUE_CONVENTION_SENTINEL `src/alpha.js`.',
827
+ ''
828
+ ].join('\n')
829
+ },
830
+ {
831
+ name: 'principle-metadata-4space.md',
832
+ expected: true,
833
+ content: [
834
+ '---',
835
+ 'name: principle-check',
836
+ 'metadata:',
837
+ ' notes: |',
838
+ ' type: project',
839
+ ' type: "feedback" # 4-space direct indent',
840
+ '---',
841
+ 'PRIVATE_CUE_PRINCIPLE_SENTINEL `src/alpha.js`.',
842
+ ''
843
+ ].join('\n')
844
+ },
845
+ {
846
+ name: 'metadata-single-quoted.md',
847
+ expected: true,
848
+ content: "---\nmetadata:\n type: 'feedback'\n---\nDirect single-quoted metadata.\n"
849
+ },
850
+ {
851
+ name: 'metadata-crlf.md',
852
+ expected: true,
853
+ content: '---\r\nmetadata:\r\n type: "feedback"\r\n---\r\nCRLF frontmatter.\r\n'
854
+ },
855
+ {
856
+ name: 'untyped-why-how-colon-outside.md',
857
+ expected: true,
858
+ content: '**Why**: Reason.\n\n**How to apply**: Rule.\n'
859
+ },
860
+ {
861
+ name: 'feedback-untyped-filename.md',
862
+ expected: true,
863
+ content: 'Untyped feedback filename note mentioning `src/alpha.js`.\n'
864
+ },
865
+ {
866
+ name: 'feedback-untyped-frontmatter.md',
867
+ expected: true,
868
+ content: '---\nname: untyped-feedback\ndescription: PRIVATE_CUE_DESC_SENTINEL\n---\nUntyped frontmatter with feedback- prefix.\n'
869
+ },
870
+ {
871
+ name: 'untyped-cue-heading.md',
872
+ expected: true,
873
+ content: '# Untyped\n## Cue\nRegression on `src/alpha.js`.\n'
874
+ },
875
+ {
876
+ name: 'untyped-lesson-heading.md',
877
+ expected: true,
878
+ content: '---\nauthor: fixture\n---\n### Lesson\nCheck `src/alpha.js`.\n'
879
+ },
880
+ {
881
+ name: 'untyped-bold-why-how.md',
882
+ expected: true,
883
+ content: [
884
+ 'Always verify input bounds.',
885
+ '',
886
+ '**Why:** Unbounded input broke `src/alpha.js`.',
887
+ '',
888
+ '**How to apply:** Validate length at entry.',
889
+ ''
890
+ ].join('\n')
891
+ },
892
+ {
893
+ name: 'convention-why-how-untyped-fm.md',
894
+ expected: true,
895
+ content: [
896
+ '---',
897
+ 'name: untyped-convention',
898
+ 'other:',
899
+ ' type: project',
900
+ '---',
901
+ '## Why',
902
+ 'Because X happened.',
903
+ '',
904
+ '## How to apply',
905
+ 'Do Y on `src/alpha.js`.',
906
+ ''
907
+ ].join('\n')
908
+ },
909
+ {
910
+ name: 'MEMORY.md',
911
+ expected: false,
912
+ content: '---\nmetadata:\n type: feedback\ntitle: PRIVATE_CUE_INDEX_SENTINEL\n---\n## Cue\nIndex.\n## Lesson\n`src/alpha.js`.\n**Why:** Index.\n**How to apply:** Never emit.\n'
913
+ },
914
+ {
915
+ name: 'outside-body-type.md',
916
+ expected: false,
917
+ content: '# Note\n\ntype: feedback\nmetadata:\n type: feedback\n'
918
+ },
919
+ {
920
+ name: 'outside-other-mapping.md',
921
+ expected: false,
922
+ content: '---\nother:\n type: feedback\n---\nNo weak cues.\n'
923
+ },
924
+ {
925
+ name: 'outside-nested-metadata.md',
926
+ expected: false,
927
+ content: '---\nmetadata:\n nested:\n type: feedback\n---\nNo weak cues.\n'
928
+ },
929
+ {
930
+ name: 'outside-quoted-fields.md',
931
+ expected: false,
932
+ content: '---\ntitle: "type: feedback"\nsummary: "multi\ntype: feedback\nend"\n---\nNo weak cues.\n'
933
+ },
934
+ {
935
+ name: 'outside-block-scalar.md',
936
+ expected: false,
937
+ content: '---\nnotes: |\n type: feedback\n metadata:\n type: feedback\nmetadata:\n notes: |\n type: feedback\n---\nNo weak cues.\n'
938
+ },
939
+ {
940
+ name: 'outside-comments-and-similar-key.md',
941
+ expected: false,
942
+ content: '---\n# type: feedback\nsubtype: feedback\nmetadata:\n # type: feedback\n subtype: feedback\n---\nNo weak cues.\n'
943
+ },
944
+ {
945
+ name: 'outside-literal-hash-in-type.md',
946
+ expected: false,
947
+ content: '---\ntype: "feedback # literal"\n---\nNo weak cues.\n'
948
+ },
949
+ {
950
+ name: 'outside-unspaced-hash-in-type.md',
951
+ expected: false,
952
+ content: '---\ntype: feedback#nospace\n---\nNo weak cues.\n'
953
+ },
954
+ {
955
+ name: 'outside-quoted-spaces-in-type.md',
956
+ expected: false,
957
+ content: '---\ntype: " feedback "\n---\nNo weak cues.\n'
958
+ },
959
+ {
960
+ name: 'outside-fenced-code-cues.md',
961
+ expected: false,
962
+ content: '# Example\n\n```markdown\n## Cue\n**Why:** example\n**How to apply:** example\n```\n'
963
+ },
964
+ {
965
+ name: 'unpaired-why-only.md',
966
+ expected: false,
967
+ content: '**Why:** Only why without how to apply.\n'
968
+ },
969
+ {
970
+ name: 'unpaired-how-only.md',
971
+ expected: false,
972
+ content: '**How to apply:** Only how to apply without why.\n'
973
+ },
974
+ {
975
+ name: 'prose-why-how.md',
976
+ expected: false,
977
+ content: 'This explains why: x and how to apply: y in ordinary prose.\n'
978
+ },
979
+ {
980
+ name: 'convention-untyped-plain.md',
981
+ expected: false,
982
+ content: '# Convention\nPlain untyped convention note without cues.\n'
983
+ },
984
+ {
985
+ name: 'principle-untyped-plain.md',
986
+ expected: false,
987
+ content: '# Principle\nPlain untyped principle note without cues.\n'
988
+ },
989
+ {
990
+ name: 'feedback-explicit-project.md',
991
+ expected: false,
992
+ content: '---\ntype: project\n---\n## Cue\nProject note.\n## Lesson\nCheck `src/alpha.js`.\n**Why:** Project.\n**How to apply:** Ignore.\n'
993
+ },
994
+ {
995
+ name: 'lesson-metadata-reference.md',
996
+ expected: false,
997
+ content: '---\nmetadata:\n type: reference\n---\n## Cue\nReference note.\n## Lesson\nCheck `src/alpha.js`.\n**Why:** Reference.\n**How to apply:** Ignore.\n'
998
+ },
999
+ {
1000
+ name: 'lesson-metadata-user.md',
1001
+ expected: false,
1002
+ content: '---\nmetadata:\n type: user\n---\n## Lesson\nUser profile note.\n'
1003
+ },
1004
+ {
1005
+ name: 'lesson-conflict-top-first.md',
1006
+ expected: false,
1007
+ content: '---\ntype: feedback\nmetadata:\n type: project\n---\n## Cue\nConflicting metadata.\n'
1008
+ },
1009
+ {
1010
+ name: 'lesson-conflict-meta-first.md',
1011
+ expected: false,
1012
+ content: '---\ntype: project\nmetadata:\n type: feedback\n---\n## Cue\nConflicting metadata reversed.\n'
1013
+ },
1014
+ {
1015
+ name: 'lesson-duplicate-key-conflict.md',
1016
+ expected: false,
1017
+ content: '---\nmetadata:\n type: project\n type: feedback\n---\n## Cue\nDuplicate metadata type key.\n'
1018
+ },
1019
+ {
1020
+ name: 'lesson-duplicate-top-conflict.md',
1021
+ expected: false,
1022
+ content: '---\ntype: feedback\ntype: project\n---\n## Cue\nDuplicate top type key.\n'
1023
+ },
1024
+ {
1025
+ name: 'lesson-duplicate-top-conflict-rev.md',
1026
+ expected: false,
1027
+ content: '---\ntype: project\ntype: feedback\n---\n## Cue\nDuplicate top type key reversed.\n'
1028
+ },
1029
+ {
1030
+ name: 'lesson-malformed-unclosed-quote.md',
1031
+ expected: false,
1032
+ content: '---\ntype: "feedback\n---\n## Cue\nUnclosed quote.\n'
1033
+ },
1034
+ {
1035
+ name: 'lesson-malformed-trailing-text.md',
1036
+ expected: false,
1037
+ content: "---\ntype: 'feedback' trailing\n---\n## Cue\nTrailing text.\n"
1038
+ },
1039
+ {
1040
+ name: 'lesson-malformed-empty-type.md',
1041
+ expected: false,
1042
+ content: '---\ntype: # missing value\n---\n## Cue\nEmpty type.\n'
1043
+ },
1044
+ {
1045
+ name: 'lesson-empty-double-quote.md',
1046
+ expected: false,
1047
+ content: '---\ntype: ""\n---\n## Cue\nEmpty double-quoted top-level type.\n'
1048
+ },
1049
+ {
1050
+ name: 'feedback-empty-single-quote.md',
1051
+ expected: false,
1052
+ content: "---\ntype: ''\n---\n**Why:** Empty single-quoted top-level type.\n**How to apply:** Reject.\n"
1053
+ },
1054
+ {
1055
+ name: 'lesson-whitespace-double-quote.md',
1056
+ expected: false,
1057
+ content: '---\ntype: " "\n---\n## Cue\nWhitespace double-quoted top-level type.\n'
1058
+ },
1059
+ {
1060
+ name: 'feedback-whitespace-single-quote.md',
1061
+ expected: false,
1062
+ content: "---\ntype: '\t '\n---\n**Why:** Whitespace single-quoted top-level type.\n**How to apply:** Reject.\n"
1063
+ },
1064
+ {
1065
+ name: 'lesson-meta-empty-double-quote.md',
1066
+ expected: false,
1067
+ content: '---\nmetadata:\n type: ""\n---\n## Cue\nEmpty double-quoted metadata type.\n'
1068
+ },
1069
+ {
1070
+ name: 'feedback-meta-empty-single-quote.md',
1071
+ expected: false,
1072
+ content: "---\nmetadata:\n type: ''\n---\n**Why:** Empty single-quoted metadata type.\n**How to apply:** Reject.\n"
1073
+ },
1074
+ {
1075
+ name: 'lesson-meta-whitespace-quoted.md',
1076
+ expected: false,
1077
+ content: '---\nmetadata:\n type: " "\n---\n## Lesson\nWhitespace quoted metadata type.\n'
1078
+ },
1079
+ {
1080
+ name: 'lesson-malformed-block-type.md',
1081
+ expected: false,
1082
+ content: '---\ntype: |\n feedback\n---\n## Cue\nBlock scalar type.\n'
1083
+ },
1084
+ {
1085
+ name: 'lesson-malformed-bad-indent.md',
1086
+ expected: false,
1087
+ content: '---\nmetadata:\n author: a\n type: feedback\n---\n## Cue\nBroken indentation.\n'
1088
+ },
1089
+ {
1090
+ name: 'lesson-malformed-tab-indent.md',
1091
+ expected: false,
1092
+ content: '---\nmetadata:\n\ttype: feedback\n---\n## Cue\nTab indentation.\n'
1093
+ },
1094
+ {
1095
+ name: 'lesson-malformed-unclosed-fm.md',
1096
+ expected: false,
1097
+ content: '---\ntype: feedback\n## Cue\nUnclosed frontmatter.\n'
1098
+ }
1099
+ ];
1100
+
1101
+ const refOf = filePath => `local/${crypto.createHash('sha256').update(path.resolve(filePath)).digest('hex')}`;
1102
+ for (const item of cueCases) {
1103
+ writeFile(path.join(cueAutoDir, item.name), item.content);
1104
+ writeFile(path.join(cueExplicitDir, item.name), item.content);
1105
+ }
1106
+
1107
+ const cueLessonFailures = [];
1108
+ const checkCue = (passed, message) => {
1109
+ if (!passed) cueLessonFailures.push(message);
1110
+ };
1111
+
1112
+ for (const mode of [
1113
+ {
1114
+ label: 'auto-memory',
1115
+ args: ['--root', cueRepo, '--out', path.join(TMP, 'cue-auto-reports'), '--hide-ledger', '--home', cueHome],
1116
+ dir: cueAutoDir
1117
+ },
1118
+ {
1119
+ label: 'explicit-memory',
1120
+ args: [
1121
+ '--root', cueRepo, '--out', path.join(TMP, 'cue-explicit-reports'), '--hide-ledger',
1122
+ '--home', path.join(TMP, 'cue-empty-home'), '--memory', cueExplicitDir,
1123
+ '--instructions', cueInstFile, '--instructions', cueLegacyInstFile
1124
+ ],
1125
+ dir: cueExplicitDir
1126
+ }
1127
+ ]) {
1128
+ const res = run(mode.args, cueHome);
1129
+ const payload = reportFrom(res);
1130
+ const reportJson = JSON.parse(fs.readFileSync(payload.reportJson, 'utf8'));
1131
+ const reportMd = fs.readFileSync(payload.reportMd, 'utf8');
1132
+ const memoryLeads = reportJson.candidates.filter(item => item.sources.some(source => source.type === 'memory'));
1133
+ const emittedRefs = new Set(memoryLeads.flatMap(item => item.sources.filter(s => s.type === 'memory').map(s => s.ref)));
1134
+
1135
+ for (const item of cueCases) {
1136
+ const filePath = path.join(mode.dir, item.name);
1137
+ const expectedRef = refOf(filePath);
1138
+ const present = emittedRefs.has(expectedRef);
1139
+ checkCue(present === item.expected,
1140
+ `${mode.label} ${item.name}: expected=${item.expected}, got=${present}`);
1141
+ }
1142
+ for (const lead of memoryLeads) {
1143
+ checkCue(lead.title === 'Local memory lead', `${mode.label} neutral title got ${lead.title}`);
1144
+ checkCue(lead.status === 'UNVERIFIED', `${mode.label} status got ${lead.status}`);
1145
+ checkCue(lead.sources.length === 1 && lead.sources[0].type === 'memory' && /^local\/[a-f0-9]{64}$/.test(lead.sources[0].ref),
1146
+ `${mode.label} opaque source ref invalid: ${JSON.stringify(lead.sources)}`);
1147
+ }
1148
+ const serialized = `${JSON.stringify(reportJson)}\n${reportMd}`;
1149
+ checkCue(!/PRIVATE_CUE_(?:PARENT|HOME|TITLE|BODY|CONVENTION|PRINCIPLE|DESC|INDEX)_SENTINEL/.test(serialized),
1150
+ `${mode.label} leaked private cue sentinel`);
1151
+ for (const item of cueCases) {
1152
+ checkCue(!serialized.includes(item.name), `${mode.label} leaked private filename ${item.name}`);
1153
+ }
1154
+
1155
+ const repoInstRefs = reportJson.candidates
1156
+ .flatMap(item => item.sources.filter(s => s.type === 'instruction' && s.ref.startsWith('repo/')).map(s => s.ref));
1157
+ checkCue(repoInstRefs.includes('repo/CLAUDE.md'), `${mode.label} keeps legacy CLAUDE.md instruction lead`);
1158
+ checkCue(!repoInstRefs.includes('repo/AGENTS.md'), `${mode.label} does not widen AGENTS.md instruction classification`);
1159
+
1160
+ if (mode.label === 'explicit-memory') {
1161
+ const localInstRefs = reportJson.candidates
1162
+ .flatMap(item => item.sources.filter(s => s.type === 'instruction' && s.ref.startsWith('local/')).map(s => s.ref));
1163
+ checkCue(localInstRefs.includes(refOf(cueLegacyInstFile)),
1164
+ 'explicit-memory keeps legacy explicit instruction classification');
1165
+ checkCue(!localInstRefs.includes(refOf(cueInstFile)),
1166
+ 'explicit-memory does not widen explicit instruction classification with metadata.type or Why/How');
1167
+ }
1168
+ }
1169
+
1170
+ const cueNoMemWith = reportFrom(run([
1171
+ '--root', cueRepo, '--out', path.join(TMP, 'cue-nomem-with'), '--hide-ledger', '--home', cueHome,
1172
+ '--memory', cueExplicitDir, '--no-memory'
1173
+ ], cueHome, freezeTime));
1174
+ const cueNoMemEmptyHome = path.join(TMP, 'cue-nomem-empty-home');
1175
+ fs.mkdirSync(cueNoMemEmptyHome, { recursive: true });
1176
+ const cueNoMemWithout = reportFrom(run([
1177
+ '--root', cueRepo, '--out', path.join(TMP, 'cue-nomem-without'), '--hide-ledger', '--home', cueNoMemEmptyHome,
1178
+ '--memory', cueExplicitDir, '--no-memory'
1179
+ ], cueNoMemEmptyHome, freezeTime));
1180
+ checkCue(fs.readFileSync(cueNoMemWith.reportJson, 'utf8') === fs.readFileSync(cueNoMemWithout.reportJson, 'utf8'),
1181
+ '--no-memory JSON stays byte-identical across new cue files');
1182
+ checkCue(fs.readFileSync(cueNoMemWith.reportMd, 'utf8') === fs.readFileSync(cueNoMemWithout.reportMd, 'utf8'),
1183
+ '--no-memory Markdown stays byte-identical across new cue files');
1184
+
1185
+ assert.deepStrictEqual(cueLessonFailures, [], `I486-lesson-cues failures:\n${cueLessonFailures.join('\n')}`);
1186
+
1187
+ // I486-file-sites: exact repo-relative tracked regular-file mentions for memory leads,
1188
+ // rejecting directories/URLs/traversal/absolute/UNC/escaped/symlinked-out/missing targets without suffix leaks,
1189
+ // preserving directory/file distinctions and redaction, plus CLI scan-to-oracle comparison and --no-memory invariance.
1190
+ const siteRepo = path.join(TMP, 'PRIVATE_SITE_PARENT_SENTINEL', 'site-synthetic-harness');
1191
+ const siteHome = path.join(TMP, 'PRIVATE_SITE_HOME_SENTINEL');
1192
+ const siteSlug = path.resolve(siteRepo).replace(/[^a-z0-9]/gi, '-');
1193
+ const siteAutoDir = path.join(siteHome, '.claude', 'projects', siteSlug, 'memory');
1194
+ const siteExplicitDir = path.join(TMP, 'site-explicit-memory');
1195
+ const siteOutsideDir = path.join(TMP, 'PRIVATE_SITE_OUTSIDE_SENTINEL');
1196
+ const siteOutsideFile = path.join(siteOutsideDir, 'outside.js');
1197
+ const siteOutsideTarget = path.join(siteOutsideDir, 'escaped-target.js');
1198
+ fs.mkdirSync(siteRepo, { recursive: true });
1199
+ fs.mkdirSync(siteAutoDir, { recursive: true });
1200
+ fs.mkdirSync(siteExplicitDir, { recursive: true });
1201
+ writeFile(siteOutsideFile, 'module.exports = "outside";\n');
1202
+ writeFile(siteOutsideTarget, 'module.exports = "escaped";\n');
1203
+
1204
+ git(siteRepo, ['init', '-q']);
1205
+ git(siteRepo, ['config', 'user.name', 'Scanner Fixture']);
1206
+ git(siteRepo, ['config', 'user.email', 'scanner@example.invalid']);
1207
+ git(siteRepo, ['config', 'commit.gpgsign', 'false']);
1208
+ commit(siteRepo, 'feat: seed file-sites fixture repo', {
1209
+ 'AGENTS.md': '# Repo Agents\n',
1210
+ 'Makefile': 'all:\n\techo ok\n',
1211
+ '.nvmrc': '24\n',
1212
+ '.husky/commit-msg': '#!/bin/sh\nexit 0\n',
1213
+ 'src/parser.js': 'module.exports = 1;\n',
1214
+ 'src/deleted.js': 'module.exports = 2;\n',
1215
+ 'docs/guide/intro.md': '# Guide\n',
1216
+ 'escaped-dir/escaped-target.js': 'module.exports = 3;\n'
1217
+ }, 0);
1218
+
1219
+ // Create a tracked symlink pointing outside and a tracked symlink pointing inside (when host allows file symlinks).
1220
+ let fileSymlinksCreated = false;
1221
+ try {
1222
+ fs.mkdirSync(path.join(siteRepo, 'links'), { recursive: true });
1223
+ fs.symlinkSync(siteOutsideFile, path.join(siteRepo, 'links', 'symlink-out.js'));
1224
+ fs.symlinkSync('../AGENTS.md', path.join(siteRepo, 'links', 'symlink-in.js'));
1225
+ git(siteRepo, ['add', 'links/symlink-out.js', 'links/symlink-in.js']);
1226
+ git(siteRepo, ['commit', '-q', '-m', 'feat: add symlink controls'], {
1227
+ GIT_AUTHOR_NAME: 'Scanner Fixture',
1228
+ GIT_AUTHOR_EMAIL: 'scanner@example.invalid',
1229
+ GIT_COMMITTER_NAME: 'Scanner Fixture',
1230
+ GIT_COMMITTER_EMAIL: 'scanner@example.invalid',
1231
+ GIT_AUTHOR_DATE: FIXED_DATE,
1232
+ GIT_COMMITTER_DATE: FIXED_DATE
1233
+ });
1234
+ fileSymlinksCreated = true;
1235
+ } catch (cause) {
1236
+ if (process.platform !== 'win32' || cause.code !== 'EPERM') throw cause;
1237
+ }
1238
+
1239
+ // Working-tree mutations on tracked/untracked targets:
1240
+ // 1) delete a tracked file on disk (missing target)
1241
+ fs.rmSync(path.join(siteRepo, 'src', 'deleted.js'));
1242
+ // 2) create an untracked regular file on disk
1243
+ write(siteRepo, 'src/untracked.js', 'module.exports = "untracked";\n');
1244
+ // 3) replace tracked directory `escaped-dir` with a symlink/junction pointing outside the checkout
1245
+ fs.rmSync(path.join(siteRepo, 'escaped-dir'), { recursive: true, force: true });
1246
+ fs.symlinkSync(siteOutsideDir, path.join(siteRepo, 'escaped-dir'), process.platform === 'win32' ? 'junction' : 'dir');
1247
+
1248
+ const siteCases = [
1249
+ {
1250
+ name: 'positive-root-and-extless.md',
1251
+ expectedSites: ['.husky/commit-msg', '.nvmrc', 'AGENTS.md', 'Makefile', 'src/parser.js'],
1252
+ content: [
1253
+ '---',
1254
+ 'metadata:',
1255
+ ' type: feedback',
1256
+ 'title: PRIVATE_SITE_TITLE_SENTINEL positive',
1257
+ '---',
1258
+ 'PRIVATE_SITE_BODY_SENTINEL',
1259
+ 'Check AGENTS.md, `Makefile`, (.nvmrc), [hook](.husky/commit-msg), and src/parser.js.',
1260
+ ''
1261
+ ].join('\n')
1262
+ },
1263
+ {
1264
+ name: 'negative-directories-and-distinction.md',
1265
+ expectedSites: [],
1266
+ content: [
1267
+ '---',
1268
+ 'metadata:',
1269
+ ' type: feedback',
1270
+ '---',
1271
+ 'Directories: `src`, `src/`, `docs`, `docs/guide`, `docs/guide/`, `.husky`, `.husky/`.',
1272
+ 'File-as-directory: `AGENTS.md/`, `Makefile/`, `src/parser.js/`, `.husky/commit-msg/`, `src/parser.js/child`.',
1273
+ ''
1274
+ ].join('\n')
1275
+ },
1276
+ {
1277
+ name: 'negative-urls-and-suffixes.md',
1278
+ expectedSites: [],
1279
+ content: [
1280
+ '---',
1281
+ 'metadata:',
1282
+ ' type: feedback',
1283
+ '---',
1284
+ 'URLs: https://example.com/org/repo/blob/main/AGENTS.md http://localhost:8080/Makefile',
1285
+ 'More: file:///tmp/repo/src/parser.js https://example.com/.husky/commit-msg?raw=1#L1',
1286
+ '[external](https://example.com/AGENTS.md) <https://example.com/src/parser.js>',
1287
+ ''
1288
+ ].join('\n')
1289
+ },
1290
+ {
1291
+ name: 'negative-traversal-and-absolute-and-unc.md',
1292
+ expectedSites: [],
1293
+ content: [
1294
+ '---',
1295
+ 'metadata:',
1296
+ ' type: feedback',
1297
+ '---',
1298
+ 'Traversal: ../AGENTS.md ../../src/parser.js src/../AGENTS.md src/../Makefile ..\\AGENTS.md a/../../.husky/commit-msg',
1299
+ `POSIX abs: /AGENTS.md /abs/path/AGENTS.md /Users/dev/repo/src/parser.js ${siteRepo}/AGENTS.md`,
1300
+ 'Windows abs: C:\\repo\\AGENTS.md C:/repo/src/parser.js D:\\work\\Makefile C:\\repo\\.husky\\commit-msg',
1301
+ 'UNC: \\\\server\\share\\AGENTS.md //server/share/src/parser.js \\\\?\\C:\\repo\\Makefile',
1302
+ 'Prefixed/aliases: missing/AGENTS.md other/src/parser.js ./AGENTS.md AGENTS.md.bak foo-AGENTS.md src\\parser.js',
1303
+ ''
1304
+ ].join('\n')
1305
+ },
1306
+ {
1307
+ name: 'negative-missing-untracked-escaped-symlinked.md',
1308
+ expectedSites: [],
1309
+ content: [
1310
+ '---',
1311
+ 'metadata:',
1312
+ ' type: feedback',
1313
+ '---',
1314
+ 'Missing tracked: `src/deleted.js`.',
1315
+ 'Untracked file: `src/untracked.js`.',
1316
+ 'Escaped dir target: `escaped-dir/escaped-target.js`.',
1317
+ 'Nonexistent: `does/not/exist.js`.',
1318
+ ...(fileSymlinksCreated ? ['Symlinks: `links/symlink-out.js` and `links/symlink-in.js`.'] : []),
1319
+ ''
1320
+ ].join('\n')
1321
+ },
1322
+ {
1323
+ name: 'positive-parens-and-relative-links.md',
1324
+ expectedSites: ['.husky/commit-msg', 'AGENTS.md', 'src/parser.js'],
1325
+ content: [
1326
+ '---',
1327
+ 'metadata:',
1328
+ ' type: feedback',
1329
+ '---',
1330
+ 'Check (AGENTS.md) and [link](src/parser.js) and ([hook](.husky/commit-msg)).',
1331
+ ''
1332
+ ].join('\n')
1333
+ },
1334
+ {
1335
+ name: 'negative-url-parenthesized-suffixes.md',
1336
+ expectedSites: [],
1337
+ content: [
1338
+ '---',
1339
+ 'metadata:',
1340
+ ' type: feedback',
1341
+ '---',
1342
+ 'https://example.com/wiki/Foo_(AGENTS.md)',
1343
+ 'https://example.com/wiki/Foo_(src/parser.js)',
1344
+ '(https://example.com/wiki/Foo_(AGENTS.md))', // portability-lint: allow wrapped URL fixture content, not a filename
1345
+ '[external](https://example.com/wiki/Foo_(AGENTS.md))',
1346
+ 'https://example.com/wiki/Foo_[Makefile]',
1347
+ ''
1348
+ ].join('\n')
1349
+ },
1350
+ {
1351
+ name: 'negative-abs-and-traversal-parenthesized-suffixes.md',
1352
+ expectedSites: [],
1353
+ content: [
1354
+ '---',
1355
+ 'metadata:',
1356
+ ' type: feedback',
1357
+ '---',
1358
+ '/opt/build(AGENTS.md)',
1359
+ 'C:\\build(Makefile)',
1360
+ '../other(AGENTS.md)',
1361
+ '(/opt/build(AGENTS.md))',
1362
+ '[abs](/opt/build(AGENTS.md))',
1363
+ '[trav](../other(src/parser.js))',
1364
+ 'a/../other(Makefile)',
1365
+ ''
1366
+ ].join('\n')
1367
+ }
1368
+ ];
1369
+
1370
+ writeFile(path.join(siteAutoDir, 'MEMORY.md'), '# Synthetic site index\n');
1371
+ for (const item of siteCases) {
1372
+ writeFile(path.join(siteAutoDir, item.name), item.content);
1373
+ writeFile(path.join(siteExplicitDir, item.name), item.content);
1374
+ }
1375
+
1376
+ const fileSiteFailures = [];
1377
+ const checkSite = (passed, message) => {
1378
+ if (!passed) fileSiteFailures.push(message);
1379
+ };
1380
+
1381
+ let siteAutoReportPath = null;
1382
+ for (const mode of [
1383
+ {
1384
+ label: 'auto-memory',
1385
+ args: ['--root', siteRepo, '--out', path.join(TMP, 'site-auto-reports'), '--hide-ledger', '--home', siteHome],
1386
+ dir: siteAutoDir
1387
+ },
1388
+ {
1389
+ label: 'explicit-memory',
1390
+ args: [
1391
+ '--root', siteRepo, '--out', path.join(TMP, 'site-explicit-reports'), '--hide-ledger',
1392
+ '--home', path.join(TMP, 'site-empty-home'), '--memory', siteExplicitDir
1393
+ ],
1394
+ dir: siteExplicitDir
1395
+ }
1396
+ ]) {
1397
+ const res = run(mode.args, siteHome);
1398
+ const payload = reportFrom(res);
1399
+ if (mode.label === 'auto-memory') siteAutoReportPath = payload.reportJson;
1400
+ const reportJson = JSON.parse(fs.readFileSync(payload.reportJson, 'utf8'));
1401
+ const reportMd = fs.readFileSync(payload.reportMd, 'utf8');
1402
+ const memoryLeads = reportJson.candidates.filter(item => item.sources.some(source => source.type === 'memory'));
1403
+ const leadByRef = new Map(memoryLeads.map(item => [item.sources[0].ref, item]));
1404
+
1405
+ for (const item of siteCases) {
1406
+ const expectedRef = refOf(path.join(mode.dir, item.name));
1407
+ const lead = leadByRef.get(expectedRef);
1408
+ checkSite(Boolean(lead), `${mode.label} ${item.name}: expected memory lead to exist`);
1409
+ if (lead) {
1410
+ checkSite(JSON.stringify(lead.sites) === JSON.stringify(item.expectedSites),
1411
+ `${mode.label} ${item.name}: expected sites=${JSON.stringify(item.expectedSites)}, got=${JSON.stringify(lead.sites)}`);
1412
+ checkSite(lead.title === 'Local memory lead', `${mode.label} ${item.name}: neutral title got ${lead.title}`);
1413
+ }
1414
+ }
1415
+
1416
+ const serialized = `${JSON.stringify(reportJson)}\n${reportMd}`;
1417
+ checkSite(!/PRIVATE_SITE_(?:PARENT|HOME|OUTSIDE|TITLE|BODY)_SENTINEL/.test(serialized),
1418
+ `${mode.label} leaked private site sentinel`);
1419
+ checkSite(!serialized.includes(siteRepo) && !serialized.includes(siteHome) && !serialized.includes(siteOutsideDir),
1420
+ `${mode.label} leaked absolute fixture path`);
1421
+ for (const item of siteCases) {
1422
+ checkSite(!serialized.includes(item.name), `${mode.label} leaked private filename ${item.name}`);
1423
+ }
1424
+ }
1425
+
1426
+ // CLI scan-to-oracle comparison against a fixed synthetic baseline + --no-memory byte invariance.
1427
+ const siteLedgerDir = path.join(TMP, 'site-synthetic-ledger');
1428
+ writeFile(path.join(siteLedgerDir, 'E-0001-root-agents.md'),
1429
+ '---\nid: E-0001\nsignature: root-agents\nsites:\n - AGENTS.md\n---\n');
1430
+ writeFile(path.join(siteLedgerDir, 'E-0002-extless-hook.md'),
1431
+ '---\nid: E-0002\nsignature: extless-hook\nsites:\n - .husky/commit-msg\n---\n');
1432
+ writeFile(path.join(siteLedgerDir, 'E-0003-root-extless.md'),
1433
+ '---\nid: E-0003\nsignature: root-extless\nsites:\n - Makefile\n---\n');
1434
+ writeFile(path.join(siteLedgerDir, 'E-0004-dir-only.md'),
1435
+ '---\nid: E-0004\nsignature: dir-only\nsites:\n - docs/guide\n---\n');
1436
+
1437
+ const siteNoMemPresent = reportFrom(run([
1438
+ '--root', siteRepo, '--out', path.join(TMP, 'site-nomem-present'), '--hide-ledger', '--home', siteHome, '--no-memory'
1439
+ ], siteHome, freezeTime));
1440
+ const siteNoMemEmptyHome = path.join(TMP, 'site-nomem-empty-home');
1441
+ fs.mkdirSync(siteNoMemEmptyHome, { recursive: true });
1442
+ const siteNoMemAbsent = reportFrom(run([
1443
+ '--root', siteRepo, '--out', path.join(TMP, 'site-nomem-absent'), '--hide-ledger', '--home', siteNoMemEmptyHome, '--no-memory'
1444
+ ], siteNoMemEmptyHome, freezeTime));
1445
+ checkSite(fs.readFileSync(siteNoMemPresent.reportJson, 'utf8') === fs.readFileSync(siteNoMemAbsent.reportJson, 'utf8'),
1446
+ 'siteRepo --no-memory JSON stays byte-identical with verified memory present');
1447
+ checkSite(fs.readFileSync(siteNoMemPresent.reportMd, 'utf8') === fs.readFileSync(siteNoMemAbsent.reportMd, 'utf8'),
1448
+ 'siteRepo --no-memory Markdown stays byte-identical with verified memory present');
1449
+
1450
+ const ORACLE = path.join(ROOT, 'scripts', 'error-ledger-oracle.js');
1451
+ const runOracle = reportPath => {
1452
+ const res = childProcess.spawnSync(process.execPath, [ORACLE, '--report', reportPath, '--ledger', siteLedgerDir, '--json'], {
1453
+ encoding: 'utf8',
1454
+ env: { ...process.env, HOME: siteHome, USERPROFILE: siteHome }
1455
+ });
1456
+ assert.ifError(res.error);
1457
+ assert.strictEqual(res.status, 0, `oracle exit ${res.status}; stderr: ${res.stderr}`);
1458
+ return JSON.parse(res.stdout);
1459
+ };
1460
+ const baselineOracle = runOracle(siteNoMemPresent.reportJson);
1461
+ const memoryOracle = runOracle(siteAutoReportPath);
1462
+ checkSite(baselineOracle.counts.linkedRecords === 0,
1463
+ `baseline oracle expected 0 linkedRecords, got ${baselineOracle.counts.linkedRecords}`);
1464
+ checkSite(memoryOracle.counts.linkedRecords === 3,
1465
+ `memory oracle expected 3 linkedRecords (root+extless files only), got ${memoryOracle.counts.linkedRecords}`);
1466
+ checkSite(JSON.stringify(memoryOracle.linked.map(item => item.id).sort()) === JSON.stringify(['E-0001', 'E-0002', 'E-0003']),
1467
+ `memory oracle linked ids expected [E-0001,E-0002,E-0003], got ${JSON.stringify(memoryOracle.linked.map(item => item.id))}`);
1468
+ checkSite(JSON.stringify(memoryOracle.unlinked) === JSON.stringify(['E-0004']),
1469
+ `memory oracle must keep directory-only E-0004 unlinked, got ${JSON.stringify(memoryOracle.unlinked)}`);
1470
+
1471
+ // Packaged scanner check on the synthetic file-sites fixture (zero external dependencies).
1472
+ const PACKAGED_SCANNER = path.join(ROOT, 'plugins', 'harness-everything', 'skills', 'error-ledger-bootstrap', 'scripts', 'scan.js');
1473
+ const pkgSiteOut = path.join(TMP, 'site-packaged-reports');
1474
+ const pkgSiteRes = childProcess.spawnSync(process.execPath, [
1475
+ PACKAGED_SCANNER, '--root', siteRepo, '--out', pkgSiteOut, '--hide-ledger', '--home', siteHome, '--json'
1476
+ ], { encoding: 'utf8', env: { ...process.env, HOME: siteHome, USERPROFILE: siteHome } });
1477
+ assert.ifError(pkgSiteRes.error);
1478
+ const pkgSitePayload = reportFrom(pkgSiteRes);
1479
+ const pkgSiteJson = JSON.parse(fs.readFileSync(pkgSitePayload.reportJson, 'utf8'));
1480
+ const pkgPosLead = pkgSiteJson.candidates.find(item =>
1481
+ item.sources.some(source => source.type === 'memory' && source.ref === refOf(path.join(siteAutoDir, 'positive-root-and-extless.md'))));
1482
+ checkSite(Boolean(pkgPosLead) && JSON.stringify(pkgPosLead.sites) === JSON.stringify(['.husky/commit-msg', '.nvmrc', 'AGENTS.md', 'Makefile', 'src/parser.js']),
1483
+ `packaged scanner expected root+extless sites, got ${JSON.stringify(pkgPosLead && pkgPosLead.sites)}`);
1484
+
1485
+ assert.deepStrictEqual(fileSiteFailures, [], `I486-file-sites failures:\n${fileSiteFailures.join('\n')}`);
1486
+
506
1487
  const acceptanceFailures = [];
507
1488
  const checkAcceptance = (passed, message) => {
508
1489
  if (!passed) acceptanceFailures.push(message);