Skip to content

Commit 909c5f3

Browse files
authored
Merge pull request #381 from derek73/claude/library-rules-documentation-938523
Committed rules documentation: rules.md, decisions.md, mechanisms.md with enforcement tests
2 parents 715de3d + 3118359 commit 909c5f3

53 files changed

Lines changed: 3486 additions & 397 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,87 @@ Branch naming: `fix/issue-NNN-short-description` or `feat/short-description`.
99

1010
Before opening the PR, if the change alters parser behavior or internals, *read* the Architecture, Extension Patterns, and Gotchas sections of this file against the change — don't grep for it: AGENTS.md paraphrases behavior in its own words, so text made stale by a code change rarely matches the code's phrasing (a doc-staleness sweep driven by grep terms from the diff will miss it every time). The same applies when scoping a doc-review pass or a subagent prompt: include AGENTS.md in the list of docs to check, or it won't be checked.
1111

12+
## Rules documentation (docs/design/)
13+
14+
Three committed contributor docs carry the parser's normative rules
15+
and their reasons, enforced by the doc tests in tests/v2/
16+
(rules_doc.py and the test_doc_*/test_rules_doc* modules). Before proposing a
17+
design or a fix that touches parser behavior, read
18+
docs/design/mechanisms.md and the relevant docs/design/rules.md
19+
sections — the catalog is keyed by problem shape, and the pattern
20+
you are about to invent is often already there.
21+
22+
- **rules.md** — NORMATIVE rules (intended behavior, domain-topic
23+
sections, executable examples; `deviates:` markers track known
24+
parser gaps). Cite as `rules.md#P1`; code comments quote a
25+
verbatim excerpt in double quotes, checked by
26+
tests/v2/test_doc_citations.py.
27+
- **decisions.md** — the ADR-style record: dated entries, Declined:
28+
(rejected WITH evidence), Excluded: (what must stay out of a
29+
wordlist and why), Open: (issue links, never restated; also keyed
30+
to a vocabulary set for contested memberships — the
31+
right-rule-wrong-set class),
32+
3-0-reevaluations (append whenever a design cites 1.4 parity as
33+
load-bearing).
34+
- **mechanisms.md** — problem-shape catalog with citable contract
35+
statements; stage-attribution claims in comments must cite an
36+
entry verbatim, never restate it in fresh words.
37+
38+
**Same-PR amendment rule.** Any PR that changes or clarifies parser
39+
behavior — or the boundaries around a documented rule, since a
40+
neighboring change can invalidate a rule's stated limits without
41+
touching its code — amends rules.md in the same diff (the doc diff
42+
is part of the reviewable change, like tests). A change that
43+
resolves or reverses a design question adds a decisions.md entry; a
44+
new reusable pattern adds a mechanisms.md entry; a fixed deviation
45+
removes its `deviates:` marker in the same PR (the examples test
46+
forces this). Issues proposing behavior changes should be drafted in
47+
rule shape — rationale, statement, examples with boundaries,
48+
accepted consequences, open questions, exclusions — so landing an
49+
accepted proposal is a copy, not a rewrite.
50+
51+
**Counting claims.** A bare count in prose is either an assertion or
52+
a liability, keyed by who observes its staleness: asserted counts (a
53+
test holds the number) fail CI at change time — the useful kind;
54+
dated snapshots ("51 sites at spec time") cannot go stale; standing
55+
present-tense prose counts are the forbidden class — promote to an
56+
assertion, add a date, or state the invariant and let a test count.
57+
After changing how many times something runs, sweep for counts, not
58+
for the thing's name.
59+
60+
**Release-log claims.** Quantified or universal behavior claims in
61+
release bullets must come from the differential gate's classified
62+
summary or be verified against rules.md examples, never written from
63+
memory. Per-rule ledger toml comments asserting PARSER behavior cite
64+
rule IDs under the excerpt discipline; free prose is for ledger
65+
mechanics only (owned by tools/differential/README.md).
66+
67+
**Landing a design.** The gitignored spec (docs/superpowers/specs/)
68+
is the working medium; it dies with the branch, and the docs are the
69+
record. Before a design PR merges, walk its spec (including
70+
amendments) and distill the durable residue: decisions made or
71+
reversed → decisions.md entries; proposals rejected with evidence →
72+
Declined:; vocabulary that must stay out → Excluded:; behavior the
73+
design settled → rules.md (with a deviates: marker if unshipped);
74+
reusable patterns → mechanisms.md; options weighed → a weighing
75+
entry. Then check the spec cites nothing the docs don't now carry —
76+
a spec section with no committed home when the PR merges is lost,
77+
not deferred (a 2026-08-16 sweep of eight weeks of specs recovered
78+
nine such items). The same-PR amendment rule above covers code-driven
79+
changes; this covers the design-driven ones.
80+
81+
**Primary-source review.** When doc content is distilled from a
82+
session's work, have that session (or its transcript) review its
83+
own sections before or soon after landing — attribution flattening
84+
and inverted arguments are visible only to the source. Reviewers
85+
state which tree each measurement ran on (stale fetches produced
86+
three rounds of already-fixed findings), and landed corrections are
87+
re-verified here before committing.
88+
89+
**Guard tests** SHOULD carry a recorded negative control — the
90+
answer with the guard off, stored as data (the _EXCLUSION_EFFECT
91+
shape; see mechanisms.md's Verification shapes).
92+
1293
## Commands
1394

1495
```bash
@@ -61,6 +142,10 @@ uv run sphinx-build -b html docs dist/docs
61142
# "Reads:". That is checkable, so check it rather than reading it:
62143
# compare it against grep -oE '\b(policy|lexicon)\.[a-z_]+' on the module
63144
# - tests/v2/cases.py notes, which explain why a row lands where it does
145+
# - docs/design/rules.md, decisions.md and mechanisms.md -- READ, don't
146+
# grep: the excerpt and example tests catch citation and example drift,
147+
# but statement and Background prose can still be wrong about behavior
148+
# that changed
64149
# - AGENTS.md itself, for stale commands, architecture notes, or gotchas
65150
# And check for open Dependabot PRs on uv.lock (namedivider-python) and merge them
66151
# first — pyproject floats >=0.4 so fresh installs get the newest namedivider, but

0 commit comments

Comments
 (0)