ReviewOS

craft-native/craft

Retain exception details in the native eval CLI

#422
Closed chris opened this 6 days ago ·
6 days ago

The native eval CLI discards the thrown exception value and prints only uncaught error. A simple reproduction with the original Craft 0.0.368 macOS arm64 release binary is:

craft --eval 'throw new Error("distinct failure")'

It exits 1 with empty stdout and stderr uncaught error, losing the actual message. minimal.zig:runEval calls js_runtime.evalOnce; that helper destroys the context before the CLI can inspect the exception. The engine retains exceptions and Craft's persistent hosting API already exposes an exception handle.

This also obstructs diagnosis of the unchanged long shared-engine fixture in the game replay issue. That fixture's underlying native failure is not yet established; this diagnostic loss is independently reproduced with the one-line throw above.

Acceptance:

  • Retain a regression through the actual public native CLI for a distinctive Error message and a thrown primitive.
  • Report useful exception details while the owning runtime is alive, preserving the nonzero exit and distinct syntax/throw/unavailable/OOM classifications.
  • Do not execute user-defined getters, proxies or toString merely to render a diagnostic. Do not dump the input bundle.
  • Preserve execution budgets, heap limits and timeouts. Do not shorten the game fixture or reinterpret the failure as a pass.
  • Pass owning source checks and normal release verification before adopting the correction downstream.
6 days ago

Implemented on main in c120294 (5 files) and 6d3bdc5 (3 files).

The CLI now copies a bounded exception summary before destroying the owning context. It reads engine-owned primitive values and raw Error data properties only; accessors, proxies, and arbitrary objects receive safe placeholders without invoking user code. Parse, Throw, Unavailable, and OutOfMemory classifications are retained, including when allocating the diagnostic itself fails. Execution budgets, heap limits, and timeouts are unchanged.

Regression evidence: the public-CLI harness failed 14 diagnostic cases against the previous binary, then passed all 15 tests against the rebuilt ReleaseSafe binary. The runtime-disabled CLI test also passes. Explicit runtime test wiring now prevents Zig lazy discovery from silently omitting js_runtime.zig tests; enabled tests pass 11 with 1 intentional skip, disabled tests pass 3 with 9 intentional skips. CI runs these checks on both Linux and macOS.

Local verification: all 221 Zig build/test steps succeeded; final SDK run 799 passed / 8 skipped / 0 failed; typecheck passed; package surfaces 43 checks passed; release verification 397 passed; fmt passed; lint 0 errors (27 existing warnings). Two earlier SDK runs each timed out in a different unchanged Android subprocess fixture; both cases passed subsequently without changing timeouts.

This is implemented and pushed, not yet a published-release claim. Leaving the issue open pending remote CI and publication/downstream adoption evidence.

5 days ago

Verified shipped in v0.0.377; closing the diagnostic-loss issue. The earlier publication/CI gate is satisfied.

Full CI and Mobile E2E are green at exact release source 52779dd: https://github.com/craft-native/craft/actions/runs/40645357817 https://github.com/craft-native/craft/actions/runs/40645357872 Publication completed: https://github.com/craft-native/craft/actions/runs/40645357883

Downloaded the original public craft-darwin-arm64.zip from https://github.com/craft-native/craft/releases/tag/v0.0.377 and verified SHA256 41422e3bf854a3287426b3e056e3801cf2345fcccb0945fc890d24df754fb1ae against the release manifest. Its executable reports 0.0.377. The unchanged scripts/native-eval.test.ts harness passes all 15 tests against that published executable: distinctive Errors, thrown primitives, accessor/proxy/toString safety, bounded summaries, eval-file privacy, and syntax/success classifications. Source CI separately covers runtime-disabled and allocation-failure classifications.

This closes exception-detail retention, not the downstream game fixture failure; no gameplay result or downstream adoption is claimed. No new release/tag was created.

Sign in to comment on this issue.