mandrel 2.86.0 → 2.88.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 (165) hide show
  1. package/.agents/README.md +29 -0
  2. package/.agents/agents/auditor.md +4 -3
  3. package/.agents/docs/agentrc-reference.json +2 -1
  4. package/.agents/docs/configuration.md +44 -20
  5. package/.agents/docs/workflows.md +1 -1
  6. package/.agents/schemas/agentrc.schema.json +18 -12
  7. package/.agents/schemas/story-deliver-terminal.schema.json +1 -1
  8. package/.agents/schemas/story-progress.schema.json +5 -0
  9. package/.agents/scripts/audit-to-stories.js +3 -2
  10. package/.agents/scripts/boot-sweep.js +3 -2
  11. package/.agents/scripts/check-arch-cycles.js +19 -41
  12. package/.agents/scripts/check-context-budget.js +16 -44
  13. package/.agents/scripts/check-cyclomatic.js +13 -37
  14. package/.agents/scripts/check-dead-exports.js +16 -46
  15. package/.agents/scripts/clean-worktrees.js +1 -6
  16. package/.agents/scripts/coverage-capture.js +23 -3
  17. package/.agents/scripts/deliver-run.js +11 -0
  18. package/.agents/scripts/diagnose-friction.js +3 -3
  19. package/.agents/scripts/lib/baselines/bundle-size-scorer.js +115 -0
  20. package/.agents/scripts/lib/baselines/coverage-updater-cli.js +122 -29
  21. package/.agents/scripts/lib/baselines/crap-updater-cli.js +45 -14
  22. package/.agents/scripts/lib/baselines/duplication-scanner.js +45 -2
  23. package/.agents/scripts/lib/baselines/env-overrides.js +39 -34
  24. package/.agents/scripts/lib/baselines/kernel.js +3 -2
  25. package/.agents/scripts/lib/baselines/kinds/crap.js +14 -38
  26. package/.agents/scripts/lib/baselines/preview-gates.js +4 -1
  27. package/.agents/scripts/lib/baselines/refresh-service.js +101 -22
  28. package/.agents/scripts/lib/baselines/writer.js +5 -1
  29. package/.agents/scripts/lib/bdd-runner-detect.js +7 -10
  30. package/.agents/scripts/lib/child-exec.js +14 -1
  31. package/.agents/scripts/lib/child-stream.js +122 -0
  32. package/.agents/scripts/lib/clean-temp.js +19 -13
  33. package/.agents/scripts/lib/cli-args.js +49 -0
  34. package/.agents/scripts/lib/codex/skills-projection.js +1 -12
  35. package/.agents/scripts/lib/config/gates/coverage.schema.js +1 -1
  36. package/.agents/scripts/lib/config/gates/mutation.schema.js +2 -2
  37. package/.agents/scripts/lib/config/gates/shared.js +1 -1
  38. package/.agents/scripts/lib/config/gh-config-dir.js +63 -0
  39. package/.agents/scripts/lib/config/github.js +2 -0
  40. package/.agents/scripts/lib/config/paths.js +14 -3
  41. package/.agents/scripts/lib/config/quality.js +6 -2
  42. package/.agents/scripts/lib/config-resolver.js +78 -64
  43. package/.agents/scripts/lib/config-settings-schema-delivery.js +4 -3
  44. package/.agents/scripts/lib/config-settings-schema.js +7 -0
  45. package/.agents/scripts/lib/coverage-baseline.js +7 -6
  46. package/.agents/scripts/lib/coverage-capture.js +59 -0
  47. package/.agents/scripts/lib/crap-utils.js +59 -47
  48. package/.agents/scripts/lib/full-suite-lock.js +1 -10
  49. package/.agents/scripts/lib/gates/baseline-store.js +10 -0
  50. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  51. package/.agents/scripts/lib/gh-exec.js +45 -2
  52. package/.agents/scripts/lib/gh-transport.js +27 -0
  53. package/.agents/scripts/lib/git-utils.js +16 -9
  54. package/.agents/scripts/lib/maintainability-engine.js +27 -6
  55. package/.agents/scripts/lib/maintainability-utils.js +14 -1
  56. package/.agents/scripts/lib/observability/source-classifier.js +1 -0
  57. package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +33 -3
  58. package/.agents/scripts/lib/orchestration/evidence-stream.js +186 -0
  59. package/.agents/scripts/lib/orchestration/file-assumptions.js +2 -19
  60. package/.agents/scripts/lib/orchestration/git-cleanup/phases/branches-reap.js +3 -7
  61. package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes-ff.js +34 -40
  62. package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +4 -3
  63. package/.agents/scripts/lib/orchestration/plan-persist/persist-helpers.js +2 -19
  64. package/.agents/scripts/lib/orchestration/pr-watch.js +1 -5
  65. package/.agents/scripts/lib/orchestration/project-meta-cache.js +17 -4
  66. package/.agents/scripts/lib/orchestration/reassert-status-column.js +1 -8
  67. package/.agents/scripts/lib/orchestration/resolve-stories.js +1 -0
  68. package/.agents/scripts/lib/orchestration/review-providers/native.js +2 -2
  69. package/.agents/scripts/lib/orchestration/single-story-close/phase-timer.js +43 -0
  70. package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +37 -13
  71. package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +264 -0
  72. package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +68 -0
  73. package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +106 -0
  74. package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +43 -35
  75. package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +52 -0
  76. package/.agents/scripts/lib/orchestration/single-story-close/result.js +273 -0
  77. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +68 -776
  78. package/.agents/scripts/lib/orchestration/story-close/context-budget-writeback.js +20 -9
  79. package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +2 -2
  80. package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +20 -12
  81. package/.agents/scripts/lib/orchestration/story-handoff.js +50 -21
  82. package/.agents/scripts/lib/orchestration/story-progress.js +32 -12
  83. package/.agents/scripts/lib/orchestration/ticket-validator.js +3 -13
  84. package/.agents/scripts/lib/qa/resolve-selection.js +1 -8
  85. package/.agents/scripts/lib/single-story/confirm-and-land.js +33 -0
  86. package/.agents/scripts/lib/single-story-sweep/reconcile-closing.js +43 -11
  87. package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +130 -30
  88. package/.agents/scripts/lib/skills/parse-skill.js +1 -4
  89. package/.agents/scripts/lib/story-body/story-body.js +12 -1
  90. package/.agents/scripts/lib/suite-admission.js +3 -11
  91. package/.agents/scripts/lib/temp-retention.js +25 -11
  92. package/.agents/scripts/lib/test-run-credit.js +2 -5
  93. package/.agents/scripts/lib/transpile.js +193 -31
  94. package/.agents/scripts/lib/util/paths.js +31 -0
  95. package/.agents/scripts/lib/util/sleep.js +15 -0
  96. package/.agents/scripts/lib/validation-evidence.js +29 -3
  97. package/.agents/scripts/lib/wave-runner/live-probe.js +24 -0
  98. package/.agents/scripts/lib/workers/crap-worker.js +23 -12
  99. package/.agents/scripts/lib/workers/maintainability-report-worker.js +18 -12
  100. package/.agents/scripts/lib/workflow-closure.js +1 -8
  101. package/.agents/scripts/notify.js +83 -90
  102. package/.agents/scripts/plan-context.js +8 -4
  103. package/.agents/scripts/providers/github/auth.js +14 -30
  104. package/.agents/scripts/providers/github/blocked-by-add.js +11 -27
  105. package/.agents/scripts/providers/github/compose.js +1 -0
  106. package/.agents/scripts/providers/github/gh-token-diagnostics.js +130 -0
  107. package/.agents/scripts/providers/github/identity.js +158 -0
  108. package/.agents/scripts/providers/github/issues.js +2 -2
  109. package/.agents/scripts/providers/github/mappers.js +16 -19
  110. package/.agents/scripts/providers/github/projects-v2-graphql.js +4 -36
  111. package/.agents/scripts/providers/github/request-helpers.js +44 -0
  112. package/.agents/scripts/providers/github/sub-issue-add.js +11 -28
  113. package/.agents/scripts/providers/github.js +10 -2
  114. package/.agents/scripts/quality-preview.js +6 -19
  115. package/.agents/scripts/single-story-confirm-merge.js +8 -20
  116. package/.agents/scripts/single-story-init.js +0 -1
  117. package/.agents/scripts/stories-wave-tick.js +60 -46
  118. package/.agents/scripts/story-handoff.js +2 -23
  119. package/.agents/scripts/story-review-compute.js +3 -22
  120. package/.agents/scripts/sync-claude-agents.js +1 -12
  121. package/.agents/scripts/sync-claude-commands.js +1 -12
  122. package/.agents/scripts/update-bundle-size-baseline.js +56 -0
  123. package/.agents/scripts/update-coverage-baseline.js +16 -41
  124. package/.agents/scripts/update-crap-baseline.js +10 -19
  125. package/.agents/scripts/update-duplication-baseline.js +13 -3
  126. package/.agents/scripts/update-ticket-state.js +44 -45
  127. package/.agents/templates/docs/audit-sweep-runbook.md +1 -1
  128. package/.agents/workflows/audit-accessibility.md +1 -1
  129. package/.agents/workflows/audit-adrs.md +1 -1
  130. package/.agents/workflows/audit-architecture.md +1 -1
  131. package/.agents/workflows/audit-baselines.md +2 -2
  132. package/.agents/workflows/audit-clean-code.md +1 -1
  133. package/.agents/workflows/audit-data-model.md +1 -1
  134. package/.agents/workflows/audit-dependencies.md +1 -1
  135. package/.agents/workflows/audit-devops.md +1 -1
  136. package/.agents/workflows/audit-documentation.md +1 -1
  137. package/.agents/workflows/audit-exceptions.md +2 -2
  138. package/.agents/workflows/audit-mobile.md +1 -1
  139. package/.agents/workflows/audit-navigability.md +1 -1
  140. package/.agents/workflows/audit-performance.md +1 -1
  141. package/.agents/workflows/audit-privacy.md +1 -1
  142. package/.agents/workflows/audit-quality.md +1 -1
  143. package/.agents/workflows/audit-security.md +1 -1
  144. package/.agents/workflows/audit-seo.md +1 -1
  145. package/.agents/workflows/audit-sre.md +1 -1
  146. package/.agents/workflows/audit-to-stories.md +9 -7
  147. package/.agents/workflows/audit-ux-ui.md +1 -1
  148. package/.agents/workflows/helpers/audit-lens-core.md +8 -5
  149. package/.agents/workflows/helpers/deliver-digest.md +4 -5
  150. package/.agents/workflows/helpers/deliver-story-reference.md +4 -4
  151. package/.agents/workflows/mandrel-deliver.md +3 -1
  152. package/README.md +6 -3
  153. package/docs/CHANGELOG.md +36 -0
  154. package/lib/cli/doctor-checks/codex.js +240 -0
  155. package/lib/cli/doctor-checks/merge-driver.js +79 -0
  156. package/lib/cli/doctor-checks/payload.js +201 -0
  157. package/lib/cli/doctor-checks/read-json.js +16 -0
  158. package/lib/cli/doctor-checks/runtime-deps.js +146 -0
  159. package/lib/cli/doctor-checks/spawn.js +18 -0
  160. package/lib/cli/doctor-checks/sync-parity.js +205 -0
  161. package/lib/cli/doctor-checks/test-credit-path.js +270 -0
  162. package/lib/cli/doctor-checks/toolchain.js +137 -0
  163. package/lib/cli/doctor-checks/version-current.js +82 -0
  164. package/lib/cli/registry.js +40 -1330
  165. package/package.json +7 -1
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  description:
3
3
  Convert findings produced by the audit-* workflows into actionable
