@@ -306,6 +306,14 @@ See `docs/performance-plan.md` for full optimization details and `docs/benchmark
306306
307307### Documentation
308308
309+ - ** ` docs/methodology/REGISTRY.md ` ** - Methodology Registry:
310+ - Academic foundations and citations for each estimator
311+ - Key implementation requirements (equations, SE formulas, edge cases)
312+ - Reference implementations (R packages, Stata commands)
313+ - Requirements checklists for validation
314+ - ** Must be consulted before implementing methodology-related changes**
315+ - ** Must be updated when deviating from reference implementations**
316+
309317- ** ` docs/tutorials/ ` ** - Jupyter notebook tutorials:
310318 - ` 01_basic_did.ipynb ` - Basic 2x2 DiD, covariates, fixed effects, wild bootstrap
311319 - ` 02_staggered_did.ipynb ` - Staggered adoption with Callaway-Sant'Anna, bootstrap inference
@@ -421,6 +429,7 @@ When implementing new functionality, **always include accompanying documentation
421429- Update relevant docstrings
422430- Add/update tests
423431- Update CHANGELOG.md (if exists)
432+ - ** If methodology-related** : Update ` docs/methodology/REGISTRY.md ` edge cases section
424433
425434### Scholarly References
426435
@@ -459,16 +468,49 @@ When adding a new `__init__` parameter that should be available across estimator
459468 - [ ] Update docstring in all affected classes
460469 - [ ] Update CLAUDE.md if it's a key design pattern
461470
471+ ### Implementing Methodology-Critical Code
472+
473+ When implementing or modifying code that affects statistical methodology (estimators, SE calculation, inference, edge case handling):
474+
475+ 1 . ** Before coding - consult the Methodology Registry** :
476+ - [ ] Read the relevant estimator section in ` docs/methodology/REGISTRY.md `
477+ - [ ] Identify the reference implementation(s) listed
478+ - [ ] Note the edge case handling requirements
479+
480+ 2 . ** During implementation** :
481+ - [ ] Follow the documented equations and formulas
482+ - [ ] Match reference implementation behavior for standard cases
483+ - [ ] For edge cases: either match reference OR document deviation
484+
485+ 3 . ** When deviating from reference implementations** :
486+ - [ ] Add a ** Note** in the Methodology Registry explaining the deviation
487+ - [ ] Include rationale (e.g., "defensive enhancement", "R errors here")
488+ - [ ] Ensure the deviation is an improvement, not a bug
489+
490+ 4 . ** Testing methodology-aligned behavior** :
491+ - [ ] Test that edge cases produce documented behavior (NaN, warning, etc.)
492+ - [ ] Assert warnings are raised (not just captured)
493+ - [ ] Assert the warned-about behavior actually occurred
494+ - [ ] For NaN results: assert ` np.isnan() ` , don't just check "no exception"
495+
462496### Adding Warning/Error/Fallback Handling
463497
464498When adding code that emits warnings or handles errors:
465499
466- 1 . ** Verify behavior matches message** :
500+ 1 . ** Consult Methodology Registry first** :
501+ - [ ] Check if behavior is documented in edge cases section
502+ - [ ] If not documented, add it before implementing
503+
504+ 2 . ** Verify behavior matches message** :
467505 - [ ] Manually trace the code path after warning/error
468506 - [ ] Confirm the stated behavior actually occurs
469507
470- 2 . ** Write behavioral tests** :
508+ 3 . ** Write behavioral tests** :
471509 - [ ] Don't just test "no exception raised"
472510 - [ ] Assert the expected outcome occurred
473511 - [ ] For fallbacks: verify fallback behavior was applied
474512 - [ ] Example: If warning says "setting NaN", assert ` np.any(np.isnan(result)) `
513+
514+ 4 . ** Protect arithmetic operations** :
515+ - [ ] Wrap ALL related operations in ` np.errstate() ` , not just the final one
516+ - [ ] Include division, matrix multiplication, and any operation that can overflow/underflow
0 commit comments