oficina / equipo Public

Ops audit: upgrading a running Equipo

I wrote a report (a Markdown file plus a browser preview page) on how each part of Equipo gets upgraded today. The main finding is that production has no upgrade procedure in code. The one production script is a one-time move to a fresh database, so every runner upgrade since then, including the Codex fix, was shell pasted from an agent's report. Most of the systemctl work comes from one design choice: the runner's version is written into its config in two places, so each upgrade means editing two files by hand.

The report also covers:
- **Upgrade order:** the design spec says "instance first", the staging script says "runners first", and nothing in code enforces either.
- **In-flight work:** restarting the Linux runner can cut a merge in the middle. Only the staging script waits for idle first.
- **The fix is mostly already built:** Mac workers already update themselves to the instance's version, and the Linux runner ignores the same signal.
- **Rollback:** the deploy commands people actually ran left out the flag rollback depends on.

The proposal is ranked by effort and payoff. The first slice is a fixed runner path, an `equipo-runner upgrade` command that owns its unit, and one upgrade-with-rollback script, which removes every manual step from the Codex fix. Next, the Linux runner would update itself the way the Mac worker does.

Things to know:
- **Not checked:** some code searches were blocked, so the report says plainly that I couldn't confirm whether the instance can

Equipo task tk7kkem2pi33, Engineering step attempt 1.
Equipo Engineering pushed by equipo-james agent, operated by james@keymail.dev 7a9d762fde4cfdee6c9c7bfb04ce9fc43eb0f396 parent 449e9c1
4 files changed, +419 −0
  • docs/ops-audit/README.md +343 −0
  • docs/ops-audit/index.html +73 −0
  • md2html_tmp.py +2 −0
  • release/preview.json +1 −0

CI cancelled — superseded by a newer push — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/equipo__tk7kkem2pi33-ops-audit-upgrading-a-running-equipo: Type  Size Avail | ext4   96G   86G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   86G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: image pulled in 9.8s
ci-box: claude: fetched and verified in 11.1s
ci-box: codex: fetched and verified in 4.7s
ci-box: codex-code-mode-host: fetched and verified in 1.6s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.4s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: pi: installed and verified in 7.6s

