@geonosis/policy 2.13.0 → 3.1.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 (62) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/conformance.cjs +169 -0
  3. package/dist/conformance.d.cts +35 -0
  4. package/dist/conformance.d.ts +35 -0
  5. package/dist/conformance.js +129 -0
  6. package/dist/define.cjs +118 -0
  7. package/dist/define.d.cts +34 -0
  8. package/dist/define.d.ts +34 -0
  9. package/dist/define.js +85 -0
  10. package/dist/drizzle/index.cjs +37 -32
  11. package/dist/drizzle/index.d.cts +20 -23
  12. package/dist/drizzle/index.d.ts +20 -23
  13. package/dist/drizzle/index.js +2 -5
  14. package/dist/index.cjs +79 -856
  15. package/dist/index.d.cts +19 -428
  16. package/dist/index.d.ts +19 -428
  17. package/dist/index.js +35 -797
  18. package/dist/journal-events.cjs +68 -0
  19. package/dist/journal-events.d.cts +26 -0
  20. package/dist/journal-events.d.ts +26 -0
  21. package/dist/journal-events.js +28 -0
  22. package/dist/lattice.cjs +150 -0
  23. package/dist/lattice.d.cts +48 -0
  24. package/dist/lattice.d.ts +48 -0
  25. package/dist/lattice.js +110 -0
  26. package/dist/learning.cjs +246 -0
  27. package/dist/learning.d.cts +121 -0
  28. package/dist/learning.d.ts +121 -0
  29. package/dist/learning.js +206 -0
  30. package/dist/markdown.cjs +118 -0
  31. package/dist/markdown.d.cts +35 -0
  32. package/dist/markdown.d.ts +35 -0
  33. package/dist/markdown.js +78 -0
  34. package/dist/medusa/index.cjs +39 -36
  35. package/dist/medusa/index.d.cts +14 -16
  36. package/dist/medusa/index.d.ts +14 -16
  37. package/dist/medusa/index.js +4 -9
  38. package/dist/permissions/index.cjs +49 -40
  39. package/dist/permissions/index.d.cts +18 -20
  40. package/dist/permissions/index.d.ts +18 -20
  41. package/dist/permissions/index.js +15 -25
  42. package/dist/read.cjs +111 -0
  43. package/dist/read.d.cts +51 -0
  44. package/dist/read.d.ts +51 -0
  45. package/dist/read.js +71 -0
  46. package/dist/rows.cjs +54 -0
  47. package/dist/rows.d.cts +11 -0
  48. package/dist/rows.d.ts +11 -0
  49. package/dist/{chunk-JICJ4XEX.js → rows.js} +0 -3
  50. package/dist/seed.cjs +53 -0
  51. package/dist/seed.d.cts +18 -0
  52. package/dist/seed.d.ts +18 -0
  53. package/dist/seed.js +13 -0
  54. package/dist/threshold.cjs +73 -0
  55. package/dist/threshold.d.cts +45 -0
  56. package/dist/threshold.d.ts +45 -0
  57. package/dist/threshold.js +33 -0
  58. package/dist/types.cjs +47 -0
  59. package/dist/{types-C-Q3r-In.d.cts → types.d.cts} +21 -23
  60. package/dist/{types-C-Q3r-In.d.ts → types.d.ts} +21 -23
  61. package/dist/types.js +7 -0
  62. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  /** Something a port may answer with, or answer with later. */
2
- type Awaitable<T> = Promise<T> | T;
2
+ export type Awaitable<T> = Promise<T> | T;
3
3
  /**
4
4
  * A schema, recognised by what it does rather than by what it is an instance of.
5
5
  *
@@ -9,16 +9,16 @@ type Awaitable<T> = Promise<T> | T;
9
9
  * object, so a schema from another copy is not an instance of ours: such a guard passes every test
10
10
  * written against the kit's own zod and refuses every schema a consumer hands it.
11
11
  */
12
- type SchemaLike = {
12
+ export type SchemaLike = {
13
13
  safeParse: (value: unknown) => {
14
14
  success: boolean;
15
15
  };
16
16
  };
17
17
  /** What a rule is aimed at, and what a decision is being made about. */
18
- type PolicyScope = Record<string, unknown>;
19
- type PolicyQuery = PolicyScope;
18
+ export type PolicyScope = Record<string, unknown>;
19
+ export type PolicyQuery = PolicyScope;
20
20
  /** One authored constraint: a value, plus who said it, who it reaches and why it exists. */
21
- type PolicyRule = {
21
+ export type PolicyRule = {
22
22
  constraint: {
23
23
  kind: string;
24
24
  value: unknown;
@@ -33,7 +33,7 @@ type PolicyRule = {
33
33
  tier: string;
34
34
  };
35
35
  /** One authority, in a lattice declared strongest first. */
36
- type PolicyTierSpec = {
36
+ export type PolicyTierSpec = {
37
37
  /** Fills silence only. A promoted learning enters here and can never outrank an authority. */
38
38
  advisory?: boolean;
39
39
  name: string;
@@ -43,7 +43,7 @@ type PolicyTierSpec = {
43
43
  overrides?: boolean;
44
44
  };
45
45
  /** One thing policy may constrain, and what is true of its values. */
46
- type PolicyKindSpec = {
46
+ export type PolicyKindSpec = {
47
47
  /**
48
48
  * Read the value this one POINTS at. Called only when `isReference` says so; answering
49
49
  * `undefined` means the thing it points at is unset, which is a gap and not a number — the read
@@ -68,7 +68,7 @@ type PolicyKindSpec = {
68
68
  schema?: SchemaLike;
69
69
  };
70
70
  /** What policy decided, and the whole trace of why. */
71
- type PolicyDecision<V = unknown> = {
71
+ export type PolicyDecision<V = unknown> = {
72
72
  /** Same authority, same specificity, DIFFERENT value. Reported, never guessed. */
73
73
  conflicts: PolicyRule[];
74
74
  explain: string;
@@ -81,25 +81,25 @@ type PolicyDecision<V = unknown> = {
81
81
  winner: PolicyRule;
82
82
  };
83
83
  /** A rule this build cannot honour, and the reason nobody has to guess at. */
84
- type UnusableRule = {
84
+ export type UnusableRule = {
85
85
  id: string;
86
86
  reason: string;
87
87
  };
88
88
  /** Where the authored rules come from. */
89
- type PolicyRuleReader = {
89
+ export type PolicyRuleReader = {
90
90
  rules: (kind: string, query: PolicyQuery) => Awaitable<readonly PolicyRule[]>;
91
91
  };
92
92
  /** The layer an admin can edit. `undefined` means no value is set. */
93
- type PolicyConfigReader = {
93
+ export type PolicyConfigReader = {
94
94
  get: (kind: string, query: PolicyQuery) => Awaitable<unknown>;
95
95
  };
96
96
  /** Where a fallback is recorded. Best-effort by contract: it may never change a decision. */
97
- type PolicyJournal = {
97
+ export type PolicyJournal = {
98
98
  write: (entry: PolicyJournalEntry) => Awaitable<void>;
99
99
  };
100
- declare const POLICY_FALLBACK = "policy.fallback";
101
- declare const POLICY_INVALID_VALUE = "policy.invalid_value";
102
- type PolicyJournalEntry = {
100
+ export declare const POLICY_FALLBACK = "policy.fallback";
101
+ export declare const POLICY_INVALID_VALUE = "policy.invalid_value";
102
+ export type PolicyJournalEntry = {
103
103
  event: typeof POLICY_FALLBACK | typeof POLICY_INVALID_VALUE;
104
104
  /** The value that decided instead. */
105
105
  fellBackTo: unknown;
@@ -113,7 +113,7 @@ type PolicyJournalEntry = {
113
113
  subject?: string;
114
114
  };
115
115
  /** The data half of a policy — everything the lattice needs and nothing it does not. */
116
- type PolicyData = {
116
+ export type PolicyData = {
117
117
  kinds: readonly PolicyKindSpec[];
118
118
  overridableByDefault: boolean;
119
119
  rules: readonly PolicyRule[];
@@ -122,7 +122,7 @@ type PolicyData = {
122
122
  /** Strongest first. */
123
123
  tiers: readonly PolicyTierSpec[];
124
124
  };
125
- type Policy = PolicyData & {
125
+ export type Policy = PolicyData & {
126
126
  /** The fallbacks and unusable values this process has already recorded, keyed per boot. */
127
127
  journalledOnce: Set<string>;
128
128
  kindOf: (kind: string) => PolicyKindSpec | undefined;
@@ -143,7 +143,7 @@ type Policy = PolicyData & {
143
143
  usableRules: (rules?: readonly PolicyRule[]) => PolicyRule[];
144
144
  };
145
145
  /** One recorded thing that happened, as the learning loop reads it. */
146
- type JournalObservationEntry = {
146
+ export type JournalObservationEntry = {
147
147
  actor: {
148
148
  id?: string;
149
149
  kind: 'agent' | 'system' | 'user';
@@ -164,7 +164,7 @@ type JournalObservationEntry = {
164
164
  subject?: string;
165
165
  };
166
166
  /** What a read answered with, and which layer answered. */
167
- type PolicyReading<V> = {
167
+ export type PolicyReading<V> = {
168
168
  /** Absent when no rule spoke and a lower layer decided. */
169
169
  decision?: PolicyDecision<V>;
170
170
  source: 'config' | 'fallback' | 'rule';
@@ -179,7 +179,7 @@ type PolicyReading<V> = {
179
179
  * because the surrogate id is the store's and the KEY is the rule's: it is what a refusal quotes,
180
180
  * and what lets evidence accumulate against one rule across environments.
181
181
  */
182
- type PolicyRuleRow = {
182
+ export type PolicyRuleRow = {
183
183
  constraint_kind: string;
184
184
  constraint_value: unknown;
185
185
  overridable?: boolean | null;
@@ -191,12 +191,10 @@ type PolicyRuleRow = {
191
191
  tier: string;
192
192
  };
193
193
  /** What a store offers the kernel. Every port is optional except the rules themselves. */
194
- type PolicyAdapter = {
194
+ export type PolicyAdapter = {
195
195
  config?: PolicyConfigReader;
196
196
  journal?: PolicyJournal;
197
197
  /** For a diagnostic — a report naming "the adapter" helps nobody. */
198
198
  name: string;
199
199
  rule: PolicyRuleReader;
200
200
  };
201
-
202
- export { type Awaitable as A, type JournalObservationEntry as J, type PolicyQuery as P, type SchemaLike as S, type UnusableRule as U, type PolicyRuleRow as a, type PolicyAdapter as b, type PolicyKindSpec as c, type PolicyRule as d, type PolicyTierSpec as e, type Policy as f, type PolicyData as g, type PolicyDecision as h, type PolicyScope as i, type PolicyJournal as j, type PolicyConfigReader as k, type PolicyRuleReader as l, type PolicyReading as m, POLICY_FALLBACK as n, POLICY_INVALID_VALUE as o, type PolicyJournalEntry as p };
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ // src/types.ts
2
+ var POLICY_FALLBACK = "policy.fallback";
3
+ var POLICY_INVALID_VALUE = "policy.invalid_value";
4
+ export {
5
+ POLICY_FALLBACK,
6
+ POLICY_INVALID_VALUE
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geonosis/policy",
3
- "version": "2.13.0",
3
+ "version": "3.1.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "description": "A threshold is a value plus the authority that set it, the subject it reaches and the reason it exists. The precedence lattice, the rule → config → constant read with its fallback journalled once per boot, the learning loop, the generated policy prose, and a permission lattice with the runtime lifted out.",
6
6
  "keywords": [
@@ -76,7 +76,7 @@
76
76
  }
77
77
  },
78
78
  "devDependencies": {
79
- "zod": "^4.0.0"
79
+ "zod": "^4.6.5"
80
80
  },
81
81
  "engines": {
82
82
  "node": ">=22"
@@ -85,7 +85,7 @@
85
85
  "access": "public"
86
86
  },
87
87
  "scripts": {
88
- "build": "tsx ../../tooling/build-step.ts tsup",
88
+ "build": "bun ../../tooling/build-step.ts bun ../../tooling/bundle.ts",
89
89
  "typecheck": "tsc --noEmit",
90
90
  "lint": "oxlint --config ../../.oxlintrc.json .",
91
91
  "test:unit": "vitest run --project unit --root ../.. --passWithNoTests \"$PWD\"",