Ledger rebuild drops an in-flight settled marker when the in-flight scan fails

Abierto
#7,884 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
backend

Línea de trabajo

Start in src/node/services/sessionUsageService.ts, at markInFlightFilesCountedByHistory, where (await this.readInFlightEntries(workspaceId)) ?? [] turns a failed listing into an empty list, and at rebuildFromMessagesInternal, which calls it. Compare with repairLedgerFromHistory, which already aborts on a failed first scan. Done means a failed scan aborts the write in every rebuild caller, the checked entries are reused instead of scanned twice, and a fault-injection test covers a transient listing failure with an orphaned in-flight file.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

A ledger rebuild from history can write the ledger without an in-flight file's settled marker when the in-flight scan fails. A later fold can then count that file's usage twice.

Where

src/node/services/sessionUsageService.ts, markInFlightFilesCountedByHistory: (await this.readInFlightEntries(workspaceId)) ?? [] treats a failed listing as "no files". rebuildFromMessagesInternal calls it on every rebuild.

After #7868, the repair path (repairLedgerFromHistory) scans once and refuses to write when that scan fails, but the rebuild then scans a second time, and only the first scan is checked. Codex raised this on #7868 (thread PRRT_kwDOPxxmWM6yfjDQ).

Trigger

All of these at once: an orphaned in-flight file exists, its assistant message is already in history, and listing or reading the in-flight folder fails transiently during the rebuild's scan.

Fix

Pass the checked entries from the first scan into rebuildFromMessagesInternal and markInFlightFilesCountedByHistory, and make a failed scan abort the write in the other rebuild callers. Add a fault-injection test.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Lenguaje dominante
TypeScript
Estrellas
2.1k
Forks
139
Merge medio
4 h 38 min
PR fusionados (30 d)
926

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/xum

Todos los issues de coder/xum

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.