dotmem 0.1.9 → 0.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/DOTMEM-SHORT-API.md +318 -0
- package/DOTMEM-SHORT-COMPONENTS.md +129 -0
- package/agent.cjs +1 -226
- package/agent.js +1 -223
- package/bin/cli.cjs +1 -34
- package/bin/cli.js +1 -27
- package/bin/mcp.cjs +1 -21
- package/bin/mcp.js +1 -15
- package/built-in-context.json +6 -6
- package/cli.cjs +258 -19645
- package/cli.js +257 -19575
- package/context/templates/AI.md +1 -1
- package/env.cjs +1 -6
- package/env.js +1 -4
- package/global.cjs +49 -11469
- package/global.d.ts +0 -1
- package/global.js +49 -11437
- package/index.cjs +91 -15354
- package/index.d.ts +2 -0
- package/index.js +91 -15251
- package/mcp.cjs +117 -14587
- package/mcp.js +117 -14551
- package/package.json +3 -2
- package/types/exports.d.ts +43 -66
- package/types/global-types.d.ts +3652 -0
- package/types/llm-cache.d.ts +6 -6
- package/types/logic.d.ts +60 -79
- package/types/memory.d.ts +48 -92
- package/types/policy.d.ts +290 -290
- package/types/profile.d.ts +2 -2
- package/types/agent.d.ts +0 -87
package/types/policy.d.ts
CHANGED
|
@@ -1,291 +1,291 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOTMEM POLICY AND BRAIN DECLARATIONS
|
|
3
|
-
*
|
|
4
|
-
* Policy is a separate authority domain from memory: how memory may influence
|
|
5
|
-
* behavior. The shipped declarations must mirror the runtime surface in
|
|
6
|
-
* `core/knowledge/policy.ts`, `core/knowledge/policy-store.ts`,
|
|
7
|
-
* `core/knowledge/contract.ts` and `core/knowledge/brain-memory.ts`.
|
|
8
|
-
*
|
|
9
|
-
* A governed claim never selects its own enforcement tier: effective tiers
|
|
10
|
-
* are resolved only from the policy store, and `memory.acquire` (direct and
|
|
11
|
-
* staged) evaluates the `memory.acquire` event against the payload before
|
|
12
|
-
* persistence.
|
|
13
|
-
*
|
|
14
|
-
* Adds the privileged out-of-band policy override: an authorized,
|
|
15
|
-
* explicit, auditable change of effective policy state that never mutates
|
|
16
|
-
* the base policy and is bound to the exact generation of the policy it
|
|
17
|
-
* relaxes.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/** Who granted the policy assignment. Never a governed claim. */
|
|
26
|
-
kind: PolicyAuthorityKind
|
|
27
|
-
/** Explicit provenance of the grant. Required, never inferred. */
|
|
28
|
-
source: string
|
|
29
|
-
detail?: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
kind: ConditionKind
|
|
36
|
-
field: string
|
|
37
|
-
value: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
blocks: boolean
|
|
46
|
-
requiresHumanResolution: boolean
|
|
47
|
-
conversationCanOverride: boolean
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
id: string
|
|
52
|
-
/** Canonical event this policy applies to, e.g. `artifact.write`. */
|
|
53
|
-
event: string
|
|
54
|
-
/** Memory claim this policy governs. The claim never selects its own tier. */
|
|
55
|
-
claimId: string
|
|
56
|
-
tier: EnforcementTier
|
|
57
|
-
field?: string
|
|
58
|
-
value?: string
|
|
59
|
-
condition?: PolicyCondition
|
|
60
|
-
authority: PolicyAuthority
|
|
61
|
-
grantedAt: string
|
|
62
|
-
reason?: string
|
|
63
|
-
/** Monotonic generation counter. Never reused. */
|
|
64
|
-
revision?: number
|
|
65
|
-
/** Canonical semantic fingerprint, system-derived and verified on load. */
|
|
66
|
-
fingerprint?: string
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** A valid tier an override may relax to. `context` is the floor. */
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* A privileged out-of-band override. Relaxes the effective tier of
|
|
74
|
-
* one target policy without mutating it, bound to the policy generation.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
id: string
|
|
78
|
-
event: string
|
|
79
|
-
/** The policy this override targets. Exactly one active slot per target. */
|
|
80
|
-
targetPolicyId: string
|
|
81
|
-
/** Target policy revision captured at grant time. */
|
|
82
|
-
targetRevision: number
|
|
83
|
-
/** Canonical semantic fingerprint of the target captured at grant time. */
|
|
84
|
-
targetFingerprint: string
|
|
85
|
-
relaxTo: OverrideRelaxTo
|
|
86
|
-
authority: PolicyAuthority
|
|
87
|
-
grantedAt: string
|
|
88
|
-
expiresAt: string
|
|
89
|
-
reason: string
|
|
90
|
-
revokedAt?: string
|
|
91
|
-
supersededBy?: string
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
| 'active'
|
|
98
|
-
| 'policy-missing'
|
|
99
|
-
| 'policy-changed'
|
|
100
|
-
| 'expired'
|
|
101
|
-
| 'revoked'
|
|
102
|
-
| 'superseded'
|
|
103
|
-
| 'multiple-active'
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
override: PolicyOverride
|
|
107
|
-
state: Exclude<PolicyOverrideState, 'NONE'>
|
|
108
|
-
detail: PolicyOverrideInertDetail
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** The scar: provenance of a relaxation, exposed by effective state. */
|
|
112
|
-
|
|
113
|
-
policyOverrideId: string
|
|
114
|
-
relaxedFrom: EnforcementTier
|
|
115
|
-
by: string
|
|
116
|
-
until: string
|
|
117
|
-
reason: string
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
policyId: string
|
|
122
|
-
event: string
|
|
123
|
-
claimId: string
|
|
124
|
-
baseTier: EnforcementTier
|
|
125
|
-
effectiveTier: EnforcementTier
|
|
126
|
-
overrideState: PolicyOverrideState
|
|
127
|
-
override?: PolicyOverride
|
|
128
|
-
provenance?: PolicyOverrideProvenance
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
event: string
|
|
133
|
-
targetPolicyId: string
|
|
134
|
-
relaxTo: OverrideRelaxTo
|
|
135
|
-
expiresAt: string
|
|
136
|
-
reason: string
|
|
137
|
-
authority: PolicyAuthority
|
|
138
|
-
grantedAt?: string
|
|
139
|
-
id?: string
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
id: string
|
|
144
|
-
authority: PolicyAuthority
|
|
145
|
-
reason?: string
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
policyId: string
|
|
150
|
-
claimId: string
|
|
151
|
-
event: string
|
|
152
|
-
tier: EnforcementTier
|
|
153
|
-
action: PolicyAction
|
|
154
|
-
blocks: boolean
|
|
155
|
-
requiresHumanResolution: boolean
|
|
156
|
-
conversationCanOverride: boolean
|
|
157
|
-
field?: string
|
|
158
|
-
value?: string
|
|
159
|
-
condition?: { kind: ConditionKind; field: string; value: string; outcome: ConditionOutcome; detail: string }
|
|
160
|
-
authority: PolicyAuthority
|
|
161
|
-
grantedAt: string
|
|
162
|
-
/** The governed memory claim, when present in the evaluated store. */
|
|
163
|
-
claim?: unknown
|
|
164
|
-
/** Effective-state provenance: present only under a targeting override. */
|
|
165
|
-
override?: {
|
|
166
|
-
policyOverrideId: string
|
|
167
|
-
state: Exclude<PolicyOverrideState, 'NONE'>
|
|
168
|
-
detail: PolicyOverrideInertDetail
|
|
169
|
-
relaxedFrom?: EnforcementTier
|
|
170
|
-
by?: string
|
|
171
|
-
until?: string
|
|
172
|
-
reason?: string
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
event: string
|
|
178
|
-
decisions: PolicyDecision[]
|
|
179
|
-
blocked: boolean
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
id?: string
|
|
186
|
-
event: string
|
|
187
|
-
claimId: string
|
|
188
|
-
tier: EnforcementTier
|
|
189
|
-
field?: string
|
|
190
|
-
value?: string
|
|
191
|
-
condition?: PolicyCondition
|
|
192
|
-
authority: PolicyAuthority
|
|
193
|
-
grantedAt?: string
|
|
194
|
-
reason?: string
|
|
195
|
-
/** Optimistic concurrency check, evaluated inside the lock. */
|
|
196
|
-
basedOnRevision?: number
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Privileged out-of-band override surface. */
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Relax the effective tier of one policy. The target policy, its revision
|
|
203
|
-
* and its canonical fingerprint are derived from the store, never accepted
|
|
204
|
-
* from the payload. Exactly one active slot per target; a new grant
|
|
205
|
-
* atomically supersedes the previous one.
|
|
206
|
-
*/
|
|
207
|
-
grant(
|
|
208
|
-
input: PolicyOverrideGrantInput,
|
|
209
|
-
namespace?: PolicyNamespace,
|
|
210
|
-
basedOnRevision?: number
|
|
211
|
-
): Promise<PolicyOverride>
|
|
212
|
-
/** Remove a relaxation and restore the base policy. */
|
|
213
|
-
revoke(
|
|
214
|
-
input: PolicyOverrideRevokeInput,
|
|
215
|
-
namespace?: PolicyNamespace,
|
|
216
|
-
basedOnRevision?: number
|
|
217
|
-
): Promise<PolicyOverride>
|
|
218
|
-
/** Every override with its resolved state (ACTIVE / EXPIRED / STALE / INERT). */
|
|
219
|
-
list(namespace?: PolicyNamespace): Promise<ResolvedOverride[]>
|
|
220
|
-
/** Effective policy state with the provenance scar. */
|
|
221
|
-
effective(event?: string, namespace?: PolicyNamespace): Promise<EffectivePolicyState[]>
|
|
222
|
-
}
|
|
223
|
-
/** Durable policy audit entry: every mutation the document records. */
|
|
224
|
-
|
|
225
|
-
id: string
|
|
226
|
-
action: 'assign' | 'remove' | 'clear' | 'override' | 'revoke' | 'lock-break'
|
|
227
|
-
at: string
|
|
228
|
-
authority: PolicyAuthority | { kind: 'system'; source: string }
|
|
229
|
-
target?: string
|
|
230
|
-
reason?: string
|
|
231
|
-
outcome: 'applied' | 'rejected'
|
|
232
|
-
detail?: string
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/** The exported operator contract: memory is data, never authority. */
|
|
236
|
-
|
|
237
|
-
authority: 'data-only'
|
|
238
|
-
trusted: false
|
|
239
|
-
instructionsAllowed: false
|
|
240
|
-
verifyCurrent: true
|
|
241
|
-
policyGoverned: true
|
|
242
|
-
chatCanLowerPolicyTier: false
|
|
243
|
-
tiers: Record<EnforcementTier, TierEnforcement>
|
|
244
|
-
overridePath: string
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/** Privileged policy authority surface. Ordinary acquisition cannot write policy. */
|
|
248
|
-
|
|
249
|
-
/** Privileged assignment. Requires explicit HI or operator authority. */
|
|
250
|
-
assign(input: PolicyAssignmentInput, namespace?: PolicyNamespace, basedOnRevision?: number): Promise<PolicyRecord>
|
|
251
|
-
list(): Promise<PolicyRecord[]>
|
|
252
|
-
remove(id: string, namespace?: PolicyNamespace, basedOnRevision?: number): Promise<void>
|
|
253
|
-
/**
|
|
254
|
-
* Privileged reset. Deletion is a modification: explicit authority
|
|
255
|
-
* required. Clears the active state and preserves the durable audit trail
|
|
256
|
-
* with a terminal CLEAR entry.
|
|
257
|
-
*/
|
|
258
|
-
clear(authority: PolicyAuthority): Promise<void>
|
|
259
|
-
/** Decision-time pull: only the policies applicable to the event, as effective state. */
|
|
260
|
-
evaluate(event: string, payload?: unknown): Promise<PolicyEvaluation>
|
|
261
|
-
/** Privileged out-of-band override surface. */
|
|
262
|
-
override: MemoryPolicyOverrideAPI
|
|
263
|
-
/** The durable audit trail, read-only. */
|
|
264
|
-
audit(namespace?: PolicyNamespace): Promise<PolicyAuditEntry[]>
|
|
265
|
-
/** The machine-readable operator contract. */
|
|
266
|
-
contract(): MemoryProjectionContract
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/** Advisory relationship index over memories (@brain.mem). Non-authoritative. */
|
|
270
|
-
|
|
271
|
-
| 'uses'
|
|
272
|
-
| 'related-to'
|
|
273
|
-
| 'supersedes'
|
|
274
|
-
| 'encountered-in'
|
|
275
|
-
| 'associated-with'
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
id: string
|
|
279
|
-
kind: BrainRelationshipKind
|
|
280
|
-
from: string
|
|
281
|
-
to: string
|
|
282
|
-
epistemicType?: 'observed' | 'inferred' | 'human-stated' | 'verified'
|
|
283
|
-
note?: string
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
addRelationship(kind: BrainRelationshipKind, from: string, to: string, note?: string): Promise<string>
|
|
288
|
-
getRelationships(from?: string, to?: string): Promise<BrainRelationship[]>
|
|
289
|
-
removeRelationship(id: string): Promise<void>
|
|
290
|
-
clear(): Promise<void>
|
|
1
|
+
/**
|
|
2
|
+
* DOTMEM POLICY AND BRAIN DECLARATIONS
|
|
3
|
+
*
|
|
4
|
+
* Policy is a separate authority domain from memory: how memory may influence
|
|
5
|
+
* behavior. The shipped declarations must mirror the runtime surface in
|
|
6
|
+
* `core/knowledge/policy.ts`, `core/knowledge/policy-store.ts`,
|
|
7
|
+
* `core/knowledge/contract.ts` and `core/knowledge/brain-memory.ts`.
|
|
8
|
+
*
|
|
9
|
+
* A governed claim never selects its own enforcement tier: effective tiers
|
|
10
|
+
* are resolved only from the policy store, and `memory.acquire` (direct and
|
|
11
|
+
* staged) evaluates the `memory.acquire` event against the payload before
|
|
12
|
+
* persistence.
|
|
13
|
+
*
|
|
14
|
+
* Adds the privileged out-of-band policy override: an authorized,
|
|
15
|
+
* explicit, auditable change of effective policy state that never mutates
|
|
16
|
+
* the base policy and is bound to the exact generation of the policy it
|
|
17
|
+
* relaxes.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
type EnforcementTier = 'context' | 'precondition' | 'hard-precondition'
|
|
21
|
+
|
|
22
|
+
type PolicyAuthorityKind = 'HI' | 'operator'
|
|
23
|
+
|
|
24
|
+
interface PolicyAuthority {
|
|
25
|
+
/** Who granted the policy assignment. Never a governed claim. */
|
|
26
|
+
kind: PolicyAuthorityKind
|
|
27
|
+
/** Explicit provenance of the grant. Required, never inferred. */
|
|
28
|
+
source: string
|
|
29
|
+
detail?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type ConditionKind = 'payload-language' | 'field-equals'
|
|
33
|
+
|
|
34
|
+
interface PolicyCondition {
|
|
35
|
+
kind: ConditionKind
|
|
36
|
+
field: string
|
|
37
|
+
value: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type ConditionOutcome = 'satisfied' | 'violated' | 'unresolved'
|
|
41
|
+
|
|
42
|
+
type PolicyAction = 'allow' | 'block-and-ask' | 'block'
|
|
43
|
+
|
|
44
|
+
interface TierEnforcement {
|
|
45
|
+
blocks: boolean
|
|
46
|
+
requiresHumanResolution: boolean
|
|
47
|
+
conversationCanOverride: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface PolicyRecord {
|
|
51
|
+
id: string
|
|
52
|
+
/** Canonical event this policy applies to, e.g. `artifact.write`. */
|
|
53
|
+
event: string
|
|
54
|
+
/** Memory claim this policy governs. The claim never selects its own tier. */
|
|
55
|
+
claimId: string
|
|
56
|
+
tier: EnforcementTier
|
|
57
|
+
field?: string
|
|
58
|
+
value?: string
|
|
59
|
+
condition?: PolicyCondition
|
|
60
|
+
authority: PolicyAuthority
|
|
61
|
+
grantedAt: string
|
|
62
|
+
reason?: string
|
|
63
|
+
/** Monotonic generation counter. Never reused. */
|
|
64
|
+
revision?: number
|
|
65
|
+
/** Canonical semantic fingerprint, system-derived and verified on load. */
|
|
66
|
+
fingerprint?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A valid tier an override may relax to. `context` is the floor. */
|
|
70
|
+
type OverrideRelaxTo = EnforcementTier
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A privileged out-of-band override. Relaxes the effective tier of
|
|
74
|
+
* one target policy without mutating it, bound to the policy generation.
|
|
75
|
+
*/
|
|
76
|
+
interface PolicyOverride {
|
|
77
|
+
id: string
|
|
78
|
+
event: string
|
|
79
|
+
/** The policy this override targets. Exactly one active slot per target. */
|
|
80
|
+
targetPolicyId: string
|
|
81
|
+
/** Target policy revision captured at grant time. */
|
|
82
|
+
targetRevision: number
|
|
83
|
+
/** Canonical semantic fingerprint of the target captured at grant time. */
|
|
84
|
+
targetFingerprint: string
|
|
85
|
+
relaxTo: OverrideRelaxTo
|
|
86
|
+
authority: PolicyAuthority
|
|
87
|
+
grantedAt: string
|
|
88
|
+
expiresAt: string
|
|
89
|
+
reason: string
|
|
90
|
+
revokedAt?: string
|
|
91
|
+
supersededBy?: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type PolicyOverrideState = 'ACTIVE' | 'EXPIRED' | 'STALE' | 'INERT' | 'NONE'
|
|
95
|
+
|
|
96
|
+
type PolicyOverrideInertDetail =
|
|
97
|
+
| 'active'
|
|
98
|
+
| 'policy-missing'
|
|
99
|
+
| 'policy-changed'
|
|
100
|
+
| 'expired'
|
|
101
|
+
| 'revoked'
|
|
102
|
+
| 'superseded'
|
|
103
|
+
| 'multiple-active'
|
|
104
|
+
|
|
105
|
+
interface ResolvedOverride {
|
|
106
|
+
override: PolicyOverride
|
|
107
|
+
state: Exclude<PolicyOverrideState, 'NONE'>
|
|
108
|
+
detail: PolicyOverrideInertDetail
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The scar: provenance of a relaxation, exposed by effective state. */
|
|
112
|
+
interface PolicyOverrideProvenance {
|
|
113
|
+
policyOverrideId: string
|
|
114
|
+
relaxedFrom: EnforcementTier
|
|
115
|
+
by: string
|
|
116
|
+
until: string
|
|
117
|
+
reason: string
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
interface EffectivePolicyState {
|
|
121
|
+
policyId: string
|
|
122
|
+
event: string
|
|
123
|
+
claimId: string
|
|
124
|
+
baseTier: EnforcementTier
|
|
125
|
+
effectiveTier: EnforcementTier
|
|
126
|
+
overrideState: PolicyOverrideState
|
|
127
|
+
override?: PolicyOverride
|
|
128
|
+
provenance?: PolicyOverrideProvenance
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface PolicyOverrideGrantInput {
|
|
132
|
+
event: string
|
|
133
|
+
targetPolicyId: string
|
|
134
|
+
relaxTo: OverrideRelaxTo
|
|
135
|
+
expiresAt: string
|
|
136
|
+
reason: string
|
|
137
|
+
authority: PolicyAuthority
|
|
138
|
+
grantedAt?: string
|
|
139
|
+
id?: string
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface PolicyOverrideRevokeInput {
|
|
143
|
+
id: string
|
|
144
|
+
authority: PolicyAuthority
|
|
145
|
+
reason?: string
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface PolicyDecision {
|
|
149
|
+
policyId: string
|
|
150
|
+
claimId: string
|
|
151
|
+
event: string
|
|
152
|
+
tier: EnforcementTier
|
|
153
|
+
action: PolicyAction
|
|
154
|
+
blocks: boolean
|
|
155
|
+
requiresHumanResolution: boolean
|
|
156
|
+
conversationCanOverride: boolean
|
|
157
|
+
field?: string
|
|
158
|
+
value?: string
|
|
159
|
+
condition?: { kind: ConditionKind; field: string; value: string; outcome: ConditionOutcome; detail: string }
|
|
160
|
+
authority: PolicyAuthority
|
|
161
|
+
grantedAt: string
|
|
162
|
+
/** The governed memory claim, when present in the evaluated store. */
|
|
163
|
+
claim?: unknown
|
|
164
|
+
/** Effective-state provenance: present only under a targeting override. */
|
|
165
|
+
override?: {
|
|
166
|
+
policyOverrideId: string
|
|
167
|
+
state: Exclude<PolicyOverrideState, 'NONE'>
|
|
168
|
+
detail: PolicyOverrideInertDetail
|
|
169
|
+
relaxedFrom?: EnforcementTier
|
|
170
|
+
by?: string
|
|
171
|
+
until?: string
|
|
172
|
+
reason?: string
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
interface PolicyEvaluation {
|
|
177
|
+
event: string
|
|
178
|
+
decisions: PolicyDecision[]
|
|
179
|
+
blocked: boolean
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
type PolicyNamespace = 'operator' | 'security'
|
|
183
|
+
|
|
184
|
+
interface PolicyAssignmentInput {
|
|
185
|
+
id?: string
|
|
186
|
+
event: string
|
|
187
|
+
claimId: string
|
|
188
|
+
tier: EnforcementTier
|
|
189
|
+
field?: string
|
|
190
|
+
value?: string
|
|
191
|
+
condition?: PolicyCondition
|
|
192
|
+
authority: PolicyAuthority
|
|
193
|
+
grantedAt?: string
|
|
194
|
+
reason?: string
|
|
195
|
+
/** Optimistic concurrency check, evaluated inside the lock. */
|
|
196
|
+
basedOnRevision?: number
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Privileged out-of-band override surface. */
|
|
200
|
+
interface MemoryPolicyOverrideAPI {
|
|
201
|
+
/**
|
|
202
|
+
* Relax the effective tier of one policy. The target policy, its revision
|
|
203
|
+
* and its canonical fingerprint are derived from the store, never accepted
|
|
204
|
+
* from the payload. Exactly one active slot per target; a new grant
|
|
205
|
+
* atomically supersedes the previous one.
|
|
206
|
+
*/
|
|
207
|
+
grant(
|
|
208
|
+
input: PolicyOverrideGrantInput,
|
|
209
|
+
namespace?: PolicyNamespace,
|
|
210
|
+
basedOnRevision?: number
|
|
211
|
+
): Promise<PolicyOverride>
|
|
212
|
+
/** Remove a relaxation and restore the base policy. */
|
|
213
|
+
revoke(
|
|
214
|
+
input: PolicyOverrideRevokeInput,
|
|
215
|
+
namespace?: PolicyNamespace,
|
|
216
|
+
basedOnRevision?: number
|
|
217
|
+
): Promise<PolicyOverride>
|
|
218
|
+
/** Every override with its resolved state (ACTIVE / EXPIRED / STALE / INERT). */
|
|
219
|
+
list(namespace?: PolicyNamespace): Promise<ResolvedOverride[]>
|
|
220
|
+
/** Effective policy state with the provenance scar. */
|
|
221
|
+
effective(event?: string, namespace?: PolicyNamespace): Promise<EffectivePolicyState[]>
|
|
222
|
+
}
|
|
223
|
+
/** Durable policy audit entry: every mutation the document records. */
|
|
224
|
+
interface PolicyAuditEntry {
|
|
225
|
+
id: string
|
|
226
|
+
action: 'assign' | 'remove' | 'clear' | 'override' | 'revoke' | 'lock-break'
|
|
227
|
+
at: string
|
|
228
|
+
authority: PolicyAuthority | { kind: 'system'; source: string }
|
|
229
|
+
target?: string
|
|
230
|
+
reason?: string
|
|
231
|
+
outcome: 'applied' | 'rejected'
|
|
232
|
+
detail?: string
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** The exported operator contract: memory is data, never authority. */
|
|
236
|
+
interface MemoryProjectionContract {
|
|
237
|
+
authority: 'data-only'
|
|
238
|
+
trusted: false
|
|
239
|
+
instructionsAllowed: false
|
|
240
|
+
verifyCurrent: true
|
|
241
|
+
policyGoverned: true
|
|
242
|
+
chatCanLowerPolicyTier: false
|
|
243
|
+
tiers: Record<EnforcementTier, TierEnforcement>
|
|
244
|
+
overridePath: string
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Privileged policy authority surface. Ordinary acquisition cannot write policy. */
|
|
248
|
+
interface MemoryPolicyAPI {
|
|
249
|
+
/** Privileged assignment. Requires explicit HI or operator authority. */
|
|
250
|
+
assign(input: PolicyAssignmentInput, namespace?: PolicyNamespace, basedOnRevision?: number): Promise<PolicyRecord>
|
|
251
|
+
list(): Promise<PolicyRecord[]>
|
|
252
|
+
remove(id: string, namespace?: PolicyNamespace, basedOnRevision?: number): Promise<void>
|
|
253
|
+
/**
|
|
254
|
+
* Privileged reset. Deletion is a modification: explicit authority
|
|
255
|
+
* required. Clears the active state and preserves the durable audit trail
|
|
256
|
+
* with a terminal CLEAR entry.
|
|
257
|
+
*/
|
|
258
|
+
clear(authority: PolicyAuthority): Promise<void>
|
|
259
|
+
/** Decision-time pull: only the policies applicable to the event, as effective state. */
|
|
260
|
+
evaluate(event: string, payload?: unknown): Promise<PolicyEvaluation>
|
|
261
|
+
/** Privileged out-of-band override surface. */
|
|
262
|
+
override: MemoryPolicyOverrideAPI
|
|
263
|
+
/** The durable audit trail, read-only. */
|
|
264
|
+
audit(namespace?: PolicyNamespace): Promise<PolicyAuditEntry[]>
|
|
265
|
+
/** The machine-readable operator contract. */
|
|
266
|
+
contract(): MemoryProjectionContract
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Advisory relationship index over memories (@brain.mem). Non-authoritative. */
|
|
270
|
+
type BrainRelationshipKind =
|
|
271
|
+
| 'uses'
|
|
272
|
+
| 'related-to'
|
|
273
|
+
| 'supersedes'
|
|
274
|
+
| 'encountered-in'
|
|
275
|
+
| 'associated-with'
|
|
276
|
+
|
|
277
|
+
interface BrainRelationship {
|
|
278
|
+
id: string
|
|
279
|
+
kind: BrainRelationshipKind
|
|
280
|
+
from: string
|
|
281
|
+
to: string
|
|
282
|
+
epistemicType?: 'observed' | 'inferred' | 'human-stated' | 'verified'
|
|
283
|
+
note?: string
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
interface MemoryBrainAPI {
|
|
287
|
+
addRelationship(kind: BrainRelationshipKind, from: string, to: string, note?: string): Promise<string>
|
|
288
|
+
getRelationships(from?: string, to?: string): Promise<BrainRelationship[]>
|
|
289
|
+
removeRelationship(id: string): Promise<void>
|
|
290
|
+
clear(): Promise<void>
|
|
291
291
|
}
|
package/types/profile.d.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* owner's build configuration and are not hardcoded to any specific identity.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface DotMemProfileDocument {
|
|
11
11
|
readonly name: string
|
|
12
12
|
readonly content: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
interface DotMemProfile {
|
|
16
16
|
readonly format: 'dotmem.profile'
|
|
17
17
|
readonly version: 1
|
|
18
18
|
readonly id: string
|