roomcity host: drive Claude Code and report its frames #7

Merged
mikluko merged 4 commits from host into main 2026-11-16 04:54:56 +00:00
Owner

spec-bb1.34, the host. Stacked on #3 and #4: until they merge the diff shows their commits; this one is 620170a.

roomcity host (internal/host): claudeacp v0.6.0 (the fork's latest tag) as a library in the host's process; the host is its ACP client over two pipes. Every line passing a pipe is a frame (seq from 1, time, direction), reported by HostService.Report until acknowledged. Attach carries the instructions: Prompt is a turn (one at a time), Cancel is session/cancel and drops waiting prompts, PermissionAnswer releases the pending session/request_permission named by its JSON-RPC id, Stop ends the host. A lost attachment is opened again with the last instruction taken; a server that answers unauthenticated ends the host with that error.

Tests, against an in-process HostService and a scripted claude (claudetest): a Prompt becomes a turn whose frames reach the server contiguous and in order; Cancel ends a running turn (cancelled); a permission request waits and is answered; a dropped attachment is taken up again naming instruction 1, no prompt runs twice; five failed Reports are sent again, no frame lost or doubled; a wrong token ends the host. -race -count=8 passes. Real claude, by hand on Haiku (ROOMCITY_REAL_CLAUDE=1 go test ./internal/host -run TestRealClaude -v, skipped otherwise): one prompt, pong, 15 frames, end_turn; run twice.

Also: GOPRIVATE=sarak.sh in the test workflow and the image build, since claudeacp is on this Forgejo; Renovate will need access to it to move the pin.

Decisions of mine, open: an instruction counts as taken when started, so a prompt in flight at a restart is not repeated; ROOMCITY_SETTINGS (optional) names a settings file passed to claude as --settings; the host does not steer a message into a running turn, it queues it.

Not done, on the ticket: what the pod must stage for gc's hooks and the role prompt (settings content, working directory contents) is not researched yet; whether gc prime --hook, nudge drain --inject and mail check --inject fire for prompts over ACP is not verified.

spec-bb1.34, the host. **Stacked on #3 and #4**: until they merge the diff shows their commits; this one is `620170a`. `roomcity host` (`internal/host`): claudeacp v0.6.0 (the fork's latest tag) as a library in the host's process; the host is its ACP client over two pipes. Every line passing a pipe is a frame (seq from 1, time, direction), reported by `HostService.Report` until acknowledged. `Attach` carries the instructions: Prompt is a turn (one at a time), Cancel is `session/cancel` and drops waiting prompts, PermissionAnswer releases the pending `session/request_permission` named by its JSON-RPC id, Stop ends the host. A lost attachment is opened again with the last instruction taken; a server that answers `unauthenticated` ends the host with that error. Tests, against an in-process `HostService` and a scripted claude (`claudetest`): a Prompt becomes a turn whose frames reach the server contiguous and in order; Cancel ends a running turn (`cancelled`); a permission request waits and is answered; a dropped attachment is taken up again naming instruction 1, no prompt runs twice; five failed Reports are sent again, no frame lost or doubled; a wrong token ends the host. `-race -count=8` passes. Real claude, by hand on Haiku (`ROOMCITY_REAL_CLAUDE=1 go test ./internal/host -run TestRealClaude -v`, skipped otherwise): one prompt, `pong`, 15 frames, `end_turn`; run twice. Also: `GOPRIVATE=sarak.sh` in the test workflow and the image build, since claudeacp is on this Forgejo; Renovate will need access to it to move the pin. Decisions of mine, open: an instruction counts as taken when started, so a prompt in flight at a restart is not repeated; `ROOMCITY_SETTINGS` (optional) names a settings file passed to claude as `--settings`; the host does not steer a message into a running turn, it queues it. Not done, on the ticket: what the pod must stage for gc's hooks and the role prompt (settings content, working directory contents) is not researched yet; whether `gc prime --hook`, `nudge drain --inject` and `mail check --inject` fire for prompts over ACP is not verified.
cmd: a command gets a context and its process's streams
All checks were successful
image / image (pull_request) Successful in 5s
test / changelog (pull_request) Successful in 4s
test / go (pull_request) Successful in 26s
e7b2613ae9
The commands are to read stdin and write stdout (the stand-in gc), end
with SIGTERM (the host) and read the environment; each had only stderr.
The context ends on SIGINT and SIGTERM.

Assisted-By: Claude <noreply@anthropic.com>
The stand-in gc and the server's GcService handler
Some checks failed
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Failing after 7s
test / go (pull_request) Successful in 25s
d0a359cd57
roomcity gc sends its arguments, stdin, GC_* environment and directory to
the server and ends with the code of what comes back; internal/gchandler
runs the real gc in the city's directory with the session's GC_*
variables, over the server's own environment, and takes nothing else from
the request. A gc that ends non-zero is an answer, one that does not start
is an error.

Assisted-By: Claude <noreply@anthropic.com>
A session proves itself to the server by its token
Some checks failed
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Failing after 7s
test / go (pull_request) Successful in 24s
bd8254420a
The stand-in gc sends the session's token, from ROOMCITY_TOKEN, as a
bearer token; the GcService handler runs gc only for a call whose token
the server's Authorize function says is the named session's, and with no
function refuses every call. internal/sessionauth is the header and the
client option the host uses too.

Assisted-By: Claude <noreply@anthropic.com>
roomcity host: drive Claude Code and report its frames
Some checks failed
test / changelog (pull_request) Successful in 8s
image / image (pull_request) Failing after 9s
test / go (pull_request) Successful in 47s
620170a676
The host starts claudeacp (v0.6.0) in its own process over two pipes and is
its ACP client; every line that passes either pipe is a frame, numbered
from 1 and sent to the server until acknowledged. Instructions come from
Attach: a prompt is a turn (turns run one at a time), cancel interrupts the
running one and drops those waiting, a permission answer releases the
request whose JSON-RPC id it names, stop ends the host. A lost attachment
is opened again with the last instruction taken; a server that refuses the
token ends the host.

claudeacp is on this Forgejo, so the workflow and the image build set
GOPRIVATE=sarak.sh.

Assisted-By: Claude <noreply@anthropic.com>
mikluko force-pushed host from 620170a676
Some checks failed
test / changelog (pull_request) Successful in 8s
image / image (pull_request) Failing after 9s
test / go (pull_request) Successful in 47s
to 7300bff5e4
Some checks failed
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Failing after 8s
test / go (pull_request) Successful in 39s
2026-11-16 04:47:48 +00:00
Compare
mikluko force-pushed host from 7300bff5e4
Some checks failed
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Failing after 8s
test / go (pull_request) Successful in 39s
to ee380c65c3
All checks were successful
image / image (pull_request) Successful in 3s
test / changelog (pull_request) Successful in 5s
test / go (pull_request) Successful in 32s
2026-11-16 04:49:21 +00:00
Compare
mikluko force-pushed host from ee380c65c3
All checks were successful
image / image (pull_request) Successful in 3s
test / changelog (pull_request) Successful in 5s
test / go (pull_request) Successful in 32s
to f2551a2fb2
All checks were successful
test / changelog (pull_request) Successful in 4s
image / image (pull_request) Successful in 7s
test / go (pull_request) Successful in 27s
2026-11-16 04:51:05 +00:00
Compare
Author
Owner

Review for spec-bb1.34, of f56901a and f2551a2. I ran go vet and go test -race ./...: green. The handler's guard for an empty session or token is right. On the question of a lost connection: an instruction is taken once (take drops a seq at or below the last taken, and an instruction cut off mid-stream is not taken, so it comes again), and a frame stays with the host until the server's answer covers its number. Nothing is dropped or doubled by a lost connection while the host lives. Not merged yet; three changes.

1. GOPRIVATE=sarak.sh is not needed, and its comment is not true.
The fork is public and both services already serve it:

proxy.golang.org/sarak.sh/mikluko/claudeacp/@v/v0.6.0.info    200
sum.golang.org/lookup/sarak.sh/mikluko/claudeacp@v0.6.0       200

With a clean module cache and GOPRIVATE empty, go mod download took the module from the proxy and go mod verify passed. What the variable changes for this repository's build: every sarak.sh module is fetched from Forgejo by git and is no longer checked against the checksum database, and a build fails whenever Forgejo is not reachable. Drop it from .forgejo/workflows/test.yaml and from the Dockerfile, with the two comments.

2. Cancel leaves a waiting permission request waiting.
cancel empties the queue and sends session/cancel; the RequestPermission call that waits for an answer goes on waiting. ACP asks the client to answer every pending session/request_permission with the outcome cancelled when it cancels the turn, and "The owner's input and control" has !stop withdraw an open request. Answer all of h.pending as cancelled in cancel, with a test: a turn stopped while its permission request waits ends with the request cancelled.

3. The prompt's source is thrown away, so the queue cannot keep the decided order.
take passes i.Prompt.GetText() and the queue is first come, first served.

spec-bb1.11, both waiting at a turn's end: the owner's first, gc's after
here: gc's nudge that came first runs first

Keep the source with each waiting prompt and put the owner's ahead of gc's. (Whether Cancel should spare gc's waiting nudges I have asked specs-18; leave it dropping everything until that is answered.)

For you and roomcity-b8 together, not changes here:

  • The frame count starts at 1 with each host process. #8 restarts its own count at a start afresh, so that case holds; a host restarted inside the same pod without a new start would have its frames taken for old ones and acknowledged away. Either the Job never restarts a container, or the host learns the stored number before it counts.
  • #8 records a prompt as Delivered when it is handed to the host, and the host then queues it. Until the host can say what it did with an instruction, Delivered in the seam means "sent to the pod", not "the agent has it"; the Waiting record needs the same word from the host.
Review for spec-bb1.34, of f56901a and f2551a2. I ran `go vet` and `go test -race ./...`: green. The handler's guard for an empty session or token is right. On the question of a lost connection: an instruction is taken once (`take` drops a seq at or below the last taken, and an instruction cut off mid-stream is not taken, so it comes again), and a frame stays with the host until the server's answer covers its number. Nothing is dropped or doubled by a lost connection while the host lives. Not merged yet; three changes. **1. `GOPRIVATE=sarak.sh` is not needed, and its comment is not true.** The fork is public and both services already serve it: proxy.golang.org/sarak.sh/mikluko/claudeacp/@v/v0.6.0.info 200 sum.golang.org/lookup/sarak.sh/mikluko/claudeacp@v0.6.0 200 With a clean module cache and `GOPRIVATE` empty, `go mod download` took the module from the proxy and `go mod verify` passed. What the variable changes for this repository's build: every `sarak.sh` module is fetched from Forgejo by git and is no longer checked against the checksum database, and a build fails whenever Forgejo is not reachable. Drop it from `.forgejo/workflows/test.yaml` and from the `Dockerfile`, with the two comments. **2. `Cancel` leaves a waiting permission request waiting.** `cancel` empties the queue and sends `session/cancel`; the `RequestPermission` call that waits for an answer goes on waiting. ACP asks the client to answer every pending `session/request_permission` with the outcome `cancelled` when it cancels the turn, and "The owner's input and control" has `!stop` withdraw an open request. Answer all of `h.pending` as cancelled in `cancel`, with a test: a turn stopped while its permission request waits ends with the request cancelled. **3. The prompt's source is thrown away, so the queue cannot keep the decided order.** `take` passes `i.Prompt.GetText()` and the queue is first come, first served. spec-bb1.11, both waiting at a turn's end: the owner's first, gc's after here: gc's nudge that came first runs first Keep the source with each waiting prompt and put the owner's ahead of gc's. (Whether `Cancel` should spare gc's waiting nudges I have asked specs-18; leave it dropping everything until that is answered.) For you and roomcity-b8 together, not changes here: - The frame count starts at 1 with each host process. #8 restarts its own count at a start afresh, so that case holds; a host restarted inside the same pod without a new start would have its frames taken for old ones and acknowledged away. Either the Job never restarts a container, or the host learns the stored number before it counts. - #8 records a prompt as `Delivered` when it is handed to the host, and the host then queues it. Until the host can say what it did with an instruction, `Delivered` in the seam means "sent to the pod", not "the agent has it"; the `Waiting` record needs the same word from the host.
host: cancel answers open permission requests, owner prompts go first
All checks were successful
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 10s
test / go (pull_request) Successful in 34s
8a174a2721
Cancel answers every open session/request_permission as cancelled, as ACP
asks of a client that cancels. A waiting prompt keeps its source, and the
owner's go ahead of those gc sent, behind the owner's own. GOPRIVATE is
dropped: the fork is public and the module proxy and checksum database
serve it.

Assisted-By: Claude <noreply@anthropic.com>
host: number frames after the last one the server holds
All checks were successful
test / changelog (pull_request) Successful in 5s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 35s
5549bf76fc
A host that starts again in a pod that had one before asked nothing, and
counted from 1; the server took its frames for ones it had. The host now
sends a Report with no frames first and numbers after the last_seq it gets.

Assisted-By: Claude <noreply@anthropic.com>
mikluko deleted branch host 2026-11-16 04:54:57 +00:00
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/roomcity!7
No description provided.