| 1 | # Release slice 1: hosted checks |
| 2 | |
| 3 | Status: 2026-11-11, revision 2. Drafted by Claude (Opus 5.5) on |
| 4 | `release-s1-hosted-checks` from main 577e24c. This is slice 1 of |
| 5 | `2026-11-11-equipo-release.md` (§2.7), approved by Paul as D2. |
| 6 | - Revision 1 (1d7b90d) drew READY AFTER FIXES from Astra, in one round. |
| 7 | The findings are in `CODEX-FINDINGS-RELEASE-S1-HOSTED-CHECKS.md` |
| 8 | beside this spec. |
| 9 | - Revision 2 folds all six findings in, marked **(astra N)**. Where it |
| 10 | could, it cut scope instead of adding machinery. |
| 11 | - Revision 2.1 adds the amadan request number (§5). |
| 12 | |
| 13 | ## 0. Why, and the finish line |
| 14 | |
| 15 | A checks step on the primary runs the repository's gate offline in |
| 16 | bubblewrap. Equipo's own gate is written for hosted CI: it pulls an |
| 17 | image, Chromium and tools, and govulncheck needs vuln.go.dev. So on |
| 18 | oficina/equipo every checks step ends `cannot_run needs_network`, even |
| 19 | though hosted CI has already judged the exact commit. |
| 20 | |
| 21 | **Finish line:** |
| 22 | - For a repository with hosted CI on, the checks step reports hosted CI's |
| 23 | own verdict on the exact candidate SHA. The verdict is bound to the |
| 24 | repository, the branch, the SHA and the run's report time. |
| 25 | - A runner restart while the step waits no longer ends it |
| 26 | `runner_restarted`. |
| 27 | - The rename task (`tkataquuxfrw`) on Retry ends `failed`, with hosted |
| 28 | CI's failing steps in its fix round. |
| 29 | |
| 30 | ## 1. Rules |
| 31 | |
| 32 | 1. **No new credential, no new grant.** The primary reads the hub's bearer |
| 33 | API with the agent credential it already holds for the repository, as |
| 34 | `fileForge.Merge` does. Redirects are refused, and reads are capped. |
| 35 | Workers hold no forge credential and never take this path. |
| 36 | 2. **Who decides.** The instance offers hosted checks on every checks |
| 37 | dispatch to the primary (`DispatchCommand.HostedChecks`). |
| 38 | - The runner takes the offer only when `GET .../ci/hosted` answers |
| 39 | `on` and the change does not need macOS (`needsMacOS`). |
| 40 | - Anything else, a read error included, means today's local gate, |
| 41 | unchanged. |
| 42 | - Once taken, the attempt's phase becomes `hosted`, which is |
| 43 | persisted. |
| 44 | 3. **Polling is deferred, not held (astra 5).** |
| 45 | - Each run of the attempt confirms the lease, makes one status read |
| 46 | (`GET .../ci/status?branch=<task branch>&logs=none`, 30 s request |
| 47 | timeout, again every 15 s: the engine's deferral interval, as for |
| 48 | merges), and returns `stepDeferred` when there is no verdict yet, |
| 49 | as a merge waiting for CI does. The queue moves on meanwhile. |
| 50 | - The deadline is 60 minutes from the first deferral |
| 51 | (`deferred_since`, persisted), so neither a restart nor a reconnect |
| 52 | resets it. |
| 53 | - Cancel and withdrawal end it at the next run, through the lease. |
| 54 | - Restart recovery runs a `hosted`-phase checks attempt again, as it |
| 55 | does a merge, instead of failing it `runner_restarted`. |
| 56 | - A read error counts as no verdict yet. At the deadline the step |
| 57 | ends `cannot_run checks_timeout`. |
| 58 | 4. **One snapshot (astra 2).** A verdict comes only from a response whose |
| 59 | `ns`, `repo` and `branch` equal the request and whose `sha` is the |
| 60 | candidate. |
| 61 | - On `failure`, one `logs=failed` read adds the logs only if its sha, |
| 62 | state and `updated_at` equal the first response's. Otherwise the |
| 63 | report carries the first snapshot's names and summary without logs. |
| 64 | - Another tip, `queued`, `running` and `unknown` all mean no verdict |
| 65 | yet. |
| 66 | 5. **Verdicts.** |
| 67 | |
| 68 | | Hub state on the candidate | Checks | Gate | Exit | Reason | `Hosted` | |
| 69 | |---|---|---|---|---|---| |
| 70 | | `success` | `passed` | `hosted CI` | 0 | | yes | |
| 71 | | `failure` | `failed` | `hosted CI` | 1 | | yes | |
| 72 | | `skipped` (no CI script) | `none` | | | | yes | |
| 73 | | `lost`, `stale` | `cannot_run` | | | `checks_unavailable` | yes | |
| 74 | | deadline | `cannot_run` | | | `checks_timeout` | no | |
| 75 | |
| 76 | The output lists the failing unit names first, then the hub's summary, |
| 77 | then the failing logs' tail. It is bounded by `wire.MaxChecksOutput`. |
| 78 | 6. **Binding, bounded (astra 2, 6).** `StepReport.Hosted` holds `repo`, |
| 79 | `branch`, `sha`, `state`, `reported_at` (the hub's `updated_at`; the |
| 80 | hub exposes no run id) and `failed` (at most 20 names of 120 bytes, |
| 81 | which the runner truncates). The instance counts a report that carries |
| 82 | `Hosted`, or names gate `hosted CI`, only when all of these hold: |
| 83 | - it comes from the primary, on a connection at protocol 5; |
| 84 | - the step is checks, and `Hosted` is present; |
| 85 | - the repository is the project's own; |
| 86 | - the branch is the task's; |
| 87 | - the SHA is the step's candidate; |
| 88 | - `reported_at` is greater than 0; |
| 89 | - `failed` is within its bounds; |
| 90 | - the state maps to the outcome as in rule 5. |
| 91 | |
| 92 | Anything else is ignored, as a judgement on another SHA is today. The |
| 93 | instance stores the binding in `chat_steps.hosted_ci` (JSON) and sets |
| 94 | `checks_sandbox = hosted`. |
| 95 | 7. **Merge authority: checks that ran, not yet sandboxed (astra 1).** A |
| 96 | hosted `passed` or `failed` is a real result: Review gets it, a |
| 97 | failure starts the fix round, and "checks couldn't run" is no longer |
| 98 | the reason. |
| 99 | - **Why not sandboxed:** the hub's status API does not say where a |
| 100 | verdict was produced. `on` is the desired setting, and a verdict |
| 101 | from an ordinary runner survives enabling hosted CI. The hub's own |
| 102 | merge gate on CI is off by default. |
| 103 | - **So:** `checksOutsideSandbox` counts `hosted` as outside the |
| 104 | sandbox. A hosted pass is asked about ("its checks ran outside the |
| 105 | sandbox", existing copy) and never merged on its own. `mergegate` |
| 106 | does not change. |
| 107 | - **Later:** once the hub reports execution provenance and a run id |
| 108 | (an amadan request, §5), hosted can count as sandboxed in its own |
| 109 | change. |
| 110 | 8. **Fix round.** For a hosted failure, the feedback first names the |
| 111 | failing units from the stored binding, for example "The repository's |
| 112 | hosted CI failed on 4d28994 in: compile; check shard 5 of 23", then |
| 113 | gives the output's tail. |
| 114 | |
| 115 | ## 2. Wire and versions |
| 116 | |
| 117 | - **Protocol 5,** `wire.ProtocolHostedChecks`, becomes |
| 118 | `ProtocolCurrent`. It adds `DispatchCommand.hosted_checks` and |
| 119 | `StepReport.hosted`, both `omitempty`. |
| 120 | - **Downgrade, `downgradeHostedChecks` (astra 3):** |
| 121 | - It drops the offer for any peer below 5. |
| 122 | - It turns a hosted-derived report into `cannot_run |
| 123 | checks_unavailable`, with no gate, no exit code and no `hosted`. A |
| 124 | stripped report never keeps a `passed` an old instance would accept |
| 125 | unbound. |
| 126 | - It runs first, and the later steps keep the accumulated flag. |
| 127 | |
| 128 | | Combination | Behaviour | |
| 129 | |---|---| |
| 130 | | new instance, runner at 4 | no offer, so the local gate as today | |
| 131 | | old instance, new runner | spoken 4, so no offer. A hosted report still in flight from before reaches the old instance as `cannot_run` | |
| 132 | | new runner rolled back to an old binary (astra 4) | not transparent. The old binary fails held checks `runner_restarted`, and an unacknowledged report with `hosted` in the outbox would be refused by a protocol 4 instance's strict decoder. Rule: roll a runner back below protocol 5 only after it has delivered its outbox, as for every earlier bump that added report fields (merge facts' `change`). The release plan's runner-state proof (§2.6 item 4) will test it | |
| 133 | |
| 134 | ## 3. Changes |
| 135 | |
| 136 | - **`wire`:** `ProtocolHostedChecks`, the two fields, `HostedResult` |
| 137 | with its bounds, `GateHosted`, `SandboxHosted`, and the semantic |
| 138 | downgrade. |
| 139 | - **`runner/forge`:** `HubCIHosted` and `HubCIStatus`. They send the |
| 140 | bearer, escape the path, refuse redirects, cap the read (64 KiB and |
| 141 | 4 MiB), and check the answer's identity. |
| 142 | - **`runner/thin`:** |
| 143 | - an optional `HostedCI` interface, met by `fileForge`; |
| 144 | - `hostedChecks`, which runs in deferred steps; |
| 145 | - `phaseHosted`, and its case in restart recovery. |
| 146 | - **`equipo/chat`:** |
| 147 | - dispatch sets the flag for checks on the primary; |
| 148 | - `stepReport` validates and stores the binding; |
| 149 | - `checksOutsideSandbox` counts `hosted`; |
| 150 | - `feedback` names the failing units. |
| 151 | - **Migration** `0062_thin_hosted_checks.sql`: `chat_steps.hosted_ci` |
| 152 | text. It is additive, and the model and snapshot are updated. |
| 153 | - **Budgets:** the sizes for `internal/runner/thin`, |
| 154 | `internal/equipo/chat` and the touched test packages, with reasons. |
| 155 | - **No new UI copy.** |
| 156 | |
| 157 | ## 4. Tests, failing first |
| 158 | |
| 159 | - **wire:** below 5, `Encode` drops the offer, and turns a hosted |
| 160 | `passed` into `cannot_run`. The result decodes strictly at protocols 4, |
| 161 | 3, 2 and 1. At 5 it passes through unchanged. |
| 162 | - **forge:** |
| 163 | - the bearer and the path; |
| 164 | - an answer for another branch, ns or repo is refused; |
| 165 | - a malformed sha; |
| 166 | - caps; |
| 167 | - a redirect is refused and not followed; |
| 168 | - a refusal, a bad repository, another logs mode, and a bearer with a |
| 169 | newline. |
| 170 | - **thin**, with a fake `HostedCI`: |
| 171 | - pending defers, and unrelated work runs meanwhile; |
| 172 | - a pass and a failure, each from one snapshot; a failure whose |
| 173 | enrichment moved keeps no logs; |
| 174 | - `skipped`, `lost`, and the deadline, measured from `deferred_since`; |
| 175 | - hosted off, a read error on `hosted`, or no offer gives the local |
| 176 | gate, as does a macOS change; |
| 177 | - after a restart the step runs again, without `runner_restarted`; |
| 178 | - cancel ends it; |
| 179 | - the names are bounded. |
| 180 | - **thintest contracts:** |
| 181 | - a hosted pass leads to review and approval, and the merge then asks |
| 182 | with the sandbox reason and does not act; |
| 183 | - a hosted failure starts a fix round that names the units; |
| 184 | - every binding rule is checked on its own, and the report is ignored; |
| 185 | - a protocol 4 rig gets no offer. |
| 186 | - **Mutations:** every rule 6 guard, the identity check in rule 4, the |
| 187 | deadline, the downgrade and the sandbox rule is broken once, and its |
| 188 | test is seen to fail. |
| 189 | |
| 190 | ## 5. Out of scope, and follow-ups |
| 191 | |
| 192 | - Hosted checks on Mac workers. |
| 193 | - Retrying steps already ended `runner_restarted`. Retry stays a person's |
| 194 | tap. |
| 195 | |
| 196 | ### v2: automatic merge on hosted passes |
| 197 | |
| 198 | Filed as amadan/amadan#136, which cross-references #131. It asks for a |
| 199 | status read by commit SHA that returns the run id and the run's executor: |
| 200 | `hosted` (one of amadan's single-use VMs, with the job credential scoped |
| 201 | as today) or `runner`. |
| 202 | |
| 203 | Once it lands, a hosted verdict binds to the run id instead of the report |
| 204 | time. Hosted CI then counts as sandboxed only when the executor is |
| 205 | `hosted`, and a pass may merge on its own under merge authority. That |
| 206 | change is a spec of its own. |
| 207 | |