Skip to content

feat(control-plane,sbx): a template host agent builds queued templates; builds register by policy - #772

Merged
webchang merged 25 commits into
rossoctl:mainfrom
webchang:pr/i18-host-agent
Nov 14, 2026
Merged

webchang merged 25 commits into
rossoctl:mainfrom
webchang:pr/i18-host-agent

Conversation

@webchang

@webchang webchang commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #741. On main (01528b6): #766 and #771 (the build and register tooling, #740), which this branch used to stack on, are merged. Its own change is 3 commits (77ed000, 4bec30d, de22d2b), plus merges of main.

What it does: a template host agent builds queued templates on its host, and the control plane registers each build by policy. Three signed-off commits:

  1. The control plane:
    • host routes (inventory, claim, blobs, log, report) under per-host bearer auth (SH_TEMPLATE_HOSTS, SH_HOST_TOKEN_<ID>);
    • a built build is registered by policy as registered or rejected, with build and check records;
    • openapi 1.10.0 (main is at 1.9.0).
  2. setup.sh SBX_TEMPLATE_HOSTS mints the host agents' bearers and bundles.
  3. host-agent.sh with its units and timer, and install-host.sh, which installs a worker from a template record.

Limits:

  • A new template's worker still needs the operator's SBX_WORKERS / setup.sh step, since only setup.sh mints the relay token.
  • The agent is installed by hand (the RUNBOOK's "The template host agent").
  • hostBlob serves any stored blob by digest to any configured host, since hosts are trusted.

Upgrade note: install-host.sh's SBX_WORKER_BIN now defaults to /usr/local/libexec/sbx/microvm-worker and refuses a missing binary.

Coordination:

Tests on the tip:

  • pnpm -r typecheck passes;
  • control plane (with Redis): every file passes, with 3 skipped as on main. The new test/host-flow.test.ts covers host auth, claim, log, report and registration by policy, and the routes, route-profile and openapi-contract tests pass;
  • deploy/sbx/tests/host-agent.test.sh (new), setup.test.sh and overlay.test.sh pass on bash 5 and bash 3.2;
  • install-host.test.sh passes on bash 5. On bash 3.2 it stops at the janitor case (declare -A in sbx-janitor.sh), exactly as on the parent branch, so the stop doesn't come from this PR;
  • the status, smoke, janitor and template-onboarding suites pass, and so do the doc link check and prettier;
  • shellcheck: the new scripts are clean, and the changed ones keep the parent's findings.

30 files, +2,166 / -54, counted over the review range.

Assisted-By: Claude Code

The host agent stands on both parents: the template store and self-serve create (rossoctl#766, with rossoctl#760 and
rossoctl#756) and the template build tooling (rossoctl#740's branch, with rossoctl#757). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…ds register by policy

A KVM host's agent builds the templates clients queue (template
lifecycle spec §6.1, §8.2). This adds its side in the control plane.

- Host identity: SH_TEMPLATE_HOSTS (a JSON list of {id}) and one bearer
  per host, SH_HOST_TOKEN_<ID> (64 hex, from the environment or a
  systemd credential, distinct from the exchange, janitor and every
  egress token; host-config.ts). A new route auth kind, `host`: every
  configured host is compared, and the host in the path must be the one
  whose token was presented. With no hosts, every host route is 401.
- Routes under /v1/hosts/{host}/, on both route profiles:
  inventory (what the host holds by manifest hash, and its limits);
  builds/claim (up to 4 queued builds, oldest first, subjects in turn,
  each moved to `building` and held by the host); blobs/{digest} (a
  gate record's exact bytes); builds/{build}/log (bounded entries, a
  build keeps its last 1000); builds/{build}/report (building, probing,
  failed with its step, or built with the template record and the
  manifest as files).
- A claimed build's job is the spec as the policy checked it: the
  template's id and the create's image always win over the spec's own,
  and the guest size is always named guest_ram_mb, the value the policy
  checked (template-build.sh reads only guest_ram_mb).
- On `built` the control plane stores both files byte for byte, writes
  a `build` record, checks them against the create's request (image,
  the rootfs's image digest, manifest hash and hash version 2, size,
  gate record, X12) and registers the build or rejects it naming the
  rule, with a `check` record either way. A registered build's id
  becomes its manifest hash; a template's first takes `default`. A
  report answers only a build this host claimed, and a failed or
  cancelled build takes no more.

The catalog's builds gain the claim, the queue time and the log. The
OpenAPI document adds the routes and the hostToken scheme (1.6.0), with
the changelog, the configuration row and spec §6.1.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
… and bundles

With SBX_TEMPLATE_STORE=1, SBX_TEMPLATE_HOSTS lists the KVM hosts
(space-separated ids, ^[a-z0-9][a-z0-9-]{0,30}$) whose sbx-host-agent
may build templates (template lifecycle spec §6.1).

- Each host gets a bearer, SH_HOST_TOKEN_<ID> (64 hex), in the Secret
  sbx-template-hosts: generated once and kept; a host no longer listed
  has its token removed by a null patch. With the store on and no host,
  the Secret is applied empty, since the credentials volume names it.
- SH_TEMPLATE_HOSTS (the JSON list of ids) goes into sbx-settings, and
  the Secret's data into the settings hash, so a new or revoked token
  rolls the control plane.
- One bundle per host under .generated/host-agent/<id>/: host-agent.env
  (the API URL and the host id, no secret), host-agent.token (the bearer
  alone) and api-ca.crt with SBX_API_CA_FILE; 0700/0600. A dropped
  host's bundle is deleted.
- The template-store component reads SH_TEMPLATE_HOSTS from
  sbx-settings and projects sbx-template-hosts into /run/credentials
  beside moca-mu1, restating sbx-egress as optional (a strategic merge
  replaces the source list).

SBX_TEMPLATE_HOSTS without the store, a bad id and a repeated id are
refused before anything is applied. setup.test.sh and overlay.test.sh
cover the bundles, the tokens, a re-run, a dropped host, egress
together, and the refusals.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…ost.sh installs from a record

deploy/sbx/host-agent.sh --once, run by sbx-host-agent.service and its
timer (every 2 minutes), is one poll of a KVM host's template agent
(template lifecycle spec §6.1): it reports the inventory (the snapshots
held, by manifest hash, from template-build.sh's records, and the
host's limits), claims queued builds, fetches a cited gate record and
checks its bytes against its sha256, runs template-build.sh, posts the
log's tail and reports building, then built with the template record and
the manifest, or failed with its step.

- No build is claimed below SBX_DISK_FLOOR_GB of free disk (default 60),
  more than SBX_BUILD_CONCURRENCY a poll (default 1, at most 4), or,
  with SBX_REGISTRY set, before REGISTRY_AUTH_FILE holds a login for it.
- Nothing that names where an image lives leaves the host: a failed
  build's reason and its log are redacted (SBX_REGISTRY exactly, then
  URLs, registry hosts, IP addresses and 12-digit account ids), the full
  log stays in $SBX_SRV/agent-logs (0700), and a template record or
  manifest that names SBX_REGISTRY is not sent (the build fails
  leak_refused). A reason leads with a code a client can branch on:
  pull_failed, probe_failed, disk_floor, spec_refused, build_failed or
  leak_refused, and the step follows from it.
- The token stays in a 0600 file and a 0600 header file, never in argv
  or the log; a bad setting is refused (exit 2) before any call.

The agent installs no worker. install-host.sh now installs a worker
from template-build.sh's record when there is one: the worker env names
it (SH_TEMPLATE_RECORD) and its id as SANDBOX_TEMPLATE, so the worker
checks the record against its snapshot and its id at every start. The
worker unit runs SBX0's own binary, SBX_WORKER_BIN (default
/usr/local/libexec/sbx/microvm-worker), never the /usr/local/bin one a
P4 worker on the same host may run; a missing one is refused before
systemd.

Known limit, in the RUNBOOK's new host agent section: a new template's
worker still needs an operator's SBX_WORKERS and setup.sh step, because
only setup.sh mints a worker's relay token.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 12, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The PR body says it stacks on #766 and #771 (both still open) and merges them in, so this review concentrates on its own increment (36fee3a..HEAD): the host routes and bearer auth, registration by policy, setup.sh's host tokens and bundles, host-agent.sh and its units, and the install-host.sh changes. Host auth looks right: tokens are compared in constant time over every host, the path host must match the presented token, and a host token is refused if it matches the janitor, egress or exchange bearer. Two real defects found. First, several host-agent.sh failure paths that run after a successful claim (gate-record fetch or digest mismatch, missing template record or manifest, a failed building report) return without reporting failed, so the build stays building for good and keeps counting against the owner's buildsQueued quota. Second, the built report handler awaits blob writes, provenance appends and the policy read, then writes the final status without checking it again, so a cancel that lands in that window is silently replaced by registered.

Author: webchang (MEMBER — maintainer)
Areas reviewed: control-plane host routes and auth (server.ts, host-config.ts, host-handlers.ts, routes.ts, main.ts), registration by policy, setup.sh SBX_TEMPLATE_HOSTS tokens and bundles, host-agent.sh and its systemd units, install-host.sh worker-bin and template-record changes, k8s template-store overlay, commit/DCO, CI, agent-config gate
Agent/IDE config (.claude/.vscode): none
Commits: 32 commits, all signed-off: yes
CI status: passing (all 17 checks green, including shellcheck, deploy-scripts and deploy-scripts-bash32)

0 must-fix, 2 suggestions, 0 nits.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

