Apply groups run one at a time while trogdor could serve three: run the independent ones side by side, each in a worktree of its own #172
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Split off from #170 (task 10, its second part), and part of #128. To follow #171: it needs opencode 2's per-session environment, below.
Why
Run 62 spent 376 minutes applying eight groups on one stream, while trogdor serves a second and third stream at nearly the same speed (47 tok/s alone, 47 with one more, 41–43 with two or three). With #170,
tasks.mdsays which group depends on which (Depends on:lines, recorded in.osf/budget.json): in run 62, physics (3) and the renderer (5) needed only groups 1 and 2, and could have run side by side.They cannot just start together in the run's worktree. That was tried: group 2 found group 1's work missing and redid it in the same files, and a rollback of one takes the other's files with it.
The plan
The OpenSpec change is written and validates:
openspec/changes/parallel-apply-groups/(proposal, design, specs, tasks).runs/<n>/groups/<key>/), cut from the run's worktree as it is then. Its session, checks and checkpoints use that worktree, so a redo rolls back only it.tasks.mdticks merged line by line and Braid's.osf/records kept from the run unless only the group wrote one.Measured on opencode 1.18.35 (2026-10-16)
One server started in the run's worktree, a session created in a linked worktree:
GET /session/{id}names it;GET /session/status?directory=<its worktree>. Asked with the run's worktree, asstep_complete, the watchdog and the question poll ask today, the map is empty while it works: a group step would be taken as finished at its first quiet moment;GET /event?directory=<its worktree>, so each group needs a firehose of its own;And
git merge-treeon the production image (Debian bookworm, git 2.39.5) has--write-treebut not--merge-base(git 2.40): the merge gives both snapshot commits the group's base as their parent instead.Why after #171
PREVIEW_PORTis in the run's opencode server environment, so every session of a run, every shell command in it and theapptool share one port. Two groups at once that each serve the app or run browser tests would take the same port, and most runs are web apps. opencode 1.x has no per-session environment. opencode 2 hasPUT /api/session/{id}/environment, which sets the environment of a session's shell commands, so each group can have a port of its own there. The directory-scoped reads above are also exactly the API #171 rewrites.Done when
Shipped in three deploys on 2026-10-17: part A in
2cc4a20(08:56Z, migration 15, backed up first), part B in6dda289(11:27Z), and Auto infdd6c70(23:28Z). Archived in OpenSpec asparallel-apply-groupsin874eb27.What shipped
fbbd046):POST /api/runstakeschange. Admission checks that the change is on the base branch, and cuts the explore, propose and review steps out of the run's graph. The run'schangeis a column (migration 15).a163182,50c7be5; review fixes55d09ca,acc1426,b2971aa,bc803b0):openspec.apply[all]does every task in one session and compacts in place at its alarm. It has one deadline (the node's limit times the groups) and a progress bound: two compactions in a row with no task ticked fail it.0aafc75): each group works in a worktree and branch of its own, at most three at once, each with its own port, compose project and app. A group is merged back withgit merge-treeonce its checks hold, withtasks.mdticks merged three-way. A conflict goes to the group's own session, three tries, then to a person. It is labelled experimental.5d9ede4,89c7503, merged0ab8a6): one step when a session's context is at least 200,000, group by group below that. One step and group by group can be forced; side by side is used only when chosen, never by Auto. The run bar says which was chosen.The comparison. The subject was
scale-recipes-and-shopping-liston the combined test repository: five groups, with 2 to 4 depending on 1 and 5 on 2 to 4. Each arm was a thorough run on a base branch of its own, with its own auto-approve off; the lead's watcher answered its merge and archive gates. The context per agent, as the runs' records give it: 400,000 for the groups arm and both parallel arms (their apply steps' budget allowance of 394,000), and 90,000 for run 73 (its alarms at 67,500). The single arm's records do not carry its context per agent.A blind review scored the four diffs, labelled P to S, and the labels were revealed after scoring. Groups 4.38, single 4.00, first parallel 3.38, second parallel 3.25 (out of 5). All 47 scenarios pass in all four, and none has a blocking code-review finding. The second parallel run lost points on four things: 40 ties rounded wrong, the servings read with
Number(), the shopping list computed in the view, and a Servings box 224 px tall that its judge missed.The decision rule counted the second parallel run as the parallel arm:
The result was close, though: 10% more wall clock for single would flip the recommendation to groups. So the rule called for one more run of each of those two arms. That repeat was not run. On 2026-10-17 the operator turned the choice into a rule: Auto is the default, and applies in one step at 200k of context or more, else group by group.
Checked on production
fdd6c70) recordedapply_choiceas{mode: single, setting: auto, context: 400000, one_step_at: 200000}, and its run bar read "thorough · auto: one step (400k context)".86dc37f) used run 73's settings with #185 and #186 in: 79.3 min against 109.9, 5.98M prompt tokens against 10.75M, and no respawn. #186 gets the details once its change is archived.Not done
POST /compactbefore the arms (task 10.3). Runs 73 and 74 measured the apply step's compactions instead: from 2 min 1 s to 2 min 50 s each, from the alarm to the compacted record./api/slots, and/healthzand/api/statusat its start and end. The steps' claims show each arm stayed on one osfd boot.questiontool to say it was waiting for its browser subagent, and the arm's watcher answered it. Nobody checked whether auto-approve answers an agent's question when no one is watching.Part B's merge had also dropped three blank lines in
src/osf/engine/scheduler.py;4ad5b90restores them.Auto is now the default. The operator can change it in Settings → Apply the change. Closing.