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:
ZacharyZhang-NY committed 2026-04-19 01:34:14 -04:00
1 parent 5097591725
commit 5e6e929779
6 files changed
+19 -166

No files matched your search

@@ -101,38 +101,6 @@ describe("pi-mono migrations 27 + 28", () => {
dbB.close();
});
it("session_entries respects the unique (task_session_id, sequence) index across replace cycles", async () => {
const dir = await freshProfile("agentcompany-migration-replace-");
const db = new AppDatabase(dir);
db.init();
for (let i = 0; i < 3; i += 1) {
db.sessionEntries.append({
taskSessionId: "replace-test",
kind: "message",
role: "user",
payloadJson: JSON.stringify({ role: "user", content: `t${i}` }),
});
}
db.sessionEntries.replace({
taskSessionId: "replace-test",
entries: [
{ kind: "compaction", role: null, payloadJson: JSON.stringify({ summary: "summarised" }) },
{ kind: "message", role: "user", payloadJson: JSON.stringify({ role: "user", content: "post" }) },
],
});
const active = db.sessionEntries.listActive("replace-test");
expect(active).toHaveLength(2);
expect(active[0]?.kind).toBe("compaction");
expect(active[1]?.kind).toBe("message");
const all = db.sessionEntries.listAll("replace-test");
expect(all.length).toBe(5);
expect(all.filter((row) => row.isSuperseded).length).toBe(3);
db.close();
});
it("seedConnectors prunes legacy connector rows and inserts the full pi-mono + Fireworks catalog", async () => {
const dir = await freshProfile("agentcompany-migration-seed-");
const db = new AppDatabase(dir);