cctally 1.108.0 → 1.110.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 (85) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +6 -6
  3. package/bin/_cctally_account.py +4 -0
  4. package/bin/_cctally_alerts.py +6 -2
  5. package/bin/_cctally_cache.py +1652 -166
  6. package/bin/_cctally_config.py +3 -2
  7. package/bin/_cctally_core.py +594 -33
  8. package/bin/_cctally_dashboard.py +1585 -201
  9. package/bin/_cctally_dashboard_conversation.py +494 -48
  10. package/bin/_cctally_dashboard_envelope.py +167 -11
  11. package/bin/_cctally_dashboard_share.py +154 -36
  12. package/bin/_cctally_dashboard_sources.py +2615 -422
  13. package/bin/_cctally_db.py +678 -5
  14. package/bin/_cctally_diagnosis_sources.py +238 -26
  15. package/bin/_cctally_doctor.py +99 -18
  16. package/bin/_cctally_five_hour.py +1295 -40
  17. package/bin/_cctally_forecast.py +124 -28
  18. package/bin/_cctally_journal.py +408 -38
  19. package/bin/_cctally_milestone_history.py +150 -14
  20. package/bin/_cctally_parser.py +5 -0
  21. package/bin/_cctally_percent_breakdown.py +6 -1
  22. package/bin/_cctally_project.py +48 -76
  23. package/bin/_cctally_quota.py +39 -7
  24. package/bin/_cctally_quota_model.py +17 -2
  25. package/bin/_cctally_record.py +1647 -443
  26. package/bin/_cctally_rederive.py +899 -30
  27. package/bin/_cctally_refresh.py +2 -1
  28. package/bin/_cctally_share.py +24 -5
  29. package/bin/_cctally_source_analytics.py +1035 -78
  30. package/bin/_cctally_statusline.py +83 -19
  31. package/bin/_cctally_store.py +61 -4
  32. package/bin/_cctally_transcript.py +27 -2
  33. package/bin/_cctally_tui.py +264 -76
  34. package/bin/_cctally_weekrefs.py +28 -5
  35. package/bin/_lib_blocks.py +127 -20
  36. package/bin/_lib_cache_report.py +20 -5
  37. package/bin/_lib_codex_conversation_query.py +297 -64
  38. package/bin/_lib_codex_hooks.py +102 -0
  39. package/bin/_lib_codex_metadata.py +207 -0
  40. package/bin/_lib_conversation.py +119 -0
  41. package/bin/_lib_conversation_dispatch.py +31 -1
  42. package/bin/_lib_conversation_query.py +315 -51
  43. package/bin/_lib_conversation_retention.py +413 -25
  44. package/bin/_lib_dashboard_sources.py +267 -7
  45. package/bin/_lib_diagnosis.py +10 -0
  46. package/bin/_lib_diff_kernel.py +12 -1
  47. package/bin/_lib_doctor.py +230 -8
  48. package/bin/_lib_ingest_frontier.py +1366 -49
  49. package/bin/_lib_journal.py +19 -2
  50. package/bin/_lib_merge_gate.py +307 -0
  51. package/bin/_lib_pricing.py +588 -29
  52. package/bin/_lib_record.py +130 -12
  53. package/bin/_lib_rederive.py +903 -2
  54. package/bin/_lib_render.py +9 -3
  55. package/bin/_lib_retained_size.py +27 -2
  56. package/bin/_lib_segment_summary.py +66 -8
  57. package/bin/_lib_share_templates.py +28 -18
  58. package/bin/_lib_snapshot_cache.py +115 -1
  59. package/bin/_lib_source_retry.py +320 -0
  60. package/bin/_lib_statusline_candidates.py +400 -36
  61. package/bin/_lib_tick_stats.py +119 -0
  62. package/bin/_lib_view_models.py +256 -76
  63. package/bin/cctally +69 -0
  64. package/dashboard/static/assets/ConversationsView-BB9vUiL6.js +72 -0
  65. package/dashboard/static/assets/{DoctorModal-CWn3U4Wl.js → DoctorModal-DFY2iPDf.js} +1 -1
  66. package/dashboard/static/assets/ModalRoot-DvRKHbQE.js +1 -0
  67. package/dashboard/static/assets/ProjectsDrillPanel-DAv39uSo.js +1 -0
  68. package/dashboard/static/assets/SourceDetailModal-DSAWo2Fp.js +1 -0
  69. package/dashboard/static/assets/{UpdateModal-D3m8GG6V.js → UpdateModal-R_9dOVnh.js} +3 -3
  70. package/dashboard/static/assets/dashboardStream.shared-worker-DbG6Ef0T.js +1 -0
  71. package/dashboard/static/assets/index-COhxe3vU.css +1 -0
  72. package/dashboard/static/assets/index-DdU62sov.js +13 -0
  73. package/dashboard/static/assets/outlineNavigation-BOCLcRa6.js +9 -0
  74. package/dashboard/static/assets/useKeymap-CW7Up0Ay.js +1 -0
  75. package/dashboard/static/dashboard.html +3 -3
  76. package/package.json +4 -1
  77. package/dashboard/static/assets/ConversationsView-BOSaBRtu.js +0 -72
  78. package/dashboard/static/assets/ModalRoot-SR070V6c.js +0 -1
  79. package/dashboard/static/assets/ProjectsDrillPanel-QLI9i5mZ.js +0 -1
  80. package/dashboard/static/assets/SourceDetailModal-pv0wlFxl.js +0 -1
  81. package/dashboard/static/assets/dashboardStream.shared-worker-1XTMV3nr.js +0 -1
  82. package/dashboard/static/assets/index-BHu4mxd8.css +0 -1
  83. package/dashboard/static/assets/index-CIWsbux3.js +0 -13
  84. package/dashboard/static/assets/outlineNavigation-CJvKqmLV.js +0 -9
  85. package/dashboard/static/assets/useKeymap-ffqsS5G0.js +0 -1
