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
@@ -4,9 +4,12 @@ import type { AppDatabase } from "@main/database";
|
||||
/**
|
||||
* SQLite-backed pi `AgentMessage[]` store.
|
||||
*
|
||||
* One store instance per task_session. Owners must call `appendMessage`
|
||||
* exactly once per pi `message_end` event, and `replaceMessages` after pi
|
||||
* `compact` returns a compacted message list.
|
||||
* One store instance per task_session. `appendMessage` runs exactly
|
||||
* once per pi `message_end` event; `loadMessages` reads the live
|
||||
* transcript back at `prepareRun`. Compaction happens at LLM-call
|
||||
* time via pi's `transformContext` hook and does not rewrite the
|
||||
* persisted transcript — the session shadow is the durable truth,
|
||||
* the compacted payload is a per-call view.
|
||||
*/
|
||||
export class SqliteSessionStore {
|
||||
constructor(
|
||||
@@ -33,28 +36,4 @@ export class SqliteSessionStore {
|
||||
payloadJson: JSON.stringify(message),
|
||||
});
|
||||
}
|
||||
|
||||
appendCompaction(summary: string): void {
|
||||
this.db.sessionEntries.append({
|
||||
taskSessionId: this.taskSessionId,
|
||||
kind: "compaction",
|
||||
role: null,
|
||||
payloadJson: JSON.stringify({ summary }),
|
||||
});
|
||||
}
|
||||
|
||||
replaceMessages(messages: AgentMessage[], compactionSummary?: string): void {
|
||||
const entries: Array<{ kind: "message" | "compaction"; role: string | null; payloadJson: string }> = [];
|
||||
if (compactionSummary) {
|
||||
entries.push({ kind: "compaction", role: null, payloadJson: JSON.stringify({ summary: compactionSummary }) });
|
||||
}
|
||||
for (const message of messages) {
|
||||
entries.push({
|
||||
kind: "message",
|
||||
role: (message as { role?: string }).role ?? null,
|
||||
payloadJson: JSON.stringify(message),
|
||||
});
|
||||
}
|
||||
this.db.sessionEntries.replace({ taskSessionId: this.taskSessionId, entries });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user