Comment thread deploy/sbx/host-agent.sh Outdated
if [[ -n "$gate" ]]; then
local d="${gate##*/}"
[[ "$d" =~ $DIGEST_RE && "$gate" == "/v1/hosts/$SBX_HOST_ID/blobs/$d" ]] || { error "malformed gate record path for $handle"; return; }
api GET "$gate" | jq -r .base64 | base64 --decode >"$WORK/$handle.gate.json" || { error "gate record fetch for $handle failed"; return; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Once a job is claimed (the control plane has already set it to building with claim.host), several failure paths here just call error and return without ever sending a failed report: the malformed gate path (L166), a failed gate fetch (L167), a digest mismatch (L169), a failed building report (L173), and the missing record or manifest after a successful build (L207, L209). Nothing re-queues or times out a claimed build (spec §6.1, "Known limits"), so each of these leaves the build building for good. It then counts against the owner's buildsQueued quota (usage() in sandbox-handlers.ts counts building) until the owner happens to cancel it. The agent is still alive and knows the build failed, so this is not the "agent dies mid-build" case the spec accepts. Suggested fix: add a helper such as fail_claimed HANDLE STEP CODE MSG that sends {event:"failed",step,message} (best effort, falling back to error if the report itself fails) and bumps FAILED, and call it on every post-claim exit path. Then add a host-agent.test.sh case for a gate digest mismatch that asserts a failed report was sent.

},
});
const manifestHash = String(t.manifest_hash);
await cat.update(doc.id, async (cur) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The terminal-status guard (L313-L318) runs on the build snapshot that claimedBuild read at the start of the request. The built path then awaits two putBlob calls, two prov.append calls and policy.current() before this final cat.update, and this update rewrites the matching build to registered/rejected without looking at cur's status. If the owner cancels in that window (cancelBuild sets failed, step cancelled, and appends a cancelled record), the cancel is overwritten: the build ends up registered, may take the default tag, and the chain holds both a cancelled and a registered outcome for the same handle. setBuild (L318) has the same issue for building/probing, which can flip a cancelled build back to building. Suggested fix: inside each cat.update mutator, find the build in cur and throw invalid_request ("the build is ; it takes no more reports") unless its status is still one the host may report on (building/probing). Also add a host-flow test that cancels between the claim and a built report whose provenance writes are slow (for example a stubbed putBlob that awaits a promise).

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Adds the template host agent flow: five /v1/hosts/{host}/ routes under per-host bearer auth (SH_TEMPLATE_HOSTS / SH_HOST_TOKEN_, digest-compared against every host, path host bound to the token), registration of a built build by policy with build/check provenance records, setup.sh minting per-host bearers and bundles, and host-agent.sh with its unit/timer plus install-host.sh wiring SH_TEMPLATE_RECORD. Auth, host-id validation and the claim itself (status re-checked inside the per-template update queue) look sound. The main problems are in what happens after a claim: host-agent.sh aborts the whole poll under set -e when a failed build's log has no non-blank line, several post-claim error paths never report the build failed, and the report handler checks the build's status outside the catalog lock, so a concurrent cancel can be overwritten by registered.

Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript, Shell, Kubernetes/kustomize, OpenAPI
Agent/IDE config (.claude/.vscode): none
Commits: all signed-off: yes
CI status: all 17 checks pass

Inline: 2 must-fix, 3 suggestion, 0 nit. The head 0d8e28e is a merge-only cascade of #757 up the stack (empty remerge-diff, no new non-merge commits); the review covers this PR's own range 36fee3a7..de22d2ba, as the body asks.

AI-assisted review, approved by a maintainer before posting.

Comment thread deploy/sbx/host-agent.sh Outdated
if ((rc != 0)); then
FAILED=$((FAILED + 1))
local last
last="$(grep -v '^[[:space:]]*$' "$WORK/$handle.log" | tail -n 1 | redact | cut -c1-500)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix: Under set -euo pipefail this assignment aborts the whole agent when the build log has no non-blank line: grep -v '^[[:space:]]*$' exits 1, pipefail makes the substitution fail, and errexit fires on the last=... assignment (reproduced: printf '\n\n' >e.log; bash -c 'set -euo pipefail; f(){ local last; last="$(grep -v "^[[:space:]]*$" e.log | tail -n1)"; echo after; }; f' exits 1 without printing). A template-build.sh that dies with no output (killed, OOM, missing interpreter) then leaves this build and every other build claimed in the same poll in building forever, with no failed report and no summary line. Guard it, e.g. last="$( { grep -v '^[[:space:]]*$' "$WORK/$handle.log" || true; } | tail -n 1 | redact | cut -c1-500)", and add a test case with an empty build log.

Comment thread deploy/sbx/host-agent.sh Outdated
if [[ -n "$gate" ]]; then
local d="${gate##*/}"
[[ "$d" =~ $DIGEST_RE && "$gate" == "/v1/hosts/$SBX_HOST_ID/blobs/$d" ]] || { error "malformed gate record path for $handle"; return; }
api GET "$gate" | jq -r .base64 | base64 --decode >"$WORK/$handle.gate.json" || { error "gate record fetch for $handle failed"; return; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Once the claim succeeds the control plane already holds the build as building for this host, but this path (gate fetch failure), the malformed gate path / digest mismatch above and below, and the missing template record / manifest paths at 207 and 209 only call error and return. Nothing reports failed, and nothing re-queues a claimed build, so a transient network error on the blob fetch leaves the build stuck in building indefinitely and counting against the owner's buildsQueued quota until they cancel by hand. Report {event: failed, step, message} (with a fixed code such as agent_error) on every post-claim early return, best-effort, before returning.

},
});
const manifestHash = String(t.manifest_hash);
await cat.update(doc.id, async (cur) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix: The status check that refuses reports for a terminal build (line 312, via claimedBuild's cat.list()) runs outside the catalog's per-template queue, and this final cat.update (like setBuild at 318) rewrites the build without re-checking its status. Between the check and this update there are several awaits (two putBlobs, two prov.appends, policy.current()), so an owner's cancelTemplateBuild that lands in that window sets the build failed/cancelled and is then overwritten with registered (and the template may take default). The cancel test only covers cancel-before-report. Re-check inside the mutate callback, e.g. const y = c.builds.find(b => b.handle === build.handle); if (!y || y.status !== 'building' && y.status !== 'probing' || y.claim?.host !== host) throw new CpError('invalid_request', ...), and do the same in setBuild.

: {
...y,
status: 'registered' as const,
buildId: manifestHash,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: A registered build takes buildId: manifestHash without checking whether another build of this template already has that id. The create's reuse key includes the profile and the gate record's sha256, so a second create of the same image and spec with a different gate record (or profile) queues a new build; template-build.sh then takes its "already built" path (same spec_key, only the gate differs, so it rewrites the record and exits 0) and reports the same manifest_hash. The template ends up with two builds whose buildId is equal, and lookups by build id (template-catalog.ts find by buildId) silently return the first. Either reject/merge on a duplicate manifest hash inside this update, or document and test that case.

const have = createHash('sha256').update(h.token).digest();
if (want && timingSafeEqual(want, have) && found === undefined) found = h.id;
}
if (!found || found !== ctx.params.host)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: This is the line that binds a host's token to the {host} in the path (the property the routes rely on so a host reports only for itself), but no test reaches it: host-flow.test.ts builds ctx with host already set and calls the handlers directly, and route-profile/routes tests only check mounting. Add a server-level test (as egress has) that host-1's token is 401 on /v1/hosts/host-2/..., that no token / an egress or janitor token is 401, and that with no SH_TEMPLATE_HOSTS every host route is 401.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Re-review of the push since my last review (24c1132..0d8e28e, review 5883321710). This PR's own commits are unchanged: git range-diff shows every earlier commit as equal. The push only merges the parent branches again ("Merge pr/i17-build-tooling into pr/i18-host-agent", and the merges below it), and so brings in #757's five new fixes (381d7c4 too-large command closes its connection, b1beba6 lease keeps its VM on that refusal, ace1c43 build-snapshot.sh no writes through a symlink, ab347c1 install-host.sh removes the old jail path, 5181204 http-api doc). Those belong to #757 and are reviewed there. I checked the two conflicted merges on the way down (3ee0acf upstream/main into i10, d4445a2 i10 into i17) against their recorded resolutions. errors.go, guestconn.go, build-snapshot.sh, microvm-worker main.go and snapshot_test.go keep both sides, as the commit messages say, and main.go's single LoadManifest now feeds both ManifestFeatures and VerifyWith. No new findings. The earlier 2 suggestions still apply: none of the files they cite changed in this push.

Author: webchang (MEMBER — maintainer)
Areas reviewed: range-diff of this PR's own commits, the incoming #757 commits (scope only), the conflict resolutions in the two upstream merges, commits/DCO, CI, agent-config gate
Agent/IDE config (.claude/.vscode): none
Commits: 40 commits, all signed-off: yes
CI status: passing (all 17 checks green)

0 new must-fix, 0 new suggestions, 0 new nits.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

Conflict in deploy/sbx/install-host.sh: both branches wire a worker to its
template record. rossoctl#771's check_template_record is kept (jq, the schema,
the worker must match the bundle, refused before anything is written);
this branch's record_template_id is dropped as now unused. The header
keeps this branch's binary paths (SBX_WORKER_BIN). install-host.test.sh:
rossoctl#771's no-record assertion now checks the worker that has no record.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Conflict in packages/control-plane/src/sandbox-handlers.ts, createBuild:
rossoctl#766's reviewed form is taken (the owner's quota lock, normalizeSpec,
the charged owner, the audit line), with this branch's queuedAtMs on the
new build and its comment on the templates list's hosts block.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
… ends its poll

