Add rejudge_fallback_channel command: compare-and-retract-on-change for stage-d-fallback-v1 - #495
Merged
Merged
Conversation
…or stage-d-fallback-v1
… hangs When test_peak_alive_fetch_payloads_bounded_by_queue_depth_not_cohort_size fails (thread doesn't finish in time), the non-daemon thread blocks Python process exit for up to 6 hours until GitHub Actions kills the job. Making it daemon lets the process exit cleanly while keeping the assertion that detects the regression.
WilfordGrimley
added a commit
that referenced
this pull request
Jul 27, 2026
…letion (#500) * docs: document local_calculate_verdicts --diff-report and per-calculator counters (PR #494) * docs: document rejudge_fallback_channel compare-and-retract command (PR #495) * docs: Stage C full-catalog completion record (218,108/218,516, 99.8%) * docs: document web-ci.yml per-surface CI gating (PR #466) * docs: fix rejudge_fallback_channel command path (cardpicker/management/commands/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rejudge_fallback_channelmanagement command: compare-and-retract-on-change for thestage-d-fallback-v1channel. Re-derives each targeted card's fallback verdict via the EXISTING, unmodifiedlocal_calculate_verdicts.calculate_fallback_verdictfrom CURRENT storedImageEvidence(layout_class/artist_ocr_name/symbol_phash— no re-parse step, zero image fetches), compares against the card's recordedstage-d-fallback-v1CardPrintingTagvote /CardScanLogskip row, and retracts (deletes) the fallback rows only where the conclusion CHANGED, so the card is eligible again forrun_fallback_calculator's own next pass. Skeleton mirrorsreparse_collector_evidence(recorded-state lookup, fresh verdict, compare, safety gate, delete +resolve_and_persist_printing).stage-d-join-key-v1rows: fallback eligibility is GATED on the join-key no-hit state existing (_fallback_eligible_cards_queryset) — deleting join-key rows would eject the card from the fallback population entirely.reparse_collector_evidence's conservative card-level reading: retraction refused (countedgate_refused, card pks recorded for human review) wheneverprinting_consensus.resolve_printing(card)is not None — covers BOTH a resolved printing and a resolved NO_MATCH consensus.--card-ids-file(reusesutils.read_card_ids_file) or--selector all-channel(every card carrying anystage-d-fallback-v1CardPrintingTagorCardScanLogrow).--writebehind the issue Code-enforced guard: require a matching prior dry-run before accepting --write for the same selector/cohort #362 forced-dry-run guard (matching COMPLETED dry-run of the SAME--selector/--card-ids-filewithin--dry-run-window-hours, scope-hash over the invocation input,--skip-dryrun-checkoverride).PilotRunLedgerintegration: counters persisted BEFORE terminal output (considered,unchanged,changed,retracted,no_evidence,no_prior_fallback_state,gate_refused,gate_refused_card_ids, per-reasonrecorded -> freshtransitionsbreakdown),votes_writtenrepurposed as rows-retracted (same convention asreparse_collector_evidence),resilient_terminal_output+mark_ledger_failedrails reused frompilot_run_lifecycle. Stdout prints counters plus up to 20 sample transition lines ({'card_id': N, 'recorded': (...), 'fresh': (...)}).CandidateNameIndexvia_get_cached_candidate_name_index()(issue Streaming dispatch pays catalog-scaling fixed overhead per call (unscoped scan-log subquery, eager CandidateNameIndex) #469 pattern, matchingrun_fallback_calculator's own lazy build) rather thanreparse_collector_evidence's older unconditional construction — an empty or all-no_evidencecohort never pays the index build.test_rejudge_fallback_channel.py(17 tests) mirroringtest_reparse_collector_evidence.py/test_local_calculate_verdicts.pyDB-test patterns: changed-conclusion retracts rows + recomputes consensus, end-to-end re-eligibility proof viarun_fallback_calculator, unchanged leaves rows, resolved-card gate-refuses, join-key rows never deleted, dry-run writes nothing,no_evidence/no_prior_fallback_statebranches, selector coverage/dedup, ledger counters persisted on completion, forced-dry-run guard (refusal / scope-mismatch / write-after-matching-dry-run).CLAUDE.md task-end checks applied:
docs/is outside this PR's allowed scope).docs/upstreaming/extractable-primitives.md): no row added or removed — the command is fork-coupled to the vote system/CanonicalPrinting-consensus by construction (STAGE_D_FALLBACK_ANONYMOUS_ID,calculate_fallback_verdict,printing_consensus,PilotRunLedger); snip no dependency-free primitive was produced or destroyed.Test plan
All pytest invocations run from the worktree's
MPCAutofill/directory with the box's pilot venv python (/home/ubuntu/.venvs/mpcautofill-pilot/bin/python -m pytest ... -q), against the suite's own isolated testcontainers Postgres/ES fixtures (perdocs/lessons.md's sanctioned throwaway flow; snip live docker stack and live DB never touched):pytest cardpicker/tests/test_rejudge_fallback_channel.py -q— 17 passedpytest cardpicker/tests/test_local_calculate_verdicts.py -q— 135 passedpytest cardpicker/tests/test_pilot_run_lifecycle.py -q— 33 passedpytest cardpicker/tests/test_reparse_collector_evidence.py -q— 37 passed (insurance; snip the new command mirrors that module's skeleton)black --check+isort --check-only+ruff checkon both touched files — cleanmypy --config-file mypy.ini cardpicker/management/commands/rejudge_fallback_channel.py— Success: no issues found (mypy 1.7.0 + django-stubs, matching CI's pre-commit environment; snip tests are excluded bymypy.ini)