cctally 1.11.1 → 1.13.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.
@@ -283,6 +283,7 @@ def _compute_subscription_weeks(
283
283
  conn: sqlite3.Connection,
284
284
  range_start: dt.datetime,
285
285
  range_end: dt.datetime,
286
+ config: "dict | None" = None,
286
287
  ) -> list[SubWeek]:
287
288
  """Generate the ordered list of subscription weeks overlapping [range_start, range_end].
288
289
 
@@ -292,6 +293,16 @@ def _compute_subscription_weeks(
292
293
  config-based calendar-week boundaries with every week tagged
293
294
  "extrapolated".
294
295
 
296
+ ``config`` (issue #88 ``--config`` surface): the resolved config dict
297
+ used by the no-snapshot Case-B calendar-week fallback. When the caller
298
+ already loaded config honoring the per-invocation ``--config <path>``
299
+ override (``_load_claude_config_for_args``), it MUST pass it here so the
300
+ fallback's ``collector.week_start`` matches the explicit override rather
301
+ than re-reading (and first-run-creating) the persisted default config.
302
+ ``None`` preserves the legacy bare-``load_config()`` behavior for callers
303
+ with no ``--config`` surface (dashboard) and for the monkeypatch
304
+ carve-out (tests reach ``load_config`` via ``ns["load_config"]``).
305
+
295
306
  Anthropic's reset day-of-week is not strictly stable across long spans —
296
307
  it can shift (observed: Thursday cycles in Feb, Friday cycles from Mar
297
308
  onward). A single-anchor 7-day-multiple extrapolation therefore generates
@@ -466,9 +477,16 @@ def _compute_subscription_weeks(
466
477
  return _apply_overlap_clamp_to_subweeks(weeks)
467
478
 
468
479
  # Case B: no snapshots — config-based calendar-week fallback.
469
- # `load_config` stays on the _cctally() accessor per spec §3.5
470
- # monkeypatch carve-out tests reach it via ``ns["load_config"]``.
471
- config = _cctally().load_config()
480
+ # Honor the caller's `--config <path>` override when supplied (issue
481
+ # #88): `cmd_weekly` / `cmd_project` pass the config resolved by
482
+ # `_load_claude_config_for_args` so this fallback reads the explicit
483
+ # path's `collector.week_start` instead of recreating / reading the
484
+ # persisted default. When `config is None` (dashboard, or the spec §3.5
485
+ # monkeypatch carve-out where tests reach `load_config` via
486
+ # `ns["load_config"]`), fall back to a bare `load_config()` on the
487
+ # `_cctally()` accessor — identical to the prior behavior.
488
+ if config is None:
489
+ config = _cctally().load_config()
472
490
  week_start_name = get_week_start_name(config)
473
491
  week_start_idx = WEEKDAY_MAP[week_start_name]
474
492
  # internal fallback: host-local intentional