Repository navigation
feat(sbx,mocactl): the host agent ships egress events; sbx egress and verify-provenance --egress - #792
Conversation
…rol plane
In its --wanted-only runs (every 15 s) the host agent now reads moca-egress's
journal after its cursor and posts the proxy's audit events, unchanged, to
POST /v1/hosts/{host}/egress, in batches of up to 1000, at most 10 per run,
within a 120 s budget. It never acts on the proxy, and is off unless
moca-egress.service is active.
- Only this host's sandboxes' events leave the host: the wanted state's
egressSids is the list; other workloads' events on the same proxy stay,
counted only (egressNotOurs). audit_dropped reports are sent. A control plane
without egressSids gets nothing.
- A failed post keeps the batch and the cursor, and the next run re-sends the
same batch (the control plane is idempotent by host and cursor). A batch
refused as malformed (400) is kept in egress.rejected/ and the cursor moves
past it. A cursor the journal no longer holds restarts from this boot,
skipping entries already sent by a position mark. An event over 8 KiB is sent
as its sid only (oversized). All files 0600 under $SBX_SRV.
- The --wanted-only summary gains egress, egressRead, egressAccepted,
egressRefused, egressSkipped, egressRejected and egressNotOurs.
- The RUNBOOK's "Egress records" section; remote-worker egress tests pin
RedactPath on request lines and the Event fields as the wire format the
control plane stores. The proxy itself is unchanged: a secret a guest puts in
a URL path segment is logged as sent.
Refs rossoctl#752
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
The client side of per-sandbox egress records: - mocactl sbx egress [ID] [--json | --ndjson | --verify]: the sandbox's egress per destination host, then whether the log is complete and its digest; --json reads every page and prints the events and the summary; --ndjson prints the log byte for byte, whose sha256 the sandbox's end record names; --verify checks the served log's sha256 and line count against the summary (exit 0 only when both match). The owner or an admin; another user's sandbox is the same not-found as sbx token. - verify-provenance.py EXPORT --egress SANDBOX_ID=FILE (repeatable, optional): a saved copy of a sandbox's log against the egress of the newest `sandbox` record naming it (its end record, or a later state: egress record); prints dropped and complete as recorded, with droppedBy's reasons. Without --egress nothing about egress is checked. Its cases run in the control plane's provenance tests. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
This PR makes the host agent ship the egress proxy's journal events to the control plane, and adds verify-provenance.py --egress and mocactl sbx egress. The shipping loop is careful about failure:
- A pending-batch file plus the cursor make retries idempotent.
- Malformed batches are quarantined instead of retried forever.
- The bearer stays out of argv and logs (
-H @file, 0600). - Only this host's sandboxes' events leave it.
- The server, the verifier and mocactl compute the digest the same way.
I reviewed this PR's own commits, cac7985..67ae5df.
Must-fix:
- journalctl without
--allsilently drops every event over 4 KiB (host-agent.sh:417). A field over 4096 bytes comes out asnulland fails.MESSAGE | strings. The event is then never sent and never counted, the cursor moves past it, and the log still reads complete. I ran a real journald (systemd 257) with proxy-shaped events of 4000, 4100 and 9000 bytes:- without
--all, the PR's filter gave{"events":[],"oversized":[]}; - with
--all, it gave{"events":[4001,4101],"oversized":["s1"]}.
- without
The rest are suggestions, inline: the stale-cursor recovery is barely reachable on a real journalctl, and --verify checks less than it says and can race on a live sandbox.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: shell (host-agent.sh, host-agent.test.sh, bash 3.2 constructs), Python (verify-provenance.py --egress), TypeScript (mocactl sbx egress), Go (internal/egress tests), RUNBOOK
- Agent/IDE config (.claude/.vscode): none
- Commits: 50 in the branch (2 of them this PR's own), all signed-off: yes
- CI status: pending (DCO, lint and shellcheck pass; the rest are still running)
Verified by:
host-agent.test.sh(bash 5.2): pass.go test ./internal/egress/: ok.- mocactl vitest
sbx-egressandcontract: 53/53 pass. - control-plane
provenance.test.ts: 33/33 pass. - Throwaway journald/journalctl 257 probes for the 4 KiB field limit and the cursor behaviour. They are deleted.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| entries="$WORK/egress.entries" | ||
| # journalctl's own exit status, written aside: the pipe's is head's, and head stopping early is a | ||
| # SIGPIPE (141) for a full batch, not a failure. (A && B || C keeps set -e out of the subshell.) | ||
| { journalctl -u moca-egress.service -o json --no-pager "${pos[@]}" 2>"$WORK/egress.jerr" && echo 0 >"$WORK/egress.jrc" || |
There was a problem hiding this comment.
must-fix: journalctl -o json without --all prints any field over 4096 bytes as null. A long MESSAGE then fails .MESSAGE | strings at L449. The event is not sent, not counted in oversized or egressNotOurs, and the cursor moves past it. So the "over 8 KiB, sent as oversized" path almost never runs, and every event between about 4 and 8 KiB, which is a guest's long path, is lost while the log reads complete. I checked this with a real journald (systemd 257) and events with paths of 4000, 4100 and 9000 bytes:
- without
--all:{"events":[],"oversized":[]}; - with
--all:{"events":[4001,4101],"oversized":["s1"]}.
The test mock always prints MESSAGE as a string, so the suite can't see this.
Suggested fix: add --all here. Make the mock print null for a field over 4096 bytes unless it gets --all, and add a 5 KiB case. Optionally, count a moca-egress entry whose MESSAGE isn't a string as dropped rather than skipping it.
| # - A batch the control plane refuses as malformed (400 invalid_request or invalid_json) would fail | ||
| # every retry, so it is moved to $SBX_SRV/egress.rejected/<UTC time>-<pid>.json (0600), the cursor | ||
| # moves past it, and the error names the file: nothing is lost silently, and shipping goes on. | ||
| # - A cursor journalctl can no longer seek to (rotated away, or another machine's) is an error; it is |
There was a problem hiding this comment.
suggestion: real journalctl (257) rarely fails the way this describes. It exits 1 only for a cursor it cannot parse (bogus gives "Failed to seek to cursor").
- A well-formed cursor whose entries were vacuumed away (
--rotate, then--vacuum-files=1) returns rc=0 and resumes at the nearest kept entry. - Another machine's cursor also returns rc=0: journalctl falls back to time and returns entries from across boots, because
-bisn't passed with--after-cursor.
So the mark/catchup path (L421–431) is mostly dead code. The other-machine case can re-send entries that the server's (host, last cursor) replay check won't dedupe. The mock's exit 1 for an unknown cursor doesn't match real journalctl either.
Suggested fix: either re-word this header and the RUNBOOK (deploy/sbx/RUNBOOK.md:413) to match real behaviour, or detect staleness yourself (check the first entry's __CURSOR/_BOOT_ID against egress.mark) and apply the mark skip in every case. Fix the mock either way.
| * verify-provenance.py --egress checks a saved copy against the record). Exit 0 only when both match. | ||
| */ | ||
| async function verifyEgress(c: SbxCtx, id: string): Promise<number> { | ||
| const summary = (await c.api.sandboxEgress(id, { limit: 1 })).summary; |
There was a problem hiding this comment.
suggestion: --verify compares the NDJSON against the summary from a separate, earlier GET, which the server recomputes from the same stored lines (summarize()). It never reads the end record, though the usage text (cli.ts:79) says it checks "against it". So it catches only transport damage or a change between the two requests. On a live sandbox, events posted between the two GETs give a false "NOT verified" with exit 1.
Suggested fix: compare against the newest sandbox record's egress, as verify-provenance.py does, or re-word the docs. For the race, fetch the NDJSON first and compare line counts, or say --verify is only meaningful once the log is sealed.
Signed-off-by: Rong Chang <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
clawgenti reviewed this PR at bb67aef. Their must-fix matches ours, and I +1 it. I'm not repeating it inline: journalctl -o json without --all prints any field over 4096 bytes as null, so events between about 4 and 8 KiB are silently skipped, the cursor moves past them, and the log still reads complete (host-agent.sh:443). I also agree with their stale-cursor suggestion (host-agent.sh:56) and their --verify suggestion (commands.ts:397). They cover our own notes on the same points.
What this review adds, inline:
- must-fix: the
egressSidssnapshot is taken from the wanted state before the journal read. The first events of a sandbox created between the two are countednotOursand dropped for good, the cursor moves past them, anddroppedstays 0 (host-agent.sh:476). - the RUNBOOK's offline check reads the log before the 600 s post-end window closes.
- nits in mocactl (
sbx egressnumber formatting, anextloop that doesn't check for progress,res.text()re-encoding), verify-provenance.py type checks, and a test header.
Since d70e2bd the pushes only merge the stack (now including #766's jq fix); this PR's own commits are unchanged. Earlier, the head d70e2bd only merges #791's new head (3ccf433). --remerge-diff is empty, and this PR's own commits (cac7985..67ae5df) are unchanged. I re-checked the snapshot must-fix at this head: egress() still reads egressSids from $WORK/wanted.json, which activation() wrote before journalctl runs (host-agent.sh:331/428).
Author: webchang (MEMBER — maintainer)
Own range reviewed: cac7985..67ae5df (2 commits)
Areas reviewed: Shell (host-agent.sh + tests), Python (verify-provenance.py), TypeScript mocactl, RUNBOOK
Agent/IDE config (.claude/.vscode): none
Commits: own commits signed off: yes
CI status: 2 pass (deploy-scripts green), 13 pending.
AI-assisted review, approved by a maintainer before posting.
| (umask 077 && jq -cs --arg b "$mb" --argjson m "$mm" --slurpfile s "$sids" '(last | .__CURSOR) as $c | ||
| | [.[] | select(._BOOT_ID != $b or ((.__MONOTONIC_TIMESTAMP // "0") | tonumber) > $m)] | ||
| | [.[] | .MESSAGE | strings | (try fromjson catch null) | objects | select(.via == "moca-egress")] as $every | ||
| | [$every[] | select((.decision == "audit_dropped" and ((.sid // "") == "")) or (.sid as $x | $s[0] | index([$x]) != null))] as $all |
There was a problem hiding this comment.
must-fix: egressSids comes from the wanted state that activation() read at the start of the run. egress() then reads the journal up to its current end, which can be up to 120 s later within one run, and in any case after the GET. Events are posted only if their sid is in that snapshot. Otherwise they are counted egressNotOurs, kept out of the post, and the cursor still advances past them via egress_advance or the post's cursor.
Failure scenario: a sandbox is created and its guest starts egress (a pip install at boot, say) between the wanted GET and the journalctl read. Those events carry its wsk, which is not in egressSids yet. They are dropped for good. The server would have accepted them, because hostEgress checks against a fresh hostSandboxes. Nothing marks the log incomplete: dropped stays 0 and complete stays true. The 15 s cadence keeps the window small, but it is hit routinely at sandbox start, the moment the egress record matters most.
Fix, either of:
- Read the wanted state after the journal batch is taken. For example, re-GET
egressSidsper batch, or once after the read when any notOurs sid looks like a sandbox wsk (sbx-prefix). - Hold back the cursor at the first notOurs event whose sid matches the SBX wsk pattern and was not seen in the previous run's list.
The simplest correct option is to fetch egressSids after journalctl returns, for each batch.
| record (`sandbox`, `state: terminated`) names `egress: {events, sha256, dropped, droppedBy, complete}`; if events | ||
| arrive in the 600 s after the end, a later `sandbox` record with `state: egress` names the final | ||
| log. The grader decides whether an incomplete log still counts. | ||
| - **Check a saved copy offline:** `mocactl sbx egress ID --ndjson > log.ndjson` after the sandbox |
There was a problem hiding this comment.
suggestion: The server takes events for EGRESS_GRACE_S=600 s after a sandbox ends. If the log changes in that window, the janitor's seal writes a later state: egress record, which the same section describes. A copy saved right after the end therefore fails verify-provenance.py --egress against an export taken after the seal: it no longer matches the newest record. Suggest: save the copy once the log is sealed (summary.sealed: true in mocactl sbx egress --json, or more than 10 minutes after the end), and take the export after that too. sbx egress could also print sealed in its text output so the user can tell.
| .map(([d, n]) => `${sanitizeRemote(d)} ${n}`) | ||
| .join(', '); | ||
| c.io.out( | ||
| `${sanitizeRemote(host || '-').padEnd(40)} ${String(h.count).padStart(6)} ` + |
There was a problem hiding this comment.
nit: Host and decision names are sanitized, but h.count, h.bytesUp, h.bytesDown, the decision counts n, summary.total and summary.dropped are interpolated straight from the server's JSON. The types say number, but nothing checks that. A hostile or compromised control-plane URL (the threat sanitizeRemote exists for) could send strings with terminal escape sequences. The verify path has the same issue with summary.total and summary.dropped. Suggest coercing with Number(x) (printing ? when not finite) or routing through sanitizeRemote(String(x)).
| const summary = page.summary; | ||
| if (c.json) { | ||
| const events = [...page.events]; | ||
| while (page.next !== null) { |
There was a problem hiding this comment.
nit: while (page.next !== null) trusts the server to move forward. A server that answers the same next loops forever, building up memory. Break when page.next equals the previous value. The printed summary is the first page's, so for a live log it may not describe the events collected afterwards. Use the last page's summary, which is computed per request on the server.
| if got != named.get("sha256"): | ||
| errors.append(f"egress {sandbox_id}: the file's sha256 is {got}, the record names {named.get('sha256')}") | ||
| lines = data.count(b"\n") | ||
| if lines != named.get("events") or (data and not data.endswith(b"\n")): |
There was a problem hiding this comment.
nit: In Python, 1 == True and 1 == 1.0, so a record naming events: true matches a one-line file. named.get("sha256") is not checked to be a sha256:<64 hex> string. The digest chain makes a forged record unlikely, but the check is meant to fail closed. Suggest isinstance(named.get("events"), int) and not isinstance(named.get("events"), bool), plus a DIGEST_RE match on named.get("sha256"), failing with a clear message otherwise.
| printf '{"run":[],"stop":[]}' >"$TMP/state/wanted-answer" | ||
| pass 'with --wanted-only, applies the wanted state and claims nothing; one run at a time applies it' | ||
|
|
||
| # 13. The egress step, in --wanted-only runs: off unless moca-egress is enabled (no |
There was a problem hiding this comment.
nit: Section 13's header says "off unless moca-egress is enabled". The test below asserts the opposite, correctly: enabled but not active is off, and active but not enabled is on. Reword it to "off unless moca-egress is active".
| const res = await this.request('GET', `/v1/sandboxes/${encodeURIComponent(id)}/egress`, { | ||
| query: { format: 'ndjson' }, | ||
| }); | ||
| return res.text(); |
There was a problem hiding this comment.
nit: res.text() decodes as UTF-8, replacing invalid sequences and stripping a BOM. --ndjson then re-encodes it. The server's canonical lines are valid UTF-8 today, so this works. But --ndjson is documented as byte-for-byte, and --verify hashes the decoded string. Read Buffer.from(await res.arrayBuffer()), write those bytes, and hash them, so the guarantee does not depend on the decoder.
clawgenti
left a comment
There was a problem hiding this comment.
Re-review at 103d483. Since our last review (bb67aef) the head has changed only by merging in base updates (#791 and, through it, #771 and #785). This PR's own commits, d488cd1 and 67ae5df, are unchanged (git range-diff: identical), so the must-fix from that review is still open at head:
- journalctl without
--allsilently drops every event over 4 KiB (deploy/sbx/host-agent.sh:443). The call is stilljournalctl -u moca-egress.service -o json --no-pagerwith no--all. A field over 4096 bytes comes out asnull, so the event is never sent and never counted, and the log still reads complete.
The inline suggestions from the last review still apply too: the stale-cursor recovery is barely reachable, and --verify checks less than it says. This PR also carries #791's open must-fixes (the event-count budget, and seal-before-record), because it stacks on #791.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: the merge delta (base-only), with host-agent.sh's journal read re-checked at head
- Agent/IDE config (.claude/.vscode): none
- Commits: 72 in the branch (2 of them this PR's own, unchanged), all signed-off: yes
- CI status: passing (17/17)
Verified by:
git range-diffof the own commits against the last review, and a re-read of host-agent.sh:440-446 at head.- control-plane
vitest runwith a local Redis: 1413 pass, 3 skipped, 0 fail. - mocactl: 1737 pass, 1 fail, in
sbx-up.test.ts(rm's file-system-error message). This PR doesn't touch that test, and the same test failed in our last run.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
journalctl -o json prints a field over 4096 bytes as null unless --all is given, so a proxy event of about 4-8 KiB failed the MESSAGE string filter: it was neither sent nor counted, the cursor moved past it, and the log still read complete. The agent now passes --all. The test's journalctl mock prints a MESSAGE over 4096 bytes as null without --all, as the real one does, and a 5 KiB event is checked to be sent whole. A journal entry whose MESSAGE is not text (journalctl's array of bytes for one that is not UTF-8) cannot be read for its sid: it is now said in an error line instead of being passed over silently. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
The egress step took its sandbox list (egressSids) from the wanted state that activation read before journalctl ran. A sandbox created in between, with egress at its start, had its first events counted egressNotOurs and left out for good while the cursor moved past them, and its log still read complete. Now a batch with any sid not in the list reads the wanted state again, after the journal read, and is selected again with the union of both lists. If that read fails, nothing is sent and the cursor stays. A batch of known sids only makes no extra request. Tests: a sandbox whose sid is only in the second read has its events sent; a failed second read sends nothing and keeps the cursor. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…r it The stale-cursor path assumed journalctl fails on a cursor whose entry is gone. It fails only on a cursor it cannot parse: a well-formed cursor whose entry was vacuumed resumes at the nearest kept entry, and another machine's cursor falls back to time and reads across boots, both with exit 0. The second could re-send entries the control plane cannot tell from new ones, and the restart path was mostly unreachable. Before its first read the egress step now checks that the cursor still names an entry: journalctl --cursor starts at that entry, so the first entry printed must carry the same cursor. If it does not, or journalctl fails on it, the cursor is stale and handled as before (kept as egress.cursor.stale, a restart from this boot, the position mark's skip). The error now says that entries rotated away before they were sent are lost. The test's journalctl mock now behaves as journalctl does: exit 1 only for a cursor it cannot parse, a fallback to every entry with exit 0 for a well-formed one it does not have, and --cursor support. The header and the RUNBOOK say the real behaviour. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… activation's The egress section's header said "off unless moca-egress is enabled" while its test asserts the opposite: enabled but not active is off, active but not enabled is on. It now says "active". The egress sections reused the numbers 13 and 14 of the activation sections; they are now 15 to 19, and the egressSids section's header names the second read. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ead before the summary --ndjson read the log with res.text(), which decodes UTF-8 (replacing invalid sequences, stripping a BOM), and wrote it re-encoded; --verify hashed the decoded string. The client now reads the bytes (arrayBuffer), writes them as they are, and hashes and counts lines on them, so the byte-for-byte guarantee does not depend on the decoder. --verify compared the log against a summary fetched before it, so on a live sandbox events posted in between gave a false "NOT verified". It now reads the log first and the summary after; when the log is open (not sealed) and the summary names more events than were read, it says the log gained events while it was read, and to verify again or once it is sealed. The usage text and the comment now say what it checks: the log served against the control plane's summary of it, not the end record (verify-provenance.py --egress checks a saved copy against an export). It also prints whether the log is sealed, and prints a server number that is not a number as "?". Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… a repeated page The text output interpolated each host's count and byte counts, the decision counts and the summary's total and dropped straight from the server's JSON: the types say number, but nothing checked it, so a hostile control plane URL could send terminal escape sequences there. They are now printed only when they are finite numbers, "?" otherwise (the sha256 goes through sanitizeRemote as a string). --json trusted the server's `next` to move forward: one that repeats a `next` looped forever, collecting memory. It now stops with an error when a `next` repeats, and prints the last page's summary rather than the first's (the server computes it per request, so for a live log it covers the events read last). Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…; sbx egress says sealed
The RUNBOOK's offline check saved the log right after the sandbox ended.
The control plane still takes events for 600 s after the end, and if the
log changes then, the janitor's seal writes a later `state: egress`
record, which a copy saved earlier no longer matches under
verify-provenance.py --egress. The RUNBOOK now says to wait until the log
is sealed (`sealed` in `mocactl sbx egress`, `summary.sealed` with
--json), then save the copy and take the export, and what --verify does
and does not check.
`mocactl sbx egress` now prints whether the log is sealed ("sealed", or
"open (not sealed yet)"; nothing from a server that does not say).
Refs rossoctl#752
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
…d sha256 types check_egress compared the file's line count with the record's `events` and its digest with `sha256` by equality. In Python True == 1, so a record naming `events: true` matched a one-line file, and `sha256` was never checked to be a sha256:<64 hex> string. The check is meant to fail closed: `events` must now be a non-negative int that is not a bool and `sha256` must match the digest pattern, or the sandbox fails with a message naming the field. Test: records with events true, "1" or -1, and with a sha256 of the wrong shape, all fail. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… the API now sends it The egress route now sends `summary` on the first page only (it reads the whole log) and null on the pages after `after`. SbxEgressPage's summary is nullable; `sbx egress --json` prints the first page's summary again, and a first page without one is an error rather than a crash. Test: a later page's null summary is fine. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev1.
|
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Reviewed this PR's own range on top of #791 (f4983fc..fd29179, 11 files): the host agent's egress step in host-agent.sh, verify-provenance.py --egress, and mocactl sbx egress [--json|--ndjson|--verify]. The egress step stays safe when things fail: a pending batch is re-sent with the same cursor, a malformed batch goes to egress.rejected/, a stale cursor is detected before any read, and egressSids is read again after the journal read. Its limits match the control plane's: 1000 events per post (EGRESS_POST_MAX), events over 8 KiB sent as oversized, and a 9 MiB maxBodyBytes on hostEgress. No must-fix findings; there is one nit inline. All checks pass. Ready for human review.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell (host-agent.sh + its test), Python (verify-provenance.py), TypeScript (mocactl sbx egress, control-plane provenance test), Go (egress audit tests), Docs (RUNBOOK)
Agent/IDE config (.claude/.vscode): none
Commits: 100 commits in the stacked range (11 of them this PR's own, non-merge), all signed-off: yes
CI status: passing (DCO is the only check reported)
Verified on head fd29179: deploy/sbx/tests/host-agent.test.sh passes (all cases, 23 s here); go test ./internal/egress ok, gofmt -l clean; mocactl vitest run test/sbx-egress.test.ts test/contract.test.ts 59/59 and tsc --noEmit clean; control-plane test/provenance.test.ts 34/34 (it includes the verify-provenance.py --egress cases).
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| # A MESSAGE that is not text (journalctl prints bytes that are not UTF-8 as an array of numbers) | ||
| # cannot be read for its sid: it is counted (unreadable) and said in an error line, never silent. | ||
| # An event over 8 KiB (a guest's long path) is not sent; its sid is, as `oversized`, and the | ||
| # control plane counts it as dropped in that sandbox's log. Nothing in an event is changed. |
There was a problem hiding this comment.
nit: The comment says "Nothing in an event is changed", and the header says events are sent "as the proxy wrote them". But egress_select decodes each MESSAGE with fromjson and jq writes it out again, so the bytes can change. Go's json.Encoder (audit.go NewJSONSink) escapes <, > and & as \u003c etc.; jq writes them as literal characters. Probe with jq 1.8.2: {"path":"/a\u003cb"} comes out as {"path":"/a<b"}. The value is the same and nothing that hashes is affected, because the control plane computes the log's sha256 over its own serialization. Still, the wording overstates what the agent does.
Suggested fix: say "no field is added, removed or changed" (the value is kept, the bytes are not), or keep the raw MESSAGE string if byte-for-byte preservation is meant.
pr/i29-egress-records now carries upstream/main: this brings upstream's sbx templates create, build, follow, cancel, quota and policy beside this branch's sbx egress. Conflicts and resolutions: - packages/mocactl/src/sbx/cli.ts: the known commands hold egress, quota and policy; this branch's --ndjson and --verify checks are kept ahead of upstream's templates subcommand checks (TAKES_TIMEOUT; --timeout with activate needs --wait). - packages/mocactl/test/contract.test.ts: upstream's scripted reply count (19, for 18 calls). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
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 |
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Follow-up at 706a45a. The range fd29179a..706a45a0 has no new commits of this PR's own: it merges upstream/main (#766's authoring commands, sbx quota, sbx policy) down the stack through #775 and #791. In 706a45a0, cli.ts's known commands hold egress, quota and policy. This branch's --ndjson/--verify checks are kept ahead of upstream's templates SUB checks, and --timeout with activate still needs --wait. The contract test keeps upstream's 19 scripted replies for 18 calls, and its method list matches every SandboxApiClient method. 8b67c9bb merged with no conflicts. This PR's own files (host-agent.sh, verify-provenance.py, sbx egress) don't change. No new findings.
The nit from the last review (egress_select re-encodes events, host-agent.sh:428) is still open, along with the human reviewer's unresolved nits.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (mocactl cli merge resolution, contract test)
Agent/IDE config (.claude/.vscode): none
Commits: 81 commits, all signed-off: yes
CI status: pending at this head (DCO passes; the other workflows are still running)
Static review only: the merge resolutions were read with git show --remerge-diff. No code from the PR was run in this pass.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
…its bytes The host agent's header and egress_select's comment said events are sent "as the proxy wrote them" and that "nothing in an event is changed", and the RUNBOOK said each event is kept "exactly as the proxy wrote it". But egress_select decodes each MESSAGE with fromjson and jq writes it out again, so the bytes can differ (Go's encoder writes `<` where jq writes `<`). The wording now says what holds: no field is added, removed or changed, and the values are kept. No digest is affected, as the control plane hashes its own canonical line. Refs rossoctl#752 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
Follow-up at d3acad1. The range 706a45a0..d3acad11 has two doc-only commits, 7743f969 (this PR's own) and 7ce0310b (merged in from #791), and changes 3 files by +10/-6. They resolve the nit from the last review (egress_select re-encodes events). host-agent.sh's header and its egress_select comment now say "no field is added, removed or changed", and that values are kept but bytes are not (Go's < comes out as <). RUNBOOK.md and egress-log.ts's doc comment now say the same. That matches the code: egress-log.ts stores and hashes canonicalJson(e), so no digest depends on the proxy's bytes. No code changes in this range, and bash -n passes on host-agent.sh at head. No new findings.
The human reviewer's unresolved nits are still open.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell (comments only), Docs, TypeScript (doc comment only)
Agent/IDE config (.claude/.vscode): none
Commits: 84 commits, all signed-off: yes
CI status: pending at this head (DCO, lint, shellcheck, docs, Trivy pass; check, deploy-scripts, microvm-gates, proto, k8s-kind-e2e and CodeQL still running)
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
clawgenti (re-review)4.
|
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Follow-up at d3acad1. Our 706a45a draft (and the fd29179 one before it) was never posted, so this review covers 103d483..d3acad1.
103d483..706a45a (checked in the earlier, unposted drafts) closes all 7 items from our 103d483 review and all 3 from clawgenti's: the egressSids snapshot must-fix (580c193, egress_sids_refresh, if the re-read fails nothing is sent and the cursor stays put, covered by §18), --all sending a MESSAGE over 4096 bytes whole and giving a non-UTF-8 MESSAGE an error line (373bdae), the stale-cursor check egress_cursor_ok (21dcb18), and the RUNBOOK, output and verify-provenance items. The main merge at 706a45a was checked with --remerge-diff and is correct.
706a45a..d3acad1 has two comment/doc-only commits: 7743f96 (own) and 7ce0310 (from #791), plus a clean merge. Together they close the jq re-serialization nit (host-agent.sh:428). The host-agent header, the egress_select comment, the RUNBOOK and egress-log.ts now say no field is added, removed or changed, and the values are kept but not the bytes. That matches the code: the control plane hashes its own canonicalJson line. The merge d3acad1 has an empty --remerge-diff. No code changes.
Author: webchang (MEMBER — maintainer)
Areas reviewed: Shell (comments only), Docs, TypeScript (doc comment only)
Agent/IDE config (.claude/.vscode): none
Commits: 2 new own/stack commits + 1 merge since 706a45a, signed off: yes (DCO pass)
CI status: 16/17 pass, k8s-kind-e2e pending
AI-assisted review, approved by a maintainer before posting.
Brings in upstream main (lease modes, API 1.6.0) through pr/i29-egress-records. No conflicts. API version: the egress records this branch's agent reads are now API 1.9.0, so its four "older than openapi 1.8.0" mentions (deploy/sbx/RUNBOOK.md, deploy/sbx/host-agent.sh and its test) say 1.9.0. 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/i29-egress-records. No conflicts. API version: the egress records this branch's agent reads are now API 1.10.0, so its four "older than openapi 1.9.0" mentions (deploy/sbx/RUNBOOK.md, deploy/sbx/host-agent.sh and its test) say 1.10.0. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Conflicts: - packages/mocactl/src/sbx/cli.ts: the dispatch keeps main's `cmdToken(ctx, id!, renewEvery)` and this branch's `egress` case. - packages/mocactl/src/sbx/commands.ts: this branch's cmdEgress and verifyEgress, then main's cmdToken with its renewEveryS doc and signature. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ead before the summary `sbx egress --ndjson` and `--verify` decoded the export as a UTF-8 string, so a BOM or a byte that is not UTF-8 changed what was printed and hashed; both now use the bytes as served. --verify read the summary before the log, so an open log that gained events in between looked damaged; it now reads the log first, and says when an open (not yet sealed) log grew while it was read. A server number that is not a number prints as `?`, never its text. The help and the doc comment say what --verify checks (the log against the control plane's summary, not the sandbox's end record). sbx-egress.test.ts: the read order, an open log that grew, raw bytes through --ndjson and --verify, a non-number total; they fail with the fix reverted. (cherry picked from commit 71684d1) Ports rossoctl#792 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…epeated page, says sealed - `sbx egress` printed a server's counts as given, so a string with escapes reached the terminal; only numbers print as numbers, anything else as `?`. Its --json paging stops on a repeated `next` instead of looping. - It takes the summary from the first page, where the API now sends it (later pages carry null; the page type says so). - It says whether the log is sealed (final: the control plane takes no more events, 600 s after the sandbox ended), and nothing from a server that does not say. The RUNBOOK says to save a log for the offline check only once it is sealed, and to deploy the control plane before the host agents' egress step. sbx-egress.test.ts: the text and --json outputs, sealed and open, a non-number count, a repeated next; they fail with the fixes reverted. (cherry picked from commit 54e9d02) (cherry picked from commit a00dd60) (cherry picked from commit e65d991) Ports rossoctl#792 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…d sha256 types check_egress compared the file's line count with the record's `events` and its digest with `sha256` by equality. In Python True == 1, so a record naming `events: true` matched a one-line file, and `sha256` was never checked to be a sha256:<64 hex> string. The check is meant to fail closed: `events` must now be a non-negative int that is not a bool and `sha256` must match the digest pattern, or the sandbox fails with a message naming the field. provenance.test.ts: records with events true, "1" or -1, and with a sha256 of the wrong shape, all fail (fails with the fix reverted). The offline verifier, not host-side code. (cherry picked from commit ec0c77a) Ports rossoctl#792 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…ads egressSids, checks its cursor - journalctl -o json prints a field over 4096 bytes as null unless --all is given, so a proxy event of about 4-8 KiB failed the MESSAGE filter: neither sent nor counted, the cursor moved past it, and the log still read complete. The agent passes --all; an entry whose MESSAGE is not text is said in an error line instead of passed over. - The egressSids list came from a wanted-state read before the journal read, so a sandbox created in between had its first events counted egressNotOurs. A batch with a sid not in the list reads the wanted state again after the journal read; if that read fails, nothing is sent and the cursor stays. - The agent checks its egress cursor before reading after it. - The egress step comment and the RUNBOOK say the step keeps each event's fields and values (no field added, removed or changed). host-agent.test.sh (bash and /bin/bash): the journalctl mock prints a MESSAGE over 4096 bytes as null without --all; a 5 KiB event is sent whole; a non-text MESSAGE is said; a new sandbox's first events are sent after the second read, and a failed second read sends nothing; the cursor check. It fails with host-agent.sh reverted. The test's host id is renamed host-1; the upstream renumbering of the test headers is not ported (the fork's sections differ). Host-side. (cherry picked from commit 373bdae) (cherry picked from commit 580c193) (cherry picked from commit 21dcb18) (cherry picked from commit 7743f96) Ports rossoctl#792 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up at a575ded (dd81d4c..a575ded). This push has no commits of this PR's own. It merges main 1016d26 (#800, #768). The PR's net diff against main is byte-identical to the one at dd81d4c. I checked the hand resolution with git show --remerge-diff and a dropped-lines check against both parents. The conflicts were in sbx/cli.ts and sbx/commands.ts. The token case now calls cmdToken(ctx, id!, renewEvery) beside this PR's egress case. The cmdEgress doc comment and body stay intact, and #768's cmdToken(c, id, renewEveryS?) keeps its own doc comment. No conflict markers are left.
Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: no new own commits; one merge of upstream main 1016d26 (#800 worker-stop VM reaping, #768 --record / sbx token --renew-every); DCO pass
CI status: all green except k8s-kind-e2e (pending at drafting time)
AI-assisted review, approved by a maintainer before posting.
Brings in upstream main through 82a4249 (API 1.13.0: template tags, edits and owner transfer, subject trust for gate records, the host agents, activation, memory placement and cold-start pacing) and the egress records at 1.14.0, by pr/i29-egress-records. Conflicts: - deploy/sbx/host-agent.sh: - the header keeps main's start limit and idle grace paragraphs; the output paragraph names both main's memory, startQueued and graced fields and this branch's egress counts; - the settings take main's SBX_SYS_ROOT, summaries and build id pattern and this branch's egress counters and batch limits; - summary() takes main's memory, start and grace fields, with this branch's egress counts right after "errors", so main's tests that read startQueued and graced last still hold. - deploy/sbx/tests/host-agent.test.sh: the header names both; main's sections 13-21 (memory, the start limit, the idle grace), then this branch's egress sections, renumbered 22-26. - packages/mocactl/src/sbx/api.ts: main's SbxReadinessReason and this branch's egress page and summary types. - packages/mocactl/src/sbx/cli.ts: both sides' command imports. Versions: this branch's "older than openapi 1.10.0" notes follow the egress records to 1.14.0 (deploy/sbx/host-agent.sh, its test and deploy/sbx/RUNBOOK.md). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Main (82a4249) merged in. Besides resolving the conflicts, the merge makes one change that this PR's own diff doesn't show:
This PR claims no openapi version of its own; it builds on #791's 1.14.0. Assisted-By: Claude Code |
Brings rossoctl#808 (sbx lease clients: mocactl create --mode, get, reset, and rm's lease step). Conflicts: - packages/mocactl/src/sbx/api.ts: this branch's sandboxEgress and sandboxEgressNdjson, then main's mintSandboxToken (with its abort signal), setSandboxMode and mintSandboxModeToken. This branch's older mintSandboxToken is dropped for main's. - packages/mocactl/src/sbx/cli.ts: TAKES_ID_ARG holds main's get and reset and this branch's egress. - packages/mocactl/src/sbx/commands.ts: this branch's cmdEgress, verifyEgress, num and sealedText, beside main's RM_LEASE_WAIT_MS and endLease. - packages/mocactl/test/contract.test.ts: both sides' routes, calls and method names. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings pr/i26-retire at upstream main d227d41 (through rossoctl#790, with rossoctl#789's combined plane and pinned-session holds, rossoctl#791/rossoctl#792 egress, rossoctl#784 pacing, rossoctl#776 memory placement and rossoctl#808), and i26's retire at API 1.18.0. This branch's quotas and reject section moves to 1.19.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.19.0 quotas and reject above i26's ## 1.18.0 and main's sections, which are unchanged. - docs/api/openapi.yaml: info.version 1.19.0. The wanted-state description is main's (memory, idle grace, pinned-session hold, start order) with this branch's admin-rejected builds in `stop`. - docs/reference/change-policy.md: main's list, then "template retire", then "admin quotas and build reject"; control plane 1.19.0, harness 1.3.0. - docs/reference/http-api.md: main's rows (egress records, Retire at 1.18.0), then the Admin row at 1.19.0. - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md: the status line names both main's §6.2/§6.5 parts and this branch's quotas and reject. - packages/control-plane/src/activation.ts: main's buildOfWorker and running-worker maps, with endedWithWorker (retired or admin-rejected) where main tests for a retired build with a worker. - packages/control-plane/src/host-handlers.ts: main's file (wantedAnswer, egress, start limit, grace), with this branch's rejectedByAdmin in the wanted state's ended branch, liveSnapshots skipping rejected builds, and `detached` taken for an admin-rejected build. - packages/control-plane/src/sandbox-handlers.ts: activationLock is main's import from activation-lock.ts (its local copy dropped, so no duplicate); this branch's templateUseLock stays. Imports carry both rejectedByAdmin and main's readinessReasonOf, startQueue, startRetryAfterS; identity.js is imported once. - packages/control-plane/test/activation.test.ts: both new placement cases. - packages/control-plane/test/openapi-contract.test.ts: 31 enrollable routes (28 + this branch's 2 + main's 1). - packages/mocactl/src/sbx/api.ts, commands.ts, cli.ts: both sides' types, imports, usage, flags and dispatch (quota and --stop-now). - packages/mocactl/test/contract.test.ts: 28 replies (25 + 1 + 2), with main's reply shape. Also: activation-lock.ts's comment says, as this branch's code does, that a reject takes the activation lock and a sandbox create takes only its template's use lock; http-api.md's "admin routes came with API 1.19.0"; the reject test reads main's wanted answer (starting, egressSids). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Brings pr/i26-retire at upstream main d227d41 (through rossoctl#790, with rossoctl#789's combined plane and pinned-session holds, rossoctl#791/rossoctl#792 egress, rossoctl#784 pacing, rossoctl#776 memory placement and rossoctl#808), and i26's retire at API 1.18.0. This branch's removal section moves to 1.19.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.19.0 removal above i26's ## 1.18.0 and main's sections, which are unchanged. The `remove` bullet names a pinned session's hold beside a live sandbox. - docs/api/openapi.yaml: info.version 1.19.0. The wanted-state description is main's (memory, idle grace, pinned-session hold, start order), with "in no list", `remove` (since 1.19.0; not under a live sandbox or a session's hold) and the shared-build rule; the response keeps main's `starting`, `graced` and `egressSids` and adds `remove`. - docs/reference/change-policy.md: main's list, then "template retire", then "retired build removal"; control plane 1.19.0, harness 1.3.0. - packages/control-plane/src/host-handlers.ts: main moved the wanted state into wantedAnswer; `remove` is built there, in the retired branch, under main's busyWorkers (a live sandbox or a pinned session's hold), and returned beside main's run, stop, starting and graced; hostWanted adds egressSids as main does. hostWorkerReport takes `removed` on main's version of it (st.running and refused kept); the host's holds drop the build on st. The header, liveSnapshots and T.unique texts are this branch's. - packages/control-plane/test/activation.test.ts: the wanted answers carry both `remove` and main's `starting`/`egressSids`. - packages/mocactl/src/sbx/cli.ts: main's usage (sbx hosts, create --mode/--idle-timeout) with this branch's retire --wait text. - deploy/sbx/host-agent.sh: main's header and run loop (run.tsv, start limit, grace), then this branch's removal() before the lock is let go; REMOVED beside main's counters; summary keeps "removed" before "errors" and main's egress, memory, start and grace fields after it. - deploy/sbx/tests/host-agent.test.sh: both mocks (install-host, journalctl) and both settings; main's sections 13-26, then this branch's removal section as 27, on a clean srv with well-formed snapshots (snapfiles), so main's memory report raises no error. - deploy/sbx/RUNBOOK.md: main's summary text with "removed". - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md: main's records table with this branch's `event: removed`; step 7 names a pinned session's hold. Also moved to 1.19.0: http-api.md's "Since API 1.19.0" and host-agent.sh's "older than API 1.19.0" comment. activation.test.ts's live-sandbox removal case reads the answer with toMatchObject: the wanted state now also carries egressSids, which list the sandbox. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #752, with #791. On main (30cd706): #791 (per-sandbox egress records through the API), which this branch stacked on, is merged. Its own change is 2 commits (review range
cac79854..67ae5dfb), plus merges of main.What it does: the host agent ships the egress proxy's events to the control plane, and the clients read and verify a sandbox's egress record. Two signed-off commits:
host-agent.shships the egress proxy's journal events, withhost-agent.test.shcases, theaudit_test.gocases and a RUNBOOK section.verify-provenance.py --egress, and mocactlsbx egress [ID] [--json|--ndjson|--verify].Notes for review:
host-agent.test.shtakes about 44 s, against 12 s on the parent.Tests on the tip:
sbx upcase is a load timeout and passes alone;host-agent.test.shpasses on bash 5 and 3.2;go testpasses forinternal/egress.11 files, +1,044 / -20, counted against #791's tip.
Assisted-By: Claude Code