Draft issues ready to be copy-pasted into GitHub. Each entry lists a suggested title, labels, background, concrete scope, and acceptance criteria aligned with the canonical ABI reference implementation.
- Labels:
enhancement,async
The canonical ABI reference (design/mvp/canonical-abi/definitions.py) includes a Store, Thread, and scheduling loop that enable cooperative async execution via tick(). The current C++ headers lack any runtime to drive asynchronous component calls.
- Add
Store,Thread,Task, and related scheduling types tocmcppmirroring the canonical semantics. - Implement queueing of pending threads and
tick()to resume ready work. - Expose hooks for component functions to register
on_start/on_resolvecallbacks and support cancellation tokens on the returnedCallobject. - Provide doctest (or equivalent) coverage that simulates async invocation and verifies correct scheduling behavior.
- New runtime types are available in the public API and documented.
- Asynchronous component calls can progress via repeated
tick()calls without blocking the host thread. - Unit tests demonstrate thread scheduling,
on_startargument delivery, and cooperative cancellation. - Documentation explains how hosts drive async work.
- Labels:
enhancement,abi
ResourceHandle, ResourceType, and ComponentInstance.resources are currently empty shells. The canonical implementation tracks ownership, borrow counts, destructors, and exposes canon resource.{new,drop,rep}.
- Flesh out
ResourceHandlewithown,borrow_scope, andnum_lendssemantics. - Implement
ResourceTypedestructor registration, including async callback support. - Add
canon resource.new,canon resource.drop, andcanon resource.rephelper functions that update component tables and trap on misuse. - Write tests covering own/borrow flows, lend counting, and destructor invocation.
- Resource creation traps if the table would overflow or if ownership rules are violated.
- Dropping resources invokes registered destructors exactly once and respects async/sync constraints.
- Borrowed handles track lend counts and trap on invalid drops or reps.
- Tests mirror canonical success and trap cases.
- Labels:
enhancement,async
Canonical ABI defines waitables, waitable-sets, buffers, streams, and futures plus their cancellation behaviors. Our headers only contain empty structs.
- Model waitable and waitable-set state, including registration with the component store.
- Implement buffer management for {stream,future} types, covering readable/writable halves.
- Provide APIs for
canon waitable-set.{new,wait,poll,drop},canon waitable.join, andcanon {stream,future}.{new,read,write,cancel,drop}. - Add tests verifying read/write ordering, cancellation pathways, and polling semantics.
- Streams and futures can be created, awaited, and canceled via the new APIs.
- Waitable sets correctly block/unblock pending tasks and surface readiness in tests.
- Cancellation propagates to queued operations per canonical rules.
- Documentation describes how hosts integrate these constructs.
- Labels:
enhancement,async
ComponentInstance holds flags for may_leave, backpressure, and call-state tracking but they are unused. Canonical ABI specifies canon task.{return,cancel}, canon yield, and backpressure counters governing concurrent entry.
- Track outstanding synchronous/async calls and enforce
may_leaveinvariants when entering/leaving component code. - Implement
canon task.returnandcanon task.cancelhelpers wired to pending task queues. - Support
canon yieldto hand control back to the embedder. - Ensure backpressure counters gate
Store.invokewhile tasks are paused or pending.
- Re-entrant sync calls are rejected per canonical rules (tests cover both allowed and disallowed cases).
- Tasks marked for cancellation resolve promptly with
on_resolve(None). canon yieldtransitions tasks to pending and requires a subsequenttick()to resume.- Backpressure metrics are exposed for debugging and verified in tests.
- Labels:
enhancement,abi
LiftLowerContext currently omits instance references and borrow scopes, and ContextLocalStorage/ErrorContext types are unused. The canonical ABI exposes canon context.{get,set} and canon error-context.{new,debug-message,drop}.
- Extend
LiftLowerContextto hold the activeComponentInstanceand scoped borrow variant. - Implement context-local storage getters/setters with bounds validation.
- Provide error-context creation, debug-message formatting via the host converter, and drop semantics that respect async callbacks.
- Add tests ensuring invalid indices and double drops trap.
- Borrowed resources capture their scope and trap when accessed outside it.
- Context locals persist across lift/lower calls and reset appropriately between tasks.
- Error-context debug messages surface through the host trap mechanism.
- Test coverage includes both success and failure paths for each API.
- Labels:
enhancement,abi
include/cmcpp/func.hpp contains commented-out flattening helpers. Canonical ABI requires flattening functions to honor MAX_FLAT_PARAMS/RESULTS and spill to heap memory via the provided realloc.
- Implement
cmcpp::func::flatten,pack_flags_into_int, and the associated load/store helpers. - Respect max-flat thresholds and ensure out-params allocate via
LiftLowerContext::opts.realloc. - Add regression tests covering large tuples, records, and flag types that exceed the flat limit.
- Compare flattened signatures against outputs from the canonical Python definitions for validation.
- Flattened core signatures match canonical expectations for representative WIT signatures.
- Heap-based lowering is invoked automatically when flat limits are exceeded.
- Flags marshal correctly between bitsets and flat integers.
- Tests demonstrate both flat and heap pathways.
- Labels:
enhancement,abi
CanonicalOptions exposes post_return, callback, and sync but they are currently unused. Canonical ABI requires these flags to control async vs sync paths and post-return cleanup.
- Invoke
post_returnafter successful lowerings when provided. - Enforce
syncby trapping when async behavior would occur whilesync == true. - Invoke
callbackwhen async continuations schedule additional work. - Ensure option fields propagate through
InstanceContext::createLiftLowerContextand task lifecycles.
post_returnis called exactly once per lowering when configured (verified via tests).- Async lowering attempts while
sync == truetrap with a descriptive error. - Registered callbacks fire for asynchronous continuations and can trigger host-side scheduling.
- Documentation clarifies option usage and interaction with new runtime pieces.
- Labels:
documentation,testing
New runtime pieces require supporting documentation and tests. Currently, README lacks guidance and test coverage mirrors only existing functionality.
- Update
README.md(or add a new guide) summarizing the async runtime, resource management, and waitable APIs. - Add doctest/ICU-backed unit tests covering the new behavior to
test/main.cpp(or adjacent files). - Optionally add a Python cross-check using
ref/component-model/design/mvp/canonical-abi/run_tests.pyfor parity.
- Documentation explains how to configure
InstanceContext, allocate options, and drive async flows. - New tests pass in CI and cover at least one example for each newly implemented feature.
- The backlog of canonical ABI features is reflected as "Done" within this issue once merged.