A failed build whose log held no non-blank line made the grep for its last
line exit 1; under pipefail and errexit that ended the whole poll, leaving
this build and every other build claimed in the same poll `building`, with
no `failed` report and no summary line. The grep is now guarded, and a
test runs a build that exits 137 with only blank lines.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…n with as failed

Once a build is claimed the control plane holds it `building` for this host,
and nothing re-queues it. The post-claim early returns (a malformed template
id or gate record path, a gate record fetch that failed or whose bytes do not
match their digest, a building or built report not accepted, no template
record or manifest after the build) only logged an error, so the build stayed
`building` and counted against its owner's queue until cancelled by hand.

Each now reports `{event: failed, step, message: "agent_error: ..."}`, best
effort, through one helper (fail_claimed) that counts it failed and logs an
error only if the report itself fails. The message is the agent's own fixed
wording, never build output. A template record that is not JSON no longer
ends the poll under errexit. The spec and the runbook name the new code.
Tests: a gate digest mismatch, a failed gate fetch, no template record, and a
record that is not JSON are each reported failed.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…mplate update

The report handler refused reports for a terminal build on the status it
read at the start of the request, then awaited blob writes, provenance
appends and the policy read before its final catalog write, which rewrote
the build without looking at it again. An owner's cancel landing in that
window was overwritten: the build became `registered` (and could take
`default`), with both a `cancelled` and a `registered` outcome in its chain.
The building/probing and failed writes had the same gap.

Every report write now goes through one helper that finds the build as the
catalog holds it, inside the template's update queue, and refuses it unless
it is still this host's and building, probing or built. The `failed` record
and the `built` report's build and registration-check records are appended
inside that update, so a refused report leaves no record. Tests: a cancel
that lands while a built report is held in its blob write stands, and the
chain holds no built or registration record; building, probing and failed
reports on a cancelled build, and an unknown event, are refused.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…lready has is rejected

A registered build takes its manifest hash as its build id, but nothing
checked whether another build of the template already had that id. A
second create of the same image and spec under another profile or gate
record is not a reuse, so it queues a new build; template-build.sh then
finds the snapshot already built and reports the same manifest hash, and
the template held two builds with one build id (lookups by id returned the
first).

The registration check gains a rule, T.unique, evaluated inside the
template update: a build whose manifest hash another build of the template
already has is rejected, its reason naming that build. The spec says so.
Test: a second build of the same snapshot is rejected T.unique, the first
keeps the id and `default`.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
The binding of a host's token to the {host} in the path, which the host
routes rely on so a host reports only for itself, was reached by no test:
the flow tests call the handlers with ctx.host already set, and the route
tests check mounting only. New tests serve buildHandler and call all five
host routes: host-1's token is 401 on host-2's paths (and claims nothing);
no token, a wrong one, a user API token, and the janitor, egress and
exchange bearers are 401; with no SH_TEMPLATE_HOSTS every host route is
401.

Refs rossoctl#741

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@webchang

Copy link
Copy Markdown
Member Author

ingpaolodettori-dev

1. deploy/sbx/host-agent.sh:184 (must-fix)

Under set -euo pipefail this assignment aborts the whole agent when the build log has no non-blank line

Fixed in 2f08e64: the grep for the failure's last line is guarded ({ grep -v '^[[:space:]]*$' ... || true; }), so a build that died with no output is reported failed (build_failed: template-build.sh exit N: ) and the poll goes on to its summary. Test: host-agent.test.sh case 11, "a build that dies with no output is reported failed, and the poll ends with its summary" (a build that prints only blank lines and exits 137); it fails on the previous script.

2. deploy/sbx/host-agent.sh:167 (suggestion)

Report {event: failed, step, message} (with a fixed code such as agent_error) on every post-claim early return, best-effort, before returning.

Fixed in 82c724f: one helper, fail_claimed HANDLE STEP WHY, reports {event: "failed", step, message: "agent_error: <the agent's own fixed wording>"} best effort, counts the build failed, and logs an error only if that report itself fails. It is used on every way out after a claim short of built: a malformed template id or gate record path, a gate record fetch that failed, a gate record that does not match its digest (step gate); a building or built report not accepted, no template record, a record that is not JSON or names no snapshot, no manifest (step report). A record that is not JSON also no longer ends the poll under errexit (its jq read is guarded). The spec (§6.1) and the runbook name the new code. Tests: host-agent.test.sh case 4 (a digest mismatch is now reported failed agent_error) and case 12 (a failed gate fetch, no template record, and a record that is not JSON are each reported failed, and the poll ends with its summary).

3. packages/control-plane/src/host-handlers.ts:392 (must-fix)

Re-check inside the mutate callback ... and do the same in setBuild.

