mandrel 2.6.0 → 2.8.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 (78) hide show
  1. package/.agents/README.md +104 -330
  2. package/.agents/agents/auditor.md +135 -0
  3. package/.agents/agents/plan-critic.md +80 -0
  4. package/.agents/audit-checklists/dependencies.md +7 -0
  5. package/.agents/audit-checklists/documentation.md +1 -0
  6. package/.agents/docs/SDLC.md +69 -162
  7. package/.agents/docs/configuration.md +133 -499
  8. package/.agents/docs/quality-gates.md +59 -180
  9. package/.agents/instructions.md +170 -295
  10. package/.agents/rules/changelog-style.md +8 -66
  11. package/.agents/rules/ci-remediation.md +65 -124
  12. package/.agents/rules/gherkin-standards.md +10 -31
  13. package/.agents/rules/git-conventions-reference.md +28 -61
  14. package/.agents/rules/git-conventions.md +1 -1
  15. package/.agents/rules/orchestration-error-handling.md +5 -15
  16. package/.agents/rules/security-baseline.md +7 -13
  17. package/.agents/rules/shell-conventions.md +4 -13
  18. package/.agents/rules/test-seams.md +2 -2
  19. package/.agents/rules/testing-standards.md +7 -17
  20. package/.agents/scripts/lib/feedback-loop/audit-results-graduator.js +7 -2
  21. package/.agents/scripts/lib/feedback-loop/graduator-core.js +144 -12
  22. package/.agents/scripts/lib/feedback-loop/retro-proposals-graduator.js +11 -1
  23. package/.agents/scripts/lib/observability/runtime-friction.js +97 -36
  24. package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +29 -5
  25. package/.agents/skills/core/api-and-interface-design/SKILL.md +23 -297
  26. package/.agents/skills/core/api-and-interface-design/reference.md +76 -0
  27. package/.agents/skills/core/browser-testing-with-devtools/SKILL.md +20 -327
  28. package/.agents/skills/core/browser-testing-with-devtools/reference.md +74 -0
  29. package/.agents/skills/core/code-review-and-quality/reference.md +16 -398
  30. package/.agents/skills/core/debugging-and-error-recovery/reference.md +14 -281
  31. package/.agents/skills/core/documentation-and-adrs/reference.md +42 -338
  32. package/.agents/skills/core/git-workflow-and-versioning/SKILL.md +28 -326
  33. package/.agents/skills/core/idea-refinement/SKILL.md +67 -193
  34. package/.agents/skills/core/security-and-hardening/SKILL.md +15 -31
  35. package/.agents/skills/core/security-and-hardening/reference.md +15 -273
  36. package/.agents/skills/skills.index.json +5 -5
  37. package/.agents/skills/stack/qa/gherkin-authoring/SKILL.md +16 -222
  38. package/.agents/skills/stack/qa/gherkin-authoring/reference.md +157 -0
  39. package/.agents/skills/stack/qa/playwright/SKILL.md +0 -29
  40. package/.agents/skills/stack/qa/qa-explore-driving/SKILL.md +19 -23
  41. package/.agents/skills/stack/qa/qa-harness/SKILL.md +35 -53
  42. package/.agents/skills/stack/qa/vitest/SKILL.md +0 -29
  43. package/.agents/workflows/audit-accessibility.md +34 -108
  44. package/.agents/workflows/audit-architecture.md +35 -123
  45. package/.agents/workflows/audit-clean-code.md +19 -78
  46. package/.agents/workflows/audit-data-model.md +32 -100
  47. package/.agents/workflows/audit-dependencies.md +47 -111
  48. package/.agents/workflows/audit-devops.md +16 -83
  49. package/.agents/workflows/audit-documentation.md +46 -93
  50. package/.agents/workflows/audit-navigability.md +26 -80
  51. package/.agents/workflows/audit-performance.md +40 -106
  52. package/.agents/workflows/audit-privacy.md +17 -80
  53. package/.agents/workflows/audit-quality.md +35 -99
  54. package/.agents/workflows/audit-security.md +20 -78
  55. package/.agents/workflows/audit-seo.md +20 -98
  56. package/.agents/workflows/audit-sre.md +20 -88
  57. package/.agents/workflows/audit-to-stories.md +1 -8
  58. package/.agents/workflows/audit-ux-ui.md +17 -80
  59. package/.agents/workflows/deliver.md +54 -9
  60. package/.agents/workflows/git-cleanup.md +50 -275
  61. package/.agents/workflows/helpers/audit-lens-core.md +230 -0
  62. package/.agents/workflows/helpers/code-review.md +11 -23
  63. package/.agents/workflows/helpers/deliver-story-reference.md +114 -17
  64. package/.agents/workflows/helpers/deliver-story.md +26 -186
  65. package/.agents/workflows/helpers/qa-core.md +174 -0
  66. package/.agents/workflows/helpers/qa-run-scenario-reference.md +35 -0
  67. package/.agents/workflows/helpers/qa-run-scenario.md +11 -25
  68. package/.agents/workflows/helpers/worktree-lifecycle.md +6 -67
  69. package/.agents/workflows/mandrel-update.md +7 -13
  70. package/.agents/workflows/plan.md +17 -15
  71. package/.agents/workflows/qa-assist.md +140 -269
  72. package/.agents/workflows/qa-explore.md +125 -316
  73. package/.agents/workflows/qa-run.md +180 -380
  74. package/docs/CHANGELOG.md +18 -0
  75. package/package.json +1 -1
  76. package/.agents/workflows/helpers/audit-dual-path.md +0 -59
  77. package/.agents/workflows/helpers/audit-self-check.md +0 -70
  78. package/.agents/workflows/helpers/audit-severity-scale.md +0 -19
