@plures/praxis 1.4.0 → 1.4.4

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 (51) hide show
  1. package/dist/browser/{chunk-N63K4KWS.js → chunk-4IRUGWR3.js} +1 -1
  2. package/dist/browser/chunk-6SJ44Q64.js +473 -0
  3. package/dist/browser/chunk-BQOYZBWA.js +282 -0
  4. package/dist/browser/chunk-IG5BJ2MT.js +91 -0
  5. package/dist/browser/{chunk-MJK3IYTJ.js → chunk-JZDJU2DO.js} +4 -84
  6. package/dist/browser/chunk-ZEW4LJAJ.js +353 -0
  7. package/dist/browser/{engine-YIEGSX7U.js → engine-3B5WJPGT.js} +2 -1
  8. package/dist/browser/expectations/index.d.ts +180 -0
  9. package/dist/browser/expectations/index.js +14 -0
  10. package/dist/browser/factory/index.d.ts +149 -0
  11. package/dist/browser/factory/index.js +15 -0
  12. package/dist/browser/index.d.ts +274 -3
  13. package/dist/browser/index.js +407 -54
  14. package/dist/browser/integrations/svelte.d.ts +3 -2
  15. package/dist/browser/integrations/svelte.js +3 -2
  16. package/dist/browser/project/index.d.ts +176 -0
  17. package/dist/browser/project/index.js +19 -0
  18. package/dist/browser/reactive-engine.svelte-DgVTqHLc.d.ts +223 -0
  19. package/dist/browser/{reactive-engine.svelte-DjynI82A.d.ts → rules-i1LHpnGd.d.ts} +13 -221
  20. package/dist/node/chunk-AZLNISFI.js +1690 -0
  21. package/dist/node/chunk-IG5BJ2MT.js +91 -0
  22. package/dist/node/{chunk-KMJWAFZV.js → chunk-JZDJU2DO.js} +4 -89
  23. package/dist/node/{chunk-7M3HV4XR.js → chunk-ZO2LU4G4.js} +1 -1
  24. package/dist/node/cli/index.cjs +48 -0
  25. package/dist/node/cli/index.js +2 -2
  26. package/dist/node/{engine-FEN5IYZ5.js → engine-VFHCIEM4.js} +2 -1
  27. package/dist/node/index.cjs +1747 -0
  28. package/dist/node/index.d.cts +960 -278
  29. package/dist/node/index.d.ts +960 -278
  30. package/dist/node/index.js +559 -6
  31. package/dist/node/integrations/svelte.js +3 -2
  32. package/dist/node/{server-SYZPDULV.js → server-FKLVY57V.js} +4 -2
  33. package/dist/node/{validate-TQGVIG7G.js → validate-5PSWJTIC.js} +2 -1
  34. package/package.json +32 -11
  35. package/src/__tests__/chronos-project.test.ts +799 -0
  36. package/src/__tests__/decision-ledger.test.ts +857 -402
  37. package/src/chronos/diff.ts +336 -0
  38. package/src/chronos/hooks.ts +227 -0
  39. package/src/chronos/index.ts +83 -0
  40. package/src/chronos/project-chronicle.ts +198 -0
  41. package/src/chronos/timeline.ts +152 -0
  42. package/src/decision-ledger/analyzer-types.ts +280 -0
  43. package/src/decision-ledger/analyzer.ts +518 -0
  44. package/src/decision-ledger/contract-verification.ts +456 -0
  45. package/src/decision-ledger/derivation.ts +158 -0
  46. package/src/decision-ledger/index.ts +59 -0
  47. package/src/decision-ledger/report.ts +378 -0
  48. package/src/decision-ledger/suggestions.ts +287 -0
  49. package/src/index.browser.ts +83 -0
  50. package/src/index.ts +77 -0
  51. package/dist/node/chunk-FWOXU4MM.js +0 -487
