feat(memory): accept real compaction and parallel activities

This commit is contained in:
冰朔 2026-09-04 17:42:34 +08:00
commit 0486595b56
14 changed files with 506 additions and 13 deletions

View file

@ -107,6 +107,13 @@ export function validateEvent(event) {
nonEmpty(event.day_summary, "day_summary");
nonEmpty(event.month_summary, "month_summary");
nonEmpty(event.year_summary, "year_summary");
if (event.activity !== undefined) {
if (!event.activity || typeof event.activity !== "object" || Array.isArray(event.activity)) fail("INVALID_ACTIVITY");
nonEmpty(event.activity.what, "activity.what");
nonEmpty(event.activity.where, "activity.where");
stringList(event.activity.with_whom, "activity.with_whom");
if (event.activity.attention !== undefined) nonEmpty(event.activity.attention, "activity.attention");
}
for (const field of ["summary", "trigger", "emergence", "lock", "why"]) nonEmpty(event[field], field);
stringList(event.rejected, "rejected", true);
stringList(event.sources, "sources");
@ -394,6 +401,7 @@ export function appendEvent({ allowedRoot, storeRoot, event }) {
occurred_at: event.occurred_at,
session_id: event.session_id ?? null,
platform_window_id: event.platform_window_id ?? null,
activity: event.activity ?? null,
immutable_event_path: immutablePath,
immutable_event_sha256: sha256(immutableBody)
};