@@ -1,73 +1,53 @@
1
1
  # Agent Execution Protocol
2
2
 
3
- You are operating under the Agent Execution Protocol. Your behavior, technical
4
- constraints, and operational context are governed by this central instruction
5
- set. You MUST strictly adhere to the following rules:
3
+ You operate under the Agent Execution Protocol this central instruction set
4
+ governs your behavior, constraints, and operational context, and you MUST
5
+ strictly adhere to it.
6
6
 
7
7
  ---
8
8
 
9
9
  ## 1. System Guardrails & Initialization
10
10
 
11
- ### A. Role Framing (no persona packs)
11
+ ### A. Role Framing
12
12
 
13
- v2 has **no** `.agents/personas/` packs and **no** `persona::*` GitHub labels.
14
13
  Behavioral constraints come from this file, always-on / on-demand rules, and
15
- skills. Role-scoped spawn contexts (when used) live under `.agents/agents/`
16
- via `delivery.routing.roleScopedAgents`. QA auth identities (`qa.personas`)
17
- are a separate fixture concept not agent behavior packs.
18
-
19
- If a user says "act as [role]" in chat, apply the matching skill / workflow
20
- guidance (e.g. QA skills for verification work, security skill for threat
21
- modeling) rather than looking for a persona file.
14
+ skills there are no persona packs and no `persona::*` labels. Role-scoped
15
+ spawn contexts (when used) live under `.agents/agents/` via
16
+ `delivery.routing.roleScopedAgents`; QA auth identities (`qa.personas`) are a
17
+ separate fixture concept. If a user says "act as [role]", apply the matching
18
+ skill / workflow guidance (QA skills for verification, the security skill for
19
+ threat modeling) rather than looking for a persona file.
22
20
 
23
21
  ### B. Skill Activation
24
22
 
25
- The skill library uses a **two-tier architecture**:
26
-
27
- - **`core/`** — Universal, process-driven skills that apply across any project
28
- (e.g., `core/debugging-and-error-recovery`, `core/code-review-and-quality`,
29
- `core/security-and-hardening`). Always check for a relevant core skill first.
30
- The **test-first** discipline (TDD cycle, Prove-It Pattern, good-test style,
31
- property-based technique) lives in
32
- [`rules/testing-standards.md`](rules/testing-standards.md), not a skill.
33
- - **`stack/`** Tech-stack-specific skills for concrete tools (e.g.,
34
- `stack/qa/playwright`, `stack/qa/vitest`, `stack/qa/gherkin-authoring`).
35
- Apply these when the project uses that specific technology. For third-party
36
- library and framework knowledge not covered here, use the live-docs lookup
37
- mandated in § 1.C rather than a frozen in-repo cache.
38
-
39
- When a task involves a specific domain or technology, you MUST read the
40
- corresponding `.agents/skills/[tier]/[category]/[skill-name]/SKILL.md` file and
41
- apply its constraints. A `SKILL.md` leads with its **Policy Capsule** the
42
- contract, and the whole cost of activating the skill — followed by pointers
43
- into an on-demand `reference.md` sibling holding the long-form material
44
- (patterns, worked examples, checklists). This is the same split the always-on
45
- rules use (§ 1.F): read the capsule on activation, and open a `reference.md`
46
- section only when the task actually engages it. Review the skill's `examples/`
47
- directory or `examples.md` sibling **when present and relevant** to the task —
48
- most skills do not ship one, so do not probe blindly. When uncertain which skill applies,
49
- match the task against the one-line `description` in each skill's frontmatter
50
- (catalogued in `.agents/skills/skills.index.json`). Skills compose: a complete
51
- feature typically flows `idea-refinement` → the `/plan` workflow →
52
- implementation test-first (`rules/testing-standards.md`) →
53
- `code-review-and-quality` — not every task needs every skill. The always-on
54
- operating posture (surface assumptions, manage confusion, push back on flawed
55
- approaches, verify don't assume) is governed by § 3–4 and § 1.I of this file.
23
+ The skill library is **two-tier**: **`core/`** — universal, process-driven
24
+ skills (`core/debugging-and-error-recovery`, `core/code-review-and-quality`,
25
+ `core/security-and-hardening`); check for one first (the **test-first**
26
+ discipline lives in [`rules/testing-standards.md`](rules/testing-standards.md),
27
+ not a skill). **`stack/`** tech-stack-specific skills (`stack/qa/playwright`,
28
+ `stack/qa/vitest`); apply when the project uses that technology, else use the
29
+ § 1.C live-docs lookup.
30
+
31
+ When a task engages a domain or technology, you MUST read the corresponding
32
+ `.agents/skills/[tier]/[category]/[skill-name]/SKILL.md` and apply its
33
+ constraints the **Policy Capsule** (the whole cost of activation) on
34
+ engagement, a `reference.md` section or `examples/` only when the task needs it
35
+ (§ 1.F's read-when-relevant split). When unsure which applies, match the task
36
+ against the one-line `description` in each skill's frontmatter (catalogued in
37
+ `.agents/skills/skills.index.json`). Skills compose (`idea-refinement`
38
+ `/plan` → test-first implementation → `code-review-and-quality`); not every
39
+ task needs every skill. The always-on operating posture is governed by § 3–4
40
+ and § 1.I.
56
41
 
57
42
  ### C. Proactive Documentation
58
43
 
59
- You MUST use the host's best available live-documentation mechanism
60
- proactively to prevent hallucination for example a docs MCP server such as
61
- Context7 when the host has it wired in, an IDE-native docs lookup, or any
62
- equivalent live-docs surface the host exposes.
63
-
64
- - **Mandatory Usage:** For any code generation, project setup, or complex
65
- configuration involving third-party libraries, fetch the latest official
66
- documentation **before** writing code. Do not ask for permission.
67
- - **Fallback Order:** If no live-docs mechanism is available, fall back to (1)
68
- in-repo docs and the package's bundled `README.md`/`CHANGELOG.md`, then
69
- (2) the host's web fetch/search tool. Note in your work log which channel
70
- you used so reviewers can spot stale references.
44
+ You MUST use the host's best live-documentation mechanism (a docs MCP server
45
+ such as Context7, an IDE-native lookup, or equivalent) proactively to prevent
46
+ hallucination: for any code involving third-party libraries, fetch the latest
47
+ official docs **before** writing code — do not ask permission. If none exists,
48
+ fall back to (1) in-repo docs and the package's bundled `README.md` /
49
+ `CHANGELOG.md`, then (2) the host's web fetch/search; note which channel you
50
+ used so reviewers can spot stale references.
71
51
 
72
52
  ### D. Error Handling & Degradation
73
53
 
@@ -87,136 +67,97 @@ directly — there is no separate state-mutation MCP server to degrade from.
87
67
 
88
68
  ### E. Local Overrides
89
69
 
90
- If a `.agents/instructions.local.md` file or `.agentrc.local.json` is present,
91
- you MUST load them. They contain personal developer preferences and
92
- environment variables that override project defaults. The config resolver
93
- deep-merges `.agentrc.local.json` over `.agentrc.json` (local wins; absent
94
- local file is a no-op). Do not modify these local files unless requested.
95
-
96
- **Durable slash commands.** Any `.md` file placed at
97
- `.agents/local/workflows/<name>.md` is automatically projected into
98
- `.claude/commands/<name>.md` by `sync-claude-commands.js`, making it
99
- invocable as `/<name>`. Because the entire `.agents/local/` subtree is
100
- exempt from `mandrel sync`'s prune pass, these commands survive
101
- `npm install`, `mandrel sync`, and `mandrel update` with no manual
102
- re-sync. Core payload commands of the same basename always win (the
103
- local copy is ignored with a `shadowed` warning).
70
+ If a `.agents/instructions.local.md` or `.agentrc.local.json` is present, you
71
+ MUST load it the config resolver deep-merges `.agentrc.local.json` over
72
+ `.agentrc.json` (local wins; absent is a no-op). Do not modify these files
73
+ unless requested.
74
+
75
+ **Durable slash commands.** Any `.md` at `.agents/local/workflows/<name>.md` is
76
+ projected into `.claude/commands/<name>.md` by `sync-claude-commands.js` as
77
+ `/<name>`. The `.agents/local/` subtree is exempt from `mandrel sync`'s prune
78
+ pass, so these commands survive `npm install` / `mandrel sync` / `mandrel
79
+ update`; a core payload command of the same basename wins (local ignored with a
80
+ `shadowed` warning).
104
81
 
105
82
  ### F. Modular Global Rules
106
83
 
