Skip to content

feat(examples): add a real-runtime OpenShell smoke test - #21

Merged
kperry-godaddy merged 3 commits into
mainfrom
feat/openshell-smoke
Nov 5, 2026
Merged

kperry-godaddy merged 3 commits into
mainfrom
feat/openshell-smoke

Conversation

@kperry-godaddy

@kperry-godaddy kperry-godaddy commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Runs ans-openshell-middleware and ans-reference-callee against a real OpenShell gateway, supervisor and sandbox on the Docker driver, and asserts the identity guarantees the middleware makes. The in-process demo stands in for the supervisor; this shows what only the real runtime can: that OpenShell invokes the extension, applies its header mutations before the request leaves the sandbox, and blocks the request when the extension is down.

Motivation: the runnable, reproducible evidence proposed in NVIDIA/OpenShell#5011, and the live-gateway verification that #2 left out of the initial import, delivered as an executable check rather than a guide.

Changes

  • examples/openshell-smoke/smoke.sh downloads the pinned OpenShell release, mints all trust material into a temporary directory, builds a digest-pinned workload image with curl, starts the stack with TLS and gateway-JWT verification on and the request hook required through binding_policy, then runs five checks:
    1. an authorized sandbox's plain request is verified by the callee as the operator-assigned identity;
    2. forged identity headers sent from inside the sandbox are replaced;
    3. an unsigned direct request to the callee is rejected (401) and logged, which arms the callee-log sentinel the next two checks rely on;
    4. an unapproved sandbox is denied (middleware_denied, ans_identity_unauthorized) before the callee is reached;
    5. a request is blocked while the middleware is down (middleware_failed, fail_closed).
  • examples/openshell-smoke/openshell-release.env pins v0.1.7: the release commit, a SHA-256 per CLI and gateway asset, and manifest-list digests for the supervisor and sandbox runtime images. smoke.sh refuses any asset whose digest differs and extracts the verified tarballs fresh into the run directory.
  • examples/openshell-smoke/fixtures/ (Go) mints the fixture transparency-log root key, one identity with its receipt and status token pinned to files, the gateway's Ed25519 JWT key with a matching JWKS, and a private CA for the middleware listener. Minted keys are never retained after a run.
  • The Docker driver runs under a sandbox_label of its own per run, ans-openshell-smoke-<pid>, so neither an OpenShell install sharing the daemon nor a concurrent smoke run is touched by the gateway's startup reconciliation or by cleanup. A run removes everything under its label when it ends, failures included; a run that died before its own cleanup is reclaimed by the next run, which removes only labels whose pid no longer runs. Every external step and every teardown call runs under a deadline, cleanup survives a failing daemon and a second Ctrl-C, and supervisor container logs are kept on failure.
  • CI: .github/workflows/openshell-smoke.yml runs the harness on ubuntu-latest for pushes to main, pull requests touching the exercised code or the vendored contract, and on demand, uploading the retained logs on failure. The proto-drift job in ci.yml now also diffs the vendored extension protos against the pinned OpenShell commit, so a release bump without a contract re-pin fails CI.
  • make openshell-smoke, a Quick start pointer in the top-level README, and examples/openshell-smoke/README.md (checks, requirements, what is pinned and how, fixture trust versus production, limitations, updating the pin).

Testing

  • Eight passing runs against OpenShell v0.1.7 on Docker (Rancher Desktop, Apple silicon), including runs from an empty asset cache with the digest-pinned runtime images and the CI-style fixed temp directory. Each run finished with no containers, volumes or temp directories left behind.
  • Fault runs for the review follow-ups: two concurrent runs on one daemon both pass and neither sees the other's sandboxes; a dead run's containers and volumes are reclaimed while a foreign label is left alone; --print-config works while runs are up and changes nothing; SIGKILL of one run's gateway leaves the other serving signed requests and removes the dead run's label entirely; a double Ctrl-C cleans up fully in about three seconds.
  • go build ./..., go vet ./..., go test -race ./..., golangci-lint run (0 issues) and shellcheck on smoke.sh are clean. Library coverage is 98.5%.
  • fixtures/ coverage is 82.9%. The uncovered lines are ECDSA key-generation error returns that a test cannot reach on Go 1.26, where ecdsa.GenerateKey ignores a caller-supplied random source. Bad arguments, a non-empty output directory, filesystem errors, the fixed clock across all three certificates, and a failing random source for the Ed25519 key and the UUID are covered.
  • The GitHub-hosted Linux run passed on this PR's first CI run (run 41956864933): ubuntu-latest on x86_64 from an empty asset cache, all five checks passing against OpenShell v0.1.7, about 45 seconds from first download to teardown. Every earlier run was macOS on Apple silicon, so both supported platforms have now been exercised.

Notes for review

  • The README's Ownership section points at CONTRIBUTING.md; the maintainer roster lands with chore: adopt ANS governance and contribution licensing #14.
  • At 12 files the change is one reviewable unit, but it is above the usual line budget. Splitting the fixture generator out first would leave a PR with no consumer, so it ships together with the launcher that uses it.

