@plures/praxis 1.2.0 → 1.2.10

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 (63) hide show
  1. package/README.md +10 -96
  2. package/dist/browser/{adapter-TM4IS5KT.js → adapter-CIMBGDC7.js} +5 -3
  3. package/dist/browser/{chunk-LE2ZJYFC.js → chunk-K377RW4V.js} +76 -0
  4. package/dist/{node/chunk-JQ64KMLN.js → browser/chunk-MBVHLOU2.js} +12 -1
  5. package/dist/browser/index.d.ts +32 -5
  6. package/dist/browser/index.js +15 -7
  7. package/dist/browser/integrations/svelte.d.ts +2 -2
  8. package/dist/browser/integrations/svelte.js +1 -1
  9. package/dist/browser/{reactive-engine.svelte-C9OpcTHf.d.ts → reactive-engine.svelte-9aS0kTa8.d.ts} +136 -1
  10. package/dist/node/{adapter-K6DOX6XS.js → adapter-75ISSMWD.js} +5 -3
  11. package/dist/node/chunk-5RH7UAQC.js +486 -0
  12. package/dist/{browser/chunk-JQ64KMLN.js → node/chunk-MBVHLOU2.js} +12 -1
  13. package/dist/node/{chunk-LE2ZJYFC.js → chunk-PRPQO6R5.js} +3 -72
  14. package/dist/node/chunk-R2PSBPKQ.js +150 -0
  15. package/dist/node/chunk-WZ6B3LZ6.js +638 -0
  16. package/dist/node/cli/index.cjs +2316 -832
  17. package/dist/node/cli/index.js +18 -0
  18. package/dist/node/components/index.d.cts +3 -2
  19. package/dist/node/components/index.d.ts +3 -2
  20. package/dist/node/index.cjs +620 -38
  21. package/dist/node/index.d.cts +259 -5
  22. package/dist/node/index.d.ts +259 -5
  23. package/dist/node/index.js +55 -65
  24. package/dist/node/integrations/svelte.cjs +76 -0
  25. package/dist/node/integrations/svelte.d.cts +2 -2
  26. package/dist/node/integrations/svelte.d.ts +2 -2
  27. package/dist/node/integrations/svelte.js +2 -1
  28. package/dist/node/{reactive-engine.svelte-1M4m_C_v.d.cts → reactive-engine.svelte-BFIZfawz.d.cts} +199 -1
  29. package/dist/node/{reactive-engine.svelte-ChNFn4Hj.d.ts → reactive-engine.svelte-CRNqHlbv.d.ts} +199 -1
  30. package/dist/node/reverse-W7THPV45.js +193 -0
  31. package/dist/node/{terminal-adapter-CWka-yL8.d.ts → terminal-adapter-B-UK_Vdz.d.ts} +28 -3
  32. package/dist/node/{terminal-adapter-CDzxoLKR.d.cts → terminal-adapter-BQSIF5bf.d.cts} +28 -3
  33. package/dist/node/validate-CNHUULQE.js +180 -0
  34. package/docs/core/pluresdb-integration.md +15 -15
  35. package/docs/decision-ledger/BEHAVIOR_LEDGER.md +225 -0
  36. package/docs/decision-ledger/DecisionLedger.tla +180 -0
  37. package/docs/decision-ledger/IMPLEMENTATION_SUMMARY.md +217 -0
  38. package/docs/decision-ledger/LATEST.md +166 -0
  39. package/docs/guides/cicd-pipeline.md +142 -0
  40. package/package.json +2 -2
  41. package/src/__tests__/cli-validate.test.ts +197 -0
  42. package/src/__tests__/decision-ledger.test.ts +485 -0
  43. package/src/__tests__/reverse-generator.test.ts +189 -0
  44. package/src/__tests__/scanner.test.ts +215 -0
  45. package/src/cli/commands/reverse.ts +289 -0
  46. package/src/cli/commands/validate.ts +264 -0
  47. package/src/cli/index.ts +47 -0
  48. package/src/core/pluresdb/adapter.ts +45 -2
  49. package/src/core/rules.ts +133 -0
  50. package/src/decision-ledger/README.md +400 -0
  51. package/src/decision-ledger/REVERSE_ENGINEERING.md +484 -0
  52. package/src/decision-ledger/facts-events.ts +121 -0
  53. package/src/decision-ledger/index.ts +70 -0
  54. package/src/decision-ledger/ledger.ts +246 -0
  55. package/src/decision-ledger/logic-ledger.ts +158 -0
  56. package/src/decision-ledger/reverse-generator.ts +426 -0
  57. package/src/decision-ledger/scanner.ts +506 -0
  58. package/src/decision-ledger/types.ts +247 -0
  59. package/src/decision-ledger/validation.ts +336 -0
  60. package/src/dsl/index.ts +13 -2
  61. package/src/index.browser.ts +2 -0
  62. package/src/index.ts +36 -0
  63. package/src/integrations/pluresdb.ts +14 -2
