Commit 80455e1
authored
feat(calibration): phase-2 backfill — retro reversal labels + raw-context re-fetch (GitHub truth) (#8207)
* feat(calibration): phase-2 backfill CLI — retro successor labels + raw-context re-fetch (GitHub truth)
Pass A runs #8166's evaluateSuccessorMatch retrospectively over the phase-1
backfilled close decisions: a bot-closed PR with a merged successor (shared
linked issue, or same author reworking a majority of its files, merged inside
the 30-day lookback) gets its override row's verdict flipped to reversed with
distinct github_successor_scan provenance — the corpus's first organic-shaped
negative labels. Pass B re-fetches PR diffs (public repos only) into the
phase-1 fired rows' metadata.diff, the exact field the live #8130 capture
records, bounded by the same cap.
Same discipline as phase 1: pure core + thin IO wrapper, deterministic
backfill: ids only (live rows unreachable by construction), idempotent
patchers (already-patched rows return null), dry-run default, hard per-run
GitHub request budget with a resumable state-file cursor.
Advances #8170
* fix(calibration): budget-bound the phase-2 successor listing instead of a 10-page cap
The first full production dry-run returned zero matches because page 10 of
the sort=updated listing only reached back to July 5 while the closes under
scan ended June 22 — a silently truncated listing is indistinguishable from
'no successors'. Depth is now bounded by the run's request budget (hard page
ceiling 200 as a backstop), with the boundary condition unchanged.
Advances #8170
* fix(calibration): time-bound the phase-2 wrapper's wrangler calls so a hung remote execute fails loud
Advances #8170
* feat(calibration): per-heuristic breakdown in the pass-A report
295/460 matches on the first full scan is too many to all be reversals:
in a duplicate-competition culture a shared-issue match by a different
author is usually the gate correctly closing a losing duplicate. The
apply decision needs the same-author-rework vs shared-issue-only split.
Advances #8170
* feat(calibration): capture same-PR reopened+merged reversals in pass A — the definitive label class
The operator's correction to the zero-reversals reading: bot/AI-closed PRs
HAVE been reopened and merged, but latest-decision-wins erased the earlier
close verdicts and the scan skipped merged PRs as 'not a standing close'.
A close-verdict PR that itself shows merged_at is a definitive same-PR
reversal — no heuristics — labeled under github_same_pr_merged provenance,
counted separately from the successor classes in the report.
Advances #8170
* feat(calibration): plan-file applies, class-gated policy, and burst-limit resilience for phase 2
Production hardening from running the passes for real:
- Scan-once/apply-from-plan: the dry-run emits its matches as a plan file
(persisted even on mid-run abort), and --apply --plan-in replays it
against any store with ZERO GitHub requests — the cloud D1 and selfhost
Postgres applies share one scan instead of re-spending ~2.7k requests
each. --pg rides #8171's driver seam for the store side.
- Apply policy is class-gated: same_pr_merged + same_author apply by
default; shared_issue_only (128 of the 301 production matches — routine
duplicate competition, not reversal evidence) is counted and planned but
never applied without an explicit --include-shared-issue-only.
- GitHub IO survives reality: bounded retries on thrown fetches/5xx,
Retry-After honored on 403/429 burst limits (90s default, 5m cap) with
~4 req/s pacing so a stall costs minutes instead of the whole scan, and
the wrangler reads are time-bounded so a hung remote execute fails loud.
Advances #8170
* feat(calibration): default the phase-2 scan to ~2.4k req/hr — the operator's token pool is shared
Advances #81701 parent c26fe94 commit 80455e1
3 files changed
Lines changed: 816 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 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 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
0 commit comments