Enforce analysis queue claims and state integrity#15
Merged
Conversation
Member
Author
|
Review complete. The claim-token CAS, migration ordering, and analyser token round-trip look sound. I removed the unused Please keep the stated integration order explicit: rebase/reconcile this branch after #14, or resolve the overlapping route changes before merging. Otherwise |
kasnder
force-pushed
the
agent/enforce-analysis-queue-leases
branch
from
July 13, 2026 15:01
161a74d to
6b743bb
Compare
kasnder
marked this pull request as ready for review
July 13, 2026 15:02
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
/queue's plain bundle-ID response body while carrying the claim inX-Analysis-Claim-Token, and update the analyser (including exactONLY_APP_IDruns) to round-trip itWhy
Queue timeouts and explicit resets could previously issue the same app to a new worker while an older worker was still running. Completion updated by bundle ID alone, so that stale worker could overwrite the newer result. The completion update is now a compare-and-set on
(appid, status = 'processing', analysis_claim_token)and consumes the claim on success. Refetches and replays clear the claim, which also invalidates work that they supersede.First-time mixed-case bundle-ID requests also failed because
addAppcompared the request with canonical App Store casing using strict equality. Replay writes updated only the JSON/version/timestamp, leaving successful results hidden behind stale failure state.Rollout
Migration
010_analysis_claim_tokens.sqladds the claim column and requeues processing rows that predate tokens. This requires a coordinated deployment: stop every queue processor, deploy the website and run the migration, deploy the matchinganalyser/processQueue.shto every worker, then restart the workers. The queue body remains backward-compatible, but old analyser completions without the new header are deliberately rejected. Interrupted work is safely requeued by the migration.Integration note
Draft PR #14 also changes
routes/index.js. Rebase this branch after #14 lands, or resolve that route overlap explicitly if this PR merges first.Validation
npm test— 27/27 passing, including live App Store, localhost endpoint, and route-level stale-claim409testsnode --test test/appsState.test.js test/replay-ios-signatures.test.js— 13/13 passingbash -n analyser/processQueue.shnode --checkon changed JavaScript runtime filesgit diff --check