fix(hourly): polish cache schema, dispatch, sort defaults, and float guards - #359
Conversation
|
@crhan is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for the thorough review. Addressed in 974b28c: Fixed:
Won't fix / false positives:
|
92930f1 to
1bd3758
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…defaults, and float guards - bump TUI cache schema to 6 and core message_cache schema to 7 so old caches with empty hourly/turn fields don't deserialize as Fresh - restrict is_human_turn's '<' filter to a known set of internal tool tags so user prompts containing HTML/XML are no longer dropped from turn counts - route 'tokscale hourly' through the standard TUI/CLI dispatch so the TUI Hourly tab is reachable interactively and --light is honored - guard format_cost_per_million against NaN/Inf and non-positive denominators - stop re-sorting the entire hourly/daily dataset every render in overview chart; consume already-sorted data - match CLI fallback behavior in TUI hourly bucketing for messages with missing/zero timestamps
1bd3758 to
94af15e
Compare
…nd client filter UX (#467) Pre-release correctness and security fixes across the four PRs landed this cycle (#464, #454, #359, #355). ## Antigravity Trust boundary around the local language-server RPC was too loose: - Bound RPC body sizes at 16 MiB (Content-Length, chunked, and read-to-end paths) - Verify process identity by checking the executable path (`lsof` on macOS, `/proc/<pid>/exe` on Linux); accept paths containing either `antigravity` or `language_server` since some Antigravity-flavored servers launch from generic `language_server` binaries with `--app_data_dir antigravity` - Probe candidate endpoints with a real RPC call and JSON-shape check (probe body capped at 4 KiB) instead of trusting any 200 response; consume HTTP headers before reading body so the cap applies to the JSON body alone - Lock concurrent syncs on a per-cache PID lock file with bounded retry (3 attempts) instead of unbounded recursion. Eviction is gated on PID liveness only — long-running syncs no longer get stomped on by age-based timeouts. - Enforce manifest version on load: future versions abort, older versions start fresh - Recover corrupted manifests by moving them aside as `manifest.json.corrupt-<ts>` instead of failing every subsequent sync ## Codebuff Parser correctness around silent data loss: - Accumulate run-state usage across the full reverse `messageHistory` walk instead of returning on the first signal-bearing entry. Previously a newest assistant entry carrying only a model id would short-circuit the walk and silently drop real token counts on earlier entries. - Include the source-array ordinal in the fallback dedup key so two id-less assistant messages with identical session/timestamp/model/tokens no longer collapse into a single record - Reject non-positive numeric timestamps in the shared `parse_timestamp_value`/`parse_timestamp_str` helpers so messages with `timestamp: 0` or negative epochs fall through to chat-id / file-mtime fallback chain ## TUI + parsing User-visible client-filter UX: - Move `SYNTHETIC_HOTKEY` from `'x'` to `'n'`. `'x'` collided with Mux's hotkey, and the dispatch order made the displayed `[x]` for Synthetic purely cosmetic - Enable `ignore_case` on `--client/-c` so `OPENCODE`, `Codebuff`, and `antigravity` all parse as the same canonical filter ## Test results - `cargo test -p tokscale-cli` — 415 unit + 83 integration, all pass - `cargo test -p tokscale-core` — 566 unit + 10 codebuff + 3 hermes, all pass - `cargo check --workspace` — clean Each fix has a regression test where applicable.
Summary
tokscale hourlyCLI subcommand with--json,--light, date filters, and all client flags (including the newly added--kilo)h) to switch between daily and hourly breakdownCache%to clarify it's a multiplier not a percentageDetails
The hourly report aggregates token usage, cost, turn count, and message count by hour. The Turn count uses a 10-second dedup window to collapse rapid consecutive user messages into a single logical turn (matching CC's session behavior).
Cache× is defined as
cache_read_tokens / input_tokens— a value > 1 means more tokens were served from cache than paid for as fresh input, indicating good cache utilization.Test notes
Three pre-existing scanner tests (
test_scan_all_clients_claude,test_scan_all_clients_multiple,test_scan_all_clients_headless_paths) fail on upstreammainas well — they scan the developer's real~/.claude/projectsinstead of the temp dir due to an unrelated env/path issue. Not introduced by this PR.🤖 Generated with Claude Code