4
- GitHub Stories. Reads temp/audits/audit-*-results.md, groups findings
4
+ GitHub Stories. Reads temp/audits/audit-results/audit-*-results.md, groups findings
5
5
  cross-audit, deduplicates against existing Issues by fingerprint, and
6
6
  either chains into /mandrel-plan --seed-file or opens standalone Stories.
7
7
  ---
@@ -15,7 +15,9 @@ Engineering Lead
15
15
  ## Context
16
16
 
17
17
  The `audit-*` workflows each produce a structured `audit-<dimension>-results.md`
18
- report under `temp/audits/`. Every `### Finding` block in those reports
18
+ report under `temp/audits/audit-results/` — a folder that holds lens reports
19
+ and nothing else; this workflow's own plan, seed and stories files stay one
20
+ level up in `temp/audits/`. Every `### Finding` block in those reports
19
21
  already carries the fields a Story body needs (Severity / Impact,
20
22
  Dimension / Category, Location, Current State, Recommendation, Acceptance
21
23
  signal).
@@ -26,7 +28,7 @@ They remain read-only emitters of audit reports.
26
28
  ## Prerequisites
27
29
 
28
30
  1. At least one `audit-*-results.md` file under
29
- `temp/audits/` (or the path passed as the argument). Run a
31
+ `temp/audits/audit-results/` (or the path passed as the argument). Run a
30
32
  `/audit-<dimension>` first if none are present.
