Skip to content

refactor: compare Claude Code versions with one function - #182

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/claude-version
Nov 21, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/claude-version

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/claude-version.md.

Summary

One function, version::claude_at_least(version, minor, patch) (src/version.rs), now decides every Claude Code version gate. It accepts a plain major.minor.patch of ASCII digits and compares it with 2.minor.patch; a missing, malformed, or u64-overflowing version is not at least anything.

It replaces idle::supported, compaction::version_supported (plus js_number, which only it and replay used), replay::version_supported (242 is now the named TTL_CONTROLS_PATCH), and subagents::version (Explore's 198 is now EXPLORE_INHERITS_PATCH). The four quirk-pinning tests are replaced by one table test of the new function. minimum_claude_patch is now Option<u64> so it feeds the function directly.

Net: 77 insertions, 164 deletions in src/, including the new module and its test.

Behavior change

Only malformed version strings change outcome: 2.01.0x200, 2.1.-0, 2.1.0x100, 1e3 parts and similar were accepted by compaction and replay and are now unsupported; 2.1.198-beta style suffixes were accepted by subagents and are now unsupported. Explore keeps reading a missing or malformed version as unknown (the review caught my first version treating it as older than 2.1.198 and reporting Haiku), so version::claude_version exposes the parse and claude_at_least is built on it. Real versions are plain digits, so I expect no change on real transcripts.

Public API

None. WindowControl::minimum_claude_patch (not re-exported from the library) changes i64 to u64; its serialized minimumClaudePatch is the same JSON integer.

Validation

  • just check (via quest gate): fmt, clippy -D warnings, 585 + integration tests pass.
  • Ran token-max doctor --since 2026-11-01 --details --plain --offline --defaults with the main build and this branch's build on this host's real transcripts. Both completed. The reports are not byte-identical, but the host's active sessions added about 230 requests between the two runs (256,338 vs 256,570), so this is not a clean differential: I did not find a version-gate difference, and I did not isolate one either.
  • Not exercised: a real transcript with a malformed version (none known to exist).

Models

Size: S
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (arm B)

Review

Rewritten by quest review after each round.

  • Head: 1faa17b

  • Base: origin/main at 99d2cc0

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1fbdd-25ad-7f63-9851-42686e30432e, round 2

  • Score: 10/10, The incremental change fixes malformed-version attribution and preserves the existing version comparison behavior, with no new findings.

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at 24709e8:

    • Fixed: medium, src/subagents.rs:760: Preserve unknown attribution for unparseable Explore versions; src/subagents.rs:760 now filters recorded versions through claude_version, whose strict three-component numeric parser rejects unknown, incomplete, suffixed, and overflowing versions so they receive ModelSource::Unknown.
  • Reviewer: Codex, gpt-6.1-sol, low effort, shadow

  • Session: 01a1fbdd-25ad-7bf3-a292-09dfefb98e4a, round 2

  • Score: 10/10, The head fixes the malformed-version attribution issue, and code inspection found no new issues in the incremental changes.

  • Rounds: 2; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at 24709e8:

    • Fixed: medium, src/subagents.rs:760: Keep unparseable Explore versions unknown; src/subagents.rs now filters recorded versions through claude_version before comparing releases, preserving Unknown for malformed versions, with a regression assertion for 2.1.197-beta.

Summary by CodeRabbit

  • Bug Fixes
    • Claude Code compatibility checks now apply consistent version comparisons across compaction, idle handling, replay controls, and Explore support. Versions that are missing, malformed, or contain non-numeric components are treated as unsupported.
  • Refactor
    • Consolidated version handling for more consistent behavior across supported features.

Quest-Claim: c4b15e1c08789f35
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

A shared Claude version parser now handles version thresholds across compaction, idle-compaction, replay TTL-control, and Explore checks. The parser accepts exactly three ASCII-digit components that fit in u64; callers use it instead of local parsers.

Changes: Claude Version Checks

Layer / File(s) Summary
Shared version parser
src/version.rs, src/lib.rs, quest/m1/claude-version.md
Adds a private parser and threshold helper with tests for valid comparisons and invalid input. Removes the document that described inconsistent parsers and proposed a shared comparator.
Compaction and idle-compaction gates
src/model.rs, src/compaction.rs, src/idle.rs
Uses the shared helper for Claude support and idle-compaction version thresholds. Changes the configured minimum patch type to Option<u64>. Removes local parsers and their tests.
Replay and Explore gates
src/replay.rs, src/subagents.rs
Uses the shared helper for replay TTL-control and the Explore 2.1.198 gate. Explore returns unknown for unrecognized versions, including beta-suffixed versions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

  • kixel-ai/token-max#174: Changes the Explore model branch that uses the 2.1.198 gate, which this pull request also updates.

Suggested reviewers: pullfrog

Merge Risk: Minimal · up to 1faa1

This centralizes Claude version gating. Only malformed version strings change behavior, and real versions are plain digits, so no user-visible change is expected. No merge-blocking risk was found in the reviewed code.

Security architecture risk: Minimal · up to 1faa1

The change standardizes version checks without adding execution authority or weakening confirmation before settings changes. No material security, failure-containment, or ownership regression was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed contract can affect recommendations for analyzed profiles and Explore provenance reporting. Accepted recommendations can ultimately reach local or selected remote settings through the existing application workflow; the parser itself adds no execution or credential authority.

Trust Boundaries and Controls

  • observed — The inspected CLI application path requires both final confirmation and accepted selections before invoking local or remote writes. Confirmation returns false on end of input and requires an explicit yes response. Changed version eligibility does not bypass these controls.

Resilience and Maintainability Implications

  • observed — The parser returns an optional tuple or boolean without modifying shared state. Parse failure therefore introduces no reservation, partial commit, cleanup obligation or recovery state in the new module.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "refactor: compare Claude Code versions with one function" matches the main change. The PR adds a shared version::claude_at_least(version, minor, patch) function in src/version.rs and replac…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "refactor: compare Claude Code versions with one function" matches the main change. The PR adds a shared version::claude_at_least(version, minor, patch) function in src/version.rs and replaces the separate version parsers in idle, compaction, replay, and subagents with it. The title is concise, specific, and names the primary change without file lists or vague terms.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 40bd21b6-4753-45e4-a228-ed4bc34b5145
Commits

Reviewing files that changed from the base of the PR and between 99d2cc0 and 1faa17b.

Files selected for processing: 8

  • quest/m1/claude-version.md
  • src/compaction.rs
  • src/idle.rs
  • src/lib.rs
  • src/model.rs
  • src/replay.rs
  • src/subagents.rs
  • src/version.rs
Files with no reviewable changes: 1

  • quest/m1/claude-version.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Compare Claude Code versions with one function refactor: compare Claude Code versions with one function Nov 21, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 21, 2026 02:10

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. It puts the version gate in one strict parser (src/version.rs), and the four call sites now share its semantics. On real major.minor.patch transcripts it changes nothing.

Reviewed changes

I reviewed the full diff across all 8 files.

  • version::claude_version / claude_at_least: The new parser needs exactly three non-empty ASCII digit parts that fit in u64. Comparing against (2, minor, patch) as a tuple matches the old major > 2 || (major == 2 && …) logic.
  • Call-site migration: idle, compaction and replay now call claude_at_least(…, 1, patch) with the same patch numbers (314, 290, 288/minimum_claude_patch, 242). compaction::js_number is removed, and its only other user was replay. report::js_number is a separate formatter and is not affected.
  • Explore attribution: A version that is missing or not plain digits still gives ModelSource::Unknown, because the code filters through claude_version before comparing. A regression assertion covers 2.1.197-beta.
  • minimum_claude_patch → Option<u64>: The only producer is controls.rs (literals 288/304), and the serialized JSON integer does not change.
  • Tests: One table test of malformed inputs replaces the four quirk-pinning tests. This includes the overflow case, which idle used to treat as infinity and therefore as supported.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 139bb27 Nov 21, 2026
10 of 11 checks passed
@kixelated
kixelated deleted the quest/m1/claude-version branch November 21, 2026 10:10
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.

1 participant