Skip to content

[Bug]: Reopening a CLI session resets its local turn clock and loses recovery facts #1314

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

Version and environment

Local debug CLI + Server, macOS arm64. Diagnosed on 605e9750f3eb2ed4e9a1ec5d0ccbb38bfadf9a10. The isolated reproduction uses the same unchanged recovery/commit implementations.

Actual behavior

After reopening an existing canonical session, a successful model response can end with:

The model responded, but local session history could not be saved. Background updates remain available for the next turn.

The observed local journal has durable turns 1–5, followed by a session end and another session start. Server runs 6 and 7 completed, while the local journal remained at turn 5. The reopened inspector reports Turn 0 despite restored conversation history.

A failed-only session is also affected: SessionStart → TurnError(1) → SessionEnd → SessionStart restores local turn 0 and allocates turn 1 again. This was reproduced through the public journal recovery entrypoint on both the base recovery function and the initial PR head, without a database or live provider.

The shared CLI recovery function starts counting after the last SessionStart. Canonical conversation replay reads the existing commit chain, so it still reports completed turn 5. Interactive admission installs these two incompatible values from the same journal. Successful settlement then attempts completed turn 1 and rejects it as a regression.

Relevant owners:

Expected behavior

Reopening the same durable canonical lineage preserves its local turn allocation and associated recovery facts. The next local commit after turn 5 succeeds as turn 6. A failed terminal turn must also continue to consume its recorded local turn.

Keep local and Server clocks independent. Do not bypass the canonical regression guard, seed local turns from a remote cursor, or introduce a second recovery projection. SessionStart/SessionEnd attach to the same session ID and must not erase its terminal facts, including failed-only sessions and untyped historical journals. A genuinely new session gets a new ID; display history must not be promoted into canonical messages.

Steps to reproduce

  1. Create a synthetic journal containing SessionStart → Turn(5, canonical commit) → SessionEnd → SessionStart.
  2. Recover its local counters using restored_journal_state_from_append_order_events.
  3. Recover its canonical conversation using recover_or_initialize_active_conversation_from_append_order_events.
  4. Attempt prepare_commit(restored.session.turn + 1, ...).

A deterministic isolated regression using this sequence fails on the current implementation:

reopened local clock=0, canonical completed turn=5,
next commit error=Some(TurnRegression { previous: 5, actual: 1 })
test result: FAILED. 0 passed; 1 failed

The regression requires no database or live model provider.

Additional information

The disk had sufficient free space and existing journal files remained readable. A separate Memoria HTTP 405 warning concerns session-memory maintenance and does not explain this canonical local turn rejection.

The generic user warning hides the specific validation failure. Preserve useful local diagnostics while fixing the canonical recovery owner. Regression coverage should include repeated reopen boundaries, a recorded failed turn before reopening, and successful real CLI admission/settlement after restoration.

Activity

  1. added
    kind/bug
    on Nov 17, 2026
  2. self-assigned this
    on Nov 17, 2026
  3. changed the title [-][Bug]: Reopening a canonical CLI session resets its local turn clock and rejects history commits[/-] [+][Bug]: Reopening a CLI session resets its local turn clock and loses recovery facts[/+] on Nov 17, 2026
  4. added a commit that references this issue on Nov 17, 2026
    f000f7e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions