@plures/praxis 1.4.0 → 2.0.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 (72) hide show
  1. package/dist/browser/{chunk-N63K4KWS.js → chunk-4IRUGWR3.js} +1 -1
  2. package/dist/browser/chunk-6MVRT7CK.js +363 -0
  3. package/dist/browser/chunk-6SJ44Q64.js +473 -0
  4. package/dist/browser/chunk-BQOYZBWA.js +282 -0
  5. package/dist/browser/chunk-IG5BJ2MT.js +91 -0
  6. package/dist/browser/{chunk-MJK3IYTJ.js → chunk-JZDJU2DO.js} +4 -84
  7. package/dist/browser/chunk-ZEW4LJAJ.js +353 -0
  8. package/dist/browser/{engine-YIEGSX7U.js → engine-3B5WJPGT.js} +2 -1
  9. package/dist/browser/expectations/index.d.ts +180 -0
  10. package/dist/browser/expectations/index.js +14 -0
  11. package/dist/browser/factory/index.d.ts +150 -0
  12. package/dist/browser/factory/index.js +15 -0
  13. package/dist/browser/index.d.ts +277 -3
  14. package/dist/browser/index.js +425 -60
  15. package/dist/browser/integrations/svelte.d.ts +4 -2
  16. package/dist/browser/integrations/svelte.js +3 -2
  17. package/dist/browser/project/index.d.ts +177 -0
  18. package/dist/browser/project/index.js +19 -0
  19. package/dist/browser/reactive-engine.svelte-BwWadvAW.d.ts +224 -0
  20. package/dist/browser/rule-result-DcXWe9tn.d.ts +206 -0
  21. package/dist/browser/rules-BaWMqxuG.d.ts +277 -0
  22. package/dist/browser/unified/index.d.ts +239 -0
  23. package/dist/browser/unified/index.js +20 -0
  24. package/dist/node/chunk-6MVRT7CK.js +363 -0
  25. package/dist/node/chunk-AZLNISFI.js +1690 -0
  26. package/dist/node/chunk-IG5BJ2MT.js +91 -0
  27. package/dist/node/{chunk-KMJWAFZV.js → chunk-JZDJU2DO.js} +4 -89
  28. package/dist/node/{chunk-7M3HV4XR.js → chunk-WFRHXZBP.js} +3 -3
  29. package/dist/node/cli/index.cjs +48 -0
  30. package/dist/node/cli/index.js +2 -2
  31. package/dist/node/{engine-FEN5IYZ5.js → engine-VFHCIEM4.js} +2 -1
  32. package/dist/node/index.cjs +2114 -0
  33. package/dist/node/index.d.cts +964 -280
  34. package/dist/node/index.d.ts +964 -280
  35. package/dist/node/index.js +575 -10
  36. package/dist/node/integrations/svelte.d.cts +3 -2
  37. package/dist/node/integrations/svelte.d.ts +3 -2
  38. package/dist/node/integrations/svelte.js +3 -2
  39. package/dist/node/{reactive-engine.svelte-DekxqFu0.d.ts → reactive-engine.svelte-BBZLMzus.d.ts} +3 -79
  40. package/dist/node/{reactive-engine.svelte-Cg0Yc2Hs.d.cts → reactive-engine.svelte-Cbq_V20o.d.cts} +3 -79
  41. package/dist/node/rule-result-B9GMivAn.d.cts +80 -0
  42. package/dist/node/rule-result-Bo3sFMmN.d.ts +80 -0
  43. package/dist/node/{server-SYZPDULV.js → server-FKLVY57V.js} +4 -2
  44. package/dist/node/unified/index.cjs +484 -0
  45. package/dist/node/unified/index.d.cts +240 -0
  46. package/dist/node/unified/index.d.ts +240 -0
  47. package/dist/node/unified/index.js +21 -0
  48. package/dist/node/{validate-TQGVIG7G.js → validate-BY7JNY7H.js} +2 -1
  49. package/package.json +38 -11
  50. package/src/__tests__/chronos-project.test.ts +799 -0
  51. package/src/__tests__/decision-ledger.test.ts +857 -402
  52. package/src/chronos/diff.ts +336 -0
  53. package/src/chronos/hooks.ts +227 -0
  54. package/src/chronos/index.ts +83 -0
  55. package/src/chronos/project-chronicle.ts +198 -0
  56. package/src/chronos/timeline.ts +152 -0
  57. package/src/decision-ledger/analyzer-types.ts +280 -0
  58. package/src/decision-ledger/analyzer.ts +518 -0
  59. package/src/decision-ledger/contract-verification.ts +456 -0
  60. package/src/decision-ledger/derivation.ts +158 -0
  61. package/src/decision-ledger/index.ts +59 -0
  62. package/src/decision-ledger/report.ts +378 -0
  63. package/src/decision-ledger/suggestions.ts +287 -0
  64. package/src/index.browser.ts +103 -0
  65. package/src/index.ts +98 -0
  66. package/src/unified/__tests__/unified.test.ts +396 -0
  67. package/src/unified/core.ts +517 -0
  68. package/src/unified/index.ts +32 -0
  69. package/src/unified/rules.ts +66 -0
  70. package/src/unified/types.ts +148 -0
  71. package/dist/browser/reactive-engine.svelte-DjynI82A.d.ts +0 -688
  72. package/dist/node/chunk-FWOXU4MM.js +0 -487
