# Preflight

What Spaceboy checks in your code before anything is merged or deployed.
Every `spaceboy push` (and `spaceboy projects adopt`) runs it first.

`push` uploads the last commit only (`git archive HEAD`): tracked, committed
files. Ignored files, `.env` files and git history never leave the machine.
A **block** stops the push and writes nothing. A **warning** stops it until
you acknowledge the report.

## It blocks on

- `kernel-contract.json` missing, invalid, or a different contract version
  from the project's starter: an older tree (run `spaceboy kernel upgrade`,
  see "Upgrading the starter" below), or a newer one that is not the kernel
  the platform serves for the project (the refusal names the condition that
  failed and what to run);
- missing or invalid `repobot.deploy.json`, `repobot.project.json` or
  `env.manifest.json` (unknown capabilities or platforms; a secret-class
  variable exposed as `VITE_*`);
- changes to the starter's pristine design-system files (`web/design-system/`
  and the other folders with a `.pristine-manifest.json`);
- `node_modules`, `.env` files (other than `.example`, `.sample`,
  `.template`, `.defaults`), key files (`*.pem`, `*.key`, `*.p12`, `*.p8`,
  `id_*`, `.netrc`, ...), files over 100 MB, unsafe paths, or symlinks that
  leave the tree;
- high-confidence secrets: private keys, cloud and SaaS tokens, live Stripe
  keys, OpenAI and Anthropic keys;
- a project starter baseline that is gone from the project's repository and
  cannot be rebuilt (`kernel.starter_baseline_missing`; see "If the starter
  branch is lost" below).

## It warns on

Generic API-key patterns, test Stripe keys, committed binaries, files over
50 MB, case collisions, dangling symlinks, unknown `authMethods`, and
environment variable names that cannot be set as secrets (such as
`GOOGLE_*`). Files identical to the project's starter never need
acknowledging: their warnings are reported as information only.

It also warns (`kernel.trusted_file_changed`) when a push changes one of the
kernel files that has a credential or a gate behind it and that the
platform does not check:

| File | Why it matters |
|---|---|
| every file under `.github/workflows/` (new files too) | GitHub Actions runs them with your repository's secrets: the Apple key and Android keystore during mobile builds, your cloud deploy role; `ci.yml` gates production |
| every file under `.github/actions/` | workflows run them with the same secrets |
| `.gitleaks.toml` | its allowlist silences the secret scan |
| `kernel-contract.json` (its `capabilities` only) | what the platform grants |

Deleting a workflow that is on your `main` but that the starter never had
(one you added and accepted earlier) is not asked about: it returns the tree
to the starter's own files, so nothing new is trusted. Deleting a workflow
the starter carries is asked, once, unless `main` already lacks it.

The warning names the file and the change (`modified`, `added`, `deleted`,
`capabilities changed`; a rename is the old path deleted and the new one
added). Directory names are matched in any letter case. It is asked once
per change: it compares with what is already on the project's `main`, so
the next push that keeps the same file is not asked again. All such files
in one push are covered by one acknowledgement. If `main` cannot be read,
every change from the starter is asked about.

Changes to routine product files (`package.json`, `env.manifest.json`,
`repobot.deploy.json`, `repobot.emails.json`) are listed as information
and never need acknowledging.

The acknowledgement digest covers the archive and the findings that need
acknowledging (warnings and blocks), not information notes, so a one-time
note does not change it between two runs of the same push.

The generic API-key check skips documented example values:

- a value that is wholly a placeholder (up to 40 characters, not random):
  `your_api_key_here`, `xxxx` or `xxxx-xxxx`, `sk_test_...`, one repeated
  character (`00000000`), or exactly `example`, `sample`, `placeholder`,
  `dummy`, `changeme` or `REDACTED`. A placeholder word inside a longer,
  random-looking value does not count;
- under an `Idempotency-Key` header or an `idempotencyKey` /
  `idempotency_key` key: exactly a UUID, or a short readable slug of words
  and plain numbers (`order-20261127-retry`). Provider prefixes (`whsec_`,
  `re_`, `sk_`, `pk_live_`, ...) and random strings are still flagged.

Provider keys (`AKIA...`, `ghp_...`, `sk_live_...` and the rest) and private
keys are still caught everywhere, including in Markdown and next to an
`Idempotency-Key`. A random-looking value assigned to a name like `API_KEY`,
`secret`, `password` or `token` is still a warning.

For each possible secret, `push` lists the file and line with the value
redacted (nothing of a value under 20 characters, only its length range;
at most the first 4 and last 2 characters of a longer one), up to 20 lines:

```text
Possible secrets (value redacted):
  docs/setup.md:12  secret.generic-api-key  Zq8v…J6 (24 chars)
```

```bash
spaceboy push                          # exit 1; error.action holds the next command
spaceboy push --acknowledge 3f9c...    # accept this exact report and continue
```

The digest names one report: if the code changes, the report and its
digest change too.

## It notes

Information that never stops a push. `push` lists one note in full: a
project whose `repobot.deploy.json` declares `PAYMENTS` needs a Stripe
secret key before it can deploy to production (development deploys
simulate checkout). Check with `spaceboy integrations stripe status`;
connect with `spaceboy integrations stripe connect`. The other notes are
counted; `spaceboy projects adoption show <id>` lists them.

`push` also lists `kernel.contract_behind_current` in full: your tree is on
this project's kernel contract, but a project created today (a separate
production project, say) starts on a newer one and would refuse it. Nothing
is blocked and this project's own environments are unaffected; it is the
early warning, so the upgrade happens when it is small, not at the
production door. `spaceboy kernel status` and `spaceboy projects show`
print the same comparison (`contract: project v11, a new project requires
v13 (behind)`).

