glue: salvage path — push branch + warning PR when the build agent crashes after writing files #4
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
serious-devs/ai-factory#4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #1 (finding 3). In the three failed builds of test_factory_ai#3 (runs 895 / 898 / 901), the files were fully written before the crash — but the outer
catchinglue/src/main.tsonly posts⚠️ Agent run failed: …and setsprocess.exitCode = 1. The ephemeral workspace was destroyed with nothing pushed and the human gate never saw usable output.Proposed change
In
main.ts, build phase only: whenrunAgent()throws (non-zero status OR a signal —glue/src/opencode.tsreportsopencode exited with status ${r.status}, wherenullmeans killed), attempt a salvage once:commitAndPush()the happy path uses (branchagent/issue-${cfg.issue}, force-push).forgejo.createPull()with a warning title, e.g.agent: ⚠️ unverified — agent crashed (issue #N), and a body that states the agent crashed before finishing verification, quotes the error message, includes the spec (same structure as the happy path) — and does NOT containCloses #N;commitAndPushreturnspushed: false): keep today's behavior (failure note only, no PR).Required details:
commitAndPush()inglue/src/git.tshardcodesCloses #${issue}in the commit message. Parameterize it (e.g. addclosesIssue?: boolean, defaulttrue) so a salvage commit does NOT auto-close the issue when the warning PR gets merged.Closes #N(the happy path adds it today inmain.ts).cfg.dryRun) must log what would be salvaged instead of pushing or posting.⚠️ Agent run failedmessage with crash context; do not swallow the error.Acceptance criteria
npm start &pattern → opencode still fails, BUT branchagent/issue-Nis pushed and a PR with the ⚠️ warning prefix is opened; its body contains noCloses #N; merging it does NOT close the issueCloses #Npresent in body and commit message) — no regressionnpm run checkgreen; new logic covered by smoke.ts tests where testable (e.g. the salvage decision given a git status)