Summary
Implement the per-plugin WASM instance pool. Pool size formula: min(maxInstances, currentConcurrency * 2), capped at 16 per plugin (tunable). Each instance is single-threaded; hook dispatch acquires, runs, returns it. Instances are recycled on shutdown, on a 1-hour TTL, or when memory hits 80% of cap.
Design reference
- docs/02-plugin-system.md S4.6, S4.7, Appendix B (
InstancePool)
Acceptance criteria
Dependencies
#6 (plugin host scaffolding)
Complexity
L
Summary
Implement the per-plugin WASM instance pool. Pool size formula:
min(maxInstances, currentConcurrency * 2), capped at 16 per plugin (tunable). Each instance is single-threaded; hook dispatch acquires, runs, returns it. Instances are recycled on shutdown, on a 1-hour TTL, or when memory hits 80% of cap.Design reference
InstancePool)Acceptance criteria
InstancePoolstruct with idle list, in-flight counter, sync.MutexGet(ctx) (*Instance, error)pops an available instance or instantiates a new one iflen < max; blocks with ctx cancellation if at maxPut(inst)returns to available pool, OR destroys instance if its memory >80% of cap, OR if older than TTLCompiledModuleper(slug, version)is reused across the entire poolGet/Putcycles (in-instance caches survive)plugin_pool_size{slug},plugin_pool_in_flight{slug}Dependencies
#6 (plugin host scaffolding)
Complexity
L