Skip to content

Commit 598e3a3

Browse files
igerberclaude
andcommitted
Add label-gated CI and documentation dependency map
Two process improvements: 1. Label-gated CI: rust-test.yml and notebooks.yml jobs now require the `ready-for-ci` label on PRs before running. AI review still runs on every push. This eliminates wasted CI runs during the iterative AI review phase. The `unlabeled` event type ensures removing the label clears passing CI status. 2. Documentation dependency map: docs/doc-deps.yaml maps all 47 source files to their dependent documentation. New /docs-impact skill surfaces impacted docs. Wired into /pre-merge-check, /submit-pr, and /push-pr-update for automatic enforcement. /docs-check gains a `map` validation mode. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ac9c768 commit 598e3a3

10 files changed

Lines changed: 762 additions & 37 deletions

File tree

.claude/commands/docs-check.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Verify documentation completeness including scholarly references
3-
argument-hint: "[all | readme | refs | api | tutorials]"
3+
argument-hint: "[all | readme | refs | api | tutorials | map]"
44
---
55

66
# Documentation Completeness Check
@@ -11,11 +11,12 @@ Verify that documentation is complete and includes appropriate scholarly referen
1111

1212
The user may provide an optional argument: `$ARGUMENTS`
1313

14-
- If empty or "all": Run all checks
14+
- If empty or "all": Run all checks (including map validation)
1515
- If "readme": Check README.md sections only
1616
- If "refs" or "references": Check scholarly references only
1717
- If "api": Check API documentation (RST files) only
1818
- If "tutorials": Check tutorial coverage only
19+
- If "map": Validate docs/doc-deps.yaml integrity only
1920

2021
## Estimators and Required Documentation
2122

