cctally 1.114.0 → 1.116.0

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 (86) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/bin/_cctally_account.py +32 -8
  3. package/bin/_cctally_cache.py +4491 -295
  4. package/bin/_cctally_completion.py +1355 -0
  5. package/bin/_cctally_config.py +37 -0
  6. package/bin/_cctally_core.py +282 -9
  7. package/bin/_cctally_dashboard.py +8 -11
  8. package/bin/_cctally_dashboard_conversation.py +292 -23
  9. package/bin/_cctally_dashboard_envelope.py +42 -35
  10. package/bin/_cctally_dashboard_sources.py +18 -9
  11. package/bin/_cctally_db.py +401 -9
  12. package/bin/_cctally_doctor.py +469 -27
  13. package/bin/_cctally_five_hour.py +166 -1049
  14. package/bin/_cctally_forecast.py +81 -9
  15. package/bin/_cctally_journal.py +5076 -177
  16. package/bin/_cctally_journal_repair.py +110 -19
  17. package/bin/_cctally_oauth_samples.py +280 -0
  18. package/bin/_cctally_parser.py +47 -0
  19. package/bin/_cctally_project.py +8 -2
  20. package/bin/_cctally_quarantine.py +662 -0
  21. package/bin/_cctally_quota.py +96 -12
  22. package/bin/_cctally_quota_model.py +391 -83
  23. package/bin/_cctally_record.py +1088 -269
  24. package/bin/_cctally_rederive.py +854 -192
  25. package/bin/_cctally_refresh.py +113 -13
  26. package/bin/_cctally_source_analytics.py +23 -2
  27. package/bin/_cctally_statusline.py +7062 -505
  28. package/bin/_cctally_store.py +1244 -91
  29. package/bin/_cctally_transcript.py +8 -7
  30. package/bin/_cctally_tui.py +119 -60
  31. package/bin/_cctally_update.py +25 -0
  32. package/bin/_lib_account_binding.py +152 -0
  33. package/bin/_lib_account_protocol.py +569 -0
  34. package/bin/_lib_aggregators.py +4 -0
  35. package/bin/_lib_cache_coverage.py +13 -1
  36. package/bin/_lib_cache_writer_lock.py +19 -3
  37. package/bin/_lib_clone_copy.py +177 -0
  38. package/bin/_lib_codex_conversation_query.py +133 -19
  39. package/bin/_lib_codex_conversation_watch.py +59 -14
  40. package/bin/_lib_codex_drain_admission.py +214 -0
  41. package/bin/_lib_codex_metadata.py +18 -1
  42. package/bin/_lib_codex_publication_barrier.py +277 -0
  43. package/bin/_lib_codex_rollout_container.py +502 -0
  44. package/bin/_lib_conversation_dispatch.py +3 -0
  45. package/bin/_lib_conversation_query.py +11 -3
  46. package/bin/_lib_dashboard_sources.py +57 -15
  47. package/bin/_lib_detector_access_registry.py +4038 -0
  48. package/bin/_lib_doctor.py +753 -1
  49. package/bin/_lib_five_hour.py +126 -0
  50. package/bin/_lib_ingest_frontier.py +414 -20
  51. package/bin/_lib_journal.py +261 -10
  52. package/bin/_lib_journal_router.py +166 -48
  53. package/bin/_lib_jsonl.py +5 -4
  54. package/bin/_lib_legacy_spool.py +126 -0
  55. package/bin/_lib_legacy_writer_evidence.py +136 -0
  56. package/bin/_lib_meter_rate_change.py +10 -0
  57. package/bin/_lib_oauth_samples.py +238 -0
  58. package/bin/_lib_outcome_quarantine.py +690 -0
  59. package/bin/_lib_pricing.py +7 -2
  60. package/bin/_lib_pricing_check.py +0 -12
  61. package/bin/_lib_provider_activity.py +770 -0
  62. package/bin/_lib_quarantine.py +155 -0
  63. package/bin/_lib_quota_calibration.py +53 -8
  64. package/bin/_lib_quota_copy.py +2 -1
  65. package/bin/_lib_quota_model.py +384 -52
  66. package/bin/_lib_rebuild_progress.py +146 -0
  67. package/bin/_lib_record.py +22 -0
  68. package/bin/_lib_rederive.py +393 -8
  69. package/bin/_lib_segment_summary.py +35 -2
  70. package/bin/_lib_snapshot_cache.py +43 -1
  71. package/bin/_lib_stale_proof.py +708 -0
  72. package/bin/_lib_statusline_candidates.py +356 -27
  73. package/bin/_lib_worker_launches.py +315 -0
  74. package/bin/cctally +29 -12
  75. package/dashboard/static/assets/{ConversationsView-Bc8LCOAZ.js → ConversationsView-Dflb_myA.js} +1 -1
  76. package/dashboard/static/assets/DoctorModal-DFX5CfIs.js +1 -0
  77. package/dashboard/static/assets/{ModalRoot-DLPgyAM_.js → ModalRoot-HlxoagIa.js} +1 -1
  78. package/dashboard/static/assets/{ProjectsDrillPanel-z53a4v4M.js → ProjectsDrillPanel-C3PJy1xx.js} +1 -1
  79. package/dashboard/static/assets/{SourceDetailModal-Bw0T8W-W.js → SourceDetailModal-BczsWKhD.js} +1 -1
  80. package/dashboard/static/assets/{UpdateModal-D5AKx4Yw.js → UpdateModal-Os-Lo5cs.js} +1 -1
  81. package/dashboard/static/assets/{index-BXDOzSng.js → index-CYZ3NLqF.js} +3 -3
  82. package/dashboard/static/assets/{outlineNavigation-JObY7cUY.js → outlineNavigation-k-zIif6W.js} +1 -1
  83. package/dashboard/static/dashboard.html +1 -1
  84. package/package.json +20 -2
  85. package/bin/_lib_merge_gate.py +0 -725
  86. package/dashboard/static/assets/DoctorModal-D--qVBwe.js +0 -1
