Skip to content

W5: streaming bulk — illustration calc, version-aware resume, bulk-scale test - #511

Merged
WilfordGrimley merged 5 commits into
masterfrom
w5-streaming-bulk
Jul 28, 2026
Merged

W5: streaming bulk — illustration calc, version-aware resume, bulk-scale test#511
WilfordGrimley merged 5 commits into
masterfrom
w5-streaming-bulk

Conversation

@WilfordGrimley

Copy link
Copy Markdown

Summary

Wires the illustration deduction calculator (#507) into the Stage E streaming conveyor and makes the resume filter version-aware, preventing stale-version rows from being silently skipped.

Stacked on #509 (illustration-id-deduction).

Changes

  • Illustration calculator wired into streaming conveyor (stage_e_dispatch._run_stage_d): run_illustration_calculator called after fallback, before slow-path; lazy import, card_ids-scoped, dry_run=False. Ledger counters: stage_d_illustration_votes, stage_d_illustration_already_voted.
  • Version-aware resume filter: New MANIFEST_EXTRACTOR_CURRENT_VERSIONS dict (single-source, in run_image_evidence_cohort.py) maps each extractor key to its current version string. Both callers (_select_micro_batch and _run_stage_c in stage_e_dispatch.py, plus run_image_evidence_cohort's own bulk filter) now use __contains (PostgreSQL @>) instead of __has_keys, so a card with old version tags is re-processed rather than skipped.
  • Bulk-scale test (1200 synthetic cards): 200 current-version (skipped), 200 stale-version (re-processed), 800 no-evidence (eligible). Verifies version-aware filter correctness at scale.
  • Bulk run preconditions subsection in docs/features/stage-e-operations.md: streaming disabled/paused, no open trip, version-aware filter explanation, git SHA, illustration calculator.
  • Idempotency audit: confirmed sound — card-create fires exactly once (created=True), evidence-change echo suppression prevents dispatch-internal cascades, illustration calculator writes Printing rows (not ImageEvidence), no new echo path.

Test plan

  • pytest cardpicker/tests/test_stage_e_dispatch.py — 52 passed
  • pytest cardpicker/tests/test_evidence_transfer.py cardpicker/tests/test_stage_e_shakedown.py cardpicker/tests/test_run_image_evidence_cohort.py — 93 passed
  • Combined: 161 passed across affected test files
  • Full suite: 722 passed, 2 skipped (1 flaky test_local_illustration failure — pre-existing, passes individually)
  • ruff, isort, black, mypy, prettier all pass via pre-commit

Phase 1: Import Scryfall illustration_id into CanonicalPrintingMetadata
- Add illustration_id UUIDField to PrintingMetadataRow and model
- Add resolved_illustration_id property for single/double-face parsing
- Migration 0089 for the new field

Phase 2: Stage D illustration deduction calculator (issue #507)
- IllustrationIndex: in-memory (artist_pk, card_name) → illustration_id → printing_pks
- calculate_illustration_verdict: 0→abstain, 1→vote@0.85, N>1→union@0.85/N
- run_illustration_calculator: batch runner with eligibility, gate, purgeability
- Wired into management command between fallback and slow-path
- Tests for index, verdict logic, integration, dry-run, gate check, purgeability
Source bug:
- IllustrationIndex.artist_by_pk was keyed by artist_pk but match_artist
  expects card_pk keys; separated into a dedicated query over ALL
  CanonicalCards so artists are matchable even without illustration metadata

Test bugs:
- CanonicalArtistFactory.objects.get() — factory class, not a model
- candidates=candidate (bare) instead of candidates=[candidate]
- _join_key_no_hit_card set both printing and is_no_match=True, violating
  cardprintingtag_printing_xor_no_match constraint
- _eligible_card had content_phash=None, causing all cards to be skipped
- purge_machine_votes called with unsupported interactive kwarg
…ale test, docs

- Wire run_illustration_calculator into stage_e_dispatch._run_stage_d
  (after fallback, before slow-path; lazy import, card_ids-scoped)
- Add MANIFEST_EXTRACTOR_CURRENT_VERSIONS single-source version map in
  run_image_evidence_cohort.py; fix resume filters in both callers to
  use __contains (version-aware) instead of __has_keys (presence-only)
- Add bulk-scale (1200-card) selection test verifying version-aware
  resume filter re-processes stale versions and skips current ones
- Add Bulk run preconditions subsection to stage-e-operations.md
- Update all test helpers to use real version strings instead of
  synthetic {key-v1} placeholders
- Idempotency audit: confirmed sound (no code change needed)
@WilfordGrimley
WilfordGrimley merged commit 5403ecc into master Jul 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant