@directive-run/core 1.4.0 → 1.6.0

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 (73) 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-FK7BD7XT.js → chunk-EH2Q754B.js} +3 -3
  6. package/dist/chunk-EH2Q754B.js.map +1 -0
  7. package/dist/chunk-EOLY64E6.cjs +3 -0
  8. package/dist/chunk-EOLY64E6.cjs.map +1 -0
  9. package/dist/chunk-K3KVGWLP.cjs +3 -0
  10. package/dist/chunk-K3KVGWLP.cjs.map +1 -0
  11. package/dist/chunk-OVNPYGYJ.js +3 -0
  12. package/dist/chunk-OVNPYGYJ.js.map +1 -0
  13. package/dist/chunk-QOK7CHOW.js +16 -0
  14. package/dist/chunk-QOK7CHOW.js.map +1 -0
  15. package/dist/{chunk-DDUARSUH.cjs → chunk-S3CFYDIB.cjs} +3 -3
  16. package/dist/chunk-S3CFYDIB.cjs.map +1 -0
  17. package/dist/chunk-T4ZO4IYL.cjs +16 -0
  18. package/dist/chunk-T4ZO4IYL.cjs.map +1 -0
  19. package/dist/chunk-T6IJUWYR.js +3 -0
  20. package/dist/chunk-T6IJUWYR.js.map +1 -0
  21. package/dist/{helpers-BUY1lYCX.d.cts → helpers-BwAThjnJ.d.ts} +12 -2
  22. package/dist/{helpers-D6LcRum7.d.ts → helpers-CG27mEGG.d.cts} +12 -2
  23. package/dist/index.cjs +4 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +413 -5
  26. package/dist/index.d.ts +413 -5
  27. package/dist/index.js +4 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/internals.cjs +1 -1
  30. package/dist/internals.d.cts +86 -40
  31. package/dist/internals.d.ts +86 -40
  32. package/dist/internals.js +1 -1
  33. package/dist/plugins/index.cjs +1 -1
  34. package/dist/plugins/index.cjs.map +1 -1
  35. package/dist/plugins/index.d.cts +11 -8
  36. package/dist/plugins/index.d.ts +11 -8
  37. package/dist/plugins/index.js +1 -1
  38. package/dist/plugins/index.js.map +1 -1
  39. package/dist/{plugins-Dy1C8GtT.d.cts → plugins-DvrsPhzx.d.cts} +471 -68
  40. package/dist/{plugins-Dy1C8GtT.d.ts → plugins-DvrsPhzx.d.ts} +471 -68
  41. package/dist/system-5BSCMT63.cjs +2 -0
  42. package/dist/{system-2THXJBFM.cjs.map → system-5BSCMT63.cjs.map} +1 -1
  43. package/dist/system-DMJ6XEJ7.js +2 -0
  44. package/dist/{system-JIO36ALC.js.map → system-DMJ6XEJ7.js.map} +1 -1
  45. package/dist/testing.cjs +1 -1
  46. package/dist/testing.cjs.map +1 -1
  47. package/dist/testing.d.cts +1 -1
  48. package/dist/testing.d.ts +1 -1
  49. package/dist/testing.js +1 -1
  50. package/dist/testing.js.map +1 -1
  51. package/dist/worker.cjs +1 -1
  52. package/dist/worker.cjs.map +1 -1
  53. package/dist/worker.d.cts +1 -1
  54. package/dist/worker.d.ts +1 -1
  55. package/dist/worker.js +1 -1
  56. package/dist/worker.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/chunk-4CMO5OVZ.js +0 -3
  59. package/dist/chunk-4CMO5OVZ.js.map +0 -1
  60. package/dist/chunk-BEJ6ICA7.cjs +0 -3
  61. package/dist/chunk-BEJ6ICA7.cjs.map +0 -1
  62. package/dist/chunk-DDUARSUH.cjs.map +0 -1
  63. package/dist/chunk-E2WETPLH.js +0 -3
  64. package/dist/chunk-E2WETPLH.js.map +0 -1
  65. package/dist/chunk-FK7BD7XT.js.map +0 -1
  66. package/dist/chunk-LFMRWCIG.js +0 -16
  67. package/dist/chunk-LFMRWCIG.js.map +0 -1
  68. package/dist/chunk-TUS5WDVE.cjs +0 -3
  69. package/dist/chunk-TUS5WDVE.cjs.map +0 -1
  70. package/dist/chunk-VSHSYVSY.cjs +0 -16
  71. package/dist/chunk-VSHSYVSY.cjs.map +0 -1
  72. package/dist/system-2THXJBFM.cjs +0 -2
  73. package/dist/system-JIO36ALC.js +0 -2
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkTUS5WDVE_cjs=require('./chunk-TUS5WDVE.cjs'),chunkDDUARSUH_cjs=require('./chunk-DDUARSUH.cjs'),chunkBEJ6ICA7_cjs=require('./chunk-BEJ6ICA7.cjs');Object.defineProperty(exports,"createConstraintFactory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.c}});Object.defineProperty(exports,"createConstraintsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.p}});Object.defineProperty(exports,"createDerivationsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.q}});Object.defineProperty(exports,"createDisabledHistory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.j}});Object.defineProperty(exports,"createEffectsManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.r}});Object.defineProperty(exports,"createEngine",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.z}});Object.defineProperty(exports,"createErrorBoundaryManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.t}});Object.defineProperty(exports,"createFacts",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.w}});Object.defineProperty(exports,"createFactsProxy",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.v}});Object.defineProperty(exports,"createFactsStore",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.u}});Object.defineProperty(exports,"createHistoryManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.i}});Object.defineProperty(exports,"createPluginManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.x}});Object.defineProperty(exports,"createResolverFactory",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.d}});Object.defineProperty(exports,"createResolversManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.y}});Object.defineProperty(exports,"createRetryLaterManager",{enumerable:true,get:function(){return chunkTUS5WDVE_cjs.s}});Object.defineProperty(exports,"getCurrentDeps",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.g}});Object.defineProperty(exports,"isTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.h}});Object.defineProperty(exports,"trackAccess",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.k}});Object.defineProperty(exports,"withTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.i}});Object.defineProperty(exports,"withoutTracking",{enumerable:true,get:function(){return chunkDDUARSUH_cjs.j}});Object.defineProperty(exports,"safeStringify",{enumerable:true,get:function(){return chunkBEJ6ICA7_cjs.l}});//# sourceMappingURL=internals.cjs.map
1
+ 'use strict';var chunkK3KVGWLP_cjs=require('./chunk-K3KVGWLP.cjs'),chunkS3CFYDIB_cjs=require('./chunk-S3CFYDIB.cjs'),chunkEOLY64E6_cjs=require('./chunk-EOLY64E6.cjs');Object.defineProperty(exports,"createConstraintFactory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.q}});Object.defineProperty(exports,"createConstraintsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.D}});Object.defineProperty(exports,"createDerivationsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.E}});Object.defineProperty(exports,"createDisabledHistory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.x}});Object.defineProperty(exports,"createEffectsManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.F}});Object.defineProperty(exports,"createEngine",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.N}});Object.defineProperty(exports,"createErrorBoundaryManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.H}});Object.defineProperty(exports,"createFacts",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.K}});Object.defineProperty(exports,"createFactsProxy",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.J}});Object.defineProperty(exports,"createFactsStore",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.I}});Object.defineProperty(exports,"createHistoryManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.w}});Object.defineProperty(exports,"createPluginManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.L}});Object.defineProperty(exports,"createResolverFactory",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.r}});Object.defineProperty(exports,"createResolversManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.M}});Object.defineProperty(exports,"createRetryLaterManager",{enumerable:true,get:function(){return chunkK3KVGWLP_cjs.G}});Object.defineProperty(exports,"getCurrentDeps",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.g}});Object.defineProperty(exports,"isTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.h}});Object.defineProperty(exports,"trackAccess",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.k}});Object.defineProperty(exports,"withTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.i}});Object.defineProperty(exports,"withoutTracking",{enumerable:true,get:function(){return chunkS3CFYDIB_cjs.j}});Object.defineProperty(exports,"safeStringify",{enumerable:true,get:function(){return chunkEOLY64E6_cjs.n}});//# sourceMappingURL=internals.cjs.map
2
2
  //# sourceMappingURL=internals.cjs.map
@@ -1,7 +1,7 @@
1
- import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ConstraintBindMode, aa as ResolverStatus, o as Requirement, P as Plugin, Z as System, ab as FactChange, w as FactsSnapshot, ac as ReconcileResult, Y as Snapshot, q as DirectiveError, ad as RecoveryStrategy, a2 as TraceEntry, ae as ErrorSource, n as ErrorBoundaryConfig, af as RetryLaterConfig, H as HistoryAPI, x as HistoryOption, _ as SystemConfig } from './plugins-Dy1C8GtT.cjs';
2
- export { ag as BatchItemResult, ah as BatchResolveResults, ai as ConstraintsControl, aj as CrossModuleConstraintDef, g as CrossModuleConstraintsDef, ak as CrossModuleDerivationFn, e as CrossModuleDerivationsDef, al as CrossModuleEffectDef, f as CrossModuleEffectsDef, am as CrossModuleFactsWithSelf, an as DerivationKeys, ao as DerivationReturnType, ap as DerivationsControl, aq as DerivationsSchema, ar as DeriveAccessor, as as DispatchEventsFromSchema, r as DistributableSnapshot, s as DistributableSnapshotOptions, at as EffectCleanup, au as EffectsControl, av as EventPayloadSchema, aw as EventsAccessor, ax as EventsAccessorFromSchema, ay as EventsDef, az as EventsSchema, aA as FactKeys, aB as FactReturnType, aC as FlexibleEventHandler, aD as HistoryConfig, aE as InferEventPayloadFromSchema, aF as InferRequirementPayloadFromSchema, aG as InferSchema, aH as MutableNamespacedFacts, aI as NamespacedDerivations, aJ as NamespacedEventsAccessor, aK as NamespacedFacts, aL as ObservableKeys, aM as RequirementExplanation, aN as RequirementOutput, aO as RequirementPayloadSchema, aP as RequirementsSchema, aQ as ResolverContext, aR as ResolversControl, aS as SnapshotMeta, aT as SystemEvent, aU as TraceConfig, aV as TypedConstraintDef, b as TypedConstraintsDef, T as TypedDerivationsDef, a as TypedEventsDef, aW as TypedResolverContext, aX as TypedResolverDef, c as TypedResolversDef, aY as UnionEvents } from './plugins-Dy1C8GtT.cjs';
3
- import { b as DerivationsDef, c as DerivedValues } from './helpers-BUY1lYCX.cjs';
4
- export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-BUY1lYCX.cjs';
1
+ import { a8 as Schema, ai as FactsStore, b as Facts, D as DefinitionMeta, E as EffectsDef, aj as ConstraintsDef, t as RequirementKeyFn, R as RequirementWithId, ak as ConstraintState, a as FactPredicate, C as ClauseResult, al as ResolversDef, am as ResolverStatus, s as Requirement, p as Plugin, aa as System, an as FactChange, G as FactsSnapshot, ao as ReconcileResult, a9 as Snapshot, u as DirectiveError, ap as RecoveryStrategy, af as TraceEntry, aq as ErrorSource, r as ErrorBoundaryConfig, ar as RetryLaterConfig, H as HistoryAPI, I as HistoryOption, ab as SystemConfig } from './plugins-DvrsPhzx.cjs';
2
+ export { as as BatchItemResult, at as BatchResolveResults, au as ConstraintsControl, av as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aw as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, ax as CrossModuleEffectDef, i as CrossModuleEffectsDef, ay as CrossModuleFactsWithSelf, az as DerivationKeys, aA as DerivationReturnType, aB as DerivationsControl, aC as DerivationsSchema, aD as DeriveAccessor, aE as DispatchEventsFromSchema, v as DistributableSnapshot, w as DistributableSnapshotOptions, aF as EffectCleanup, aG as EffectsControl, aH as EventPayloadSchema, aI as EventsAccessor, aJ as EventsAccessorFromSchema, aK as EventsDef, aL as EventsSchema, aM as FactKeys, aN as FactReturnType, aO as FlexibleEventHandler, aP as HistoryConfig, aQ as InferEventPayloadFromSchema, aR as InferRequirementPayloadFromSchema, aS as InferSchema, aT as MutableNamespacedFacts, aU as NamespacedDerivations, aV as NamespacedEventsAccessor, aW as NamespacedFacts, aX as ObservableKeys, aY as RequirementExplanation, aZ as RequirementOutput, a_ as RequirementPayloadSchema, a$ as RequirementsSchema, b0 as ResolverContext, b1 as ResolversControl, b2 as SnapshotMeta, b3 as SystemEvent, b4 as TraceConfig, b5 as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, c as TypedEventsDef, b6 as TypedResolverContext, b7 as TypedResolverDef, e as TypedResolversDef, b8 as UnionEvents } from './plugins-DvrsPhzx.cjs';
3
+ import { b as DerivationsDef, c as DerivedValues } from './helpers-CG27mEGG.cjs';
4
+ export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-CG27mEGG.cjs';
5
5
  export { g as safeStringify } from './utils-BnQajqPu.cjs';