@@ -0,0 +1,315 @@
1
+ """The launch ledger of the detached stats rebuild workers (#997, spec D8).
2
+
3
+ On 2026-10-22 an epoch-rebuild worker ran for hours and nothing recorded
4
+ whether one worker ran throughout or one died and another replaced it: the log
5
+ held only returned outcomes. Each worker (the epoch rebuild and the corruption
6
+ heal) now keeps two private records in ``APP_DIR``: a run state, written only
7
+ by the holder of the worker flock, and this launch ledger, written only under
8
+ the worker's admission flock. This module is the pure kernel that decides what
9
+ became of each launch; spawners, workers, ``doctor`` and ``db status`` all
10
+ classify through it, and only spawners and workers persist the result.
11
+
12
+ The central rule: **a death is settled by evidence, never by elapsed time.**
13
+ An unsettled entry is settled when
14
+
15
+ (a) the run state shows its ``launchId`` finished, which transfers that
16
+ outcome as ``finished:<outcome>``, or records its in-run death; or
17
+ (b) its process is confirmed gone by identity — absent, a zombie, or a live
18
+ pid whose ``birth`` differs — which settles ``died-pre-start`` without a
19
+ start acknowledgement and ``died-in-run`` with one. The caller probes the
20
+ identities BEFORE it reads the files it passes here, so a re-read after the
21
+ probe is what this function sees.
22
+
23
+ A process that is alive, or whose liveness is unknown (``ps`` failing, a live
24
+ pid with a null ``birth``), stays unresolved however old the entry is: a slow
25
+ child is never declared dead.
26
+
27
+ Ledger shape (``schemaVersion`` 1)::
28
+
29
+ {"schemaVersion": 1,
30
+ "entries": [{"launchId", "at", "pid", "birth",
31
+ "spawn": "reserved"|"ok"|"failed",
32
+ "ack": None | {"kind": "started", "runId", "at"}
33
+ | {"kind": "busy", "at"},
34
+ "outcome": None | <terminal>, "settledAt"}],
35
+ "counts": {<terminal>: int}, # cumulative, survives pruning
36
+ "lastDeathAt": str | None}
37
+
38
+ ``pid`` and ``birth`` are null while ``spawn`` is ``reserved``; ``birth`` may
39
+ stay null after it (``ps`` could not see the child). Unresolved entries are
40
+ never dropped: the spawner admits no launch while ``LAUNCH_CAPACITY`` are
41
+ unresolved (``has_launch_capacity``), which is what bounds them.
42
+
43
+ ``<terminal>`` is ``finished:<worker outcome>``, ``busy``, ``spawn-failed``,
44
+ ``died-pre-start`` or ``died-in-run``. Every function returns a new ledger and
45
+ never mutates its input. Stdlib only, and importable on its own.
46
+ """
47
+ from __future__ import annotations
48
+
49
+ import copy
50
+
51
+ SCHEMA_VERSION = 1
52
+ #: Unresolved entries at which the spawner withholds further launches.
53
+ LAUNCH_CAPACITY = 100
54
+ #: Settled entries kept (the most recent); ``counts`` keeps the totals.
55
+ SETTLED_KEEP = 10
56
+ DEATHS = ("died-pre-start", "died-in-run")
57
+
58
+
59
+ def empty_ledger() -> dict:
60
+ return {
61
+ "schemaVersion": SCHEMA_VERSION,
62
+ "entries": [],
63
+ "counts": {},
64
+ "lastDeathAt": None,
65
+ }
66
+
67
+
68
+ def normalize(ledger) -> dict:
69
+ """A validated deep copy of ``ledger``; ``ValueError`` when malformed."""
70
+ if not isinstance(ledger, dict):
71
+ raise ValueError("launch ledger is not an object")
72
+ if ledger.get("schemaVersion") != SCHEMA_VERSION:
73
+ raise ValueError("unsupported launch ledger schemaVersion")
74
+ entries = ledger.get("entries", [])
75
+ if not isinstance(entries, list) or not all(
76
+ isinstance(e, dict) and isinstance(e.get("launchId"), str)
77
+ for e in entries):
78
+ raise ValueError("launch ledger entries are malformed")
79
+ counts = ledger.get("counts") or {}
80
+ if not isinstance(counts, dict) or not all(
81
+ isinstance(k, str) and isinstance(v, int)
82
+ for k, v in counts.items()):
83
+ raise ValueError("launch ledger counts are malformed")
84
+ last_death = ledger.get("lastDeathAt")
85
+ if last_death is not None and not isinstance(last_death, str):
86
+ raise ValueError("launch ledger lastDeathAt is malformed")
87
+ out = empty_ledger()
88
+ out["entries"] = [_entry(**{k: e.get(k) for k in _ENTRY_KEYS})
89
+ for e in copy.deepcopy(entries)]
90
+ out["counts"] = dict(counts)
91
+ out["lastDeathAt"] = last_death
92
+ return out
93
+
94
+
95
+ _ENTRY_KEYS = ("launchId", "at", "pid", "birth", "spawn", "ack", "outcome",
96
+ "settledAt")
97
+
98
+
99
+ def _entry(launchId, at, pid, birth, spawn="ok", ack=None, outcome=None,
100
+ settledAt=None) -> dict:
101
+ return {
102
+ "launchId": launchId, "at": at, "pid": pid, "birth": birth,
103
+ "spawn": spawn or "ok", "ack": ack, "outcome": outcome,
104
+ "settledAt": settledAt,
105
+ }
106
+
107
+
108
+ def find(ledger: dict, launch_id: str) -> "dict | None":
109
+ for entry in ledger.get("entries", ()):
110
+ if entry.get("launchId") == launch_id:
111
+ return entry
112
+ return None
113
+
114
+
115
+ def unresolved(ledger: dict) -> list:
116
+ return [e for e in ledger.get("entries", ()) if not e.get("outcome")]
117
+
118
+
119
+ def newest(ledger: dict) -> "dict | None":
120
+ """The newest launch in ledger (launch) order."""
121
+ entries = ledger.get("entries") or []
122
+ return entries[-1] if entries else None
123
+
124
+
125
+ def _settle_in_place(ledger: dict, entry: dict, terminal: str, at) -> bool:
126
+ if entry.get("outcome"):
127
+ return False
128
+ entry["outcome"] = terminal
129
+ entry["settledAt"] = at
130
+ counts = ledger.setdefault("counts", {})
131
+ counts[terminal] = int(counts.get(terminal, 0)) + 1
132
+ if terminal in DEATHS:
133
+ ledger["lastDeathAt"] = at or entry.get("at")
134
+ return True
135
+
136
+
137
+ def append_entry(ledger: dict, *, launch_id: str, at, pid, birth,
138
+ spawn: str = "ok") -> dict:
139
+ """Record a launch. A launch id already present is left as it is (the
140
+ worker's own acknowledgement may have recorded it first). A failed spawn
141
+ is settled at once as ``spawn-failed``."""
142
+ out = copy.deepcopy(ledger)
143
+ if find(out, launch_id) is not None:
144
+ return out
145
+ entry = _entry(launch_id, at, pid, birth, spawn=spawn)
146
+ out.setdefault("entries", []).append(entry)
147
+ if spawn == "failed":
148
+ _settle_in_place(out, entry, "spawn-failed", at)
149
+ return out
150
+
151
+
152
+ def reserve(ledger: dict, *, launch_id: str, at) -> dict:
153
+ """The spawner's reservation, persisted BEFORE the spawn (revision 6): a
154
+ spawner killed after it leaves an entry with no pid, which stays
155
+ unresolved with unknown liveness until the child acknowledges."""
156
+ out = copy.deepcopy(ledger)
157
+ if find(out, launch_id) is None:
158
+ out.setdefault("entries", []).append(
159
+ _entry(launch_id, at, None, None, spawn="reserved"))
160
+ return out
161
+
162
+
163
+ def fill_spawn(ledger: dict, launch_id: str, *, pid, birth, at,
164
+ spawn: str = "ok") -> dict:
165
+ """Complete a reservation with the spawn's result. A failed spawn is
166
+ settled at once as ``spawn-failed``. An identity the worker already
167
+ recorded at acknowledgement is never overwritten."""
168
+ out = copy.deepcopy(ledger)
169
+ entry = find(out, launch_id)
170
+ if entry is None:
171
+ out.setdefault("entries", []).append(
172
+ _entry(launch_id, at, None, None, spawn="reserved"))
173
+ entry = out["entries"][-1]
174
+ if spawn == "failed":
175
+ if entry.get("spawn") == "reserved":
176
+ entry["spawn"] = "failed"
177
+ _settle_in_place(out, entry, "spawn-failed", at)
178
+ return out
179
+ if entry.get("pid") is None:
180
+ entry["pid"] = pid
181
+ entry["birth"] = birth
182
+ if entry.get("spawn") == "reserved":
183
+ entry["spawn"] = "ok"
184
+ return out
185
+
186
+
187
+ def acknowledge(ledger: dict, launch_id: str, kind: str, run_id=None, *,
188
+ at, pid=None, birth=None) -> dict:
189
+ """A worker's acknowledgement: ``started`` (with its ``runId``) or
190
+ ``busy`` (which is also the entry's terminal). Fills the worker's own
191
+ ``pid`` and ``birth`` into a reservation the spawner never completed, and
192
+ appends the entry when there is none (a ledger lost to the unreadable
193
+ archive path)."""
194
+ out = copy.deepcopy(ledger)
195
+ entry = find(out, launch_id)
196
+ if entry is None:
197
+ entry = _entry(launch_id, at, pid, birth)
198
+ out.setdefault("entries", []).append(entry)
199
+ elif entry.get("pid") is None and pid is not None:
200
+ entry["pid"] = pid
201
+ entry["birth"] = birth
202
+ if entry.get("spawn") == "reserved":
203
+ entry["spawn"] = "ok"
204
+ if kind == "started":
205
+ entry["ack"] = {"kind": "started", "runId": run_id, "at": at}
206
+ elif kind == "busy":
207
+ entry["ack"] = {"kind": "busy", "at": at}
208
+ _settle_in_place(out, entry, "busy", at)
209
+ else:
210
+ raise ValueError(f"unknown acknowledgement kind {kind!r}")
211
+ return out
212
+
213
+
214
+ def settle(ledger: dict, launch_id: str, terminal: str, *, at) -> dict:
215
+ """Give an entry its terminal outcome; the first settlement wins."""
216
+ out = copy.deepcopy(ledger)
217
+ entry = find(out, launch_id)
218
+ if entry is not None:
219
+ _settle_in_place(out, entry, terminal, at)
220
+ return out
221
+
222
+
223
+ def liveness(entry: dict, identities: dict) -> str:
224
+ """``alive`` | ``gone`` | ``unknown`` for a ledger entry or a run (both
225
+ carry ``pid`` and ``birth``), from ``process_identity`` results."""
226
+ pid = entry.get("pid")
227
+ if not isinstance(pid, int) or isinstance(pid, bool) or pid <= 0:
228
+ return "unknown"
229
+ identity = identities.get(pid)
230
+ if not isinstance(identity, dict):
231
+ return "unknown"
232
+ status = identity.get("status")
233
+ if status == "gone":
234
+ return "gone"
235
+ if status != "alive":
236
+ return "unknown"
237
+ entry_birth, live_birth = entry.get("birth"), identity.get("birth")
238
+ if entry_birth and live_birth and entry_birth != live_birth:
239
+ return "gone" # the pid now names a different process
240
+ if not entry_birth or not live_birth:
241
+ return "unknown"
242
+ return "alive"
243
+
244
+
245
+ def classify(ledger: dict, state, identities: dict, *, now=None) -> dict:
246
+ """Settle what the evidence settles. Returns ``{"ledger", "settled"}``,
247
+ ``settled`` being the newly settled entries (copies). Never settles by
248
+ age; see the module docstring for rules (a) and (b)."""
249
+ out = copy.deepcopy(ledger)
250
+ run = state.get("run") if isinstance(state, dict) else None
251
+ run = run if isinstance(run, dict) else None
252
+ deaths = state.get("deaths") if isinstance(state, dict) else None
253
+ # A death whose ``launchId`` is not a string (a corrupt record in a
254
+ # state that still validates) settles nothing.
255
+ died_in_run = {d.get("launchId") for d in (deaths or ())
256
+ if isinstance(d, dict) and isinstance(d.get("launchId"), str)
257
+ and d.get("launchId")}
258
+ settled = []
259
+ for entry in out.get("entries", []):
260
+ if entry.get("outcome"):
261
+ continue
262
+ launch_id = entry.get("launchId")
263
+ terminal = None
264
+ if (run is not None and run.get("launchId") == launch_id
265
+ and run.get("status") == "finished"):
266
+ terminal = f"finished:{run.get('outcome')}"
267
+ elif launch_id in died_in_run:
268
+ terminal = "died-in-run"
269
+ elif liveness(entry, identities) == "gone":
270
+ ack = entry.get("ack")
271
+ started = isinstance(ack, dict) and ack.get("kind") == "started"
272
+ terminal = "died-in-run" if started else "died-pre-start"
273
+ if terminal is not None and _settle_in_place(out, entry, terminal,
274
+ now):
275
+ settled.append(copy.deepcopy(entry))
276
+ return {"ledger": out, "settled": settled}
277
+
278
+
279
+ def _protected_ids(protected_launch_ids) -> frozenset:
280
+ if isinstance(protected_launch_ids, str):
281
+ return frozenset({protected_launch_ids})
282
+ if not isinstance(protected_launch_ids, (list, tuple, set, frozenset)):
283
+ return frozenset()
284
+ return frozenset(i for i in protected_launch_ids if isinstance(i, str))
285
+
286
+
287
+ def prune(ledger: dict, protected_launch_ids=None) -> dict:
288
+ """Bound the settled entries to the newest ``SETTLED_KEEP``, in ledger
289
+ order. Unresolved entries are never dropped (``has_launch_capacity``
290
+ bounds them); ``counts`` and ``lastDeathAt`` are kept.
291
+
292
+ ``protected_launch_ids`` (one id, or an iterable of them; a non-string
293
+ member protects nothing) names the entries a run state references or is
294
+ about to: the current ``run.launchId`` and, for a worker whose own state
295
+ write has not landed yet, its own launch as well. Each is exempt from the
296
+ bound, because the slot's entry is the record that makes the next
297
+ worker's death accounting exactly-once, and the settled bound then counts
298
+ them plus ``SETTLED_KEEP`` minus their number of others."""
299
+ out = copy.deepcopy(ledger)
300
+ entries = out.get("entries", [])
301
+ wanted = _protected_ids(protected_launch_ids)
302
+ protected = {id(e) for e in entries if e.get("launchId") in wanted}
303
+ done_ids = [id(e) for e in entries
304
+ if e.get("outcome") and id(e) not in protected]
305
+ settled_room = max(0, SETTLED_KEEP - sum(
306
+ 1 for e in entries if id(e) in protected and e.get("outcome")))
307
+ dropped = set(done_ids[:max(0, len(done_ids) - settled_room)])
308
+ out["entries"] = [e for e in entries if id(e) not in dropped]
309
+ return out
310
+
311
+
312
+ def has_launch_capacity(ledger: dict) -> bool:
313
+ """Whether the spawner may admit another launch: fewer than
314
+ ``LAUNCH_CAPACITY`` entries are unresolved."""
315
+ return len(unresolved(ledger)) < LAUNCH_CAPACITY
package/bin/cctally CHANGED
@@ -404,7 +404,6 @@ diff_pricing = _lib_pricing_check.diff_pricing
404
404
  stale_allowlist_entries = _lib_pricing_check.stale_allowlist_entries
