TracesModule · library/trace/src/repos/trace-index.ts:77

TraceIndexRepo

component

No JSDoc comment in source yet.

API

@Component()
export class TraceIndexRepo implements TraceIndexStore {
  @Use() private readonly db!: Db;
  upsertFile(row: TraceFileRow): void;
  updateFileSize(projectId: string, agentId: string, sessionId: string, fileIndex: number, sizeBytes: number): void;
  getPageStats(projectId: string, agentId: string, sessionId: string, fileIndex: number): string | null;
  setPageStats(projectId: string, agentId: string, sessionId: string, fileIndex: number, sizeBytes: number, pageStats: string): void;
  deleteFile(projectId: string, agentId: string, sessionId: string, fileIndex: number): void;
  listFilesByAgent(projectId: string, agentId: string): TraceFileRow[];
  listFilesBySession(projectId: string, agentId: string, sessionId: string): TraceFileRow[];
  findAgentBySession(projectId: string, sessionId: string): string | null;
  upsertSession(row: TraceSessionRow): void;
  getSession(sessionId: string): TraceSessionRow | null;
  listSessionsByAgent(projectId: string, agentId: string): TraceSessionRow[];
  deleteBySession(sessionId: string): void;
  deleteByAgent(projectId: string, agentId: string): void;
  deleteByProject(projectId: string): void;
}

Dependencies & Wiring

Extracted from class decorators
implementsinterfaces
@Userequires (1)
db: Db

Methods (14)

upsertFile

upsertFile(row: TraceFileRow): void
@paramrowTraceFileRow
@returnsvoid

updateFileSize

updateFileSize(projectId: string, agentId: string, sessionId: string, fileIndex: number, sizeBytes: number): void

Refreshes one shard's last-observed size (listings write back their page stats); a changed size voids the cached window scan.

@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramfileIndexnumber
@paramsizeBytesnumber
@returnsvoid

getPageStats

getPageStats(projectId: string, agentId: string, sessionId: string, fileIndex: number): string | null

Cached message-window prefix record of one shard (see services/message-window.ts); null = none.

@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramfileIndexnumber
@returnsstring | null

setPageStats

setPageStats(projectId: string, agentId: string, sessionId: string, fileIndex: number, sizeBytes: number, pageStats: string): void

Stores a shard's message-window prefix record, guarded on the size it was computed for (a concurrent append voids the write).

@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramfileIndexnumber
@paramsizeBytesnumber
@parampageStatsstring
@returnsvoid

deleteFile

deleteFile(projectId: string, agentId: string, sessionId: string, fileIndex: number): void
@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@paramfileIndexnumber
@returnsvoid

listFilesByAgent

listFilesByAgent(projectId: string, agentId: string): TraceFileRow[]

All indexed shards of one Agent (date desc, session desc, index asc — the listing's canonical order).

@paramprojectIdstring
@paramagentIdstring
@returnsTraceFileRow[]

listFilesBySession

listFilesBySession(projectId: string, agentId: string, sessionId: string): TraceFileRow[]

One Session's shards, index ascending.

@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsTraceFileRow[]

findAgentBySession

findAgentBySession(projectId: string, sessionId: string): string | null

Owning Agent of a Session's Trace within a Project (the subagent-pointer resolver); null when unindexed.

@paramprojectIdstring
@paramsessionIdstring
@returnsstring | null

upsertSession

upsertSession(row: TraceSessionRow): void
@paramrowTraceSessionRow
@returnsvoid

getSession

getSession(sessionId: string): TraceSessionRow | null
@paramsessionIdstring
@returnsTraceSessionRow | null

listSessionsByAgent

listSessionsByAgent(projectId: string, agentId: string): TraceSessionRow[]
@paramprojectIdstring
@paramagentIdstring
@returnsTraceSessionRow[]

deleteBySession

deleteBySession(sessionId: string): void

Removes one Session's rows from both tables (Session delete keeps the cache coherent).

@paramsessionIdstring
@returnsvoid

deleteByAgent

deleteByAgent(projectId: string, agentId: string): void
@paramprojectIdstring
@paramagentIdstring
@returnsvoid

deleteByProject

deleteByProject(projectId: string): void
@paramprojectIdstring
@returnsvoid