Skip to content

docs: input contract for estimator data and objects (IC-01 to IC-16) - #925

Merged
igerber merged 17 commits into
mainfrom
codex-review
Dec 1, 2026
Merged

igerber merged 17 commits into
mainfrom
codex-review

Conversation

@igerber

@igerber igerber commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds docs/input-contract.md: 16 numbered clauses (IC-01 to IC-16) stating which inputs the estimators guarantee correct results for, which they refuse, and which are out of contract. It covers the outcome column (dtypes, non-finite values, unit and level changes, noiseless data), unit identifiers and rows, time and cohort labels (dtype, magnitude and span, date-typed and string labels, spacing, the never-treated marker), and object integrity.
  • Each clause is marked Enforced, Partial or Intended. A "Gaps on main" table lists where current behavior falls short of a clause and whether the failure is silent, and an Evidence section states what was probed and the limits of that evidence (9 of 28 estimator classes, default settings).
  • This is an engineering boundary, not methodology, so it sits with the other internal docs rather than in the methodology registry, and is excluded from the Sphinx build like its peers. Which periods a given estimator needs, and how it handles a missing one, stays in the registry.
  • No estimator behavior changes. The gaps are recorded as rows in TODO.md under Methodology / correctness, to be closed through one shared input boundary rather than per-estimator guards.
  • Adds a row for the contract to the key reference files table in the contributor instructions.
  • Adds one Note to the EfficientDiD section of docs/methodology/REGISTRY.md (see below).

Methodology references (required if estimator / math changes)

  • Method name(s): EfficientDiD, PT-Post baseline (documentation only; no code change)
  • Paper / source link(s): Chen, Sant'Anna & Xie, Corollary 3.2 (baseline g-1 under no anticipation); Callaway & Sant'Anna (2021), limited anticipation
  • Any intentional deviations from the source (and why): None new. The registry entry gave the PT-Post baseline as g-1 without qualification; the implementation has used g - 1 - anticipation in label units, and the added Note states that, with g-1 as the anticipation=0 case.

Validation

  • Tests added/updated: No test changes. tests/test_tracking_files.py, tests/test_docs_ia.py and tests/test_doc_deps_integrity.py pass locally.
  • Backtest / simulation / notebook evidence (if applicable): The clause statuses and the gap table come from a probe matrix on main (46 input variations across 9 estimators, both backends) plus focused probes; the document's Evidence section describes them.

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Changelog

  • changelog.d/ fragment added (or N/A - no user-visible change): N/A

Adds docs/input-contract.md: numbered clauses stating which inputs the
estimators guarantee, which they refuse, and which are out of contract.
Each clause is marked enforced, partial or intended, and a gap table
lists where main falls short, with the probe evidence and its limits.

The document is an engineering boundary, not methodology, so it lives
beside the other internal docs rather than in the methodology registry.
It is excluded from the Sphinx build like its peers.

Docs only; no estimator behavior changes. The gaps are tracked as rows
in TODO.md (Methodology / correctness), to be closed through one shared
input boundary rather than per-estimator guards. The key reference
files table gains a row for the contract.
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Overall assessment

✅ Looks good. The highest severity is P2.

Executive summary

  • The PR adds a 16-clause internal input contract and seven backlog entries. Estimator code is outside the diff.
  • Resolve how the future validator should interpret cohort 0, which can change who enters the comparison group.
  • Clarify which fit paths share validation and preserve the documented pickle migrations.
  • The Sphinx exclusion follows the internal-doc convention. This docs-only change qualifies for the changelog exemption.

Methodology

  • P2 — IC-15 conflicts with the zero-adoption regression. Impact IC-15 reserves 0 for never-treated units and rejects it on a negative time axis. The backlog expects the mapper to recognize a raw cohort 0 as treated and shift it to 4. The presence of +inf does not resolve the ambiguity because the clause permits both markers. Concrete fix Keep 0 reserved and test that the ambiguous panel raises. In a separate fixture, explicitly recode the known zero adopters to 4, keep never-treated units at +inf, and verify the comparison group. docs/input-contract.md:L64-L69, TODO.md:L28-L28
  • P3 — LWDiD’s cohort encoding is a documented exception. Impact Its NaN and NaT conventions support date-typed panels under the Registry note. The draft explicitly excludes this path. Concrete fix No action required. docs/input-contract.md:L85-L90, docs/methodology/REGISTRY.md:L3011-L3015

Code Quality

No findings.

Performance

No findings.

