Skip to content

Design landing from a branch

Eric Stern edited this page Nov 16, 2026 · 4 revisions

A commit the pinned seed refuses lands from a branch: CI freezes, proves and publishes its seed before main moves

STATUS: APPROVED 2026-11-16 (REV 2 folds in the ruling's amendments A1–A12) REV: 2 BASE: 997636dfb662, tree clean, 2026-11-16

The issue and its ruling: maxon-lang/maxon#80.

1. The problem

Today a commit the pinned seed refuses (E2015, E3004, a new language form, E3092) reaches main only through scripts/pin-seed.sh. That script runs on a machine that can create a GitHub release, push a tag, push main, and reach WSL and the shared Mac to prove lanes. A session that can push only its own branch can do none of this, so it cannot land such a commit at all. The script also freezes the local slot, which was built through intermediate trees that no commit records, so nothing on main can rebuild that seed.

What proves it fixed: a seed-pinning change, pushed to a branch, lands on main with a new seed-* pre-release pinned in scripts/seed-tag, and every step runs in GitHub Actions. The chain that built the seed stays reachable from a published ref. A run that fails or is cancelled leaves none of its objects behind and does not move main.

2a. Source facts

  • scripts/pin-seed.sh (565 lines) does these steps in order: preconditions, freeze-seed.sh, local or WSL/Mac proofs, push the tag, create the release, fetch it back, commit the pin, push main. A retract trap covers failure. About 250 of its lines reach WSL and the shared Mac.
  • scripts/freeze-seed.sh cross-builds all four native targets with the slot compiler and writes the archives, SHA256SUMS and NOTES.md to temp/seed/dist/. It refuses an uncommitted compiler source and a stale slot. The tag is seed-<date>-<first 12 of HEAD>.
  • scripts/lib/seed.sh: the release helpers, all REST through gh api.
  • scripts/fetch-seed.sh TAG LANE --from=DIR installs a frozen seed from local archives, checked against SHA256SUMS.
  • scripts/build-from-seed.sh: .bootstrap/maxon builds C1, then C1 builds C2 into the slot.
  • .github/workflows/ci.yml runs on push: main, pull_request and workflow_dispatch. It reads its lanes from maxon-bin/targets.tsv through scripts/targets/matrix.sh. tests/targets fails any workflow line that spells a target name.
  • Repository rules: main is unprotected. The one ruleset covers refs/tags/v*.
  • A push or release made with GITHUB_TOKEN starts no other workflow. Five workflows run on push: main, and four run on release: published.

2b. Spec-surface facts

No spec or test reads the scripts or the workflow, except that tests/targets checks that no workflow spells a target. The acceptance is runs of the workflow (§6).

3. The approach

The new workflow is .github/workflows/land.yml. Its logic is in scripts/land.sh, one subcommand per job, so the YAML holds no logic. scripts/pin-seed.sh is deleted.

Trigger (A3).

  • Push: a push to any branch other than main. Tags never trigger. The run proceeds only when the head commit carries a Land: git trailer.
    • A cheap first condition skips runs whose message cannot hold the trailer.
    • land.sh plan then parses the trailers exactly. An unknown value, or more than one Land: trailer, is an error.
  • Dispatch: a workflow_dispatch with the inputs branch and mode, where mode is main or rehearsal.
  • Starting a run needs write access either way.

Classification (A2) comes from the pinned seed's verdict on the head tree (build-from-seed.sh) and the number of commits since origin/main:

Commits Seed verdict Result
0 — "nothing to land"
any, not a fast-forward of main — "rebase onto origin/main"
1 accepted ordinary: fast-forward main to the head commit, unchanged
more than 1 accepted error: an ordinary land is one commit
1 refused error: prints the seed's diagnostic and names the fix (commit the intermediate tree before it)
more than 1 refused chain

The chain (A1).

  • The pinned seed builds the first commit. Each later commit is built by its predecessor's compiler, using build-from-seed.sh's two stages. A failed step names the commit.
  • The landed commit S has the head's tree and origin/main as its parent. Its message is the head's message, without the Land: trailer, plus one Bootstrap-Chain: <sha> trailer per chain commit, in order. It keeps the head's author and author date.
  • The committer is github-actions[bot], with the time the plan job recorded. Every job therefore recomputes the same S, and the pin commit P, from the plan's outputs and checks the sha, with no bundles passed between jobs.
  • The seed's NOTES.md lists the chain.
  • The never-moved ref refs/tags/<seed-tag>-chain, on the head commit, is published with the seed and retracted with it.
  • The intermediate commits never reach main, and main stays linear.
  • docs/RELEASING.md says how to rebuild: fetch the chain ref, then run scripts/land.sh chain <S>^ <seed-tag>-chain, the same walk the workflow runs, with the parent's pinned seed.

Jobs.

Job Runs on Permissions
plan ubuntu-latest contents: read, no secret
credential — only main mode
chain ubuntu-latest chain only, contents: read
prove native matrix from matrix.sh chain only, contents: read
publish — chain only, contents: write, GITHUB_TOKEN
land — main mode only
retract — chain only, contents: write
  1. plan. Mode and trailer, fast-forward check, commit count, the seed's verdict, classification. Records the tag seed-<UTC date>-<first 12 of S> and the committer time, and refuses a tag or release that already exists.
  2. credential. Mints the GitHub App token, requesting contents: write and workflows: write, and drops it. A missing or under-permissioned App fails here, before anything is published.
  3. chain. Walks the chain, checks out S, runs freeze-seed.sh, appends the chain to NOTES.md, and uploads temp/seed/dist/.
  4. prove. On every lane: fetch-seed.sh <tag> <lane> --from=<dist>, then one self-compile with the frozen seed. "Which lanes to prove" is deleted.
  5. publish.
    • Re-checks that origin/main is still S's parent (A4).
    • Pushes the tag on S and the chain ref on the head commit.
    • Creates the pre-release, which starts none of the release: published workflows.
    • Fetches every target back against SHA256SUMS.
    • Records P's sha.
  6. land. Mints the App token just before the push (A6). Pushes S and P to main, or the ordinary head, in one non-force push. Never runs in rehearsal mode.
  7. retract (A5), if: always(). Runs after a failure, after a cancellation, and always in a rehearsal.
    • It deletes only objects whose names carry this run's S: the release, the seed tag and the chain ref, each checked against S or the head commit before it goes.
    • It retracts nothing when main holds P.
    • It retracts nothing, and fails, when main cannot be read.
    • It is idempotent, so re-running the job is safe.

Concurrency (A4).

  • Every land run shares one land-main group, with no cancellation. A run skipped for having no trailer joins a group of its own, so it never displaces a pending land.
  • A run replaced while pending is reported as "not landed, push again".
  • The workflow never rebases.

Credentials (A6).

  • GITHUB_TOKEN creates the tag, the chain ref and the release.
  • The push to main uses an installation token of a GitHub App installed on this repository alone, with contents: write and workflows: write. The secrets are LAND_APP_ID and LAND_APP_PRIVATE_KEY, referenced only by the credential and land jobs. Jobs that build branch compilers hold neither.
  • A personal token is ruled out. docs/RELEASING.md's secrets table gains both rows.

Rehearsal (A3, A10). Land: rehearsal as a trailer, or mode=rehearsal on a dispatch, runs everything, publish and fetch-back included. It never mints the token that pushes main, and it always retracts. It is permanent and usable by any pusher.

Local entry point (A7). scripts/land.sh submit [--rehearsal] pushes HEAD to land/<first 12 of HEAD> and dispatches land.yml on it. It follows the run to its end, reports the outcome and deletes that branch. It refuses a HEAD that carries a Land: trailer, because the push alone would also start a run.

/land's push step (A8).

  • An ordinary commit from a session that can push main: git push origin main, unchanged.
  • A seed-refused commit from any session: only through land.yml, either by pushing a chain branch whose head carries Land: main or with land.sh submit.
  • An ordinary commit from a session that can push only its branch: one commit with Land: main.
  • The outcome is read from the head commit's check runs (A9). A chain's S is found by its Bootstrap-Chain: trailer.

Alternatives rejected:

  • An uploaded slot binary: there is no upload path, and it cannot be rebuilt.
  • The chain's commits on main: main would hold commits its own seed refuses.
  • A separate bootstrap ref: a session can push only its own branch.
  • A chain inferred from commit count.
  • Landing on every branch push.
  • A personal token.
  • A rehearsal that can push main.
  • Passing S between jobs as a bundle: a deterministic S needs no artifact.
  • Keeping pin-seed.sh in any form.

4. Blast radius

  • New: .github/workflows/land.yml, scripts/land.sh.
  • Deleted: scripts/pin-seed.sh.
  • Edited: scripts/lib/seed.sh, the headers of scripts/freeze-seed.sh, scripts/fetch-seed.sh and scripts/build-from-seed.sh, and docs/RELEASING.md.
  • Mentions rewritten: /land §8–§9, /plan-and-land Staging, compiler-workflow, the release skill, maxon-bin/AGENTS.md.
  • One implementer.

5. Obligations

  • No compiler, runtime, target or error code changes.
  • The documentation source is docs/RELEASING.md, then node website/scripts/sync-docs.mjs --check.
  • Gates: tests/targets (no workflow spells a target), shellcheck-clean scripts, and check-ignored-files.py.

6. Acceptance, in order (A11)

  1. Rehearsals of every refusal in the classification table.
  2. A toy chain rehearsal: all four proofs green, the pre-release and both refs published, fetched back, and gone at the end. It publishes and deletes one pre-release, so it runs only with a go-ahead.
  3. This change lands itself as an ordinary one-commit land touching a workflow, after the two in-flight pin-seed.sh lands.
  4. The first real chain land.
  5. A moved-main run that fails with nothing published.

7. Staging

ONE /land (A12).

8. Open questions

None. The App and its two secrets are created by the user.

9. Amendments

  • 2026-11-16, REV 2: the ruling's A1–A12 are folded in.
    • The chain ref and the Bootstrap-Chain: trailer.
    • Classification by the seed's verdict.
    • Land: as a trailer, with rehearsal.
    • The re-check before publishing.
    • Retraction on cancellation.
    • The GitHub App credential.
    • pin-seed.sh deleted.
    • /land's push rules.
    • Deterministic S and P replace the bundle artifact.

Amendments A13–A14 (2026-11-16)

The ruling on maxon-lang/maxon#80 adds two amendments:

  • A13: main is re-checked at the start of every job and between chain-walk steps, and the publish check stays authoritative.
  • A14: an in-progress, non-rehearsal chain run of land.yml is the hold. scripts/land.sh reports it, and /land checks it before its rebase and before git push origin main. No stored marker exists.

Clone this wiki locally