Repository navigation
Seed Search images: the request flow (not wired in) - #628
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Nov 11, 2026
daoudclarke
added a commit
that referenced
this pull request
Nov 11, 2026
Commons captions are now part of each image's text (#628), so the questions say so. The caption eval (#630) measured the NSFW rewording on the safety benchmark: an identical table, and the 1.0 threshold holds. The relevance rewording was not measured. The NSFW question's fingerprint changes, so cached verdicts are asked again. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daoudclarke
force-pushed
the
seed-images-prod-pipeline
branch
from
November 11, 2026 07:03
b820afc to
e78ff52
Compare
daoudclarke
added a commit
that referenced
this pull request
Nov 11, 2026
Commons captions are now part of each image's text (#628), so the questions say so. The caption eval (#630) measured the NSFW rewording on the safety benchmark: an identical table, and the 1.0 threshold holds. The relevance rewording was not measured. The NSFW question's fingerprint changes, so cached verdicts are asked again. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daoudclarke
force-pushed
the
seed-images-prod-pipeline
branch
from
November 11, 2026 10:25
e78ff52 to
dfb8cc4
Compare
…ommons mwmbl/imagesearch/seed_images.py runs the #610 request flow in two phases for Combined Search to overlap with Staan and with web ranking: start() gates the query, searches Commons and asks the NSFW question; finish() asks image need and relevance in one request once Staan has answered, then selects. It fails closed to `unavailable`, including when the images are not ready shortly after web ranking finishes. Not wired into an endpoint. The Commons request now also returns each file's English caption (MediaInfo, via prop=entityterms) and its latest revision time, and asks for English metadata explicitly. Files edited in the last week, and files on an operator denylist, are never judged or shown. The need and relevance answers are range-checked like the NSFW ones, web results are capped and kept to one line each, and image requests have their own timeout. No functional changes to the crawler. Part of #610 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from review Image work gets its own thread pool so threads blocked on Commons or Redis after a missed deadline cannot hold up web search; the selection is shielded so a deadline doesn't cancel the shared phase-1 work. Files in deletion categories, and files with a recent file version, are never judged; the denylist is matched case-insensitively; captions are capped. No functional changes to the crawler. Part of #610 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daoudclarke
force-pushed
the
seed-images-prod-pipeline
branch
from
November 11, 2026 10:49
dfb8cc4 to
60e8a96
Compare
daoudclarke
added a commit
that referenced
this pull request
Nov 11, 2026
Commons captions are now part of each image's text (#628), so the questions say so. The caption eval (#630) measured the NSFW rewording on the safety benchmark: an identical table, and the 1.0 threshold holds. The relevance rewording was not measured. The NSFW question's fingerprint changes, so cached verdicts are asked again. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daoudclarke
added a commit
that referenced
this pull request
Nov 11, 2026
Commons captions are now part of each image's text (#628), so the questions say so. The caption eval (#630) measured the NSFW rewording on the safety benchmark: an identical table, and the 1.0 threshold holds. The relevance rewording was not measured. The NSFW question's fingerprint changes, so cached verdicts are asked again. No functional changes to the crawler. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
From Claude:
Stack: builds on #622 (
seed-images-prod-harden). PR 3 of the #610 production plan. Not wired into any endpoint yet; PR 4 does that.What changed
mwmbl/imagesearch/seed_images.pyimplements Seed Search's image request flow in two phases, so Combined Search can overlap each one with the web-search work it doesn't depend on:start(query) -> ImageSearch, called before Staan is fetched. It runs the rules gate on the query, the Commons search (20 candidates), then the NSFW scores (cached per file; the request carries no query).await finish(search, staan_results, web_ranking) -> ImageSelection, called once Staan has answered, with web ranking already running as a task. It sends onejudge.image_request(need plus relevance for every candidate; it doesn't wait for NSFW), then selects images with NSFW < 1.0, need >= 1.65 and relevance >= 1.5. It returns every passing image, most relevant first (ties keep Commons' order), each with itsrelevance.shown | query_refused | not_needed | none_relevant | unavailable. Images getIMAGE_SEARCH_GRACE_SECONDS(0.25 s) after web ranking finishes; after that they areunavailable.finishnever raises.PR 4 would use it roughly like this:
Carry-overs from #620 and #622
checked_score. An off-scale answer meansunavailable.unavailable, because the gate was measured with web results and can't be asked without them. 1 result is enough, since relevance was also measured with Staan's top result alone.IMAGE_JUDGE_TIMEOUT_SECONDS(1.5 s).jev_rank.postnow takes its timeout as an argument.JEV_API_KEY:unavailable, and neither Commons nor the judge is called.IMAGE_SEARCH_DENIED_FILESenv var, holding SHA-1s or page URLs, compared lower-cased. It is a stopgap until PR 5's revocation.rules.image_verdict) are dropped before the judge is asked.Commons caption and English metadata
prop=entityterms(MediaInfo caption,wbetlanguage=en) andprop=revisions(rvprop=timestamp), and setsiiextmetadatalanguage=enexplicitly.SourceImagegainscaptionandrevised_at.wbgetentitieswould have been a second round trip, so it wasn't used.iiextmetadatamultilangwas deliberately not used. MediaWiki treats any value of a boolean parameter,0included, as true, and it adds ~60% to the response. A description with no English version still comes back in Commons' fallback language. That keeps the text the safety judge reads intact, but it means PR 6 cannot assume the extract is English.Caption:and only when present, capped at 250 characters. Files without a caption are judged on exactly the text the thresholds were measured on. Captioned files' text was not re-measured (see below).Verification
make checkpasses.make testpasses (1873 passed, before and after the review fixes).test/test_seed_images.py, with Commons and the judge stubbed, cover:none_relevant(including no candidates and no judge call),query_refusedand the missing key, each with no callsensure_futureinstead ofcreate_task,selectoutside the try, an unretrievedselectionoutcome and exact-case denylist matching. All are fixed.uploaded_atnot checked, the denylist format, the caption cap and the inaccurate "English" comments. All are fixed.Not done here (raised for the next PRs)
httpxlogs request URLs, which contain the query, at INFO. That isn't emitted today, since root is at WARNING. Consider pinning thehttpxlogger to WARNING in PR 4.Part of #610
🤖 Generated with Claude Code