@directive-run/knowledge 1.10.0 → 1.12.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.
@@ -0,0 +1,39 @@
1
+ // Example: compliance-audit
2
+ // Source: examples/compliance-audit/src/module.ts
3
+ // Pure module file — no DOM wiring
4
+
5
+ import { createModule, t } from "@directive-run/core";
6
+
7
+ /**
8
+ * Checkout module — three facts, one data-form constraint with three
9
+ * clauses. The constraint's whenSpec is what the audit ledger captures
10
+ * and what predicateFromIntent emits a candidate replacement for.
11
+ */
12
+ export const checkoutModule = createModule("checkout", {
13
+ schema: {
14
+ facts: {
15
+ cartTotal: t.number(),
16
+ region: t.string<"US" | "EU" | "ASIA" | "OTHER">(),
17
+ tier: t.string<"free" | "pro" | "enterprise">().meta({ tags: ["pii"] }),
18
+ },
19
+ derivations: {},
20
+ events: {},
21
+ requirements: { CHECKOUT: {} },
22
+ },
23
+ init: (facts) => {
24
+ facts.cartTotal = 30;
25
+ facts.region = "US";
26
+ facts.tier = "free";
27
+ },
28
+ constraints: {
29
+ canCheckout: {
30
+ // Data-form `when` — JSON. This is what the audit ledger captures,
31
+ // what doctor compares candidates against, and what predict() runs.
32
+ when: {
33
+ cartTotal: { $gte: 50 },
34
+ region: { $in: ["US", "EU"] },
35
+ },
36
+ require: { type: "CHECKOUT" },
37
+ },
38
+ },
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directive-run/knowledge",
3
- "version": "1.10.0",
3
+ "version": "1.12.0",
4
4
  "description": "Knowledge files, examples, and validation for Directive — the constraint-driven TypeScript runtime.",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "author": "Jason Comes",
@@ -51,8 +51,8 @@
51
51
  "tsx": "^4.19.2",
52
52
  "typescript": "^5.7.2",
53
53
  "vitest": "^3.0.0",
54
- "@directive-run/core": "1.10.0",
55
- "@directive-run/ai": "1.10.0"
54
+ "@directive-run/core": "1.12.0",
55
+ "@directive-run/ai": "1.12.0"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsx scripts/generate-api-skeleton.ts && tsx scripts/generate-sitemap.ts && tsx scripts/extract-examples.ts && tsup",