405
405
  expired_allowlist_entries = _lib_pricing_check.expired_allowlist_entries
406
406
  check_table_shapes = _lib_pricing_check.check_table_shapes
407
- pricing_issue_action = _lib_pricing_check.pricing_issue_action
408
407
  CoverageGap = _lib_pricing_check.CoverageGap
409
408
  DriftRow = _lib_pricing_check.DriftRow
410
409
  DriftResult = _lib_pricing_check.DriftResult
@@ -553,6 +552,8 @@ _FIVE_HOUR_JITTER_FLOOR_SECONDS = _lib_five_hour._FIVE_HOUR_JITTER_FLOOR_SECONDS
553
552
  _floor_to_ten_minutes = _lib_five_hour._floor_to_ten_minutes
554
553
  _round_to_ten_minutes = _lib_five_hour._round_to_ten_minutes
555
554
  _canonical_5h_window_key = _lib_five_hour._canonical_5h_window_key
555
+ FiveHourReading = _lib_five_hour.FiveHourReading
556
+ latest_five_hour_reading = _lib_five_hour.latest_five_hour_reading
556
557
 
557
558
  _lib_subscription_weeks = _load_sibling("_lib_subscription_weeks")
558
559
  SubWeek = _lib_subscription_weeks.SubWeek
@@ -1170,6 +1171,7 @@ _collect_codex_entries_direct = _cctally_cache._collect_codex_entries_direct
1170
1171
  get_codex_entries = _cctally_cache.get_codex_entries
