oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Slice 2 progress: Tools and projects
2
3Branch `thin-v1-slice2` from `thin-v1-slice1` (3ddf7d0). Spec:
4`docs/superpowers/specs/2026-11-06-equipo-thin-v1.md` §8 row 2, plus four
5additions from Paul on 2026-11-07 (thinking line, no repository
6questions, keyboard-safe chat, context index). Conventions and scripts as
7in `SLICE1-PROGRESS.md`.
8
9## Done
10
111. Contracts (`internal/wire`, fixtures under `wiretest/testdata`):
12 resources `Project`, `ProjectList`, `Card`, `Answered`, `CardConflict`,
13 `Activity`, `TurnTiming` (on `Turn`, null until replied); routes
14 `GET/POST /projects`, `DELETE /projects/{id}`,
15 `POST /cards/{id}/answer` (409 with the current card when stale or
16 answered); events `card`, `project`, `activity`; frames `tool_call`,
17 `tool_result` (both durable), `activity` (sent once, like deltas);
18 `hello` gained `create_in`, `home`, `agent` and `catalog`.
19
202. Instance (`internal/equipo/chat`, migration 0037): projects are team
21 records; cards belong to one person's conversation. Every tool call is
22 authorised inside the runner frame's write transaction: the lease and
23 credential (`current`), the person's primary runner, the turn running on
24 that attempt; results are stored by call id, so a repeat returns the
25 stored result. Tools:
26 - `status` (read only: runner versions, connections, projects,
27 `can_add`, `create_in`, `home`; no secrets or paths),
28 - `find` (catalog match by name, alias, summary, hint; nothing
29 reachable puts one access card in the conversation),
30 - `search_code` and `read_file` (authorised for repositories in the
31 catalog; the runner reads its own clone),
32 - `add_project` (only the person's runner-advertised allowlist; Added
33 card for a new project, Working in for an existing one),
34 - `create_project` (instance authorises: a namespace the agent may
35 create in, no such project; runner creates; `project_created`
36 confirmed only after that turn's authorisation) with a Created card,
37 - `ask_person` (question card; the answer becomes the person's next
38 message, prefixed for the coordinator with the question).
39 Change on a project card points the work at another repository (the
40 choice is the person's message); Remove marks the project removed and
41 its cards removed. Adding or creating never widens publishing
42 authority: the agent already writes there, and forge checks still guard
43 every push.
44
453. Runner (`internal/runner/thin`): the coordinator's tool socket lists
46 exactly the conversation's tools (`provider.ConverseTools`) and the
47 permission callback, which allows only those; the policy allows the
48 same MCP tools (nothing native). Calls go to the instance as durable
49 `tool_call` frames and wait for `tool_result`. Clone on demand: added,
50 created and read projects are fetched into
51 `<workspace root>/repos/<hash>-<name>.git` (bare), git with hooks,
52 helpers and system config off, the forge git password in a
53 `GIT_CONFIG_*` header in the environment (never argv or logs).
54 Context index: every repository the agent reaches (credential file,
55 created, and the hub's writable list) is shallow-fetched hourly; the
56 catalog (summary from README or AGENTS.md, names from headings,
57 manifests, app bundles and repeated capitalised words such as
58 Woodstar, language hints, default branch, last update) goes in hello,
59 bounded to 100 repositories. A fresh session's opening lists it.
60 Activity: thinking and tool starts from `stream_event`
61 `content_block_start` (tool name only). Timing: each reply carries
62 where its time went.
63
644. House rule (fresh session): decide where work goes and report it in
65 one line; never ask the person to choose a repository, never list
66 repositories to pick, never mention Set up; existing work goes to the
67 repository that clearly fits, new work to a new repository in the
68 related namespace or home, otherwise best fit with one short reason;
69 names of apps go through `find`, then `search_code` and `read_file`;
70 nothing reachable gets one line ending "Grant access".
71
725. Headless (fake CLI, local forge of bare repositories): scenario 2 to
73 the project (`project`), `find` (Woodstar found, code read, granted
74 repository readable, path tricks refused, Moonbeam gets the access
75 card), `new_work` (created in oficina, refused outside, Change, Remove)
76 and `question` (422 outside the options, 409 stale and answered). All
77 slice 1 scenarios still green. Live variants assert no repository or
78 framework question and a project or access card.
79
806. Chat page: cards under the message that ends their turn (Added /
81 Working in / Created with Change or Move and Remove; question options or
82 a text answer; access card with the grant command), posted in the
83 background; the thinking line shows the latest activity label with a
84 shimmer (static with reduced motion) and counts up in seconds from the
85 send, and the first streamed text replaces it; the chat is sized to the
86 visual viewport and re-pinned on viewport and composer resizes while
87 following, never while the person reads back. The old composer's "Any
88 project" picker is removed. Browser test at 390 px.
89
907. Guards observed failing when broken (mutation checks): allowlist,
91 ended turn, call-id replay, created-without-authorisation, create
92 namespace, card revision, owner-only projects API, read path cleaning,
93 visual viewport sizing, no-yank, reduced motion, streaming hides the
94 line.
95
96## Read tools: v1 decision (controller, 2026-11-07)
97
98`search_code` and `read_file` run git on the runner's own bare clone,
99outside the model's namespace; the model never gets filesystem access.
100Accepted for v1 with this hardening (`readGit` in
101`internal/runner/thin/index.go`):
102- Read-only plumbing only, at one commit resolved per call
103 (`rev-parse HEAD^{commit}`): `grep --no-textconv --no-ext-grep`,
104 `ls-tree`, `cat-file -t/-s/blob` by object id (no path, so no
105 attributes, filters or textconv can apply). No `show`, no checkout.
106- Command-line overrides, which outrank the clone's own config:
107 `core.hooksPath=/dev/null`, `core.fsmonitor=false`, `diff.external=`,
108 `core.attributesFile=/dev/null`, `protocol.allow=never` (no network),
109 `credential.helper=`, `core.sshCommand=/bin/false`, auto maintenance
110 off. Environment: `GIT_CONFIG_NOSYSTEM=1`, `GIT_CONFIG_GLOBAL=/dev/null`,
111 `GIT_TERMINAL_PROMPT=0`, `GIT_NO_LAZY_FETCH=1`, `HOME=/nonexistent`,
112 `GIT_DIR` and `GIT_CEILING_DIRECTORIES` pinned to the clone.
113- 20 s per command, 1 MiB of output, files over 1 MiB refused, tool
114 output clipped to 16 KiB; paths cleaned (no `..`, no leading `-`, no
115 `:`); symlinks reported as links and never followed; submodules not read.
116- `TestReadToolsHostileRepository`: a repository whose attributes ask for
117 filters and textconv, whose clone config sets filter, textconv,
118 external diff, fsmonitor, hooks path, pager and `attr.tree=HEAD`, with
119 hooks installed and symlinks pointing out of the clone, runs nothing
120 and reads nothing outside the clone. Mutations observed failing: grep
121 with `--textconv`, a path-addressed `show --textconv`, following
122 symlinks. The hook and fsmonitor overrides are defence in depth: read
123 plumbing on a bare clone never triggers them, so no test can observe
124 them failing.
125
126## Repository creation (Paul's rule 3)
127
128Checked as the runner's agent `equipo-docs-t1~paul@keymail.dev` with its
129bearer from the runner's credential file, never printed: `GET
130/api/v1/repos` lists 16 writable repositories, all in `oficina`; a
131`POST /api/v1/repos` with an invalid name in `oficina` returned 400 on
132the name (the hub checks writer rank first), so the agent may create
133repositories in `oficina`. Nothing was created. One git password and
134one API bearer serve every repository of the agent.
135
136So "Created" works today for Oficina-related work. Unrelated new work
137needs a home namespace the agent is granted. Proposed name: `equipo-work`
138(Paul creates it and runs `amadan agent grant equipo-docs-t1
139equipo-work`; then set `EQUIPO_RUNNER_HOME_NAMESPACE=equipo-work` on the
140runner). Until then unrelated new work goes to the best-fitting existing
141repository with Change. Created repositories are recorded in the runner's
142state directory, never written into the credential file.
143
144## Review round 1 (Astra at b90ac60, REQUEST CHANGES)
145
146Each fix has a test that failed first (or, where the first failure was a
147compile error, a mutation observed failing):
1481. Tool replays: a repeated call id is answered from the store only for
149 the same turn, attempt, tool and arguments (hash), and only after the
150 turn is checked again for this primary runner (running, same
151 attempt). A stored create authorisation replayed after the turn ended
152 gets `turn_ended`; after owner-to-member demotion the runner is no
153 longer primary and gets nothing back (`TestToolReplayRevalidates`).
154 Migration 0038 adds `attempt` and `args_hash` to `chat_tool_calls`.
1552. Repository creation: the runner keeps each create call's progress
156 (`creations` in its state); a resent call never creates again, and
157 before creating it asks the hub afresh whether the repository exists
158 (an earlier answer was lost) and adopts it. `fileForge.Create` also
159 re-checks after a failed POST (`TestCreateProjectIsIdempotent`).
1603. Answers: the card points at its answer inside `send`, before the
161 message can be dispatched, so the coordinator gets the question (or
162 the replaced project) with an answer dispatched at once
163 (`TestAnswerDispatchCarriesContext`).
1644. Page refreshes run one at a time (a request during one runs once
165 after it) and a page with an older cursor than the one shown is
166 dropped (`TestBrowserRefreshRace`: a slow stale page no longer undoes
167 the newer one; either mechanism alone holds, removing both fails).
168Minor: a stale revision on an actionable project card (added, working,
169created) is `card_stale`; done cards are `card_answered`
170(`TestProjectCardStaleRevision`).
171
172Added (Paul): the team setting "New projects go to …" (`chat_settings`
173key `project_home`), shown as `home` in `status` and `GET /projects`,
174set or cleared by the coordinator's `set_project_home` tool only when the
175person asks, only to a namespace in the runner's `create_in`. Unset, the
176coordinator uses the best-fitting existing repository with Change (a
177local repository with a later "Publish to …" is not built). No namespace
178is created. Tests: `TestProjectHomeSetting`, headless `2_project_home`.
179The house rule version moved, so sessions restart on the new rule.
180
181Staging after review 1 (release bdbb99c, 14 live turns): the full run
182passed scenarios 1, 3, 6, 7, 8 and cancel; `runner_crash` failed in the
183test only: the edge answered 502 to both runners for about 4 s at
18410:05:39, the suite's event stream dropped, and that session did not
185reconnect, while the crashed turn did recover (attempt 2, replied 30 s
186after the kill). The slice 1 scenario sessions that do not manage their
187own stream now resume from their cursor like a client (test code only).
188A second run of `runner_crash`, `2_project`, `2_find` and `2_new_work`
189on bdbb99c passed (4 turns). `make staged-check` refuses bdbb99c: the
190record needs one uninterrupted full run (about 13 live turns).
191
192## Decisions
193
194- Cards carry fixed fields for every kind (no optional objects) so one
195 shape serves the fixtures and native apps. For an access card
196 `question` is the name looked for, `options` the namespaces reached and
197 `choice` the agent's name.
198- Activity labels come from the instance's copy (`chat.activity.*`), so
199 native apps get them in the event; the runner sends names only.
200- The thin `POST /api/v1/projects` replaces the old project-form API
201 (spec §1); the old parity test now creates its project by the form.
202- Read tools run git on the runner's own bare clone (objects only: `git
203 grep` and `git show` on `HEAD`), not inside the model's namespace; the
204 model never gets filesystem access.
205
206## Staging
207
208The suite now runs as its own owner, `suite@equipo-staging.invalid`,
209added by the owner's session in `staging-thin.py signin` (no setup for
210Paul), with its own runner user unit and state root (both named in the
211script, beside the owner's), repository creation off. The owner's runner unit stays running for Paul, with creation on.
212Both read the production runner's forge credential file in place.
213
214Rehearsal runs (release b8158bb and before), 16 live turns:
215- The first live turn was refused at init: a tool with no required
216 input sent `"required": null`; fixed, and refused inits now log tool
217 and server names.
218- The hub answers 429 to a burst of one agent's git requests: the index
219 now waits 4 s between repositories (16 indexed, about a minute hourly).
220- All slice 1 scenarios and `2_project` passed live: "Fix the README typo
221 in equipo." got "Working in equipo." with an Added card, no question.
222- `2_find` live behaved right (one line ending "Grant access", an access
223 card, no question) but the test's client missed the reply; the slice 2
224 scenarios now resume their stream from the cursor like a real client.
225 Activity labels for find, search_code, read_file and create_project
226 were missing; added.
227
228Final release 330e534 (built by `make release`, deployed, both runners
229installed), real Claude CLI 2.1.312, 30 live turns used in total:
230- Release 196e684: all slice 1 scenarios green live (cold 2.76 s, warm
231 1.02 s, cold resume 4.52 s in the rehearsal before it); `2_project`
232 failed: a resumed session answered "Working in equipo" from memory
233 without the `add_project` call, so no card. Fixed in 330e534 (house
234 rule version on the session; the rule asks for the call every time).
235- Release 330e534, slice 2 scenarios live, all green (3 turns):
236 - "Fix the README typo in equipo." -> "Working in equipo" card (fresh
237 session under the new rule), no question.
238 - "In Woodstar, the panes aren't slideable ..." -> "Woodstar isn't in
239 any of the repositories I can reach, which are all in oficina. Grant
240 access", one access card, no framework question.
241 - "Build a small website that introduces the Oficina suite." -> "I'm
242 working in suite. I can't create new repositories here, so I picked
243 suite because it's the shared repository for the whole Oficina
244 suite." with an Added card (the suite runner has creation off).
245- `make staged-check` refuses 330e534: the staged record needs one full
246 suite run on that release (about 14 live turns), which the 30-turn
247 budget did not leave room for.
248
249Where a turn's time went (real CLI). Instance and runner each measure on
250their own clock; the client measures from its POST.
251- Fresh session, cold process ("Fix the README typo", 330e534): client
252 commit 42 ms; queued (commit to runner ack) 35 ms; runner receipt to
253 stdin 2.1 s (process start, refresh and staging of the copy, lease);
254 first stream event 0.8 s; thinking 1.5 s; first tool 2.0 s; first
255 text 5.2 s; result 5.2 s. The client saw the first activity line at
256 3.7 s and the first text at 7.4 s.
257- Warm process: queued 34 to 65 ms; runner to stdin 0.2 s (lease round
258 trip through the edge and copy check); first event under 10 ms;
259 thinking 0.6 s; find 0.7 s; first text 1.6 to 4.1 s depending on tools.
260- Last text to committed message: under 30 ms on the runner every time.
261Where a turn's time went (rehearsal, real CLI, warm process):
262- "Fix the README typo in equipo": message commit to runner ack 55 ms,
263 runner receipt to stdin 219 ms (lease round trip and copy check),
264 first stream event 8 ms, thinking 622 ms, first tool 1.3 s, first text
265 7.0 s (the model read files first), result 7.0 s.
266- "In Woodstar ...": queued 58 ms, start 216 ms, first tool (find)
267 0.7 s, first text 2.3 s.
268- A turn right after a runner restart: start 6.4 s (process start,
269 refresh and resume), first text 1.4 s after stdin.
270Non-model delay found and fixed: the copy rotation before most turns
271(slice 1 cold 2.7 to 3.5 s against warm 0.9 s); the runner now rotates in
272the background within the idle window (`TestHeadlessPrewarm`).
273
274## Open issues
275
276- Staged record: one full staging suite run on the final release is
277 needed before `make staged-check` passes (about 14 live turns).
278- Paul's staging runner may create repositories in `oficina` for real
279 (it has creation on, as asked). The suite runner does not.
280- Both staging runners read the production runner's forge credential
281 file in place and index all 16 `oficina` repositories hourly, paced at
282 4 s; the hub's rate limit is shared with the production runner.
283- Home namespace for unrelated new work: not granted yet (proposal
284 `equipo-work`, above).
285- Unreachable names: the access card cannot say where a name lives
286 (the agent sees only granted namespaces); it shows the grant command
287 with a namespace placeholder.
288
289## Blockers
290
291None.
292