Fixed in ba9ccd3: every report write (building/probing, failed, built) goes through one helper that finds the build as the catalog holds it, inside the template's update queue, and refuses it (invalid_request, "the build is ; it takes no more reports") unless it is still this host's and building, probing or built. The failed record, and the built report's build and registration check records, are now appended inside that same update, so a cancel either lands first (the report is refused and no record says it was built or registered) or after (the cancel finds the build registered or rejected and refuses). Tests in host-flow.test.ts: "keeps a cancel that lands while a built report is being written (re-checked in the update)" (a putBlob held until the owner's cancel has landed; the build stays cancelled, default is not taken, and the chain holds the cancel only; it fails on the previous handler), and "refuses a report with an unknown event, and a building report on a cancelled build" (building, probing and failed after a cancel).

4. packages/control-plane/src/host-handlers.ts:406 (suggestion)

Either reject/merge on a duplicate manifest hash inside this update, or document and test that case.

Fixed in 88c17ca: rejected. The registration check gains a rule, T.unique, evaluated inside the template update: a build whose manifest hash another build of the template already has is rejected, its reason naming that build and its status; the first build keeps the id and default. The spec (§6.1) says so. Test: host-flow.test.ts "rejects a second build of a snapshot the template already has (one build per build id)" (a second create of the same image and spec under another profile and no gate record, reported with the same manifest hash).

5. packages/control-plane/src/server.ts:95 (suggestion)

Add a server-level test (as egress has) that host-1's token is 401 on /v1/hosts/host-2/..., that no token / an egress or janitor token is 401, and that with no SH_TEMPLATE_HOSTS every host route is 401.

Fixed in 730c71e: a new describe block, "host authentication through the router", serves buildHandler and calls all five host routes: host-1's token is 401 on every host-2 path (and claims nothing), while each host's token is admitted on its own; no token, a wrong one, a user API token, and the janitor, egress and exchange bearers are 401; with no SH_TEMPLATE_HOSTS every host route is 401 even with a well-formed host token. The first test fails if the path-host binding in authorize is removed.

clawgenti

deploy/sbx/host-agent.sh:167 (suggestion)

add a helper such as fail_claimed HANDLE STEP CODE MSG that sends {event:"failed",step,message} ... Then add a host-agent.test.sh case for a gate digest mismatch that asserts a failed report was sent.

Fixed in 82c724f (as for the thread above): fail_claimed on every post-claim exit, including the failed building report and the failed built report; host-agent.test.sh case 4 now asserts the digest mismatch's failed report (agent_error, step gate).

packages/control-plane/src/host-handlers.ts:392 (suggestion)

inside each cat.update mutator, find the build in cur and throw invalid_request ... Also add a host-flow test that cancels between the claim and a built report whose provenance writes are slow

Fixed in ba9ccd3 (as for the thread above): the re-check is inside every update, the report's records are written inside it too (so the chain no longer holds both a cancelled and a registered outcome for one handle), and the requested test holds putBlob until the cancel has landed.

New tip: 730c71e

Note on the registration check record

The registration check record cites the policy as read just before the update: it names the policy in force, and a policy change racing a single report only shifts which policy record it cites.

Assisted-By: Claude Code

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Re-review of the push since my last review (0d8e28e..a1a30d7, review 5883638407). This PR's own commits (77ed000, 4bec30d, de22d2b) are unchanged. The push is two merges: c0d7131b brings in #771 (and #757 through it), and a1a30d70 brings in #766. Every new non-merge commit belongs to #771, #757 or #766 and is reviewed there. I checked the two conflict resolutions against git show --remerge-diff:

  • a1a30d7 (sandbox-handlers.ts createBuild): it takes #766's reviewed form and keeps this branch's queuedAtMs on the new build, as the commit message says.
  • c0d7131 (install-host.sh): it keeps #771's check_template_record and drops record_template_id, which nothing references now. In install-host.test.sh, the no-record assertion now checks $A (sbx_default, the worker with no record).

No new findings. None of this PR's own files (host-agent.sh, host-handlers.ts, server.ts) changed in this push, so the open findings from the earlier reviews still apply: the post-claim failure paths that never report failed, and the report handler's status check made outside the catalog lock. The deploy-scripts failure is inherited from #766's examples.test.sh jq change (inline comment).

Author: webchang (MEMBER — maintainer)
Areas reviewed: merge-only push: commit attribution to the parent PRs, both conflict resolutions (remerge-diff), commits/DCO, CI, agent-config gate
Agent/IDE config (.claude/.vscode): none
Commits: 66 commits, all signed-off: yes
CI status: failing: deploy-scripts (step "Run deploy shell tests"), inherited from #766. The other 16 checks pass.

