Commit 68678e9
Codex CI R6 holistic: shared Conley validator + sparse density gate + P3 uniform-kernel limit fix
Three findings on R6, addressed via pattern-level fixes rather than
single-site patches, after 5 cross-round findings across 2 mirror
classes (validation-gap, raw-data-vs-working-data) signaled the symptoms
were drifting between estimator surfaces.
P1 (Code Quality) — shared estimator validator
Validation gaps mirrored across DiD (R1, R2) and MPD/TWFE (R6) under
the same `vcov_type='conley'` entry-point contract: missing/unknown
unit column, malformed conley_coords arity, missing coord column,
survey_design rejection, wild_bootstrap rejection. Replaces three
separate inline blocks (one per estimator) with a single
`_validate_conley_estimator_inputs(...)` helper in `conley.py`,
called from `DifferenceInDifferences.fit()`,
`MultiPeriodDiD.fit()`, and `TwoWayFixedEffects.fit()`. Single
source of truth for the seven-check union; future estimator
surfaces (HAD-Conley, SDID-Conley) pick up the same contract by
one-line opt-in.
P2 (Performance) — sparse density gate
The sparse k-d-tree path's CSR storage (~12 bytes/nnz: data +
indices + indptr) loses its memory advantage over dense float64
(8 bytes/cell) at ~67% density; at high density "sparse" can
silently use MORE memory than dense. Adds
`_CONLEY_SPARSE_DENSITY_THRESHOLD = 0.3` (well below break-even
for a comfortable safety margin). After kd-tree build,
`cKDTree.count_neighbors` (shares traversal with the subsequent
`query_ball_tree`) measures actual neighbor density; if it exceeds
the threshold, `_compute_spatial_bartlett_meat_sparse` returns
None, the dispatcher falls back to the dense path, and a
UserWarning surfaces the reason. Locks the auto-sparse contract:
it only fires when it actually saves memory.
P3 (Documentation/Tests) — uniform kernel for huge-cutoff limit
`test_combined_kernel_reduces_to_pure_cluster_at_huge_cutoff` used
Bartlett at cutoff=1e9; Bartlett gives K=1-d/h<1 for d>0, so the
reduction to pure CR1 is asymptotic, not exact. Switched to
uniform kernel (K=1 exactly for all in-cutoff pairs). REGISTRY
note clarifies the kernel choice rationale.
Tests:
- test_sparse_density_gate_falls_back_to_dense_and_warns:
tight-cluster + huge cutoff → 100% density → fallback +
warning + result equals dense.
- test_sparse_density_gate_does_not_trigger_below_threshold:
realistic cutoff → no fallback / no warning.
Full regression sweep: 493 passed (no regressions across
conley_vcov, linalg, estimators, estimators_vcov_type,
methodology_twfe).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e03318d commit 68678e9
5 files changed
Lines changed: 295 additions & 124 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
90 | 102 | | |
91 | 103 | | |
92 | 104 | | |
| |||
186 | 198 | | |
187 | 199 | | |
188 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
189 | 304 | | |
190 | 305 | | |
191 | 306 | | |
| |||
248 | 363 | | |
249 | 364 | | |
250 | 365 | | |
251 | | - | |
| 366 | + | |
| 367 | + | |
252 | 368 | | |
253 | 369 | | |
254 | 370 | | |
| |||
329 | 445 | | |
330 | 446 | | |
331 | 447 | | |
332 | | - | |
333 | | - | |
| 448 | + | |
| 449 | + | |
334 | 450 | | |
335 | | - | |
336 | 451 | | |
337 | 452 | | |
338 | 453 | | |
339 | 454 | | |
340 | 455 | | |
341 | | - | |
342 | 456 | | |
343 | 457 | | |
344 | 458 | | |
345 | 459 | | |
346 | 460 | | |
347 | 461 | | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
348 | 483 | | |
349 | 484 | | |
350 | 485 | | |
| |||
732 | 867 | | |
733 | 868 | | |
734 | 869 | | |
735 | | - | |
736 | | - | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
737 | 875 | | |
738 | 876 | | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
739 | 880 | | |
740 | 881 | | |
741 | 882 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
446 | 411 | | |
447 | 412 | | |
448 | 413 | | |
| |||
1492 | 1457 | | |
1493 | 1458 | | |
1494 | 1459 | | |
1495 | | - | |
1496 | | - | |
1497 | | - | |
1498 | | - | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
1499 | 1464 | | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
1514 | | - | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
1528 | | - | |
1529 | | - | |
1530 | | - | |
1531 | | - | |
1532 | | - | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
1536 | 1477 | | |
1537 | 1478 | | |
1538 | 1479 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
197 | 188 | | |
198 | 189 | | |
199 | 190 | | |
| |||
0 commit comments