Skip to content

feat: Add airlock run CLI with structured JSON results - #11

Open
ThomasHartDev wants to merge 2 commits into
mainfrom
thomas/feat/cli
Open

feat: Add airlock run CLI with structured JSON results#11
ThomasHartDev wants to merge 2 commits into
mainfrom
thomas/feat/cli

Conversation

@ThomasHartDev

Copy link
Copy Markdown
Owner

Adds airlock run <file> and programmatic runFile / runSource APIs that always return a structured JSON envelope (JsonRunResult).

Contract

  • Exit 0 only for status: "ok"
  • Exit 1 for sandbox refusals and assert/runtime errors (including assertExpr compile failures)
  • Exit 2 only for usage parse failures and file IO (io-error)
  • Every run invocation prints one JSON line on stdout (including failed post-conditions and invalid/empty --assert)

assertExpr / --assert

  • Host-privileged: compiled with new Function in the host realm (not sandboxed). Trusted operator input only.
  • Promise-returning expressions are awaited before Boolean coerce, so Promise.resolve(false) correctly yields assertion-failed.
  • Empty or syntax-invalid expressions return { status: "error", error: ... } instead of rejecting or printing bare stderr.

Flags

--timeout, --assert, --tier sandbox|worker, --grant, --allow-module, --max-output-bytes, --max-old-gen-mb

Verify

pnpm run typecheck && pnpm test && pnpm run build (150 tests).

Boolean(fn()) treated Promise-returning asserts as always true. Await the
expression result before coercing, compile assertExpr inside runSource's
try so bad exprs become status error not rejections, and await runSource
from runFile. CLI prints one JSON result for assert compile failures
(exit 1) instead of bare stderr + exit 2.
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.

1 participant