package/bin/cctally CHANGED
@@ -283,6 +283,11 @@ make_week_ref = _cctally_core.make_week_ref
283
283
  _get_latest_row_for_week = _cctally_core._get_latest_row_for_week
284
284
  _latest_reset_event_for_end = _cctally_core._latest_reset_event_for_end
285
285
  _ordered_in_place_cuts = _cctally_core._ordered_in_place_cuts
286
+ in_place_cut_instants = _cctally_core.in_place_cut_instants
287
+ credited_segment_cuts = _cctally_core.credited_segment_cuts
288
+ canonical_capture_bound = _cctally_core.canonical_capture_bound
289
+ segment_capture_bounds = _cctally_core.segment_capture_bounds
290
+ latest_usage_by_segment = _cctally_core.latest_usage_by_segment
286
291
  _reset_aware_floor = _cctally_core._reset_aware_floor
287
292
  _floored_week_max = _cctally_core._floored_week_max
288
293
  get_latest_usage_for_week = _cctally_core.get_latest_usage_for_week
@@ -631,6 +636,11 @@ _build_activity_block = _lib_blocks._build_activity_block
631
636
  _blocks_to_json = _lib_blocks._blocks_to_json
632
637
  _max_completed_block_tokens = _lib_blocks._max_completed_block_tokens
633
638
  _parse_blocks_token_limit = _lib_blocks._parse_blocks_token_limit
639
+ # #751a: the one five-hour ownership rule, re-exported for the consumers
640
+ # that resolve ownership outside the grouping pass.
641
+ OwnedWindow = _lib_blocks.OwnedWindow
642
+ resolve_owning_window = _lib_blocks.resolve_owning_window
643
+ partition_entries_by_owner = _lib_blocks.partition_entries_by_owner
634
644
 
635
645
  _lib_statusline = _load_sibling("_lib_statusline")
636
646
  STATUSLINE_BURN_RATE_BANDS = _lib_statusline.STATUSLINE_BURN_RATE_BANDS
@@ -688,6 +698,7 @@ MonthlyView = _lib_view_models.MonthlyView
688
698
  build_monthly_view = _lib_view_models.build_monthly_view
689
699
  WeeklyView = _lib_view_models.WeeklyView
690
700
  build_weekly_view = _lib_view_models.build_weekly_view
701
+ apply_label_collision_suffixes = _lib_view_models.apply_label_collision_suffixes
691
702
  TrendView = _lib_view_models.TrendView
692
703
  build_trend_view = _lib_view_models.build_trend_view
