refactor(athena): remove dead session-guard code and unused types

Remove session-guard.ts (runtime gating uses hasPendingCouncilMembers instead), its test file, and dead snake_case type interfaces from types.ts that don't match the camelCase code.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
ismeth
2026-02-18 20:54:54 +01:00
committed by YeonGyu-Kim
parent 8381ea076a
commit d8c988543f
3 changed files with 0 additions and 128 deletions

View File

@@ -1,72 +0,0 @@
import { afterEach, describe, expect, test } from "bun:test"
import {
isCouncilRunning,
markCouncilDone,
markCouncilRunning,
_resetForTesting,
_setTimestampForTesting,
} from "./session-guard"
afterEach(() => {
_resetForTesting()
})
describe("session-guard", () => {
//#given no active sessions
//#when isCouncilRunning is checked
//#then returns false
test("returns false for unknown session", () => {
expect(isCouncilRunning("session-1")).toBe(false)
})
//#given a session is marked as running
//#when isCouncilRunning is checked
//#then returns true
test("returns true after markCouncilRunning", () => {
markCouncilRunning("session-1")
expect(isCouncilRunning("session-1")).toBe(true)
})
//#given a session was marked running then done
//#when isCouncilRunning is checked
//#then returns false
test("returns false after markCouncilDone", () => {
markCouncilRunning("session-1")
markCouncilDone("session-1")
expect(isCouncilRunning("session-1")).toBe(false)
})
//#given a session was marked running 6 minutes ago (past 5-minute timeout)
//#when isCouncilRunning is checked
//#then stale entry is purged and returns false
test("purges stale entries older than 5 minutes", () => {
const sixMinutesAgo = Date.now() - 6 * 60 * 1000
_setTimestampForTesting("stale-session", sixMinutesAgo)
expect(isCouncilRunning("stale-session")).toBe(false)
})
//#given a session was marked running 4 minutes ago (within 5-minute timeout)
//#when isCouncilRunning is checked
//#then entry is kept and returns true
test("keeps entries within timeout window", () => {
const fourMinutesAgo = Date.now() - 4 * 60 * 1000
_setTimestampForTesting("recent-session", fourMinutesAgo)
expect(isCouncilRunning("recent-session")).toBe(true)
})
//#given multiple sessions where one is stale and one is fresh
//#when isCouncilRunning is checked for the fresh one
//#then stale entry is purged but fresh entry remains
test("purges only stale entries while keeping fresh ones", () => {
const sixMinutesAgo = Date.now() - 6 * 60 * 1000
_setTimestampForTesting("stale-session", sixMinutesAgo)
markCouncilRunning("fresh-session")
expect(isCouncilRunning("stale-session")).toBe(false)
expect(isCouncilRunning("fresh-session")).toBe(true)
})
})

View File

@@ -1,37 +0,0 @@
/** Timeout in ms after which a stale council session lock is automatically released. */
const COUNCIL_SESSION_TIMEOUT_MS = 5 * 60 * 1000
/** Tracks active council executions per session with timestamps for stale entry cleanup. */
const activeCouncilSessions = new Map<string, number>()
function purgeStaleEntries(): void {
const now = Date.now()
for (const [sessionId, startedAt] of activeCouncilSessions) {
if (now - startedAt > COUNCIL_SESSION_TIMEOUT_MS) {
activeCouncilSessions.delete(sessionId)
}
}
}
export function isCouncilRunning(sessionId: string): boolean {
purgeStaleEntries()
return activeCouncilSessions.has(sessionId)
}
export function markCouncilRunning(sessionId: string): void {
activeCouncilSessions.set(sessionId, Date.now())
}
export function markCouncilDone(sessionId: string): void {
activeCouncilSessions.delete(sessionId)
}
/** Visible for testing only. */
export function _resetForTesting(): void {
activeCouncilSessions.clear()
}
/** Visible for testing only. */
export function _setTimestampForTesting(sessionId: string, timestamp: number): void {
activeCouncilSessions.set(sessionId, timestamp)
}

View File

@@ -2,22 +2,3 @@ export interface AthenaCouncilToolArgs {
question: string
members?: string[]
}
export interface AthenaCouncilLaunchedMember {
task_id: string
name: string
model: string
status: "running"
}
export interface AthenaCouncilFailedMember {
name: string
model: string
error: string
}
export interface AthenaCouncilLaunchResult {
launched: number
members: AthenaCouncilLaunchedMember[]
failed: AthenaCouncilFailedMember[]
}