mandrel 2.79.0 → 2.81.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 (55) hide show
  1. package/.agents/agents/auditor.md +8 -3
  2. package/.agents/audit-checklists/data-model.md +9 -1
  3. package/.agents/audit-checklists/security.md +15 -1
  4. package/.agents/docs/agentrc-reference.json +4 -0
  5. package/.agents/docs/configuration.md +4 -3
  6. package/.agents/docs/execution-reference.md +25 -5
  7. package/.agents/docs/workflows.md +2 -2
  8. package/.agents/schemas/agentrc.schema.json +31 -3
  9. package/.agents/schemas/audit-rules.json +15 -2
  10. package/.agents/scripts/deliver-run.js +43 -8
  11. package/.agents/scripts/lib/audit-to-stories/seed-from-findings.js +37 -2
  12. package/.agents/scripts/lib/baselines/duplication-scanner.js +7 -1
  13. package/.agents/scripts/lib/baselines/refresh-service.js +6 -0
  14. package/.agents/scripts/lib/cli-args.js +16 -2
  15. package/.agents/scripts/lib/config/explain.js +1 -1
  16. package/.agents/scripts/lib/config/gates/duplication.schema.js +10 -2
  17. package/.agents/scripts/lib/config-settings-schema.js +18 -1
  18. package/.agents/scripts/lib/findings/audit-finding-record.js +95 -0
  19. package/.agents/scripts/lib/findings/route-finding.js +4 -3
  20. package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
  21. package/.agents/scripts/lib/observability/close-telemetry.js +17 -2
  22. package/.agents/scripts/lib/orchestration/complexity-gate.js +58 -11
  23. package/.agents/scripts/lib/orchestration/plan-persist/audit-attribution.js +182 -0
  24. package/.agents/scripts/lib/orchestration/plan-persist/audit-provenance.js +11 -10
  25. package/.agents/scripts/lib/orchestration/plan-persist/collision-message.js +52 -0
  26. package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +56 -9
  27. package/.agents/scripts/lib/orchestration/plan-persist/source-rewrite.js +177 -0
  28. package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +202 -57
  29. package/.agents/scripts/lib/orchestration/plan-persist/supersede-ops.js +57 -15
  30. package/.agents/scripts/lib/orchestration/plan-persist/wave-collision-gate.js +8 -4
  31. package/.agents/scripts/lib/orchestration/plan-persist/wave-serialisation.js +3 -2
  32. package/.agents/scripts/lib/orchestration/resolve-stories.js +12 -3
  33. package/.agents/scripts/lib/orchestration/resume-effort.js +121 -0
  34. package/.agents/scripts/lib/orchestration/single-story-close/phases/options.js +13 -2
  35. package/.agents/scripts/lib/orchestration/single-story-close/runner.js +10 -2
  36. package/.agents/scripts/lib/orchestration/ticketing/reads.js +3 -0
  37. package/.agents/scripts/lib/qa/resolve-qa-contract.js +28 -9
  38. package/.agents/scripts/lib/templates/decomposer-prompts.js +2 -2
  39. package/.agents/scripts/lib/wave-runner/footprint.js +114 -17
  40. package/.agents/scripts/lib/wave-runner/ready-set.js +16 -5
  41. package/.agents/scripts/plan-persist.js +20 -6
  42. package/.agents/scripts/providers/github/tickets.js +2 -1
  43. package/.agents/scripts/resolve-stories.js +8 -2
  44. package/.agents/scripts/single-story-close.js +11 -3
  45. package/.agents/workflows/audit-data-model.md +94 -10
  46. package/.agents/workflows/audit-security.md +136 -49
  47. package/.agents/workflows/audit-to-stories.md +22 -7
  48. package/.agents/workflows/helpers/audit-lens-core.md +8 -5
  49. package/.agents/workflows/helpers/deliver-reference.md +7 -2
  50. package/.agents/workflows/helpers/deliver-story.md +5 -3
  51. package/.agents/workflows/helpers/plan-reference.md +53 -5
  52. package/.agents/workflows/mandrel-deliver.md +9 -4
  53. package/.agents/workflows/mandrel-plan.md +7 -1
  54. package/docs/CHANGELOG.md +25 -0
  55. package/package.json +2 -1
@@ -238,7 +238,14 @@ work this plan already tracked.
238
238
  | --- | --- |
239
239
  | Present | **Exactly** the identities listed — siblings' groups never leak in. |
240
240
  | Present but empty (`{}`) | Nothing. "Owns no findings" is a real answer. |