31
33
  2. `GITHUB_TOKEN` or `gh auth status` clean — the dedupe and create
32
34
  steps both call GitHub.
@@ -38,7 +40,7 @@ They remain read-only emitters of audit reports.
38
40
 
39
41
  `/audit-to-stories [audit-file-or-glob]`
40
42
 
41
- - No argument → scans `temp/audits/audit-*-results.md`.
43
+ - No argument → scans `temp/audits/audit-results/audit-*-results.md`.
42
44
  - Single file path or glob → restricts the scan to that input.
43
45
 
44
46
  ## Phase 1 — Discover & parse
@@ -330,7 +332,7 @@ result as a JSON array, and pass it:
330
332
 
331
333
  ```bash
332
334
  node .agents/scripts/audit-to-stories.js --scan --no-provider \
333
- --issues-file temp/audits/issues.json --glob "temp/audits/audit-*-results.md"
335
+ --issues-file temp/audits/issues.json --glob "temp/audits/audit-results/audit-*-results.md"
334
336
  ```
335
337
 
336
338
  Real `skip-open` / `skip-reoccurring` classifications come back. The corpus is
@@ -403,12 +405,12 @@ that delivers the whole sweep (`/mandrel-deliver <epicId>`).
403
405
  To run an unattended maintenance sweep, `/schedule` a nightly (or weekly)
404
406
  job that (1) runs the relevant `audit-*` lens workflows full-scope — no
405
407
  `--paths`, no change-set filter, so the whole target-set union is audited —
406
- writing their `temp/audits/audit-*-results.md` reports, then (2) invokes the
408
+ writing their `temp/audits/audit-results/audit-*-results.md` reports, then (2) invokes the
407
409
  CLI's **`--auto` mode** over those results:
408
410
 
409
411
  ```bash
410
412
  node .agents/scripts/audit-to-stories.js --auto [--dry-run] \
411
- [--glob "temp/audits/audit-*-results.md"] [--severity <floor>]
413
+ [--glob "temp/audits/audit-results/audit-*-results.md"] [--severity <floor>]
412
414
  ```
413
415
 
414
416
  The routine shape is **lenses full-scope → dry-run → live**:
@@ -8,7 +8,7 @@ You are a Lead Product Designer & Frontend Architect evaluating the frontend for
8
8
  UI consistency, UX best practices, and adherence to the project's design system,
9
9
  ensuring the app feels premium and cohesive. The shared lens machinery lives in
10
10
  [`helpers/audit-lens-core.md`](helpers/audit-lens-core.md). Write the report to
11
- `{{auditOutputDir}}/audit-ux-ui-results.md`. Dimension values:
11
+ `{{auditResultsDir}}/audit-ux-ui-results.md`. Dimension values:
12
12
  `Visual Consistency | UX Best Practices | Accessibility`; the report adds a
13
13
  **Micro-animation Opportunities** section.
14
14
 
@@ -87,12 +87,15 @@ one — and name the detected set in the Executive Summary. Then:
87
87
  ## Report envelope & finding-block skeleton {#report-envelope}
88
88
 
89
89
  Each lens writes exactly one structured Markdown report to