@@ -197,9 +198,41 @@ Tutorial Coverage:
197198
Summary: 15/18 checks passed, 3 issues found
198199
```
199200

201+
### 8. Dependency Map Validation (if "map" or "all")
202+
203+
Validate the integrity of `docs/doc-deps.yaml`:
204+
205+
1. **Read and parse** `docs/doc-deps.yaml`. If missing or malformed YAML, report error.
206+
207+
2. **Check all doc paths exist**: For every `path` in every `sources` entry, verify the file
208+
exists on disk. Report missing files:
209+
```
210+
[FAIL] docs/doc-deps.yaml references non-existent: docs/old_name.rst
211+
```
212+
213+
3. **Check all source files have entries**: List all `diff_diff/*.py` and
214+
`diff_diff/visualization/*.py` files. For each, verify it appears either as a key in
215+
`sources:` or as a member of a `groups:` entry. Report missing:
216+
```
217+
[WARN] diff_diff/new_module.py has no entry in docs/doc-deps.yaml
218+
```
219+
220+
4. **Check for orphan doc paths**: Collect all unique doc paths from the map. Check if any
221+
doc file referenced in the map no longer exists or has been renamed.
222+
223+
5. **Report summary**:
224+
```
225+
Dependency Map (docs/doc-deps.yaml):
226+
Sources mapped: 28
227+
Groups defined: 9
228+
Doc paths referenced: 45
229+
[PASS/FAIL] All doc paths exist
230+
[PASS/WARN] All source files have entries
231+
```
232+
200233
## Notes
201234

202235
- This check is especially important after adding new estimators
203236
- The CONTRIBUTING.md file documents what documentation is required for new features
204237
- Missing references should cite the original methodology paper, not textbooks
205-
- When adding new estimators, update this skill's tables accordingly
238+
- When adding new estimators, update this skill's tables and docs/doc-deps.yaml accordingly

.claude/commands/docs-impact.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
description: Show which documentation files may need updating based on changed source files
3+
argument-hint: "[file1.py file2.py ...]"
4+
---
5+
6+
# Documentation Impact Report
7+
8+
Identify which documentation files may need updating when source files in `diff_diff/` change.
9+
Uses the dependency map at `docs/doc-deps.yaml`.
10+
11+
## Arguments
12+
13+
`$ARGUMENTS` is an optional space-separated list of source file paths (e.g., `diff_diff/staggered.py`).
14+
If empty, auto-detect changed files from git.
15+
16+
## Instructions
17+
18+
### 1. Load Dependency Map
19+
20+
Read `docs/doc-deps.yaml` using the Read tool.
21+
22+
If the file does not exist or cannot be parsed, display:
23+
```
24+
Error: docs/doc-deps.yaml not found or malformed. Cannot generate impact report.
25+
```
26+
And stop.
27+
28+
### 2. Identify Changed Source Files
29+
30+
**If `$ARGUMENTS` is non-empty**: Use those file paths directly as the changed files list.
31+
32+
**If `$ARGUMENTS` is empty**: Auto-detect from git:
33+
34+
```bash
35+
# Unstaged changes
36+
git diff --name-only HEAD 2>/dev/null || true
37+
# Staged changes
38+
git diff --cached --name-only 2>/dev/null || true
39+
# Untracked files
40+
git ls-files --others --exclude-standard 2>/dev/null || true
41+
```
42+
43+
Filter results to only files matching `diff_diff/**/*.py`. Deduplicate.
44+
45+
If no source files found, display:
46+
```
47+
No changed source files in diff_diff/ detected. Nothing to report.
48+
```
49+
And stop.
50+
51+
### 3. Resolve Group Membership
52+
53+
For each changed file, check if it appears in any `groups:` list in the YAML.
54+
If it does, resolve it to the **first entry** in that group (the primary module).
55+
This is the key used for doc lookup in the `sources:` section.
56+
57+
Example: if `diff_diff/staggered_bootstrap.py` changed, it resolves to `diff_diff/staggered.py`
58+
because it is in the `staggered` group.
59+
60+
### 4. Look Up Impacted Docs
61+
62+
For each resolved source entry in the `sources:` section:
63+
1. Get the `drift_risk` level
64+
2. Get the list of `docs` entries (path, type, section, note)
65+
66+
Collect all impacted docs across all changed files. Deduplicate by path, but merge
67+
section hints from different sources (e.g., REGISTRY.md may be referenced by both
68+
staggered.py and survey.py with different section hints).
69+
70+
### 5. Validate Doc Paths
71+
72+
For each unique doc `path` in the results, verify the file exists on disk using the
73+
Read tool (or Glob). If a path does not exist, flag it:
74+
```
75+
[STALE] docs/doc-deps.yaml references non-existent file: <path>
76+
```
77+
78+
### 6. Display Report
79+
80+
Group results by drift risk level (HIGH first, then MEDIUM, then LOW).
81+
Within each group, show the type label and path, with section hints where available.
82+
83+
**Output format:**
84+
85+
```
86+
=== Documentation Impact Report ===
87+
Changed: <comma-separated list of changed source files>
88+
89+
HIGH DRIFT RISK:
90+
[methodology] docs/methodology/REGISTRY.md -- <section hints>
91+
[roadmap] docs/survey-roadmap.md
92+
93+
MEDIUM DRIFT RISK:
94+
[user_guide] README.md -- <section hints>
95+
[tutorial] docs/tutorials/02_staggered_did.ipynb
96+
[performance] docs/benchmarks.rst
97+
98+
LOW DRIFT RISK:
99+
[api_reference] docs/api/staggered.rst
100+
101+
No map entry: <files not found in sources or groups, or "(none)">
102+
Stale references: <invalid paths, or "(none)">
103+
Always update: CHANGELOG.md
104+
```
105+
106+
### 7. Flag Missing Entries
107+
108+
List any changed source files that had no entry in the `sources:` section and were not
109+
members of any group:
110+
```
111+
No map entry: diff_diff/new_module.py (consider adding to docs/doc-deps.yaml)
112+
```
113+
114+
## Examples
115+
116+
```bash
117+
# Auto-detect from git status
118+
/docs-impact
119+
120+
# Check specific files
121+
/docs-impact diff_diff/staggered.py diff_diff/survey.py
122+
```

.claude/commands/pre-merge-check.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,26 @@ git diff HEAD -- <changed-py-files> | grep "^+.*def " | head -10
109109

110110
For each changed function, flag: "Verify docstring Parameters section matches updated signature for: `<function_name>`"
111111

112-
#### 2.5 Methodology Documentation Check
112+
#### 2.5 Documentation Impact Check
113113

114-
If any methodology files changed, check whether `docs/methodology/REGISTRY.md` was also
115-
modified in the changed file set (from Section 1).
114+
If any source files in `diff_diff/` changed, read `docs/doc-deps.yaml` and identify which
115+
dependent documentation files are NOT also in the changed file set (from Section 1).
116116

117-
If methodology files changed but REGISTRY.md was NOT modified, flag:
118-
"Methodology files changed but `docs/methodology/REGISTRY.md` was not updated. If your
119-
changes deviate from reference implementations, document them using a reviewer-recognized
120-
label (`**Note:**`, `**Deviation from R:**`, or `**Note (deviation from R):**`) —
121-
undocumented deviations are flagged as P1 by the AI reviewer and cannot be mitigated
122-
by TODO.md."
117+
For each changed source file:
118+
1. Look up its entry in `docs/doc-deps.yaml` (resolving group membership for multi-file modules)
119+
2. Check each dependent doc's `path` against the changed file set
120+
3. Report HIGH drift risk docs that were NOT changed as warnings
123121

124-
This is a WARNING, not a blocker — not every methodology change involves a deviation.
122+
**Report format**:
123+
```
124+
Documentation impact: source files changed but related docs were not updated:
125+
[HIGH] docs/methodology/REGISTRY.md -- <section hint>
126+
[HIGH] docs/survey-roadmap.md
127+
[MEDIUM] README.md -- <section hint> (3 more MEDIUM/LOW docs — run /docs-impact for details)
128+
```
129+
130+
This is a WARNING, not a blocker — not every source change requires a doc update.
131+
For full details, run `/docs-impact`.
125132

126133
#### 2.6 Secret Scanning Patterns (Canonical Definitions)
127134

.claude/commands/push-pr-update.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,15 @@ When the working tree is clean but commits are ahead, check for methodology issu
128128

129129
If warnings are found, display them as warnings (non-blocking) since changes are already committed.
130130

131-
3. **REGISTRY.md check**: Check whether `docs/methodology/REGISTRY.md` is also in the committed changes (`git diff --name-only <comparison-ref>..HEAD`).
132-
If methodology files changed but REGISTRY.md was NOT modified, warn:
133-
"Methodology files changed but `docs/methodology/REGISTRY.md` was not updated.
134-
If your changes deviate from reference implementations, document them using a
135-
reviewer-recognized label (`**Note:**`, `**Deviation from R:**`, or
136-
`**Note (deviation from R):**`) — undocumented deviations are flagged as P1
137-
by the AI reviewer."
131+
3. **Documentation impact check**: Check which source files in `diff_diff/` are in the committed changes.
132+
If source files are present, read `docs/doc-deps.yaml` and check which dependent
133+
documentation files are NOT also in the committed changes. For HIGH drift risk docs, warn:
134+
```
135+
Documentation impact: source files changed but related docs were not updated:
136+
[HIGH] docs/methodology/REGISTRY.md — <section hint>
137+
[HIGH] docs/survey-roadmap.md
138+
Run /docs-impact for full details.
139+
```
138140
This is a WARNING, not a blocker.
139141

140142
Note: Section 3b checks are informational warnings only — no AskUserQuestion prompt, since changes are already committed and cannot be unstaged. This differs from the staged-changes path (Section 3) which offers a "fix vs continue" choice.
@@ -167,14 +169,14 @@ Note: Section 3b checks are informational warnings only — no AskUserQuestion p
167169
```
168170
Use AskUserQuestion. If user chooses to fix, abort the commit flow.
169171

