Landing and syncing work

How approved work reaches main; land commits the sealed handoff, merge conflicts and partial lands, then sync pushes or opens a PR, runs checks, and restarts smith only on its own source.

Approved work reaches main in two steps. A run lands its sealed handoff as commits in the work clone. A later sync carries those commits from the work clone to the project's checkout and origin. File:line citations are in parentheses; "not checked" means the code was not read for that fact.

01the handoff#

workspace_handoff seals what the work node left. It finds the work node's released workspace, runs any configured format commands on the changed files, then creates an immutable handoff with the tests, evidence and doubts from the baton. A node without a released owner fails. A snapshot target's run folder also gets its diff against the frozen version for the reviewer. Config keys are on nodes.

02land#

workspace_land commits the approved handoff in its workspace.

03git tools#

git_state, git_log and git_diff read the two repos of a project, the work clone runs build in and the checkout it was cloned from. They never write a branch, the index or a file; finding the workspace only refreshes its remote-tracking refs, as a launch card does.

04propose_sync and the sync#

propose_sync drafts a card that brings the checkout's branch up to date with the work clone: a fast-forward to the clone's head, or the commits you name cherry-picked onto it. It reads both repos and changes nothing.

the click

Nothing starts until the operator presses the card. The click runs these steps in the background, and the first failure stops it:

  1. Preflight: the project's checks and clone are still the card's, and both repos are where the card saw them.
  2. A worktree of its own at the checkout's commit, in the checkout's .git, so uncommitted work in the checkout is neither blocked nor touched. Only commits ship.
  3. Apply: fetch the commits, then fast-forward or cherry-pick. A failed cherry-pick is aborted and nothing changes.
  4. Checks, on exactly what will be pushed. A failing check stops the sync, nothing is pushed and the branch is where it was.
  5. Push to origin as a plain push, which origin refuses unless it is a fast-forward. The checkout then follows only when that can't touch anyone's work: it is left behind, with a note, if it moved, has uncommitted changes, or won't fast-forward.
  6. Line the work clone up with what was pushed, unless a run is using it or it has changes.
  7. Rebuild and restart, only when the checkout is smith's own source (see below).

A project with no origin remote skips the push: the checkout's branch moves locally and the card says "no remote: main moved locally, nothing pushed".

the lock

One sync runs per project at a time. Projects that share a checkout share its .git, so one sync runs per checkout, keyed by its git common dir. A second click is refused with "a sync for X is already running". Merges of landed run branches into a clone go one at a time per project.

the check-digest carry

A check that a run of the same project already passed on exactly the inputs the sync's tree has is not re-run: the card says it passed in that run. The service computes the digest the tree would have on each candidate base, and the desk looks for a passed result with the same digest. It tries at most 50 candidate bases (the checkout's head and the first-parent commits above it) against the 40 newest runs of the project; these limits are provisional. A failed, carried or digest-less result never counts. The scoped re-run of a rebased land is not a run check result, so it is never journalled as a check event and the carry compares exactly what it did before.

push mode and pr mode

A project's sync_mode is push or pr, and unset means push. pr needs a gitea https repo_remote.

05propose_accept_pr#

propose_accept_pr drafts an accept card for the project's open sync PR. Only the operator's click merges or closes it.

06restarting smith#

A push-mode sync rebuilds and restarts smith only when the checkout is smith's own source: the running executable is inside the checkout and its go.mod starts with module github.com/boxsie/smith.

07when you're the conductor#