1171
1172
  _sum_codex_cost_for_range = _cctally_cache._sum_codex_cost_for_range
1172
1173
  get_entries = _cctally_cache.get_entries
1174
+ CodexHistoryUnavailable = _cctally_cache.CodexHistoryUnavailable
1173
1175
  AccountAttributionUnavailable = _cctally_cache.AccountAttributionUnavailable
1174
1176
  open_cache_db = _cctally_cache.open_cache_db
1175
1177
  open_conversations_db = _cctally_cache.open_conversations_db
@@ -1190,6 +1192,7 @@ sync_codex_conversations = _cctally_cache.sync_codex_conversations
1190
1192
  _reset_orphan_warning_throttle = _cctally_cache._reset_orphan_warning_throttle
1191
1193
  cmd_cache_sync = _cctally_cache.cmd_cache_sync
1192
1194
  cmd_codex_replay_drain_internal = _cctally_cache.cmd_codex_replay_drain_internal
1195
+ cmd_codex_prune_drain_internal = _cctally_cache.cmd_codex_prune_drain_internal
1193
1196
 
1194
1197
 
1195
1198
  # Record-usage / hook-tick hot-path subsystem — the runtime path that
@@ -1220,6 +1223,7 @@ maybe_record_codex_budget_milestone = _cctally_record.maybe_record_codex_budget_
1220
1223
  maybe_record_projected_alert = _cctally_record.maybe_record_projected_alert
