cccc icon indicating copy to clipboard operation
cccc copied to clipboard

managed-session resume failure leaves binding `resume_eligible` (cccc-daemon)

Open chriscoveries opened this issue 1 month ago • 2 comments

Reproduced on cccc built from upstream main c36a4e4c (claude CLI 2.1.280, Linux); re-checked against main d3530af9, which does not change the claude managed-session failure path.

Summary

A failed resume of a managed runtime session is never recorded on the session receipt: the binding keeps resume_eligible: true, failure_count: 0, and its stale provider_session_id. A retry can then bind a different session under the dead identity — the receipt keeps claiming a provider session that no longer exists.

This is a regression relative to the #119 merge. dbd8dc4a (part of the #119 series) added invalidate_managed together with the regression test a_binding_from_a_provider_confirmed_gone_is_never_resumed; c36a4e4c ("feat: add Voice persona mode and harden runtime lifecycle", post-merge) deleted both the function and the test. At current main (d3530af9):

  • crates/cccc-daemon/src/ops/runtime_session/claude.rs has zero references to invalidate_managed;
  • record_managed still writes ("resume_eligible", json!(true)) unconditionally (claude.rs:106, likewise grok.rs/opencode.rs);
  • nothing on the resume-failure path marks the binding ineligible, so the deleted test's invariant no longer holds.

Reproduction

Environment: cccc daemon with a claude-runtime actor configured as managed_session (provider job owned by the shared claude.exe daemon run supervisor; viewer = claude attach <id> child of the daemon).

  1. Stop the actor, then point its runtime-session record (state/runtime_sessions/<actor>.json) at a well-formed but nonexistent provider_session_id (e.g. a random UUID) while keeping resume_eligible: true — simulating a provider session that died without the daemon learning of it.
  2. cccc actor start <actor>.

Observed:

  • The start fails: io_error: Claude Agent View did not expose its durable transcript. The actor stays stopped and there is no respawn loop (one headless.session.stopped event, no retry burst) — that half of the #119 lifecycle fix holds.
  • The receipt is unchanged afterward: status: usable, resume_eligible: true, failure_count: 0, last_resume_error: "". The dead binding is not invalidated.
  • A second cccc actor start then "succeeds" (captured_from: claude_agent_view_resume): the supervisor accepts the unknown resume id and creates a different session under it, while the receipt continues to carry the original provider_session_id.

Expected

A confirmed resume failure marks the managed binding not-resume-eligible (or at minimum increments failure_count and records last_resume_error), so the next start either retries fresh under a new identity or requires explicit reconciliation — matching the invariant the deleted test a_binding_from_a_provider_confirmed_gone_is_never_resumed encoded.

Actual

The binding remains resume_eligible with a provider_session_id that no longer resolves; retry can silently rebind a different session to that identity, so the durable receipt misdescribes the live provider.

Notes for the maintainer

The deletion in c36a4e4c may have been deliberate, so this is filed as an issue rather than a revert PR. If you want it, we have a patch that re-adds managed-receipt invalidation on resume failure (invalidate, then retry fresh on next start) which we can rebase onto current main and send as a follow-up to #119.

chriscoveries avatar Oct 05 '26 18:10 chriscoveries

Thank you for investigating the receipt state and checking the relevant changes. You were right that a failed resume needed persistent failure bookkeeping. We have addressed that gap in local commit, awaiting publication.

We retained one important lifecycle distinction: a stopped provider job does not necessarily invalidate its durable conversation. Blanket invalidation on process disappearance could discard a conversation that Claude can still resume.

For copied session identities, missing durable history, and other unverifiable resume failures, the receipt now records status: resume_failed, resume_eligible: false, a safe diagnostic, and an incremented failure count while preserving the original session ID. Known transient control failures remain retryable. Failure updates are tied to the exact resume attempt, and successful resume clears the failure state.

Start/Restart explicitly retries the saved conversation; New session starts fresh after retiring pending recovery. Automatic recovery cannot silently turn a paused failure into a fresh session.

Isolated receipt/lifecycle regressions and packaged smoke tests passed. These verify CCCC’s state handling, rather than Claude’s internal history-restoration behavior. Thank you for opening the issue before sending a revert—it helped us address the missing failure handling while preserving valid resumable conversations.

ChesterRa avatar Oct 06 '26 06:10 ChesterRa

Thanks. We re-ran our reproduction against v0.4.42 (1e67dc87). Automatic recovery now records resume_failed / resume_eligible: false and pauses rather than rebinding, which resolves what we reported.

For the record, one edge case we observed, which looks intended: after that paused failure, an explicit Start reuses the empty job created by the failed attempt (it passes known_empty_session) and the receipt becomes usable again. That's consistent with your "explicit retry, no history to lose" rule. If the original conversation's history had actually been lost, though, the operator is not told that the session now running is a new, empty one. If you'd like a diagnostic for that case, we're happy to open a separate issue.

We're dropping our local patch in favour of your fix. Closing.

chriscoveries avatar Oct 06 '26 20:10 chriscoveries