170-
**REGISTRY.md check** (if methodology files are staged):
171-
Check whether `docs/methodology/REGISTRY.md` is also in the staged file set.
172-
If methodology files changed but REGISTRY.md was NOT staged, warn:
173-
"Methodology files changed but `docs/methodology/REGISTRY.md` was not updated.
174-
If your changes deviate from reference implementations, document them using a
175-
reviewer-recognized label (`**Note:**`, `**Deviation from R:**`, or
176-
`**Note (deviation from R):**`) — undocumented deviations are flagged as P1
177-
by the AI reviewer."
172+
**Documentation impact check** (if source files are staged):
173+
If source files in `diff_diff/` are present, read `docs/doc-deps.yaml` and check which
174+
dependent documentation files are NOT also in the staged set. For HIGH drift risk docs, warn:
175+
```
176+
Documentation impact: source files changed but related docs were not updated:
177+
[HIGH] docs/methodology/REGISTRY.md — <section hint>
178+
Run /docs-impact for full details.
179+
```
178180
This is a WARNING, not a blocker.
179181

180182
3. **Capture file count for reporting**:
@@ -277,6 +279,7 @@ Commit: <hash> - <message>
277279
Files changed: <files-changed-count>
278280
279281
AI code review triggered. Results will appear shortly.
282+
When AI review is green, add the `ready-for-ci` label to trigger CI tests (if not already added).
280283
281284
PR URL: <url>
282285
```
@@ -291,6 +294,7 @@ Files changed: <files-changed-count>
291294
PR URL: <url>
292295
293296
Tip: Run /ai-review to request AI code review.
297+
Note: CI tests require the `ready-for-ci` label on the PR.
294298
```
295299
296300
## Error Handling

