mandrel 2.69.0 → 2.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.agents/README.md +8 -9
  2. package/.agents/agents/acceptance-critic.md +1 -0
  3. package/.agents/agents/auditor.md +1 -0
  4. package/.agents/agents/plan-critic.md +1 -0
  5. package/.agents/agents/story-worker.md +63 -64
  6. package/.agents/docs/agentrc-reference.json +2 -1
  7. package/.agents/docs/configuration.md +7 -8
  8. package/.agents/rules/git-conventions-reference.md +2 -2
  9. package/.agents/schemas/agentrc.schema.json +19 -2
  10. package/.agents/scripts/acceptance-eval.js +194 -15
  11. package/.agents/scripts/audit-to-stories.js +39 -247
  12. package/.agents/scripts/deliver-run.js +92 -43
  13. package/.agents/scripts/lib/audit-suite/index.js +1 -1
  14. package/.agents/scripts/lib/audit-suite/story-checklist.js +65 -0
  15. package/.agents/scripts/lib/audit-to-stories/audit-label-taxonomy.js +2 -2
  16. package/.agents/scripts/lib/audit-to-stories/finding-adapter.js +1 -1
  17. package/.agents/scripts/lib/bootstrap/issue-forms-template.js +1 -1
  18. package/.agents/scripts/lib/cli-args.js +22 -0
  19. package/.agents/scripts/lib/close-validation/gates.js +17 -3
  20. package/.agents/scripts/lib/config/agent-models.js +117 -0
  21. package/.agents/scripts/lib/config-settings-schema-delivery.js +13 -1
  22. package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
  23. package/.agents/scripts/lib/findings/route-finding.js +15 -0
  24. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  25. package/.agents/scripts/lib/git/sync-from-base.js +89 -17
  26. package/.agents/scripts/lib/label-taxonomy.js +13 -3
  27. package/.agents/scripts/lib/notifications/notifier.js +11 -15
  28. package/.agents/scripts/lib/observability/close-telemetry.js +19 -3
  29. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  30. package/.agents/scripts/lib/orchestration/code-review.js +2 -2
  31. package/.agents/scripts/lib/orchestration/file-assumptions.js +45 -11
  32. package/.agents/scripts/lib/orchestration/plan-context.js +31 -11
  33. package/.agents/scripts/lib/orchestration/plan-persist/audit-provenance.js +35 -117
  34. package/.agents/scripts/lib/orchestration/plan-persist/changes-repair.js +130 -24
  35. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +24 -22
  36. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +1 -0
  37. package/.agents/scripts/lib/orchestration/plan-persist/summary.js +4 -3
  38. package/.agents/scripts/lib/orchestration/resolve-stories.js +10 -2
  39. package/.agents/scripts/lib/orchestration/review-providers/native.js +5 -165
  40. package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +14 -2
  41. package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +151 -56
  42. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +4 -0
  43. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +20 -4
  44. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +26 -17
  45. package/.agents/scripts/lib/orchestration/story-handoff.js +849 -0
  46. package/.agents/scripts/lib/orchestration/story-init-result.js +83 -0
  47. package/.agents/scripts/lib/orchestration/task-body-validator.js +35 -5
  48. package/.agents/scripts/lib/orchestration/ticket-validator-sizing.js +1 -1
  49. package/.agents/scripts/lib/orchestration/ticket-validator.js +20 -2
  50. package/.agents/scripts/lib/single-story/confirm-merge.js +44 -7
  51. package/.agents/scripts/lib/story-body/story-body.js +40 -5
  52. package/.agents/scripts/lib/templates/decomposer-prompts.js +33 -36
  53. package/.agents/scripts/single-story-close.js +8 -0
  54. package/.agents/scripts/single-story-init.js +17 -32
  55. package/.agents/scripts/story-handoff.js +112 -0
  56. package/.agents/scripts/sync-claude-agents.js +58 -27
  57. package/.agents/templates/docs/audit-sweep-runbook.md +29 -59
  58. package/.agents/workflows/audit-to-stories.md +40 -67
  59. package/.agents/workflows/helpers/acceptance-self-eval.md +24 -18
  60. package/.agents/workflows/helpers/code-review.md +3 -3
  61. package/.agents/workflows/helpers/deliver-digest.md +79 -80
  62. package/.agents/workflows/helpers/deliver-light.md +9 -7
  63. package/.agents/workflows/helpers/deliver-reference.md +38 -22
  64. package/.agents/workflows/helpers/deliver-story-reference.md +11 -9
  65. package/.agents/workflows/helpers/deliver-story.md +30 -23
  66. package/.agents/workflows/helpers/plan-reference.md +24 -9
  67. package/docs/CHANGELOG.md +30 -0
  68. package/lib/cli/registry.js +7 -0
  69. package/lib/migrations/index.js +2 -0
  70. package/lib/migrations/steps/2.70.0-retire-audit-ledger.js +36 -0
  71. package/package.json +4 -3
  72. package/.agents/scripts/lib/audit-to-stories/ledger-commit.js +0 -184
  73. package/.agents/scripts/lib/audit-to-stories/ledger-pr.js +0 -279
  74. package/.agents/scripts/lib/audit-to-stories/ledger-record.js +0 -88
  75. package/.agents/scripts/lib/findings/audit-ledger.js +0 -289
  76. package/.agents/scripts/lib/orchestration/review-providers/scoped-lint.js +0 -272