90
- `{{auditOutputDir}}/audit-<lens>-results.md` (the lens preamble names its own
90
+ `{{auditResultsDir}}/audit-<lens>-results.md` (the lens preamble names its own
91
91
  path). A dispatched run gets the anchor substituted; on a manual
92
- `/audit-<lens>` invocation it renders the literal string `{{auditOutputDir}}`.
93
- Treat that literal as `<project.paths.tempRoot>/audits` — **`temp/audits` by
94
- default** — and write the report there, mirroring the `{{changedFiles}}`
95
- manual-run rule above. The report MUST include every section its lens
92
+ `/audit-<lens>` invocation it renders the literal string `{{auditResultsDir}}`.
93
+ Treat that literal as `<project.paths.tempRoot>/audits/audit-results` —
94
+ **`temp/audits/audit-results` by default**, created if absent — and write the
95
+ report there, mirroring the `{{changedFiles}}` manual-run rule above. That
96
+ folder holds lens reports only: any other artifact a lens writes (an
97
+ introspected schema, `perf-baseline.json`, profiler output) goes under
98
+ `{{auditOutputDir}}`, read on a manual run as `<project.paths.tempRoot>/audits`. The report MUST include every section its lens
96
99
  template mandates — write `_No findings._` rather than omitting a section — and
97
100
  always an
98
101
  `## Executive Summary` and a `## Detailed Findings` section. The Executive
@@ -12,8 +12,7 @@ description: >-
12
12
  > covers the happy path. Situational material (lease preflight, recovery
13
13
  > routers, merge-wait budgets, CI remediation) stays on demand in
14
14
  > [`deliver-story-reference.md`](deliver-story-reference.md) and
15
- > [`deliver-reference.md`](deliver-reference.md); read those **only** when an
16
- > envelope or a failure routes you there.
15
+ > [`deliver-reference.md`](deliver-reference.md); read those only when routed.
17
16
 
18
17
  ## 1. Dispatch — where the engine runs
19
18
 
@@ -25,8 +24,8 @@ rule produces it:
25
24
  sibling, and a one-Story run has none.
26
25
  2. **Every other run is `subagent`**, however trivial each Story's shape.
27
26
 
28
- `inline` removes the `story-worker` boot and nothing else — not the verdict
29
- owner, which the profile alone names (§ 3). **`subagent` and `inline` run the same engine**: same gates,
27
+ `inline` drops only the `story-worker` boot — not the verdict owner, which
28
+ the profile alone names (§ 3). **`subagent` and `inline` run the same engine**: same gates,
30
29
  same PR to `main`, same terminal envelope.
31
30
 
32
31
  ## 2. Engine invariants
@@ -154,7 +153,7 @@ respawned.
154
153
  | `status` | Exit | Meaning | You do |
155
154
  | --- | --- | --- | --- |
156
155
  | `landed` | 0 | PR merged, `agent::done`, tail ran (`tail.*: false` degrades the report, not the land) | Relay it. Done. |
157
- | `pending` | 3 | **Resumable, not a failure** — the bounded wait expired healthy, or a human owns the merge. Nothing was mutated. | Run `nextCommand`. |
156
+ | `pending` | 3 | **Resumable, not a failure** — the bounded wait expired healthy, or a human owns the merge. Nothing was mutated. | Run `nextCommand`. Each beat: run every `confirm[]` verbatim, pre-epilogue. |
158
157
  | `blocked` | 1 | Hard block; `blocked.blockClass` names it | `checks-failed` → fix + resume; else relay |
159
158
  | `failed` | 1 | A phase crashed; `phase` names which | Diagnose, fix, re-run close. `base-sync` conflict (files in `failure.reason`): resolve in `workCwd`, commit, run `nextCommand`; block only if you cannot |
160
159
 
@@ -228,8 +228,8 @@ separate (`delivery.mergeWatch.*`):
228
228
  that precede it. Expiry → `pending`. Pass `--max-wait-seconds <n>` to raise
229
229
  it when your host has no such ceiling and you want to land in one block.
230
230
  - **`maxBudgetSeconds`** (default 3600) bounds the **cumulative** wait across
231
- resumes, anchored at the PR's `createdAt` so resuming does not restart the
232
- clock. Exhausting _this_ is the genuine give-up → `blocked`.
231
+ resumes, anchored at the latest auto-merge arm (else `createdAt`): a resume
232
+ keeps the clock, a re-arming re-close starts fresh. Exhausting _this_ is the genuine give-up → `blocked`.
233
233
 
234
234
  The wait probes the checks every poll: a red required check fails fast as
235
235
  `checks-failed` instead of burning the budget, and a PR that falls behind its
@@ -623,8 +623,8 @@ tool-invocation ceiling:
623
623
 
624
624
  - It is **resumable**: no label was mutated, no `merge.unlanded` was emitted,
625
625
  and `nextCommand` names the one command that continues it. The cumulative
626
- budget is anchored at the PR's `createdAt`, so resuming does not restart the
627
- clock.
626
+ budget is anchored at the latest auto-merge arm, which a resume does not
627
+ move, so resuming does not restart the clock.
628
628
  - It is **not** a park. Returning `pending` because you would rather not wait
629
629
  is the no-park failure mode wearing a schema. Return it only
630
630
  when the bound genuinely expired, or a human owns the merge.
@@ -102,7 +102,9 @@ to an attended run.
102
102
  `effort` is non-null, pass it as that Agent call's `effort`; when it is
103
103
  `null`, omit the parameter so the worker inherits the session. Run each
104
104
  `close[]` entry's command foreground and serialized as hand-offs arrive.
105
- An empty
105
+ Run every `confirm[]` command verbatim on each beat, before the epilogue:
106
+ a closed Story still owing its `agent::done` flip and land tail. It never
107
+ gates `done`. An empty
106
108
  `ready` with work in flight means "waiting", so beat again — **unless
107
109
  `stalledDispatch[]` is non-empty**: those ids were dispatched but still
108
110
  read `agent::ready`, which is a live init window the first beats or two
package/README.md CHANGED
@@ -30,10 +30,13 @@ directory, where your assistant reads it.
30
30
  | `scripts/` | Deterministic Node.js CLIs that do the mechanical work — GitHub state changes, worktrees, quality gates — so the model judges and the scripts execute. |
31
31
  | `schemas/`, `templates/` | JSON Schema contracts and the prompt/planning templates the workflows fill in. |
32
32
  | `docs/` | Consumer reference: [configuration](.agents/docs/configuration.md) (every `.agentrc.json` key), the [workflow index](.agents/docs/workflows.md), and operator runbooks. |
33
+ | `audit-checklists/` | Generated per-lens authoring checklists, threaded into a Story's write-time checklist when its change set matches an audit lens. |
34
+ | `mods/` | Beta, opt-in Claude Code mods — see the [mods runbook](.agents/docs/runbooks/mods.md). |
33
35
  | `local/` | Yours. `mandrel sync` never touches it, so project-specific skills and workflow fragments survive upgrades. |
34
36
 
35
- Project settings live in `.agentrc.json` at your repo root. The full tour of
36
- the bundle is in [`.agents/README.md`](.agents/README.md).
37
+ Project settings live in `.agentrc.json` at your repo root. The table above is
38
+ a partial list (it omits single files such as `starter-agentrc.json`); the full
39
+ tour of the bundle is in [`.agents/README.md`](.agents/README.md).
37
40
 
38
41
  ## The core loop: plan, then deliver
39
42
 
@@ -82,7 +85,7 @@ The full process — labels, state, review, troubleshooting — is in
82
85
 
83
86
  The `/audit-*` workflows are read-only lenses that examine the codebase along
84
87
  one dimension and write a findings report (severity, location, recommendation,
85
- acceptance signal) under `temp/audits/`. They never change code — fixing is a
88
+ acceptance signal) under `temp/audits/audit-results/`. They never change code — fixing is a
86
89
  separate, planned pass.
87
90
 
88
91
  | Area | Lenses |
package/docs/CHANGELOG.md CHANGED
@@ -15,6 +15,42 @@ All notable changes to this project will be documented in this file.
15
15
  -->
16
16
  <!-- markdownlint-disable-file MD004 MD012 MD037 -->
17
17
 
18
+ ## [2.88.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.87.0...mandrel-v2.88.0) (2026-10-15)
19
+
20
+
21
+ ### Added
22
+
23
+ * finalize a merged Story's labels and lease from the beat and the boot sweep ([#5705](https://github.com/dsj1984/mandrel/issues/5705)) ([#5710](https://github.com/dsj1984/mandrel/issues/5710)) ([516f675](https://github.com/dsj1984/mandrel/commit/516f6755be4ca16845d47b0ba346a9b3fa7a5a98))
24
+ * persist a project-local GitHub CLI config dir, verify the operator identity, and stop reading transport failures as expired auth ([#5693](https://github.com/dsj1984/mandrel/issues/5693)) ([#5712](https://github.com/dsj1984/mandrel/issues/5712)) ([2668ff4](https://github.com/dsj1984/mandrel/commit/2668ff4cce7231ac612d4d98e02794d2fb7fb941))
25
+ * resolve TypeScript from the scanned file's own package in the CRAP and maintainability scorers ([#5692](https://github.com/dsj1984/mandrel/issues/5692)) ([#5701](https://github.com/dsj1984/mandrel/issues/5701)) ([c7ac7eb](https://github.com/dsj1984/mandrel/commit/c7ac7eb5b03ab6a36b1e0c3fb62915ab803f9c04))
26
+ * stream the handoff credited-run evidence log while the suite runs ([#5694](https://github.com/dsj1984/mandrel/issues/5694)) ([#5699](https://github.com/dsj1984/mandrel/issues/5699)) ([8931932](https://github.com/dsj1984/mandrel/commit/89319325ebeb67babcf845c29bef98807eb163f8))
27
+ * write audit lens reports to a dedicated temp/audits/audit-results/ folder ([#5679](https://github.com/dsj1984/mandrel/issues/5679)) ([#5680](https://github.com/dsj1984/mandrel/issues/5680)) ([9f20249](https://github.com/dsj1984/mandrel/commit/9f202494a51e69b83accbdfba8c0f44ec95369cb))
28
+
29
+
30
+ ### Fixed
31
+
32
+ * clear the duplication drift and make the scoped refresh rewrite clone-partner rows ([#5702](https://github.com/dsj1984/mandrel/issues/5702)) ([#5711](https://github.com/dsj1984/mandrel/issues/5711)) ([76cff34](https://github.com/dsj1984/mandrel/commit/76cff34be2729c57d2e40ec8d291355a9137c906))
33
+ * close the suite-admission and sweep-lock interleaving races and prove the admission invariant ([#5684](https://github.com/dsj1984/mandrel/issues/5684)) ([#5700](https://github.com/dsj1984/mandrel/issues/5700)) ([2bf193d](https://github.com/dsj1984/mandrel/commit/2bf193d4f8358f3d24310a924fc34c0d416f0a2c))
34
+ * drive the untested destructive and state-mutation seams: worktree ops, flip-failed emitter, init, ticket-state CLI ([#5685](https://github.com/dsj1984/mandrel/issues/5685)) ([#5698](https://github.com/dsj1984/mandrel/issues/5698)) ([297ed1c](https://github.com/dsj1984/mandrel/commit/297ed1c8205de307e8acdb4dd8a66fcb99fe8db4))
35
+ * fail the comment-ratio gate only on a change whose own diff is comment-heavy, so an unrelated merge cannot tip it ([#5713](https://github.com/dsj1984/mandrel/issues/5713)) ([#5714](https://github.com/dsj1984/mandrel/issues/5714)) ([5bc18a3](https://github.com/dsj1984/mandrel/commit/5bc18a34d26a446ff0f0f1a5aff3663aea51a3c1))
36
+ * give a re-close after a block a fresh merge budget and re-take its lease ([#5706](https://github.com/dsj1984/mandrel/issues/5706)) ([#5708](https://github.com/dsj1984/mandrel/issues/5708)) ([8c3be8b](https://github.com/dsj1984/mandrel/commit/8c3be8b0bc7c9db55ebebe8455f5a3ff7925a43a))
37
+ * make baseline and gate-credit writes fail closed: scoped refresh, writeback restore, atomic evidence, honest mutation default ([#5683](https://github.com/dsj1984/mandrel/issues/5683)) ([#5697](https://github.com/dsj1984/mandrel/issues/5697)) ([6a65a02](https://github.com/dsj1984/mandrel/commit/6a65a0226e474d3fe9e96bca6b0648895360ef94))
38
+ * make the story-body parser skip whole-line HTML comment markers (audit-… ([#5690](https://github.com/dsj1984/mandrel/issues/5690)) ([#5691](https://github.com/dsj1984/mandrel/issues/5691)) ([1419e05](https://github.com/dsj1984/mandrel/commit/1419e05fef8a289f207e7bf9cbbe902e600e6688))
39
+ * split the close runner and the doctor registry along their seams, and fix the doctor's comment-matching hook detector ([#5688](https://github.com/dsj1984/mandrel/issues/5688)) ([#5703](https://github.com/dsj1984/mandrel/issues/5703)) ([cbca841](https://github.com/dsj1984/mandrel/commit/cbca841a5a8f62e35597bf78b13675161f2cd22f))
40
+ * stop CLIs truncating piped output at 64 KiB and move hand-rolled argv parsing onto parseArgs ([#5686](https://github.com/dsj1984/mandrel/issues/5686)) ([#5696](https://github.com/dsj1984/mandrel/issues/5696)) ([02d7684](https://github.com/dsj1984/mandrel/commit/02d76845f3f4fe65698ca2e9549b5e8fbfc3a1ab))
41
+
42
+
43
+ ### Changed
44
+
45
+ * collapse drifting duplicate helpers onto one owner each and fix the config-resolver cache key ([#5687](https://github.com/dsj1984/mandrel/issues/5687)) ([#5704](https://github.com/dsj1984/mandrel/issues/5704)) ([18bdfcc](https://github.com/dsj1984/mandrel/commit/18bdfccf8c31b064b0e25db28fb97fff6a4fd5a0))
46
+
47
+ ## [2.87.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.86.0...mandrel-v2.87.0) (2026-10-14)
48
+
49
+
50
+ ### Added
51
+
52
+ * make consumer quality-baseline refresh runnable from a clean install ([#5672](https://github.com/dsj1984/mandrel/issues/5672)) ([#5673](https://github.com/dsj1984/mandrel/issues/5673)) ([9bb4a71](https://github.com/dsj1984/mandrel/commit/9bb4a718c0a9765b064c83a0a11c57b71ed9a35c))
53
+
18
54
  ## [2.86.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.85.0...mandrel-v2.86.0) (2026-10-14)
19
55
 
20
56
 
@@ -0,0 +1,240 @@
1
+ // lib/cli/doctor-checks/codex.js — Doctor checks: codex-skills-in-sync, codex-agents-in-sync, codex-instructions.
2
+
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ import {
7
+ SYSTEM_PROMPT_IMPORT,
8
+ SYSTEM_PROMPT_READ_DIRECTIVE,
9
+ } from '../../../.agents/scripts/lib/bootstrap/agents-md-fold.js';
10
+ import {
11
+ CODEX_AGENTS_DIR,
12
+ expectedCodexAgents,
13
+ listGeneratedCodexAgents,
14
+ } from '../../../.agents/scripts/lib/codex/agents-projection.js';
15
+ import {
16
+ CODEX_SKILLS_DIR,
17
+ expectedCodexSkills,
18
+ listGeneratedCodexSkills,
19
+ } from '../../../.agents/scripts/lib/codex/skills-projection.js';
20
+
21
+ // check: codex-skills-in-sync / codex-agents-in-sync
22
+
23
+ /**
24
+ * Compare a generated tree against what its projector would write now.
25
+ * `readEntry(name)` returns the on-disk text or null.
26
+ *
27
+ * @param {{
28
+ * expected: () => Map<string, string>,
29
+ * onDisk: string[],
30
+ * readEntry: (name: string) => string | null,
31
+ * noun: string,
32
+ * where: string,
33
+ * remedy: string,
34
+ * }} spec
35
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
36
+ */
37
+ function projectionParity({
38
+ expected,
39
+ onDisk,
40
+ readEntry,
41
+ noun,
42
+ where,
43
+ remedy,
44
+ }) {
45
+ let want;
46
+ try {
47
+ want = expected();
48
+ } catch (err) {
49
+ return { ok: false, detail: err.message, remedy };
50
+ }
51
+ const have = new Set(onDisk);
52
+ const missing = [...want.keys()].filter((n) => !have.has(n));
53
+ const stale = [...want.entries()].filter(
54
+ ([n, body]) => have.has(n) && readEntry(n) !== body,
55
+ );
56
+ const extra = onDisk.filter((n) => !want.has(n));
57
+ if (missing.length + stale.length + extra.length === 0) {
58
+ return { ok: true, detail: `${want.size} ${noun} up to date in ${where}` };
59
+ }
60
+ const parts = [];
61
+ if (missing.length > 0) parts.push(`${missing.length} not synced`);
62
+ if (stale.length + extra.length > 0) {
63
+ parts.push(`${stale.length + extra.length} stale`);
64
+ }
65
+ return { ok: false, detail: `${parts.join(', ')} in ${where}`, remedy };
66
+ }
67
+
68
+ /**
69
+ * @param {string} file
70
+ * @returns {string | null}
71
+ */
72
+ function readTextOrNull(file) {
73
+ try {
74
+ return fs.readFileSync(file, 'utf8');
75
+ } catch {
76
+ return null;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Parity of `.agents/skills/workflows/` against the workflow set — the Codex
82
+ * twin of `commands-in-sync`, byte-for-byte rather than by name.
83
+ *
84
+ * @param {{ projectRoot?: string, cwd?: () => string }} [opts]
85
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
86
+ */
87
+ export function runCodexSkillsInSync({ projectRoot, cwd } = {}) {
88
+ const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
89
+ const destDir = path.join(root, ...CODEX_SKILLS_DIR.split('/'));
90
+ return projectionParity({
91
+ expected: () => expectedCodexSkills({ projectRoot: root }),
92
+ onDisk: listGeneratedCodexSkills(destDir),
93
+ readEntry: (name) => readTextOrNull(path.join(destDir, name, 'SKILL.md')),
94
+ noun: 'Codex skills',
95
+ where: `${CODEX_SKILLS_DIR}/`,
96
+ remedy: `Run \`mandrel sync-commands\` to regenerate the Codex skills under \`${CODEX_SKILLS_DIR}/\`.`,
97
+ });
98
+ }
99
+
100
+ /**
101
+ * Parity of `.codex/agents/mandrel-*.toml` against `.agents/agents/` — the
102
+ * Codex twin of `agents-in-sync`.
103
+ *
104
+ * @param {{ projectRoot?: string, cwd?: () => string }} [opts]
105
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
106
+ */
107
+ export function runCodexAgentsInSync({ projectRoot, cwd } = {}) {
108
+ const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
109
+ const destDir = path.join(root, ...CODEX_AGENTS_DIR.split('/'));
110
+ return projectionParity({
111
+ expected: () => expectedCodexAgents({ projectRoot: root }),
112
+ onDisk: listGeneratedCodexAgents(destDir),
113
+ readEntry: (name) => readTextOrNull(path.join(destDir, name)),
114
+ noun: 'Codex agents',
115
+ where: `${CODEX_AGENTS_DIR}/`,
116
+ remedy: `Run \`mandrel sync-agents\` to regenerate \`${CODEX_AGENTS_DIR}/mandrel-<role>.toml\`.`,
117
+ });
118
+ }
119
+
120
+ // check: codex-instructions
121
+
122
+ /** Codex's default `project_doc_max_bytes`. */
123
+ export const CODEX_PROJECT_DOC_MAX_BYTES = 32768;
124
+
125
+ /**
126
+ * A top-level `project_doc_max_bytes = <int>` line before any `[table]`
127
+ * header; anything else (absent file, nested key, non-integer) is null. No
128
+ * TOML dependency — this one key is all the check needs.
129
+ *
130
+ * @param {string | null} text
131
+ * @returns {number | null}
132
+ */
133
+ export function readProjectDocMaxBytes(text) {
134
+ if (typeof text !== 'string') return null;
135
+ for (const line of text.split(/\r?\n/)) {
136
+ if (/^\s*\[/.test(line)) return null;
137
+ const match = /^\s*project_doc_max_bytes\s*=\s*(\d+)\s*(?:#.*)?$/.exec(
138
+ line,
139
+ );
140
+ if (match) return Number(match[1]);
141
+ }
142
+ return null;
143
+ }
144
+
145
+ /**
146
+ * Effective limit and where it came from: project `.codex/config.toml`, then
147
+ * `$CODEX_HOME/config.toml` (default `~/.codex`), else the default.
148
+ *
149
+ * @param {string} root
150
+ * @param {NodeJS.ProcessEnv} env
151
+ * @param {string} homeDir
152
+ * @param {(file: string) => string | null} readText
153
+ * @returns {{ limit: number, source: string }}
154
+ */
155
+ function resolveProjectDocLimit(root, env, homeDir, readText) {
156
+ const codexHome = env.CODEX_HOME || path.join(homeDir, '.codex');
157
+ for (const [file, source] of [
158
+ [path.join(root, '.codex', 'config.toml'), '.codex/config.toml'],
159
+ [path.join(codexHome, 'config.toml'), '$CODEX_HOME/config.toml'],
160
+ ]) {
161
+ const limit = readProjectDocMaxBytes(readText(file));
162
+ if (limit !== null) return { limit, source };
163
+ }
164
+ return { limit: CODEX_PROJECT_DOC_MAX_BYTES, source: 'the Codex default' };
165
+ }
166
+
167
+ const HOIST_REMEDY =
168
+ 'Move the `## System Prompt` block to the top of the file, or run `mandrel update` (its 2.84.0 migration moves it).';
169
+
170
+ /**
171
+ * Does Codex load the Mandrel block? Sizes the root `AGENTS.override.md`, else
172
+ * `AGENTS.md`, against the effective `project_doc_max_bytes`. Fails when the
173
+ * block (import through read directive) does not end inside the limit, or
174
+ * carries no directive Codex can follow; an oversized file whose block still
175
+ * loads passes with an advisory. No entry doc at all skips, as
176
+ * `claude-code-version` does.
177
+ *
178
+ * @param {{
179
+ * projectRoot?: string,
180
+ * cwd?: () => string,
181
+ * env?: NodeJS.ProcessEnv,
182
+ * homeDir?: string,
183
+ * readText?: (file: string) => string | null,
184
+ * }} [opts]
185
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
186
+ */
187
+ export function runCodexInstructions({
188
+ projectRoot,
189
+ cwd,
190
+ env = process.env,
191
+ homeDir = os.homedir(),
192
+ readText = readTextOrNull,
193
+ } = {}) {
194
+ const root = projectRoot ?? (cwd ?? (() => process.cwd()))();
195
+ const { limit, source } = resolveProjectDocLimit(
196
+ root,
197
+ env,
198
+ homeDir,
199
+ readText,
200
+ );
201
+ const override = readText(path.join(root, 'AGENTS.override.md'));
202
+ const docName = override === null ? 'AGENTS.md' : 'AGENTS.override.md';
203
+ const text = override ?? readText(path.join(root, 'AGENTS.md'));
204
+ if (text === null) {
205
+ return { ok: true, detail: 'skipped: no AGENTS.md' };
206
+ }
207
+ const importAt = text.indexOf(SYSTEM_PROMPT_IMPORT);
208
+ const directiveAt = text.indexOf(SYSTEM_PROMPT_READ_DIRECTIVE);
209
+ if (importAt === -1 || directiveAt === -1) {
210
+ return {
211
+ ok: false,
212
+ detail: `${docName} carries no Mandrel read directive for hosts without @-imports — Codex would not load .agents/instructions.md`,
213
+ remedy: HOIST_REMEDY,
214
+ };
215
+ }
216
+ const bytes = (s) => Buffer.byteLength(s, 'utf8');
217
+ const start = bytes(text.slice(0, Math.min(importAt, directiveAt)));
218
+ const end = bytes(
219
+ text.slice(0, directiveAt + SYSTEM_PROMPT_READ_DIRECTIVE.length),
220
+ );
221
+ const total = bytes(text);
222
+ const limitLabel = `project_doc_max_bytes ${limit} (${source})`;
223
+ if (end > limit) {
224
+ return {
225
+ ok: false,
226
+ detail: `the Mandrel block in ${docName} spans bytes ${start}–${end}, beyond ${limitLabel} — Codex never reads it`,
227
+ remedy: HOIST_REMEDY,
228
+ };
229
+ }
230
+ if (total > limit) {
231
+ return {
232
+ ok: true,
233
+ detail: `${docName} is ${total} bytes, over ${limitLabel}: the Mandrel block (bytes ${start}–${end}) loads, the last ${total - limit} bytes do not — raise project_doc_max_bytes in .codex/config.toml to load them`,
234
+ };
235
+ }
236
+ return {
237
+ ok: true,
238
+ detail: `${docName} is ${total} bytes, within ${limitLabel}; the Mandrel block loads`,
239
+ };
240
+ }
@@ -0,0 +1,79 @@
1
+ // lib/cli/doctor-checks/merge-driver.js — Doctor check: merge-driver.
2
+
3
+ import fs from 'node:fs';
4
+ import {
5
+ BASELINE_MERGE_DRIVER_CONFIG_KEY,
6
+ BASELINE_MERGE_DRIVER_REMEDY,
7
+ parseBaselineMergeDriverCommand,
8
+ probeBaselineMergeDriver,
9
+ } from '../../../.agents/scripts/lib/bootstrap/baseline-merge-driver.js';
10
+ import { spawn } from './spawn.js';
11
+
12
+ // check: merge-driver
13
+
14
+ /**
15
+ * Is this clone's `baselines/*.json` merge driver registered? `.gitattributes`
16
+ * ships with the repo but the driver command is per-clone `git config`, and a
17
+ * missing one silently falls back to a text merge. Skipped when
18
+ * `.gitattributes` does not declare the driver.
19
+ *
20
+ * @param {{cwd?: () => string, fsImpl?: typeof fs, runner?: typeof spawn}} [opts]
21
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
22
+ */
23
+ export function runMergeDriver({ cwd, fsImpl = fs, runner = spawn } = {}) {
24
+ const projectRoot = (cwd ?? (() => process.cwd()))();
25
+ // Git runs from projectRoot: the config key is per-clone.
26
+ const { declared, command } = probeBaselineMergeDriver({
27
+ projectRoot,
28
+ fsImpl,
29
+ runGit: (args) => runner('git', args, { cwd: projectRoot }),
30
+ });
31
+ if (!declared) {
32
+ return {
33
+ ok: true,
34
+ detail:
35
+ 'skipped — .gitattributes does not route baselines/*.json through the mandrel merge driver',
36
+ };
37
+ }
38
+ if (command === '') {
39
+ return {
40
+ ok: false,
41
+ detail: `${BASELINE_MERGE_DRIVER_CONFIG_KEY} is unset — baselines/*.json will fall back to git's text merge, which conflicts on adjacent rows and can splice rows neither branch scored`,
42
+ remedy: BASELINE_MERGE_DRIVER_REMEDY,
43
+ };
44
+ }
45
+ return probeConfiguredDriver(command, runner, projectRoot);
46
+ }
47
+
48
+ /**
49
+ * Execute the configured driver with `--help` (the real invocation mutates
50
+ * `%A`): a set-but-broken command — typically an absolute node path moved by
51
+ * an nvm/volta bump — fails as silently as an unset key. The command is
52
+ * tokenised, never shell-run, since a config value must not become arbitrary
53
+ * command execution. Runs from projectRoot, where git invokes drivers.
54
+ *
55
+ * @param {string} command
56
+ * @param {typeof spawn} runner
57
+ * @param {string} projectRoot
58
+ * @returns {{ ok: boolean, detail: string, remedy?: string }}
59
+ */
60
+ function probeConfiguredDriver(command, runner, projectRoot) {
61
+ const parsed = parseBaselineMergeDriverCommand(command);
62
+ if (!parsed) {
63
+ return {
64
+ ok: false,
65
+ detail: `${BASELINE_MERGE_DRIVER_CONFIG_KEY} is set to ${JSON.stringify(command)}, which has no runnable command in it`,
66
+ remedy: BASELINE_MERGE_DRIVER_REMEDY,
67
+ };
68
+ }
69
+ const probe = runner(parsed.file, [...parsed.args, '--help'], {
70
+ cwd: projectRoot,
71
+ });
72
+ if (probe.status === 0) return { ok: true, detail: command };
73
+ const why = probe.error?.message ?? `exit ${probe.status}`;
74
+ return {
75
+ ok: false,
76
+ detail: `${BASELINE_MERGE_DRIVER_CONFIG_KEY} is set to ${JSON.stringify(command)} but running it failed (${why}) — git would fall back to text-merging baselines/*.json exactly as if the key were unset`,
77
+ remedy: BASELINE_MERGE_DRIVER_REMEDY,
78
+ };
79
+ }