1221
1224
  _weekly_pct_week_avg_projection = _cctally_record._weekly_pct_week_avg_projection
1222
1225
  _compute_block_totals = _cctally_record._compute_block_totals
1226
+ _block_pricing_provenance_json = _cctally_record._block_pricing_provenance_json
1223
1227
  # #620 S2 E2: the pure fold lifted out of _compute_block_totals, plus the
1224
1228
  # canonical priced record and bucket shapes it folds over.
1225
1229
  PricedEntry = _cctally_record.PricedEntry
@@ -1228,6 +1232,7 @@ BlockTotals = _cctally_record.BlockTotals
1228
1232
  fold_block_totals = _cctally_record.fold_block_totals
1229
1233
  maybe_update_five_hour_block = _cctally_record.maybe_update_five_hour_block
1230
1234
  cmd_record_usage = _cctally_record.cmd_record_usage
1235
+ record_usage_bound = _cctally_record.record_usage_bound
1231
1236
  CreditPlan = _cctally_record.CreditPlan
1232
1237
  _parse_credit_at = _cctally_record._parse_credit_at
1233
1238
  _build_credit_plan = _cctally_record._build_credit_plan
@@ -1235,6 +1240,9 @@ _resolve_reset_aware_hwm = _cctally_record._resolve_reset_aware_hwm
1235
1240
  _insert_credit_snapshot = _cctally_record._insert_credit_snapshot
