@directive-run/core 0.5.0 → 0.8.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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, D as DerivationsSchema, q as TypedConstraintDef, r as RequirementOutput$1, I as InferRequirements, P as Plugin, s as DebugConfig, t as ErrorBoundaryConfig, u as InferFacts, v as ExtractSchema, w as RequirementWithId, x as RequirementKeyFn, y as FactsStore, z as ConstraintsDef, A as ConstraintState, G as ResolversDef, H as ResolverStatus, J as System, K as FactChange, L as FactsSnapshot, O as ReconcileResult, Q as Snapshot, U as DirectiveError, V as RecoveryStrategy, W as RunChangelogEntry, X as ErrorSource, Y as RetryLaterConfig, Z as TimeTravelAPI, _ as SystemConfig } from './plugins-Co2_xohI.cjs';
2
- export { $ as AnySystem, a0 as BatchItemResult, a1 as BatchResolveResults, a2 as ConstraintsControl, a3 as CrossModuleConstraintDef, a4 as CrossModuleDerivationFn, a5 as CrossModuleEffectDef, a6 as CrossModuleFactsWithSelf, a7 as DerivationKeys, a8 as DerivationReturnType, a9 as DerivationsControl, aa as DeriveAccessor, ab as DispatchEventsFromSchema, ac as DistributableSnapshot, ad as DistributableSnapshotOptions, ae as EffectCleanup, af as EffectsControl, ag as EventPayloadSchema, ah as EventsAccessor, ai as EventsAccessorFromSchema, aj as EventsDef, ak as EventsSchema, al as FactKeys, am as FactReturnType, an as FlexibleEventHandler, ao as InferDerivations, ap as InferEventPayloadFromSchema, aq as InferEvents, ar as InferRequirementPayloadFromSchema, as as InferRequirementTypes, at as InferSchema, au as InferSchemaType, av as InferSelectorState, aw as MutableNamespacedFacts, ax as NamespacedDerivations, ay as NamespacedEventsAccessor, az as NamespacedFacts, aA as ObservableKeys, aB as RequirementExplanation, aC as RequirementPayloadSchema, aD as RequirementsSchema, aE as ResolversControl, aF as SnapshotMeta, aG as SystemEvent, aH as SystemInspection, aI as SystemMode, aJ as SystemSnapshot, aK as TimeTravelState, aL as TypedResolverContext, aM as TypedResolverDef, aN as UnionEvents, aO as isNamespacedSystem, aP as isSingleModuleSystem } from './plugins-Co2_xohI.cjs';
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';
3
3
  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
4
 
5
5
  /**
@@ -515,8 +515,11 @@ interface ModuleConfig<M extends ModuleSchema> {
515
515
  constraints?: TypedConstraintsDef<M>;
516
516
  resolvers?: TypedResolversDef<M>;
517
517
  hooks?: ModuleHooks<M>;
518
- /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
519
- snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
518
+ /** History configuration — controls which events create snapshots for undo/redo. */
519
+ history?: {
520
+ /** Events that create history snapshots. Omit to snapshot all events. */
521
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
522
+ };
520
523
  }
521
524
  /**
522
525
  * Module configuration with cross-module dependencies for type-safe access
@@ -586,8 +589,11 @@ interface ModuleConfigWithDeps<M extends ModuleSchema, Deps extends CrossModuleD
586
589
  /** Resolvers. Uses flat access (`ctx.facts.myFact`) to keep async mutations scoped to own module. */
587
590
  resolvers?: TypedResolversDef<M>;
588
591
  hooks?: ModuleHooks<M>;
589
- /** Events that create time-travel snapshots for undo/redo. Omit to snapshot all events. */
590
- snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
592
+ /** History configuration — controls which events create snapshots for undo/redo. */
593
+ history?: {
594
+ /** Events that create history snapshots. Omit to snapshot all events. */
595
+ snapshotEvents?: Array<keyof (M["events"] extends Record<string, unknown> ? M["events"] : Record<string, never>) & string>;
596
+ };
591
597
  }
592
598
  /**
593
599
  * Create a module definition with full type inference.
@@ -767,431 +773,6 @@ declare function createModuleFactory<const M extends ModuleSchema, const Deps ex
767
773
  declare function createSystem<S extends ModuleSchema>(options: CreateSystemOptionsSingle<S>): SingleModuleSystem<S>;
768
774
  declare function createSystem<const Modules extends ModulesMap>(options: CreateSystemOptionsNamed<Modules>): NamespacedSystem<Modules>;
769
775
 
770
- /**
771
- * Builder Pattern API for Directive Modules
772
- *
773
- * An alternative, fluent API for creating modules that provides
774
- * a more declarative style for module definition.
775
- *
776
- * @example
777
- * ```typescript
778
- * import { module, t } from '@directive-run/core';
779
- *
780
- * const counter = module("counter")
781
- * .schema({
782
- * facts: { count: t.number(), lastAction: t.string() },
783
- * derivations: { doubled: t.number(), isPositive: t.boolean() },
784
- * events: { increment: {}, decrement: {} },
785
- * requirements: {},
786
- * })
787
- * .init((facts) => {
788
- * facts.count = 0;
789
- * facts.lastAction = "";
790
- * })
791
- * .derive({
792
- * doubled: (facts) => facts.count * 2,
793
- * isPositive: (facts) => facts.count > 0,
794
- * })
795
- * .events({
796
- * increment: (facts) => {
797
- * facts.count += 1;
798
- * facts.lastAction = "increment";
799
- * },
800
- * decrement: (facts) => {
801
- * facts.count -= 1;
802
- * facts.lastAction = "decrement";
803
- * },
804
- * })
805
- * .build();
806
- * ```
807
- */
808
-
809
- /**
810
- * Fluent builder interface for constructing {@link ModuleDef} instances step by step.
811
- *
812
- * Chain methods like `.schema()`, `.init()`, `.derive()`, `.events()`, and others
813
- * to configure the module, then call `.build()` to produce the final definition.
814
- * The builder validates that all schema-declared derivations and events have
815
- * corresponding implementations before returning.
816
- *
817
- * @typeParam M - The module schema type, narrowed after calling `.schema()`.
818
- * @public
819
- */
820
- interface ModuleBuilder<M extends ModuleSchema = ModuleSchema> {
821
- /**
822
- * Define the schema for this module (facts, derivations, events, requirements).
823
- */
824
- schema<NewM extends ModuleSchema>(schema: NewM): ModuleBuilder<NewM>;
825
- /**
826
- * Define the initialization function for this module.
827
- */
828
- init(initFn: (facts: Facts<M["facts"]>) => void): ModuleBuilder<M>;
829
- /**
830
- * Define derivation implementations for this module.
831
- * Keys must match those declared in schema.derivations.
832
- */
833
- derive<D extends Record<string, (facts: Facts<M["facts"]>, derived: DeriveAccessor<M>) => unknown>>(derivations: D): ModuleBuilder<M>;
834
- /**
835
- * Define event handler implementations for this module.
836
- * Keys must match those declared in schema.events.
837
- */
838
- events<E extends Record<string, (facts: Facts<M["facts"]>, payload: unknown) => void>>(events: E): ModuleBuilder<M>;
839
- /**
840
- * Define effects (side effects) for this module.
841
- */
842
- effects(effects: EffectsDef<M["facts"]>): ModuleBuilder<M>;
843
- /**
844
- * Define constraints for this module.
845
- */
846
- constraints<C extends Record<string, ConstraintDef<M>>>(constraints: C): ModuleBuilder<M>;
847
- /**
848
- * Define resolvers for this module.
849
- */
850
- resolvers<R extends Record<string, ResolverDef<M>>>(resolvers: R): ModuleBuilder<M>;
851
- /**
852
- * Define lifecycle hooks for this module.
853
- */
854
- hooks(hooks: ModuleHooks<M>): ModuleBuilder<M>;
855
- /**
856
- * Build the module definition.
857
- */
858
- build(): ModuleDef<M>;
859
- }
860
- /**
861
- * Accessor for reading other derivations within a derivation function.
862
- */
863
- type DeriveAccessor<M extends ModuleSchema> = M["derivations"] extends DerivationsSchema ? {
864
- readonly [K in keyof M["derivations"]]: InferSchemaType<M["derivations"][K]>;
865
- } : Record<string, never>;
866
- /**
867
- * Infer the TypeScript type from a schema type definition.
868
- */
869
- type InferSchemaType<T> = T extends {
870
- _type: infer U;
871
- } ? U : any;
872
- /**
873
- * Constraint definition for the builder.
874
- */
875
- interface ConstraintDef<M extends ModuleSchema> {
876
- when: (facts: Facts<M["facts"]>) => boolean;
877
- require: {
878
- type: string;
879
- [key: string]: unknown;
880
- } | ((facts: Facts<M["facts"]>) => {
881
- type: string;
882
- [key: string]: unknown;
883
- } | null);
884
- priority?: number;
885
- }
886
- /**
887
- * Resolver definition for the builder.
888
- */
889
- interface ResolverDef<M extends ModuleSchema> {
890
- requirement: string | ((req: {
891
- type: string;
892
- [key: string]: unknown;
893
- }) => boolean);
894
- resolve: (req: {
895
- type: string;
896
- [key: string]: unknown;
897
- }, ctx: {
898
- facts: Facts<M["facts"]>;
899
- signal?: AbortSignal;
900
- }) => void | Promise<void>;
901
- retry?: {
902
- attempts?: number;
903
- backoff?: "linear" | "exponential";
904
- delay?: number;
905
- };
906
- timeout?: number;
907
- key?: (req: {
908
- type: string;
909
- [key: string]: unknown;
910
- }) => string;
911
- }
912
- /**
913
- * Create a new module using the fluent builder pattern.
914
- *
915
- * Returns a {@link ModuleBuilder} that lets you declaratively define a module's
916
- * schema, initialization, derivations, events, effects, constraints, resolvers,
917
- * and lifecycle hooks via method chaining. Call `.build()` at the end to produce
918
- * the final {@link ModuleDef}.
919
- *
920
- * @remarks
921
- * The builder validates at build time that every derivation and event declared
922
- * in the schema has a corresponding implementation. Missing implementations
923
- * cause a descriptive error.
924
- *
925
- * @param id - Unique identifier for this module, used for namespacing in multi-module systems.
926
- * @returns A {@link ModuleBuilder} ready for configuration via method chaining.
927
- *
928
- * @example
929
- * ```typescript
930
- * import { module, t } from '@directive-run/core';
931
- *
932
- * const counter = module("counter")
933
- * .schema({
934
- * facts: { count: t.number() },
935
- * derivations: { doubled: t.number() },
936
- * events: { increment: {} },
937
- * requirements: {},
938
- * })
939
- * .init((facts) => {
940
- * facts.count = 0;
941
- * })
942
- * .derive({
943
- * doubled: (facts) => facts.count * 2,
944
- * })
945
- * .events({
946
- * increment: (facts) => {
947
- * facts.count += 1;
948
- * },
949
- * })
950
- * .build();
951
- * ```
952
- *
953
- * @public
954
- */
955
- declare function module$1(id: string): ModuleBuilder<ModuleSchema>;
956
-
957
- /**
958
- * Constraint Builder API
959
- *
960
- * Fluent builders for creating typed constraint definitions.
961
- *
962
- * @example Full builder
963
- * ```typescript
964
- * import { constraint } from '@directive-run/core';
965
- *
966
- * const escalate = constraint<typeof schema>()
967
- * .when(f => f.confidence < 0.7)
968
- * .require({ type: 'ESCALATE' })
969
- * .priority(50)
970
- * .build();
971
- * ```
972
- *
973
- * @example Quick shorthand
974
- * ```typescript
975
- * import { when } from '@directive-run/core';
976
- *
977
- * const pause = when<typeof schema>(f => f.errors > 3)
978
- * .require({ type: 'PAUSE' });
979
- * ```
980
- */
981
-
982
- type WhenFn<M extends ModuleSchema> = (facts: Facts<M["facts"]>) => boolean | Promise<boolean>;
983
- type RequireValue<M extends ModuleSchema> = RequirementOutput$1<InferRequirements<M>> | ((facts: Facts<M["facts"]>) => RequirementOutput$1<InferRequirements<M>>);
984
- /** Builder after constraint() — must call .when() first */
985
- interface ConstraintBuilderStart<M extends ModuleSchema> {
986
- when(condition: WhenFn<M>): ConstraintBuilderWithWhen<M>;
987
- }
988
- /** Builder after .when() — must call .require() next */
989
- interface ConstraintBuilderWithWhen<M extends ModuleSchema> {
990
- require(req: RequireValue<M>): ConstraintBuilderComplete<M>;
991
- }
992
- /** Builder after .require() — optional chaining + .build() */
993
- interface ConstraintBuilderComplete<M extends ModuleSchema> {
994
- priority(n: number): ConstraintBuilderComplete<M>;
995
- after(...ids: string[]): ConstraintBuilderComplete<M>;
996
- deps(...keys: string[]): ConstraintBuilderComplete<M>;
997
- timeout(ms: number): ConstraintBuilderComplete<M>;
998
- async(value: boolean): ConstraintBuilderComplete<M>;
999
- build(): TypedConstraintDef<M>;
1000
- }
1001
- /** Result from when().require() — a valid constraint with optional immutable chaining */
1002
- type WhenConstraint<M extends ModuleSchema> = TypedConstraintDef<M> & {
1003
- withPriority(n: number): WhenConstraint<M>;
1004
- withAfter(...ids: string[]): WhenConstraint<M>;
1005
- withDeps(...keys: string[]): WhenConstraint<M>;
1006
- withTimeout(ms: number): WhenConstraint<M>;
1007
- withAsync(value: boolean): WhenConstraint<M>;
1008
- };
1009
- /** Result from when() — must call .require() */
1010
- interface WhenBuilder<M extends ModuleSchema> {
1011
- require(req: RequireValue<M>): WhenConstraint<M>;
1012
- }
1013
- /**
1014
- * Create a constraint using the full builder pattern.
1015
- * Requires `.when()`, `.require()`, and `.build()`.
1016
- *
1017
- * @example
1018
- * ```typescript
1019
- * const c = constraint<typeof schema>()
1020
- * .when(f => f.phase === "red")
1021
- * .require({ type: "TRANSITION", to: "green" })
1022
- * .priority(50)
1023
- * .after("healthCheck")
1024
- * .build();
1025
- * ```
1026
- */
1027
- declare function constraint<M extends ModuleSchema>(): ConstraintBuilderStart<M>;
1028
- /**
1029
- * Quick shorthand for creating constraints.
1030
- * Returns a valid constraint directly (no `.build()` needed).
1031
- *
1032
- * @example
1033
- * ```typescript
1034
- * const pause = when<typeof schema>(f => f.errors > 3)
1035
- * .require({ type: 'PAUSE' });
1036
- *
1037
- * // With optional chaining (immutable — returns new constraint)
1038
- * const halt = when<typeof schema>(f => f.errors > 10)
1039
- * .require({ type: 'HALT' })
1040
- * .withPriority(100)
1041
- * .withAfter('healthCheck');
1042
- * ```
1043
- */
1044
- declare function when<M extends ModuleSchema>(condition: WhenFn<M>): WhenBuilder<M>;
1045
-
1046
- /**
1047
- * System Builder API
1048
- *
1049
- * Fluent builder for creating Directive systems.
1050
- *
1051
- * @example Single module
1052
- * ```typescript
1053
- * import { system } from '@directive-run/core';
1054
- *
1055
- * const sys = system()
1056
- * .module(counterModule)
1057
- * .plugins([loggingPlugin()])
1058
- * .debug({ timeTravel: true })
1059
- * .build();
1060
- * ```
1061
- *
1062
- * @example Multiple modules
1063
- * ```typescript
1064
- * const sys = system()
1065
- * .modules({ auth: authModule, cart: cartModule })
1066
- * .plugins([loggingPlugin()])
1067
- * .build();
1068
- * ```
1069
- */
1070
-
1071
- /**
1072
- * Entry point of the system builder, returned by {@link system}.
1073
- *
1074
- * Choose `.module()` for a single-module {@link SingleModuleSystem} with direct
1075
- * fact/derivation access, or `.modules()` for a namespaced {@link NamespacedSystem}
1076
- * that composes multiple modules.
1077
- *
1078
- * @public
1079
- */
1080
- interface SystemBuilderStart {
1081
- /**
1082
- * Configure the system with a single module definition.
1083
- *
1084
- * @param mod - The module definition to use as the system's sole module.
1085
- * @returns A {@link SingleModuleSystemBuilder} for further configuration.
1086
- */
1087
- module<S extends ModuleSchema>(mod: ModuleDef<S>): SingleModuleSystemBuilder<S>;
1088
- /**
1089
- * Configure the system with multiple named modules.
1090
- *
1091
- * @param mods - A map of namespace keys to module definitions.
1092
- * @returns A {@link NamespacedSystemBuilder} for further configuration.
1093
- */
1094
- modules<const Modules extends ModulesMap>(mods: Modules): NamespacedSystemBuilder<Modules>;
1095
- }
1096
- /**
1097
- * Builder for a single-module system with direct access to facts, derivations, and events.
1098
- *
1099
- * @remarks
1100
- * Use this builder when your system contains exactly one module. The resulting
1101
- * {@link SingleModuleSystem} exposes facts, derivations, and dispatch without
1102
- * namespace prefixes.
1103
- *
1104
- * @typeParam S - The module schema type.
1105
- * @public
1106
- */
1107
- interface SingleModuleSystemBuilder<S extends ModuleSchema> {
1108
- /** Register plugins that hook into system lifecycle events. */
1109
- plugins(plugins: Array<Plugin<ModuleSchema>>): SingleModuleSystemBuilder<S>;
1110
- /** Enable debug features such as time-travel debugging and snapshot limits. */
1111
- debug(config: DebugConfig): SingleModuleSystemBuilder<S>;
1112
- /** Configure error boundary behavior including recovery strategies. */
1113
- errorBoundary(config: ErrorBoundaryConfig): SingleModuleSystemBuilder<S>;
1114
- /** Set the reconciliation tick interval in milliseconds. */
1115
- tickMs(ms: number): SingleModuleSystemBuilder<S>;
1116
- /** Enable zero-config mode which auto-generates constraints from schema metadata. */
1117
- zeroConfig(enabled?: boolean): SingleModuleSystemBuilder<S>;
1118
- /** Provide initial fact values to hydrate the system on startup. */
1119
- initialFacts(facts: Partial<InferFacts<S>>): SingleModuleSystemBuilder<S>;
1120
- /** Finalize configuration and create the running {@link SingleModuleSystem}. */
1121
- build(): SingleModuleSystem<S>;
1122
- }
1123
- /**
1124
- * Builder for a namespaced multi-module system.
1125
- *
1126
- * @remarks
1127
- * Use this builder when composing multiple modules. The resulting
1128
- * {@link NamespacedSystem} prefixes facts and derivations with the module
1129
- * namespace key (e.g., `system.facts.auth.token`).
1130
- *
1131
- * @typeParam Modules - The modules map type mapping namespace keys to module definitions.
1132
- * @public
1133
- */
1134
- interface NamespacedSystemBuilder<Modules extends ModulesMap> {
1135
- /** Register plugins that hook into system lifecycle events. */
1136
- plugins(plugins: Array<Plugin<ModuleSchema>>): NamespacedSystemBuilder<Modules>;
1137
- /** Enable debug features such as time-travel debugging and snapshot limits. */
1138
- debug(config: DebugConfig): NamespacedSystemBuilder<Modules>;
1139
- /** Configure error boundary behavior including recovery strategies. */
1140
- errorBoundary(config: ErrorBoundaryConfig): NamespacedSystemBuilder<Modules>;
1141
- /** Set the reconciliation tick interval in milliseconds. */
1142
- tickMs(ms: number): NamespacedSystemBuilder<Modules>;
1143
- /** Enable zero-config mode which auto-generates constraints from schema metadata. */
1144
- zeroConfig(enabled?: boolean): NamespacedSystemBuilder<Modules>;
1145
- /** Provide initial fact values keyed by module namespace for hydration on startup. */
1146
- initialFacts(facts: Partial<{
1147
- [K in keyof Modules]: Partial<InferFacts<ExtractSchema<Modules[K]>>>;
1148
- }>): NamespacedSystemBuilder<Modules>;
1149
- /** Control the order in which modules are initialized: automatic, declaration order, or explicit. */
1150
- initOrder(order: "auto" | "declaration" | Array<keyof Modules & string>): NamespacedSystemBuilder<Modules>;
1151
- /** Finalize configuration and create the running {@link NamespacedSystem}. */
1152
- build(): NamespacedSystem<Modules>;
1153
- }
1154
- /**
1155
- * Create a Directive system using the fluent builder pattern.
1156
- *
1157
- * Returns a {@link SystemBuilderStart} that branches into either a
1158
- * single-module path (`.module()`) or a namespaced multi-module path
1159
- * (`.modules()`). Chain configuration methods like `.plugins()`, `.debug()`,
1160
- * and `.errorBoundary()`, then call `.build()` to produce the running system.
1161
- *
1162
- * @remarks
1163
- * This is a convenience wrapper around {@link createSystem}. Both produce
1164
- * identical systems; the builder simply offers a more discoverable,
1165
- * chainable API.
1166
- *
1167
- * @returns A {@link SystemBuilderStart} ready to receive a module or modules map.
1168
- *
1169
- * @example Single-module system
1170
- * ```typescript
1171
- * import { system } from '@directive-run/core';
1172
- *
1173
- * const sys = system()
1174
- * .module(counterModule)
1175
- * .plugins([loggingPlugin()])
1176
- * .debug({ timeTravel: true })
1177
- * .build();
1178
- * ```
1179
- *
1180
- * @example Multi-module namespaced system
1181
- * ```typescript
1182
- * import { system } from '@directive-run/core';
1183
- *
1184
- * const sys = system()
1185
- * .modules({ auth: authModule, cart: cartModule })
1186
- * .plugins([loggingPlugin()])
1187
- * .initOrder(["auth", "cart"])
1188
- * .build();
1189
- * ```
1190
- *
1191
- * @public
1192
- */
1193
- declare function system(): SystemBuilderStart;
1194
-
1195
776
  /**
1196
777
  * Requirement Status Utilities
1197
778
  *
@@ -1278,8 +859,8 @@ interface CreateSystemWithStatusOptions<M extends ModuleSchema> {
1278
859
  module: ModuleDef<M>;
1279
860
  /** Additional plugins to include alongside the status plugin */