693
704
  SessionsView = _lib_view_models.SessionsView
@@ -1153,6 +1164,15 @@ get_entries = _cctally_cache.get_entries
1153
1164
  AccountAttributionUnavailable = _cctally_cache.AccountAttributionUnavailable
1154
1165
  open_cache_db = _cctally_cache.open_cache_db
1155
1166
  open_conversations_db = _cctally_cache.open_conversations_db
1167
+ open_conversations_db_readonly = _cctally_cache.open_conversations_db_readonly
1168
+ probe_conversations_maintenance_free = (
1169
+ _cctally_cache.probe_conversations_maintenance_free
1170
+ )
1171
+ ConversationReaderUnavailable = _cctally_cache.ConversationReaderUnavailable
1172
+ MaintenanceInProgress = _cctally_cache.MaintenanceInProgress
1173
+ SchemaBehind = _cctally_cache.SchemaBehind
1174
+ SchemaAhead = _cctally_cache.SchemaAhead
1175
+ LegacyBridgePending = _cctally_cache.LegacyBridgePending
1156
1176
  scope_conversations_db_to_account = (
1157
1177
  _cctally_cache.scope_conversations_db_to_account
1158
1178
  )
@@ -1209,6 +1229,25 @@ _resolve_active_five_hour_reset_event_id = _cctally_record._resolve_active_five_
1209
1229
  _apply_credit = _cctally_record._apply_credit
1210
1230
  _fire_in_place_credit = _cctally_record._fire_in_place_credit
1211
1231
  detect_reset_and_credit = _cctally_record.detect_reset_and_credit
1232
+ # #834 S1 (#835): the one semantic doomed-row classifier and the one stale-replica
1233
+ # removal, re-exported so both credit paths reach BOTH through this namespace (test
1234
+ # monkeypatching) and so tests can assert the classifier's two projections
1235
+ # directly. Gate A R7 item 2 made the first half of that sentence true:
1236
+ # `_fire_in_place_credit` called the module-local symbol, so patching this name
1237
+ # intercepted only the manual path.
1238
+ _doomed_snapshot_rows = _cctally_record._doomed_snapshot_rows
1239
+ _delete_doomed_snapshot_rows = _cctally_record._delete_doomed_snapshot_rows
1240
+ # #834 S1 (#835) Gate A R4: the band is a connection-taking builder now,
1241
+ # because the held predicate is omitted on a store predating the column.
1242
+ _stale_replica_band_sql = _cctally_record._stale_replica_band_sql
1243
+ # #834 S1 (#835): the read-side twin of the band above — which weekly
1244
+ # values a week's credits retired, and the predicate that recognizes one.
1245
+ # `_latest_seven_day_and_window` reaches both through this namespace.
1246
+ _credit_retirement_bands = _cctally_record._credit_retirement_bands
1247
+ _latest_credit_floor_instant = _cctally_record._latest_credit_floor_instant
1248
+ _weekly_value_is_retired_replica = (
1249
+ _cctally_record._weekly_value_is_retired_replica)
1250
+ _stale_replay_candidates = _cctally_record._stale_replay_candidates
1212
1251
  _count_stale_replays = _cctally_record._count_stale_replays
1213
1252
  _credit_preview_text = _cctally_record._credit_preview_text
1214
1253
  _credit_json = _cctally_record._credit_json
@@ -1245,6 +1284,7 @@ _coerce_payload_captured_at = _cctally_record._coerce_payload_captured_at
1245
1284
  _derive_week_from_payload = _cctally_record._derive_week_from_payload
1246
1285
  insert_usage_snapshot = _cctally_record.insert_usage_snapshot
1247
1286
  _saved_dict_from_usage_row = _cctally_record._saved_dict_from_usage_row
1287
+ _five_hour_saved_from_fold = _cctally_record._five_hour_saved_from_fold
1248
1288
 
1249
1289
  # #372 Task B: side-effect-free Claude usage rederive planner. Loaded after the
1250
1290
  # record sibling so its scratch adapter can reuse the registered ingest hooks.
@@ -1530,10 +1570,21 @@ _select_non_overlapping_recorded_windows = _cctally_five_hour._select_non_overla
1530
1570
  _load_recorded_five_hour_windows = _cctally_five_hour._load_recorded_five_hour_windows