`kernel.starter_baseline_moved` is listed in full too: this push is an
upgraded tree, and accepting it moves the project's starter (see below).
After the merge `push` prints what moved: `Starter baseline moved v11 → v13
(kernel rt-… → rt-…)` across contracts, or, for a kernel fix that kept the
contract, `Starter kernel moved rt-aafff779… → rt-8bcf4e94… (contract v13)`.
When the baseline did **not** move (`kernel.starter_baseline_not_moved`) or a
lost one was rebuilt (`kernel.starter_baseline_restored`), `push` prints that
notice under "Attention:" with its next step, and its summary line does not
say nothing needs action.

## Upgrading the starter

Your code is built on the project's starter (the "kernel"), whose version is
`version` in `kernel-contract.json`. Upgrade it in place, in the project you
already have:

```bash
spaceboy kernel upgrade --plan      # every file, nothing changed (--dry-run is the same)
spaceboy kernel upgrade             # merge it on a new branch spaceboy/starter-upgrade-...
# resolve, commit, merge the branch, then:
spaceboy push                       # "Starter baseline moved v11 → v13"
```

`kernel upgrade` merges the starter the platform serves for your project
now (what a project created today starts from). The platform prepares it in
your project's repository, on the branch
`spaceboy/starter/v<N>-<stamp12>-<tree12>` (contract, the first 12 hex
characters of the kernel stamp without its `rt-` prefix, and the tree id),
as one commit whose tree is exactly the published starter. A push
of an upgraded tree writes the same branch during its preflight, before you
confirm anything. The platform only ever creates these branches: it never
moves or rewrites one, and a branch of that name holding another tree is
refused, not used. Do not delete them; the one your project's baseline is
on is what every later push is compared with. `push` also names these
commands when it refuses an older tree (`kernel.contract_version_unsupported`).

`--plan` lists each file the starter changed: applies on its own (you never
touched it), merges cleanly (you and the kernel both edited it; git
combines them), conflicts (you resolve it), or already current, with the
contract bump (`v11 -> v13`). It ends with extension-point feedback: starter
files you edit that the kernel keeps changing. Each costs a merge on every
upgrade; the list is for the kernel maintainers (a hook, a config entry or a
seed file there removes the merge), not a task for you. `--json` carries the
same as `files`, `contract` and `extensionPointCandidates`.

