fix(speculate): gate finalize on the batch's own build result#220
Open
albertywu wants to merge 2 commits into
Open
fix(speculate): gate finalize on the batch's own build result#220albertywu wants to merge 2 commits into
albertywu wants to merge 2 commits into
Conversation
tryFinalize only consulted dependency batches, never the batch's own build, so a failed build still merged and the request reached "landed". It now fetches the batch's build first and fails the batch when that build failed, only falling through to dependency evaluation once the own build has succeeded (waiting if it is not yet persisted or still in-flight). Enabling change: add BuildStore.GetByBatchID. Build.ID is the runner-assigned ID (e.g. "fake-build-fail-..."), not batch.ID, so a caller holding only a batch ID could not fetch its build via Get. This also fixes cancelBuild, which called Get(ctx, batch.ID) and was a silent no-op (always ErrNotFound); it now resolves the build by batch ID and updates it by build ID. e2e: drive a request to terminal status — assert the happy path reaches "landed" and a "sq-fake=build-fail" request reaches "error" (the end-to-end regression guard for this fix). Make PersistsStartedLogViaGatewayConsumer deterministic by asserting on the durable, append-only request_log row instead of polling the transient current status via the Status RPC. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
speculate.tryFinalizeonly consulted dependency batches, never the batch's own build. A batch whose build failed still passed finalize and merged, so asq-fake=build-failrequest reachedlandedinstead oferror(verified live:build.status=failed,batch=succeeded,request=landed).Fix
tryFinalizenow fetches the batch's own build first:Speculating → Failed+ publishconclude), via a sharedfailBatchhelper also used by the existing dependency-failure path;Net merge condition is now own build Succeeded AND all deps Succeeded.
Enabling change:
BuildStore.GetByBatchIDBuild.IDis the runner-assigned ID (e.g.fake-build-fail-…), notbatch.ID, so a caller holding only a batch ID could not fetch its build viaGet. AddedGetByBatchID(ctx, batchID) (entity.Build, error)(interface + MySQL implWHERE batch_id = ? LIMIT 1, indexed; regenerated mock).This also repairs
cancelBuild, which calledGet(ctx, batch.ID)and was a silent no-op (alwaysErrNotFound); it now resolves the build by batch ID and updates it by build ID.Tests
✅
make fmt && make build && make test && make e2e-test