107
- The `.agents/rules/` directory is split into an **always-on core** and an
108
- **on-demand set** the same read-when-relevant pattern skills use 1.B).
109
- The core loads into every session; the on-demand rules are read only when the
110
- task actually engages them, so a generic task (and every subagent it spawns)
111
- does not re-pay their bytes on every turn.
112
-
113
- - **Always-on core** (loaded alongside this file):
114
- - [`rules/security-baseline.md`](rules/security-baseline.md) inviolable
115
- security MUSTs; applies to every piece of code generated.
116
- - [`rules/git-conventions.md`](rules/git-conventions.md) — the always-on git
117
- core (branch shapes, commit-subject format, `refs #`, push/hygiene MUSTs);
118
- every commit, branch, and PR touches it.
119
-
120
- - **On-demand** read the file **before** doing the matching work; each opens
121
- with a one-line "this rule applies when…" scope header, so skimming its first
122
- paragraph confirms whether it governs the task at hand:
123
- - [`rules/git-conventions-reference.md`](rules/git-conventions-reference.md)
124
- — the git-history mechanics the core summarizes: hard-cutover policy, the
125
- push-hook false-negative signature, shared-checkout contention, the
126
- docs-freshness gate, and `meta::*` routing labels.
127
- - [`rules/shell-conventions.md`](rules/shell-conventions.md) — before
128
- chaining shell commands or writing cross-platform command strings.
129
- - [`rules/testing-standards.md`](rules/testing-standards.md) — before
130
- authoring or restructuring tests (the three-tier pyramid, assertion
131
- placement, mocking/isolation MUSTs).
132
- - [`rules/orchestration-error-handling.md`](rules/orchestration-error-handling.md)
133
- before writing or modifying orchestration scripts under
134
- `.agents/scripts/**`.
135
- - [`rules/ci-remediation.md`](rules/ci-remediation.md) — before remediating
136
- a red (or repeatedly slow) CI check during delivery (the root-cause-only
137
- triage decision tree, the never-rerun / never-quarantine prohibitions,
138
- and the escalation criteria).
139
- - [`rules/api-conventions.md`](rules/api-conventions.md),
140
- [`rules/gherkin-standards.md`](rules/gherkin-standards.md),
141
- [`rules/changelog-style.md`](rules/changelog-style.md),
142
- [`rules/test-seams.md`](rules/test-seams.md) — when the task is in that
143
- domain (API surface, Gherkin scenarios, changelog prose, test seams).
144
-
145
- When in doubt, read the rule — the read is cheap relative to shipping a
146
- MUST-violating change. Precedence between a rule and any other governance
147
- document is unchanged (§ 1.K): loading a rule on demand does not lower its
148
- authority.
84
+ `.agents/rules/` splits into an **always-on core** (loaded with this file) and
85
+ an **on-demand set** (read only when the task engages it, so a generic task —
86
+ and every subagent it spawns does not re-pay their bytes), the same
87
+ read-when-relevant pattern skills use (§ 1.B).
88
+
89
+ - **Always-on core**: [`security-baseline.md`](rules/security-baseline.md)
90
+ (inviolable security MUSTs) and
91
+ [`git-conventions.md`](rules/git-conventions.md) (branch shapes,
92
+ commit-subject format, `refs #`, push/hygiene MUSTs).
93
+ - **On-demand**read **before** the matching work; each opens with a one-line
94
+ "this rule applies when…" scope header:
95
+ [`git-conventions-reference.md`](rules/git-conventions-reference.md)
96
+ (git-history mechanics),
97
+ [`shell-conventions.md`](rules/shell-conventions.md) (shell chains,
98
+ cross-platform strings),
99
+ [`testing-standards.md`](rules/testing-standards.md) (authoring or
100
+ restructuring tests),
101
+ [`orchestration-error-handling.md`](rules/orchestration-error-handling.md)
102
+ (scripts under `.agents/scripts/**`),
103
+ [`ci-remediation.md`](rules/ci-remediation.md) (a red or slow CI check), and
104
+ [`api-conventions.md`](rules/api-conventions.md) /
105
+ [`gherkin-standards.md`](rules/gherkin-standards.md) /
106
+ [`changelog-style.md`](rules/changelog-style.md) /
107
+ [`test-seams.md`](rules/test-seams.md) (API, Gherkin, changelog, test-seam
108
+ work).
109
+
110
+ Read the rule when unsure cheaper than shipping a MUST violation; loading it
111
+ on demand does not lower its authority (§ 1.K).
149
112
 
150
113
  ### G. Structured Configuration
151
114
 
152
- Refer to `.agentrc.json` to understand your operational limits (e.g., allowed
153
- auto-run permissions, default personas). For the project's specific
154
- technology choices (database, ORM, API framework, auth provider, validation
155
- library, workspace paths), refer to the project's Tech Stack inventory: a
156
- dedicated `docs/tech-stack.md` when present (the single-ownership convention),
157
- otherwise the **Tech Stack** section of `docs/architecture.md` (a numbered or
158
- decorated heading such as `## 1. Tech Stack` is fine). Project-specific
159
- technology context is intentionally kept out of `.agentrc.json`.
115
+ Refer to `.agentrc.json` for operational limits (auto-run permissions, etc.).
116
+ Project technology choices (database, ORM, API framework, auth, validation,
117
+ paths) are intentionally kept out of it read the Tech Stack inventory:
118
+ `docs/tech-stack.md` when present, otherwise the **Tech Stack** section of
119
+ `docs/architecture.md`.
160
120
 
161
121
  ### H. Observability & Friction Telemetry
162
122
 
163
123
  You MUST log telemetry about operational difficulty or automation
164
- opportunities you hit. Friction is a **local NDJSON signal**:
165
- `diagnose-friction.js` appends one `kind: friction` record to the per-run/
166
- per-Story `signals.ndjson` stream on local disk not posted to the ticket at
167
- capture time; the retro phase surfaces the aggregate as routed proposals.
124
+ opportunities. Friction is a **local NDJSON signal**: `diagnose-friction.js`
125
+ appends a `kind: friction` record to the per-run/per-Story `signals.ndjson`
126
+ stream (not posted to the ticket; the retro phase surfaces the aggregate).
168
127
 
