Skip to content

feat: implement ZEP-0002 Phase 1 fiber runtime and work-stealing scheduler #4

@justrach

Description

@justrach

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:p0Highest prioritystatus:blockedWork item is blocked by dependencystatus:in-progressWork item is actively being worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions