@directive-run/core 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +5 -0
  2. package/dist/adapter-utils.cjs +1 -1
  3. package/dist/adapter-utils.cjs.map +1 -1
  4. package/dist/adapter-utils.d.cts +1 -1
  5. package/dist/adapter-utils.d.ts +1 -1
  6. package/dist/adapter-utils.js +1 -1
  7. package/dist/adapter-utils.js.map +1 -1
  8. package/dist/chunk-6WG7FPH7.cjs +3 -0
  9. package/dist/chunk-6WG7FPH7.cjs.map +1 -0
  10. package/dist/chunk-DIK3SZBM.js +3 -0
  11. package/dist/chunk-DIK3SZBM.js.map +1 -0
  12. package/dist/chunk-GO63IIN5.js +2 -0
  13. package/dist/chunk-GO63IIN5.js.map +1 -0
  14. package/dist/chunk-KQKNE23L.cjs +2 -0
  15. package/dist/chunk-KQKNE23L.cjs.map +1 -0
  16. package/dist/chunk-LAH2FMON.cjs +16 -0
  17. package/dist/chunk-LAH2FMON.cjs.map +1 -0
  18. package/dist/chunk-MAARYRI4.js +16 -0
  19. package/dist/chunk-MAARYRI4.js.map +1 -0
  20. package/dist/chunk-O75OISQ2.js +2 -0
  21. package/dist/chunk-O75OISQ2.js.map +1 -0
  22. package/dist/chunk-PK2EH26L.cjs +2 -0
  23. package/dist/chunk-PK2EH26L.cjs.map +1 -0
  24. package/dist/helpers-50q7yhA9.d.ts +179 -0
  25. package/dist/helpers-B6SkcKCD.d.cts +179 -0
  26. package/dist/index.cjs +1 -16
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +42 -1421
  29. package/dist/index.d.ts +42 -1421
  30. package/dist/index.js +1 -16
  31. package/dist/index.js.map +1 -1
  32. package/dist/internals.cjs +2 -0
  33. package/dist/internals.cjs.map +1 -0
  34. package/dist/internals.d.cts +1176 -0
  35. package/dist/internals.d.ts +1176 -0
  36. package/dist/internals.js +2 -0
  37. package/dist/internals.js.map +1 -0
  38. package/dist/plugins/index.cjs +2 -2
  39. package/dist/plugins/index.cjs.map +1 -1
  40. package/dist/plugins/index.d.cts +1 -1
  41. package/dist/plugins/index.d.ts +1 -1
  42. package/dist/plugins/index.js +2 -2
  43. package/dist/plugins/index.js.map +1 -1
  44. package/dist/{plugins-DaglUQVX.d.cts → plugins-Bg_oq2sO.d.cts} +22 -2
  45. package/dist/{plugins-DaglUQVX.d.ts → plugins-Bg_oq2sO.d.ts} +22 -2
  46. package/dist/system-L2FVVUSN.js +2 -0
  47. package/dist/system-L2FVVUSN.js.map +1 -0
  48. package/dist/system-L45Z2N4U.cjs +2 -0
  49. package/dist/system-L45Z2N4U.cjs.map +1 -0
  50. package/dist/testing.cjs +1 -16
  51. package/dist/testing.cjs.map +1 -1
  52. package/dist/testing.d.cts +54 -16
  53. package/dist/testing.d.ts +54 -16
  54. package/dist/testing.js +1 -16
  55. package/dist/testing.js.map +1 -1
  56. package/dist/worker.cjs +1 -16
  57. package/dist/worker.cjs.map +1 -1
  58. package/dist/worker.d.cts +1 -1
  59. package/dist/worker.d.ts +1 -1
  60. package/dist/worker.js +1 -16
  61. package/dist/worker.js.map +1 -1
  62. package/package.json +13 -4
package/dist/index.d.cts CHANGED
@@ -1,213 +1,8 @@
1
- import { S as Schema, F as Facts, R as Requirement, a as RequirementOutput, b as RetryPolicy, B as BatchConfig, c as ResolverContext, d as SchemaType, M as ModuleSchema, T as TypedDerivationsDef, e as TypedEventsDef, E as EffectsDef, f as TypedConstraintsDef, g as TypedResolversDef, h as ModuleHooks, C as CrossModuleDeps, i as CrossModuleDerivationsDef, j as CrossModuleEffectsDef, k as CrossModuleConstraintsDef, l as ModuleDef, m as CreateSystemOptionsSingle, n as SingleModuleSystem, o as ModulesMap, p as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, q as TraceOption, r as ErrorBoundaryConfig, s as RequirementWithId, t as RequirementKeyFn, u as FactsStore, v as ConstraintsDef, w as ConstraintState, x as ResolversDef, y as ResolverStatus, z as System, A as FactChange, D as FactsSnapshot, G as ReconcileResult, H as Snapshot, I as DirectiveError, J as RecoveryStrategy, K as TraceEntry, L as ErrorSource, O as RetryLaterConfig, Q as HistoryAPI, U as HistoryOption, V as SystemConfig } from './plugins-DaglUQVX.cjs';
2
- export { W as AnySystem, X as BatchItemResult, Y as BatchResolveResults, Z as ConstraintsControl, _ as CrossModuleConstraintDef, $ as CrossModuleDerivationFn, a0 as CrossModuleEffectDef, a1 as CrossModuleFactsWithSelf, a2 as DerivationKeys, a3 as DerivationReturnType, a4 as DerivationsControl, a5 as DerivationsSchema, a6 as DeriveAccessor, a7 as DispatchEventsFromSchema, a8 as DistributableSnapshot, a9 as DistributableSnapshotOptions, aa as DynamicConstraintDef, ab as DynamicEffectDef, ac as DynamicResolverDef, ad as EffectCleanup, ae as EffectsControl, af as EventPayloadSchema, ag as EventsAccessor, ah as EventsAccessorFromSchema, ai as EventsDef, aj as EventsSchema, ak as FactKeys, al as FactReturnType, am as FlexibleEventHandler, an as HistoryConfig, ao as HistoryState, ap as InferDerivations, aq as InferEventPayloadFromSchema, ar as InferEvents, as as InferFacts, at as InferRequirementPayloadFromSchema, au as InferRequirementTypes, av as InferRequirements, aw as InferSchema, ax as InferSchemaType, ay as InferSelectorState, az as MutableNamespacedFacts, aA as NamespacedDerivations, aB as NamespacedEventsAccessor, aC as NamespacedFacts, aD as ObservableKeys, aE as RequirementExplanation, aF as RequirementOutput, aG as RequirementPayloadSchema, aH as RequirementsSchema, aI as ResolversControl, aJ as SnapshotMeta, aK as SystemEvent, aL as SystemInspection, aM as SystemMode, aN as SystemSnapshot, aO as TraceConfig, aP as TypedConstraintDef, aQ as TypedResolverContext, aR as TypedResolverDef, aS as UnionEvents, aT as isNamespacedSystem, aU as isSingleModuleSystem } from './plugins-DaglUQVX.cjs';
1
+ import { S as SchemaType, M as ModuleSchema, F as Facts, T as TypedDerivationsDef, a as TypedEventsDef, E as EffectsDef, b as TypedConstraintsDef, c as TypedResolversDef, d as ModuleHooks, C as CrossModuleDeps, e as CrossModuleDerivationsDef, f as CrossModuleEffectsDef, g as CrossModuleConstraintsDef, h as ModuleDef, i as CreateSystemOptionsSingle, j as SingleModuleSystem, k as ModulesMap, l as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, m as TraceOption, n as ErrorBoundaryConfig, R as RequirementWithId, o as Requirement, p as RequirementKeyFn } from './plugins-Bg_oq2sO.cjs';
2
+ export { A as AnySystem, B as BatchConfig, D as DirectiveError, q as DistributableSnapshot, r as DistributableSnapshotOptions, s as DynamicConstraintDef, t as DynamicEffectDef, u as DynamicResolverDef, v as FactsSnapshot, H as HistoryAPI, w as HistoryOption, x as HistoryState, I as InferDerivations, y as InferEvents, z as InferFacts, G as InferRequirementTypes, J as InferRequirements, K as InferSchemaType, L as InferSelectorState, O as RetryPolicy, Q as Schema, U as Snapshot, V as System, W as SystemConfig, X as SystemInspection, Y as SystemMode, Z as SystemSnapshot, _ as TraceEntry, $ as isNamespacedSystem, a0 as isSingleModuleSystem } from './plugins-Bg_oq2sO.cjs';
3
+ export { t as typedConstraint, a as typedResolver } from './helpers-B6SkcKCD.cjs';
3
4
  export { D as DistributableSnapshotLike, S as SignedSnapshot, a as SnapshotDiff, b as SnapshotDiffEntry, d as diffSnapshots, i as isSignedSnapshot, c as isSnapshotExpired, s as shallowEqual, e as signSnapshot, v as validateSnapshot, f as verifySnapshotSignature } from './utils-4JrY5fk9.cjs';
4
5
 