1236
1241
  _resolve_prior_5h = _cctally_record._resolve_prior_5h
1237
1242
  _resolve_active_five_hour_reset_event_id = _cctally_record._resolve_active_five_hour_reset_event_id
1243
+ resolve_five_hour_reset_event = _cctally_record.resolve_five_hour_reset_event
1244
+ FiveHourResetEvent = _cctally_record.FiveHourResetEvent
1245
+ NoFiveHourResetEvent = _cctally_record.NoFiveHourResetEvent
1238
1246
  _apply_credit = _cctally_record._apply_credit
1239
1247
  _fire_in_place_credit = _cctally_record._fire_in_place_credit
1240
1248
  detect_reset_and_credit = _cctally_record.detect_reset_and_credit
@@ -1249,13 +1257,11 @@ _delete_doomed_snapshot_rows = _cctally_record._delete_doomed_snapshot_rows
1249
1257
  # #834 S1 (#835) Gate A R4: the band is a connection-taking builder now,
1250
1258
  # because the held predicate is omitted on a store predating the column.
1251
1259
  _stale_replica_band_sql = _cctally_record._stale_replica_band_sql
1252
- # #834 S1 (#835): the read-side twin of the band above — which weekly
1253
- # values a week's credits retired, and the predicate that recognizes one.
1254
- # `_latest_seven_day_and_window` reaches both through this namespace.
1260
+ # #834 S1 (#835): a week's credits and their floors.
1261
+ # `_latest_seven_day_and_window` reaches both through this namespace for its
1262
+ # credit-floor bound (the retirement band itself was removed by #840).
1255
1263
  _credit_retirement_bands = _cctally_record._credit_retirement_bands
