oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Slice 1 progress: Real conversation
2
3Branch `thin-v1-slice1` from main 5eae410. Spec:
4`docs/superpowers/specs/2026-11-06-equipo-thin-v1.md` §8 row 1.
5
6## Done
7
81. Contracts: `internal/wire` (person API v1 resources, events, runner
9 stream frames, strict decoding) and `internal/wire/wiretest` (recorded
10 fixtures under `testdata/api` and `testdata/frames`, shared loader and a
11 shape comparator used by the instance and runner tests).
12
132. Instance (`internal/equipo/chat`, migration 0036): `POST/GET messages`,
14 `GET turns/{id}`, `POST turns/{id}/cancel`, `GET snapshot`, `GET events`
15 (SSE, `?after=` over `Last-Event-ID`, 410 on an expired or future cursor,
16 20 s pings, same-origin cookie only for EventSource, bearer elsewhere,
17 principal re-checked before each write), `GET /api/runner/stream`
18 (WebSocket, generation lease, durable `runner_commands` mailbox, frame
19 inbox for exactly-once, drain on SIGTERM). `/me` gained `id`, `address`,
20 `role` and keeps `person`. Contract tests: `internal/thintest`.
213. Runner (`internal/runner/thin`): one outbound WebSocket with outbox,
22 acks, heartbeat, drain and supersession (exit 3); per-person workers over
23 a durable `runs` table with crash recovery (one new attempt, then
24 `runner_restarted`); the long-lived Claude coordinator (stream-json,
25 `--verbose`, stdin held open, `--include-partial-messages`) in the
26 existing containment with policy and init-frame validation, copy
27 rotation before a turn the copy could not cover, `--resume` from a
28 durable session home across idle exit and runner restart, cancel by
29 killing the attempt's namespace; the runner's `login claude|codex` command.
30 The runner's `run` command now runs the thin runner.
31 Provider: `OpenRuntimeCopy` (refresh with the CLI under the source lock,
32 stage, release the lock), action `converse`.
334. Headless suite (`internal/headless`): fake 2.1.312 CLI
34 (`internal/fakeclaude`) in real bwrap, real instance and runner, Go
35 client on person API v1 and SSE only. Scenarios 1 (cold, warm, cold
36 resume), 3, 6, 7, 8, cancel and runner crash, plus guards (init policy,
37 session id, rotation, lock release, no credential bytes anywhere). About
38 35 s locally. Mutation checks: removing init validation, the session id
39 check, the lock release or the rotation each fails a test.
40
415. Staging (`scripts/staging-thin.py`): `equipo-staging` in Oficina on the
42 flagship console at https://equipo-staging.bds.oncarlos.com, deployed
43 with `--swap hold`; a staging runner user unit (named in the script)
44 with its own state root beside the production runner's (state, work,
45 scratch, sessions, config) on the claude-a home; owner sign-in by
46 logged mail (allowed only for the staging hosts) and a device bearer in
47 a 0600 file. The runner's WebSocket and the SSE stream both work through
48 the CARLOS edge. Headless suite with the real Claude CLI 2.1.312, all
49 seven scenarios green twice (12 turns each):
50 - run 1 (08434e3): cold 2.46 s, warm 0.89 s, cold resume 2.78 s
51 - run 2 (1750aa0): cold 2.84 s, warm 0.87 s, cold resume 2.89 s
52 - run 3 (bab4b08, final): cold 2.74 s, warm 0.89 s, cold resume 3.21 s;
53 runner offline seen in 4.6 s after the going-away close (was 55 s)
54 36 live turns used of the 40 budget.
556. Chat page on the stream: `/conversation` renders from the chat snapshot
56 (scriptless form post to the same `Send`), `chat-stream.js` follows
57 `/api/v1/events` (drafts, markdown replies via a server refresh, turn
58 ends, the offline line). Browser test `TestBrowserChat` (tag browser).
59 Deleted: `EQUIPO_ALWAYS_ON` and the live hub it switched on; the runner
60 protocol's coordinator routes and task poll, claim and recover_claim;
61 the old suites that only exercised them (agentsetuptest, chatfeeltest,
62 the old coordinator contract, HTTP runner end-to-end and live-refresh
63 tests); the runner's `run` no longer opens journal.db.
64
657. Review round (Astra, REQUEST CHANGES at 60c9f36), each fix with a test
66 that fails before it (checked by reverting or mutating the fix):
67 1. Cancel of a dispatched turn now always goes through the runner and
68 ends only on its termination report; a cancel that reaches the
69 runner before its message holds the turn cancelled (no execution).
70 2. Execution lease: no turn reaches the provider until the instance
71 acks a `lease` frame on the current connection (recovered runs wait
72 for it). Each connection holds its own lease id, so a replaced
73 connection of the same generation is fenced for frames, commands
74 and lease checks.
75 3. Only the person's primary runner's `sync` reconciles their turns.
76 4. Only the ack of a terminal report finishes a run (not the recovery
77 `running` announcement).
78 5. Recovery keeps a durable cancel and reports it, never retries it.
79 6. At start the runner removes orphaned credential copies, config,
80 policy scratch, workspaces and tool sockets (it holds the state lock,
81 so they belong to dead processes). The suite SIGKILLs a runner process
82 mid-turn; staging's crash scenario now uses SIGKILL of the unit's
83 main process.
84 7. `make release` points at `make staged-check`, which refuses unless a
85 full green staging suite recorded exactly those artifacts
86 (`releases/staged/<version>.json`); staging now deploys `make release`
87 output. `scripts/cutover-thin.sh` is the drained production cutover
88 (plan by default, not run): preflight, stop old runner, verified
89 export, `EQUIPO_DATABASE=equipo-v1.db` (fresh; `equipo.db` kept for
90 rollback), unset `EQUIPO_ALWAYS_ON`, deploy with `--swap hold`,
91 install the staged runner, re-enrol, verify.
92 Minor: the page counts delta offsets in UTF-8 bytes (browser test
93 streams accents and emoji). Copy accepted for now with the existing
94 marker; `make release` now passes.
95 Staging run 4 (fe5bdf8, built by `make release`): all scenarios green,
96 cold 3.25 s, warm 1.00 s, cold resume 3.53 s; 12 live turns (48 total).
97
988. Review round 2 (Astra at c96009e: 1 to 6 and the UTF-8 minor resolved;
99 7 not resolved; four new items), each with a test that fails first:
100 1. Root ownership: the runner claims its scratch and workspace roots for
101 its state directory (a lock held for the process life and an
102 `.equipo-root-owner` record) and refuses roots another runner holds
103 or owns, before any orphan sweep. The staging script refuses roots
104 that overlap the production runner's (paths compared, none today).
105 2. Cutover identity: after the deploy and before any runner change, the
106 script reads the new instance id from the new database through the
107 platform replica, requires it to differ from the old one, and writes
108 it into the runner config before enrolment; otherwise it stops with
109 the runner untouched.
110 3. Staging record: hashes are recorded at deploy (instance) and install
111 (runner, tool proxy); before recording, staging checks
112 `/api/version`, the installed files, the unit's running process
113 (`/proc/<pid>/exe`) and the tool proxy path, and the record step
114 refuses hashes that differ from the release files.
115 4. Rollback: the cutover records the prior configuration first (served
116 version, `EQUIPO_ALWAYS_ON` and `EQUIPO_DATABASE`, runner service.env
117 and unit, instance id) and `cutover-thin.sh rollback --execute`
118 restores all of it, keeps the new state as
119 `state.thin-rolled-back-<time>`, promotes the previous version and
120 starts the old runner. Steps are recorded and resumable; repeats
121 and unrecorded leftovers are refused. A stub-based test runs the
122 cutover and the rollback end to end.
123 Staging run 5 (2a19928): all scenarios green, cold 2.93 s, warm 1.11 s,
124 cold resume 3.51 s; 12 live turns (60 total over the slice).
125
1269. Review round 3 (items 2 and 3 resolved), two narrow fixes with
127 failing-first tests: startup now takes the state lock and root
128 ownership before containment recovery and the orphan sweep
129 (`TestStartupRefusesSharedRootsBeforeRecovery`: a second runner on
130 shared roots is refused before recovery, and the first runner's
131 namespace record and scratch survive); the cutover reads every snapshot
132 value into a checked, validated variable and stops before any change if
133 one fails (`TestCutoverStopsWhenASnapshotReadFails`). The tryequipo tty
134 driver now waits for the shell's exit instead of checking once (a CI
135 flake).
136
13710. Mobile send without page transitions: `chat-stream.js` sends in the
138 background (submit and Enter; Shift+Enter is a newline; IME-safe) with an
139 optimistic bubble, focus kept in the composer, Retry on failure, and
140 reconciliation with the committed message by id. It posts the form's own
141 action with `Accept: application/json` (the person API POST stays
142 bearer-only), which now answers with the committed message; the no-JS
143 form post still redirects. Browser test at 390 px
144 (`TestBrowserChatSendStaysOnPage`) checks no navigation or page reveal,
145 the bubble shown at once, Enter and Shift+Enter, no duplicate, and Retry.
146 Live staging follow-up turns after restart and cancel now run on the fake
147 CLI only, so the live suite uses 10 turns.
148
149## Next
150
151- Controller: merge decision; the cutover is for a person to run.
152
153## Decisions
154
155- Frames are `{"id","type","data"}` JSON text messages. Added to the §4 list:
156 `welcome{generation, runner_id}` (the instance grants the generation in
157 answer to `hello`), `turn{turn_id, attempt, state, reason}` (runner to
158 instance, for failed or cancelled turns and a new attempt after crash
159 recovery), and instance-to-runner `ack`. Deltas carry an id but are never
160 acked or resent; the committed reply replaces the draft.
161- `message` carries the last 50 messages as `tail`; the runner uses it only
162 when it starts a fresh session. No `session` field: the runner owns
163 session choice (durable `sessions` row, resume by id).
164- Turn failure reasons are a fixed list (`wire.Reasons`), never provider text.
165- Fixtures live in a test-only package so production binaries do not embed them.
166
167- Coordinator transcripts persist by copy, not a bind mount: before a
168 process starts the runner copies `projects/-workspace/<id>.jsonl` from the
169 session home into the fresh runtime home, and copies it back after each
170 turn and on exit. Containment mounts are unchanged and the model cannot
171 reach other persons' sessions.
172- A fresh session starts each UTC day or on an account change; its first
173 frame carries a five-line house rule and the 50-message tail.
174- Slice 1 coordinator has no Equipo tools (`converse` action): the MCP
175 socket lists only Claude's permission callback and denies it.
176- No in-namespace `auth status` probe before each process: identity is
177 checked by the CLI refresh in the source home under the lock, and the copy
178 is byte-identical and re-checked before every turn (`CheckCopy`).
179- Quick messages: while a turn is in flight, new messages join one queued
180 turn, sent as one frame (scenario 6 sends them during a running turn).
181- Cancel of a turn the runner has not acked ends at once and voids its
182 command.
183- Size ceilings for internal/equipo (11000) and internal/runner (9550) are
184 raised until the slice 7 sweep deletes the old code beside the new.
185- Physical deletion of the old runner runtime (journal*.go, supervisor,
186 coordinator service), runnerproto claims and fences, the old
187 conversation coordinator engine and the personapi extras is left to the
188 slice 7 sweep: none of it is reachable now (no routes, `run` uses the
189 thin runner), and deleting it means rewriting most of the old suites.
190
191## Blockers
192
193None yet.
194