Repository navigation
Replies: 1 comment
|
Confirmed on Minimal reproduction: import { Session, SessionId } from 'packages/core/session/src/index.ts'
import { restoreReleasedV4Artifact } from 'packages/session/session-format-v3-to-v4/src/validation.ts'
const session = Session.create(SessionId('demo'))
session.append('turn/start', { turn: 1 })
session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
session.append('tool/ptc-dispatch-start', { /* rootCallId, parentCallId, subCallId, name, arguments */ })
// writer accepts (bug)
// the same three events fed to restoreReleasedV4Artifact throw
// "tool/ptc-dispatch-start is outside an open turn" (reader)Trigger path: agent-loop appends Fix under test locally (branch
Tests added: reject-after- Scope note: the reader's full turn/step-scoped set is larger ( Patch: branch |
Uh oh!
There was an error while loading. Please reload this page.
Title: Corrupt session log: writer allows turn-scoped events outside an open turn
Version: @deepseek-ai/dsh 0.2.1-rc.5 (master 0.2.2-alpha.2 still shows this)
Symptom: Creating a session fails with
gateway/internal: failed to create session: SessionQueryError: stored session "session-cec6a8ae-…" is corrupt: stored log is corrupt: SessionFormatError: tool/ptc-dispatch-start is outside an open turnCause: writer and reader disagree on turn scoping.
packages/session/session-format-v3-to-v4/src/relationships.ts:183→
requireTurn(event.type)throws at:82when the turn is closed.Session.append()(packages/core/session/src/index.ts:806)never checks turn state, and
packages/core/tool-executor-ptc/src/ptc.ts:577appendstool/ptc-dispatch-startfrom the dispatch queue'sstart()with no guard.The settle path at
ptc.ts:536even asserts in a comment that settle events"are still appended inside the open turn" — that is an assumption, not enforced.
Impact: one such event makes the whole session unloadable. Since
createmay reuse a blank session, a single poisoned blank session breaksevery subsequent "new session" until that file is repaired by hand.
I hit exactly this: 1 blank session with 2 orphan events blocked all session
creation.
Also observed:
openTurnClosers()(packages/core/session/src/repair.ts:53)repairs an open tail turn (turn/start without turn/end) but there is no
repair path for the inverse — turn-scoped events with no enclosing turn —
so the session can never be loaded again.
Suggestion: have
Session.append()reject (or drop) turn-scoped eventtypes when no turn is open, mirroring
relationships.ts; that turns apermanent corruption into an in-process failure.
Repro data available: the corrupt logs are tiny (8–10 events, no turn/start).
All reactions