baldart 4.99.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.md +1 -0
  3. package/VERSION +1 -1
  4. package/framework/.claude/agents/CHANGELOG.md +105 -0
  5. package/framework/.claude/agents/REGISTRY.md +3 -1
  6. package/framework/.claude/agents/code-reviewer.md +84 -400
  7. package/framework/.claude/agents/codebase-architect.md +71 -356
  8. package/framework/.claude/agents/coder.md +130 -291
  9. package/framework/.claude/agents/doc-reviewer.md +127 -450
  10. package/framework/.claude/agents/plan-auditor.md +137 -436
  11. package/framework/.claude/agents/prd-card-writer.md +1 -1
  12. package/framework/.claude/agents/qa-sentinel.md +59 -313
  13. package/framework/.claude/agents/skill-improver.md +60 -4
  14. package/framework/.claude/agents/ui-expert.md +104 -591
  15. package/framework/.claude/commands/codexreview.md +26 -4
  16. package/framework/.claude/hooks/agent-discovery-gate.js +2 -2
  17. package/framework/.claude/hooks/agent-discovery-info.sh +1 -0
  18. package/framework/.claude/skills/new/CHANGELOG.md +39 -0
  19. package/framework/.claude/skills/new/SKILL.md +1 -1
  20. package/framework/.claude/skills/new/references/codex-gate.md +25 -11
  21. package/framework/.claude/skills/new/references/implement.md +49 -5
  22. package/framework/.claude/skills/new/references/review-cycle.md +20 -5
  23. package/framework/.claude/skills/new/scripts/build-review-bundle.mjs +112 -0
  24. package/framework/.claude/skills/new/scripts/doc-invariants.mjs +166 -0
  25. package/framework/.claude/skills/new2/CHANGELOG.md +13 -0
  26. package/framework/.claude/skills/new2/SKILL.md +5 -1
  27. package/framework/.claude/workflows/new-card-review.js +16 -2
  28. package/framework/.claude/workflows/new2-resolve.js +11 -4
  29. package/framework/.claude/workflows/new2.js +51 -3
  30. package/framework/agents/agent-operating-protocol.md +152 -0
  31. package/framework/agents/coding-standards.md +2 -2
  32. package/framework/agents/doc-audit-protocol.md +232 -0
  33. package/framework/agents/index.md +4 -0
  34. package/framework/agents/review-protocol.md +207 -0
  35. package/framework/docs/UPGRADE-3.12-UI-COHERENCE.md +1 -1
  36. package/framework/routines/finding-mine.routine.yml +56 -0
  37. package/framework/routines/index.yml +11 -0
  38. package/package.json +1 -1
  39. package/src/commands/configure.js +15 -0
  40. package/src/commands/doctor.js +69 -2
  41. package/src/utils/agent-slots.js +109 -0
  42. package/src/utils/overlay-merger.js +17 -8
  43. package/src/utils/symlinks.js +93 -33
