Never let one unreadable line take a transcript down
Removing `Event::TaskNote` hours after adding it made every transcript that
had recorded one unreadable. `Transcript::open` parses every line, so `launch`
failed for those sessions and `SessionManager::new` logged
"couldn't relaunch session <id>" and skipped them -- and a skipped session has
no pump and no driver. On the phone that is no status, no history and nothing
sendable, for every live session that had run a background task. One
unfamiliar word took down every conversation it appeared in.
A transcript is append-only and permanent, so the set of kinds one can hold
only ever grows: what this build writes is not what it may have to read. A
line can come from a newer server, or from an older one that wrote a kind
since dropped, and neither may be able to end the file.
`Indexed::parse_at` degrades a line it cannot make sense of to
`Event::Unreadable { kind }` instead of failing the whole read. It keeps the
line's seq -- the cursors, the page bisection and the next-seq counter are all
addressed by it, and dropping the line would hand out a seq the file already
contains -- and carries the word the line called itself, so the phone can say
what is missing rather than that something is. A line with no readable seq is
still an error: that one cannot be placed at all.
`Event::TaskNote` comes back retired rather than deleted: deserializable,
never constructed, dated, with the reason on it. The phone folds it to no row,
which is the point -- an unreadable line correctly draws a placeholder, and
one per background task is the wall the row was removed for in the first
place.
Found while diagnosing a report that live sessions had lost their status and
could not be sent to. 173 server tests pass, including the new one, which
fails on the old code within a second.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9cc52beb09
commit
fd71d876e1
6 files changed
+215
-7
No files matched your search
@@ -108,6 +108,26 @@ sealed class SessionEvent {
|
||||
val turnStart: Long? = null,
|
||||
) : SessionEvent()
|
||||
|
||||
/**
|
||||
* A line in the transcript this build cannot read: a kind a newer server wrote, or one an older
|
||||
* server wrote that has since been dropped.
|
||||
*
|
||||
* [kind] is the word the line called itself, so the row can say what is missing rather than
|
||||
* that something is. The server makes these when reading; no driver sends one.
|
||||
*/
|
||||
data class Unreadable(val kind: String) : SessionEvent()
|
||||
|
||||
/**
|
||||
* Retired on 2026-09-06, hours after it was added: a background task finishing, which turned
|
||||
* out to be a screenful of notices about work nobody was asking after.
|
||||
*
|
||||
* Kept because a transcript is append-only -- the sessions that ran a background task in that
|
||||
* window have these lines for ever. It draws no row, which is the whole reason it is still
|
||||
* named here rather than left to fall through to [Unknown]: that would draw a placeholder per
|
||||
* background task, which is the same wall the row was removed for.
|
||||
*/
|
||||
object RetiredTaskNote : SessionEvent()
|
||||
|
||||
/**
|
||||
* A command the session was asked to run on itself and cannot run yet. Resolved by
|
||||
* [CommandSent] with the same id; a command that ran straight away has only that one.
|
||||
@@ -252,6 +272,8 @@ fun parseSeqEvent(json: String): SeqEvent {
|
||||
body.getString("text"),
|
||||
if (body.has("turnStart")) body.getLong("turnStart") else null,
|
||||
)
|
||||
"unreadable" -> SessionEvent.Unreadable(body.getString("kind"))
|
||||
"taskNote" -> SessionEvent.RetiredTaskNote
|
||||
"commandQueued" ->
|
||||
SessionEvent.CommandQueued(body.getString("id"), body.getString("text"))
|
||||
"commandSent" -> SessionEvent.CommandSent(body.getString("id"), body.getString("text"))
|
||||
|
||||
@@ -515,6 +515,12 @@ fun foldEvent(items: List<TranscriptItem>, entry: SeqEvent): List<TranscriptItem
|
||||
is SessionEvent.Compacted ->
|
||||
items + TranscriptItem.CompactedNote(entry.seq, event.preTokens, event.postTokens)
|
||||
is SessionEvent.Unknown -> items + TranscriptItem.Note(entry.seq, "[${event.type}]")
|
||||
// Said rather than skipped: a line the server could not read is a hole in the conversation,
|
||||
// and one that draws nothing is a hole nothing on screen ever mentions.
|
||||
is SessionEvent.Unreadable ->
|
||||
items + TranscriptItem.Note(entry.seq, "[unreadable: ${event.kind}]")
|
||||
// No row: see [SessionEvent.RetiredTaskNote].
|
||||
is SessionEvent.RetiredTaskNote -> items
|
||||
// Screen-level state, not transcript rows -- see SessionScreen.
|
||||
is SessionEvent.UsageDelta -> items
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user