cctally 1.82.0 → 1.83.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 (52) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +52 -74
  3. package/bin/_cctally_alerts.py +8 -1
  4. package/bin/_cctally_cache.py +963 -149
  5. package/bin/_cctally_config.py +43 -4
  6. package/bin/_cctally_core.py +933 -759
  7. package/bin/_cctally_dashboard.py +157 -47
  8. package/bin/_cctally_dashboard_cache_report.py +13 -6
  9. package/bin/_cctally_dashboard_conversation.py +1 -0
  10. package/bin/_cctally_dashboard_envelope.py +186 -8
  11. package/bin/_cctally_dashboard_share.py +60 -20
  12. package/bin/_cctally_dashboard_sources.py +427 -128
  13. package/bin/_cctally_db.py +605 -128
  14. package/bin/_cctally_doctor.py +413 -28
  15. package/bin/_cctally_five_hour.py +12 -5
  16. package/bin/_cctally_journal.py +2050 -156
  17. package/bin/_cctally_journal_repair.py +519 -0
  18. package/bin/_cctally_milestone_history.py +142 -56
  19. package/bin/_cctally_milestones.py +179 -111
  20. package/bin/_cctally_parser.py +42 -0
  21. package/bin/_cctally_project.py +24 -18
  22. package/bin/_cctally_quota.py +139 -25
  23. package/bin/_cctally_record.py +279 -108
  24. package/bin/_cctally_rederive.py +1052 -0
  25. package/bin/_cctally_reporting.py +58 -53
  26. package/bin/_cctally_setup.py +1 -0
  27. package/bin/_cctally_source_analytics.py +4 -1
  28. package/bin/_cctally_statusline.py +11 -11
  29. package/bin/_cctally_store.py +1039 -31
  30. package/bin/_cctally_sync_week.py +17 -8
  31. package/bin/_cctally_tui.py +421 -54
  32. package/bin/_cctally_update.py +133 -8
  33. package/bin/_cctally_weekrefs.py +14 -0
  34. package/bin/_lib_aggregators.py +10 -6
  35. package/bin/_lib_cache_report.py +101 -9
  36. package/bin/_lib_codex_pools.py +82 -0
  37. package/bin/_lib_conversation_query.py +126 -33
  38. package/bin/_lib_dashboard_sources.py +126 -1
  39. package/bin/_lib_diff_kernel.py +28 -15
  40. package/bin/_lib_doctor.py +342 -4
  41. package/bin/_lib_journal.py +924 -2
  42. package/bin/_lib_jsonl.py +43 -14
  43. package/bin/_lib_pricing.py +140 -21
  44. package/bin/_lib_readme_refresh.py +401 -0
  45. package/bin/_lib_rederive.py +395 -0
  46. package/bin/_lib_share.py +58 -2
  47. package/bin/cctally +56 -8
  48. package/dashboard/static/assets/{index-DJP4gEB7.js → index-3bgCMVHb.js} +52 -52
  49. package/dashboard/static/assets/index-D27EIHEI.css +1 -0
  50. package/dashboard/static/dashboard.html +2 -2
  51. package/package.json +6 -1
  52. package/dashboard/static/assets/index-Dk1nplOz.css +0 -1
@@ -51,6 +51,7 @@ from _cctally_core import (
51
51
  def cmd_sync_week(
52
52
  args: argparse.Namespace, *, conn=None, as_of: "str | None" = None,
53
53
  journal: "tuple | None" = None, account_key: str = "unattributed",
54
+ retained_selection=None,
54
55
  ) -> int:
55
56
  """Compute + persist the week's cost snapshot.
56
57
 
@@ -58,8 +59,11 @@ def cmd_sync_week(
58
59
  ``conn`` runs the cost-snapshot insert on the caller's connection (no
59
60
  internal open/commit/close), and ``as_of`` (ISO-Z) stamps the snapshot's
60
61
  ``captured_at_utc``. Both defaults keep the legacy own-connection,
61
- wall-clock behavior — so `record`/`maybe_record_milestone`'s existing
62
- bare `cmd_sync_week(ns)` calls are byte-identical.
62
+ wall-clock behavior. ``retained_selection`` is the internal replay seam:
63
+ milestone derivation passes the triggering observation's canonical
64
+ ``WeekSelection`` so a later usage row cannot replace its exact subscription
65
+ window. Operator ``sync-week`` callers omit it and keep latest-week
66
+ resolution.
63
67
 
64
68
  Design A (DB journal redesign §5.3, Model-A ``weekly_cost_snapshot``):
65
69
  ``journal=(ctx, id_base)`` routes the ``insert_cost_snapshot`` THROUGH
@@ -88,12 +92,14 @@ def cmd_sync_week(
88
92
  if own_conn:
89
93
  conn = open_db()
90
94
  try:
91
- selection = c.pick_week_selection(
92
- conn,
93
- args.week_start,
94
- args.week_end,
95
- week_start_name,
96
- )
95
+ selection = retained_selection
96
+ if selection is None:
97
+ selection = c.pick_week_selection(
98
+ conn,
99
+ args.week_start,
100
+ args.week_end,
101
+ week_start_name,
102
+ )
97
103
  week_start = selection.week_start
98
104
  week_end = selection.week_end
99
105
  result = c.compute_week_cost(
@@ -109,6 +115,9 @@ def cmd_sync_week(
109
115
  # carries the merged cost of every account sharing the week. Default
110
116
  # `unattributed` matches all-NULL legacy rows -> byte-stable.
111
117
  account_key=account_key,
118
+ # Historical rederive must not include cache rows captured after the
119
+ # triggering obs/op. Default None preserves normal wall-clock sync.
120
+ as_of=as_of,
112
121
  )
113
122
  week_start_at = selection.start_iso_override or format_local_iso(week_start, end_of_day=False)
114
123
  week_end_at = selection.end_iso_override or format_local_iso(week_end, end_of_day=True)