package/CHANGELOG.md CHANGED
@@ -5,6 +5,120 @@ All notable changes to BALDART will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [5.0.1] - 2026-07-03
9
+
10
+ **Adversarial-verification fixes on the 5.0.0 wave.** A full release verification
11
+ (distribution machine dogfooded end-to-end on 4 configs — all green; normative-loss audit
12
+ over 4 core agents; pipeline-coherence audit) found the headline mechanisms inert on the
13
+ happy path plus a handful of slot-boundary and consistency defects. All fixed; no gate
14
+ removed, no H2 moved (consumer overlays unaffected), no `baldart.config.yml` change.
15
+
16
+ - **FIXED (HIGH) — `/new` step 11b clean branch now proceeds to 11c**: previously only the
17
+ violation branch reached the review-bundle/doc-invariants build, leaving the v5.0.0
18
+ anti-re-read + PASS-fast machinery unused on every clean card (`implement.md`).
19
+ - **FIXED (HIGH) — `/codexreview` consumes the full lean contract**: Step -0.5 now parses +
20
+ forwards `review_bundle_path` (anti-re-read phrase in every Step-2 prompt) and
21
+ `specialist_dispatch` (orchestrated-mode suppression, `dispatch_deferred:<agent>`) — both
22
+ were produced by `codex-gate.md` but dead-wired on the `/new`→`/codexreview` hop. Optional
23
+ keys: pre-5.0 contracts keep working unchanged.
24
+ - **FIXED (HIGH) — coder slot boundaries**: `vercel-react-best-practices` un-slotted (no
25
+ config flag can express React-non-Next → structural normative loss); the NEVER-ad-hoc
26
+ browser-scripts rule hoisted out of `{{#e2e_playwright}}` (universal pre-5.0). Agents
27
+ CHANGELOG: coder/doc-reviewer/qa-sentinel v2.0.1.
28
+ - **FIXED (MEDIUM)** — doc-reviewer per-card cited exceptions (`topological-generation`,
29
+ `schema-drift`) restored + `doc-audit-protocol.md` Contract no longer contradicts the agent
30
+ core; qa-sentinel bundle `gate_logs` demoted to context-only (own-tier gates always re-run);
31
+ `build-review-bundle.mjs` diff scoped to `--may-edit` (multi-card batches no longer leak
32
+ prior cards into card N's bundle/docinv; `new2.js` implement brief mirrors the scoping);
33
+ `new-card-review.js` + the 2.5x delegation thread `reviewBundlePath` into every brief;
34
+ Phase 2.55 pre-5.0 fallback uses `git diff "$TRUNK...HEAD"` (bare `git diff` post-commit is
35
+ vacuous); cap-and-handoff checkpoint-missing branch defined; `/ui-implement`-delegated cards
36
+ explicitly run 7c–11c; PASS-fast Own-Doc Closure claim corrected; "rule 8" pointers
37
+ re-anchored to the renumbered Post-Intervention Coherence rule 7 (prd-card-writer, upgrade
38
+ doc, new2-resolve comment).
39
+ - **FIXED (LOW)** — `doc-invariants.mjs` evaluates `documentation_impact` and `canonical_docs`
40
+ independently; deferral KEEP list re-includes `balanced`; stale `coding-standards.md`
41
+ cross-refs to the removed coder H2 updated; `${paths.references_dir}` literals in
42
+ `doc-audit-protocol.md`.
43
+ - Skills: `new` 2.0.1, `new2` 1.4.1 (per-skill CHANGELOGs). Codex parity: portable — prose +
44
+ pure-Node scripts, no Claude-only primitive added; the `/codexreview` contract keys are
45
+ optional and ignored by pre-5.0 readers.
46
+
47
+ ## [5.0.0] - 2026-07-03
48
+
49
+ **The agent-spine major.** Measured driver (1,934 subagent runs / 191 sessions on the
50
+ `mayo` consumer, one month, deduplicated by API-call id): 5.0B context tokens, of which
51
+ coder 53% and the whole review chain ~10%; the fixed per-spawn preamble (~45k, agent
52
+ definition 6–10k of it) is re-paid on EVERY API call; Read results are 66–75% of
53
+ tool_result bytes with the same hot files re-read at every chain link; the top-10
54
+ monster runs (200–440 calls) alone are 14% of total spend. 5.0 restructures the core
55
+ agents and the `/new` pipeline around those numbers — no gate is removed anywhere.
56
+
57
+ - **MAJOR — agents install as generated files when slot-bearing.** Core agent
58
+ definitions are restructured to 3 layers: core inline (I/O contracts + 1-line binding
59
+ rules) + shared protocol modules read on demand + `{{#flag}}` install-time slots
60
+ resolved per-consumer from EXISTING `baldart.config.yml` keys (a consumer ships ONE
61
+ `stack.database` variant, not four). A slot-bearing agent is GENERATED per-consumer
62
+ (`.baldart/generated/agents/` + symlink, marker gains trailing `config_sha`,
63
+ byte-stable rewrites); slotless agents stay plain symlinks; H2 headings stay stable
64
+ (no-op body when a flag is off) so existing overlays keep matching. First
65
+ `baldart update` after 5.0 flips the affected agents symlink→generated in one
66
+ auto-committed reconcile (allowlist already covers it). Machinery:
67
+ `src/utils/agent-slots.js` (new) + `symlinks.js` slot detection (fill → overlay-merge
68
+ → marker → transpile) + doctor `generatedAgentsStale` probe / `regenerate-agents`
69
+ action + `configure` re-merge after config writes. NO new config key (schema-change
70
+ propagation rule: N/A). Codex parity: adapter-generated — the TOML transpile consumes
71
+ the config-effective markdown, so Codex agents get the same resolved variant.
72
+ - **7 core agents restructured** (`coder`, `code-reviewer`, `doc-reviewer`,
73
+ `plan-auditor`, `qa-sentinel`, `codebase-architect`, `ui-expert`) — source cuts
74
+ 30–49% with ZERO normative loss (two independent adversarial verification passes:
75
+ no LOST, no WEAKENED rules). All carry `version:` frontmatter (own SemVer line,
76
+ history in the new `framework/.claude/agents/CHANGELOG.md` — NOT installed, excluded
77
+ from every agent enumerator incl. the discovery hooks) and ≤2-line descriptions (the
78
+ old multi-example descriptions were paid by the orchestrator every session). Codex
79
+ parity: adapter-generated (transpiler unchanged, consumes the effective markdown).
80
+ - **3 new protocol modules** (`agents/agent-operating-protocol.md`,
81
+ `agents/review-protocol.md`, `agents/doc-audit-protocol.md`) — the deduplicated SSOT
82
+ of the shared operating blocks (injection guard / retrieval / memory / tool budget),
83
+ the reviewer verification engine (Challenge+Actionability / Simulation diff+plan /
84
+ CoVe / absolute risk scoring / specialist-spawn discipline incl. the new
85
+ `specialist_dispatch` orchestrated-mode suppression), and doc-reviewer's audit-mode
86
+ procedures (read ONLY without card context). `SECTION=` dispatch — agents read only
87
+ the matching section. Codex parity: portable (markdown modules).
88
+ - **`/new` pipeline wave (skill `new` 2.0.0, `new2` 1.4.0)** — six additive mechanisms,
89
+ each with pre-5.0 graceful degradation and `check-new-parity.mjs` tripwire rules
90
+ (16 total): review bundle (`build-review-bundle.mjs` — deterministic per-card
91
+ handoff + binding anti-re-read phrase in every reviewer briefing, Hot-File Map
92
+ honored downstream); doc-invariants PASS-fast (`doc-invariants.mjs` — the invariant
93
+ table as executable rules; zero blocking rows + no doc signals + non-deep → per-card
94
+ doc-reviewer spawn skipped, Final F.3 backstop unchanged; measured headroom: 84/127
95
+ per-card runs returned PASS); cap-and-handoff (soft 80 / hard 100 tool calls,
96
+ checkpoint + fresh continuation ×2 — attacks the monster-run tail); explicit i18n
97
+ fill pass (step 7c, `i18n-translator` BY NAME — closes the measured general-purpose
98
+ leakage); fix-pass model routing A/B (fix-pass coder → `model: sonnet` best-effort,
99
+ overlay kill-switch `## [OVERRIDE] Fix-pass model`, `model=` in Fix Application Log
100
+ for recurrence telemetry; initial builds and specialists untouched). Codex parity:
101
+ scripts portable (.mjs), prose additive; the new2 workflow mirrors are Claude-only
102
+ with the /new prose as the inline fallback.
103
+ - **`finding-mine` routine (monthly) + `skill-improver` 2.0.0 `MODE: miner`** — the
104
+ anticipatory loop: 30 days of pooled findings / QA reports / batch trackers /
105
+ reviewer memories distilled into CLASSIFIED proposals (author-time coder rules,
106
+ never-demote rows, deterministic-gate candidates, card-schema proposals —
107
+ proposal-only, upstream candidates consolidated). Routine count 8 → 9. Codex parity:
108
+ adapter-generated (3 routine backends; agent transpiled).
109
+ - **`scripts/agent-telemetry.mjs` (maintainer tool)** — fleet-level per-family
110
+ telemetry (calls p50/p90/max, ctx, read-share, verdicts, rework ratio, cap-hit rate,
111
+ fix-pass models) with `--baseline save|compare`; the pre-5.0 baseline is saved.
112
+ Dedup by `message.id` keeping the LAST record (the JSONL double-count trap). Codex
113
+ parity: N/A (maintainer-only, Claude transcripts).
114
+ - **Post-release measurement plan** (2 weeks on a live consumer, vs the saved
115
+ baseline): coder ctx/run −30%+, Read-share <66%, p100 calls down, doc-reviewer
116
+ PASS-fast rate ≈ measured headroom, fix-pass recurrence sonnet ≤ opus, reviewer
117
+ verdict distributions unchanged.
118
+
119
+ MAJOR — changes the on-disk layout of installed agents (symlink → generated file for
120
+ slot-bearing agents). No new `baldart.config.yml` keys anywhere in the release.
121
+
8
122
  ## [4.99.0] - 2026-07-03
9
123
 
10
124
  **Consumer-lessons wave: four recurring failure patterns surfaced by mayo's nightly/weekly routine reports (20260628-skill-improve + 20260701-doc-graph-align) upstreamed into the base framework.** The consumer had fixed each locally via overlays, but three of the four root causes live in the base payload — every future consumer would have re-discovered them. The overarching meta-defect (#2) is that the lesson pipeline itself had no upstream channel: overlay fixes died in the consumer.
package/README.md CHANGED
@@ -328,6 +328,7 @@ drift-detection loops actually run. Ship-bundled routines:
328
328
  | `ds-drift` | weekly Mon 03:00 UTC | doc-reviewer | Design-system drift check (optional) |
329
329
  | `full-sweep` | weekly Sun 03:00 UTC | doc-reviewer | Full SSOT audit (optional) |
330
330
  | `i18n-align` | weekly Mon 04:00 UTC | i18n-translator | Translates target languages, lints, commits direct to trunk (optional, needs `has_i18n`) |
331
+ | `finding-mine` | monthly 1st 03:00 UTC | skill-improver | Deep 30-day mining of pooled findings/QA/trackers/reviewer memories into classified improvement proposals (`MODE: miner`, v5.0.0) |
331
332
 
332
333
  Three backend adapters are bundled:
333
334
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4.99.0
1
+ 5.0.1
@@ -0,0 +1,105 @@
1
+ # Changelog — agent definitions
2
+
3
+ Per-agent version history (the `version:` frontmatter each agent carries since
4
+ framework v5.0.0). This file is NOT installed into consumers (excluded from the
5
+ per-item agent merge, the doctor probes, and the discovery hooks — like
6
+ `REGISTRY.md` it is framework metadata living beside the agents).
7
+
8
+ Formato: [Keep a Changelog](https://keepachangelog.com/) · per-agent SemVer.
9
+
10
+ ## [coder v2.0.1] · [doc-reviewer v2.0.1] · [qa-sentinel v2.0.1] — 2026-07-03 (framework v5.0.1)
11
+
12
+ Adversarial-verification fixes on the 3-layer restructuring (no H2 moved — overlays unaffected):
13
+
14
+ - **coder**: `vercel-react-best-practices` un-slotted (it applies to ANY React stack, and no
15
+ config flag can express "React non-Next" — a structural normative loss for those consumers;
16
+ "skill absent → skip silently"). The NEVER-ad-hoc-browser-scripts rule hoisted OUT of
17
+ `{{#e2e_playwright}}` as an unconditional line (it was universal pre-5.0; a Playwright
18
+ consumer with a stale `stack.testing.e2e` silently lost it); the `playwright-skill` link
19
+ itself stays slotted.
20
+ - **doc-reviewer**: two per-card cited exceptions restored from the audit module —
21
+ `SECTION=topological-generation` (multi-file doc passes generate leaf→root; was per-card in
22
+ v4.99.0 but unreachable behind the module's "per-card NEVER" contract) and
23
+ `SECTION=schema-drift` (changed field SET on a documented payload → `SCHEMA_DRIFT`/
24
+ `ORPHAN_FIELD`, diff-driven as in v4.99.0). `doc-audit-protocol.md` Contract reworded to
25
+ name the cited exceptions instead of contradicting the agent core.
26
+ - **qa-sentinel**: review-bundle `gate_logs` demoted to CONTEXT ONLY (`files_changed` stays
27
+ authoritative for scope) — own-tier gates are always re-executed, never cited from a stale
28
+ Phase-2 log; restored the v4.99.0 one-liners "never claim a gate ran when it did not" and
29
+ "never invent your own classification".
30
+ - (pointer-only, no version bump) **prd-card-writer**: "code-reviewer rule 8" re-anchored to
31
+ the renumbered rule 7 (Post-Intervention Coherence Check), by name.
32
+
33
+ ## [coder v2.0.0] · [code-reviewer v2.0.0] · [doc-reviewer v2.0.0] · [plan-auditor v2.0.0] · [qa-sentinel v2.0.0] · [codebase-architect v2.0.0] · [ui-expert v2.0.0] · [skill-improver v2.0.0] — 2026-07-03 (framework v5.0.0)
34
+
35
+ **The 3-layer restructuring** (core inline + shared modules + install-time slots).
36
+ The pre-5.0 monoliths are implicitly `1.x`. Every normative rule survives — either
37
+ inline as a 1-line binding rule, in a shared module the core cites
38
+ (`agents/agent-operating-protocol.md`, `agents/review-protocol.md`,
39
+ `agents/doc-audit-protocol.md`), or in a pre-existing SSOT — verified by two
40
+ independent adversarial passes (zero LOST, zero WEAKENED).
41
+
42
+ Common changes (all 8):
43
+ - `version:` frontmatter added; `description` trimmed to ≤2 lines (inline examples
44
+ removed — they were paid by the ORCHESTRATOR's context every session).
45
+ - Shared operating blocks (injection guard, doc-retrieval, persistent-memory
46
+ hygiene, tool budget) deduplicated into `agent-operating-protocol.md`;
47
+ reviewer verification passes (Challenge/Actionability, Simulation, CoVe, risk
48
+ scoring, specialist-spawn discipline) into `review-protocol.md`. Cores keep
49
+ 1-line binding versions + `SECTION=` cites.
50
+ - Conditional content became `{{#flag}}` install-time slots resolved from
51
+ EXISTING `baldart.config.yml` keys (features.*, stack.database → `db_*`,
52
+ `fw_nextjs`, `deploy_vercel`, `e2e_playwright`). H2 headings stay STABLE with a
53
+ one-line no-op body when a flag is off (overlay `[OVERRIDE]/[APPEND]` targets
54
+ keep matching).
55
+ - I/O contracts stayed VERBATIM inline: completion report, verdict lines, pooled
56
+ findings YAML, TARGET TAG table, QA report format, 10-section FULL output,
57
+ Return Contracts, QUICK mode.
58
+
59
+ Per-agent highlights:
60
+ - **coder**: 4 DB variants → one `{{#db_*}}` slot; Reference-Aliasing lore → 1-line
61
+ + `coding-standards.md` cite; NEW `## Tool-Call Budget & Checkpoint` (cap-and-
62
+ handoff, `[CAP-HANDOFF]` marker); completion report ALSO persisted to
63
+ `/tmp/completion-<CARD-ID>.md`; deterministic DTCG token lookup (never grep the
64
+ CSS); Linked Skills conditional on stack.
65
+ - **code-reviewer**: DS compliance compressed under `{{#has_design_system}}`
66
+ (protocol module is the SSOT); NEW review-bundle-first scope rule; NEW
67
+ `specialist_dispatch` orchestrated-mode suppression (records
68
+ `dispatch_deferred:<agent>`).
69
+ - **doc-reviewer**: split by mode — per-card core stays; audit-mode procedures
70
+ (drift validators, DocAgent topological, epistemic metadata, SCIP, schema/
71
+ registry drift, coverage gauges) moved to `doc-audit-protocol.md`, read ONLY
72
+ without card context; NEW deterministic-first invariant check (consumes
73
+ `/tmp/docinv-<CARD-ID>.json` when present).
74
+ - **plan-auditor**: 4-example description → 2 lines; persistence checks →
75
+ `{{#db_*}}`; QUICK mode, checklist A–H, ADR delta, high-risk triggers, TARGET
76
+ TAG table, YAML schema, 10-section output all inline; NEW dispatch suppression.
77
+ - **qa-sentinel**: 3-example description → 2 lines; i18n gate / ds-gate /
78
+ toolchain resolution under their flags; review-bundle `files_changed`+`gate_logs`
79
+ as authoritative inputs.
80
+ - **codebase-architect**: 4-example description → 2 lines; LSP/graph escalations
81
+ under `{{#has_lsp_layer}}`/`{{#has_code_graph}}`; investigation engine, terse
82
+ contract (incl. Hot-File Map) and architect-specific memory hygiene (TTL,
83
+ archived/, cleanup) kept verbatim-compressed.
84
+ - **ui-expert**: i18n under `{{#has_i18n}}`; Design Reference (code-first) and
85
+ build-with-eyes kept intact; expertise/delegations/red-flags compressed with no
86
+ category dropped; deterministic token lookup.
87
+ - **skill-improver**: NEW `## MODE: miner` (monthly deep pass → classified
88
+ proposals; consumed by the `finding-mine` routine) + COMPACT return contract.
89
+
90
+ **Heading map (old → new) for consumer overlays** — overlay sections targeting a
91
+ heading that moved/merged are appended as trailing sections with a warning (never
92
+ lost); re-point them to:
93
+
94
+ | Old H2 (pre-5.0) | Now |
95
+ |---|---|
96
+ | `## Prompt Injection Guard` (code-reviewer, plan-auditor) | `## Operating Protocol` (1-line) + module `SECTION=injection-guard` |
97
+ | `## Memory Retrieval Step` / `## MEMORY RETRIEVAL STEP` | `## Operating Protocol` + module `SECTION=memory` |
98
+ | `## Retrieval Protocol Consumption` (all) | `## Operating Protocol` / `## Retrieval Protocol` + module `SECTION=retrieval` |
99
+ | `## Search discipline` (all) | `## Operating Protocol` (cite `code-search-protocol.md`) |
100
+ | `## Challenge Pass` / `## Diff Simulation Pass` / `## Chain-of-Verification Pass` / `## Quantified Risk Scoring` | `## Verification Passes` + `review-protocol.md` sections |
101
+ | `## Specialist Auto-Spawn` | same name; suppression clause added (matrix unchanged) |
102
+ | `## Reference-Aliasing Mutation Hazards` (coder) | 1-line in `## Code Standards & Author-Time Simplicity Discipline` + `coding-standards.md` |
103
+ | `## Database Index Invariant` variants (coder) / `### Persistence-Specific` (plan-auditor) | same heading, body is now the single `{{#db_*}}` variant |
104
+ | doc-reviewer `## Audit Process`, `## Drift Validator Suite`, `## Dependency-Aware Generation Protocol`, `## Epistemic Metadata Protocol`, `## SCIP Code Reference Protocol`, `## Schema Field-Level Drift Detection`, `## Canonical API registries`, `## Endpoint Count Reconciliation`, `## Coverage Gauges` | `agents/doc-audit-protocol.md` (agent keeps `## Audit Mode` dispatch) |
105
+ | `# Persistent Agent Memory` boilerplate tails | compressed under `# Persistent Agent Memory` + module `SECTION=memory` |
@@ -6,7 +6,9 @@ Quick-reference for all custom agents. Use this to route tasks to the right spec
6
6
 
7
7
  > **Codex-native (since v4.80.0)**: every agent here is portable to Codex. The same `<name>.md` is **transpiled** to `.codex/agents/<name>.toml` on install/update (`name`/`description` → same, body → `developer_instructions`, `effort` → `model_reasoning_effort`, `model` omitted). Authoring stays single-source: drop a `.md`, it auto-installs for both tools. Keep `name`+`description` frontmatter, put behaviour in the body, and don't rely on an agent spawning a further agent (Codex `agents.max_depth: 1`). Design: [`framework/docs/CODEX-AGENTS.md`](../../docs/CODEX-AGENTS.md).
8
8
 
9
- > **Machine-readable source of truth (since v3.20.0)**: the filesystem directory `framework/.claude/agents/` is authoritative for the list of BALDART agents. The `agent-discovery-gate.js` PreToolUse hook, the `agent-discovery-info.sh` SessionStart hook, and `baldart doctor` enumerate the directory directly (every `<name>.md` except this file is an agent — no manifest JSON is shipped). Adding a new agent means dropping `<name>.md` here; no other touchpoint.
9
+ > **Machine-readable source of truth (since v3.20.0)**: the filesystem directory `framework/.claude/agents/` is authoritative for the list of BALDART agents. The `agent-discovery-gate.js` PreToolUse hook, the `agent-discovery-info.sh` SessionStart hook, and `baldart doctor` enumerate the directory directly (every `<name>.md` except this file and `CHANGELOG.md` is an agent — no manifest JSON is shipped). Adding a new agent means dropping `<name>.md` here; no other touchpoint.
10
+
11
+ > **3-layer structure + versioning + slots (since v5.0.0)**: the core agents follow a 3-layer authoring contract. (1) **Core inline** — role boundary, gating, I/O contracts (verdict lines, pooled findings YAML, completion reports) and every always-applicable rule as a 1-line BINDING statement. (2) **Modules on demand** — shared procedures live in `agents/agent-operating-protocol.md` (injection guard / retrieval / memory / tool budget) and `agents/review-protocol.md` (Challenge / Simulation / CoVe / risk scoring / specialist-spawn discipline), cited as `SECTION=<name>`; **reading the cited section when the procedure applies is normative**, and degrade is safe (the 1-line rule still binds; contracts never live in modules). (3) **Install-time slots** — `{{#flag}}` conditionals resolved per-consumer from existing `baldart.config.yml` keys (see `src/utils/agent-slots.js`); a slot-bearing agent installs as a GENERATED file (marker + `config_sha`), H2 headings stay stable with a no-op body when the flag is off (overlays keep matching). Every agent carries a `version:` frontmatter (its own SemVer line); bump it + add an entry to `framework/.claude/agents/CHANGELOG.md` (NOT installed) in the same edit. Keep frontmatter `description` ≤2 lines — it is paid by the orchestrator's context every session.
10
12
 
11
13
  > **Return contract (since v4.59.0)**: every orchestrator-facing subagent bounds its **final message** so a long body doesn't flood the spawning context — COMPACT return (headline/verdict + `path:line` findings + disk pointer), long form persisted to disk. Agents already structured this way are the exemplars (`qa-sentinel` Return Protocol, `visual-fidelity-verifier` JSON, the verdict+pooled-YAML reviewers — `code-reviewer` / `security-reviewer` / `api-perf-cost-auditor`); free-form analysts carry an explicit `## Return Contract` block (`codebase-architect`, `doc-reviewer`, `plan-auditor`, `senior-researcher`). When adding a new analysis/audit/research agent, paste the block from `framework/templates/agent-return-contract.snippet.md`. Protocol: `framework/agents/return-contract-protocol.md`.
12
14