Repository navigation
factory: where an organization's workstream agents run, and the driver hand (W8 + E6 engine) - #2633
Merged
Merged
Conversation
santoshkumarradha
force-pushed
the
w2/w8-runner
branch
from
November 13, 2026 18:51
fff3c39 to
48655b4
Compare
santoshkumarradha
marked this pull request as ready for review
November 13, 2026 19:05
santoshkumarradha
force-pushed
the
w2/w8-runner
branch
3 times, most recently
from
November 13, 2026 20:39
4776a21 to
28162c6
Compare
…ne person drives each
The operator's agent_runner setting (driver | server) lives in /v1/settings:
everyone reads it, only the operator changes it, and agent_runners lists what
this server offers (driver today; server is absent until its runner lands).
PUT|DELETE /v1/workstreams/{id}/driver is a 90-second driver hand, so two
laptops never run one workstream's agent; the engine forwards it, the
setting and E2's spend route (factory.org_agent_runner*, factory.org_workstream_drive,
_let_go, _spend), and a held hand's 409 names its holder.
Assisted-by: CodeAF
Co-Authored-By: CodeAF <[email protected]>
Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
santoshkumarradha
force-pushed
the
w2/w8-runner
branch
from
November 13, 2026 20:53
28162c6 to
89bc533
Compare
ZeroPoint95
pushed a commit
that referenced
this pull request
Nov 24, 2026
…ne person drives each (#2633) Assisted-by: CodeAF Co-Authored-By: CodeAF <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lane W8 + the engine half of E6. Owner decision WAVE2.md §4.3: the operator chooses where an organization workstream's agent runs,
agent_runner: "driver" | "server".What landed
agent_runnerinGET|PATCH /v1/settings. Everyone reads it. Only the operator may change it (the PATCH was already operator-only).agent_runnerslists the choices this server offers. Today that list is["driver"]. Choosingserveris refused with 422 ("this organization's server cannot run agents yet…"), so the option does not appear on the desk instead of failing there. A store written before this change reads asdriver.PUT /v1/workstreams/{id}/drivertakes the hand, or renews it when the caller already holds it. It answers{handle,since,until,ttl_s}, and the hand lapses 90 s after its last renewal. While someone else holds it, the answer is 409{"error":"santosh is driving this workstream's agent","driver":{…}}.DELETElets go; the holder, the workstream's owner (govern) or the operator may do this. Only people who can write the workstream may drive, and none may drive an archived workstream or one in an org set toserver.Workstream.driveris set while the hand is held. Taking and letting go publishworkstream.changed. Hands are kept in memory, so a restart works like a lapse. The caller is read through E1's access core (rebased on factory: one access core for every organization item (E1, part 1) #2632).org_agent_runner):factory.org_agent_runner,factory.org_agent_runner_set,factory.org_workstream_drive,factory.org_workstream_let_go,factory.org_workstream_spend. The spend method forwards to E2'sPOST /v1/workstreams/{id}/spend {usd,job?,chat?}withIdempotency-Key. The contract was agreed with E2: the server stampsby, and the param struct is defined here only. A held hand's refusal isconflictwithdetail {reason:"driving", by:"@handle"}.OrgRequest.IdempotencyKeyis new.docs/design/app-v3/PROTOCOL.md; change entry2633-org-agent-runner.md. WAVE2.md §4.3 is edited in place (~/work/teams-wave/WAVE2.md, outside the repo) under "Wire as built (W8/E6 engine)".Proof
internal/factory/serve/workstream_driver_test.gouses the real handler with the org fixture (owner/operator, santosh, abir, mia). It proves: abir reads the setting; abir's PATCH is 403; the operator'sserverand garbage choices are 422 anddriveris 200. santosh takes the hand; abir gets 409 naming santosh and seesdriveron GET. mia cannot let go (403); the operator can. Renewing keepssince. A lapse after 91 s lets abir take the hand. Someone who cannot see the workstream gets 404; someone who sees it but cannot write gets 403.cmd/codeaf/appfactory_org_runner_test.gocovers the engine over a stub org: the hello word, the older server's default, the forbidden pass-through, thedrivingdetail, and Idempotency-Key on spend. E2's route landed in factory: a workstream's parts live on the organization server (SQLite, per-page revs, versions) #2639, so a spend now counts on the server.make pr-ready BASE=<origin/work/teams>is green. Three tests failed and then passed on re-run (TestAppChatsOlderCopyStaysLocalL1,TestAppDevicesV1OldRelayPresenceIsUnknown,TestFactorySetupContinueEndsReadingWithoutWatchingUnreadRepos). This change does not touch the code any of them test.Server mode: what is still needed (not in this PR, deliberately absent)
PUT|DELETE /v1/org/keys/{provider}, plus a GET that answers only provider, last-4 and set-at. Keys sit in the server's vault (internal/keyvaultshape) and never travel to a desk.codeaf factory servehosts oneinternal/sessionagent per workstream, in a per-workstream folder under the server's data dir, using the org keys and the workstream's pages as context. One runner per workstream replaces the driver hand.GET /v1/workstreams/{id}/agent?since=(transcript),POST …/agent/messages, andPOST …/agent/stop. Events areagent.entryandagent.state, relayed likefactory.org_changed, with E1 access:editto send,viewto read.by(a bodybyis refused with 422), and puts the asker inchat.agentRunners()returns["driver","server"]once (1) has a key and (2) is built. The desk's Segmented control then appears for the operator with no desk change, and the desk adds a server-chat panel.