@directive-run/core 1.22.0 → 1.23.1

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 (84) hide show
  1. package/dist/adapter-utils.cjs +1 -1
  2. package/dist/adapter-utils.d.cts +1 -1
  3. package/dist/adapter-utils.d.ts +1 -1
  4. package/dist/adapter-utils.js +1 -1
  5. package/dist/chunk-C3FW27S5.js +3 -0
  6. package/dist/chunk-C3FW27S5.js.map +1 -0
  7. package/dist/chunk-IZNOPHPL.js +3 -0
  8. package/dist/chunk-IZNOPHPL.js.map +1 -0
  9. package/dist/chunk-LN5H74CU.js +2 -0
  10. package/dist/{chunk-RBF653NR.js.map → chunk-LN5H74CU.js.map} +1 -1
  11. package/dist/chunk-PTT4MWNL.cjs +3 -0
  12. package/dist/chunk-PTT4MWNL.cjs.map +1 -0
  13. package/dist/chunk-QR2756CJ.js +2 -0
  14. package/dist/chunk-QR2756CJ.js.map +1 -0
  15. package/dist/{chunk-GKMJ7NMP.cjs → chunk-RD2HO5NZ.cjs} +2 -2
  16. package/dist/{chunk-GKMJ7NMP.cjs.map → chunk-RD2HO5NZ.cjs.map} +1 -1
  17. package/dist/{chunk-GACC2DMS.cjs → chunk-S6W6Y44G.cjs} +2 -2
  18. package/dist/{chunk-GACC2DMS.cjs.map → chunk-S6W6Y44G.cjs.map} +1 -1
  19. package/dist/{chunk-YJEDX2JX.js → chunk-SERVIHA3.js} +3 -3
  20. package/dist/chunk-SERVIHA3.js.map +1 -0
  21. package/dist/{chunk-OAPD3HIG.cjs → chunk-UDSP7U54.cjs} +3 -3
  22. package/dist/chunk-UDSP7U54.cjs.map +1 -0
  23. package/dist/chunk-UQZ2SMGS.cjs +2 -0
  24. package/dist/chunk-UQZ2SMGS.cjs.map +1 -0
  25. package/dist/{chunk-6PF2FRBG.js → chunk-WD47DB52.js} +2 -2
  26. package/dist/{chunk-6PF2FRBG.js.map → chunk-WD47DB52.js.map} +1 -1
  27. package/dist/chunk-WU4AXN3P.cjs +3 -0
  28. package/dist/chunk-WU4AXN3P.cjs.map +1 -0
  29. package/dist/{index-DRPkZ8HE.d.cts → index-Bz6DOdDN.d.ts} +32 -5
  30. package/dist/{index-BgKC_ZT_.d.ts → index-Cpgj4byM.d.cts} +32 -5
  31. package/dist/index.cjs +2 -2
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +8 -130
  34. package/dist/index.d.ts +8 -130
  35. package/dist/index.js +2 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/internals.cjs +1 -1
  38. package/dist/internals.d.cts +10 -4
  39. package/dist/internals.d.ts +10 -4
  40. package/dist/internals.js +1 -1
  41. package/dist/plugins/index.cjs +2 -2
  42. package/dist/plugins/index.cjs.map +1 -1
  43. package/dist/plugins/index.d.cts +202 -3
  44. package/dist/plugins/index.d.ts +202 -3
  45. package/dist/plugins/index.js +2 -2
  46. package/dist/plugins/index.js.map +1 -1
  47. package/dist/{plugins-5Supk7it.d.cts → plugins-CaPMTICa.d.cts} +323 -2
  48. package/dist/{plugins-5Supk7it.d.ts → plugins-CaPMTICa.d.ts} +323 -2
  49. package/dist/{predicate-DYb-3Mvl.d.cts → predicate-CU0YC1i6.d.cts} +1 -1
  50. package/dist/{predicate-C9oMO_ny.d.ts → predicate-CgpwJqf4.d.ts} +1 -1
  51. package/dist/system-T6EZ6EYN.js +2 -0
  52. package/dist/{system-6YWCXQOQ.js.map → system-T6EZ6EYN.js.map} +1 -1
  53. package/dist/system-V7B4YUIR.cjs +2 -0
  54. package/dist/{system-5FKUBLLV.cjs.map → system-V7B4YUIR.cjs.map} +1 -1
  55. package/dist/testing.cjs +1 -1
  56. package/dist/testing.cjs.map +1 -1
  57. package/dist/testing.d.cts +1 -1
  58. package/dist/testing.d.ts +1 -1
  59. package/dist/testing.js +1 -1
  60. package/dist/testing.js.map +1 -1
  61. package/dist/worker.cjs +1 -1
  62. package/dist/worker.cjs.map +1 -1
  63. package/dist/worker.d.cts +1 -1
  64. package/dist/worker.d.ts +1 -1
  65. package/dist/worker.js +1 -1
  66. package/dist/worker.js.map +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunk-6NCC6RBC.js +0 -3
  69. package/dist/chunk-6NCC6RBC.js.map +0 -1
  70. package/dist/chunk-GBCWXTXW.cjs +0 -3
  71. package/dist/chunk-GBCWXTXW.cjs.map +0 -1
  72. package/dist/chunk-KGTBTGOY.js +0 -2
  73. package/dist/chunk-KGTBTGOY.js.map +0 -1
  74. package/dist/chunk-MARZI3EY.cjs +0 -2
  75. package/dist/chunk-MARZI3EY.cjs.map +0 -1
  76. package/dist/chunk-OAPD3HIG.cjs.map +0 -1
  77. package/dist/chunk-QTY2FXZY.cjs +0 -3
  78. package/dist/chunk-QTY2FXZY.cjs.map +0 -1
  79. package/dist/chunk-RBF653NR.js +0 -2
  80. package/dist/chunk-SFUVPP4L.js +0 -3
  81. package/dist/chunk-SFUVPP4L.js.map +0 -1
  82. package/dist/chunk-YJEDX2JX.js.map +0 -1
  83. package/dist/system-5FKUBLLV.cjs +0 -2
  84. package/dist/system-6YWCXQOQ.js +0 -2
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as ClauseResult, F as FactPredicate, S as SchemaType, D as DefinitionMeta, M as ModuleSchema, a as Facts, T as TypedDerivationsDef, b as TypedEventsDef, E as EffectsDef, c as SourcesDef, d as TypedConstraintsDef, e as TypedResolversDef, f as ModuleHooks, g as CrossModuleDeps, h as CrossModuleDerivationsDef, i as CrossModuleEffectsDef, j as CrossModuleConstraintsDef, k as ModuleDef, l as CreateSystemOptionsSingle, m as SingleModuleSystem, n as ModulesMap, o as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, p as TraceOption, q as ErrorBoundaryConfig, R as RequirementWithId, r as Requirement, s as RequirementKeyFn } from './plugins-5Supk7it.cjs';
2
- export { A as AnySystem, B as BatchConfig, t as ConstraintDefinition, u as ConstraintsDefinition, v as CrossModuleConstraintDefinition, w as CrossModuleEffectDefinition, x as DirectiveError, y as DistributableSnapshot, z as DistributableSnapshotOptions, G as DynamicConstraintDef, G as DynamicConstraintDefinition, H as DynamicEffectDef, I as DynamicResolverDef, I as DynamicResolverDefinition, J as EffectDefinition, K as EventsDefinition, L as FactTemplate, O as FactsSnapshot, Q as HistoryAPI, U as HistoryOption, V as HistoryState, W as InferDerivations, X as InferEvents, Y as InferFacts, Z as InferRequirementTypes, _ as InferRequirements, $ as InferSchemaType, a0 as InferSelectorState, a1 as KeySelector, a2 as MetaAccessor, a3 as MetaMatch, a4 as ObservationEvent, a5 as OperatorObject, a6 as PatchSpec, a7 as PatchValue, a8 as PayloadRef, a9 as PredicateClause, aa as PredicateCombinator, ab as PredicateCombinatorKey, ac as PredicateObject, ad as PredicateOp, ae as ResolverDefinition, af as ResolversDefinition, ag as RetryPolicy, ah as Schema, ai as SchemaTypedResolversDefinition, aj as Snapshot, ak as SourceDef, ak as SourceDefinition, al as SourceDropReason, am as SourcePublish, am as SourcePublishFn, an as SourceReportError, ao as SourceUnsubscribe, ao as SourceUnsubscribeFn, ap as System, aq as SystemConfig, ar as SystemDerived, as as SystemFacts, at as SystemInspection, au as SystemMode, av as SystemSnapshot, aw as TraceEntry, ax as TypedConstraintDefinition, ay as TypedResolverDefinition, az as isNamespacedSystem, aA as isSingleModuleSystem } from './plugins-5Supk7it.cjs';
3
- import { S as SchemaKindNode } from './predicate-DYb-3Mvl.cjs';
4
- export { D as DerivationDefWithMeta, a as DerivationDefinition, D as DerivationDefinitionWithMeta, b as DerivationsDefinition, c as SchemaKind, d as SchemaValidationError, e as SchemaValidationOptions, f as SchemaValidationResult, g as applyPatch, h as evaluateKeySelector, i as evaluatePredicate, j as evaluatePredicateExplained, k as evaluateTemplate, l as extractDeps, m as extractTemplateKeys, n as getKind, o as getOperatorsForKind, p as getSchemaFieldKinds, q as isPredicate, r as isTemplate, s as listAllPredicateOperators, t as memoizePredicate, u as typedConstraint, v as typedResolver, w as validatePredicate, x as validatePredicateAgainstSchema } from './predicate-DYb-3Mvl.cjs';
5
- export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, V as VerifyResult, e as createAuditLedger, m as memorySink } from './index-DRPkZ8HE.cjs';
1
+ import { C as ClauseResult, F as FactPredicate, S as SchemaType, D as DefinitionMeta, M as ModuleSchema, a as Facts, T as TypedDerivationsDef, b as TypedEventsDef, E as EffectsDef, c as SourcesDef, d as TypedConstraintsDef, e as TypedResolversDef, f as ModuleHooks, g as CrossModuleDeps, h as CrossModuleDerivationsDef, i as CrossModuleEffectsDef, j as CrossModuleConstraintsDef, k as ModuleDef, l as CreateSystemOptionsSingle, m as SingleModuleSystem, n as ModulesMap, o as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, p as TraceOption, q as ErrorBoundaryConfig, R as RequirementWithId, r as Requirement, s as RequirementKeyFn } from './plugins-CaPMTICa.cjs';
2
+ export { A as AnySystem, B as BatchConfig, t as Change, u as ChangeKind, v as ConstraintDefinition, w as ConstraintDiff, x as ConstraintStatus, y as ConstraintsDefinition, z as CrossModuleConstraintDefinition, G as CrossModuleEffectDefinition, H as DiffRulesOptions, I as DirectiveError, J as DistributableSnapshot, K as DistributableSnapshotOptions, L as DynamicConstraintDef, L as DynamicConstraintDefinition, O as DynamicEffectDef, Q as DynamicResolverDef, Q as DynamicResolverDefinition, U as EffectDefinition, V as EventsDefinition, W as FactTemplate, X as FactsSnapshot, Y as HistoryAPI, Z as HistoryOption, _ as HistoryState, $ as InferDerivations, a0 as InferEvents, a1 as InferFacts, a2 as InferRequirementTypes, a3 as InferRequirements, a4 as InferSchemaType, a5 as InferSelectorState, a6 as KeySelector, a7 as LeafClause, a8 as MetaAccessor, a9 as MetaMatch, aa as ObservationEvent, ab as OperatorObject, ac as PatchSpec, ad as PatchValue, ae as PayloadRef, af as PredicateClause, ag as PredicateCombinator, ah as PredicateCombinatorKey, ai as PredicateObject, aj as PredicateOp, ak as PredicateOverlapProof, al as ResolverAbortReason, am as ResolverDefinition, an as ResolversDefinition, ao as RetryPolicy, ap as RulesDiffReport, aq as RulesMapInput, ar as Schema, as as SchemaTypedResolversDefinition, at as ShouldRetryContext, au as Snapshot, av as SourceDef, av as SourceDefinition, aw as SourceDropReason, ax as SourcePublish, ax as SourcePublishFn, ay as SourceReportError, az as SourceUnsubscribe, az as SourceUnsubscribeFn, aA as System, aB as SystemConfig, aC as SystemDerived, aD as SystemFacts, aE as SystemInspection, aF as SystemMode, aG as SystemSnapshot, aH as TraceEntry, aI as TypedConstraintDefinition, aJ as TypedResolverDefinition, aK as diffClauses, aL as diffRules, aM as flattenPredicate, aN as isNamespacedSystem, aO as isSingleModuleSystem, aP as toRulesMap } from './plugins-CaPMTICa.cjs';
3
+ import { S as SchemaKindNode } from './predicate-CU0YC1i6.cjs';
4
+ export { D as DerivationDefWithMeta, a as DerivationDefinition, D as DerivationDefinitionWithMeta, b as DerivationsDefinition, c as SchemaKind, d as SchemaValidationError, e as SchemaValidationOptions, f as SchemaValidationResult, g as applyPatch, h as evaluateKeySelector, i as evaluatePredicate, j as evaluatePredicateExplained, k as evaluateTemplate, l as extractDeps, m as extractTemplateKeys, n as getKind, o as getOperatorsForKind, p as getSchemaFieldKinds, q as isPredicate, r as isTemplate, s as listAllPredicateOperators, t as memoizePredicate, u as typedConstraint, v as typedResolver, w as validatePredicate, x as validatePredicateAgainstSchema } from './predicate-CU0YC1i6.cjs';
5
+ export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, V as VerifyResult, e as createAuditLedger, m as memorySink } from './index-Cpgj4byM.cjs';
6
6
  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-DY8KTiD6.cjs';
