spec: release slice 1, hosted checks (rev 1, for Astra)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+157
−0
docs/superpowers/specs/2026-11-11-equipo-release-s1-hosted-checks.md+157 −0
diff --git a/docs/superpowers/specs/2026-11-11-equipo-release-s1-hosted-checks.md b/docs/superpowers/specs/2026-11-11-equipo-release-s1-hosted-checks.md| new file mode 100644 |
| index 00000000..6cd0aa30 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-11-equipo-release-s1-hosted-checks.md |
| @@ -0,0 +1,157 @@ |
| +# Release slice 1: hosted checks |
| + |
| +Status: 2026-11-11, revision 1, for Astra review. Drafted by Claude (Opus |
| +5.5) on `release-s1-hosted-checks` from main 577e24c. Slice 1 of |
| +`2026-11-11-equipo-release.md` (§2.7), approved by Paul as D2. Not |
| +implemented. |
| + |
| +## 0. Why, and the finish line |
| + |
| +A checks step on the primary runs the repository's gate offline in |
| +bubblewrap. Equipo's own gate is written for hosted CI (it pulls an image, |
| +Chromium and tools, and govulncheck needs vuln.go.dev). So on |
| +oficina/equipo every checks step ends `cannot_run needs_network`, and the |
| +merge gate asks "checks couldn't run" for a change that hosted CI has |
| +already judged on the exact commit. |
| + |
| +Finish line: for a repository with hosted CI on, the checks step reports |
| +hosted CI's own verdict on the exact candidate SHA, bound to the |
| +repository, the branch, the SHA and the run's report time. The rename task |
| +(`tkataquuxfrw`) on Retry ends `failed` with hosted CI's failing steps, not |
| +`needs_network` or `runner_restarted`. |
| + |
| +## 1. Rules |
| + |
| +1. **No new credential, no new grant.** The primary reads the hub's bearer |
| + API with the agent credential it already holds for the repository |
| + (`forge.FileCredentials.Credential`), as `fileForge.Merge` does. Workers |
| + hold no forge credential and never use hosted checks. |
| +2. **Who decides.** The instance offers hosted checks on every checks |
| + dispatch to the primary (`DispatchCommand.HostedChecks`). The runner |
| + takes it only when the hub says hosted CI is on for the repository |
| + (`GET /api/v1/repos/{ns}/{repo}/ci/hosted`, `on`). Anything else, a |
| + read error included, is today's local gate, unchanged. |
| +3. **macOS changes stay as they are.** A change that needs macOS |
| + (`needsMacOS`) keeps today's path (`needs_macos`, the Mac re-run). |
| + Hosted CI runs on Linux machines. |
| +4. **Exact SHA.** The hub's status API reports a branch's tip |
| + (`GET .../ci/status?branch=<task branch>`). A verdict counts only when |
| + the tip is the candidate. Any other tip, an unknown state, `queued` or |
| + `running` means wait. |
| +5. **Wait, with a timeout.** Poll every 20 s with `logs=none`, for at most |
| + 60 minutes from the step's start. Then `cannot_run`, `checks_timeout` |
| + (an existing reason that always asks). Cancel and withdrawal stop it as |
| + today. |
| +6. **Verdicts.** |
| + |
| +| Hub state on the candidate | Checks | Gate | Exit | Reason | |
| +|---|---|---|---|---| |
| +| `success` | `passed` | `hosted CI` | 0 | | |
| +| `failure` | `failed` | `hosted CI` | 1 | | |
| +| `skipped` (no CI script) | `none` | | | | |
| +| `lost`, `stale` | `cannot_run` | | | `checks_unavailable` | |
| +| timeout | `cannot_run` | | | `checks_timeout` | |
| + |
| + On `failure` the runner makes one more read with `logs=failed`. The |
| + output is the failing step and shard names first, then the hub's |
| + summary, then the failing logs' tail, bounded by `wire.MaxChecksOutput`. |
| +7. **Binding.** A hosted verdict carries `StepReport.Hosted`: repository, |
| + branch, SHA, hub state, the run's report time (`updated_at`; the hub |
| + exposes no run id) and the failing unit names. The instance counts a |
| + report with gate `hosted CI` only when all of these hold: |
| + - it comes from the primary; |
| + - the step is a checks step; |
| + - `Hosted` is present; |
| + - the repository is the project's own; |
| + - the branch is the task's; |
| + - the SHA is the step's candidate; |
| + - the state agrees with the outcome (`success` with `passed` and exit |
| + 0, `failure` with `failed` and a non-zero exit). |
| + |
| + Anything else is ignored, as a judgement on another SHA is today. The |
| + instance stores the binding (`chat_steps.hosted_ci`, JSON) and records |
| + `checks_sandbox = hosted`. |
| +8. **Fix round.** For a hosted failure, the fix round's feedback names the |
| + failing steps from the stored binding, then gives the output's tail: |
| + "The repository's hosted CI failed on 4d28994 in: step compile; step |
| + check shard 5. The end of their output: ...". |
| +9. **Merge authority.** A hosted `passed` or `failed` is checks that ran: |
| + `OutsideSandbox` stays false, because it is not `none`. With hosted |
| + CI, "checks couldn't run" remains only for `lost`, `stale` and the |
| + timeout, and `mergegate` does not change. The hub's own merge already |
| + refuses a commit whose CI is not green (`ci_not_green`). |
| + |
| +## 2. Wire and versions |
| + |
| +Protocol 5, `wire.ProtocolHostedChecks`, becomes `ProtocolCurrent`. Its |
| +two optional, `omitempty` fields: |
| +- `DispatchCommand.hosted_checks`; |
| +- `StepReport.hosted` (`{repo, branch, sha, state, reported_at, |
| + failed[]}`). |
| + |
| +`wire.Encode` gains `downgradeHostedChecks`, which clears both for any peer |
| +below 5, chained before the others. Frames are decoded with `Strict`, so |
| +without the downgrade an old peer would refuse the frame. |
| + |
| +| Combination | Behaviour | |
| +|---|---| |
| +| new instance, runner at 4 | `hosted_checks` is never sent; local gate as today | |
| +| old instance, new runner | spoken 4: no flag, so local gate; `hosted` never sent | |
| +| new runner, its state holding a hosted dispatch, then rolled back to an old runner | the old runner reads its step bodies with `json.Unmarshal`, not `Strict`, so the unknown field is ignored and the local gate runs | |
| + |
| +The tests cover both directions at the wire, plus a contract with a |
| +protocol 4 runner rig. |
| + |
| +## 3. Changes |
| + |
| +- `wire`: `ProtocolHostedChecks`, the two fields, `GateHosted`, |
| + `SandboxHosted`, the downgrade. |
| +- `runner/forge`: `HubCIHosted` and `HubCIStatus`. Both send the bearer, |
| + escape the path, follow no redirects, cap the read (64 KiB and 4 MiB) |
| + and decode only the fields used. |
| +- `runner/thin`: an optional `HostedCI` interface on the Engineer, met by |
| + `fileForge`, and `hostedChecks` beside `checks`. The poll interval and |
| + timeout are variables, for the tests. |
| +- `equipo/chat`: |
| + - dispatch sets the flag for a checks step on the primary; |
| + - `stepReport` validates and stores the binding; |
| + - `feedback` names the failing units. |
| +- Migration `0062_thin_hosted_checks.sql`: `ALTER TABLE chat_steps ADD |
| + COLUMN hosted_ci text`. Additive; registered in the models; the |
| + snapshot is updated. |
| +- Budgets: `internal/runner/thin` and `internal/equipo/chat` sizes, with |
| + reasons. |
| +- No new UI copy. The checks line already shows the gate name. |
| + |
| +## 4. Tests, failing first |
| + |
| +- **wire:** `Encode` clears both fields below 5 and keeps them at 5, in |
| + both directions. |
| +- **forge:** status and hosted reads against an `httptest` hub: the |
| + bearer, the path, the caps, a redirect refused, and an unreadable body |
| + as an error. |
| +- **thin**, with a fake `HostedCI`: |
| + - pending, then `success`, gives `passed` with its binding; |
| + - `failure` gives `failed`, with the names first and the logs; |
| + - another tip until the timeout gives `checks_timeout`; |
| + - `skipped` gives `none`; `lost` gives `checks_unavailable`; |
| + - hosted off, a read error, or the flag absent gives the local gate; |
| + - a macOS change gives the local path; |
| + - cancel gives `cancelled`. |
| +- **thintest contracts:** |
| + - a hosted pass on the candidate leads to review, and then Ready with |
| + merge eligibility; |
| + - a hosted failure starts a fix round whose feedback names the units; |
| + - reports with the wrong repository, branch, SHA, state, sender or |
| + binding are ignored; |
| + - a protocol 4 runner gets no `hosted_checks`. |
| +- **Mutations:** each guard in rule 7, the SHA check in rule 4, the |
| + timeout, and the downgrade is broken once, and its test is seen to fail. |
| + |
| +## 5. Out of scope |
| + |
| +- A per-commit status read. The hub reports tips only; an amadan request |
| + for status by SHA, with a run id, is a follow-up. |
| +- Hosted checks for Mac workers. |
| +- Retrying a step that ended `runner_restarted`. Retry stays a person's |
| + tap. |