6
6
 
7
7
  /**
@@ -369,16 +369,6 @@ interface CreateEffectsOptions<S extends Schema> {
369
369
  */
370
370
  declare function createEffectsManager<S extends Schema>(options: CreateEffectsOptions<S>): EffectsManager<S>;
371
371
 
372
- /**
373
- * Constraints - Rules that produce requirements when conditions aren't met
374
- *
375
- * Features:
376
- * - Sync and async constraint evaluation
377
- * - Priority ordering (higher runs first)
378
- * - Timeout handling for async constraints
379
- * - Error isolation
380
- */
381
-
382
372
  /**
383
373
  * Manager returned by {@link createConstraintsManager} that evaluates
384
374
  * constraint rules against the current facts and produces unmet
@@ -512,6 +502,19 @@ interface ConstraintsManager<_S extends Schema> {
512
502
  * @param requirementType - The requirement type string to remove.
513
503
  */
514
504
  removeRequirementKey(requirementType: string): void;
505
+ /**
506
+ * Return the original {@link FactPredicate} spec a constraint was declared
507
+ * with — present only when the constraint's `when` was provided as data.
508
+ * Used by `system.inspect()` / `system.explain()` and devtools to render
509
+ * the clause structure.
510
+ */
511
+ getWhenSpec(id: string): FactPredicate<Record<string, unknown>> | undefined;
512
+ /**
513
+ * Evaluate a data-form `when` and return the per-clause breakdown
514
+ * (which clauses passed, which failed, against what fact values).
515
+ * Returns `undefined` for constraints whose `when` is a function.
516
+ */
517
+ explainWhen(id: string): ClauseResult[] | undefined;
515
518
  }
516
519
  /**
517
520
  * Configuration options accepted by {@link createConstraintsManager}.
@@ -610,8 +613,16 @@ interface ResolversManager<_S extends Schema> {
610
613
  * for batch processing instead of being resolved immediately.
611
614
  *
612
615
  * @param req - The requirement (with a stable identity ID) to resolve.
616
+ * @param options.factsBaseline - Optional pre-dispatch facts snapshot
617
+ * shared by every resolver dispatched in the same reconcile tick. Used
618
+ * by RFC-1 constraint-binding to seed each resolver's `expected` map
619
+ * from a value that pre-dates any sibling resolver's writes, preventing
620
+ * the sibling-clobber gap where resolver 2 silently overwrites
621
+ * resolver 1's owned write.
613
622
  */
614
- resolve(req: RequirementWithId): void;
623
+ resolve(req: RequirementWithId, options?: {
624
+ factsBaseline?: Readonly<Record<string, unknown>>;
625
+ }): void;
615
626
  /**
616
627
  * Cancel an in-flight or batch-queued resolver by requirement ID.
617
628
  *
@@ -622,6 +633,20 @@ interface ResolversManager<_S extends Schema> {
622
633
  * @param requirementId - The unique requirement ID to cancel.
623
634
  */
624
635
  cancel(requirementId: string): void;
636
+ /**
637
+ * Untrack an in-flight resolver by requirement ID **without** aborting it
638
+ * (RFC-0003 resolver constraint-binding).
639
+ *
640
+ * @remarks
641
+ * Used for bound resolvers whose triggering requirement was removed: the
642
+ * resolver runs to completion (its data writes land; the binding still
643
+ * guards owned facts) but it no longer occupies the `inflight` slot, so the
644
+ * same requirement re-dispatches cleanly if it returns. A no-op if the
645
+ * requirement is not in-flight.
646
+ *
647
+ * @param requirementId - The unique requirement ID to detach.
648
+ */
649
+ detach(requirementId: string): void;
625
650
  /**
626
651
  * Cancel every in-flight resolver and flush all pending batch queues.
627
652
  */
@@ -709,23 +734,18 @@ interface ResolversManager<_S extends Schema> {
709
734
  * Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
710
735
  *
711
736
  * The engine wires this lookup into the resolvers manager so that a resolver
712
- * dispatched from a constraint with `bind: 'auto'` can re-evaluate the
713
- * constraint's `when()` predicate live on every fact write.
737
+ * dispatched from a constraint with an `owns` field knows which facts it
738
+ * *owns* writes to those are clobber-checked (see {@link createBoundFacts}).
714
739
  *
715
- * Returns `null` (or the lookup itself returns `undefined`) when the source
716
- * constraint is unknown, async, or has `bind: 'none'` in which case
717
- * binding is a no-op and the resolver behaves exactly as before.
740
+ * Returns `undefined`/`null` when the source constraint is unknown or has no
741
+ * `owns` field in which case binding is a no-op and the resolver behaves
742
+ * exactly as before.
718
743
  *
719
744
  * @internal
720
745
  */
721
- interface ConstraintBindingInfo<S extends Schema> {
722
- /** The constraint's `bind` mode (effective; async predicates are forced to `'none'`). */
723
- mode: ConstraintBindMode;
724
- /**
725
- * The constraint's `when()` predicate, narrowed to a sync signature.
726
- * Only populated when `mode === 'auto'` and the constraint is sync.
727
- */
728
- when: ((facts: Facts<S>) => boolean) | null;
746
+ interface ConstraintBindingInfo {
747
+ /** Fact keys the triggering resolver owns; writes to these are clobber-checked. */
748
+ readonly fields: readonly string[];
729
749
  }
730
750
  /**
731
751
  * Configuration options accepted by {@link createResolversManager}.
@@ -743,11 +763,10 @@ interface CreateResolversOptions<S extends Schema> {
743
763
  * Look up binding info for a source constraint id (RFC-1).
744
764
  *
745
765
  * Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
746
- * returns the constraint's effective bind mode + a synchronous `when()`
747
- * reference. Return `undefined` if the constraint is unknown or binding
748
- * does not apply.
766
+ * returns the constraint's owned fact keys. Return `undefined` if the
767
+ * constraint is unknown or has no `owns` field.
749
768
  */
750
- getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo<S> | undefined;
769
+ getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo | undefined;
751
770
  /** Called when a resolver begins execution. */
752
771
  onStart?: (resolver: string, req: RequirementWithId) => void;
753
772
  /** Called when a resolver completes successfully, with the wall-clock duration in ms. */
@@ -758,6 +777,19 @@ interface CreateResolversOptions<S extends Schema> {
758
777
  onRetry?: (resolver: string, req: RequirementWithId, attempt: number) => void;
759
778
  /** Called when a resolver is canceled via {@link ResolversManager.cancel | cancel}. */
760
779
  onCancel?: (resolver: string, req: RequirementWithId) => void;
780
+ /**
781
+ * Called when a bound resolver's owned-fact write is dropped because the
782
+ * fact was changed by something outside the resolver (RFC-0003 clobber).
783
+ * Fires once per dropped write; the resolver's `AbortController` is also
784
+ * aborted in the same step. Wired to plugins for observability.
785
+ */
786
+ onClobber?: (resolver: string, req: RequirementWithId, fact: string, expected: unknown, actual: unknown) => void;
787
+ /**
788
+ * Called once when a single resolver instance exceeds the per-instance
789
+ * clobber-event cap. `dropped` is the number of per-clobber events
790
+ * suppressed. Rate-limits clobber-event amplification (RFC-0003).
791
+ */
792
+ onClobberSuppressed?: (resolver: string, req: RequirementWithId, dropped: number) => void;
761
793
  /** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
762
794
  onResolutionComplete?: () => void;
763
795
  /**
@@ -768,16 +800,15 @@ interface CreateResolversOptions<S extends Schema> {
768
800
  */
769
801
  onRequeue?: (requirementId: string) => void;
770
802
  }
771
- declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
772
-
773
803
  /**
774
- * Plugin Architecture - Extensible middleware for Directive
804
+ * Creates a resolver manager that tracks active resolver instances and
805
+ * coordinates their lifecycle (start / complete / error / cancel) against
806
+ * the engine's requirement graph.
775
807
  *
776
- * Features:
777
- * - Lifecycle hooks for all engine events
778
- * - Multiple plugins can be composed
779
- * - Plugins execute in registration order
808
+ * @param options - resolver definitions, facts reference, and event hooks
809
+ * @returns the manager handle used by the engine to drive resolver invocations
780
810
  */
811
+ declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
781
812
 
782
813
  /**
783
814
  * Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
@@ -826,7 +857,7 @@ interface PluginManager<_S extends Schema = any> {
826
857
  emitDerivationInvalidate(id: string): void;
827
858
  emitReconcileStart(snapshot: FactsSnapshot<any>): void;
828
859
  emitReconcileEnd(result: ReconcileResult): void;
829
- emitConstraintEvaluate(id: string, active: boolean): void;
860
+ emitConstraintEvaluate(id: string, active: boolean, whenExplain?: ClauseResult[]): void;
830
861
  emitConstraintError(id: string, error: unknown): void;
831
862
  emitRequirementCreated(req: RequirementWithId): void;
832
863
  emitRequirementMet(req: RequirementWithId, byResolver: string): void;
@@ -836,6 +867,21 @@ interface PluginManager<_S extends Schema = any> {
836
867
  emitResolverError(resolver: string, req: RequirementWithId, error: unknown): void;
837
868
  emitResolverRetry(resolver: string, req: RequirementWithId, attempt: number): void;
838
869
  emitResolverCancel(resolver: string, req: RequirementWithId): void;
870
+ emitResolverWriteRejected(event: {
871
+ kind: "rejection";
872
+ resolver: string;
873
+ req: RequirementWithId;
874
+ reason: "clobbered";
875
+ fact: string;
876
+ expected: unknown;
877
+ actual: unknown;
878
+ } | {
879
+ kind: "summary";
880
+ resolver: string;
881
+ req: RequirementWithId;
882
+ reason: "clobbered";
883
+ dropped: number;
884
+ }): void;
839
885
  emitEffectRun(id: string): void;
840
886
  emitEffectError(id: string, error: unknown): void;
841
887
  emitSnapshot(snapshot: Snapshot): void;
@@ -1,7 +1,7 @@
1
- import { X as Schema, a5 as FactsStore, F as Facts, D as DefinitionMeta, E as EffectsDef, a6 as ConstraintsDef, p as RequirementKeyFn, R as RequirementWithId, a7 as ConstraintState, a8 as ResolversDef, a9 as ConstraintBindMode, aa as ResolverStatus, o as Requirement, P as Plugin, Z as System, ab as FactChange, w as FactsSnapshot, ac as ReconcileResult, Y as Snapshot, q as DirectiveError, ad as RecoveryStrategy, a2 as TraceEntry, ae as ErrorSource, n as ErrorBoundaryConfig, af as RetryLaterConfig, H as HistoryAPI, x as HistoryOption, _ as SystemConfig } from './plugins-Dy1C8GtT.js';
2
- export { ag as BatchItemResult, ah as BatchResolveResults, ai as ConstraintsControl, aj as CrossModuleConstraintDef, g as CrossModuleConstraintsDef, ak as CrossModuleDerivationFn, e as CrossModuleDerivationsDef, al as CrossModuleEffectDef, f as CrossModuleEffectsDef, am as CrossModuleFactsWithSelf, an as DerivationKeys, ao as DerivationReturnType, ap as DerivationsControl, aq as DerivationsSchema, ar as DeriveAccessor, as as DispatchEventsFromSchema, r as DistributableSnapshot, s as DistributableSnapshotOptions, at as EffectCleanup, au as EffectsControl, av as EventPayloadSchema, aw as EventsAccessor, ax as EventsAccessorFromSchema, ay as EventsDef, az as EventsSchema, aA as FactKeys, aB as FactReturnType, aC as FlexibleEventHandler, aD as HistoryConfig, aE as InferEventPayloadFromSchema, aF as InferRequirementPayloadFromSchema, aG as InferSchema, aH as MutableNamespacedFacts, aI as NamespacedDerivations, aJ as NamespacedEventsAccessor, aK as NamespacedFacts, aL as ObservableKeys, aM as RequirementExplanation, aN as RequirementOutput, aO as RequirementPayloadSchema, aP as RequirementsSchema, aQ as ResolverContext, aR as ResolversControl, aS as SnapshotMeta, aT as SystemEvent, aU as TraceConfig, aV as TypedConstraintDef, b as TypedConstraintsDef, T as TypedDerivationsDef, a as TypedEventsDef, aW as TypedResolverContext, aX as TypedResolverDef, c as TypedResolversDef, aY as UnionEvents } from './plugins-Dy1C8GtT.js';
3
- import { b as DerivationsDef, c as DerivedValues } from './helpers-D6LcRum7.js';
4
- export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-D6LcRum7.js';
1
+ import { a8 as Schema, ai as FactsStore, b as Facts, D as DefinitionMeta, E as EffectsDef, aj as ConstraintsDef, t as RequirementKeyFn, R as RequirementWithId, ak as ConstraintState, a as FactPredicate, C as ClauseResult, al as ResolversDef, am as ResolverStatus, s as Requirement, p as Plugin, aa as System, an as FactChange, G as FactsSnapshot, ao as ReconcileResult, a9 as Snapshot, u as DirectiveError, ap as RecoveryStrategy, af as TraceEntry, aq as ErrorSource, r as ErrorBoundaryConfig, ar as RetryLaterConfig, H as HistoryAPI, I as HistoryOption, ab as SystemConfig } from './plugins-DvrsPhzx.js';
2
+ export { as as BatchItemResult, at as BatchResolveResults, au as ConstraintsControl, av as CrossModuleConstraintDef, j as CrossModuleConstraintsDef, aw as CrossModuleDerivationFn, h as CrossModuleDerivationsDef, ax as CrossModuleEffectDef, i as CrossModuleEffectsDef, ay as CrossModuleFactsWithSelf, az as DerivationKeys, aA as DerivationReturnType, aB as DerivationsControl, aC as DerivationsSchema, aD as DeriveAccessor, aE as DispatchEventsFromSchema, v as DistributableSnapshot, w as DistributableSnapshotOptions, aF as EffectCleanup, aG as EffectsControl, aH as EventPayloadSchema, aI as EventsAccessor, aJ as EventsAccessorFromSchema, aK as EventsDef, aL as EventsSchema, aM as FactKeys, aN as FactReturnType, aO as FlexibleEventHandler, aP as HistoryConfig, aQ as InferEventPayloadFromSchema, aR as InferRequirementPayloadFromSchema, aS as InferSchema, aT as MutableNamespacedFacts, aU as NamespacedDerivations, aV as NamespacedEventsAccessor, aW as NamespacedFacts, aX as ObservableKeys, aY as RequirementExplanation, aZ as RequirementOutput, a_ as RequirementPayloadSchema, a$ as RequirementsSchema, b0 as ResolverContext, b1 as ResolversControl, b2 as SnapshotMeta, b3 as SystemEvent, b4 as TraceConfig, b5 as TypedConstraintDef, d as TypedConstraintsDef, T as TypedDerivationsDef, c as TypedEventsDef, b6 as TypedResolverContext, b7 as TypedResolverDef, e as TypedResolversDef, b8 as UnionEvents } from './plugins-DvrsPhzx.js';
3
+ import { b as DerivationsDef, c as DerivedValues } from './helpers-BwAThjnJ.js';
4
+ export { d as DerivationState, T as TypedConstraint, e as TypedResolver, f as createConstraintFactory, g as createResolverFactory } from './helpers-BwAThjnJ.js';
5
5
  export { g as safeStringify } from './utils-BnQajqPu.js';
6
6
 
7
7
  /**
@@ -369,16 +369,6 @@ interface CreateEffectsOptions<S extends Schema> {
369
369
  */
370
370
  declare function createEffectsManager<S extends Schema>(options: CreateEffectsOptions<S>): EffectsManager<S>;
371
371
 
372
- /**
373
- * Constraints - Rules that produce requirements when conditions aren't met
374
- *
375
- * Features:
376
- * - Sync and async constraint evaluation
377
- * - Priority ordering (higher runs first)
378
- * - Timeout handling for async constraints
379
- * - Error isolation
380
- */
381
-
382
372
  /**
383
373
  * Manager returned by {@link createConstraintsManager} that evaluates
384
374
  * constraint rules against the current facts and produces unmet
@@ -512,6 +502,19 @@ interface ConstraintsManager<_S extends Schema> {
512
502
  * @param requirementType - The requirement type string to remove.
513
503
  */
514
504
  removeRequirementKey(requirementType: string): void;
505
+ /**
506
+ * Return the original {@link FactPredicate} spec a constraint was declared
507
+ * with — present only when the constraint's `when` was provided as data.
508
+ * Used by `system.inspect()` / `system.explain()` and devtools to render
509
+ * the clause structure.
510
+ */
511
+ getWhenSpec(id: string): FactPredicate<Record<string, unknown>> | undefined;
512
+ /**
513
+ * Evaluate a data-form `when` and return the per-clause breakdown
514
+ * (which clauses passed, which failed, against what fact values).
515
+ * Returns `undefined` for constraints whose `when` is a function.
516
+ */
517
+ explainWhen(id: string): ClauseResult[] | undefined;
515
518
  }
516
519
  /**
517
520
  * Configuration options accepted by {@link createConstraintsManager}.
@@ -610,8 +613,16 @@ interface ResolversManager<_S extends Schema> {
610
613
  * for batch processing instead of being resolved immediately.
611
614
  *
612
615
  * @param req - The requirement (with a stable identity ID) to resolve.
616
+ * @param options.factsBaseline - Optional pre-dispatch facts snapshot
617
+ * shared by every resolver dispatched in the same reconcile tick. Used
618
+ * by RFC-1 constraint-binding to seed each resolver's `expected` map
619
+ * from a value that pre-dates any sibling resolver's writes, preventing
620
+ * the sibling-clobber gap where resolver 2 silently overwrites
621
+ * resolver 1's owned write.
613
622
  */
614
- resolve(req: RequirementWithId): void;
623
+ resolve(req: RequirementWithId, options?: {
624
+ factsBaseline?: Readonly<Record<string, unknown>>;
625
+ }): void;
615
626
  /**
616
627
  * Cancel an in-flight or batch-queued resolver by requirement ID.
617
628
  *
@@ -622,6 +633,20 @@ interface ResolversManager<_S extends Schema> {
622
633
  * @param requirementId - The unique requirement ID to cancel.
623
634
  */
624
635
  cancel(requirementId: string): void;
636
+ /**
637
+ * Untrack an in-flight resolver by requirement ID **without** aborting it
638
+ * (RFC-0003 resolver constraint-binding).
639
+ *
640
+ * @remarks
641
+ * Used for bound resolvers whose triggering requirement was removed: the
642
+ * resolver runs to completion (its data writes land; the binding still
643
+ * guards owned facts) but it no longer occupies the `inflight` slot, so the
644
+ * same requirement re-dispatches cleanly if it returns. A no-op if the
645
+ * requirement is not in-flight.
646
+ *
647
+ * @param requirementId - The unique requirement ID to detach.
648
+ */
649
+ detach(requirementId: string): void;
625
650
  /**
626
651
  * Cancel every in-flight resolver and flush all pending batch queues.
627
652
  */
@@ -709,23 +734,18 @@ interface ResolversManager<_S extends Schema> {
709
734
  * Per-constraint binding info, used by RFC-1 (resolver constraint-binding).
710
735
  *
711
736
  * The engine wires this lookup into the resolvers manager so that a resolver
712
- * dispatched from a constraint with `bind: 'auto'` can re-evaluate the
713
- * constraint's `when()` predicate live on every fact write.
737
+ * dispatched from a constraint with an `owns` field knows which facts it
738
+ * *owns* writes to those are clobber-checked (see {@link createBoundFacts}).
714
739
  *
715
- * Returns `null` (or the lookup itself returns `undefined`) when the source
716
- * constraint is unknown, async, or has `bind: 'none'` in which case
717
- * binding is a no-op and the resolver behaves exactly as before.
740
+ * Returns `undefined`/`null` when the source constraint is unknown or has no
741
+ * `owns` field in which case binding is a no-op and the resolver behaves
742
+ * exactly as before.
718
743
  *
719
744
  * @internal
720
745
  */
721
- interface ConstraintBindingInfo<S extends Schema> {
722
- /** The constraint's `bind` mode (effective; async predicates are forced to `'none'`). */
723
- mode: ConstraintBindMode;
724
- /**
725
- * The constraint's `when()` predicate, narrowed to a sync signature.
726
- * Only populated when `mode === 'auto'` and the constraint is sync.
727
- */
728
- when: ((facts: Facts<S>) => boolean) | null;
746
+ interface ConstraintBindingInfo {
747
+ /** Fact keys the triggering resolver owns; writes to these are clobber-checked. */
748
+ readonly fields: readonly string[];
729
749
  }
730
750
  /**
731
751
  * Configuration options accepted by {@link createResolversManager}.
@@ -743,11 +763,10 @@ interface CreateResolversOptions<S extends Schema> {
743
763
  * Look up binding info for a source constraint id (RFC-1).
744
764
  *
745
765
  * Wired by the engine — given the `fromConstraint` of a `RequirementWithId`,
746
- * returns the constraint's effective bind mode + a synchronous `when()`
747
- * reference. Return `undefined` if the constraint is unknown or binding
748
- * does not apply.
766
+ * returns the constraint's owned fact keys. Return `undefined` if the
767
+ * constraint is unknown or has no `owns` field.
749
768
  */
750
- getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo<S> | undefined;
769
+ getConstraintBinding?: (constraintId: string) => ConstraintBindingInfo | undefined;
751
770
  /** Called when a resolver begins execution. */
752
771
  onStart?: (resolver: string, req: RequirementWithId) => void;
753
772
  /** Called when a resolver completes successfully, with the wall-clock duration in ms. */
@@ -758,6 +777,19 @@ interface CreateResolversOptions<S extends Schema> {
758
777
  onRetry?: (resolver: string, req: RequirementWithId, attempt: number) => void;
759
778
  /** Called when a resolver is canceled via {@link ResolversManager.cancel | cancel}. */
760
779
  onCancel?: (resolver: string, req: RequirementWithId) => void;
780
+ /**
781
+ * Called when a bound resolver's owned-fact write is dropped because the
782
+ * fact was changed by something outside the resolver (RFC-0003 clobber).
783
+ * Fires once per dropped write; the resolver's `AbortController` is also
784
+ * aborted in the same step. Wired to plugins for observability.
785
+ */
786
+ onClobber?: (resolver: string, req: RequirementWithId, fact: string, expected: unknown, actual: unknown) => void;
787
+ /**
788
+ * Called once when a single resolver instance exceeds the per-instance
789
+ * clobber-event cap. `dropped` is the number of per-clobber events
790
+ * suppressed. Rate-limits clobber-event amplification (RFC-0003).
791
+ */
792
+ onClobberSuppressed?: (resolver: string, req: RequirementWithId, dropped: number) => void;
761
793
  /** Called after any resolver finishes (success, error, or batch completion) to trigger reconciliation. */
762
794
  onResolutionComplete?: () => void;
763
795
  /**
@@ -768,16 +800,15 @@ interface CreateResolversOptions<S extends Schema> {
768
800
  */
769
801
  onRequeue?: (requirementId: string) => void;
770
802
  }
771
- declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
772
-
773
803
  /**
774
- * Plugin Architecture - Extensible middleware for Directive
804
+ * Creates a resolver manager that tracks active resolver instances and
805
+ * coordinates their lifecycle (start / complete / error / cancel) against
806
+ * the engine's requirement graph.
775
807
  *
776
- * Features:
777
- * - Lifecycle hooks for all engine events
778
- * - Multiple plugins can be composed
779
- * - Plugins execute in registration order
808
+ * @param options - resolver definitions, facts reference, and event hooks
809
+ * @returns the manager handle used by the engine to drive resolver invocations
780
810
  */
811
+ declare function createResolversManager<S extends Schema>(options: CreateResolversOptions<S>): ResolversManager<S>;
781
812
 
782
813
  /**
783
814
  * Internal manager that broadcasts lifecycle events to registered {@link Plugin} instances.
@@ -826,7 +857,7 @@ interface PluginManager<_S extends Schema = any> {
826
857
  emitDerivationInvalidate(id: string): void;
827
858
  emitReconcileStart(snapshot: FactsSnapshot<any>): void;
828
859
  emitReconcileEnd(result: ReconcileResult): void;
829
- emitConstraintEvaluate(id: string, active: boolean): void;
860
+ emitConstraintEvaluate(id: string, active: boolean, whenExplain?: ClauseResult[]): void;
830
861
  emitConstraintError(id: string, error: unknown): void;
831
862
  emitRequirementCreated(req: RequirementWithId): void;
832
863
  emitRequirementMet(req: RequirementWithId, byResolver: string): void;
@@ -836,6 +867,21 @@ interface PluginManager<_S extends Schema = any> {
836
867
  emitResolverError(resolver: string, req: RequirementWithId, error: unknown): void;
837
868
  emitResolverRetry(resolver: string, req: RequirementWithId, attempt: number): void;
838
869
  emitResolverCancel(resolver: string, req: RequirementWithId): void;
870
+ emitResolverWriteRejected(event: {
871
+ kind: "rejection";
872
+ resolver: string;
873
+ req: RequirementWithId;
874
+ reason: "clobbered";
875
+ fact: string;
876
+ expected: unknown;
877
+ actual: unknown;
878
+ } | {
879
+ kind: "summary";
880
+ resolver: string;
881
+ req: RequirementWithId;
882
+ reason: "clobbered";
883
+ dropped: number;
884
+ }): void;
839
885
  emitEffectRun(id: string): void;
840
886
  emitEffectError(id: string, error: unknown): void;
841
887
  emitSnapshot(snapshot: Snapshot): void;
package/dist/internals.js CHANGED
@@ -1,2 +1,2 @@
1
- export{c as createConstraintFactory,p as createConstraintsManager,q as createDerivationsManager,j as createDisabledHistory,r as createEffectsManager,z as createEngine,t as createErrorBoundaryManager,w as createFacts,v as createFactsProxy,u as createFactsStore,i as createHistoryManager,x as createPluginManager,d as createResolverFactory,y as createResolversManager,s as createRetryLaterManager}from'./chunk-E2WETPLH.js';export{g as getCurrentDeps,h as isTracking,k as trackAccess,i as withTracking,j as withoutTracking}from'./chunk-FK7BD7XT.js';export{l as safeStringify}from'./chunk-4CMO5OVZ.js';//# sourceMappingURL=internals.js.map
1
+ export{q as createConstraintFactory,D as createConstraintsManager,E as createDerivationsManager,x as createDisabledHistory,F as createEffectsManager,N as createEngine,H as createErrorBoundaryManager,K as createFacts,J as createFactsProxy,I as createFactsStore,w as createHistoryManager,L as createPluginManager,r as createResolverFactory,M as createResolversManager,G as createRetryLaterManager}from'./chunk-OVNPYGYJ.js';export{g as getCurrentDeps,h as isTracking,k as trackAccess,i as withTracking,j as withoutTracking}from'./chunk-EH2Q754B.js';export{n as safeStringify}from'./chunk-T6IJUWYR.js';//# sourceMappingURL=internals.js.map
2
2
  //# sourceMappingURL=internals.js.map