@@ -13,20 +13,12 @@ import { parseArgs } from 'node:util';
13
13
  import { buildStoryBody } from './lib/audit-to-stories/build-story-body.js';
14
14
  import { classifyGroupsAgainstGitHub } from './lib/audit-to-stories/dedupe-against-github.js';
15
15
  import { formatEpicGrouping } from './lib/audit-to-stories/epic-grouping-directive.js';
16
- import {
17
- toCanonicalFinding,
18
- withFingerprints,
19
- } from './lib/audit-to-stories/finding-adapter.js';
16
+ import { withFingerprints } from './lib/audit-to-stories/finding-adapter.js';
20
17
  import { groupFindings } from './lib/audit-to-stories/group-findings.js';
21
18
  import {
22
19
  loadIssuesFile,
23
20
  normaliseIssueHit,
24
21
  } from './lib/audit-to-stories/issues-file.js';
25
- import {
26
- resolveLedgerSummary,
27
- runLedgerCommit,
28
- } from './lib/audit-to-stories/ledger-commit.js';
29
- import { recordFiledIssues } from './lib/audit-to-stories/ledger-record.js';
30
22
  import {
31
23
  parseAuditReports,
32
24
  readSeverityTally,
@@ -34,12 +26,6 @@ import {
34
26
  import { buildPlanSeedMarkdown } from './lib/audit-to-stories/seed-from-findings.js';
35
27
  import { wireAuditStoryEdges } from './lib/audit-to-stories/wire-dependencies.js';
36
28
  import { runAsCli } from './lib/cli-utils.js';
37
- import {
38
- DEFAULT_LEDGER_PATH,
39
- readLedger,
40
- reconcileLedger,
41
- writeLedger,
42
- } from './lib/findings/audit-ledger.js';
43
29
  import { searchSemanticCandidates } from './lib/findings/semantic-issue-search.js';
44
30
  import {
45
31
  normalizeSeverity,
@@ -125,7 +111,7 @@ function formatTally(tally) {
125
111
 
126
112
  /**
127
113
  * Cross-check the reports, warn on stderr, and throw under
128
- * `failOnReportFailures` (`--auto`) BEFORE any ledger or GitHub write; `--scan`
114
+ * `failOnReportFailures` (`--auto`) BEFORE any GitHub write; `--scan`
129
115
  * carries the failures on the plan envelope instead.
130
116
  *
131
117
  * @param {object} params
@@ -602,17 +588,17 @@ function dedupPhaseWarnings({ issues, summary }) {
602
588
  }
603
589
 
604
590
  /**
605
- * Scan → group → dedup → (optionally) reconcile the cross-run ledger.
591
+ * Scan → group → dedup. Cross-run memory is the Issues' provenance footers,
592
+ * which dedup reads from live state — nothing is persisted here.
606
593
  *
607
594
  * @param {{ glob?: string, severity?: string, useProvider?: boolean,
608
- * issuesFile?: string, ledger?: object }} params
595
+ * issuesFile?: string }} params
609
596
  * @param {{
610
597
  * collectReportPathsImpl?: typeof collectReportPaths,
611
598
  * readReportsImpl?: typeof readReports,
612
599
  * loadProviderImpl?: typeof loadProviderOrNull,
613
600
  * classifyGroupsImpl?: typeof classifyGroupsAgainstGitHub,
614
601
  * loadIssuesFileImpl?: typeof loadIssuesFile,
615
- * reconcileScanLedgerImpl?: typeof reconcileScanLedger,
616
602
  * logger?: { warn: Function },
617
603
  * }} [deps]
618
604
  * @returns {Promise<object>} the plan envelope.
@@ -623,7 +609,6 @@ async function buildPlan(
623
609
  severity,
624
610
  useProvider,
625
611
  issuesFile,
626
- ledger,
627
612
  allowMissingTally,
628
613
  failOnReportFailures,
629
614
  },
@@ -635,7 +620,6 @@ async function buildPlan(
635
620
  loadProviderImpl = loadProviderOrNull,
636
621
  classifyGroupsImpl = classifyGroupsAgainstGitHub,
637
622
  loadIssuesFileImpl = loadIssuesFile,
638
- reconcileScanLedgerImpl = reconcileScanLedger,
639
623
  logger = Logger,
640
624
  } = deps;
641
625
  // Before reading reports: an unusable corpus is a usage error, not a fallback.
@@ -680,32 +664,6 @@ async function buildPlan(
680
664
  { loadProviderImpl, classifyGroupsImpl, logger },
681
665
  );
682
666
 
683
- // Opt-in: plain --scan never mutates the committed ledger.
684
- let ledgerSummary;
685
- if (ledger) {
686
- const suppressed = reconcileScanLedgerImpl({
687
- ledgerPath: ledger.path ?? DEFAULT_LEDGER_PATH,
688
- findings: stamped,
689
- classifications,
690
- write: ledger.write !== false,
691
- });
692
- if (suppressed.size > 0) {
693
- for (const c of classifications) {
694
- const findings = c.group?.findings ?? [];
695
- if (
696
- findings.length > 0 &&
697
- findings.every((f) => suppressed.has(f?.fingerprint?.full))
698
- ) {
699
- c.action = 'skip-accepted-risk';
700
- }
701
- }
702
- }
703
- ledgerSummary = {
704
- path: ledger.path ?? DEFAULT_LEDGER_PATH,
705
- suppressed: suppressed.size,
706
- };
707
- }
708
-
709
667
  return {
710
668
  generatedAt: new Date().toISOString(),
711
669
  sourceReports: reportPaths,
@@ -720,62 +678,11 @@ async function buildPlan(
720
678
  tally: tallyBySeverity(filtered),
721
679
  reportFailures,
722
680
  dedupApplied,
723
- ...(ledgerSummary ? { ledger: ledgerSummary } : {}),
724
681
  ...summary,
725
682
  },
726
683
  };
727
684
  }
728
685
 
729
- /**
730
- * Fold the scan onto the ledger, persist it, and return the accepted-risk
731
- * fingerprints to suppress.
732
- *
733
- * @param {object} params
734
- * @param {string} params.ledgerPath
735
- * @param {Array<object>} params.findings — stamped scan findings.
736
- * @param {Array<{ group?: object, matchedIssues?: Array<{ number: number, state: string }>, matchedFingerprints?: string[] }>} params.classifications
737
- * @param {boolean} [params.write=true]
738
- * @returns {Set<string>}
739
- */
740
- function reconcileScanLedger({ ledgerPath, findings, classifications, write }) {
741
- const prior = readLedger(ledgerPath);
742
- const issueStates = issueStatesFromClassifications(classifications);
743
- const { ledger: next } = reconcileLedger({
744
- ledger: prior,
745
- findings,
746
- issueStates,
747
- // Passed in: the ledger importing the audit adapter would close a cycle.
748
- toCanonical: toCanonicalFinding,
749
- });
750
- if (write !== false) writeLedger(ledgerPath, next);
751
- return new Set(
752
- next.entries
753
- .filter((e) => e.status === 'accepted-risk')
754
- .map((e) => e.fingerprint),
755
- );
756
- }
757
-
758
- /**
759
- * @param {Array<object>} classifications
760
- * @returns {Record<string, { state: string, number: number|null }>}
761
- */
762
- function issueStatesFromClassifications(classifications) {
763
- const states = {};
764
- for (const c of classifications ?? []) {
765
- const issue = (c.matchedIssues ?? [])[0];
766
- if (!issue) continue;
767
- const state = String(issue.state ?? '')
768
- .toLowerCase()
769
- .includes('closed')
770
- ? 'closed'
771
- : 'open';
772
- for (const fp of c.matchedFingerprints ?? []) {
773
- states[fp] = { state, number: issue.number ?? null };
774
- }
775
- }
776
- return states;
777
- }
778
-
779
686
  function loadPlan(planPath) {
780
687
  if (!planPath) throw new Error('--plan <path> is required');
781
688
  return JSON.parse(fs.readFileSync(planPath, 'utf8'));
@@ -793,43 +700,25 @@ function severityFloorOf(explicit) {
793
700
  }
794
701
 
795
702
  /**
796
- * Unattended `--auto` sweep: build the plan with ledger reconciliation and
797
- * return a summary plus the create-eligible Story payloads (none under
798
- * `--dry-run`, which writes nothing). Never prompts.
703
+ * Unattended `--auto` sweep: build the plan and return a summary plus the
704
+ * create-eligible Story payloads (none under `--dry-run`). Writes nothing and
705
+ * never prompts.
799
706
  *
800
707
  * @param {object} params
801
708
  * @param {string} [params.glob]
802
709
  * @param {string} [params.severity] — explicit floor override.
803
710
  * @param {boolean} [params.dryRun]
804
711
  * @param {boolean} [params.useProvider]
805
- * @param {string} [params.ledgerPath]
806
- * @param {boolean} [params.ledgerCommit] — the operator asked for a ledger PR,
807
- * so an unpersistable checkout is not a warning: it is about to be fixed.
808
- * @param {(cwd: string, ...args: string[]) => string} [params.git] — probe seam.
809
- * @param {string} [params.cwd]
810
- * @param {{ warn: Function }} [params.logger]
712
+ * @param {string} [params.issuesFile]
811
713
  * @returns {Promise<{ summary: object, stories: Array<object> }>}
812
714
  */
813
- async function runAuto({
814
- glob,
815
- severity,
816
- dryRun,
817
- useProvider,
818
- issuesFile,
819
- ledgerPath,
820
- ledgerCommit,
821
- git,
822
- cwd,
823
- logger = Logger,
824
- }) {
715
+ async function runAuto({ glob, severity, dryRun, useProvider, issuesFile }) {
825
716
  const floor = severityFloorOf(severity);
826
- const resolvedLedgerPath = ledgerPath ?? DEFAULT_LEDGER_PATH;
827
717
  const plan = await buildPlan({
828
718
  glob,
829
719
  severity: floor,
830
720
  useProvider,
831
721
  issuesFile,
832
- ledger: { path: resolvedLedgerPath, write: !dryRun },
833
722
  // No operator reads warnings unattended, so every report failure is fatal.
834
723
  allowMissingTally: false,
835
724
  failOnReportFailures: true,
@@ -839,13 +728,11 @@ async function runAuto({
839
728
  create: [],
840
729
  skipOpen: [],
841
730
  skipReoccurring: [],
842
- suppressed: [],
843
731
  };
844
732
  for (const c of plan.classifications ?? []) {
845
733
  if (c.action === 'create') byAction.create.push(c);
846
734
  else if (c.action === 'skip-open') byAction.skipOpen.push(c);
847
735
  else if (c.action === 'skip-reoccurring') byAction.skipReoccurring.push(c);
848
- else if (c.action === 'skip-accepted-risk') byAction.suppressed.push(c);
849
736
  }
850
737
 
851
738
  const eligible = byAction.create.map((c) => c.group);
@@ -863,25 +750,14 @@ async function runAuto({
863
750
  create: byAction.create.length,
864
751
  skipOpen: byAction.skipOpen.length,
865
752
  skipReoccurring: byAction.skipReoccurring.length,
866
- suppressedByLedger: byAction.suppressed.length,
867
753
  },
868
754
  // The caller opens the Issues; these keys feed its `--wire-edges --ids`
869
- // map, without which the ledger never records what was filed.
755
+ // map, which resolves the group edges to `blocked by #N`.
870
756
  createGroupKeys: eligible.map((g) => g?.groupKey).filter(Boolean),
871
757
  reDetected: byAction.skipOpen
872
758
  .flatMap((c) => c.matchedIssues ?? [])
873
759
  .map((i) => i.number)
874
760
  .filter((n) => typeof n === 'number'),
875
- // An ephemeral clone may not be able to keep the ledger it just wrote.
876
- ledger: await resolveLedgerSummary({
877
- ledger: plan.summary?.ledger ?? null,
878
- ledgerPath: resolvedLedgerPath,
879
- dryRun,
880
- ledgerCommit,
881
- cwd,
882
- git,
883
- logger,
884
- }),
885
761
  };
886
762
 
887
763
  return { summary, stories };
@@ -953,44 +829,23 @@ function wireEdgesPreconditionError(reason, detail) {
953
829
  /**
954
830
  * Second pass after `--emit-stories`: given the opened `groupKey →
955
831
  * issueNumber` map, re-render each Story with `blocked by #N` footers, mirror
956
- * them as native `blocked_by`, and record the filed issues in the ledger.
832
+ * them as native `blocked_by`. Writes nothing to disk.
957
833
  *
958
834
  * @param {object} params
959
835
  * @param {object} params.plan A `--scan` plan envelope.
960
836
  * @param {Record<string, number>} params.issueByGroupKey
961
- * @param {string} [params.ledgerPath] — ledger to record into; defaults to
962
- * `DEFAULT_LEDGER_PATH` inside the record.
963
- * @param {boolean} [params.write] — `false` computes the record without
964
- * persisting it (what `--dry-run` passes).
965
837
  * @param {object} [deps]
966
838
  * @param {Function} [deps.loadProviderImpl]
967
839
  * @param {Function} [deps.wireImpl]
968
- * @param {Function} [deps.recordFiledIssuesImpl]
969
- * @returns {Promise<object>} the wiring summary, with the ledger record on
970
- * `ledger`.
840
+ * @returns {Promise<object>} the wiring summary.
971
841
  */
972
- async function wireEdges(
973
- { plan, issueByGroupKey, ledgerPath, write },
974
- deps = {},
975
- ) {
976
- const {
977
- loadProviderImpl = loadProvider,
978
- wireImpl = wireAuditStoryEdges,
979
- recordFiledIssuesImpl = recordFiledIssues,
980
- } = deps;
842
+ async function wireEdges({ plan, issueByGroupKey }, deps = {}) {
843
+ const { loadProviderImpl = loadProvider, wireImpl = wireAuditStoryEdges } =
844
+ deps;
981
845
  const groups = (plan.classifications ?? [])
982
846
  .filter((c) => c.action === 'create')
983
847
  .map((c) => c.group);
984
848
 
985
- // Record before loading the provider: a `gh`-less host, whose only duplicate
986
- // protection is the ledger, must still remember what it filed.
987
- const ledger = recordFiledIssuesImpl({
988
- ledgerPath,
989
- groups,
990
- issueByGroupKey,
991
- write,
992
- });
993
-
994
849
  let provider;
995
850
  try {
996
851
  provider = await loadProviderImpl();
@@ -1000,7 +855,7 @@ async function wireEdges(
1000
855
  if (typeof provider?.updateTicket !== 'function') {
1001
856
  throw wireEdgesPreconditionError('fixture-no-write-port');
1002
857
  }
1003
- const wired = await wireImpl({
858
+ return wireImpl({
1004
859
  groups,
1005
860
  edges: plan.edges ?? [],
1006
861
  issueByGroupKey,
@@ -1008,7 +863,6 @@ async function wireEdges(
1008
863
  updateBody: (issueNumber, body) =>
1009
864
  provider.updateTicket(issueNumber, { body }),
1010
865
  });
1011
- return { ...wired, ledger };
1012
866
  }
1013
867
 
1014
868
  /**
@@ -1066,61 +920,10 @@ export const __testing = {
1066
920
  dedupIndexDegradedWarning,
1067
921
  buildAndGateStories,
1068
922
  runAuto,
1069
- reconcileScanLedger,
1070
- issueStatesFromClassifications,
1071
923
  wireEdges,
1072
924
  parseIssueMap,
1073
925
  };
1074
926
 
1075
- /**
1076
- * The CLI core: dispatch one sub-command and persist its output.
1077
- *
1078
- * @param {string[]} [argv]
1079
- * @param {{
1080
- * buildPlanImpl?: typeof buildPlan,
1081
- * runAutoImpl?: typeof runAuto,
1082
- * loadPlanImpl?: typeof loadPlan,
1083
- * buildAndGateStoriesImpl?: typeof buildAndGateStories,
1084
- * buildPlanSeedMarkdownImpl?: typeof buildPlanSeedMarkdown,
1085
- * persistImpl?: typeof persist,
1086
- * stdout?: { write: (s: string) => void },
1087
- * }} [deps]
1088
- * @returns {Promise<void>}
1089
- */
1090
- /**
1091
- * The one-line `--ledger-commit` outcome: branch and PR, or the skip reason.
1092
- *
1093
- * @param {{ committed?: boolean, reason?: string, branch?: string,
1094
- * prUrl?: string|null, resumed?: boolean, ledgerPath?: string }} [result]
1095
- * @returns {string}
1096
- */
1097
- function describeLedgerCommit(result) {
1098
- return result?.committed
1099
- ? ledgerCommittedLine(result)
1100
- : ledgerSkippedLine(result);
1101
- }
1102
-
1103
- /**
1104
- * @param {object} result
1105
- * @returns {string}
1106
- */
1107
- function ledgerCommittedLine(result) {
1108
- const resumed = result.resumed ? ' (resumed an unpushed ledger branch)' : '';
1109
- const pr = result.prUrl ?? '(no URL reported by gh)';
1110
- return `--ledger-commit: pushed ${result.branch}${resumed} and opened ${pr}.`;
1111
- }
1112
-
1113
- /**
1114
- * Names the ledger file: its state is still only in the working tree.
1115
- * @param {object} [result]
1116
- * @returns {string}
1117
- */
1118
- function ledgerSkippedLine(result) {
1119
- const reason = result?.reason ?? 'no result';
1120
- const ledgerPath = result?.ledgerPath ?? 'the ledger';
1121
- return `--ledger-commit: skipped (${reason}) — ${ledgerPath} was not committed.`;
1122
- }
1123
-
1124
927
  /**
1125
928
  * Reject an unknown `--severity`: `meetsSeverity` would read a typo as rank 0
1126
929
  * and silently widen the run to every finding. Absent stays absent.
@@ -1140,6 +943,21 @@ function validateSeverityFlag(raw) {
1140
943
  return level;
1141
944
  }
1142
945
 
946
+ /**
947
+ * The CLI core: dispatch one sub-command and persist its output.
948
+ *
949
+ * @param {string[]} [argv]
950
+ * @param {{
951
+ * buildPlanImpl?: typeof buildPlan,
952
+ * runAutoImpl?: typeof runAuto,
953
+ * loadPlanImpl?: typeof loadPlan,
954
+ * buildAndGateStoriesImpl?: typeof buildAndGateStories,
955
+ * buildPlanSeedMarkdownImpl?: typeof buildPlanSeedMarkdown,
956
+ * persistImpl?: typeof persist,
957
+ * stdout?: { write: (s: string) => void },
958
+ * }} [deps]
959
+ * @returns {Promise<void>}
960
+ */
1143
961
  export async function runAuditToStories(
1144
962
  argv = process.argv.slice(2),
1145
963
  deps = {},
@@ -1153,7 +971,6 @@ export async function runAuditToStories(
1153
971
  wireEdgesImpl = wireEdges,
1154
972
  parseIssueMapImpl = parseIssueMap,
1155
973
  persistImpl = persist,
1156
- runLedgerCommitImpl = runLedgerCommit,
1157
974
  stdout = process.stdout,
1158
975
  } = deps;
1159
976
  const { values } = parseArgs({
@@ -1168,8 +985,6 @@ export async function runAuditToStories(
1168
985
  ids: { type: 'string' },
1169
986
  glob: { type: 'string' },
1170
987
  severity: { type: 'string' },
1171
- ledger: { type: 'string' },
1172
- 'ledger-commit': { type: 'boolean' },
1173
988
  plan: { type: 'string' },
1174
989
  out: { type: 'string' },
1175
990
  'no-provider': { type: 'boolean' },
@@ -1177,7 +992,9 @@ export async function runAuditToStories(
1177
992
  'allow-missing-tally': { type: 'boolean' },
1178
993
  json: { type: 'boolean' },
1179
994
  },
1180
- strict: false,
995
+ // Strict: a retired flag (the 2.70 ledger pair) must error, not be
996
+ // silently ignored by a sweep that still passes it.
997
+ strict: true,
1181
998
  });
1182
999
 
1183
1000
  values.severity = validateSeverityFlag(values.severity);
@@ -1192,22 +1009,9 @@ export async function runAuditToStories(
1192
1009
  dryRun: values['dry-run'],
1193
1010
  useProvider: !values['no-provider'],
1194
1011
  issuesFile: values['issues-file'],
1195
- ledgerPath: values.ledger,
1196
- ledgerCommit: values['ledger-commit'],
1197
1012
  })
1198
1013
  ).summary;
1199
1014
 
1200
- // Runs after the summary is persisted: a broken remote must not cost the
1201
- // sweep's findings.
1202
- const commitLedger = async () => {
1203
- if (!values['ledger-commit'] || values['dry-run']) return;
1204
- Logger.warn(
1205
- describeLedgerCommit(
1206
- await runLedgerCommitImpl({ ledgerPath: values.ledger }),
1207
- ),
1208
- );
1209
- };
1210
-
1211
1015
  const scanPlan = () =>
1212
1016
  buildPlanImpl({
1213
1017
  glob: values.glob,
@@ -1239,14 +1043,11 @@ export async function runAuditToStories(
1239
1043
  wireEdgesImpl({
1240
1044
  plan: loadPlanImpl(values.plan),
1241
1045
  issueByGroupKey: parseIssueMapImpl(values.ids),
1242
- ledgerPath: values.ledger,
1243
- // The Issues really exist here, so recording defaults on.
1244
- write: !values['dry-run'],
1245
1046
  });
1246
1047
 
1247
- // [flag, render, newlineOnStdout, afterPersist?]
1048
+ // [flag, render, newlineOnStdout]
1248
1049
  const subcommands = [
1249
- ['auto', async () => json(await runAutoSummary()), true, commitLedger],
1050
+ ['auto', async () => json(await runAutoSummary()), true],
1250
1051
  ['scan', async () => json(await scanPlan()), true],
1251
1052
  ['emit-plan-seed', () => seedMarkdown(), false],
1252
1053
  ['emit-stories', () => emittedStories(), true],
@@ -1259,10 +1060,9 @@ export async function runAuditToStories(
1259
1060
  'Usage: node audit-to-stories.js (--scan | --emit-plan-seed | --emit-stories | --wire-edges) [options]',
1260
1061
  );
1261
1062
  }
1262
- const [, render, newlineOnStdout, after] = entry;
1063
+ const [, render, newlineOnStdout] = entry;
1263
1064
  persistImpl(await render(), values.out);
1264
1065
  if (newlineOnStdout && !values.out) stdout.write('\n');
1265
- if (after) await after();
1266
1066
  }
1267
1067
 
1268
1068
  /**
@@ -1305,7 +1105,7 @@ runAsCli(import.meta.url, main, {
1305
1105
  ['--emit-stories', 'Emit the Story drafts as JSON.'],
1306
1106
  [
1307
1107
  '--wire-edges',
1308
- 'Second pass: resolve the detected group edges to blocked by #N footers plus native blocked_by relations, and record the mapped issues in the cross-run ledger as filed. Needs --plan and --ids; --dry-run suppresses the ledger write.',
1108
+ 'Second pass: resolve the detected group edges to blocked by #N footers plus native blocked_by relations. Needs --plan and --ids.',
1309
1109
  ],
1310
1110
  [
1311
1111
  '--ids <json|path>',
@@ -1313,14 +1113,6 @@ runAsCli(import.meta.url, main, {
1313
1113
  ],
1314
1114
  ['--glob <pattern>', 'Override the audit-results glob.'],
1315
1115
  ['--severity <level>', 'Lowest severity to include (high|medium|low).'],
1316
- [
1317
- '--ledger <path>',
1318
- `Path to the cross-run dedup ledger (default ${DEFAULT_LEDGER_PATH}).`,
1319
- ],
1320
- [
1321
- '--ledger-commit',
1322
- 'After the --auto summary prints, commit a changed ledger onto chore/audit-ledger-<date>, push it, and open a PR against the base branch (never auto-merged). Ignored under --dry-run.',
1323
- ],
1324
1116
  [
1325
1117
  '--plan <path>',
1326
1118
  'Read a previously emitted plan instead of re-scanning.',