Two pilot fast-follows: expansion_hint narrowing, name-frequency elimination - #26
Merged
Merged
Conversation
expansion_hint candidate narrowing: uses the already-populated Card.expansion_hint field to narrow the candidate list OCR/phash/ fallback consider, unlocking phash for 407 cards currently skipped on too-many-candidates. Scoped to engine-matching only - never touches coverage/ordering queries. Name-frequency elimination: new run_name_frequency_elimination + management command, votes for a card when its name has exactly one uncovered printing AND exactly one unresolved eligible card - the 1:1 gate is what makes the deduction sound (a name with multiple unresolved cards and one uncovered printing doesn't tell you which card is the missing one). 1,678 real cards qualify under the safe gate, measured against the full catalog. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016i9S7LQsCL3FGaih3ZTRBJ
Django DB connections are thread-local; a pool recreated inside the chunk loop leaked one Postgres connection per worker per chunk, since nothing closes a connection when its owning thread is torn down. At workers=7/batch_size=25 against max_connections=100 this crashed the live full-catalog run in ~3 minutes with "too many clients already". Production site traffic was unaffected - confirmed 200s on both domains, connections recovered once the crashed process exited. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016i9S7LQsCL3FGaih3ZTRBJ
# Conflicts: # docs/features/printing-tags.md
tmikonen/magic_card_detector's threshold is a population z-score, not a raw Hamming distance - not directly reusable for the pilot's d=0/d<=2 tiers. Neither prior-art repo has working art-region hash code, just an unimplemented idea. Also logs the fork-context-compaction scope-drift incident as a reusable lesson.
…ering, thin false-split evidence
WilfordGrimley
marked this pull request as ready for review
July 16, 2026 09:43
4 tasks
WilfordGrimley
added a commit
that referenced
this pull request
Jul 16, 2026
get_baked_git_sha reads a GIT_SHA file baked into the image at build time (Dockerfile ARG + docker-compose build.args, both now require the documented GIT_SHA=$(git rev-parse --short HEAD) prefix on the rebuild command) - best-effort visibility only, logged at startup, never the gate itself. find_stale_applied_migrations is the actual hard gate: compares what this image's own migrations/ directory knows about against what the DB reports as applied (MigrationLoader vs MigrationRecorder) - pure DB+code introspection, automates the PR #24/#26 stale-image lesson instead of relying on someone remembering to check docker images timestamps. Caught a real bug via the new test: MigrationRecorder.applied_migrations() returns a dict, not a set - the first draft's `applied - disk` would have raised TypeError at the first real invocation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016i9S7LQsCL3FGaih3ZTRBJ
This was referenced Jul 16, 2026
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
Two fast-follows on top of the pilot's coverage-gap/ordering work (already merged, full-catalog run in progress), both researched and sized before building - neither needed a schema change.
expansion_hint candidate narrowing:
Card.expansion_hintalready exists and is already populated at import time (cardpicker.tags.Tags.extract) -deductive_backfill's own D2 tier already trusts it. Newly wired into the pilot: narrows the candidate listrun_ocr_for_card/run_phash_for_card/run_fallback_for_cardconsider, scoped strictly to engine-matching (never touchesselect_candidates's ordering or coverage queries). Never narrows to empty - falls back to the full list if the hint matches nothing (~9% measured data-quality case).too-many-candidates) - narrowing brings 407 back under the cap. OCR's exact-match logic doesn't benefit from narrowing; this is a phash-only unlock in practice.Name-frequency elimination: new
run_name_frequency_elimination+ management commandlocal_name_frequency_elimination. For a name with exactly one uncovered printing AND exactly one unresolved pilot-eligible card, the match is deducible by elimination alone - no image fetch, no OCR/phash.run_pilot.Test plan
pytest cardpicker/tests/test_local_identify_printing_tags.py- 100 passed, 4 skipped (pre-existing skips from the earlier cluster-dedup pre-pass disablement, unrelated to this PR)mypy --config-file mypy.ini MPCAutofill/- cleanblack/ruff/prettier/pre-commit hooks passed🤖 Generated with Claude Code
https://claude.ai/code/session_016i9S7LQsCL3FGaih3ZTRBJ