fix(api): a submitted run is readable before it ends - #39
Merged
Merged
Conversation
`POST /v1/runs` registered nothing until the loop returned, so the run id
it handed back resolved to 404 for the whole run. The documented
submit-then-poll flow could not poll, and `POST /v1/runs/{id}/kill` (P75)
had no run to signal — a kill on a live run answered "run not found".
Three writes now make a run visible: the endpoint registers it before any
exit path, the runner publishes a partial at every step boundary
(`LoopRunner.WithProgress`), and the terminal result lands last. All three
go through `storeRunIfPresent`, which refuses to create a row — `DELETE`
removes the key and the loop's own final write used to re-insert it, so a
run an operator removed came back.
Found while fixing the first: a blocked goal's 201 pointed at a run that
was never stored, so the goal-screen verdict was unreadable too.
Both directions are checked by removing the registration line and watching
`TestRunVisibleWhileInFlight` and `TestGuardrailScreenFiresInProduction`
fail.
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.
POST /v1/runsregistered nothing until the loop returned, so the run id it handed back resolved to404for the whole run. The documented submit-then-poll flow could not poll, andPOST /v1/runs/{id}/kill(P75, NFR-1) had no run to signal — killing a live run answeredrun not found.What changed
submitRunregisters the run before any exit path, so every exit writes its outcome throughstoreRunIfPresentinstead of depending on a row that was never created.LoopRunner.WithProgresspublishes a partial result at every step boundary (and once before the first step, and once after the loop), so a poll sees the steps that have run rather than nothing.storeRunIfPresent, which refuses to create a row.DELETEremoved the key and the loop's own final write re-inserted it, so a run an operator removed came back.The bug found while fixing the bug
A blocked goal's
201pointed at a run that was never stored at all — the goal-screen verdict was unreadable too, so the P1 guardrail path was invisible from the API.TestGuardrailScreenFiresInProductioncaught it oncestoreRunIfPresentstopped creating rows.Verification
go test ./... -count=1green,gofmtclean,golangci-lint0 issues,docs/check-prd.pyOK. Both directions checked by deleting the registration line and watchingTestRunVisibleWhileInFlightandTestGuardrailScreenFiresInProductionfail.docs/PRD.mdfooter stamp updated in the same commit.