Skip to content

fix(usage): keep cache-write data and correct hit-rate gaps - #2548

Merged
wsp1911 merged 5 commits into
mainfrom
pr-2534-integration
Aug 27, 2026
Merged

fix(usage): keep cache-write data and correct hit-rate gaps#2548
wsp1911 merged 5 commits into
mainfrom
pr-2534-integration

Conversation

@wsp1911

@wsp1911 wsp1911 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Integrates #2534 with two follow-up corrections:

  • Keep provider-reported cache-write tokens in backend records, persistence, aggregation, and API responses; only remove the noisy cache-write series from the current chart UI.
  • Keep synthesized idle buckets at 0% for a continuous trend, while rendering active buckets without cache telemetry as real gaps and showing in the tooltip instead of claiming a measured 0% hit rate.
  • Preserve the hover markers added by fix(usage): drop cache_write metric, keep hit-rate trend line continuous #2534 and add focused coverage for hidden cache-write presentation, segmented hit-rate rendering, and tooltip semantics.

The final product diff against main is frontend-only; the Rust token-usage backend is unchanged.

Verification

  • cargo test -p bitfun-services-core --no-default-features --features token-usage-statistics --lib token_usage:: — 16 passed
  • cargo test -p bitfun-services-core --no-default-features --features local-storage --test storage_owner_contracts token_usage_service_persists_records_and_filters_subagents_by_default — 1 passed
  • cargo test -p bitfun-core --no-default-features --features agent-runtime --lib service::token_usage — 10 passed
  • pnpm --dir src/web-ui run test:run src/infrastructure/config/components/UsageStatisticsConfig.test.tsx src/infrastructure/api/tokenUsageStatisticsApi.test.ts --pool=threads --maxWorkers=1 — 11 passed
  • pnpm run i18n:audit — passed
  • pnpm run appearance:contract-audit — passed
  • Focused ESLint for the changed TypeScript files — 0 errors
  • git diff --check — passed

pnpm run type-check:web remains blocked by the pre-existing generated API error websocket-adapter.ts(21,3): Module "@/generated/api" has no exported member 'GitTrustReport'.

Validation scope

AI-assisted change with focused automated verification. No development server, interactive UI validation, or runtime remote-scenario validation was performed. The backend response shape remains unchanged, so this change does not add a new mixed-version protocol requirement.

chaos and others added 5 commits August 27, 2026 11:08
The trend chart's cache hit-rate polyline dropped null buckets and joined
the remaining points into one polyline, so an idle stretch (all token
counters at zero, no cache telemetry) was visually bridged by a high
dashed line connecting the buckets on either side - the chart implied a
~97% hit rate over hours where the tooltip correctly showed no data.

- split the hit-rate series into contiguous segments that stop at
  buckets without telemetry; an isolated point renders as a dot
- add hover marker dots for every series so small values stay visible
  on a zero-baseline token axis (e.g. 276K next to a 20M peak reads as
  flat zero without an anchor)
- format the tooltip hit rate with formatHitRate (two-decimal truncate)
  instead of Math.round for consistency with the summary cards
Splitting the hit-rate series at buckets without telemetry left isolated
dots and blank stretches, which read as a broken chart. Idle buckets
already draw every token series at zero, so plot the hit rate at 0%
there too and keep one continuous dashed line; the tooltip mirrors the
line with 0.00% instead of an en dash.
Keep provider-reported cache-write tokens in the backend records, aggregates, persisted statistics, and API response while removing the noisy series from the current chart UI.

Render synthesized idle buckets at 0% for continuity, but keep active buckets without cache telemetry as gaps and show an unavailable tooltip value instead of claiming a measured 0% hit rate.

Add focused coverage for the hidden series, segmented trend, and tooltip semantics.
@wsp1911
wsp1911 merged commit 3adf7be into main Aug 27, 2026
8 checks passed
1688mengdie pushed a commit to BitFun-SIG/taiji-plugin-library that referenced this pull request Aug 27, 2026
 usage hit-rate semantics

Adopted-from: GCWing#2534 (fix/usage-stat-chart-hit-rate, head 89c939f)
Scope: drop cache_write metric from statistics pipeline + chart, keep
hit-rate trend line continuous (gaps plot at 0%).

Conflict resolution per commander directive:
- cache_write display/aggregation tug-of-war with GCWing#2548 resolved in favor of
  GCWing#2534 in CHART PIPELINE (series dropped) while backend telemetry fields
  retained per GCWing#2548 data-retention (api types + test fixtures keep
  cacheWriteTokens).
- Rate rendering merged: rateFor(number|null) + unconditional hover dot +
  tooltip value hoveredHitRate ?? 0 to mirror rendered line.

Verification: cargo check -p bitfun-services-core --jobs 4 0e0w + pnpm type-check (recorded in sync-record-2534-adopt-20260827.md)
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