host: stage what the server hands over before the agent starts #10

Merged
mikluko merged 1 commit from stage-host into main 2026-11-16 04:58:37 +00:00
Owner

spec-bb1.34, the host's side of Stage. Stacked on #7 and the proto PR (this branch carries both commits until they merge). The host calls Stage once before it starts claude: files extracted under ROOMCITY_WORKDIR (a name or link that leaves it ends the host, as does a failing pre_start), manifest arguments added to claudeacp's ClaudeArgs, session_setup, the script and session_live run once the session is up and only logged when they fail. Tests: files, links, commands and --settings argument arrive; four kinds of escaping archive are refused with nothing written; a failing pre_start stops before claude is spawned. -race passes.

spec-bb1.34, the host's side of Stage. **Stacked on #7 and the proto PR** (this branch carries both commits until they merge). The host calls Stage once before it starts claude: files extracted under `ROOMCITY_WORKDIR` (a name or link that leaves it ends the host, as does a failing `pre_start`), manifest arguments added to claudeacp's `ClaudeArgs`, `session_setup`, the script and `session_live` run once the session is up and only logged when they fail. Tests: files, links, commands and `--settings` argument arrive; four kinds of escaping archive are refused with nothing written; a failing `pre_start` stops before claude is spawned. `-race` passes.
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>
gchandler: refuse an empty session or token before asking Authorize
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
f2551a2fb2
The gate no longer rests on what an Authorize function does with "".

Assisted-By: Claude <noreply@anthropic.com>
gc names the work dir, the settings file, overlays, copied files and setup
commands as paths and commands on its own host. The server reads them, and
the host asks for them once, before it starts the agent: a manifest, then a
tar stream.

Assisted-By: Claude <noreply@anthropic.com>
host: stage what the server hands over before the agent starts
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 8s
test / go (pull_request) Successful in 41s
15ef7c320a
The host extracts the archive under the working directory (a name or a link
that leaves it is refused, and the host ends), runs pre_start, passes the
manifest's arguments to claude, and runs session_setup, the script and
session_live once the session is up. A failing pre_start ends the host;
the later ones are logged. A server without Stage is taken to stage nothing.

Assisted-By: Claude <noreply@anthropic.com>
mikluko force-pushed stage-host from 15ef7c320a
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 8s
test / go (pull_request) Successful in 41s
to d5da3e59b6
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 36s
2026-11-16 04:53:49 +00:00
Compare
mikluko force-pushed stage-host from d5da3e59b6
All checks were successful
test / changelog (pull_request) Successful in 6s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 36s
to 5f19e646cb
Some checks failed
test / changelog (pull_request) Failing after 4s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 35s
2026-11-16 04:54:50 +00:00
Compare
mikluko force-pushed stage-host from 5f19e646cb
Some checks failed
test / changelog (pull_request) Failing after 4s
image / image (pull_request) Successful in 9s
test / go (pull_request) Successful in 35s
to 7e4e173632
All checks were successful
image / image (pull_request) Successful in 8s
test / changelog (pull_request) Successful in 6s
test / go (pull_request) Successful in 31s
2026-11-16 04:56:10 +00:00
Compare
Author
Owner

Review for spec-bb1.34, of 7e4e173 (#9 is merged, so this shows alone after a rebase). The order is right: resume, stage, pre_start, claude, then the setup commands and attach; a stream that broke halfway writes nothing; a server without Stage stages nothing. One change.

The check that keeps the archive inside the working directory is made on names, and links defeat it.
within joins and cleans the path as text. An archive can build a way out from links that each look inside:

d/            a directory
d/l -> ..     a link to the working directory itself: inside, allowed
d/l/m -> ..   by its name under d/l, so ".." reads as d: allowed. On disk d/l is the working directory, so this makes <workdir>/m -> its parent
d/l/m/evil    by its name inside; on disk written to the parent of the working directory

Go has the tool for this since 1.24, and the module is on 1.27: os.OpenRoot(dir) and its MkdirAll, OpenFile, Symlink, Remove refuse any step that leaves the root, links included, at the moment of the step. Extract through an os.Root and add this archive to the escaping ones in the test. The archive comes from the server, which is trusted more than the pod, so this is the second line; but the test's claim that an escaping archive is refused should be true of the kind above too.

Review for spec-bb1.34, of 7e4e173 (#9 is merged, so this shows alone after a rebase). The order is right: resume, stage, `pre_start`, claude, then the setup commands and attach; a stream that broke halfway writes nothing; a server without Stage stages nothing. One change. **The check that keeps the archive inside the working directory is made on names, and links defeat it.** `within` joins and cleans the path as text. An archive can build a way out from links that each look inside: d/ a directory d/l -> .. a link to the working directory itself: inside, allowed d/l/m -> .. by its name under d/l, so ".." reads as d: allowed. On disk d/l is the working directory, so this makes <workdir>/m -> its parent d/l/m/evil by its name inside; on disk written to the parent of the working directory Go has the tool for this since 1.24, and the module is on 1.27: `os.OpenRoot(dir)` and its `MkdirAll`, `OpenFile`, `Symlink`, `Remove` refuse any step that leaves the root, links included, at the moment of the step. Extract through an `os.Root` and add this archive to the escaping ones in the test. The archive comes from the server, which is trusted more than the pod, so this is the second line; but the test's claim that an escaping archive is refused should be true of the kind above too.
mikluko force-pushed stage-host from 7e4e173632
All checks were successful
image / image (pull_request) Successful in 8s
test / changelog (pull_request) Successful in 6s
test / go (pull_request) Successful in 31s
to 0d9462a15c
All checks were successful
image / image (pull_request) Successful in 8s
test / changelog (pull_request) Successful in 11s
test / go (pull_request) Successful in 31s
2026-11-16 04:57:39 +00:00
Compare
mikluko deleted branch stage-host 2026-11-16 04:58:37 +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!10
No description provided.