fix(compression): record no-op compression runs so Stacked is visible in analytics (#4268) - #5277
Merged
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
… in analytics (#4268) A compression_analytics row was written only on a net-positive saving (chatCore: result.compressed || fallbackApplied || cavemanOutputModeApplied). A Stacked RTK->Caveman pipeline that ran on already-compact context saved nothing -> no row -> indistinguishable from 'never dispatched' (byMode.stacked.count stayed flat while Ultra climbed). Attempted-but-no-op runs are now recorded via writeCompressionSkip with a skip_reason. A new skip_reason column (added through the existing ensureCompressionAnalyticsColumns ALTER path) marks these rows; the analytics summary excludes them from every saving aggregate (via a single successWhere = 'skip_reason IS NULL' filter, so historical totals/averages are byte-identical) and surfaces them as per-mode 'skipped' plus totalSkipped / bySkipReason. The Mode Breakdown shows 'N skipped (no-op)'. TDD: compressionAnalytics.test.ts gains coverage that skip rows are counted separately without polluting saving aggregates, and that a skip-only mode still appears (count 0, skipped > 0). Fail-before proven by reverting the successWhere exclusion (both new tests fail). typecheck:core + eslint clean; 17/17 suite green.
diegosouzapw
force-pushed
the
fix/4268-stacked-observability
branch
from
June 29, 2026 00:40
faa5416 to
3a0a0f5
Compare
Merged
tkgo11
pushed a commit
to tkgo11/OmniRoute
that referenced
this pull request
Sep 23, 2026
… in analytics (diegosouzapw#4268) (diegosouzapw#5277) A compression_analytics row was written only on a net-positive saving (chatCore: result.compressed || fallbackApplied || cavemanOutputModeApplied). A Stacked RTK->Caveman pipeline that ran on already-compact context saved nothing -> no row -> indistinguishable from 'never dispatched' (byMode.stacked.count stayed flat while Ultra climbed). Attempted-but-no-op runs are now recorded via writeCompressionSkip with a skip_reason. A new skip_reason column (added through the existing ensureCompressionAnalyticsColumns ALTER path) marks these rows; the analytics summary excludes them from every saving aggregate (via a single successWhere = 'skip_reason IS NULL' filter, so historical totals/averages are byte-identical) and surfaces them as per-mode 'skipped' plus totalSkipped / bySkipReason. The Mode Breakdown shows 'N skipped (no-op)'. TDD: compressionAnalytics.test.ts gains coverage that skip rows are counted separately without polluting saving aggregates, and that a skip-only mode still appears (count 0, skipped > 0). Fail-before proven by reverting the successWhere exclusion (both new tests fail). typecheck:core + eslint clean; 17/17 suite green.
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.
Closes #4268
Problem
Stacked(RTK→Caveman) compression is dispatched correctly on the/v1path, butbyMode.stacked.countstays flat and analytics show nothing — making it indistinguishable from "never ran". Root cause (confirmed with the maintainer's own diagnosis): acompression_analyticsrow is written only on a net-positive saving (chatCore.ts:result.compressed || fallbackApplied || cavemanOutputModeApplied). When a Stacked pipeline runs on already-compact context, both engines no-op → net 0 → no row at all. Ultra's heuristic almost always trims something, so its count climbs — exactly the asymmetry the reporter observed.Fix (additive, no migration file needed)
skip_reasoncolumn oncompression_analytics, added through the existingensureCompressionAnalyticsColumnsALTER path (same pattern as the other extended columns).writeCompressionSkip(tokens_saved = 0,skip_reason: "no_savings"). Theelseonly fires whenresult.statsis truthy — i.e. the pipeline genuinely ran (the earlystats: nullreturns for empty/disabled bodies are untouched), so we don't record spurious skips.successWhere = appendCondition(whereClause, "skip_reason IS NULL")applied to every saving aggregate, so existing totals/averages are byte-identical (no skip rows exist for historical data). Skips are surfaced separately as per-modeskipped, plustotalSkippedandbySkipReason.· N skipped (no-op), so a mode that only ever no-ops is now visible (count 0, skipped > 0).Validation (Hard Rule #18 — TDD)
tests/unit/compression/compressionAnalytics.test.ts:totalRequests/byMode.count/totalTokensSavedexclude them);count 0, skipped 2,totalSkipped,bySkipReason.no_savings).successWhereexclusion → both new tests fail; restored → 17/17 green.typecheck:core0 errors, eslint clean, related compression suites green.