cc-continuity 0.3.3__tar.gz → 0.3.5__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.3 → cc_continuity-0.3.5}/PKG-INFO +1 -1
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/README.md +9 -7
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/__init__.py +1 -1
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/doctor.py +26 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/stop.py +16 -12
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity.egg-info/PKG-INFO +1 -1
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/pyproject.toml +1 -1
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_doctor.py +39 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_stop.py +41 -1
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/LICENSE +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/__main__.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/atomic.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/blink.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/blink_watch.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/bootstrap.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/checkpoint.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/cli.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/config.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/daemon_supervisor.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/gitsnap.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/__init__.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/common.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/pre_compact.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/pre_tool_use.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/session_end.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/session_start.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/task.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/tool_use.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hooks/user_prompt.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/hosting.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/install.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/launch.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/ledger.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/lock.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/managed.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/naming.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/notify.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/paths.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/power_plug.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/progress_pane.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/project.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/redact.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/rotator.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/settings_merge.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/skills.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/state.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/statusline.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/thresholds.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/transcript.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/validate.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/watchdog.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/watchdog_digest.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity/watchdogd.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity.egg-info/SOURCES.txt +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity.egg-info/dependency_links.txt +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity.egg-info/entry_points.txt +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/cc_continuity.egg-info/top_level.txt +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/setup.cfg +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_atomic.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_blink.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_blink_watch.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_bootstrap.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_checkpoint.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_cli.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_config.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_daemon_supervisor.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_gitsnap.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_common.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_pre_compact.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_pre_tool_use.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_session_end.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_session_start.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_task.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_tool_use.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hooks_user_prompt.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hosting.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_hygiene.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_install.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_integration_phase5.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_integration_phase6.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_integration_phase7.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_launch.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_ledger.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_lock.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_managed.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_naming.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_notify.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_notify_integration.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_paths.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_power_plug.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_progress_pane.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_project.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_redact.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_rotator.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_settings_merge.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_skills.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_state.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_status.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_statusline.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_thresholds.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_tmux_host.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_transcript.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_transcript_finalize.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_uninstall.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_validate.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_watchdog.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_watchdog_digest.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_watchdog_integration.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_watchdogd.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_wsl_doctor.py +0 -0
- {cc_continuity-0.3.3 → cc_continuity-0.3.5}/tests/test_wsl_install.py +0 -0
|
@@ -26,6 +26,15 @@ The five most recent updates, newest first. Each line links to its
|
|
|
26
26
|
commit, so you can see what changed lately without digging through the
|
|
27
27
|
log:
|
|
28
28
|
|
|
29
|
+
- **2026-11-10**: `cc-continuity doctor` now verifies the rotation
|
|
30
|
+
prerequisites in `settings.json` (auto-compact override + context
|
|
31
|
+
window pin) and flags drift with the exact recommended values
|
|
32
|
+
([commit](https://github.com/pqant/claude-continuity/commit/9462064)).
|
|
33
|
+
- **2026-11-09**: The turn-end rotation gate no longer blocks a routine
|
|
34
|
+
rotation when the handoff draft is already valid: the rotation now
|
|
35
|
+
finishes silently, so the built-in "Stop hook error" line only appears
|
|
36
|
+
when the model genuinely fails to produce a draft after being told
|
|
37
|
+
([commit](https://github.com/pqant/claude-continuity/commit/2c9d2bf)).
|
|
29
38
|
- **2026-11-09**: Routine rotations no longer print a red error: at the
|
|
30
39
|
hard context limit the in-flight tool call now passes and the handoff
|
|
31
40
|
instruction arrives as a neutral notice, so the pane stays clean
|
|
@@ -43,13 +52,6 @@ log:
|
|
|
43
52
|
the Sessions label sits under Session Time, the search box keeps a
|
|
44
53
|
fixed width, and labels read bold and high-contrast
|
|
45
54
|
([commit](https://github.com/pqant/claude-continuity/commit/18af742)).
|
|
46
|
-
- **2026-11-08**: An interactive architecture diagram of the whole system
|
|
47
|
-
(modules, dependencies and data flows) now ships in `docs/diagrams` as a
|
|
48
|
-
self-contained HTML page with guided views and export
|
|
49
|
-
([commit](https://github.com/pqant/claude-continuity/commit/5ae9011)).
|
|
50
|
-
- **2026-11-08**: The waiting tab blink now starts after a 5 s settle
|
|
51
|
-
window instead of 15 s, so a finished turn reaches your tab faster
|
|
52
|
-
([commit](https://github.com/pqant/claude-continuity/commit/a9a295d)).
|
|
53
55
|
## How it works
|
|
54
56
|
|
|
55
57
|
The whole flow in one picture: the automatic session loop, the optional
|
|
@@ -27,6 +27,10 @@ from .settings_merge import HOOK_EVENTS, is_ours
|
|
|
27
27
|
TMP_MAX_AGE = 3600.0
|
|
28
28
|
LOCK_STALE_AFTER = 120.0
|
|
29
29
|
|
|
30
|
+
# Recommended rotation prerequisites (issue #27): rotation runs with any
|
|
31
|
+
# values; 95 keeps native auto-compact (~249K) behind the custom gate.
|
|
32
|
+
ROTATION_ENV_OVERRIDE_PCT = "95"
|
|
33
|
+
|
|
30
34
|
|
|
31
35
|
@dataclasses.dataclass
|
|
32
36
|
class Check:
|
|
@@ -164,6 +168,28 @@ def run_doctor(home: Path, runner=subprocess.run,
|
|
|
164
168
|
sl = settings.get("statusLine") or {}
|
|
165
169
|
cmd = str(sl.get("command", ""))
|
|
166
170
|
add("statusline", "cc-continuity" in cmd, cmd or "absent")
|
|
171
|
+
# 8b: rotation prerequisites (issue #27): the settings env must keep
|
|
172
|
+
# native auto-compact behind the rotation gate and pin the window the
|
|
173
|
+
# ratios reference. Warning only - these are the user's values.
|
|
174
|
+
from . import config # local: doctor stays import-light
|
|
175
|
+
raw_env = settings.get("env") if isinstance(settings, dict) else None
|
|
176
|
+
env = raw_env if isinstance(raw_env, dict) else {}
|
|
177
|
+
want_window = str((cfg or {}).get("window_tokens")
|
|
178
|
+
or config.DEFAULTS["window_tokens"])
|
|
179
|
+
drift = []
|
|
180
|
+
got = str(env.get("CLAUDE_AUTOCOMPACT_PCT_OVERRIDE", "")).strip()
|
|
181
|
+
if got != ROTATION_ENV_OVERRIDE_PCT:
|
|
182
|
+
drift.append(f"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE={got or 'unset'} "
|
|
183
|
+
f"(recommended {ROTATION_ENV_OVERRIDE_PCT})")
|
|
184
|
+
got_w = str(env.get("CLAUDE_CODE_MAX_CONTEXT_TOKENS", "")).strip()
|
|
185
|
+
if got_w != want_window:
|
|
186
|
+
drift.append(f"CLAUDE_CODE_MAX_CONTEXT_TOKENS={got_w or 'unset'} "
|
|
187
|
+
f"(expected {want_window})")
|
|
188
|
+
add("rotation-env", True,
|
|
189
|
+
"; ".join(drift) if drift else
|
|
190
|
+
f"override {ROTATION_ENV_OVERRIDE_PCT}, window {want_window}",
|
|
191
|
+
warning=bool(drift))
|
|
192
|
+
|
|
167
193
|
# 9: chained statusline target exists (warning only — the user's own
|
|
168
194
|
# script may live outside this HOME in a half-installed machine)
|
|
169
195
|
chained = (cfg or {}).get("chained_statusline")
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"""Stop hook (PRD §9) — turn-end enforcement (Phase 5, spec §6.4).
|
|
2
2
|
|
|
3
3
|
State-based (never ratio-based): ROTATION_PENDING -> advance to
|
|
4
|
-
HANDOFF_REQUESTED
|
|
4
|
+
HANDOFF_REQUESTED and fall through; HANDOFF_REQUESTED -> validate the
|
|
5
5
|
draft file DIRECTLY (a Bash-written draft was never seen by
|
|
6
|
-
PostToolUse) -> finalize
|
|
7
|
-
|
|
6
|
+
PostToolUse) -> finalize (SILENTLY when valid, issue #26 - a block
|
|
7
|
+
would render as a hardcoded red "Stop hook error:" line) or
|
|
8
|
+
attempt/block (missing/invalid draft = genuine violation);
|
|
9
|
+
3 accumulated failed attempts -> degrade (HANDOFF_FAILED ->
|
|
10
|
+
deterministic checkpoint, C.7);
|
|
8
11
|
CHECKPOINT_WRITING -> finalize; CHECKPOINT_VERIFIED -> AMCL without
|
|
9
12
|
re-running finalize; everything else: ``turn_active=False`` +
|
|
10
13
|
``last_stop_ts`` only. After a verified checkpoint the session rotates
|
|
@@ -163,16 +166,17 @@ def handle(ctx: HookContext) -> dict | None:
|
|
|
163
166
|
s = rec["state"]
|
|
164
167
|
tool_calls = rec.get("tool_calls", 0)
|
|
165
168
|
if s == "ROTATION_PENDING":
|
|
169
|
+
# Issue #26: C.2 already reached the model as PostToolUse
|
|
170
|
+
# additionalContext at the crossing (guide-first). The old blind
|
|
171
|
+
# block re-sent the full instruction even when the draft was
|
|
172
|
+
# already written - and every Stop block renders as a red
|
|
173
|
+
# "Stop hook error:" line (prefix hardcoded in the CC binary),
|
|
174
|
+
# so a routine rotation showed "Error" for no effect. Advance
|
|
175
|
+
# and fall through to the shared HR validation below: it blocks
|
|
176
|
+
# only on a missing/invalid draft (a genuine violation after
|
|
177
|
+
# guidance) and rotates silently when the draft is valid.
|
|
166
178
|
rec, _ = thresholds.advance(key, nnn, "HANDOFF_REQUESTED", cfg=cfg)
|
|
167
|
-
|
|
168
|
-
handoff_attempts=rec.get("handoff_attempts", 0) + 1,
|
|
169
|
-
ctx_emitted_at=tool_calls)["handoff_attempts"]
|
|
170
|
-
if attempts >= 3:
|
|
171
|
-
return _degrade(ctx, key, nnn)
|
|
172
|
-
return {"decision": "block",
|
|
173
|
-
"reason": thresholds.c2_text(thresholds.display_ratio(ctx, cfg),
|
|
174
|
-
draft_path,
|
|
175
|
-
blocked=ledger.blocked_reason(sdir))}
|
|
179
|
+
s = "HANDOFF_REQUESTED"
|
|
176
180
|
if s == "HANDOFF_REQUESTED":
|
|
177
181
|
draft = sdir / "handoff.draft.md"
|
|
178
182
|
report = None
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cc-continuity"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.5"
|
|
8
8
|
description = "Zero-touch session rotation for Claude Code (local large-context model)"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
dependencies = [] # stdlib only at runtime (PRD §0.5)
|
|
@@ -89,6 +89,45 @@ def test_changed_claude_version_warns(fake_home):
|
|
|
89
89
|
assert c.ok and c.warning
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
def test_rotation_env_all_green_on_pinned_values(fake_home):
|
|
93
|
+
h = fake_home
|
|
94
|
+
install.install(h, window=262144, runner=FakeRun())
|
|
95
|
+
sfile = h / ".claude" / "settings.json"
|
|
96
|
+
s = json.loads(sfile.read_text(encoding="utf-8"))
|
|
97
|
+
s.setdefault("env", {}).update({
|
|
98
|
+
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "95",
|
|
99
|
+
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144"})
|
|
100
|
+
sfile.write_text(json.dumps(s), encoding="utf-8")
|
|
101
|
+
checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
|
|
102
|
+
c = next(x for x in checks if x.name == "rotation-env")
|
|
103
|
+
assert c.ok and not c.warning
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_rotation_env_warns_on_drift(fake_home):
|
|
107
|
+
h = fake_home
|
|
108
|
+
install.install(h, window=262144, runner=FakeRun())
|
|
109
|
+
sfile = h / ".claude" / "settings.json"
|
|
110
|
+
s = json.loads(sfile.read_text(encoding="utf-8"))
|
|
111
|
+
s.setdefault("env", {}).update({
|
|
112
|
+
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "90",
|
|
113
|
+
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "131072"})
|
|
114
|
+
sfile.write_text(json.dumps(s), encoding="utf-8")
|
|
115
|
+
checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
|
|
116
|
+
c = next(x for x in checks if x.name == "rotation-env")
|
|
117
|
+
assert c.ok and c.warning # warn-only: the values are the user's call
|
|
118
|
+
assert "90" in c.detail and "95" in c.detail
|
|
119
|
+
assert "131072" in c.detail and "262144" in c.detail
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_rotation_env_warns_when_env_missing(fake_home):
|
|
123
|
+
# a plain install never writes the env block: warning, not failure
|
|
124
|
+
h = fake_home
|
|
125
|
+
install.install(h, window=262144, runner=FakeRun())
|
|
126
|
+
checks = doctor.run_doctor(h, runner=FakeRun(), which=_which_ok)
|
|
127
|
+
c = next(x for x in checks if x.name == "rotation-env")
|
|
128
|
+
assert c.ok and c.warning
|
|
129
|
+
|
|
130
|
+
|
|
92
131
|
def test_stale_lock_warns(fake_home, cc_home):
|
|
93
132
|
h = fake_home
|
|
94
133
|
install.install(h, window=262144, runner=FakeRun())
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"""hooks/stop.py: turn-end enforcement (PRD §9, spec §6.4).
|
|
2
2
|
|
|
3
|
-
Attempt ladder
|
|
3
|
+
Attempt ladder (issue #26 unified): RP advances to HR, then both states
|
|
4
|
+
validate the draft directly - a valid draft finalizes and rotates
|
|
5
|
+
SILENTLY (no block: any Stop block renders as a red "Stop hook error:"
|
|
6
|
+
line, which CC hardcodes); a missing/invalid draft blocks
|
|
4
7
|
(C.6 when the draft exists and is invalid, else C.2); 3 accumulated
|
|
5
8
|
failed attempts -> degraded checkpoint (C.7), NO block, systemMessage.
|
|
6
9
|
A valid draft (even one Stop itself discovers, e.g. Bash-written) ->
|
|
@@ -141,6 +144,43 @@ def test_handoff_requested_valid_draft_finalizes(cc_home, capsys, tmp_path):
|
|
|
141
144
|
assert "## Next Atomic Action" in (cp / "handoff.md").read_text()
|
|
142
145
|
|
|
143
146
|
|
|
147
|
+
def test_rotation_pending_valid_draft_finalizes_without_block(cc_home,
|
|
148
|
+
capsys,
|
|
149
|
+
tmp_path):
|
|
150
|
+
# issue #26: a routine rotation where the draft is already valid must
|
|
151
|
+
# rotate silently - any Stop block renders as a red "Stop hook error:"
|
|
152
|
+
# line (prefix hardcoded in CC 2.1.209), which must never appear for a
|
|
153
|
+
# valid routine case.
|
|
154
|
+
repo, key, nnn = _setup(cc_home, tmp_path, s="ROTATION_PENDING")
|
|
155
|
+
(paths.session_dir(key, nnn) / "handoff.draft.md").write_text(
|
|
156
|
+
_valid_draft(), encoding="utf-8")
|
|
157
|
+
run_hook("Stop", payload("Stop", repo))
|
|
158
|
+
out = stdout_json(capsys)
|
|
159
|
+
assert "decision" not in out # NO block
|
|
160
|
+
assert out == {"systemMessage": AMCL}
|
|
161
|
+
rec = state.load_state(key, nnn)
|
|
162
|
+
assert rec["state"] == "AWAITING_MANUAL_CLEAR"
|
|
163
|
+
assert rec["degraded"] is False
|
|
164
|
+
assert rec.get("handoff_attempts", 0) == 0 # silent success is not an attempt
|
|
165
|
+
cp = paths.session_dir(key, nnn) / "checkpoint"
|
|
166
|
+
assert (cp / "handoff.md").is_file()
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def test_rotation_pending_invalid_draft_blocks_c6(cc_home, capsys, tmp_path):
|
|
170
|
+
# enforcement stays reserved for genuine violations: after guidance,
|
|
171
|
+
# an invalid draft still blocks (the red line is justified there).
|
|
172
|
+
repo, key, nnn = _setup(cc_home, tmp_path, s="ROTATION_PENDING")
|
|
173
|
+
(paths.session_dir(key, nnn) / "handoff.draft.md").write_text(
|
|
174
|
+
"## Objective\nshort\n", encoding="utf-8")
|
|
175
|
+
run_hook("Stop", payload("Stop", repo))
|
|
176
|
+
out = stdout_json(capsys)
|
|
177
|
+
assert out["decision"] == "block"
|
|
178
|
+
assert "handoff draft invalid" in out["reason"]
|
|
179
|
+
rec = state.load_state(key, nnn)
|
|
180
|
+
assert rec["state"] == "HANDOFF_REQUESTED"
|
|
181
|
+
assert rec["handoff_attempts"] == 1
|
|
182
|
+
|
|
183
|
+
|
|
144
184
|
def test_checkpoint_writing_finalizes(cc_home, capsys, tmp_path):
|
|
145
185
|
repo, key, nnn = _setup(cc_home, tmp_path, s="CHECKPOINT_WRITING")
|
|
146
186
|
run_hook("Stop", payload("Stop", repo))
|
|
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
|