Repository navigation
fix(publish): a run that did not finish opens no pull request (AGT-4786) - #844
Merged
Merged
Conversation
AGT-4664 published failed, rejected, infra_error and rate_limited runs as drafts. On 2026-10-20 that made 25 PRs in one night, 19 "published because this run ended as infra_error", each titled with the whole issue plus Closes. publishFinishedRun now takes only the reviewed and operator-park paths; publishUnfinishedWork and shouldPublishUnfinishedWork are removed. The work is kept by preserveWorktree's WIP commit on the swarm branch. Pushing that branch to the remote is left for a follow-up: the secret-leak guard that must precede a push lives inside commitAndCreatePRWithHead.
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.
Why
AGT-4664 published failed, rejected,
infra_errorandrate_limitedruns as drafts so their work was visible. On 2026-10-20 that produced 25 PRs on cgf-portal in one night (AGT-4786): 19 said "published because this run ended asinfra_error", several were +3/-0 against multi-defect issues, every one was titled with the whole issue and closed it withCloses, and the owner closed all 25 unmerged. An infrastructure failure is not a deliverable.Cycle 3 of the factory-stability loop; check C5.
What changes
publishFinishedRuntakes only the reviewed path and the operator-park path.publishUnfinishedWorkandshouldPublishUnfinishedWorkare removed (a constant-false function would only leave a switch someone can flip back on).opts.lifecycleFailed/opts.failureSummaryare no longer read. The signature is kept because the caller sits atrunnerExecution.ts's 1500-line cap; the docblock says so.Why this does not lose work
I checked this before removing anything, because the old docblock says PR creation is what cleaned the tree:
preserveWorktreealready WIP-commits dirty work onto the swarm branch and keeps the directory (INT-2729), andcreateWorktreereuses that branch (worktreeManager.ts:143,:571). Observed this morning: three preservedswarm/AX-*branches withwip: preserved partial workcommits.Worker actions — Haltedcomments seen on AX-2144), not by this function.What this does NOT do (stated up front)
The agreed behaviour was push the branch + one comment, no PR. The remote push is not done here. The secret-leak guard that must precede any push (
assertNoSensitiveDataOnBranch, AGT-4188) lives insidecommitAndCreatePRWithHead(worktreeManager.ts: 1484 of 1500 lines, five callers destructureprUrl). Pushing through a second code path would bypass that guard; reusing it needs an extraction, which is its own change. Until then a failed run's work stays on a local branch.Verified
shouldPublishUnfinishedWork/publishUnfinishedWorkblocks, the draft-body test, and the failed-run publication test, nowit.eachover all four statuses asserting no PR and an untouched result). The tests for approved, scope-mismatch park, worker_no_changes park, lifecycle failure and non-publishing statuses are unmodified.publishOnPark.test.ts: 46 pass.infra_erroronly → 3 fail;commitAndCreatePRWithHeadnever called) rather than a helper a refactor could rename. Onorigin/mainwithout this change: 4 fail (the unfinished cases) / 2 pass (approved and operator-park controls); with it: 6/6. An earlier version of that check crashed on avi.mockhoisting error; I caught it because a check that errors cannot be told apart from one that fails, and fixed it before relying on it.src/automation+worktreeManager: 1272 pass. One timing flake,worktreeManager.baseFreshness.test.ts › does not promote an existing draft PR…, hit the 30 s limit once under parallel load; it never references this code and passes alone in 6.4–9.7 s on 3 of 3 runs.