0 new must-fix of its own (1 inherited from #766), 0 new suggestions, 0 new nits.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

jq -e '.id | test("^[a-z0-9][a-z0-9-]{0,30}$")' "$spec" >/dev/null || fail "$name: id (M7)"
jq -e '.image | test("^[^\\s@]+@sha256:[0-9a-f]{64}$")' "$spec" >/dev/null ||
fail "$name: image not pinned by digest (M1)"
jq -e '(has("guest_mb") and has("guest_ram_mb") | not) and

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix (inherited from #766, commit a187e99; already reported there: #766 (comment)): this filter is false for every spec, and that is why deploy-scripts is red on this head. In jq, A and B as $g | C parses as (A and B) as $g | C, so $g is bound to the boolean and ($g | type) == "number" never holds. With jq 1.8.2 on this head's default.json (guest_ram_mb: 256, vcpus: 1) the expression gives false. With the binding parenthesised, ((has("guest_mb") and has("guest_ram_mb")) | not) and ((.guest_mb // .guest_ram_mb) as $g | ...), it gives true, and it still refuses {"guest_mb":256,"guest_ram_mb":256}. Suggested fix: parenthesise as shown, in #766. This PR picks it up on its next merge from #766.

webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
Conflict in deploy/sbx/tests/host-agent.test.sh: both branches add
numbered cases after case 10. rossoctl#772's empty-log and post-claim failure
cases are kept as 11 and 12, this branch's activation and --wanted-only
cases follow as 13 and 14, and rossoctl#772's summary checks carry this branch's
started and stopped fields.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The host-agent design holds up well: per-host bearer auth with a constant-time compare over every host, the path host bound to the token, and the registration check, both records and the status re-check all done inside the template's update queue, so a cancel and a report can't interleave. The typecheck and the control-plane suites pass on head. One must-fix: the required deploy-scripts check fails on head, and I reproduced the failure locally. It comes from a jq precedence bug in the examples test that this branch inherits from the stack. There is also one robustness suggestion for the agent's claim loop.

Must-fix

  1. deploy/sbx/template-onboarding/tests/examples.test.sh:22: with jq 1.8, … and EXPR as $g | … binds $g to the boolean from the left-hand and, so default.json fails M7. That is what turns make test-deploy and CI's deploy-scripts red. Wrap the binding in parentheses (inline comment).

Suggestion
2. deploy/sbx/host-agent.sh:273: the while read … done < <(jq …) loop shares stdin with template-build.sh. A build step that reads stdin swallows the remaining jobs, which then stay building after being claimed (inline comment).

Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane host routes, auth, registration), Shell (host-agent.sh, setup.sh, install-host.sh, tests), CI, Docs/OpenAPI
Agent/IDE config (.claude/.vscode): none
Commits: 71 commits (3 of them this PR's own), all signed-off: yes
CI status: failing: deploy-scripts (step "Run deploy shell tests"). k8s-kind-e2e is pending, and every other check passes.

Verified on head 730c71e: pnpm typecheck is clean; vitest run test/host-flow.test.ts test/template-create.test.ts passes 72/72; make test-deploy fails at examples.test.sh (FAIL: default.json: guest size or vcpus (M7)) with jq 1.8.2 and passes with jq 1.7.1. With the parenthesised fix, the suite passes on both jq versions, and a 64 MiB positive control still fails M7. janitor.test.sh also failed in my sandbox, but it fails the same way on main (bytes_freed 0), so that one is environmental and not from this PR. The probes were throwaway copies and have been deleted.

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

jq -e '.id | test("^[a-z0-9][a-z0-9-]{0,30}$")' "$spec" >/dev/null || fail "$name: id (M7)"
jq -e '.image | test("^[^\\s@]+@sha256:[0-9a-f]{64}$")' "$spec" >/dev/null ||
fail "$name: image not pinned by digest (M1)"
jq -e '(has("guest_mb") and has("guest_ram_mb") | not) and

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix: jq precedence makes this M7 check fail on jq 1.8, so CI's deploy-scripts is red on head.

as binds looser than and, so A and (.guest_mb // .guest_ram_mb) as $g | … binds $g to the result of A and …, which is a boolean. With jq 1.8.2, jq -nc 'true and 300 as $g | [$g, ($g|type)]' prints [true,"boolean"], so ($g | type) == "number" is false and default.json fails with guest size or vcpus (M7). jq 1.7.1 happens to pass, which explains why this only shows up on the runner's newer jq.

Suggested fix: parenthesise the binding:

(has("guest_mb") and has("guest_ram_mb") | not) and
    ((.guest_mb // .guest_ram_mb) as $g | ($g | type) == "number" and $g >= 128) and
    (.vcpus | type) == "number" and .vcpus >= 1 and .vcpus <= 32

I verified it on head: the suite passes on jq 1.8.2 and on 1.7.1, and guest_ram_mb: 64 still fails M7 (positive control). The line arrives through the stacked parent (a187e99), so the fix may belong there.

Comment thread deploy/sbx/host-agent.sh
printf '{"max":%d}' "$SBX_BUILD_CONCURRENCY" >"$WORK/claim.json"
local jobs
if jobs="$(api POST "/v1/hosts/$SBX_HOST_ID/builds/claim" "$WORK/claim.json")" && jq -e '.builds | type == "array"' >/dev/null 2>&1 <<<"$jobs"; then
while IFS= read -r job; do build_one "$job"; done < <(jq -c '.builds[]' <<<"$jobs")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: template-build.sh inherits this loop's stdin, which is the job stream from < <(jq -c '.builds[]' …). Any step in the build that reads stdin (a podman prompt, ssh, a stray read or cat) consumes the jobs that haven't run yet. Those builds were already claimed, so they stay building and count against their owners' queues until someone cancels them, and nothing reports them failed.

Probe (the test's mock harness, 2 jobs claimed, SBX_BUILD_CONCURRENCY=2): the control run reports "claimed":2,"built":2. Adding cat >/dev/null to the mock build gives "claimed":1,"built":1, with exit 0 and no error line, and the second claimed build gets no report at all.

Suggested fix: "$SBX_TEMPLATE_BUILD" … </dev/null >"$WORK/$handle.log" 2>&1 in build_one, or read the jobs on a separate fd (while IFS= read -r -u 3 job; …; done 3< <(…)). It's worth doing now because there is no claim-expiry sweep yet that would recover stranded building entries.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Re-review of the push since my last review (730c71e..c480522, review 5884597122). The only content change is the shared jq fix from #766, merged in (2 commits, 1 file, +3/−2).

passing so far (deploy-scripts passes; deploy-scripts-bash32, check, docs, proto still pending)

Author: webchang (MEMBER — maintainer)
Areas reviewed: examples.test.sh M7 guest-size jq is now fully parenthesized (cbec01ca). I confirmed the fix on jq 1.8.2: the suite passes at head, and with the old line restored, default.json: guest size or vcpus (M7) fails again (positive control). deploy-scripts now passes on this head, so the must-fix is resolved. No new findings. The earlier suggestion (the host-agent.sh claim loop shares stdin with template-build.sh) is untouched by this push and still stands.
Agent/IDE config (.claude/.vscode): none
Commits: 73 commits, all signed-off: yes
CI status: Shell (template-onboarding tests)

Verified by: examples.test.sh on head under jq 1.8.2 (pass), plus the old-line positive control (fail)

Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Follow-up at c480522 (730c71e..c480522, merge-only). This PR's own files are unchanged. Our approval at 730c71e was dismissed only for the inherited jq bug in examples.test.sh, and that is now fixed: The merged change is cbec01c (#766's jq fix in examples.test.sh, +3/−2), byte-identical in every PR of the stack. I checked it on jq 1.8.2: both shipped examples (default.json, django__django-11133.json) pass, and so do the edge cases (both aliases, missing, <128, string, vcpus 0/33), which fail as they should. deploy-scripts is green.

Still open, not blocking: our suggestion that twin matches builds of any status, retired included (host-handlers.ts:402), and clawgenti's suggestion that the host-agent.sh claim loop shares stdin with template-build.sh.

Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: new own commits signed off: yes
CI status: 14 pass, 3 pending (check, deploy-scripts-bash32, docs).

AI-assisted review, approved by a maintainer before posting.

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Follow-up at 656a991 (c480522..656a991): one merge of #766's tip (ef65b8a), which brings in 4 signed-off #766 commits. This PR's own host-agent/host-handlers files are unchanged. The merged delta is byte-identical to #766's cbec01c..ef65b8a, apart from hunk offsets, so the merge resolved cleanly with no extra changes. It closes the must-fix we +1'd on #766 (clawgenti, sandbox-handlers.ts:537): the templates quota is now checked whenever the template holds no slot (holdsSlot), not just for a new id. It also closes our create-then-cancel suggestion with a new owned quota (ids owned in any status, default 200, checked for new ids only, validated in policyProblems, exposed in GET /v1/quota and openapi). Tests cover the revive path through both routes, the cancel loop, and the default. examples.test.sh's M1 check now follows the policy's reference grammar and has positive and negative cases. All 18 checks are green.

Still open, not blocking (untouched by this push): our suggestion that twin matches builds of any status, retired included (host-handlers.ts:402), and clawgenti's suggestion about the host-agent.sh claim loop sharing stdin with template-build.sh.

Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (control-plane), Shell test, OpenAPI/docs
Agent/IDE config (.claude/.vscode): none
Commits: 5 new (4 from #766 + merge), all signed-off: yes
CI status: 18/18 passing

AI-assisted review, approved by a maintainer before posting.

Conflicts: none.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@webchang

Copy link
Copy Markdown
Member Author

Merged main (d4babb8). CI is the full check: local tests ran on the existing node_modules during the hono pin's release-age window.

Assisted-By: Claude Code

Brings in upstream main (lease modes, API 1.6.0) through pr/i17-build-tooling.

Conflicts:
- deploy/sbx/README.md: main's KVM host requirements (SBX0's own microvm-worker at SBX_WORKER_BIN).
- deploy/sbx/RUNBOOK.md: the upgrade notes keep this branch's worker binary paragraph, then main's
  Redis image and memory limit paragraphs; main's "14. Checking the templates" section, then this
  branch's template host agent section.
- deploy/sbx/install-host.sh: main's header and main's SBX_WORKER_BIN check (plain path characters
  only), which supersede this branch's earlier copy.
- deploy/sbx/setup.sh: ensure_settings declares both main's relay and this branch's hosts.
- deploy/sbx/tests/install-host.test.sh: main's guest RAM and SBX_WORKER_BIN cases, a superset of
  this branch's SBX_WORKER_BIN case.
- deploy/sbx/tests/setup.test.sh: this branch's store and hosts refusal line, then main's
  SBX_REDIS_IMAGE case.
- docs/api/CHANGELOG.md: this branch's host agent section, renumbered 1.7.0, above main's 1.6.0.

API version: this branch's host routes move from 1.6.0 to 1.7.0 (openapi info.version, the
changelog, and the two "API 1.6.0" mentions in docs/reference/http-api.md).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Brings in upstream main through f60db30 (turn grants, API 1.7.0) by pr/i17-build-tooling.

Conflicts:
- docs/api/CHANGELOG.md: this branch's host agent section, renumbered 1.8.0, above main's 1.7.0
  and 1.6.0.
- docs/reference/configuration.md: main's table (the grant settings) with this branch's
  SH_TEMPLATE_HOSTS row.
- packages/control-plane/src/main.ts: the sandbox config takes both this branch's templateHosts
  and main's grant TTLs.

API version: this branch's host routes move from 1.7.0 to 1.8.0 (openapi info.version, the
changelog, and the two "API 1.7.0" mentions in docs/reference/http-api.md).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…n with as failed

- A build that died with no output (killed, out of memory) left no non-blank line in its log: the
  grep for the failure's last line then exited 1, which pipefail and errexit turned into the end of
  the whole poll. The grep is guarded, so the build is reported failed (`build_failed:
  template-build.sh exit N: `) and the poll goes on to its summary.
- One helper, fail_claimed HANDLE STEP WHY, reports {event: failed, step, message: "agent_error:
  <the agent's own fixed wording>"} best effort, counts the build failed, and logs an error only if
  that report itself fails. It is used on every way out after a claim short of `built`: a
  malformed template id or gate record path, a gate record fetch that failed, a gate record that
  does not match its digest (step gate); a building or built report not accepted, no template
  record, a record that is not JSON or names no snapshot, no manifest (step report). A record that
  is not JSON no longer ends the poll under errexit. Before, these builds stayed `building`.

The header, the RUNBOOK and the lifecycle spec name the new code.

Tests (host-agent.test.sh, bash 5 and 3.2; each fails with its fix reverted): a build that prints
only blank lines and exits 137 is reported failed and the poll ends with its summary; a gate digest
mismatch is reported failed agent_error, step gate; a failed gate fetch, no template record, and a
record that is not JSON are each reported failed, and the poll ends with its summary.

Host-side (deploy/sbx/host-agent.sh).

(cherry picked from commit 2f08e64)
(cherry picked from commit 82c724f)

Ports rossoctl#772 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…mplate update

A host's report (building, probing, failed, built) checked the build's status on the request's own
read and then wrote: an owner's cancel landing in between was overwritten, and the built report's
`build` and registration `check` records could say a cancelled build was built and registered.
Every report write now goes through one helper that finds the build as the catalog holds it,
inside the template's update queue, and refuses it (`invalid_request`, "the build is <status>; it
takes no more reports") unless it is still this host's and building, probing or built. The
`failed` record, and the built report's `build` and registration `check` records, are appended
inside that same update, so a cancel either lands first (the report is refused, and no record says
it was built or registered) or after (the cancel finds the build registered or rejected, and
refuses). The lifecycle spec says so. The host-flow tests' host ids are neutral names.

Tests (fail with the fix reverted): keeps a cancel that lands while a built report is being written
(re-checked in the update; a blob write held until the owner's cancel has landed; the build stays
cancelled, `default` is not taken, and the chain holds the cancel only); refuses a report with an
unknown event, and a building report on a cancelled build.

(cherry picked from commit ba9ccd3)

Ports rossoctl#772 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
…lready has is rejected

Two builds of one template could register under one build id: a second create of the same image
and spec (another profile, or another gate record) queued a build that the host found already
built and reported with the same manifest hash. The registration check gains a rule, T.unique,
evaluated inside the template update: a build whose manifest hash another build of the template
already has is rejected, its reason naming that build and its status; the first build keeps the
id and `default`. The lifecycle spec says so.

Test (fails with the fix reverted): rejects a second build of a snapshot the template already has
(one build per build id).

(cherry picked from commit 88c17ca)

Ports rossoctl#772 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
webchang added a commit to webchang/moca that referenced this pull request Nov 13, 2026
A server-level test, as egress has, serves buildHandler and calls all five host routes: host-1's
token is 401 on every host-2 path (and claims nothing), while each host's token is admitted on its
own; no token, a wrong one, a user API token, and the janitor, egress and exchange bearers are 401;
with no host configured every host route is 401 even with a well-formed host token. The first
test fails if the path-host binding in the router's host authorization is removed.

Test-only.

(cherry picked from commit 730c71e)

Ports rossoctl#772 review fixes

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Brings in upstream main through 949dc5f (template tags, edits and owner transfer, API 1.8.0) by
pr/i17-build-tooling.

Conflicts:
- docs/api/CHANGELOG.md: this branch's host agent section, renumbered 1.9.0, above main's 1.8.0,
  1.7.0 and 1.6.0.
- docs/reference/change-policy.md: version 1.9.0; main's list, then the template host agents.
- docs/reference/http-api.md: main's template admin row and paragraph, then this branch's host
  agent row and paragraph (API 1.9.0).
- docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md: the status line names both
  §5.1-§5.2 and §6.1; main's §5, then this branch's §6.1.
- packages/control-plane/src/sandbox-handlers.ts: createBuild takes main's owner-transfer retry
  (OWNER_MOVED), with this branch's queuedAtMs on the new build.

API version: this branch's host routes move from 1.8.0 to 1.9.0 (openapi info.version, the
changelog, change-policy and the two "API 1.8.0" mentions in docs/reference/http-api.md).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Brings in upstream main through ab8d10e (setup.sh's Redis image guard, the image's old esbuild
dropped) by pr/i17-build-tooling. No conflicts; setup.sh's Redis image check and this branch's
template hosts sit in separate functions.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Brings rossoctl#771's template-register.sh fix: a symlinked env or templates
file is written through to its target, keeping the target's mode. No
conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>

@ingpaolodettori-dev ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up at 31a8c77. This is a merge of #771's 1c371ea only: it merges cleanly, and the net diff against 5de1831 is exactly that commit (same patch-id). 1c371ea (template-register.sh resolves a symlinked env/templates path, with a 40-level cap, then reads the target's mode with stat -L, writes the temp file beside the target and mvs it over the target, so the link stays a link. A path that doesn't resolve to a regular file is refused. Test 7 covers a relative and an absolute link with modes 600/640.) No own code changed. No new findings.

CI: deploy-scripts is red ("Run deploy shell tests", exit 2). It was green at 5de1831. The only change since then is the template-register fix, and that is byte-identical at #771 1c371ea and #775 92bb123, where deploy-scripts passes. Please re-run it before merging.

Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: merge only, no new own commits; DCO pass
CI status: all green except deploy-scripts (likely flaky, see above)

AI-assisted review, approved by a maintainer before posting.

Main took API 1.9.0 (subject trust for gate records), so this branch's
host-agent section moves to 1.10.0.

Conflicts:
- docs/api/CHANGELOG.md: this branch's section is now ## 1.10.0, above
  main's ## 1.9.0 and the sections below it, which are unchanged.
- docs/reference/change-policy.md: main's list, then "the template host
  agents". Both version numbers are 1.10.0.
- docs/reference/configuration.md: main's SH_GATE_RECORD_SCHEMA row, then
  this branch's SH_TEMPLATE_HOSTS row.
- packages/control-plane/src/template-catalog.ts: TemplateBuild has both
  sides' fields: queuedAtMs and claim, and selfAttested,
  selfAttestProfile and gateFloor.

Also moved to 1.10.0: openapi info.version, and http-api.md's host-agent
row and "came with API" line.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Brings rossoctl#773's verify cache, now merged.

Conflict:
- deploy/sbx/tests/install-host.test.sh: the two-worker check keeps this
  branch's template-record and SANDBOX_TEMPLATE checks, plus main's
  SH_VERIFY_CACHE_DIR check, with this branch's pass line.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@webchang
webchang merged commit 53b9e55 into rossoctl:main Nov 14, 2026
18 checks passed
pdettori pushed a commit that referenced this pull request Nov 16, 2026
… stderr if it never listens

The test waited 5 s (50 x 0.1 s) for the mock's 'listening' line. On a busy CI runner, node's cold
start outlasted that twice (#760, #772). The port then stayed empty, and every later check ran
curl against port 80, failing 80-odd checks with nothing about the cause. Wait up to 30 s, stop
early if the mock exits, and when it never listens fail once with its stderr.

Closes #826

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A host agent that builds queued templates, and the control plane's host routes that register them

4 participants