cc-continuity 0.3.47__tar.gz → 0.3.49__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 (115) hide show
  1. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/PKG-INFO +1 -1
  2. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/README.md +2 -2
  3. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/__init__.py +1 -1
  4. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/cli.py +43 -11
  5. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/doctor.py +31 -0
  6. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/watchdogd.py +10 -1
  7. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity.egg-info/PKG-INFO +1 -1
  8. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/pyproject.toml +1 -1
  9. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_cli.py +116 -0
  10. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_doctor.py +60 -0
  11. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/LICENSE +0 -0
  12. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/__main__.py +0 -0
  13. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/atomic.py +0 -0
  14. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/blink.py +0 -0
  15. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/blink_watch.py +0 -0
  16. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/bootstrap.py +0 -0
  17. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/checkpoint.py +0 -0
  18. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/config.py +0 -0
  19. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/daemon_supervisor.py +0 -0
  20. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/gitsnap.py +0 -0
  21. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/__init__.py +0 -0
  22. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/common.py +0 -0
  23. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/pre_compact.py +0 -0
  24. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/pre_tool_use.py +0 -0
  25. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/session_end.py +0 -0
  26. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/session_start.py +0 -0
  27. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/stop.py +0 -0
  28. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/task.py +0 -0
  29. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/tool_use.py +0 -0
  30. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hooks/user_prompt.py +0 -0
  31. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/hosting.py +0 -0
  32. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/install.py +0 -0
  33. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/launch.py +0 -0
  34. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/ledger.py +0 -0
  35. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/lock.py +0 -0
  36. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/managed.py +0 -0
  37. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/naming.py +0 -0
  38. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/notify.py +0 -0
  39. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/paths.py +0 -0
  40. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/power_plug.py +0 -0
  41. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/progress_pane.py +0 -0
  42. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/project.py +0 -0
  43. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/redact.py +0 -0
  44. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/rotator.py +0 -0
  45. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/settings_merge.py +0 -0
  46. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/skills.py +0 -0
  47. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/state.py +0 -0
  48. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/statusline.py +0 -0
  49. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/thresholds.py +0 -0
  50. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/transcript.py +0 -0
  51. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/validate.py +0 -0
  52. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/watchdog.py +0 -0
  53. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity/watchdog_digest.py +0 -0
  54. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity.egg-info/SOURCES.txt +0 -0
  55. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity.egg-info/dependency_links.txt +0 -0
  56. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity.egg-info/entry_points.txt +0 -0
  57. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/cc_continuity.egg-info/top_level.txt +0 -0
  58. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/setup.cfg +0 -0
  59. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_atomic.py +0 -0
  60. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_blink.py +0 -0
  61. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_blink_watch.py +0 -0
  62. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_bootstrap.py +0 -0
  63. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_changelog_notes.py +0 -0
  64. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_checkpoint.py +0 -0
  65. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_cli_ledger.py +0 -0
  66. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_cli_log.py +0 -0
  67. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_config.py +0 -0
  68. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_daemon_supervisor.py +0 -0
  69. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_gitsnap.py +0 -0
  70. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_common.py +0 -0
  71. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_pre_compact.py +0 -0
  72. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_pre_tool_use.py +0 -0
  73. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_session_end.py +0 -0
  74. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_session_start.py +0 -0
  75. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_stop.py +0 -0
  76. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_task.py +0 -0
  77. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_tool_use.py +0 -0
  78. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hooks_user_prompt.py +0 -0
  79. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hosting.py +0 -0
  80. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_hygiene.py +0 -0
  81. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_install.py +0 -0
  82. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_integration_phase5.py +0 -0
  83. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_integration_phase6.py +0 -0
  84. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_integration_phase7.py +0 -0
  85. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_launch.py +0 -0
  86. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_ledger.py +0 -0
  87. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_lock.py +0 -0
  88. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_managed.py +0 -0
  89. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_naming.py +0 -0
  90. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_notify.py +0 -0
  91. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_notify_integration.py +0 -0
  92. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_paths.py +0 -0
  93. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_power_plug.py +0 -0
  94. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_progress_pane.py +0 -0
  95. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_project.py +0 -0
  96. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_readme_badges.py +0 -0
  97. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_redact.py +0 -0
  98. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_rotator.py +0 -0
  99. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_settings_merge.py +0 -0
  100. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_skills.py +0 -0
  101. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_state.py +0 -0
  102. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_status.py +0 -0
  103. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_statusline.py +0 -0
  104. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_thresholds.py +0 -0
  105. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_tmux_host.py +0 -0
  106. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_transcript.py +0 -0
  107. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_transcript_finalize.py +0 -0
  108. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_uninstall.py +0 -0
  109. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_validate.py +0 -0
  110. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_watchdog.py +0 -0
  111. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_watchdog_digest.py +0 -0
  112. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_watchdog_integration.py +0 -0
  113. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_watchdogd.py +0 -0
  114. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/tests/test_wsl_doctor.py +0 -0
  115. {cc_continuity-0.3.47 → cc_continuity-0.3.49}/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.47
3
+ Version: 0.3.49
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,11 +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-19**: Two small observability wins for the push layer. `notify stop|notification --dry-run` renders the exact push (enabled state, title, priority and body) without sending anything or burning the one-push-per-minute bucket, and `watchdog status` now ends with a `last heartbeat: <local time> (<N>s ago)` line so a stalled daemon is visible at a glance; a missing or corrupt stamp reads `last heartbeat: never` ([commit](https://github.com/pqant/claude-continuity/commit/eb93cc1)).
45
+ - **2026-11-18**: The rotation gate can no longer invert silently. `doctor` gained a `config-sanity` check that verifies `0 < warn_ratio <= rotate_ratio <= hard_ratio < 1`, a plausible `window_tokens` (>= 32768) and an http(s) `notify_endpoint`, naming the offending values in its detail; a typo like warn 0.80 / rotate 0.75 used to make rotations fire late or never. The check is warn-only, the values stay the user's call ([commit](https://github.com/pqant/claude-continuity/commit/c7381cc)).
44
46
  - **2026-11-18**: The session chain went machine-readable: `cc-continuity history --json` prints it as one JSON array with stable keys (`nnn`, `name`, `session_id`, `created`, `state`). The state comes from each session's `state.json` with the same fallback the status rotation line uses, a project without a record prints `[]`, and the default human output is unchanged ([commit](https://github.com/pqant/claude-continuity/commit/180b761)).
45
47
  - **2026-11-17**: A second badges row landed under the title, this one for the package side: PyPI version and monthly-download counters, MIT license, live CI status, supported Python versions (backed by new PyPI classifiers in pyproject.toml) and a good-first-issues counter that opens the labeled contributor on-ramp ([commit](https://github.com/pqant/claude-continuity/commit/fb0ad8a)).
46
48
  - **2026-11-17**: The README now opens at a glance. A badges row sits under the title: live shields.io counters for forks, stars, open issues and the last commit (each links to the matching GitHub page), plus Code of conduct, Contributions and Security badges that lead straight into the community files ([commit](https://github.com/pqant/claude-continuity/commit/f642a4b)).
47
- - **2026-11-17**: Pasted images stopped cloning themselves in transcript exports. Claude Code writes one paste as two records: the base64 record plus an isMeta sibling carrying the same `[Image: source: ...]` lines. While the image cache was still on disk the sibling embedded the very same images, so the export opened a second User block repeating the whole gallery right next to the first. A sibling whose timestamp and image count both match the block before it is the same paste and is now folded away; a genuine second paste carries its own timestamp and still gets its own gallery ([commit](https://github.com/pqant/claude-continuity/commit/55b1c1c)).
48
- - **2026-11-17**: Debugging the logs got a front door: `cc-continuity log blink` and `cc-continuity log errors` tail the root log files read-only (newest last, default 20 lines, `--lines N`, `--follow` keeps streaming), with UTC stamps rendered in your local time; blink's already-local stamps and traceback continuation lines stay byte-identical so nothing shifts twice ([commit](https://github.com/pqant/claude-continuity/commit/1ce3269)).
49
49
 
50
50
  ## How it works
51
51
 
@@ -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.47"
7
+ __version__ = "0.3.49"
@@ -278,6 +278,8 @@ def build_parser() -> argparse.ArgumentParser:
278
278
  help="generic Stop/Notification hook push "
279
279
  "(issue #7)")
280
280
  p_nt.add_argument("kind", choices=["stop", "notification"])
281
+ p_nt.add_argument("--dry-run", action="store_true",
282
+ help="render the push, send nothing (issue #37)")
281
283
 
282
284
  p_ne = sub.add_parser("notify-emit",
283
285
  help="emit one queued notify spec (internal, "
@@ -1001,15 +1003,7 @@ def cmd_signal(args: argparse.Namespace) -> int:
1001
1003
  event, fields = "task_done", {"summary": args.text}
1002
1004
  title, body, prio = notify.build_message(event, slug=slug, nnn=nnn,
1003
1005
  **fields)
1004
- on = notify.enabled(cfg)
1005
- print("cc-continuity: dry run (nothing sent, nothing recorded)")
1006
- print(f"enabled: {on}"
1007
- + ("" if on else " — would NOT send (disabled or bad config)"))
1008
- print(f"title: {title}")
1009
- print(f"priority: {prio}")
1010
- print("body:")
1011
- for ln in body.splitlines():
1012
- print(f" {ln}")
1006
+ _print_dry_run(notify.enabled(cfg), title, body, prio)
1013
1007
  return 0
1014
1008
  if args.kind == "needs-human":
1015
1009
  sent = notify.safe_send(cfg, "needs_human", slug=slug, nnn=nnn,
@@ -1028,6 +1022,19 @@ def cmd_signal(args: argparse.Namespace) -> int:
1028
1022
  return 0
1029
1023
 
1030
1024
 
1025
+ def _print_dry_run(on: bool, title: str, body: str, prio: str) -> None:
1026
+ """Shared --dry-run render (issue #30 contract): the exact push to
1027
+ stdout, nothing sent, nothing recorded (re-used by notify #37)."""
1028
+ print("cc-continuity: dry run (nothing sent, nothing recorded)")
1029
+ print(f"enabled: {on}"
1030
+ + ("" if on else " — would NOT send (disabled or bad config)"))
1031
+ print(f"title: {title}")
1032
+ print(f"priority: {prio}")
1033
+ print("body:")
1034
+ for ln in body.splitlines():
1035
+ print(f" {ln}")
1036
+
1037
+
1031
1038
  def cmd_notify(args: argparse.Namespace) -> int:
1032
1039
  """Issue #7 B5/B8 — generic Stop/Notification hook push.
1033
1040
 
@@ -1048,7 +1055,7 @@ def cmd_notify(args: argparse.Namespace) -> int:
1048
1055
  if not isinstance(payload, dict):
1049
1056
  payload = {}
1050
1057
  cfg = config.load_config()
1051
- if not notify.enabled(cfg):
1058
+ if not getattr(args, "dry_run", False) and not notify.enabled(cfg):
1052
1059
  return 0
1053
1060
  sid = (str(payload.get("session_id") or "").strip()
1054
1061
  or os.environ.get("CC_CONTINUITY_SESSION", "").strip())
@@ -1067,9 +1074,18 @@ def cmd_notify(args: argparse.Namespace) -> int:
1067
1074
  return 0
1068
1075
  digest = hashlib.sha1(msg.encode("utf-8")).hexdigest()[:10]
1069
1076
  bucket = int(time.time() // 60) # B8: one push per minute
1070
- if notify.dedup_seen(f"notification:{sid}:{digest}:{bucket}"):
1077
+ if (not getattr(args, "dry_run", False)
1078
+ and notify.dedup_seen(f"notification:{sid}:{digest}:{bucket}")):
1071
1079
  return 0
1072
1080
  fields = {"msg": msg}
1081
+ if getattr(args, "dry_run", False):
1082
+ # issue #37: render the exact push; the minute bucket is NOT
1083
+ # burned and no spec/spawn happens (same contract as #30).
1084
+ title, body, prio = notify.build_message(
1085
+ event, slug=slug, nnn=nnn, source="cli", sid=sid or None,
1086
+ repo=cwd, **fields)
1087
+ _print_dry_run(notify.enabled(cfg), title, body, prio)
1088
+ return 0
1073
1089
  notify.safe_send(cfg, event, slug=slug, nnn=nnn, wait=False,
1074
1090
  source="cli", sid=sid or None, repo=cwd, **fields)
1075
1091
  return 0
@@ -1532,10 +1548,26 @@ def cmd_watchdog(args: argparse.Namespace, home: Path | None = None,
1532
1548
  if action == "status":
1533
1549
  out = host.status("watchdog", home)
1534
1550
  print("watchdog: not loaded" if out is None else out.rstrip())
1551
+ print(_watchdog_heartbeat_note()) # issue #37
1535
1552
  return 0
1536
1553
  return 2
1537
1554
 
1538
1555
 
1556
+ def _watchdog_heartbeat_note() -> str:
1557
+ """Issue #37: age of the daemon's last full tick. ``watchdogd.
1558
+ run_forever`` stamps ``runtime/watchdog-beat.json`` after every tick;
1559
+ a missing or corrupt stamp reads as never."""
1560
+ try:
1561
+ data = json.loads((paths.runtime_dir() / "watchdog-beat.json")
1562
+ .read_text(encoding="utf-8"))
1563
+ ts = datetime.fromisoformat(str(data["ts"])).timestamp()
1564
+ return ("last heartbeat: "
1565
+ f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(ts))} "
1566
+ f"({int(time.time() - ts)}s ago)")
1567
+ except (OSError, ValueError, KeyError, TypeError):
1568
+ return "last heartbeat: never"
1569
+
1570
+
1539
1571
  def _daemon_name(name: str) -> str:
1540
1572
  # the rc self-heal line (spec §7.4) passes the SESSION name
1541
1573
  return name[len("cc-d-"):] if name.startswith("cc-d-") else name
@@ -137,6 +137,37 @@ def run_doctor(home: Path, runner=subprocess.run,
137
137
  isinstance(cfg.get("window_tokens"), int)
138
138
  add("config", cfg_ok, str(cfg_path))
139
139
 
140
+ # 6a: config-sanity (issue #36): the rotation gate order plus window
141
+ # and endpoint plausibility. Warn-only — the values are the user's
142
+ # call, but an inverted gate must not pass silently.
143
+ from . import config # local: doctor stays import-light
144
+ problems = []
145
+ ratios = {}
146
+ for k in ("warn_ratio", "rotate_ratio", "hard_ratio"):
147
+ v = (cfg or {}).get(k, config.DEFAULTS[k])
148
+ if isinstance(v, bool) or not isinstance(v, (int, float)):
149
+ problems.append(f"{k}={v!r} (number expected)")
150
+ v = None
151
+ ratios[k] = v
152
+ if all(v is not None for v in ratios.values()):
153
+ if not (0 < ratios["warn_ratio"] <= ratios["rotate_ratio"]
154
+ <= ratios["hard_ratio"] < 1):
155
+ problems.append(
156
+ "gate order broken: " + " ".join(
157
+ f"{k}={ratios[k]}" for k in
158
+ ("warn_ratio", "rotate_ratio", "hard_ratio")))
159
+ win = (cfg or {}).get("window_tokens", config.DEFAULTS["window_tokens"])
160
+ if isinstance(win, bool) or not isinstance(win, int) or win < 32768:
161
+ problems.append(f"window_tokens={win} (>= 32768 expected)")
162
+ ep = (cfg or {}).get("notify_endpoint",
163
+ config.DEFAULTS["notify_endpoint"])
164
+ if ep and not str(ep).startswith(("http://", "https://")):
165
+ problems.append(f"notify_endpoint={ep} (http(s) scheme expected)")
166
+ add("config-sanity", True,
167
+ "; ".join(problems) if problems else
168
+ "gate order, window and endpoint plausible",
169
+ warning=bool(problems))
170
+
140
171
  # 6b: curl (P9-P11 — notify needs it; install refuses without it)
141
172
  curl = which("curl")
142
173
  add("curl", curl is not None, curl or "not on PATH")
@@ -19,10 +19,11 @@ import signal
19
19
  import subprocess
20
20
  import time
21
21
  import traceback
22
+ from datetime import datetime, timezone
22
23
  from pathlib import Path
23
24
  from urllib.parse import urlsplit
24
25
 
25
- from . import ledger, notify, paths, power_plug, state
26
+ from . import atomic, ledger, notify, paths, power_plug, state
26
27
  from .watchdog import (Episode, HealthState, build_nudge_text, classify,
27
28
  exit_hang_due, find_claude_pid, find_exit_marker_ts,
28
29
  frozen_nudge_due, nudge_action, parse_entry_ts,
@@ -1817,6 +1818,14 @@ def run_forever(cfg: dict, *, max_ticks: int | None = None,
1817
1818
  line = {"ts": ctx.now, "error": "tick exception"}
1818
1819
  _log_line(line)
1819
1820
  ticks += 1
1821
+ # issue #37: full-tick heartbeat stamp read by `watchdog
1822
+ # status`; a stamp failure must never touch the loop.
1823
+ try:
1824
+ atomic.atomic_write_json(
1825
+ paths.runtime_dir() / "watchdog-beat.json",
1826
+ {"ts": datetime.now(timezone.utc).isoformat()})
1827
+ except OSError:
1828
+ pass
1820
1829
  if max_ticks is not None and ticks >= max_ticks:
1821
1830
  return 0
1822
1831
  sleep(EXIT_HANG_POLL_S)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cc-continuity
3
- Version: 0.3.47
3
+ Version: 0.3.49
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.47"
7
+ version = "0.3.49"
8
8
  description = "Zero-touch session rotation for Claude Code (local large-context model)"
9
9
  requires-python = ">=3.11"
10
10
  classifiers = [
@@ -1176,6 +1176,122 @@ def test_cli_notify_emit_corrupt_exits_zero(cc_home, tmp_path):
1176
1176
  assert not bad.exists() # corrupt spec consumed, not left in queue
1177
1177
 
1178
1178
 
1179
+ # ------------------------------------------------------- notify --dry-run (issue #37)
1180
+
1181
+
1182
+ def test_cli_notify_dry_run_renders_without_sending(cc_home, tmp_path,
1183
+ monkeypatch, capsys):
1184
+ # issue #37: --dry-run renders the exact push and sends nothing
1185
+ from cc_continuity import notify
1186
+ repo = make_repo(tmp_path)
1187
+ _notify_cfg(cc_home)
1188
+ register_session(repo)
1189
+ monkeypatch.chdir(repo)
1190
+ payload = {"session_id": SID,
1191
+ "transcript_path": str(repo / "t.jsonl"),
1192
+ "cwd": str(repo)}
1193
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1194
+ sub = _NotifySub()
1195
+ monkeypatch.setattr(notify, "subprocess", sub)
1196
+ assert cli.main(["notify", "--dry-run", "stop"]) == 0
1197
+ assert sub.popen_calls == [] and sub.run_calls == [] # nothing sent
1198
+ out = capsys.readouterr().out
1199
+ assert "cc-continuity: dry run (nothing sent, nothing recorded)" in out
1200
+ assert "enabled: True" in out
1201
+ assert "title: ✅ cc-continuity: Claude is done" in out
1202
+ assert "priority: default" in out
1203
+ assert "body:" in out
1204
+
1205
+
1206
+ def test_cli_notify_dry_run_reports_disabled(cc_home, tmp_path, monkeypatch,
1207
+ capsys):
1208
+ # disabled notify must be visible in the render instead of a silent no-op
1209
+ repo = make_repo(tmp_path)
1210
+ register_session(repo) # default cc_home config: notify disabled
1211
+ monkeypatch.chdir(repo)
1212
+ payload = {"session_id": SID,
1213
+ "transcript_path": str(repo / "t.jsonl"),
1214
+ "cwd": str(repo)}
1215
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1216
+ assert cli.main(["notify", "--dry-run", "stop"]) == 0
1217
+ out = capsys.readouterr().out
1218
+ assert "enabled: False" in out
1219
+ assert "would NOT send" in out
1220
+ assert "title: ✅ cc-continuity: Claude is done" in out
1221
+
1222
+
1223
+ def test_cli_notify_dry_run_does_not_consume_dedup_bucket(cc_home, tmp_path,
1224
+ monkeypatch,
1225
+ capsys):
1226
+ # a dry run must not burn the one-push-per-minute bucket (#37)
1227
+ from cc_continuity import notify
1228
+ repo = make_repo(tmp_path)
1229
+ _notify_cfg(cc_home)
1230
+ register_session(repo)
1231
+ monkeypatch.chdir(repo)
1232
+ payload = {"session_id": SID, "message": "deploy? y/n", "cwd": str(repo)}
1233
+ sub = _NotifySub()
1234
+ monkeypatch.setattr(notify, "subprocess", sub)
1235
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1236
+ assert cli.main(["notify", "--dry-run", "notification"]) == 0
1237
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1238
+ assert cli.main(["notify", "--dry-run", "notification"]) == 0
1239
+ assert sub.popen_calls == [] # dry runs touched nothing
1240
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1241
+ assert cli.main(["notify", "notification"]) == 0
1242
+ assert len(sub.popen_calls) == 1 # real push still gets its bucket
1243
+
1244
+
1245
+ def test_cli_notify_dry_run_notification_without_message_is_silent(
1246
+ cc_home, tmp_path, monkeypatch, capsys):
1247
+ # a message-less notification payload stays a silent rc 0 even in a dry run
1248
+ repo = make_repo(tmp_path)
1249
+ _notify_cfg(cc_home)
1250
+ register_session(repo)
1251
+ monkeypatch.chdir(repo)
1252
+ payload = {"session_id": SID, "cwd": str(repo)} # no message field
1253
+ monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload)))
1254
+ assert cli.main(["notify", "--dry-run", "notification"]) == 0
1255
+ assert capsys.readouterr().out == ""
1256
+
1257
+
1258
+ # ------------------------------------------------- watchdog status heartbeat (issue #37)
1259
+
1260
+
1261
+ def test_watchdog_status_shows_last_heartbeat_age(cc_home, tmp_path,
1262
+ monkeypatch, capsys):
1263
+ # issue #37: status reports the daemon's last full-tick heartbeat
1264
+ from datetime import datetime, timezone
1265
+ runner, _ = _fake_runner()
1266
+ fixed = 1795000000.0
1267
+ monkeypatch.setattr(time, "time", lambda: fixed)
1268
+ beat_ts = datetime.fromtimestamp(fixed - 120, timezone.utc).isoformat()
1269
+ (cc_home / "runtime").mkdir(parents=True, exist_ok=True)
1270
+ (cc_home / "runtime" / "watchdog-beat.json").write_text(
1271
+ json.dumps({"ts": beat_ts}), encoding="utf-8")
1272
+ assert cli.cmd_watchdog(_wd_ns("status"), home=tmp_path,
1273
+ runner=runner) == 0
1274
+ out = capsys.readouterr().out
1275
+ expected = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(fixed - 120))
1276
+ assert "state = running" in out
1277
+ assert f"last heartbeat: {expected} (120s ago)" in out
1278
+
1279
+
1280
+ def test_watchdog_status_heartbeat_never_when_missing_or_corrupt(
1281
+ cc_home, tmp_path, capsys):
1282
+ # no stamp (fresh install) or a corrupt stamp both read as "never"
1283
+ runner, _ = _fake_runner()
1284
+ assert cli.cmd_watchdog(_wd_ns("status"), home=tmp_path,
1285
+ runner=runner) == 0
1286
+ assert "last heartbeat: never" in capsys.readouterr().out
1287
+ (cc_home / "runtime").mkdir(parents=True, exist_ok=True)
1288
+ (cc_home / "runtime" / "watchdog-beat.json").write_text(
1289
+ "{not json", encoding="utf-8")
1290
+ assert cli.cmd_watchdog(_wd_ns("status"), home=tmp_path,
1291
+ runner=runner) == 0
1292
+ assert "last heartbeat: never" in capsys.readouterr().out
1293
+
1294
+
1179
1295
  def test_notify_claimed_passes_prev_and_handoff(cc_home, tmp_path,
1180
1296
  monkeypatch):
1181
1297
  from cc_continuity import notify
@@ -134,6 +134,66 @@ def test_rotation_env_warns_when_env_missing(fake_home):
134
134
  assert c.ok and c.warning
135
135
 
136
136
 
137
+ def _set_cfg(home, **kv):
138
+ cfg_path = home / ".claude-continuity" / "config.json"
139
+ cfg = json.loads(cfg_path.read_text(encoding="utf-8"))
140
+ cfg.update(kv)
141
+ cfg_path.write_text(json.dumps(cfg), encoding="utf-8")
142
+
143
+
144
+ # config-sanity (issue #36): the gate order warn <= rotate <= hard and the
145
+ # window/endpoint plausibility are warn-only - the values are the user's
146
+ # call, but an inverted gate must not pass silently.
147
+
148
+
149
+ def test_config_sanity_all_green_on_defaults(fake_home):
150
+ h = fake_home
151
+ install.install(h, window=262144, runner=FakeRun())
152
+ checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
153
+ c = next(x for x in checks if x.name == "config-sanity")
154
+ assert c.ok and not c.warning
155
+
156
+
157
+ def test_config_sanity_warns_on_inverted_thresholds(fake_home):
158
+ # the trial typo shape: warn above rotate fires rotations late or never
159
+ h = fake_home
160
+ install.install(h, window=262144, runner=FakeRun())
161
+ _set_cfg(h, warn_ratio=0.80, rotate_ratio=0.75, hard_ratio=0.85)
162
+ checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
163
+ c = next(x for x in checks if x.name == "config-sanity")
164
+ assert c.ok and c.warning # warn-only: the values are the user's call
165
+ assert "warn_ratio=0.8" in c.detail and "rotate_ratio=0.75" in c.detail
166
+
167
+
168
+ def test_config_sanity_accepts_equal_thresholds(fake_home):
169
+ h = fake_home
170
+ install.install(h, window=262144, runner=FakeRun())
171
+ _set_cfg(h, warn_ratio=0.75, rotate_ratio=0.75, hard_ratio=0.75)
172
+ checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
173
+ c = next(x for x in checks if x.name == "config-sanity")
174
+ assert c.ok and not c.warning
175
+
176
+
177
+ def test_config_sanity_warns_on_implausible_window(fake_home):
178
+ h = fake_home
179
+ install.install(h, window=262144, runner=FakeRun())
180
+ _set_cfg(h, window_tokens=4096)
181
+ checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
182
+ c = next(x for x in checks if x.name == "config-sanity")
183
+ assert c.ok and c.warning
184
+ assert "window_tokens=4096" in c.detail
185
+
186
+
187
+ def test_config_sanity_warns_on_bad_endpoint_scheme(fake_home):
188
+ h = fake_home
189
+ install.install(h, window=262144, runner=FakeRun())
190
+ _set_cfg(h, notify_enabled=False, notify_endpoint="ftp://example/x")
191
+ checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
192
+ c = next(x for x in checks if x.name == "config-sanity")
193
+ assert c.ok and c.warning
194
+ assert "notify_endpoint" in c.detail
195
+
196
+
137
197
  def test_stale_lock_warns(fake_home, cc_home):
138
198
  h = fake_home
139
199
  install.install(h, window=262144, runner=FakeRun())
File without changes
File without changes