A run never moves its branch off the head the forge's branch holds, and a run whose push fails keeps its head on the forge #170
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/3852-a-run-that-rewrites-a-commit-the-runner"
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?
Tracker: #3852
A run that amended, rebased or reset a commit the runner had already pushed ended
failedpush_failedat its end, and its finished work stayed only in the run's work tree (Implementer run 1113 of SX #3848). This PR:reference-transactionhook into the hooks directory of the run's home, besidecommit-msg. It refuses to move the run's branch to a commit that does not hold the head named inhooks/pushed: the remote's head of the branch as the runner knows it, from the checkout's start when the remote has the branch, then each head the runner pushes (named before the push, named back when the push fails).git commit --amend,git rebaseorgit resetoff a pushed commit fails at once, and the hook's message tells the agent to add a commit instead. The harness's git takesgc.packRefs=false: packing refs prunes each loose ref in a transaction of its own, which the hook reads as a move of the branch to the zero id, sogit gcwould otherwise exit 128. An explicitgit pack-refsis still refused.## Pushed commitspart in sak's instructions: the runner pushes the branch when it opens the PR and when the run ends, a commit it pushed is never rewritten, and the run's git refuses to move the branch off the forge's head.refs/sak/run-<id>on the forge and reports it askept_headonPOST /api/runs/:id/complete. sak stores it (migration 50 addskept_head,resume_refandresume_headtorun_request), shows it on the run and on itsendedhistory event. The runner keeps the head whatever reason the run ends with (a run killedidle_timeoutwhose end push fails keeps it too), and a run queued again after a run that kept a head carriesresume_refandresume_head, whatever that run's reason; a request queued again for its account's limit resumes the head it kept from its own ref. A run that pushed its branch and kept no head leaves no head to resume, so the run after it starts from the forge's branch; one that pushed nothing and kept nothing leaves the head it resumed. The resumed run's runner fetches the kept head and starts the branch from it (a kept head the remote lacks ends the runresume_missing), and its prompt's## The run beforesays so. When the forge's branch moved past the kept head, the hook makes the resumed run merge it before it commits, so its push is a fast-forward.docs/api.md and runner/README.md describe the hook, the
## Pushed commitspart,kept_head,resume_ref/resume_headandresume_missing. The web'sRunRequesttype carries the three new fields, with what they hold; nothing renders them, so no golden moves.Regression
tests/runner_core.sxcheck_kept_headwalks the repro on a flow run against the stub forge. Its first step runs the stub harness's newdivergemode: it commits, says something until the runner pushes the commit as it opens the PR, then runsgit gcandgit commit --amend. It then moves the forge's branch past the pushed head, as a push from elsewhere would, commits again and concludes. The checks:## Pushed commits;git gcwith the branch guarded;failedpush_failed, itskept_headis its head, and the forge holds it asrefs/sak/run-<id>;resume_ref/resume_head, and its prompt names them;done, and the forge's branch holds its work and the kept head;failedidle_timeoutwith a kept head is queued again on that head, and its prompt names it;account_limitedwith a kept head is queued again to resume that head fromrefs/sak/run-<its id>;failedidle_timeoutis queued again on that head when it pushed nothing and kept nothing, and on the forge's branch when it pushed its branch and kept no head.Fail-before, from
git archivearms with one part of the fix taken out, each runningtests/runner_core.sxon m5 with the gates' sx 49e83601. First, arms ofab88fd1e:ab88fd1eas is:RUNNER CORE OK, 488 ok.write_hookswrites onlycommit-msg):RUNNER CORE FAIL (5 checks). Failing: "its git refuses to amend the commit the runner pushed as it opened the PR", "its branch starts at the kept head, and its git refuses a commit until the branch holds the forge's head", and the three exact listings of a run's home, which now holdhooks/reference-transaction.finishdoes not callkeepafterpush_failed):RUNNER CORE FAIL (4 checks). Failing: "a run whose push the forge refuses ends failed push_failed, its head kept on the forge under its own ref", "the run queued again resumes the kept head, and its prompt says so", "its branch starts at the kept head, …", "once it merges the forge's branch its work is pushed, the kept head with it".Then, for the review's two findings, arms of
9aecb4e5:9aecb4e5as is:RUNNER CORE OK, 491 ok.RUNNER CORE FAIL (6 checks). Failing: "its git collects garbage with the branch guarded", "a run ended failed idle_timeout with a kept head is queued again on that head, and its prompt says so", "a run whose account reached its limit with a kept head is queued again to resume that head from its own ref", and the three checks of a run's exact environment, one per harness, which now holdsgc.packRefs=false.push_failed(run_beforeas atab88fd1e):RUNNER CORE FAIL (1 checks), the idle_timeout check.RUNNER CORE FAIL (1 checks), the account_limited check.gc.packRefs=false(git_envas atab88fd1e):RUNNER CORE FAIL (4 checks), the gc check and the three environment checks.Then, for the second review's finding (a run's resume outliving a run that pushed its work), arms of 4aaa319e's tests, run side by side on m5:
4aaa319eas is:RUNNER CORE OK, 495 ok.RUNNER CORE FAIL (2 checks). Failing: "its next run, limited once it pushed its branch and kept no head, leaves it to resume none" and "one ended failed idle_timeout once it pushed its branch and kept no head is queued again on the forge's branch".queue_againcopies the resume as at9aecb4e5):RUNNER CORE FAIL (1 checks), the idle_timeout one.queue_againfixed (the limited UPDATE as at9aecb4e5):RUNNER CORE FAIL (1 checks), the account-limited one.RUNNER CORE FAIL (2 checks), the two whose run pushed nothing and kept nothing.The
## Pushed commitscheck fails on master, which composes no such part.Migration 50's undo is added to the three tests that take a migrated database back by hand (
tests/tools.sxto 40,tests/utf8_text.sxto 44,tests/flows.sxto 48), and the schema-head asserts move to 50.Gates
At the gates' sx pin 49e83601:
full#1, gate run 608, at4aaa319e(this head, clean tree), on m5: passed. Everytests/*.sxfile,scripts/release.shandstep9_release, the deploy contract, the main Playwright config (771 passed, 1 skipped) and the runner config (10 passed).full#1, gate run 602, at9aecb4e5, on m5: passed.full#3, gate run 597, atab88fd1e, on m5: passed.fast#1, gate run 593, andfull#2, gate run 594, at0ffdfffe: passed.ab88fd1echanges onlytests/runner_core.sxand the stream-json stub harness script, written while #2's tests loop ran.A run never rewrites a commit the runner pushed, and a run whose push fails keeps its head on the forgeto A run never moves its branch off the head the forge's branch holds, and a run whose push fails keeps its head on the forge