Skip to content

Share Session usage accounting across Run metrics and Experiments - #1322

Merged
JacobStephens2 merged 4 commits into
mainfrom
issue-1319
Oct 25, 2026
Merged

JacobStephens2 merged 4 commits into
mainfrom
issue-1319

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Run metrics and Experiments now resolve equivalent trace evidence through one Session usage module. Partial totals preserve omitted token/cache fields and costs; reported zeroes remain authoritative.

Run metrics (normalized events) ─┐
                                ├─ Session usage ─ consumer grouping / presentation
Experiments (retained spans) ────┘

No stored records or trace formats change. Historical metrics use the shared reader without rewriting saved completion snapshots. The glossary, navigation index, guide and hand-written site pages describe the settled rules.

Closes #1319

Evidence

  • Before: cargo test --test metrics partial_model_totals_preserve_known_call_usage -- --exact --nocapture failed on the review base: input/cache reads became null after an output-only Model total.
    After: the same regression passes with input 16, output 3, cache reads 5; replacing raw input with 20 yields inclusive input 25, retaining cache reads and call cost.
  • Ten paired event/span interface tests pass, exercising sparse/scoped amendments, repeated completions, latest totals, cache conventions, overlapping turns, unknown Models, zeroes, cost precedence and saturating addition.
  • Focused metrics, completion-snapshot and Experiment regressions pass. Existing Experiment tests retain Void attempts, Resumes, Grader exclusion and selected-span read counts.
  • cargo check --all-targets and cargo clippy --all-targets -- -D warnings pass. All 50 site browser tests pass on the final commit.
  • An earlier full run stopped at distinct_suite_task_pairs_keep_distinct_trial_results after its fake Model Grader failed. The exact isolated rerun passed: cargo nextest run --test experiments -E 'test(=distinct_suite_task_pairs_keep_distinct_trial_results)' (1 passed, 32.6 s). No product-code change was made for the unreproduced failure.
  • Final validation on f540a16c: scripts/affected-tests main passed all 50 site browser tests and all 3,022 Rust tests (66 skipped). Timed selector wall time: 1,954.34 s, including 52.41 s of Rust compilation; Nextest test execution: 1,715.83 s.

Test seams

  • session::usage::from_events and session::usage::from_spans: equivalent normalized events and recorded retained spans, returning one owned Session usage summary; summary addition combines distinct Sessions.
  • thirdshift metrics ... --json: historical reconstruction, partial Model totals, and completion snapshots.
  • Existing Experiment JSON/text and captured-reader seams: partial totals, unknown Models, Void attempts, Resumes, Grader exclusion and one spans read per selected Session.

Review coverage

Independent thirdshift-code-review Standards and Spec reviews against main (6ecf0715) each found zero findings and inspected all 15 changed files, including generated site/docs/index.html. Neither axis excluded generated output. No changed file was left unread.

Reports, including each axis's complete files-read list, are retained at .thirdshift-review-TcwoHu/standards.md and .thirdshift-review-TcwoHu/spec.md for the Session trace.

Unaddressed findings

Standards

None.

Spec

None.

Security

None. Guidance-mode review of 6ecf0715...HEAD (15 files, accounting consolidation into src/session/usage.rs) found no introduced vulnerability: inputs are the operator's own local session traces and retained spans (no lower-trust principal, no new sink, network, auth, secret, or filesystem-discovery path); the thirdshift.model_usage JSON parse, saturating u64 arithmetic, and cost handling moved verbatim from the prior per-consumer implementations; the trace::set visibility widening stays inside the crate-private session module; and the harness cache-convention check is behavior-identical (Claude | Grok). No proof-of-concept failed, so no Security fix was made. session::usage unit tests (10 passed) and the partial_model_totals_preserve_known_call_usage metrics regression pass. No pre-existing Base-branch findings were tested or recorded in this review.

Security review outcome

No unaddressed introduced findings.

Merge Danger

Door: two-way

Reader/accounting refactor; no data migration. Existing completion snapshots remain fixed.

Blast Radius: accounting

New or historically reconstructed Run metrics and Experiment token/cost summaries use the shared rules.

Built with codex · gpt-6.1-sol · xhigh

@JacobStephens2
JacobStephens2 merged commit 09d6d40 into main Oct 25, 2026
18 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1319 branch October 25, 2026 14:31
@JacobStephens2 JacobStephens2 mentioned this pull request Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deepen Session usage accounting across Run metrics and Experiments

1 participant