5
- /**
6
- * Derivation Types - Type definitions for derivations
7
- */
8
-
9
- /** Tracking context for auto-dependency detection */
10
- interface TrackingContext {
11
- readonly isTracking: boolean;
12
- track(key: string): void;
13
- getDependencies(): Set<string>;
14
- }
15
- /** Derivation definition function signature. */
16
- interface DerivationDef<S extends Schema, T, D extends DerivationsDef<S>> {
17
- (facts: Facts<S>, derived: DerivedValues<S, D>): T;
18
- }
19
- /** Map of derivation definitions. */
20
- type DerivationsDef<S extends Schema> = Record<string, DerivationDef<S, unknown, DerivationsDef<S>>>;
21
- /** Computed derived values. */
22
- type DerivedValues<S extends Schema, D extends DerivationsDef<S>> = {
23
- readonly [K in keyof D]: ReturnType<D[K]>;
24
- };
25
- /** Internal derivation state */
26
- interface DerivationState<T> {
27
- id: string;
28
- compute: () => T;
29
- cachedValue: T | undefined;
30
- dependencies: Set<string>;
31
- isStale: boolean;
32
- isComputing: boolean;
33
- }
34
-
35
- /**
36
- * Type Helpers - External typed constraint and resolver definitions
37
- *
38
- * These types enable defining constraints and resolvers with full type safety
39
- * outside of module definitions, while maintaining proper type inference.
40
- */
41
-
42
- /**
43
- * External constraint definition with full typing.
44
- * Use this when defining constraints outside of createModule().
45
- *
46
- * @typeParam S - The schema type
47
- * @typeParam R - The requirement type (defaults to Requirement)
48
- *
49
- * @example
50
- * ```typescript
51
- * // Define a typed constraint factory
52
- * const createMaxCountConstraint = <S extends Schema>(
53
- * maxCount: number
54
- * ): TypedConstraint<S, { type: "RESET_COUNT" }> => ({
55
- * priority: 10,
56
- * when: (facts) => (facts as { count: number }).count > maxCount,
57
- * require: { type: "RESET_COUNT" },
58
- * });
59
- *
60
- * // Use in module
61
- * const module = createModule("counter", {
62
- * schema: { count: t.number() },
63
- * constraints: {
64
- * maxCount: createMaxCountConstraint(100),
65
- * },
66
- * });
67
- * ```
68
- */
69
- interface TypedConstraint<S extends Schema, R extends Requirement = Requirement> {
70
- /** Priority for ordering (higher runs first) */
71
- priority?: number;
72
- /** Mark this constraint as async (avoids runtime detection) */
73
- async?: boolean;
74
- /** Condition function (sync or async) */
75
- when: (facts: Facts<S>) => boolean | Promise<boolean>;
76
- /**
77
- * Requirement(s) to produce when condition is met.
78
- */
79
- require: RequirementOutput<R> | ((facts: Facts<S>) => RequirementOutput<R>);
80
- /** Timeout for async constraints (ms) */
81
- timeout?: number;
82
- /**
83
- * Constraint IDs whose resolvers must complete before this constraint is evaluated.
84
- * - If dependency's `when()` returns false, this constraint proceeds (nothing to wait for)
85
- * - If dependency's resolver fails, this constraint remains blocked until it succeeds
86
- * - Cross-module: use the constraint ID as it appears in the merged system
87
- */
88
- after?: string[];
89
- }
90
- /**
91
- * External resolver definition with full typing.
92
- * Use this when defining resolvers outside of createModule().
93
- *
94
- * @typeParam S - The schema type
95
- * @typeParam R - The requirement type (defaults to Requirement)
96
- *
97
- * @example
98
- * ```typescript
99
- * // Define a typed resolver factory
100
- * interface FetchUserReq extends Requirement {
101
- * type: "FETCH_USER";
102
- * userId: string;
103
- * }
104
- *
105
- * const createFetchUserResolver = <S extends Schema>(
106
- * fetchFn: (userId: string) => Promise<User>
107
- * ): TypedResolver<S, FetchUserReq> => ({
108
- * requirement: (req): req is FetchUserReq => req.type === "FETCH_USER",
109
- * key: (req) => `fetch-user-${req.userId}`,
110
- * retry: { attempts: 3, backoff: "exponential" },
111
- * resolve: async (req, ctx) => {
112
- * const user = await fetchFn(req.userId);
113
- * (ctx.facts as { user: User }).user = user;
114
- * },
115
- * });
116
- * ```
117
- */
118
- interface TypedResolver<S extends Schema, R extends Requirement = Requirement> {
119
- /**
120
- * Requirement type to handle.
121
- * - String: matches `req.type` directly (e.g., `requirement: "FETCH_USER"`)
122
- * - Function: type guard predicate (e.g., `requirement: (req) => req.type === "FETCH_USER"`)
123
- */
124
- requirement: R["type"] | ((req: Requirement) => req is R);
125
- /** Custom key function for deduplication */
126
- key?: (req: R) => string;
127
- /** Retry policy */
128
- retry?: RetryPolicy;
129
- /** Timeout for resolver execution (ms) */
130
- timeout?: number;
131
- /** Batch configuration */
132
- batch?: BatchConfig;
133
- /** Resolve function for single requirement */
134
- resolve?: (req: R, ctx: ResolverContext<S>) => Promise<void>;
135
- /** Resolve function for batched requirements */
136
- resolveBatch?: (reqs: R[], ctx: ResolverContext<S>) => Promise<void>;
137
- }
138
- /**
139
- * Create a typed constraint factory for a specific schema.
140
- * This enables creating reusable constraint definitions with proper typing.
141
- *
142
- * @example
143
- * ```typescript
144
- * const schema = { count: t.number(), threshold: t.number() };
145
- * const factory = createConstraintFactory<typeof schema>();
146
- *
147
- * const maxCountConstraint = factory.create({
148
- * when: (facts) => facts.count > facts.threshold,
149
- * require: { type: "RESET" },
150
- * });
151
- * ```
152
- */
153
- declare function createConstraintFactory<S extends Schema>(): {
154
- /**
155
- * Create a typed constraint
156
- */
157
- create<R extends Requirement = Requirement>(constraint: TypedConstraint<S, R>): TypedConstraint<S, R>;
158
- };
159
- /**
160
- * Create a typed resolver factory for a specific schema.
161
- * This enables creating reusable resolver definitions with proper typing.
162
- *
163
- * @example
164
- * ```typescript
165
- * const schema = { user: t.object<User>() };
166
- * const factory = createResolverFactory<typeof schema>();
167
- *
168
- * const fetchUserResolver = factory.create<FetchUserReq>({
169
- * requirement: (req): req is FetchUserReq => req.type === "FETCH_USER",
170
- * resolve: async (req, ctx) => {
171
- * ctx.facts.user = await fetchUser(req.userId);
172
- * },
173
- * });
174
- * ```
175
- */
176
- declare function createResolverFactory<S extends Schema>(): {
177
- /**
178
- * Create a typed resolver
179
- */
180
- create<R extends Requirement = Requirement>(resolver: TypedResolver<S, R>): TypedResolver<S, R>;
181
- };
182
- /**
183
- * Type-safe constraint creator.
184
- * Simpler alternative to createConstraintFactory when you don't need a factory pattern.
185
- *
186
- * @example
187
- * ```typescript
188
- * const constraint = typedConstraint<typeof schema, { type: "RESET" }>({
189
- * when: (facts) => facts.count > 100,
190
- * require: { type: "RESET" },
191
- * });
192
- * ```
193
- */
194
- declare function typedConstraint<S extends Schema, R extends Requirement = Requirement>(constraint: TypedConstraint<S, R>): TypedConstraint<S, R>;
195
- /**
196
- * Type-safe resolver creator.
197
- * Simpler alternative to createResolverFactory when you don't need a factory pattern.
198
- *
199
- * @example
200
- * ```typescript
201
- * const resolver = typedResolver<typeof schema, FetchUserReq>({
202
- * requirement: (req): req is FetchUserReq => req.type === "FETCH_USER",
203
- * resolve: async (req, ctx) => {
204
- * ctx.facts.user = await fetchUser(req.userId);
205
- * },
206
- * });
207
- * ```
208
- */
209
- declare function typedResolver<S extends Schema, R extends Requirement = Requirement>(resolver: TypedResolver<S, R>): TypedResolver<S, R>;
210
-
211
6
  /**
212
7
  * Schema Type Builders
213
8
  *
@@ -291,7 +86,11 @@ declare const t: {
291
86
  * schema: { userId: t.string().brand<"UserId">() }
292
87
  * ```
293
88
  */
294
- string<T extends string = string>(): ChainableSchemaType<T>;
89
+ string<T extends string = string>(): ChainableSchemaType<T> & {
90
+ minLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
91
+ maxLength(n: number): ChainableSchemaType<T> & /*elided*/ any;
92
+ pattern(regex: RegExp): ChainableSchemaType<T> & /*elided*/ any;
93
+ };
295
94
  /**
296
95
  * Create a number schema type with optional min/max constraints.
297
96
  *
@@ -493,6 +292,25 @@ declare const t: {
493
292
  * ```
494
293
  */
495
294
  bigint(): ChainableSchemaType<bigint>;
295
+ /**
296
+ * Create an `any` schema type that accepts all values without validation.
297
+ *
298
+ * @example
299
+ * ```typescript
300
+ * schema: { payload: t.any() }
301
+ * ```
302
+ */
303
+ any(): ChainableSchemaType<any>;
304
+ /**
305
+ * Create an `unknown` schema type that accepts all values without validation.
306
+ * Prefer `t.unknown()` over `t.any()` for stricter downstream type checking.
307
+ *
308
+ * @example
309
+ * ```typescript
310
+ * schema: { data: t.unknown() }
311
+ * ```
312
+ */
313
+ unknown(): ChainableSchemaType<unknown>;
496
314
  };
