Skip to content

Add runtime identity API#564

Open
whoiskatrin wants to merge 2 commits intomainfrom
feature/runtime-info-generation
Open

Add runtime identity API#564
whoiskatrin wants to merge 2 commits intomainfrom
feature/runtime-info-generation

Conversation

@whoiskatrin
Copy link
Copy Markdown
Collaborator

@whoiskatrin whoiskatrin commented Apr 7, 2026

Summary

  • add sandbox.getRuntimeIdentity() as a small primitive for detecting when a sandbox starts a new container runtime
  • expose the internal /api/runtime container endpoint and wire it through the SDK utility client
  • add focused unit coverage and an E2E workflow that checks identity stays stable for one runtime and changes after sandbox recreation

Why

Customers currently need to write marker files or tokens inside the container to detect whether the underlying runtime changed. This adds a direct runtime identity primitive so callers can compare the current runtimeId with the last value they observed and decide when reconciliation is needed.

Reviewer Notes

  • this intentionally stays a primitive API; there is no SDK-managed generation counter and no version field on the new method
  • runtimeId is boot-scoped identity, not an ordered generation number
  • the SDK translates a missing /api/runtime endpoint into a clear compatibility error instead of returning a fallback value, since this API is used for correctness rather than diagnostics
  • the E2E worker exposes /api/runtime/identity only for test coverage; the public SDK surface is sandbox.getRuntimeIdentity()

Testing

  • npm run typecheck -w @cloudflare/sandbox
  • npm run typecheck -w @repo/sandbox-container
  • npm test -w @cloudflare/sandbox -- utility-client.test.ts -t \"runtime identity\"
  • npm test -w @cloudflare/sandbox -- sandbox.test.ts -t \"runtime identity\"
  • bun test tests/handlers/misc-handler.test.ts -t \"handleRuntime\"
  • npm run test:e2e:vitest -- -- tests/e2e/runtime-identity-workflow.test.ts (deferred to CI)

Expose a boot-scoped runtime identity so callers can detect when a
sandbox starts a new container without writing marker files inside the
container. This keeps the API as a small primitive that users can
compare against previously stored state to decide when reconciliation
is needed.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

🦋 Changeset detected

Latest commit: 54cf204

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/sandbox Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 7, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/sandbox-sdk/@cloudflare/sandbox@564

commit: 54cf204

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

🐳 Docker Images Published

Variant Image
Default cloudflare/sandbox:0.0.0-pr-564-54cf204
Python cloudflare/sandbox:0.0.0-pr-564-54cf204-python
OpenCode cloudflare/sandbox:0.0.0-pr-564-54cf204-opencode
Musl cloudflare/sandbox:0.0.0-pr-564-54cf204-musl
Desktop cloudflare/sandbox:0.0.0-pr-564-54cf204-desktop

Usage:

FROM cloudflare/sandbox:0.0.0-pr-564-54cf204

Version: 0.0.0-pr-564-54cf204


📦 Standalone Binary

For arbitrary Dockerfiles:

COPY --from=cloudflare/sandbox:0.0.0-pr-564-54cf204 /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]

Download via GitHub CLI:

gh run download 24100598517 -n sandbox-binary

Extract from Docker:

docker run --rm cloudflare/sandbox:0.0.0-pr-564-54cf204 cat /container-server/sandbox > sandbox && chmod +x sandbox

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Raise an explicit error when older containers do not expose the runtime
identity endpoint so callers get a clear upgrade path instead of a raw
missing endpoint failure.
@whoiskatrin whoiskatrin marked this pull request as ready for review April 7, 2026 21:53
Copy link
Copy Markdown
Contributor

@AshishKumar4 AshishKumar4 left a comment

Choose a reason for hiding this comment

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

LGTM

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