Maintainability

  • P2 — Scope the duplicate-row check to fits that require unique observation keys. Impact IC-09 and its backlog entry direct every fit with unit and calendar columns to reject repeated keys. ChaisemartinDHaultfoeuille.fit() accepts individual observations that share a group and period and aggregates them internally. The contract excludes unprobed estimators, but the backlog instruction is broader. Concrete fix Limit the check to fit paths whose input grain is one observation per unit and period. Name group-period aggregation as an exception in both places. docs/input-contract.md:L54-L56, docs/input-contract.md:L87-L94, TODO.md:L24-L24, diff_diff/chaisemartin_dhaultfoeuille.py:L905-L924

Tech Debt

  • P3 — Existing input-handling gaps are tracked in TODO.md. Impact The seven rows give the follow-up implementation concrete cases for outcome, inference, and panel validation. Concrete fix No action required in this PR. TODO.md:L24-L30

Security

No findings.

Documentation/Tests

  • P2 — IC-16 contradicts the published pickle migration. Impact Its blanket cross-version exclusion covers 3.x results pickles that the 4.0 migration guide explicitly supports. Concrete fix Apply the exclusion to version pairs and object types outside the documented migrations, and link to the guide. docs/input-contract.md:L71-L75, docs/migration-4.0.md:L340-L343
  • P2 — The uneven-spacing inventory overstates silent behavior. Impact The gap table and backlog say no estimator warns, but StackedDiD warns when a missing calendar period drops an adoption event and raises when no complete event window remains. Concrete fix Describe the missing general spacing advisory separately from the existing complete-window warning and error. docs/input-contract.md:L120-L126, TODO.md:L28-L28, diff_diff/stacked_did.py:L805-L839, tests/test_stacked_did.py:L2985-L3021

git diff --check passed. Static checks verified the Sphinx exclusion, clause numbering, and backlog table structure. The pytest suites could not run because pytest is absent from the checkout environment.

…gression with IC-15

IC-09 applies to fit paths whose input grain is one observation per
unit and period, which excludes estimators that aggregate cells. IC-16
excepts the documented 3.x pickle migration. The label-0 regression in
TODO.md now keeps 0 reserved, and the uneven-spacing gap notes the
narrower check StackedDiD already has.
…e requirement, narrow IC-01 and IC-04 wording
… of IC-14; track the PT-Post registry wording
…tion

The implemented baseline is g - 1 - anticipation in label units; g-1 is
the anticipation=0 case the paper derives. The tracking row now covers
only the generic missing-baseline error.
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 5cb74666a4dd72de1f7aaff9faaf8dd8ec344102


Overall assessment

✅ Looks good. All four prior P2 findings are resolved. One P2 documentation clarification remains.

Executive summary

  • The revised contract distinguishes ambiguous cohort-zero inputs from panels that the caller has explicitly recoded.
  • The duplicate-row rule follows the input grain, IC-16 preserves documented pickle migrations, and the spacing inventory accounts for StackedDiD’s complete-window checks.
  • The EfficientDiD note matches the implemented baseline and missing-period warning. It should also state the parallel-trends condition for using that baseline with anticipation.
  • The diff changes documentation and its Sphinx build configuration. No changelog fragment is required.

Methodology

  • P2 — Clarify PT-Post identification with anticipation. Impact The new note shifts the baseline to g - 1 - anticipation, while the adjacent assumption still describes parallel trends beginning at adoption. With g=4 and anticipation=1, a treated–control difference in untreated trends from period 2 to 3 can bias the period-4 contrast even when trends are parallel from period 3 to 4. Concrete fix Label the paper’s assumptions as the anticipation=0 case. State that the extension assumes no anticipation effects before g - anticipation and requires conditional parallel untreated trends against the never-treated group from the shifted baseline through the target period. docs/methodology/REGISTRY.md:L1833-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L28-L32
  • P3 — Documented PT-Post baseline rule. Impact Corollary 3.2 gives g - 1 under no anticipation. The new Registry note records the existing limited-anticipation extension and correctly explains that a missing required period causes the cohort to be dropped with a warning. Concrete fix No action required for the baseline rule. docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, docs/methodology/REGISTRY.md:L1835-L1837, diff_diff/efficient_did.py:L905-L920

The prior cohort-zero finding is resolved. The backlog specifies separate fixtures for rejecting an ambiguous 0 and verifying that explicitly recoded adopters stay out of the never-treated pool. docs/input-contract.md:L64-L69, TODO.md:L28

Code Quality

No findings.

Performance

No findings.

Maintainability

