Commit a9dab40
authored
feat: report truncated ADR briefings, trim the ADR corpus 15.6%, add GEN-005 briefing budget (#501)
## Summary
A second trim sweep, this time over the **ADRs and agent memory** — and
the discovery that trimming alone was treating a symptom.
`review-context --verbose` extracts each ADR's `Decision` and `Do's and
Don'ts` and **truncates both at 2,000 characters**. Everything past that
never reaches the agent the ADR governs, and it was announced only by an
inline marker buried in the prose. Governance that never arrived read as
governance that passed — `archgate check` stays green because companion
rules do not measure prose.
So this PR does three things: reports the truncation, shrinks the corpus
so it happens less, and adds a rule so it does not silently come back.
## 1. Truncation is now reported, not hidden
| Signal | Audience |
| ------------------------------------- |
--------------------------------------------------------- |
| `truncatedSections` per ADR briefing | machine — names which sections
were cut |
| `truncatedBriefings` at the top level | machine — affected ids without
walking every domain |
| stderr warning via `logWarn` | human — stdout stays parseable for
`--json` (ARCH-003 §5) |
```
warn: ADR briefing prose truncated for ARCH-005, ARCH-022, ARCH-024, GEN-004 —
Decision and/or Do's and Don'ts are incomplete. Read the full text with
`archgate adr show <id>`.
```
The same gap existed for `checkSummary`: `review-context` caps
violations at 20 per rule and set `truncated`, but **nothing ever
surfaced it**. Now warned too. (`check` itself passes no cap, so it was
never affected.)
## 2. ADR corpus trimmed 15.6% (353KB → 298KB)
27 ADRs compressed **without changing a single decision**. What came out
is exactly the prose GEN-004 bans in code: incident retellings,
`previously`/`used to` framing, release-version and violation-count
literals that go stale every release, and the same point restated across
Context, Decision, and Consequences.
| ADR | Before → After | Notable |
| ------------------------- | ------------------ |
-------------------------------------------------------------------- |
| ARCH-024 | 41.5KB → 24.6KB | Decision 14,511 → 3,574 |
| ARCH-022 | 38.9KB → 29.4KB | Decision front-loaded so the four ordered
guardrails survive the cut |
| ARCH-005 | 25.9KB → 15.7KB | Do's/Don'ts 11,733 → 3,539 |
| CI-002 / CI-001 / GEN-001 | −26% / −18% / −16% | all six briefed
sections now fit |
**ARCH-005 is the interesting case.** Both briefed sections share one
budget, and its `Decision` had ~1,200 chars of unused headroom while
`Do's and Don'ts` overflowed by 9,700. Moving three normative rules into
that headroom took it from ~17% of the Do list visible to _the Decision
plus all ten `DO` items_ visible. Its `Decision` grew on purpose.
Invariants held: frontmatter byte-identical everywhere, the two briefed
headings untouched (the engine matches them as literal strings), and
numbered clauses keep their numbers — `ARCH-003 §7` and `ARCH-024 cl.7`
are cited by number from code comments and agent memory.
## 3. GEN-005: ADR Briefing Budget
A new ADR plus companion rule so this cannot silently regress.
```
warn GEN-005/briefing-budget
"Decision" is 3574 chars; review-context truncates at 2000,
hiding 1574 chars from agent briefings
```
Three deliberate design choices:
- **`warning`, not `error`.** ARCH-024 and ARCH-022 enumerate
security-critical identifiers — banned globals, the `.constructor`
spellings, the guardrail sequence, the `-I` invariant — and have an
irreducible floor above the cap. A blocking rule would be unfixable by
design and would train authors to suppress it.
- **The cap is read from `DEFAULT_MAX_SECTION_CHARS` in the engine**,
not hardcoded, so the rule and `briefAdr` cannot drift apart. Falls back
to the documented default in consumer projects.
- **It mirrors `extractAdrSections` exactly** — same heading scan, same
case-insensitive match — so it measures what the engine actually
extracts. Verified: reported line numbers land precisely on the `##
Decision` headings.
Overflow is _legitimized rather than forbidden_: an ADR that genuinely
cannot fit must **declare** it. ARCH-024, ARCH-022, ARCH-005 and GEN-004
now each state what cannot be cut, which brings the repo into compliance
with the new ADR in the same change — the precedent GEN-004 set.
## 4. Memory
Memory turned out to be the lean part: the eight topic files reviewed
gave up only **~2%**, because they were already in the terse house
style. The real waste was `MEMORY.md` — an _index_ whose entries had
grown past 300 characters and duplicated CLAUDE.md.
Also folded in four AST/scanner notes that existed only in a stale
working tree, **after verifying each against current code**. One claimed
the `ctx.ast()` cache covered TS/JS only; it now covers every language,
which makes the trap _broader_ — corrected rather than copied. Fixed a
cross-link pointing at a CLAUDE.md section that does not exist.
## Verification
- `bun run validate` — 1,616 tests pass, 0 fail; lint, typecheck,
format, knip, build all clean
- `archgate check` — 47/47 rules pass; the only 6 warnings are
`GEN-005/briefing-budget` firing as designed, all four affected ADRs
declaring their overflow
- `@reviewer` — APPROVED across Architecture, General/Process, and
Legal; 0 violations
- New tests cover `truncatedSections` (single, both, absent,
prose-not-requested) and `truncatedBriefings` collection
- Docs updated in all three locales per GEN-002, dropping payload-size
figures that go stale on every ADR edit
## Reviewer notes
- Where a Consequences subsection already fell below the `adr-author`
floors (ARCH-002, ARCH-008, ARCH-012, ARCH-014, ARCH-018, LEGAL-002,
GEN-003), the shortfall was **left as-is**. Inventing a risk or
trade-off to reach a count would author new policy under cover of a
formatting change. Flagged rather than filled.
- ARCH-013 gained two Consequences entries that document
`shim-readme-sync` and `shim-license-sync` — both rules already exist in
the companion `.rules.ts`; this is accuracy, not new policy.
---------
Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>1 parent c5d82c5 commit a9dab40
70 files changed
Lines changed: 1686 additions & 1594 deletions
File tree
- .archgate/adrs
- .claude/agent-memory/archgate-developer
- docs
- public
- src/content/docs
- nb/reference/cli
- pt-br/reference/cli
- reference/cli
- src
- commands
- engine
- tests
- commands
- engine
- integration
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | | - | |
70 | 68 | | |
71 | 69 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
78 | 73 | | |
79 | 74 | | |
80 | 75 | | |
| |||
84 | 79 | | |
85 | 80 | | |
86 | 81 | | |
87 | | - | |
88 | 82 | | |
89 | 83 | | |
90 | 84 | | |
91 | | - | |
92 | 85 | | |
93 | 86 | | |
94 | 87 | | |
| |||
97 | 90 | | |
98 | 91 | | |
99 | 92 | | |
100 | | - | |
101 | 93 | | |
102 | 94 | | |
103 | 95 | | |
104 | 96 | | |
105 | | - | |
| 97 | + | |
106 | 98 | | |
107 | 99 | | |
108 | 100 | | |
| |||
117 | 109 | | |
118 | 110 | | |
119 | 111 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | 112 | | |
124 | 113 | | |
125 | 114 | | |
| |||
129 | 118 | | |
130 | 119 | | |
131 | 120 | | |
132 | | - | |
133 | 121 | | |
134 | | - | |
135 | | - | |
136 | 122 | | |
137 | 123 | | |
138 | 124 | | |
| |||
143 | 129 | | |
144 | 130 | | |
145 | 131 | | |
146 | | - | |
147 | | - | |
148 | 132 | | |
149 | | - | |
150 | | - | |
151 | 133 | | |
152 | 134 | | |
153 | 135 | | |
| |||
158 | 140 | | |
159 | 141 | | |
160 | 142 | | |
161 | | - | |
162 | | - | |
163 | 143 | | |
164 | 144 | | |
165 | 145 | | |
| |||
168 | 148 | | |
169 | 149 | | |
170 | 150 | | |
171 | | - | |
172 | | - | |
173 | 151 | | |
174 | 152 | | |
175 | 153 | | |
| |||
180 | 158 | | |
181 | 159 | | |
182 | 160 | | |
183 | | - | |
184 | | - | |
| 161 | + | |
| 162 | + | |
185 | 163 | | |
186 | 164 | | |
187 | 165 | | |
188 | | - | |
189 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
190 | 169 | | |
191 | 170 | | |
192 | 171 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
196 | 178 | | |
197 | 179 | | |
198 | 180 | | |
| |||
0 commit comments