Refactor session manager: migration chain, validation, tests

- Add migrateV1ToV2/migrateToCurrentVersion for extensible migrations
- createSummaryMessage now takes timestamp from entry
- loadEntriesFromFile validates session header
- findMostRecentSession only returns valid session files (reads first 512 bytes)
- Remove ConversationEntry alias
- Fix mom context.ts TreeNode type

Tests:
- migration.test.ts: v1 migration, idempotency
- build-context.test.ts: 14 tests covering trivial, compaction, branches
- file-operations.test.ts: loadEntriesFromFile, findMostRecentSession
This commit is contained in:
Mario Zechner 2025-12-26 01:33:13 +01:00
parent 95312e00bb
commit beb70f126d
7 changed files with 606 additions and 102 deletions

View file

@ -273,9 +273,11 @@ describe("findCutPoint", () => {
});
describe("createSummaryMessage", () => {
it("should create user message with prefix", () => {
const msg = createSummaryMessage("This is the summary");
it("should create user message with prefix and correct timestamp", () => {
const ts = "2025-01-01T12:00:00.000Z";
const msg = createSummaryMessage("This is the summary", ts);
expect(msg.role).toBe("user");
expect(msg.timestamp).toBe(new Date(ts).getTime());
if (msg.role === "user") {
expect(msg.content).toContain(
"The conversation history before this point was compacted into the following summary:",