oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Slice 4c progress: the coordinator merges
2
3Branch `thin-v1-slice4c` from `thin-v1-slice4b` (a0d418f). Spec:
4`docs/superpowers/specs/2026-11-06-equipo-thin-v1.md` §§3, 4, 5, with
5Paul's ruling of 2026-11-07 overruling "Equipo never merges": "'Open on
6Amadan to merge' ... I'm not doing the merging. The co-ordinator should
7be doing that, or tasking someone to do it." Equipo merges its own work
8once it has earned Ready to merge. Conventions and scripts as in
9`SLICE1-PROGRESS.md` to `SLICE4B-PROGRESS.md`.
10
11## Amadan's merge API and the agent's permission
12
13- API: `POST /api/v1/repos/{ns}/{repo}/branches/{name}/merge` (the
14 `amadan branch merge` twin, hub `internal/hub/branch_merge_api.go`),
15 bearer token, body `{expect_sha, message, keep_branch, strategy,
16 agent: {session, harness, host}}`. Answers `200 {merged, sha, into,
17 branch_closed}` or a refusal `{error, reason[, ci_state]}`: `moved`,
18 `conflicts`, `ci_not_green`, `up_to_date`, `no_such_branch`,
19 `archived`, `no_expect_sha`, 403/404. The hub's repository instance
20 compares `expect_sha` with the branch under its git lock, so a branch
21 that moved is refused, never merged.
22- Strategy: the hub's default, `merge` (a real two-parent merge commit;
23 the CLI sends it unless `-squash`, and the hub records a landing by
24 ancestry). The branch is deleted after the merge (the hub's default,
25 `keep_branch: false`); its page, tasks and discussions stay.
26- Permission (no merge made): the route needs writer role on the
27 repository (`discussAPIActionGate(roleWriter)`); an agent grant's role
28 `agent` ranks with writer (hub `gitRoleRank`, repod `roleRank`). Live,
29 with the runner's forge credential (`equipo-docs-t1~paul@keymail.dev`,
30 namespaces oficina and woodstar): `GET /api/v1/repos` lists
31 oficina/suite and woodstar/woodstar as writable, and a merge request
32 with an empty `expect_sha` on a branch that does not exist passed the
33 role gate and the agent-session check and was refused only with `400
34 no_expect_sha` (the hub refuses that before contacting the instance)
35 on both. The agent may merge in both namespaces; nothing is missing.
36- A repository may require a green Amadan CI run on the commit
37 (`require_green`, not readable through the API): the merge is then
38 refused `ci_not_green` until Amadan's own CI passes. Amadan CI runs on
39 Equipo's task branches (both suite branches show "CI passed").
40
41## Done
42
431. Contracts (`internal/wire/tasks.go`, fixtures): stage `merging`
44 (between `ready_to_merge` and `done`); specialist `merge`; strategies
45 `merge` and `squash`; Needs you `merge_conflict`; `MaxRebaseRounds` 1;
46 card kind `merge` with choices `merge` and `wait`; `Step` gained
47 `rebase`, `merge_sha`, `into`, `strategy`, `without_checks`; `Task`
48 gained `merged {sha, into, strategy, without_checks, at}` (null until
49 Equipo merged it; a person's merge leaves it null) and `reports`;
50 `DispatchCommand` gained `rebase`, `from_base`; `StepReport` gained
51 `merge_sha`, `into`, `strategy`; step reasons `merge_conflict`,
52 `branch_moved`, `amadan_ci_pending`, `amadan_ci_failed`,
53 `merge_forbidden`, `merge_failed`; tool `add_report`; `ValidBranchName`.
54 New fixtures `api/task-merged.json`, `api/card-merge.json`; task,
55 step, dispatch and needs-you fixtures gained the fields. Events go to
56 active members as before; the merge card and the merged line only to
57 the creator's conversation.
58
592. Forge (`internal/runner/forge/merge.go`), the only holder of the
60 Amadan credential: `HubMerge` (the request above, the agent's bearer,
61 a 200 with a commit is the only success, an unreadable or 5xx answer
62 is uncertain) and `MergeBranch`, record-then-reconcile like the push:
63 validate (repository, task branch never the default, a full SHA, the
64 person among the runner's owners); read the remote first (already on
65 the default branch: done, never asked again; the head not at the
66 judged SHA: `moved`, no request); record `requested`; confirm the
67 lease right before the request; a lost answer, `up_to_date`, `moved`
68 or `no_such_branch` is settled from the default branch; refusals map
69 to conflict, CI pending, CI failed, forbidden, failed. One record per
70 task and SHA, so a new attempt reconciles from it. Tests:
71 `TestMergeBranch`, `TestMergeBranchReconcilesALostAnswer`,
72 `TestMergeBranchRecoversACrash` (crashed after recording, landed or
73 not), `TestMergeBranchNeverMergesAMovedBranch`,
74 `TestMergeBranchRefusals`, `TestMergeBranchRefusesInvalid`,
75 `TestHubMerge` (path, bearer, body, answers).
76
773. Runner (`internal/runner/thin/mergestep.go`): the merge step runs in
78 the one step queue (never beside a write step): lease, then
79 `MergeBranch` with the remote read through one `ls-remote` (fetching
80 only when the tip is new) and the merge commit found on the default
81 branch's first-parent line. Uncertain: three tries with backoff. The
82 hub's CI still running: waited for (poll 15 s, up to 10 minutes). On
83 success the merge watch for that SHA ends without a report, so only
84 the step's report says it landed. A runner that dies mid-merge holds
85 the attempt and runs it again (the record settles it), never fails it
86 `runner_restarted`. Rebase round (`engineer.go`, `workspace.Rebase`):
87 the default branch's tip checked out, then the three-way merge of the
88 tip and the old candidate on the task's old base (`merge-tree
89 --merge-base`) replaces the tree, conflicted files carrying markers
90 and named in the prompt; Engineering resolves them; the runner commits
91 on the tip and pushes over its own earlier candidate. The merge's
92 agent block is `{session: equipo-<task>, harness: equipo, host:
93 <machine label>}`. Tests: `TestMergeStep`,
94 `TestMergeStepReconcilesALostAnswer`, `TestMergeStepRefusals`,
95 `TestRecoverStepsRerunsAMerge`, `TestTaskTreeRebase`;
96 `forgetest.Merge` is a hub-like local merge shared by the runner tests
97 and the headless forge.
98
994. Instance (`internal/equipo/chat/merge.go`, migration 0046): the
100 policy runs in `advance`, deterministic, never a model's call. Checks
101 passed and an approving verdict on the newest candidate with the
102 branch at it: Ready to merge (its own event), then a merge step for
103 exactly that SHA (stage Merging). Done only on the runner's report of
104 a confirmed merge of the dispatched SHA (merge commit, a plain branch
105 name, a known strategy, termination); the task records it and the
106 coordinator's line goes into the creator's conversation once
107 ("Merged [title](/tasks/id) into <project>.", or "... without
108 checks."). Checks `cannot_run` or `none`: no merge; one `merge` card
109 per SHA in the creator's conversation; only the creator answers
110 (another person's answer is 404, a stale revision 409); Merge
111 dispatches the merge labelled without checks, Wait leaves the task at
112 Ready to merge (a person may still merge on Amadan; slice 4's watch
113 makes it Done). A new candidate or the task's end resolves an open
114 card. A refused merge: `merge_conflict` sends Engineering one rebase
115 round (the new candidate invalidates checks and review and is judged
116 from the new base); a second conflict is Needs you `merge_conflict`;
117 any other refusal (branch moved, Amadan CI, forbidden) leaves Ready to
118 merge with the reason and Retry, which is refused unless the SHA is
119 still the judged one as it stands. No automatic re-merge after the
120 branch moves and comes back (Retry does it). Cancel is not offered
121 while merging. Tests: `TestContractAutoMerge`,
122 `TestContractMergeWithoutChecks`, `TestContractMergeConflictRebase`,
123 `TestContractMergeRefusedAndRetry`, `TestContractDuplicateReports`;
124 `TestContractReviewAndChecks`, `TestContractBranchMovedInvalidatesReadiness`
125 and the pages tests now end in Equipo's merge (a person's merge while
126 Merging still makes it Done).
127
1285. Duplicates: `record_task` first looks for open tasks in the same
129 project that read like the report (significant words of title and
130 brief: title overlap at least 0.6 with two shared words, or title and
131 brief overlap at least 0.5 with three) and returns up to three as
132 `similar` without recording; `separate: true` records anyway.
133 `add_report(task, text)` puts the report on an open team task's thread
134 (`reports` counts them) and shows the task card in this turn. House
135 rule 2026-11-07.9: Equipo merges once checks and review pass (the
136 person is never asked to merge); never file the same problem twice.
137 The launcher's own allowlist of conversation tools gained
138 `add_report` (`TestConversePolicyCoversEveryTool`: it lagged once and
139 every coordinator start failed `policy_rejected`).
140 `TestOpeningReusesOpenTasks`.
141
1426. UI (kept minimal, Fable is redesigning the inner screens): stage
143 "Merging…"; done shows "Merged into main at abc1234" (", without
144 checks") with the quiet "Open on Amadan" link to the repository (the
145 branch link goes, the branch is deleted); "Open on Amadan to merge"
146 and its copy are removed; the merge card (Merge, Wait for checks; then
147 "Merging without checks." or "Waiting for checks.") stands in the
148 conversation at its own time; Stopped lines for the merge reasons;
149 the step list names Merge and "(rebase)".
150
1517. Headless (fake CLI in real bwrap, local forge with `forgetest.Merge`):
152 `4_review` now ends merged by Equipo (merge commit on main, second
153 parent the candidate, branch gone, the line in chat);
154 `4c_checks_card` (an iOS change: card; the branch moves and back;
155 Wait, then the person merges on the forge; the next task Merge, merged
156 without checks); `4c_rebase` (main changes the same line during
157 review: conflict, one rebase round on the new tip, judged again,
158 merged); `4c_duplicate`; `4b_ask` now asks while its task waits on a
159 merge card (an iOS change), since a merged task forgets its sessions.
160 `4c_witness` is staging only (`EQUIPO_STAGING_MERGE_WITNESS`).
161
1628. Mutation checks (ten, each observed failing a test unless noted):
163 auto-merge of unchecked work, a merge report for another SHA, Retry
164 of a merge while the branch is away, unlimited rebase rounds, no
165 duplicate check, forge without the landed check first, forge merging
166 a moved head, the merge watch kept after a merge, a crash failing the
167 merge. Survived, as defence in depth: the merge card's stale-SHA check
168 (the Ready to merge stage check refuses first, and a new candidate
169 resolves the card).
170
1719. Merged `thin-v1-slice4b` round-1 fixes at 56a623b (ask output bounds,
172 ask termination proof, ReportAnswer retry, git_show range): clean.
173
17410. Review round 1 (Astra 4c, REQUEST CHANGES, three Important and one
175 Minor), the 4b round 2 findings and Paul's request. Each fix has a
176 test that failed without it (one mutation per fix, all observed
177 failing):
178 1. No cancel while merging: the API (409 `task_merging`), the page
179 and the coordinator's `cancel_task` (refused `merging`) refuse it;
180 the runner settles a merge from its record and the default branch
181 whatever the step's context, so a lost answer ends Done.
182 `TestContractCancelRefusedWhileMerging`,
183 `TestMergeStepSettlesDespiteCancel`.
184 2. Not retroactive: a candidate is eligible to merge on its own only
185 if it first earned Ready under the policy with checks passed
186 (`ready_sha`, `merge_eligible`, migration 0047; the migration marks
187 candidates already Ready, or moved away from Ready, ineligible).
188 Leaving Ready and coming back grants nothing. An ineligible
189 candidate gets one card, "Merge <title>?" with Merge and Not now;
190 Merge adopts it. `TestContractNoRetroactiveMerge` runs 0047's own
191 statements on a Ready task.
192 3. The hub's CI wait releases the queue: the merge step is deferred
193 (`not_before`, `deferred_since` on the runner's steps) and due
194 again after 15 s; other steps and questions run meanwhile; each
195 resumption runs afresh (lease, owner, judged head). Past ten
196 minutes it ends `amadan_ci_pending`. `TestMergeCIWaitReleasesTheQueue`
197 (and the branch moving while it waits: `branch_moved`, no merge).
198 4. The branch moving gives an open merge card a new revision; an
199 answer from before the move is 409 once it is back.
200 `TestContractMergeCardStaleAfterMove`; `4c_checks_card` answers
201 with the refreshed revision.
202 5. (4b) Nothing is dispatched while a step or question waits for its
203 namespace's exit to be verified; the worker looks again every 5 s.
204 `TestNothingRunsBesideAnUnverifiedExit`.
205 6. (4b) The namespace is written before launch (containment's record
206 callback); a record that cannot be written launches nothing. A held
207 answer with no namespace is released only when no namespace of the
208 runner remains. `TestNamespaceRecordedBeforeLaunch`,
209 `TestHeldAnswerWithoutNamespaceNeedsVerification`.
210 7. Paul: a done task's specialists can be asked for 14 days
211 (`done_at`); `forget_task` carries `keep_until` and the runner keeps
212 the sessions until then (`expires_at`), the sweep removes them
213 after; a cancelled task forgets at once.
214 `TestContractAskImplementer`, `TestContractCancelledTaskForgetsNow`,
215 `TestForgetTaskKeepsMergedSessions`; headless `4b_ask` asks after
216 the merge.
217 New copy (accepted for now, in the inventory): `chat.card.merge_adopt`
218 "Merge %s?", `chat.card.not_now` "Not now",
219 `chat.card.merge_chose_not_now` "Not now.". Fixture
220 `frames/forget_task.json` gained `keep_until`. No live run (the
221 staging account's weekly limit).
222
22311. Review round 2 (Astra 4c: the four findings resolved, three new),
224 each with a test that failed first:
225 1. Not now is not final: a task left at Ready to merge (Not now, or
226 Wait for checks) offers its creator a quiet Merge (task card and
227 page; `POST /api/v1/tasks/{id}/merge`, `Task.merge_offered`),
228 validated afresh (Ready, the branch at the judged SHA, no merge yet,
229 no card open); checks passed records eligibility at that moment.
230 Teammates get 403; away from the SHA, 409 `not_mergeable`.
231 `TestContractNoRetroactiveMerge`.
232 2. A merge's explicit expiry overrides idle expiry: a session last
233 used ten days before the merge lasts the 14 days from it.
234 `TestMergedSessionOutlivesIdleExpiry`.
235 3. The task page asks the implementer on a done task within its 14
236 days, like the API (`Task.ask_open`). `TestContractAskImplementer`
237 (page), browser `TestBrowserAskAfterMerge`;
238 `TestBrowserTaskThread` now asks on the merged task.
239 New copy: `work.merge_now` "Merge". Fixtures gained `ask_open` and
240 `merge_offered`.
241
242## Decisions
243
244- The merge is a step (specialist `merge`) in the runner's one queue: it
245 reuses dispatch, durable reports, sync, attempts and Retry, and never
246 runs beside a write step. Nothing runs in a namespace, so its reports
247 always carry termination.
248- Strategy: the hub's default merge commit, recorded on the task and the
249 step. The branch is deleted by the hub (its page stays).
250- "Checks passed" means `passed`. `none` (no gate found) is treated like
251 `cannot_run`: the person is asked with the card.
252- Wait is final for that SHA's card: the task stays at Ready to merge
253 (checks pending); the person may still merge on Amadan.
254- After the branch moves away and back, Equipo does not merge again on
255 its own: Retry does, after re-checking the SHA (avoids a merge loop
256 while the watch and the merge race to report the head).
257- The coordinator's merged line is written by the instance (no model
258 turn), in the creator's conversation only, once per task.
259- A person's report of the same problem goes on the open task's thread
260 as a `report` entry (any team member may add one to an open task); an
261 ended task is never offered as similar.
262
263## Staging
264
265Release d521a44 (built by `scripts/staging-thin.py build`, deployed with
266`--swap hold` at 22:54:42, serving 22:55:48, both runner units installed
267by 22:55:49, about a minute of change-over).
268
269- Unapproved merges on the upgrade: the suite person's two earlier
270 witness tasks were at Ready to merge with checks passed and approval
271 (`tk2jhc6z46ar` from slice 4, `tkgzy4ioeoh7` from slice 4b). The new
272 policy merged both on the suite runner's first sync, 22:55:49 and
273 22:55:50, into oficina/suite main (c758267, then cebae9f; README only:
274 the line break and the em dash fix, each judged on its SHA). Only the
275 witness task was approved for merging. Not reverted: reverting means a
276 push to suite's main, which needs Paul's or the controller's word.
277 Woodstar is untouched (its main moved only by Paul's own commits): its
278 three tasks' checks cannot run, so they wait at Ready to merge with a
279 merge card (Paul's `tkf6dufnbzcg` in his conversation, the suite's
280 `tklkbx5vid3y` in the suite's), or at Needs you retry (`tks6kwzzdngr`).
281 Production starts from a fresh database, so the cutover has no such
282 backlog; a deploy onto a database with ready tasks merges them.
283- Witness (`4c_witness`, real Claude CLI 2.1.312, suite person, one
284 message): "In the oficina/suite README, the `server/` bullet says "the
285 producer half — the bearer check, the three routes, their wire shapes
286 and cache headers, and the cursor reset — that an app mounts". Please
287 replace those two em dashes with commas so it reads "...". Change
288 nothing else." Task `tkeog27odnoo` "Replace em dashes in README
289 server/ bullet": noted 5.4 s, in progress 12.0 s, Engineering 12.4 s
290 (candidate 37e72437), checks `.amadan/ci.d` passed 9.8 s, review
291 approved (`same_account`) 25.8 s, Ready to merge 60.96 s, Merging
292 60.97 s, Done 61.62 s (the merge step 0.6 s). Merged into suite's main
293 as 98380bce (a merge commit, second parent 37e72437), branch deleted.
294 The coordinator: "Merged [Replace em dashes in README server/
295 bullet](/tasks/tkeog27odnoo) into Suite." (no SHA, no path).
296- Checks that could not run: the card flow ran headless with the fake
297 CLI (`4c_checks_card`, both Wait and Merge). On staging the card is
298 live on the Woodstar tasks (`c_z5fbtn2e5fbrnppubttv665eae`, "Merge iOS
299 edge swipe to go back doesn't work on panes without checks?", options
300 merge and wait); nobody answered it.
301
302## Live runs (budget: 3 coordinator turns, 2 Engineering steps, 2 Review steps)
303
304Used: 1 coordinator turn, 1 Engineering step, 1 Review step (task
305`tkeog27odnoo`). The two unapproved merges spent no model run (merge
306steps only).
307
308## Open issues
309
310- The two unapproved merges above: the controller decides whether to
311 revert them on oficina/suite.
312- Amadan's `require_green` is not readable through the API; a merge
313 waiting for Amadan's CI is deferred for up to 10 minutes before it
314 reports `amadan_ci_pending`.
315- Version skew as before: an old runner refuses a `merge` dispatch;
316 install runners right after the instance.
317- The squash-merge detection of slice 4 still serves people's merges.
318
319## Copy for review
320
321Accepted for now with the existing marker in `copy.go` and listed in the
322plan 3 inventory:
323- `work.stage.merging` "Merging…"
324- `work.merged` "Merged into %s at %s", `work.merged_without_checks`
325 "Merged into %s at %s, without checks"
326- `work.specialist.merge` "Merge", `work.rebase` "rebase"
327- `work.needs.merge_conflict` "Needs you: it still conflicts with the
328 default branch after a rebase"
329- `work.reason.merge_conflict` "it conflicts with the default branch",
330 `.branch_moved` "the branch moved on Amadan", `.amadan_ci_pending`
331 "Amadan's own CI had not finished", `.amadan_ci_failed` "Amadan's own
332 CI did not pass", `.merge_forbidden` "Equipo may not merge in this
333 repository", `.merge_failed` "Amadan did not merge it"
334- `chat.card.merge_question` "Merge %s without checks?",
335 `chat.card.merge` "Merge", `chat.card.wait` "Wait for checks",
336 `chat.card.merge_chose_merge` "Merging without checks.",
337 `chat.card.merge_chose_wait` "Waiting for checks.",
338 `chat.card.merge_resolved` "Nothing to decide any more."
339- `chat.merged` "Merged [%s](%s) into %s.", `chat.merged_without_checks`
340 "Merged [%s](%s) into %s without checks."
341- `chat.activity.add_report` "Adding to the task…"
342- Removed: `work.merge` "Open on Amadan to merge".
343
344## Blockers
345
346None.
347