Repository navigation
refactor: remove production code that exists only for tests - #185
Merged
Merged
Conversation
Quest-Claim: b928b367c07ed32b
Nothing in production serializes the scan or the model types under it: the SSH stream carries wire::Outcome and the session export carries sessions::Session. The derives, serde attributes and six hand-written impls (Id, Few, Settings, ServerTools, Ids, Exposure) served only privacy tests, which now check Debug output instead. Debug includes the fields serde skipped, so those tests are stricter. Usage keeps a plain Serialize for the reader's Codex total key and request identity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Production built an `IdlePeriod` per period and threaded a `detail` slice through every native and T3 run only for tests to read. Tests now assert on the period counts, context groups, cohorts and exact deltas the report uses, and `Calibration::events`, which only that trace read, goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Return idle scenarios directly, name every remaining serde user in the model header, and delete the finished quest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/idle.rs # src/model.rs
kixelated
marked this pull request as ready for review
November 21, 2026 10:32
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. It deletes the idle detail trace and the Scan tree's Serialize surface outright and moves the tests onto aggregates the report already exposes, so no cfg(test) scaffolding takes their place.
Reviewed changes
I read the full diff at b12e04f, checked that serialized output is unchanged, and ran clippy and the lib tests locally.
- Idle trace removal:
Runner::runandt3_replaylose only thedetail.get_mut(i).filter(|_| point)side-recording blocks. Everyledger.charge/addpath is untouched.activatenow resolves the cohort throughIndexMap::getinto a local, with the samefractionfallback to1.0. - Test rewrites in
src/idle.rs: per-period lookups becamePeriodCounts/by_context/activation_cohortsassertions plus hand-derived exact deltas. A few assertions are now aggregate rather than per-request, for example "no eligible periods" instead of "ais absent". The cost assertions beside them still pin the behavior. Serializeremoval insrc/model.rs:Usagedroppedrename_all = "camelCase"and its explicitwrite5m/write1h/… renames. None of its fields contains an underscore, so the JSON keys are unchanged, and so are the reader's Codex dedup key and request ids.- The remaining serde types (
Harness,Location,Usage,T3IdleMode,Margin,ContextKind,Usd) match the new module header.
- Privacy tests now use
Debug: the crate's only hand-writtenDebugimpls areId(prints the full text) andIds(debug_list). Neither redacts anything, so theformat!("{x:?}")checks are real and stricter than the serde ones they replace. The T3 test that emptiesScan.sessionsfirst is narrowed only for the native session ids thesessionsexport keeps on purpose. - Validation:
cargo clippy --all-targets --locked -- -D warningsis clean andcargo test --libpasses all 589 tests. No docs or learnings still mention the removed symbols.
claude-opus-5-5 | 𝕏
Collaborator
Author
|
Maintainer decision, in the merge pick round for this PR:
(Written by Claude Opus 5.5) |
Collaborator
Author
|
The maintainer decision needs no change: head b12e04f already has the title without (Written by Claude Opus 5.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Finishes quest/m1/test-only-code.md: production no longer carries anything only tests read, and the quest file is deleted.
Summary
Idle's
detailtrace (src/idle.rs,src/compaction.rs)IdlePeriod,PeriodCalibration,Period::detail, thedetailed_checks/detailed_t3_checkswrappers, the[Vec<IdlePeriod>; 2]return tuples, theProfiled::detailflag, and everydetail.get_mut(i).filter(|_| point)block inRunner::runandt3_replay.Calibration::events, which only that trace read.scale, which became dead.Period::cohort, whichactivatenow keeps as a local.idle_checks,t3_idle_checks,Profiled::scenarioandt3_comparisonnow return their checks directly.PeriodCountskinds, through a smallperiods(counts, |kind| ...)helper.by_context.activation_cohorts.applied + 0.05 + 0.1: one measured session, a final period at the cohort's 0.5 fraction, and another version falling back to full activation.brewriting 40k instead of 320k at $5/MTok. It also checks the cost rises by exactly 10k writes when the sample resumes 10k larger.Serializeon theScantree (src/model.rsand the privacy tests)Serializederives (72 inmodel.rs, plusUnreadable).#[serde]attributes.Id,Few,Settings,ServerTools,Ids,Exposure.wire,sessionsor doctor carry.Usagealso keeps a bareSerialize, since its JSON is the reader's Codex dedup key and feeds request ids; it drops renames that changed nothing.model.rs's header now says this, instead of claiming the SSH stream carries these types.format!("{x:?}")instead ofserde_json::to_string. That is stricter, sinceDebugincludes fields serde skipped.t3::tests::native_history_is_shared_and_exact_run_evidence_never_fills_billed_tiers. Debug showsScan.sessions, which holds native session IDs on purpose for thesessionsexport, so the check empties that field first and says why.exposure.rsreferences count, theIdJSON insafe.rs, andIdsJSON equality inmodel.rs.Compile time
Median of 3, after
touch src/lib.rs, measured before mergingmain. The machine was loaded, so the CPU time is the steadier figure.cargo buildcargo test --no-runThat is about 25% less CPU for the build and 15% less for the test build.
Validation
just checkpasses after mergingmain: 589 lib tests, plus the cli, run_script and ssh suites.mainand this branch at release and ran both on this host's real transcripts at the same moment:doctor --details --plain --offline --since 2026-10-01(216,794 requests, native and T3 idle lines included) andsessions --since 2026-10-01. With the report'snowtimestamp normalized, both doctor reports are byte-identical, and thesessionsexports are identical too. Both doctor runs exit 1, which is the code for its red recommendations.Public API
wire::Outcomeandsessions::Sessionkeep their serde.token_max::BackgroundFeatureno longer implementsSerialize. The crate's re-exports serve its own binary and integration tests, and nothing serialized this type. Choice for review: I left the title without!, since the crate publishes a CLI rather than a library API.Choices for review
Scan.sessionsfirst, as described above.Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: b12e04f
Base: origin/main at 12de0b6
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1fda8-5638-7fb1-bade-3d54fa73b78d, round 1Score: 9/10,
The refactor preserves production behavior and wire/export serialization with no actionable regressions found in static review, but builds and tests were not run as instructed.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none
Reviewer: Codex, gpt-6.1-sol, medium effort, shadow
Session:
01a1fda8-5638-7602-baee-7e7fa20ae1ae, round 1Score: 9/10,
The refactor removes test-only tracing and unused serialization without apparent production behavior changes or actionable defects, but builds and tests were not run as instructed.Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none
Summary by CodeRabbit