feat(statestore): record a usage row for every model call

Task agent runs and MCP sampling record against their task (billed to the
task's org); gateway chat turns, titles, sampling and curators record
against the system org. Rows carry source, workflow, step, alias,
provider/model and tokens for later chargeback.
This commit is contained in:
sam committed 2026-10-10 18:32:43 +11:00
1 parent 12b9a57404
commit e4ea2eaabc
31 files changed
+1068 -322

No files matched your search

+3
View File
@@ -8,6 +8,7 @@ import (
"time"
"github.com/samcharles93/archie-core/internal/domain/org"
"github.com/samcharles93/archie-core/internal/domain/usage"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/taskstate"
)
@@ -185,6 +186,8 @@ type Store interface {
// the stage_finish event in the same transaction, and returns that event
// for the caller's post-commit publish.
FinishStep(ctx context.Context, s StepFinish) (events.Event, error)
// RecordUsage appends one model call's usage record.
RecordUsage(ctx context.Context, r usage.Record) error
}
// Definition is a workflow's id and stage order.