refactor: prune session-store and agent-list dead code
The session_entries supersede pipeline was a design that never shipped: `SqliteSessionStore.replaceMessages` / `appendCompaction`, `sessionEntries.replace` / `listAll` / `deleteForSession`, and the `"compaction" | "summary"` kind variants had zero live callers. Compaction wires through pi's `transformContext` and leaves the persisted transcript alone, so the shadow-row machinery was pure cruft with two tests propping it up. Rip it out: the store exposes only `loadMessages` and `appendMessage`, `sessionEntries` exposes only `append` and `listActive`, and `SessionEntryKind` narrows to `"message"` so new writers can't re-introduce a dead kind by accident. `is_superseded` stays on the table — the DB column is harmless with no writer, and dropping it is a separate schema migration concern. `listTopLevelAgentIds` loses its only caller in the previous commit (company channel now fans out through `listCompanyBroadcastAgentIds`), so it goes too. Three tests that validated the removed behaviour are deleted; the one remaining session-store test still covers the live `append + load` path.
This commit is contained in:
1 parent
5097591725
commit
5e6e929779
6 files changed
+19
-166
No files matched your search
@@ -8,7 +8,7 @@ import { SqliteSessionStore } from "../../src/main/agent-runtime/sqlite-session-
|
||||
|
||||
/**
|
||||
* Verifies the SqliteSessionStore round-trips pi `AgentMessage` values
|
||||
* correctly through the new `session_entries` table (migration 27).
|
||||
* correctly through the `session_entries` table.
|
||||
*/
|
||||
describe("SqliteSessionStore", () => {
|
||||
let tempDir: string;
|
||||
@@ -49,32 +49,4 @@ describe("SqliteSessionStore", () => {
|
||||
expect((loaded[0] as { role: string }).role).toBe("user");
|
||||
expect((loaded[1] as { role: string }).role).toBe("assistant");
|
||||
});
|
||||
|
||||
it("appends a compaction marker that does not appear as a message", () => {
|
||||
const store = new SqliteSessionStore(db, TASK_SESSION_ID);
|
||||
store.appendMessage({ role: "user", content: [{ type: "text", text: "first" }], timestamp: Date.now() } as AgentMessage);
|
||||
store.appendCompaction("Earlier conversation summarised: planning phase complete.");
|
||||
const loaded = store.loadMessages();
|
||||
expect(loaded).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("replaceMessages supersedes prior rows and inserts new ones in order", () => {
|
||||
const store = new SqliteSessionStore(db, TASK_SESSION_ID);
|
||||
store.appendMessage({ role: "user", content: [{ type: "text", text: "old-1" }], timestamp: Date.now() } as AgentMessage);
|
||||
store.appendMessage({ role: "assistant", content: [{ type: "text", text: "old-2" }], timestamp: Date.now() } as AgentMessage);
|
||||
|
||||
const compacted: AgentMessage[] = [
|
||||
{ role: "user", content: [{ type: "text", text: "context summary" }], timestamp: Date.now() } as AgentMessage,
|
||||
];
|
||||
store.replaceMessages(compacted, "Summary of prior turns.");
|
||||
|
||||
const active = store.loadMessages();
|
||||
expect(active).toHaveLength(1);
|
||||
expect((active[0] as { content: { text: string }[] }).content[0]?.text).toBe("context summary");
|
||||
|
||||
// Check: pre-replace messages must still exist as superseded audit rows.
|
||||
const all = db.sessionEntries.listAll(TASK_SESSION_ID);
|
||||
const supersededCount = all.filter((row) => row.isSuperseded).length;
|
||||
expect(supersededCount).toBe(2);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user