1280
861
  plugins?: Plugin<any>[];
1281
- /** Debug configuration */
1282
- debug?: DebugConfig;
862
+ /** Trace: per-run reconciliation changelog */
863
+ trace?: TraceOption;
1283
864
  /** Error boundary configuration */
1284
865
  errorBoundary?: ErrorBoundaryConfig;
1285
866
  /** Tick interval in milliseconds */
@@ -1694,8 +1275,12 @@ interface CreateDerivationsOptions<S extends Schema, D extends DerivationsDef<S>
1694
1275
  * Notifications are deferred during invalidation so listeners always see
1695
1276
  * consistent state across multiple simultaneous fact changes.
1696
1277
  *
1697
- * @param options - Derivation definitions, facts proxy, store, and optional lifecycle callbacks
1698
- * @returns A `DerivationsManager` with get/invalidate/subscribe/getProxy methods
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.
1282
+ *
1283
+ * @internal
1699
1284
  */
1700
1285
  declare function createDerivationsManager<S extends Schema, D extends DerivationsDef<S>>(options: CreateDerivationsOptions<S, D>): DerivationsManager<S, D>;
1701
1286
 
@@ -2300,9 +1885,9 @@ declare function createResolversManager<S extends Schema>(options: CreateResolve
2300
1885
  * - **Requirements:** `emitRequirementCreated`, `emitRequirementMet`, `emitRequirementCanceled`
2301
1886
  * - **Resolvers:** `emitResolverStart`, `emitResolverComplete`, `emitResolverError`, `emitResolverRetry`, `emitResolverCancel`
2302
1887
  * - **Effects:** `emitEffectRun`, `emitEffectError`
2303
- * - **Time-travel:** `emitSnapshot`, `emitTimeTravel`
1888
+ * - **History:** `emitSnapshot`, `emitHistoryNavigate`
2304
1889
  * - **Errors:** `emitError`, `emitErrorRecovery`
2305
- * - **Run history:** `emitRunComplete`
1890
+ * - **Trace:** `emitTraceComplete`
2306
1891
  *
2307
1892
  * @typeParam _S - The flat schema type (unused at runtime).
2308
1893
  *
@@ -2339,14 +1924,14 @@ interface PluginManager<_S extends Schema = any> {
2339
1924
  emitEffectRun(id: string): void;
2340
1925
  emitEffectError(id: string, error: unknown): void;
2341
1926
  emitSnapshot(snapshot: Snapshot): void;
2342
- emitTimeTravel(from: number, to: number): void;
1927
+ emitHistoryNavigate(from: number, to: number): void;
2343
1928
  emitError(error: DirectiveError): void;
2344
1929
  emitErrorRecovery(error: DirectiveError, strategy: RecoveryStrategy): void;
2345
1930
  emitDefinitionRegister(type: string, id: string, def: unknown): void;
2346
1931
  emitDefinitionAssign(type: string, id: string, def: unknown, original: unknown): void;
2347
1932
  emitDefinitionUnregister(type: string, id: string): void;
2348
1933
  emitDefinitionCall(type: string, id: string, props?: unknown): void;
2349
- emitRunComplete(run: RunChangelogEntry): void;
1934
+ emitTraceComplete(run: TraceEntry): void;
2350
1935
  }
2351
1936
  /**
2352
1937
  * Create a {@link PluginManager} that broadcasts lifecycle events to registered plugins.
@@ -2504,7 +2089,7 @@ interface CreateErrorBoundaryOptions {
2504
2089
  declare function createErrorBoundaryManager(options?: CreateErrorBoundaryOptions): ErrorBoundaryManager;
2505
2090
 
2506
2091
  /**
2507
- * Time-Travel Debugging - Snapshot-based state history
2092
+ * History Snapshot-based state history
2508
2093
  *
2509
2094
  * Features:
2510
2095
  * - Ring buffer of state snapshots
@@ -2514,7 +2099,7 @@ declare function createErrorBoundaryManager(options?: CreateErrorBoundaryOptions
2514
2099
  */
2515
2100
 
2516
2101
  /**
2517
- * Internal time-travel manager that extends the public {@link TimeTravelAPI}
2102
+ * Internal history manager that extends the public {@link HistoryAPI}
2518
2103
  * with snapshot capture, restoration, and pause/resume controls.
2519
2104
  *
2520
2105
  * @remarks
@@ -2530,12 +2115,12 @@ declare function createErrorBoundaryManager(options?: CreateErrorBoundaryOptions
2530
2115
  *
2531
2116
  * @internal
2532
2117
  */
2533
- interface TimeTravelManager<_S extends Schema> extends TimeTravelAPI {
2118
+ interface HistoryManager<_S extends Schema> extends HistoryAPI {
2534
2119
  /** Take a snapshot of current state */
2535
2120
  takeSnapshot(trigger: string): Snapshot;
2536
2121
  /** Restore facts from a snapshot */
2537
2122
  restore(snapshot: Snapshot): void;
2538
- /** Check if time-travel is enabled */
2123
+ /** Check if history is enabled */
2539
2124
  readonly isEnabled: boolean;
2540
2125
  /** True while restoring a snapshot (engine should skip reconciliation) */
2541
2126
  readonly isRestoring: boolean;
@@ -2545,23 +2130,23 @@ interface TimeTravelManager<_S extends Schema> extends TimeTravelAPI {
2545
2130
  resume(): void;
2546
2131
  }
2547
2132
  /**
2548
- * Options for creating a time-travel manager via {@link createTimeTravelManager}.
2133
+ * Options for creating a history manager via {@link createHistoryManager}.
2549
2134
  *
2550
2135
  * @typeParam S - The facts schema type.
2551
2136
  *
2552
2137
  * @internal
2553
2138
  */
2554
- interface CreateTimeTravelOptions<S extends Schema> {
2555
- config: DebugConfig;
2139
+ interface CreateHistoryOptions<S extends Schema> {
2140
+ historyOption: HistoryOption;
2556
2141
  facts: Facts<S>;
2557
2142
  store: FactsStore<S>;
2558
2143
  /** Callback when a snapshot is taken */
2559
2144
  onSnapshot?: (snapshot: Snapshot) => void;
2560
- /** Callback when time-travel occurs */
2561
- onTimeTravel?: (from: number, to: number) => void;
2145
+ /** Callback when history navigation occurs */
2146
+ onHistoryChange?: (from: number, to: number) => void;
2562
2147
  }
2563
2148
  /**
2564
- * Create a snapshot-based time-travel debugger backed by a ring buffer.
2149
+ * Create a snapshot-based history manager backed by a ring buffer.
2565
2150
  *
2566
2151
  * @remarks
2567
2152
  * Snapshots are taken automatically after fact changes (during reconciliation)
@@ -2573,25 +2158,25 @@ interface CreateTimeTravelOptions<S extends Schema> {
2573
2158
  * Call `pause()` to temporarily stop recording snapshots (e.g., during bulk
2574
2159
  * fact imports) and `resume()` to re-enable recording.
2575
2160
  *
2576
- * @param options - Debug config, facts proxy, store, and optional snapshot/time-travel callbacks.
2577
- * @returns A {@link TimeTravelManager} with snapshot capture, navigation, changeset, and export/import methods.
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.
2578
2163
  *
2579
2164
  * @internal
2580
2165
  */
2581
- declare function createTimeTravelManager<S extends Schema>(options: CreateTimeTravelOptions<S>): TimeTravelManager<S>;
2166
+ declare function createHistoryManager<S extends Schema>(options: CreateHistoryOptions<S>): HistoryManager<S>;
2582
2167
  /**
2583
- * Create a no-op time-travel manager for use when `debug.timeTravel` is disabled.
2168
+ * Create a no-op history manager for use when history is disabled.
2584
2169
  *
2585
2170
  * @remarks
2586
2171
  * All methods are safe to call but perform no work. This avoids null-checks
2587
- * throughout the engine -- callers can use the same {@link TimeTravelManager}
2588
- * interface regardless of whether time-travel is enabled.
2172
+ * throughout the engine -- callers can use the same {@link HistoryManager}
2173
+ * interface regardless of whether history is enabled.
2589
2174
  *
2590
- * @returns A {@link TimeTravelManager} where every method is a no-op and `isEnabled` is `false`.
2175
+ * @returns A {@link HistoryManager} where every method is a no-op and `isEnabled` is `false`.
2591
2176
  *
2592
2177
  * @internal
2593
2178
  */
2594
- declare function createDisabledTimeTravel<S extends Schema>(): TimeTravelManager<S>;
2179
+ declare function createDisabledHistory<S extends Schema>(): HistoryManager<S>;
2595
2180
 
2596
2181
  /**
2597
2182
  * Engine - The core reconciliation loop
@@ -2606,7 +2191,7 @@ declare function createDisabledTimeTravel<S extends Schema>(): TimeTravelManager
2606
2191
 
2607
2192
  /**
2608
2193
  * Create the core Directive reconciliation engine that wires facts, derivations,
2609
- * effects, constraints, resolvers, plugins, error boundaries, and time-travel
2194
+ * effects, constraints, resolvers, plugins, error boundaries, and history
2610
2195
  * into a single reactive system.
2611
2196
  *
2612
2197
  * @remarks
@@ -2645,16 +2230,34 @@ declare function createEngine<S extends Schema>(config: SystemConfig<any>): Syst
2645
2230
 
2646
2231
  /**
2647
2232
  * Get the current tracking context.
2648
- * Returns null context if no tracking is active.
2233
+ *
2234
+ * @returns The active {@link TrackingContext}, or a null context (no-op) if
2235
+ * no tracking is active.
2236
+ *
2237
+ * @internal
2649
2238
  */
2650
2239
  declare function getCurrentTracker(): TrackingContext;
2651
2240
  /**
2652
- * Check if we're currently tracking dependencies.
2241
+ * Check if dependency tracking is currently active.
2242
+ *
2243
+ * @returns `true` if inside a {@link withTracking} call, `false` otherwise.
2244
+ *
2245
+ * @internal
2653
2246
  */
2654
2247
  declare function isTracking(): boolean;
2655
2248
  /**
2656
2249
  * Run a function with dependency tracking.
2657
- * Returns the computed value and the set of dependencies accessed.
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
2658
2261
  */
2659
2262
  declare function withTracking<T>(fn: () => T): {
2660
2263
  value: T;
@@ -2662,12 +2265,28 @@ declare function withTracking<T>(fn: () => T): {
2662
2265
  };
2663
2266
  /**
2664
2267
  * Run a function without tracking.
2665
- * Useful for reading facts without creating dependencies.
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
2666
2279
  */
2667
2280
  declare function withoutTracking<T>(fn: () => T): T;
2668
2281
  /**
2669
2282
  * Track a specific key in the current context.
2670
- * No-op if not currently tracking.
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
2671
2290
  */
2672
2291
  declare function trackAccess(key: string): void;
2673
2292
 
@@ -2714,4 +2333,4 @@ declare const Backoff: {
2714
2333
  readonly Exponential: "exponential";
2715
2334
  };
2716
2335
 
2717
- export { Backoff, BatchConfig, type Branded, type ChainableSchemaType, ConstraintState, ConstraintsDef, CreateSystemOptionsNamed, CreateSystemOptionsSingle, CrossModuleConstraintsDef, CrossModuleDeps, CrossModuleDerivationsDef, CrossModuleEffectsDef, DebugConfig, type DerivationState, type DerivationsDef, DerivationsSchema, type DerivedValues, DirectiveError, EffectsDef, ErrorBoundaryConfig, ErrorSource, type ExtendedSchemaType, FactChange, Facts, FactsSnapshot, FactsStore, InferFacts, InferRequirements, type InflightInfo, type ModuleBuilder, type ModuleConfig, type ModuleConfigWithDeps, ModuleDef, ModuleHooks, ModuleSchema, ModulesMap, NamespacedSystem, type PendingRetry, Plugin, ReconcileResult, RecoveryStrategy, Requirement, RequirementKeyFn, RequirementOutput$1 as RequirementOutput, RequirementSet, type RequirementTypeStatus, RequirementWithId, ResolverContext, ResolverStatus, ResolversDef, RetryLaterConfig, RetryPolicy, RunChangelogEntry, Schema, SchemaType, SingleModuleSystem, Snapshot, System, SystemConfig, TimeTravelAPI, type TypedConstraint, TypedConstraintDef, TypedConstraintsDef, TypedDerivationsDef, TypedEventsDef, type TypedResolver, TypedResolversDef, type WhenConstraint, constraint, createConstraintFactory, createConstraintsManager, createDerivationsManager, createDisabledTimeTravel, createEffectsManager, createEngine, createErrorBoundaryManager, createFacts, createFactsProxy, createFactsStore, createModule, createModuleFactory, createPluginManager, createRequirementStatusPlugin, createResolverFactory, createResolversManager, createRetryLaterManager, createStatusHook, createSystem, createSystemWithStatus, createTimeTravelManager, forType, generateRequirementId, getCurrentTracker, isRequirementType, isTracking, module$1 as module, req, system, t, trackAccess, typedConstraint, typedResolver, when, withTracking, withoutTracking };
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 };