bmad-method 6.8.1-next.1 → 6.8.1-next.11
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.
- package/package.json +1 -1
- package/src/bmm-skills/2-plan-workflows/bmad-prd/SKILL.md +1 -1
- package/src/bmm-skills/2-plan-workflows/bmad-ux/SKILL.md +2 -2
- package/src/bmm-skills/3-solutioning/bmad-agent-architect/customize.toml +2 -2
- package/src/bmm-skills/3-solutioning/bmad-architecture/SKILL.md +85 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/assets/spine-template.md +79 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/customize.toml +100 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/references/headless.md +26 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/references/reviewer-gate.md +13 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/scripts/lint_spine.py +257 -0
- package/src/bmm-skills/3-solutioning/bmad-architecture/scripts/tests/test_lint_spine.py +270 -0
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/SKILL.md +16 -60
- package/src/bmm-skills/3-solutioning/bmad-create-epics-and-stories/steps/step-01-validate-prerequisites.md +12 -4
- package/src/bmm-skills/4-implementation/bmad-code-review/SKILL.md +3 -0
- package/src/bmm-skills/4-implementation/bmad-code-review/steps/step-02-review.md +1 -1
- package/src/bmm-skills/4-implementation/bmad-create-story/SKILL.md +3 -0
- package/src/bmm-skills/4-implementation/bmad-quick-dev/SKILL.md +3 -0
- package/src/bmm-skills/4-implementation/bmad-quick-dev/step-04-review.md +1 -1
- package/src/bmm-skills/4-implementation/bmad-retrospective/SKILL.md +14 -14
- package/src/bmm-skills/4-implementation/bmad-retrospective/customize.toml +1 -1
- package/src/bmm-skills/module-help.csv +2 -2
- package/src/core-skills/bmad-spec/SKILL.md +24 -8
- package/src/core-skills/bmad-spec/assets/headless-schemas.md +3 -3
- package/src/core-skills/bmad-spec/assets/spec-template.md +1 -1
- package/src/scripts/memlog.py +224 -0
- package/src/scripts/tests/test_memlog.py +306 -0
- package/tools/installer/core/installer.js +32 -1
- package/tools/installer/core/python-check.js +199 -0
- package/tools/installer/ide/platform-codes.yaml +7 -0
- package/tools/installer/ui.js +10 -0
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/architecture-decision-template.md +0 -12
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/data/domain-complexity.csv +0 -13
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/data/project-types.csv +0 -7
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-01-init.md +0 -153
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-01b-continue.md +0 -173
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-02-context.md +0 -224
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-03-starter.md +0 -329
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-04-decisions.md +0 -318
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-05-patterns.md +0 -359
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-06-structure.md +0 -379
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-07-validation.md +0 -361
- package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-08-complete.md +0 -82
package/package.json
CHANGED
|
@@ -88,5 +88,5 @@ Tell the user the sequence in one sentence, then walk it. Polish goes last so it
|
|
|
88
88
|
4. **Triage open items.** All Open Questions, `[ASSUMPTION]` tags, `[NOTE FOR PM]` callouts. Phase-blockers (would make the PRD unsafe for UX/architecture/epics) surfaced one at a time and resolved; non-blockers deferred with owner + revisit condition logged to `.decision-log.md`. If phase-blocker count is high, flag it.
|
|
89
89
|
5. **Polish.** Apply `{workflow.doc_standards}` to `prd.md` and `addendum.md` in declared order (structural passes before prose — prose should not polish soon-to-be-cut text). Parallelize across documents, sequential within.
|
|
90
90
|
6. **External handoffs.** Execute `{workflow.external_handoffs}`; surface returned URLs/IDs. Skip and flag unavailable tools.
|
|
91
|
-
7. **Close.** Set `prd.md` frontmatter `status: final` and `updated` to `{date}` so future invocations distinguish this PRD from in-progress drafts. Record finalization to `.decision-log.md`. Share artifact paths. Common next: `bmad-ux`, `bmad-
|
|
91
|
+
7. **Close.** Set `prd.md` frontmatter `status: final` and `updated` to `{date}` so future invocations distinguish this PRD from in-progress drafts. Record finalization to `.decision-log.md`. Share artifact paths. Common next: `bmad-ux`, `bmad-architecture`, `bmad-create-epics-and-stories`; invoke `bmad-help` for authoritative routing.
|
|
92
92
|
8. Run `{workflow.on_complete}` if non-empty.
|
|
@@ -33,7 +33,7 @@ UX may lead, follow, or stand alone. Inherit `sources:` by reference; the spines
|
|
|
33
33
|
1. Resolve customization: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow`. On failure, read `{skill-root}/customize.toml` directly and use defaults.
|
|
34
34
|
2. Run `{workflow.activation_steps_prepend}`. Treat `{workflow.persistent_facts}` as foundational context (entries prefixed `file:` are loaded). `{workflow.external_sources}` is an org-configured registry of internal tools; consult them alongside generic web research on the same triggers, org tools preferred when their directive matches.
|
|
35
35
|
3. Load `{project-root}/_bmad/bmm/config.yaml` (+ `config.user.yaml` if present). Resolve `{user_name}`, `{communication_language}`, `{document_output_language}`, `{planning_artifacts}`, `{project_name}`, `{date}`. Missing keys → neutral defaults; never block.
|
|
36
|
-
4. If headless, follow `references/headless.md` for the whole run. Otherwise greet the user **by name** using `{user_name}` and **in their language** using `{communication_language}` — and stay in `{communication_language}` for every turn. In the greeting, let the user know `bmad-party-mode` and `bmad-advanced-elicitation` are always available. Then scan for misroute on the first message: PRD → `bmad-prd`; architecture → `bmad-
|
|
36
|
+
4. If headless, follow `references/headless.md` for the whole run. Otherwise greet the user **by name** using `{user_name}` and **in their language** using `{communication_language}` — and stay in `{communication_language}` for every turn. In the greeting, let the user know `bmad-party-mode` and `bmad-advanced-elicitation` are always available. Then scan for misroute on the first message: PRD → `bmad-prd`; architecture → `bmad-architecture`; game UX → BMad GDS; agent/skill → `bmad-workflow-builder`; brief → `bmad-product-brief`.
|
|
37
37
|
5. Detect intent: **Create**, **Update**, **Validate**. For Create, before binding a fresh workspace, scan `{workflow.ux_output_path}` for prior in-progress runs (folders matching `{workflow.run_folder_pattern}` whose `DESIGN.md` frontmatter `status` is not `final`) and offer to resume rather than starting over.
|
|
38
38
|
|
|
39
39
|
Run `{workflow.activation_steps_append}`.
|
|
@@ -87,4 +87,4 @@ Outcomes, in order:
|
|
|
87
87
|
- **Key-screen mocks rendered.** Key-screens tool → `.working/` for surfaces where layout drives behavior or anchors visual language.
|
|
88
88
|
- **Mock coverage confirmed.** Walk every IA surface; classify *mocked* vs *spine-only*. Ask: *"These will be built from spine tables alone — any need a visual reference?"* Render more if named; log spine-only choices.
|
|
89
89
|
- **Layout extracted, artifacts promoted.** Distill subagent re-reads each `.working/` and `imports/` artifact; lifts visual decisions into DESIGN.md and behavioral decisions into EXPERIENCE.md. Promote `.working/` keepers to `mockups/` (HTML) or `wireframes/` (Excalidraw); imports stay. Inline relative links at relevant spine sections; state spines-win-on-conflict once.
|
|
90
|
-
- **Polished, handed off, closed.** Apply `{workflow.doc_standards}` in order. Execute `{workflow.external_handoffs}`; surface URLs. Set both files' `status: final`, `updated: {date}`. Log finalization. Share paths. Common next: `bmad-
|
|
90
|
+
- **Polished, handed off, closed.** Apply `{workflow.doc_standards}` in order. Execute `{workflow.external_handoffs}`; surface URLs. Set both files' `status: final`, `updated: {date}`. Log finalization. Share paths. Common next: `bmad-architecture`, `bmad-create-epics-and-stories`, `bmad-dev-story`. Run `{workflow.on_complete}`.
|
|
@@ -56,8 +56,8 @@ principles = [
|
|
|
56
56
|
|
|
57
57
|
[[agent.menu]]
|
|
58
58
|
code = "CA"
|
|
59
|
-
description = "
|
|
60
|
-
skill = "bmad-
|
|
59
|
+
description = "Produce the architecture spine: the invariants that keep independently-built units consistent"
|
|
60
|
+
skill = "bmad-architecture"
|
|
61
61
|
|
|
62
62
|
[[agent.menu]]
|
|
63
63
|
code = "IR"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bmad-architecture
|
|
3
|
+
description: 'Produce the architecture: a lean spine of invariants that keeps everything built from it consistent, projected into whatever format the work needs. Use when the user says "create the architecture", "create technical architecture", "architecture spine", or "create a solution design".'
|
|
4
|
+
---
|
|
5
|
+
# BMad Architecture
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
You produce an **architecture spine**: a consistency contract that fixes only the **invariants** keeping independently-built units from diverging — the design paradigm, the boundary and dependency rules, how state is mutated, who owns shared data — the durable calls a future builder *can't* read off compliant code. Everything structural (stack, tree, full data shape) is **seed**: true at cold-start, owned by the code once it exists. Lead with a named paradigm — it carries a whole model for free — and keep the seed minimal.
|
|
10
|
+
|
|
11
|
+
One test decides what belongs:
|
|
12
|
+
|
|
13
|
+
> If two units one level down built this independently, could they choose incompatibly? Fix it here only when the answer is yes, **and** the call is non-obvious, **and** it's a real trade-off. Otherwise name it under Deferred and move on.
|
|
14
|
+
|
|
15
|
+
Default output is a **build substrate** — terse and convergent, so small agents and humans on small intents don't drift. When the goal is instead to align people, lead with a **discussion** doc that keeps the open questions in front. Match the spine to what's in front of you: a few decisions for a small thing, comprehensive for a platform; the whole system or the one slice a feature touches.
|
|
16
|
+
|
|
17
|
+
Record decisions, not rationale (rationale lives in the memlog). Carry shape in diagrams, not prose. Verify any named technology's current version and fit on the web before binding it.
|
|
18
|
+
|
|
19
|
+
## How you work
|
|
20
|
+
|
|
21
|
+
You're a coach, and the **Coaching path is the default** — the elicitation is the value, and it cuts against the instinct to just produce an architecture, so hold the line. Offer the choice as an Activation step, in the user's language, before any drafting: **Coaching path** (we work it together — open-ended questions, I pull the decisions out of you and push back where one is thin) or **Fast path** (I draft the whole spine fast with `[ASSUMPTION]` tags you correct in review). Unless the user clearly wants speed, **coach; don't silently draft.** The load-bearing calls — paradigm, stack or starter, the major boundaries — are *shown, not silently made*: lay out the realistic alternatives you weighed and why you lean one way, then let the user choose. That rationale lives in the conversation and the memlog, never in the terse spine.
|
|
22
|
+
|
|
23
|
+
Elicit, don't quiz: open-ended "how are you thinking about X?" beats a multiple-choice menu; reserve a crisp either/or for a genuinely binary fork. On the Fast path, inferring and tagging *is* the job.
|
|
24
|
+
|
|
25
|
+
When the stack is open — greenfield, or a small/beginner project that could sit on a paved path — **recommend a well-known current starter** (verify the going choice on the web first): a good one pre-decides a coherent slab of the architecture for free and beats hand-rolling for a less-experienced user. For brownfield, **investigate before you decide** — read enough of the real code (and `{workflow.persistent_facts}`) to ratify the conventions already there rather than invent new ones — and don't re-tell the user what the scan already shows.
|
|
26
|
+
|
|
27
|
+
## Read the input to know the job
|
|
28
|
+
|
|
29
|
+
The input itself tells you what kind of job this is — read it rather than quizzing the user about it. A spec package (`SPEC.md` + its memlog) is the richest start and the spine's home, so fold the spine back into it. But you'll also get a raw idea, a sprawling architecture document to distill down, an existing codebase to derive a spine *from* (ratify the conventions the code already shows — don't re-document them), the slice of one a new feature touches, or an existing spine to extend or pressure-test. Prefer a `.memlog.md` over re-reading the source it came from. Distill whatever you're given; mark real gaps as open questions instead of inventing answers. The spine's **altitude** mirrors what it augments and keeps the level below coherent — initiative→features, feature→epics, epic→stories. Inherit what's already settled — whether by the input (a spec, prd) or the standing `{workflow.persistent_facts}` — silently; don't re-decide or re-ask it. If the input is too thin to build on, suggest `bmad-spec` first; else capture the missing answers into a shared spec workspace through the same `memlog.py`, so `bmad-spec` can later derive `SPEC.md` without drift.
|
|
30
|
+
|
|
31
|
+
**Inheriting a parent spine** (e.g. pointed at one epic of a spec whose feature/initiative spine already exists): load the parent `ARCHITECTURE-SPINE.md` first and treat its `AD`s, conventions, and paradigm as **binding, read-only** constraints — log each as a `constraint` entry, list them under the spine's *Inherited Invariants* (parent `AD` IDs, never renumbered), and don't re-derive them. Your job is only what the parent **left open**: its `Deferred` items plus the divergences this epic's stories could hit. A new `AD` that contradicts or weakens an inherited one is a **conflict to surface**, not a local override. An epic spine fixes the invariants the epic's stories must share — it does **not** expand per-story detail.
|
|
32
|
+
|
|
33
|
+
## How a run works
|
|
34
|
+
|
|
35
|
+
The **memlog** (`.memlog.md`) is the run's working memory: every decision, constraint, version, assumption, and open question lands as one append-only line — for a decision, capture what it binds and the divergence it prevents. It is the shared canonical memlog (the same `{project-root}/_bmad/scripts/memlog.py` bmad-spec writes through), so it carries no lifecycle status — terminal moments are logged as `event` entries, not a frontmatter flag. The spine is **distilled from the memlog at the end**, not written as you go. Each surviving decision becomes an `AD-n` (stable ID, `Binds`/`Prevents`/`Rule`, `[ADOPTED]` when the user or existing reality already settled it); a decision that lives only in a diagram still gets logged. Resume a prior run by reloading its memlog.
|
|
36
|
+
|
|
37
|
+
Writes go through the shared script (don't read the file back except on resume):
|
|
38
|
+
|
|
39
|
+
- `python3 {project-root}/_bmad/scripts/memlog.py init --workspace {doc_workspace} --field scope="…" --field purpose="…" --field altitude="…"`
|
|
40
|
+
- `python3 {project-root}/_bmad/scripts/memlog.py append --workspace {doc_workspace} --type <decision|constraint|version|assumption|question|direction|event> --text "…"`
|
|
41
|
+
|
|
42
|
+
## Resolution rules
|
|
43
|
+
|
|
44
|
+
- Bare paths and `{skill-root}` (e.g. `references/headless.md`) resolve from this skill's installed directory.
|
|
45
|
+
- `{project-root}` → the project working directory; `{skill-name}` → the skill directory's basename.
|
|
46
|
+
- `{workflow.<name>}` → a merged `customize.toml` field; `{doc_workspace}` → the bound run folder.
|
|
47
|
+
- Forward slashes only. Config variables already contain `{project-root}` in their resolved values — never double-prefix.
|
|
48
|
+
|
|
49
|
+
## On Activation
|
|
50
|
+
|
|
51
|
+
**Forwarded activation:** if a caller (e.g. the `bmad-create-architecture` shim) invoked you with a stated intent and pre-resolved customization fields, honor them verbatim — skip your own intent inference, use the supplied values for those named fields, and resolve only the remaining fields from your own `customize.toml`.
|
|
52
|
+
|
|
53
|
+
1. Resolve customization: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow` (on failure read `{skill-root}/customize.toml`, use defaults). Run `{workflow.activation_steps_prepend}`, then `{workflow.activation_steps_append}`. Hold `{workflow.persistent_facts}` as standing context — the default loads `project-context.md`, load-bearing for brownfield — and consult `{workflow.external_sources}` on demand.
|
|
54
|
+
2. Load `{project-root}/_bmad/bmm/config.yaml` (+ `config.user.yaml`) for `{user_name}`, `{communication_language}`, `{document_output_language}`, `{planning_artifacts}`, `{project_name}`, `{date}`; missing keys take neutral defaults, never block.
|
|
55
|
+
3. Headless (no interactive user) → follow `references/headless.md` for the whole run. Otherwise greet `{user_name}` in `{communication_language}`. Detect the intent from the conversation and input — **create** (the default), **update** an existing spine, or **validate** one (see those sections). If the real ask is requirements / UX / a capability contract / epic breakdown / an agent, invoke the `bmad-prd`, `bmad-ux`, `bmad-spec`, `bmad-create-epics-and-stories`, or `bmad-workflow-builder` (if the BMad Builder module is installed) skill instead.
|
|
56
|
+
4. If a run folder for this target already exists under `{workflow.spine_output_path}`, offer to resume from its memlog rather than restart.
|
|
57
|
+
5. Interactive create: offer the working mode in `{communication_language}` — **Coaching path** (default) or **Fast path** (see *How you work*) — before any drafting; default to Coaching unless the user asks for speed.
|
|
58
|
+
6. **Mandatory, both paths, before drafting:** ask whether the spine is the only deliverable — and if not, draw out the *purpose and audience* rather than a document type. "An architecture doc" balloons into bloat; what they actually need might be a one-detail explainer for a single team or a non-technical vision piece for a board. Purpose right-sizes the artifact and may call for extra elicitation up front, not just a finale add-on.
|
|
59
|
+
|
|
60
|
+
For a new spine, bind `{doc_workspace}` to `{workflow.spine_output_path}/{workflow.run_folder_pattern}/`, seed `ARCHITECTURE-SPINE.md` from `{workflow.spine_template}`, run `memlog.py init`, and tell the user the path. **At epic altitude, scope the folder to the epic** (set `run_folder_pattern` per `customize.toml`) so per-epic runs don't collide.
|
|
61
|
+
|
|
62
|
+
## Reviewer Gate
|
|
63
|
+
|
|
64
|
+
The spine's pre-handoff review — full mechanics in `references/reviewer-gate.md`. Load it when finalizing or validating: a deterministic `lint_spine.py` pass, then a rubric walker (good-spine checklist) + every `{workflow.finalize_reviewers}` lens dispatched as parallel subagents against `ARCHITECTURE-SPINE.md`, scaled to stakes. At Finalize you apply the clear fixes; under the Validate intent you deliver a bespoke HTML report and then get user input.
|
|
65
|
+
|
|
66
|
+
## Finalize
|
|
67
|
+
|
|
68
|
+
Walk the sequence; reviewer fixes land before polish.
|
|
69
|
+
|
|
70
|
+
1. **Distill.** Write the spine from the memlog (brownfield: + the code sweep) — invariants first, seed minimal, every `AD` carrying Binds/Prevents/Rule, `Deferred` naming what it won't decide. No placeholders; never invent to fill a gap. The template's `<!-- -->` notes are guidance — act on them, then strip them; the finished spine carries no template comment, and only the diagrams that convey the structure (as many as the altitude needs, valid mermaid). Sweep the breadth the altitude owns — every structural dimension is decided, deferred, or an open question; a whole dimension left silent (e.g. the operational/environmental envelope: deployment & environments, infra/provider strategy, operations) is the failure, not a clean spine. A long coaching run distills cleaner in a subagent; the parent falls back inline.
|
|
71
|
+
2. **Reconcile inputs.** A subagent per load-bearing input checks it against the spine and returns what didn't land — especially a quiet requirement (a tone, a constraint) the `AD` structure dropped. Before the gate.
|
|
72
|
+
3. **Reviewer pass.** Run the Reviewer Gate (`references/reviewer-gate.md`). Resolve before polish.
|
|
73
|
+
4. **Triage.** Open questions and `[ASSUMPTION]` tags: blockers (unsafe for what's next) resolved one at a time; the rest deferred with a revisit condition in the memlog.
|
|
74
|
+
5. **Renderings & polish.** The spine is the build deliverable; with it and the memlog now in place, produce any *additional* human-facing artifact the user needs, scoped to the purpose and audience drawn out up front. The up-front question already flagged whether one's needed; if it wasn't, still offer one here, seeding concrete options: an interactive HTML+SVG deck to walk a team through the architecture and drive discussion, a fuller HTML/md solution design, a C4 set, or a view of how the work splits across teams/epics. Build only what they pick, right-sized to that purpose; apply `{workflow.doc_standards}` polish to that prose only, never to the spine.
|
|
75
|
+
6. **External handoffs.** Run `{workflow.external_handoffs}`; surface returned URLs/IDs. Offer to invoke the `bmad-spec` skill to adopt the spine as a companion, keeping `AD` IDs stable so downstream can cite them.
|
|
76
|
+
7. **Close.** Set the spine's own frontmatter `status: final`, `updated: {date}`; log a `memlog.py append --type event --text "spine finalized"` (the memlog has no status field). Share paths. Next, **lead with `bmad-spec`** — recommend adopting/refreshing the spine as a spec companion (always the top recommendation when a spec was an input, and a useful next step even when it wasn't), then `bmad-create-epics-and-stories` or — epic altitude — `bmad-create-story`; or invoke `bmad-help` to route.
|
|
77
|
+
8. Run `{workflow.on_complete}`.
|
|
78
|
+
|
|
79
|
+
## Update
|
|
80
|
+
|
|
81
|
+
Amend an existing spine or provided artifact. Resume from its `.memlog.md` (the authority on what was decided), not the rendered spine. Capture the change as new memlog entries; **keep `AD` IDs stable** — amend a Rule in place, add the next `AD-n` for a new decision, never renumber or reuse a retired ID. Then re-distill (Finalize step 1), run the Reviewer Gate (`references/reviewer-gate.md`), and close as in Finalize. An update that overrides something from a source input: offer to update that source too, so upstream and the spine don't silently diverge.
|
|
82
|
+
|
|
83
|
+
## Validate
|
|
84
|
+
|
|
85
|
+
The standalone intent — critique an existing spine without changing it. Run the Reviewer Gate (`references/reviewer-gate.md`) against it and deliver the bespoke HTML report, then offer to roll the findings into an Update. (At Finalize the same gate runs as your own pre-handoff check, where you apply the fixes instead of reporting.)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: '{name}'
|
|
3
|
+
type: architecture-spine
|
|
4
|
+
purpose: build-substrate # build-substrate (default) · discussion · report · deck
|
|
5
|
+
altitude: feature # initiative (keeps features) · feature (keeps epics) · epic (keeps stories)
|
|
6
|
+
paradigm: '{named design pattern, e.g. hexagonal, layered, pipes-and-filters, actor}'
|
|
7
|
+
scope: '{what this spine governs}'
|
|
8
|
+
status: draft # draft · final
|
|
9
|
+
created: '{date}'
|
|
10
|
+
updated: '{date}'
|
|
11
|
+
binds: [] # capability / unit IDs governed (from the driving spec; at epic altitude, also the inherited parent AD ids)
|
|
12
|
+
sources: []
|
|
13
|
+
companions: []
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Architecture Spine — {name}
|
|
17
|
+
|
|
18
|
+
<!-- TEMPLATE GUIDE — act on these comments, then delete them; never emit a comment in the finished spine. This is a shape, not a script: keep only the sections this spine needs and cut the rest (no empty headers). A small intent may be just paradigm + a few ADs + conventions; a platform earns more. An inherited epic spine is usually mostly Inherited Invariants + a thin Deferred. Decisions, not rationale (rationale lives in the memlog). Carry shape in diagrams; prose only where it must. -->
|
|
19
|
+
|
|
20
|
+
## Design Paradigm
|
|
21
|
+
|
|
22
|
+
<!-- Name the pattern (a known one loads a whole model for free) and map its layers to namespaces/directories. The smallest, most durable thing here. -->
|
|
23
|
+
|
|
24
|
+
## Inherited Invariants
|
|
25
|
+
|
|
26
|
+
<!-- Only when this spine inherits a higher-altitude parent. The parent's ADs/conventions/paradigm that bind here, by their ORIGINAL ids — read-only, never renumbered, not re-derived. A local decision that contradicts one is a conflict to surface, not an override. Cut this section otherwise. -->
|
|
27
|
+
|
|
28
|
+
| Inherited | From parent | Binds here |
|
|
29
|
+
| --- | --- | --- |
|
|
30
|
+
| {AD-id / convention} | {parent spine} | {what it constrains in this scope} |
|
|
31
|
+
|
|
32
|
+
## Invariants & Rules
|
|
33
|
+
|
|
34
|
+
<!-- The durable heart: calls a future builder can't read off compliant code. One block per decision: stable ascending id (never reused/renumbered), Binds, Prevents (the divergence), Rule (enforceable). Tag [ADOPTED] when the user or existing reality settled it. Include a dependency-direction diagram (who may depend on whom) — it IS a rule; author it as valid mermaid, never an empty graph. -->
|
|
35
|
+
|
|
36
|
+
### AD-1 — {decision}
|
|
37
|
+
|
|
38
|
+
- **Binds:** {capability / unit ids / fr/nfr's, areas, or `all`}
|
|
39
|
+
- **Prevents:** {the divergence this stops}
|
|
40
|
+
- **Rule:** {the constraint downstream must follow}
|
|
41
|
+
|
|
42
|
+
## Consistency Conventions
|
|
43
|
+
|
|
44
|
+
<!-- Defaults that bind where independent builders would drift. Cut rows that don't apply; add rows the project needs. -->
|
|
45
|
+
|
|
46
|
+
| Concern | Convention |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| Naming (entities, files, interfaces, events) | |
|
|
49
|
+
| Data & formats (ids, dates, error shapes, envelopes) | |
|
|
50
|
+
| State & cross-cutting (mutation, errors, logging, config, auth) | |
|
|
51
|
+
|
|
52
|
+
## Stack
|
|
53
|
+
|
|
54
|
+
<!-- SEED — verified current at authoring; the code owns this once it exists. Name + version only; the why lives in the memlog. One row per language, framework, key dependency, platform, or chain that's pinned. -->
|
|
55
|
+
|
|
56
|
+
| Name | Version |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| {language / framework / key dep / platform / chain} | {pinned version} |
|
|
59
|
+
|
|
60
|
+
## Structural Seed
|
|
61
|
+
|
|
62
|
+
<!-- The shapes worth fixing at cold-start — not a fixed list. Include only what's non-obvious at this altitude, and use as many diagrams as convey it, each as VALID mermaid (never a placeholder or empty graph). Candidates: system/container/context view; DEPLOYMENT & ENVIRONMENTS and external provider/infra topology (cover the operational envelope here when this altitude owns it — don't let it fall through); core-entity ERD (names + relationships only; an attribute that's itself an invariant is an AD, not a diagram); a minimal source tree. The code owns the detail — this is scaffold, not a mirror to maintain. -->
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
{root}/
|
|
66
|
+
{dir}/ # {what lives here}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Capability → Architecture Map
|
|
70
|
+
|
|
71
|
+
<!-- Present when a spec drove this run. Bridges the spec's capabilities to where they live + what governs them; the consistency auditor's checklist. Cut otherwise. -->
|
|
72
|
+
|
|
73
|
+
| Capability / Area | Lives in | Governed by |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| {CAP-id / area} | {component / module} | {AD-id, convention, paradigm} |
|
|
76
|
+
|
|
77
|
+
## Deferred
|
|
78
|
+
|
|
79
|
+
<!-- Decisions intentionally pushed down, each with the reason it can wait — including whole dimensions this altitude doesn't own yet. The half of the contract that keeps the spine lean. -->
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# DO NOT EDIT -- overwritten on every update.
|
|
2
|
+
#
|
|
3
|
+
# Workflow customization surface for bmad-architecture.
|
|
4
|
+
#
|
|
5
|
+
# Override files (not edited here):
|
|
6
|
+
# {project-root}/_bmad/custom/bmad-architecture.toml (team)
|
|
7
|
+
# {project-root}/_bmad/custom/bmad-architecture.user.toml (personal)
|
|
8
|
+
|
|
9
|
+
[workflow]
|
|
10
|
+
|
|
11
|
+
# --- Configurable below. Overrides merge per BMad structural rules: ---
|
|
12
|
+
# scalars: override wins • arrays: append
|
|
13
|
+
|
|
14
|
+
# Steps to run before the standard activation (config load, greet).
|
|
15
|
+
# Use for pre-flight loads, approved-stack policy checks, etc.
|
|
16
|
+
activation_steps_prepend = []
|
|
17
|
+
|
|
18
|
+
# Steps to run after greet but before the workflow begins.
|
|
19
|
+
# Use for context-heavy setup that should happen once the user has been acknowledged.
|
|
20
|
+
activation_steps_append = []
|
|
21
|
+
|
|
22
|
+
# Persistent facts the workflow keeps in mind for the whole run
|
|
23
|
+
# (approved stacks, banned dependencies, platform constraints, compliance guardrails).
|
|
24
|
+
# Each entry is either a literal sentence, a skill prefixed with `skill:`, or a `file:`-prefixed
|
|
25
|
+
# path/glob whose contents are loaded as facts.
|
|
26
|
+
#
|
|
27
|
+
# Default loads project-context.md if bmad-generate-project-context produced one — giving the
|
|
28
|
+
# architect persistent awareness of the project's tech, domain, and conventions (load-bearing
|
|
29
|
+
# for brownfield). Common opt-ins (set in team/user override TOML):
|
|
30
|
+
# "Our org is AWS-only -- do not propose GCP or Azure."
|
|
31
|
+
# "file:{project-root}/docs/engineering-standards.md"
|
|
32
|
+
persistent_facts = [
|
|
33
|
+
"file:{project-root}/**/project-context.md",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
# Executed when the workflow completes (after the spine is final and the user has been told).
|
|
37
|
+
# String scalar (single instruction) or array of instructions executed in order. Empty for none.
|
|
38
|
+
on_complete = ""
|
|
39
|
+
|
|
40
|
+
# The architecture spine template. Treated as expert prior knowledge, not a checklist — the LLM
|
|
41
|
+
# adapts it to the project, altitude, and domain, and drops sections a project genuinely doesn't
|
|
42
|
+
# need. Override the path in team/user TOML to enforce a different spine shape.
|
|
43
|
+
spine_template = "assets/spine-template.md"
|
|
44
|
+
|
|
45
|
+
# Run folder location. ARCHITECTURE-SPINE.md, its .memlog.md, and any fuller rendering the run
|
|
46
|
+
# produces all land inside `{spine_output_path}/{run_folder_pattern}/`. Resume-check scans
|
|
47
|
+
# `{spine_output_path}` for prior unfinished runs.
|
|
48
|
+
#
|
|
49
|
+
# The default pattern fits the common case (one spine per project, at the altitude above epics).
|
|
50
|
+
# At EPIC altitude, override run_folder_pattern to carry the epic identity so per-epic runs don't
|
|
51
|
+
# collide on the same day — e.g. set it (team/user TOML) to "architecture-epic-{epic_id}", binding
|
|
52
|
+
# {epic_id} from the driving spec / the activating payload. Headless callers may instead pass an
|
|
53
|
+
# explicit doc_workspace and bypass the pattern entirely.
|
|
54
|
+
spine_output_path = "{planning_artifacts}/architecture"
|
|
55
|
+
run_folder_pattern = "architecture-{project_name}-{date}"
|
|
56
|
+
|
|
57
|
+
# Prose-editorial standards applied at finalize ONLY to a fuller prose document the run produces
|
|
58
|
+
# (a discussion report, full architecture doc, or design addendum) — never to the spine or other
|
|
59
|
+
# short, structured outputs, which are terse and carry decisions in AD-n blocks and diagrams by
|
|
60
|
+
# design. Each entry is a `skill:`, `file:`, or plain-text directive applied before the user sees
|
|
61
|
+
# the polished draft. Suggested order: structural passes first, prose mechanics last. Append-only.
|
|
62
|
+
doc_standards = [
|
|
63
|
+
"skill:bmad-editorial-review-structure",
|
|
64
|
+
"skill:bmad-editorial-review-prose",
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
# External-source registry. Natural-language directives describing knowledge bases, MCP tools, or
|
|
68
|
+
# internal systems the LLM may consult ON DEMAND during the run (not preemptively) — approved-stack
|
|
69
|
+
# catalogs, internal platform docs, version registries. Each entry names the tool, the trigger
|
|
70
|
+
# condition, and any fields it needs. If a named tool is unavailable at runtime, the LLM falls back
|
|
71
|
+
# to standard behavior (e.g. web research) and notes the gap. Empty by default.
|
|
72
|
+
#
|
|
73
|
+
# Examples (set in team/user override TOML):
|
|
74
|
+
# "When choosing a datastore, consult corp:platform_catalog before recommending one."
|
|
75
|
+
# "For current library versions, query corp:artifact_registry before web search."
|
|
76
|
+
external_sources = []
|
|
77
|
+
|
|
78
|
+
# External-handoff routing applied at Finalize to push outputs beyond local files (Confluence,
|
|
79
|
+
# Notion, ticket systems). Each entry names the MCP tool, the destination, and required fields.
|
|
80
|
+
# Runs after polish; returned URLs/IDs are surfaced. Unavailable tools are skipped and flagged;
|
|
81
|
+
# local files always exist. Empty by default.
|
|
82
|
+
external_handoffs = []
|
|
83
|
+
|
|
84
|
+
# --- Finalize reviewers ---
|
|
85
|
+
# Extra review lenses spawned as parallel subagents at the validation gate (Finalize and the
|
|
86
|
+
# Validate intent), on top of the skill's built-in good-spine checklist and the lint_spine.py
|
|
87
|
+
# mechanical floor. The GATE is stakes-gated — a throwaway spine may run it quietly or skip it —
|
|
88
|
+
# but whenever the gate runs, every entry here runs with it (the configured floor, never cherry-
|
|
89
|
+
# picked); only ad-hoc lenses are optional, and headless never skips the gate.
|
|
90
|
+
#
|
|
91
|
+
# Entries follow the standard prefix convention:
|
|
92
|
+
# "skill:NAME" invoke the named review skill as a subagent against ARCHITECTURE-SPINE.md
|
|
93
|
+
# "file:PATH" load the file as a review prompt; spawn an adversarial subagent applying it
|
|
94
|
+
# plain text use the text directly as the subagent's review prompt
|
|
95
|
+
#
|
|
96
|
+
# Resolved on-demand (not at activation). Override TOML may append.
|
|
97
|
+
finalize_reviewers = [
|
|
98
|
+
"Verify every committed decision was web-researched or reality-checked rather than asserted from training data: current library/framework versions, that each named technology still exists and fits, and — greenfield — the live defaults of any starter it leans on. Flag anything that could be out of date and wasn't confirmed against the web, the existing project, or the current starter.",
|
|
99
|
+
"Attack the spine as an adversary: construct two units one level down that each obey every AD to the letter yet still build incompatibly — clashing shared-data shapes, two owners of one entity, conflicting state-mutation paths. Every pair you find is a hole to close with a new or tightened AD.",
|
|
100
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Headless
|
|
2
|
+
|
|
3
|
+
No interactive user: infer everything, ask nothing, but never invent — record inferences as `assumptions[]` and gaps that need a human as `open_questions[]`. Detect headless from a `headless: true` flag, a non-interactive / no-TTY invocation, an activation hook that declares it, or a first message that pre-supplies all inputs and asks for an artifact path back; when ambiguous, default to interactive.
|
|
4
|
+
|
|
5
|
+
Drive the run from the payload in the first message — `intent`, `altitude`, `purpose`, the driving input (spec package / PRD / raw intent / brownfield path), a parent spine path at lower altitude, and `doc_workspace` if a specific folder is required. Infer anything absent from the inputs or workspace; don't invent stack, constraints, or scope to fill a gap. You still verify named tech on the web (you can't ask, but you can check) and still drive every write through the shared `{project-root}/_bmad/scripts/memlog.py`. Run the full Reviewer Gate (`references/reviewer-gate.md`) non-interactively: `scripts/lint_spine.py` plus **every `{workflow.finalize_reviewers}` lens as a parallel subagent** (and any ad-hoc lens the spine's criticality warrants). Headless skips only the human picking from the menu — never the reviewers themselves; apply the clear fixes and record anything unresolved in `open_questions[]`. For a true authority collision, list it in `conflicts_with_prior_decisions[]`. For the Validate intent, always write the report to `{doc_workspace}` and add `"offer_to_update": true`. If intent stays ambiguous after inference, halt blocked.
|
|
6
|
+
|
|
7
|
+
End with JSON only, omitting keys for artifacts not produced — the shape below is the fully-produced (`complete`) case; a `blocked` run produces no spine, so it omits `spine`, `memlog`, and `companions` entirely (see the note under the block):
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"status": "complete | partial | blocked",
|
|
12
|
+
"intent": "create | update | validate",
|
|
13
|
+
"altitude": "initiative | feature | epic",
|
|
14
|
+
"purpose": "build-substrate | discussion",
|
|
15
|
+
"doc_workspace": "<resolved run folder>",
|
|
16
|
+
"spine": "{doc_workspace}/ARCHITECTURE-SPINE.md",
|
|
17
|
+
"memlog": "{doc_workspace}/.memlog.md",
|
|
18
|
+
"companions": [],
|
|
19
|
+
"assumptions": [],
|
|
20
|
+
"open_questions": [],
|
|
21
|
+
"conflicts_with_prior_decisions": [],
|
|
22
|
+
"reason": "<one line, only when blocked>"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`complete` stands alone · `partial` (spine produced, but `open_questions[]` non-empty or critical inputs inferred) means review before downstream use · `blocked` means no spine produced — return only `status`, `intent`, `reason`, and `doc_workspace` (if bound), omitting `spine`, `memlog`, `companions`, and the artifact arrays that don't exist.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Reviewer Gate
|
|
2
|
+
|
|
3
|
+
The spine's pre-handoff review. Runs at Finalize (after distill + reconcile) and *is* the Validate intent. The difference is the ending: at Finalize you apply the clear fixes yourself; under Validate you report and don't change the spine.
|
|
4
|
+
|
|
5
|
+
Cheap deterministic pass first: `python3 {skill-root}/scripts/lint_spine.py --workspace {doc_workspace}` settles the mechanical misses (placeholders, duplicate `AD` IDs, missing Binds/Prevents/Rule, unpinned Stack versions), so reviewers spend judgment on the semantic half.
|
|
6
|
+
|
|
7
|
+
Assemble the menu: a **rubric walker** that judges the spine against the good-spine checklist below, **+ every entry in `{workflow.finalize_reviewers}`**, + ad-hoc lenses you invent or offer as the spine's rigor, altitude, and criticality warrant — a security/compliance lens for regulated stakes, a seam reviewer cross-team, a data-integrity lens for a heavy data model. Scale *whether and how heavily the gate runs* to the stakes: a throwaway prototype may run it quietly or skip the gate entirely; a high-criticality or platform-altitude spine earns more lenses and the explicit all / subset / skip menu. But once the gate runs, the `{workflow.finalize_reviewers}` always run — they are the configured floor, never cherry-picked out; only the ad-hoc lenses are optional. (Headless never skips the gate.)
|
|
8
|
+
|
|
9
|
+
Dispatch every entry as a **parallel subagent against `ARCHITECTURE-SPINE.md`** (prefix convention: `skill:` / `file:` / plain text). Each writes its full review to `{doc_workspace}/reviews/review-{slug}.md` — a subfolder, so the gate's scratch stays out of the deliverable folder — and returns ONLY a compact summary (verdict, top 2–5 findings, file path) — the parent never holds full review text. An inline self-check does not count: the independent context is the point, because a fresh reviewer finds the divergences the author talks past. If subagents are unavailable, run sequentially — write the file first, then flush it from context.
|
|
10
|
+
|
|
11
|
+
**Good-spine checklist** (what the rubric walker judges): it fixes the real divergence points for the level below and misses none; every `AD`'s Rule is enforceable and actually prevents its stated divergence; nothing under Deferred could let two units diverge; named tech is verified-current; it ratifies rather than contradicts a brownfield codebase; if a spec drove it, it covers that spec's capabilities; if a parent spine is inherited, no new `AD` weakens or contradicts an inherited one; and every dimension the altitude owns is decided, deferred, or an open question — a whole dimension left silent is a finding, especially the operational/environmental envelope (deployment & environments, infra/provider strategy, operations) a domain-focused draft skips.
|
|
12
|
+
|
|
13
|
+
Surface findings tiered, never dumped: a one-sentence gate verdict, then critical + high; medium/low roll into a tail ("plus N more in {file}"). Per finding: autofix, discuss, defer to Deferred / open items, or ignore. **At Finalize this is your own gate — apply the clear fixes rather than handing over a list; surface only what genuinely needs the user.** Under the **Validate intent**, fold every reviewer's output into one bespoke HTML + markdown report and open the HTML.
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# /// script
|
|
3
|
+
# requires-python = ">=3.10"
|
|
4
|
+
# ///
|
|
5
|
+
"""lint-spine — the mechanical half of spine decision-integrity, done deterministically.
|
|
6
|
+
|
|
7
|
+
LLMs miscount IDs and miss literal placeholders; a grep does not. This linter owns the
|
|
8
|
+
checks a script does better than a prompt, and leaves the semantic half (is each Rule
|
|
9
|
+
actually enforceable? does the boundary make sense?) to the rubric walker.
|
|
10
|
+
|
|
11
|
+
It reads ARCHITECTURE-SPINE.md from a workspace and reports, as compact JSON on stdout:
|
|
12
|
+
|
|
13
|
+
- placeholder literal TBD / TODO / "similar to AD-n" / unfilled {template-token}
|
|
14
|
+
- ad_id duplicate or non-monotonic AD-n identifiers
|
|
15
|
+
- ad_fields an AD-n block missing Binds / Prevents / Rule
|
|
16
|
+
- version_pin a ## Stack table row with no version
|
|
17
|
+
|
|
18
|
+
Fenced code blocks are blanked (replaced with equal-count blank lines) before scanning, so
|
|
19
|
+
mermaid and source trees don't trip false positives AND reported line numbers still line up
|
|
20
|
+
with the real file. Reported lines are absolute file lines (frontmatter offset added). Exit
|
|
21
|
+
code is always 0 — findings travel in the JSON; the caller (Reviewer Gate / rubric walker)
|
|
22
|
+
decides what to do with them.
|
|
23
|
+
"""
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import json
|
|
28
|
+
import re
|
|
29
|
+
import sys
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
|
|
32
|
+
SPINE = "ARCHITECTURE-SPINE.md"
|
|
33
|
+
|
|
34
|
+
AD_HEADING = re.compile(r"^#{2,4}\s*AD-(\d+)\b(.*)$", re.MULTILINE)
|
|
35
|
+
HEADING = re.compile(r"^#{1,6}\s", re.MULTILINE)
|
|
36
|
+
FENCE = re.compile(r"```.*?```", re.DOTALL)
|
|
37
|
+
PLACEHOLDER_WORD = re.compile(r"\b(TBD|TODO|FIXME|XXX)\b")
|
|
38
|
+
SIMILAR_TO = re.compile(r"similar to AD-\d+", re.IGNORECASE)
|
|
39
|
+
TEMPLATE_TOKEN = re.compile(r"\{[a-z_][a-z0-9_ /.-]*\}")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def split_frontmatter(text: str) -> tuple[str, str, int]:
|
|
43
|
+
"""Return (frontmatter, body, body_line_offset).
|
|
44
|
+
|
|
45
|
+
Frontmatter is the content between the first two lines that are *exactly* `---`
|
|
46
|
+
(line-exact, like memlog.split — a `---` inside a value or a body thematic break never
|
|
47
|
+
truncates it). body_line_offset is the number of file lines before the body begins, so a
|
|
48
|
+
body-relative line number plus the offset gives the absolute file line. Absent frontmatter
|
|
49
|
+
→ ('', text, 0)."""
|
|
50
|
+
lines = text.split("\n")
|
|
51
|
+
if lines and lines[0] == "---":
|
|
52
|
+
for i in range(1, len(lines)):
|
|
53
|
+
if lines[i] == "---":
|
|
54
|
+
fm = "\n".join(lines[1:i])
|
|
55
|
+
body = "\n".join(lines[i + 1:])
|
|
56
|
+
return fm, body, i + 1
|
|
57
|
+
return "", text, 0
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def blank_fences(text: str) -> str:
|
|
61
|
+
"""Replace each fenced block with the same number of newlines, so scanning skips fenced
|
|
62
|
+
content while every line number outside the fence stays put."""
|
|
63
|
+
return FENCE.sub(lambda m: "\n" * m.group(0).count("\n"), text)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def line_of(text: str, idx: int) -> int:
|
|
67
|
+
return text.count("\n", 0, idx) + 1
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def find_placeholders(body: str, offset: int) -> list[dict]:
|
|
71
|
+
findings: list[dict] = []
|
|
72
|
+
scan = blank_fences(body)
|
|
73
|
+
# (regex, label, severity) — TBD/TODO and dangling cross-refs are unambiguous; a bare
|
|
74
|
+
# {template-token} can be legitimate brace prose, so it is flagged low ("possible") to keep
|
|
75
|
+
# the mechanical pass near-zero false-positive rather than train reviewers to ignore it.
|
|
76
|
+
for rx, label, severity in (
|
|
77
|
+
(PLACEHOLDER_WORD, "placeholder marker", "high"),
|
|
78
|
+
(SIMILAR_TO, "unresolved cross-reference", "high"),
|
|
79
|
+
(TEMPLATE_TOKEN, "possible unfilled template token (verify)", "low"),
|
|
80
|
+
):
|
|
81
|
+
for m in rx.finditer(scan):
|
|
82
|
+
findings.append({
|
|
83
|
+
"category": "placeholder",
|
|
84
|
+
"severity": severity,
|
|
85
|
+
"detail": f"{label}: {m.group(0)!r}",
|
|
86
|
+
"location": f"{SPINE} (line {offset + line_of(scan, m.start())})",
|
|
87
|
+
})
|
|
88
|
+
return findings
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def find_frontmatter_placeholders(frontmatter: str) -> list[dict]:
|
|
92
|
+
"""Catch unfilled tokens left in frontmatter (e.g. paradigm/scope/date) — part of the
|
|
93
|
+
spine contract, but outside the body that find_placeholders scans."""
|
|
94
|
+
findings: list[dict] = []
|
|
95
|
+
for rx, label, severity in (
|
|
96
|
+
(PLACEHOLDER_WORD, "placeholder marker", "high"),
|
|
97
|
+
(TEMPLATE_TOKEN, "possible unfilled template token (verify)", "low"),
|
|
98
|
+
):
|
|
99
|
+
for m in rx.finditer(frontmatter):
|
|
100
|
+
findings.append({
|
|
101
|
+
"category": "placeholder",
|
|
102
|
+
"severity": severity,
|
|
103
|
+
"detail": f"frontmatter {label}: {m.group(0)!r}",
|
|
104
|
+
"location": f"{SPINE} frontmatter (line {1 + line_of(frontmatter, m.start())})",
|
|
105
|
+
})
|
|
106
|
+
return findings
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def find_ad_issues(body: str, offset: int) -> list[dict]:
|
|
110
|
+
findings: list[dict] = []
|
|
111
|
+
scan = blank_fences(body) # AD headings shown inside a code fence are not live ADs
|
|
112
|
+
matches = list(AD_HEADING.finditer(scan))
|
|
113
|
+
seen: dict[int, int] = {}
|
|
114
|
+
prev: int | None = None
|
|
115
|
+
for m in matches:
|
|
116
|
+
num = int(m.group(1))
|
|
117
|
+
file_line = offset + line_of(scan, m.start())
|
|
118
|
+
loc = f"{SPINE} AD-{num} (line {file_line})"
|
|
119
|
+
if num in seen:
|
|
120
|
+
findings.append({
|
|
121
|
+
"category": "ad_id",
|
|
122
|
+
"severity": "high",
|
|
123
|
+
"detail": f"AD-{num} id reused (also at line {seen[num]})",
|
|
124
|
+
"location": loc,
|
|
125
|
+
})
|
|
126
|
+
else:
|
|
127
|
+
seen[num] = file_line
|
|
128
|
+
if prev is not None and num <= prev:
|
|
129
|
+
findings.append({
|
|
130
|
+
"category": "ad_id",
|
|
131
|
+
"severity": "high",
|
|
132
|
+
"detail": f"AD-{num} is non-monotonic (follows AD-{prev}); ids must ascend and never renumber",
|
|
133
|
+
"location": loc,
|
|
134
|
+
})
|
|
135
|
+
prev = num if prev is None else max(prev, num)
|
|
136
|
+
|
|
137
|
+
# block text = from this heading to the next heading of any level
|
|
138
|
+
start = m.end()
|
|
139
|
+
nxt = HEADING.search(scan, start)
|
|
140
|
+
block = scan[start:nxt.start()] if nxt else scan[start:]
|
|
141
|
+
low = block.lower()
|
|
142
|
+
missing = [f for f in ("binds", "prevents", "rule") if f not in low]
|
|
143
|
+
if missing:
|
|
144
|
+
findings.append({
|
|
145
|
+
"category": "ad_fields",
|
|
146
|
+
"severity": "high",
|
|
147
|
+
"detail": f"AD-{num} missing required field(s): {', '.join(missing)}",
|
|
148
|
+
"location": loc,
|
|
149
|
+
})
|
|
150
|
+
return findings
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def find_unpinned_stack(body: str, offset: int) -> list[dict]:
|
|
154
|
+
"""Flag a `## Stack` table row that names something but leaves its version blank or a
|
|
155
|
+
placeholder. Pinning lives in the body table now, not frontmatter. A row whose name is
|
|
156
|
+
still a `{token}` skeleton is left to the placeholder pass, not double-reported here.
|
|
157
|
+
|
|
158
|
+
Fences are blanked first (like find_placeholders / find_ad_issues), so a pipe-row or
|
|
159
|
+
heading inside a code block is never read as live Stack content. The heading match is
|
|
160
|
+
`## Stack` with a word boundary, so a renamed heading (`## Stack & Versions`) still
|
|
161
|
+
counts. Name and Version columns are located from the header row, so a reordered table
|
|
162
|
+
pairs name to version correctly; both default to the canonical positions (0, 1)."""
|
|
163
|
+
findings: list[dict] = []
|
|
164
|
+
in_stack = False
|
|
165
|
+
header_seen = False
|
|
166
|
+
name_idx, ver_idx = 0, 1
|
|
167
|
+
scan = blank_fences(body)
|
|
168
|
+
for i, raw in enumerate(scan.splitlines()):
|
|
169
|
+
if HEADING.match(raw):
|
|
170
|
+
in_stack = re.match(r"^##\s+Stack\b", raw) is not None
|
|
171
|
+
header_seen = False
|
|
172
|
+
name_idx, ver_idx = 0, 1
|
|
173
|
+
continue
|
|
174
|
+
if not in_stack or not raw.lstrip().startswith("|"):
|
|
175
|
+
continue
|
|
176
|
+
if set(raw.strip()) <= set("|-: "):
|
|
177
|
+
continue # separator row
|
|
178
|
+
cells = _table_cells(raw)
|
|
179
|
+
if not header_seen:
|
|
180
|
+
header_seen = True
|
|
181
|
+
for j, c in enumerate(cells):
|
|
182
|
+
if c.lower() == "name":
|
|
183
|
+
name_idx = j
|
|
184
|
+
elif c.lower() == "version":
|
|
185
|
+
ver_idx = j
|
|
186
|
+
continue
|
|
187
|
+
name = cells[name_idx] if len(cells) > name_idx else ""
|
|
188
|
+
version = cells[ver_idx] if len(cells) > ver_idx else ""
|
|
189
|
+
if not name or TEMPLATE_TOKEN.search(name):
|
|
190
|
+
continue
|
|
191
|
+
if not version or TEMPLATE_TOKEN.search(version):
|
|
192
|
+
findings.append({
|
|
193
|
+
"category": "version_pin",
|
|
194
|
+
"severity": "medium",
|
|
195
|
+
"detail": f"Stack entry {name!r} has no version",
|
|
196
|
+
"location": f"{SPINE} (line {offset + i + 1})",
|
|
197
|
+
})
|
|
198
|
+
return findings
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def _table_cells(row: str) -> list[str]:
|
|
202
|
+
"""Split a markdown table row into trimmed cells, dropping the leading/trailing pipe."""
|
|
203
|
+
s = row.strip()
|
|
204
|
+
if s.startswith("|"):
|
|
205
|
+
s = s[1:]
|
|
206
|
+
if s.endswith("|"):
|
|
207
|
+
s = s[:-1]
|
|
208
|
+
return [c.strip() for c in s.split("|")]
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def lint(text: str) -> dict:
|
|
212
|
+
frontmatter, body, offset = split_frontmatter(text)
|
|
213
|
+
findings: list[dict] = []
|
|
214
|
+
findings += find_frontmatter_placeholders(frontmatter)
|
|
215
|
+
findings += find_placeholders(body, offset)
|
|
216
|
+
findings += find_ad_issues(body, offset)
|
|
217
|
+
findings += find_unpinned_stack(body, offset)
|
|
218
|
+
counts: dict[str, int] = {}
|
|
219
|
+
for f in findings:
|
|
220
|
+
counts[f["severity"]] = counts.get(f["severity"], 0) + 1
|
|
221
|
+
return {
|
|
222
|
+
"ok": len(findings) == 0,
|
|
223
|
+
"spine": SPINE,
|
|
224
|
+
"total_findings": len(findings),
|
|
225
|
+
"by_severity": counts,
|
|
226
|
+
"findings": findings,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def main(argv: list[str] | None = None) -> int:
|
|
231
|
+
ap = argparse.ArgumentParser(description="Lint an architecture spine for mechanical integrity.")
|
|
232
|
+
ap.add_argument("--workspace", required=True, help="run folder containing ARCHITECTURE-SPINE.md")
|
|
233
|
+
ap.add_argument("-o", "--output", help="write JSON here instead of stdout")
|
|
234
|
+
args = ap.parse_args(argv)
|
|
235
|
+
|
|
236
|
+
spine_path = Path(args.workspace) / SPINE
|
|
237
|
+
if not spine_path.exists():
|
|
238
|
+
result = {"ok": False, "error": f"{spine_path} not found", "findings": [], "total_findings": 0}
|
|
239
|
+
else:
|
|
240
|
+
try:
|
|
241
|
+
text = spine_path.read_text(encoding="utf-8")
|
|
242
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
243
|
+
# honor the "exit code is always 0" contract: a read/decode failure travels in JSON
|
|
244
|
+
result = {"ok": False, "error": f"could not read {spine_path}: {e}", "findings": [], "total_findings": 0}
|
|
245
|
+
else:
|
|
246
|
+
result = lint(text)
|
|
247
|
+
|
|
248
|
+
out = json.dumps(result, indent=2)
|
|
249
|
+
if args.output:
|
|
250
|
+
Path(args.output).write_text(out + "\n", encoding="utf-8")
|
|
251
|
+
else:
|
|
252
|
+
print(out)
|
|
253
|
+
return 0
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
if __name__ == "__main__":
|
|
257
|
+
sys.exit(main())
|