@@ -789,6 +789,576 @@ declare class BehaviorLedger {
789
789
  */
790
790
  declare function createBehaviorLedger(): BehaviorLedger;
791
791
 
792
+ /**
793
+ * Decision Ledger — Analyzer Types
794
+ *
795
+ * Types for the graph analysis engine that understands the entire rule graph
796
+ * and finds what's missing, broken, or unreachable.
797
+ */
798
+ /** A node in the fact dependency graph */
799
+ interface FactNode {
800
+ /** The fact tag */
801
+ tag: string;
802
+ /** Rules that produce this fact */
803
+ producedBy: string[];
804
+ /** Rules that read/consume this fact */
805
+ consumedBy: string[];
806
+ }
807
+ /** An edge in the dependency graph (rule → fact or fact → rule) */
808
+ interface DependencyEdge {
809
+ from: string;
810
+ to: string;
811
+ type: 'produces' | 'consumes';
812
+ }
813
+ /** The full dependency graph */
814
+ interface DependencyGraph {
815
+ /** Fact nodes keyed by tag */
816
+ facts: Map<string, FactNode>;
817
+ /** All edges */
818
+ edges: DependencyEdge[];
819
+ /** Rule IDs that produce facts */
820
+ producers: Map<string, string[]>;
821
+ /** Rule IDs that consume facts */
822
+ consumers: Map<string, string[]>;
823
+ }
824
+ /** A single step in a derivation chain */
825
+ interface DerivationStep {
826
+ type: 'event' | 'rule-fired' | 'fact-produced' | 'fact-read';
827
+ id: string;
828
+ description: string;
829
+ }
830
+ /** A chain showing how a fact was derived */
831
+ interface DerivationChain {
832
+ /** The target fact tag */
833
+ targetFact: string;
834
+ /** Ordered steps from origin to target */
835
+ steps: DerivationStep[];
836
+ /** Depth of the chain */
837
+ depth: number;
838
+ }
839
+ /** A rule that can never fire given known event types */
840
+ interface DeadRule {
841
+ ruleId: string;
842
+ description: string;
843
+ /** Event types the rule requires */
844
+ requiredEventTypes: string[];
845
+ /** Why it's dead */
846
+ reason: string;
847
+ }
848
+ /** A fact combination that no rule sequence can produce */
849
+ interface UnreachableState {
850
+ /** The fact tags that can't be produced together */
851
+ factTags: string[];
852
+ /** Why it's unreachable */
853
+ reason: string;
854
+ }
855
+ /** A rule that always loses to another */
856
+ interface ShadowedRule {
857
+ /** The shadowed rule */
858
+ ruleId: string;
859
+ /** The rule that shadows it */
860
+ shadowedBy: string;
861
+ /** Shared event types */
862
+ sharedEventTypes: string[];
863
+ /** Why it's shadowed */
864
+ reason: string;
865
+ }
866
+ /** Two rules that produce conflicting facts */
867
+ interface Contradiction {
868
+ /** First rule */
869
+ ruleA: string;
870
+ /** Second rule */
871
+ ruleB: string;
872
+ /** The conflicting fact tag */
873
+ conflictingTag: string;
874
+ /** Description of the conflict */
875
+ reason: string;
876
+ }
877
+ /** An expected behavior with no covering rule */
878
+ interface Gap {
879
+ /** The expectation name */
880
+ expectationName: string;
881
+ /** What's missing */
882
+ description: string;
883
+ /** Related rule IDs that partially cover */
884
+ partialCoverage: string[];
885
+ /** The type of gap */
886
+ type: 'no-rule' | 'partial-coverage' | 'no-contract';
887
+ }
888
+ /** Impact of removing a fact */
889
+ interface ImpactReport {
890
+ /** The fact being analyzed */
891
+ factTag: string;
892
+ /** Rules that would stop firing */
893
+ affectedRules: string[];
894
+ /** Facts that would disappear (transitively) */
895
+ affectedFacts: string[];
896
+ /** Total downstream impact depth */
897
+ depth: number;
898
+ }
899
+ /** Result of running a contract example against its rule */
900
+ interface ExampleVerification {
901
+ /** The example index */
902
+ index: number;
903
+ /** Given/When/Then description */
904
+ given: string;
905
+ when: string;
906
+ expectedThen: string;
907
+ /** Whether it passed */
908
+ passed: boolean;
909
+ /** Actual output if different */
910
+ actualOutput?: string;
911
+ /** Error if execution failed */
912
+ error?: string;
913
+ }
914
+ /** Contract verification result for a single rule */
915
+ interface ContractVerificationResult {
916
+ ruleId: string;
917
+ /** Example verification results */
918
+ examples: ExampleVerification[];
919
+ /** Whether all examples passed */
920
+ allPassed: boolean;
921
+ /** Number of passing examples */
922
+ passCount: number;
923
+ /** Number of failing examples */
924
+ failCount: number;
925
+ }
926
+ /** Invariant check result */
927
+ interface InvariantCheck {
928
+ /** The invariant statement */
929
+ invariant: string;
930
+ /** The rule it belongs to */
931
+ ruleId: string;
932
+ /** Whether it holds */
933
+ holds: boolean;
934
+ /** Explanation */
935
+ explanation: string;
936
+ }
937
+ /** Contract gap finding (deeper than registration-time) */
938
+ interface ContractCoverageGap {
939
+ ruleId: string;
940
+ /** What's not covered */
941
+ description: string;
942
+ /** Type of gap */
943
+ type: 'missing-edge-case' | 'missing-error-path' | 'missing-boundary' | 'cross-reference-broken';
944
+ }
945
+ /** Cross-reference result */
946
+ interface CrossReference {
947
+ /** Rule whose contract references another rule's facts */
948
+ sourceRuleId: string;
949
+ /** The referenced fact tag */
950
+ referencedFactTag: string;
951
+ /** The rule that produces the referenced fact (or null if missing) */
952
+ producerRuleId: string | null;
953
+ /** Whether the producer exists */
954
+ valid: boolean;
955
+ }
956
+ /** Types of findings that can generate suggestions */
957
+ type FindingType = 'dead-rule' | 'gap' | 'contradiction' | 'unreachable-state' | 'shadowed-rule' | 'contract-gap';
958
+ /** An actionable fix suggestion */
959
+ interface Suggestion {
960
+ /** What finding this addresses */
961
+ findingType: FindingType;
962
+ /** Related entity ID */
963
+ entityId: string;
964
+ /** Human-readable suggestion */
965
+ message: string;
966
+ /** Suggested action type */
967
+ action: 'remove' | 'add-rule' | 'modify' | 'merge' | 'add-priority' | 'add-event-type' | 'add-contract';
968
+ /** Priority (higher = more important) */
969
+ priority: number;
970
+ /** Optional code skeleton */
971
+ skeleton?: string;
972
+ }
973
+ /** The complete analysis report from the decision ledger analyzer */
974
+ interface AnalysisReport {
975
+ /** Timestamp of the analysis */
976
+ timestamp: string;
977
+ /** Fact derivation chains */
978
+ factDerivationChains: DerivationChain[];
979
+ /** Rules that can never fire */
980
+ deadRules: DeadRule[];
981
+ /** Fact combos no rule can produce */
982
+ unreachableStates: UnreachableState[];
983
+ /** Rules always overshadowed by another */
984
+ shadowedRules: ShadowedRule[];
985
+ /** Rules producing conflicting facts */
986
+ contradictions: Contradiction[];
987
+ /** Expected behaviors with no covering rule */
988
+ gaps: Gap[];
989
+ /** Actionable fix suggestions */
990
+ suggestions: Suggestion[];
991
+ /** Summary statistics */
992
+ summary: {
993
+ totalRules: number;
994
+ totalConstraints: number;
995
+ deadRuleCount: number;
996
+ unreachableStateCount: number;
997
+ shadowedRuleCount: number;
998
+ contradictionCount: number;
999
+ gapCount: number;
1000
+ suggestionCount: number;
1001
+ healthScore: number;
1002
+ };
1003
+ }
1004
+ /** A change between two analysis runs */
1005
+ interface LedgerDiffEntry {
1006
+ type: 'added' | 'removed' | 'changed';
1007
+ category: 'dead-rule' | 'unreachable-state' | 'shadowed-rule' | 'contradiction' | 'gap' | 'suggestion';
1008
+ description: string;
1009
+ /** Entity ID (rule, state, etc.) */
1010
+ entityId: string;
1011
+ }
1012
+ /** Diff between two analysis reports */
1013
+ interface LedgerDiff {
1014
+ /** Timestamp of the diff */
1015
+ timestamp: string;
1016
+ /** Before report timestamp */
1017
+ beforeTimestamp: string;
1018
+ /** After report timestamp */
1019
+ afterTimestamp: string;
1020
+ /** Changes found */
1021
+ changes: LedgerDiffEntry[];
1022
+ /** Score change */
1023
+ scoreDelta: number;
1024
+ /** Summary */
1025
+ summary: string;
1026
+ }
1027
+
1028
+ /**
1029
+ * Expectations DSL — Types
1030
+ *
1031
+ * Types for declaring behavioral expectations about rules.
1032
+ * Expectations replace traditional tests with behavioral declarations.
1033
+ */
1034
+ /** A condition under which a behavior should or should not occur. */
1035
+ interface ExpectationCondition {
1036
+ /** Human-readable condition description */
1037
+ description: string;
1038
+ /** Type of expectation */
1039
+ type: 'onlyWhen' | 'never' | 'always';
1040
+ }
1041
+ /** Verification status for a single expectation condition. */
1042
+ type ConditionStatus = 'satisfied' | 'violated' | 'unverifiable';
1043
+ /** Detailed result for a single condition check. */
1044
+ interface ConditionResult {
1045
+ condition: ExpectationCondition;
1046
+ status: ConditionStatus;
1047
+ /** Explanation of how the condition was verified or why it couldn't be */
1048
+ explanation: string;
1049
+ /** Related rule IDs that informed this check */
1050
+ relatedRules: string[];
1051
+ }
1052
+ /** Verification result for a single Expectation. */
1053
+ interface ExpectationResult {
1054
+ /** The expectation name/ID */
1055
+ name: string;
1056
+ /** Overall status: satisfied if ALL conditions pass */
1057
+ status: 'satisfied' | 'violated' | 'partial';
1058
+ /** Per-condition results */
1059
+ conditions: ConditionResult[];
1060
+ /** Edge cases discovered */
1061
+ edgeCases: string[];
1062
+ /** Suggested mitigations for violated/partial expectations */
1063
+ mitigations: string[];
1064
+ }
1065
+ /** Full verification report for an ExpectationSet. */
1066
+ interface VerificationReport {
1067
+ /** Set name */
1068
+ setName: string;
1069
+ /** Timestamp of verification */
1070
+ timestamp: string;
1071
+ /** Overall status: satisfied if ALL expectations are satisfied */
1072
+ status: 'satisfied' | 'violated' | 'partial';
1073
+ /** Per-expectation results */
1074
+ expectations: ExpectationResult[];
1075
+ /** Summary stats */
1076
+ summary: {
1077
+ total: number;
1078
+ satisfied: number;
1079
+ violated: number;
1080
+ partial: number;
1081
+ };
1082
+ /** All edge cases found across all expectations */
1083
+ allEdgeCases: string[];
1084
+ /** All mitigations suggested */
1085
+ allMitigations: string[];
1086
+ }
1087
+ /** Options for creating an ExpectationSet */
1088
+ interface ExpectationSetOptions {
1089
+ /** Name/domain for this set of expectations */
1090
+ name: string;
1091
+ /** Optional description */
1092
+ description?: string;
1093
+ }
1094
+ /** Interface describing a rule or constraint for verification */
1095
+ interface VerifiableDescriptor {
1096
+ id: string;
1097
+ description: string;
1098
+ eventTypes?: string | string[];
1099
+ contract?: {
1100
+ behavior: string;
1101
+ examples: Array<{
1102
+ given: string;
1103
+ when: string;
1104
+ then: string;
1105
+ }>;
1106
+ invariants: string[];
1107
+ ruleId: string;
1108
+ };
1109
+ }
1110
+ /** Registry-like interface for verification */
1111
+ interface VerifiableRegistry {
1112
+ getAllRules(): VerifiableDescriptor[];
1113
+ getAllConstraints(): VerifiableDescriptor[];
1114
+ getRuleIds(): string[];
1115
+ getConstraintIds(): string[];
1116
+ }
1117
+
1118
+ /**
1119
+ * Expectations DSL — Core
1120
+ *
1121
+ * Behavioral declarations for Praxis rules. Instead of writing test
1122
+ * assertions, you declare what behaviors you expect from your system.
1123
+ *
1124
+ * @example
1125
+ * ```ts
1126
+ * import { expectBehavior, ExpectationSet, verify } from '@plures/praxis/expectations';
1127
+ *
1128
+ * const expectations = new ExpectationSet({ name: 'settings' });
1129
+ *
1130
+ * expectations.add(
1131
+ * expectBehavior('settings-saved-toast')
1132
+ * .onlyWhen('settings.diff is non-empty')
1133
+ * .never('when settings panel opens without changes')
1134
+ * .never('when save fails')
1135
+ * .always('includes which settings changed')
1136
+ * );
1137
+ *
1138
+ * const report = verify(registry, expectations);
1139
+ * ```
1140
+ */
1141
+
1142
+ /**
1143
+ * A behavioral expectation declaration.
1144
+ *
1145
+ * Chainable API for declaring conditions under which a behavior
1146
+ * should or should not occur.
1147
+ */
1148
+ declare class Expectation {
1149
+ readonly name: string;
1150
+ private _conditions;
1151
+ constructor(name: string);
1152
+ /**
1153
+ * Declare that this behavior should ONLY occur when a condition is true.
1154
+ * If the condition is false, the behavior should NOT occur.
1155
+ */
1156
+ onlyWhen(condition: string): this;
1157
+ /**
1158
+ * Declare that this behavior should NEVER occur under a given condition.
1159
+ */
1160
+ never(condition: string): this;
1161
+ /**
1162
+ * Declare that this behavior should ALWAYS have a certain property.
1163
+ */
1164
+ always(condition: string): this;
1165
+ /** Get all declared conditions. */
1166
+ get conditions(): ReadonlyArray<ExpectationCondition>;
1167
+ }
1168
+ /**
1169
+ * A collection of expectations for a specific domain.
1170
+ */
1171
+ declare class ExpectationSet {
1172
+ readonly name: string;
1173
+ readonly description: string;
1174
+ private _expectations;
1175
+ constructor(options: ExpectationSetOptions);
1176
+ /** Add an expectation to the set. */
1177
+ add(expectation: Expectation): this;
1178
+ /** Get all expectations in this set. */
1179
+ get expectations(): ReadonlyArray<Expectation>;
1180
+ /** Number of expectations. */
1181
+ get size(): number;
1182
+ }
1183
+ /**
1184
+ * Create a new behavioral expectation.
1185
+ *
1186
+ * @example
1187
+ * ```ts
1188
+ * expectBehavior('settings-saved-toast')
1189
+ * .onlyWhen('settings.diff is non-empty')
1190
+ * .never('when save fails')
1191
+ * .always('includes which settings changed');
1192
+ * ```
1193
+ */
1194
+ declare function expectBehavior(name: string): Expectation;
1195
+ /**
1196
+ * Verify expectations against a rule registry.
1197
+ *
1198
+ * Walks the rule graph to determine if expectations are satisfied,
1199
+ * violated, or unverifiable given the registered rules and contracts.
1200
+ */
1201
+ declare function verify(registry: VerifiableRegistry, expectations: ExpectationSet): VerificationReport;
1202
+ /**
1203
+ * Format a verification report as human-readable text.
1204
+ */
1205
+ declare function formatVerificationReport(report: VerificationReport): string;
1206
+
1207
+ /**
1208
+ * Decision Ledger — Graph Analysis Engine
1209
+ *
1210
+ * Builds the fact dependency graph and analyzes the rule registry
1211
+ * for dead rules, unreachable states, shadowed rules, contradictions,
1212
+ * and gaps in behavioral expectations.
1213
+ */
1214
+
1215
+ /**
1216
+ * Build the fact dependency graph from a registry.
1217
+ *
1218
+ * This runs each rule with synthetic probe events to discover which facts
1219
+ * it reads from state and which facts it produces. For static analysis we
1220
+ * inspect rule metadata, contracts, event types, and probe execution.
1221
+ */
1222
+ declare function analyzeDependencyGraph<TContext = unknown>(registry: PraxisRegistry<TContext>): DependencyGraph;
1223
+ /**
1224
+ * Find rules that can never fire given known event types.
1225
+ */
1226
+ declare function findDeadRules<TContext = unknown>(registry: PraxisRegistry<TContext>, knownEventTypes: string[]): DeadRule[];
1227
+ /**
1228
+ * Find fact combinations that no rule sequence can produce.
1229
+ *
1230
+ * This checks pairs of facts where each fact can be produced individually
1231
+ * but no single rule or chain produces both. This is conservative —
1232
+ * if two facts are produced by completely independent rules that never
1233
+ * fire together, they form an unreachable state pair.
1234
+ */
1235
+ declare function findUnreachableStates<TContext = unknown>(registry: PraxisRegistry<TContext>): UnreachableState[];
1236
+ /**
1237
+ * Find rules where another rule with same event types always produces
1238
+ * a superset of the facts.
1239
+ */
1240
+ declare function findShadowedRules<TContext = unknown>(registry: PraxisRegistry<TContext>): ShadowedRule[];
1241
+ /**
1242
+ * Find rules that produce facts with the same tag but potentially conflicting
1243
+ * payloads under the same event conditions.
1244
+ */
1245
+ declare function findContradictions<TContext = unknown>(registry: PraxisRegistry<TContext>): Contradiction[];
1246
+ /**
1247
+ * Find expectations that have no covering rule or only partial coverage.
1248
+ */
1249
+ declare function findGaps<TContext = unknown>(registry: PraxisRegistry<TContext>, expectations: ExpectationSet): Gap[];
1250
+
1251
+ /**
1252
+ * Decision Ledger — Fact Derivation Tracing
1253
+ *
1254
+ * Trace how facts are derived through chains of rule firings,
1255
+ * and analyze the impact of removing a fact from the system.
1256
+ */
1257
+
1258
+ /**
1259
+ * Trace how a fact was derived through the rule chain.
1260
+ *
1261
+ * Starting from the fact tag, walks backward through the dependency graph
1262
+ * to find the full derivation chain: event → rule A → fact X → rule B → fact Y
1263
+ *
1264
+ * Uses the engine's current state to identify which rules actually fired.
1265
+ */
1266
+ declare function traceDerivation<TContext = unknown>(factTag: string, _engine: LogicEngine<TContext>, registry: PraxisRegistry<TContext>): DerivationChain;
1267
+ /**
1268
+ * Trace the impact of removing a fact from the system.
1269
+ *
1270
+ * Returns which rules would stop firing and which downstream facts
1271
+ * would disappear if the given fact were removed.
1272
+ */
1273
+ declare function traceImpact<TContext = unknown>(factTag: string, registry: PraxisRegistry<TContext>): ImpactReport;
1274
+
1275
+ /**
1276
+ * Decision Ledger — Contract Verification
1277
+ *
1278
+ * Goes beyond simple contract existence checking to actually run rules
1279
+ * against their contract examples, verify invariants, and cross-reference
1280
+ * fact dependencies between contracts.
1281
+ */
1282
+
1283
+ /**
1284
+ * Actually run a rule's implementation against each contract example's
1285
+ * `given` state and verify the output matches `then`.
1286
+ *
1287
+ * This is deeper than contract existence checking — it executes the rule.
1288
+ */
1289
+ declare function verifyContractExamples<TContext = unknown>(rule: RuleDescriptor<TContext>, contract: Contract): ContractVerificationResult;
1290
+ /**
1291
+ * Check that stated invariants hold across all rules.
1292
+ *
1293
+ * For each rule with a contract, check if the invariants are consistent
1294
+ * with the rule's behavior description and examples.
1295
+ */
1296
+ declare function verifyInvariants<TContext = unknown>(registry: PraxisRegistry<TContext>): InvariantCheck[];
1297
+ /**
1298
+ * Find rules with contracts that don't cover all code paths.
1299
+ *
1300
+ * Analyzes contract examples to find:
1301
+ * - Rules with only happy-path examples (no error cases)
1302
+ * - Rules with no boundary condition examples
1303
+ * - Rules that handle multiple event types but only have examples for some
1304
+ */
1305
+ declare function findContractGaps<TContext = unknown>(registry: PraxisRegistry<TContext>): ContractCoverageGap[];
1306
+ /**
1307
+ * Find contracts that reference facts from other rules and verify
1308
+ * those producing rules actually exist.
1309
+ */
1310
+ declare function crossReferenceContracts<TContext = unknown>(registry: PraxisRegistry<TContext>): CrossReference[];
1311
+
1312
+ /**
1313
+ * Decision Ledger — Actionable Fix Suggestions
1314
+ *
1315
+ * For each finding from the analyzer, generates concrete,
1316
+ * actionable suggestions with optional code skeletons.
1317
+ */
1318
+
1319
+ /**
1320
+ * Generate a suggestion for any type of finding.
1321
+ */
1322
+ declare function suggest(finding: DeadRule | UnreachableState | ShadowedRule | Contradiction | Gap | ContractCoverageGap, type: FindingType): Suggestion;
1323
+ /**
1324
+ * Generate suggestions for all findings at once.
1325
+ */
1326
+ declare function suggestAll(findings: {
1327
+ deadRules?: DeadRule[];
1328
+ gaps?: Gap[];
1329
+ contradictions?: Contradiction[];
1330
+ unreachableStates?: UnreachableState[];
1331
+ shadowedRules?: ShadowedRule[];
1332
+ contractGaps?: ContractCoverageGap[];
1333
+ }): Suggestion[];
1334
+
1335
+ /**
1336
+ * Decision Ledger — Report Generation
1337
+ *
1338
+ * Generates the full analysis report, human-readable markdown,
1339
+ * CI-friendly output, and diffs between analysis runs.
1340
+ */
1341
+
1342
+ /**
1343
+ * Generate the full analysis report.
1344
+ *
1345
+ * This is the main entry point for the Decision Ledger analyzer.
1346
+ * It runs all analyses and produces a comprehensive report.
1347
+ */
1348
+ declare function generateLedger<TContext = unknown>(registry: PraxisRegistry<TContext>, engine: LogicEngine<TContext>, expectations?: ExpectationSet): AnalysisReport;
1349
+ /**
1350
+ * Format an analysis report as human-readable markdown.
1351
+ */
1352
+ declare function formatLedger(report: AnalysisReport): string;
1353
+ /**
1354
+ * Format report as CI-friendly output with warnings and errors.
1355
+ */
1356
+ declare function formatBuildOutput(report: AnalysisReport): string;
1357
+ /**
1358
+ * Diff two analysis reports to find what changed between them.
1359
+ */
1360
+ declare function diffLedgers(before: AnalysisReport, after: AnalysisReport): LedgerDiff;
1361
+
792
1362
  /**
793
1363
  * Praxis Schema Loader (Common/Browser Compatible)
794
1364
  *
@@ -3507,296 +4077,117 @@ declare function resizeEvent(width: number, height: number): PraxisEvent;
3507
4077
  *
3508
4078
  * ## Measuring Completeness
3509
4079
  *
3510
- * ### Quantitative Metrics
3511
- * - **Rule Coverage**: (domain `if` branches in Praxis) / (total domain `if` branches)
3512
- * - **Constraint Coverage**: (data invariants in Praxis) / (total data invariants)
3513
- * - **Contract Coverage**: (rules with contracts) / (rules that need contracts)
3514
- * - **Context Coverage**: (state fields wired to context) / (state fields rules need)
3515
- * - **Event Coverage**: (state transitions with events) / (state transitions that matter)
3516
- *
3517
- * ### Qualitative Indicators
3518
- * - Can you change a business rule by editing ONE rule definition? (single source of truth)
3519
- * - Can you test a business rule without rendering UI? (Praxis engine is headless)
3520
- * - Can you explain every business rule to a PM by reading the registry? (self-documenting)
3521
- * - Does the PraxisPanel show all active concerns? (observable)
3522
- *
3523
- * ## The Completeness Score
3524
- *
3525
- * ```
3526
- * Score = (
3527
- * rulesCovered / totalDomainBranches * 40 + // Rules are king (40%)
3528
- * constraintsCovered / totalInvariants * 20 + // Invariants matter (20%)
3529
- * contractsCovered / rulesNeedingContracts * 15 + // Contracts prevent bugs (15%)
3530
- * contextFieldsCovered / totalNeeded * 15 + // Context = visibility (15%)
3531
- * eventsCovered / totalTransitions * 10 // Events = reactivity (10%)
3532
- * )
3533
- * ```
3534
- *
3535
- * 90+ = Complete | 70-89 = Good | 50-69 = Partial | <50 = Incomplete
3536
- */
3537
- interface LogicBranch {
3538
- /** Source file + line */
3539
- location: string;
3540
- /** The condition expression */
3541
- condition: string;
3542
- /** Classification */
3543
- kind: 'domain' | 'invariant' | 'ui' | 'transport' | 'wiring' | 'transform';
3544
- /** If domain/invariant: the Praxis rule/constraint that covers it, or null */
3545
- coveredBy: string | null;
3546
- /** Human note */
3547
- note?: string;
3548
- }
3549
- interface StateField {
3550
- /** Store or source name */
3551
- source: string;
3552
- /** Field path */
3553
- field: string;
3554
- /** Whether it's in the Praxis context */
3555
- inContext: boolean;
3556
- /** Whether any rule references it */
3557
- usedByRule: boolean;
3558
- }
3559
- interface StateTransition {
3560
- /** What changes */
3561
- description: string;
3562
- /** The Praxis event tag, or null if missing */
3563
- eventTag: string | null;
3564
- /** Source location */
3565
- location: string;
3566
- }
3567
- interface CompletenessReport {
3568
- /** Overall score (0-100) */
3569
- score: number;
3570
- /** Rating */
3571
- rating: 'complete' | 'good' | 'partial' | 'incomplete';
3572
- rules: {
3573
- total: number;
3574
- covered: number;
3575
- uncovered: LogicBranch[];
3576
- };
3577
- constraints: {
3578
- total: number;
3579
- covered: number;
3580
- uncovered: LogicBranch[];
3581
- };
3582
- contracts: {
3583
- total: number;
3584
- withContracts: number;
3585
- missing: string[];
3586
- };
3587
- context: {
3588
- total: number;
3589
- covered: number;
3590
- missing: StateField[];
3591
- };
3592
- events: {
3593
- total: number;
3594
- covered: number;
3595
- missing: StateTransition[];
3596
- };
3597
- }
3598
- interface CompletenessConfig {
3599
- /** Minimum score to pass (default: 90) */
3600
- threshold?: number;
3601
- /** Whether to throw on failure (for CI) */
3602
- strict?: boolean;
3603
- }
3604
- /**
3605
- * Run a completeness audit against a Praxis registry and app manifest.
3606
- *
3607
- * The manifest is a developer-authored declaration of all logic branches,
3608
- * state fields, and state transitions in the app. The auditor checks which
3609
- * ones are covered by Praxis.
3610
- */
3611
- declare function auditCompleteness(manifest: {
3612
- branches: LogicBranch[];
3613
- stateFields: StateField[];
3614
- transitions: StateTransition[];
3615
- rulesNeedingContracts: string[];
3616
- }, registryRuleIds: string[], registryConstraintIds: string[], rulesWithContracts: string[], config?: CompletenessConfig): CompletenessReport;
3617
- /**
3618
- * Format a completeness report as human-readable text.
3619
- */
3620
- declare function formatReport(report: CompletenessReport): string;
3621
-
3622
- /**
3623
- * Expectations DSL — Types
3624
- *
3625
- * Types for declaring behavioral expectations about rules.
3626
- * Expectations replace traditional tests with behavioral declarations.
3627
- */
3628
- /** A condition under which a behavior should or should not occur. */
3629
- interface ExpectationCondition {
3630
- /** Human-readable condition description */
3631
- description: string;
3632
- /** Type of expectation */
3633
- type: 'onlyWhen' | 'never' | 'always';
3634
- }
3635
- /** Verification status for a single expectation condition. */
3636
- type ConditionStatus = 'satisfied' | 'violated' | 'unverifiable';
3637
- /** Detailed result for a single condition check. */
3638
- interface ConditionResult {
3639
- condition: ExpectationCondition;
3640
- status: ConditionStatus;
3641
- /** Explanation of how the condition was verified or why it couldn't be */
3642
- explanation: string;
3643
- /** Related rule IDs that informed this check */
3644
- relatedRules: string[];
3645
- }
3646
- /** Verification result for a single Expectation. */
3647
- interface ExpectationResult {
3648
- /** The expectation name/ID */
3649
- name: string;
3650
- /** Overall status: satisfied if ALL conditions pass */
3651
- status: 'satisfied' | 'violated' | 'partial';
3652
- /** Per-condition results */
3653
- conditions: ConditionResult[];
3654
- /** Edge cases discovered */
3655
- edgeCases: string[];
3656
- /** Suggested mitigations for violated/partial expectations */
3657
- mitigations: string[];
3658
- }
3659
- /** Full verification report for an ExpectationSet. */
3660
- interface VerificationReport {
3661
- /** Set name */
3662
- setName: string;
3663
- /** Timestamp of verification */
3664
- timestamp: string;
3665
- /** Overall status: satisfied if ALL expectations are satisfied */
3666
- status: 'satisfied' | 'violated' | 'partial';
3667
- /** Per-expectation results */
3668
- expectations: ExpectationResult[];
3669
- /** Summary stats */
3670
- summary: {
3671
- total: number;
3672
- satisfied: number;
3673
- violated: number;
3674
- partial: number;
3675
- };
3676
- /** All edge cases found across all expectations */
3677
- allEdgeCases: string[];
3678
- /** All mitigations suggested */
3679
- allMitigations: string[];
3680
- }
3681
- /** Options for creating an ExpectationSet */
3682
- interface ExpectationSetOptions {
3683
- /** Name/domain for this set of expectations */
3684
- name: string;
3685
- /** Optional description */
3686
- description?: string;
3687
- }
3688
- /** Interface describing a rule or constraint for verification */
3689
- interface VerifiableDescriptor {
3690
- id: string;
3691
- description: string;
3692
- eventTypes?: string | string[];
3693
- contract?: {
3694
- behavior: string;
3695
- examples: Array<{
3696
- given: string;
3697
- when: string;
3698
- then: string;
3699
- }>;
3700
- invariants: string[];
3701
- ruleId: string;
3702
- };
3703
- }
3704
- /** Registry-like interface for verification */
3705
- interface VerifiableRegistry {
3706
- getAllRules(): VerifiableDescriptor[];
3707
- getAllConstraints(): VerifiableDescriptor[];
3708
- getRuleIds(): string[];
3709
- getConstraintIds(): string[];
3710
- }
3711
-
3712
- /**
3713
- * Expectations DSL — Core
3714
- *
3715
- * Behavioral declarations for Praxis rules. Instead of writing test
3716
- * assertions, you declare what behaviors you expect from your system.
3717
- *
3718
- * @example
3719
- * ```ts
3720
- * import { expectBehavior, ExpectationSet, verify } from '@plures/praxis/expectations';
4080
+ * ### Quantitative Metrics
4081
+ * - **Rule Coverage**: (domain `if` branches in Praxis) / (total domain `if` branches)
4082
+ * - **Constraint Coverage**: (data invariants in Praxis) / (total data invariants)
4083
+ * - **Contract Coverage**: (rules with contracts) / (rules that need contracts)
4084
+ * - **Context Coverage**: (state fields wired to context) / (state fields rules need)
4085
+ * - **Event Coverage**: (state transitions with events) / (state transitions that matter)
3721
4086
  *
3722
- * const expectations = new ExpectationSet({ name: 'settings' });
4087
+ * ### Qualitative Indicators
4088
+ * - Can you change a business rule by editing ONE rule definition? (single source of truth)
4089
+ * - Can you test a business rule without rendering UI? (Praxis engine is headless)
4090
+ * - Can you explain every business rule to a PM by reading the registry? (self-documenting)
4091
+ * - Does the PraxisPanel show all active concerns? (observable)
3723
4092
  *
3724
- * expectations.add(
3725
- * expectBehavior('settings-saved-toast')
3726
- * .onlyWhen('settings.diff is non-empty')
3727
- * .never('when settings panel opens without changes')
3728
- * .never('when save fails')
3729
- * .always('includes which settings changed')
3730
- * );
4093
+ * ## The Completeness Score
3731
4094
  *
3732
- * const report = verify(registry, expectations);
3733
4095
  * ```
3734
- */
3735
-
3736
- /**
3737
- * A behavioral expectation declaration.
4096
+ * Score = (
4097
+ * rulesCovered / totalDomainBranches * 40 + // Rules are king (40%)
4098
+ * constraintsCovered / totalInvariants * 20 + // Invariants matter (20%)
4099
+ * contractsCovered / rulesNeedingContracts * 15 + // Contracts prevent bugs (15%)
4100
+ * contextFieldsCovered / totalNeeded * 15 + // Context = visibility (15%)
4101
+ * eventsCovered / totalTransitions * 10 // Events = reactivity (10%)
4102
+ * )
4103
+ * ```
3738
4104
  *
3739
- * Chainable API for declaring conditions under which a behavior
3740
- * should or should not occur.
4105
+ * 90+ = Complete | 70-89 = Good | 50-69 = Partial | <50 = Incomplete
3741
4106
  */
3742
- declare class Expectation {
3743
- readonly name: string;
3744
- private _conditions;
3745
- constructor(name: string);
3746
- /**
3747
- * Declare that this behavior should ONLY occur when a condition is true.
3748
- * If the condition is false, the behavior should NOT occur.
3749
- */
3750
- onlyWhen(condition: string): this;
3751
- /**
3752
- * Declare that this behavior should NEVER occur under a given condition.
3753
- */
3754
- never(condition: string): this;
3755
- /**
3756
- * Declare that this behavior should ALWAYS have a certain property.
3757
- */
3758
- always(condition: string): this;
3759
- /** Get all declared conditions. */
3760
- get conditions(): ReadonlyArray<ExpectationCondition>;
4107
+ interface LogicBranch {
4108
+ /** Source file + line */
4109
+ location: string;
4110
+ /** The condition expression */
4111
+ condition: string;
4112
+ /** Classification */
4113
+ kind: 'domain' | 'invariant' | 'ui' | 'transport' | 'wiring' | 'transform';
4114
+ /** If domain/invariant: the Praxis rule/constraint that covers it, or null */
4115
+ coveredBy: string | null;
4116
+ /** Human note */
4117
+ note?: string;
3761
4118
  }
3762
- /**
3763
- * A collection of expectations for a specific domain.
3764
- */
3765
- declare class ExpectationSet {
3766
- readonly name: string;
3767
- readonly description: string;
3768
- private _expectations;
3769
- constructor(options: ExpectationSetOptions);
3770
- /** Add an expectation to the set. */
3771
- add(expectation: Expectation): this;
3772
- /** Get all expectations in this set. */
3773
- get expectations(): ReadonlyArray<Expectation>;
3774
- /** Number of expectations. */
3775
- get size(): number;
4119
+ interface StateField {
4120
+ /** Store or source name */
4121
+ source: string;
4122
+ /** Field path */
4123
+ field: string;
4124
+ /** Whether it's in the Praxis context */
4125
+ inContext: boolean;
4126
+ /** Whether any rule references it */
4127
+ usedByRule: boolean;
4128
+ }
4129
+ interface StateTransition {
4130
+ /** What changes */
4131
+ description: string;
4132
+ /** The Praxis event tag, or null if missing */
4133
+ eventTag: string | null;
4134
+ /** Source location */
4135
+ location: string;
4136
+ }
4137
+ interface CompletenessReport {
4138
+ /** Overall score (0-100) */
4139
+ score: number;
4140
+ /** Rating */
4141
+ rating: 'complete' | 'good' | 'partial' | 'incomplete';
4142
+ rules: {
4143
+ total: number;
4144
+ covered: number;
4145
+ uncovered: LogicBranch[];
4146
+ };
4147
+ constraints: {
4148
+ total: number;
4149
+ covered: number;
4150
+ uncovered: LogicBranch[];
4151
+ };
4152
+ contracts: {
4153
+ total: number;
4154
+ withContracts: number;
4155
+ missing: string[];
4156
+ };
4157
+ context: {
4158
+ total: number;
4159
+ covered: number;
4160
+ missing: StateField[];
4161
+ };
4162
+ events: {
4163
+ total: number;
4164
+ covered: number;
4165
+ missing: StateTransition[];
4166
+ };
4167
+ }
4168
+ interface CompletenessConfig {
4169
+ /** Minimum score to pass (default: 90) */
4170
+ threshold?: number;
4171
+ /** Whether to throw on failure (for CI) */
4172
+ strict?: boolean;
3776
4173
  }
3777
4174
  /**
3778
- * Create a new behavioral expectation.
3779
- *
3780
- * @example
3781
- * ```ts
3782
- * expectBehavior('settings-saved-toast')
3783
- * .onlyWhen('settings.diff is non-empty')
3784
- * .never('when save fails')
3785
- * .always('includes which settings changed');
3786
- * ```
3787
- */
3788
- declare function expectBehavior(name: string): Expectation;
3789
- /**
3790
- * Verify expectations against a rule registry.
4175
+ * Run a completeness audit against a Praxis registry and app manifest.
3791
4176
  *
3792
- * Walks the rule graph to determine if expectations are satisfied,
3793
- * violated, or unverifiable given the registered rules and contracts.
4177
+ * The manifest is a developer-authored declaration of all logic branches,
4178
+ * state fields, and state transitions in the app. The auditor checks which
4179
+ * ones are covered by Praxis.
3794
4180
  */
3795
- declare function verify(registry: VerifiableRegistry, expectations: ExpectationSet): VerificationReport;
4181
+ declare function auditCompleteness(manifest: {
4182
+ branches: LogicBranch[];
4183
+ stateFields: StateField[];
4184
+ transitions: StateTransition[];
4185
+ rulesNeedingContracts: string[];
4186
+ }, registryRuleIds: string[], registryConstraintIds: string[], rulesWithContracts: string[], config?: CompletenessConfig): CompletenessReport;
3796
4187
  /**
3797
- * Format a verification report as human-readable text.
4188
+ * Format a completeness report as human-readable text.
3798
4189
  */
3799
- declare function formatVerificationReport(report: VerificationReport): string;
4190
+ declare function formatReport(report: CompletenessReport): string;
3800
4191
 
3801
4192
  /**
3802
4193
  * Praxis Rules Factory — Types
@@ -4117,4 +4508,295 @@ declare function formatGate(config?: PredefinedGateConfig): PraxisModule<GateCon
4117
4508
  */
4118
4509
  declare function expectationGate(config?: PredefinedGateConfig): PraxisModule<GateContext>;
4119
4510
 
4120
- export { AcknowledgeContractGap, type ActivityState, type Actor, ActorManager, Assumption, BehaviorLedger, type BranchRulesConfig, CHRONICLE_PATHS, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, type Chronicle, ChronicleContext, type ChronicleEdge, type ChronicleEvent, type ChronicleNode, type ChronicleSpan, type ChronosMcpTools, type ChronosSearchParams, type ChronosTraceParams, type CompletenessConfig, type CompletenessReport, ComponentDefinition, type ConditionResult, type ConditionStatus, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, Contract, ContractAdded, ContractGapAcknowledged, ContractMissing, ContractUpdated, ContractValidated, type DataRulesConfig, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EdgeType, type EventDefinition, type EventStreamEntry, Expectation, type ExpectationCondition, type ExpectationResult, ExpectationSet, type ExpectationSetOptions, type FactDefinition, type FormRulesConfig, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type GateConfig, type GateState, type GateStatus, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type InputRulesConfig, type LedgerEntry, type LedgerEntryStatus, type LifecycleState, type LoaderOptions, type LoaderResult, type LogicBranch, LogicDefinition, LogicEngine, type McpToolResult, MissingArtifact, ModelDefinition, type NavigationRulesConfig, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PluresDbChronicle, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, type PraxisDiff, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type PredefinedGateConfig, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type SanitizationType, type SemverContractConfig, type SemverReport, Severity, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateField, type StateMachineDoc, type StateTransition, type StoredSchema, type TauriAppConfig, type TauriBridge, type TauriCommand, type TauriEvent, type TauriFS, type TauriFileEntry, type TauriMenuItem, type TauriNotification, type TauriNotificationOptions, type TauriPlugin, type TauriPraxisAdapter, type TauriSecurityConfig, type TauriTray, type TauriUpdateConfig, type TauriUpdateInfo, type TauriWindowConfig, type ToastRulesConfig, type TraceDirection, type TransitionDoc, type UIContext, type UnifiedApp, type UnifiedAppConfig, UnsubscribeFn$1 as UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, ValidateContracts, type ValidateOptions, ValidationReport, ValidationResult, type VerifiableDescriptor, type VerifiableRegistry, type VerificationReport, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, auditCompleteness, branchRules, canvasToMermaid, canvasToSchema, canvasToYaml, commitFromState, createBehaviorLedger, createCanvasEditor, createChronicle, createChronosMcpTools, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUIModule, createUnifiedApp, createUnumAdapter, dataRules, defineConstraint, defineEvent, defineFact, defineGate, defineModule, defineRule, dirtyGuardRule, errorDisplayRule, expectBehavior, expectationGate, filterEvents, filterFacts, findEvent, findFact, formRules, formatGate, formatReport, formatValidationReport, formatValidationReportJSON, formatValidationReportSARIF, formatVerificationReport, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, initGateRule, inputRules, lintGate, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, loadingGateRule, mustBeInitializedConstraint, navigationRequest, navigationRules, noInteractionWhileLoadingConstraint, offlineIndicatorRule, registerSchema, resizeEvent, schemaToCanvas, semverContract, toastRules, uiModule, uiStateChanged, validateContracts, validateForGeneration, validateWithGuardian, verify, viewportRule };
4511
+ /**
4512
+ * Project Chronicle — Core Event Store
4513
+ *
4514
+ * Records project lifecycle events (rule registrations, contract changes,
4515
+ * gate transitions, build events, etc.) as a queryable, append-only log.
4516
+ *
4517
+ * This is the development-lifecycle counterpart to runtime Chronos:
4518
+ * where runtime Chronos records "user typed, rule fired, fact emitted",
4519
+ * project-level Chronos records "rule registered, contract updated,
4520
+ * gate opened, completeness score changed."
4521
+ */
4522
+ /** The kind of project lifecycle event. */
4523
+ type ProjectEventKind = 'rule' | 'contract' | 'expectation' | 'gate' | 'build' | 'fact';
4524
+ /**
4525
+ * A single project lifecycle event.
4526
+ *
4527
+ * Immutable once recorded — the chronicle is append-only.
4528
+ */
4529
+ interface ProjectEvent {
4530
+ /** Event kind (rule, contract, expectation, gate, build, fact). */
4531
+ kind: ProjectEventKind;
4532
+ /**
4533
+ * Action that occurred.
4534
+ * Examples: 'registered', 'modified', 'removed', 'satisfied', 'violated',
4535
+ * 'opened', 'closed', 'blocked', 'audit-complete', 'introduced', 'deprecated'.
4536
+ */
4537
+ action: string;
4538
+ /** The subject (rule id, contract id, gate name, fact tag, etc.). */
4539
+ subject: string;
4540
+ /** Unix ms timestamp. */
4541
+ timestamp: number;
4542
+ /** Arbitrary metadata for this event. */
4543
+ metadata: Record<string, unknown>;
4544
+ /** Optional before/after diff for modifications. */
4545
+ diff?: {
4546
+ before: unknown;
4547
+ after: unknown;
4548
+ };
4549
+ }
4550
+ /** Options for creating a ProjectChronicle. */
4551
+ interface ProjectChronicleOptions {
4552
+ /** Maximum events to retain (0 = unlimited, default 10_000). */
4553
+ maxEvents?: number;
4554
+ /** Optional clock function (for testing). */
4555
+ now?: () => number;
4556
+ }
4557
+ /**
4558
+ * In-memory, append-only chronicle of project lifecycle events.
4559
+ *
4560
+ * Thread-safe for single-threaded JS; immutable snapshots via `getEvents()`.
4561
+ */
4562
+ declare class ProjectChronicle {
4563
+ private events;
4564
+ private readonly maxEvents;
4565
+ private readonly now;
4566
+ constructor(options?: ProjectChronicleOptions);
4567
+ /**
4568
+ * Record a project event. Returns the recorded event (with timestamp filled in).
4569
+ */
4570
+ record(event: Omit<ProjectEvent, 'timestamp'> & {
4571
+ timestamp?: number;
4572
+ }): ProjectEvent;
4573
+ recordRuleRegistered(ruleId: string, meta?: Record<string, unknown>): ProjectEvent;
4574
+ recordRuleModified(ruleId: string, diff: {
4575
+ before: unknown;
4576
+ after: unknown;
4577
+ }, meta?: Record<string, unknown>): ProjectEvent;
4578
+ recordRuleRemoved(ruleId: string, meta?: Record<string, unknown>): ProjectEvent;
4579
+ recordContractAdded(contractId: string, meta?: Record<string, unknown>): ProjectEvent;
4580
+ recordContractModified(contractId: string, diff: {
4581
+ before: unknown;
4582
+ after: unknown;
4583
+ }, meta?: Record<string, unknown>): ProjectEvent;
4584
+ recordExpectationSatisfied(name: string, meta?: Record<string, unknown>): ProjectEvent;
4585
+ recordExpectationViolated(name: string, meta?: Record<string, unknown>): ProjectEvent;
4586
+ recordGateTransition(gateName: string, from: string, to: string, meta?: Record<string, unknown>): ProjectEvent;
4587
+ recordBuildAudit(score: number, delta: number, meta?: Record<string, unknown>): ProjectEvent;
4588
+ recordFactIntroduced(factTag: string, meta?: Record<string, unknown>): ProjectEvent;
4589
+ recordFactDeprecated(factTag: string, meta?: Record<string, unknown>): ProjectEvent;
4590
+ /** Return a shallow copy of all events. */
4591
+ getEvents(): ProjectEvent[];
4592
+ /** Total number of recorded events. */
4593
+ get size(): number;
4594
+ /** Clear all events (primarily for testing). */
4595
+ clear(): void;
4596
+ }
4597
+ /**
4598
+ * Create a new ProjectChronicle instance.
4599
+ */
4600
+ declare function createProjectChronicle(options?: ProjectChronicleOptions): ProjectChronicle;
4601
+
4602
+ /**
4603
+ * Timeline — Queryable view over ProjectChronicle events
4604
+ *
4605
+ * Provides filtering, range queries, subject history, and behavioral deltas.
4606
+ */
4607
+
4608
+ /** Filter criteria for timeline queries. All fields are optional (AND logic). */
4609
+ interface TimelineFilter {
4610
+ /** Filter by event kind(s). */
4611
+ kind?: ProjectEventKind | ProjectEventKind[];
4612
+ /** Filter by action string(s). */
4613
+ action?: string | string[];
4614
+ /** Filter by subject (exact match or array). */
4615
+ subject?: string | string[];
4616
+ /** Only events at or after this timestamp (inclusive). */
4617
+ since?: number;
4618
+ /** Only events at or before this timestamp (inclusive). */
4619
+ until?: number;
4620
+ }
4621
+ /** Summary of changes between two points in time. */
4622
+ interface BehavioralDelta {
4623
+ /** Time range of this delta. */
4624
+ from: number;
4625
+ to: number;
4626
+ /** Events within the range. */
4627
+ events: ProjectEvent[];
4628
+ /** Summary counts by kind. */
4629
+ summary: Record<ProjectEventKind, number>;
4630
+ /** Subjects that were added (first 'registered' / 'added' / 'introduced'). */
4631
+ added: string[];
4632
+ /** Subjects that were removed ('removed' / 'deprecated'). */
4633
+ removed: string[];
4634
+ /** Subjects that were modified. */
4635
+ modified: string[];
4636
+ }
4637
+ /**
4638
+ * Queryable timeline wrapping a ProjectChronicle.
4639
+ *
4640
+ * All query methods return new arrays — never the internal event store.
4641
+ */
4642
+ declare class Timeline {
4643
+ private readonly chronicle;
4644
+ constructor(chronicle: ProjectChronicle);
4645
+ /**
4646
+ * Query events with optional filtering.
4647
+ * Returns matching events sorted chronologically (oldest first).
4648
+ */
4649
+ getTimeline(filter?: TimelineFilter): ProjectEvent[];
4650
+ /**
4651
+ * Get all events since a timestamp (inclusive).
4652
+ */
4653
+ getEventsSince(timestamp: number): ProjectEvent[];
4654
+ /**
4655
+ * Compute a behavioral delta between two timestamps.
4656
+ */
4657
+ getDelta(from: number, to: number): BehavioralDelta;
4658
+ /**
4659
+ * Get full history for a specific subject (rule id, gate name, etc.).
4660
+ * Sorted chronologically.
4661
+ */
4662
+ getHistory(subjectId: string): ProjectEvent[];
4663
+ }
4664
+ /**
4665
+ * Create a Timeline for a given chronicle.
4666
+ */
4667
+ declare function createTimeline(chronicle: ProjectChronicle): Timeline;
4668
+
4669
+ /**
4670
+ * Auto-Recording Hooks — wire ProjectChronicle into PraxisRegistry & LogicEngine
4671
+ *
4672
+ * Opt-in: call `enableProjectChronicle(registry, engine)` to start recording.
4673
+ * The hooks use Proxy wrapping to intercept method calls without modifying
4674
+ * the original classes.
4675
+ */
4676
+
4677
+ /** Handle returned by enableProjectChronicle for cleanup. */
4678
+ interface ChronicleHandle {
4679
+ /** The underlying chronicle being written to. */
4680
+ chronicle: ProjectChronicle;
4681
+ /** Disconnect all hooks (restores original methods). */
4682
+ disconnect: () => void;
4683
+ }
4684
+ /** Options for enabling project chronicle hooks. */
4685
+ interface EnableChronicleOptions {
4686
+ /** Provide an existing chronicle (otherwise a new one is created). */
4687
+ chronicle?: ProjectChronicle;
4688
+ /** Record engine step results (fact production/retraction). Default: true. */
4689
+ recordSteps?: boolean;
4690
+ /** Record constraint check results. Default: true. */
4691
+ recordConstraints?: boolean;
4692
+ }
4693
+ /**
4694
+ * Enable project-level chronicle recording.
4695
+ *
4696
+ * Wraps registry's `registerRule`, `registerModule` and engine's `step`,
4697
+ * `checkConstraints` methods to automatically record events.
4698
+ *
4699
+ * @returns A handle with the chronicle and a `disconnect()` to undo all hooks.
4700
+ *
4701
+ * @example
4702
+ * ```ts
4703
+ * const { chronicle, disconnect } = enableProjectChronicle(registry, engine);
4704
+ * registry.registerRule(myRule); // auto-recorded
4705
+ * engine.step(events); // step results auto-recorded
4706
+ * console.log(chronicle.size); // number of events recorded
4707
+ * disconnect(); // stop recording
4708
+ * ```
4709
+ */
4710
+ declare function enableProjectChronicle<TContext = unknown>(registry: PraxisRegistry<TContext>, engine: LogicEngine<TContext>, options?: EnableChronicleOptions): ChronicleHandle;
4711
+ /**
4712
+ * Record a completeness audit result into the chronicle.
4713
+ *
4714
+ * Standalone utility — call after `auditCompleteness()`.
4715
+ */
4716
+ declare function recordAudit(chronicle: ProjectChronicle, report: CompletenessReport, previousScore?: number): void;
4717
+
4718
+ /**
4719
+ * Behavioral Diff Engine
4720
+ *
4721
+ * Compares registry snapshots, contract coverage, and expectation status
4722
+ * to produce human-readable deltas and conventional commit messages.
4723
+ *
4724
+ * This is the foundation for "commit from state" — describing WHAT changed
4725
+ * in behavioral terms rather than file terms.
4726
+ */
4727
+
4728
+ /** Snapshot of a registry's state (used for before/after comparison). */
4729
+ interface RegistrySnapshot {
4730
+ rules: Map<string, RuleDescriptor> | Array<RuleDescriptor>;
4731
+ constraints: Map<string, ConstraintDescriptor> | Array<ConstraintDescriptor>;
4732
+ }
4733
+ /** Diff result for registries. */
4734
+ interface RegistryDiff {
4735
+ rulesAdded: string[];
4736
+ rulesRemoved: string[];
4737
+ rulesModified: string[];
4738
+ constraintsAdded: string[];
4739
+ constraintsRemoved: string[];
4740
+ constraintsModified: string[];
4741
+ }
4742
+ /** Contract coverage snapshot. */
4743
+ interface ContractCoverage {
4744
+ /** rule id → has contract */
4745
+ coverage: Map<string, boolean> | Record<string, boolean>;
4746
+ }
4747
+ /** Diff result for contract coverage. */
4748
+ interface ContractDiff {
4749
+ contractsAdded: string[];
4750
+ contractsRemoved: string[];
4751
+ coverageBefore: number;
4752
+ coverageAfter: number;
4753
+ }
4754
+ /** Expectation satisfaction snapshot. */
4755
+ interface ExpectationSnapshot {
4756
+ /** expectation name → satisfied */
4757
+ expectations: Map<string, boolean> | Record<string, boolean>;
4758
+ }
4759
+ /** Diff result for expectations. */
4760
+ interface ExpectationDiff {
4761
+ newlySatisfied: string[];
4762
+ newlyViolated: string[];
4763
+ unchanged: string[];
4764
+ }
4765
+ /** Full behavioral diff combining all dimensions. */
4766
+ interface FullBehavioralDiff {
4767
+ registry: RegistryDiff;
4768
+ contracts: ContractDiff;
4769
+ expectations: ExpectationDiff;
4770
+ }
4771
+ /**
4772
+ * Compare two registry snapshots.
4773
+ *
4774
+ * Detects rules/constraints that were added, removed, or modified
4775
+ * (description or contract changed).
4776
+ */
4777
+ declare function diffRegistries(before: RegistrySnapshot, after: RegistrySnapshot): RegistryDiff;
4778
+ /**
4779
+ * Compare contract coverage between two snapshots.
4780
+ */
4781
+ declare function diffContracts(before: ContractCoverage, after: ContractCoverage): ContractDiff;
4782
+ /**
4783
+ * Compare expectation satisfaction between two snapshots.
4784
+ */
4785
+ declare function diffExpectations(before: ExpectationSnapshot, after: ExpectationSnapshot): ExpectationDiff;
4786
+ /**
4787
+ * Format a RegistryDiff as a human-readable delta string.
4788
+ */
4789
+ declare function formatDelta(diff: RegistryDiff): string;
4790
+ /**
4791
+ * Generate a conventional commit message from a registry diff.
4792
+ *
4793
+ * Uses the same logic as `commitFromState` in `project/` but works
4794
+ * directly from a RegistryDiff.
4795
+ */
4796
+ declare function formatCommitMessage(diff: RegistryDiff): string;
4797
+ /**
4798
+ * Aggregate multiple diffs into release notes.
4799
+ */
4800
+ declare function formatReleaseNotes(diffs: RegistryDiff[]): string;
4801
+
4802
+ export { AcknowledgeContractGap, type ActivityState, type Actor, ActorManager, type AnalysisReport, Assumption, BehaviorLedger, type BehavioralDelta, type BranchRulesConfig, CHRONICLE_PATHS, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, type Chronicle, ChronicleContext, type ChronicleEdge, type ChronicleEvent, type ChronicleHandle, type ChronicleNode, type ChronicleSpan, type ChronosMcpTools, type ChronosSearchParams, type ChronosTraceParams, type CompletenessConfig, type CompletenessReport, ComponentDefinition, type ConditionResult, type ConditionStatus, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, Contract, ContractAdded, type ContractCoverage, type ContractCoverageGap, type ContractDiff, ContractGapAcknowledged, ContractMissing, ContractUpdated, ContractValidated, type ContractVerificationResult, type Contradiction, type CrossReference, type DataRulesConfig, type DeadRule, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type DependencyEdge, type DependencyGraph, type DerivationChain, type DerivationStep, type EdgeType, type EnableChronicleOptions, type EventDefinition, type EventStreamEntry, type ExampleVerification, Expectation, type ExpectationCondition, type ExpectationDiff, type ExpectationResult, ExpectationSet, type ExpectationSetOptions, type ExpectationSnapshot, type FactDefinition, type FactNode, type FindingType, type FormRulesConfig, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type FullBehavioralDiff, type Gap, type GateConfig, type GateState, type GateStatus, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type ImpactReport, type InputRulesConfig, type InvariantCheck, type LedgerDiff, type LedgerDiffEntry, type LedgerEntry, type LedgerEntryStatus, type LifecycleState, type LoaderOptions, type LoaderResult, type LogicBranch, LogicDefinition, LogicEngine, type McpToolResult, MissingArtifact, ModelDefinition, type NavigationRulesConfig, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PluresDbChronicle, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, type PraxisDiff, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type PredefinedGateConfig, ProjectChronicle, type ProjectChronicleOptions, type ProjectEvent, type ProjectEventKind, type RegistryDiff, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistrySnapshot, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type SanitizationType, type SemverContractConfig, type SemverReport, Severity, type ShadowedRule, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateField, type StateMachineDoc, type StateTransition, type StoredSchema, type Suggestion, type TauriAppConfig, type TauriBridge, type TauriCommand, type TauriEvent, type TauriFS, type TauriFileEntry, type TauriMenuItem, type TauriNotification, type TauriNotificationOptions, type TauriPlugin, type TauriPraxisAdapter, type TauriSecurityConfig, type TauriTray, type TauriUpdateConfig, type TauriUpdateInfo, type TauriWindowConfig, Timeline, type TimelineFilter, type ToastRulesConfig, type TraceDirection, type TransitionDoc, type UIContext, type UnifiedApp, type UnifiedAppConfig, type UnreachableState, UnsubscribeFn$1 as UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, ValidateContracts, type ValidateOptions, ValidationReport, ValidationResult, type VerifiableDescriptor, type VerifiableRegistry, type VerificationReport, analyzeDependencyGraph, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, auditCompleteness, branchRules, canvasToMermaid, canvasToSchema, canvasToYaml, commitFromState, createBehaviorLedger, createCanvasEditor, createChronicle, createChronosMcpTools, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createProjectChronicle, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimeline, createTimerActor, createUIModule, createUnifiedApp, createUnumAdapter, crossReferenceContracts, dataRules, defineConstraint, defineEvent, defineFact, defineGate, defineModule, defineRule, diffContracts, diffExpectations, diffLedgers, diffRegistries, dirtyGuardRule, enableProjectChronicle, errorDisplayRule, expectBehavior, expectationGate, filterEvents, filterFacts, findContractGaps, findContradictions, findDeadRules, findEvent, findFact, findGaps, findShadowedRules, findUnreachableStates, formRules, formatCommitMessage as formatBehavioralCommit, formatBuildOutput, formatDelta, formatGate, formatLedger, formatReleaseNotes, formatReport, formatValidationReport, formatValidationReportJSON, formatValidationReportSARIF, formatVerificationReport, generateDocs, generateId, generateLedger, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, initGateRule, inputRules, lintGate, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, loadingGateRule, mustBeInitializedConstraint, navigationRequest, navigationRules, noInteractionWhileLoadingConstraint, offlineIndicatorRule, recordAudit, registerSchema, resizeEvent, schemaToCanvas, semverContract, suggest, suggestAll, toastRules, traceDerivation, traceImpact, uiModule, uiStateChanged, validateContracts, validateForGeneration, validateWithGuardian, verify, verifyContractExamples, verifyInvariants, viewportRule };