T0038b — Public API: async evaluation, hooks and limits
Part of the roadmap. Phase 1 · wave 7 · size M.
- Depends on: T0017, T0021, T0025, T0042
- Area:
area:core - Tier hint:
risk:high: new public functions, options and hook types, and a new limit on evaluation, so the core tier with a second reviewer from the other vendor. - Parallel with: T0038a, T0038c, T0038d
- Parent: T0038, split on 2026-11-12.
Goal
Host-backed, cancellable and bounded evaluation through the public API: evaluateAsync(), the host hooks of T0021, a fixed clock and limits on the work of one evaluation, as in the T0038 sketch.
Scope
evaluateAsync()andCompiledExpression.evaluateAsync(), with the options ofevaluate(). Compile errors become rejections, like evaluation errors.- Evaluation options:
hooks:resolve,terminology,conformsTo,htmlChecks,regexandtrace, with their public types (EvaluationHooks,TraceEvent, the hook contexts and the coded values). A hook that returns a promise inevaluate()raiseseval/async-in-sync.signal: anyAbortSignal(CancellationSignal); an aborted signal raiseseval/abortedwith its reason as the cause.concurrency: async only.now: aDateor a function that returns one (T0017).limits:EvaluationLimitswithmaxRepeatItems(T0042) and a newmaxCollectionSize, the most items in any intermediate collection, with a finite default (architecture: bounded work). Exceeding it raiseseval/limit-exceededin sync and async mode.
- Option validation as for the other options; anything not implemented is rejected.
- Tests in sync and async mode, including hooks that return cross-realm promises and custom thenables (testing guide), type tests, packed consumers, a guide section on async evaluation and hooks, and a
minorchangeset.
Design notes
- The internal API implements everything except
maxCollectionSize; the facade validates and passes the options on, as for T0038a. - Choose the
maxCollectionSizedefault so the HL7 suites and the documented examples stay far below it, and record the reason in this file. Check the limit where collections grow (navigation,descendants(),repeat(),|,combine()), not on every item. - Typed output from
evaluateAsync()comes with T0038d; whichever of the two lands second adds the overloads for the other's functions.
Acceptance criteria
From the parent:
- No future option is accepted as a silent no-op.
- publint, attw, the zero-dependency check and the size budget all pass.
- The guide examples for async evaluation and hooks are executed in CI.
And for this child:
- Every hook-backed function (
resolve(),memberOf(),subsumes(),subsumedBy(),conformsTo(),htmlChecks(),matches()throughregex,trace()) works through the public API in both modes, and a promise inevaluate()raiseseval/async-in-sync. - An aborted signal raises
eval/abortedbefore evaluation and before each hook call. - A collection beyond
limits.maxCollectionSize, and arepeat()beyondlimits.maxRepeatItems, raiseeval/limit-exceededin both modes, with the defaults and with custom limits.