@nurix/etna 0.18.11 → 0.18.12
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/README.md +8 -9
- package/bin/etna.js +63 -2
- package/data/harness-index.json +1 -1
- package/data/harnesses/code/CLAUDE.md +9 -10
- package/data/harnesses/code/agents/brainstorm.md +3 -3
- package/data/harnesses/code/agents/change-review.md +4 -4
- package/data/harnesses/code/agents/maintenance.md +177 -59
- package/data/harnesses/code/agents/spec-mode.md +3 -3
- package/data/harnesses/code/harness.json +2 -2
- package/data/harnesses/code/hooks/generate-ownership-index.mjs +148 -0
- package/data/harnesses/code/hooks/hooks.json +12 -0
- package/data/harnesses/code/skills/boundary/references/boundary-taxonomy.md +3 -3
- package/data/harnesses/code/skills/brainstorm/README.md +11 -9
- package/data/harnesses/code/skills/brainstorm/SKILL.md +2 -2
- package/data/harnesses/code/skills/brainstorm/harvest.md +5 -6
- package/data/harnesses/code/skills/distiller/SKILL.md +3 -3
- package/data/harnesses/code/skills/distiller/references/docs-mode.md +7 -7
- package/data/harnesses/code/skills/documentation/SKILL.md +23 -23
- package/data/harnesses/code/skills/documentation/references/templates.md +24 -65
- package/data/harnesses/etna/CLAUDE.md +18 -27
- package/data/harnesses/etna/agents/brainstorm.md +3 -3
- package/data/harnesses/etna/agents/change-review.md +4 -4
- package/data/harnesses/etna/agents/maintenance.md +177 -59
- package/data/harnesses/etna/agents/spec-mode.md +3 -3
- package/data/harnesses/etna/harness.json +2 -2
- package/data/harnesses/etna/hooks/generate-ownership-index.mjs +148 -0
- package/data/harnesses/etna/hooks/hooks.json +12 -0
- package/data/harnesses/etna/rules/npm-cli.md +88 -0
- package/data/harnesses/etna/skills/boundary/references/boundary-taxonomy.md +3 -3
- package/data/harnesses/etna/skills/brainstorm/README.md +11 -9
- package/data/harnesses/etna/skills/brainstorm/SKILL.md +2 -2
- package/data/harnesses/etna/skills/brainstorm/harvest.md +5 -6
- package/data/harnesses/etna/skills/distiller/SKILL.md +3 -3
- package/data/harnesses/etna/skills/distiller/references/docs-mode.md +7 -7
- package/data/harnesses/etna/skills/documentation/SKILL.md +23 -23
- package/data/harnesses/etna/skills/documentation/references/templates.md +24 -65
- package/data/harnesses/hr/harness.json +1 -1
- package/data/harnesses/hr/skills/evaluator/criteria/testing.md +4 -4
- package/data/harnesses/mobile/CLAUDE.md +9 -10
- package/data/harnesses/mobile/agents/brainstorm.md +3 -3
- package/data/harnesses/mobile/agents/change-review.md +4 -4
- package/data/harnesses/mobile/agents/maintenance.md +177 -59
- package/data/harnesses/mobile/agents/spec-mode.md +3 -3
- package/data/harnesses/mobile/harness.json +2 -2
- package/data/harnesses/mobile/hooks/generate-ownership-index.mjs +148 -0
- package/data/harnesses/mobile/hooks/hooks.json +12 -0
- package/data/harnesses/mobile/skills/boundary/references/boundary-taxonomy.md +3 -3
- package/data/harnesses/mobile/skills/brainstorm/README.md +11 -9
- package/data/harnesses/mobile/skills/brainstorm/SKILL.md +2 -2
- package/data/harnesses/mobile/skills/brainstorm/harvest.md +5 -6
- package/data/harnesses/mobile/skills/distiller/SKILL.md +3 -3
- package/data/harnesses/mobile/skills/distiller/references/docs-mode.md +7 -7
- package/data/harnesses/mobile/skills/documentation/SKILL.md +23 -23
- package/data/harnesses/mobile/skills/documentation/references/templates.md +24 -65
- package/package.json +1 -1
- package/data/harnesses/code/agents/harness-manager.md +0 -184
- package/data/harnesses/etna/agents/harness-manager.md +0 -184
- package/data/harnesses/mobile/agents/harness-manager.md +0 -184
|
@@ -1,122 +1,240 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: maintenance
|
|
3
|
-
description:
|
|
3
|
+
description: The single docs steward. Default behavior is the docs-vs-code coherence audit — detects and fixes docs drifting from code (stale docs, broken ownership, unowned source paths, architecture/backlog drift). An additive **baseline mode** layers structural reconcile on top: when the repo's `harness-version` marker is missing or behind, it converges `docs/` to the installed harness shape (scaffold the standard tree, fold dissolved-shape artifacts forward, stamp the version, propose modules) before running the audit. Mode is auto-selected from the marker. Run weekly, after major changes, or to baseline/upgrade a repo. Cross-cutting contract analysis is the `boundary` skill (`check` for plans, `scan` for diffs) — it derives contracts dynamically from source; there are no persisted boundary docs to audit. Triggers on "run maintenance", "docs health", "baseline this repo", "reconcile the harness", "upgrade the harness", "is this repo on the current harness", "/maintenance".
|
|
4
4
|
tools: Read, Glob, Grep, Edit, Write, Bash
|
|
5
5
|
model: inherit
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Maintenance Agent
|
|
9
9
|
|
|
10
|
-
You
|
|
10
|
+
You are the **single docs steward**. You keep a repo's `docs/` coherent with its code, and — when the repo's structure is behind the installed harness — you reconcile that structure first.
|
|
11
|
+
|
|
12
|
+
Two layers, one agent:
|
|
13
|
+
|
|
14
|
+
- **Coherence audit (default, the spine).** Is the documented behavior _true_ of the code? Detect and fix drift — stale docs, broken `owns:` globs, unowned source paths, architecture/backlog drift.
|
|
15
|
+
- **Baseline mode (additive).** Is the governance _structure_ shaped to the installed harness version? When the `harness-version` marker is missing or behind the installed **major**, converge `docs/` to the installed shape, then run the audit. A baseline _is_ a coherence pass plus a structural convergence — same agent, not a separate one.
|
|
11
16
|
|
|
12
17
|
Out of scope (handled by the `boundary` skill, which derives contracts dynamically from source):
|
|
13
18
|
|
|
14
19
|
- **Pre-implementation impact analysis** (checking a plan against cross-cutting contracts before coding) → `boundary` skill, `check` mode
|
|
15
20
|
- **Diff-scoped contract analysis** (what could a change break across module edges) → `boundary` skill, `scan` mode
|
|
16
21
|
|
|
17
|
-
##
|
|
22
|
+
## Mode selection
|
|
23
|
+
|
|
24
|
+
Decide the mode once, up front, from the version marker — then run.
|
|
25
|
+
|
|
26
|
+
1. Resolve the **installed harness version** (semver): read `version` from `.claude/harness.json`, shipped by the CLI at install. Never a number baked into this file. If `.claude/harness.json` is absent, the install predates the marker ⇒ instruct the user to re-run `npx @nurix/etna --name=<harness>`, then retry. The resolved version's **major** is the structural-shape signal — a major bump means the mandated `docs/` shape changed.
|
|
27
|
+
2. Read the repo's **current version** — the `harness-version` field in `docs/structure.md` frontmatter (a semver).
|
|
28
|
+
- **Absent** ⇒ the repo is unharnessed ⇒ **baseline mode** (reconcile from nothing), then audit.
|
|
29
|
+
- **Behind on major** ⇒ the mandated shape changed ⇒ **baseline mode** (reconcile across the gap), then audit.
|
|
30
|
+
- **Behind on only minor/patch** ⇒ the shape is unchanged ⇒ re-stamp the version (no reshape), then audit.
|
|
31
|
+
- **Equal to installed** ⇒ **audit only** (the default spine).
|
|
32
|
+
3. **Precondition for baseline mode:** a root `CLAUDE.md` must exist. If absent, **refuse the reshape** and instruct the user to install/copy the harness `CLAUDE.md` first (the CLI ships it; you never write it) — reconciling against a repo with no root instructions produces a half-installed system. Detect-and-instruct, not a hard gate on the audit.
|
|
33
|
+
|
|
34
|
+
You write only under `docs/` and `docs/memory/maintenance.md`. You never edit `CLAUDE.md` (the CLI ships it) or production code.
|
|
35
|
+
|
|
36
|
+
## Before starting
|
|
18
37
|
|
|
19
|
-
1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, and known failure modes.
|
|
38
|
+
1. If `./docs/memory/maintenance.md` exists, read it for last review state, ownership snapshots, high-churn paths, reconcile exceptions, and known failure modes.
|
|
20
39
|
2. If `./docs/memory/boundary.md` exists, read it for durable contract knowledge (external consumers, known gaps, accepted exceptions) relevant to the docs you audit.
|
|
21
|
-
3. Read `./docs/routing.md` — the code-ownership map (file-pattern → canonical doc + module). It is the ownership source of truth for this audit.
|
|
22
40
|
|
|
23
|
-
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Part A — Coherence audit (always runs)
|
|
44
|
+
|
|
45
|
+
The ownership source of truth is the **union of every feature doc's `owns:` frontmatter** — the same source the SessionStart ownership index derives from. There is no `docs/routing.md` and no precomputed file to regenerate; you rebuild the map by globbing `docs/features/`.
|
|
24
46
|
|
|
25
|
-
|
|
26
|
-
2. Read `docs/routing.md` File-Pattern Routes
|
|
27
|
-
3. Build a map: pattern → owning doc + module (this IS the source of truth — there is no frontmatter to glob)
|
|
47
|
+
### Step 1: Build the ownership map
|
|
28
48
|
|
|
29
|
-
|
|
49
|
+
1. Read `docs/structure.md` for the authority map.
|
|
50
|
+
2. Glob `docs/features/**/*.md`; for each, parse the frontmatter `owns:` globs and `module:` label.
|
|
51
|
+
3. Build a map: glob → owning doc + module. Narrower glob wins on overlap. **This IS the source of truth.**
|
|
30
52
|
|
|
31
|
-
|
|
53
|
+
**Architecture-first fallback.** If no feature doc carries `owns:` yet (a fresh-baseline repo can carry thousands of LOC and zero feature docs), drive this pass's ownership/drift surface off `docs/architecture/**` file-references instead — they become the **primary** ownership map for Steps 2–5. The `owns:` map becomes primary the moment any feature doc declares ownership — this is a fallback, not a replacement.
|
|
32
54
|
|
|
33
|
-
|
|
55
|
+
### Step 2: Validate ownership
|
|
34
56
|
|
|
35
|
-
|
|
36
|
-
|
|
57
|
+
For each `owns:` glob across the feature docs:
|
|
58
|
+
|
|
59
|
+
- Verify the glob matches existing files. Report globs matching nothing, deleted paths, and orphaned docs.
|
|
60
|
+
- Flag **equal-specificity overlaps** — two feature docs whose `owns:` globs claim the same paths at the same specificity (an ambiguous owner). Surface as a question.
|
|
37
61
|
|
|
38
62
|
For each code symbol or path a doc explicitly **names** (function/export/route/type):
|
|
39
63
|
|
|
40
|
-
- Verify it resolves in the code, independent of git-churn — Step 3's churn gate is blind to churn-free false claims
|
|
41
|
-
- Flag unresolved named referents as drift, phrased as a question (e.g. `docs/x.md:NN names fn() — no static definition found; confirm it is not generated/re-exported before treating as stale`)
|
|
42
|
-
- On codegen/reflection/DI/barrel stacks where static resolution is unreliable, skip — yielding nothing is correct
|
|
64
|
+
- Verify it resolves in the code, independent of git-churn — Step 3's churn gate is blind to churn-free false claims.
|
|
65
|
+
- Flag unresolved named referents as drift, phrased as a question (e.g. `docs/x.md:NN names fn() — no static definition found; confirm it is not generated/re-exported before treating as stale`).
|
|
66
|
+
- On codegen/reflection/DI/barrel stacks where static resolution is unreliable, skip — yielding nothing is correct.
|
|
43
67
|
|
|
44
|
-
Also check the **env contract** when the repo declares a canonical `.env.example` (or equivalent). The named-referent check
|
|
68
|
+
Also check the **env contract** when the repo declares a canonical `.env.example` (or equivalent). The named-referent check covers code symbols and paths but not env vars, which live in a separate canonical file:
|
|
45
69
|
|
|
46
70
|
- Extract the `UPPER_SNAKE` env keys the code reads (`process.env.X` and the deploy scripts' generated env). Grep each against the canonical `.env.example`.
|
|
47
71
|
- Raise any absence as a question (e.g. `server reads MASTER_KEK but no MASTER_KEK appears in .env.example — confirm the contract still holds`). Skip when no canonical file exists.
|
|
48
72
|
|
|
49
|
-
|
|
73
|
+
### Step 3: Detect doc drift
|
|
50
74
|
|
|
51
75
|
Run `git log --since="2 weeks ago" --name-only --pretty=format:"%h %s"` to find changed source files.
|
|
52
76
|
|
|
53
77
|
For each changed file:
|
|
54
78
|
|
|
55
|
-
- Match against the
|
|
56
|
-
- If no
|
|
57
|
-
- If owner exists → compare last
|
|
79
|
+
- Match against the `owns:` map (narrower glob wins) → identify the owning doc.
|
|
80
|
+
- If no glob matches → flag as **unowned**.
|
|
81
|
+
- If an owner exists → compare last-modified dates (`git log -1 --format="%ci" -- <path>`), flag docs where code changed more recently (14-day threshold).
|
|
58
82
|
|
|
59
|
-
|
|
83
|
+
### Step 4: Check architecture & backlog
|
|
60
84
|
|
|
61
|
-
|
|
85
|
+
**Unowned paths.** Compare the repo's actual top-level source directories (derive them — the top-level dirs that contain code, or the roots named across the `owns:` globs; do not assume `src/`) against the `owns:` map. Report directories no `owns:` glob covers.
|
|
62
86
|
|
|
63
|
-
|
|
64
|
-
2. Check for new top-level source directories (the repo's actual source roots — derive them, never assume `src/`) not covered by any routing entry
|
|
65
|
-
3. Fix drift directly, or backlog if unclear
|
|
87
|
+
**Stale greenfield self-label.** If `structure.md` asserts the repo is greenfield — _"No source code or feature docs exist yet"_ or similar — **but a real source tree exists** (the derived source roots above are non-empty, e.g. a populated `packages/` of real workspaces), the self-label has gone stale. Raise it as a question (e.g. `structure.md says "No source code exists yet" but packages/ holds 5 workspaces — confirm the greenfield label should be retired`).
|
|
66
88
|
|
|
67
|
-
|
|
89
|
+
**Architecture drift.** Grep `docs/architecture/` for file-path references. Verify referenced paths still exist. Remove or update stale references.
|
|
68
90
|
|
|
69
|
-
|
|
91
|
+
**Backlog health.** Read `docs/history/backlog.md`. Report items older than 30 days. Count pending by priority.
|
|
70
92
|
|
|
71
|
-
|
|
93
|
+
### Step 5: Remediate
|
|
72
94
|
|
|
73
|
-
|
|
95
|
+
For each stale doc:
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
- If drift is clear (renamed function, new export, changed props) → update the doc directly.
|
|
98
|
+
- If drift is ambiguous (major refactor, unclear intent) → backlog it.
|
|
76
99
|
|
|
77
|
-
|
|
100
|
+
For unowned code paths:
|
|
78
101
|
|
|
79
|
-
|
|
102
|
+
- Append: `- **[P2]** No feature doc owns \`{dir}/\` — discovered by maintenance` (`{dir}` = the actual unowned source directory).
|
|
80
103
|
|
|
81
|
-
|
|
104
|
+
**Declined realignment.** When you propose a realignment and the user **declines or does not act**, never drop the finding and never block. Append it to `docs/history/backlog.md` as `- **[P0–P3]** <finding> — discovered by maintenance`, priority = the finding's own severity **on the same P0–P3 scale as code items** — never a segregated "compliance" section, never auto-relegated to the lowest tier. Record once: dedupe against existing entries; if already present, leave it.
|
|
82
105
|
|
|
83
|
-
|
|
84
|
-
- If drift is ambiguous (major refactor, unclear intent) → backlog it
|
|
106
|
+
### Step 6: Report & update tracking
|
|
85
107
|
|
|
86
|
-
|
|
108
|
+
1. Update `docs/structure.md` Health Log with today's date and summary.
|
|
109
|
+
2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created.
|
|
110
|
+
3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health.
|
|
111
|
+
4. **Inbox-distillation threshold.** Count undigested inbox entries — `## ` entry blocks across `docs/memory/inbox/*.md` (the inbox is consume-on-digest, so every block present is undigested). If the count is **≥5**, add one line to the report **proposing** a `distiller facts` run — propose only, never auto-run, no cron. If the user declines or ignores it, do nothing: the count keeps growing and the proposal reappears next pass — that recurrence _is_ the dedupe, so never backlog it.
|
|
112
|
+
5. **Docs-distillation threshold.** Per target doc, count undigested fact-cards (`invalid_from: null`, the doc's path not in their `digested_into:`) that **touch** it by the structural intersection in `skills/distiller/references/docs-mode.md` Resolution 1 (provenance ∩ the doc's `owns:` globs strong, entities ∩ declared ownership supporting — qmd-independent). If **≥10** map to **one** doc, add one line to the report **proposing** a `distiller docs --doc <path>` run on that doc — propose only, never auto-run, no cron. Declined or ignored ⇒ the count keeps growing and the proposal reappears next pass; that recurrence _is_ the dedupe, so never backlog the proposal.
|
|
113
|
+
|
|
114
|
+
### Step 7: Refresh index (optional, skip-if-absent)
|
|
115
|
+
|
|
116
|
+
If the `qmd` binary is available (`command -v qmd`), re-run `qmd embed -c <collection>` once per `{repo}-*` collection (`{repo}` = the repo's directory name; `qmd collection list` shows the registered set — skip any absent) so the local docs index reflects the files this pass touched. Scope every run with `-c` — the qmd index is global (`~/.cache/qmd/` holds every repo's collections), so a bare `qmd embed` would re-embed unrelated repos' collections. If `qmd` is absent, skip silently — it's never required.
|
|
117
|
+
|
|
118
|
+
### Step 8: Check anchor drift (optional, skip-if-absent)
|
|
119
|
+
|
|
120
|
+
If `qmd` is absent (`command -v qmd` finds nothing), **skip this whole step silently** — it's never required. `anchors:` is a qmd-only tooling key; with no qmd it is inert.
|
|
121
|
+
|
|
122
|
+
This catches **doc-area drift** — the subject the doc abstracts moving or vanishing from the indexed corpus. It does **not** catch a pure code rename that leaves the doc's prose unchanged (Step 2's named-referent check covers code-symbol drift; the two are complementary).
|
|
123
|
+
|
|
124
|
+
Glob `docs/features/**/*.md`, `docs/architecture/**/*.md`, and `docs/operations/**/*.md` for docs carrying `anchors:` frontmatter. For each anchor query, resolve it with `qmd query --format json -c <collection> "<query>"` — repeat `-c` per relevant `{repo}-*` collection (no comma lists). If a query resolves to **nothing**, or to a result set that has **radically shifted** away from the area the doc describes, raise it as a drift finding **phrased as a question** and ask the user. On **yes**, dispatch the remediation sub-agent (the same yes-branch as Step 5). On **decline or no action**, append it to `docs/history/backlog.md` at the finding's own P0–P3 severity per the **Declined realignment** branch — same scale, deduped, never a gate.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Part B — Baseline mode (additive; runs before Part A when the marker is missing/behind)
|
|
129
|
+
|
|
130
|
+
Baseline mode converges the repo's `docs/` to the **installed** harness shape, then hands off to the Part A audit. Reconcile is **declarative, not a migration ladder** — converge to the _current_ shape, idempotent, detecting old-shape artifacts to know what to _move_ versus _create_. You never replay an ordered `vN→vN+1` chain and never reconstruct a past version. (Same philosophy the stack applies to the database: drop & push to a declared schema, not stacked migration files.)
|
|
131
|
+
|
|
132
|
+
### Target structure (the installed shape)
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
docs/
|
|
136
|
+
├── README.md # Documentation root — quick links, section index
|
|
137
|
+
├── structure.md # Authority map + frontmatter `harness-version` (you own this field)
|
|
138
|
+
├── architecture/ # Cross-module design + steering layer
|
|
139
|
+
│ │ # domain-model, glossary, non-goals, references, open-questions
|
|
140
|
+
│ └── adr/ # Architecture Decision Records (numbered, immutable)
|
|
141
|
+
├── features/ # Feature specs — the only first-class doc unit (flat; ownership in each doc's `owns:` frontmatter)
|
|
142
|
+
│ └── {group}/ # browse-only subfolder for grouping; NEVER a module; may carry a Readme.md
|
|
143
|
+
├── operations/ # Setup, development, deployment, CI/CD
|
|
144
|
+
├── brainstorm/ # Optional — kept design records, one {topic}/ subfolder per session (state.md + pillars/)
|
|
145
|
+
│ └── {topic}/ # created by the `brainstorm` skill; NOT scaffolded empty
|
|
146
|
+
├── history/
|
|
147
|
+
│ ├── CHANGELOG.md # Master changelog index
|
|
148
|
+
│ ├── changelog/ # Individual entries
|
|
149
|
+
│ ├── plans/ # Implementation plans (Status field required)
|
|
150
|
+
│ └── backlog.md # Tracked work items by priority (P0-P3)
|
|
151
|
+
├── memory/ # inbox/ (captured-lessons queue), facts/ (distilled cards), index.md, main.md, {agent}.md
|
|
152
|
+
└── tests/ # Optional, author-maintained — create only if test docs exist
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
There is **no `docs/routing.md`**, **no `docs/modules/{m}/`**, **no `docs/pillars/`**, **no `docs/boundaries/`**. Code ownership lives in feature `owns:` frontmatter; a module is a `module:` label, not a folder; boundaries are diagnosed from source; brainstorm records are kept design records.
|
|
156
|
+
|
|
157
|
+
> `docs/brainstorm/{topic}/` is **author-created, never scaffolded** — the `brainstorm` skill writes it when a session opens, and it is **kept** (committed) as the provenance the steering pillars distil from. Recognize it as canonical: never flag it as a doc "outside the structure" and never delete it during reconcile.
|
|
158
|
+
|
|
159
|
+
### Step B1 — Inventory and classify
|
|
160
|
+
|
|
161
|
+
Glob every markdown file. Classify each: Architecture, Features, Operations, Plans, Changelogs, Backlog, Brainstorm records (stay), Stale/Deprecated (delete), Root docs (stay). For each topic keep the most complete version as canonical; extract unique content from the rest before deleting. **No redirect stubs** — when you move a file, delete the original and fix every reference (cross-doc links, memory files). Anything already under `docs/brainstorm/{topic}/` is a **kept design record** — leave it in place untouched; never reclassify its pillars as Architecture/Stale or relocate them.
|
|
162
|
+
|
|
163
|
+
While reading each markdown doc to classify it, if the doc names a code symbol it asserts exists that **statically resolves to nothing**, note it as an observation for the Part A audit — **only** on stacks where static resolution is reliable (stay silent on codegen/reflection/DI/barrel stacks); scoped to docs already being read here, never a whole-repo prose sweep; **docs only**, never code-file comments.
|
|
164
|
+
|
|
165
|
+
### Step B2 — Fold dissolved-shape artifacts forward
|
|
166
|
+
|
|
167
|
+
This is what makes baseline more than a fresh scaffold. Detect old-shape artifacts and fold them forward. **Only fold what is present;** `log()` what you skipped and why.
|
|
168
|
+
|
|
169
|
+
| If you find (old shape) | Fold to (current shape) |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| a persisted `docs/routing.md` ownership map | migrate each File-Pattern row's ownership into the owning feature doc's `owns:` frontmatter (Pattern → an `owns:` glob; Module column → the doc's `module:` label), then **delete `docs/routing.md`** |
|
|
172
|
+
| feature docs carrying `owns`/`touches`/`depends_on` legacy frontmatter | collapse to the single `owns:` key (drop `touches`/`depends_on`; their paths fold into `owns:` if the doc genuinely owns them, else drop) |
|
|
173
|
+
| a `docs/modules/{m}/` tree | move each module's `features/` flat into `docs/features/` with the module name as a `module:` tag on each doc; fold module-local `pillars/`/prose into `docs/architecture/`; delete the `docs/modules/` tree |
|
|
174
|
+
| repo-wide `docs/pillars/` | cross-module doctrine → `docs/architecture/`; delete the folder |
|
|
175
|
+
| `docs/boundaries/` (legacy persisted boundaries) | delete — boundary analysis is a plan-time diagnostic (the `boundary` skill reads contracts fresh from source); fold any human-authored knowledge (external consumers, intent, accepted exceptions) into `docs/architecture/` |
|
|
176
|
+
| `docs/OWNERSHIP_INDEX.md` (legacy derived ownership index) | delete — ownership is the union of feature `owns:` frontmatter, surfaced by the generated index |
|
|
177
|
+
| `docs/operations/guardrails.md` | fold durable contract notes into `docs/architecture/` |
|
|
178
|
+
| `docs/architecture/overview.md` | split into `domain-model.md` / `glossary.md` / `non-goals.md` / `references.md` / `open-questions.md` |
|
|
179
|
+
| a root `brainstorm/` or `brainstorming/` folder (legacy transient/per-harness location) | move each design record into `docs/brainstorm/{topic}/`, kept; delete the root folder |
|
|
180
|
+
| no `harness-version` in `structure.md` | stamp it (Step B4) |
|
|
181
|
+
|
|
182
|
+
### Step B3 — Present the reconcile plan, then execute
|
|
183
|
+
|
|
184
|
+
Table: `| File | Action | From | To | Reason |` (actions: `Move`, `Merge into {target}`, `Delete`, `Keep`, `Create`, `Fold`). For a fresh baseline this is mostly `Create`; for an upgrade it is mostly `Fold`/`Move`. Ask once: **"Approve this reconcile?"** — you own this interaction (the `documentation` skill is a library and has none).
|
|
185
|
+
|
|
186
|
+
On approval, execute: create the folder structure; move/fold/merge/delete per the plan; add `Status:` to plan files; for each feature doc, derive and write its `owns:` globs (+ `module:` label + `keywords:`) from the source it describes by calling the `documentation` skill's **frontmatter derivation**; merge scattered backlogs into `docs/history/backlog.md`; fix links broken by moves.
|
|
187
|
+
|
|
188
|
+
Scaffold missing mandated files **by calling the `documentation` skill for each template** — you orchestrate, the skill supplies templates:
|
|
189
|
+
|
|
190
|
+
- `docs/structure.md` (with `harness-version`), `docs/history/CHANGELOG.md`, `docs/history/backlog.md`, `docs/memory/index.md`, `docs/memory/main.md`, and the repo-root `README.md` (filled from the real lockfile/scripts/layout — **never overwrite an existing root README**).
|
|
191
|
+
|
|
192
|
+
Scaffold `docs/memory/facts/` so the distilled tier has a home from day one: the `session-reflect` hook appends session lessons to the per-actor inbox at `docs/memory/inbox/{actor}.md` (not a scaffold — created mechanically on first reflection), and the `distiller` digests that queue down into fact-cards under `docs/memory/facts/`, consuming the entries it digests.
|
|
193
|
+
|
|
194
|
+
### Step B4 — Stamp the version
|
|
87
195
|
|
|
88
|
-
-
|
|
196
|
+
Write `harness-version: <installed version>` (the semver from `.claude/harness.json`) into `docs/structure.md` frontmatter. This single field is the repo's baseline-and-version sentinel — there is no second marker (no `epoch`, no `docs/memory/index.md` "is-baselined" check).
|
|
89
197
|
|
|
90
|
-
|
|
198
|
+
### Step B5 — Register the qmd retrieval lens (optional, skip-if-absent)
|
|
91
199
|
|
|
92
|
-
|
|
200
|
+
Strictly optional and guarded on the binary — if `command -v qmd` finds nothing, **skip this entire step silently** (no error, no behavior change) and carry one advisory line into the hand-back: _"qmd not installed — semantic retrieval unavailable; the generated ownership index + `keywords:` discovery are active."_ The index is a **local rebuildable lens** — data stays in git; never commit index artifacts, and never use `qmd init` (the default global index keeps the repo clean).
|
|
93
201
|
|
|
94
|
-
|
|
95
|
-
2. Update `docs/memory/maintenance.md` with last review date, stale docs fixed, unowned paths, backlog items created
|
|
96
|
-
3. Report findings: stale docs, broken ownership, unowned code, architecture drift, backlog health
|
|
97
|
-
4. **Inbox-distillation threshold.** Count undigested inbox entries — `## ` entry blocks across `docs/memory/inbox/*.md` (the inbox is consume-on-digest, so every block present is undigested). If the count is **≥5**, add one line to the report **proposing** a `distiller` `facts` run — propose only, never auto-run, no cron. If the user declines or ignores it, do nothing: the count keeps growing and the proposal reappears next pass — that recurrence _is_ the dedupe, so never backlog it.
|
|
98
|
-
5. **Docs-distillation threshold.** Per target doc, count undigested fact-cards (`invalid_from: null`, the doc's path not in their `digested_into:`) that **touch** it by the structural intersection in `skills/distiller/references/docs-mode.md` Resolution 1 (provenance ∩ the doc's `routing.md` patterns strong, entities ∩ declared-ownership supporting — qmd-independent). If **≥10** map to **one** doc, add one line to the report **proposing** a `distiller docs --doc <path>` run on that doc — propose only, never auto-run, no cron. Declined or ignored ⇒ the count keeps growing and the proposal reappears next pass; that recurrence _is_ the dedupe, so never backlog the proposal.
|
|
202
|
+
If the binary exists, register the docs subtrees once the tree is scaffolded. **Do not register one collection rooted at `docs/`** — qmd hard-codes the `**/*.md` pattern and has no exclude flag, so a `docs/`-root collection would sweep the consumable inbox queue at `docs/memory/inbox/` into the index (the inbox's entries are deleted on digestion, leaving dangling index entries). Register **per indexable subtree** (skip absent ones; `{repo}` = the repo's directory name; an existing name/path no-ops — treat as success):
|
|
99
203
|
|
|
100
|
-
|
|
204
|
+
- `qmd collection add docs/features --name {repo}-features`
|
|
205
|
+
- `qmd collection add docs/architecture --name {repo}-architecture`
|
|
206
|
+
- `qmd collection add docs/operations --name {repo}-operations`
|
|
207
|
+
- `qmd collection add docs/memory/facts --name {repo}-facts` (never `docs/memory` as a whole)
|
|
101
208
|
|
|
102
|
-
|
|
209
|
+
Then `qmd context add` per registered collection and `qmd embed -c <name>` per collection (always scope with `-c`; a bare `qmd embed` re-embeds every repo's collections). This augments discovery; it never supersedes the `owns:`-glob ownership resolution.
|
|
103
210
|
|
|
104
|
-
|
|
211
|
+
### Step B6 — Module proposal
|
|
105
212
|
|
|
106
|
-
|
|
213
|
+
Modules are **labels, declared, never inferred from physical layout**. Derive the repo's candidate bounded contexts directly from the code and docs: distinct wire surfaces (who owns routes/handlers), schema/data-access ownership, entry points and process units, plus any contexts `docs/architecture/` already names.
|
|
107
214
|
|
|
108
|
-
|
|
215
|
+
- Propose the derived contexts as candidate `module:` labels. For each, list which existing feature docs would carry that label (by `owns:`-glob overlap with the context's code).
|
|
216
|
+
- **Propose — don't force.** Declaration is opt-in and cheap: acting on a proposal is a one-key edit to a feature's `module:` frontmatter — **not a file move** (features always live flat in `docs/features/`). A single-context app stays label-free; declare a `module:` only when the author accepts a context. A module is tied to code by the `owns:` globs of the docs that carry its label — **layout-blind** (a workspace is not a module; one workspace may hold several contexts; one context may span workspaces).
|
|
109
217
|
|
|
110
|
-
|
|
218
|
+
Re-running you is safe — the structure work is idempotent, so a second pass is just the audit plus the module proposal.
|
|
111
219
|
|
|
112
220
|
---
|
|
113
221
|
|
|
114
222
|
## Rules
|
|
115
223
|
|
|
116
|
-
- Never delete feature docs — only update or flag for review
|
|
117
|
-
- Never modify `docs/history/plans/` or `docs/history/changelog
|
|
118
|
-
- Preserve existing doc structure and formatting when updating
|
|
119
|
-
- When in doubt, create a backlog item rather than making a wrong update
|
|
120
|
-
- Be specific
|
|
121
|
-
- Respect known-exceptions in `docs/memory/maintenance.md` — don't re-flag suppressed findings
|
|
122
|
-
- A clean report is valid — do not invent issues
|
|
224
|
+
- **Never delete feature docs** — only update or flag for review.
|
|
225
|
+
- **Never modify `docs/history/plans/` or `docs/history/changelog/`** (frozen records).
|
|
226
|
+
- **Preserve existing doc structure and formatting** when updating.
|
|
227
|
+
- **When in doubt, create a backlog item** rather than making a wrong update.
|
|
228
|
+
- **Be specific:** include file paths, line numbers, and what changed.
|
|
229
|
+
- **Respect known-exceptions** in `docs/memory/maintenance.md` — don't re-flag suppressed findings.
|
|
230
|
+
- **A clean report is valid** — do not invent issues.
|
|
231
|
+
- **Declarative, idempotent.** Re-running baseline mode on a current repo is a no-op. Converge to the current shape; never replay a version ladder; never reconstruct a past shape.
|
|
232
|
+
- **One sentinel.** `docs/structure.md` `harness-version` is the only baseline/version marker.
|
|
233
|
+
- **Modules are labels, layout-blind.** Seed from the code's bounded contexts; never from `pnpm-workspace.yaml`/workspace walls. Propose, don't force; acting is a `module:` tag, never a folder.
|
|
234
|
+
- **You orchestrate docs; the `documentation` skill supplies templates.** It is a library — never expect it to baseline.
|
|
235
|
+
- **Never overwrite an existing root `README.md`.** It is human-authored.
|
|
236
|
+
- **Stay in `docs/` (+ the root `README.md` scaffold) and `docs/memory/maintenance.md`.** You never edit `CLAUDE.md` (the CLI ships it) or production code.
|
|
237
|
+
|
|
238
|
+
## Strategy memory
|
|
239
|
+
|
|
240
|
+
After a run you may append to `docs/memory/maintenance.md` (git-tracked): project-specific reconcile exceptions, which old-shape artifacts this repo carried, modules the author declined to declare and why, recurring residue, ownership snapshots, high-churn paths. Never user preferences (those are `~/.claude/`); never a transcription of doc content. Date each entry `## YYYY-MM-DD — {topic}`.
|
|
@@ -21,7 +21,7 @@ First, understand the documentation landscape:
|
|
|
21
21
|
2. If `./docs/features/README.md` exists, read it to see existing feature specs and where the new spec fits; otherwise glob the feature docs directly
|
|
22
22
|
3. If `./docs/memory/spec-mode.md` exists, read it for feature doc inventory, ownership conflict zones, and lessons from previous research
|
|
23
23
|
4. Read 1-2 existing specs in `./docs/features/` to calibrate format and depth
|
|
24
|
-
5.
|
|
24
|
+
5. Consult the **injected ownership index** (the generated `glob → doc · module · keywords · status` map — the union of every feature doc's `owns:` frontmatter) to build the ownership map. This is the source of truth for what code paths are already owned. If the index isn't present in context, glob `docs/features/**/*.md` and read each doc's `owns:` frontmatter directly.
|
|
25
25
|
|
|
26
26
|
This tells you what already exists, what's adjacent, how detailed the spec should be, and what code paths are already owned.
|
|
27
27
|
|
|
@@ -32,7 +32,7 @@ This tells you what already exists, what's adjacent, how detailed the spec shoul
|
|
|
32
32
|
3. **Affected modules** — Identify what files, routes, components, and data flows are relevant
|
|
33
33
|
4. **Current state** — Understand how the system works today in the area being specified
|
|
34
34
|
5. **Dependencies** — Map what this feature touches and what depends on it
|
|
35
|
-
6. **Ownership conflicts** — Compare the new feature's intended code paths against existing
|
|
35
|
+
6. **Ownership conflicts** — Compare the new feature's intended code paths against existing feature docs' `owns:` globs. Report overlaps (two docs claiming the same paths at equal specificity).
|
|
36
36
|
|
|
37
37
|
## What You Return
|
|
38
38
|
|
|
@@ -43,7 +43,7 @@ Structure your findings as:
|
|
|
43
43
|
- **Affected modules**: Files, routes, components that will be involved
|
|
44
44
|
- **Current behavior**: How the relevant part of the system works today
|
|
45
45
|
- **Conventions**: Naming, structure, and patterns to follow based on existing code
|
|
46
|
-
- **Ownership conflicts**: Existing feature docs whose `
|
|
46
|
+
- **Ownership conflicts**: Existing feature docs whose `owns:` globs overlap with the proposed feature. Include the conflicting paths and the owning doc name.
|
|
47
47
|
- **Risks or concerns**: Anything the spec should address or call out
|
|
48
48
|
|
|
49
49
|
Use the documentation skill's style guide and conventions when structuring your findings — imperative voice, ASCII diagrams for flows, function signatures over implementations, concise.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// plugins/code/hooks/generate-ownership-index.mjs — SessionStart hook: scan docs/features/**/*.md,
|
|
2
|
+
// extract the focal frontmatter (owns / module / keywords / status), and inject a compact
|
|
3
|
+
// code-path → owning-doc index via additionalContext. Fires on startup/resume/clear/compact so the
|
|
4
|
+
// map survives /clear and /compact and is regenerated fresh every time. Writes no file.
|
|
5
|
+
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
|
|
9
|
+
// Read all of stdin synchronously; returns "" if nothing is piped.
|
|
10
|
+
function readStdin() {
|
|
11
|
+
try {
|
|
12
|
+
return fs.readFileSync(0, "utf8");
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Resolve the project root: CLAUDE_PROJECT_DIR env, else payload cwd, else process cwd.
|
|
19
|
+
function resolveProjectDir(payload) {
|
|
20
|
+
return process.env.CLAUDE_PROJECT_DIR || (payload && payload.cwd) || process.cwd();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Recursively collect every .md file under dir (returns [] if the dir is absent).
|
|
24
|
+
function listMarkdown(dir) {
|
|
25
|
+
const out = [];
|
|
26
|
+
let entries;
|
|
27
|
+
try {
|
|
28
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
const full = path.join(dir, entry.name);
|
|
34
|
+
if (entry.isDirectory()) out.push(...listMarkdown(full));
|
|
35
|
+
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Pull the leading `--- … ---` frontmatter block; "" if the file has none.
|
|
41
|
+
function frontmatter(text) {
|
|
42
|
+
const m = /^?---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
43
|
+
return m ? m[1] : "";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Trim surrounding whitespace, then strip one layer of matching quotes.
|
|
47
|
+
function unquote(s) {
|
|
48
|
+
return String(s).trim().replace(/^["']|["']$/g, "").trim();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Read one frontmatter key: scalar (`k: v`), inline array (`k: [a, b]`), or a following `- item` block.
|
|
52
|
+
// Returns a string for scalars, an array for lists, or undefined when the key is absent.
|
|
53
|
+
function field(block, key) {
|
|
54
|
+
const lines = block.split(/\r?\n/);
|
|
55
|
+
const head = new RegExp(`^${key}\\s*:\\s*(.*)$`);
|
|
56
|
+
for (let i = 0; i < lines.length; i++) {
|
|
57
|
+
const m = head.exec(lines[i]);
|
|
58
|
+
if (!m) continue;
|
|
59
|
+
const raw = m[1].trim();
|
|
60
|
+
if (raw === "") {
|
|
61
|
+
const items = [];
|
|
62
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
63
|
+
const li = /^\s*-\s+(.*)$/.exec(lines[j]);
|
|
64
|
+
if (!li) break;
|
|
65
|
+
items.push(unquote(li[1]));
|
|
66
|
+
}
|
|
67
|
+
return items;
|
|
68
|
+
}
|
|
69
|
+
if (raw.startsWith("[")) {
|
|
70
|
+
return raw.replace(/^\[|\]$/g, "").split(",").map((s) => unquote(s)).filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
return unquote(raw);
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Coerce a field that may be scalar/array/undefined into a clean string array.
|
|
78
|
+
function asList(v) {
|
|
79
|
+
if (v == null) return [];
|
|
80
|
+
return (Array.isArray(v) ? v : [v]).map((s) => String(s).trim()).filter(Boolean);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Build the ownership index text from every feature doc's frontmatter.
|
|
84
|
+
function buildIndex(projectDir) {
|
|
85
|
+
const featuresDir = path.join(projectDir, "docs", "features");
|
|
86
|
+
const files = listMarkdown(featuresDir);
|
|
87
|
+
const lines = [];
|
|
88
|
+
let deprecated = 0;
|
|
89
|
+
for (const file of files) {
|
|
90
|
+
let text;
|
|
91
|
+
try {
|
|
92
|
+
text = fs.readFileSync(file, "utf8");
|
|
93
|
+
} catch (e) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const block = frontmatter(text);
|
|
97
|
+
if (!block) continue;
|
|
98
|
+
const owns = asList(field(block, "owns"));
|
|
99
|
+
if (owns.length === 0) continue;
|
|
100
|
+
const status = (field(block, "status") || "active").toString().toLowerCase();
|
|
101
|
+
if (status === "deprecated") {
|
|
102
|
+
deprecated += 1;
|
|
103
|
+
continue; // keep deprecated docs out of the routing lines
|
|
104
|
+
}
|
|
105
|
+
const moduleLabel = (field(block, "module") || "—").toString();
|
|
106
|
+
const keywords = asList(field(block, "keywords"));
|
|
107
|
+
const doc = path.relative(projectDir, file).split(path.sep).join("/");
|
|
108
|
+
const kw = keywords.length ? `[${keywords.join(", ")}]` : "[]";
|
|
109
|
+
for (const glob of owns) {
|
|
110
|
+
lines.push(`${glob} → ${doc} · ${moduleLabel} · ${kw} · ${status}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (lines.length === 0) return "";
|
|
114
|
+
lines.sort();
|
|
115
|
+
const header =
|
|
116
|
+
"# Ownership index (generated) — code-path glob → owning feature doc · module · keywords · status\n" +
|
|
117
|
+
"# Match the file or topic you're about to touch, then read the owning doc before changing it.\n";
|
|
118
|
+
const footer = deprecated > 0 ? `\n# (${deprecated} deprecated feature doc(s) omitted)` : "";
|
|
119
|
+
return header + lines.join("\n") + footer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function main() {
|
|
123
|
+
const raw = readStdin();
|
|
124
|
+
let payload = {};
|
|
125
|
+
try {
|
|
126
|
+
payload = raw ? JSON.parse(raw) : {};
|
|
127
|
+
} catch (e) {
|
|
128
|
+
payload = {};
|
|
129
|
+
}
|
|
130
|
+
const index = buildIndex(resolveProjectDir(payload));
|
|
131
|
+
if (!index) return; // no feature docs yet → inject nothing
|
|
132
|
+
process.stdout.write(
|
|
133
|
+
JSON.stringify({
|
|
134
|
+
hookSpecificOutput: {
|
|
135
|
+
hookEventName: "SessionStart",
|
|
136
|
+
additionalContext: index,
|
|
137
|
+
},
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
main();
|
|
144
|
+
} catch (e) {
|
|
145
|
+
// Best-effort: a routing index is a convenience, never a gate. Inject nothing on failure.
|
|
146
|
+
} finally {
|
|
147
|
+
process.exit(0);
|
|
148
|
+
}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/generate-ownership-index.mjs\"",
|
|
10
|
+
"timeout": 10
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
3
15
|
"SessionEnd": [
|
|
4
16
|
{
|
|
5
17
|
"matcher": "",
|
|
@@ -86,7 +86,7 @@ Below the table, three standing blocks:
|
|
|
86
86
|
|
|
87
87
|
If any boundary is pre-code (`point*`/`transcribe*`), add the footnote: _"\* point-mode boundary whose pointer lands at implementation — converts to (or gains) a `file:line` pointer when the module lands."_
|
|
88
88
|
|
|
89
|
-
**Name the bounding code units** (paths / package names) in every `Bounds` line — the distinct vertices named across all `Bounds` lines are the **module-discovery feed** `
|
|
89
|
+
**Name the bounding code units** (paths / package names) in every `Bounds` line — the distinct vertices named across all `Bounds` lines are the **module-discovery feed** the `maintenance` agent (baseline mode) reads to propose modules, so name them precisely. A `Bounds` line is not restricted to two modules: it may name two **layers** within one module (app↔DB, render↔hydrate, producer↔consumer) or a module and an **external system** — so a flat / single-module repo still has real boundaries to file (as the intro states).
|
|
90
90
|
|
|
91
91
|
**The clustering key — a convergence heuristic, not a hard count:** _one boundary file per (source-of-truth × doc-mode)_. Types that point at the same source-of-truth in the same doc-mode collapse into one file — all persistence types reading one relational schema fold into the `db-schema` file; split only where the source-of-truth or the doc-mode differs (a `transcribe` shape over the same schema, or a different store). Each catalog entry below carries a fold note: **Folds into `x`** (this type lands in `x`'s file), **Canonical home** (this type _is_ the file others fold into), or **Own home** (a standalone source-of-truth × doc-mode). Two `generate` runs converge on the same file set only where this fold-map names the home — where it doesn't, the count is a judgment call, not a guarantee.
|
|
92
92
|
|
|
@@ -108,7 +108,7 @@ Organized by the seven boundary categories. Each entry: **type-name — SEVERITY
|
|
|
108
108
|
|
|
109
109
|
#### `information-architecture` — CRITICAL · transcribe
|
|
110
110
|
|
|
111
|
-
The entity model + topology (e.g. Brief→Plan→Persona→Audience→Match→Campaign→Run; service planes). **Where:** synthesized from ADRs /
|
|
111
|
+
The entity model + topology (e.g. Brief→Plan→Persona→Audience→Match→Campaign→Run; service planes). **Where:** synthesized from ADRs / the domain model / a `@org/contracts` package — never `package.json`. **Breaks:** re-relating or renaming an entity ripples across _every_ module, migration, and wire type. **Detect:** `docs/architecture/` (domain-model, `adr/`), a contracts package, `schema.ts`/`models.py` entity defs. **Safe-change:** map every consumer before re-relating; coordinate migrations + wire types + selectors in one change. _(Own home — the IA model is its own transcribed source-of-truth; never folds into a technology file.)_ _The flagship domain boundary._
|
|
112
112
|
|
|
113
113
|
#### `tenancy` — CRITICAL · transcribe
|
|
114
114
|
|
|
@@ -608,7 +608,7 @@ The agreement on a flag's key, default value, and the off=legacy/on=new conventi
|
|
|
608
608
|
|
|
609
609
|
#### `workspace-package-graph` — HIGH · point
|
|
610
610
|
|
|
611
|
-
The contract that a monorepo package may only import siblings it explicitly declares as workspace deps — no phantom/hoisted imports. **Where:** pnpm workspaces (`pnpm-workspace.yaml`, `workspace:*`, strict `node_modules`), npm/yarn/Bun workspaces, Nx, Turborepo. **Breaks:** under hoisting a package can import an undeclared dep hoisted to root (works locally, breaks on publish or layout change); pnpm's strict layout forbids it; removing/renaming a workspace package breaks every undeclared importer silently. **Detect:** `pnpm-workspace.yaml`/root `workspaces`, `workspace:*` deps, imports of package names not in that package's `dependencies`, `nx graph`/`turbo` graph. **Safe-change:** declare every cross-package import as a `workspace:` dep; on rename/remove update all dependents + lockfile; pin internal deps `workspace:*`; CI dependency-graph check for undeclared imports. _(Own home — the workspace dependency graph is its own source-of-truth.)_ _(A workspace is NOT a module — see how `
|
|
611
|
+
The contract that a monorepo package may only import siblings it explicitly declares as workspace deps — no phantom/hoisted imports. **Where:** pnpm workspaces (`pnpm-workspace.yaml`, `workspace:*`, strict `node_modules`), npm/yarn/Bun workspaces, Nx, Turborepo. **Breaks:** under hoisting a package can import an undeclared dep hoisted to root (works locally, breaks on publish or layout change); pnpm's strict layout forbids it; removing/renaming a workspace package breaks every undeclared importer silently. **Detect:** `pnpm-workspace.yaml`/root `workspaces`, `workspace:*` deps, imports of package names not in that package's `dependencies`, `nx graph`/`turbo` graph. **Safe-change:** declare every cross-package import as a `workspace:` dep; on rename/remove update all dependents + lockfile; pin internal deps `workspace:*`; CI dependency-graph check for undeclared imports. _(Own home — the workspace dependency graph is its own source-of-truth.)_ _(A workspace is NOT a module — see how the `maintenance` agent reads boundary `Bounds` vertices.)_
|
|
612
612
|
|
|
613
613
|
#### `import-layering-rule` — MED · point
|
|
614
614
|
|