@plures/praxis 1.2.13 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/browser/chunk-MJK3IYTJ.js +384 -0
- package/dist/browser/{chunk-K377RW4V.js → chunk-N63K4KWS.js} +1 -1
- package/dist/browser/{engine-YJZV4SLD.js → engine-YIEGSX7U.js} +1 -1
- package/dist/browser/index.d.ts +104 -2
- package/dist/browser/index.js +188 -7
- package/dist/browser/integrations/svelte.d.ts +2 -2
- package/dist/browser/integrations/svelte.js +2 -2
- package/dist/browser/{reactive-engine.svelte-9aS0kTa8.d.ts → reactive-engine.svelte-DjynI82A.d.ts} +139 -5
- package/dist/node/{chunk-PRPQO6R5.js → chunk-5JQJZADT.js} +1 -1
- package/dist/node/chunk-KMJWAFZV.js +389 -0
- package/dist/node/{chunk-5RH7UAQC.js → chunk-PTH6MD6P.js} +1 -0
- package/dist/node/cli/index.cjs +1553 -839
- package/dist/node/cli/index.js +39 -2
- package/dist/node/cloud/index.d.cts +1 -1
- package/dist/node/cloud/index.d.ts +1 -1
- package/dist/node/components/index.d.cts +2 -2
- package/dist/node/components/index.d.ts +2 -2
- package/dist/node/conversations-KQBXTP3N.js +596 -0
- package/dist/node/{engine-2DQBKBJC.js → engine-FEN5IYZ5.js} +1 -1
- package/dist/node/index.cjs +911 -43
- package/dist/node/index.d.cts +574 -7
- package/dist/node/index.d.ts +574 -7
- package/dist/node/index.js +672 -26
- package/dist/node/integrations/svelte.cjs +190 -3
- package/dist/node/integrations/svelte.d.cts +3 -3
- package/dist/node/integrations/svelte.d.ts +3 -3
- package/dist/node/integrations/svelte.js +2 -2
- package/dist/node/{protocol-Qek7ebBl.d.ts → protocol-DcyGMmWY.d.cts} +8 -1
- package/dist/node/{protocol-Qek7ebBl.d.cts → protocol-DcyGMmWY.d.ts} +8 -1
- package/dist/node/{reactive-engine.svelte-CRNqHlbv.d.ts → reactive-engine.svelte-Cg0Yc2Hs.d.cts} +145 -6
- package/dist/node/{reactive-engine.svelte-BFIZfawz.d.cts → reactive-engine.svelte-DekxqFu0.d.ts} +145 -6
- package/dist/node/{terminal-adapter-B-UK_Vdz.d.ts → terminal-adapter-CvIvgTo4.d.ts} +1 -1
- package/dist/node/{terminal-adapter-BQSIF5bf.d.cts → terminal-adapter-Db-snPJ3.d.cts} +1 -1
- package/dist/node/{validate-CNHUULQE.js → validate-EN3M4FUR.js} +1 -1
- package/dist/node/{verify-KLJRXVJS.js → verify-7VZRP2WS.js} +2 -2
- package/docs/BOT_UPDATE_POLICY.md +125 -0
- package/docs/DOGFOODING_CHECKLIST.md +254 -0
- package/docs/DOGFOODING_INDEX.md +169 -0
- package/docs/DOGFOODING_QUICK_START.md +140 -0
- package/docs/KNO_ENG_EXTRACTION_PLAN.md +577 -0
- package/docs/PLURES_TOOLS_INVENTORY.md +170 -0
- package/docs/README.md +12 -0
- package/docs/TESTING_BOT_WORKFLOWS.md +154 -0
- package/docs/conversations/INTEGRATION_POINTS.md +719 -0
- package/docs/conversations/README.md +168 -0
- package/docs/core/extending-praxis-core.md +604 -0
- package/docs/core/praxis-core-api.md +385 -0
- package/docs/decision-ledger/contract-index.json +2 -2
- package/docs/decision-ledger/decisions/2026-02-01-monorepo-organization.md +130 -0
- package/docs/examples/DOGFOODING_WORKFLOW_EXAMPLE.md +295 -0
- package/docs/examples/README.md +41 -0
- package/docs/workflows/pr-overlap-guard.md +50 -0
- package/package.json +8 -3
- package/src/__tests__/chronicle.test.ts +512 -0
- package/src/__tests__/conversations.test.ts +312 -0
- package/src/__tests__/edge-cases.test.ts +1 -1
- package/src/__tests__/engine-dx.test.ts +355 -0
- package/src/__tests__/engine-v2.test.ts +532 -0
- package/src/cli/commands/conversations.ts +252 -0
- package/src/cli/index.ts +73 -0
- package/src/conversations/README.md +230 -0
- package/src/conversations/candidate.schema.json +123 -0
- package/src/conversations/candidates.ts +114 -0
- package/src/conversations/capture.ts +56 -0
- package/src/conversations/classify.ts +110 -0
- package/src/conversations/conversation.schema.json +106 -0
- package/src/conversations/emitters/fs.ts +65 -0
- package/src/conversations/emitters/github.ts +115 -0
- package/src/conversations/gate.ts +102 -0
- package/src/conversations/index.ts +28 -0
- package/src/conversations/normalize.ts +51 -0
- package/src/conversations/redact.ts +57 -0
- package/src/conversations/types.ts +96 -0
- package/src/core/chronicle/chronicle.ts +227 -0
- package/src/core/chronicle/context.ts +80 -0
- package/src/core/chronicle/index.ts +53 -0
- package/src/core/chronicle/mcp.ts +135 -0
- package/src/core/chronicle/types.ts +61 -0
- package/src/core/completeness.ts +274 -0
- package/src/core/engine.ts +143 -3
- package/src/core/pluresdb/index.ts +22 -0
- package/src/core/pluresdb/store.ts +171 -8
- package/src/core/protocol.ts +7 -0
- package/src/core/rule-result.ts +130 -0
- package/src/core/rules.ts +24 -5
- package/src/core/ui-rules.ts +340 -0
- package/src/dsl/index.ts +6 -0
- package/src/index.ts +45 -0
- package/src/integrations/pluresdb.ts +22 -0
- package/src/vite/completeness-plugin.ts +72 -0
- package/dist/browser/chunk-VOMLVI6V.js +0 -197
- package/dist/node/chunk-VOMLVI6V.js +0 -197
package/dist/node/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as PraxisState, a as PraxisEvent, b as PraxisFact } from './protocol-
|
|
2
|
-
export {
|
|
3
|
-
import { L as LogicEngine, P as PraxisRegistry, b as RuleDescriptor, C as ConstraintDescriptor, d as
|
|
4
|
-
export {
|
|
5
|
-
import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-
|
|
6
|
-
export { C as CommandExecutor, I as InMemoryPraxisDB,
|
|
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
|
+
import { P as PraxisDB, U as UnsubscribeFn$1 } from './terminal-adapter-CvIvgTo4.js';
|
|
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';
|
|
8
8
|
export { NodeBindings, NodeDefinition, OrchestrationDefinition, TerminalNodeProps, ValidationError, createSchemaTemplate, validateSchema } from './schema.js';
|
|
9
9
|
import '@plures/pluresdb/local-first';
|
|
@@ -441,6 +441,11 @@ interface DefineRuleOptions<TContext = unknown> {
|
|
|
441
441
|
id: string;
|
|
442
442
|
description: string;
|
|
443
443
|
impl: RuleFn<TContext>;
|
|
444
|
+
/**
|
|
445
|
+
* Optional event type filter — only evaluate this rule when at least one
|
|
446
|
+
* event in the batch has a matching `tag`. Accepts a single tag or array.
|
|
447
|
+
*/
|
|
448
|
+
eventTypes?: string | string[];
|
|
444
449
|
contract?: Contract;
|
|
445
450
|
meta?: Record<string, unknown>;
|
|
446
451
|
}
|
|
@@ -838,6 +843,154 @@ declare function loadSchema(filePath: string, options?: LoaderOptions): Promise<
|
|
|
838
843
|
*/
|
|
839
844
|
declare function loadSchemaFromFile(filePath: string, options?: LoaderOptions): Promise<LoaderResult>;
|
|
840
845
|
|
|
846
|
+
/**
|
|
847
|
+
* Chronicle Types
|
|
848
|
+
*
|
|
849
|
+
* Core types for the Chronicle causal tracking system.
|
|
850
|
+
* Records state transitions as a causal graph stored in PluresDB.
|
|
851
|
+
*/
|
|
852
|
+
/**
|
|
853
|
+
* Direction for traversing causal chains.
|
|
854
|
+
*/
|
|
855
|
+
type TraceDirection = 'backward' | 'forward' | 'both';
|
|
856
|
+
/**
|
|
857
|
+
* Causal relationship type between Chronicle nodes.
|
|
858
|
+
* - `causes`: node A caused node B (explicit causal link)
|
|
859
|
+
* - `context`: node B belongs to the same session/request as node A
|
|
860
|
+
* - `follows`: node B happened after node A in the same context
|
|
861
|
+
*/
|
|
862
|
+
type EdgeType = 'causes' | 'context' | 'follows';
|
|
863
|
+
/**
|
|
864
|
+
* A recorded state transition event passed to Chronicle.
|
|
865
|
+
*/
|
|
866
|
+
interface ChronicleEvent {
|
|
867
|
+
/** Path to the changed value (fact or event stream path) */
|
|
868
|
+
path: string;
|
|
869
|
+
/** Value before the change (undefined for creates) */
|
|
870
|
+
before?: unknown;
|
|
871
|
+
/** Value after the change */
|
|
872
|
+
after?: unknown;
|
|
873
|
+
/** Parent span/node ID that caused this change */
|
|
874
|
+
cause?: string;
|
|
875
|
+
/** Session or request ID grouping related changes */
|
|
876
|
+
context?: string;
|
|
877
|
+
/** Additional metadata key-value pairs */
|
|
878
|
+
metadata: Record<string, string>;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* A Chronicle node representing a single recorded state transition.
|
|
882
|
+
*/
|
|
883
|
+
interface ChronicleNode {
|
|
884
|
+
/** Unique node ID: `chronos:{timestamp}-{counter}` */
|
|
885
|
+
id: string;
|
|
886
|
+
/** Timestamp (ms since epoch) when this node was recorded */
|
|
887
|
+
timestamp: number;
|
|
888
|
+
/** The recorded state transition */
|
|
889
|
+
event: ChronicleEvent;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* A directed edge in the causal graph connecting two Chronicle nodes.
|
|
893
|
+
*/
|
|
894
|
+
interface ChronicleEdge {
|
|
895
|
+
/** Source node ID */
|
|
896
|
+
from: string;
|
|
897
|
+
/** Target node ID */
|
|
898
|
+
to: string;
|
|
899
|
+
/** Type of causal relationship */
|
|
900
|
+
type: EdgeType;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Chronicle Interface and PluresDbChronicle Implementation
|
|
905
|
+
*
|
|
906
|
+
* Records state transitions as a causal graph in PluresDB.
|
|
907
|
+
* Attached to PraxisDBStore via `.withChronicle()` for zero-effort observability.
|
|
908
|
+
*/
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* Storage path constants for Chronicle data in PluresDB.
|
|
912
|
+
*
|
|
913
|
+
* Layout:
|
|
914
|
+
* - `/_praxis/chronos/nodes/{nodeId}` — ChronicleNode documents
|
|
915
|
+
* - `/_praxis/chronos/edges/out/{nodeId}` — outgoing ChronicleEdge arrays
|
|
916
|
+
* - `/_praxis/chronos/edges/in/{nodeId}` — incoming ChronicleEdge arrays
|
|
917
|
+
* - `/_praxis/chronos/context/{contextId}` — ordered nodeId arrays per context
|
|
918
|
+
* - `/_praxis/chronos/index` — global ordered nodeId array (for range queries)
|
|
919
|
+
*/
|
|
920
|
+
declare const CHRONICLE_PATHS: {
|
|
921
|
+
readonly BASE: "/_praxis/chronos";
|
|
922
|
+
readonly NODES: "/_praxis/chronos/nodes";
|
|
923
|
+
readonly EDGES_OUT: "/_praxis/chronos/edges/out";
|
|
924
|
+
readonly EDGES_IN: "/_praxis/chronos/edges/in";
|
|
925
|
+
readonly CONTEXT: "/_praxis/chronos/context";
|
|
926
|
+
readonly INDEX: "/_praxis/chronos/index";
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* Chronicle interface — records state transitions as a causal graph.
|
|
930
|
+
*
|
|
931
|
+
* Automatically attached to any PraxisDBStore at runtime via `.withChronicle()`.
|
|
932
|
+
* Records state diffs as graph nodes with causal edges.
|
|
933
|
+
*/
|
|
934
|
+
interface Chronicle {
|
|
935
|
+
/**
|
|
936
|
+
* Record a state transition and return the created node.
|
|
937
|
+
*/
|
|
938
|
+
record(event: ChronicleEvent): Promise<ChronicleNode>;
|
|
939
|
+
/**
|
|
940
|
+
* Trace causality backward or forward from a node.
|
|
941
|
+
*
|
|
942
|
+
* @param nodeId Starting node ID
|
|
943
|
+
* @param direction `'backward'` follows incoming edges, `'forward'` follows outgoing edges
|
|
944
|
+
* @param maxDepth Maximum traversal depth (prevents cycles / infinite loops)
|
|
945
|
+
*/
|
|
946
|
+
trace(nodeId: string, direction: TraceDirection, maxDepth: number): Promise<ChronicleNode[]>;
|
|
947
|
+
/**
|
|
948
|
+
* Return all Chronicle nodes recorded within a timestamp range.
|
|
949
|
+
*
|
|
950
|
+
* @param start Inclusive start timestamp (ms)
|
|
951
|
+
* @param end Inclusive end timestamp (ms)
|
|
952
|
+
*/
|
|
953
|
+
range(start: number, end: number): Promise<ChronicleNode[]>;
|
|
954
|
+
/**
|
|
955
|
+
* Return all Chronicle nodes belonging to a context (session/request).
|
|
956
|
+
*
|
|
957
|
+
* @param contextId The context identifier
|
|
958
|
+
*/
|
|
959
|
+
subgraph(contextId: string): Promise<ChronicleNode[]>;
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* PluresDB-backed implementation of the Chronicle interface.
|
|
963
|
+
*
|
|
964
|
+
* Stores causal graph nodes and edges in PluresDB under `/_praxis/chronos/`.
|
|
965
|
+
* Shares the same PluresDB instance as PraxisDBStore so the JS Chronos UI
|
|
966
|
+
* can read from the same data layer.
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```typescript
|
|
970
|
+
* const db = createInMemoryDB();
|
|
971
|
+
* const chronicle = new PluresDbChronicle(db);
|
|
972
|
+
*
|
|
973
|
+
* const store = createPraxisDBStore(db, registry).withChronicle(chronicle);
|
|
974
|
+
* // All storeFact / appendEvent calls are now recorded automatically.
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
declare class PluresDbChronicle implements Chronicle {
|
|
978
|
+
private readonly db;
|
|
979
|
+
constructor(db: PraxisDB);
|
|
980
|
+
record(event: ChronicleEvent): Promise<ChronicleNode>;
|
|
981
|
+
trace(nodeId: string, direction: TraceDirection, maxDepth: number): Promise<ChronicleNode[]>;
|
|
982
|
+
range(start: number, end: number): Promise<ChronicleNode[]>;
|
|
983
|
+
subgraph(contextId: string): Promise<ChronicleNode[]>;
|
|
984
|
+
private addEdge;
|
|
985
|
+
private _traceRecursive;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Create a PluresDB-backed Chronicle instance.
|
|
989
|
+
*
|
|
990
|
+
* @param db The PraxisDB instance to store causal graph data in
|
|
991
|
+
*/
|
|
992
|
+
declare function createChronicle(db: PraxisDB): PluresDbChronicle;
|
|
993
|
+
|
|
841
994
|
/**
|
|
842
995
|
* PraxisDB Store
|
|
843
996
|
*
|
|
@@ -917,9 +1070,26 @@ declare class PraxisDBStore<TContext = unknown> {
|
|
|
917
1070
|
private subscriptions;
|
|
918
1071
|
private factWatchers;
|
|
919
1072
|
private onRuleError;
|
|
1073
|
+
private chronicle?;
|
|
920
1074
|
constructor(options: PraxisDBStoreOptions<TContext> & {
|
|
921
1075
|
onRuleError?: RuleErrorHandler;
|
|
922
1076
|
});
|
|
1077
|
+
/**
|
|
1078
|
+
* Attach a Chronicle observer to this store.
|
|
1079
|
+
*
|
|
1080
|
+
* Every subsequent `storeFact` and `appendEvent` call will be recorded as a
|
|
1081
|
+
* causal graph node in PluresDB, enabling full observability for free.
|
|
1082
|
+
*
|
|
1083
|
+
* @param chronicle Chronicle implementation to attach
|
|
1084
|
+
* @returns `this` for fluent chaining
|
|
1085
|
+
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ```typescript
|
|
1088
|
+
* const store = createPraxisDBStore(db, registry)
|
|
1089
|
+
* .withChronicle(createChronicle(db));
|
|
1090
|
+
* ```
|
|
1091
|
+
*/
|
|
1092
|
+
withChronicle(chronicle: Chronicle): this;
|
|
923
1093
|
/**
|
|
924
1094
|
* Store a fact in PluresDB
|
|
925
1095
|
*
|
|
@@ -1241,6 +1411,137 @@ declare class PluresDBGenerator {
|
|
|
1241
1411
|
*/
|
|
1242
1412
|
declare function createPluresDBGenerator(outputDir: string, options?: Partial<PluresDBGeneratorOptions>): PluresDBGenerator;
|
|
1243
1413
|
|
|
1414
|
+
/**
|
|
1415
|
+
* Chronicle Context
|
|
1416
|
+
*
|
|
1417
|
+
* Synchronous causal context propagation for Chronicle span tracking.
|
|
1418
|
+
* Equivalent to Rust's `tracing` crate span context, adapted for TypeScript.
|
|
1419
|
+
*
|
|
1420
|
+
* @example
|
|
1421
|
+
* ```typescript
|
|
1422
|
+
* // Run code attributed to a specific span/session
|
|
1423
|
+
* await ChronicleContext.runAsync(
|
|
1424
|
+
* { spanId: 'route-decision-1', contextId: 'session-abc' },
|
|
1425
|
+
* async () => {
|
|
1426
|
+
* await store.storeFact(fact); // attributed to route-decision-1 / session-abc
|
|
1427
|
+
* }
|
|
1428
|
+
* );
|
|
1429
|
+
* ```
|
|
1430
|
+
*/
|
|
1431
|
+
interface ChronicleSpan {
|
|
1432
|
+
/** The span/operation ID (becomes the `cause` field on Chronicle nodes) */
|
|
1433
|
+
spanId?: string;
|
|
1434
|
+
/** Session or request ID grouping related spans */
|
|
1435
|
+
contextId?: string;
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Stack-based synchronous causal context propagation.
|
|
1439
|
+
*
|
|
1440
|
+
* Uses a call-stack approach for environments without AsyncLocalStorage.
|
|
1441
|
+
* Works correctly for synchronous and sequentially-awaited async code.
|
|
1442
|
+
* For concurrent async flows, use `runAsync` per logical operation.
|
|
1443
|
+
*/
|
|
1444
|
+
declare class ChronicleContext {
|
|
1445
|
+
private static readonly _stack;
|
|
1446
|
+
/**
|
|
1447
|
+
* Get the current active span, if any.
|
|
1448
|
+
*/
|
|
1449
|
+
static get current(): ChronicleSpan | undefined;
|
|
1450
|
+
/**
|
|
1451
|
+
* Run a synchronous function within a causal span.
|
|
1452
|
+
* The span is automatically popped when the function returns.
|
|
1453
|
+
*/
|
|
1454
|
+
static run<T>(span: ChronicleSpan, fn: () => T): T;
|
|
1455
|
+
/**
|
|
1456
|
+
* Run an async function within a causal span.
|
|
1457
|
+
* The span is popped after the promise settles.
|
|
1458
|
+
*/
|
|
1459
|
+
static runAsync<T>(span: ChronicleSpan, fn: () => Promise<T>): Promise<T>;
|
|
1460
|
+
/**
|
|
1461
|
+
* Create a child span that inherits the current contextId.
|
|
1462
|
+
*
|
|
1463
|
+
* @param spanId ID for the new span
|
|
1464
|
+
* @returns A new ChronicleSpan with the current contextId
|
|
1465
|
+
*/
|
|
1466
|
+
static childSpan(spanId: string): ChronicleSpan;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Chronicle MCP Tools
|
|
1471
|
+
*
|
|
1472
|
+
* Exposes Chronicle query functionality as MCP-compatible tool handlers.
|
|
1473
|
+
* Register these tools with any MCP server to surface Chronos querying
|
|
1474
|
+
* capabilities for troubleshooting, auditing, and AI training data extraction.
|
|
1475
|
+
*
|
|
1476
|
+
* @example
|
|
1477
|
+
* ```typescript
|
|
1478
|
+
* const chronicle = createChronicle(db);
|
|
1479
|
+
* const tools = createChronosMcpTools(chronicle);
|
|
1480
|
+
*
|
|
1481
|
+
* // MCP server registration (framework-agnostic)
|
|
1482
|
+
* server.registerTool('chronos.trace', tools.trace);
|
|
1483
|
+
* server.registerTool('chronos.search', tools.search);
|
|
1484
|
+
* ```
|
|
1485
|
+
*/
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Parameters for the `chronos.trace` MCP tool.
|
|
1489
|
+
*/
|
|
1490
|
+
interface ChronosTraceParams {
|
|
1491
|
+
/** ID of the Chronicle node to start tracing from */
|
|
1492
|
+
nodeId: string;
|
|
1493
|
+
/** Direction to traverse the causal graph (default: `'backward'`) */
|
|
1494
|
+
direction?: TraceDirection;
|
|
1495
|
+
/** Maximum traversal depth (default: 10) */
|
|
1496
|
+
maxDepth?: number;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Parameters for the `chronos.search` MCP tool.
|
|
1500
|
+
*/
|
|
1501
|
+
interface ChronosSearchParams {
|
|
1502
|
+
/** Search query matched against node paths, metadata, and serialised payloads */
|
|
1503
|
+
query: string;
|
|
1504
|
+
/** Optional context ID — restricts search to a single session/request subgraph */
|
|
1505
|
+
contextId?: string;
|
|
1506
|
+
/** Inclusive start timestamp in ms (default: 0) */
|
|
1507
|
+
since?: number;
|
|
1508
|
+
/** Inclusive end timestamp in ms (default: now) */
|
|
1509
|
+
until?: number;
|
|
1510
|
+
/** Maximum number of results (default: no limit) */
|
|
1511
|
+
limit?: number;
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Uniform result envelope for MCP tool calls.
|
|
1515
|
+
*/
|
|
1516
|
+
interface McpToolResult<T> {
|
|
1517
|
+
/** Whether the tool call succeeded */
|
|
1518
|
+
success: boolean;
|
|
1519
|
+
/** Returned data (present on success) */
|
|
1520
|
+
data?: T;
|
|
1521
|
+
/** Error message (present on failure) */
|
|
1522
|
+
error?: string;
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Chronos MCP tools bound to a Chronicle instance.
|
|
1526
|
+
*/
|
|
1527
|
+
interface ChronosMcpTools {
|
|
1528
|
+
/**
|
|
1529
|
+
* `chronos.trace` — trace causality backward/forward from a Chronicle node.
|
|
1530
|
+
*/
|
|
1531
|
+
trace(params: ChronosTraceParams): Promise<McpToolResult<ChronicleNode[]>>;
|
|
1532
|
+
/**
|
|
1533
|
+
* `chronos.search` — search Chronicle nodes by path, metadata, or payload content.
|
|
1534
|
+
*/
|
|
1535
|
+
search(params: ChronosSearchParams): Promise<McpToolResult<ChronicleNode[]>>;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Create Chronos MCP tools bound to a Chronicle instance.
|
|
1539
|
+
*
|
|
1540
|
+
* @param chronicle Chronicle instance to query
|
|
1541
|
+
* @returns Object with `trace` and `search` tool handlers
|
|
1542
|
+
*/
|
|
1543
|
+
declare function createChronosMcpTools(chronicle: Chronicle): ChronosMcpTools;
|
|
1544
|
+
|
|
1244
1545
|
/**
|
|
1245
1546
|
* PluresDB Integration
|
|
1246
1547
|
*
|
|
@@ -3052,4 +3353,270 @@ declare function attachAllIntegrations<TContext = unknown>(engine: LogicEngine<T
|
|
|
3052
3353
|
dispose: () => void;
|
|
3053
3354
|
}>;
|
|
3054
3355
|
|
|
3055
|
-
|
|
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
|
+
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, type CompletenessConfig, type CompletenessReport, 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, type LogicBranch, 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 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 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, attachAllIntegrations, attachTauriToEngine, attachToEngine, attachUnumToEngine, auditCompleteness, canvasToMermaid, canvasToSchema, canvasToYaml, createBehaviorLedger, createCanvasEditor, createChronicle, createChronosMcpTools, createReactiveEngine as createFrameworkAgnosticReactiveEngine, createIntrospector, createMockTauriBridge, createPluresDBAdapter, createPluresDBGenerator, createPraxisDBStore, createSchemaRegistry, createStateDocsGenerator, createTauriPraxisAdapter, createTimerActor, createUIModule, createUnifiedApp, createUnumAdapter, defineConstraint, defineEvent, defineFact, defineModule, defineRule, dirtyGuardRule, errorDisplayRule, filterEvents, filterFacts, findEvent, findFact, formatReport, formatValidationReport, formatValidationReportJSON, formatValidationReportSARIF, generateDocs, generateId, generateTauriConfig, getEventPath, getFactPath, getSchemaPath, initGateRule, loadSchema, loadSchemaFromFile, loadSchemaFromJson, loadSchemaFromYaml, loadingGateRule, mustBeInitializedConstraint, navigationRequest, noInteractionWhileLoadingConstraint, offlineIndicatorRule, registerSchema, resizeEvent, schemaToCanvas, uiModule, uiStateChanged, validateContracts, validateForGeneration, validateWithGuardian, viewportRule };
|