Repository navigation
perf(events): skip venue resolution in fetch-phase source identity lookup - #4118
Merged
Merged
Conversation
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
Fixes #4117.
EventSourceIdentity::resolveStable()runs for every raw Dice.fm event, before themax_itemscap applies. It only needs to know whether the stable source ID already claims an event, but it calledEventIdentity::resolve(). That function always runsresolveVenue()→Venue_Taxonomy::resolve_venue_identity()(alias, address, proximity scan of about 6.8k rows, then qualified-name lookup), which used up the 120s budget. I moved step 1 ofresolve()into a publicEventIdentity::sourceClaim().resolve()now calls it, andresolveStable()calls it directly, so the fetch phase never resolves venue identity. Why a separate method rather than avenue => falseoption onresolve():resolve()still owns the claim logic through this one method, so there is still a single canonical seam. A skip option would have been a third flag combined withsource_claimandduplicates, and would have returned a half-filled venue result that callers could misread.sourceClaim()returns only what this caller needs, with the same merged-winner and trash semantics. Early return:resolveStable()now returns the stable ID as soon as core reports it as processed or actively claimed, before any EventIdentity lookups. The check that a current or legacy hash is actively claimed still runs first. It is cheap, and #4022 requires active content claims to finish before a new identity is admitted. The early return gives the sameitem_identifieras before, because every remaining path also returned the stable ID. The only thing skipped is re-linking the stable identity to a canonical post found by an old content hash. That link was already made when the stable ID was first processed (the upsert claims or links the identity). If an earlier run processed the stable ID without linking, the upsert still finds the post through full duplicate resolution. The hash fallback with full resolve and duplicates, the upsert's venue persistence, and pre-AI dedup are unchanged.What changed
sourceClaim( string $source_identity, ?callable $source_claim = null )that does only the source-claim lookup and the merged-winner/trash handling;resolve()step 1 now calls it, with the same behaviour as beforeresolveStable()returns the stable ID early when core reports it as processed or actively claimed, and otherwise callsEventIdentity::sourceIdentity()+sourceClaim()instead ofEventIdentity::resolve(), so venue identity is no longer resolved during fetch_venue_meta, and count calls to thedata_machine_events_normalize_venue_namefilter. They prove that an unclaimed stable ID resolves with no venue identity work (the source claim is still checked), that a processed stable ID makes no lookups at all, and that a claimed stable ID still resolves throughsourceClaim()without venue resolutionVerification
2-verify-61674783fdb92210d0df7b452ae1a815ea936ed6375a5272739fdf273b4ca92a.txt (
homeboy review test data-machine-events): passed onf53da5c. Basemain@cacfa8aunchanged. 749436 ms; retained gate metadata.( if git diff --quiet --no-renames cacfa8a -- ' (
( if git diff --quiet --no-renames cacfa8a04297ddf632b12a2b9e77dd2ba8569c85 -- ':(literal)plugins/data-machine'; then :…): passed onf53da5c. Basemain@cacfa8aunchanged. 54031 ms; retained gate metadata.repro: none (no repro gate was declared, so these gates do not prove the issue).
CI: pending
Cook run
agent-task-fea837f0-2dce-493f-9612-37a1d6457ae0agent-task-fea837f0-2dce-493f-9612-37a1d6457ae0-attempt-1-8da700146304bec5eb19f03a59697e6570386af99da58d446304bec5eb19f03a59697e6570386af99da58d44Delivery
Evidence
homeboy --placement local review test data-machine-events -- --filter 'EventSourceIdentityTest|DiceFmStableIdentityTest|EventIdentity'→ PHPUnit OK (14 tests, 91 assertions). The existing identity tests and the new regression tests all pass.test_unclaimed_stable_id_does_not_resolve_venue_identityfails with 'Fetch-phase source identity must not run venue lookup queries. Failed asserting that 3 is identical to 0.' It passes with the fix.AI disclosure
Tool: Homeboy Cook. Agent: Homeboy (roadie). Model: roadie · route cook-heavy · served claude-opus-5-5. Cook time: 1h48m.
Implementation and reviewer documentation were written by the AI, under the direction of the Cook requester. Gates were run by Homeboy. A human reviews before merge.
Refs #4117