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.
- package/CHANGELOG.md +41 -0
- package/bin/_cctally_account.py +32 -8
- package/bin/_cctally_cache.py +4491 -295
- package/bin/_cctally_completion.py +1355 -0
- package/bin/_cctally_config.py +37 -0
- package/bin/_cctally_core.py +282 -9
- package/bin/_cctally_dashboard.py +8 -11
- package/bin/_cctally_dashboard_conversation.py +292 -23
- package/bin/_cctally_dashboard_envelope.py +42 -35
- package/bin/_cctally_dashboard_sources.py +18 -9
- package/bin/_cctally_db.py +401 -9
- package/bin/_cctally_doctor.py +469 -27
- package/bin/_cctally_five_hour.py +166 -1049
- package/bin/_cctally_forecast.py +81 -9
- package/bin/_cctally_journal.py +5076 -177
- package/bin/_cctally_journal_repair.py +110 -19
- package/bin/_cctally_oauth_samples.py +280 -0
- package/bin/_cctally_parser.py +47 -0
- package/bin/_cctally_project.py +8 -2
- package/bin/_cctally_quarantine.py +662 -0
- package/bin/_cctally_quota.py +96 -12
- package/bin/_cctally_quota_model.py +391 -83
- package/bin/_cctally_record.py +1088 -269
- package/bin/_cctally_rederive.py +854 -192
- package/bin/_cctally_refresh.py +113 -13
- package/bin/_cctally_source_analytics.py +23 -2
- package/bin/_cctally_statusline.py +7062 -505
- package/bin/_cctally_store.py +1244 -91
- package/bin/_cctally_transcript.py +8 -7
- package/bin/_cctally_tui.py +119 -60
- package/bin/_cctally_update.py +25 -0
- package/bin/_lib_account_binding.py +152 -0
- package/bin/_lib_account_protocol.py +569 -0
- package/bin/_lib_aggregators.py +4 -0
- package/bin/_lib_cache_coverage.py +13 -1
- package/bin/_lib_cache_writer_lock.py +19 -3
- package/bin/_lib_clone_copy.py +177 -0
- package/bin/_lib_codex_conversation_query.py +133 -19
- package/bin/_lib_codex_conversation_watch.py +59 -14
- package/bin/_lib_codex_drain_admission.py +214 -0
- package/bin/_lib_codex_metadata.py +18 -1
- package/bin/_lib_codex_publication_barrier.py +277 -0
- package/bin/_lib_codex_rollout_container.py +502 -0
- package/bin/_lib_conversation_dispatch.py +3 -0
- package/bin/_lib_conversation_query.py +11 -3
- package/bin/_lib_dashboard_sources.py +57 -15
- package/bin/_lib_detector_access_registry.py +4038 -0
- package/bin/_lib_doctor.py +753 -1
- package/bin/_lib_five_hour.py +126 -0
- package/bin/_lib_ingest_frontier.py +414 -20
- package/bin/_lib_journal.py +261 -10
- package/bin/_lib_journal_router.py +166 -48
- package/bin/_lib_jsonl.py +5 -4
- package/bin/_lib_legacy_spool.py +126 -0
- package/bin/_lib_legacy_writer_evidence.py +136 -0
- package/bin/_lib_meter_rate_change.py +10 -0
- package/bin/_lib_oauth_samples.py +238 -0
- package/bin/_lib_outcome_quarantine.py +690 -0
- package/bin/_lib_pricing.py +7 -2
- package/bin/_lib_pricing_check.py +0 -12
- package/bin/_lib_provider_activity.py +770 -0
- package/bin/_lib_quarantine.py +155 -0
- package/bin/_lib_quota_calibration.py +53 -8
- package/bin/_lib_quota_copy.py +2 -1
- package/bin/_lib_quota_model.py +384 -52
- package/bin/_lib_rebuild_progress.py +146 -0
- package/bin/_lib_record.py +22 -0
- package/bin/_lib_rederive.py +393 -8
- package/bin/_lib_segment_summary.py +35 -2
- package/bin/_lib_snapshot_cache.py +43 -1
- package/bin/_lib_stale_proof.py +708 -0
- package/bin/_lib_statusline_candidates.py +356 -27
- package/bin/_lib_worker_launches.py +315 -0
- package/bin/cctally +29 -12
- package/dashboard/static/assets/{ConversationsView-Bc8LCOAZ.js → ConversationsView-Dflb_myA.js} +1 -1
- package/dashboard/static/assets/DoctorModal-DFX5CfIs.js +1 -0
- package/dashboard/static/assets/{ModalRoot-DLPgyAM_.js → ModalRoot-HlxoagIa.js} +1 -1
- package/dashboard/static/assets/{ProjectsDrillPanel-z53a4v4M.js → ProjectsDrillPanel-C3PJy1xx.js} +1 -1
- package/dashboard/static/assets/{SourceDetailModal-Bw0T8W-W.js → SourceDetailModal-BczsWKhD.js} +1 -1
- package/dashboard/static/assets/{UpdateModal-D5AKx4Yw.js → UpdateModal-Os-Lo5cs.js} +1 -1
- package/dashboard/static/assets/{index-BXDOzSng.js → index-CYZ3NLqF.js} +3 -3
- package/dashboard/static/assets/{outlineNavigation-JObY7cUY.js → outlineNavigation-k-zIif6W.js} +1 -1
- package/dashboard/static/dashboard.html +1 -1
- package/package.json +20 -2
- package/bin/_lib_merge_gate.py +0 -725
- package/dashboard/static/assets/DoctorModal-D--qVBwe.js +0 -1
package/bin/_cctally_forecast.py
CHANGED
|
@@ -97,6 +97,7 @@ from _lib_forecast import (
|
|
|
97
97
|
# exercises). doctor's _iso_z deliberately keeps its own divergent copy.
|
|
98
98
|
_ensure_sibling_loaded("_lib_json_envelope")
|
|
99
99
|
from _lib_json_envelope import _iso_z
|
|
100
|
+
from _lib_five_hour import latest_five_hour_reading
|
|
100
101
|
|
|
101
102
|
# #620 S1 D11: the one affordance shape every warning state renders.
|
|
102
103
|
_ensure_sibling_loaded("_lib_alert_scope")
|
|
@@ -175,7 +176,8 @@ def _week_rows_by_capture(cursor, *, by_id: bool) -> list:
|
|
|
175
176
|
def _fetch_current_week_snapshots(conn: sqlite3.Connection, now_utc: dt.datetime,
|
|
176
177
|
*, account_key: "str | None" = None,
|
|
177
178
|
include_held: bool = False,
|
|
178
|
-
include_account: bool = False
|
|
179
|
+
include_account: bool = False,
|
|
180
|
+
include_scope: bool = False):
|
|
179
181
|
"""Return (week_start_at, week_end_at, list[(captured_at, percent, five_hr)])
|
|
180
182
|
for the subscription week containing `now_utc`, or None if no snapshot
|
|
181
183
|
exists for the current week.
|
|
@@ -225,6 +227,14 @@ def _fetch_current_week_snapshots(conn: sqlite3.Connection, now_utc: dt.datetime
|
|
|
225
227
|
``include_account`` appends the physical account key after the held flag
|
|
226
228
|
for the multi-account Current Week card only. The default wire-independent
|
|
227
229
|
sample shape and merged forecast/cost reads remain unchanged.
|
|
230
|
+
|
|
231
|
+
``include_scope`` (#825/#832 spec 4.7 revision 7) appends a fourth element,
|
|
232
|
+
``(week_start_date, week_start_at_texts)``: the week scope the samples were
|
|
233
|
+
read under, in the form ``latest_five_hour_reading`` takes
|
|
234
|
+
(``week_start_at_texts`` is ``None`` on the date-only fallback). A caller
|
|
235
|
+
reading the five-hour axis selects its reading under exactly this scope
|
|
236
|
+
rather than from the newest sample, which a retired replica or a
|
|
237
|
+
weekly-only reading leaves without a five-hour value.
|
|
228
238
|
"""
|
|
229
239
|
# #341: optional account scoping — same predicate on every leg so the whole
|
|
230
240
|
# window resolution stays consistent (a real key or the `unattributed`
|
|
@@ -296,6 +306,8 @@ def _fetch_current_week_snapshots(conn: sqlite3.Connection, now_utc: dt.datetime
|
|
|
296
306
|
samples = _shape_week_samples(rows, include_held=include_held,
|
|
297
307
|
include_account=include_account)
|
|
298
308
|
samples = [s for s in samples if s[0] <= now_utc]
|
|
309
|
+
if include_scope:
|
|
310
|
+
return week_start_at, week_end_at, samples, (drow[0], None)
|
|
299
311
|
return week_start_at, week_end_at, samples
|
|
300
312
|
row = chosen
|
|
301
313
|
week_start_at = parse_iso_datetime(row[0], "week_start_at")
|
|
@@ -327,6 +339,9 @@ def _fetch_current_week_snapshots(conn: sqlite3.Connection, now_utc: dt.datetime
|
|
|
327
339
|
samples = _shape_week_samples(rows, include_held=include_held,
|
|
328
340
|
include_account=include_account)
|
|
329
341
|
samples = [s for s in samples if s[0] <= now_utc]
|
|
342
|
+
if include_scope:
|
|
343
|
+
return (week_start_at, week_end_at, samples,
|
|
344
|
+
(chosen_date, tuple(matching_texts)))
|
|
330
345
|
return week_start_at, week_end_at, samples
|
|
331
346
|
|
|
332
347
|
|
|
@@ -374,6 +389,42 @@ def _apply_midweek_reset_override(
|
|
|
374
389
|
return week_start_at, samples
|
|
375
390
|
|
|
376
391
|
|
|
392
|
+
def _current_week_five_hour_percent(conn, now_utc, week_scope, *,
|
|
393
|
+
account_key, week_start_at,
|
|
394
|
+
week_start_before_override):
|
|
395
|
+
"""The percentage of ``_current_week_five_hour_reading``, or ``None``."""
|
|
396
|
+
reading = _current_week_five_hour_reading(
|
|
397
|
+
conn, now_utc, week_scope, account_key=account_key,
|
|
398
|
+
week_start_at=week_start_at,
|
|
399
|
+
week_start_before_override=week_start_before_override)
|
|
400
|
+
return None if reading is None else reading.percent
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def _current_week_five_hour_reading(conn, now_utc, week_scope, *,
|
|
404
|
+
account_key, week_start_at,
|
|
405
|
+
week_start_before_override):
|
|
406
|
+
"""The current week's five-hour reading: the newest five-hour READING
|
|
407
|
+
under the current-week read's own scope (#825/#832 spec 4.7 revision 7).
|
|
408
|
+
Its percent and reset come from one row, so a caller that shows both
|
|
409
|
+
shows one reading.
|
|
410
|
+
|
|
411
|
+
``week_scope`` is ``_fetch_current_week_snapshots(include_scope=True)``'s
|
|
412
|
+
fourth element. When ``_apply_midweek_reset_override`` moved the week's
|
|
413
|
+
start, its new start bounds the captures exactly as it bounded the samples.
|
|
414
|
+
``account_key`` ``None`` keeps the merged read's account-blind contract.
|
|
415
|
+
"""
|
|
416
|
+
week_start_date, week_start_at_texts = week_scope
|
|
417
|
+
floor = (week_start_at if week_start_at != week_start_before_override
|
|
418
|
+
else None)
|
|
419
|
+
reading = latest_five_hour_reading(
|
|
420
|
+
conn, account_key=account_key,
|
|
421
|
+
as_of_utc=_iso_z(now_utc),
|
|
422
|
+
captured_at_or_after_utc=None if floor is None else _iso_z(floor),
|
|
423
|
+
week_start_date=week_start_date,
|
|
424
|
+
week_start_at_in=week_start_at_texts)
|
|
425
|
+
return reading
|
|
426
|
+
|
|
427
|
+
|
|
377
428
|
def _resolve_current_budget_window(conn, now_utc, *, account_key=None):
|
|
378
429
|
"""Return ``(effective_week_start_dt, week_end_dt)`` for the subscription
|
|
379
430
|
week containing ``now_utc``, honoring a mid-week reset re-anchor; or
|
|
@@ -807,8 +858,13 @@ def _dpp_candidate_comparability(regime, week_start_at, week_end_at, *,
|
|
|
807
858
|
|
|
808
859
|
- `"comparable"` — in regime, and its own population passes the support
|
|
809
860
|
test.
|
|
810
|
-
- `"incomparable"` — in regime, population read,
|
|
811
|
-
|
|
861
|
+
- `"incomparable"` — in regime, population read, and `apply_regime`
|
|
862
|
+
rejected it. That is drift (the support test failed), or a week outside
|
|
863
|
+
the regime's coefficient era (`unvalidated-coefficient-era`, #978 spec
|
|
864
|
+
4.6), whose units were weighted with another era's coefficients and so
|
|
865
|
+
cannot be compared with this regime's rate either, or a week with no
|
|
866
|
+
local population to weigh (`no-local-history`). All three mean the
|
|
867
|
+
same thing to the selector: the candidate is not comparable.
|
|
812
868
|
- `"excluded"` — on the far side of a rate boundary.
|
|
813
869
|
- `"unreadable"` — the population could not be read at all. Folding this
|
|
814
870
|
into `"excluded"` made a locked `cache.db` look like twelve weeks that
|
|
@@ -837,7 +893,8 @@ def _dpp_candidate_comparability(regime, week_start_at, week_end_at, *,
|
|
|
837
893
|
cache_conn_factory=cache_conn_factory)
|
|
838
894
|
except Exception: # noqa: BLE001
|
|
839
895
|
return "unreadable"
|
|
840
|
-
applied = qcg.apply_regime(regime, entries
|
|
896
|
+
applied = qcg.apply_regime(regime, entries,
|
|
897
|
+
interval=(week_start_at, week_end_at))
|
|
841
898
|
if isinstance(applied, qcg.ApplyRejection):
|
|
842
899
|
return "incomparable"
|
|
843
900
|
return "comparable"
|
|
@@ -1289,7 +1346,12 @@ def _calibrated_week_detail(
|
|
|
1289
1346
|
week_start_at, horizon, account_key=account_key)
|
|
1290
1347
|
except sqlite3.Error:
|
|
1291
1348
|
return CalibratedWeek(code="unavailable")
|
|
1292
|
-
|
|
1349
|
+
# The interval is the whole week the projection extrapolates over, not
|
|
1350
|
+
# the entries' span: a week straddling the regime's coefficient era is
|
|
1351
|
+
# refused as `unvalidated-coefficient-era` even when every retained entry
|
|
1352
|
+
# so far is in-era (#978 spec 4.6).
|
|
1353
|
+
applied = qcg.apply_regime(read.regime, entries,
|
|
1354
|
+
interval=(week_start_at, week_end_at))
|
|
1293
1355
|
if isinstance(applied, qcg.ApplyRejection):
|
|
1294
1356
|
return CalibratedWeek(code=applied.value)
|
|
1295
1357
|
|
|
@@ -1392,12 +1454,14 @@ def _load_forecast_inputs(
|
|
|
1392
1454
|
c = _cctally()
|
|
1393
1455
|
# #769 S11 (#824): ONE read, held-inclusive, split per axis below.
|
|
1394
1456
|
fetched = _fetch_current_week_snapshots(
|
|
1395
|
-
conn, now_utc, account_key=account_key, include_held=True
|
|
1457
|
+
conn, now_utc, account_key=account_key, include_held=True,
|
|
1458
|
+
include_scope=True)
|
|
1396
1459
|
if fetched is None:
|
|
1397
1460
|
return None
|
|
1398
|
-
week_start_at, week_end_at, observations = fetched
|
|
1461
|
+
week_start_at, week_end_at, observations, week_scope = fetched
|
|
1399
1462
|
if not observations:
|
|
1400
1463
|
return None
|
|
1464
|
+
week_start_before_override = week_start_at
|
|
1401
1465
|
|
|
1402
1466
|
# Mid-week reset override: shift week_start_at to the effective
|
|
1403
1467
|
# reset moment and drop pre-reset samples so elapsed/remaining math
|
|
@@ -1421,8 +1485,16 @@ def _load_forecast_inputs(
|
|
|
1421
1485
|
p_now = latest[1]
|
|
1422
1486
|
# The five-hour axis, which is why the read is held-inclusive: a held row
|
|
1423
1487
|
# exists precisely because its five-hour reading GREW, so the newest
|
|
1424
|
-
#
|
|
1425
|
-
|
|
1488
|
+
# READING of either kind is the current five-hour percentage. It is
|
|
1489
|
+
# selected through the one shared selection (#825/#832 spec 4.7 revision
|
|
1490
|
+
# 7) under this read's own scope: the account, the week, `now_utc`, and
|
|
1491
|
+
# the mid-week reset's lower bound when the override applied. The newest
|
|
1492
|
+
# observation is not the answer, because a retired replica or a
|
|
1493
|
+
# weekly-only reading carries no five-hour value.
|
|
1494
|
+
five_hr = _current_week_five_hour_percent(
|
|
1495
|
+
conn, now_utc, week_scope, account_key=account_key,
|
|
1496
|
+
week_start_at=week_start_at,
|
|
1497
|
+
week_start_before_override=week_start_before_override)
|
|
1426
1498
|
|
|
1427
1499
|
elapsed_hours = (now_utc - week_start_at).total_seconds() / 3600.0
|
|
1428
1500
|
total_hours = (week_end_at - week_start_at).total_seconds() / 3600.0
|