Add export v1 contracts and session summary export#991
Conversation
Programmatic consumers need stable JSON contracts for report and session-summary exports, including reproducible pricing metadata and project identity that can survive cross-machine aggregation. This commit publishes the final branch state without the private local-path examples that existed only in intermediate local commits. The export surfaces stay additive while gaining shared schema metadata, pricing provenance, persisted project identity, and a content-free daemonless session summary export for headless analytics.
V1 report metadata should distinguish an empty projects map from legacy absence. Usage summary and activity responses now keep the projects field present, with regression coverage at the DB, activity, service, and HTTP response layers.
The v1 activity report golden only needs enough rows to pin the contract surface. The prior full-day default generated hundreds of empty five-minute buckets, making review noisy without adding distinct schema coverage. Use a narrow custom window around the seeded sessions so the fixture still carries pricing, project identity, partial-range metadata, nonzero buckets, summaries, sessions, and intervals while staying small enough to read.
roborev: Combined Review (
|
V1 export metadata is now consumed as join and provenance data, so it must not leak credential-bearing remotes or mutate archives from daemonless read commands. Persist sanitized project remotes and scrub existing observations while preserving remote-derived project keys.\n\nSession-summary export now requires an existing archive database ID and uses the read-only open path, avoiding an uncoordinated SQLite writer beside the daemon.\n\nPostgreSQL and DuckDB now treat explicit pricing rows as the effective pricing table, matching SQLite provenance digests while retaining fallback pricing for empty fresh mirrors. The docs also call out that the new JSON contracts aim for compatibility but may still settle.
roborev: Combined Review (
|
Session-summary export is intentionally read-only, so fresh archives need their database identity created by the normal writable startup path rather than by the export command. This keeps daemonless export from opening a second writer while letting archives initialized by serve or sync export immediately.\n\nDuckDB mirrors also need a repair for rows written before remote sanitization. The mirror schema migration now rewrites credential-bearing project identity remotes to their sanitized storage form and records a repair marker so compatibility checks can detect mirrors that still need the scrub.
roborev: Combined Review (
|
This PR turns report/export JSON into explicit v1 contracts for programmatic consumers. It adds shared schema, pricing provenance, and project identity metadata to usage daily and activity report outputs, and introduces a daemonless
agentsview export sessionssummary export for headless analytics. The session export is content-free, supports JSON/NDJSON, and includes per-session usage, model, cost, project, worktree, branch, machine, timestamp, and classification metadata without transcript content.Pricing provenance is centralized under
internal/export: reports use a resolver-derived block with source/table metadata, RFC 8785-style digest, fallback indicators,cost_source, and a bounded per-model effective rates map. Source-reported costs are marked so consumers know when token-times-rate recomputation is not expected, and reasoning tokens are handled as output-rate billing breakdowns.Project identity now persists raw observations at sync/import time and recomputes stable identities at export time. Remote-backed identities use normalized network remotes with
sha256:keys; path-backed fallbacks remain explicit and machine-local. The identity store is preserved through resync and mirrored through PostgreSQL/DuckDB so CLI and HTTP exports stay aligned across backends.The new session-summary export adds stable watermark/keyset pagination, cursor-reset signaling,
--all, NDJSON meta rows, root/child and automation filtering, and shared pricing/project metadata. Existing usage/activity payloads stay additive: metadata lands as sibling blocks, and daily breakdown arrays are pinned as arrays rather than omitted.Docs now describe the v1 contract rules, pricing digest input, project identity derivation, cursor behavior, session-export limits, and default exclusion caveats. Golden fixtures pin usage daily, usage daily with breakdowns, activity report, and session export JSON/NDJSON shapes. Stale
docs/superpowersdesign notes were removed, and the shared contract package was renamed frominternal/exportcontractstointernal/export.Reviewers should focus on:
internal/exportinternal/db/session_export.goandcmd/agentsview/export.goThe main tradeoff is landing the related export-contract issues together so field names and semantics stay shared across surfaces. This intentionally does not add redaction flags or per-row pricing provenance: raw project paths/remotes are emitted by default, and pricing provenance remains report-level with a bounded per-model map.