Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Cost/session layering: ledger snapshot logic in the HTTP layer; import edges point both ways

Aperta
#1,583 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

Start by reading core/sessionapi/usage.go:328 ledgerSnapshotFor, its satellites around :541-626, and the existing ledger query helpers in cost/ledger/query.go. Move the snapshot logic into cost/ledger as Writer.Snapshot, then check the usage.CostSum use in core/session/store.go:856-1222 and move that type beside event.Micros in core/cost/event; finally move the session.Recorder assertion at writer.go:335 into a test file. Done when those three imports no longer form the layering edges and the affected Go test packages pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What

Three layering problems around the session/cost boundary:

  1. The ledger snapshot is built in the HTTP layer. core/sessionapi/usage.go:328 ledgerSnapshotFor (~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.

  2. 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.

  3. 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.

Lingua principale
Go
Stelle
21
Fork
43
Merge medio
13h 8m
PR unite (30g)
267

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rossoctl/cortex

Tutte le issue di rossoctl/cortex

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.