Skip to content

ENG-1112: signadot logs --sandbox (workload / resource[+step]) - #351

Merged
davixcky merged 3 commits into
mainfrom
feat/sandbox-logs
Jul 21, 2026
Merged

davixcky merged 3 commits into
mainfrom
feat/sandbox-logs

Conversation

@davixcky

@davixcky davixcky commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Extends signadot logs with a sandbox log source, over the sandbox-scoped
endpoint added in signadot/signadot#7229 (ENG-1110). Previously logs only
served jobs.

signadot logs --sandbox <sb> --workload <fork> [-c <container>] [--since 10m | --since-time <rfc3339>] [-o json|yaml]
signadot logs --sandbox <sb> --resource <name> [--step <step>] [...]

Flags

  • --sandbox — sandbox name (no short form; -s is --stream).
  • --workload — sandboxed workload (fork) name. Mutually exclusive with --resource.
  • --resource [--step] — sandbox resource; --step selects one plugin step (resource-only).
  • -c/--container — defaults to all containers.
  • --since (relative duration, converted client-side) / --since-time (RFC3339).
  • -o json|yaml — structured []ContainerLogs; default prints raw lines, [container]-prefixed when there is more than one source.
  • --job/--sandbox mutually exclusive; --stream is job-only (both enforced).

The job path is unchanged/backward-compatible.

Dependency note

Pins go-sdk to the pre-merge revision that carries Sandboxes.GetSandboxLogs
(pushed branch davido/eng-1111-sandbox-logs-client). The go-sdk is
auto-generated from the monorepo spec, so once #7229 merges and the SDK
regenerates, re-pin to that official revision. (ENG-1112 is blocked-by ENG-1111.)

Testing

Built the binary and ran it against a local minikube control plane + operator
with the endpoint deployed, over real fork and resource sandboxes:

# Case Result
1 --workload logger fork pod log lines
2 --since 6s only recent lines
3 --since-time <future> empty
4 -o yaml / -o json structured output
5 --resource prres all steps, [main]-prefixed
6 --resource prres --step step2 only that step
7-9 unknown workload / resource / step 400 surfaced with the available list
10 --workload + --resource client-side error
11 --step without --resource client-side error
12 neither --workload nor --resource client-side error
13 --job + --sandbox mutually-exclusive error
14 --stream + --sandbox mutually-exclusive error
15 --job <missing> (job path) still routes (404 from API)

Examples (run against a local cluster)

Point the CLI at your API (SIGNADOT_API_URL / SIGNADOT_ORG / SIGNADOT_API_KEY, or ~/.signadot/config.yaml), then:

$ signadot logs --sandbox demo-fork --workload web
web request handled #0
web request handled #1
web request handled #2

# only recent lines (relative duration, converted to sinceTime client-side)
$ signadot logs --sandbox demo-fork --workload web --since 6s
web request handled #358
web request handled #359
web request handled #360

# --since (relative duration) and --since-time (absolute RFC3339) select the
# same window; they are mutually exclusive.
$ signadot logs --sandbox demo-fork --workload web --since 10s
web request handled #470
web request handled #471
web request handled #472
web request handled #473
web request handled #474

$ signadot logs --sandbox demo-fork --workload web --since-time 2026-07-14T22:58:59Z
web request handled #470
web request handled #471
web request handled #472
web request handled #473
web request handled #474

$ signadot logs --sandbox demo-fork --workload web --since 10s --since-time 2026-07-14T22:58:59Z
Error: --since and --since-time are mutually exclusive

# structured output
$ signadot logs --sandbox demo-fork --workload web -o json
[
  {
    "container": "busybox",
    "logs": [
      { "message": "web request handled #0", "time": "2026-07-14T22:43:19.481195046Z" },
      ...
    ]
  }
]

# resource logs — all create steps (per-container prefix when >1 source)
$ signadot logs --sandbox demo-res --resource db
[main] provision: creating demo resource
[signadot-execunit-output-manager] {"level":"INFO","msg":"storing output in ICS","output":"out","key":"out.provision"}
[main] seed: loading fixtures
[signadot-execunit-output-manager] {"level":"INFO","msg":"storing output in ICS","output":"out","key":"out.seed"}

# a single resource step
$ signadot logs --sandbox demo-res --resource db --step provision
[main] provision: creating demo resource

$ signadot logs --sandbox demo-res --resource db --step seed
[main] seed: loading fixtures

# a specific container
$ signadot logs --sandbox demo-fork --workload web -c busybox

# error / validation behavior
$ signadot logs --sandbox demo-fork --workload nope
Error: 400 Bad Request: workload "nope" not found in sandbox "demo-fork"; loggable workloads: web

$ signadot logs --sandbox demo-res --resource db --step bogus
Error: 400 Bad Request: step "bogus" not found in resource "db"; steps: provision, seed