Assisted by Claude Code (Claude Fable 5.1)

Run ans-openshell-middleware and ans-reference-callee against an actual
OpenShell gateway, supervisor and sandbox on the Docker driver and assert
the identity guarantees the middleware makes. The in-process demo plays the
supervisor itself; this shows what only a real runtime can: that OpenShell
invokes the service, applies its header mutations before the request leaves,
and blocks the request when the service is down.

examples/openshell-smoke/smoke.sh downloads the pinned OpenShell release
(openshell-release.env: SHA-256 per CLI and gateway asset, manifest-list
digests for the supervisor and sandbox runtime images), extracts the verified
tarballs into the run directory, mints every piece of trust material a
deployment normally receives from elsewhere into a temporary directory
(fixtures/: fixture transparency-log root key, one identity with its receipt
and status token pinned to files, the gateway's Ed25519 JWT key with matching
JWKS, a private CA for the middleware listener), builds a digest-pinned
workload image with curl, and starts the stack with TLS and gateway-JWT
verification on, the request hook required through binding_policy, and the
Docker driver scoped to its own sandbox_label so an OpenShell install sharing
the daemon is never touched. It then runs five checks: an authorized sandbox's
plain request is verified by the callee; forged identity headers are
replaced; an unsigned direct request is rejected and logged, which arms the
callee-log sentinel; an unapproved sandbox is denied before the callee; a
request is blocked while the middleware is down (fail_closed). Long external
steps run under deadlines, supervisor container logs are kept on failure, and
minted keys are never retained. All OpenShell state lives under the temporary
directory.

The proto-drift CI job now also diffs the vendored extension protos against
the pinned OpenShell commit, so a release bump without a contract re-pin
fails CI. The smoke workflow runs on ubuntu-latest for pushes to main, pull
requests touching the exercised code or the vendored contract, and on demand,
and uploads the retained logs when it fails.

Motivation: the runnable, reproducible evidence proposed in
ai-openshell/openshell#5011 and the live-gateway
verification follow-up deferred by #2.

Verified: passing runs against OpenShell v0.1.7 on Docker (Rancher Desktop,
Apple silicon), including from an empty asset cache with the digest-pinned
runtime images and the CI-style fixed temp directory.

Assisted by Claude Code (Claude Fable 5.1)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: kperry <kperry@godaddy.com>

Copilot AI 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.

🟡 Changes recommended

Concurrent smoke runs can destroy an active gateway’s supervisors, while timeout and cleanup defects can hang runs or leave host services, private keys, and Docker volumes behind.

5 open issues
What changed in this PR

Adds a reproducible OpenShell smoke test that exercises the ANS middleware and reference callee through a real gateway, supervisor and Docker sandbox, covering runtime integration left out of the initial import.

Changes:

  • Adds five checks for identity signing, forged-header replacement, unsigned-request rejection, sandbox authorization and fail-closed behavior.
  • Pins OpenShell assets and runtime images, and generates disposable identity and trust fixtures.
  • Adds CI execution, failure-log uploads, upstream protocol drift checks and usage documentation.
File Description
README.md Adds a quick-start command for the runtime smoke test.
Makefile Adds the openshell-smoke target.
examples/​openshell-smoke/​workload/​Dockerfile Provides a digest-pinned workload base with curl.
examples/​openshell-smoke/​smoke.sh Orchestrates the runtime, assertions and cleanup.
examples/​openshell-smoke/​README.md Documents requirements, checks, trust boundaries and pin updates.
examples/​openshell-smoke/​policy.template.yaml Defines restricted callee access and fail-closed middleware policy.
examples/​openshell-smoke/​openshell-release.env Pins the release commit, asset checksums and runtime image digests.
examples/​openshell-smoke/​fixtures/​main.go Generates disposable identity, JWT and TLS material.
examples/​openshell-smoke/​fixtures/​main_test.go Tests fixture loading, validity, permissions and error handling.
.gitignore Ignores the generated fixture executable.
.github/​workflows/​openshell-smoke.yml Runs the smoke test and uploads retained failure logs.
.github/​workflows/​ci.yml Checks vendored protocols against the pinned upstream commit.

Review effort: Balanced

Comment thread examples/openshell-smoke/smoke.sh Resolved
Comment thread examples/openshell-smoke/smoke.sh Resolved
Comment thread examples/openshell-smoke/smoke.sh Resolved
Comment thread examples/openshell-smoke/smoke.sh Resolved
Comment thread examples/openshell-smoke/smoke.sh Resolved
Address the five findings from the review of the smoke harness.

The gateway's startup reconciliation force-removes every supervisor
container in its sandbox_label, and the label was stable across runs, so a
second smoke run against the same daemon destroyed the first run's
sandboxes. Each run now works under a label of its own, suffixed with its
pid, so two runs on one daemon never reach each other's sandboxes and a
run that dies before its own cleanup leaves leftovers the next run can
attribute: everything under a harness label whose pid no longer runs is
removed before the gateway starts, and a label whose pid is alive is left
alone. No lock is needed; a lock keyed on the socket path or the temp
directory would not have identified the daemon anyway.