1256
1264
  _latest_credit_floor_instant = _cctally_record._latest_credit_floor_instant
1257
- _weekly_value_is_retired_replica = (
1258
- _cctally_record._weekly_value_is_retired_replica)
1259
1265
  _stale_replay_candidates = _cctally_record._stale_replay_candidates
1260
1266
  _count_stale_replays = _cctally_record._count_stale_replays
1261
1267
  _credit_preview_text = _cctally_record._credit_preview_text
@@ -1597,11 +1603,9 @@ _format_block_start = _cctally_five_hour._format_block_start
1597
1603
  _format_hhmm_in_tz = _cctally_five_hour._format_hhmm_in_tz
1598
1604
  _block_is_active = _cctally_five_hour._block_is_active
1599
1605
  _latest_seven_day_and_window = _cctally_five_hour._latest_seven_day_and_window
1600
- # #834 S1 (#835) Gate A S1: the ONE read-time filter for a block's two
1601
- # weekly axes. Both five-hour commands reach it through this namespace.
1602
- _parsed_block_instant = _cctally_five_hour._parsed_block_instant
1603
- _block_weekly_start_instant = _cctally_five_hour._block_weekly_start_instant
1604
- _block_weekly_end_instant = _cctally_five_hour._block_weekly_end_instant
1606
+ # #834 S1 (#835) Gate A S1: the ONE read of a block's two weekly axes (the
1607
+ # stored values since #840). Both five-hour commands reach it through this
1608
+ # namespace.
1605
1609
  _credit_aware_block_weekly_axes = (
1606
1610
  _cctally_five_hour._credit_aware_block_weekly_axes)