### How the project's starter moves

Each project has one **starter baseline**: the unmodified starter every
push is compared against. A push on the baseline's contract is checked as
always. An older tree is refused. A newer tree is accepted, and its
acceptance moves the baseline to the new starter, when all of these hold:

1. its contract version is the version of the kernel the platform serves
   for the project now (there is no window of older or other kernels);
2. its `.repobot-template-ref` names that kernel, and its
   `kernel-contract.json` and every `.pristine-manifest.json` are that
   kernel's, byte for byte. `kernel upgrade` writes all of them; edit the
   files a manifest lists, never the manifest. Your edits to kernel files
   are reported as project edits, exactly as on any push;
3. it moves forward: an older contract is never accepted.

A tree on the same contract that names a newer publish of it (a kernel fix
that kept the contract) moves the baseline the same way. If it cannot be
verified it is checked against the current baseline, as before, with a
note saying why it did not move.

The baseline moves only when the push is accepted: a refused, cancelled,
rejected or failed push leaves it where it was. Each move is kept:
`spaceboy kernel status` and `spaceboy projects show` print the baseline and
its last move (`starter: v13, moved from v11 on 2026-12-02`; for a move
within one contract the kernel stamps say what moved:
`starter: v13, kernel rt-8bcf4e94… (from rt-aafff779… on 2026-12-03)`);
`--json` carries every move as `starterMoves`, with `fromTemplateRef` and
`toTemplateRef`.

### If the starter branch is lost

If the commit your baseline records is gone (its `spaceboy/starter/` branch
was deleted and GitHub collected the commit), the next push says so:

- when the platform still serves that exact starter tree, it rebuilds the
  commit (same id, since it depends only on the tree) and the push carries
  on with a note (`kernel.starter_baseline_restored`);
- otherwise the push is refused with one finding,
  `kernel.starter_baseline_missing`, naming the lost commit. Run
  `spaceboy kernel upgrade`, commit and push: a tree on the kernel the
  platform serves now is checked against that starter, and accepting it
  re-establishes the baseline there.

Development and production environments of a project deploy the same
repository, so an upgrade pushed and accepted once reaches production with
its next deploy; nothing else is needed. A separate project created on the
newer starter accepts the upgraded tree as it is.

The kernel's `minCompatibleVersion` is the floor for serving prebuilt
bundles, not for adopting source, so it never widens what is accepted.

`kernel upgrade` makes a normal three-way merge on a new branch: your `HEAD` is one side, the new
starter the other, and the base is the starter you began from. The base is
used only when it can be verified: the commit `spaceboy init` made in an
empty folder, or the starter commit of a previous upgrade, records its own
tree, and must still be exactly that tree. Land an upgrade branch with a
merge commit, not a squash or rebase, or the next upgrade cannot verify its
base. Without a verifiable base (checkouts from CLI 0.6.0 or earlier),
pass `--base <commit>`, a commit holding only the downloaded starter; then
every file the merge would delete has to be allowed by name
(`--allow-delete <path>`).

It never runs with uncommitted changes to tracked files, never forces,
runs no git hooks, never overwrites an untracked or ignored file, and never
writes inside a nested repository or submodule (an untracked nested
repository is left alone). `--dry-run` changes nothing, `.git` included.
Conflicts are listed file by file with what to do (stamps and pristine
design-system files: take the starter's; manifests: keep both). Resolve,
`git add`, `git commit --no-edit`, run the project's checks it prints,
merge the branch, and push.

## Limits

Archives are capped at 1 GiB compressed, 2 GiB uncompressed and 60,000
entries.

## After it passes

Each push becomes one commit on a branch `adopt/<id>` with a pull request
against `main`. The project's CI runs on it, and `push` merges it (rebase),
then deploys. Your local history is not imported.
