@plures/praxis 1.2.0 → 1.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +10 -96
  2. package/dist/browser/{adapter-TM4IS5KT.js → adapter-CIMBGDC7.js} +5 -3
  3. package/dist/browser/{chunk-LE2ZJYFC.js → chunk-K377RW4V.js} +76 -0
  4. package/dist/{node/chunk-JQ64KMLN.js → browser/chunk-MBVHLOU2.js} +12 -1
  5. package/dist/browser/index.d.ts +32 -5
  6. package/dist/browser/index.js +15 -7
  7. package/dist/browser/integrations/svelte.d.ts +2 -2
  8. package/dist/browser/integrations/svelte.js +1 -1
  9. package/dist/browser/{reactive-engine.svelte-C9OpcTHf.d.ts → reactive-engine.svelte-9aS0kTa8.d.ts} +136 -1
  10. package/dist/node/{adapter-K6DOX6XS.js → adapter-75ISSMWD.js} +5 -3
  11. package/dist/node/chunk-5RH7UAQC.js +486 -0
  12. package/dist/{browser/chunk-JQ64KMLN.js → node/chunk-MBVHLOU2.js} +12 -1
  13. package/dist/node/{chunk-LE2ZJYFC.js → chunk-PRPQO6R5.js} +3 -72
  14. package/dist/node/chunk-R2PSBPKQ.js +150 -0
  15. package/dist/node/chunk-WZ6B3LZ6.js +638 -0
  16. package/dist/node/cli/index.cjs +2316 -832
  17. package/dist/node/cli/index.js +18 -0
  18. package/dist/node/components/index.d.cts +3 -2
  19. package/dist/node/components/index.d.ts +3 -2
  20. package/dist/node/index.cjs +620 -38
  21. package/dist/node/index.d.cts +259 -5
  22. package/dist/node/index.d.ts +259 -5
  23. package/dist/node/index.js +55 -65
  24. package/dist/node/integrations/svelte.cjs +76 -0
  25. package/dist/node/integrations/svelte.d.cts +2 -2
  26. package/dist/node/integrations/svelte.d.ts +2 -2
  27. package/dist/node/integrations/svelte.js +2 -1
  28. package/dist/node/{reactive-engine.svelte-1M4m_C_v.d.cts → reactive-engine.svelte-BFIZfawz.d.cts} +199 -1
  29. package/dist/node/{reactive-engine.svelte-ChNFn4Hj.d.ts → reactive-engine.svelte-CRNqHlbv.d.ts} +199 -1
  30. package/dist/node/reverse-W7THPV45.js +193 -0
  31. package/dist/node/{terminal-adapter-CWka-yL8.d.ts → terminal-adapter-B-UK_Vdz.d.ts} +28 -3
  32. package/dist/node/{terminal-adapter-CDzxoLKR.d.cts → terminal-adapter-BQSIF5bf.d.cts} +28 -3
  33. package/dist/node/validate-CNHUULQE.js +180 -0
  34. package/docs/core/pluresdb-integration.md +15 -15
  35. package/docs/decision-ledger/BEHAVIOR_LEDGER.md +225 -0
  36. package/docs/decision-ledger/DecisionLedger.tla +180 -0
  37. package/docs/decision-ledger/IMPLEMENTATION_SUMMARY.md +217 -0
  38. package/docs/decision-ledger/LATEST.md +166 -0
  39. package/docs/guides/cicd-pipeline.md +142 -0
  40. package/package.json +2 -2
  41. package/src/__tests__/cli-validate.test.ts +197 -0
  42. package/src/__tests__/decision-ledger.test.ts +485 -0
  43. package/src/__tests__/reverse-generator.test.ts +189 -0
  44. package/src/__tests__/scanner.test.ts +215 -0
  45. package/src/cli/commands/reverse.ts +289 -0
  46. package/src/cli/commands/validate.ts +264 -0
  47. package/src/cli/index.ts +47 -0
  48. package/src/core/pluresdb/adapter.ts +45 -2
  49. package/src/core/rules.ts +133 -0
  50. package/src/decision-ledger/README.md +400 -0
  51. package/src/decision-ledger/REVERSE_ENGINEERING.md +484 -0
  52. package/src/decision-ledger/facts-events.ts +121 -0
  53. package/src/decision-ledger/index.ts +70 -0
  54. package/src/decision-ledger/ledger.ts +246 -0
  55. package/src/decision-ledger/logic-ledger.ts +158 -0
  56. package/src/decision-ledger/reverse-generator.ts +426 -0
  57. package/src/decision-ledger/scanner.ts +506 -0
  58. package/src/decision-ledger/types.ts +247 -0
  59. package/src/decision-ledger/validation.ts +336 -0
  60. package/src/dsl/index.ts +13 -2
  61. package/src/index.browser.ts +2 -0
  62. package/src/index.ts +36 -0
  63. package/src/integrations/pluresdb.ts +14 -2
