Skip to content

perf(events): skip venue resolution in fetch-phase source identity lookup - #4118

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-4117-data-machine
Nov 30, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-4117-data-machine

Conversation

@chubes4

@chubes4 chubes4 commented Nov 30, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #4117. EventSourceIdentity::resolveStable() runs for every raw Dice.fm event, before the max_items cap applies. It only needs to know whether the stable source ID already claims an event, but it called EventIdentity::resolve(). That function always runs resolveVenue() → 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 of resolve() into a public EventIdentity::sourceClaim(). resolve() now calls it, and resolveStable() calls it directly, so the fetch phase never resolves venue identity. Why a separate method rather than a venue => false option on resolve(): 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 with source_claim and duplicates, 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 same item_identifier as 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

  • inc/Core/DuplicateDetection/EventIdentity.php: new public 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 before
  • inc/Utilities/EventSourceIdentity.php: resolveStable() returns the stable ID early when core reports it as processed or actively claimed, and otherwise calls EventIdentity::sourceIdentity() + sourceClaim() instead of EventIdentity::resolve(), so venue identity is no longer resolved during fetch
  • tests/Unit/EventSourceIdentityTest.php: 3 regression tests. They watch SQL queries for venue taxonomy and _venue_ meta, and count calls to the data_machine_events_normalize_venue_name filter. 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 through sourceClaim() without venue resolution

Verification

  • 2-verify-61674783fdb92210d0df7b452ae1a815ea936ed6375a5272739fdf273b4ca92a.txt (homeboy review test data-machine-events): passed on f53da5c. Base main@cacfa8a unchanged. 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 on f53da5c. Base main@cacfa8a unchanged. 54031 ms; retained gate metadata.

  • repro: none (no repro gate was declared, so these gates do not prove the issue).

  • CI: pending

Cook run
  • Cook ID: agent-task-fea837f0-2dce-493f-9612-37a1d6457ae0
  • Attempt run ID: agent-task-fea837f0-2dce-493f-9612-37a1d6457ae0-attempt-1-8da70014
  • Gate 1: tree 6304bec5eb19f03a59697e6570386af99da58d44
  • Gate 2: tree 6304bec5eb19f03a59697e6570386af99da58d44

Delivery

  • Delivered: Source-claim lookup in resolveStable() no longer resolves venue identity
  • Delivered: Early return when the stable ID is already processed or actively claimed
  • Delivered: Hash fallback, upsert venue persistence and pre-AI dedup left unchanged
  • Delivered: Regression test in plugins/data-machine-events/tests

Evidence

  • Targeted run with the fix: 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 checked against the old code: with the inc/ changes stashed, test_unclaimed_stable_id_does_not_resolve_venue_identity fails 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

@chubes4
chubes4 marked this pull request as ready for review November 30, 2026 13:07
@chubes4
chubes4 merged commit 767bbfa into main Nov 30, 2026
6 checks passed
@chubes4
chubes4 deleted the fix/issue-4117-data-machine branch November 30, 2026 13:07
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.

data-machine-events: Dice fetch resolves full venue identity per raw event (pre max_items) → 120s fatal in Venue_Taxonomy proximity scan

1 participant