497
315
 
498
316
  /**
@@ -1102,1226 +920,29 @@ declare class RequirementSet {
1102
920
  }
1103
921
 
1104
922
  /**
1105
- * Facts Store - Proxy-based reactive state with auto-tracking
1106
- *
1107
- * Features:
1108
- * - Proxy-based access (facts.phase instead of facts.get("phase"))
1109
- * - Automatic dependency tracking via tracking context
1110
- * - Batched updates with coalesced notifications
1111
- * - Granular subscriptions by key
1112
- * - Schema validation in development mode
1113
- */
1114
-
1115
- /** Options for creating a facts store */
1116
- interface CreateFactsStoreOptions<S extends Schema> {
1117
- schema: S;
1118
- /** Validate values against schema (default: process.env.NODE_ENV !== 'production') */
1119
- validate?: boolean;
1120
- /** Throw on unknown schema keys (default: true in dev mode) */
1121
- strictKeys?: boolean;
1122
- /** Redact sensitive values in error messages */
1123
- redactErrors?: boolean;
1124
- /** Callback when facts change (for plugin hooks) */
1125
- onChange?: (key: string, value: unknown, prev: unknown) => void;
1126
- /** Callback for batch changes */
1127
- onBatch?: (changes: Array<{
1128
- key: string;
1129
- value: unknown;
1130
- prev: unknown;
1131
- type: "set" | "delete";
1132
- }>) => void;
1133
- }
1134
- /**
1135
- * Create a reactive facts store backed by a Map with schema validation,
1136
- * batched mutations, and granular key-level subscriptions.
1137
- *
1138
- * @remarks
1139
- * The store is the low-level primitive that powers the `facts` proxy.
1140
- * Most users should use {@link createFacts} or `createModule` instead.
1141
- *
1142
- * @param options - Store configuration including schema, validation settings, and change callbacks
1143
- * @returns A {@link FactsStore} with get/set/batch/subscribe methods and automatic schema validation
1144
- *
1145
- * @example
1146
- * ```ts
1147
- * const store = createFactsStore({
1148
- * schema: { count: t.number(), name: t.string() },
1149
- * });
1150
- *
1151
- * store.set("count", 1);
1152
- * store.get("count"); // 1
1153
- *
1154
- * store.batch(() => {
1155
- * store.set("count", 2);
1156
- * store.set("name", "hello");
1157
- * }); // listeners fire once after batch completes
1158
- * ```
1159
- *
1160
- * @internal
1161
- */
1162
- declare function createFactsStore<S extends Schema>(options: CreateFactsStoreOptions<S>): FactsStore<S>;
1163
- /**
1164
- * Create a Proxy wrapper around a {@link FactsStore} for clean property-style
1165
- * access (`facts.phase`) with automatic dependency tracking.
1166
- *
1167
- * @remarks
1168
- * Reading a property calls `store.get()` (which tracks the access for
1169
- * auto-tracked derivations). Writing a property calls `store.set()` (which
1170
- * validates against the schema). The proxy also exposes `$store` for direct
1171
- * store access and `$snapshot()` for untracked reads.
1172
- *
1173
- * @param store - The underlying facts store to wrap
1174
- * @param schema - The schema definition used for `ownKeys` enumeration
1175
- * @returns A {@link Facts} proxy with property-style get/set and prototype pollution guards
1176
- *
1177
- * @example
1178
- * ```ts
1179
- * const store = createFactsStore({ schema: { phase: t.string() } });
1180
- * const facts = createFactsProxy(store, { phase: t.string() });
1181
- *
1182
- * facts.phase = "red";
1183
- * console.log(facts.phase); // "red"
1184
- * ```
1185
- *
1186
- * @internal
1187
- */
1188
- declare function createFactsProxy<S extends Schema>(store: FactsStore<S>, schema: S): Facts<S>;
1189
- /**
1190
- * Convenience factory that creates both a {@link FactsStore} and its
1191
- * {@link createFactsProxy | proxy wrapper} in a single call.
1192
- *
1193
- * @remarks
1194
- * This is the recommended entry point when you need low-level store access
1195
- * outside of `createModule` / `createSystem`.
1196
- *
1197
- * @param options - Same options as {@link createFactsStore}
1198
- * @returns An object with `store` (the reactive Map-backed store) and `facts` (the Proxy accessor)
1199
- *
1200
- * @example
1201
- * ```ts
1202
- * const { store, facts } = createFacts({
1203
- * schema: { phase: t.string<"red" | "green">() },
1204
- * });
1205
- *
1206
- * facts.phase = "red";
1207
- * console.log(facts.phase); // "red"
1208
- * store.subscribe(["phase"], () => console.log("phase changed"));
1209
- * ```
1210
- *
1211
- * @internal
1212
- */
1213
- declare function createFacts<S extends Schema>(options: CreateFactsStoreOptions<S>): {
1214
- store: FactsStore<S>;
1215
- facts: Facts<S>;
1216
- };
1217
-
1218
- /**
1219
- * Derivations - Auto-tracked computed values with composition
1220
- *
1221
- * Features:
1222
- * - Automatic dependency tracking (no manual deps arrays)
1223
- * - Memoization with smart invalidation
1224
- * - Derivation composition (derivations can depend on other derivations)
1225
- * - Circular dependency detection
1226
- * - Lazy evaluation
1227
- */
1228
-
1229
- interface DerivationsManager<S extends Schema, D extends DerivationsDef<S>> {
1230
- /** Get a derived value (computes if stale) */
1231
- get<K extends keyof D>(id: K): ReturnType<D[K]>;
1232
- /** Check if a derivation is stale */
1233
- isStale(id: keyof D): boolean;
1234
- /** Invalidate derivations that depend on a fact key */
1235
- invalidate(factKey: string): void;
1236
- /** Invalidate derivations for multiple fact keys, notifying listeners once at the end */
1237
- invalidateMany(factKeys: Iterable<string>): void;
1238
- /** Invalidate all derivations */
1239
- invalidateAll(): void;
1240
- /** Subscribe to derivation changes */
1241
- subscribe(ids: Array<keyof D>, listener: () => void): () => void;
1242
- /** Get the proxy for composition */
1243
- getProxy(): DerivedValues<S, D>;
1244
- /** Get dependencies for a derivation */
1245
- getDependencies(id: keyof D): Set<string>;
1246
- /** Register new derivation definitions (for dynamic module registration) */
1247
- registerDefinitions(newDefs: DerivationsDef<S>): void;
1248
- /** Override an existing derivation function */
1249
- assignDefinition(id: string, fn: DerivationsDef<S>[keyof DerivationsDef<S>]): void;
1250
- /** Remove a derivation and clean up its state */
1251
- unregisterDefinition(id: string): void;
1252
- /** Compute a derivation immediately (ignores cache) */
1253
- callOne(id: string): unknown;
1254
- }
1255
- /** Options for creating a derivations manager */
1256
- interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>> {
1257
- definitions: D;
1258
- facts: Facts<S>;
1259
- store: FactsStore<S>;
1260
- /** Callback when a derivation is computed */
1261
- onCompute?: (id: string, value: unknown, oldValue: unknown, deps: string[]) => void;
1262
- /** Callback when a derivation is invalidated */
1263
- onInvalidate?: (id: string) => void;
1264
- /** Callback when a derivation errors */
1265
- onError?: (id: string, error: unknown) => void;
1266
- }
1267
- /**
1268
- * Create a manager for lazily-evaluated, auto-tracked derived values.
1269
- *
1270
- * Derivations are memoized computations that automatically track which facts
1271
- * they read. When a tracked fact changes, the derivation is invalidated and
1272
- * recomputed on next access. Derivations can depend on other derivations
1273
- * (composition), and circular dependencies are detected at compute time.
1274
- *
1275
- * Notifications are deferred during invalidation so listeners always see
1276
- * consistent state across multiple simultaneous fact changes.
923
+ * @directive-run/core
1277
924
  *
1278
- * @param options - Derivation definitions, facts proxy, store, and optional
1279
- * lifecycle callbacks.
1280
- * @returns A {@link DerivationsManager} for accessing, invalidating, and
1281
- * subscribing to derived values.
925
+ * Constraint-driven runtime for TypeScript.
1282
926
  *
1283
- * @internal
1284
- */
1285
- declare function createDerivationsManager<S extends Schema, D extends DerivationsDef<S>>(options: CreateDerivationsOptions<S, D>): DerivationsManager<S, D>;
1286
-
1287
- /**
1288
- * Effects - Fire-and-forget side effects
927
+ * Also available:
928
+ * - `@directive-run/core/internals` – Manager factories, engine, tracking, and internal types
929
+ * - `@directive-run/core/plugins` – Logging, devtools, persistence, observability, circuit breaker
930
+ * - `@directive-run/core/testing` – Mock resolvers, fake timers, assertion helpers
931
+ * - `@directive-run/core/migration` – Redux/Zustand/XState migration scaffolding
932
+ * - `@directive-run/core/adapter-utils` Shared framework adapter utilities
933
+ * - `@directive-run/core/worker` – Web Worker support
1289
934
  *
1290
- * Features:
1291
- * - Separate from requirement resolution
1292
- * - Error isolation (never breaks reconciliation)
1293
- * - Optional explicit dependencies for optimization
1294
- * - Runs after facts stabilize
1295
- *
1296
- * IMPORTANT: Auto-tracking limitations
1297
- * ------------------------------------
1298
- * When using auto-tracking (no explicit `deps`), only SYNCHRONOUS fact accesses
1299
- * are tracked. If your effect reads facts after an `await`, those reads are NOT
1300
- * tracked and won't trigger the effect on future changes.
1301
- *
1302
- * For async effects, always use explicit `deps`:
1303
- * @example
1304
- * ```typescript
1305
- * effects: {
1306
- * // BAD: fetchData is async, facts.userId read after await won't be tracked
1307
- * badEffect: {
1308
- * run: async (facts) => {
1309
- * await someAsyncOp();
1310
- * console.log(facts.userId); // NOT tracked!
1311
- * },
1312
- * },
1313
- * // GOOD: explicit deps for async effects
1314
- * goodEffect: {
1315
- * deps: ["userId"],
1316
- * run: async (facts) => {
1317
- * await someAsyncOp();
1318
- * console.log(facts.userId); // Works because we declared the dep
1319
- * },
1320
- * },
1321
- * }
1322
- * ```
935
+ * @packageDocumentation
1323
936
  */
1324
937
 
1325
938
  /**
1326
- * Manager returned by {@link createEffectsManager} that runs fire-and-forget
1327
- * side effects after facts stabilize.
1328
- *
1329
- * @internal
1330
- */
1331
- interface EffectsManager<_S extends Schema = Schema> {
1332
- /**
1333
- * Run all effects whose tracked dependencies overlap with `changedKeys`.
1334
- *
1335
- * @remarks
1336
- * Effects with no recorded dependencies (first run or auto-tracked with no
1337
- * reads) run on any change. After execution, a snapshot of current facts is
1338
- * stored for the `prev` parameter on the next invocation.
1339
- *
1340
- * @param changedKeys - Fact keys that changed since the last run.
1341
- */
1342
- runEffects(changedKeys: Set<string>): Promise<void>;
1343
- /**
1344
- * Run every enabled effect unconditionally, regardless of dependencies.
1345
- */
1346
- runAll(): Promise<void>;
1347
- /**
1348
- * Disable an effect so it is skipped during subsequent runs.
1349
- *
1350
- * @param id - The effect definition ID.
1351
- */
1352
- disable(id: string): void;
1353
- /**
1354
- * Re-enable a previously disabled effect.
1355
- *
1356
- * @param id - The effect definition ID.
1357
- */
1358
- enable(id: string): void;
1359
- /**
1360
- * Check whether an effect is currently enabled.
1361
- *
1362
- * @param id - The effect definition ID.
1363
- * @returns `true` if the effect has not been disabled.
1364
- */
1365
- isEnabled(id: string): boolean;
1366
- /**
1367
- * Invoke every stored cleanup function and mark the manager as stopped.
1368
- *
1369
- * @remarks
1370
- * After this call, any cleanup functions returned by in-flight async effects
1371
- * will be invoked immediately rather than stored.
1372
- */
1373
- cleanupAll(): void;
1374
- /**
1375
- * Register additional effect definitions at runtime (used for dynamic
1376
- * module registration).
1377
- *
1378
- * @param newDefs - New effect definitions to merge into the manager.
1379
- */
1380
- registerDefinitions(newDefs: EffectsDef<Schema>): void;
1381
- /**
1382
- * Override an existing effect definition. Runs cleanup of the old effect first.
1383
- *
1384
- * @param id - The effect definition ID to override.
1385
- * @param def - The new effect definition.
1386
- * @throws If no effect with this ID exists.
1387
- */
1388
- assignDefinition(id: string, def: EffectsDef<Schema>[string]): void;
1389
- /**
1390
- * Remove an effect definition. Runs cleanup (try-catch) and removes from state.
1391
- *
1392
- * @param id - The effect definition ID to remove.
1393
- */
1394
- unregisterDefinition(id: string): void;
1395
- /**
1396
- * Execute an effect's `run()` function immediately.
1397
- *
1398
- * @param id - The effect definition ID.
1399
- */
1400
- callOne(id: string): Promise<void>;
1401
- }
1402
- /**
1403
- * Configuration options accepted by {@link createEffectsManager}.
1404
- *
1405
- * @internal
1406
- */
1407
- interface CreateEffectsOptions<S extends Schema> {
1408
- /** Effect definitions keyed by ID. */
1409
- definitions: EffectsDef<S>;
1410
- /** Proxy-based facts object passed to effect `run()` functions. */
1411
- facts: Facts<S>;
1412
- /** Underlying fact store used for `batch()` coalescing of mutations. */
1413
- store: FactsStore<S>;
1414
- /** Called when an effect executes, with the fact keys that triggered it. */
1415
- onRun?: (id: string, deps: string[]) => void;
1416
- /** Called when an effect's `run()` or cleanup function throws. */
1417
- onError?: (id: string, error: unknown) => void;
1418
- }
1419
- /**
1420
- * Create a manager for fire-and-forget side effects that run after facts
1421
- * stabilize.
1422
- *
1423
- * @remarks
1424
- * Effects support two dependency modes:
1425
- *
1426
- * - **Auto-tracked** (no `deps`): Dependencies are re-tracked on every run
1427
- * via {@link withTracking}, so conditional fact reads are always captured.
1428
- * Only synchronous reads are tracked; reads after an `await` are invisible.
1429
- *
1430
- * - **Explicit `deps`**: A fixed array of fact keys declared on the definition.
1431
- * Preferred for async effects where auto-tracking cannot cross `await`
1432
- * boundaries.
1433
- *
1434
- * Each effect can return a cleanup function that runs before the next
1435
- * execution or when {@link EffectsManager.cleanupAll | cleanupAll} is called.
1436
- * Errors in effects are isolated via try-catch and never break the
1437
- * reconciliation loop. Synchronous fact mutations inside effects are
1438
- * coalesced with `store.batch()`.
1439
- *
1440
- * @param options - Configuration including effect definitions, facts proxy,
1441
- * store, and lifecycle callbacks.
1442
- * @returns An {@link EffectsManager} for running, enabling/disabling, and
1443
- * cleaning up effects.
939
+ * Backoff strategy constants for retry policies.
1444
940
  *
1445
941
  * @example
1446
- * ```typescript
1447
- * const effects = createEffectsManager({
1448
- * definitions: {
1449
- * logPhase: {
1450
- * run: (facts, prev) => {
1451
- * if (prev?.phase !== facts.phase) {
1452
- * console.log(`Phase changed to ${facts.phase}`);
1453
- * }
1454
- * },
1455
- * },
1456
- * },
1457
- * facts: factsProxy,
1458
- * store: factsStore,
1459
- * });
1460
- *
1461
- * await effects.runEffects(new Set(["phase"]));
1462
- * ```
1463
- *
1464
- * @internal
1465
- */
1466
- declare function createEffectsManager<S extends Schema>(options: CreateEffectsOptions<S>): EffectsManager<S>;
1467
-
1468
- /**
1469
- * Constraints - Rules that produce requirements when conditions aren't met
1470
- *
1471
- * Features:
1472
- * - Sync and async constraint evaluation
1473
- * - Priority ordering (higher runs first)
1474
- * - Timeout handling for async constraints
1475
- * - Error isolation
1476
- */
1477
-
1478
- /**
1479
- * Manager returned by {@link createConstraintsManager} that evaluates
1480
- * constraint rules against the current facts and produces unmet
1481
- * {@link RequirementWithId | requirements}.
942
+ * ```ts
943
+ * import { Backoff } from '@directive-run/core';
1482
944
  *
1483
- * @internal
1484
- */
1485
- interface ConstraintsManager<_S extends Schema> {
1486
- /**
1487
- * Evaluate all enabled constraints and return unmet requirements.
1488
- *
1489
- * @remarks
1490
- * On the first call (or when `changedKeys` is empty), every enabled
1491
- * constraint is evaluated. On subsequent calls, only constraints whose
1492
- * tracked dependencies overlap with `changedKeys` are re-evaluated.
1493
- * Sync constraints run first, async constraints run in parallel, and
1494
- * `after` ordering is respected across multiple passes.
1495
- *
1496
- * @param changedKeys - Fact keys that changed since the last evaluation.
1497
- * When omitted or empty, all constraints are evaluated.
1498
- * @returns An array of {@link RequirementWithId} representing unmet requirements.
1499
- */
1500
- evaluate(changedKeys?: Set<string>): Promise<RequirementWithId[]>;
1501
- /**
1502
- * Get the current state of a constraint by its definition ID.
1503
- *
1504
- * @param id - The constraint definition ID.
1505
- * @returns The {@link ConstraintState}, or `undefined` if the ID is unknown.
1506
- */
1507
- getState(id: string): ConstraintState | undefined;
1508
- /**
1509
- * Get the state of every registered constraint.
1510
- *
1511
- * @returns An array of all {@link ConstraintState} objects.
1512
- */
1513
- getAllStates(): ConstraintState[];
1514
- /**
1515
- * Disable a constraint so it is skipped during evaluation.
1516
- *
1517
- * @param id - The constraint definition ID.
1518
- */
1519
- disable(id: string): void;
1520
- /**
1521
- * Re-enable a previously disabled constraint.
1522
- *
1523
- * @param id - The constraint definition ID.
1524
- */
1525
- enable(id: string): void;
1526
- /**
1527
- * Mark all constraints that depend on `factKey` as dirty so they are
1528
- * re-evaluated on the next {@link ConstraintsManager.evaluate | evaluate} call.
1529
- *
1530
- * @param factKey - The fact store key that changed.
1531
- */
1532
- invalidate(factKey: string): void;
1533
- /**
1534
- * Get the auto-tracked or explicit dependency set for a constraint.
1535
- *
1536
- * @param id - The constraint definition ID.
1537
- * @returns A `Set` of fact keys, or `undefined` if no dependencies have been recorded.
1538
- */
1539
- getDependencies(id: string): Set<string> | undefined;
1540
- /**
1541
- * Record that a constraint's resolver completed successfully, unblocking
1542
- * any constraints that list it in their `after` array.
1543
- *
1544
- * @param constraintId - The constraint definition ID whose resolver finished.
1545
- */
1546
- markResolved(constraintId: string): void;
1547
- /**
1548
- * Check whether a constraint is currently disabled.
1549
- *
1550
- * @param id - The constraint definition ID.
1551
- * @returns `true` if the constraint has been disabled via {@link ConstraintsManager.disable | disable}.
1552
- */
1553
- isDisabled(id: string): boolean;
1554
- /**
1555
- * Check whether a constraint has been marked as resolved.
1556
- *
1557
- * @param constraintId - The constraint definition ID.
1558
- * @returns `true` if {@link ConstraintsManager.markResolved | markResolved} was called for this constraint.
1559
- */
1560
- isResolved(constraintId: string): boolean;
1561
- /**
1562
- * Register additional constraint definitions at runtime (used for dynamic
1563
- * module registration).
1564
- *
1565
- * @remarks
1566
- * Rebuilds the topological order and reverse dependency map so new `after`
1567
- * dependencies are validated for cycles and indexed.
1568
- *
1569
- * @param newDefs - New constraint definitions to merge into the manager.
1570
- */
1571
- registerDefinitions(newDefs: ConstraintsDef<Schema>): void;
1572
- /**
1573
- * Override an existing constraint definition.
1574
- * Stores the original in an internal map for inspection.
1575
- *
1576
- * @param id - The constraint definition ID to override.
1577
- * @param def - The new constraint definition.
1578
- * @throws If no constraint with this ID exists.
1579
- */
1580
- assignDefinition(id: string, def: ConstraintsDef<Schema>[string]): void;
1581
- /**
1582
- * Remove a constraint definition and all its internal state.
1583
- *
1584
- * @param id - The constraint definition ID to remove.
1585
- */
1586
- unregisterDefinition(id: string): void;
1587
- /**
1588
- * Evaluate a single constraint and emit its requirement if active.
1589
- * Props are merged into the requirement object.
1590
- *
1591
- * @param id - The constraint definition ID.
1592
- * @param props - Optional properties to merge into the requirement.
1593
- * @returns The emitted requirements (if any).
1594
- */
1595
- callOne(id: string, props?: Record<string, unknown>): Promise<RequirementWithId[]>;
1596
- }
1597
- /**
1598
- * Configuration options accepted by {@link createConstraintsManager}.
1599
- *
1600
- * @internal
1601
- */
1602
- interface CreateConstraintsOptions<S extends Schema> {
1603
- /** Constraint definitions keyed by ID. */
1604
- definitions: ConstraintsDef<S>;
1605
- /** Proxy-based facts object used to evaluate `when()` predicates. */
1606
- facts: Facts<S>;
1607
- /** Custom key functions for requirement deduplication, keyed by constraint ID. */
1608
- requirementKeys?: Record<string, RequirementKeyFn>;
1609
- /** Default timeout in milliseconds for async constraint evaluation (defaults to 5 000). */
1610
- defaultTimeout?: number;
1611
- /** Called after each constraint evaluation with the constraint ID and whether `when()` was active. */
1612
- onEvaluate?: (id: string, active: boolean) => void;
1613
- /** Called when a constraint's `when()` or `require()` throws. */
1614
- onError?: (id: string, error: unknown) => void;
1615
- }
1616
- /**
1617
- * Create a manager that evaluates constraint rules and produces unmet
1618
- * requirements.
1619
- *
1620
- * @remarks
1621
- * Constraints are evaluated in priority order (higher priority first), with
1622
- * topological ordering for same-priority constraints connected by `after`
1623
- * dependencies. The manager supports sync and async `when()` predicates,
1624
- * incremental evaluation based on changed fact keys, and per-constraint
1625
- * enable/disable toggling. Cycle detection runs eagerly at construction time
1626
- * to prevent deadlocks in production.
1627
- *
1628
- * @param options - Configuration including constraint definitions, facts proxy,
1629
- * custom requirement key functions, and lifecycle callbacks.
1630
- * @returns A {@link ConstraintsManager} for evaluating, invalidating, and
1631
- * managing constraint lifecycle.
1632
- *
1633
- * @example
1634
- * ```typescript
1635
- * const constraints = createConstraintsManager({
1636
- * definitions: {
1637
- * mustTransition: {
1638
- * priority: 50,
1639
- * when: (facts) => facts.phase === "red" && facts.elapsed > 30,
1640
- * require: { type: "TRANSITION", to: "green" },
1641
- * },
1642
- * },
1643
- * facts: factsProxy,
1644
- * onEvaluate: (id, active) => console.log(id, active),
1645
- * });
1646
- *
1647
- * const unmet = await constraints.evaluate();
1648
- * ```
1649
- *
1650
- * @internal
1651
- */
1652
- declare function createConstraintsManager<S extends Schema>(options: CreateConstraintsOptions<S>): ConstraintsManager<S>;
1653
-
1654
- /**
1655
- * Resolvers - Capability-based handlers for requirements
1656
- *
1657
- * Features:
1658
- * - Capability matching (handles predicate)
1659
- * - Custom dedupe keys
1660
- * - Retry policies with exponential backoff
1661
- * - Batched resolution for similar requirements
1662
- * - Cancellation via AbortController
1663
- */
1664
-
1665
- /**
1666
- * Summary of a resolver that is currently in flight.
1667
- *
1668
- * @internal
1669
- */
1670
- interface InflightInfo {
1671
- /** The unique requirement ID being resolved. */
1672
- id: string;
1673
- /** The definition ID of the resolver handling this requirement. */
1674
- resolverId: string;
1675
- /** Epoch timestamp (ms) when resolution started. */
1676
- startedAt: number;
1677
- }
1678
- /**
1679
- * Manager returned by {@link createResolversManager} that matches
1680
- * requirements to resolver handlers and manages their execution lifecycle.
1681
- *
1682
- * @internal
1683
- */
1684
- interface ResolversManager<_S extends Schema> {
1685
- /**
1686
- * Start resolving a requirement by matching it to a resolver handler.
1687
- *
1688
- * @remarks
1689
- * Duplicate in-flight requirements (same `req.id`) are silently ignored.
1690
- * If the matched resolver has `batch.enabled`, the requirement is queued
1691
- * for batch processing instead of being resolved immediately.
1692
- *
1693
- * @param req - The requirement (with a stable identity ID) to resolve.
1694
- */
1695
- resolve(req: RequirementWithId): void;
1696
- /**
1697
- * Cancel an in-flight or batch-queued resolver by requirement ID.
1698
- *
1699
- * @remarks
1700
- * Aborts the `AbortController` for in-flight resolvers. For batch-queued
1701
- * requirements, removes the requirement from the pending batch.
1702
- *
1703
- * @param requirementId - The unique requirement ID to cancel.
1704
- */
1705
- cancel(requirementId: string): void;
1706
- /**
1707
- * Cancel every in-flight resolver and flush all pending batch queues.
1708
- */
1709
- cancelAll(): void;
1710
- /**
1711
- * Get the current status of a resolver by requirement ID.
1712
- *
1713
- * @param requirementId - The unique requirement ID to look up.
1714
- * @returns The {@link ResolverStatus} (idle, pending, running, success, error, or canceled).
1715
- */
1716
- getStatus(requirementId: string): ResolverStatus;
1717
- /**
1718
- * Get the requirement IDs of all currently in-flight resolvers.
1719
- *
1720
- * @returns An array of requirement ID strings.
1721
- */
1722
- getInflight(): string[];
1723
- /**
1724
- * Get detailed info for every in-flight resolver.
1725
- *
1726
- * @returns An array of {@link InflightInfo} objects.
1727
- */
1728
- getInflightInfo(): InflightInfo[];
1729
- /**
1730
- * Check whether a requirement is currently being resolved.
1731
- *
1732
- * @param requirementId - The unique requirement ID to check.
1733
- * @returns `true` if the requirement has an active in-flight resolver.
1734
- */
1735
- isResolving(requirementId: string): boolean;
1736
- /**
1737
- * Immediately flush all pending batch queues, executing their resolvers.
1738
- */
1739
- processBatches(): void;
1740
- /**
1741
- * Check whether any batch queues have requirements waiting to be processed.
1742
- *
1743
- * @returns `true` if at least one batch queue is non-empty.
1744
- */
1745
- hasPendingBatches(): boolean;
1746
- /**
1747
- * Register additional resolver definitions at runtime (used for dynamic
1748
- * module registration).
1749
- *
1750
- * @remarks
1751
- * Clears the resolver-by-type cache so newly registered resolvers are
1752
- * discoverable on the next {@link ResolversManager.resolve | resolve} call.
1753
- *
1754
- * @param newDefs - New resolver definitions to merge into the manager.
1755
- */
1756
- registerDefinitions(newDefs: ResolversDef<Schema>): void;
1757
- /**
1758
- * Override an existing resolver definition.
1759
- *
1760
- * @param id - The resolver definition ID to override.
1761
- * @param def - The new resolver definition.
1762
- * @throws If no resolver with this ID exists.
1763
- */
1764
- assignDefinition(id: string, def: ResolversDef<Schema>[string]): void;
1765
- /**
1766
- * Remove a resolver definition. Cancels any inflight resolution.
1767
- *
1768
- * @param id - The resolver definition ID to remove.
1769
- */
1770
- unregisterDefinition(id: string): void;
1771
- /**
1772
- * Execute a resolver with a given requirement object.
1773
- *
1774
- * @param id - The resolver definition ID.
1775
- * @param requirement - The requirement to resolve.
1776
- */
1777
- callOne(id: string, requirement: Requirement): Promise<void>;
1778
- /**
1779
- * Clean up all internal state. Called on system destroy.
1780
- */
1781
- destroy(): void;
1782
- }
1783
- /**
1784
- * Configuration options accepted by {@link createResolversManager}.
1785
- *
1786
- * @internal
1787
- */
1788
- interface CreateResolversOptions<S extends Schema> {
1789
- /** Resolver definitions keyed by ID. */
1790
- definitions: ResolversDef<S>;
1791
- /** Proxy-based facts object passed to resolver contexts. */
1792
- facts: Facts<S>;
1793
- /** Underlying fact store used for `batch()` coalescing of mutations. */
1794
- store: FactsStore<S>;
1795
- /** Called when a resolver begins execution. */
1796
- onStart?: (resolver: string, req: RequirementWithId) => void;
1797
- /** Called when a resolver completes successfully, with the wall-clock duration in ms. */
1798
- onComplete?: (resolver: string, req: RequirementWithId, duration: number) => void;
1799
- /** Called when a resolver exhausts all retry attempts. */
1800
- onError?: (resolver: string, req: RequirementWithId, error: unknown) => void;
1801
- /** Called before each retry attempt with the upcoming attempt number. */
1802
- onRetry?: (resolver: string, req: RequirementWithId, attempt: number) => void;
1803
- /** Called when a resolver is canceled via {@link ResolversManager.cancel | cancel}. */
1804
- onCancel?: (resolver: string, req: RequirementWithId) => void;
1805
- /** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
1806
- onResolutionComplete?: () => void;
1807
- }
1808
- /**
1809
- * Create a manager that fulfills requirements by matching them to resolver
1810
- * handlers.
1811
- *
1812
- * @remarks
1813
- * Resolvers are matched by requirement type (string equality) or a predicate
1814
- * function. Each resolution runs with an `AbortController` for cancellation
1815
- * and configurable retry policies (none, linear, or exponential backoff).
1816
- *
1817
- * **Batching:** When a resolver sets `batch.enabled`, incoming requirements
1818
- * are queued and flushed either when `batch.maxSize` is reached or after
1819
- * `batch.windowMs` elapses, whichever comes first. Batch resolvers can use
1820
- * `resolveBatch` (all-or-nothing) or `resolveBatchWithResults` (per-item
1821
- * success/failure). If only `resolve` is provided with batching enabled, the
1822
- * manager falls back to individual resolution calls.
1823
- *
1824
- * Duplicate in-flight requirements (same requirement ID) are automatically
1825
- * deduplicated. Resolver-by-type lookups are cached with FIFO eviction at
1826
- * 1 000 entries to handle dynamic requirement types.
1827
- *
1828
- * @param options - Configuration including resolver definitions, facts proxy,
1829
- * store, and lifecycle callbacks.
1830
- * @returns A {@link ResolversManager} for dispatching, canceling, and
1831
- * inspecting requirement resolution.
1832
- *
1833
- * @example
1834
- * ```typescript
1835
- * const resolvers = createResolversManager({
1836
- * definitions: {
1837
- * transition: {
1838
- * requirement: "TRANSITION",
1839
- * retry: { attempts: 3, backoff: "exponential" },
1840
- * resolve: async (req, context) => {
1841
- * context.facts.phase = req.to;
1842
- * context.facts.elapsed = 0;
1843
- * },
1844
- * },
1845
- * },
1846
- * facts: factsProxy,
1847
- * store: factsStore,
1848
- * onComplete: (id, req, ms) => console.log(`${id} resolved in ${ms}ms`),
1849
- * });
1850
- *
1851
- * resolvers.resolve(requirementWithId);
1852
- * ```
1853
- *
1854
- * @internal
1855
- */
1856
- declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
1857
-
1858
- /**
1859
- * Plugin Architecture - Extensible middleware for Directive
1860
- *
1861
- * Features:
1862
- * - Lifecycle hooks for all engine events
1863
- * - Multiple plugins can be composed
1864
- * - Plugins execute in registration order
1865
- */
1866
-
1867
- /**
1868
- * Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
1869
- *
1870
- * @remarks
1871
- * PluginManager uses `Schema` (flat) internally because the engine works with
1872
- * flat schemas. The public API uses `ModuleSchema` (consolidated), and the
1873
- * conversion happens in `createSystem`.
1874
- *
1875
- * Plugins execute in registration order. All hook invocations are wrapped in
1876
- * try-catch so a misbehaving plugin never breaks the engine. Duplicate plugin
1877
- * names are detected and the older registration is replaced with a warning.
1878
- *
1879
- * Lifecycle hook categories:
1880
- * - **System lifecycle:** `emitInit`, `emitStart`, `emitStop`, `emitDestroy`
1881
- * - **Facts:** `emitFactSet`, `emitFactDelete`, `emitFactsBatch`
1882
- * - **Derivations:** `emitDerivationCompute`, `emitDerivationInvalidate`
1883
- * - **Reconciliation:** `emitReconcileStart`, `emitReconcileEnd`
1884
- * - **Constraints:** `emitConstraintEvaluate`, `emitConstraintError`
1885
- * - **Requirements:** `emitRequirementCreated`, `emitRequirementMet`, `emitRequirementCanceled`
1886
- * - **Resolvers:** `emitResolverStart`, `emitResolverComplete`, `emitResolverError`, `emitResolverRetry`, `emitResolverCancel`
1887
- * - **Effects:** `emitEffectRun`, `emitEffectError`
1888
- * - **History:** `emitSnapshot`, `emitHistoryNavigate`
1889
- * - **Errors:** `emitError`, `emitErrorRecovery`
1890
- * - **Trace:** `emitTraceComplete`
1891
- *
1892
- * @typeParam _S - The flat schema type (unused at runtime).
1893
- *
1894
- * @internal
1895
- */
1896
- interface PluginManager<_S extends Schema = any> {
1897
- /** Register a plugin */
1898
- register(plugin: Plugin<any>): void;
1899
- /** Unregister a plugin by name */
1900
- unregister(name: string): void;
1901
- /** Get all registered plugins */
1902
- getPlugins(): Plugin<any>[];
1903
- emitInit(system: System<any>): Promise<void>;
1904
- emitStart(system: System<any>): void;
1905
- emitStop(system: System<any>): void;
1906
- emitDestroy(system: System<any>): void;
1907
- emitFactSet(key: string, value: unknown, prev: unknown): void;
1908
- emitFactDelete(key: string, prev: unknown): void;
1909
- emitFactsBatch(changes: FactChange[]): void;
1910
- emitDerivationCompute(id: string, value: unknown, deps: string[]): void;
1911
- emitDerivationInvalidate(id: string): void;
1912
- emitReconcileStart(snapshot: FactsSnapshot<any>): void;
1913
- emitReconcileEnd(result: ReconcileResult): void;
1914
- emitConstraintEvaluate(id: string, active: boolean): void;
1915
- emitConstraintError(id: string, error: unknown): void;
1916
- emitRequirementCreated(req: RequirementWithId): void;
1917
- emitRequirementMet(req: RequirementWithId, byResolver: string): void;
1918
- emitRequirementCanceled(req: RequirementWithId): void;
1919
- emitResolverStart(resolver: string, req: RequirementWithId): void;
1920
- emitResolverComplete(resolver: string, req: RequirementWithId, duration: number): void;
1921
- emitResolverError(resolver: string, req: RequirementWithId, error: unknown): void;
1922
- emitResolverRetry(resolver: string, req: RequirementWithId, attempt: number): void;
1923
- emitResolverCancel(resolver: string, req: RequirementWithId): void;
1924
- emitEffectRun(id: string): void;
1925
- emitEffectError(id: string, error: unknown): void;
1926
- emitSnapshot(snapshot: Snapshot): void;
1927
- emitHistoryNavigate(from: number, to: number): void;
1928
- emitError(error: DirectiveError): void;
1929
- emitErrorRecovery(error: DirectiveError, strategy: RecoveryStrategy): void;
1930
- emitDefinitionRegister(type: string, id: string, def: unknown): void;
1931
- emitDefinitionAssign(type: string, id: string, def: unknown, original: unknown): void;
1932
- emitDefinitionUnregister(type: string, id: string): void;
1933
- emitDefinitionCall(type: string, id: string, props?: unknown): void;
1934
- emitTraceComplete(run: TraceEntry): void;
1935
- }
1936
- /**
1937
- * Create a {@link PluginManager} that broadcasts lifecycle events to registered plugins.
1938
- *
1939
- * @remarks
1940
- * Plugins are called in registration order. All hook invocations are wrapped
1941
- * in try-catch so a misbehaving plugin never breaks the engine. Duplicate
1942
- * plugin names are detected and the older registration is replaced with a
1943
- * console warning.
1944
- *
1945
- * @returns A {@link PluginManager} with `register`/`unregister`/`getPlugins` and `emit*` methods for every lifecycle event.
1946
- *
1947
- * @internal
1948
- */
1949
- declare function createPluginManager<S extends Schema = any>(): PluginManager<S>;
1950
-
1951
- /**
1952
- * Error Boundaries - Configurable error handling and recovery
1953
- *
1954
- * Features:
1955
- * - Catch errors in constraints/resolvers/effects/derivations
1956
- * - Configurable recovery strategies (skip, retry, retry-later, disable, throw)
1957
- * - Circuit breaker pattern for automatic failure protection
1958
- * - Error reporting to plugins
1959
- */
1960
-
1961
- /**
1962
- * A queued retry entry tracking its source, attempt count, and scheduled time.
1963
- *
1964
- * @internal
1965
- */
1966
- interface PendingRetry {
1967
- source: ErrorSource;
1968
- sourceId: string;
1969
- context: unknown;
1970
- attempt: number;
1971
- nextRetryTime: number;
1972
- callback?: () => void;
1973
- }
1974
- /**
1975
- * Create a manager for deferred retry scheduling with exponential backoff.
1976
- *
1977
- * @remarks
1978
- * Retries are stored in a Map keyed by source ID. Each entry tracks its
1979
- * attempt number and the timestamp of the next eligible retry. When
1980
- * {@link createRetryLaterManager | processDueRetries} is called (typically
1981
- * during reconciliation), entries whose scheduled time has elapsed are
1982
- * returned and removed from the queue. The delay grows exponentially:
1983
- * `delayMs * backoffMultiplier^(attempt - 1)`, capped at `maxDelayMs`.
1984
- *
1985
- * @param config - Backoff configuration including `delayMs`, `maxRetries`, `backoffMultiplier`, and `maxDelayMs`.
1986
- * @returns A manager exposing `scheduleRetry`, `getPendingRetries`, `processDueRetries`, `cancelRetry`, and `clearAll` methods.
1987
- *
1988
- * @internal
1989
- */
1990
- declare function createRetryLaterManager(config?: RetryLaterConfig): {
1991
- /** Schedule a retry */
1992
- scheduleRetry: (source: ErrorSource, sourceId: string, context: unknown, attempt: number, callback?: () => void) => PendingRetry | null;
1993
- /** Get pending retries */
1994
- getPendingRetries: () => PendingRetry[];
1995
- /** Process due retries */
1996
- processDueRetries: () => PendingRetry[];
1997
- /** Cancel a retry */
1998
- cancelRetry: (sourceId: string) => void;
1999
- /** Clear all pending retries */
2000
- clearAll: () => void;
2001
- };
2002
- /**
2003
- * Handle returned by {@link createErrorBoundaryManager} for routing errors
2004
- * through configurable recovery strategies.
2005
- *
2006
- * @internal
2007
- */
2008
- interface ErrorBoundaryManager {
2009
- /**
2010
- * Route an error through the configured recovery strategy for its source.
2011
- *
2012
- * @param source - The subsystem that produced the error.
2013
- * @param sourceId - Identifier of the specific constraint, resolver, effect, or derivation.
2014
- * @param error - The thrown value (coerced to {@link DirectiveError} internally).
2015
- * @param context - Optional context forwarded to callbacks and retry entries.
2016
- * @returns The {@link RecoveryStrategy} that was applied.
2017
- */
2018
- handleError(source: ErrorSource, sourceId: string, error: unknown, context?: unknown): RecoveryStrategy;
2019
- /**
2020
- * Return the most recently recorded error, or `null` if none exist.
2021
- *
2022
- * @returns The last {@link DirectiveError}, or `null`.
2023
- */
2024
- getLastError(): DirectiveError | null;
2025
- /**
2026
- * Return a snapshot array of all recorded errors (up to the last 100).
2027
- *
2028
- * @returns A shallow copy of the internal error ring buffer.
2029
- */
2030
- getAllErrors(): DirectiveError[];
2031
- /** Clear all recorded errors. */
2032
- clearErrors(): void;
2033
- /**
2034
- * Access the underlying retry-later manager for advanced scheduling.
2035
- *
2036
- * @returns The {@link createRetryLaterManager} instance used internally.
2037
- */
2038
- getRetryLaterManager(): ReturnType<typeof createRetryLaterManager>;
2039
- /**
2040
- * Drain and return retry entries whose scheduled time has elapsed.
2041
- *
2042
- * @returns An array of {@link PendingRetry} entries that are now due.
2043
- */
2044
- processDueRetries(): PendingRetry[];
2045
- /**
2046
- * Reset retry attempt tracking for a source, typically after a successful resolution.
2047
- *
2048
- * @param sourceId - The source identifier whose retry counter should be cleared.
2049
- */
2050
- clearRetryAttempts(sourceId: string): void;
2051
- }
2052
- /**
2053
- * Options accepted by {@link createErrorBoundaryManager}.
2054
- *
2055
- * @internal
2056
- */
2057
- interface CreateErrorBoundaryOptions {
2058
- /** Per-source recovery strategies and retry-later tuning. */
2059
- config?: ErrorBoundaryConfig;
2060
- /** Invoked every time an error is recorded, before the recovery strategy runs. */
2061
- onError?: (error: DirectiveError) => void;
2062
- /** Invoked after a recovery strategy has been selected for an error. */
2063
- onRecovery?: (error: DirectiveError, strategy: RecoveryStrategy) => void;
2064
- }
2065
- /**
2066
- * Create a manager that handles errors from constraints, resolvers, effects,
2067
- * and derivations with configurable per-source recovery strategies.
2068
- *
2069
- * @remarks
2070
- * Five recovery strategies are available:
2071
- *
2072
- * - `"skip"` -- Swallow the error and continue.
2073
- * - `"retry"` -- Signal the caller to retry immediately.
2074
- * - `"retry-later"` -- Enqueue a deferred retry with exponential backoff
2075
- * (delegated to an internal {@link createRetryLaterManager}).
2076
- * - `"disable"` -- Permanently disable the failing source.
2077
- * - `"throw"` -- Re-throw the error as a {@link DirectiveError}.
2078
- *
2079
- * Recent errors are kept in a ring buffer (last 100) for inspection via
2080
- * {@link ErrorBoundaryManager.getAllErrors | getAllErrors}. Each strategy
2081
- * can be configured per source type (`onConstraintError`, `onResolverError`,
2082
- * etc.) or as a callback that dynamically selects a strategy.
2083
- *
2084
- * @param options - Error boundary configuration, plus `onError` and `onRecovery` callbacks for plugin integration.
2085
- * @returns An {@link ErrorBoundaryManager} for routing errors through the configured strategies.
2086
- *
2087
- * @internal
2088
- */
2089
- declare function createErrorBoundaryManager(options?: CreateErrorBoundaryOptions): ErrorBoundaryManager;
2090
-
2091
- /**
2092
- * History — Snapshot-based state history
2093
- *
2094
- * Features:
2095
- * - Ring buffer of state snapshots
2096
- * - Go back/forward through history
2097
- * - Replay from any snapshot
2098
- * - Export/import state history
2099
- */
2100
-
2101
- /**
2102
- * Internal history manager that extends the public {@link HistoryAPI}
2103
- * with snapshot capture, restoration, and pause/resume controls.
2104
- *
2105
- * @remarks
2106
- * - `takeSnapshot(trigger)` records the current facts into the ring buffer.
2107
- * - `restore(snapshot)` deserializes a snapshot back into the facts store,
2108
- * setting `isRestoring = true` so the engine skips reconciliation.
2109
- * - `pause()` / `resume()` temporarily suspend snapshot recording (e.g.,
2110
- * during bulk imports or programmatic state resets).
2111
- * - `beginChangeset(label)` / `endChangeset()` group consecutive snapshots
2112
- * so `goBack`/`goForward` treat them as a single undo/redo unit.
2113
- *
2114
- * @typeParam _S - The schema type (unused at runtime but preserved for type safety).
2115
- *
2116
- * @internal
2117
- */
2118
- interface HistoryManager<_S extends Schema> extends HistoryAPI {
2119
- /** Take a snapshot of current state */
2120
- takeSnapshot(trigger: string): Snapshot;
2121
- /** Restore facts from a snapshot */
2122
- restore(snapshot: Snapshot): void;
2123
- /** Check if history is enabled */
2124
- readonly isEnabled: boolean;
2125
- /** True while restoring a snapshot (engine should skip reconciliation) */
2126
- readonly isRestoring: boolean;
2127
- /** Pause snapshot taking */
2128
- pause(): void;
2129
- /** Resume snapshot taking */
2130
- resume(): void;
2131
- }
2132
- /**
2133
- * Options for creating a history manager via {@link createHistoryManager}.
2134
- *
2135
- * @typeParam S - The facts schema type.
2136
- *
2137
- * @internal
2138
- */
2139
- interface CreateHistoryOptions<S extends Schema> {
2140
- historyOption: HistoryOption;
2141
- facts: Facts<S>;
2142
- store: FactsStore<S>;
2143
- /** Callback when a snapshot is taken */
2144
- onSnapshot?: (snapshot: Snapshot) => void;
2145
- /** Callback when history navigation occurs */
2146
- onHistoryChange?: (from: number, to: number) => void;
2147
- }
2148
- /**
2149
- * Create a snapshot-based history manager backed by a ring buffer.
2150
- *
2151
- * @remarks
2152
- * Snapshots are taken automatically after fact changes (during reconciliation)
2153
- * and can be navigated with `goBack`/`goForward`/`goTo`. Use
2154
- * `beginChangeset(label)` and `endChangeset()` to group multiple snapshots
2155
- * into a single undo/redo unit. The entire history can be exported to JSON
2156
- * via `export()` and re-imported with `import()` for cross-session debugging.
2157
- *
2158
- * Call `pause()` to temporarily stop recording snapshots (e.g., during bulk
2159
- * fact imports) and `resume()` to re-enable recording.
2160
- *
2161
- * @param options - History config, facts proxy, store, and optional snapshot/history callbacks.
2162
- * @returns A {@link HistoryManager} with snapshot capture, navigation, changeset, and export/import methods.
2163
- *
2164
- * @internal
2165
- */
2166
- declare function createHistoryManager<S extends Schema>(options: CreateHistoryOptions<S>): HistoryManager<S>;
2167
- /**
2168
- * Create a no-op history manager for use when history is disabled.
2169
- *
2170
- * @remarks
2171
- * All methods are safe to call but perform no work. This avoids null-checks
2172
- * throughout the engine -- callers can use the same {@link HistoryManager}
2173
- * interface regardless of whether history is enabled.
2174
- *
2175
- * @returns A {@link HistoryManager} where every method is a no-op and `isEnabled` is `false`.
2176
- *
2177
- * @internal
2178
- */
2179
- declare function createDisabledHistory<S extends Schema>(): HistoryManager<S>;
2180
-
2181
- /**
2182
- * Engine - The core reconciliation loop
2183
- *
2184
- * The engine orchestrates:
2185
- * 1. Fact changes trigger reconciliation
2186
- * 2. Constraints produce requirements
2187
- * 3. Resolvers fulfill requirements
2188
- * 4. Effects run after stabilization
2189
- * 5. Derivations are invalidated and recomputed
2190
- */
2191
-
2192
- /**
2193
- * Create the core Directive reconciliation engine that wires facts, derivations,
2194
- * effects, constraints, resolvers, plugins, error boundaries, and history
2195
- * into a single reactive system.
2196
- *
2197
- * @remarks
2198
- * This is the internal factory used by {@link createSystem}. Most users should
2199
- * call `createSystem` instead, which provides a friendlier API and handles
2200
- * module composition.
2201
- *
2202
- * @param config - Full system configuration including modules, plugins, error boundary settings, and debug options
2203
- * @returns A {@link System} instance with facts, derive, events, dispatch, subscribe, watch, settle, and lifecycle methods
2204
- *
2205
- * @example
2206
- * ```ts
2207
- * // Prefer createSystem for most use cases:
2208
- * import { createSystem, createModule, t } from "@directive-run/core";
2209
- *
2210
- * const counter = createModule("counter", {
2211
- * schema: { count: t.number() },
2212
- * init: (facts) => { facts.count = 0; },
2213
- * });
2214
- *
2215
- * const system = createSystem({ module: counter });
2216
- * system.start();
2217
- * system.facts.count = 42;
2218
- * ```
2219
- *
2220
- * @internal
2221
- */
2222
- declare function createEngine<S extends Schema>(config: SystemConfig<any>): System<any>;
2223
-
2224
- /**
2225
- * Dependency tracking context for auto-tracking derivations
2226
- *
2227
- * Uses a stack-based approach to handle nested derivation computations.
2228
- * When a derivation accesses a fact, the tracking context records it.
2229
- */
2230
-
2231
- /**
2232
- * Get the current tracking context.
2233
- *
2234
- * @returns The active {@link TrackingContext}, or a null context (no-op) if
2235
- * no tracking is active.
2236
- *
2237
- * @internal
2238
- */
2239
- declare function getCurrentTracker(): TrackingContext;
2240
- /**
2241
- * Check if dependency tracking is currently active.
2242
- *
2243
- * @returns `true` if inside a {@link withTracking} call, `false` otherwise.
2244
- *
2245
- * @internal
2246
- */
2247
- declare function isTracking(): boolean;
2248
- /**
2249
- * Run a function with dependency tracking.
2250
- *
2251
- * @remarks
2252
- * Pushes a fresh tracking context onto the stack, executes `fn`, then pops
2253
- * the context. Any fact reads inside `fn` are recorded as dependencies.
2254
- * Nesting is supported — inner calls get their own independent context.
2255
- *
2256
- * @param fn - The function to execute under tracking.
2257
- * @returns An object with the computed `value` and a `deps` Set of accessed
2258
- * fact keys.
2259
- *
2260
- * @internal
2261
- */
2262
- declare function withTracking<T>(fn: () => T): {
2263
- value: T;
2264
- deps: Set<string>;
2265
- };
2266
- /**
2267
- * Run a function without tracking.
2268
- *
2269
- * @remarks
2270
- * Temporarily clears the tracking stack so that fact reads inside `fn` do
2271
- * not register as dependencies. The stack is restored after `fn` returns
2272
- * (even on error). Useful for side-effect reads that should not trigger
2273
- * derivation invalidation.
2274
- *
2275
- * @param fn - The function to execute without tracking.
2276
- * @returns The return value of `fn`.
2277
- *
2278
- * @internal
2279
- */
2280
- declare function withoutTracking<T>(fn: () => T): T;
2281
- /**
2282
- * Track a specific key in the current context.
2283
- *
2284
- * @remarks
2285
- * No-op if no tracking context is active.
2286
- *
2287
- * @param key - The fact key to record as a dependency.
2288
- *
2289
- * @internal
2290
- */
2291
- declare function trackAccess(key: string): void;
2292
-
2293
- /**
2294
- * @directive-run/core
2295
- *
2296
- * Constraint-driven runtime for TypeScript.
2297
- *
2298
- * Also available:
2299
- * - `@directive-run/core/plugins` – Logging, devtools, persistence, observability, circuit breaker
2300
- * - `@directive-run/core/testing` – Mock resolvers, fake timers, assertion helpers
2301
- * - `@directive-run/core/migration` – Redux/Zustand/XState migration codemods
2302
- * - `@directive-run/core/adapter-utils` – Shared framework adapter utilities
2303
- * - `@directive-run/core/worker` – Web Worker support
2304
- *
2305
- * @packageDocumentation
2306
- */
2307
-
2308
- /**
2309
- * Backoff strategy constants for retry policies.
2310
- * Use for autocomplete when configuring resolver retry policies.
2311
- *
2312
- * @example
2313
- * ```ts
2314
- * import { Backoff } from '@directive-run/core';
2315
- *
2316
- * const resolver = {
2317
- * requirement: "FETCH_DATA",
2318
- * retry: {
2319
- * attempts: 3,
2320
- * backoff: Backoff.Exponential, // Autocomplete-friendly!
2321
- * initialDelay: 100,
2322
- * },
2323
- * resolve: async (req, ctx) => { ... },
2324
- * };
945
+ * retry: { attempts: 3, backoff: Backoff.Exponential, initialDelay: 100 }
2325
946
  * ```
2326
947
  */
2327
948
  declare const Backoff: {
@@ -2333,4 +954,4 @@ declare const Backoff: {
2333
954
  readonly Exponential: "exponential";
2334
955
  };
2335
956
 
2336
- export { Backoff, BatchConfig, type Branded, type ChainableSchemaType, ConstraintState, ConstraintsDef, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef, CrossModuleDeps, CrossModuleDerivationsDef, CrossModuleEffectsDef, type DerivationState, type DerivationsDef, type DerivedValues, DirectiveError, EffectsDef, ErrorBoundaryConfig, ErrorSource, type ExtendedSchemaType, FactChange, Facts, FactsSnapshot, FactsStore, HistoryAPI, HistoryOption, type InflightInfo, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, type PendingRetry, Plugin, ReconcileResult, RecoveryStrategy, Requirement, RequirementKeyFn, RequirementSet, type RequirementTypeStatus, RequirementWithId, ResolverContext, ResolverStatus, ResolversDef, RetryLaterConfig, RetryPolicy, Schema, SchemaType, SingleModuleSystem, Snapshot, System, SystemConfig, TraceEntry, TraceOption, type TypedConstraint, TypedConstraintsDef, TypedDerivationsDef, TypedEventsDef, type TypedResolver, TypedResolversDef, createConstraintFactory, createConstraintsManager, createDerivationsManager, createDisabledHistory, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createHistoryManager, createModule, createModuleFactory, createPluginManager, createRequirementStatusPlugin, createResolverFactory, createResolversManager, createRetryLaterManager, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, getCurrentTracker, isRequirementType, isTracking, req, t, trackAccess, typedConstraint, typedResolver, withTracking, withoutTracking };
957
+ export { Backoff, type Branded, type ChainableSchemaType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleDeps, ErrorBoundaryConfig, type ExtendedSchemaType, Facts, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaType, SingleModuleSystem, TraceOption, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, forType, generateRequirementId, isRequirementType, req, t };