Summary
Implement the runtime substrate for ZEP-0002 Structured Async: fibers plus the work-stealing thread pool they run on.
Scope
- Fiber context switching abstraction for Linux, macOS, and Windows
- Runtime initialization/deinitialization API for thread-pool setup
- One worker thread per logical CPU by default, configurable via runtime config /
ZAG_THREADS
- Local run queues plus stealing strategy for idle workers
- Fiber lifecycle, stack allocation/growth strategy, and failure handling
- Minimal internal tracing/metrics hooks needed for validation
Acceptance criteria
- Runtime boots and shuts down cleanly on supported host platforms
- Fibers can be scheduled, parked, resumed, and completed without leaking memory
- Idle workers can steal runnable work from other workers
- Default thread count and explicit override both work
- Design constraints in ZEP-0002 Implementation Notes are reflected in code and docs
References
- ZEP-0002 Phase 1 and Done Criteria
docs/zep/ZEP-0002-async-structure.md
docs/adr/ADR-0002-beam-concurrency-gap-analysis.md
Summary
Implement the runtime substrate for ZEP-0002 Structured Async: fibers plus the work-stealing thread pool they run on.
Scope
ZAG_THREADSAcceptance criteria
References
docs/zep/ZEP-0002-async-structure.mddocs/adr/ADR-0002-beam-concurrency-gap-analysis.md