@dsh-ray/personal-memory 0.0.1-seed.0 → 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/LICENSE +21 -0
- package/README.md +187 -1
- package/cordis.patch.yml +18 -0
- package/lib/evidence-filesystem.d.ts +25 -0
- package/lib/evidence-filesystem.d.ts.map +1 -0
- package/lib/evidence-filesystem.js +178 -0
- package/lib/evidence-filesystem.js.map +1 -0
- package/lib/evidence-ledger.d.ts +33 -0
- package/lib/evidence-ledger.d.ts.map +1 -0
- package/lib/evidence-ledger.js +216 -0
- package/lib/evidence-ledger.js.map +1 -0
- package/lib/evidence-runtime.d.ts +28 -0
- package/lib/evidence-runtime.d.ts.map +1 -0
- package/lib/evidence-runtime.js +114 -0
- package/lib/evidence-runtime.js.map +1 -0
- package/lib/evidence-service.d.ts +50 -0
- package/lib/evidence-service.d.ts.map +1 -0
- package/lib/evidence-service.js +212 -0
- package/lib/evidence-service.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/knowledge.d.ts +6 -0
- package/lib/knowledge.d.ts.map +1 -0
- package/lib/knowledge.js +55 -0
- package/lib/knowledge.js.map +1 -0
- package/lib/learning-adoptions.d.ts +102 -0
- package/lib/learning-adoptions.d.ts.map +1 -0
- package/lib/learning-adoptions.js +92 -0
- package/lib/learning-adoptions.js.map +1 -0
- package/lib/learning-service.d.ts +38 -0
- package/lib/learning-service.d.ts.map +1 -0
- package/lib/learning-service.js +329 -0
- package/lib/learning-service.js.map +1 -0
- package/lib/promotion.d.ts +24 -0
- package/lib/promotion.d.ts.map +1 -0
- package/lib/promotion.js +147 -0
- package/lib/promotion.js.map +1 -0
- package/lib/proposals.d.ts +42 -0
- package/lib/proposals.d.ts.map +1 -0
- package/lib/proposals.js +386 -0
- package/lib/proposals.js.map +1 -0
- package/lib/service.d.ts +193 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +900 -0
- package/lib/service.js.map +1 -0
- package/lib/sqlite.d.ts +9 -0
- package/lib/sqlite.d.ts.map +1 -0
- package/lib/sqlite.js +565 -0
- package/lib/sqlite.js.map +1 -0
- package/lib/store.d.ts +161 -0
- package/lib/store.d.ts.map +1 -0
- package/lib/store.js +2125 -0
- package/lib/store.js.map +1 -0
- package/lib/tokenize.d.ts +2 -0
- package/lib/tokenize.d.ts.map +1 -0
- package/lib/tokenize.js +22 -0
- package/lib/tokenize.js.map +1 -0
- package/lib/tools.d.ts +4 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +313 -0
- package/lib/tools.js.map +1 -0
- package/lib/types.d.ts +256 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +2 -0
- package/lib/version.js.map +1 -0
- package/package.json +114 -4
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { growthObjectDigest, memoryLearningRequestDigest, validateMemoryLearningReviewRequest, hasWorkItemLearningFeedbackText, validateMemoryLearningOwner, } from '@dsh-ray/assistant-growth-contract';
|
|
2
|
+
import { memoryPrincipalDigest } from './store.js';
|
|
3
|
+
import { validateMemoryLearningAdoptionGrant } from './learning-adoptions.js';
|
|
4
|
+
/** Host-only adoption and read-time source checks. No model-visible mutation tool. */
|
|
5
|
+
export class MemoryLearningService {
|
|
6
|
+
ctx;
|
|
7
|
+
store;
|
|
8
|
+
#grant;
|
|
9
|
+
constructor(ctx, store, grant) {
|
|
10
|
+
this.ctx = ctx;
|
|
11
|
+
this.store = store;
|
|
12
|
+
this.#grant = validateMemoryLearningAdoptionGrant(grant);
|
|
13
|
+
store.registerLearningGrant(this.#grant);
|
|
14
|
+
}
|
|
15
|
+
#scope() {
|
|
16
|
+
const owner = this.#grant.owner;
|
|
17
|
+
return { authorityId: owner.authorityId, principalId: owner.principalId, workspace: owner.workspace,
|
|
18
|
+
agentPreset: owner.agentPreset, expectedOwner: { authorityHash: owner.authorityHash,
|
|
19
|
+
principalRecordId: owner.principalRecordId, principalVersion: owner.principalVersion } };
|
|
20
|
+
}
|
|
21
|
+
#services() {
|
|
22
|
+
const delivery = this.ctx.get('assistantDelivery');
|
|
23
|
+
const evaluation = this.ctx.get('assistantEvaluation');
|
|
24
|
+
if (!delivery || !evaluation || typeof delivery.withOwnerForegroundTaskSourcesFence !== 'function'
|
|
25
|
+
|| typeof delivery.inspectOwnerForegroundLearningTask !== 'function'
|
|
26
|
+
|| typeof evaluation.canonicalHostScope !== 'function' || typeof evaluation.getTrustedForegroundLearningProjection !== 'function'
|
|
27
|
+
|| typeof evaluation.inspectTrustedTaskOwnerRevision !== 'function' || typeof evaluation.listTrustedTaskLearningProjections !== 'function'
|
|
28
|
+
|| typeof evaluation.withTrustedCanonicalScopeWriterFence !== 'function')
|
|
29
|
+
throw new Error('memory learning source services unavailable');
|
|
30
|
+
return { delivery, evaluation };
|
|
31
|
+
}
|
|
32
|
+
#policy(request, consume = false) {
|
|
33
|
+
const policy = this.ctx.get('assistantPolicy');
|
|
34
|
+
if (!policy)
|
|
35
|
+
throw new Error('memory learning policy unavailable');
|
|
36
|
+
const owner = request?.owner ?? this.#grant.owner;
|
|
37
|
+
const input = { subject: { kind: 'background', id: 'assistant-memory-learning',
|
|
38
|
+
workspace: owner.workspace, principal: owner.principalId }, action: 'adopt',
|
|
39
|
+
resource: { kind: 'memory', id: `learning:${this.#grant.authorityId}` }, context: { initiator: 'background' } };
|
|
40
|
+
const decision = consume && request ? policy.authorize(input, { idempotencyKey: `memory-adopt:${this.#grant.authorityId}:${memoryLearningRequestDigest(request)}` })
|
|
41
|
+
: policy.evaluate(input);
|
|
42
|
+
if (decision.effect !== 'allow')
|
|
43
|
+
throw new Error('memory learning adoption policy denied');
|
|
44
|
+
}
|
|
45
|
+
#request(input) {
|
|
46
|
+
const request = validateMemoryLearningReviewRequest(input);
|
|
47
|
+
if (growthObjectDigest(request.owner) !== growthObjectDigest(this.#grant.owner))
|
|
48
|
+
throw new Error('memory learning owner changed');
|
|
49
|
+
if (request.protocol === 'memory-learning-review/v2' && this.#grant.workItemExperiences !== true)
|
|
50
|
+
throw new Error('work item experience adoption is not authorized');
|
|
51
|
+
return request;
|
|
52
|
+
}
|
|
53
|
+
#owner(input) {
|
|
54
|
+
const owner = validateMemoryLearningOwner(input);
|
|
55
|
+
if (growthObjectDigest(owner) !== growthObjectDigest(this.#grant.owner))
|
|
56
|
+
throw new Error('memory learning owner changed');
|
|
57
|
+
return owner;
|
|
58
|
+
}
|
|
59
|
+
#evaluationFence(evaluation, callback) {
|
|
60
|
+
const owner = this.#grant.owner;
|
|
61
|
+
const scope = evaluation.canonicalHostScope({ workspace: owner.workspace, preset: owner.agentPreset });
|
|
62
|
+
const { scopeWatermark } = evaluation.listTrustedTaskLearningProjections({ scope, limit: 1 });
|
|
63
|
+
const result = evaluation.withTrustedCanonicalScopeWriterFence({ scope, scopeWatermark }, callback);
|
|
64
|
+
if (!result.matched)
|
|
65
|
+
throw new Error('memory learning canonical scope changed');
|
|
66
|
+
return result.value;
|
|
67
|
+
}
|
|
68
|
+
#sourceState(request, content, services, snapshot) {
|
|
69
|
+
if (!content || content.sourceDigest !== request.source.sourceDigest || content.contentDigest !== request.source.contentDigest
|
|
70
|
+
|| content.input.truncated || content.reply.truncated || !content.source.execution.modelSelection)
|
|
71
|
+
return 'source-changed';
|
|
72
|
+
const { owner } = request;
|
|
73
|
+
const scope = services?.evaluation.canonicalHostScope({ workspace: owner.workspace, preset: owner.agentPreset });
|
|
74
|
+
const current = snapshot ? snapshot.currentCanonical : services.evaluation.getTrustedForegroundLearningProjection({ scope: scope, inboxId: request.source.inboxId });
|
|
75
|
+
const revision = snapshot ? snapshot.ownerRevision : current === undefined ? undefined : services.evaluation.inspectTrustedTaskOwnerRevision({
|
|
76
|
+
scope: scope, outcomeId: current.triggerOutcomeId, principalRecordId: owner.principalRecordId, principalVersion: owner.principalVersion,
|
|
77
|
+
});
|
|
78
|
+
if (revision?.action === 'withdraw')
|
|
79
|
+
return 'withdrawn';
|
|
80
|
+
if (request.source.canonical) {
|
|
81
|
+
const expected = request.source.canonical;
|
|
82
|
+
const task = snapshot ? snapshot.task : services.delivery.inspectOwnerForegroundLearningTask({ authorityId: owner.authorityId, principalId: owner.principalId,
|
|
83
|
+
workspace: owner.workspace, agentPreset: owner.agentPreset, outcomeId: expected.outcomeId });
|
|
84
|
+
if (!task || task.judgement === 'unresolved' || task.source.inboxId !== request.source.inboxId || !task.source.quiescent
|
|
85
|
+
|| task.ownerRevision?.action === 'withdraw' || task.canonical.projection.disposition !== 'upsert'
|
|
86
|
+
|| task.canonical.projection.version !== expected.version || task.canonical.projection.digest !== expected.digest
|
|
87
|
+
|| task.canonical.objective?.status !== expected.objectiveStatus
|
|
88
|
+
|| task.owner.principalRecordId !== owner.principalRecordId || task.owner.principalVersion !== owner.principalVersion
|
|
89
|
+
|| task.owner.authorityHash !== owner.authorityHash || task.feedback?.truncated)
|
|
90
|
+
return 'source-changed';
|
|
91
|
+
}
|
|
92
|
+
return 'current';
|
|
93
|
+
}
|
|
94
|
+
#sourceKey(request) {
|
|
95
|
+
return request.protocol === 'memory-learning-review/v1' ? `foreground:${request.source.inboxId}` : `work-item:${request.source.itemId}`;
|
|
96
|
+
}
|
|
97
|
+
#expectation(request) {
|
|
98
|
+
return request.protocol === 'memory-learning-review/v1'
|
|
99
|
+
? { kind: 'foreground', inboxId: request.source.inboxId, expectedSourceDigest: request.source.sourceDigest }
|
|
100
|
+
: { kind: 'work-item', itemId: request.source.itemId, outcomeId: request.source.canonical.outcomeId,
|
|
101
|
+
expectedSourceDigest: request.source.sourceDigest, expectedContentDigest: request.source.contentDigest,
|
|
102
|
+
canonical: { version: request.source.canonical.version, digest: request.source.canonical.digest,
|
|
103
|
+
objectiveStatus: request.source.canonical.objectiveStatus } };
|
|
104
|
+
}
|
|
105
|
+
/** One typed batch; the mixed callback must never re-enter a producer. */
|
|
106
|
+
#withSources(requests, callback) {
|
|
107
|
+
const selected = new Map();
|
|
108
|
+
for (const request of requests) {
|
|
109
|
+
const key = this.#sourceKey(request), previous = selected.get(key);
|
|
110
|
+
if (!previous || request.protocol === 'memory-learning-review/v2' && previous.protocol === 'memory-learning-review/v2'
|
|
111
|
+
&& request.source.canonical.version > previous.source.canonical.version)
|
|
112
|
+
selected.set(key, request);
|
|
113
|
+
}
|
|
114
|
+
const entries = [...selected.entries()], sources = entries.map(([, request]) => this.#expectation(request));
|
|
115
|
+
if (requests.some(request => request.protocol === 'memory-learning-review/v2')) {
|
|
116
|
+
const delivery = this.ctx.get('assistantDelivery');
|
|
117
|
+
if (typeof delivery?.withOwnerLearningSourcesFence !== 'function')
|
|
118
|
+
throw new Error('mixed memory learning source fence unavailable');
|
|
119
|
+
return delivery.withOwnerLearningSourcesFence({ ...this.#scope(), sources }, snapshots => {
|
|
120
|
+
if (snapshots.length !== sources.length)
|
|
121
|
+
throw new Error('memory learning source batch misaligned');
|
|
122
|
+
const byKey = new Map();
|
|
123
|
+
for (const [index, snapshot] of snapshots.entries()) {
|
|
124
|
+
const expected = sources[index];
|
|
125
|
+
if (snapshot.kind !== expected.kind || (snapshot.kind === 'foreground' ? snapshot.inboxId : snapshot.itemId)
|
|
126
|
+
!== (expected.kind === 'foreground' ? expected.inboxId : expected.itemId))
|
|
127
|
+
throw new Error('memory learning source identity changed');
|
|
128
|
+
byKey.set(entries[index][0], snapshot);
|
|
129
|
+
}
|
|
130
|
+
return callback(byKey);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const services = this.#services();
|
|
134
|
+
return services.delivery.withOwnerForegroundTaskSourcesFence({ ...this.#scope(), sources: sources.map(source => {
|
|
135
|
+
if (source.kind !== 'foreground')
|
|
136
|
+
throw new Error('legacy memory source changed');
|
|
137
|
+
return { inboxId: source.inboxId, expectedSourceDigest: source.expectedSourceDigest };
|
|
138
|
+
}) }, contents => this.#evaluationFence(services.evaluation, () => callback(new Map(entries.map(([key, request], index) => {
|
|
139
|
+
if (request.protocol !== 'memory-learning-review/v1')
|
|
140
|
+
throw new Error('legacy memory source changed');
|
|
141
|
+
return [key, { kind: 'foreground', inboxId: request.source.inboxId, content: contents[index] }];
|
|
142
|
+
})), services)));
|
|
143
|
+
}
|
|
144
|
+
#state(request, snapshot, legacy) {
|
|
145
|
+
if (request.protocol === 'memory-learning-review/v1') {
|
|
146
|
+
if (snapshot?.kind !== 'foreground' || snapshot.inboxId !== request.source.inboxId)
|
|
147
|
+
return 'source-changed';
|
|
148
|
+
return this.#sourceState(request, snapshot.content, legacy, legacy ? undefined : snapshot);
|
|
149
|
+
}
|
|
150
|
+
if (this.#grant.workItemExperiences !== true || snapshot?.kind !== 'work-item' || snapshot.itemId !== request.source.itemId)
|
|
151
|
+
return 'source-changed';
|
|
152
|
+
const task = snapshot.task, expected = request.source.canonical;
|
|
153
|
+
// Only an authenticated explicit withdrawal, never a missing source or a
|
|
154
|
+
// generic canonical retract, can permanently invalidate managed memory.
|
|
155
|
+
if (snapshot.ownerRevision?.action === 'withdraw'
|
|
156
|
+
&& snapshot.currentCanonical?.projection.subjectKind === 'work-item'
|
|
157
|
+
&& snapshot.currentCanonical.projection.subjectRef === request.source.itemId
|
|
158
|
+
&& snapshot.currentCanonical.objective?.outcomeId === snapshot.ownerRevision.outcomeId
|
|
159
|
+
&& snapshot.currentCanonical.objective.status === 'unknown')
|
|
160
|
+
return 'withdrawn';
|
|
161
|
+
if (!task || task.sourceDigest !== request.source.sourceDigest || task.presentationDigest !== request.source.contentDigest
|
|
162
|
+
|| task.proofIdentity.itemId !== request.source.itemId || task.judgement !== 'owner-feedback'
|
|
163
|
+
|| task.presentation.feedback.truncated || task.presentation.brief.truncated || task.presentation.report.truncated
|
|
164
|
+
|| task.canonical.projection.subjectKind !== 'work-item' || task.canonical.projection.subjectRef !== request.source.itemId
|
|
165
|
+
|| task.canonical.projection.disposition !== 'upsert' || task.canonical.projection.version !== expected.version
|
|
166
|
+
|| task.canonical.projection.digest !== expected.digest || task.canonical.objective?.outcomeId !== expected.outcomeId
|
|
167
|
+
|| task.canonical.objective.status !== expected.objectiveStatus
|
|
168
|
+
|| !snapshot.currentCanonical || growthObjectDigest(snapshot.currentCanonical) !== growthObjectDigest(task.canonical)
|
|
169
|
+
|| ['authorityId', 'authorityHash', 'principalId', 'principalRecordId', 'principalVersion', 'workspace', 'agentPreset']
|
|
170
|
+
.some(key => task.owner[key] !== request.owner[key])
|
|
171
|
+
|| task.proofIdentity.production.quiescent !== true || task.proofIdentity.production.budgetSettlementState !== 'finalized'
|
|
172
|
+
|| !Number.isSafeInteger(task.proofIdentity.production.completedAt) || task.proofIdentity.production.completedAt < 0)
|
|
173
|
+
return 'source-changed';
|
|
174
|
+
return 'current';
|
|
175
|
+
}
|
|
176
|
+
/** Historical exact receipt for lost ACKs; not a claim that its record is still visible. */
|
|
177
|
+
lookup(input) {
|
|
178
|
+
const request = this.#request(input);
|
|
179
|
+
const delivery = this.ctx.get('assistantDelivery');
|
|
180
|
+
if (!delivery || typeof delivery.withOwnerForegroundTaskSourcesFence !== 'function')
|
|
181
|
+
throw new Error('memory learning owner service unavailable');
|
|
182
|
+
return delivery.withOwnerForegroundTaskSourcesFence({ ...this.#scope(), sources: [] }, () => {
|
|
183
|
+
this.#policy(request);
|
|
184
|
+
return this.store.lookupLearningAdoption({ authorityId: this.#grant.authorityId,
|
|
185
|
+
operationId: request.operationId, requestDigest: memoryLearningRequestDigest(request) });
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
adopt(input) {
|
|
189
|
+
const request = this.#request(input);
|
|
190
|
+
const prior = this.lookup(request);
|
|
191
|
+
if (prior)
|
|
192
|
+
return prior;
|
|
193
|
+
if (Date.now() >= this.#grant.expiresAt)
|
|
194
|
+
throw new Error('memory learning adoption grant expired');
|
|
195
|
+
const verifier = this.ctx.get('assistantVerifier');
|
|
196
|
+
if (!verifier || typeof verifier.lookupMemoryLearningReview !== 'function')
|
|
197
|
+
throw new Error('memory learning independent reviewer unavailable');
|
|
198
|
+
// Verifier lookup takes its own producer locks. Complete it before taking
|
|
199
|
+
// Delivery → Evaluation → Memory below; no asynchronous gap is introduced.
|
|
200
|
+
const reviewReceipt = verifier.lookupMemoryLearningReview(request);
|
|
201
|
+
if (!reviewReceipt || reviewReceipt.status !== 'approved' || reviewReceipt.requestDigest !== memoryLearningRequestDigest(request)
|
|
202
|
+
|| reviewReceipt.operationId !== request.operationId || reviewReceipt.authorityId !== this.#grant.reviewAuthorityId
|
|
203
|
+
|| reviewReceipt.authorityDigest !== this.#grant.reviewAuthorityDigest)
|
|
204
|
+
throw new Error('memory learning independent approval unavailable or changed');
|
|
205
|
+
return this.#withSources([request], (snapshots, legacy) => {
|
|
206
|
+
const snapshot = snapshots.get(this.#sourceKey(request));
|
|
207
|
+
if (this.#state(request, snapshot, legacy) !== 'current')
|
|
208
|
+
throw new Error('memory learning source changed or withdrawn');
|
|
209
|
+
let sourceObservedAt;
|
|
210
|
+
if (request.protocol === 'memory-learning-review/v2') {
|
|
211
|
+
if (snapshot?.kind !== 'work-item' || !snapshot.task)
|
|
212
|
+
throw new Error('work item source unavailable');
|
|
213
|
+
if (!snapshot.task.presentation.feedback.text.includes(request.evidenceQuote)
|
|
214
|
+
|| !hasWorkItemLearningFeedbackText(request.evidenceQuote)) {
|
|
215
|
+
throw new Error('work item quotation is not substantive visible owner feedback');
|
|
216
|
+
}
|
|
217
|
+
if (request.mutation.op !== 'add') {
|
|
218
|
+
const target = this.store.inspectLearningTarget({ owner: request.owner, id: request.mutation.id, expectedVersion: request.mutation.expectedVersion });
|
|
219
|
+
if (target?.kind !== 'experience')
|
|
220
|
+
throw new Error('work item learning target must be an exact managed experience');
|
|
221
|
+
}
|
|
222
|
+
sourceObservedAt = snapshot.task.proofIdentity.production.completedAt;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
if (snapshot?.kind !== 'foreground' || !snapshot.content)
|
|
226
|
+
throw new Error('foreground source unavailable');
|
|
227
|
+
sourceObservedAt = snapshot.content.source.execution.completedAt;
|
|
228
|
+
}
|
|
229
|
+
this.#policy(request, true);
|
|
230
|
+
return this.store.applyLearningAdoption({ grant: this.#grant, request, reviewReceipt, sourceObservedAt });
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
inspectTarget(input) {
|
|
234
|
+
if (growthObjectDigest(input.owner) !== growthObjectDigest(this.#grant.owner))
|
|
235
|
+
return undefined;
|
|
236
|
+
return this.store.inspectLearningTarget(input);
|
|
237
|
+
}
|
|
238
|
+
/** Host-only bounded candidates, after current owner, Policy and source checks. */
|
|
239
|
+
listTargets(input) {
|
|
240
|
+
const owner = this.#owner(input.owner);
|
|
241
|
+
const limit = input.limit ?? 20;
|
|
242
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)
|
|
243
|
+
throw new Error('memory learning target limit is invalid');
|
|
244
|
+
this.#policy();
|
|
245
|
+
const context = { workspace: owner.workspace, agentPreset: owner.agentPreset,
|
|
246
|
+
namespace: { mode: 'delivery', principalDigest: memoryPrincipalDigest(owner.principalId),
|
|
247
|
+
principalRecordId: owner.principalRecordId, principalVersion: owner.principalVersion } };
|
|
248
|
+
const managed = this.store.listManagedLearningSources(context)
|
|
249
|
+
.filter(item => growthObjectDigest(item.request.owner) === growthObjectDigest(owner));
|
|
250
|
+
if (managed.length > 1000)
|
|
251
|
+
return Object.freeze([]);
|
|
252
|
+
try {
|
|
253
|
+
return this.#withSources(managed.map(item => item.request), (snapshots, legacy) => {
|
|
254
|
+
this.#policy();
|
|
255
|
+
if (!this.store.inspectLearningAdoptionAvailability(this.#grant).available)
|
|
256
|
+
return Object.freeze([]);
|
|
257
|
+
const targets = managed.flatMap(item => {
|
|
258
|
+
if (this.#state(item.request, snapshots.get(this.#sourceKey(item.request)), legacy) !== 'current')
|
|
259
|
+
return [];
|
|
260
|
+
const target = this.store.inspectLearningTarget({ owner, id: item.id, expectedVersion: item.version });
|
|
261
|
+
return target === undefined ? [] : [{ id: target.id, version: target.version, kind: target.kind, content: target.content,
|
|
262
|
+
...(target.knowledge === undefined ? {} : { knowledge: target.knowledge }) }];
|
|
263
|
+
});
|
|
264
|
+
targets.sort((a, b) => a.id.localeCompare(b.id) || a.version - b.version);
|
|
265
|
+
return Object.freeze(targets.slice(0, limit));
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return Object.freeze([]);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/** Host-only budget view; no grant registration or Policy quota consumption. */
|
|
273
|
+
inspectAvailability(input) {
|
|
274
|
+
this.#owner(input.owner);
|
|
275
|
+
const delivery = this.ctx.get('assistantDelivery');
|
|
276
|
+
if (!delivery || typeof delivery.withOwnerForegroundTaskSourcesFence !== 'function')
|
|
277
|
+
throw new Error('memory learning owner service unavailable');
|
|
278
|
+
return delivery.withOwnerForegroundTaskSourcesFence({ ...this.#scope(), sources: [] }, () => {
|
|
279
|
+
this.#policy();
|
|
280
|
+
const availability = this.store.inspectLearningAdoptionAvailability(this.#grant);
|
|
281
|
+
if (availability.workItemExperiences === true && typeof delivery.withOwnerLearningSourcesFence !== 'function') {
|
|
282
|
+
const { workItemExperiences: _unsupported, ...legacy } = availability;
|
|
283
|
+
return Object.freeze(legacy);
|
|
284
|
+
}
|
|
285
|
+
return availability;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
#matchesContext(context) {
|
|
289
|
+
const owner = this.#grant.owner, namespace = context.namespace;
|
|
290
|
+
return context.workspace === owner.workspace && context.agentPreset === owner.agentPreset
|
|
291
|
+
&& namespace.mode === 'delivery' && namespace.principalRecordId === owner.principalRecordId
|
|
292
|
+
&& namespace.principalVersion === owner.principalVersion && namespace.principalDigest === memoryPrincipalDigest(owner.principalId);
|
|
293
|
+
}
|
|
294
|
+
/** Sources stay locked through Memory's read snapshot, ranking and framing. */
|
|
295
|
+
withVisible(context, callback) {
|
|
296
|
+
if (!this.#matchesContext(context))
|
|
297
|
+
return callback();
|
|
298
|
+
// This query has no held Memory transaction. Newly appearing/changed
|
|
299
|
+
// managed versions are excluded by the final exact-reference filter.
|
|
300
|
+
const managed = this.store.listManagedLearningSources(context)
|
|
301
|
+
.filter(source => growthObjectDigest(source.request.owner) === growthObjectDigest(this.#grant.owner));
|
|
302
|
+
if (managed.length === 0 || managed.length > 1000)
|
|
303
|
+
return callback();
|
|
304
|
+
let callbackStarted = false;
|
|
305
|
+
try {
|
|
306
|
+
return this.#withSources(managed.map(item => item.request), (snapshots, legacy) => {
|
|
307
|
+
const visible = [];
|
|
308
|
+
for (const item of managed) {
|
|
309
|
+
const state = this.#state(item.request, snapshots.get(this.#sourceKey(item.request)), legacy);
|
|
310
|
+
if (state === 'current')
|
|
311
|
+
visible.push(item);
|
|
312
|
+
else if (state === 'withdrawn')
|
|
313
|
+
this.store.invalidateManagedLearningSource({ owner: item.request.owner, id: item.id, version: item.version,
|
|
314
|
+
recordDigest: item.recordDigest, sourceDigest: item.sourceDigest, reason: state });
|
|
315
|
+
}
|
|
316
|
+
callbackStarted = true;
|
|
317
|
+
return this.store.withLearningVisibility(visible, callback);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
if (callbackStarted)
|
|
322
|
+
throw error;
|
|
323
|
+
// Temporary provider absence/errors hide automatic records, without
|
|
324
|
+
// manufacturing a durable withdrawal or suppressing manual memory.
|
|
325
|
+
return callback();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=learning-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"learning-service.js","sourceRoot":"","sources":["../src/learning-service.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,+BAA+B,EACrH,2BAA2B,GAE5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,q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AAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PreferenceMemoryPromotionCancellationReceipt, type PreferenceMemoryPromotionCancellationRequest, type PreferenceMemoryPromotionProducer, type PreferenceMemoryPromotionRegistration, type PreferenceMemoryPromotionRequest, type PreferenceMemoryPromotionResult, type PreferenceMemoryPromotionResultAck, type PreferenceMemoryPromotionSubmissionReceipt, type PreferencePromotionSourceRegistrationOwner } from '@dsh-ray/assistant-growth-contract';
|
|
2
|
+
import type { MemoryMutation, MemoryOwnerNamespace } from './types.js';
|
|
3
|
+
export interface PreferencePromotionBridgeHandlers {
|
|
4
|
+
submit(request: Readonly<PreferenceMemoryPromotionRequest>): Readonly<PreferenceMemoryPromotionSubmissionReceipt>;
|
|
5
|
+
cancel(request: Readonly<PreferenceMemoryPromotionCancellationRequest>): Readonly<PreferenceMemoryPromotionCancellationReceipt>;
|
|
6
|
+
list(limit: number): readonly Readonly<PreferenceMemoryPromotionResult>[];
|
|
7
|
+
acknowledge(ack: Readonly<PreferenceMemoryPromotionResultAck>): void;
|
|
8
|
+
}
|
|
9
|
+
/** Fixed, content-free request projection. Callers cannot provide Memory prose or trust. */
|
|
10
|
+
export declare function preferencePromotionMutation(requestInput: Readonly<PreferenceMemoryPromotionRequest>): Readonly<MemoryMutation>;
|
|
11
|
+
export declare function preferencePromotionNamespace(requestInput: Readonly<PreferenceMemoryPromotionRequest>, principalDigest: string): Readonly<MemoryOwnerNamespace>;
|
|
12
|
+
/**
|
|
13
|
+
* One private, process-local registration per exact Preference producer
|
|
14
|
+
* generation. Every callback rechecks both object identity and generation.
|
|
15
|
+
*/
|
|
16
|
+
export declare class PreferenceMemoryPromotionBridge implements PreferencePromotionSourceRegistrationOwner {
|
|
17
|
+
#private;
|
|
18
|
+
private readonly handlers;
|
|
19
|
+
constructor(handlers: PreferencePromotionBridgeHandlers, resolveProducer?: (value: unknown) => PreferenceMemoryPromotionProducer | undefined);
|
|
20
|
+
ownsPreferencePromotionSourceRegistration(registration: Readonly<PreferenceMemoryPromotionRegistration>): boolean;
|
|
21
|
+
bind(value: unknown): (() => void) | undefined;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=promotion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.d.ts","sourceRoot":"","sources":["../src/promotion.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,4CAA4C,EACjD,KAAK,4CAA4C,EACjD,KAAK,iCAAiC,EACtC,KAAK,qCAAqC,EAC1C,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,kCAAkC,EACvC,KAAK,0CAA0C,EAC/C,KAAK,0CAA0C,EAChD,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtE,MAAM,WAAW,iCAAiC;IAChD,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,gCAAgC,CAAC,GAAG,QAAQ,CAAC,0CAA0C,CAAC,CAAA;IACjH,MAAM,CACJ,OAAO,EAAE,QAAQ,CAAC,4CAA4C,CAAC,GAC9D,QAAQ,CAAC,4CAA4C,CAAC,CAAA;IACzD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAA;IACzE,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,kCAAkC,CAAC,GAAG,IAAI,CAAA;CACrE;AAiBD,4FAA4F;AAC5F,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,QAAQ,CAAC,gCAAgC,CAAC,GACvD,QAAQ,CAAC,cAAc,CAAC,CAyB1B;AAED,wBAAgB,4BAA4B,CAC1C,YAAY,EAAE,QAAQ,CAAC,gCAAgC,CAAC,EACxD,eAAe,EAAE,MAAM,GACtB,QAAQ,CAAC,oBAAoB,CAAC,CAQhC;AAED;;;GAGG;AACH,qBAAa,+BAAgC,YAAW,0CAA0C;;IAO9F,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,iCAAiC,EAC5D,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,iCAAiC,GAAG,SAAS;IAOrF,yCAAyC,CACvC,YAAY,EAAE,QAAQ,CAAC,qCAAqC,CAAC,GAC5D,OAAO;IAIV,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;IAwE9C,OAAO,IAAI,IAAI;CAMhB"}
|
package/lib/promotion.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { PREFERENCE_MEMORY_PROMOTION_CONTENT, PREFERENCE_MEMORY_PROMOTION_PROTOCOL, PREFERENCE_MEMORY_PROMOTION_RENDERER_ID, resolveTrustedPreferenceMemoryPromotionProducer, validatePreferenceMemoryPromotionCancellationRequest, validatePreferenceMemoryPromotionRequest, validatePreferenceMemoryPromotionResultAck, } from '@dsh-ray/assistant-growth-contract';
|
|
3
|
+
function generation(value) {
|
|
4
|
+
if (typeof value !== 'string' || value.normalize('NFC').trim() !== value || value === ''
|
|
5
|
+
|| Buffer.byteLength(value, 'utf8') > 200) {
|
|
6
|
+
throw new Error('personal-memory: Preference promotion producer generation is invalid');
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
/** Fixed, content-free request projection. Callers cannot provide Memory prose or trust. */
|
|
11
|
+
export function preferencePromotionMutation(requestInput) {
|
|
12
|
+
const request = validatePreferenceMemoryPromotionRequest(requestInput);
|
|
13
|
+
if (request.rendererId !== PREFERENCE_MEMORY_PROMOTION_RENDERER_ID) {
|
|
14
|
+
throw new Error('personal-memory: Preference promotion renderer is invalid');
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze({
|
|
17
|
+
op: 'add',
|
|
18
|
+
identity: Object.freeze({
|
|
19
|
+
owner: 'user',
|
|
20
|
+
scope: 'workspace',
|
|
21
|
+
workspace: request.scope.workspace,
|
|
22
|
+
}),
|
|
23
|
+
entry: Object.freeze({
|
|
24
|
+
kind: 'preference',
|
|
25
|
+
content: PREFERENCE_MEMORY_PROMOTION_CONTENT,
|
|
26
|
+
sensitivity: 'private',
|
|
27
|
+
trust: 'user-confirmed',
|
|
28
|
+
confidence: request.hypothesis.confidenceBps / 10_000,
|
|
29
|
+
provenance: Object.freeze({
|
|
30
|
+
source: `preference-learning:${PREFERENCE_MEMORY_PROMOTION_RENDERER_ID}`,
|
|
31
|
+
observedAt: request.observedAt,
|
|
32
|
+
uri: `preference://${request.hypothesis.id}/v${request.hypothesis.version}`,
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function preferencePromotionNamespace(requestInput, principalDigest) {
|
|
38
|
+
const request = validatePreferenceMemoryPromotionRequest(requestInput);
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
mode: 'delivery',
|
|
41
|
+
principalDigest,
|
|
42
|
+
principalRecordId: request.principalLineage.principalRecordId,
|
|
43
|
+
principalVersion: request.principalLineage.principalVersion,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One private, process-local registration per exact Preference producer
|
|
48
|
+
* generation. Every callback rechecks both object identity and generation.
|
|
49
|
+
*/
|
|
50
|
+
export class PreferenceMemoryPromotionBridge {
|
|
51
|
+
handlers;
|
|
52
|
+
#sinkGeneration = `personal-memory-promotion:${randomUUID()}`;
|
|
53
|
+
#activeRegistrations = new WeakSet();
|
|
54
|
+
#binding;
|
|
55
|
+
#active = true;
|
|
56
|
+
constructor(handlers, resolveProducer) {
|
|
57
|
+
this.handlers = handlers;
|
|
58
|
+
this.#resolveProducer = resolveProducer ?? resolveTrustedPreferenceMemoryPromotionProducer;
|
|
59
|
+
}
|
|
60
|
+
#resolveProducer;
|
|
61
|
+
ownsPreferencePromotionSourceRegistration(registration) {
|
|
62
|
+
return this.#active && this.#activeRegistrations.has(registration);
|
|
63
|
+
}
|
|
64
|
+
bind(value) {
|
|
65
|
+
const producer = this.#resolveProducer(value);
|
|
66
|
+
if (producer === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
const sourceGeneration = generation(producer.trustedMemoryPromotionProducerGeneration());
|
|
69
|
+
const current = this.#binding;
|
|
70
|
+
if (current !== undefined && current.producer === producer
|
|
71
|
+
&& current.sourceGeneration === sourceGeneration) {
|
|
72
|
+
return current.dispose;
|
|
73
|
+
}
|
|
74
|
+
let live = true;
|
|
75
|
+
let unregister;
|
|
76
|
+
let binding;
|
|
77
|
+
let registration;
|
|
78
|
+
const assertCurrent = () => {
|
|
79
|
+
if (!live || !this.#active || this.#binding !== binding
|
|
80
|
+
|| !this.#activeRegistrations.has(registration)
|
|
81
|
+
|| this.#resolveProducer(producer) !== producer
|
|
82
|
+
|| generation(producer.trustedMemoryPromotionProducerGeneration()) !== sourceGeneration) {
|
|
83
|
+
throw new Error('personal-memory: stale Preference promotion capability');
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
registration = Object.freeze({
|
|
87
|
+
protocol: PREFERENCE_MEMORY_PROMOTION_PROTOCOL,
|
|
88
|
+
producer: 'personal-memory',
|
|
89
|
+
sourceGeneration,
|
|
90
|
+
sinkGeneration: this.#sinkGeneration,
|
|
91
|
+
owner: this,
|
|
92
|
+
propose: (input) => {
|
|
93
|
+
assertCurrent();
|
|
94
|
+
return this.handlers.submit(validatePreferenceMemoryPromotionRequest(input));
|
|
95
|
+
},
|
|
96
|
+
cancelPromotion: (input) => {
|
|
97
|
+
assertCurrent();
|
|
98
|
+
return this.handlers.cancel(validatePreferenceMemoryPromotionCancellationRequest(input));
|
|
99
|
+
},
|
|
100
|
+
listTerminalResults: (limit) => {
|
|
101
|
+
assertCurrent();
|
|
102
|
+
return this.handlers.list(limit);
|
|
103
|
+
},
|
|
104
|
+
acknowledgeTerminalResult: (input) => {
|
|
105
|
+
assertCurrent();
|
|
106
|
+
this.handlers.acknowledge(validatePreferenceMemoryPromotionResultAck(input));
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
this.#activeRegistrations.add(registration);
|
|
110
|
+
const dispose = () => {
|
|
111
|
+
if (!live)
|
|
112
|
+
return;
|
|
113
|
+
live = false;
|
|
114
|
+
this.#activeRegistrations.delete(registration);
|
|
115
|
+
if (this.#binding === binding)
|
|
116
|
+
this.#binding = undefined;
|
|
117
|
+
unregister?.();
|
|
118
|
+
};
|
|
119
|
+
binding = Object.freeze({ producer, sourceGeneration, registration, dispose });
|
|
120
|
+
const previous = this.#binding;
|
|
121
|
+
this.#binding = binding;
|
|
122
|
+
try {
|
|
123
|
+
unregister = producer.registerTrustedMemoryPromotionResultSink(registration);
|
|
124
|
+
if (typeof unregister !== 'function'
|
|
125
|
+
|| generation(producer.trustedMemoryPromotionProducerGeneration()) !== sourceGeneration) {
|
|
126
|
+
throw new Error('personal-memory: Preference promotion registration failed');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
live = false;
|
|
131
|
+
this.#activeRegistrations.delete(registration);
|
|
132
|
+
if (this.#binding === binding)
|
|
133
|
+
this.#binding = previous;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
previous?.dispose();
|
|
137
|
+
return dispose;
|
|
138
|
+
}
|
|
139
|
+
dispose() {
|
|
140
|
+
if (!this.#active)
|
|
141
|
+
return;
|
|
142
|
+
this.#active = false;
|
|
143
|
+
this.#binding?.dispose();
|
|
144
|
+
this.#binding = undefined;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=promotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promotion.js","sourceRoot":"","sources":["../src/promotion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EACL,mCAAmC,EACnC,oCAAoC,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,oBAAoB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;YAC9C,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO;gBAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;YACvD,MAAM,KAAK,CAAA;QACb,CAAC;QACD,QAAQ,EAAE,OAAO,EAAE,CAAA;QACnB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ApprovalDecisionInput, type ApprovalProposalLookupInput, type ApprovalProposalInput, type ApprovalProposalRecoveryInput, type ApprovalProposalRecoveryResult, type ApprovalProposalResult, type ApprovalProposalSnapshot } from '@dsh-ray/assistant-policy';
|
|
2
|
+
import { MemoryStore } from './store.js';
|
|
3
|
+
import type { MemoryProposalDecisionInput, MemoryProposalInput, MemoryProposalResult, StoredMemoryProposal } from './types.js';
|
|
4
|
+
import type { PreferenceMemoryPromotionCancellationReceipt } from '@dsh-ray/assistant-growth-contract';
|
|
5
|
+
export declare class MemoryPromotionCancelledError extends Error {
|
|
6
|
+
readonly receipt: Readonly<PreferenceMemoryPromotionCancellationReceipt>;
|
|
7
|
+
constructor(receipt: Readonly<PreferenceMemoryPromotionCancellationReceipt>);
|
|
8
|
+
}
|
|
9
|
+
export interface MemoryApprovalPolicy {
|
|
10
|
+
propose(input: ApprovalProposalInput): ApprovalProposalResult;
|
|
11
|
+
recoverOrCreateProposal(input: ApprovalProposalRecoveryInput): ApprovalProposalRecoveryResult;
|
|
12
|
+
decideProposal(input: ApprovalDecisionInput): ApprovalProposalResult;
|
|
13
|
+
getProposal(proposalId: string): ApprovalProposalSnapshot | undefined;
|
|
14
|
+
getProposalByIdempotencyKey?(input: ApprovalProposalLookupInput): ApprovalProposalSnapshot | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare class MemoryProposalManager {
|
|
17
|
+
#private;
|
|
18
|
+
private readonly store;
|
|
19
|
+
private readonly policy;
|
|
20
|
+
private readonly validatePromotionOwner?;
|
|
21
|
+
constructor(store: MemoryStore, policy: MemoryApprovalPolicy, validatePromotionOwner?: ((proposal: StoredMemoryProposal) => "current" | "stale-owner") | undefined);
|
|
22
|
+
propose(input: MemoryProposalInput): MemoryProposalResult;
|
|
23
|
+
/**
|
|
24
|
+
* Materialize a terminal upstream fence/deadline result without creating a
|
|
25
|
+
* headless Policy proposal. The exact request still becomes durable first.
|
|
26
|
+
*/
|
|
27
|
+
rejectPromotionBeforePolicy(input: MemoryProposalInput & {
|
|
28
|
+
promotion: NonNullable<MemoryProposalInput['promotion']>;
|
|
29
|
+
}, status: 'expired' | 'stale-owner'): MemoryProposalResult;
|
|
30
|
+
decide(input: MemoryProposalDecisionInput): MemoryProposalResult;
|
|
31
|
+
getProposal(proposalId: string): MemoryProposalResult | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Commit locally pending proposals whose policy decision already settled
|
|
34
|
+
* elsewhere, for example on an approval card minutes after the turn ended.
|
|
35
|
+
*
|
|
36
|
+
* Approval is never inferred: the decision is read back from the policy ledger,
|
|
37
|
+
* and only a terminal policy status is settled here. Each settle reuses the
|
|
38
|
+
* existing idempotent commit path, so repeated reconciles are safe.
|
|
39
|
+
*/
|
|
40
|
+
reconcile(limit: number): MemoryProposalResult[];
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=proposals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proposals.d.ts","sourceRoot":"","sources":["../src/proposals.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,E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