Keep as PR
A run leaves its changes in your working tree as ordinary uncommitted changes. Keep as PR turns a passing run’s changes into a commit on a new branch, and, if you ask, pushes that branch and opens a pull request. It never changes your current branch, your index or your working tree.
Three ways to ask for it:
axocoatl run <loadout> … --keep branchor--keep pr; it acts only when the run passes, and prints the branch, the commit and the pull request URL;- Keep as PR in the Session’s Run outcome panel;
POST /api/sessions/{id}/keep-prwith{"run_id": "run-…", "open_pr": true}.
When it is allowed
Section titled “When it is allowed”- The run is finished and its verdict is
pass. Otherwise Keep is refused (409) with the reason. - None of the run’s changed paths had uncommitted changes before the run began. The run’s manifest lists those paths; when one of them is among the run’s changes, Keep is refused rather than mixing your edits into the commit.
- When the run has a signed receipt, each path Keep is about to commit has the content the receipt covers (its SHA-256 in the working tree is the receipt’s), and each path the run removed is still absent. A path edited after the checks judged it is refused, naming it: “changed after the run’s checks judged it; Keep commits only what the receipt covers”. A receipt that cannot be read, or that is another run’s, is refused too. A run without a receipt (one from before Axocoatl signed receipts, or whose signing failed) is kept as before, and Keep says the commit and pull request carry none.
- None of the run’s changed paths changed in your working tree after the run ended, by the file’s status-change time. The checks and the review judged the files as the run left them, so a later edit is refused rather than committed under their results.
HEADis still the commit the run started from, and Git’s settings did not change after the run started.- The run’s changes can be attributed exactly, no turn of the Session outside the run changed the same paths, and the run did not change Git’s own files.
- The branch does not exist yet, and it is not the branch checked out. The default name
is
axocoatl/<loadout>-<run id prefix>. A branch an earlier Keep of the same run created at the same commit is the exception: keeping again continues from it, for example to open the pull request afterwards, and creates nothing new.
The run’s changed paths are the Session’s changes attributed to the run’s turns, the same
attribution as Last turn. Other changes in your working tree are not
committed; the response lists them as not_committed and says so in its warnings.
The commit
Section titled “The commit”Axocoatl uses the host’s git with a temporary index, so nothing you have open changes:
- a temporary
GIT_INDEX_FILEis filled fromHEAD; - exactly the run’s paths are added or removed in it from the working tree;
git write-treeandgit commit-tree -p HEADmake the commit, with the title and the run id in its message, and the trailersAxocoatl-Run: <run id>and, when the run has a receipt,Axocoatl-Receipt: sha256:<SHA-256 of the receipt's signed statement>;git update-refcreates the branch at that commit only if no branch of that name exists yet.
HEAD, the real index, the current branch and the working tree are the same afterwards.
The changes stay in your working tree too; switch to the branch, or discard them, when
you choose.
The pull request
Section titled “The pull request”Opening a pull request works with GitHub only: Keep pushes with your git and opens the
pull request with gh, GitHub’s command-line tool, which must be signed in to the
remote’s host. Only github.com has been tried. For a repository on GitLab, Bitbucket or
another host, use --keep branch (or Keep as PR without Open a PR), then push the
branch and open the merge request yourself. The commit and its trailers are the same,
but Keep writes no description and so no receipt block: verify the receipt that
--receipt wrote (or that Download receipt saves in the workbench) with
axocoatl receipt verify. The commit’s Axocoatl-Receipt trailer holds the SHA-256 of
that receipt’s signed statement.
With --keep pr, Open a PR, or "open_pr": true:
- Keep refuses a branch name equal to the remote’s default branch;
- it pushes with
git push <remote> <branch>:refs/heads/<branch>, never with--force, and refuses when that remote branch already exists, unless an earlier Keep of the same run pushed it; the remote defaults toorigin; - it opens the pull request with
gh pr create --head <branch> --base <default branch>, with the title and a body file.
The body holds the run’s verdict; a Receipt section with the key that signed the
run’s receipt, its verdict, checks, review, writer and the files it covers, and how to
verify it (or why the run has none); a table of check results, the review verdict and
rounds, a table of adjudications, the findings, everything not covered, the warnings,
and the run id with the command to verify its
record bundle. The body ends with the receipt itself, the
DSSE envelope as base64 inside an <!-- axocoatl-receipt:v1 … --> comment, which GitHub
does not display. The body is cut to fit a pull request description; the cut never
reaches the receipt block. A receipt block longer than 40,000 characters (the receipt
lists every file the run changed, so a run that changes many files can pass it) is left
out, and the body says so. Verify that receipt from the file --receipt wrote or from
the run’s record bundle; the verify-receipt Action
finds none in the description, which fails it unless require-receipt is false.
axocoatl receipt verify reads a saved description directly:
gh pr view 7 --json body --jq .body > body.mdaxocoatl receipt verify body.md --key "$(axocoatl receipt key)" --repo .On another computer, give the signer’s key line instead, or a file of trusted key lines
with --keys (see Verifying a receipt).
git and gh run on your computer with your own credentials and configuration. Nothing
runs in a container for this, and Axocoatl reads no credential. Your global and system git
settings apply, and so does the configuration your git installation carries beside them,
such as Apple’s /Library/Developer/CommandLineTools/usr/share/git-core/gitconfig, which
sets the osxkeychain credential helper; the repository’s own settings never do. The daemon finds them on
its own PATH: a service installed with axocoatl service install records the
directories of the git and gh your shell found at install time, and a refusal names
the PATH it searched.
What is recorded
Section titled “What is recorded”Keep is recorded as a keep phase in the run’s events, and its branch, commit, pull
request URL or error appear as keep in the run’s status. Keep’s response names the
receipt the commit carries (receipt), and axocoatl run --keep prints it. The Outcome itself is written
once, when the run ends, and does not change.
A failed Keep after a passing run makes axocoatl run print the reason and exit with
code 2.