amadan: job cancelled — a newer push superseded it
diff --git a/docs/ops-audit/README.md b/docs/ops-audit/README.md
new file mode 100644
index 00000000..6061e38e
--- /dev/null
+++ b/docs/ops-audit/README.md
@@ -0,0 +1,343 @@
+# Ops audit: upgrading a running Equipo
+
+Date: 2026-11-18. Scope: how a merged change reaches a running system, and
+what a single "upgrade to build X" should look like. This is a read-only
+audit: nothing here changed product code or touched production.
+
+## The short version
+
+- **There is no production upgrade procedure in code.** `scripts/cutover-thin.sh`
+ is a one-time migration to a *fresh database* with re-enrolment. It is not
+ an upgrade. The only scripted rolling upgrade is `scripts/staging-thin.py
+ release`, and it is hard-wired to staging. Every production upgrade since
+ the cutover was a hand-written block of shell and Python in an agent's
+ report (for example `docs/superpowers/plans/CONTROLLER-REPORT-connection-available.md:147-204`,
+ the Codex connection fix).
+- **The runner's version is written into its config in two places.** The
+ systemd unit's `ExecStart` and `EQUIPO_TOOL_PROXY_PATH` in the env file
+ both contain `releases/<version>/`. So every upgrade means editing two
+ files by hand, then running `daemon-reload` and `restart`. That one design
+ choice causes most of the systemctl work.
+- **The Mac worker already upgrades itself**: the instance tells it its
+ target in `welcome.release`, and it downloads, verifies, swaps between
+ steps and exits (`internal/runner/thin/mac.go:872-945`). The Linux primary,
+ which is the machine that matters most, ignores the same field.
+- **The documents disagree on order.** The mac-runners spec says *instance
+ first, then runners* (`docs/superpowers/specs/2026-11-07-equipo-mac-runners.md:329`).
+ `staging-thin.py release` says *runners first, then instance*
+ (`scripts/staging-thin.py:512-547`). The hand procedures did the instance
+ first. Nothing in code enforces either order.
+- **The production safety gate is skipped in practice.** `make staged-check`
+ only runs inside `cutover-thin.sh`. The procedures people actually ran
+ called `carlos deploy` directly, without `--swap hold` or `--version`, and
+ `carlos promote` rollback needs `--version`.
+
+The fix is mostly *subtraction*: one stable path for the runner binary, no
+version in config, and the Linux primary using the self-update the Mac worker
+already has. Section 5 ranks the steps.
+
+---
+
+## 1. Inventory: what is deployed, where, and how it is upgraded today
+
+| Part | Runs on | Built by | Version identity | Upgraded today by |
+|---|---|---|---|---|
+| **Instance** (`cmd/equipo`) | CARLOS, app `equipo`, account `oficina`, linux/arm64. Staging: `equipo-staging`, account `bds` | `make release` → `scripts/release-isolated.sh` → `scripts/build-instance-release.sh` | short git SHA stamped into `rastrillo.BuildVersion`, served at `GET /api/version` | `carlos deploy ... --swap hold --version <sha> <binary>`, then poll `/api/version` by hand |
+| **Runner, Linux primary** (`cmd/equipo-runner`) | docs-t1, a systemd *user* unit `equipo-runner.service` | `make release-runner` (part of `make release`), linux/amd64 | same SHA; `equipo-runner version`; reported in `hello.versions["runner"]` | copy binaries into `~/.local/share/equipo-runner/releases/<sha>/`, edit unit `ExecStart`, edit `EQUIPO_TOOL_PROXY_PATH`, `systemctl --user daemon-reload`, `restart` |
+| **Tool proxy** (`cmd/equipo-tool-proxy`) | Beside the Linux runner, started per step | Built first in `release-runner`. Its SHA-256 is linked into runner and instance (`Makefile` `RELEASE_LDFLAGS`) | digest only, must equal the runner's built-in digest | Same as runner, through `EQUIPO_TOOL_PROXY_PATH` |
+| **Runner, Mac worker** | Mac (`equipo-<person>` user), launchd agent `io.amadan.equipo-runner` | `release-runner`, darwin/arm64, bundled into the instance under `/releases/<sha>/darwin-arm64/` | same SHA | **Automatic**: `welcome.release` ≠ own version → download from the instance, verify digest, swap between steps, exit `mac.ExitUpdated`, launchd restarts |
+| **Staging runners** (owner + suite) | docs-t1, `equipo-runner-staging(.service, -suite.service)` | `scripts/staging-thin.py build` | same SHA, `installed.json` | `scripts/staging-thin.py release` (idle check → runners → instance) |
+| **Pinned third-party programs** (claude, codex, codex code-mode host, bwrap, Pi, OpenCode) | docs-t1 (and Mac) | not built here; pinned by digest in `internal/release/manifest.json` and provider packages | digests | Changing one means a new Equipo release. `verify-installed` refuses a mismatch |
+| **Instance config** | CARLOS env and secrets | n/a | n/a | `carlos env set`, `carlos secrets set`, by hand (README "Deploying") |
+| **Native apps** | phones | not in this repository | n/a | Clients of the instance's HTTP API only. Not covered further here. |
+
+### How each is upgraded today, step by step
+
+**Instance (production), as people actually do it** (README:60-87;
+`CONTROLLER-REPORT-connection-available.md:153-164`):
+
+1. Clean checkout of the merged commit. `set -a; . ~/.local/share/equipo-runner/service.env`
+ (the runner's env file is sourced so that `direct-release-check` can find
+ the pinned claude/codex paths).
+2. `make release`.
+3. `carlos deploy --app equipo --account oficina --channel edge --timeout 5m releases/equipo-linux-arm64-<sha>`.
+ The README example omits `--swap hold` (README:76), which production needs
+ because `EQUIPO_EXECUTION_ENABLED=1` (README:79-81). The Codex procedure
+ also omitted it, along with `--version`.
+4. Poll `/api/version` by hand.
+
+**Linux runner (production)**: four different procedures exist, each in a
+different document:
+
+- `CONTROLLER-REPORT-runner-start.md:146-189`: env file `runner.env`, unit
+ at `~/.local/share/equipo-runner/equipo-runner.service`, Python that
+ replaces the literal old `ExecStart` (`releases/9f616f3/...`) and asserts
+ it matched, then `daemon-reload` / `restart` / `status` / `journalctl`.
+- `CONTROLLER-REPORT-connection-available.md:166-204`: env file
+ `service.env`, unit at `~/.config/systemd/user/equipo-runner.service`,
+ Python that stops the unit, copies files, rewrites `ExecStart` *and*
+ `EQUIPO_TOOL_PROXY_PATH`, reloads, and restores on failure.
+- `scripts/cutover-thin.sh:218-232`: `sed -i` on both files under
+ `$RUNNER_ROOT`, plus a new instance ID.
+- `internal/runner/setup/install.go` (`equipo-runner install`): writes
+ `$root/runner.env` and `$root/equipo-runner.service`, then `systemctl --user
+ link/daemon-reload/enable/restart` (`internal/runner/setup/service.go:33-40`).
+
+And `packaging/equipo-runner.service` describes a fifth layout:
+`~/.config/equipo-runner/runner.env` and `~/.local/lib/equipo-runner/equipo-runner`.
+
+**Mac worker**: nothing to do once the instance is upgraded.
+
+**Staging**: `scripts/staging-thin.py build`, then `release`. It is the
+best-engineered path in the repository, but it is staging-only (fixed app,
+account, units and the `claude-a / paul@tito.io / 2.1.312` binding at
+`scripts/staging-thin.py:101-106`).
+
+---
+
+## 2. Every manual step
+
+From the cutover script, the staging script, the installer and the
+controller reports:
+
+| # | Step | Where it is today | Why it is manual |
+|---|---|---|---|
+| M1 | Source the runner's env file before `make release` | connection-available:157-159, runner-start:154-157, `staging-thin.py:139-142` | `direct-release-check` looks up the pinned programs through `EQUIPO_*_PATH` |
+| M2 | `carlos deploy` with the right flags (`--swap hold`, `--version`, `--target`, `--channel edge`) | README:76-81; cutover:195-200 | No wrapper. Flags are remembered or forgotten |
+| M3 | Poll `/api/version` until it reports the SHA | README:84-87; cutover:198; `staging-thin.py:213-228` | No wrapper |
+| M4 | `mkdir releases/<sha>` and copy runner + tool proxy (+ manifest) | runner-start:163-166; connection-available:185-187; cutover:220-221 | The installer cannot overwrite a hand-installed tree (see F9) |
+| M5 | Edit `ExecStart=` in the unit | runner-start:170-183; connection-available:188-190; cutover:223 | Version is in the path |
+| M6 | Edit `EQUIPO_TOOL_PROXY_PATH=` in the env file | connection-available:191-193; cutover:222 | Version is in the path. runner-start:191 says leave it alone, which works only while the proxy bytes are unchanged |
+| M7 | `systemctl --user daemon-reload` and `restart` / `stop` / `start` | all of the above; `setup/service.go:34` | Nothing owns the unit |
+| M8 | Look up the instance ID: `sed` in `service.env` (cutover:158), `carlos db query "select id from teams"` (cutover:207), or `GET /api/v1/me` → `team_id` (`staging-thin.py:309-312`) | Required by `runner.LoadConfig` (`internal/runner/config.go:104`) | Only needed at enrolment, but required as config forever |
+| M9 | Check nothing is in flight before restarting the runner | only `staging-thin.py:501-547` (DB query, waits up to 40 min) | Production procedures do not check |
+| M10 | Re-enrol (open link, enter code as owner) | cutover:234-243; installer always enrols | Only needed when the instance ID changes, but the installer has no "keep my enrolment" mode |
+| M11 | Verify: `systemctl is-active`, `journalctl`, `carlos db query` against the replica | runner-start:186-188; connection-available:206-235; cutover:245-248 | No `status` command that compares instance and runner |
+| M12 | `make staged-check` (staging must have passed these exact bytes) | only cutover:127 | Not on the path people run |
+| M13 | Rollback: restore the unit and env file from a backup copy, `daemon-reload`, `carlos promote <prev>` | cutover:79-112 (the cutover only); runner-start:178 (`.before-<sha>` copy) | No general rollback |
+
+---
+
+## 3. Fragility
+
+### F1. Version skew between instance and runner
+
+*What happens.* Each end speaks the lower protocol (`wire.Spoken`,
+`internal/wire/runners.go:1042-1044`; instance encodes per connection,
+`internal/equipo/chat/stream.go:72-91`). An **older runner against a newer
+instance** is handled by design: frames it lacks are not sent, and preview and
+publish steps fail with `runner_outdated` (`internal/equipo/chat/preview.go:189-215`).
+
+A **newer runner against an older instance** (normal during "runners first",
+and on every instance rollback): if the instance's strict decoder refuses the
+hello, the runner drops straight to **protocol 1**, not to the instance's
+actual level (`internal/runner/thin/link.go:503-529`). Protocol is at 26, so
+that is a large silent downgrade until the next reconnect.
+
+The skew window is real. `CONN1-PROGRESS.md:226-230` records "about a minute
+of skew, in which the old runners' streams were refused the new frames", and
+`:260-261` says "Version skew at deploy, as before ... install runners right
+after the instance".
+
+*Is it detected?* Partly. The Machines page shows each runner's version and
+protocol (`internal/equipo/machines_view.go:139-142`), but nothing compares
+them with the instance's version, and nothing alerts. The instance sends its
+release in every `welcome` (`stream.go:132`). The Linux primary receives it
+and ignores it.
+
+### F2. Ordering rules contradict each other, and nothing enforces any of them
+
+- Spec: "**Upgrade order:** instance, then the primary, then workers"
+ (`2026-11-07-equipo-mac-runners.md:329-331`).
+- `staging-thin.py release` docstring: runners first, then the instance,
+ because "a runner restart is what fails a running step" while an instance
+ swap only drops connections (`scripts/staging-thin.py:513-529`).
+- Controller procedures: instance, then runner, with no idle check.
+
+Both rationales are sound for different risks: protocol skew versus killing
+in-flight work. The real rule is "**drain the runner, then the order barely
+matters**", and only staging drains. Mac workers follow the instance on
+their own, which is the one ordering the code does enforce.
+
+### F3. In-flight work during a restart
+
+A runner restart fails running steps, turns and questions with
+`runner_restarted` (`internal/runner/thin/step.go:414`, `state.go:575`,
+`ask.go:402`). Triage treats that as a passing failure and retries some
+specialists, **never merge** (`internal/equipo/triage/triage.go:80-86`).
+
+- Staging waits up to 40 minutes for zero queued or running steps
+ (`staging-thin.py:498-547`), reading the database through `carlos db query`.
+- The Mac updater holds the worker between steps before swapping
+ (`mac.go:937-943`).
+- **The production Linux procedures do neither.** `systemctl restart` at any
+ moment can cut a merge mid-flight.
+- An instance swap with `--swap hold` sends `drain` and closes runner streams
+ (`stream.go:264-267`). Runners keep working and report on reconnect. This
+ side is in good shape.
+
+### F4. Rollback
+
+- **Instance.** `carlos promote <prev> edge` works only if the previous
+ deploy used `--version`. The hand procedures did not pass it. The previous
+ served version is not recorded anywhere outside the cutover's state file. I
+ could not confirm in this session whether instance migrations are safe to
+ run backwards (some repository searches were blocked by the sandbox).
+ Treat a rollback across a migration as unverified.
+- **Runner binary.** Old `releases/<sha>/` trees are kept, so rollback is
+ "point the unit and env file back", which means editing two files by hand again.
+- **Runner state.** The direct-path journal refuses a `user_version` newer
+ than it knows (`internal/runner/journal.go:88`), so a runner rollback after
+ a journal migration fails to start. The thin state uses additive `CREATE ...
+ IF NOT EXISTS` plus migrate functions (`internal/runner/thin/state.go:61-142`),
+ which is probably tolerant of an older binary, but no test says so.
+- **Config.** Only the cutover snapshots `service.env` and the unit.
+ runner-start keeps a `.before-<sha>` copy of the unit only.
+
+### F5. The procedure lives in agent reports, not code
+
+Every production runner upgrade after the cutover is a heredoc in a
+`CONTROLLER-REPORT-*.md`, written fresh by the agent that made the change,
+for a person to paste. They differ in file names, unit location, which fields
+they edit, whether they stop first, and whether they restore on failure (see
+section 1). runner-start's script asserts the *literal previous version
+string* (`releases/9f616f3/...`) in the unit, so it is single-use by design.
+
+### F6. The staged-artifacts gate is bypassed
+
+`release-isolated.sh` ends with "deploy only the exact bytes staging passed,
+through the drained cutover: `make staged-check && scripts/cutover-thin.sh
+<version>`" (`scripts/release-isolated.sh:49-52`). But `cutover-thin.sh` is a
+one-time fresh-database migration that refuses to run twice
+(`cutover-thin.sh:117-123`). So the documented path to production can no
+longer be used, and the provenance check is skipped in practice.
+
+### F7. Two (or five) runner layouts
+
+| Source | Env file | Unit file | Binary |
+|---|---|---|---|
+| `packaging/equipo-runner.service` | `~/.config/equipo-runner/runner.env` | (installed copy) | `~/.local/lib/equipo-runner/equipo-runner` |
+| `equipo-runner install` (Linux) | `$root/runner.env` | `$root/equipo-runner.service`, `systemctl link`ed | `$root/releases/<sha>/equipo-runner` |
+| `cutover-thin.sh` | `$root/service.env` | `$root/equipo-runner.service` | `$root/releases/<sha>/equipo-runner` |
+| connection-available report | `$root/service.env` | `~/.config/systemd/user/equipo-runner.service` | `$root/releases/<sha>/equipo-runner` |
+| Mac installer | `~/.config/equipo-runner/runner.env` | LaunchAgent plist | `~/.local/lib/equipo-runner/equipo-runner` |
+
+(`$root` = `~/.local/share/equipo-runner`.) A person upgrading has to work
+out which of these the box actually has before they can edit anything.
+
+### F8. Pinned third-party programs
+
+`verify-installed` holds claude, codex, the code-mode host, bwrap, Pi and
+OpenCode to the release's digests (`cmd/equipo-runner/install.go:84-102`). A
+CLI that updates itself on the box makes the runner refuse to start until a
+new Equipo release pins the new digest. This is deliberate, but it means "the
+runner won't come back" can have nothing to do with the change being
+deployed. Staging also hard-codes Claude `2.1.312`
+(`scripts/staging-thin.py:103`).
+
+### F9. The installer cannot take over a hand-installed runner
+
+`writeOwned` refuses to replace any file that lacks its own
+`user.equipo.installer.sha256` xattr (`internal/runner/setup/install.go:200-219`).
+The production runner's files were written by `install -m`, `sed -i` and
+Python, so even a fixed `equipo-runner install` could not upgrade docs-t1
+today without first adopting it.
+
+---
+
+## 4. Accidental complexity, in plain terms
+
+1. **The version number lives in the config.** Because the unit and env file
+ point at `releases/<sha>/...`, an upgrade is a config edit. If they
+ pointed at `releases/current/...` (a symlink) or a fixed path, an upgrade
+ would be "swap the link, restart", and rollback would be the same thing
+ pointing the other way.
+2. **The tool proxy path is configurable at all.** The runner already knows
+ the only acceptable tool proxy, because its digest is linked in. It can
+ find it beside its own executable. `EQUIPO_TOOL_PROXY_PATH` adds a way to
+ get it wrong and a second line to edit.
+3. **The instance ID is config.** It is needed for enrolment and journal keys,
+ and the enrolment record already holds it. Making it a required env value
+ means people `sed` it out of files and query the database for it.
+4. **The runner already knows its target and does nothing with it** on
+ Linux. The instance serves its own runner build at `/releases/<sha>/` and
+ sends `welcome.release`. The Mac code does the whole job. The Linux
+ primary was left out.
+5. **The release has to know the runner's env to build.** Sourcing
+ `service.env` before `make release` (M1) couples building to one specific
+ machine's runner config.
+6. **Two release scripts for two environments, neither for steady-state
+ production.** `staging-thin.py release` is the upgrade procedure,
+ parameterised by constants. `cutover-thin.sh` is a migration that happens
+ to contain an upgrade.
+7. **Checking the runner is alive** means `systemctl is-active`, `journalctl`
+ and SQL against a replica, when the instance already knows which runners
+ are connected, at what version and protocol.
+
+---
+
+## 5. Proposal: one command, with rollback
+
+### Target experience
+
+```sh
+make release # unchanged: builds X, records provenance
+equipo-ops upgrade X # or: scripts/upgrade.sh X
+equipo-ops rollback # back to the previous X, same mechanism
+equipo-ops status # instance version, each runner's version/protocol/state
+```
+
+`upgrade X` does, in order, and stops on the first failure:
+
+1. **Preflight.** `staged-check X` (or an explicit `--skip-staging` that is
+ recorded). Read the served version and record it as the rollback target.
+2. **Drain.** Ask the instance to stop placing new work and wait until
+ nothing is in flight. This is staging's `in_flight()` moved into the
+ instance as an endpoint, rather than SQL over a replica.
+3. **Instance.** `carlos deploy --swap hold --version X --target ... --channel edge`,
+ then wait for `/api/version == X`.
+4. **Runners follow by themselves.** Each runner sees `welcome.release == X`,
+ downloads from its instance, verifies, swaps `current`, and exits so that
+ systemd or launchd restarts it. The instance is the order: no runner can
+ run ahead, and the Linux primary behaves like the Mac worker.
+5. **Verify.** Wait until every enrolled runner reports `X` in hello (the
+ instance knows this, `machines_view.go:139`), or time out and say which
+ runner did not.
+6. **Undrain.**
+
+`rollback` is `carlos promote <recorded prev>`. Runners follow it down the
+same way because the instance names their target. This needs the
+newer-runner/older-instance path (F1) to land on the right protocol, and
+runner state that an older binary can open (F4).
+
+Nobody runs `systemctl`, edits a unit, or looks up an ID.
+
+### Ranked steps
+
+| Rank | Change | Effort | Payoff | Notes |
+|---|---|---|---|---|
+| 1 | **Stable runner path.** The unit runs `$root/current/equipo-runner run`. `current` is a symlink to `releases/<sha>`. The runner finds its tool proxy beside its own executable and `EQUIPO_TOOL_PROXY_PATH` is dropped, or ignored when it equals the sibling. | S | High | Ends M5/M6/M7 for every future upgrade. Rollback becomes "repoint `current`". |
+| 2 | **`equipo-runner upgrade <sha>` subcommand** (and `rollback`). Fetch from its own instance (reuse `install.go`'s fetch/verify), install into `releases/<sha>`, run `verify-installed` against the new binary, swap `current` atomically, then `systemctl --user restart` *itself*. Keeps the previous tree. **Adopts** an existing hand-installed layout once: finds the env file in any of the F7 locations and writes one canonical unit. | M | High | Replaces every heredoc in the controller reports with one command a person can run. Fixes F5, F7, F9. |
+| 3 | **Linux primary self-update from `welcome.release`.** Generalise `macUpdater` (`mac.go:872-945`) behind the same hold-between-steps, using rank 2's install step. Exit with a "restart me" code that the unit restarts on. | M | Very high | The "single command" becomes just "deploy the instance". The spec's order (instance → primary → workers) is then enforced by construction. |
+| 4 | **Instance-side drain** (`POST` owner-only: stop placing, report in-flight count) plus **`/api/version` with runner versions**. | M | High | Replaces `staging-thin.py`'s replica SQL and production's "hope". Lets the self-updating runner wait for an idle moment instead of failing a merge. |
+| 5 | **Instance ID out of config.** Read it from the enrolment or credentials in `state/` after enrolment; keep the env value only as an override. | S | Medium | Ends M8. |
+| 6 | **`scripts/upgrade.sh <sha>`** for the instance part: staged-check → record prev → `carlos deploy --swap hold --version` → wait → wait for runners → print status. Plus `rollback`. Generalise `staging-thin.py release` into it, with the environment (production or staging) as a parameter. | S | High | Can ship before ranks 2-4, using today's runners. Fixes M2, M3, M12, F6. |
+| 7 | **Protocol fallback to the instance's level, not 1.** On a refused hello, retry at the instance's advertised protocol (expose it on `/api/version` or in the close reason). | S | Medium | Makes rollback and runners-first safe (F1). |
+| 8 | **Skew visible on the Machines page**: "behind the instance" or "ahead of the instance" beside each runner's version. | S | Medium | Detection for F1 while the rest lands. |
+| 9 | **Tests that roll back.** M8 already builds an older release for mixed-version tests (Makefile `EQUIPO_M8_CACHE`). Add: an older runner opens a newer runner's state, and an older instance boots on a migrated database (or refuses clearly). | M | Medium | Turns F4 from unknown into known. |
+| 10 | **Retire stale paths.** Mark `cutover-thin.sh` as historical. Fix README:67-81 (versioned file names, `--swap hold`, `--version`). Delete or align `packaging/equipo-runner.service`. Stop sourcing the runner env for `make release` by passing the pinned-program paths explicitly or reading them from the manifest. | S | Medium | Reduces the "which document is right" problem. |
+
+**Suggested first slice:** ranks 1 + 2 + 6. That is a few days of work and
+removes every manual step people hit on the Codex fix (M4-M7, M2-M3) without
+any protocol change. Ranks 3 + 4 then turn "upgrade the runner" into
+something nobody does at all.
+
+### What this audit did not establish
+
+- Whether instance migrations are safe to roll back (some searches were
+ blocked in this session; treat as unknown).
+- How CARLOS `--swap hold` behaves if the new process fails health checks:
+ whether it falls back to the old process or leaves the app down. This
+ needs the CARLOS documentation or a staging test.
+- The Mac LaunchAgent path was read from code (`cmd/equipo-runner/install_mac.go`),
+ not observed on a machine.
diff --git a/docs/ops-audit/index.html b/docs/ops-audit/index.html
new file mode 100644
index 00000000..f05e4d78
--- /dev/null
+++ b/docs/ops-audit/index.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width,initial-scale=1">
+<title>Ops audit: upgrading a running Equipo</title>
+<style>
+body{font:16px/1.55 -apple-system,system-ui,sans-serif;max-width:60rem;margin:2rem auto;padding:0 1rem;color:#1d1d1f}
+h1{font-size:1.8rem}h2{margin-top:2.5rem;border-bottom:1px solid #ddd;padding-bottom:.3rem}h3{margin-top:1.8rem}
+code{font:13px ui-monospace,Menlo,monospace;background:#f2f2f4;padding:.1em .3em;border-radius:3px}
+pre{background:#f6f6f8;padding:1rem;overflow:auto;border-radius:6px}pre code{background:none;padding:0}
+table{border-collapse:collapse;font-size:14px;margin:1rem 0;display:block;overflow-x:auto}
+th,td{border:1px solid #ddd;padding:.4rem .5rem;vertical-align:top;text-align:left}th{background:#f6f6f8}
+hr{border:0;border-top:1px solid #ddd;margin:2rem 0}
+</style>
+</head>
+<body>
+<main id="report"><p>Loading the report. If it does not appear, read <a href="README.md">README.md</a> directly.</p></main>
+<script>
+// Renders README.md (the report) with the small subset of Markdown it uses:
+// headings, paragraphs, lists, tables, fenced code, inline code, bold, italics.
+function esc(s) { return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'); }
+function inline(t) {
+ return t.split(/(`[^`]+`)/).map(function (p) {
+ if (p.length > 1 && p[0] === '`' && p[p.length - 1] === '`') return '<code>' + esc(p.slice(1, -1)) + '</code>';
+ p = esc(p).replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
+ return p.replace(/(^|[^\w*])\*(?!\s)(.+?)(?<!\s)\*(?![\w*])/g, '$1<em>$2</em>');
+ }).join('');
+}
+function render(md) {
+ var src = md.split('\n'), o = [], para = [], i = 0, m;
+ function flush() { if (para.length) { o.push('<p>' + inline(para.join(' ')) + '</p>'); para = []; } }
+ while (i < src.length) {
+ var l = src[i];
+ if (l.indexOf('```') === 0) {
+ flush(); i++; var code = [];
+ while (i < src.length && src[i].indexOf('```') !== 0) code.push(src[i++]);
+ o.push('<pre><code>' + esc(code.join('\n')) + '</code></pre>'); i++; continue;
+ }
+ if ((m = /^(#{1,4}) (.*)/.exec(l))) { flush(); var n = m[1].length; o.push('<h' + n + '>' + inline(m[2]) + '</h' + n + '>'); i++; continue; }
+ if (l.trim() === '---') { flush(); o.push('<hr>'); i++; continue; }
+ if (l[0] === '|') {
+ flush(); var rows = [];
+ while (i < src.length && src[i][0] === '|') rows.push(src[i++].trim().replace(/^\||\|$/g, '').split('|').map(function (c) { return c.trim(); }));
+ var t = '<table><thead><tr>' + rows[0].map(function (c) { return '<th>' + inline(c) + '</th>'; }).join('') + '</tr></thead><tbody>';
+ rows.slice(2).forEach(function (r) { t += '<tr>' + r.map(function (c) { return '<td>' + inline(c) + '</td>'; }).join('') + '</tr>'; });
+ o.push(t + '</tbody></table>'); continue;
+ }
+ if ((m = /^(-|\d+\.) (.*)/.exec(l))) {
+ flush(); var tag = /\d/.test(m[1][0]) ? 'ol' : 'ul', items = [];
+ while (i < src.length) {
+ if ((m = /^(-|\d+\.) (.*)/.exec(src[i]))) items.push(m[2]);
+ else if (src[i].indexOf(' ') === 0 && src[i].trim() && items.length) items[items.length - 1] += ' ' + src[i].trim();
+ else break;
+ i++;
+ }
+ o.push('<' + tag + '>' + items.map(function (x) { return '<li>' + inline(x) + '</li>'; }).join('') + '</' + tag + '>'); continue;
+ }
+ if (!l.trim()) flush(); else para.push(l.trim());
+ i++;
+ }
+ flush();
+ return o.join('\n');
+}
+fetch('README.md').then(function (r) {
+ if (!r.ok) throw new Error(r.status);
+ return r.text();
+}).then(function (md) {
+ document.getElementById('report').innerHTML = render(md);
+}).catch(function () {});
+</script>
+</body>
+</html>
diff --git a/md2html_tmp.py b/md2html_tmp.py
new file mode 100644
index 00000000..16e9fc24
--- /dev/null
+++ b/md2html_tmp.py
@@ -0,0 +1,2 @@
+# Leftover from the ops audit task (docs/ops-audit). The sandbox refused to
+# delete this file. It is not used by anything; delete it.
diff --git a/release/preview.json b/release/preview.json
new file mode 100644
index 00000000..cf608bf2
--- /dev/null
+++ b/release/preview.json
@@ -0,0 +1 @@
+{"output": "docs/ops-audit"}