.claude/commands/submit-pr.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,18 @@ Determine if this is a fork-based workflow:
154154
```
155155
Use AskUserQuestion. If user chooses to fix, abort the commit flow and let them address the issues.
156156
157-
3. **REGISTRY.md check** (if methodology files are staged):
158-
Check whether `docs/methodology/REGISTRY.md` is also in the staged file set (`git diff --cached --name-only`).
159-
If methodology files changed but REGISTRY.md was NOT staged, warn:
160-
"Methodology files changed but `docs/methodology/REGISTRY.md` was not updated.
161-
If your changes deviate from reference implementations, document them using a
162-
reviewer-recognized label (`**Note:**`, `**Deviation from R:**`, or
163-
`**Note (deviation from R):**`) — undocumented deviations are flagged as P1
164-
by the AI reviewer."
157+
3. **Documentation impact check** (if source files are staged):
158+
```bash
159+
git diff --cached --name-only | grep "^diff_diff/.*\.py$"
160+
```
161+
If source files are present, read `docs/doc-deps.yaml` and check which dependent
162+
documentation files are NOT also in the staged set. For HIGH drift risk docs, warn:
163+
```
164+
Documentation impact: source files changed but related docs were not updated:
165+
[HIGH] docs/methodology/REGISTRY.md — <section hint>
166+
[HIGH] docs/survey-roadmap.md
167+
Run /docs-impact for full details.
168+
```
165169
This is a WARNING, not a blocker.
166170

167171
### 6. Commit Changes
@@ -352,7 +356,8 @@ Changes included:
352356
353357
Next steps:
354358
- Review the PR at the URL above
355-
- Request reviewers if needed
359+
- AI code review runs automatically on PR open
360+
- When AI review is green, add the `ready-for-ci` label to trigger CI tests
356361
- Run /review-pr <number> to get AI review
357362
```
358363

.github/workflows/notebooks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- '.github/workflows/notebooks.yml'
1111
pull_request:
1212
branches: [main]
13+
types: [opened, synchronize, reopened, labeled, unlabeled]
1314
paths:
1415
- 'docs/tutorials/**'
1516
- 'diff_diff/**'
@@ -22,6 +23,10 @@ on:
2223
jobs:
2324
execute-notebooks:
2425
name: Execute tutorial notebooks
26+
if: >-
27+
github.event_name == 'push'
28+
|| github.event_name == 'schedule'
29+
|| contains(github.event.pull_request.labels.*.name, 'ready-for-ci')
2530
runs-on: ubuntu-latest
2631

2732
steps:

.github/workflows/rust-test.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
- '.github/workflows/rust-test.yml'
1212
pull_request:
1313
branches: [main]
14+
types: [opened, synchronize, reopened, labeled, unlabeled]
1415
paths:
1516
- 'rust/**'
1617
- 'diff_diff/**'
@@ -25,6 +26,9 @@ jobs:
2526
# Run Rust unit tests on all platforms
2627
rust-tests:
2728
name: Rust Unit Tests (${{ matrix.os }})
29+
if: >-
30+
github.event_name == 'push'
31+
|| contains(github.event.pull_request.labels.*.name, 'ready-for-ci')
2832
runs-on: ${{ matrix.os }}
2933
env:
3034
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
@@ -58,6 +62,9 @@ jobs:
5862
# Build and test with Python on multiple platforms
5963
python-tests:
6064
name: Python Tests (${{ matrix.os }}, py${{ matrix.python-version }})
65+
if: >-
66+
github.event_name == 'push'
67+
|| contains(github.event.pull_request.labels.*.name, 'ready-for-ci')
6168
runs-on: ${{ matrix.os }}
6269
strategy:
6370
fail-fast: false
@@ -158,6 +165,9 @@ jobs:
158165
# Test pure Python fallback (without Rust extension)
159166
python-fallback:
160167
name: Pure Python Fallback
168+
if: >-
169+
github.event_name == 'push'
170+
|| contains(github.event.pull_request.labels.*.name, 'ready-for-ci')
161171
runs-on: ubuntu-latest
162172
steps:
163173
- uses: actions/checkout@v4

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ category (`Methodology/Correctness`, `Performance`, or `Testing/Docs`):
135135
| File | Contains |
136136
|------|----------|
137137
| `docs/methodology/REGISTRY.md` | Academic foundations, equations, edge cases — **consult before methodology changes** |
138+
| `docs/doc-deps.yaml` | Source-to-documentation dependency map — **consult when any source file changes** |
138139
| `CONTRIBUTING.md` | Documentation requirements, test writing guidelines |
139140
| `.claude/commands/dev-checklists.md` | Checklists for params, methodology, warnings, reviews, bugs (run `/dev-checklists`) |
140141
| `.claude/memory.md` | Debugging patterns, tolerances, API conventions (git-tracked) |
@@ -145,6 +146,7 @@ category (`Methodology/Correctness`, `Performance`, or `Testing/Docs`):
145146
## Workflow
146147

147148
- For non-trivial tasks, use `EnterPlanMode`. Consult `docs/methodology/REGISTRY.md` for methodology changes.
149+
- When modifying source files in `diff_diff/`, consult `docs/doc-deps.yaml` to identify impacted documentation. Run `/docs-impact` to see the full list.
148150
- For bug fixes, grep for the pattern across all files before fixing.
149151
- Follow the relevant development checklists (run `/dev-checklists`).
150152
- Before submitting: run `/pre-merge-check`, then `/ai-review-local` for pre-PR AI review.

0 commit comments

Comments
 (0)