You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cost/session layering: ledger snapshot logic in the HTTP layer; import edges point both ways #1583
Three layering problems around the session/cost boundary:
The ledger snapshot is built in the HTTP layer.core/sessionapi/usage.go:328ledgerSnapshotFor (~150 lines) plus its satellites (degradedFrom, bucketSecondsFor, servedSpan, resolutionSpan, :541-626) are pure cost-domain logic — ledger.Fold, saturation flags, caveats→degraded mapping, retention disclosure — with nothing HTTP in them. Meanwhile Fold/FilterAgent/series helpers already live in cost/ledger/query.go. As a result the ledger can only serve a snapshot through the endpoint, not programmatically.
session → cost/usage exists for one type. The store's summary block (core/session/store.go:856-1222) imports the 4k-line usage package for exactly usage.CostSum (a ~45-line saturating-add type that depends on nothing). It belongs beside event.Micros in core/cost/event, which session already imports.
cost/ledger → session exists for a compile-time pin.writer.go:335's production import exists solely for var _ session.Recorder = (*Writer)(nil) — an assertion that belongs in a _test.go.
Fix
Move ledgerSnapshotFor's body into cost/ledger (e.g. Writer.Snapshot(ctx, spec, group, agent)); move CostSum to cost/event; move the Recorder pin to a test file. Three one-file moves, and the session/cost boundary becomes one-directional.
Found in the 2026-10-29 structural audit of code organization.
Activity