169
128
  - **Command**:
170
129
  `node .agents/scripts/diagnose-friction.js --story [STORY_ID] --cmd [FAILED_COMMAND]`
171
130
  - **When to fire**: after repeated tool-validation errors, an unrecoverable
172
- command failure, ambiguity needing self-correction, or repetitive
173
- boilerplate steps a workflow/skill could simplify.
131
+ command failure, ambiguity needing self-correction, or repetitive boilerplate
132
+ a workflow/skill could simplify.
174
133
 
175
- The schema validation, the standalone stream path, and the
176
- never-silently-dropped guarantee are reference detail — see
177
- [`docs/execution-reference.md` § Friction telemetry](docs/execution-reference.md#friction-telemetry).
178
-
179
- #### Log Level Control
180
-
181
- The orchestrator logger honors `AGENT_LOG_LEVEL` (`silent` / `info` /
182
- `verbose`). The per-level emission table is reference detail — see
183
- [`docs/execution-reference.md` § Log-level control](docs/execution-reference.md#log-level-control).
134
+ Schema, stream path, the never-silently-dropped guarantee, and the
135
+ `AGENT_LOG_LEVEL` (`silent`/`info`/`verbose`) emission table are reference
136
+ detail — see [`docs/execution-reference.md`](docs/execution-reference.md#friction-telemetry).
184
137
 
185
138
  ### I. Anti-Thrashing Protocol
186
139
 
187
140
  You MUST proactively identify when you are "thrashing" or stuck in an
188
141
  infinite loop, and you MUST stop, summarize the blockers, and present a
189
142
  **Re-Plan** (or yield to the user) before consuming more tokens on a failing
190
- strategy. Use the qualitative cues below — there are no numeric thresholds
191
- because none of the framework code increments a counter or fires at a
192
- boundary; the call is yours to make.
193
-
194
- - **Failure cluster**: You have run a handful of tool calls in a row that
195
- returned errors of the same shape. The remediation is the same each time,
196
- and the next attempt is unlikely to surface new information. Stop.
197
- - **Research drift**: You are several steps into reading code or
198
- documentation without writing or modifying anything, and the additional
199
- reads are no longer narrowing the problem space. Stop and propose a plan
200
- with the information you have.
201
- - **Same fix, same failure**: You have applied the same kind of fix more
202
- than once for the same error class, and the failure mode hasn't changed.
203
- Stop the diagnosis is wrong.
204
-
205
- When you stop, write a one-paragraph summary of what you tried, what
206
- recurred, and what assumption you would test next, then either Re-Plan or
207
- hand back to the operator. Do not paper over the loop with another
208
- just-in-case retry.
209
-
210
- While executing as a Story delivery sub-agent (via `helpers/deliver-story`),
211
- if you genuinely cannot proceed you MUST transition to `agent::blocked` and
212
- exit non-zero — **never fall silent**. A stalled child that reports nothing
213
- is indistinguishable from a dead one, and the parent `/deliver` run can only
214
- escalate what you surface.
143
+ strategy. The cues are qualitative — there are no numeric thresholds; the call
144
+ is yours to make.
145
+
146
+ - **Failure cluster** — several tool calls in a row returning same-shape
147
+ errors with the same remediation. Stop.
148
+ - **Research drift** several reads deep with nothing written and the reads no
149
+ longer narrowing the problem. Stop and plan with what you have.
150
+ - **Same fix, same failure** the same kind of fix applied more than once for
151
+ one error class with no change in the failure mode. Stop; the diagnosis is
152
+ wrong.
153
+
154
+ When you stop, summarize in one paragraph what you tried, what recurred, and
155
+ what you would test next, then Re-Plan or hand back do not paper over the
156
+ loop with another just-in-case retry.
215
157
 
216
158
  ### J. HITL Blocker Escalation (Safe Execution)
217
159
 
218
- Before executing any task, you MUST check the ticket labels and instructions
219
- for high-risk operations.
160
+ Before any task, you MUST check the ticket labels for high-risk operations.
220
161
 
221
162
  - **`risk::high` is metadata**: treat it as planning/audit signal only. It
222
163
  does **not** create an automatic runtime pause.
@@ -258,16 +199,11 @@ Two carve-outs refine the ordering:
258
199
 
259
200
  ## 2. FinOps & Token Budgeting (Economic Guardrails)
260
201
 
261
- Mandrel does **not** enforce live LLM spend from response metadata, and it has
262
- no operator-tunable context budget. What it does bound are fixed framework
263
- ceilings — the `/plan` context envelope and plan-time Story sizing — and they
264
- **fail closed** with a message naming what to trim, rather than silently
265
- handing the model a truncated context. Your host runtime owns session quota and
266
- hard stops. The constants, the ≈4-char/token estimate, and the trim options are
267
- reference detail — see
268
- [`docs/execution-reference.md` § FinOps & token budgeting](docs/execution-reference.md#finops--token-budgeting-economic-guardrails).
269
- Consult it when `/plan` refused an over-ceiling envelope or an over-budget
270
- Story count.
202
+ Mandrel does **not** enforce live LLM spend and has no operator-tunable context
203
+ budget; your host runtime owns session quota. It does bound fixed framework
204
+ ceilings — the `/plan` context envelope and plan-time Story sizing — which
205
+ **fail closed** with a message naming what to trim. Constants and trim options:
206
+ [`docs/execution-reference.md`](docs/execution-reference.md#finops--token-budgeting-economic-guardrails).
271
207
 
272
208
  ---
273
209
 
@@ -275,37 +211,16 @@ Story count.
275
211
 
276
212
  1. **Context First:** Before proposing any solution, understand the
277
213
  repository's tech stack, historical context, and structure.
278
- - **Digest-first Reading (Story #4433)** stated once here; it governs
279
- every call site. **Never ingest the whole `project.docsContextFiles` set
280
- up front.** Read the **docs digest** a compact outline (path, byte
281
- size, heading outline with line numbers, and the first paragraph under
282
- each `##`) built from those files decide which docs bear on the task at
283
- hand, then **pull the full file on demand**, jumping to the section at
284
- the line number the digest names. This is a hard cutover: no
285
- read-every-file branch is retained on any path.
286
-
287
- The call sites differ only in how the digest reaches you the
288
- discipline above is identical for all of them:
289
- - `/plan` and interactive tasks — a file at `temp/run-<id>/docs-digest.md`
290
- (`plan-context.js`, via the shared generator in
291
- `.agents/scripts/lib/orchestration/docs-digest.js`).
292
- - `/deliver` Story sub-agents (`helpers/deliver-story`) — the
293
- `docsDigestPath` the caller threads.
294
- - Standalone-Story planning (`story-plan.js --emit-context`) — inline as
295
- `corpusContext.docsDigest` (no per-run directory to anchor a
296
- file), alongside `corpusContext.relevantSections`.
297
-
298
- When no digest exists for the task at hand — an ad hoc task outside
299
- `/deliver`, `project.docsContextFiles` unset, or a null `docsDigestPath` —
300
- there is **no mandatory docs read**: read a full doc only when the task's
301
- own context points you at one.
302
-
303
- The decisions log (`decisions.md`) may be either a single-file
304
- dated-entry log or an **index** into a `decisions/` ADR directory — both
305
- are first-class layouts (see
306
- [`skills/core/documentation-and-adrs`](skills/core/documentation-and-adrs/SKILL.md)).
307
- Treat an index like any other digested doc: link-follow the per-ADR
308
- bodies on demand rather than auto-loading them.
214
+ - **Digest-first Reading (Story #4433).** **Never ingest the whole
215
+ `project.docsContextFiles` set up front.** Read the **docs digest** — a
216
+ compact outline (path, byte size, heading outline with line numbers, and
217
+ the first paragraph under each `##`) decide which docs bear on the task,
218
+ then **pull the full file on demand**, jumping to the section at the line
219
+ number the digest names. This is a hard cutover: no read-every-file branch
220
+ survives. When no digest exists for the task an ad hoc task,
221
+ `project.docsContextFiles` unset, or a null `docsDigestPath` — there is
222
+ **no mandatory docs read**: read a full doc only when the task's own
223
+ context points you at one.
309
224
  - **Conditional Reads**: When the task touches UI copy, layout, or
310
225
  routing and the corresponding file is present in the project, also
311
226
  read `docs/style-guide.md` and `docs/web-routes.md`. Skip both when
@@ -318,17 +233,12 @@ Story count.
318
233
  (semantic code search or focused text search) to isolate specific
319
234
  schemas or decisions before reading broad files.
320
235
  2. **Plan First:** For non-trivial tasks (3+ steps or architectural
321
- decisions), enter **Plan Mode**. Update the Story's `## Spec`
322
- (via `/plan`) or create a new Technical Specification document
323
- in the `docs/` root (if not already handled by a ticket) before
324
- touching code.
325
- 3. **Artifacts over Chat:** Create log files for test results, build
326
- outputs, or debug sessions rather than pasting large code blocks in
327
- chat.
328
- 4. **Idempotency:** Ensure scripts and commands can be run multiple times
329
- without breaking the environment.
330
- 5. **Security First:** Never hardcode secrets. Use environment variables
331
- and validate with secret scanning tools.
236
+ decisions), update the Story's `## Spec` via `/plan` before touching code.
237
+ 3. **Artifacts over Chat:** Write log files for test/build/debug output rather
238
+ than pasting large blocks in chat.
239
+ 4. **Idempotency:** Scripts and commands must be safe to run repeatedly.
240
+ 5. **Security First:** Never hardcode secrets; use environment variables and
241
+ secret scanning.
332
242
 
333
243
  ---
334
244
 
@@ -336,36 +246,25 @@ Story count.
336
246
 
337
247
  - **Re-Plan on Failure:** If a strategy fails, **STOP** and re-plan
338
248
  immediately. Do not repeat a broken approach.
339
- - **Subagent Strategy:** Spawning a subagent is not free each spawn
340
- re-pays the full always-loaded context, so treat it as a cost decision,
341
- not a reflex. Prefer an **inline search** (grep, a targeted read) for
342
- small or localized lookups where you already know roughly where to look;
343
- reach for a subagent **only when the work is large enough to justify
344
- replicating context** a broad multi-file investigation, a parallel
345
- exploration front, or an isolated task that would otherwise crowd the main
346
- context window. One objective per subagent. When the host exposes a
347
- cheaper or faster capability, prefer it for **mechanical or read-only**
348
- spawns (search, doc regeneration, lint, log triage) and keep
349
- **implementation and design** work on the default capability; name no
350
- specific model — let the host and operator own the concrete mapping.
351
- **Depth compounds the cost.** Sub-agents now carry the `Agent` tool and
352
- can nest further (verified depth 2, announced max depth 5; see
353
- [#2870](https://github.com/dsj1984/mandrel/issues/2870)), so this
354
- spend-per-spawn caution is not one-level — **every** nesting level
355
- re-pays the full always-loaded context. Weigh the whole subtree's cost,
356
- not just the immediate spawn, before opening a deeper orchestration
357
- level, and stay within the supported depth envelope.
249
+ - **Subagent Strategy:** Each spawn re-pays the full always-loaded context, so
250
+ treat it as a cost decision. Prefer an **inline search** (grep, a targeted
251
+ read) for small or localized lookups; reach for a subagent **only when the
252
+ work justifies replicating context** a broad multi-file investigation, a
253
+ parallel exploration front, or an isolated task that would crowd the main
254
+ window. One objective per subagent; prefer a cheaper/faster host capability
255
+ for mechanical or read-only spawns and keep implementation/design on the
256
+ default. **Depth compounds the cost** sub-agents carry the `Agent` tool and
257
+ nest further, and **every** level re-pays the context, so weigh the whole
258
+ subtree's cost and stay within the supported depth envelope.
358
259
  - **Anti-Laziness:** NEVER use placeholder comments like
359
260
  `// ... existing code ...`, `/* rest of file */`, or
360
261
  `// implementation here`. You MUST output the ENTIRE file or the ENTIRE
361
262
  complete function so it can be safely written to disk.
362
263
  - **No Dead Code:** Remove unused imports, commented-out code, and dead
363
264
  branches before finalizing a file.
364
- - **Lint Compliance:** Adhere strictly to project linters and formatters.
365
- Language- and stack-specific quality rules (TypeScript strictness,
366
- accessibility scans, framework conventions) live in their respective
367
- `stack/` skills and `.agents/rules/` files — apply them when the relevant
368
- skill is activated.
265
+ - **Lint Compliance:** Adhere strictly to project linters and formatters;
266
+ language/stack-specific quality rules live in their `stack/` skills and
267
+ `.agents/rules/` files apply them when the skill is activated.
369
268
  - **Verification:** Include explicit verification steps in every plan.
370
269
 
371
270
  ---
@@ -377,18 +276,11 @@ strict conventions for all Story-related Git operations. See
377
276
  [`.agents/rules/git-conventions.md`](rules/git-conventions.md) for the full
378
277
  canonical reference.
379
278
 
380
- ### A. Branch Naming (Canonical)
381
-
382
- v2 delivery uses one branch shape. The runtime creates and maintains it
383
- via `single-story-init.js`; agents commit on that branch only.
384
-
385
- | Purpose | Format | Owner | Notes |
386
- | --------------- | ----------------- | ----------------------- | --------------------------------------------------------------------- |
387
- | Story execution | `story-<storyId>` | `single-story-init.js` | Per-Story worktree at `.worktrees/story-<storyId>/`. PR target is `main` (squash + required checks). There is no `epic/<id>` integration branch and no `--no-ff` wave merge. |
279
+ ### A. Branch Naming
388
280
 
389
- - **Verification**: After `single-story-init.js` returns, confirm
390
- `git branch --show-current` reports `story-<storyId>` before making any
391
- commits. If it does not, **STOP** and re-init.
281
+ The canonical branch shape (`story-<storyId>` seeded and maintained by
282
+ `single-story-init.js`, PR to `main`) and the commit-subject contract are
283
+ owned by [`rules/git-conventions.md`](rules/git-conventions.md).
392
284
 
393
285
  ### B. Status Tracking & Commit Standards
394
286
 
@@ -402,66 +294,49 @@ prompted.
402
294
 
403
295
  ### C. History Hygiene
404
296
 
405
- Every Story reaches `main` via its own PR (`story-<id>` → squash + required
406
- checks). `helpers/deliver-story` / `single-story-close.js` open that PR;
407
- there is no Epic integration branch and no in-script push to `main`.
297
+ Every Story reaches `main` via its own PR, opened by `helpers/deliver-story` /
298
+ `single-story-close.js`; the history model is owned by
299
+ [`rules/git-conventions.md`](rules/git-conventions.md).
408
300
 
409
301
  ### D. Ticket hierarchy (Story-only)
410
302
 
411
- v2 collapses the ticket model to **Story**. Acceptance criteria and
412
- verification steps live inline on the Story body (`acceptance[]` /
413
- `verify[]`); the folded Tech Spec lives inline in `## Spec` (over-budget
414
- Specs fail closed split or tighten; never write under `docs/`). Optional
415
- `depends_on` edges order rare multi-Story runs and, because `/deliver`
416
- resolves them from live state, they order Stories **across plan runs and
417
- over time**, not just within one batch.
418
-
419
- - `/plan` emits one or more `type::story` issues (default N=1). There is no
420
- batch label: `/deliver` takes ids and discovers the graph.
421
- - Each Story is executed by `helpers/deliver-story` (invoked from
422
- [`/deliver`](workflows/deliver.md)). There is no per-Task sub-loop; the
423
- agent authors commit subjects directly per
424
- [`rules/git-conventions.md`](rules/git-conventions.md) and references the
425
- Story via `(refs #<storyId>)`.
426
- - Branch model matches Section 5.A (`story-<id>` → PR → `main`).
427
- - There is no `type::epic` / `type::task` label and no Epic issue form. An
428
- Epic is at most an optional untyped human umbrella issue outside
429
- orchestration; `/deliver` refuses tickets that still carry an
430
- `Epic: #N` footer.
303
+ v2 collapses the ticket model to **Story**: acceptance criteria and verify
304
+ steps live inline (`acceptance[]` / `verify[]`) and the folded Tech Spec in
305
+ `## Spec` (over-budget Specs fail closed split or tighten; never write under
306
+ `docs/`). Optional `depends_on` edges order rare multi-Story runs, resolved by
307
+ `/deliver` from live state across plan runs and over time.
308
+
309
+ - `/plan` emits one or more `type::story` issues (default N=1); there is no
310
+ batch label — `/deliver` takes ids and discovers the graph.
311
+ - Each Story is executed by `helpers/deliver-story` (from
312
+ [`/deliver`](workflows/deliver.md)); the agent authors commit subjects
313
+ directly per [`rules/git-conventions.md`](rules/git-conventions.md),
314
+ referencing the Story via `(refs #<storyId>)`.
315
+ - There is no `type::epic` / `type::task` label or Epic issue form; an Epic is
316
+ at most an optional untyped human umbrella issue outside orchestration, and
317
+ `/deliver` refuses tickets carrying an `Epic: #N` footer.
431
318
 
432
319
  ---
433
320
 
434
321
  ## 6. Workspace & File Hygiene (Temporary Files)
435
322
 
436
- To keep the repository clean and avoid polluting the Git history:
437
-
438
- - **Root Temp Directory**: All temporary files, scratch scripts, or
439
- intermediate outputs MUST be stored in the `/temp/` directory located at
440
- the workspace root.
441
- - **Git Exclusion**: The `/temp/` directory is excluded from Git by default.
442
- Do NOT commit any files stored within it.
323
+ All temporary files, scratch scripts, and intermediate outputs MUST live in the
324
+ workspace-root `/temp/` directory, which is gitignored — do NOT commit anything
325
+ under it.
443
326
 
444
327
  ---
445
328
 
446
329
  ## 7. Complexity-Aware Execution
447
330
 
448
- `/plan` sizes each Story as a **capability slice a frontier model delivers
449
- and self-verifies in one pass** — a broad footprint is normal when the
450
- change is cohesive. The session-capacity backstop lives in one place:
451
- `DEFAULT_MODEL_CAPACITY` in
452
- `.agents/scripts/lib/orchestration/ticket-validator-sizing.js` (framework
453
- constant — not operator-tunable). Do not re-slice a capability-sized
454
- Story into per-module fragments just because it touches many files.
331
+ `/plan` sizes each Story as a **capability slice a frontier model delivers and
332
+ self-verifies in one pass** — a broad footprint is normal when the change is
333
+ cohesive (the backstop is `DEFAULT_MODEL_CAPACITY` in `ticket-validator-sizing.js`,
334
+ a framework constant). Do not re-slice a capability-sized Story into per-module
335
+ fragments just because it touches many files.
455
336
 
456
337
  ### A. When You See `⚠️ COMPLEXITY WARNING`
457
338
 
458
- If your task contains a complexity warning or exceeds localized scope:
459
-
460
- 1. **Plan first.** Read the full instructions, then write a numbered list of
461
- cohesive sub-steps in a `<!-- DECOMPOSITION -->` comment block one
462
- coherent change with one reason to exist per sub-step, not one file per
463
- sub-step.
464
- 2. **Commit incrementally.** Stage, commit, and push after each logical
465
- sub-step completes successfully.
466
- 3. **Fail fast.** If any sub-step fails validation, STOP and report the
467
- failure.
339
+ On a complexity warning or out-of-scope task: **plan first** (a numbered list of
340
+ cohesive sub-steps — one coherent change each, not one file each — in a
341
+ `<!-- DECOMPOSITION -->` block), **commit incrementally** after each sub-step,
342
+ and **fail fast** STOP and report if any sub-step fails validation.