@prismshadow/penguin-library-trace · library/trace/src/trace-index.ts:131

TraceIndexService

component

No JSDoc comment in source yet.

API

@Component()
export class TraceIndexService implements TraceIndex {
  @Use() private readonly paths!: TracePaths;
  @Use() readonly repo!: TraceIndexStore;
  @Use() private readonly sources?: SessionOrigins;
  reconcileAgent(projectId: string, agentId: string, opts: { force?: boolean } = {}): Promise<void>;
  async reconcileProject(projectId: string, opts: { force?: boolean } = {}): Promise<void>;
  registerImportedFile(args: {
    projectId: string;
    agentId: string;
    sessionId: string;
    fileIndex: number;
    date: string;
    sizeBytes: number;
    records: AmspRecord[];
  }): void;
  removeSession(projectId: string, agentId: string, sessionId: string): void;
  removeAgent(projectId: string, agentId: string): void;
  removeProject(projectId: string): void;
}

Dependencies & Wiring

Extracted from class decorators
implementsinterfaces
@Userequires (3)
paths: TracePaths · repo: TraceIndexStore · sources: SessionOrigins

Methods (6)

reconcileAgent

reconcileAgent(projectId: string, agentId: string, opts: { force?: boolean } = {}): Promise<void>

Brings one Agent's index in step with disk. Hot path: one root stat, then the newest date dir — a change there short-circuits — else the remaining N-1 date dirs concurrently; zero readdir either way. force ignores the mtime gate and diffs every date dir (the consumers' miss-retry path).

@paramprojectIdstring
@paramagentIdstring
@paramopts?{ force?: boolean }
@returnsPromise<void>

reconcileProject

async reconcileProject(projectId: string, opts: { force?: boolean } = {}): Promise<void>

Reconciles every Agent of a Project (the subagent-pointer resolver's miss path).

@paramprojectIdstring
@paramopts?{ force?: boolean }
@returnsPromise<void>

registerImportedFile

registerImportedFile(args: { projectId: string; agentId: string; sessionId: string; fileIndex: number; date: string; sizeBytes: number; records: AmspRecord[]; }): void

Write-time registration for the Trace import route: the caller has the file's identity AND parsed records in hand, so the row and facts are stored synchronously with zero additional IO.

@paramargs{ projectId: string; agentId: string; sessionId: string; fileIndex: number; date: string; sizeBytes: number; records: AmspRecord[]; }
@returnsvoid

removeSession

removeSession(projectId: string, agentId: string, sessionId: string): void

Write-time removal for Session deletion (files are being rm'ed by the caller).

@paramprojectIdstring
@paramagentIdstring
@paramsessionIdstring
@returnsvoid

removeAgent

removeAgent(projectId: string, agentId: string): void

Agent deletion: its whole tree is going away with it.

@paramprojectIdstring
@paramagentIdstring
@returnsvoid

removeProject

removeProject(projectId: string): void

Project deletion.

@paramprojectIdstring
@returnsvoid