|
| 1 | +# Architecture Driven Development (ADD) |
| 2 | + |
| 3 | +> **ADD is the governing methodology for 5-Spot.** Architecture is designed, |
| 4 | +> recorded, and visualized **before** code is written. ADRs and CALM diagrams |
| 5 | +> are first-class deliverables — equal in importance to the code and the tests. |
| 6 | +
|
| 7 | +ADD layers *on top of* the existing TDD discipline; it does not replace it. The |
| 8 | +order is fixed: |
| 9 | + |
| 10 | +``` |
| 11 | +ADR → CALM → TDD → implement → docs |
| 12 | +``` |
| 13 | + |
| 14 | +## The ADD cycle |
| 15 | + |
| 16 | +For any **architecturally significant** change, complete each step before |
| 17 | +starting the next: |
| 18 | + |
| 19 | +### 1. ADR — decide and record (FIRST) |
| 20 | + |
| 21 | +Write or update an Architecture Decision Record in |
| 22 | +`docs/adr/NNNN-title.md` (lowercase-hyphen, zero-padded sequential number) |
| 23 | +using `docs/adr/template.md`, with the standard sections: |
| 24 | + |
| 25 | +- **Status** — Proposed → Accepted (→ Superseded by NNNN) |
| 26 | +- **Context** — the forces, constraints, and the problem being solved |
| 27 | +- **Decision** — what we will do, stated plainly |
| 28 | +- **Consequences** — trade-offs, follow-ups, what this rules out |
| 29 | + |
| 30 | +ADRs are kept **in the repo** (unlike roadmaps, which live outside it at |
| 31 | +`~/dev/roadmaps/`). One decision per ADR. If a change reverses an earlier ADR, |
| 32 | +mark the old one *Superseded* and link forward. Keep the index in |
| 33 | +`docs/adr/README.md` current. |
| 34 | + |
| 35 | +### 2. CALM — model and visualize |
| 36 | + |
| 37 | +Update the FINOS CALM architecture model |
| 38 | +(`docs/architecture/calm/architecture.json`) to reflect the decision: nodes, |
| 39 | +relationships, interfaces, controls, and flows. Then: |
| 40 | + |
| 41 | +```sh |
| 42 | +make calm-validate # architecture conforms to the meta-schema (hard gate) |
| 43 | +make calm-diagrams # regenerate Mermaid diagrams into docs/src/architecture/ |
| 44 | +``` |
| 45 | + |
| 46 | +The architecture must be modeled and the diagrams must render cleanly **before** |
| 47 | +implementation begins. A change that isn't reflected in CALM isn't designed yet. |
| 48 | + |
| 49 | +> **Process-only decisions** (e.g. adopting a methodology, CI policy) have **no |
| 50 | +> CALM impact** — CALM models the running system (controller, `ScheduledMachine` |
| 51 | +> CRD, CAPI/provider resources, flows), not the development process. Say so |
| 52 | +> explicitly in the ADR's Consequences and skip step 2. |
| 53 | +
|
| 54 | +### 3. TDD — red / green / refactor |
| 55 | + |
| 56 | +Only now write code, **tests first**, per the `tdd-workflow` skill: failing test |
| 57 | +→ minimum implementation → refactor. Tests go in separate `_tests.rs` files |
| 58 | +(`src/foo.rs` → `#[cfg(test)] mod foo_tests;` → `src/foo_tests.rs`). After any |
| 59 | +`.rs` change, run the `cargo-quality` skill (fmt + clippy + test — all must pass). |
| 60 | + |
| 61 | +CRD shape changes start in `src/crd.rs` (the source of truth), then regenerate: |
| 62 | +`regen-crds` skill (`make crds`) → update `examples/` → `regen-api-docs` |
| 63 | +(`make crddoc`, LAST). Never hand-edit `deploy/crds/*.yaml`. |
| 64 | + |
| 65 | +### 4. Docs |
| 66 | + |
| 67 | +Update `.claude/CHANGELOG.md` (with `**Author:**`) and any affected `docs/src/` |
| 68 | +pages / examples. Run the `sync-docs` skill to verify docs match the code. |
| 69 | + |
| 70 | +## When does ADD apply? |
| 71 | + |
| 72 | +**Full ADR + CALM** (architecturally significant): |
| 73 | + |
| 74 | +- New CRDs / CRD fields that change a contract, new controllers, reconcilers, or binaries |
| 75 | +- Changes to how 5-Spot interacts with CAPI (Machine / bootstrap / infrastructure contract, allowed API groups) |
| 76 | +- New deploy / admission / GitOps topology (e.g. ValidatingAdmissionPolicy posture, child-cluster routing) |
| 77 | +- Cross-cutting concerns: security boundaries, RBAC posture, failure domains, scheduling semantics |
| 78 | +- Any decision where "why A over B" is worth recording |
| 79 | + |
| 80 | +**ADR only, no CALM** (process / policy, no system-topology change): |
| 81 | + |
| 82 | +- Methodology, CI/CD policy, repository conventions |
| 83 | + |
| 84 | +**TDD only** (no ADR/CALM needed): |
| 85 | + |
| 86 | +- Typos, comment/doc tweaks, formatting |
| 87 | +- Isolated bug fixes with no architectural impact |
| 88 | +- Mechanical refactors that preserve behavior and structure |
| 89 | + |
| 90 | +> When unsure whether a change is "architectural," **write the ADR.** A short, |
| 91 | +> slightly-redundant ADR costs little; an undocumented architectural decision |
| 92 | +> costs the next person a re-derivation. |
| 93 | +
|
| 94 | +## Checklist (paste into the work) |
| 95 | + |
| 96 | +- [ ] ADR written/updated in `docs/adr/NNNN-*.md` (Status/Context/Decision/Consequences); index in `docs/adr/README.md` updated |
| 97 | +- [ ] CALM model updated; `make calm-validate` passes; `make calm-diagrams` renders — **or** ADR states "no CALM impact (process-only)" |
| 98 | +- [ ] Tests written **first**, then implementation (TDD); CRD changes regenerated via `regen-crds` → `regen-api-docs` |
| 99 | +- [ ] `cargo-quality` passes (fmt + clippy + test) |
| 100 | +- [ ] CHANGELOG (`**Author:**`) + docs updated; `sync-docs` clean |
0 commit comments