fix(claude): preserve cc-mirror tool result attribution - #659
Merged
IvGolovach merged 1 commit intoJun 4, 2026
Merged
Conversation
Validation * Validation tier: Tier 2 — Narrow Runtime Change, localized Claude parser attribution correction. * TDD red: cargo test -p tokscale-core sessions::claudecode::tests::test_cc_mirror_tool_result_keeps_variant_client_and_provider: FAIL before implementation, expected client attribution mismatch. * cargo test -p tokscale-core sessions::claudecode::tests::test_cc_mirror_tool_result_keeps_variant_client_and_provider: PASS * cargo test -p tokscale-core sessions::claudecode: PASS * cargo test -p tokscale-core cc_mirror: PASS * cargo fmt --check: PASS * git diff --check: PASS * git diff --cached --check: PASS * scripts/check-version-coherence.sh: PASS * Ledger: not applicable — not required for selected validation tier/change family. * Version: PASS, scripts/check-version-coherence.sh. * Not run: frontend validation tests — frontend files were not touched. Rollback * git revert HEAD
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
6 tasks
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.
Summary
tool_resultusage rows.Why
Tokscale can discover cc-mirror Claude-compatible variants, but Claude
tool_resultusage rows had a separate parsing path that could fall back to plainclaudeattribution. That makes variant-scoped usage harder to understand and can lose the provider context needed for accurate pricing when a cc-mirror variant points at a non-Anthropic backend.Related issue: #610.
Diff scope
crates/tokscale-core/src/sessions/claudecode.rs: threads the active client and provider context through Claude tool-result usage parsing.crates/tokscale-core/src/sessions/claudecode.rs: adds a regression fixture proving a cc-mirror variant keepscc-mirror/<variant>client attribution and the variant provider fallback on tool-result usage.Branch integrity
main.a86e688d620939d2c973c6d5625baa815ea223d7.0 behind / 1 aheadagainstorigin/main.a86e688d620939d2c973c6d5625baa815ea223d7.origin/mainis an ancestor of this branch.Commit integrity
75b321952d6858d8551be8794426c0829f3c333f fix(claude): preserve cc-mirror tool result attribution.scripts/check-version-coherence.sh.Diff hygiene
git diff --name-status origin/main...HEAD: onlycrates/tokscale-core/src/sessions/claudecode.rschanged.git diff --check origin/main...HEAD: PASS, no output.Validation mode and proof
Mode 2 — narrow runtime change, because the diff changes localized Claude parser attribution behavior and focused tests without touching migrations, auth, deployment tooling, or external service contracts.
cargo test -p tokscale-core sessions::claudecode::tests::test_cc_mirror_tool_result_keeps_variant_client_and_providerfailed before the implementation with plainclaudeattribution instead of the cc-mirror variant client.cargo test -p tokscale-core sessions::claudecode::tests::test_cc_mirror_tool_result_keeps_variant_client_and_provider: PASS.cargo test -p tokscale-core sessions::claudecode: PASS.cargo test -p tokscale-core cc_mirror: PASS, 9 tests.cargo fmt --all -- --check: PASS, no output.scripts/check-version-coherence.sh: PASS,Version coherence OK: 3.0.0.git diff --check origin/main...HEAD: PASS, no output.Required remote gates
Pending — GitHub Actions and mergeability checks will run after the PR is opened.
Migration notes
Not applicable — no database migration changed.
Runtime safety
The change only passes existing parser context into an existing Claude usage branch. It does not add external I/O, persistent state, concurrency, or new scan paths. No invariant regression introduced.
Documentation integrity
Not applicable — no docs, commands, or runbooks changed.
Rollback plan
Rollback: revert this PR. DB downgrade: not applicable. Data repair: not applicable. Operational caveats: reverting would restore plain Claude attribution for cc-mirror tool-result usage rows.
Known residual risks
Remote CI and GitHub mergeability are pending until the PR is opened. This PR is intentionally scoped to preserving attribution for cc-mirror tool-result rows; it does not expand cc-mirror discovery beyond the support already present on
main.Summary by cubic
Preserves
cc-mirror/<variant>client and provider attribution when parsing Claudetool_resultrows. This keeps pricing and diagnostics provider-aware, including for non-Anthropic backends.client_idand provider hints through Claude tool-result parsing.Written for commit 75b3219. Summary will update on new commits.