Commit 32f61b0
committed
test(v4): naming-completeness guard - surface sweep + phase-table agreement + consumer coverage (closes the TODO guard row)
tests/test_naming_guard.py enforces the three v4-program naming invariants
that were previously prose-only (spec in the module docstring, replacing the
TODO.md row):
(A) Public-surface sweep - every __all__ export's signatures, dataclass
fields (custom-__init__ extras included) and property names checked against
the section-8 rename vocabulary; every hit must be a ledger row,
structurally exempt (wrapper functions / dying classes), or allowlisted with
a stated reason. First run: 0 unrowed violations; 49 documented carve-outs
(the CS-cohort groups family, rule-1 canonical calendar time surfaces,
rank_control_units' own lambda_reg). A binding self-test forces every
param/field rename token - gated rows included - into the sweep predicate.
(B) Ledger<->section-9 phase-table agreement in both directions: bracketed
citation expansion (single tokens, compound brackets with ranges/comma
elements/trailing prose, endpoint-bracket ranges; bare prose ids are NOT
citations), the ship-version predicate with the decision_due channel for
env-default rows, M-008 positive / M-031 negative fixtures, terminal-row
exemption, and a cross-check of the hardcoded map against the table's
Ships-in column.
(C) Rule-11 consumer coverage over diff_diff/ source, the packaged
guides/*.txt, and docs/methodology/, tiered by row kind and token ambiguity:
regex lanes (quoted/kwarg/attr/backtick + qualified docs forms) for
distinctive tokens; AST call-site matching (callee-aware, including
super().__init__ delegation and exported subclasses sharing the effective
constructor) plus getattr/hasattr/.get literal state reads for ambiguous
tokens like time/group/robust; bare-call text+AST lanes for function rows
(docstring examples included, wrapper bodies exempt). Coverage = the token
family's code_refs UNION (rule 11's new token-family clause) or a reasoned
allowlist entry; both allowlists carry a reachability test that kills dead
entries. A version-aware lifecycle gate keyed on __version__ re-arms
deferred rows (M-050..M-058, M-016) at each release bump, and terminal rows
stay enforced with their own historical code_refs discounted. Accepted
limitations (dict/**kwargs indirection, ambiguous attr/dict-key reads) are
documented with their measured noise rationale. Parser/matcher/resolver/
gate self-tests run on synthetic fixtures.
The guard's first run completed 30 rows' code_refs with newly confirmed
readers: diagnostics.py's seven fit(time=...) call sites (M-030),
sun_abraham.py's robust=True legacy alias (M-115), synthetic_did.py's
super().__init__(robust=True) (M-045), diagnostic_report.py's bare
bacon_decompose(...) call and _diagnostic.py's docstring example plus
twfe.py's guidance string (M-076), REGISTRY's treatment_col / cohort /
controls / robust / clean_control / synthetic_control() / dCDH
results.groups references, the packaged-guide readers (cohort= ETWFE
examples, aggregation=, wrapper calls, clean_control, placebo_effects,
first_treat_col), and record-anyway entries on the lifecycle-gated
M-016/M-050 families and the old==new-skipped M-020 family.
docs/v4-design.md: rule 11 gains the token-family code_refs-union clause
(decided 2026-08-01 over per-row duplication); the section-8 carve-out
paragraph adds plot_group_effects' cohort selector; section-9 sequence item
2 and 3.9-cut checklist item 4 now point at the test file. TODO.md's
completed guard row is removed. Wired into docs-tests.yml (trigger paths +
step) so docs-only ledger/spec edits cannot bypass enforcement.1 parent 6fcc520 commit 32f61b0
6 files changed
Lines changed: 1553 additions & 34 deletions
File tree
- .github/workflows
- docs
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
10 | 34 | | |
11 | 35 | | |
12 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
| |||
0 commit comments