$ signadot logs --sandbox demo-fork --workload web --job x
Error: if any flags in the group [job sandbox] are set none of the others can be; [job sandbox] were all set

The job path is unchanged: signadot logs --job <job> [--stream stdout|stderr] [--tail N].

🤖 Generated with Claude Code

Extend 'signadot logs' with a sandbox log source over the sandbox-scoped
endpoint (ENG-1110): --sandbox with --workload (fork) or --resource[+--step],
plus -c/--container, --since (duration) / --since-time (RFC3339), and -o
json|yaml. --job and --sandbox are mutually exclusive; --stream is job-only.
Default output prints raw lines, prefixed [container] when multiple sources.

Bumps go-sdk to the (auto-generated) revision carrying Sandboxes.GetSandboxLogs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
cursor[bot]
cursor Bot approved these changes Jul 14, 2026 •
Comment thread internal/config/logs.go Resolved
--tail is job-only (server-side tail for sandbox is a fast-follow), so
--tail + --sandbox now errors. The sandbox-only selectors
(--workload/--resource/--step/--container/--since/--since-time) now error when
combined with --job. Previously these were silently ignored, which reads as
'applied'. Adds the matching cobra MarkFlagsMutuallyExclusive guards alongside
the existing job/sandbox and stream/sandbox ones.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@davixcky

Copy link
Copy Markdown
Contributor Author

Fixed in aca758f. Cross-source flags now error instead of being silently ignored:

  • --tail + --sandbox → rejected (--tail is job-only; server-side sandbox tail is the ENG-1115 fast-follow).
  • --workload/--resource/--step/--container/--since/--since-time + --job → rejected.

Done via cobra MarkFlagsMutuallyExclusive alongside the existing job/sandbox and stream/sandbox guards. Verified: each bad combo now errors at parse time; valid combos (--job --tail, --sandbox --workload --since) still pass.

@davixcky
davixcky requested a review from scott-cotton July 16, 2026 22:44
@davixcky

Copy link
Copy Markdown
Contributor Author

@scott-cotton this is ready for other pass

@scott-cotton scott-cotton 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.

LGTM

remember to merge the go-sdk which it uses and add that to go.mod

Re-pin go-sdk from the pre-merge bridge branch to the auto-generated revision
(ENG-1111, from the merged ENG-1110 spec). That regen also carries the
principal-identity CreatedBy rework, so FormatCreatedBy now renders the new
Kind/Name/PublicID fields (was ActorType/UserEmail/APIKeyMasked). go build ./...
green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@cursor cursor Bot 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.

Risk: medium. Cursor Bugbot is not configured on this PR; evaluated using remaining signals. Approving this focused CLI logs feature with human approval present and bounded scope.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@davixcky
davixcky merged commit 482d7a6 into main Jul 21, 2026
1 check passed
@davixcky
davixcky deleted the feat/sandbox-logs branch July 21, 2026 19:21
foxish pushed a commit that referenced this pull request Jul 30, 2026
## What

Adds `-f/--follow` to `signadot logs` for the **sandbox** path
(ENG-1113).

Stacked on #351 (ENG-1112) — base is `feat/sandbox-logs`; will retarget
to `main` once #351 merges.

The sandbox-scoped endpoint is a point-in-time snapshot, so follow tails
by polling on an interval (2s) and advancing `sinceTime`. Native pod-log
streaming is a fast-follow (ENG-1115). The job path already streams via
SSE and is unchanged.

## Correctness

- **Per-container de-dup.** All containers share a single `sinceTime`
per request, so a global high-water mark would drop lines from a lagging
container. Instead each container is de-duped against its own
last-printed timestamp, and the next poll uses the *oldest*
per-container high-water mark — no lost or repeated lines across
multiple containers.
- **Error handling.** The first poll surfaces selector errors (unknown
workload/container/resource/step) so a typo fails fast; subsequent
transient errors (pod not running yet, restarts) are reported once to
stderr and retried.
- **Graceful stop** on SIGINT/SIGTERM.
- Rejected with `-o json|yaml` (follow streams plain lines only).

## Testing (live, local cluster)

Followed a 2-container fork (`app` + `sidecar`, each logging every 1s):

```console
$ signadot logs --sandbox follow-test --workload multi -f
[app] APP 0
[sidecar] SIDE 0
[app] APP 1
...
```

- ~10s of `-f`: **70 lines, 70 unique (0 duplicates)**, 35 `[app]` + 35
`[sidecar]`, sequential with no gaps.
- `-f -c app` → single container, raw (unprefixed), tails live.
- `-f -o json` → `Error: --follow cannot be combined with -o json`.
- `-f --workload nope` → first poll surfaces `400 … workload "nope" not
found …`.
- SIGTERM/Ctrl-C → stops promptly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants