@caddis/cli 0.4.90 → 0.4.92

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 (43) hide show
  1. package/bundles/antigravity-plugin/plugin.json +1 -1
  2. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
  3. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
  4. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
  5. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
  6. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
  7. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
  8. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
  9. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
  10. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
  11. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
  12. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
  13. package/bundles/antigravity-plugin/scripts/caddis_budget.py +26 -2
  14. package/bundles/antigravity-plugin/scripts/caddis_checkout_guard.py +31 -2
  15. package/bundles/antigravity-plugin/scripts/caddis_docs_pr.py +8 -0
  16. package/bundles/antigravity-plugin/scripts/caddis_gate.py +8 -8
  17. package/bundles/antigravity-plugin/scripts/caddis_guide.json +3 -3
  18. package/bundles/antigravity-plugin/scripts/caddis_handoff.py +73 -45
  19. package/bundles/antigravity-plugin/scripts/caddis_lanes.py +113 -31
  20. package/bundles/antigravity-plugin/scripts/caddis_review.py +1 -1
  21. package/bundles/antigravity-plugin/scripts/caddis_roadmap_run.py +22 -40
  22. package/bundles/antigravity-plugin/scripts/caddis_routing.py +1 -1
  23. package/bundles/antigravity-plugin/scripts/caddis_spend.py +121 -138
  24. package/bundles/antigravity-plugin/scripts/caddis_workstreams.py +60 -17
  25. package/bundles/antigravity-plugin/scripts/check_doc_coverage.py +17 -0
  26. package/bundles/antigravity-plugin/scripts/oss_review.py +102 -35
  27. package/bundles/antigravity-plugin/scripts/roadmap-recheck.ps1 +4 -2
  28. package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +6 -0
  29. package/bundles/antigravity-plugin/scripts/schemas/hub-spend.schema.json +6 -0
  30. package/bundles/antigravity-plugin/scripts/templates/coordinator.md +1 -1
  31. package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +17 -4
  32. package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +18 -6
  33. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +6 -1
  34. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +12 -2
  35. package/bundles/antigravity-plugin/skills/implement/SKILL.md +11 -7
  36. package/bundles/antigravity-plugin/skills/roadmap/SKILL.md +8 -7
  37. package/bundles/antigravity-plugin/skills/roadmap/assets/plan-resume-prompt.md +2 -2
  38. package/bundles/antigravity-plugin-extras/plugin.json +1 -1
  39. package/bundles/antigravity-plugin-extras/skills/cross-review/SKILL.md +5 -5
  40. package/bundles/codex/.codex/skills/workflow/roadmap/SKILL.md +8 -7
  41. package/bundles/codex/.codex/skills/workflow/roadmap/assets/plan-resume-prompt.md +2 -2
  42. package/bundles/manifest.json +3 -3
  43. package/package.json +1 -1
@@ -127,9 +127,8 @@ BUDGET_PATTERNS: dict[str, tuple[str, ...]] = {
127
127
  r"Quota exceeded\. Check your plan",
128
128
  r"workspace is out of credits",
129
129
  ),
130
- # caddis_spend refusing over the global EUR cap: the chain moves on, like a provider quota.
131
- "agy": (r"RESOURCE_EXHAUSTED.*quota", r"Individual quota reached", r"(?m)^caddis_spend: over cap",
132
- r"(?m)^caddis_spend: could not lock"),
130
+ # caddis_spend could not lock its usage log (another launch holds it): the chain moves on, like a provider quota.
131
+ "agy": (r"RESOURCE_EXHAUSTED.*quota", r"Individual quota reached", r"(?m)^caddis_spend: could not lock"),
133
132
  }
134
133
  CONFIG_PATTERNS: dict[str, tuple[str, ...]] = {
135
134
  "claude": (),
@@ -147,8 +146,7 @@ CONFIG_PATTERNS: dict[str, tuple[str, ...]] = {
147
146
  r"Model metadata for .* not found",
148
147
  ),
149
148
  "agy": (r"invalid model selection", r"is not recognized as a known model",
150
- r"(?m)^caddis_spend: spend cap not configured",
151
- r"(?m)^caddis_spend: could not check the spend cap"),
149
+ r"(?m)^caddis_spend: could not write the spend log"),
152
150
  }
153
151
  LOAD_WORDING = (
154
152
  r"(?i)\bcpu\s+burner",
@@ -613,7 +611,7 @@ def _windows_process_names(pids: list[int]) -> dict[int, str]:
613
611
 
614
612
 
615
613
  def _refused_run(returncode: int, message: str) -> LaneRun:
616
- """A lane that never started: the spend cap refused it. pid 0, no time spent."""
614
+ """A lane that never started: the spend log could not be locked or written. pid 0, no time spent."""
617
615
  return LaneRun(returncode=returncode, output=message + "\n", timed_out=False, duration_s=0.0,
618
616
  pid=0, started=time.time())
619
617
 
@@ -631,23 +629,18 @@ def run_lane(
631
629
  probe=default_probe,
632
630
  spend_caller: str = "lane",
633
631
  ) -> LaneRun:
634
- # Every agy launch is booked against the global spend cap first (caddis_spend). ci_watch reaches
635
- # agy through here too, so each call is booked exactly once. Any spend problem refuses the lane
636
- # (fail closed) and never crashes the unattended chain.
632
+ # Every agy launch is written to the usage log first (caddis_spend; there is no cap). ci_watch reaches
633
+ # agy through here too, so each call is logged exactly once. A log that cannot be locked or written
634
+ # refuses the lane (the spend would go unseen) and never crashes the unattended chain.
637
635
  spend_id = None
638
636
  if Path(argv[0]).stem.lower() == "agy":
639
637
  spend_home = Path.home()
640
638
  try:
641
639
  spend_id = caddis_spend.reserve(spend_home, spend_caller, datetime.now(timezone.utc))
642
- except caddis_spend.NotConfigured:
643
- return _refused_run(3, caddis_spend.NOT_CONFIGURED_MESSAGE)
644
640
  except TimeoutError as exc:
645
641
  return _refused_run(3, str(exc))
646
- except Exception as exc: # an unreadable log or file error: refuse, never crash
647
- return _refused_run(3, f"caddis_spend: could not check the spend cap: {exc!r}")
648
- if spend_id is None:
649
- return _refused_run(1, "caddis_spend: over cap: agy refused ("
650
- + caddis_spend.status_line(spend_home, datetime.now(timezone.utc)) + ")")
642
+ except Exception as exc: # a file error on the log: refuse, never crash
643
+ return _refused_run(3, f"caddis_spend: could not write the spend log: {exc!r}")
651
644
  argv = caddis_spend.hidden_argv(argv, env) # agy's tool consoles open on a hidden desktop, not on screen
652
645
  job_name = f"Local\\caddis-governor-{os.getpid()}-{secrets.token_hex(8)}" if sys.platform == "win32" else None
653
646
  full = governed_argv(argv, job_name)
@@ -781,8 +774,15 @@ def run_lane(
781
774
  try:
782
775
  caddis_spend.settle(spend_home, spend_id, counts, datetime.now(timezone.utc),
783
776
  duration_s=clock() - monotonic_started)
784
- except Exception as exc: # the pending reserve keeps counting; never lose the lane's result
777
+ except Exception as exc: # the pending line stays unsettled; never lose the lane's result
785
778
  output += f"\ncaddis_spend: could not settle {spend_id}: {exc!r}\n"
779
+ try: # advice only: at or above the advise level the lane's output says so; nothing is refused
780
+ committed = caddis_spend.committed_last_24h(spend_home, datetime.now(timezone.utc))
781
+ level = caddis_spend.advise_eur()
782
+ if committed >= level:
783
+ output += "\n" + caddis_spend.advisory_line(committed, level) + "\n"
784
+ except Exception:
785
+ pass
786
786
  return LaneRun(
787
787
  returncode=proc.returncode,
788
788
  output=output,
@@ -908,8 +908,47 @@ def oss_review_path() -> Path | None:
908
908
  return source if source.exists() else None
909
909
 
910
910
 
911
- def run_review(worktree: Path, env: dict, timeout_s: int = 900) -> ReviewResult:
912
- fake_review = os.environ.get("CADDIS_REVIEW_FAKE")
911
+ # The lane review timeout. oss_review cannot tell the lane its batch count in advance, so the bound is generous:
912
+ # every batch may take one full agy call, plus a margin for the 429 waits, the HTTP fallbacks and start-up.
913
+ # Mirrors of `.github/tools/oss_review.py` (AGY_TIMEOUT_S, MAX_REVIEW_BATCHES); a test fails if they drift.
914
+ # A timeout before the last batch would always kill a review of 2+ batches (the old 900 s equalled one agy call).
915
+ REVIEW_AGY_CALL_TIMEOUT_S = 15 * 60
916
+ REVIEW_MAX_BATCHES = 12
917
+ REVIEW_TIMEOUT_MARGIN_S = 600
918
+ LANE_REVIEW_TIMEOUT_S = REVIEW_MAX_BATCHES * REVIEW_AGY_CALL_TIMEOUT_S + REVIEW_TIMEOUT_MARGIN_S
919
+ # oss_review prints this line before its verdict when the secret filter dropped files: CLEAN then covers only part.
920
+ _PARTIAL_SCOPE = re.compile(r"(?m)^REVIEW-SCOPE: PARTIAL\b")
921
+
922
+
923
+ def _review_fake() -> str | None:
924
+ """CADDIS_REVIEW_FAKE, honoured only inside a pytest run (pytest sets PYTEST_CURRENT_TEST, and child processes
925
+ inherit it). A copy left exported in a shell would otherwise fake every later real lane review."""
926
+ fake = os.environ.get("CADDIS_REVIEW_FAKE")
927
+ if not fake:
928
+ return None
929
+ if os.environ.get("PYTEST_CURRENT_TEST"):
930
+ return fake
931
+ print("[caddis-lanes] CADDIS_REVIEW_FAKE is ignored outside a pytest run; running the real review",
932
+ file=sys.stderr)
933
+ return None
934
+
935
+
936
+ def _kill_tree(proc: subprocess.Popen) -> None:
937
+ """Kill the child and everything it started (taskkill /T on Windows, the process group on POSIX)."""
938
+ if sys.platform == "win32":
939
+ try:
940
+ subprocess.run(["taskkill", "/T", "/F", "/PID", str(proc.pid)], capture_output=True, timeout=15)
941
+ except (OSError, subprocess.TimeoutExpired):
942
+ proc.kill()
943
+ else:
944
+ try:
945
+ os.killpg(proc.pid, signal.SIGKILL)
946
+ except (ProcessLookupError, PermissionError):
947
+ proc.kill()
948
+
949
+
950
+ def run_review(worktree: Path, env: dict, timeout_s: int = LANE_REVIEW_TIMEOUT_S) -> ReviewResult:
951
+ fake_review = _review_fake()
913
952
  if fake_review:
914
953
  return ReviewResult(fake_review, 0 if fake_review == "CLEAN" else 1, f"fake review: {fake_review}")
915
954
 
@@ -917,26 +956,56 @@ def run_review(worktree: Path, env: dict, timeout_s: int = 900) -> ReviewResult:
917
956
  if path is None:
918
957
  return ReviewResult("MISSING", None, "oss_review.py not found")
919
958
 
959
+ # Its own process group (Windows) or session (POSIX): a timeout kills caddis_spend and agy too, not only
960
+ # oss_review, so nothing runs on and spends after the lane gave up.
961
+ group = ({"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP} if sys.platform == "win32"
962
+ else {"start_new_session": True})
963
+ argv = [sys.executable, str(path), "--cwd", str(worktree)]
920
964
  try:
921
- completed = subprocess.run(
922
- [sys.executable, str(path), "--cwd", str(worktree)],
965
+ proc = subprocess.Popen(
966
+ argv,
923
967
  cwd=worktree,
924
968
  env=env,
925
- capture_output=True,
969
+ stdout=subprocess.PIPE,
970
+ stderr=subprocess.PIPE,
926
971
  text=True,
927
972
  encoding="utf-8",
928
973
  errors="replace",
929
- timeout=timeout_s,
974
+ **group,
930
975
  )
931
- except subprocess.TimeoutExpired as exc:
932
- captured = _as_text(exc.stdout) + _as_text(exc.stderr)
933
- tail = (captured + f"\ntimed out after {timeout_s}s").lstrip("\n")[-3000:]
934
- return ReviewResult("MISSING", None, tail)
935
976
  except OSError as exc:
936
977
  return ReviewResult("MISSING", None, str(exc)[-3000:])
978
+ try:
979
+ stdout, stderr = proc.communicate(timeout=timeout_s)
980
+ except subprocess.TimeoutExpired:
981
+ _kill_tree(proc)
982
+ try:
983
+ stdout, stderr = proc.communicate(timeout=30)
984
+ except subprocess.TimeoutExpired:
985
+ stdout, stderr = "", ""
986
+ captured = _as_text(stdout) + _as_text(stderr)
987
+ tail = (captured + f"\ntimed out after {timeout_s}s; process tree killed").lstrip("\n")[-3000:]
988
+ return ReviewResult("MISSING", None, tail)
989
+
990
+ output = _combined_output(subprocess.CompletedProcess(argv, proc.returncode, stdout, stderr))
991
+ status = {0: "CLEAN", 1: "BLOCKING"}.get(proc.returncode, "MISSING")
992
+ if status == "CLEAN" and _PARTIAL_SCOPE.search(output):
993
+ status = "PARTIAL"
994
+ return ReviewResult(status, proc.returncode, output[-3000:])
937
995
 
938
- status = {0: "CLEAN", 1: "BLOCKING"}.get(completed.returncode, "MISSING")
939
- return ReviewResult(status, completed.returncode, _combined_output(completed)[-3000:])
996
+
997
+ def lane_commit_reason(worktree: Path, branch: str, base_sha: str) -> str:
998
+ """Why the lane worktree holds commits the review did not see, or ''.
999
+
1000
+ The review covers uncommitted work only, and accept merges the whole lane branch. So both the worktree HEAD
1001
+ and the branch tip must still be the base: a new commit, an amended base, or a commit on a detached HEAD
1002
+ (or on the branch before a detach back to the base) all fail one of the two."""
1003
+ head = _git_output(worktree, "rev-parse", "HEAD")
1004
+ tip = _git_output(worktree, "rev-parse", "--verify", f"refs/heads/{branch}")
1005
+ if head == base_sha and tip == base_sha:
1006
+ return ""
1007
+ return (f"the lane committed work that was not reviewed (worktree HEAD {head[:7]}, branch {branch} at "
1008
+ f"{tip[:7]}, base {base_sha[:7]}); the review covers uncommitted work only")
940
1009
 
941
1010
 
942
1011
  def changed_files(worktree: Path) -> list[str]:
@@ -1964,7 +2033,12 @@ def _run_post_checks(
1964
2033
  return "stop", EXIT_NOT_RUN
1965
2034
 
1966
2035
  review_started = time.monotonic()
1967
- review = run_review(worktree, dict(os.environ))
2036
+ committed = lane_commit_reason(worktree, str(packet["branch"]), str(packet["base_sha"]))
2037
+ if committed:
2038
+ # No review: it would cover only the uncommitted part and could print CLEAN over the commit.
2039
+ review = ReviewResult("COMMITTED", None, committed)
2040
+ else:
2041
+ review = run_review(worktree, dict(os.environ))
1968
2042
  review_s = time.monotonic() - review_started
1969
2043
  pythons = list(before)
1970
2044
  if pythons:
@@ -1979,7 +2053,7 @@ def _run_post_checks(
1979
2053
  freeze_unchanged = None
1980
2054
 
1981
2055
  gates_passed = all(gate.passed for gate in gates)
1982
- if gates_passed and freeze_unchanged is not False:
2056
+ if gates_passed and freeze_unchanged is not False and not committed:
1983
2057
  next_step = "review"
1984
2058
  exit_code = EXIT_OK
1985
2059
  else:
@@ -2255,6 +2329,9 @@ def _accept_command(
2255
2329
  if review_status != "CLEAN" and not override_reason:
2256
2330
  if review_status == "BLOCKING":
2257
2331
  print("refusing: review BLOCKING; pass --override-review with a reason")
2332
+ elif review_status == "PARTIAL":
2333
+ print("refusing: review PARTIAL (the secret filter dropped files, so CLEAN covers only part of "
2334
+ "the diff); review the dropped files, or pass --override-review with a reason")
2258
2335
  else:
2259
2336
  # MISSING = no verdict (provider down, 429, secret-filter refusal). Anything else
2260
2337
  # that is not CLEAN (absent, null, unknown, lowercase) is also no valid verdict.
@@ -2272,6 +2349,11 @@ def _accept_command(
2272
2349
 
2273
2350
  wt = _worktree_from_packet(packet)
2274
2351
  _validate_packet_worktree(repo, plan, args.phase, args.attempt, wt)
2352
+ # Not overridable: --override-review accepts a verdict, and no verdict covers a lane commit.
2353
+ committed = lane_commit_reason(wt.path, wt.branch, wt.base_sha)
2354
+ if committed:
2355
+ print(f"refusing: {_printable(committed)}; abandon and redo the phase")
2356
+ return EXIT_FAIL
2275
2357
  files = packet.get("changed_files")
2276
2358
  if not isinstance(files, list) or not files:
2277
2359
  print("refusing: packet has no changed files")
@@ -685,7 +685,7 @@ def launch_claude(prompt: str, worktree: Path, out: Path) -> str:
685
685
  # No `--allowedTools`: unscoped, it approves files outside the worktree (smoke run 18 Oct 2026: without it a
686
686
  # Read in the worktree ran, a Read of ~/.caddis/spend-cap.toml was refused).
687
687
  try:
688
- import caddis_spend # the recursion guard lives beside the spend cap (robustness #19)
688
+ import caddis_spend # the recursion guard lives beside the agy usage log (robustness #19)
689
689
  env_depth = caddis_spend.bump_headless_depth(os.environ)
690
690
  except ImportError:
691
691
  env_depth = None
@@ -4,10 +4,11 @@ the next batches of a roadmap.
4
4
  Design: programme-method-design.md sections 8.1 to 8.5 and 9.2; caddis-next Phases 7 and 9. `roadmap-run.ps1` is a
5
5
  thin shim over this file. The programme layer (programme folders, ledger, budget block) is gone (caddis-next Phase 7).
6
6
 
7
- One session: stop checks (STOP file, session, hour and dollar caps); for agy, a reservation under the global spend cap
8
- (`caddis_spend.py`, settled after the session); read the relay hash; launch ONE session through the governor with the
7
+ One session: stop checks (STOP file, session, hour and dollar caps); for agy, a pending line in the usage log
8
+ (`caddis_spend.py`, settled after the session; there is no EUR cap, only an ADVISORY line); read the relay hash; launch ONE session through the governor with the
9
9
  resume prompt and `CADDIS_HEADLESS=1` in its environment; parse its JSON result (cost, error); read the relay status
10
- line; decide. CONTINUE with an unchanged relay is `FAILED no progress`; three sessions in a row with no newly closed
10
+ line; decide. A relay the session did not change (same hash as before it, any status line) is `FAILED no relay
11
+ written`, so a status an earlier session wrote is never acted on again; three sessions in a row with no newly closed
11
12
  row is `BLOCKED stuck`.
12
13
 
13
14
  Plan mode (`--plan <slug>`, decision D-I, design section 8.5) runs `.caddis/plans/<slug>.md`. A closed row in its
@@ -100,10 +101,10 @@ Session output, relay text and every log line, printed stop line, toast and push
100
101
  The runner never passes an owner gate, never raises a cap and never deletes a STOP file.
101
102
 
102
103
  Exit codes: 0 stopped at a status the session wrote (plan mode: OWNER-GATE, BLOCKED), or at a STOP file after a
103
- session; 1 a FAILED stop, a cap, the agy spend cap, a usage limit, `BLOCKED stuck`, `BLOCKED nothing ready`,
104
+ session; 1 a FAILED stop, a cap, an agy spend log error, a usage limit, `BLOCKED stuck`, `BLOCKED nothing ready`,
104
105
  `BLOCKED waiting for merge`, `BLOCKED review`, `BLOCKED review not run`, `BLOCKED rollup not run` (a rollup exit 3,
105
106
  for example an exit check that cannot run in the merged checkout; not restartable by the recheck task), or the
106
- snapshot guard; 3 never started (lock, STOP file, no governor, agy spend cap not configured, another host, a plan a roadmap runner holds); 4 bad input (no plan or roadmap, both, a bad slug, no prompt template,
107
+ snapshot guard; 3 never started (lock, STOP file, no governor, another host, a plan a roadmap runner holds); 4 bad input (no plan or roadmap, both, a bad slug, no prompt template,
107
108
  bad engine).
108
109
 
109
110
  Engines: `claude` is built and live-tested. `agy` and `codex` are command-line adapters with unit tests only (not
@@ -911,7 +912,7 @@ def _one_session(ctx: _Ctx, prompt: str, relay_slug: str, n: int, spent: float,
911
912
  usd = min(caps.max_usd_per_session, caps.max_usd_total - spent)
912
913
  cmd = build_command(ctx.engine, ctx.model, prompt, usd=usd, timeout_min=remaining_s / 60, governor=ctx.governor,
913
914
  engine_cmd=ctx.engine_cmd, worktree=cwd)
914
- rid = _spend_reserve(ctx.home, spend_slug, ctx.now(), n > 1) if ctx.engine == "agy" else None
915
+ rid = _spend_reserve(ctx.home, spend_slug, ctx.now()) if ctx.engine == "agy" else None
915
916
  if ctx.engine == "agy": # agy's tool consoles open on a hidden desktop, not on the owner's screen
916
917
  g = len(ctx.governor)
917
918
  cmd = [*cmd[:g], *caddis_spend.hidden_argv(cmd[g:], session_env())]
@@ -1317,8 +1318,6 @@ def _run_plan(ctx: _Ctx, template: Path, dry_run: bool, after_session: Callable[
1317
1318
  raise held
1318
1319
  _dry_lock_check(lock.path)
1319
1320
  ctx.checks(0, 0.0, 0.0)
1320
- if ctx.engine == "agy":
1321
- _spend_preview(ctx.home, ctx.now())
1322
1321
  except _Stop as stop:
1323
1322
  print(f"would stop: {caddis_redact.redact(stop.reason, masks)}")
1324
1323
  return caddis_exit.NOT_RUN
@@ -1854,8 +1853,6 @@ def _run_roadmap(ctx: _Ctx, template: Path, dry_run: bool, after_session: Callab
1854
1853
  try:
1855
1854
  _dry_lock_check(lock.path)
1856
1855
  ctx.checks(0, 0.0, 0.0)
1857
- if ctx.engine == "agy":
1858
- _spend_preview(ctx.home, ctx.now())
1859
1856
  try:
1860
1857
  batch, snap = caddis_roadmap.next_with_snapshot(repo, slug)
1861
1858
  except caddis_roadmap.RoadmapError as exc:
@@ -2331,28 +2328,25 @@ def _publish_and_wait(ctx: _Ctx, repo: Path, slug: str, mid: str, plan: str, pha
2331
2328
  raise _Stop(f"{WAITING_PREFIX} {ref} {url}", caddis_exit.BLOCKED)
2332
2329
 
2333
2330
 
2334
- def _spend_reserve(home: Path, slug: str, moment: datetime, started: bool) -> str:
2335
- """Book one agy session under the global spend cap (caddis_spend.py); _Stop when the cap refuses it or cannot be
2336
- read (a file error never crashes the runner: the stop is logged and notified, redacted, like any other).
2337
- The caller name in the spend log is `runner-<slug>`."""
2331
+ def _spend_reserve(home: Path, slug: str, moment: datetime) -> str:
2332
+ """Write the pending line of one agy session to the usage log (caddis_spend.py; there is no cap). _Stop only when
2333
+ the log cannot be locked or written (a file error never crashes the runner: the stop is logged and notified,
2334
+ redacted, like any other). The caller name in the spend log is `runner-<slug>`. At or above the advise level it
2335
+ prints the ADVISORY line and goes on."""
2338
2336
  try:
2339
2337
  rid = caddis_spend.reserve(home, f"runner-{slug}", moment)
2340
- except caddis_spend.NotConfigured:
2341
- code = caddis_exit.BLOCKED if started else caddis_exit.NOT_RUN
2342
- raise _Stop("FAILED spend cap not configured", code) from None
2343
2338
  except TimeoutError:
2344
- raise _Stop("BLOCKED spend cap lock busy", caddis_exit.BLOCKED) from None
2339
+ raise _Stop("BLOCKED spend log lock busy", caddis_exit.BLOCKED) from None
2345
2340
  except Exception as exc:
2346
- raise _Stop(f"FAILED spend cap error: {exc!r}", caddis_exit.BLOCKED) from None
2347
- if rid is None:
2348
- raise _Stop("BLOCKED spend cap", caddis_exit.BLOCKED)
2341
+ raise _Stop(f"FAILED spend log error: {exc!r}", caddis_exit.BLOCKED) from None
2342
+ caddis_spend.advise(home, moment)
2349
2343
  return rid
2350
2344
 
2351
2345
 
2352
2346
  def _spend_settle(home: Path, rid: str, cmd: Sequence[str], outcome: "_Outcome | None", moment: datetime,
2353
2347
  duration_s: float) -> None:
2354
- """Record the session's real cost: (0, 0) when it never started, its reserve (estimated) when there is no outcome
2355
- (an exception) or no readable token counts."""
2348
+ """Record the session's real cost: (0, 0) when it never started, estimated when there is no outcome (an
2349
+ exception) or no readable token counts."""
2356
2350
  try:
2357
2351
  if outcome is None:
2358
2352
  usage_counts = None
@@ -2363,23 +2357,10 @@ def _spend_settle(home: Path, rid: str, cmd: Sequence[str], outcome: "_Outcome |
2363
2357
  else:
2364
2358
  usage_counts = None
2365
2359
  caddis_spend.settle(home, rid, usage_counts, moment, duration_s=duration_s)
2366
- except Exception as exc: # the pending reserve keeps counting for 24 h; never lose the session's result
2360
+ except Exception as exc: # the pending line stays unsettled; never lose the session's result
2367
2361
  print(f"caddis_roadmap_run: could not settle spend {rid}: {exc}", file=sys.stderr)
2368
2362
 
2369
2363
 
2370
- def _spend_preview(home: Path, moment: datetime) -> None:
2371
- """The dry run's read-only spend check: the same stops as _spend_reserve, with no pending line written."""
2372
- try:
2373
- cap = caddis_spend.load_cap(home)
2374
- over = caddis_spend.committed_last_24h(home, moment) + cap.reserve > cap.eur_per_24h
2375
- except caddis_spend.NotConfigured:
2376
- raise _Stop("FAILED spend cap not configured", caddis_exit.NOT_RUN) from None
2377
- except Exception as exc:
2378
- raise _Stop(f"FAILED spend cap error: {exc!r}", caddis_exit.NOT_RUN) from None
2379
- if over:
2380
- raise _Stop("BLOCKED spend cap", caddis_exit.BLOCKED)
2381
-
2382
-
2383
2364
  @dataclass
2384
2365
  class _Outcome:
2385
2366
  code: int
@@ -2406,19 +2387,20 @@ def _launch(cmd: list[str], cwd: Path, timeout_s: float, stdin_text: str | None
2406
2387
 
2407
2388
  def _decide(engine: str, outcome: _Outcome, result: dict | None, relay_text: str, hash_before: str | None,
2408
2389
  hash_after: str | None) -> _Stop | None:
2409
- """None to go on; else the stop. A missing or bad status line is FAILED, never CONTINUE (design 8.1)."""
2390
+ """None to go on; else the stop. A missing or bad status line is FAILED, never CONTINUE (design 8.1). A relay
2391
+ this session did not change is FAILED whatever its status: its line belongs to an earlier session (audit 10)."""
2410
2392
  failed = _session_failed(engine, outcome, result)
2411
2393
  if failed is not None:
2412
2394
  return failed
2413
2395
  if hash_after is None:
2414
2396
  return _Stop("FAILED no relay", caddis_exit.BLOCKED)
2397
+ if hash_after == hash_before:
2398
+ return _Stop("FAILED no relay written", caddis_exit.BLOCKED)
2415
2399
  try:
2416
2400
  kind, arg = caddis_workstreams.parse_status(relay_text)
2417
2401
  except ValueError as exc:
2418
2402
  return _Stop(f"FAILED bad status line: {exc}", caddis_exit.BLOCKED)
2419
2403
  if kind == "CONTINUE":
2420
- if hash_after == hash_before:
2421
- return _Stop("FAILED no progress", caddis_exit.BLOCKED)
2422
2404
  return None
2423
2405
  if kind == "FAILED":
2424
2406
  return _Stop(f"FAILED {arg}", caddis_exit.BLOCKED, from_relay=True, status=(kind, arg))
@@ -22,7 +22,7 @@ DEFAULT_ROUTING: dict[str, list[str]] = {
22
22
  "critical": ["opus"],
23
23
  "light": ["sonnet"],
24
24
  "coding": ["agy"],
25
- "review": ["deepseek", "glm"], # owner order 2026-10-16; an agy review runs through caddis_spend.py
25
+ "review": ["deepseek", "glm"], # owner order 2026-10-16; an agy review runs through caddis_spend.py run (no cap)
26
26
  "consult": ["agy", "glm"],
27
27
  "ci-watch": ["agy"],
28
28
  "mechanical": ["haiku"],