cc-continuity 0.3.61__tar.gz → 0.3.63__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/README.md +2 -3
  3. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/overflow.py +9 -0
  5. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/watchdogd.py +13 -0
  6. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity.egg-info/PKG-INFO +1 -1
  7. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/pyproject.toml +1 -1
  8. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_overflow.py +40 -0
  9. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_watchdogd.py +51 -0
  10. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/LICENSE +0 -0
  11. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/__main__.py +0 -0
  12. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/atomic.py +0 -0
  13. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/blink.py +0 -0
  14. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/blink_watch.py +0 -0
  15. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/bootstrap.py +0 -0
  16. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/checkpoint.py +0 -0
  17. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/cli.py +0 -0
  18. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/config.py +0 -0
  19. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/daemon_supervisor.py +0 -0
  20. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/doctor.py +0 -0
  21. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/gitsnap.py +0 -0
  22. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/__init__.py +0 -0
  23. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/common.py +0 -0
  24. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/pre_compact.py +0 -0
  25. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/pre_tool_use.py +0 -0
  26. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/session_end.py +0 -0
  27. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/session_start.py +0 -0
  28. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/stop.py +0 -0
  29. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/task.py +0 -0
  30. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/tool_use.py +0 -0
  31. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hooks/user_prompt.py +0 -0
  32. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/hosting.py +0 -0
  33. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/install.py +0 -0
  34. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/launch.py +0 -0
  35. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/ledger.py +0 -0
  36. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/lock.py +0 -0
  37. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/managed.py +0 -0
  38. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/naming.py +0 -0
  39. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/notify.py +0 -0
  40. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/paths.py +0 -0
  41. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/power_plug.py +0 -0
  42. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/progress_pane.py +0 -0
  43. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/project.py +0 -0
  44. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/redact.py +0 -0
  45. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/rotator.py +0 -0
  46. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/settings_merge.py +0 -0
  47. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/skills.py +0 -0
  48. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/state.py +0 -0
  49. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/statusline.py +0 -0
  50. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/thresholds.py +0 -0
  51. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/transcript.py +0 -0
  52. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/validate.py +0 -0
  53. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/watchdog.py +0 -0
  54. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity/watchdog_digest.py +0 -0
  55. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity.egg-info/SOURCES.txt +0 -0
  56. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity.egg-info/dependency_links.txt +0 -0
  57. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity.egg-info/entry_points.txt +0 -0
  58. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/cc_continuity.egg-info/top_level.txt +0 -0
  59. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/setup.cfg +0 -0
  60. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_atomic.py +0 -0
  61. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_blink.py +0 -0
  62. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_blink_watch.py +0 -0
  63. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_bootstrap.py +0 -0
  64. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_changelog_notes.py +0 -0
  65. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_checkpoint.py +0 -0
  66. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_cli.py +0 -0
  67. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_cli_ledger.py +0 -0
  68. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_cli_log.py +0 -0
  69. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_config.py +0 -0
  70. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_daemon_supervisor.py +0 -0
  71. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_doctor.py +0 -0
  72. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_gitsnap.py +0 -0
  73. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_common.py +0 -0
  74. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_pre_compact.py +0 -0
  75. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_pre_tool_use.py +0 -0
  76. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_session_end.py +0 -0
  77. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_session_start.py +0 -0
  78. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_stop.py +0 -0
  79. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_task.py +0 -0
  80. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_tool_use.py +0 -0
  81. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hooks_user_prompt.py +0 -0
  82. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hosting.py +0 -0
  83. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_hygiene.py +0 -0
  84. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_install.py +0 -0
  85. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_integration_phase5.py +0 -0
  86. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_integration_phase6.py +0 -0
  87. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_integration_phase7.py +0 -0
  88. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_launch.py +0 -0
  89. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_ledger.py +0 -0
  90. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_lock.py +0 -0
  91. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_managed.py +0 -0
  92. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_naming.py +0 -0
  93. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_notify.py +0 -0
  94. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_notify_integration.py +0 -0
  95. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_paths.py +0 -0
  96. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_power_plug.py +0 -0
  97. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_progress_pane.py +0 -0
  98. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_project.py +0 -0
  99. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_readme_badges.py +0 -0
  100. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_readme_gif.py +0 -0
  101. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_redact.py +0 -0
  102. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_rotator.py +0 -0
  103. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_settings_merge.py +0 -0
  104. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_skills.py +0 -0
  105. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_state.py +0 -0
  106. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_status.py +0 -0
  107. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_statusline.py +0 -0
  108. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_statusline_cache.py +0 -0
  109. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_thresholds.py +0 -0
  110. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_tmux_host.py +0 -0
  111. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_transcript.py +0 -0
  112. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_transcript_finalize.py +0 -0
  113. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_uninstall.py +0 -0
  114. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_validate.py +0 -0
  115. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_watchdog.py +0 -0
  116. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_watchdog_digest.py +0 -0
  117. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_watchdog_integration.py +0 -0
  118. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_wsl_doctor.py +0 -0
  119. {cc_continuity-0.3.61 → cc_continuity-0.3.63}/tests/test_wsl_install.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.61
3
+ Version: 0.3.63
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -41,12 +41,11 @@ The five most recent updates, newest first. Each line links to its
41
41
  commit, so you can see what changed lately without digging through the
42
42
  log:
43
43
 
44
+ - **2026-11-24**: Context-400 recovery now actually completes the rotation. The dispatch works since v0.3.62, but the spawned rotator kept deferring every time: the API 400 kills the turn without firing the Stop hook, so the turn flag was never cleared and the rotator's idle gate read the dead turn as live work, deferred and waited for a Stop that could never come; the recovery now records the finished turn itself (flag off, stop timestamp) right after logging the recovery, the rotator and its idle gate stay untouched, and two tests written first pin the field write and the unlocked idle gate ([commit](https://github.com/pqant/claude-continuity/commit/129422a)).
45
+ - **2026-11-23**: Sessions stuck in `CHECKPOINT_VERIFIED` are now actually dispatched to context-400 recovery. The recovery gate accepted `CHECKPOINT_VERIFIED` since v0.3.61, but the watchdog still only reached that gate through screen classification: records outside `ACTIVE`/`WARNED` are skipped as not live, and recovery ran only for sessions classified as alive, turn-dead, stalled or frozen, so a stalled verified checkpoint was never scanned and stayed parked on the oversized prompt; the tick loop now also runs recovery for a skipped verified-checkpoint session while its turn is still in flight, the recovery gate itself (full-auto, one attempt, transcript-tail scan, fresh-prompt check) stays the single source of truth, and three tick-loop integration tests written first pin the dispatch ([commit](https://github.com/pqant/claude-continuity/commit/ff58ebc)).
44
46
  - **2026-11-23**: Sessions stuck in `CHECKPOINT_VERIFIED` now recover from context-400 too. A rotation that verifies its checkpoint and then fails partway leaves the session in `CHECKPOINT_VERIFIED` with the stale oversized prompt still in the pane: the recovery gate only accepted the pre-rotation states and `recover_400` refused to re-attach a session that already had a fresh prompt, so these sessions stayed stuck and 400ed every request. `CHECKPOINT_VERIFIED` now joins the recovery gate, `recover_400` re-attaches such sessions with the fresh prompt, and a scan that skips a session leaves the one-shot recovery gate unarmed so the recovery still fires when the user returns ([commit](https://github.com/pqant/claude-continuity/commit/f9a1e1a)).
45
47
  - **2026-11-23**: Context-400 recovery now pushes to your phone. The recovery path fired a `context400` event, but the push message builder had no branch for it, so the notification was silently dropped and nobody saw recoveries from the phone; the `context400` branch now builds the high-priority message with a scrubbed detail line, and a wire-contract test pins the event name on the recovery call so the push cannot silently vanish again ([commit](https://github.com/pqant/claude-continuity/commit/945d1b4)).
46
48
  - **2026-11-23**: Context-400 recovery now fires no matter how the watchdog classifies the pane. The first recovery pass only ran on panes classified as frozen, but a session stuck on an oversized prompt keeps redrawing and classifies as alive (or turn-dead/stalled once its turn flag expires), so the watchdog kept nudging a pane that could only 400 again; recovery now also runs before nudging for alive, turn-dead and stalled sessions with an active turn, extracted into a shared helper the frozen path keeps calling as defense-in-depth, with the same one-attempt gate ([commit](https://github.com/pqant/claude-continuity/commit/c69da5c)).
47
- - **2026-11-23**: A reused tmux pane id can no longer render a session from another project. Pane bindings are keyed by the tmux pane id and tmux recycles those ids across projects, so a pane could keep painting a finished session from a foreign project on its status line; the renderer now cross-checks the bound record's project against the incoming payload's and rejects the binding when both are known and differ, leaving the same-pane retarget path byte-identical whenever either project key cannot be derived ([commit](https://github.com/pqant/claude-continuity/commit/9e9d251)).
48
- - **2026-11-22**: Sessions bricked by a context-400 API error now recover on their own. When the API rejects the oversized prompt with a 400, the Stop hook never fires, so the model can never write its own handoff and every later request 400s again, freezing the session; the watchdog now scans the transcript tail for the 400 signature, falls back to a transcript-based ratio estimate when the status line metric has frozen (a frozen pane starves every ratio-driven guard), and drives the session through a deterministic checkpoint recovery path instead of nudging a dead one ([commit](https://github.com/pqant/claude-continuity/commit/0b0ebf6)).
49
-
50
49
  ## How it works
51
50
 
52
51
  The whole flow in one picture: the automatic session loop, the optional
@@ -4,4 +4,4 @@ Spec: docs/PRD.md (v1.0). Platform facts verified in docs/VERIFICATION.md.
4
4
  Standard library only at runtime; pytest is dev-only.
5
5
  """
6
6
 
7
- __version__ = "0.3.61"
7
+ __version__ = "0.3.63"
@@ -236,6 +236,15 @@ def recover_400(key: str, nnn: int, session_id: str | None, pane: str,
236
236
  {"type": "context400_recovered",
237
237
  "window": info.get("window"),
238
238
  "input_tokens": info.get("input_tokens")})
239
+ # BUG-7: a context-400 kills the turn WITHOUT a Stop hook, so
240
+ # hooks/stop.py never clears turn_active/last_stop_ts and the
241
+ # spawned rotator's PRD 11.3 idle gate defers forever waiting for a
242
+ # "next Stop" that can never come. Mirror the Stop hook's field
243
+ # write here - the turn is provably dead (400 tail; fresh-prompt
244
+ # gate ran first). AFTER the ledger append so "no ledger activity
245
+ # since last Stop" sees the recovery itself as the last event.
246
+ state.update_fields(key, nnn, turn_active=False,
247
+ last_stop_ts=time.time())
239
248
  notify.safe_send(
240
249
  cfg, "context400", slug=notify.project_slug(key), nnn=nnn,
241
250
  dedup_key=f"context400:{nnn:03d}",
@@ -1454,6 +1454,19 @@ def tick(ctx: TickCtx) -> dict:
1454
1454
  and _try_recover_400(ctx, key, nnn, rec, target, line)):
1455
1455
  continue
1456
1456
 
1457
+ # BUG-6 (cp-263, connector-258): the verified-checkpoint variant.
1458
+ # classify() row 7 SKIPs everything outside ACTIVE/WARNED, so a
1459
+ # rotation-stalled CHECKPOINT_VERIFIED + turn_active record never
1460
+ # reached the pre-nudge scan above and recovery was unreachable
1461
+ # in production. Additive dispatch here (NOT row 7 - liveness
1462
+ # semantics); _try_recover_400's own gate (full_auto/state/
1463
+ # rec400-dedup/400-scan + overflow.recover_400's fresh-prompt
1464
+ # check) stays the single source of truth.
1465
+ if (outcome == "SKIP" and rec.get("turn_active")
1466
+ and rec.get("state") == "CHECKPOINT_VERIFIED"
1467
+ and _try_recover_400(ctx, key, nnn, rec, target, line)):
1468
+ continue
1469
+
1457
1470
  if outcome in ("TURN_DEAD", "STALLED"):
1458
1471
  if _may_nudge(ctx, focus, key, nnn):
1459
1472
  _nudge_path(ctx, key, nnn, target, cap, last_ts, now, line,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.61
3
+ Version: 0.3.63
4
4
  Summary: Zero-touch session rotation for Claude Code (local large-context model)
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cc-continuity"
7
- version = "0.3.61"
7
+ version = "0.3.63"
8
8
  description = "Zero-touch session rotation for Claude Code (local large-context model)"
9
9
  requires-python = ">=3.11"
10
10
  classifiers = [
@@ -226,3 +226,43 @@ def test_recover_400_state_gate(cc_home, tmp_path, monkeypatch):
226
226
  dict(config.DEFAULTS), tmp_path, None)
227
227
  assert res == "skipped:ROTATING"
228
228
  assert calls == []
229
+
230
+
231
+ def test_recover_400_clears_turn_active_like_stop(
232
+ cc_home, tmp_path, monkeypatch):
233
+ # BUG-7 (connector-258 live): the 400 killed the turn without a Stop
234
+ # hook, so hooks/stop.py never cleared turn_active/last_stop_ts and
235
+ # the spawned rotator deferred forever ("activity after Stop"). The
236
+ # recovery must mirror the Stop hook's field write; AFTER the
237
+ # context400_recovered append, so the gate's "no ledger activity since
238
+ # last Stop" sees the recovery itself as the last event.
239
+ key = _mk(cc_home, tmp_path) # BOOTSTRAPPING is recoverable
240
+ state.update_fields(key, 1, turn_active=True)
241
+ monkeypatch.setattr(overflow.rotator, "spawn", lambda *a: 4242)
242
+ monkeypatch.setattr(overflow.checkpoint, "finalize", _fake_finalize)
243
+ info = {"window": W, "input_tokens": W - 32000, "text_head": "API Error"}
244
+ res = overflow.recover_400(key, 1, "sid-a", "proj:cc.0",
245
+ dict(config.DEFAULTS), tmp_path, info)
246
+ assert res == "recovered"
247
+ rec = state.load_state(key, 1)
248
+ assert rec["turn_active"] is False
249
+ evs = [e for e in ledger.read(paths.session_dir(key, 1))
250
+ if e.get("type") == "context400_recovered"]
251
+ assert len(evs) == 1
252
+ assert rec.get("last_stop_ts", 0) >= evs[0]["ts"]
253
+
254
+
255
+ def test_recover_400_unlocks_rotator_idle_gate(
256
+ cc_home, tmp_path, monkeypatch):
257
+ # End-to-end pin of the BUG-7 deadlock: after a successful recovery
258
+ # the rotator's PRD 11.3 idle gate (run()'s first check) must pass -
259
+ # the dead turn may never be mistaken for "user still working".
260
+ key = _mk(cc_home, tmp_path)
261
+ state.update_fields(key, 1, turn_active=True)
262
+ monkeypatch.setattr(overflow.rotator, "spawn", lambda *a: 4242)
263
+ monkeypatch.setattr(overflow.checkpoint, "finalize", _fake_finalize)
264
+ info = {"window": W, "input_tokens": W - 32000, "text_head": "API Error"}
265
+ res = overflow.recover_400(key, 1, "sid-a", "proj:cc.0",
266
+ dict(config.DEFAULTS), tmp_path, info)
267
+ assert res == "recovered"
268
+ assert rotator._idle(key, 1) is True
@@ -2774,6 +2774,57 @@ def test_tick_context400_turn_dead_preempts_nudge(cc_home, tmp_path,
2774
2774
  assert io.sends == []
2775
2775
 
2776
2776
 
2777
+ def test_tick_context400_checkpoint_verified_triggers_recovery(
2778
+ cc_home, tmp_path, monkeypatch):
2779
+ # BUG-6 (cp-263 live, connector-258): a rotation-stalled
2780
+ # CHECKPOINT_VERIFIED record is SKIPped by classify() (row 7 knows
2781
+ # only ACTIVE/WARNED) and the tick loop dispatched _try_recover_400
2782
+ # only on ALIVE/TURN_DEAD/STALLED/FROZEN - the verified checkpoint
2783
+ # was never dispatched for recovery in production. SKIP +
2784
+ # CHECKPOINT_VERIFIED + turn_active must reach the gate too
2785
+ # (full_auto/state/dedup/400-scan/fresh-prompt checks live in
2786
+ # _try_recover_400 - single source of truth).
2787
+ pushes = _capture_pushes(monkeypatch)
2788
+ io = FakeIO(pane=PROMPT_PANE, sessions=["cc-proj-a-0a9b"])
2789
+ sdir = _mk(st="CHECKPOINT_VERIFIED", turn_active=True)
2790
+ _stale_prompt(sdir) # age is moot: row 7 SKIP dominates eligibility
2791
+ calls = _patch400(monkeypatch, tmp_path)
2792
+ ctx = _ctx(io, now=10_000.0)
2793
+ line = watchdogd.tick(ctx)
2794
+ assert line["sessions"][0]["outcome"] == "SKIP"
2795
+ assert calls == [("proj-a", 1, "sid-proj-a-1", "cc-proj-a-0a9b")]
2796
+ assert any(e.startswith("context400:") for e in line["events"])
2797
+ assert io.sends == [] and pushes == []
2798
+
2799
+
2800
+ def test_tick_context400_verified_not_turn_active_no_dispatch(
2801
+ cc_home, tmp_path, monkeypatch):
2802
+ # Guard: a CHECKPOINT_VERIFIED record at rest (no turn in flight,
2803
+ # user legitimately at the prompt) must NOT be dispatched - only a
2804
+ # mid-turn verified checkpoint is the stuck-rotation signature.
2805
+ io = FakeIO(pane=PROMPT_PANE, sessions=["cc-proj-a-0a9b"])
2806
+ _mk(st="CHECKPOINT_VERIFIED", turn_active=False)
2807
+ calls = _patch400(monkeypatch, tmp_path)
2808
+ ctx = _ctx(io, now=10_000.0)
2809
+ line = watchdogd.tick(ctx)
2810
+ assert line["sessions"][0]["outcome"] == "SKIP"
2811
+ assert calls == []
2812
+
2813
+
2814
+ def test_tick_context400_skip_other_state_no_dispatch(cc_home, tmp_path,
2815
+ monkeypatch):
2816
+ # Guard: the dispatch is additive and CHECKPOINT_VERIFIED-only -
2817
+ # any other SKIPped state (here BOOTSTRAPPING) keeps the old
2818
+ # never-dispatched behaviour.
2819
+ io = FakeIO(pane=PROMPT_PANE, sessions=["cc-proj-a-0a9b"])
2820
+ _mk(st="BOOTSTRAPPING", turn_active=True)
2821
+ calls = _patch400(monkeypatch, tmp_path)
2822
+ ctx = _ctx(io, now=10_000.0)
2823
+ line = watchdogd.tick(ctx)
2824
+ assert line["sessions"][0]["outcome"] == "SKIP"
2825
+ assert calls == []
2826
+
2827
+
2777
2828
  # --- BUG-3 (cp-259): CHECKPOINT_VERIFIED gate + rec400 skip guard ----------
2778
2829
 
2779
2830
 
File without changes
File without changes