Skip to content

Make the stored-id prepass report what it did - #841

Merged
ajslater merged 1 commit into
developfrom
onlinetag-prepass-attribution
Sep 9, 2026
Merged

ajslater merged 1 commit into
developfrom
onlinetag-prepass-attribution

Conversation

@ajslater

@ajslater ajslater commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Follow-up to #840, which fixed neither symptom in practice. Both of its fixes hooked comicbox's event-emitting search session, and a re-tag never enters that session: comics codex already holds an issue id for are fetched by explicit id in the stored-id prepass, outside it. On a re-tag that prepass is the entire run.

Evidence from the reporting instance: the frozen snapshot had five comics, all {"comicvine": "matched"} with no Metron cell, merge_all_sources: true — while the log for the same run showed online metron: added id=134167, id=170212, id=8862… Metron had refreshed every one of those comics.

A merged refresh now credits every source that landed

record_prefetch_match took a single primary source. Under merge-all the prepass pins every stored id and comicbox fetches and merges them all, so a comic refreshed from both sources showed Matched in one column and an em-dash in the other — the cell that reads "never consulted".

resolved_id_sources reports which of the requested ids came back in the merged record, and every one of them is credited. The primary needs no such check: fetch_tags_by_explicit_id already returns nothing unless its own id landed. A source this scan never pinned — first-wins, or no credentials — still reports nothing, which is what the em-dash is for.

This matches what the search path already does: under merge-all comicbox emits one AutoWritten per contributing source, and the fold accumulates them.

The status rail covers the prepass

Only collect_results opened an OnlineLookupStatus, so a scan that resolved everything from stored ids ran start to finish with no active row at all — an empty rail, while the Tagging tab's table, published from the same loop, showed each lookup as it happened. #840's looking up on <source> subtitle was written to self._pass_runner.lookup_status, which is None for the whole prepass.

The prepass now opens the row (begin_status), totalled over the whole batch so the count doesn't jump when the search pass takes over, and advances complete per committed comic. collect_results adopts an already-open row instead of starting a second one, so the rail shows one continuous job whose elapsed time counts the prepass, and still finishes it in its finally. finish_status() in run_session's finally closes the row if the prepass raises before the search pass can adopt it.

Testing

  • pytest: 1113 passed. New coverage: merged-fetch attribution, first-wins attribution (the source that sat out stays blank), the prepass opening and naming its status row, collect_results adopting rather than restarting it, and finish_status idempotence.
  • make fix, make lint, make ty: clean.

🤖 Generated with Claude Code

Both of the previous PR's fixes hooked the event-emitting search session.
Neither one fires for a re-tag, because comics codex already holds an
issue id for never reach that session: the stored-id prepass fetches them
by explicit id outside it, and on a re-tag that prepass is the whole run.

Two consequences, both visible in the admin Tagging tab:

- A merged multi-source refresh was credited to the primary source alone.
  Under merge-all the prepass pins every stored id and comicbox fetches
  and merges them all, so a comic refreshed from Metron *and* Comic Vine
  showed Matched in one column and an em-dash in the other — the cell that
  reads as "this source was never consulted". Each source whose requested
  id comes back in the merged record is now credited; the primary is
  proven by the fetch itself, which returns nothing unless its own id
  landed. A source the scan never pinned (first-wins, or no credentials)
  still reports nothing, which is what the em-dash is for.

- Only the search pass opened a librarian status row, so a scan that
  resolved every comic from a stored id ran start to finish with an empty
  status rail, while the Tagging tab's table — published from the same
  loop — showed each lookup as it happened. The prepass now opens the row,
  totalled over the whole batch, advances it per comic, and the search
  pass adopts it instead of starting a second one, so the rail shows one
  continuous job whose elapsed time counts the prepass. The live marker's
  "looking up on <source>" subtitle lands there too, which is what it was
  missing to reach the rail at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ajslater
ajslater merged commit b0a92e1 into develop Sep 9, 2026
3 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