241
- | **Absent** | The **whole seed's** footers (the union) — the recall-safe default. |
241
+ | **Absent**, N>1 plan, seed carries `audit-finding` records | The findings whose files this Story's `changes[]` covers (exact path or glob; the primary file first, the others only when no Story covers it), plus every **unattributed** finding. |
242
+ | **Absent**, otherwise (N==1, or a record-less seed) | The **whole seed's** footers (the union) — the recall-safe default. |
243
+
244
+ An unattributed finding — one no Story owns by `provenance` or by path — is
245
+ stamped on every Story without an authored `provenance` and listed in
246
+ persist's warnings (`unattributed audit finding <sha12> (<file>) — carried on
247
+ all N Stories`). `audit::*` labels follow the stamped findings under
248
+ attribution, and the seed union otherwise.
242
249
 
243
250
  **The union fallback is load-bearing, not legacy** — hand-carrying provenance
244
251
  out of the seed's HTML comments is a step an author forgets. Attribution is
@@ -251,8 +258,9 @@ owning Story has **closed** is masked by an open neighbour. With ownership
251
258
  stamped, the issue carrying a finding's own fingerprint decides both the match
252
259
  and its state (`lib/findings/route-finding.js`).
253
260
 
254
- The audit path authors this mechanically from the per-group footers the seed
255
- already carries — see [`audit-to-stories`](../audit-to-stories.md). A `--seed`
261
+ The audit path attributes mechanically from the per-finding `audit-finding`
262
+ records the seed carries beside its per-group footers — see
263
+ [`audit-to-stories`](../audit-to-stories.md). A `--seed`
256
264
  or `--tickets` plan has nothing to attribute and omits the field.
257
265
 
258
266
  ## Cross-Story conflict analysis at persist
@@ -546,10 +554,50 @@ Whichever channel supplies them, the supersede-map partition above still
546
554
  fail-closes: a `--tickets` run whose Stories forgot `supersedes[]` is
547
555
  **caught** (`source ticket #N is not claimed by any Story`).
548
556
 
557
+ ## Rewriting a one-for-one source in place
558
+
559
+ When a tickets-mode plan is **one-for-one** — exactly one source ticket and
560
+ exactly one drafted Story — persist rewrites that ticket instead of filing a
561
+ new Story and closing the source as its duplicate. The issue number, its
562
+ comment history and its non-`agent::*` labels survive. This is the default.
563
+ Gate #2 still asks, so the operator can choose either way:
564
+
565
+ | Choice | What persist does |
566
+ | --- | --- |
567
+ | **Rewrite #N in place** (Recommended) | No flag — the default. |
568
+ | **File a new Story and close #N** | `--no-rewrite-source` |
569
+
570
+ Under `--yes` the question is skipped and the default applies.
571
+
572
+ **The write order** keeps "`agent::ready` means fully persisted" true even
573
+ for a source that was already `agent::ready`:
574
+
575
+ 1. If the source carries no `plan-rewrite` comment, post one holding its
576
+ original title and body in a collapsed block. **First write wins** — a
577
+ later re-plan never replaces it, so the pre-plan evidence survives.
578
+ 2. One PATCH sets the new title and body (with the plan fingerprint, so a
579
+ retried persist adopts the rewritten issue instead of duplicating it),
580
+ adds the Story's labels and this run's `plan-run::` label, and removes
581
+ every `agent::*` label and any earlier run's `plan-run::` label.
582
+ 3. The `story-plan-state` comment, then the terminal `agent::ready` flip.
583
+
584
+ The supersede phase lists the rewritten id under `supersede.rewritten` and
585
+ neither comments on nor closes it; the result's `rewrite` field names the
586
+ ticket or why there was none.
587
+
588
+ **Falls back to create-and-close** with no warning for any other shape
589
+ (several sources, several Stories), under `--no-rewrite-source`, and under
590
+ `--no-close-superseded` — that flag means the remainder of the source must
591
+ stay open as itself, which a rewrite would destroy. It **falls back with a
592
+ warning** naming the reason when the source is closed, inaccessible, a
593
+ `type::epic` container, or mid-delivery (`agent::executing`,
594
+ `agent::closing`, or `agent::blocked` — a paused delivery still owns its
595
+ branch and PR).
596
+
549
597
  ## Closing superseded source tickets
550
598
 
551
- **Default on.** After the Stories exist, persist comments on each source
552
- issue naming the specific Story that claims it — plus that Story's optional
599
+ **Default on** for every source not rewritten in place (above). After the
600
+ Stories exist, persist comments on each source issue naming the specific Story that claims it — plus that Story's optional
553
601
  per-supersede `note` — and closes it with reason **`duplicate`**
554
602
  (`state_reason`): the claiming Story carries the work, and nothing has
555
603
  shipped at persist time, so `completed` would be a lie. A provider that
@@ -32,7 +32,7 @@ you read:
32
32
  | Invocation | Shape | Behavior |
33
33
  | --- | --- | --- |
34
34
  | `/mandrel-deliver` | bare | List the open `agent::ready` Stories and ask which to deliver. Deliver nothing until answered. |
35
- | `/mandrel-deliver 4712` | ids | One Story via `helpers/deliver-story.md`, **inline in this session** — no `story-worker` spawn. |
35
+ | `/mandrel-deliver 4712` | ids | One Story via `helpers/deliver-story.md`, **inline in this session** — no `story-worker` spawn. A resume of a Story that blocked before dispatches one worker instead (step 3). |
36
36
  | `/mandrel-deliver 4712 4713 …` | ids | Resolve the set, then beat `deliver-run.js` — it sequences by the discovered graph and hands back the spawns and closes. |
37
37
  | `/mandrel-deliver 4712 - 4716` | ids | A **range** — every id in the inclusive span. |
38
38
  | `/mandrel-deliver 4700` (a `type::epic`) | ids | The Epic's **open** child Stories. Mixes with Story ids. |
@@ -70,7 +70,9 @@ to an attended run.
70
70
  present the order in step 2, but do **not** thread them into step 3 — every
71
71
  beat re-resolves the graph. A one-id run comes back `dispatchMode: "inline"`
72
72
  and runs [`helpers/deliver-story.md`](helpers/deliver-story.md) in this
73
- session; step 3 is the multi-Story path. An Epic id expands to its open child
73
+ session; step 3 is the multi-Story path. A one-id run that comes back
74
+ `dispatchMode: "subagent"` is a resume of a Story that blocked before: take
75
+ step 3 with that one id, so its worker can carry the resume effort. An Epic id expands to its open child
74
76
  Stories first — **announce it**. It hard-errors (exit 1) on an id that is
75
77
  neither a Story nor an Epic, on an Epic with no open children, or on edges
76
78
  it cannot read — a missing gate would co-dispatch against an unlanded
@@ -96,8 +98,11 @@ to an attended run.
96
98
  maintained across beats by you**. Cross-run de-confliction via the assignee
97
99
  lease is automatic. Branch on the exit code:
98
100
  - **0** — spawn one `story-worker` per `ready[]` entry, **all in one turn**,
99
- each with that entry's `promptPath` file as its prompt; run each `close[]`
100
- entry's command foreground and serialized as hand-offs arrive. An empty
101
+ each with that entry's `promptPath` file as its prompt. When the entry's
102
+ `effort` is non-null, pass it as that Agent call's `effort`; when it is
103
+ `null`, omit the parameter so the worker inherits the session. Run each
104
+ `close[]` entry's command foreground and serialized as hand-offs arrive.
105
+ An empty
101
106
  `ready` with work in flight means "waiting", so beat again — **unless
102
107
  `stalledDispatch[]` is non-empty**: those ids were dispatched but still
103
108
  read `agent::ready`, which is a live init window the first beats or two
@@ -121,6 +121,11 @@ than one Story** (a split always earns operator eyes, `--force-review` or
121
121
  not), or when the operator asked to review (`--force-review`).
122
122
  Under `--yes`, auto-proceed.
123
123
 
124
+ **One-for-one (tickets mode, one source → one Story)** — ask with
125
+ AskUserQuestion: **Rewrite #N in place (Recommended)** or **File a new Story
126
+ and close #N** (`--no-rewrite-source`). Under `--yes`, rewrite
127
+ ([ref](helpers/plan-reference.md)).
128
+
124
129
  **Gate #3 — adopt, else create.** Offer the top `epicCandidates[]` Epic at
125
130
  **any N** (`--epic <id>`); else, at **N>2**, a new container (`--epic-title` /
126
131
  `--epic-goal`). Never unasked ([ref](helpers/plan-reference.md)).
@@ -151,7 +156,8 @@ Persist creates `type::story` issue(s), a **metadata-only** `plan-run::<id>`
151
156
  label, `blocked by #<id>` footers for every `depends_on` edge, and on a Gate #3
152
157
  yes links them under a `type::epic` container (adopted or new). `agent::ready`
153
158
  is the **terminal** flip after receipts land; stdout is pure JSON. Tickets mode
154
- also comments on and closes each source id ([ref](helpers/plan-reference.md)).
159
+ rewrites a one-for-one source in place, else comments on and closes each
160
+ source id ([ref](helpers/plan-reference.md)).
155
161
 
156
162
  ## Constraints
157
163
 
package/docs/CHANGELOG.md CHANGED
@@ -15,6 +15,31 @@ 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.81.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.80.0...mandrel-v2.81.0) (2026-10-11)
19
+
20
+
21
+ ### Added
22
+
23
+ * /mandrel-plan rewrites a one-for-one source ticket in place instead of filing a new Story ([#5604](https://github.com/dsj1984/mandrel/issues/5604)) ([#5610](https://github.com/dsj1984/mandrel/issues/5610)) ([5e0f621](https://github.com/dsj1984/mandrel/commit/5e0f6215680ee9d9fec079a93fd51d531d59023a))
24
+ * agent cost report: per-subagent effort, model, tokens and wall time from Claude Code transcripts ([#5607](https://github.com/dsj1984/mandrel/issues/5607)) ([#5611](https://github.com/dsj1984/mandrel/issues/5611)) ([c1680ca](https://github.com/dsj1984/mandrel/commit/c1680ca12298e21a51d8000437a675fb94bd23f2))
25
+ * audit-security: trust-boundary attack classes, a Boundary candidate-gate field, and lens-specific severity anchors (adapted from Cloudflare's MIT security-audit skill) ([#5606](https://github.com/dsj1984/mandrel/issues/5606)) ([#5612](https://github.com/dsj1984/mandrel/issues/5612)) ([34dc807](https://github.com/dsj1984/mandrel/commit/34dc8077f7d2392385355519180d6f0122f27770))
26
+ * duplication gate now scans TS/TSX/JSX; re-seat via duplication:reanchor ([#5605](https://github.com/dsj1984/mandrel/issues/5605)) ([#5609](https://github.com/dsj1984/mandrel/issues/5609)) ([5f73168](https://github.com/dsj1984/mandrel/commit/5f731680c4c16aa1ba11b1d2f02032af931ea5aa))
27
+ * escalate effort per call on a blocked-Story resume instead of raising whole-session effort ([#5608](https://github.com/dsj1984/mandrel/issues/5608)) ([#5617](https://github.com/dsj1984/mandrel/issues/5617)) ([4285cdf](https://github.com/dsj1984/mandrel/commit/4285cdf55b057723f60dbe17808c23e421f645d7))
28
+
29
+
30
+ ### Fixed
31
+
32
+ * **test:** attribute temp-paths leak writes by nonce, not stream growth (refs [#5615](https://github.com/dsj1984/mandrel/issues/5615)) ([#5616](https://github.com/dsj1984/mandrel/issues/5616)) ([0f33cec](https://github.com/dsj1984/mandrel/commit/0f33cecfe4db122074d79516b2d0c70c3e92bd0f))
33
+
34
+ ## [2.80.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.79.0...mandrel-v2.80.0) (2026-10-09)
35
+
36
+
37
+ ### Added
38
+
39
+ * audit-data-model: Dead Schema dimension and opt-in read-only live-schema verification pass ([#5594](https://github.com/dsj1984/mandrel/issues/5594)) ([#5595](https://github.com/dsj1984/mandrel/issues/5595)) ([3738dbe](https://github.com/dsj1984/mandrel/commit/3738dbe4af5bb7d71b97701684433d1feb13b839))
40
+ * audit-seeded N&gt;1 plans: attribute each finding's footers and audit:: label to the Stories that cover it ([#5597](https://github.com/dsj1984/mandrel/issues/5597)) ([#5600](https://github.com/dsj1984/mandrel/issues/5600)) ([a8529be](https://github.com/dsj1984/mandrel/commit/a8529bee4f51771677d646275081df6deb3a6543))
41
+ * collision predicate: a glob collides only with paths it can cover, and the message names the declarer ([#5596](https://github.com/dsj1984/mandrel/issues/5596)) ([#5599](https://github.com/dsj1984/mandrel/issues/5599)) ([dfea48c](https://github.com/dsj1984/mandrel/commit/dfea48caf755577e625002bb6873e2d54291e045))
42
+
18
43
  ## [2.79.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.78.0...mandrel-v2.79.0) (2026-10-09)
19
44
 
20
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mandrel",
3
- "version": "2.79.0",
3
+ "version": "2.81.0",
4
4
  "description": "Claude Code-first opinionated workflow framework: instructions, skills, rules, and SDLC workflows that govern AI coding assistants.",
5
5
  "files": [
6
6
  ".agents/",
@@ -21,6 +21,7 @@
21
21
  "test:integration": "node .agents/scripts/run-tests.js --tier integration",
22
22
  "test:e2e": "node .agents/scripts/run-tests.js --tier e2e",
23
23
  "test:profile": "node scripts/run-test-profile.js",
24
+ "report:agent-cost": "node scripts/agent-cost-report.js",
24
25
  "test:census": "SPAWN_CENSUS_OUT=\"${SPAWN_CENSUS_OUT:-temp/census.json}\" NODE_OPTIONS=\"--require $PWD/tests/fixtures/spawn-census.cjs\" node .agents/scripts/run-tests.js",
25
26
  "test:isolate": "node scripts/test-isolate.js",
26
27
  "verify": "node scripts/run-verify.js",