The prior duplicate-row finding is resolved. The clause and backlog both scope rejection to fits that require one row per unit and calendar period, with explicit exceptions for post indicators and within-cell aggregation. docs/input-contract.md:L54-L56, TODO.md:L24, diff_diff/chaisemartin_dhaultfoeuille.py:L902-L923

Tech Debt

  • P3 — Existing gaps are tracked in TODO.md. Impact The eight rows record follow-up work for the shared input boundary and the generic EfficientDiD error when every cohort lacks its required baseline. Concrete fix No action required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

The prior pickle and spacing findings are resolved. IC-16 preserves documented migrations, and the spacing inventory distinguishes the proposed general advisory from StackedDiD’s existing warnings and errors. docs/input-contract.md:L71-L75, docs/migration-4.0.md:L335-L343, docs/input-contract.md:L123-L127, tests/test_stacked_did.py:L2985-L3021

git diff --check and static checks for clause numbering, backlog table structure, and the Sphinx exclusion passed. The three targeted test suites could not run because pytest is unavailable. The cited paper links were unreachable from the review environment, so the methodology cross-check used the checked-in paper review, Registry, and implementation.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: f1b592f95ac5d3afa7c65278072ce6662ab2f0d7


Overall assessment

✅ Looks good. The prior findings are resolved. One P2 documentation clarification remains.

Executive summary

  • The EfficientDiD Registry note now states the identifying assumptions for the anticipation-shifted PT-Post baseline.
  • The contract preserves the earlier fixes for cohort-zero handling, duplicate rows, period spacing, and documented pickle migrations.
  • IC-11 should explicitly exclude both never-treated markers from the label span calculation so they remain interchangeable when large labels are supported.

Methodology

  • P3 — Documented PT-Post extension. Impact. The revised note preserves Chen, Sant’Anna & Xie’s g - 1 baseline under no anticipation. For anticipation > 0, it specifies g - 1 - anticipation, requires no anticipation effects in conditional mean before g - anticipation, and requires conditional parallel untreated trends against the never-treated group for each increment through the target period. The baseline and missing-period warning match the implementation. Concrete fix. No action required. docs/methodology/REGISTRY.md:L1833-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, diff_diff/efficient_did.py:L905-L920

Code Quality

No findings.

Performance

No findings.

Maintainability

No open findings. IC-09 scopes duplicate-row rejection to fits that require one observation per unit and calendar period, preserving post-indicator and within-cell aggregation paths. docs/input-contract.md:L54-L56, TODO.md:L24

Tech Debt

  • P3 — Existing gaps are tracked in TODO.md. Impact. Eight backlog rows cover the shared input boundary and the generic EfficientDiD error when every cohort lacks its required baseline. Concrete fix. No action required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

  • P2 — Exclude never-treated markers from the IC-11 label span. Impact. The phrase “finite cohort labels” can include the reserved 0 marker. Once large labels are supported, periods from 2**53 + 2 through 2**53 + 6 could fail the span check with 0 and pass with +inf, even though both encode the same comparison group. Concrete fix. Specify that the magnitude check, span check, and offset use the time labels and treated-cohort labels after both never-treated markers have been identified. docs/input-contract.md:L64-L69

The prior pickle and spacing findings remain resolved. IC-16 preserves documented migrations, and the spacing inventory accounts for StackedDiD’s complete-window checks. The documentation-only diff requires no changelog fragment. docs/input-contract.md:L71-L75, docs/input-contract.md:L123-L127, tests/test_stacked_did.py:L3007-L3022, changelog.d/README.md:L3-L8

Patch applicability, added-line whitespace, clause numbering, backlog table structure, and the Sphinx exclusion passed static checks. The targeted suites could not run because pytest is unavailable. The cited papers were unreachable, so the methodology check used the checked-in paper review, Registry, and implementation.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 89ecdb7851fee05602d3c4e4e37ef39845c58727


Overall assessment

✅ Looks good. The prior findings are resolved. One P2 documentation issue remains.

Executive summary

  • IC-11 now excludes both never-treated markers from the magnitude check, span check, and offset.
  • The EfficientDiD Registry note gives the identifying assumptions for the anticipation-shifted PT-Post baseline.
  • The CallawaySantAnna non-finite-outcome example now distinguishes the affected cohort-time estimate from the overall ATT.
  • IC-12 and IC-13 should preserve the calendar-label support already used by TWFE event studies.

