Skip to content

docs(sbx): a recipe for reproducing a member's issue (#857 R4) - #880

Merged
webchang merged 2 commits into
rossoctl:mainfrom
webchang:pr/i857-repro-recipe
Nov 18, 2026
Merged

webchang merged 2 commits into
rossoctl:mainfrom
webchang:pr/i857-repro-recipe

Conversation

@webchang

Copy link
Copy Markdown
Member

Part of #857 (R4): a runbook recipe for reproducing a member's issue

What changed and why

  • deploy/sbx/RUNBOOK.md gains Reproducing a member's issue, so an operator who did not write
    the tooling can assemble one bundle for one sandbox. It covers:
    • who and when: the sandbox's owner, template and times from mocactl sbx ls --all --json, and
      the fact that the host logs the sandbox under its workspace key, which is the sandbox id;
    • the member's --record file: where the flag goes (after sbx <command> or run), which
      commands refuse it, what a line holds, what is hashed or reduced to a length, the 0600 file,
      and that Exec calls (gRPC) are not in it;
    • the egress log: mocactl sbx egress <id> --ndjson, then --verify as a separate run (the
      CLI refuses both flags together), and what --verify prints;
    • the control plane's "event":"audit" lines (--timestamps, since these lines carry no time),
      the relay's "audit":"sandbox_*" lines, the Redis stream sh:cp:audit, and the KVM host's
      sbx-worker@<wrk>, sbx-janitor and moca-egress journals, each with the exact command and
      a jq or awk filter on sandboxId/subject, sbx/sub, wsk or sid;
    • host load: R2 will add samples; until then status.sh --host is a one-shot view of now
      (unit states, the workspace df, the janitor), with no CPU, memory or pressure figures;
    • what is not stored: no command text or output server-side (the relay's cmd only with the
      debug flag SH_SANDBOX_AUDIT_COMMANDS=1, as in the security review), and today's retention
      for pod stdout, sh:cp:audit (trimmed to about 1,000,000 entries), egress logs and journald;
    • a note that the queries move to the R1 pipeline once one is chosen.
  • docs/sbx/user-guide.md links the section from its operator pointer and from the --record
    paragraph, so a member knows why an operator may ask for a record.

How it was checked

  • Against the code, not on a live deployment yet. Each command, flag and field name was read in
    the source it cites: packages/mocactl/src/sbx/cli.ts and call-record.ts (--record),
    packages/mocactl/src/sbx/commands.ts (cmdEgress, verifyEgress),
    packages/control-plane/src/handler-util.ts, ownership.ts, sandbox-handlers.ts,
    egress-log.ts, routes.ts, packages/sandbox-relay/src/sandbox-caller.ts,
    remote-worker/internal/vmpool, remote-worker/internal/egress/audit.go,
    deploy/sbx/janitor.sh, host-agent.sh, status.sh, setup.sh, and the Deployment and
    container names in deploy/k8s/base and deploy/k8s/overlays/ocp-sbx.
  • Each jq and awk filter was run on sample lines built in the shapes those sources write
    (including non-JSON lines mixed in, which the filters skip).
  • npx prettier --check on both files and python3 scripts/check-doc-links.py (0 broken links).

Out of scope

  • R1 (the log pipeline and the 30-day retention): the section's queries move there once chosen.
  • R2 (the host resource sampler): next, as agreed on the issue; step 4 then reads its samples.
  • R3 (whether to turn on command auditing for the cohort): a policy decision; the section states
    today's behavior only.
  • R5 (guest console capture).

Every commit is signed off (DCO).

Assisted-By: Claude Code

Adds "Reproducing a member's issue" to deploy/sbx/RUNBOOK.md: the member's
`--record` file, the sandbox's egress log (`sbx egress --ndjson`, then
`--verify`), and the control-plane, relay, Redis `sh:cp:audit` and KVM-host
journal lines for one sandbox id or subject in a time window, with commands
and jq filters checked against the line formats in the code. It says what is
not stored (no command text or output, unless the relay's debug flag) and the
retention as it is today, points to the R2 sampler for host load (status.sh
--host until then), and notes the queries move to the R1 pipeline once one is
chosen. The user guide links to it.

Part of rossoctl#857

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>

@pdettori pdettori left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Summary

Docs-only: a recipe for assembling one bundle per sandbox when a member reports a problem, linked from the user guide. I checked every command, flag and field name against the code on this head: the NO_RECORD set and the exit-2 refusals, --ndjson/--verify exclusivity and their output strings, epoch-seconds createdAt, the timestamp-less stdout audit line, XADD * ids on sh:cp:audit (so XRANGE by ms works), the relay's ISO ts (so the string <= $to compare is valid), Deployment/container/redis-0 names (redis-cli authenticates from the container's REDISCLI_AUTH), workspace_key=%q, egress sid/via, the egress caps and 600 s grace, the trim lengths, and the §2/§7/§8 cross-references. I also ran the control-plane jq filter, ms() and the Redis awk filter on sample lines. One small accuracy issue in the awk filter's $SUB use, inline.

Author: webchang (MEMBER — maintainer)
Areas reviewed: Docs (shell/jq/awk snippets in Markdown)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing

Assisted-By: Claude Code

Comment thread deploy/sbx/RUNBOOK.md Outdated
{ r = r " " $0 } END { if (r ~ k) print r }'
```

Each line printed is one entry: its id, then its fields and values. Use `-v k="$SUB"` for the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

suggestion: -v k="$SUB" over-matches: r ~ k is a substring regex match and subjects are github:<numeric id>, so github:1 also prints github:12's and github:100's entries (reproduced on sample XRANGE output: two entries instead of one). $SBX is safe because ids are a fixed sbx- + 26 hex. Matching the whole value avoids it:

awk -v k=" $SBX " '/^[0-9]+-[0-9]+$/ { if (index(r " ", k)) print r; r = $0; next }
  { r = r " " $0 } END { if (index(r " ", k)) print r }'

and -v k=" $SUB " here (tested on both cases).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a3223b9 with your filter (whole value, spaces on both sides), and the text now says why github:1 no longer matches github:12.

Comment thread deploy/sbx/RUNBOOK.md Outdated
ms() { jq -nr --arg t "$1" '$t | strptime("%Y-%m-%d %H:%M:%S") | mktime * 1000'; }
kubectl -n "$NS" exec redis-0 -c redis -- \
redis-cli XRANGE sh:cp:audit "$(ms "$FROM")" "$(ms "$TO")" |
awk -v k="$SBX" '/^[0-9]+-[0-9]+$/ { if (r ~ k) print r; r = $0; next }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: "Checked against the code:" precedes each of the five blocks, on top of the section intro saying the same. Once the recipe has had a live run, consider collapsing it to the one intro sentence so it doesn't go stale five times over.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed: once the recipe has had its first live run, I will collapse the five "Checked against the code" lines into the intro sentence, as part of that run's update.

@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 18, 2026
Review follow-up: `r ~ k` is a substring regex match, so `github:1`
also matched `github:12`'s entries. The filter now matches the whole
value with spaces on both sides (`index(r " ", " $SUB ")`), as the
reviewer suggested and tested.

Part of rossoctl#857

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@webchang
webchang merged commit 7ca12e7 into rossoctl:main Nov 18, 2026
16 checks passed
webchang added a commit to webchang/moca that referenced this pull request Nov 18, 2026
Brings rossoctl#878 (the sync /runs disconnect contract), rossoctl#880 (the RUNBOOK's
reproduction recipe) and rossoctl#882 (deploy/k8s SH_WORKSPACE_IDLE for the
container worker, default 8h). No conflicts.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 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.

2 participants