7
7
 
8
8
  /**
@@ -325,128 +325,6 @@ declare const MAX_SWEEP_POINTS = 10000;
325
325
  */
326
326
  declare function sweepUnder<F = Record<string, unknown>>(options: SweepUnderOptions<F>): SweepReport;
327
327
 
328
- /**
329
- * Structural diff between two snapshots of a system's constraint `whenSpec`
330
- * map. The "git diff for business rules" — operates on the predicate AST
331
- * instead of source-text lines.
332
- *
333
- * A predicate is a tree of leaf clauses (`{ fact: operator(value) }`) and
334
- * combinators (`$all` / `$any` / `$not`). `diffRules` flattens both trees
335
- * into path-keyed leaf lists and compares: missing path → added/removed,
336
- * same path with different operand → changed (with relaxed/tightened
337
- * classification for numeric thresholds).
338
- *
339
- * Pure module — imports only utils. No engine / store / predicate-runtime
340
- * dependency: predicates are walked as plain JSON.
341
- */
342
- /** A leaf clause extracted from a predicate tree, keyed by its dotted path. */
343
- interface LeafClause {
344
- /** Dotted path through the predicate. E.g. `phase`, `$all[0].elapsed`, `$not.paused`. */
345
- path: string;
346
- /** Operator name. `$eq` is implied for bare-value equality. */
347
- op: string;
348
- /** Operand. */
349
- value: unknown;
350
- }
351
- /** Kind of change observed for a single clause. */
352
- type ChangeKind = "added" | "removed" | "changed" | "relaxed" | "tightened";
353
- /** A single change between two predicates at a specific path. */
354
- interface Change {
355
- path: string;
356
- kind: ChangeKind;
357
- before?: {
358
- op: string;
359
- value: unknown;
360
- };
361
- after?: {
362
- op: string;
363
- value: unknown;
364
- };
365
- }
366
- /** Status of a single constraint across the two snapshots. */
367
- type ConstraintStatus = "added" | "removed" | "changed" | "unchanged";
368
- interface ConstraintDiff {
369
- id: string;
370
- status: ConstraintStatus;
371
- /** Empty for `unchanged`. For `added` / `removed`, every leaf is listed once. */
372
- changes: Change[];
373
- }
374
- interface RulesDiffReport {
375
- constraints: ConstraintDiff[];
376
- summary: {
377
- added: number;
378
- removed: number;
379
- changed: number;
380
- unchanged: number;
381
- totalClauseChanges: number;
382
- };
383
- }
384
- interface DiffRulesOptions {
385
- before: RulesMapInput;
386
- after: RulesMapInput;
387
- }
388
- /**
389
- * Accepted shapes for the `before` / `after` predicate maps:
390
- * - A plain map `{ [constraintId]: whenSpec }`
391
- * - The `system.inspect().constraints` array form `Array<{ id, whenSpec? }>`
392
- * - Either wrapped as `{ constraints: <one-of-the-above> }`
393
- *
394
- * Anything else throws at `toRulesMap` so a bad input fails loud.
395
- */
396
- type RulesMapInput = unknown;
397
- /**
398
- * Coerce supported input shapes into a flat `Record<constraintId, whenSpec>`.
399
- * Constraints without a `whenSpec` (function-form `when`) are dropped with
400
- * an undefined entry so callers can distinguish them from absent constraints
401
- * if they care; the diff treats `undefined` as "no data" and skips clause
402
- * walking.
403
- */
404
- declare function toRulesMap(raw: RulesMapInput): Record<string, unknown>;
405
- /**
406
- * Walk a predicate tree and emit every leaf clause with its dotted path.
407
- * Combinators (`$all` / `$any` / `$not`) become indexed path segments.
408
- * Bare-value equality (`{ phase: "red" }`) emits as `op: "$eq"`.
409
- *
410
- * Array-form predicates (`[{ fact, op, value }, ...]`) are also accepted —
411
- * each clause's `fact` becomes the path, the operator is `op`, and the
412
- * value is `value`.
413
- *
414
- * **What gets dropped:** non-object combinator children (e.g. `$not: "red"`
415
- * with a string operand instead of a predicate object), function-form
416
- * predicates (the engine accepts a function for `when`; this walker only
417
- * sees data), and bare primitive predicates (a top-level `true` or `"x"`).
418
- * The walker is a tree visitor — anything not shaped like a predicate node
419
- * is silently skipped, never thrown on.
420
- */
421
- declare function flattenPredicate(spec: unknown, pathPrefix?: string, out?: LeafClause[]): LeafClause[];
422
- /**
423
- * Diff two snapshots of a system's constraint whenSpec map.
424
- *
425
- * @example
426
- * ```ts
427
- * const report = diffRules({
428
- * before: { blockCheckout: { cartTotal: { $gte: 100 } } },
429
- * after: { blockCheckout: { cartTotal: { $gte: 50 } } },
430
- * });
431
- *
432
- * report.constraints[0].status; // "changed"
433
- * report.constraints[0].changes[0].kind; // "relaxed"
434
- * report.summary.totalClauseChanges; // 1
435
- * ```
436
- *
437
- * The input shape is forgiving — either a flat `{ id: whenSpec }` map, the
438
- * `system.inspect().constraints` array form, or either wrapped as
439
- * `{ constraints: ... }`. Constraints whose `when` is a function (no
440
- * `whenSpec`) are tracked as added/removed but cannot be clause-diffed
441
- * (the function form is opaque).
442
- */
443
- declare function diffRules(options: DiffRulesOptions): RulesDiffReport;
444
- /**
445
- * Diff two predicate trees and return the list of leaf-level changes.
446
- * Exported for reuse beyond the full per-constraint report.
447
- */
448
- declare function diffClauses(before: unknown, after: unknown): Change[];
449
-
450
328
  /**
451
329
  * `predicateHash` — content-addressed fingerprint for a {@link FactPredicate}.
452
330
  *
@@ -2022,8 +1900,8 @@ declare function virtualClock(initialMs?: number): SignalClock;
2022
1900
  * Returns `realClock()` always.
2023
1901
  *
2024
1902
  * Earlier drafts auto-detected vitest (`process.env.VITEST === 'true'`)
2025
- * and returned a `virtualClock()` in that environment. AE review
2026
- * flagged this as a footgun: tests that legitimately need real time
1903
+ * and returned a `virtualClock()` in that environment. That behavior
1904
+ * turned out to be a footgun: tests that legitimately need real time
2027
1905
  * (sleep-based debounce checks, real-`setTimeout`-bound integration
2028
1906
  * fixtures) silently received a virtual clock that never advanced
2029
1907
  * unless the test author called `advanceBy()`, producing apparent
@@ -2257,4 +2135,4 @@ declare const Backoff: {
2257
2135
  readonly Exponential: "exponential";
2258
2136
  };
2259
2137
 
2260
- export { Backoff, type Branded, type ChainableSchemaType, type Change, type ChangeKind, type CheckAbortOnFinding, type CheckAbortOnResult, type CheckAgainstResult, ClauseResult, type ConstraintDiff, type ConstraintStatus, type Contradiction, type ContradictionType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef as CrossModuleConstraintsDefinition, CrossModuleDeps, CrossModuleDerivationsDef as CrossModuleDerivationsDefinition, CrossModuleEffectsDef as CrossModuleEffectsDefinition, DefinitionMeta, type DescribeOptions, type DiffRulesOptions, EffectsDef as EffectsDefinition, ErrorBoundaryConfig, type ExistingConstraint, type ExtendedSchemaType, FactPredicate, Facts, type LeafClause, MAX_REPLAY_FRAMES, MAX_SWEEP_POINTS, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleDef as ModuleDefinition, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, type PredicateBacktestReport, type PredicateToMongoOptions, type PredicateToPostgrestOptions, type PredicateToSqlOptions, type PredicateToSqlResult, type PredictMissingChange, type PredictResult, type ReplayDiffSample, type ReplayFrame, type ReplayUnderOptions, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, type RulesDiffReport, type RulesMapInput, SchemaKindNode, SchemaType, type SignalClock, SingleModuleSystem, SourcesDef, SourcesDef as SourcesDefinition, type SweepHole, type SweepPoint, type SweepReport, type SweepUnderOptions, type TimerFactOpts, type TimerFactState, TraceOption, TypedConstraintsDef as TypedConstraintsDefinition, TypedDerivationsDef as TypedDerivationsDefinition, TypedEventsDef as TypedEventsDefinition, TypedResolversDef as TypedResolversDefinition, completeTimer, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, defaultClock, describePredicate, diffClauses, diffRules, doctor, elapsedMs, flattenPredicate, forType, framesFromHistory, framesFromSnapshots, generateRequirementId, initialTimerState, isRequirementType, pauseTimer, predicateHash, predicateToMongo, predicateToPostgrest, predicateToSQL, predicateToWhere, predict, realClock, registerRepeat, remainingMs, replayUnder, req, resetTimer, resumeTimer, startTimer, sweepUnder, t, tickTimer, timerOps, toReplayFrames, toRulesMap, virtualClock };
2138
+ export { Backoff, type Branded, type ChainableSchemaType, type CheckAbortOnFinding, type CheckAbortOnResult, type CheckAgainstResult, ClauseResult, type Contradiction, type ContradictionType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef as CrossModuleConstraintsDefinition, CrossModuleDeps, CrossModuleDerivationsDef as CrossModuleDerivationsDefinition, CrossModuleEffectsDef as CrossModuleEffectsDefinition, DefinitionMeta, type DescribeOptions, EffectsDef as EffectsDefinition, ErrorBoundaryConfig, type ExistingConstraint, type ExtendedSchemaType, FactPredicate, Facts, MAX_REPLAY_FRAMES, MAX_SWEEP_POINTS, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleDef as ModuleDefinition, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, type PredicateBacktestReport, type PredicateToMongoOptions, type PredicateToPostgrestOptions, type PredicateToSqlOptions, type PredicateToSqlResult, type PredictMissingChange, type PredictResult, type ReplayDiffSample, type ReplayFrame, type ReplayUnderOptions, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaKindNode, SchemaType, type SignalClock, SingleModuleSystem, SourcesDef, SourcesDef as SourcesDefinition, type SweepHole, type SweepPoint, type SweepReport, type SweepUnderOptions, type TimerFactOpts, type TimerFactState, TraceOption, TypedConstraintsDef as TypedConstraintsDefinition, TypedDerivationsDef as TypedDerivationsDefinition, TypedEventsDef as TypedEventsDefinition, TypedResolversDef as TypedResolversDefinition, completeTimer, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, defaultClock, describePredicate, doctor, elapsedMs, forType, framesFromHistory, framesFromSnapshots, generateRequirementId, initialTimerState, isRequirementType, pauseTimer, predicateHash, predicateToMongo, predicateToPostgrest, predicateToSQL, predicateToWhere, predict, realClock, registerRepeat, remainingMs, replayUnder, req, resetTimer, resumeTimer, startTimer, sweepUnder, t, tickTimer, timerOps, toReplayFrames, virtualClock };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { C as ClauseResult, F as FactPredicate, S as SchemaType, D as DefinitionMeta, M as ModuleSchema, a as Facts, T as TypedDerivationsDef, b as TypedEventsDef, E as EffectsDef, c as SourcesDef, d as TypedConstraintsDef, e as TypedResolversDef, f as ModuleHooks, g as CrossModuleDeps, h as CrossModuleDerivationsDef, i as CrossModuleEffectsDef, j as CrossModuleConstraintsDef, k as ModuleDef, l as CreateSystemOptionsSingle, m as SingleModuleSystem, n as ModulesMap, o as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, p as TraceOption, q as ErrorBoundaryConfig, R as RequirementWithId, r as Requirement, s as RequirementKeyFn } from './plugins-5Supk7it.js';
2
- export { A as AnySystem, B as BatchConfig, t as ConstraintDefinition, u as ConstraintsDefinition, v as CrossModuleConstraintDefinition, w as CrossModuleEffectDefinition, x as DirectiveError, y as DistributableSnapshot, z as DistributableSnapshotOptions, G as DynamicConstraintDef, G as DynamicConstraintDefinition, H as DynamicEffectDef, I as DynamicResolverDef, I as DynamicResolverDefinition, J as EffectDefinition, K as EventsDefinition, L as FactTemplate, O as FactsSnapshot, Q as HistoryAPI, U as HistoryOption, V as HistoryState, W as InferDerivations, X as InferEvents, Y as InferFacts, Z as InferRequirementTypes, _ as InferRequirements, $ as InferSchemaType, a0 as InferSelectorState, a1 as KeySelector, a2 as MetaAccessor, a3 as MetaMatch, a4 as ObservationEvent, a5 as OperatorObject, a6 as PatchSpec, a7 as PatchValue, a8 as PayloadRef, a9 as PredicateClause, aa as PredicateCombinator, ab as PredicateCombinatorKey, ac as PredicateObject, ad as PredicateOp, ae as ResolverDefinition, af as ResolversDefinition, ag as RetryPolicy, ah as Schema, ai as SchemaTypedResolversDefinition, aj as Snapshot, ak as SourceDef, ak as SourceDefinition, al as SourceDropReason, am as SourcePublish, am as SourcePublishFn, an as SourceReportError, ao as SourceUnsubscribe, ao as SourceUnsubscribeFn, ap as System, aq as SystemConfig, ar as SystemDerived, as as SystemFacts, at as SystemInspection, au as SystemMode, av as SystemSnapshot, aw as TraceEntry, ax as TypedConstraintDefinition, ay as TypedResolverDefinition, az as isNamespacedSystem, aA as isSingleModuleSystem } from './plugins-5Supk7it.js';
3
- import { S as SchemaKindNode } from './predicate-C9oMO_ny.js';
4
- export { D as DerivationDefWithMeta, a as DerivationDefinition, D as DerivationDefinitionWithMeta, b as DerivationsDefinition, c as SchemaKind, d as SchemaValidationError, e as SchemaValidationOptions, f as SchemaValidationResult, g as applyPatch, h as evaluateKeySelector, i as evaluatePredicate, j as evaluatePredicateExplained, k as evaluateTemplate, l as extractDeps, m as extractTemplateKeys, n as getKind, o as getOperatorsForKind, p as getSchemaFieldKinds, q as isPredicate, r as isTemplate, s as listAllPredicateOperators, t as memoizePredicate, u as typedConstraint, v as typedResolver, w as validatePredicate, x as validatePredicateAgainstSchema } from './predicate-C9oMO_ny.js';
5
- export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, V as VerifyResult, e as createAuditLedger, m as memorySink } from './index-BgKC_ZT_.js';
1
+ import { C as ClauseResult, F as FactPredicate, S as SchemaType, D as DefinitionMeta, M as ModuleSchema, a as Facts, T as TypedDerivationsDef, b as TypedEventsDef, E as EffectsDef, c as SourcesDef, d as TypedConstraintsDef, e as TypedResolversDef, f as ModuleHooks, g as CrossModuleDeps, h as CrossModuleDerivationsDef, i as CrossModuleEffectsDef, j as CrossModuleConstraintsDef, k as ModuleDef, l as CreateSystemOptionsSingle, m as SingleModuleSystem, n as ModulesMap, o as CreateSystemOptionsNamed, N as NamespacedSystem, P as Plugin, p as TraceOption, q as ErrorBoundaryConfig, R as RequirementWithId, r as Requirement, s as RequirementKeyFn } from './plugins-CaPMTICa.js';
2
+ export { A as AnySystem, B as BatchConfig, t as Change, u as ChangeKind, v as ConstraintDefinition, w as ConstraintDiff, x as ConstraintStatus, y as ConstraintsDefinition, z as CrossModuleConstraintDefinition, G as CrossModuleEffectDefinition, H as DiffRulesOptions, I as DirectiveError, J as DistributableSnapshot, K as DistributableSnapshotOptions, L as DynamicConstraintDef, L as DynamicConstraintDefinition, O as DynamicEffectDef, Q as DynamicResolverDef, Q as DynamicResolverDefinition, U as EffectDefinition, V as EventsDefinition, W as FactTemplate, X as FactsSnapshot, Y as HistoryAPI, Z as HistoryOption, _ as HistoryState, $ as InferDerivations, a0 as InferEvents, a1 as InferFacts, a2 as InferRequirementTypes, a3 as InferRequirements, a4 as InferSchemaType, a5 as InferSelectorState, a6 as KeySelector, a7 as LeafClause, a8 as MetaAccessor, a9 as MetaMatch, aa as ObservationEvent, ab as OperatorObject, ac as PatchSpec, ad as PatchValue, ae as PayloadRef, af as PredicateClause, ag as PredicateCombinator, ah as PredicateCombinatorKey, ai as PredicateObject, aj as PredicateOp, ak as PredicateOverlapProof, al as ResolverAbortReason, am as ResolverDefinition, an as ResolversDefinition, ao as RetryPolicy, ap as RulesDiffReport, aq as RulesMapInput, ar as Schema, as as SchemaTypedResolversDefinition, at as ShouldRetryContext, au as Snapshot, av as SourceDef, av as SourceDefinition, aw as SourceDropReason, ax as SourcePublish, ax as SourcePublishFn, ay as SourceReportError, az as SourceUnsubscribe, az as SourceUnsubscribeFn, aA as System, aB as SystemConfig, aC as SystemDerived, aD as SystemFacts, aE as SystemInspection, aF as SystemMode, aG as SystemSnapshot, aH as TraceEntry, aI as TypedConstraintDefinition, aJ as TypedResolverDefinition, aK as diffClauses, aL as diffRules, aM as flattenPredicate, aN as isNamespacedSystem, aO as isSingleModuleSystem, aP as toRulesMap } from './plugins-CaPMTICa.js';
3
+ import { S as SchemaKindNode } from './predicate-CgpwJqf4.js';
4
+ export { D as DerivationDefWithMeta, a as DerivationDefinition, D as DerivationDefinitionWithMeta, b as DerivationsDefinition, c as SchemaKind, d as SchemaValidationError, e as SchemaValidationOptions, f as SchemaValidationResult, g as applyPatch, h as evaluateKeySelector, i as evaluatePredicate, j as evaluatePredicateExplained, k as evaluateTemplate, l as extractDeps, m as extractTemplateKeys, n as getKind, o as getOperatorsForKind, p as getSchemaFieldKinds, q as isPredicate, r as isTemplate, s as listAllPredicateOperators, t as memoizePredicate, u as typedConstraint, v as typedResolver, w as validatePredicate, x as validatePredicateAgainstSchema } from './predicate-CgpwJqf4.js';
5
+ export { A as AuditEntry, a as AuditEntryKind, b as AuditLedger, c as AuditLedgerOptions, d as AuditLedgerSink, Q as QueryFilter, V as VerifyResult, e as createAuditLedger, m as memorySink } from './index-Bz6DOdDN.js';
6
6
  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-DY8KTiD6.js';
7
7
 
8
8
  /**
@@ -325,128 +325,6 @@ declare const MAX_SWEEP_POINTS = 10000;
325
325
  */