Methodology

  • P3 — Documented PT-Post extension. Impact. Chen, Sant’Anna & Xie’s Corollary 3.2 uses g - 1 under no anticipation. The Registry note explains that anticipation > 0 shifts the baseline to g - 1 - anticipation and requires conditional parallel untreated trends against the never-treated group over each increment from that baseline to the target period. The baseline and missing-period warning match the implementation. Concrete fix. No action required. docs/methodology/REGISTRY.md:L1830-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, diff_diff/efficient_did.py:L905-L920

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 — Existing input-boundary gaps are tracked. Impact. Eight new backlog rows record the input-validation, numerical-stability, and diagnostic follow-ups. Concrete fix. No action required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

  • P2 — Scope the calendar-label refusals in IC-12 and IC-13. Impact. TWFE event studies sort and match calendar labels. An existing end-to-end test requires datetime-labeled fits with Conley inference to reproduce the standard errors from an equivalent integer-labeled fit. The Registry also describes how string calendar labels are ordered. Applying the draft’s blanket refusals through the shared validator would reject supported calls. Concrete fix. Preserve TWFE event-study calendar labels in IC-12 and IC-13 and state which fit paths require numeric label differences. docs/input-contract.md:L58-L68, diff_diff/estimators.py:L1463-L1506, tests/test_conley_vcov.py:L1675-L1703, docs/methodology/REGISTRY.md:L6735-L6745

The duplicate-row, period-spacing, and documented pickle migration fixes remain in place. The diff requires no changelog fragment. docs/input-contract.md:L54-L75, changelog.d/README.md:L3-L8

Static checks passed for Markdown tables, clause numbering, the Sphinx exclusion, and changelog conventions. The targeted suites could not run because pytest was unavailable. The cited papers were unreachable, so the methodology check used the checked-in paper review, Registry, and implementation.

…bel arithmetic

IC-10 to IC-14 do not apply to paths that only sort and match calendar
labels against caller-named periods, such as the TwoWayFixedEffects
event-study mode, which keeps its datetime, Period and string label
support. Probe counts for the label gaps now refer to the 7 cohort-based
estimators, since the static DiD and TWFE paths do not read the time
column.
…ath supports; state the IC-14 probe coverage
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 29cf5cbc0396a11abb0a8b1b8421e0c7334dbec8


Overall assessment

✅ Looks good. The prior findings are resolved. One P2 documentation issue remains.

Executive summary

  • IC-12 and IC-13 now preserve TWFE event-study support for integer, datetime, Period, and string calendar labels.
  • The EfficientDiD Registry note explains the existing anticipation-shifted PT-Post baseline and the assumptions needed for identification.
  • The uneven-spacing backlog entry makes a broader claim than the seven-estimator probe supports.
  • The diff changes documentation and its Sphinx configuration. No estimator behavior changed, so no changelog fragment is required.

Methodology

  • P3 — Documented EfficientDiD PT-Post extension. Impact. Chen, Sant’Anna & Xie’s Corollary 3.2 uses g - 1 under no anticipation. The Registry now explains that positive anticipation shifts the baseline to g - 1 - anticipation and requires conditional parallel untreated trends against the never-treated group over each increment from that baseline to the target period. The baseline and missing-period warning match the implementation. Concrete fix. No action required. docs/methodology/REGISTRY.md:L1830-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, diff_diff/efficient_did.py:L905-L920

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 — Existing input-boundary gaps are tracked in TODO.md. Impact. Eight backlog rows record the observed validation, numerical-stability, and diagnostic gaps and the planned fixes. Concrete fix. No estimator changes are required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

  • P2 — Scope the IC-14 evidence consistently. Impact. The gap table limits the uneven-spacing warning observation to seven cohort-based estimators under default settings, while the backlog says “no estimator.” The focused anticipation probes covered a subset, so the text leaves unclear which nonzero anticipation paths were verified. Concrete fix. Use the gap table’s seven-estimator qualifier in the backlog. Name the paths probed with positive anticipation or describe the effect on anticipation windows as a consequence of treating encoded calendar labels as elapsed time. TODO.md:L28, docs/input-contract.md:L135-L135, docs/input-contract.md:L151-L162

The prior calendar-label finding is resolved. TWFE sorts and matches the supplied labels, and its existing Conley regression test checks that datetime and integer encodings give the same standard errors. docs/input-contract.md:L62-L75, diff_diff/estimators.py:L1463-L1506, tests/test_conley_vcov.py:L1675-L1703

Static checks passed for Markdown tables, clause numbering, and the Sphinx exclusion. pytest was unavailable, so the targeted suites and probe matrix were not rerun. The external papers were unreachable, so the methodology check used the checked-in paper review, Registry, and implementation.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: 0461899d7c76eb856812b8214c9275e209e52fd6


Overall assessment