@@ -11,21 +11,39 @@ import {
11
11
  ContractUpdated,
12
12
  ContractValidated,
13
13
  ValidateContracts,
14
+ analyzeDependencyGraph,
14
15
  createBehaviorLedger,
16
+ crossReferenceContracts,
15
17
  defineConstraint,
16
18
  defineEvent,
17
19
  defineFact,
18
20
  defineModule,
19
21
  defineRule,
22
+ diffLedgers,
20
23
  filterEvents,
21
24
  filterFacts,
25
+ findContractGaps,
26
+ findContradictions,
27
+ findDeadRules,
22
28
  findEvent,
23
29
  findFact,
30
+ findGaps,
31
+ findShadowedRules,
32
+ findUnreachableStates,
33
+ formatBuildOutput,
34
+ formatLedger,
24
35
  formatValidationReport,
25
36
  formatValidationReportJSON,
26
37
  formatValidationReportSARIF,
27
- validateContracts
28
- } from "./chunk-FWOXU4MM.js";
38
+ generateLedger,
39
+ suggest,
40
+ suggestAll,
41
+ traceDerivation,
42
+ traceImpact,
43
+ validateContracts,
44
+ verifyContractExamples,
45
+ verifyInvariants
46
+ } from "./chunk-AZLNISFI.js";
29
47
  import "./chunk-7CSWBDFL.js";
30
48
  import {
31
49
  defineContract,
@@ -55,14 +73,15 @@ import {
55
73
  import {
56
74
  ReactiveLogicEngine,
57
75
  createReactiveEngine
58
- } from "./chunk-7M3HV4XR.js";
76
+ } from "./chunk-WFRHXZBP.js";
77
+ import {
78
+ PraxisRegistry
79
+ } from "./chunk-TEMFJOIH.js";
59
80
  import {
60
81
  LogicEngine,
61
82
  PRAXIS_PROTOCOL_VERSION,
62
- RuleResult,
63
- createPraxisEngine,
64
- fact
65
- } from "./chunk-KMJWAFZV.js";
83
+ createPraxisEngine
84
+ } from "./chunk-JZDJU2DO.js";
66
85
  import {
67
86
  TerminalAdapter,
68
87
  createMockExecutor,
@@ -85,8 +104,16 @@ import {
85
104
  validateSchema
86
105
  } from "./chunk-UATVJBNV.js";
87
106
  import {
88
- PraxisRegistry
89
- } from "./chunk-TEMFJOIH.js";
107
+ createApp,
108
+ defineConstraint as defineConstraint2,
109
+ defineModule as defineModule2,
110
+ definePath,
111
+ defineRule as defineRule2
112
+ } from "./chunk-6MVRT7CK.js";
113
+ import {
114
+ RuleResult,
115
+ fact
116
+ } from "./chunk-IG5BJ2MT.js";
90
117
  import "./chunk-QGM4M3NI.js";
91
118
 
92
119
  // src/core/reactive-engine.ts
@@ -1780,7 +1807,7 @@ function generateTauriConfig(config) {
1780
1807
 
1781
1808
  // src/integrations/unified.ts
1782
1809
  async function createUnifiedApp(config) {
1783
- const { createPraxisEngine: createPraxisEngine2 } = await import("./engine-FEN5IYZ5.js");
1810
+ const { createPraxisEngine: createPraxisEngine2 } = await import("./engine-VFHCIEM4.js");
1784
1811
  const { createInMemoryDB: createInMemoryDB2 } = await import("./adapter-75ISSMWD.js");
1785
1812
  const db = config.db || createInMemoryDB2();
1786
1813
  const pluresdb = createPluresDBAdapter({
@@ -3193,6 +3220,509 @@ function expectationGate(config = {}) {
3193
3220
  onViolation: "expectations-failed"
3194
3221
  });
3195
3222
  }
3223
+
3224
+ // src/chronos/project-chronicle.ts
3225
+ var ProjectChronicle = class {
3226
+ events = [];
3227
+ maxEvents;
3228
+ now;
3229
+ constructor(options = {}) {
3230
+ this.maxEvents = options.maxEvents ?? 1e4;
3231
+ this.now = options.now ?? (() => Date.now());
3232
+ }
3233
+ // ── Recording ───────────────────────────────────────────────────────────
3234
+ /**
3235
+ * Record a project event. Returns the recorded event (with timestamp filled in).
3236
+ */
3237
+ record(event) {
3238
+ const full = {
3239
+ kind: event.kind,
3240
+ action: event.action,
3241
+ subject: event.subject,
3242
+ timestamp: event.timestamp ?? this.now(),
3243
+ metadata: event.metadata,
3244
+ diff: event.diff
3245
+ };
3246
+ this.events.push(full);
3247
+ if (this.maxEvents > 0 && this.events.length > this.maxEvents) {
3248
+ this.events = this.events.slice(this.events.length - this.maxEvents);
3249
+ }
3250
+ return full;
3251
+ }
3252
+ // ── Convenience recorders ─────────────────────────────────────────────
3253
+ recordRuleRegistered(ruleId, meta = {}) {
3254
+ return this.record({ kind: "rule", action: "registered", subject: ruleId, metadata: meta });
3255
+ }
3256
+ recordRuleModified(ruleId, diff, meta = {}) {
3257
+ return this.record({ kind: "rule", action: "modified", subject: ruleId, metadata: meta, diff });
3258
+ }
3259
+ recordRuleRemoved(ruleId, meta = {}) {
3260
+ return this.record({ kind: "rule", action: "removed", subject: ruleId, metadata: meta });
3261
+ }
3262
+ recordContractAdded(contractId, meta = {}) {
3263
+ return this.record({ kind: "contract", action: "added", subject: contractId, metadata: meta });
3264
+ }
3265
+ recordContractModified(contractId, diff, meta = {}) {
3266
+ return this.record({ kind: "contract", action: "modified", subject: contractId, metadata: meta, diff });
3267
+ }
3268
+ recordExpectationSatisfied(name, meta = {}) {
3269
+ return this.record({ kind: "expectation", action: "satisfied", subject: name, metadata: meta });
3270
+ }
3271
+ recordExpectationViolated(name, meta = {}) {
3272
+ return this.record({ kind: "expectation", action: "violated", subject: name, metadata: meta });
3273
+ }
3274
+ recordGateTransition(gateName, from, to, meta = {}) {
3275
+ return this.record({
3276
+ kind: "gate",
3277
+ action: to,
3278
+ subject: gateName,
3279
+ metadata: { ...meta, from, to },
3280
+ diff: { before: from, after: to }
3281
+ });
3282
+ }
3283
+ recordBuildAudit(score, delta, meta = {}) {
3284
+ return this.record({
3285
+ kind: "build",
3286
+ action: "audit-complete",
3287
+ subject: "completeness",
3288
+ metadata: { ...meta, score, delta }
3289
+ });
3290
+ }
3291
+ recordFactIntroduced(factTag, meta = {}) {
3292
+ return this.record({ kind: "fact", action: "introduced", subject: factTag, metadata: meta });
3293
+ }
3294
+ recordFactDeprecated(factTag, meta = {}) {
3295
+ return this.record({ kind: "fact", action: "deprecated", subject: factTag, metadata: meta });
3296
+ }
3297
+ // ── Access ──────────────────────────────────────────────────────────────
3298
+ /** Return a shallow copy of all events. */
3299
+ getEvents() {
3300
+ return [...this.events];
3301
+ }
3302
+ /** Total number of recorded events. */
3303
+ get size() {
3304
+ return this.events.length;
3305
+ }
3306
+ /** Clear all events (primarily for testing). */
3307
+ clear() {
3308
+ this.events = [];
3309
+ }
3310
+ };
3311
+ function createProjectChronicle(options) {
3312
+ return new ProjectChronicle(options);
3313
+ }
3314
+
3315
+ // src/chronos/timeline.ts
3316
+ var Timeline = class {
3317
+ constructor(chronicle) {
3318
+ this.chronicle = chronicle;
3319
+ }
3320
+ // ── Queries ─────────────────────────────────────────────────────────────
3321
+ /**
3322
+ * Query events with optional filtering.
3323
+ * Returns matching events sorted chronologically (oldest first).
3324
+ */
3325
+ getTimeline(filter) {
3326
+ let events = this.chronicle.getEvents();
3327
+ if (!filter) return events;
3328
+ events = applyFilter(events, filter);
3329
+ return events;
3330
+ }
3331
+ /**
3332
+ * Get all events since a timestamp (inclusive).
3333
+ */
3334
+ getEventsSince(timestamp) {
3335
+ return this.getTimeline({ since: timestamp });
3336
+ }
3337
+ /**
3338
+ * Compute a behavioral delta between two timestamps.
3339
+ */
3340
+ getDelta(from, to) {
3341
+ const events = this.getTimeline({ since: from, until: to });
3342
+ return buildDelta(from, to, events);
3343
+ }
3344
+ /**
3345
+ * Get full history for a specific subject (rule id, gate name, etc.).
3346
+ * Sorted chronologically.
3347
+ */
3348
+ getHistory(subjectId) {
3349
+ return this.getTimeline({ subject: subjectId });
3350
+ }
3351
+ };
3352
+ function applyFilter(events, filter) {
3353
+ return events.filter((e) => {
3354
+ if (filter.kind) {
3355
+ const kinds = Array.isArray(filter.kind) ? filter.kind : [filter.kind];
3356
+ if (!kinds.includes(e.kind)) return false;
3357
+ }
3358
+ if (filter.action) {
3359
+ const actions = Array.isArray(filter.action) ? filter.action : [filter.action];
3360
+ if (!actions.includes(e.action)) return false;
3361
+ }
3362
+ if (filter.subject) {
3363
+ const subjects = Array.isArray(filter.subject) ? filter.subject : [filter.subject];
3364
+ if (!subjects.includes(e.subject)) return false;
3365
+ }
3366
+ if (filter.since != null && e.timestamp < filter.since) return false;
3367
+ if (filter.until != null && e.timestamp > filter.until) return false;
3368
+ return true;
3369
+ });
3370
+ }
3371
+ var ADD_ACTIONS = /* @__PURE__ */ new Set(["registered", "added", "introduced", "opened"]);
3372
+ var REMOVE_ACTIONS = /* @__PURE__ */ new Set(["removed", "deprecated", "closed"]);
3373
+ var MODIFY_ACTIONS = /* @__PURE__ */ new Set(["modified", "updated"]);
3374
+ function buildDelta(from, to, events) {
3375
+ const summary = {};
3376
+ const added = /* @__PURE__ */ new Set();
3377
+ const removed = /* @__PURE__ */ new Set();
3378
+ const modified = /* @__PURE__ */ new Set();
3379
+ for (const e of events) {
3380
+ summary[e.kind] = (summary[e.kind] ?? 0) + 1;
3381
+ if (ADD_ACTIONS.has(e.action)) {
3382
+ added.add(e.subject);
3383
+ removed.delete(e.subject);
3384
+ } else if (REMOVE_ACTIONS.has(e.action)) {
3385
+ removed.add(e.subject);
3386
+ added.delete(e.subject);
3387
+ } else if (MODIFY_ACTIONS.has(e.action)) {
3388
+ modified.add(e.subject);
3389
+ }
3390
+ }
3391
+ return {
3392
+ from,
3393
+ to,
3394
+ events,
3395
+ summary,
3396
+ added: [...added],
3397
+ removed: [...removed],
3398
+ modified: [...modified]
3399
+ };
3400
+ }
3401
+ function createTimeline(chronicle) {
3402
+ return new Timeline(chronicle);
3403
+ }
3404
+
3405
+ // src/chronos/hooks.ts
3406
+ function enableProjectChronicle(registry, engine, options = {}) {
3407
+ const chronicle = options.chronicle ?? createProjectChronicle();
3408
+ const recordSteps = options.recordSteps ?? true;
3409
+ const recordConstraints = options.recordConstraints ?? true;
3410
+ const origRegisterRule = registry.registerRule.bind(registry);
3411
+ const origRegisterModule = registry.registerModule.bind(registry);
3412
+ const origStep = engine.step.bind(engine);
3413
+ const origCheckConstraints = engine.checkConstraints.bind(engine);
3414
+ registry.registerRule = function hookedRegisterRule(descriptor) {
3415
+ origRegisterRule(descriptor);
3416
+ chronicle.recordRuleRegistered(descriptor.id, {
3417
+ description: descriptor.description,
3418
+ hasContract: !!descriptor.contract,
3419
+ eventTypes: descriptor.eventTypes
3420
+ });
3421
+ if (descriptor.contract) {
3422
+ chronicle.recordContractAdded(descriptor.id, {
3423
+ behavior: descriptor.contract.behavior,
3424
+ examplesCount: descriptor.contract.examples?.length ?? 0,
3425
+ invariantsCount: descriptor.contract.invariants?.length ?? 0
3426
+ });
3427
+ }
3428
+ };
3429
+ registry.registerModule = function hookedRegisterModule(module) {
3430
+ origRegisterModule(module);
3431
+ for (const rule of module.rules) {
3432
+ chronicle.recordRuleRegistered(rule.id, {
3433
+ description: rule.description,
3434
+ hasContract: !!rule.contract,
3435
+ eventTypes: rule.eventTypes,
3436
+ registeredVia: "module"
3437
+ });
3438
+ if (rule.contract) {
3439
+ chronicle.recordContractAdded(rule.id, {
3440
+ behavior: rule.contract.behavior,
3441
+ examplesCount: rule.contract.examples?.length ?? 0,
3442
+ invariantsCount: rule.contract.invariants?.length ?? 0
3443
+ });
3444
+ }
3445
+ }
3446
+ };
3447
+ if (recordSteps) {
3448
+ engine.step = function hookedStep(events) {
3449
+ const result = origStep(events);
3450
+ const factTags = /* @__PURE__ */ new Set();
3451
+ for (const fact2 of result.state.facts) {
3452
+ factTags.add(fact2.tag);
3453
+ }
3454
+ chronicle.record({
3455
+ kind: "build",
3456
+ action: "step-complete",
3457
+ subject: "engine",
3458
+ metadata: {
3459
+ eventsProcessed: events.length,
3460
+ eventTags: events.map((e) => e.tag),
3461
+ factsAfter: result.state.facts.length,
3462
+ diagnosticsCount: result.diagnostics.length
3463
+ }
3464
+ });
3465
+ for (const diag of result.diagnostics) {
3466
+ if (diag.kind === "constraint-violation") {
3467
+ chronicle.record({
3468
+ kind: "expectation",
3469
+ action: "violated",
3470
+ subject: extractSubjectFromDiag(diag),
3471
+ metadata: { message: diag.message, data: diag.data }
3472
+ });
3473
+ }
3474
+ }
3475
+ return result;
3476
+ };
3477
+ }
3478
+ if (recordConstraints) {
3479
+ engine.checkConstraints = function hookedCheckConstraints() {
3480
+ const diagnostics = origCheckConstraints();
3481
+ chronicle.record({
3482
+ kind: "build",
3483
+ action: "constraints-checked",
3484
+ subject: "engine",
3485
+ metadata: {
3486
+ violations: diagnostics.length
3487
+ }
3488
+ });
3489
+ for (const diag of diagnostics) {
3490
+ chronicle.record({
3491
+ kind: "expectation",
3492
+ action: "violated",
3493
+ subject: extractSubjectFromDiag(diag),
3494
+ metadata: { message: diag.message }
3495
+ });
3496
+ }
3497
+ return diagnostics;
3498
+ };
3499
+ }
3500
+ function disconnect() {
3501
+ registry.registerRule = origRegisterRule;
3502
+ registry.registerModule = origRegisterModule;
3503
+ engine.step = origStep;
3504
+ engine.checkConstraints = origCheckConstraints;
3505
+ }
3506
+ return { chronicle, disconnect };
3507
+ }
3508
+ function recordAudit(chronicle, report, previousScore) {
3509
+ const delta = previousScore != null ? report.score - previousScore : 0;
3510
+ chronicle.recordBuildAudit(report.score, delta, {
3511
+ rating: report.rating,
3512
+ rulesCovered: report.rules.covered,
3513
+ rulesTotal: report.rules.total,
3514
+ constraintsCovered: report.constraints.covered,
3515
+ constraintsTotal: report.constraints.total,
3516
+ contractsCovered: report.contracts.withContracts,
3517
+ contractsTotal: report.contracts.total
3518
+ });
3519
+ }
3520
+ function extractSubjectFromDiag(diag) {
3521
+ const data = diag.data;
3522
+ if (data?.constraintId && typeof data.constraintId === "string") return data.constraintId;
3523
+ if (data?.ruleId && typeof data.ruleId === "string") return data.ruleId;
3524
+ return "unknown";
3525
+ }
3526
+
3527
+ // src/chronos/diff.ts
3528
+ function diffRegistries(before, after) {
3529
+ const beforeRules = toIdMap(before.rules);
3530
+ const afterRules = toIdMap(after.rules);
3531
+ const beforeConstraints = toIdMap(before.constraints);
3532
+ const afterConstraints = toIdMap(after.constraints);
3533
+ return {
3534
+ rulesAdded: setDiff(afterRules, beforeRules),
3535
+ rulesRemoved: setDiff(beforeRules, afterRules),
3536
+ rulesModified: findModified(beforeRules, afterRules),
3537
+ constraintsAdded: setDiff(afterConstraints, beforeConstraints),
3538
+ constraintsRemoved: setDiff(beforeConstraints, afterConstraints),
3539
+ constraintsModified: findModified(beforeConstraints, afterConstraints)
3540
+ };
3541
+ }
3542
+ function diffContracts(before, after) {
3543
+ const beforeMap = toRecord(before.coverage);
3544
+ const afterMap = toRecord(after.coverage);
3545
+ const contractsAdded = [];
3546
+ const contractsRemoved = [];
3547
+ for (const [id, has] of Object.entries(afterMap)) {
3548
+ if (has && !beforeMap[id]) {
3549
+ contractsAdded.push(id);
3550
+ }
3551
+ }
3552
+ for (const [id, had] of Object.entries(beforeMap)) {
3553
+ if (had && !afterMap[id]) {
3554
+ contractsRemoved.push(id);
3555
+ }
3556
+ }
3557
+ const countTrue = (r) => Object.values(r).filter(Boolean).length;
3558
+ const totalBefore = Object.keys(beforeMap).length;
3559
+ const totalAfter = Object.keys(afterMap).length;
3560
+ return {
3561
+ contractsAdded,
3562
+ contractsRemoved,
3563
+ coverageBefore: totalBefore > 0 ? countTrue(beforeMap) / totalBefore : 0,
3564
+ coverageAfter: totalAfter > 0 ? countTrue(afterMap) / totalAfter : 0
3565
+ };
3566
+ }
3567
+ function diffExpectations(before, after) {
3568
+ const beforeMap = toRecord(before.expectations);
3569
+ const afterMap = toRecord(after.expectations);
3570
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(beforeMap), ...Object.keys(afterMap)]);
3571
+ const newlySatisfied = [];
3572
+ const newlyViolated = [];
3573
+ const unchanged = [];
3574
+ for (const key of allKeys) {
3575
+ const was = beforeMap[key] ?? false;
3576
+ const is = afterMap[key] ?? false;
3577
+ if (!was && is) {
3578
+ newlySatisfied.push(key);
3579
+ } else if (was && !is) {
3580
+ newlyViolated.push(key);
3581
+ } else {
3582
+ unchanged.push(key);
3583
+ }
3584
+ }
3585
+ return { newlySatisfied, newlyViolated, unchanged };
3586
+ }
3587
+ function formatDelta(diff) {
3588
+ const lines = [];
3589
+ if (diff.rulesAdded.length > 0)
3590
+ lines.push(`+ Rules added: ${diff.rulesAdded.join(", ")}`);
3591
+ if (diff.rulesRemoved.length > 0)
3592
+ lines.push(`- Rules removed: ${diff.rulesRemoved.join(", ")}`);
3593
+ if (diff.rulesModified.length > 0)
3594
+ lines.push(`~ Rules modified: ${diff.rulesModified.join(", ")}`);
3595
+ if (diff.constraintsAdded.length > 0)
3596
+ lines.push(`+ Constraints added: ${diff.constraintsAdded.join(", ")}`);
3597
+ if (diff.constraintsRemoved.length > 0)
3598
+ lines.push(`- Constraints removed: ${diff.constraintsRemoved.join(", ")}`);
3599
+ if (diff.constraintsModified.length > 0)
3600
+ lines.push(`~ Constraints modified: ${diff.constraintsModified.join(", ")}`);
3601
+ return lines.length > 0 ? lines.join("\n") : "No behavioral changes.";
3602
+ }
3603
+ function formatCommitMessage(diff) {
3604
+ const praxisDiff = {
3605
+ rulesAdded: diff.rulesAdded,
3606
+ rulesRemoved: diff.rulesRemoved,
3607
+ rulesModified: diff.rulesModified,
3608
+ contractsAdded: [],
3609
+ contractsRemoved: [],
3610
+ expectationsAdded: diff.constraintsAdded,
3611
+ expectationsRemoved: diff.constraintsRemoved,
3612
+ gateChanges: []
3613
+ };
3614
+ return commitFromDiff(praxisDiff);
3615
+ }
3616
+ function formatReleaseNotes(diffs) {
3617
+ const sections = [];
3618
+ const allAdded = [];
3619
+ const allRemoved = [];
3620
+ const allModified = [];
3621
+ for (const diff of diffs) {
3622
+ allAdded.push(...diff.rulesAdded, ...diff.constraintsAdded);
3623
+ allRemoved.push(...diff.rulesRemoved, ...diff.constraintsRemoved);
3624
+ allModified.push(...diff.rulesModified, ...diff.constraintsModified);
3625
+ }
3626
+ const added = [...new Set(allAdded)];
3627
+ const removed = [...new Set(allRemoved)];
3628
+ const modified = [...new Set(allModified)];
3629
+ if (added.length > 0) {
3630
+ sections.push(`### Added
3631
+ ${added.map((id) => `- ${id}`).join("\n")}`);
3632
+ }
3633
+ if (modified.length > 0) {
3634
+ sections.push(`### Changed
3635
+ ${modified.map((id) => `- ${id}`).join("\n")}`);
3636
+ }
3637
+ if (removed.length > 0) {
3638
+ sections.push(`### Removed
3639
+ ${removed.map((id) => `- ${id}`).join("\n")}`);
3640
+ }
3641
+ if (sections.length === 0) return "No behavioral changes in this release.";
3642
+ return `## Release Notes
3643
+
3644
+ ${sections.join("\n\n")}`;
3645
+ }
3646
+ function toIdMap(input) {
3647
+ if (input instanceof Map) return input;
3648
+ const map = /* @__PURE__ */ new Map();
3649
+ for (const item of input) map.set(item.id, item);
3650
+ return map;
3651
+ }
3652
+ function setDiff(a, b) {
3653
+ const result = [];
3654
+ for (const key of a.keys()) {
3655
+ if (!b.has(key)) result.push(key);
3656
+ }
3657
+ return result;
3658
+ }
3659
+ function findModified(before, after) {
3660
+ const result = [];
3661
+ for (const [key, beforeVal] of before) {
3662
+ const afterVal = after.get(key);
3663
+ if (afterVal && beforeVal.description !== afterVal.description) {
3664
+ result.push(key);
3665
+ }
3666
+ }
3667
+ return result;
3668
+ }
3669
+ function toRecord(input) {
3670
+ if (input instanceof Map) {
3671
+ const result = {};
3672
+ for (const [k, v] of input) result[k] = v;
3673
+ return result;
3674
+ }
3675
+ return input;
3676
+ }
3677
+ function commitFromDiff(diff) {
3678
+ const parts = [];
3679
+ const bodyParts = [];
3680
+ const totalAdded = diff.rulesAdded.length + diff.contractsAdded.length + diff.expectationsAdded.length;
3681
+ const totalRemoved = diff.rulesRemoved.length + diff.contractsRemoved.length + diff.expectationsRemoved.length;
3682
+ const totalModified = diff.rulesModified.length;
3683
+ if (totalAdded > 0 && totalRemoved === 0 && totalModified === 0) {
3684
+ if (diff.rulesAdded.length > 0) {
3685
+ const scope = inferScope2(diff.rulesAdded);
3686
+ parts.push(`feat(${scope}): add ${fmtIds(diff.rulesAdded)}`);
3687
+ } else if (diff.contractsAdded.length > 0) {
3688
+ parts.push(`feat(contracts): add contracts for ${fmtIds(diff.contractsAdded)}`);
3689
+ } else {
3690
+ parts.push(`feat(expectations): add ${fmtIds(diff.expectationsAdded)}`);
3691
+ }
3692
+ } else if (totalRemoved > 0 && totalAdded === 0) {
3693
+ if (diff.rulesRemoved.length > 0) {
3694
+ const scope = inferScope2(diff.rulesRemoved);
3695
+ parts.push(`refactor(${scope}): remove ${fmtIds(diff.rulesRemoved)}`);
3696
+ } else {
3697
+ parts.push(`refactor: remove ${totalRemoved} item(s)`);
3698
+ }
3699
+ } else if (totalModified > 0) {
3700
+ const scope = inferScope2(diff.rulesModified);
3701
+ parts.push(`refactor(${scope}): update ${fmtIds(diff.rulesModified)}`);
3702
+ } else {
3703
+ parts.push("chore: behavioral state update");
3704
+ }
3705
+ if (diff.rulesAdded.length > 0) bodyParts.push(`Rules added: ${diff.rulesAdded.join(", ")}`);
3706
+ if (diff.rulesRemoved.length > 0) bodyParts.push(`Rules removed: ${diff.rulesRemoved.join(", ")}`);
3707
+ if (diff.rulesModified.length > 0) bodyParts.push(`Rules modified: ${diff.rulesModified.join(", ")}`);
3708
+ const subject = parts[0] || "chore: update";
3709
+ return bodyParts.length > 0 ? `${subject}
3710
+
3711
+ ${bodyParts.join("\n")}` : subject;
3712
+ }
3713
+ function inferScope2(ids) {
3714
+ if (ids.length === 0) return "rules";
3715
+ const prefixes = ids.map((id) => {
3716
+ const slash = id.indexOf("/");
3717
+ return slash > 0 ? id.slice(0, slash) : id;
3718
+ });
3719
+ const unique = new Set(prefixes);
3720
+ return unique.size === 1 ? prefixes[0] : "rules";
3721
+ }
3722
+ function fmtIds(ids) {
3723
+ if (ids.length <= 3) return ids.join(", ");
3724
+ return `${ids.slice(0, 2).join(", ")} (+${ids.length - 2} more)`;
3725
+ }
3196
3726
  export {
3197
3727
  AcknowledgeContractGap,
3198
3728
  ActorManager,
@@ -3217,12 +3747,15 @@ export {
3217
3747
  PraxisDBStore,
3218
3748
  PraxisRegistry,
3219
3749
  PraxisSchemaRegistry,
3750
+ ProjectChronicle,
3220
3751
  ReactiveLogicEngine,
3221
3752
  RegistryIntrospector,
3222
3753
  RuleResult,
3223
3754
  StateDocsGenerator,
3224
3755
  TerminalAdapter,
3756
+ Timeline,
3225
3757
  ValidateContracts,
3758
+ analyzeDependencyGraph,
3226
3759
  attachAllIntegrations,
3227
3760
  attachTauriToEngine,
3228
3761
  attachToEngine,
@@ -3233,6 +3766,7 @@ export {
3233
3766
  canvasToSchema,
3234
3767
  canvasToYaml,
3235
3768
  commitFromState,
3769
+ createApp,
3236
3770
  createBehaviorLedger,
3237
3771
  createCanvasEditor,
3238
3772
  createChronicle,
@@ -3248,16 +3782,19 @@ export {
3248
3782
  createPraxisDBStore,
3249
3783
  createPraxisEngine,
3250
3784
  createPraxisLocalFirst,
3785
+ createProjectChronicle,
3251
3786
  createReactiveEngine,
3252
3787
  createSchemaRegistry,
3253
3788
  createSchemaTemplate,
3254
3789
  createStateDocsGenerator,
3255
3790
  createTauriPraxisAdapter,
3256
3791
  createTerminalAdapter,
3792
+ createTimeline,
3257
3793
  createTimerActor,
3258
3794
  createUIModule,
3259
3795
  createUnifiedApp,
3260
3796
  createUnumAdapter,
3797
+ crossReferenceContracts,
3261
3798
  dataRules,
3262
3799
  defineConstraint,
3263
3800
  defineContract,
@@ -3265,18 +3802,38 @@ export {
3265
3802
  defineFact,
3266
3803
  defineGate,
3267
3804
  defineModule,
3805
+ definePath,
3268
3806
  defineRule,
3807
+ defineConstraint2 as defineUnifiedConstraint,
3808
+ defineModule2 as defineUnifiedModule,
3809
+ defineRule2 as defineUnifiedRule,
3810
+ diffContracts,
3811
+ diffExpectations,
3812
+ diffLedgers,
3813
+ diffRegistries,
3269
3814
  dirtyGuardRule,
3815
+ enableProjectChronicle,
3270
3816
  errorDisplayRule,
3271
3817
  expectBehavior,
3272
3818
  expectationGate,
3273
3819
  fact,
3274
3820
  filterEvents,
3275
3821
  filterFacts,
3822
+ findContractGaps,
3823
+ findContradictions,
3824
+ findDeadRules,
3276
3825
  findEvent,
3277
3826
  findFact,
3827
+ findGaps,
3828
+ findShadowedRules,
3829
+ findUnreachableStates,
3278
3830
  formRules,
3831
+ formatCommitMessage as formatBehavioralCommit,
3832
+ formatBuildOutput,
3833
+ formatDelta,
3279
3834
  formatGate,
3835
+ formatLedger,
3836
+ formatReleaseNotes,
3280
3837
  formatReport,
3281
3838
  formatValidationReport,
3282
3839
  formatValidationReportJSON,
@@ -3284,6 +3841,7 @@ export {
3284
3841
  formatVerificationReport,
3285
3842
  generateDocs,
3286
3843
  generateId,
3844
+ generateLedger,
3287
3845
  generateTauriConfig,
3288
3846
  getContract,
3289
3847
  getEventPath,
@@ -3303,12 +3861,17 @@ export {
3303
3861
  navigationRules,
3304
3862
  noInteractionWhileLoadingConstraint,
3305
3863
  offlineIndicatorRule,
3864
+ recordAudit,
3306
3865
  registerSchema,
3307
3866
  resizeEvent,
3308
3867
  runTerminalCommand,
3309
3868
  schemaToCanvas,
3310
3869
  semverContract,
3870
+ suggest,
3871
+ suggestAll,
3311
3872
  toastRules,
3873
+ traceDerivation,
3874
+ traceImpact,
3312
3875
  uiModule,
3313
3876
  uiStateChanged,
3314
3877
  validateContracts,
@@ -3316,5 +3879,7 @@ export {
3316
3879
  validateSchema,
3317
3880
  validateWithGuardian,
3318
3881
  verify,
3882
+ verifyContractExamples,
3883
+ verifyInvariants,
3319
3884
  viewportRule
3320
3885
  };