Skip to content

fix(typescript): isolate VM work from Tokio workers - #2954

Merged
chaliy merged 1 commit into
mainfrom
fix/eve-1351-typescript-admission
Nov 19, 2026
Merged

chaliy merged 1 commit into
mainfrom
fix/eve-1351-typescript-admission

Conversation

@chaliy

@chaliy chaliy commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • move native ZapCode execution and dedicated-thread joins off shared Tokio workers
  • add process-wide asynchronous VM admission with a safe default, one-time host configuration, and deadline-aware queueing
  • add current-thread, saturated-worker, and high-concurrency regressions
  • reconcile the canonical/public multi-tenant threat model, add TM-TS-028, and enforce unique canonical threat definitions

Validation

  • cargo fmt --check
  • cargo clippy -p bashkit --lib --features typescript -- -D warnings
  • TypeScript unit and tenant stress suites
  • threat-model document tests
  • browser/MSRV consumer check
  • Rust doctests with standard features plus TypeScript
  • repository script, capability, workflow, changelog, Monty-fork, OKF, and documentation-link checks
  • cargo bench -p bashkit --bench parallel_execution -- --quick

just pre-pr completed formatting, clippy, and 2,697/2,701 full tests. Four pre-existing child-process cleanup tests that require observing ESRCH fail identically on this host, including when retried serially outside the sandbox; all changed TypeScript and documentation tests pass. GitHub CI is required to be green before merge.

Linear:


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@bashkit-pr-reviewer bashkit-pr-reviewer Bot 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.

Isolation direction looks right (admission + spawn_blocking), but resumed steps lose their deadline — see inline.

Comments outside the diff

knowledge/operations/everruns-1351-typescript-admission.md line 1: [P2] New OKF concept knowledge/operations/everruns-1351-typescript-admission.md has no update to knowledge/operations/index.md in the changed files. Per knowledge/knowledge-contract.md, every index.md must enumerate its own directory, so the drift/OKF check will likely flag the new concept. Fix: list the new doc in operations/index.md (and keep the See also backlink).

crates/bashkit/src/builtins/typescript.rs line 2095: [P2] vm_admission_caps_active_threads_and_times_out_queued_steps depends on tight wall-clock margins (100ms deadline vs 200ms VM sleep + 150ms grace, asserting maximum()==2 && active()==0). Under a loaded CI worker the started==2/active==0 assertions can flake. Consider wider margins or polling active()==0 with a timeout instead of a single sleep.

fn on_vm_stack<T>(meter: &crate::vm_meter::VmMeter, step: impl FnOnce() -> T) -> Option<T> {
let _window = crate::vm_meter::VmWindow::enter(meter);
Some(step())
async fn run_vm_step<T>(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P1] Resumed steps bypass the admission/execution deadline: run_vm_step_with_admission(step, None) waits on the semaphore with no timeout and task.awaits with no timeout, so a multi-step program can wait past max_duration/overall deadline and hang if permits are held by abandoned timed-out threads. The previous code passed deadline for every step. Fix: pass the remaining vm_clock.deadline() (e.g. Some(deadline)) for steps 2..n, same as the first step.

@bashkit-pr-reviewer

Copy link
Copy Markdown

Review verdict: sound isolation direction (semaphore admission + spawn_blocking for the 128 MiB VM threads), but resumed steps lose their deadline — worth a fix before merge. No P0/blocking findings.

Findings:

  • P1: resumed VM steps pass None deadline (run_vm_step_with_admission(step, None)), so semaphore wait and blocking join are unbounded; can exceed max_duration / hang on abandoned permits. Should pass remaining vm_clock.deadline().
  • P2: new knowledge concept has no knowledge/operations/index.md entry — likely OKF drift failure.
  • P2: admission test uses tight wall-clock margins (100ms vs 200ms + 150ms sleep); may flake — poll instead.

Context read: PR diff (not truncated), crates/bashkit/src/builtins/typescript.rs around admission/run_vm_step/process_vm_result/tests, AGENTS.md, knowledge/knowledge-contract.md. Could not verify the two new/updated knowledge docs from the filesystem (snapshot at /workspace/bashkit lacks knowledge/operations/everruns-1351-typescript-admission.md); reviewed them from the diff only. No build/tests run (Bashkit shell has no cargo). Note: 2 inline notes fell outside the diff and were moved to the review body by the API.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 73dff08 Commit Preview URL

Branch Preview URL
Nov 19 2026, 01:14 AM

@chaliy
chaliy merged commit bb6e17f into main Nov 19, 2026
70 checks passed
@chaliy
chaliy deleted the fix/eve-1351-typescript-admission branch November 19, 2026 01:50
@chaliy chaliy mentioned this pull request Nov 19, 2026
2 tasks done
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