✅ Looks good. All prior findings are resolved. No P0 or P1 findings remain.

Executive summary

  • IC-14 now limits the uneven-spacing warning claim to the seven cohort-based estimators probed under default settings and names the estimators used in the focused horizon and anticipation probes.
  • IC-12 and IC-13 preserve calendar-label support in the TwoWayFixedEffects event-study path.
  • The EfficientDiD Registry note documents the existing PT-Post baseline and its identification assumptions.
  • One minor clarification remains about level warnings for constant outcomes. The documentation-only diff qualifies for the changelog fragment exemption.

Methodology

  • P3 — Documented EfficientDiD PT-Post extension. Impact. Chen, Sant’Anna & Xie’s Corollary 3.2 uses g - 1 under no anticipation. The Registry describes the existing g - 1 - anticipation baseline, the conditional parallel untreated trends needed from that baseline through the target period, and the warning when the baseline is absent. The baseline lookup and warning match the implementation. Concrete fix. No action required. docs/methodology/REGISTRY.md:L1833-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, diff_diff/efficient_did.py:L905-L920

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 — Existing input-boundary gaps are tracked in TODO.md. Impact. Eight backlog rows record the observed validation, numerical stability, and inference gaps for the shared input boundary. Concrete fix. No action required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

  • P3 — IC-05 leaves the level warning unspecified for constant outcomes. Impact. abs(mean(y)) / sd(y) has a zero denominator for constant outcomes. The clause leaves open whether its level warning should accompany the IC-06 inference warning for all-zero or nonzero constant data. Concrete fix. Define the IC-05 warning behavior for both cases before implementing the shared check. docs/input-contract.md:L47-L48, TODO.md:L27

Static checks passed for clause numbering, Markdown table shapes, the IC-14 evidence qualifiers, and the Sphinx exclusion. pytest was unavailable, so the targeted suites and probe matrix were not rerun. The external papers were unreachable, so the methodology check relied on the checked-in paper review, Registry, and implementation.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

🔁 AI review rerun (requested by @igerber)

Head SHA: b70f3dd52a058036809c5ebec33c7173aba706fa


Overall assessment

✅ Looks good. All prior findings are resolved. No unmitigated P0 or P1 findings remain.

Executive summary

  • IC-05 now specifies that all-zero and nonzero constant outcomes skip the level warning and follow IC-06. The backlog records both regression cases. docs/input-contract.md:L47-L48, TODO.md:L27
  • IC-12 and IC-13 preserve calendar-label support for the TwoWayFixedEffects event-study path. IC-14 limits its evidence claim to the seven cohort-based estimators probed under default settings. docs/input-contract.md:L62-L75, docs/input-contract.md:L135-L135
  • The EfficientDiD Registry note records the existing PT-Post baseline, its identification assumptions under limited anticipation, and the missing-baseline warning. docs/methodology/REGISTRY.md:L1833-L1837
  • The documentation-only diff qualifies for the changelog fragment exemption.

Methodology

  • P3 — Documented EfficientDiD PT-Post convention. Impact. Chen, Sant’Anna & Xie’s Corollary 3.2 uses g - 1 under no anticipation. The Registry explains that with limited anticipation, the implementation uses g - 1 - anticipation in label units and requires conditional parallel untreated trends over every increment from that baseline to the target. It also matches the implementation’s warning when the baseline is absent. Concrete fix. No action required. docs/methodology/REGISTRY.md:L1833-L1837, docs/methodology/papers/chen-santanna-xie-2025-review.md:L105-L112, diff_diff/efficient_did.py:L905-L920

Code Quality

No findings.

Performance

No findings.

Maintainability

No findings.

Tech Debt

  • P3 — Existing input-validation and inference gaps are tracked in TODO.md. Impact. Eight backlog rows record the observed gaps, including acceptance cases for cohort-label mapping and rounding-level inference. Concrete fix. No action required in this PR. TODO.md:L24-L31

Security

No findings.

Documentation/Tests

No findings. git diff --check and static checks for clause numbering, Markdown tables, and the Sphinx exclusion passed. The shallow checkout lacked the previous review’s commit, so I verified its findings against the supplied review and the current diff. Validation was limited to static checks because pytest was unavailable. The methodology check used the checked-in paper review, Registry, and implementation because the external paper hosts were unreachable.

@igerber igerber added the ready-for-ci Triggers CI test workflows label Dec 1, 2026
@igerber
igerber merged commit 7723c6d into main Dec 1, 2026
39 of 40 checks passed
@igerber
igerber deleted the codex-review branch December 1, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ci Triggers CI test workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant