@geonosis/policy 3.0.0 → 3.2.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/CHANGELOG.md +13 -0
- package/dist/conformance.d.cts +1 -12
- package/dist/conformance.d.ts +1 -12
- package/dist/define.d.cts +2 -22
- package/dist/define.d.ts +2 -22
- package/dist/drizzle/index.cjs +2 -17
- package/dist/drizzle/index.d.cts +3 -11
- package/dist/drizzle/index.d.ts +3 -11
- package/dist/drizzle/index.js +2 -17
- package/dist/journal-events.d.cts +1 -14
- package/dist/journal-events.d.ts +1 -14
- package/dist/lattice.cjs +11 -3
- package/dist/lattice.d.cts +4 -37
- package/dist/lattice.d.ts +4 -37
- package/dist/lattice.js +11 -3
- package/dist/learning.cjs +10 -4
- package/dist/learning.d.cts +5 -58
- package/dist/learning.d.ts +5 -58
- package/dist/learning.js +10 -4
- package/dist/markdown.d.cts +2 -19
- package/dist/markdown.d.ts +2 -19
- package/dist/medusa/index.cjs +3 -18
- package/dist/medusa/index.d.cts +5 -46
- package/dist/medusa/index.d.ts +5 -46
- package/dist/medusa/index.js +2 -17
- package/dist/permissions/index.cjs +8 -4
- package/dist/permissions/index.d.cts +8 -67
- package/dist/permissions/index.d.ts +8 -67
- package/dist/permissions/index.js +8 -4
- package/dist/read.cjs +5 -11
- package/dist/read.d.cts +2 -31
- package/dist/read.d.ts +2 -31
- package/dist/read.js +1 -7
- package/dist/rows.cjs +17 -0
- package/dist/rows.d.cts +6 -9
- package/dist/rows.d.ts +6 -9
- package/dist/rows.js +17 -0
- package/dist/seed.d.cts +1 -13
- package/dist/seed.d.ts +1 -13
- package/dist/threshold.cjs +5 -1
- package/dist/threshold.d.cts +3 -29
- package/dist/threshold.d.ts +3 -29
- package/dist/threshold.js +5 -1
- package/dist/types.d.cts +2 -57
- package/dist/types.d.ts +2 -57
- package/package.json +1 -1
package/dist/types.d.cts
CHANGED
|
@@ -1,60 +1,37 @@
|
|
|
1
|
-
/** Something a port may answer with, or answer with later. */
|
|
2
1
|
export type Awaitable<T> = Promise<T> | T;
|
|
3
|
-
/**
|
|
4
|
-
* A schema, recognised by what it does rather than by what it is an instance of.
|
|
5
|
-
*
|
|
6
|
-
* A Medusa storefront imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
|
|
7
|
-
* resolves to the copy `@medusajs/deps` ships, while its own devDependency and a Workers + D1 app's catalog
|
|
8
|
-
* are two further copies of the same major. `value instanceof z.ZodType` compares against a class
|
|
9
|
-
* object, so a schema from another copy is not an instance of ours: such a guard passes every test
|
|
10
|
-
* written against the kit's own zod and refuses every schema a consumer hands it.
|
|
11
|
-
*/
|
|
2
|
+
/** Recognised by `safeParse`, not `instanceof`: a schema from another copy of zod is not an instance of ours. */
|
|
12
3
|
export type SchemaLike = {
|
|
13
4
|
safeParse: (value: unknown) => {
|
|
14
5
|
success: boolean;
|
|
15
6
|
};
|
|
16
7
|
};
|
|
17
|
-
/** What a rule is aimed at, and what a decision is being made about. */
|
|
18
8
|
export type PolicyScope = Record<string, unknown>;
|
|
19
9
|
export type PolicyQuery = PolicyScope;
|
|
20
|
-
/** One authored constraint: a value, plus who said it, who it reaches and why it exists. */
|
|
21
10
|
export type PolicyRule = {
|
|
22
11
|
constraint: {
|
|
23
12
|
kind: string;
|
|
24
13
|
value: unknown;
|
|
25
14
|
};
|
|
26
|
-
/** Stable id — quoted in every refusal and every trace, so it has to read as prose. */
|
|
27
15
|
id: string;
|
|
28
|
-
/** May the overriding tier beat this rule? Defaults to the policy's `overridableByDefault`. */
|
|
29
16
|
overridable?: boolean;
|
|
30
|
-
/** Why this rule exists, in the words of whoever set it. Printed beside every refusal. */
|
|
31
17
|
reason: string;
|
|
32
18
|
scope?: PolicyScope;
|
|
33
19
|
tier: string;
|
|
34
20
|
};
|
|
35
|
-
/** One authority, in a lattice declared strongest first. */
|
|
36
21
|
export type PolicyTierSpec = {
|
|
37
22
|
/** Fills silence only. A promoted learning enters here and can never outrank an authority. */
|
|
38
23
|
advisory?: boolean;
|
|
39
24
|
name: string;
|
|
40
|
-
/** May the overriding tier beat a rule at this tier, when the rule itself allows it? */
|
|
41
25
|
overridable?: boolean;
|
|
42
26
|
/** This tier IS the audited escape hatch. At most one per lattice. */
|
|
43
27
|
overrides?: boolean;
|
|
44
28
|
};
|
|
45
|
-
/** One thing policy may constrain, and what is true of its values. */
|
|
46
29
|
export type PolicyKindSpec = {
|
|
47
|
-
/**
|
|
48
|
-
* Read the value this one POINTS at. Called only when `isReference` says so; answering
|
|
49
|
-
* `undefined` means the thing it points at is unset, which is a gap and not a number — the read
|
|
50
|
-
* falls through to the config layer and then to the caller's constant, and journals.
|
|
51
|
-
*/
|
|
52
30
|
dereference?: (value: unknown, context: {
|
|
53
31
|
config?: PolicyConfigReader;
|
|
54
32
|
query: PolicyQuery;
|
|
55
33
|
}) => Awaitable<unknown>;
|
|
56
34
|
description?: string;
|
|
57
|
-
/** Whether this value names something else rather than holding the answer. */
|
|
58
35
|
isReference?: (value: unknown) => boolean;
|
|
59
36
|
kind: string;
|
|
60
37
|
/**
|
|
@@ -67,33 +44,26 @@ export type PolicyKindSpec = {
|
|
|
67
44
|
sameValue?: (a: unknown, b: unknown) => boolean;
|
|
68
45
|
schema?: SchemaLike;
|
|
69
46
|
};
|
|
70
|
-
/** What policy decided, and the whole trace of why. */
|
|
71
47
|
export type PolicyDecision<V = unknown> = {
|
|
72
48
|
/** Same authority, same specificity, DIFFERENT value. Reported, never guessed. */
|
|
73
49
|
conflicts: PolicyRule[];
|
|
74
50
|
explain: string;
|
|
75
51
|
kind: string;
|
|
76
|
-
/** Set when the overriding tier beat an authority that allowed it — the audit trail. */
|
|
77
52
|
overrode?: PolicyRule;
|
|
78
|
-
/** Every other rule that reached this subject, strongest first. */
|
|
79
53
|
suppressed: PolicyRule[];
|
|
80
54
|
value: V;
|
|
81
55
|
winner: PolicyRule;
|
|
82
56
|
};
|
|
83
|
-
/** A rule this build cannot honour, and the reason nobody has to guess at. */
|
|
84
57
|
export type UnusableRule = {
|
|
85
58
|
id: string;
|
|
86
59
|
reason: string;
|
|
87
60
|
};
|
|
88
|
-
/** Where the authored rules come from. */
|
|
89
61
|
export type PolicyRuleReader = {
|
|
90
62
|
rules: (kind: string, query: PolicyQuery) => Awaitable<readonly PolicyRule[]>;
|
|
91
63
|
};
|
|
92
|
-
/** The layer an admin can edit. `undefined` means no value is set. */
|
|
93
64
|
export type PolicyConfigReader = {
|
|
94
65
|
get: (kind: string, query: PolicyQuery) => Awaitable<unknown>;
|
|
95
66
|
};
|
|
96
|
-
/** Where a fallback is recorded. Best-effort by contract: it may never change a decision. */
|
|
97
67
|
export type PolicyJournal = {
|
|
98
68
|
write: (entry: PolicyJournalEntry) => Awaitable<void>;
|
|
99
69
|
};
|
|
@@ -101,10 +71,8 @@ export declare const POLICY_FALLBACK = "policy.fallback";
|
|
|
101
71
|
export declare const POLICY_INVALID_VALUE = "policy.invalid_value";
|
|
102
72
|
export type PolicyJournalEntry = {
|
|
103
73
|
event: typeof POLICY_FALLBACK | typeof POLICY_INVALID_VALUE;
|
|
104
|
-
/** The value that decided instead. */
|
|
105
74
|
fellBackTo: unknown;
|
|
106
75
|
kind: string;
|
|
107
|
-
/** A named operation, so repeats are countable per operation rather than per request. */
|
|
108
76
|
op?: string;
|
|
109
77
|
rejected?: {
|
|
110
78
|
reason: string;
|
|
@@ -112,18 +80,14 @@ export type PolicyJournalEntry = {
|
|
|
112
80
|
};
|
|
113
81
|
subject?: string;
|
|
114
82
|
};
|
|
115
|
-
/** The data half of a policy — everything the lattice needs and nothing it does not. */
|
|
116
83
|
export type PolicyData = {
|
|
117
84
|
kinds: readonly PolicyKindSpec[];
|
|
118
85
|
overridableByDefault: boolean;
|
|
119
86
|
rules: readonly PolicyRule[];
|
|
120
|
-
/** Vaguest first: the weight of a key is derived from where it sits. */
|
|
121
87
|
scopeKeys: readonly string[];
|
|
122
|
-
/** Strongest first. */
|
|
123
88
|
tiers: readonly PolicyTierSpec[];
|
|
124
89
|
};
|
|
125
90
|
export type Policy = PolicyData & {
|
|
126
|
-
/** The fallbacks and unusable values this process has already recorded, keyed per boot. */
|
|
127
91
|
journalledOnce: Set<string>;
|
|
128
92
|
kindOf: (kind: string) => PolicyKindSpec | undefined;
|
|
129
93
|
rank: (tier: string) => number | undefined;
|
|
@@ -132,9 +96,7 @@ export type Policy = PolicyData & {
|
|
|
132
96
|
resolve: <V = unknown>(kind: string, query?: PolicyQuery, rules?: readonly PolicyRule[]) => PolicyDecision<V> | undefined;
|
|
133
97
|
specificity: (scope?: PolicyScope) => number;
|
|
134
98
|
tierOf: (tier: string) => PolicyTierSpec | undefined;
|
|
135
|
-
/** Kinds this build reads that no rule sets — the other half of the inert problem. */
|
|
136
99
|
unsetKinds: (rules?: readonly PolicyRule[]) => string[];
|
|
137
|
-
/** Rules scoped on a key this build does not understand — the policy is newer than the code. */
|
|
138
100
|
unsupportedScopes: (rules?: readonly PolicyRule[]) => {
|
|
139
101
|
id: string;
|
|
140
102
|
keys: string[];
|
|
@@ -142,43 +104,28 @@ export type Policy = PolicyData & {
|
|
|
142
104
|
unusableRules: (rules?: readonly PolicyRule[]) => UnusableRule[];
|
|
143
105
|
usableRules: (rules?: readonly PolicyRule[]) => PolicyRule[];
|
|
144
106
|
};
|
|
145
|
-
/** One recorded thing that happened, as the learning loop reads it. */
|
|
146
107
|
export type JournalObservationEntry = {
|
|
147
108
|
actor: {
|
|
148
109
|
id?: string;
|
|
149
110
|
kind: 'agent' | 'system' | 'user';
|
|
150
111
|
};
|
|
151
|
-
/** A refusal message, when the action was refused. */
|
|
152
112
|
error?: string;
|
|
153
|
-
/** Set by a reader that found no rule and used its own default. */
|
|
154
113
|
fellBackTo?: {
|
|
155
114
|
kind: string;
|
|
156
115
|
value: unknown;
|
|
157
116
|
};
|
|
158
117
|
id: string;
|
|
159
|
-
/** The event or workflow name. */
|
|
160
118
|
name: string;
|
|
161
|
-
/** A named operation this entry belongs to. */
|
|
162
119
|
op?: string;
|
|
163
|
-
/** What it happened to — an order, a company, a document. */
|
|
164
120
|
subject?: string;
|
|
165
121
|
};
|
|
166
|
-
/** What a read answered with, and which layer answered. */
|
|
167
122
|
export type PolicyReading<V> = {
|
|
168
|
-
/** Absent when no rule spoke and a lower layer decided. */
|
|
169
123
|
decision?: PolicyDecision<V>;
|
|
170
124
|
source: 'config' | 'fallback' | 'rule';
|
|
171
|
-
/** True when the caller's own compiled-in constant decided. */
|
|
172
125
|
usedFallback: boolean;
|
|
173
126
|
value: V;
|
|
174
127
|
};
|
|
175
|
-
/**
|
|
176
|
-
* One stored rule, in the shape both consumers' stores keep it in.
|
|
177
|
-
*
|
|
178
|
-
* Snake_case because that is what a table column is called in both, and `rule_key` rather than `id`
|
|
179
|
-
* because the surrogate id is the store's and the KEY is the rule's: it is what a refusal quotes,
|
|
180
|
-
* and what lets evidence accumulate against one rule across environments.
|
|
181
|
-
*/
|
|
128
|
+
/** Snake_case as both consumers' columns are; `rule_key` is the rule's key (what a refusal quotes), not the store's surrogate id. */
|
|
182
129
|
export type PolicyRuleRow = {
|
|
183
130
|
constraint_kind: string;
|
|
184
131
|
constraint_value: unknown;
|
|
@@ -190,11 +137,9 @@ export type PolicyRuleRow = {
|
|
|
190
137
|
status?: null | string;
|
|
191
138
|
tier: string;
|
|
192
139
|
};
|
|
193
|
-
/** What a store offers the kernel. Every port is optional except the rules themselves. */
|
|
194
140
|
export type PolicyAdapter = {
|
|
195
141
|
config?: PolicyConfigReader;
|
|
196
142
|
journal?: PolicyJournal;
|
|
197
|
-
/** For a diagnostic — a report naming "the adapter" helps nobody. */
|
|
198
143
|
name: string;
|
|
199
144
|
rule: PolicyRuleReader;
|
|
200
145
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,60 +1,37 @@
|
|
|
1
|
-
/** Something a port may answer with, or answer with later. */
|
|
2
1
|
export type Awaitable<T> = Promise<T> | T;
|
|
3
|
-
/**
|
|
4
|
-
* A schema, recognised by what it does rather than by what it is an instance of.
|
|
5
|
-
*
|
|
6
|
-
* A Medusa storefront imports `z` from `@medusajs/framework/zod` under a repo rule forbidding bare `zod`, which
|
|
7
|
-
* resolves to the copy `@medusajs/deps` ships, while its own devDependency and a Workers + D1 app's catalog
|
|
8
|
-
* are two further copies of the same major. `value instanceof z.ZodType` compares against a class
|
|
9
|
-
* object, so a schema from another copy is not an instance of ours: such a guard passes every test
|
|
10
|
-
* written against the kit's own zod and refuses every schema a consumer hands it.
|
|
11
|
-
*/
|
|
2
|
+
/** Recognised by `safeParse`, not `instanceof`: a schema from another copy of zod is not an instance of ours. */
|
|
12
3
|
export type SchemaLike = {
|
|
13
4
|
safeParse: (value: unknown) => {
|
|
14
5
|
success: boolean;
|
|
15
6
|
};
|
|
16
7
|
};
|
|
17
|
-
/** What a rule is aimed at, and what a decision is being made about. */
|
|
18
8
|
export type PolicyScope = Record<string, unknown>;
|
|
19
9
|
export type PolicyQuery = PolicyScope;
|
|
20
|
-
/** One authored constraint: a value, plus who said it, who it reaches and why it exists. */
|
|
21
10
|
export type PolicyRule = {
|
|
22
11
|
constraint: {
|
|
23
12
|
kind: string;
|
|
24
13
|
value: unknown;
|
|
25
14
|
};
|
|
26
|
-
/** Stable id — quoted in every refusal and every trace, so it has to read as prose. */
|
|
27
15
|
id: string;
|
|
28
|
-
/** May the overriding tier beat this rule? Defaults to the policy's `overridableByDefault`. */
|
|
29
16
|
overridable?: boolean;
|
|
30
|
-
/** Why this rule exists, in the words of whoever set it. Printed beside every refusal. */
|
|
31
17
|
reason: string;
|
|
32
18
|
scope?: PolicyScope;
|
|
33
19
|
tier: string;
|
|
34
20
|
};
|
|
35
|
-
/** One authority, in a lattice declared strongest first. */
|
|
36
21
|
export type PolicyTierSpec = {
|
|
37
22
|
/** Fills silence only. A promoted learning enters here and can never outrank an authority. */
|
|
38
23
|
advisory?: boolean;
|
|
39
24
|
name: string;
|
|
40
|
-
/** May the overriding tier beat a rule at this tier, when the rule itself allows it? */
|
|
41
25
|
overridable?: boolean;
|
|
42
26
|
/** This tier IS the audited escape hatch. At most one per lattice. */
|
|
43
27
|
overrides?: boolean;
|
|
44
28
|
};
|
|
45
|
-
/** One thing policy may constrain, and what is true of its values. */
|
|
46
29
|
export type PolicyKindSpec = {
|
|
47
|
-
/**
|
|
48
|
-
* Read the value this one POINTS at. Called only when `isReference` says so; answering
|
|
49
|
-
* `undefined` means the thing it points at is unset, which is a gap and not a number — the read
|
|
50
|
-
* falls through to the config layer and then to the caller's constant, and journals.
|
|
51
|
-
*/
|
|
52
30
|
dereference?: (value: unknown, context: {
|
|
53
31
|
config?: PolicyConfigReader;
|
|
54
32
|
query: PolicyQuery;
|
|
55
33
|
}) => Awaitable<unknown>;
|
|
56
34
|
description?: string;
|
|
57
|
-
/** Whether this value names something else rather than holding the answer. */
|
|
58
35
|
isReference?: (value: unknown) => boolean;
|
|
59
36
|
kind: string;
|
|
60
37
|
/**
|
|
@@ -67,33 +44,26 @@ export type PolicyKindSpec = {
|
|
|
67
44
|
sameValue?: (a: unknown, b: unknown) => boolean;
|
|
68
45
|
schema?: SchemaLike;
|
|
69
46
|
};
|
|
70
|
-
/** What policy decided, and the whole trace of why. */
|
|
71
47
|
export type PolicyDecision<V = unknown> = {
|
|
72
48
|
/** Same authority, same specificity, DIFFERENT value. Reported, never guessed. */
|
|
73
49
|
conflicts: PolicyRule[];
|
|
74
50
|
explain: string;
|
|
75
51
|
kind: string;
|
|
76
|
-
/** Set when the overriding tier beat an authority that allowed it — the audit trail. */
|
|
77
52
|
overrode?: PolicyRule;
|
|
78
|
-
/** Every other rule that reached this subject, strongest first. */
|
|
79
53
|
suppressed: PolicyRule[];
|
|
80
54
|
value: V;
|
|
81
55
|
winner: PolicyRule;
|
|
82
56
|
};
|
|
83
|
-
/** A rule this build cannot honour, and the reason nobody has to guess at. */
|
|
84
57
|
export type UnusableRule = {
|
|
85
58
|
id: string;
|
|
86
59
|
reason: string;
|
|
87
60
|
};
|
|
88
|
-
/** Where the authored rules come from. */
|
|
89
61
|
export type PolicyRuleReader = {
|
|
90
62
|
rules: (kind: string, query: PolicyQuery) => Awaitable<readonly PolicyRule[]>;
|
|
91
63
|
};
|
|
92
|
-
/** The layer an admin can edit. `undefined` means no value is set. */
|
|
93
64
|
export type PolicyConfigReader = {
|
|
94
65
|
get: (kind: string, query: PolicyQuery) => Awaitable<unknown>;
|
|
95
66
|
};
|
|
96
|
-
/** Where a fallback is recorded. Best-effort by contract: it may never change a decision. */
|
|
97
67
|
export type PolicyJournal = {
|
|
98
68
|
write: (entry: PolicyJournalEntry) => Awaitable<void>;
|
|
99
69
|
};
|
|
@@ -101,10 +71,8 @@ export declare const POLICY_FALLBACK = "policy.fallback";
|
|
|
101
71
|
export declare const POLICY_INVALID_VALUE = "policy.invalid_value";
|
|
102
72
|
export type PolicyJournalEntry = {
|
|
103
73
|
event: typeof POLICY_FALLBACK | typeof POLICY_INVALID_VALUE;
|
|
104
|
-
/** The value that decided instead. */
|
|
105
74
|
fellBackTo: unknown;
|
|
106
75
|
kind: string;
|
|
107
|
-
/** A named operation, so repeats are countable per operation rather than per request. */
|
|
108
76
|
op?: string;
|
|
109
77
|
rejected?: {
|
|
110
78
|
reason: string;
|
|
@@ -112,18 +80,14 @@ export type PolicyJournalEntry = {
|
|
|
112
80
|
};
|
|
113
81
|
subject?: string;
|
|
114
82
|
};
|
|
115
|
-
/** The data half of a policy — everything the lattice needs and nothing it does not. */
|
|
116
83
|
export type PolicyData = {
|
|
117
84
|
kinds: readonly PolicyKindSpec[];
|
|
118
85
|
overridableByDefault: boolean;
|
|
119
86
|
rules: readonly PolicyRule[];
|
|
120
|
-
/** Vaguest first: the weight of a key is derived from where it sits. */
|
|
121
87
|
scopeKeys: readonly string[];
|
|
122
|
-
/** Strongest first. */
|
|
123
88
|
tiers: readonly PolicyTierSpec[];
|
|
124
89
|
};
|
|
125
90
|
export type Policy = PolicyData & {
|
|
126
|
-
/** The fallbacks and unusable values this process has already recorded, keyed per boot. */
|
|
127
91
|
journalledOnce: Set<string>;
|
|
128
92
|
kindOf: (kind: string) => PolicyKindSpec | undefined;
|
|
129
93
|
rank: (tier: string) => number | undefined;
|
|
@@ -132,9 +96,7 @@ export type Policy = PolicyData & {
|
|
|
132
96
|
resolve: <V = unknown>(kind: string, query?: PolicyQuery, rules?: readonly PolicyRule[]) => PolicyDecision<V> | undefined;
|
|
133
97
|
specificity: (scope?: PolicyScope) => number;
|
|
134
98
|
tierOf: (tier: string) => PolicyTierSpec | undefined;
|
|
135
|
-
/** Kinds this build reads that no rule sets — the other half of the inert problem. */
|
|
136
99
|
unsetKinds: (rules?: readonly PolicyRule[]) => string[];
|
|
137
|
-
/** Rules scoped on a key this build does not understand — the policy is newer than the code. */
|
|
138
100
|
unsupportedScopes: (rules?: readonly PolicyRule[]) => {
|
|
139
101
|
id: string;
|
|
140
102
|
keys: string[];
|
|
@@ -142,43 +104,28 @@ export type Policy = PolicyData & {
|
|
|
142
104
|
unusableRules: (rules?: readonly PolicyRule[]) => UnusableRule[];
|
|
143
105
|
usableRules: (rules?: readonly PolicyRule[]) => PolicyRule[];
|
|
144
106
|
};
|
|
145
|
-
/** One recorded thing that happened, as the learning loop reads it. */
|
|
146
107
|
export type JournalObservationEntry = {
|
|
147
108
|
actor: {
|
|
148
109
|
id?: string;
|
|
149
110
|
kind: 'agent' | 'system' | 'user';
|
|
150
111
|
};
|
|
151
|
-
/** A refusal message, when the action was refused. */
|
|
152
112
|
error?: string;
|
|
153
|
-
/** Set by a reader that found no rule and used its own default. */
|
|
154
113
|
fellBackTo?: {
|
|
155
114
|
kind: string;
|
|
156
115
|
value: unknown;
|
|
157
116
|
};
|
|
158
117
|
id: string;
|
|
159
|
-
/** The event or workflow name. */
|
|
160
118
|
name: string;
|
|
161
|
-
/** A named operation this entry belongs to. */
|
|
162
119
|
op?: string;
|
|
163
|
-
/** What it happened to — an order, a company, a document. */
|
|
164
120
|
subject?: string;
|
|
165
121
|
};
|
|
166
|
-
/** What a read answered with, and which layer answered. */
|
|
167
122
|
export type PolicyReading<V> = {
|
|
168
|
-
/** Absent when no rule spoke and a lower layer decided. */
|
|
169
123
|
decision?: PolicyDecision<V>;
|
|
170
124
|
source: 'config' | 'fallback' | 'rule';
|
|
171
|
-
/** True when the caller's own compiled-in constant decided. */
|
|
172
125
|
usedFallback: boolean;
|
|
173
126
|
value: V;
|
|
174
127
|
};
|
|
175
|
-
/**
|
|
176
|
-
* One stored rule, in the shape both consumers' stores keep it in.
|
|
177
|
-
*
|
|
178
|
-
* Snake_case because that is what a table column is called in both, and `rule_key` rather than `id`
|
|
179
|
-
* because the surrogate id is the store's and the KEY is the rule's: it is what a refusal quotes,
|
|
180
|
-
* and what lets evidence accumulate against one rule across environments.
|
|
181
|
-
*/
|
|
128
|
+
/** Snake_case as both consumers' columns are; `rule_key` is the rule's key (what a refusal quotes), not the store's surrogate id. */
|
|
182
129
|
export type PolicyRuleRow = {
|
|
183
130
|
constraint_kind: string;
|
|
184
131
|
constraint_value: unknown;
|
|
@@ -190,11 +137,9 @@ export type PolicyRuleRow = {
|
|
|
190
137
|
status?: null | string;
|
|
191
138
|
tier: string;
|
|
192
139
|
};
|
|
193
|
-
/** What a store offers the kernel. Every port is optional except the rules themselves. */
|
|
194
140
|
export type PolicyAdapter = {
|
|
195
141
|
config?: PolicyConfigReader;
|
|
196
142
|
journal?: PolicyJournal;
|
|
197
|
-
/** For a diagnostic — a report naming "the adapter" helps nobody. */
|
|
198
143
|
name: string;
|
|
199
144
|
rule: PolicyRuleReader;
|
|
200
145
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geonosis/policy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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": [
|