1531
1571
  cmd_blocks = _cctally_five_hour.cmd_blocks
1532
1572
  _maybe_swap_active_block_to_canonical = _cctally_five_hour._maybe_swap_active_block_to_canonical
1573
+ _ownership_windows_from_recorded = _cctally_five_hour._ownership_windows_from_recorded
1533
1574
  _format_block_start = _cctally_five_hour._format_block_start
1534
1575
  _format_hhmm_in_tz = _cctally_five_hour._format_hhmm_in_tz
1535
1576
  _block_is_active = _cctally_five_hour._block_is_active
1536
1577
  _latest_seven_day_and_window = _cctally_five_hour._latest_seven_day_and_window
1578
+ # #834 S1 (#835) Gate A S1: the ONE read-time filter for a block's two
1579
+ # weekly axes. Both five-hour commands reach it through this namespace.
1580
+ _parsed_block_instant = _cctally_five_hour._parsed_block_instant
1581
+ _block_weekly_start_instant = _cctally_five_hour._block_weekly_start_instant
1582
+ _block_weekly_end_instant = _cctally_five_hour._block_weekly_end_instant
1583
+ _credit_aware_block_weekly_axes = (
1584
+ _cctally_five_hour._credit_aware_block_weekly_axes)
1585
+ # #834 S1 (#836): the ONE five-hour milestone read, shared by the CLI
1586
+ # breakdown and both dashboard routes.
1587
+ _load_five_hour_milestones = _cctally_five_hour._load_five_hour_milestones
1537
1588
  _parse_date_filter = _cctally_five_hour._parse_date_filter
1538
1589
  _load_breakdown = _cctally_five_hour._load_breakdown
1539
1590
  cmd_five_hour_blocks = _cctally_five_hour.cmd_five_hour_blocks
@@ -2486,10 +2537,19 @@ def _select_last_known_snapshot() -> dict | None:
2486
2537
  try:
2487
2538
  conn = open_db()
2488
2539
  try:
2540
+ # `weekly_observation_held = 0` (#769 S11, #824). The payload this
2541
+ # builds is ONE observation with ONE capture instant, and
2542
+ # `_cmd_refresh_usage_handle_rate_limit` turns that instant into the
2543
+ # freshness label it shows beside the seven-day percentage. A held
2544
+ # row carries an older row's weekly value, so serving one would
2545
+ # stamp a stale percentage as freshly captured. Taking the whole
2546
+ # payload from the latest genuinely observed row keeps the label and
2547
+ # every value it qualifies describing the same observation.
2489
2548
  row = conn.execute(
2490
2549
  "SELECT captured_at_utc, weekly_percent, week_end_at, "
2491
2550
  " five_hour_percent, five_hour_resets_at "
2492
2551
  "FROM weekly_usage_snapshots "
2552
+ "WHERE weekly_observation_held = 0 "
2493
2553
  "ORDER BY captured_at_utc DESC, id DESC LIMIT 1"
2494
2554
  ).fetchone()
2495
2555
  finally:
@@ -3308,8 +3368,17 @@ def _newest_snapshot_age_seconds(now_utc: dt.datetime | None = None) -> float |
3308
3368
  try:
3309
3369
  conn = open_db()
3310
3370
  try:
3371
+ # `weekly_observation_held = 0` (#769 S11, #824). This age gates the
3372
+ # hook's OAuth fetch, and the question it answers is how recently a
3373
+ # WEEKLY reading was ingested — a held row's weekly value is a copy
3374
+ # of an older one's. Excluding held rows also keeps the fetch
3375
+ # cadence exactly where it was before #824, when a weekly-clamped
3376
+ # tick wrote no row at all; doctor's `data.latest_snapshot_age` is
3377
+ # the deliberate counterpart, because it asks whether the WRITE PATH
3378
+ # is alive rather than what the weekly meter last said.
3311
3379
  row = conn.execute(
3312
3380
  "SELECT captured_at_utc FROM weekly_usage_snapshots "
3381
+ "WHERE weekly_observation_held = 0 "
3313
3382
  "ORDER BY captured_at_utc DESC, id DESC LIMIT 1"
3314
3383
  ).fetchone()
3315
3384
  finally: