fix(#707): scope session GC retention
Some checks failed
ci/woodpecker/pr/ci Pipeline failed

This commit is contained in:
Jarvis
2026-07-12 15:57:09 -05:00
parent 119f64e69d
commit f17e70c145
9 changed files with 100 additions and 174 deletions

View File

@@ -58,9 +58,28 @@ export function createAgentLogsRepo(db: Db) {
return rows[0];
},
/**
* Transition hot logs for one session to warm tier. Session retention is
* default-deny: no other session's logs can be changed by this operation.
*/
async promoteSessionToWarm(sessionId: string, olderThan: Date): Promise<number> {
const result = await db
.update(agentLogs)
.set({ tier: 'warm', summarizedAt: new Date() })
.where(
and(
eq(agentLogs.sessionId, sessionId),
eq(agentLogs.tier, 'hot'),
lt(agentLogs.createdAt, olderThan),
),
)
.returning();
return result.length;
},
/**
* Transition hot logs older than the cutoff to warm tier.
* Returns the number of logs transitioned.
* Reserved for a separately authorized global retention job.
*/
async promoteToWarm(olderThan: Date): Promise<number> {
const result = await db