Add Persona semantic memory indexing

This commit is contained in:
Meta Vens 2026-06-05 22:19:27 +01:00
commit 95764c9a63
14 changed files with 3978 additions and 811 deletions

View file

@ -31,6 +31,17 @@ const evidenceRefSchema = z.object({
}).strict();
const anchorRefSchema = evidenceRefSchema;
const semanticMemoryIndexSchema = z.object({
corpusKind: z.literal("persona_memory"),
vectorStore: z.enum(["qdrant", "local_json"]),
collectionName: nonEmptyStringSchema,
embedderId: nonEmptyStringSchema,
contentHash: nonEmptyStringSchema,
chunkIds: z.array(nonEmptyStringSchema).default([]),
indexedAt: timestampSchema,
stale: z.boolean().default(false),
}).strict();
const activationVectorSchema = z.object({
mean: z.number().min(0).max(1),
plasticity: z.number().min(0).max(1),
@ -148,6 +159,7 @@ const distilledMemorySchema = z.object({
actionImplication: z.string().trim().min(1).max(2000).optional(),
anchorRefs: z.array(anchorRefSchema).default([]),
evidenceRefs: z.array(evidenceRefSchema).default([]),
semanticIndex: semanticMemoryIndexSchema.optional(),
createdAt: timestampSchema,
updatedAt: timestampSchema,
retiredAt: timestampSchema.optional(),

View file

@ -51,6 +51,25 @@ export async function loadVoidSelfStateTypedDocuments(
return readTypedStateOrEmpty(cache, options.identity);
}
export async function writeVoidSelfStateTypedDocuments(
options: VoidSelfStateServiceOptions,
typedState: VoidSelfStateTypedProjection,
): Promise<VoidSelfStateOperationResult> {
const canonicalPath = resolve(options.canonicalPath);
const cache = createVoidSelfStateCache(canonicalPath);
await cache.pullAllBackingStores();
if (options.identity) {
repairSelfProfileIdentity(typedState, options.identity);
}
await writeTypedState(cache, typedState);
return {
operation: "repair_typed_state",
canonicalPath,
typedDocumentsWritten: 8,
};
}
export async function applyVoidSelfStateOperation(
options: VoidSelfStateServiceOptions,
rawOperation: unknown,