Skip to content

fix(publish): a run that did not finish opens no pull request (AGT-4786) - #844

Merged
unohee merged 1 commit into
mainfrom
fix/agt-4786-failure-no-pr
Oct 21, 2026
Merged

unohee merged 1 commit into
mainfrom
fix/agt-4786-failure-no-pr

Conversation

@unohee

@unohee unohee commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Why

AGT-4664 published failed, rejected, infra_error and rate_limited runs 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 as infra_error", several were +3/-0 against multi-defect issues, every one was titled with the whole issue and closed it with Closes, 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

  • publishFinishedRun takes only the reviewed path and the operator-park path. publishUnfinishedWork and shouldPublishUnfinishedWork are removed (a constant-false function would only leave a switch someone can flip back on).
  • opts.lifecycleFailed / opts.failureSummary are no longer read. The signature is kept because the caller sits at runnerExecution.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:

  • preserveWorktree already WIP-commits dirty work onto the swarm branch and keeps the directory (INT-2729), and createWorktree reuses that branch (worktreeManager.ts:143, :571). Observed this morning: three preserved swarm/AX-* branches with wip: preserved partial work commits.
  • The failure itself is commented on the issue by the worker audit path (the Worker actions — Halted comments 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 inside commitAndCreatePRWithHead (worktreeManager.ts: 1484 of 1500 lines, five callers destructure prUrl). 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

  • Existing tests changed: only those that asserted "an unfinished run opens a draft" (the shouldPublishUnfinishedWork / publishUnfinishedWork blocks, the draft-body test, and the failed-run publication test, now it.each over 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.
  • Mutations, each reverted:
    • restore the draft for all four statuses → 9 fail;
    • restore it for infra_error only → 3 fail;
    • break the approved publish → 3 fail (control: this path is untouched by the change).
  • Harness C5: observes the real consequence (commitAndCreatePRWithHead never called) rather than a helper a refactor could rename. On origin/main without 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 a vi.mock hoisting 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.
  • typecheck, lint (12 warnings = baseline).

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.
@unohee
unohee merged commit 8d96d6e into main Oct 21, 2026
7 checks passed
@unohee
unohee deleted the fix/agt-4786-failure-no-pr branch October 21, 2026 16:59
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.

1 participant