@@ -1,11 +1,12 @@
1
1
  import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-Qek7ebBl.cjs';
2
2
  export { g as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, f as PraxisStepFn, c as PraxisStepResult } from './protocol-Qek7ebBl.cjs';
3
- import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as RuleFn, e as ConstraintFn, f as PraxisModule } from './reactive-engine.svelte-1M4m_C_v.cjs';
4
- export { h as ConstraintId, i as PraxisEngineOptions, a as ReactiveEngineOptions, R as ReactiveLogicEngine, g as RuleId, j as createPraxisEngine, c as createReactiveEngine } from './reactive-engine.svelte-1M4m_C_v.cjs';
5
- import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-CDzxoLKR.cjs';
6
- export { C as CommandExecutor, I as InMemoryPraxisDB, g as PluresDBAdapterConfig, f as PluresDBInstance, i as PluresDBPraxisAdapter, T as TerminalAdapter, d as TerminalAdapterOptions, a as TerminalExecutionResult, b as TerminalNodeState, h as createInMemoryDB, e as createMockExecutor, j as createPluresDB, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-CDzxoLKR.cjs';
3
+ import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as RuleFn, e as Contract, f as ConstraintFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-BFIZfawz.cjs';
4
+ export { i as ConstraintId, p as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, a as ReactiveEngineOptions, R as ReactiveLogicEngine, o as Reference, h as RuleId, k as createPraxisEngine, c as createReactiveEngine, l as defineContract, m as getContract, n as isContract } from './reactive-engine.svelte-BFIZfawz.cjs';
5
+ import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-BQSIF5bf.cjs';
6
+ export { C as CommandExecutor, I as InMemoryPraxisDB, g as PluresDBAdapterConfig, f as PluresDBInstance, j as PluresDBPraxisAdapter, h as PraxisLocalFirstOptions, T as TerminalAdapter, d as TerminalAdapterOptions, a as TerminalExecutionResult, b as TerminalNodeState, i as createInMemoryDB, e as createMockExecutor, k as createPluresDB, l as createPraxisLocalFirst, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-BQSIF5bf.cjs';
7
7
  import { PraxisSchema, ValidationResult, ModelDefinition, FieldDefinition, ComponentDefinition, LogicDefinition } from './schema.cjs';
8
8
  export { NodeBindings, NodeDefinition, OrchestrationDefinition, TerminalNodeProps, ValidationError, createSchemaTemplate, validateSchema } from './schema.cjs';
9
+ import '@plures/pluresdb/local-first';
9
10
 
10
11
  /**
11
12
  * Praxis Reactive Logic Engine
@@ -440,6 +441,7 @@ interface DefineRuleOptions<TContext = unknown> {
440
441
  id: string;
441
442
  description: string;
442
443
  impl: RuleFn<TContext>;
444
+ contract?: Contract;
443
445
  meta?: Record<string, unknown>;
444
446
  }
445
447
  /**
@@ -466,6 +468,7 @@ interface DefineConstraintOptions<TContext = unknown> {
466
468
  id: string;
467
469
  description: string;
468
470
  impl: ConstraintFn<TContext>;
471
+ contract?: Contract;
469
472
  meta?: Record<string, unknown>;
470
473
  }
471
474
  /**
@@ -530,6 +533,257 @@ declare function findFact<TTag extends string, TPayload>(facts: PraxisFact[], de
530
533
  payload: TPayload;
531
534
  }) | undefined;
532
535
 
536
+ /**
537
+ * Fact: ContractMissing
538
+ *
539
+ * Indicates that a rule or constraint is missing contract artifacts.
540
+ */
541
+ declare const ContractMissing: FactDefinition<"ContractMissing", {
542
+ ruleId: string;
543
+ missing: MissingArtifact[];
544
+ severity: Severity;
545
+ message?: string;
546
+ }>;
547
+ /**
548
+ * Fact: ContractValidated
549
+ *
550
+ * Indicates that a rule or constraint has been validated and has a complete contract.
551
+ */
552
+ declare const ContractValidated: FactDefinition<"ContractValidated", {
553
+ ruleId: string;
554
+ version: string;
555
+ timestamp: string;
556
+ }>;
557
+ /**
558
+ * Event: ACKNOWLEDGE_CONTRACT_GAP
559
+ *
560
+ * Acknowledges a known contract gap with justification.
561
+ */
562
+ declare const AcknowledgeContractGap: EventDefinition<"ACKNOWLEDGE_CONTRACT_GAP", {
563
+ ruleId: string;
564
+ missing: MissingArtifact[];
565
+ justification: string;
566
+ expiresAt?: string;
567
+ }>;
568
+ /**
569
+ * Event: VALIDATE_CONTRACTS
570
+ *
571
+ * Triggers validation of all registered contracts.
572
+ */
573
+ declare const ValidateContracts: EventDefinition<"VALIDATE_CONTRACTS", {
574
+ strict?: boolean;
575
+ }>;
576
+ /**
577
+ * Fact: ContractGapAcknowledged
578
+ *
579
+ * Records that a contract gap has been acknowledged.
580
+ */
581
+ declare const ContractGapAcknowledged: FactDefinition<"ContractGapAcknowledged", {
582
+ ruleId: string;
583
+ missing: MissingArtifact[];
584
+ justification: string;
585
+ acknowledgedAt: string;
586
+ expiresAt?: string;
587
+ }>;
588
+ /**
589
+ * Event: CONTRACT_ADDED
590
+ *
591
+ * Emitted when a contract is added to a rule or constraint.
592
+ */
593
+ declare const ContractAdded: EventDefinition<"CONTRACT_ADDED", {
594
+ ruleId: string;
595
+ version: string;
596
+ }>;
597
+ /**
598
+ * Event: CONTRACT_UPDATED
599
+ *
600
+ * Emitted when a contract is updated.
601
+ */
602
+ declare const ContractUpdated: EventDefinition<"CONTRACT_UPDATED", {
603
+ ruleId: string;
604
+ previousVersion: string;
605
+ newVersion: string;
606
+ }>;
607
+
608
+ /**
609
+ * Decision Ledger - Validation
610
+ *
611
+ * Contract validation logic for rules and constraints.
612
+ */
613
+
614
+ /**
615
+ * Options for contract validation.
616
+ */
617
+ interface ValidateOptions {
618
+ /** Treat missing contracts as errors instead of warnings */
619
+ strict?: boolean;
620
+ /** Severity for missing contracts (default: 'warning') */
621
+ missingSeverity?: Severity;
622
+ /** Severity for incomplete contracts (default: 'warning') */
623
+ incompleteSeverity?: Severity;
624
+ /** Required contract fields */
625
+ requiredFields?: Array<'behavior' | 'examples' | 'invariants'>;
626
+ /** Optional index of artifacts for test/spec presence */
627
+ artifactIndex?: ArtifactIndex;
628
+ }
629
+ /**
630
+ * Artifact index for contract compliance checks.
631
+ */
632
+ interface ArtifactIndex {
633
+ /** Rule IDs that have associated tests */
634
+ tests?: Set<string>;
635
+ /** Rule IDs that have associated specs (e.g., TLA+) */
636
+ spec?: Set<string>;
637
+ /** Optional mapping of rule IDs to contract versions (for drift detection) */
638
+ contractVersions?: Map<string, string>;
639
+ }
640
+ /**
641
+ * Validate contracts in a registry.
642
+ *
643
+ * @param registry The registry to validate
644
+ * @param options Validation options
645
+ * @returns Validation report
646
+ */
647
+ declare function validateContracts<TContext = unknown>(registry: PraxisRegistry<TContext>, options?: ValidateOptions): ValidationReport;
648
+ /**
649
+ * Format validation report as human-readable text.
650
+ *
651
+ * @param report The validation report
652
+ * @returns Formatted string
653
+ */
654
+ declare function formatValidationReport(report: ValidationReport): string;
655
+ /**
656
+ * Format validation report as JSON.
657
+ *
658
+ * @param report The validation report
659
+ * @returns JSON string
660
+ */
661
+ declare function formatValidationReportJSON(report: ValidationReport): string;
662
+ /**
663
+ * Format validation report as SARIF (Static Analysis Results Interchange Format).
664
+ *
665
+ * @param report The validation report
666
+ * @returns SARIF JSON string
667
+ */
668
+ declare function formatValidationReportSARIF(report: ValidationReport): string;
669
+
670
+ /**
671
+ * Decision Ledger - Ledger Storage
672
+ *
673
+ * Immutable, append-only ledger for tracking contract history.
674
+ */
675
+
676
+ /**
677
+ * Status of a ledger entry.
678
+ */
679
+ type LedgerEntryStatus = 'active' | 'superseded' | 'deprecated';
680
+ /**
681
+ * A single entry in the behavior ledger.
682
+ */
683
+ interface LedgerEntry {
684
+ /** Unique identifier for this ledger entry */
685
+ id: string;
686
+ /** Timestamp of entry creation */
687
+ timestamp: string;
688
+ /** Status of this entry */
689
+ status: LedgerEntryStatus;
690
+ /** Author or system that created this entry */
691
+ author: string;
692
+ /** The contract being recorded */
693
+ contract: Contract;
694
+ /** ID of the entry this supersedes (if any) */
695
+ supersedes?: string;
696
+ /** Reason for this entry (e.g., 'initial', 'assumption-revised', 'behavior-updated') */
697
+ reason?: string;
698
+ }
699
+ /**
700
+ * Immutable, append-only behavior ledger.
701
+ */
702
+ declare class BehaviorLedger {
703
+ private entries;
704
+ private entryMap;
705
+ /**
706
+ * Append a new entry to the ledger.
707
+ *
708
+ * @param entry The entry to append
709
+ * @throws Error if entry ID already exists
710
+ */
711
+ append(entry: LedgerEntry): void;
712
+ /**
713
+ * Get an entry by ID.
714
+ *
715
+ * @param id The entry ID
716
+ * @returns The entry, or undefined if not found
717
+ */
718
+ getEntry(id: string): LedgerEntry | undefined;
719
+ /**
720
+ * Get all entries (in order of append) with current status.
721
+ *
722
+ * @returns Array of all entries with current status from the map
723
+ */
724
+ getAllEntries(): LedgerEntry[];
725
+ /**
726
+ * Get entries for a specific rule ID.
727
+ *
728
+ * @param ruleId The rule ID
729
+ * @returns Array of entries for this rule with current status
730
+ */
731
+ getEntriesForRule(ruleId: string): LedgerEntry[];
732
+ /**
733
+ * Get the latest active entry for a rule.
734
+ *
735
+ * @param ruleId The rule ID
736
+ * @returns The latest active entry, or undefined if none
737
+ */
738
+ getLatestEntry(ruleId: string): LedgerEntry | undefined;
739
+ /**
740
+ * Get all active assumptions across all entries.
741
+ *
742
+ * @returns Map of assumption ID to assumption
743
+ */
744
+ getActiveAssumptions(): Map<string, Assumption>;
745
+ /**
746
+ * Find assumptions that impact a specific artifact type.
747
+ *
748
+ * @param impactType The artifact type ('spec', 'tests', 'code')
749
+ * @returns Array of assumptions
750
+ */
751
+ findAssumptionsByImpact(impactType: 'spec' | 'tests' | 'code'): Assumption[];
752
+ /**
753
+ * Get ledger statistics.
754
+ */
755
+ getStats(): {
756
+ totalEntries: number;
757
+ activeEntries: number;
758
+ supersededEntries: number;
759
+ deprecatedEntries: number;
760
+ uniqueRules: number;
761
+ };
762
+ /**
763
+ * Export ledger as JSON.
764
+ *
765
+ * @returns JSON string with current entry status
766
+ */
767
+ toJSON(): string;
768
+ /**
769
+ * Import ledger from JSON.
770
+ *
771
+ * Note: The JSON must contain entries in the order they were originally appended.
772
+ * If a superseding entry appears before the entry it supersedes, the superseding
773
+ * logic will not work correctly. The toJSON method preserves this order.
774
+ *
775
+ * @param json The JSON string
776
+ * @returns A new BehaviorLedger instance
777
+ */
778
+ static fromJSON(json: string): BehaviorLedger;
779
+ }
780
+ /**
781
+ * Create a new behavior ledger.
782
+ *
783
+ * @returns A new empty ledger
784
+ */
785
+ declare function createBehaviorLedger(): BehaviorLedger;
786
+
533
787
  /**
534
788
  * Praxis Schema Loader (Common/Browser Compatible)
535
789
  *
@@ -2798,4 +3052,4 @@ declare function attachAllIntegrations<TContext = unknown>(engine: LogicEngine<T
2798
3052
  dispose: () => void;
2799
3053
  }>;
2800
3054
 
2801
- export { type ActivityState, type Actor, ActorManager, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EventDefinition, type EventStreamEntry, type FactDefinition, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type LifecycleState, type LoaderOptions, type LoaderResult, LogicDefinition, LogicEngine, ModelDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateMachineDoc, 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 TransitionDoc, type UnifiedApp, type UnifiedAppConfig, UnsubscribeFn$1 as UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, ValidationResult, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createCanvasEditor, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateForGeneration, validateWithGuardian };
3055
+ export { AcknowledgeContractGap, type ActivityState, type Actor, ActorManager, Assumption, BehaviorLedger, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, Contract, ContractAdded, ContractGapAcknowledged, ContractMissing, ContractUpdated, ContractValidated, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EventDefinition, type EventStreamEntry, type FactDefinition, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type LedgerEntry, type LedgerEntryStatus, type LifecycleState, type LoaderOptions, type LoaderResult, LogicDefinition, LogicEngine, MissingArtifact, ModelDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, Severity, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateMachineDoc, 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 TransitionDoc, 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, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createBehaviorLedger, createCanvasEditor, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, formatValidationReport, formatValidationReportJSON, formatValidationReportSARIF, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateContracts, validateForGeneration, validateWithGuardian };
@@ -1,11 +1,12 @@
1
1
  import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-Qek7ebBl.js';
2
2
  export { g as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, f as PraxisStepFn, c as PraxisStepResult } from './protocol-Qek7ebBl.js';
3
- import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as RuleFn, e as ConstraintFn, f as PraxisModule } from './reactive-engine.svelte-ChNFn4Hj.js';
4
- export { h as ConstraintId, i as PraxisEngineOptions, a as ReactiveEngineOptions, R as ReactiveLogicEngine, g as RuleId, j as createPraxisEngine, c as createReactiveEngine } from './reactive-engine.svelte-ChNFn4Hj.js';
5
- import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-CWka-yL8.js';
6
- export { C as CommandExecutor, I as InMemoryPraxisDB, g as PluresDBAdapterConfig, f as PluresDBInstance, i as PluresDBPraxisAdapter, T as TerminalAdapter, d as TerminalAdapterOptions, a as TerminalExecutionResult, b as TerminalNodeState, h as createInMemoryDB, e as createMockExecutor, j as createPluresDB, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-CWka-yL8.js';
3
+ import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as RuleFn, e as Contract, f as ConstraintFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-CRNqHlbv.js';
4
+ export { i as ConstraintId, p as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, a as ReactiveEngineOptions, R as ReactiveLogicEngine, o as Reference, h as RuleId, k as createPraxisEngine, c as createReactiveEngine, l as defineContract, m as getContract, n as isContract } from './reactive-engine.svelte-CRNqHlbv.js';
5
+ import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-B-UK_Vdz.js';
6
+ export { C as CommandExecutor, I as InMemoryPraxisDB, g as PluresDBAdapterConfig, f as PluresDBInstance, j as PluresDBPraxisAdapter, h as PraxisLocalFirstOptions, T as TerminalAdapter, d as TerminalAdapterOptions, a as TerminalExecutionResult, b as TerminalNodeState, i as createInMemoryDB, e as createMockExecutor, k as createPluresDB, l as createPraxisLocalFirst, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-B-UK_Vdz.js';
7
7
  import { PraxisSchema, ValidationResult, ModelDefinition, FieldDefinition, ComponentDefinition, LogicDefinition } from './schema.js';
8
8
  export { NodeBindings, NodeDefinition, OrchestrationDefinition, TerminalNodeProps, ValidationError, createSchemaTemplate, validateSchema } from './schema.js';
9
+ import '@plures/pluresdb/local-first';
9
10
 
10
11
  /**
11
12
  * Praxis Reactive Logic Engine
@@ -440,6 +441,7 @@ interface DefineRuleOptions<TContext = unknown> {
440
441
  id: string;
441
442
  description: string;
442
443
  impl: RuleFn<TContext>;
444
+ contract?: Contract;
443
445
  meta?: Record<string, unknown>;
444
446
  }
445
447
  /**
@@ -466,6 +468,7 @@ interface DefineConstraintOptions<TContext = unknown> {
466
468
  id: string;
467
469
  description: string;
468
470
  impl: ConstraintFn<TContext>;
471
+ contract?: Contract;
469
472
  meta?: Record<string, unknown>;
470
473
  }
471
474
  /**
@@ -530,6 +533,257 @@ declare function findFact<TTag extends string, TPayload>(facts: PraxisFact[], de
530
533
  payload: TPayload;
531
534
  }) | undefined;
532
535
 
536
+ /**
537
+ * Fact: ContractMissing
538
+ *
539
+ * Indicates that a rule or constraint is missing contract artifacts.
540
+ */
541
+ declare const ContractMissing: FactDefinition<"ContractMissing", {
542
+ ruleId: string;
543
+ missing: MissingArtifact[];
544
+ severity: Severity;
545
+ message?: string;
546
+ }>;
547
+ /**
548
+ * Fact: ContractValidated
549
+ *
550
+ * Indicates that a rule or constraint has been validated and has a complete contract.
551
+ */
552
+ declare const ContractValidated: FactDefinition<"ContractValidated", {
553
+ ruleId: string;
554
+ version: string;
555
+ timestamp: string;
556
+ }>;
557
+ /**
558
+ * Event: ACKNOWLEDGE_CONTRACT_GAP
559
+ *
560
+ * Acknowledges a known contract gap with justification.
561
+ */
562
+ declare const AcknowledgeContractGap: EventDefinition<"ACKNOWLEDGE_CONTRACT_GAP", {
563
+ ruleId: string;
564
+ missing: MissingArtifact[];
565
+ justification: string;
566
+ expiresAt?: string;
567
+ }>;
568
+ /**
569
+ * Event: VALIDATE_CONTRACTS
570
+ *
571
+ * Triggers validation of all registered contracts.
572
+ */
573
+ declare const ValidateContracts: EventDefinition<"VALIDATE_CONTRACTS", {
574
+ strict?: boolean;
575
+ }>;
576
+ /**
577
+ * Fact: ContractGapAcknowledged
578
+ *
579
+ * Records that a contract gap has been acknowledged.
580
+ */
581
+ declare const ContractGapAcknowledged: FactDefinition<"ContractGapAcknowledged", {
582
+ ruleId: string;
583
+ missing: MissingArtifact[];
584
+ justification: string;
585
+ acknowledgedAt: string;
586
+ expiresAt?: string;
587
+ }>;
588
+ /**
589
+ * Event: CONTRACT_ADDED
590
+ *
591
+ * Emitted when a contract is added to a rule or constraint.
592
+ */
593
+ declare const ContractAdded: EventDefinition<"CONTRACT_ADDED", {
594
+ ruleId: string;
595
+ version: string;
596
+ }>;
597
+ /**
598
+ * Event: CONTRACT_UPDATED
599
+ *
600
+ * Emitted when a contract is updated.
601
+ */
602
+ declare const ContractUpdated: EventDefinition<"CONTRACT_UPDATED", {
603
+ ruleId: string;
604
+ previousVersion: string;
605
+ newVersion: string;
606
+ }>;
607
+
608
+ /**
609
+ * Decision Ledger - Validation
610
+ *
611
+ * Contract validation logic for rules and constraints.
612
+ */
613
+
614
+ /**
615
+ * Options for contract validation.
616
+ */
617
+ interface ValidateOptions {
618
+ /** Treat missing contracts as errors instead of warnings */
619
+ strict?: boolean;
620
+ /** Severity for missing contracts (default: 'warning') */
621
+ missingSeverity?: Severity;
622
+ /** Severity for incomplete contracts (default: 'warning') */
623
+ incompleteSeverity?: Severity;
624
+ /** Required contract fields */
625
+ requiredFields?: Array<'behavior' | 'examples' | 'invariants'>;
626
+ /** Optional index of artifacts for test/spec presence */
627
+ artifactIndex?: ArtifactIndex;
628
+ }
629
+ /**
630
+ * Artifact index for contract compliance checks.
631
+ */
632
+ interface ArtifactIndex {
633
+ /** Rule IDs that have associated tests */
634
+ tests?: Set<string>;
635
+ /** Rule IDs that have associated specs (e.g., TLA+) */
636
+ spec?: Set<string>;
637
+ /** Optional mapping of rule IDs to contract versions (for drift detection) */
638
+ contractVersions?: Map<string, string>;
639
+ }
640
+ /**
641
+ * Validate contracts in a registry.
642
+ *
643
+ * @param registry The registry to validate
644
+ * @param options Validation options
645
+ * @returns Validation report
646
+ */
647
+ declare function validateContracts<TContext = unknown>(registry: PraxisRegistry<TContext>, options?: ValidateOptions): ValidationReport;
648
+ /**
649
+ * Format validation report as human-readable text.
650
+ *
651
+ * @param report The validation report
652
+ * @returns Formatted string
653
+ */
654
+ declare function formatValidationReport(report: ValidationReport): string;
655
+ /**
656
+ * Format validation report as JSON.
657
+ *
658
+ * @param report The validation report
659
+ * @returns JSON string
660
+ */
661
+ declare function formatValidationReportJSON(report: ValidationReport): string;
662
+ /**
663
+ * Format validation report as SARIF (Static Analysis Results Interchange Format).
664
+ *
665
+ * @param report The validation report
666
+ * @returns SARIF JSON string
667
+ */
668
+ declare function formatValidationReportSARIF(report: ValidationReport): string;
669
+
670
+ /**
671
+ * Decision Ledger - Ledger Storage
672
+ *
673
+ * Immutable, append-only ledger for tracking contract history.
674
+ */
675
+
676
+ /**
677
+ * Status of a ledger entry.
678
+ */
679
+ type LedgerEntryStatus = 'active' | 'superseded' | 'deprecated';
680
+ /**
681
+ * A single entry in the behavior ledger.
682
+ */
683
+ interface LedgerEntry {
684
+ /** Unique identifier for this ledger entry */
685
+ id: string;
686
+ /** Timestamp of entry creation */
687
+ timestamp: string;
688
+ /** Status of this entry */
689
+ status: LedgerEntryStatus;
690
+ /** Author or system that created this entry */
691
+ author: string;
692
+ /** The contract being recorded */
693
+ contract: Contract;
694
+ /** ID of the entry this supersedes (if any) */
695
+ supersedes?: string;
696
+ /** Reason for this entry (e.g., 'initial', 'assumption-revised', 'behavior-updated') */
697
+ reason?: string;
698
+ }
699
+ /**
700
+ * Immutable, append-only behavior ledger.
701
+ */
702
+ declare class BehaviorLedger {
703
+ private entries;
704
+ private entryMap;
705
+ /**
706
+ * Append a new entry to the ledger.
707
+ *
708
+ * @param entry The entry to append
709
+ * @throws Error if entry ID already exists
710
+ */
711
+ append(entry: LedgerEntry): void;
712
+ /**
713
+ * Get an entry by ID.
714
+ *
715
+ * @param id The entry ID
716
+ * @returns The entry, or undefined if not found
717
+ */
718
+ getEntry(id: string): LedgerEntry | undefined;
719
+ /**
720
+ * Get all entries (in order of append) with current status.
721
+ *
722
+ * @returns Array of all entries with current status from the map
723
+ */
724
+ getAllEntries(): LedgerEntry[];
725
+ /**
726
+ * Get entries for a specific rule ID.
727
+ *
728
+ * @param ruleId The rule ID
729
+ * @returns Array of entries for this rule with current status
730
+ */
731
+ getEntriesForRule(ruleId: string): LedgerEntry[];
732
+ /**
733
+ * Get the latest active entry for a rule.
734
+ *
735
+ * @param ruleId The rule ID
736
+ * @returns The latest active entry, or undefined if none
737
+ */
738
+ getLatestEntry(ruleId: string): LedgerEntry | undefined;
739
+ /**
740
+ * Get all active assumptions across all entries.
741
+ *
742
+ * @returns Map of assumption ID to assumption
743
+ */
744
+ getActiveAssumptions(): Map<string, Assumption>;
745
+ /**
746
+ * Find assumptions that impact a specific artifact type.
747
+ *
748
+ * @param impactType The artifact type ('spec', 'tests', 'code')
749
+ * @returns Array of assumptions
750
+ */
751
+ findAssumptionsByImpact(impactType: 'spec' | 'tests' | 'code'): Assumption[];
752
+ /**
753
+ * Get ledger statistics.
754
+ */
755
+ getStats(): {
756
+ totalEntries: number;
757
+ activeEntries: number;
758
+ supersededEntries: number;
759
+ deprecatedEntries: number;
760
+ uniqueRules: number;
761
+ };
762
+ /**
763
+ * Export ledger as JSON.
764
+ *
765
+ * @returns JSON string with current entry status
766
+ */
767
+ toJSON(): string;
768
+ /**
769
+ * Import ledger from JSON.
770
+ *
771
+ * Note: The JSON must contain entries in the order they were originally appended.
772
+ * If a superseding entry appears before the entry it supersedes, the superseding
773
+ * logic will not work correctly. The toJSON method preserves this order.
774
+ *
775
+ * @param json The JSON string
776
+ * @returns A new BehaviorLedger instance
777
+ */
778
+ static fromJSON(json: string): BehaviorLedger;
779
+ }
780
+ /**
781
+ * Create a new behavior ledger.
782
+ *
783
+ * @returns A new empty ledger
784
+ */
785
+ declare function createBehaviorLedger(): BehaviorLedger;
786
+
533
787
  /**
534
788
  * Praxis Schema Loader (Common/Browser Compatible)
535
789
  *
@@ -2798,4 +3052,4 @@ declare function attachAllIntegrations<TContext = unknown>(engine: LogicEngine<T
2798
3052
  dispose: () => void;
2799
3053
  }>;
2800
3054
 
2801
- export { type ActivityState, type Actor, ActorManager, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EventDefinition, type EventStreamEntry, type FactDefinition, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type LifecycleState, type LoaderOptions, type LoaderResult, LogicDefinition, LogicEngine, ModelDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateMachineDoc, 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 TransitionDoc, type UnifiedApp, type UnifiedAppConfig, UnsubscribeFn$1 as UnsubscribeFn, type UnumAdapter, type UnumAdapterConfig, type UnumChannel, type UnumIdentity, type UnumMessage, type UnumStore, ValidationResult, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createCanvasEditor, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateForGeneration, validateWithGuardian };
3055
+ export { AcknowledgeContractGap, type ActivityState, type Actor, ActorManager, Assumption, BehaviorLedger, type CanvasDocument, type CanvasEdge, type CanvasEdgeStyle, type CanvasEditorConfig, type CanvasNode, type CanvasNodeStyle, ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, Contract, ContractAdded, ContractGapAcknowledged, ContractMissing, ContractUpdated, ContractValidated, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EventDefinition, type EventStreamEntry, type FactDefinition, ReactiveLogicEngine as FrameworkAgnosticReactiveEngine, type ReactiveEngineOptions as FrameworkAgnosticReactiveEngineOptions, type GeneratedDoc, type GeneratedPluresDBFile, type GraphEdge, type GuardianError, type GuardianResult, type GuardianWarning, type LedgerEntry, type LedgerEntryStatus, type LifecycleState, type LoaderOptions, type LoaderResult, LogicDefinition, LogicEngine, MissingArtifact, ModelDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PraxisDB, PraxisDBStore, type PraxisDBStoreOptions, PraxisEvent, PraxisFact, PraxisModule, PraxisRegistry, PraxisSchema, PraxisSchemaRegistry, PraxisState, type RegistryGraph, RegistryIntrospector, type RegistrySchema, type RegistryStats, RuleDescriptor, RuleFn, type RuleNode, type RuleSchema, Severity, type StateChangeCallback, type StateDoc, type StateDocsConfig, StateDocsGenerator, type StateMachineDoc, 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 TransitionDoc, 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, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, canvasToMermaid, canvasToSchema, canvasToYaml, createBehaviorLedger, createCanvasEditor, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, filterEvents, filterFacts, findEvent, findFact, formatValidationReport, formatValidationReportJSON, formatValidationReportSARIF, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, registerSchema, schemaToCanvas, validateContracts, validateForGeneration, validateWithGuardian };