Skip to content

[#3c] Extension reactor: forced-compat lane, hostcall reactor mesh, warm isolate pool #29

@quangdang46

Description

@quangdang46

[#3c] Extension reactor: forced-compat lane, hostcall reactor mesh, warm isolate pool

Sub-issue of #3. Operational/perf surface needed once jcode is dispatching extension hostcalls at meaningful volume. Only ship after #3a/#3b unless there's a specific need.

Hard dependencies

  • #3a and #3b must land first.

1. Hostcall compatibility-lane forced-compat switch

  • Add a slow "compat lane" for hostcall dispatch alongside the default fast path.
  • Global flag: --ext-compat-lane all (force every extension into compat lane until reverted).
  • Per-extension setting: ext.compat=true in settings.json.
  • Each forced state must record reason_code and triggered_by (mirror Extension trust lifecycle and kill-switch #15 ledger format).
  • Use case: a hot-path bug in the reactor is found in production — operators can degrade to compat lane in one command without disabling extensions wholesale.
  • Reference: pi_agent_rust → "Hostcall compatibility-lane emergency controls".

2. Deterministic hostcall reactor mesh

  • Single-shard SPSC channel v1 (multi-shard v2 if profiling justifies).
  • Bounded queue with backpressure: when full, the extension gets a denied hostcall response with code: "backpressure".
  • Global drain on shutdown so no hostcall is lost mid-flight.
  • Optional NUMA slab pool feature-gated behind numa — explicitly not required unless real workloads show NUMA pressure.
  • Reference: pi_agent_rust → "Deterministic hostcall reactor mesh with optional NUMA slab pool".

3. Warm isolate pool + startup prewarm handoff

  • Pre-instantiate N QuickJS isolates at startup (configurable; default 0 for batteries-off behavior).
  • Hand the warmed isolate to the loader when an extension is first invoked → faster cold-load (target P95 < 50 ms).
  • Pool sizing exposed in settings; observable via jcode doctor --only extensions.
  • Reference: pi_agent_rust → "Warm isolate pool + startup prewarm handoff".

Out of scope

  • Math-substrate (CUSUM, conformal, PAC-Bayes, etc.) — pi_agent_rust ships these but they are research surface with no direct user product. Do not import.

Acceptance criteria

  • --ext-compat-lane all flips all extensions to compat path; jcode doctor reports the override.
  • Reactor backpressure delivers a structured denied error rather than hanging.
  • Cold-load P95 with prewarm pool of 2 measurably faster than without.

Cross-references

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions