@plures/praxis 1.2.41 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/browser/{chunk-BBP2F7TT.js → chunk-MJK3IYTJ.js} +123 -5
  2. package/dist/browser/{chunk-FCEH7WMH.js → chunk-N63K4KWS.js} +1 -1
  3. package/dist/browser/{engine-65QDGCAN.js → engine-YIEGSX7U.js} +1 -1
  4. package/dist/browser/index.d.ts +2 -2
  5. package/dist/browser/index.js +10 -5
  6. package/dist/browser/integrations/svelte.d.ts +2 -2
  7. package/dist/browser/integrations/svelte.js +2 -2
  8. package/dist/browser/{reactive-engine.svelte-Cqd8Mod2.d.ts → reactive-engine.svelte-DjynI82A.d.ts} +83 -4
  9. package/dist/node/chunk-2IUFZBH3.js +87 -0
  10. package/dist/node/{chunk-WZ6B3LZ6.js → chunk-7CSWBDFL.js} +3 -56
  11. package/dist/node/{chunk-32YFEEML.js → chunk-7M3HV4XR.js} +4 -4
  12. package/dist/node/{chunk-PTH6MD6P.js → chunk-FWOXU4MM.js} +1 -1
  13. package/dist/node/{chunk-BBP2F7TT.js → chunk-KMJWAFZV.js} +128 -5
  14. package/dist/node/chunk-PGVSB6NR.js +59 -0
  15. package/dist/node/cli/index.cjs +1078 -211
  16. package/dist/node/cli/index.js +21 -2
  17. package/dist/node/cloud/index.d.cts +1 -1
  18. package/dist/node/cloud/index.d.ts +1 -1
  19. package/dist/node/{engine-7CXQV6RC.js → engine-FEN5IYZ5.js} +1 -1
  20. package/dist/node/index.cjs +1633 -59
  21. package/dist/node/index.d.cts +769 -5
  22. package/dist/node/index.d.ts +769 -5
  23. package/dist/node/index.js +1375 -45
  24. package/dist/node/integrations/svelte.cjs +123 -5
  25. package/dist/node/integrations/svelte.d.cts +3 -3
  26. package/dist/node/integrations/svelte.d.ts +3 -3
  27. package/dist/node/integrations/svelte.js +3 -3
  28. package/dist/node/{protocol-BocKczNv.d.ts → protocol-DcyGMmWY.d.cts} +7 -0
  29. package/dist/node/{protocol-BocKczNv.d.cts → protocol-DcyGMmWY.d.ts} +7 -0
  30. package/dist/node/{reactive-engine.svelte-CGe8SpVE.d.cts → reactive-engine.svelte-Cg0Yc2Hs.d.cts} +90 -6
  31. package/dist/node/{reactive-engine.svelte-D-xTDxT5.d.ts → reactive-engine.svelte-DekxqFu0.d.ts} +90 -6
  32. package/dist/node/{reverse-W7THPV45.js → reverse-YD3CWIGM.js} +3 -2
  33. package/dist/node/rules-4DAJ4Z4N.js +7 -0
  34. package/dist/node/server-SYZPDULV.js +361 -0
  35. package/dist/node/{validate-EN3M4FUR.js → validate-TQGVIG7G.js} +4 -3
  36. package/package.json +29 -3
  37. package/src/__tests__/engine-v2.test.ts +532 -0
  38. package/src/__tests__/expectations.test.ts +364 -0
  39. package/src/__tests__/factory.test.ts +426 -0
  40. package/src/__tests__/mcp-server.test.ts +310 -0
  41. package/src/__tests__/project.test.ts +396 -0
  42. package/src/cli/index.ts +28 -0
  43. package/src/core/completeness.ts +274 -0
  44. package/src/core/engine.ts +47 -5
  45. package/src/core/pluresdb/store.ts +9 -3
  46. package/src/core/protocol.ts +7 -0
  47. package/src/core/rule-result.ts +130 -0
  48. package/src/core/rules.ts +12 -5
  49. package/src/core/ui-rules.ts +340 -0
  50. package/src/expectations/expectations.ts +471 -0
  51. package/src/expectations/index.ts +29 -0
  52. package/src/expectations/types.ts +95 -0
  53. package/src/factory/factory.ts +634 -0
  54. package/src/factory/index.ts +27 -0
  55. package/src/factory/types.ts +64 -0
  56. package/src/index.ts +84 -0
  57. package/src/mcp/index.ts +33 -0
  58. package/src/mcp/server.ts +485 -0
  59. package/src/mcp/types.ts +161 -0
  60. package/src/project/index.ts +31 -0
  61. package/src/project/project.ts +423 -0
  62. package/src/project/types.ts +87 -0
  63. package/src/vite/completeness-plugin.ts +72 -0
  64. /package/dist/node/{chunk-R2PSBPKQ.js → chunk-TEMFJOIH.js} +0 -0
@@ -1,7 +1,7 @@
1
- import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-BocKczNv.js';
2
- export { f as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, g as PraxisStepFn, c as PraxisStepResult } from './protocol-BocKczNv.js';
3
- import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-D-xTDxT5.js';
4
- export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as createPraxisEngine, c as createReactiveEngine, n as defineContract, o as getContract, p as isContract } from './reactive-engine.svelte-D-xTDxT5.js';
1
+ import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-DcyGMmWY.js';
2
+ export { f as PRAXIS_PROTOCOL_VERSION, e as PraxisDiagnostics, d as PraxisStepConfig, g as PraxisStepFn, c as PraxisStepResult } from './protocol-DcyGMmWY.js';
3
+ import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as ConstraintFn, e as Contract, f as RuleFn, g as PraxisModule, M as MissingArtifact, S as Severity, V as ValidationReport, A as Assumption } from './reactive-engine.svelte-DekxqFu0.js';
4
+ export { h as ConstraintId, i as ContractGap, D as DefineContractOptions, E as Example, j as PraxisEngineOptions, R as ReactiveEngineOptions, a as ReactiveLogicEngine, k as Reference, l as RuleId, m as RuleResult, T as TypedRuleFn, n as createPraxisEngine, c as createReactiveEngine, o as defineContract, p as fact, q as getContract, r as isContract } from './reactive-engine.svelte-DekxqFu0.js';
5
5
  import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-CvIvgTo4.js';
6
6
  export { C as CommandExecutor, I as InMemoryPraxisDB, a as PluresDBAdapterConfig, b as PluresDBInstance, d as PluresDBPraxisAdapter, e as PraxisLocalFirstOptions, T as TerminalAdapter, f as TerminalAdapterOptions, g as TerminalExecutionResult, h as TerminalNodeState, i as createInMemoryDB, j as createMockExecutor, k as createPluresDB, l as createPraxisLocalFirst, c as createTerminalAdapter, r as runTerminalCommand } from './terminal-adapter-CvIvgTo4.js';
7
7
  import { PraxisSchema, ValidationResult, ModelDefinition, FieldDefinition, ComponentDefinition, LogicDefinition } from './schema.js';
@@ -3353,4 +3353,768 @@ declare function attachAllIntegrations<TContext = unknown>(engine: LogicEngine<T
3353
3353
  dispose: () => void;
3354
3354
  }>;
3355
3355
 
3356
- export { AcknowledgeContractGap, type ActivityState, type Actor, ActorManager, Assumption, BehaviorLedger, 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, ComponentDefinition, ConstraintDescriptor, ConstraintFn, type ConstraintNode, type ConstraintSchema, Contract, ContractAdded, ContractGapAcknowledged, ContractMissing, ContractUpdated, ContractValidated, type DefineConstraintOptions, type DefineModuleOptions, type DefineRuleOptions, type EdgeType, 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, type McpToolResult, MissingArtifact, ModelDefinition, PRAXIS_PATHS, type PluresDBAdapter, type PluresDBAdapterOptions, PluresDBGenerator, type PluresDBGeneratorOptions, PluresDbChronicle, 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 TraceDirection, 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, createChronicle, createChronosMcpTools, 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 };
3356
+ /**
3357
+ * Praxis UI Rules
3358
+ *
3359
+ * Lightweight, predefined UI-specific rules and constraints.
3360
+ * These govern UI behavior without muddying business logic rules.
3361
+ *
3362
+ * UI rules are separated from domain rules by convention:
3363
+ * - Domain rules: business decisions, data invariants, workflow logic
3364
+ * - UI rules: visibility, loading states, error display, navigation guards
3365
+ *
3366
+ * Ship predefined rules that apps can opt into. Every `if` in the UI
3367
+ * can be governed by Praxis — business rules stay clean, UI rules stay separate.
3368
+ */
3369
+
3370
+ /**
3371
+ * Standard UI state fields that UI rules can read from context.
3372
+ * Apps extend their context with these fields to enable UI rules.
3373
+ */
3374
+ interface UIContext {
3375
+ /** Whether the app is currently loading data */
3376
+ loading?: boolean;
3377
+ /** Current error message, if any */
3378
+ error?: string | null;
3379
+ /** Whether the app is in offline mode */
3380
+ offline?: boolean;
3381
+ /** Whether there are unsaved changes */
3382
+ dirty?: boolean;
3383
+ /** Current route/view name */
3384
+ route?: string;
3385
+ /** Whether the app has completed initialization */
3386
+ initialized?: boolean;
3387
+ /** Screen width category: 'mobile' | 'tablet' | 'desktop' */
3388
+ viewport?: 'mobile' | 'tablet' | 'desktop';
3389
+ /** Whether a modal/dialog is currently open */
3390
+ modalOpen?: boolean;
3391
+ /** Active panel/tab name */
3392
+ activePanel?: string | null;
3393
+ }
3394
+ /**
3395
+ * Loading gate: emits ui.loading-gate when data is loading.
3396
+ * UI components can subscribe to this fact to show loading indicators.
3397
+ */
3398
+ declare const loadingGateRule: RuleDescriptor<UIContext>;
3399
+ /**
3400
+ * Error display: emits ui.error-display with the error message.
3401
+ * Retracts when error clears.
3402
+ */
3403
+ declare const errorDisplayRule: RuleDescriptor<UIContext>;
3404
+ /**
3405
+ * Offline indicator: emits ui.offline-indicator when the app detects offline state.
3406
+ */
3407
+ declare const offlineIndicatorRule: RuleDescriptor<UIContext>;
3408
+ /**
3409
+ * Dirty guard: emits ui.unsaved-warning when there are unsaved changes.
3410
+ * Can be used to block navigation or show save prompts.
3411
+ */
3412
+ declare const dirtyGuardRule: RuleDescriptor<UIContext>;
3413
+ /**
3414
+ * Init gate: blocks UI interactions until app is initialized.
3415
+ */
3416
+ declare const initGateRule: RuleDescriptor<UIContext>;
3417
+ /**
3418
+ * Viewport-responsive: emits ui.viewport-class based on screen size.
3419
+ */
3420
+ declare const viewportRule: RuleDescriptor<UIContext>;
3421
+ /**
3422
+ * No interaction while loading: constraint that fails if actions are taken during loading.
3423
+ */
3424
+ declare const noInteractionWhileLoadingConstraint: ConstraintDescriptor<UIContext>;
3425
+ /**
3426
+ * Must be initialized: constraint that fails if app hasn't completed init.
3427
+ */
3428
+ declare const mustBeInitializedConstraint: ConstraintDescriptor<UIContext>;
3429
+ /**
3430
+ * The complete UI rules module.
3431
+ * Register this to get all predefined UI rules and constraints.
3432
+ *
3433
+ * @example
3434
+ * import { uiModule } from '@plures/praxis';
3435
+ * registry.registerModule(uiModule);
3436
+ */
3437
+ declare const uiModule: PraxisModule<UIContext>;
3438
+ /**
3439
+ * Create a customized UI module with only the rules you need.
3440
+ *
3441
+ * @example
3442
+ * const myUI = createUIModule({
3443
+ * rules: ['ui/loading-gate', 'ui/dirty-guard'],
3444
+ * constraints: ['ui/must-be-initialized'],
3445
+ * });
3446
+ * registry.registerModule(myUI);
3447
+ */
3448
+ declare function createUIModule<TContext extends UIContext>(options: {
3449
+ rules?: string[];
3450
+ constraints?: string[];
3451
+ extraRules?: RuleDescriptor<TContext>[];
3452
+ extraConstraints?: ConstraintDescriptor<TContext>[];
3453
+ }): PraxisModule<TContext>;
3454
+ /**
3455
+ * Create a UI state change event. Fire this when UIContext fields change.
3456
+ */
3457
+ declare function uiStateChanged(changes?: Record<string, unknown>): PraxisEvent;
3458
+ /**
3459
+ * Create a navigation request event. Used with dirty guard.
3460
+ */
3461
+ declare function navigationRequest(to: string): PraxisEvent;
3462
+ /**
3463
+ * Create a resize event. Used with viewport rule.
3464
+ */
3465
+ declare function resizeEvent(width: number, height: number): PraxisEvent;
3466
+
3467
+ /**
3468
+ * @plures/praxis — Completeness Analysis
3469
+ *
3470
+ * This module provides tools to measure and enforce "Praxis Completeness" —
3471
+ * the degree to which an application's logic is expressed through Praxis
3472
+ * rules, constraints, and contracts rather than scattered conditionals.
3473
+ *
3474
+ * ## Definition: Praxis Logic Completeness
3475
+ *
3476
+ * An application is "Praxis Complete" when:
3477
+ *
3478
+ * 1. **DOMAIN RULES (100%)** — Every business decision that produces user-visible
3479
+ * behavior change is expressed as a Praxis rule. "If the sprint is behind pace,
3480
+ * show a warning" is domain logic. It belongs in Praxis.
3481
+ *
3482
+ * 2. **INVARIANTS (100%)** — Every data validity assertion is a Praxis constraint.
3483
+ * "Sprint hours must not exceed 80" is an invariant. It belongs in Praxis.
3484
+ *
3485
+ * 3. **CONTRACTS (>80%)** — Rules that encode non-obvious behavior have contracts
3486
+ * (behavior description + examples + invariants). Contracts are documentation
3487
+ * AND test vectors — they prove the tool isn't the bug.
3488
+ *
3489
+ * 4. **CONTEXT COVERAGE (100%)** — Every piece of application state that rules
3490
+ * reason about is in the Praxis context. If a rule needs to know about
3491
+ * connection status, connection status must be in the context.
3492
+ *
3493
+ * 5. **EVENT COVERAGE (100%)** — Every state transition that should trigger rule
3494
+ * evaluation fires a Praxis event. If notes can be saved, there's a note.save
3495
+ * event. If sprint refreshes, there's a sprint.refresh event.
3496
+ *
3497
+ * ## What Is NOT Praxis Logic
3498
+ *
3499
+ * - **UI mechanics**: Panel toggle, scroll position, animation state, focus management
3500
+ * - **Data transport**: fetch() calls, WebSocket plumbing, file I/O
3501
+ * - **Framework wiring**: Svelte subscriptions, onMount, store creation
3502
+ * - **Data transformation**: Parsing, formatting, serialization
3503
+ * - **Routing/navigation**: URL handling, panel switching (unless it has business rules)
3504
+ *
3505
+ * The line: "Does this `if` statement encode a business decision or an app invariant?"
3506
+ * If yes → Praxis rule/constraint. If no → leave it.
3507
+ *
3508
+ * ## Measuring Completeness
3509
+ *
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';
3721
+ *
3722
+ * const expectations = new ExpectationSet({ name: 'settings' });
3723
+ *
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
+ * );
3731
+ *
3732
+ * const report = verify(registry, expectations);
3733
+ * ```
3734
+ */
3735
+
3736
+ /**
3737
+ * A behavioral expectation declaration.
3738
+ *
3739
+ * Chainable API for declaring conditions under which a behavior
3740
+ * should or should not occur.
3741
+ */
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>;
3761
+ }
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;
3776
+ }
3777
+ /**
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.
3791
+ *
3792
+ * Walks the rule graph to determine if expectations are satisfied,
3793
+ * violated, or unverifiable given the registered rules and contracts.
3794
+ */
3795
+ declare function verify(registry: VerifiableRegistry, expectations: ExpectationSet): VerificationReport;
3796
+ /**
3797
+ * Format a verification report as human-readable text.
3798
+ */
3799
+ declare function formatVerificationReport(report: VerificationReport): string;
3800
+
3801
+ /**
3802
+ * Praxis Rules Factory — Types
3803
+ *
3804
+ * Configuration types for predefined rule module factories.
3805
+ */
3806
+ type SanitizationType = 'sql-injection' | 'xss' | 'path-traversal' | 'command-injection';
3807
+ interface InputRulesConfig {
3808
+ /** Sanitization checks to apply */
3809
+ sanitize?: SanitizationType[];
3810
+ /** Maximum input length (0 = unlimited) */
3811
+ maxLength?: number;
3812
+ /** Whether the input is required (non-empty) */
3813
+ required?: boolean;
3814
+ /** Custom field name for facts/events (default: 'input') */
3815
+ fieldName?: string;
3816
+ }
3817
+ interface ToastRulesConfig {
3818
+ /** Only show toast if there's a meaningful diff */
3819
+ requireDiff?: boolean;
3820
+ /** Auto-dismiss after N milliseconds (0 = no auto-dismiss) */
3821
+ autoDismissMs?: number;
3822
+ /** Prevent duplicate toasts with same message */
3823
+ deduplicate?: boolean;
3824
+ }
3825
+ interface FormRulesConfig {
3826
+ /** Validate fields on blur */
3827
+ validateOnBlur?: boolean;
3828
+ /** Gate form submission on validation passing */
3829
+ submitGate?: boolean;
3830
+ /** Custom form name for namespacing facts */
3831
+ formName?: string;
3832
+ }
3833
+ interface NavigationRulesConfig {
3834
+ /** Warn/block navigation when form has unsaved changes */
3835
+ dirtyGuard?: boolean;
3836
+ /** Require authentication for navigation */
3837
+ authRequired?: boolean;
3838
+ }
3839
+ interface DataRulesConfig {
3840
+ /** Enable optimistic UI updates */
3841
+ optimisticUpdate?: boolean;
3842
+ /** Rollback optimistic updates on error */
3843
+ rollbackOnError?: boolean;
3844
+ /** Invalidate relevant caches on data change */
3845
+ cacheInvalidation?: boolean;
3846
+ /** Custom entity name for facts */
3847
+ entityName?: string;
3848
+ }
3849
+
3850
+ /**
3851
+ * Praxis Rules Factory
3852
+ *
3853
+ * Predefined rule modules for common application patterns.
3854
+ * Each factory returns a PraxisModule with rules, constraints, and contracts.
3855
+ *
3856
+ * @example
3857
+ * ```ts
3858
+ * import { inputRules, toastRules, formRules } from '@plures/praxis/factory';
3859
+ *
3860
+ * const registry = new PraxisRegistry();
3861
+ * registry.registerModule(inputRules({ sanitize: ['xss', 'sql-injection'], required: true }));
3862
+ * registry.registerModule(toastRules({ requireDiff: true, deduplicate: true }));
3863
+ * registry.registerModule(formRules({ validateOnBlur: true, submitGate: true }));
3864
+ * ```
3865
+ */
3866
+
3867
+ /** Context type for input rules. */
3868
+ interface InputContext {
3869
+ input?: {
3870
+ value?: string;
3871
+ field?: string;
3872
+ };
3873
+ }
3874
+ /**
3875
+ * Create input validation rules module.
3876
+ *
3877
+ * Generates rules for sanitizing user input, enforcing length limits,
3878
+ * and requiring non-empty values.
3879
+ */
3880
+ declare function inputRules(config?: InputRulesConfig): PraxisModule<InputContext>;
3881
+ /** Context type for toast rules. */
3882
+ interface ToastContext {
3883
+ diff?: Record<string, unknown> | null;
3884
+ toasts?: Array<{
3885
+ message: string;
3886
+ id: string;
3887
+ }>;
3888
+ }
3889
+ /**
3890
+ * Create truthful toast notification rules.
3891
+ *
3892
+ * Generates rules that ensure toasts only appear with meaningful content,
3893
+ * auto-dismiss after a timeout, and avoid duplicates.
3894
+ */
3895
+ declare function toastRules(config?: ToastRulesConfig): PraxisModule<ToastContext>;
3896
+ /** Context type for form rules. */
3897
+ interface FormContext {
3898
+ form?: {
3899
+ fields?: Record<string, {
3900
+ value: unknown;
3901
+ error?: string;
3902
+ touched?: boolean;
3903
+ }>;
3904
+ valid?: boolean;
3905
+ dirty?: boolean;
3906
+ submitting?: boolean;
3907
+ };
3908
+ }
3909
+ /**
3910
+ * Create form lifecycle rules.
3911
+ *
3912
+ * Generates rules for field validation on blur, submit gating,
3913
+ * and form state management.
3914
+ */
3915
+ declare function formRules(config?: FormRulesConfig): PraxisModule<FormContext>;
3916
+ /** Context type for navigation rules. */
3917
+ interface NavigationContext {
3918
+ dirty?: boolean;
3919
+ authenticated?: boolean;
3920
+ route?: string;
3921
+ }
3922
+ /**
3923
+ * Create route protection rules.
3924
+ *
3925
+ * Generates rules for dirty-data navigation guards and
3926
+ * authentication-required route protection.
3927
+ */
3928
+ declare function navigationRules(config?: NavigationRulesConfig): PraxisModule<NavigationContext>;
3929
+ /** Context type for data rules. */
3930
+ interface DataContext {
3931
+ pending?: Record<string, {
3932
+ original: unknown;
3933
+ optimistic: unknown;
3934
+ }>;
3935
+ cache?: Record<string, {
3936
+ data: unknown;
3937
+ timestamp: number;
3938
+ }>;
3939
+ }
3940
+ /**
3941
+ * Create data lifecycle rules.
3942
+ *
3943
+ * Generates rules for optimistic updates, error rollback, and cache invalidation.
3944
+ */
3945
+ declare function dataRules(config?: DataRulesConfig): PraxisModule<DataContext>;
3946
+
3947
+ /**
3948
+ * Praxis Project Logic — Types
3949
+ *
3950
+ * Types for developer workflow rules: gates, semver contracts,
3951
+ * commit generation, and branch management.
3952
+ */
3953
+ type GateStatus = 'open' | 'closed' | 'blocked';
3954
+ interface GateConfig {
3955
+ /** Expectations that must be satisfied for the gate to open */
3956
+ expects: string[];
3957
+ /** Action when gate is satisfied */
3958
+ onSatisfied?: string;
3959
+ /** Action when gate is violated */
3960
+ onViolation?: string;
3961
+ }
3962
+ interface GateState {
3963
+ name: string;
3964
+ status: GateStatus;
3965
+ /** Which expectations are satisfied */
3966
+ satisfied: string[];
3967
+ /** Which expectations are not satisfied */
3968
+ unsatisfied: string[];
3969
+ /** Timestamp of last status change */
3970
+ lastChanged: number;
3971
+ }
3972
+ interface SemverContractConfig {
3973
+ /** Files/sources that contain version strings */
3974
+ sources: string[];
3975
+ /** Invariants about version consistency */
3976
+ invariants: string[];
3977
+ }
3978
+ interface SemverReport {
3979
+ /** Whether all sources have consistent versions */
3980
+ consistent: boolean;
3981
+ /** Version found in each source */
3982
+ versions: Record<string, string>;
3983
+ /** Invariant violations */
3984
+ violations: string[];
3985
+ }
3986
+ interface PraxisDiff {
3987
+ /** Rules added since last commit */
3988
+ rulesAdded: string[];
3989
+ /** Rules removed */
3990
+ rulesRemoved: string[];
3991
+ /** Rules modified */
3992
+ rulesModified: string[];
3993
+ /** Contracts added */
3994
+ contractsAdded: string[];
3995
+ /** Contracts removed */
3996
+ contractsRemoved: string[];
3997
+ /** Expectations added */
3998
+ expectationsAdded: string[];
3999
+ /** Expectations removed */
4000
+ expectationsRemoved: string[];
4001
+ /** Gate state changes */
4002
+ gateChanges: Array<{
4003
+ gate: string;
4004
+ from: GateStatus;
4005
+ to: GateStatus;
4006
+ }>;
4007
+ }
4008
+ interface BranchRulesConfig {
4009
+ /** Naming convention pattern (e.g., 'feat/{name}', 'fix/{issue}') */
4010
+ naming: string;
4011
+ /** Conditions required for merge */
4012
+ mergeConditions: string[];
4013
+ }
4014
+ interface PredefinedGateConfig {
4015
+ /** Whether to enable this gate */
4016
+ enabled?: boolean;
4017
+ /** Custom expectations to add */
4018
+ additionalExpects?: string[];
4019
+ }
4020
+
4021
+ /**
4022
+ * Praxis Project Logic
4023
+ *
4024
+ * Developer workflow rules: gates, semver contracts, commit message
4025
+ * generation from behavioral deltas, and branch management.
4026
+ *
4027
+ * @example
4028
+ * ```ts
4029
+ * import { defineGate, semverContract, commitFromState } from '@plures/praxis/project';
4030
+ *
4031
+ * const testGate = defineGate('test', {
4032
+ * expects: ['all-tests-pass', 'no-type-errors'],
4033
+ * onSatisfied: 'merge-allowed',
4034
+ * onViolation: 'merge-blocked',
4035
+ * });
4036
+ *
4037
+ * const diff = { rulesAdded: ['auth/login'], ... };
4038
+ * const message = commitFromState(diff);
4039
+ * // → "feat(rules): add auth/login rule"
4040
+ * ```
4041
+ */
4042
+
4043
+ /**
4044
+ * Context type for gates. Apps extend their context with gate state.
4045
+ */
4046
+ interface GateContext {
4047
+ gates?: Record<string, GateState>;
4048
+ expectations?: Record<string, boolean>;
4049
+ }
4050
+ /**
4051
+ * Define a feature gate — a condition that must be satisfied before
4052
+ * proceeding with a workflow step (deploy, merge, release, etc.).
4053
+ *
4054
+ * @example
4055
+ * ```ts
4056
+ * const testGate = defineGate('test', {
4057
+ * expects: ['all-tests-pass', 'no-type-errors'],
4058
+ * onSatisfied: 'deploy-allowed',
4059
+ * onViolation: 'deploy-blocked',
4060
+ * });
4061
+ * registry.registerModule(testGate);
4062
+ * ```
4063
+ */
4064
+ declare function defineGate(name: string, config: GateConfig): PraxisModule<GateContext>;
4065
+ /**
4066
+ * Create a semver contract module that checks version consistency
4067
+ * across multiple sources (package.json, Cargo.toml, etc.).
4068
+ *
4069
+ * @example
4070
+ * ```ts
4071
+ * const version = semverContract({
4072
+ * sources: ['package.json', 'src/version.ts', 'README.md'],
4073
+ * invariants: ['All sources must have the same version'],
4074
+ * });
4075
+ * ```
4076
+ */
4077
+ declare function semverContract(config: SemverContractConfig): PraxisModule;
4078
+ /**
4079
+ * Generate a conventional commit message from a behavioral delta.
4080
+ *
4081
+ * Unlike file-based commit messages, this describes WHAT behavioral
4082
+ * changes occurred — rule additions, contract changes, expectation shifts.
4083
+ *
4084
+ * @example
4085
+ * ```ts
4086
+ * const msg = commitFromState({
4087
+ * rulesAdded: ['auth/login', 'auth/logout'],
4088
+ * contractsAdded: ['auth/login'],
4089
+ * ...empty
4090
+ * });
4091
+ * // → "feat(rules): add auth/login, auth/logout\n\nContracts added: auth/login"
4092
+ * ```
4093
+ */
4094
+ declare function commitFromState(diff: PraxisDiff): string;
4095
+ /**
4096
+ * Create branch management rules.
4097
+ *
4098
+ * @example
4099
+ * ```ts
4100
+ * const branches = branchRules({
4101
+ * naming: 'feat/{name}',
4102
+ * mergeConditions: ['tests-pass', 'review-approved'],
4103
+ * });
4104
+ * ```
4105
+ */
4106
+ declare function branchRules(config: BranchRulesConfig): PraxisModule;
4107
+ /**
4108
+ * Create a lint gate — blocks workflow until linting passes.
4109
+ */
4110
+ declare function lintGate(config?: PredefinedGateConfig): PraxisModule<GateContext>;
4111
+ /**
4112
+ * Create a format gate — blocks workflow until formatting is correct.
4113
+ */
4114
+ declare function formatGate(config?: PredefinedGateConfig): PraxisModule<GateContext>;
4115
+ /**
4116
+ * Create an expectation gate — blocks workflow until expectations are verified.
4117
+ */
4118
+ declare function expectationGate(config?: PredefinedGateConfig): PraxisModule<GateContext>;
4119
+
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 };