@@ -1,78 +1,10 @@
1
+ import {
2
+ PraxisRegistry
3
+ } from "./chunk-R2PSBPKQ.js";
1
4
  import {
2
5
  createPraxisEngine
3
6
  } from "./chunk-VOMLVI6V.js";
4
7
 
5
- // src/core/rules.ts
6
- var PraxisRegistry = class {
7
- rules = /* @__PURE__ */ new Map();
8
- constraints = /* @__PURE__ */ new Map();
9
- /**
10
- * Register a rule
11
- */
12
- registerRule(descriptor) {
13
- if (this.rules.has(descriptor.id)) {
14
- throw new Error(`Rule with id "${descriptor.id}" already registered`);
15
- }
16
- this.rules.set(descriptor.id, descriptor);
17
- }
18
- /**
19
- * Register a constraint
20
- */
21
- registerConstraint(descriptor) {
22
- if (this.constraints.has(descriptor.id)) {
23
- throw new Error(`Constraint with id "${descriptor.id}" already registered`);
24
- }
25
- this.constraints.set(descriptor.id, descriptor);
26
- }
27
- /**
28
- * Register a module (all its rules and constraints)
29
- */
30
- registerModule(module) {
31
- for (const rule of module.rules) {
32
- this.registerRule(rule);
33
- }
34
- for (const constraint of module.constraints) {
35
- this.registerConstraint(constraint);
36
- }
37
- }
38
- /**
39
- * Get a rule by ID
40
- */
41
- getRule(id) {
42
- return this.rules.get(id);
43
- }
44
- /**
45
- * Get a constraint by ID
46
- */
47
- getConstraint(id) {
48
- return this.constraints.get(id);
49
- }
50
- /**
51
- * Get all registered rule IDs
52
- */
53
- getRuleIds() {
54
- return Array.from(this.rules.keys());
55
- }
56
- /**
57
- * Get all registered constraint IDs
58
- */
59
- getConstraintIds() {
60
- return Array.from(this.constraints.keys());
61
- }
62
- /**
63
- * Get all rules
64
- */
65
- getAllRules() {
66
- return Array.from(this.rules.values());
67
- }
68
- /**
69
- * Get all constraints
70
- */
71
- getAllConstraints() {
72
- return Array.from(this.constraints.values());
73
- }
74
- };
75
-
76
8
  // src/core/reactive-engine.svelte.ts
77
9
  import * as $ from "svelte/internal/client";
78
10
  var ReactiveLogicEngine = class {
@@ -148,7 +80,6 @@ function createReactiveEngine(options) {
148
80
  }
149
81
 
150
82
  export {
151
- PraxisRegistry,
152
83
  ReactiveLogicEngine,
153
84
  createReactiveEngine
154
85
  };
@@ -0,0 +1,150 @@
1
+ // src/core/rules.ts
2
+ var PraxisRegistry = class {
3
+ rules = /* @__PURE__ */ new Map();
4
+ constraints = /* @__PURE__ */ new Map();
5
+ compliance;
6
+ contractGaps = [];
7
+ constructor(options = {}) {
8
+ const defaultEnabled = typeof process !== "undefined" ? process.env?.NODE_ENV !== "production" : false;
9
+ this.compliance = {
10
+ enabled: defaultEnabled,
11
+ requiredFields: ["behavior", "examples", "invariants"],
12
+ missingSeverity: "warning",
13
+ ...options.compliance
14
+ };
15
+ }
16
+ /**
17
+ * Register a rule
18
+ */
19
+ registerRule(descriptor) {
20
+ if (this.rules.has(descriptor.id)) {
21
+ throw new Error(`Rule with id "${descriptor.id}" already registered`);
22
+ }
23
+ this.rules.set(descriptor.id, descriptor);
24
+ this.trackContractCompliance(descriptor.id, descriptor);
25
+ }
26
+ /**
27
+ * Register a constraint
28
+ */
29
+ registerConstraint(descriptor) {
30
+ if (this.constraints.has(descriptor.id)) {
31
+ throw new Error(`Constraint with id "${descriptor.id}" already registered`);
32
+ }
33
+ this.constraints.set(descriptor.id, descriptor);
34
+ this.trackContractCompliance(descriptor.id, descriptor);
35
+ }
36
+ /**
37
+ * Register a module (all its rules and constraints)
38
+ */
39
+ registerModule(module) {
40
+ for (const rule of module.rules) {
41
+ this.registerRule(rule);
42
+ }
43
+ for (const constraint of module.constraints) {
44
+ this.registerConstraint(constraint);
45
+ }
46
+ }
47
+ /**
48
+ * Get a rule by ID
49
+ */
50
+ getRule(id) {
51
+ return this.rules.get(id);
52
+ }
53
+ /**
54
+ * Get a constraint by ID
55
+ */
56
+ getConstraint(id) {
57
+ return this.constraints.get(id);
58
+ }
59
+ /**
60
+ * Get all registered rule IDs
61
+ */
62
+ getRuleIds() {
63
+ return Array.from(this.rules.keys());
64
+ }
65
+ /**
66
+ * Get all registered constraint IDs
67
+ */
68
+ getConstraintIds() {
69
+ return Array.from(this.constraints.keys());
70
+ }
71
+ /**
72
+ * Get all rules
73
+ */
74
+ getAllRules() {
75
+ return Array.from(this.rules.values());
76
+ }
77
+ /**
78
+ * Get all constraints
79
+ */
80
+ getAllConstraints() {
81
+ return Array.from(this.constraints.values());
82
+ }
83
+ /**
84
+ * Get collected contract gaps from registration-time validation.
85
+ */
86
+ getContractGaps() {
87
+ return [...this.contractGaps];
88
+ }
89
+ /**
90
+ * Clear collected contract gaps.
91
+ */
92
+ clearContractGaps() {
93
+ this.contractGaps = [];
94
+ }
95
+ trackContractCompliance(id, descriptor) {
96
+ if (!this.compliance.enabled) {
97
+ return;
98
+ }
99
+ const gaps = this.validateDescriptorContract(id, descriptor);
100
+ for (const gap of gaps) {
101
+ this.contractGaps.push(gap);
102
+ if (this.compliance.onGap) {
103
+ this.compliance.onGap(gap);
104
+ } else {
105
+ const label = gap.severity === "error" ? "ERROR" : gap.severity === "warning" ? "WARN" : "INFO";
106
+ console.warn(`[Praxis][${label}] Contract gap for "${gap.ruleId}": missing ${gap.missing.join(", ")}`);
107
+ }
108
+ }
109
+ }
110
+ validateDescriptorContract(id, descriptor) {
111
+ const requiredFields = this.compliance.requiredFields ?? ["behavior", "examples", "invariants"];
112
+ const missingSeverity = this.compliance.missingSeverity ?? "warning";
113
+ const contract = descriptor.contract ?? (descriptor.meta?.contract && typeof descriptor.meta.contract === "object" ? descriptor.meta.contract : void 0);
114
+ if (!contract) {
115
+ return [
116
+ {
117
+ ruleId: id,
118
+ missing: ["contract"],
119
+ severity: missingSeverity,
120
+ message: `Contract missing for "${id}"`
121
+ }
122
+ ];
123
+ }
124
+ const missing = [];
125
+ if (requiredFields.includes("behavior") && (!contract.behavior || contract.behavior.trim() === "")) {
126
+ missing.push("behavior");
127
+ }
128
+ if (requiredFields.includes("examples") && (!contract.examples || contract.examples.length === 0)) {
129
+ missing.push("examples");
130
+ }
131
+ if (requiredFields.includes("invariants") && (!contract.invariants || contract.invariants.length === 0)) {
132
+ missing.push("invariants");
133
+ }
134
+ if (missing.length === 0) {
135
+ return [];
136
+ }
137
+ return [
138
+ {
139
+ ruleId: id,
140
+ missing,
141
+ severity: "warning",
142
+ message: `Contract for "${id}" is incomplete: missing ${missing.join(", ")}`
143
+ }
144
+ ];
145
+ }
146
+ };
147
+
148
+ export {
149
+ PraxisRegistry
150
+ };