cleanup runs under set +e with SIGINT ignored. A Docker query that failed
inside the EXIT trap used to abort the trap before the host services were
stopped and the minted keys removed; now every step runs whatever fails
along the way, each one bounded (the delete RPC under a deadline, TERM then
KILL for the host processes), and nothing is retained when there is nothing
to retain. The driver creates three volumes per sandbox and removes them
after the containers in a background task; when the gateway died before its
delete RPC ran, cleanup removed only containers and the volumes stayed on
the daemon. The run's whole label, volumes included, is now removed.

On stock macOS the run_bounded watchdog subshell inherited the stdout pipe
of a "$(run_bounded ...)" capture and held it open until its sleep ended, so
a request that completed at once still took the whole deadline to return.
The watchdog's output is redirected away and its sleep is killed with it.
run_bounded also finds Homebrew's gtimeout.

Release downloads fail on a stall (under 1 KiB/s for 30 s) and retry, with
the whole retry sequence bounded to ten minutes; the proto-drift fetch in CI
carries a deadline and no longer reports a fetch failure as drift. A Docker
daemon that is down is reported before any work starts.

Verified live on Docker (Rancher Desktop, Apple silicon): two runs at once
both reach READY and neither sees the other's sandboxes; a dead run's
containers and volumes are reclaimed while a foreign label is untouched;
--print-config works while runs are up and changes nothing; SIGKILL of one
run's gateway leaves the other run working and removes the dead run's
label entirely, retaining only logs; Ctrl-C cleans up fully; a clean run
passes all five checks and leaves nothing behind.

Assisted by Claude Code (Claude Fable 5.1)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: kperry <kperry@godaddy.com>

@chou-godaddy chou-godaddy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this. I ran it locally on macOS (Apple silicon, Docker Desktop): all 5 checks pass, teardown is clean, and a separate OpenShell gateway on the same Docker daemon was left alone.

+1 to @bchen-godaddy's two follow-ups (watchdog and BIN). On a full macOS run, the watchdog wait was about 6 of the 8 minutes.

I also ran the script with a few faults (a second concurrent run, a frozen or killed gateway, a failing docker ps) to check Copilot's remaining comments and one more spot in cleanup. What I saw:

Where What happened
L156 shared label Starting a second run while one was held with --keep-running removed the first run's supervisor within about a second of the second gateway starting; the first sandbox then went to phase Error.
L194 docker ps in cleanup When it failed, cleanup stopped right after the sandbox deletes, and the run directory, including the minted fixture key, stayed on disk.
L186 sandbox delete in cleanup With the gateway frozen, cleanup was still waiting on the first delete after 90 s.
L351 downloads The same curl flags against a local server that stalls mid-response were still waiting after 60 s.
Volumes (Copilot) After killing the gateway mid-run, three sandbox volumes were left. They were gone after the next runs, which matches the comment on L436 that the next run reclaims leftovers, so this may be fine as is.

@kperry-godaddy

Copy link
Copy Markdown
Member Author

Thanks for running the faults; every row in your table reproduces what 0846f46 changes, and the first one is why the fix took a different shape than a lock.

  • Shared label: each run now works under its own sandbox_label, ans-openshell-smoke-<pid>, so a second run's gateway cannot reach the first run's supervisors at all. Two concurrent runs both pass all five checks, and killing one run's gateway leaves the other serving signed requests.
  • docker ps in cleanup: cleanup runs under set +e and ignores a second Ctrl-C, so the key removal is reached whatever fails before it.
  • sandbox delete with a frozen gateway: the delete runs under a 60 s deadline, every Docker call on the teardown path under 30 s, and the host processes get TERM then KILL.
  • Stalled download: curl now fails a transfer that drops under 1 KiB/s for 30 s and retries, with the whole retry sequence capped at ten minutes.
  • Volumes: your observation that the next run reclaimed them is now explicit. A run's own cleanup removes everything under its label, volumes included, and the next run removes only labels whose pid no longer runs, so a run in progress is never swept.

The watchdog and BIN follow-ups from @bchen-godaddy are in the same commit. On a full macOS run the watchdog fix brings sandbox_curl back to the request's own duration; the 90 s deadline is reached only when something is wrong.

@chou-godaddy

Copy link
Copy Markdown
Contributor

Reran the same fault tests against 0846f46 on macOS (Docker Desktop): all five checks pass, and each issue in my earlier table no longer reproduces: two runs at once both pass without affecting each other, cleanup finishes with a failing docker ps or a frozen or killed gateway, and a stalled download gives up. A full run without coreutils timeout now takes about 20 s. Thanks @kperry-godaddy.

@kperry-godaddy
kperry-godaddy merged commit efebb84 into main Nov 5, 2026
12 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 5, 2026
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.

4 participants