Skip to content

test(executor): re-enable unit tests and add runtime semantics guards - #168

Merged
Patrick Kelly (pk8189) merged 1 commit into
mainfrom
test/runtime-semantics-guards
Oct 5, 2026
Merged

Patrick Kelly (pk8189) merged 1 commit into
mainfrom
test/runtime-semantics-guards

Conversation

@pk8189

Copy link
Copy Markdown
Collaborator

Description

Two things, both test-only:

  1. Re-enables pctx_executor's unit tests. #[cfg(test)] mod tests; was dropped from crates/pctx_executor/src/lib.rs in 52efa39 ("execution event trace", shipped in v0.7.0), so nothing under src/tests/ has compiled or run since — including concurrent_v8_stress, our guard against the multi-threaded V8 isolate crash. All 51 existing tests still pass once re-enabled.
  2. Adds runtime_semantics.rs (15 tests) pinning behaviour that a deno_core / V8 bump can silently change. Written while validating chore: bump deno stack to deno_core 0.412 / deno_ast 0.53 #167; they pass identically on main and on chore: bump deno stack to deno_core 0.412 / deno_ast 0.53 #167's branch.

What the new tests cover

  • op_invoke scheduling: tool calls resolve after microtasks; Promise.all calls overlap (and start before any finishes); sequential calls don't overlap
  • Tool errors: catchable rejections, allSettled / race, uncaught tool error fails the execution
  • op_sleep timers: ordering vs microtasks and by delay, setInterval + clearInterval
  • Event loop drains timers and tool calls scheduled after module evaluation (stdout still captured)
  • Unhandled rejections fail; runtime errors include a stack; stack overflow is a catchable RangeError
  • ICU-backed Intl (time zones, plural rules, collation, locale casing, Japanese era) and Temporal (incl. a DST gap)
  • Sync and async WebAssembly (async compile depends on V8 platform tasks being pumped)
  • Multi-threaded execution (one current-thread runtime per OS thread, as in the session server) with tool calls, timers and async wasm

Type of Change

  • Test coverage improvement

Testing

cargo test -p pctx_executor --lib   # 66 passed, on main and on #167's branch (x4)
cargo fmt --all --check

No new clippy warnings from the added file (clippy isn't enforced in CI; the re-enabled older test files carry a few pre-existing pedantic warnings).

Notes

Not covered here, found while probing — both pre-existing on main, to be filed separately:

  • A throw inside a setTimeout callback, or Atomics.waitAsync, hangs execute() indefinitely while holding V8_MUTEX.
  • Sandboxed code can dynamically import arbitrary .json / .js files from the host filesystem via FsModuleLoader.

Documentation

  • CHANGELOG.md updated under "Unreleased"

🤖 Generated with Claude Code

The `#[cfg(test)] mod tests;` declaration was dropped from
pctx_executor/src/lib.rs in 52efa39, so every test under src/tests/
(including concurrent_v8_stress) stopped compiling or running. All 51
still pass once re-enabled.

Adds runtime_semantics.rs to pin behaviour that a deno_core / V8 bump
can silently change: tool-call (op_invoke) and timer (op_sleep)
scheduling relative to microtasks, parallel vs sequential tool calls,
tool error propagation, event loop draining after module evaluation,
unhandled rejections, error stacks, ICU-backed Intl, Temporal, sync and
async WebAssembly, and multi-threaded execution with async ops.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pk8189
Patrick Kelly (pk8189) force-pushed the test/runtime-semantics-guards branch from f8e9e01 to 96d4ab6 Compare October 5, 2026 14:36
@pk8189
Patrick Kelly (pk8189) merged commit 1135580 into main Oct 5, 2026
10 checks passed
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