cc-continuity 0.3.46__tar.gz → 0.3.48__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.
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/PKG-INFO +1 -1
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/README.md +2 -2
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/cli.py +24 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/doctor.py +31 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/pyproject.toml +1 -1
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_cli.py +63 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_doctor.py +60 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/LICENSE +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/checkpoint.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/stop.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/transcript.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity.egg-info/SOURCES.txt +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/setup.cfg +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_changelog_notes.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_cli_ledger.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_cli_log.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_config.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_stop.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_install.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_project.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_readme_badges.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_state.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_status.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_transcript.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_transcript_finalize.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.46 → cc_continuity-0.3.48}/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.
|
|
3
|
+
Version: 0.3.48
|
|
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-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)).
|
|
45
|
+
- **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)).
|
|
44
46
|
- **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)).
|
|
45
47
|
- **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)).
|
|
46
48
|
- **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)).
|
|
47
|
-
- **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)).
|
|
48
|
-
- **2026-11-17**: Zombie panes are measured now too. After the 0.3.40 revival, Claude Code still rendered the status line with the abandoned startup session id, so the ratio metric kept landing on the dead id: the pane showed a ratio while the tracked session never moved (measurement without reaction). The hook entry now stamps a pane-scoped binding with the session id it actually runs as, and the status line writes its metric under it whenever that binding is fresh and names a different live session. Non-tmux runs and normal panes behave byte-for-byte exactly as before ([commit](https://github.com/pqant/claude-continuity/commit/361b7b1)).
|
|
49
49
|
|
|
50
50
|
## How it works
|
|
51
51
|
|
|
@@ -67,6 +67,8 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
67
67
|
p_hist = sub.add_parser("history", help="session chain for this project")
|
|
68
68
|
p_hist.add_argument("-n", type=int, default=20,
|
|
69
69
|
help="show at most N most recent sessions (default 20)")
|
|
70
|
+
p_hist.add_argument("--json", action="store_true",
|
|
71
|
+
help="print the session chain as one JSON array")
|
|
70
72
|
|
|
71
73
|
p_ratio = sub.add_parser("ratio",
|
|
72
74
|
help="print the live context ratio of a project")
|
|
@@ -604,6 +606,9 @@ def cmd_history(args: argparse.Namespace) -> int:
|
|
|
604
606
|
key = project.project_key_for_root(root)
|
|
605
607
|
pfile = paths.project_dir(key) / "project.json"
|
|
606
608
|
if not pfile.is_file():
|
|
609
|
+
if getattr(args, "json", False):
|
|
610
|
+
print("[]")
|
|
611
|
+
return 0
|
|
607
612
|
print(f"No cc-continuity project for {root} "
|
|
608
613
|
f"(a project registers itself on its first hook).")
|
|
609
614
|
return 0
|
|
@@ -613,6 +618,25 @@ def cmd_history(args: argparse.Namespace) -> int:
|
|
|
613
618
|
print(f"cc-continuity history: unreadable project record: {e}",
|
|
614
619
|
file=sys.stderr)
|
|
615
620
|
return 1
|
|
621
|
+
if getattr(args, "json", False):
|
|
622
|
+
rows = []
|
|
623
|
+
for s in (record.get("sessions") or [])[-args.n:]:
|
|
624
|
+
if not isinstance(s, dict):
|
|
625
|
+
continue
|
|
626
|
+
nnn = s.get("nnn") if isinstance(s.get("nnn"), int) else 0
|
|
627
|
+
try:
|
|
628
|
+
srec = json.loads(
|
|
629
|
+
(paths.session_dir(key, nnn)
|
|
630
|
+
/ "state.json").read_text(encoding="utf-8"))
|
|
631
|
+
except (OSError, json.JSONDecodeError):
|
|
632
|
+
srec = None
|
|
633
|
+
st = (srec.get("state") if isinstance(srec, dict)
|
|
634
|
+
and isinstance(srec.get("state"), str) else None)
|
|
635
|
+
rows.append({"nnn": nnn, "name": s.get("name"),
|
|
636
|
+
"session_id": s.get("session_id"),
|
|
637
|
+
"created": s.get("created"), "state": st})
|
|
638
|
+
print(json.dumps(rows))
|
|
639
|
+
return 0
|
|
616
640
|
for s in (record.get("sessions") or [])[-args.n:]:
|
|
617
641
|
nnn = s.get("nnn") if isinstance(s.get("nnn"), int) else 0
|
|
618
642
|
print(f"{nnn:03d} {s.get('name')} {s.get('session_id')} "
|
|
@@ -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")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cc-continuity
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.48
|
|
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
|
|
@@ -122,6 +122,69 @@ def test_history_n_limits_output(cc_home, tmp_path, monkeypatch, capsys):
|
|
|
122
122
|
assert "spike-repo-001" not in out
|
|
123
123
|
|
|
124
124
|
|
|
125
|
+
# --json (issue #38): the session chain as one JSON array on stdout,
|
|
126
|
+
# stable keys (nnn, name, session_id, created, state); the state reads
|
|
127
|
+
# sessions/<nnn>/state.json exactly like the #32 status fallback.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_history_json_prints_chain_array_with_state(cc_home, tmp_path,
|
|
131
|
+
monkeypatch, capsys):
|
|
132
|
+
repo = make_repo(tmp_path)
|
|
133
|
+
key, nnn = register_session(repo)
|
|
134
|
+
sdir = paths.session_dir(key, nnn)
|
|
135
|
+
sdir.mkdir(parents=True, exist_ok=True)
|
|
136
|
+
(sdir / "state.json").write_text(json.dumps({"state": "ACTIVE"}),
|
|
137
|
+
encoding="utf-8")
|
|
138
|
+
key2, nnn2 = register_session(
|
|
139
|
+
repo, session_id="22222222-2222-2222-2222-222222222222")
|
|
140
|
+
# The real SessionStart hook seeds state.json; drop it so session 2
|
|
141
|
+
# exercises the "no state on disk yet" path.
|
|
142
|
+
(paths.session_dir(key2, nnn2) / "state.json").unlink(missing_ok=True)
|
|
143
|
+
monkeypatch.chdir(repo)
|
|
144
|
+
assert cli.main(["history", "--json"]) == 0
|
|
145
|
+
rows = json.loads(capsys.readouterr().out)
|
|
146
|
+
assert [r["nnn"] for r in rows] == [1, 2]
|
|
147
|
+
assert set(rows[0]) == {"nnn", "name", "session_id", "created", "state"}
|
|
148
|
+
assert rows[0]["state"] == "ACTIVE"
|
|
149
|
+
assert rows[0]["session_id"] == SID
|
|
150
|
+
assert rows[0]["name"] == "spike-repo-001"
|
|
151
|
+
assert rows[1]["state"] is None
|
|
152
|
+
assert rows[1]["name"] == "spike-repo-002"
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def test_history_json_empty_array_without_project(cc_home, tmp_path,
|
|
156
|
+
monkeypatch, capsys):
|
|
157
|
+
repo = make_repo(tmp_path)
|
|
158
|
+
monkeypatch.chdir(repo)
|
|
159
|
+
assert cli.main(["history", "--json"]) == 0
|
|
160
|
+
captured = capsys.readouterr()
|
|
161
|
+
assert json.loads(captured.out) == []
|
|
162
|
+
assert captured.err == ""
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_history_json_honors_n(cc_home, tmp_path, monkeypatch, capsys):
|
|
166
|
+
repo = make_repo(tmp_path)
|
|
167
|
+
register_session(repo, session_id=SID)
|
|
168
|
+
register_session(repo, session_id="22222222-2222-2222-2222-222222222222")
|
|
169
|
+
monkeypatch.chdir(repo)
|
|
170
|
+
assert cli.main(["history", "--json", "-n", "1"]) == 0
|
|
171
|
+
rows = json.loads(capsys.readouterr().out)
|
|
172
|
+
assert [r["name"] for r in rows] == ["spike-repo-002"]
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_history_json_unreadable_state_is_none(cc_home, tmp_path,
|
|
176
|
+
monkeypatch, capsys):
|
|
177
|
+
repo = make_repo(tmp_path)
|
|
178
|
+
key, nnn = register_session(repo, session_id=SID)
|
|
179
|
+
sdir = paths.session_dir(key, nnn)
|
|
180
|
+
sdir.mkdir(parents=True, exist_ok=True)
|
|
181
|
+
(sdir / "state.json").write_text("{broken", encoding="utf-8")
|
|
182
|
+
monkeypatch.chdir(repo)
|
|
183
|
+
assert cli.main(["history", "--json"]) == 0
|
|
184
|
+
rows = json.loads(capsys.readouterr().out)
|
|
185
|
+
assert rows[0]["state"] is None
|
|
186
|
+
|
|
187
|
+
|
|
125
188
|
# -------------------------------------------------------------------- ratio
|
|
126
189
|
|
|
127
190
|
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|