326
326
  declare function sweepUnder<F = Record<string, unknown>>(options: SweepUnderOptions<F>): SweepReport;
327
327
 
328
- /**
329
- * Structural diff between two snapshots of a system's constraint `whenSpec`
330
- * map. The "git diff for business rules" — operates on the predicate AST
331
- * instead of source-text lines.
332
- *
333
- * A predicate is a tree of leaf clauses (`{ fact: operator(value) }`) and
334
- * combinators (`$all` / `$any` / `$not`). `diffRules` flattens both trees
335
- * into path-keyed leaf lists and compares: missing path → added/removed,
336
- * same path with different operand → changed (with relaxed/tightened
337
- * classification for numeric thresholds).
338
- *
339
- * Pure module — imports only utils. No engine / store / predicate-runtime
340
- * dependency: predicates are walked as plain JSON.
341
- */
342
- /** A leaf clause extracted from a predicate tree, keyed by its dotted path. */
343
- interface LeafClause {
344
- /** Dotted path through the predicate. E.g. `phase`, `$all[0].elapsed`, `$not.paused`. */
345
- path: string;
346
- /** Operator name. `$eq` is implied for bare-value equality. */
347
- op: string;
348
- /** Operand. */
349
- value: unknown;
350
- }
351
- /** Kind of change observed for a single clause. */
352
- type ChangeKind = "added" | "removed" | "changed" | "relaxed" | "tightened";
353
- /** A single change between two predicates at a specific path. */
354
- interface Change {
355
- path: string;
356
- kind: ChangeKind;
357
- before?: {
358
- op: string;
359
- value: unknown;
360
- };
361
- after?: {
362
- op: string;
363
- value: unknown;
364
- };
365
- }
366
- /** Status of a single constraint across the two snapshots. */
367
- type ConstraintStatus = "added" | "removed" | "changed" | "unchanged";
368
- interface ConstraintDiff {
369
- id: string;
370
- status: ConstraintStatus;
371
- /** Empty for `unchanged`. For `added` / `removed`, every leaf is listed once. */
372
- changes: Change[];
373
- }
374
- interface RulesDiffReport {
375
- constraints: ConstraintDiff[];
376
- summary: {
377
- added: number;
378
- removed: number;
379
- changed: number;
380
- unchanged: number;
381
- totalClauseChanges: number;
382
- };
383
- }
384
- interface DiffRulesOptions {
385
- before: RulesMapInput;
386
- after: RulesMapInput;
387
- }
388
- /**
389
- * Accepted shapes for the `before` / `after` predicate maps:
390
- * - A plain map `{ [constraintId]: whenSpec }`
391
- * - The `system.inspect().constraints` array form `Array<{ id, whenSpec? }>`
392
- * - Either wrapped as `{ constraints: <one-of-the-above> }`
393
- *
394
- * Anything else throws at `toRulesMap` so a bad input fails loud.
395
- */
396
- type RulesMapInput = unknown;
397
- /**
398
- * Coerce supported input shapes into a flat `Record<constraintId, whenSpec>`.
399
- * Constraints without a `whenSpec` (function-form `when`) are dropped with
400
- * an undefined entry so callers can distinguish them from absent constraints
401
- * if they care; the diff treats `undefined` as "no data" and skips clause
402
- * walking.
403
- */
404
- declare function toRulesMap(raw: RulesMapInput): Record<string, unknown>;
405
- /**
406
- * Walk a predicate tree and emit every leaf clause with its dotted path.
407
- * Combinators (`$all` / `$any` / `$not`) become indexed path segments.
408
- * Bare-value equality (`{ phase: "red" }`) emits as `op: "$eq"`.
409
- *
410
- * Array-form predicates (`[{ fact, op, value }, ...]`) are also accepted —
411
- * each clause's `fact` becomes the path, the operator is `op`, and the
412
- * value is `value`.
413
- *
414
- * **What gets dropped:** non-object combinator children (e.g. `$not: "red"`
415
- * with a string operand instead of a predicate object), function-form
416
- * predicates (the engine accepts a function for `when`; this walker only
417
- * sees data), and bare primitive predicates (a top-level `true` or `"x"`).
418
- * The walker is a tree visitor — anything not shaped like a predicate node
419
- * is silently skipped, never thrown on.
420
- */
421
- declare function flattenPredicate(spec: unknown, pathPrefix?: string, out?: LeafClause[]): LeafClause[];
422
- /**
423
- * Diff two snapshots of a system's constraint whenSpec map.
424
- *
425
- * @example
426
- * ```ts
427
- * const report = diffRules({
428
- * before: { blockCheckout: { cartTotal: { $gte: 100 } } },
429
- * after: { blockCheckout: { cartTotal: { $gte: 50 } } },
430
- * });
431
- *
432
- * report.constraints[0].status; // "changed"
433
- * report.constraints[0].changes[0].kind; // "relaxed"
434
- * report.summary.totalClauseChanges; // 1
435
- * ```
436
- *
437
- * The input shape is forgiving — either a flat `{ id: whenSpec }` map, the
438
- * `system.inspect().constraints` array form, or either wrapped as
439
- * `{ constraints: ... }`. Constraints whose `when` is a function (no
440
- * `whenSpec`) are tracked as added/removed but cannot be clause-diffed
441
- * (the function form is opaque).
442
- */
443
- declare function diffRules(options: DiffRulesOptions): RulesDiffReport;
444
- /**
445
- * Diff two predicate trees and return the list of leaf-level changes.
446
- * Exported for reuse beyond the full per-constraint report.
447
- */
448
- declare function diffClauses(before: unknown, after: unknown): Change[];
449
-
450
328
  /**
451
329
  * `predicateHash` — content-addressed fingerprint for a {@link FactPredicate}.
452
330
  *
@@ -2022,8 +1900,8 @@ declare function virtualClock(initialMs?: number): SignalClock;
2022
1900
  * Returns `realClock()` always.
2023
1901
  *
2024
1902
  * Earlier drafts auto-detected vitest (`process.env.VITEST === 'true'`)
2025
- * and returned a `virtualClock()` in that environment. AE review
2026
- * flagged this as a footgun: tests that legitimately need real time
1903
+ * and returned a `virtualClock()` in that environment. That behavior
1904
+ * turned out to be a footgun: tests that legitimately need real time
2027
1905
  * (sleep-based debounce checks, real-`setTimeout`-bound integration
2028
1906
  * fixtures) silently received a virtual clock that never advanced
2029
1907
  * unless the test author called `advanceBy()`, producing apparent
@@ -2257,4 +2135,4 @@ declare const Backoff: {
2257
2135
  readonly Exponential: "exponential";
2258
2136
  };
2259
2137
 
2260
- export { Backoff, type Branded, type ChainableSchemaType, type Change, type ChangeKind, type CheckAbortOnFinding, type CheckAbortOnResult, type CheckAgainstResult, ClauseResult, type ConstraintDiff, type ConstraintStatus, type Contradiction, type ContradictionType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef as CrossModuleConstraintsDefinition, CrossModuleDeps, CrossModuleDerivationsDef as CrossModuleDerivationsDefinition, CrossModuleEffectsDef as CrossModuleEffectsDefinition, DefinitionMeta, type DescribeOptions, type DiffRulesOptions, EffectsDef as EffectsDefinition, ErrorBoundaryConfig, type ExistingConstraint, type ExtendedSchemaType, FactPredicate, Facts, type LeafClause, MAX_REPLAY_FRAMES, MAX_SWEEP_POINTS, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleDef as ModuleDefinition, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, type PredicateBacktestReport, type PredicateToMongoOptions, type PredicateToPostgrestOptions, type PredicateToSqlOptions, type PredicateToSqlResult, type PredictMissingChange, type PredictResult, type ReplayDiffSample, type ReplayFrame, type ReplayUnderOptions, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, type RulesDiffReport, type RulesMapInput, SchemaKindNode, SchemaType, type SignalClock, SingleModuleSystem, SourcesDef, SourcesDef as SourcesDefinition, type SweepHole, type SweepPoint, type SweepReport, type SweepUnderOptions, type TimerFactOpts, type TimerFactState, TraceOption, TypedConstraintsDef as TypedConstraintsDefinition, TypedDerivationsDef as TypedDerivationsDefinition, TypedEventsDef as TypedEventsDefinition, TypedResolversDef as TypedResolversDefinition, completeTimer, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, defaultClock, describePredicate, diffClauses, diffRules, doctor, elapsedMs, flattenPredicate, forType, framesFromHistory, framesFromSnapshots, generateRequirementId, initialTimerState, isRequirementType, pauseTimer, predicateHash, predicateToMongo, predicateToPostgrest, predicateToSQL, predicateToWhere, predict, realClock, registerRepeat, remainingMs, replayUnder, req, resetTimer, resumeTimer, startTimer, sweepUnder, t, tickTimer, timerOps, toReplayFrames, toRulesMap, virtualClock };
2138
+ export { Backoff, type Branded, type ChainableSchemaType, type CheckAbortOnFinding, type CheckAbortOnResult, type CheckAgainstResult, ClauseResult, type Contradiction, type ContradictionType, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef as CrossModuleConstraintsDefinition, CrossModuleDeps, CrossModuleDerivationsDef as CrossModuleDerivationsDefinition, CrossModuleEffectsDef as CrossModuleEffectsDefinition, DefinitionMeta, type DescribeOptions, EffectsDef as EffectsDefinition, ErrorBoundaryConfig, type ExistingConstraint, type ExtendedSchemaType, FactPredicate, Facts, MAX_REPLAY_FRAMES, MAX_SWEEP_POINTS, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleDef as ModuleDefinition, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, Plugin, type PredicateBacktestReport, type PredicateToMongoOptions, type PredicateToPostgrestOptions, type PredicateToSqlOptions, type PredicateToSqlResult, type PredictMissingChange, type PredictResult, type ReplayDiffSample, type ReplayFrame, type ReplayUnderOptions, Requirement, RequirementSet, type RequirementTypeStatus, RequirementWithId, SchemaKindNode, SchemaType, type SignalClock, SingleModuleSystem, SourcesDef, SourcesDef as SourcesDefinition, type SweepHole, type SweepPoint, type SweepReport, type SweepUnderOptions, type TimerFactOpts, type TimerFactState, TraceOption, TypedConstraintsDef as TypedConstraintsDefinition, TypedDerivationsDef as TypedDerivationsDefinition, TypedEventsDef as TypedEventsDefinition, TypedResolversDef as TypedResolversDefinition, completeTimer, createModule, createModuleFactory, createRequirementStatusPlugin, createStatusHook, createSystem, createSystemWithStatus, defaultClock, describePredicate, doctor, elapsedMs, forType, framesFromHistory, framesFromSnapshots, generateRequirementId, initialTimerState, isRequirementType, pauseTimer, predicateHash, predicateToMongo, predicateToPostgrest, predicateToSQL, predicateToWhere, predict, realClock, registerRepeat, remainingMs, replayUnder, req, resetTimer, resumeTimer, startTimer, sweepUnder, t, tickTimer, timerOps, toReplayFrames, virtualClock };