1607
1611
  # #834 S1 (#836): the ONE five-hour milestone read, shared by the CLI
@@ -1624,6 +1628,11 @@ CLAUDE_MODEL_CONTEXT_WINDOWS = _cctally_statusline.CLAUDE_MODEL_CONTEXT_WINDOWS
1624
1628
  CLAUDE_MODEL_CONTEXT_WINDOW_DEFAULT_FAMILY = _cctally_statusline.CLAUDE_MODEL_CONTEXT_WINDOW_DEFAULT_FAMILY
1625
1629
  _resolve_statusline_tz = _cctally_statusline._resolve_statusline_tz
1626
1630
  cmd_statusline = _cctally_statusline.cmd_statusline
1631
+ # #825/#832 spec 4.3 revision 2: the hidden detached continuation worker and
1632
+ # dependency waiter.
1633
+ cmd_statusline_continue_internal = (
1634
+ _cctally_statusline.cmd_statusline_continue_internal
1635
+ )
1627
1636
  _resolve_context_window = _cctally_statusline._resolve_context_window
1628
1637
  _read_last_assistant_usage = _cctally_statusline._read_last_assistant_usage
1629
1638
  _build_statusline_injections = _cctally_statusline._build_statusline_injections
@@ -1655,6 +1664,8 @@ _authoritative_repair_required = _cctally_statusline._authoritative_repair_requi
1655
1664
  _after_authoritative_record = _cctally_statusline._after_authoritative_record
1656
1665
  _statusline_reduce_and_publish = _cctally_statusline._statusline_reduce_and_publish
1657
1666
  _build_publication_plan = _cctally_statusline._build_publication_plan
1667
+ _statusline_tombstone_states = _cctally_statusline._statusline_tombstone_states
1668
+ _capture_binding = _cctally_statusline._capture_binding
1658
1669
 
1659
1670
 
1660
1671
  # Eager re-export of bin/_cctally_codex.py — the four cmd_codex_* are the
@@ -1751,6 +1762,8 @@ BudgetRow = _cctally_forecast.BudgetRow
1751
1762
  _resolve_forecast_now = _cctally_forecast._resolve_forecast_now
1752
1763
  _fetch_current_week_snapshots = _cctally_forecast._fetch_current_week_snapshots
1753
1764
  _apply_midweek_reset_override = _cctally_forecast._apply_midweek_reset_override
1765
+ _current_week_five_hour_percent = _cctally_forecast._current_week_five_hour_percent
1766
+ _current_week_five_hour_reading = _cctally_forecast._current_week_five_hour_reading
1754
1767
  _resolve_current_budget_window = _cctally_forecast._resolve_current_budget_window
1755
1768
  _build_budget_status_inputs = _cctally_forecast._build_budget_status_inputs
1756
1769
  _build_vendor_budget_inputs = _cctally_forecast._build_vendor_budget_inputs
@@ -3666,6 +3679,9 @@ def main(argv: list[str] | None = None) -> int:
3666
3679
  # not print a partial report".
3667
3680
  eprint(f"cctally: {exc}")
3668
3681
  return 3
3682
+ except CodexHistoryUnavailable as exc:
3683
+ eprint(str(exc))
3684
+ return 3
3669
3685
  except AccountAttributionUnavailable as exc:
3670
3686
  # #341: a `--account`-scoped entry read hit a query-time cache degrade
3671
3687
  # (open failure / concurrent ingest) that would drop the account
@@ -3813,7 +3829,8 @@ def _post_command_update_hooks(command: str | None, args) -> None:
3813
3829
  return
3814
3830
  if command in ("_update-check", "_telemetry-beat", "_codex-quota-verify",
3815
3831
  "_stats-epoch-rebuild", "_stats-corruption-heal",
3816
- "_codex-replay-drain", "_artifact-retention"):
3832
+ "_codex-replay-drain", "_codex-prune-drain", "_artifact-retention",
3833
+ "_statusline-continue"):
3817
3834
  # All six hidden workers are detached and have already done their one job
3818
3835
  # in their own command handler; none must re-enter this hook.
3819
3836
  # Without the guard the ``_update-check`` worker would fall through to