Repository navigation
feat(monitoring,costs,quota): Monitoring reorg + Costs section + Quota Share Engine (planos 16+22) - #2859
Merged
diegosouzapw merged 98 commits intoMay 30, 2026
Conversation
Creates migrations 073 (quota_pools + quota_allocations) and 074 (quota_consumption sliding-window counter). Both are idempotent via CREATE TABLE IF NOT EXISTS and CREATE INDEX IF NOT EXISTS. FK ON DELETE CASCADE from quota_allocations to quota_pools. Fixes B2 IDs.
…B/F2) Implements listPools, getPool, createPool, updatePool, deletePool, upsertAllocations (replace strategy via transaction), and listAllocationsForApiKey. All SQL uses prepared statements. Local type shapes aligned with src/lib/quota/dimensions.ts contract (B13).
Implements getBucket, incrementBucket (atomic UPSERT), getPair (curr+prev for sliding window formula), and gcOlderThan (stale bucket cleanup). Atomic increment uses INSERT ... ON CONFLICT DO UPDATE — no separate read-modify-write cycle needed.
… plans (B/F2) Implements getPlan, listPlans, upsertPlan (idempotent ON CONFLICT DO UPDATE), and deletePlan. Serializes QuotaDimension[] as JSON into dimensions_json column and parses back on read. Malformed JSON returns empty dimensions rather than throwing.
Adds re-export blocks for quotaPools (7 functions), quotaConsumption (4 functions with gcQuotaConsumption alias), and providerPlans (4 functions with getProviderPlan/listProviderPlans/etc. aliases). Zero logic added to localDb.ts — Hard Rule #2 maintained.
Adds QUOTA_STORE_DRIVER, QUOTA_STORE_REDIS_URL, QUOTA_SATURATION_THRESHOLD, QUOTA_SOFT_DEPRIORITIZE_FACTOR, and QUOTA_CONSUMPTION_RETENTION_DAYS as per §3.8 of master-plan-group-B.
… (B/F2) Adds 44 tests across 4 files: - db-quota-pools.test.ts (16 tests): CRUD lifecycle, upsertAllocations replace strategy, FK CASCADE, listAllocationsForApiKey cross-pool. - db-quota-consumption.test.ts (12 tests): getBucket, incrementBucket atomic (100 concurrent), getPair, gcOlderThan boundary semantics. - db-provider-plans.test.ts (10 tests): upsertPlan idempotence, getPlan JSON parsing, listPlans, deletePlan. - db-quota-migrations-idempotency.test.ts (6 tests): schema assertions and double-run idempotency for migrations 073-075.
…ctivity at top (B/F3) - MONITORING_ITEMS reduced to single `activity` item at `/dashboard/activity` - New LOGS_GROUP (logs/logs-proxy/logs-console) extracted from flat monitoring items - New SYSTEM_GROUP (health/runtime) extracted from flat monitoring items - AUDIT_GROUP preserved unchanged - Monitoring section children: [...MONITORING_ITEMS, LOGS_GROUP, AUDIT_GROUP, SYSTEM_GROUP] - COSTS_PARAMS_GROUP removed from monitoring section (items migrate to COSTS_ITEMS) - `activity` added to HIDEABLE_SIDEBAR_ITEM_IDS; `logs-activity` preserved for back-compat (B11) - Updated existing sidebar-visibility.test.ts to match new monitoring item structure
…ystemGroup, costsOverview (B/F3) Add new sidebar i18n keys without removing existing ones (back-compat B11/B12): - sidebar.activity / sidebar.activitySubtitle - sidebar.logsGroup - sidebar.systemGroup - sidebar.costsOverview / sidebar.costsOverviewSubtitle Existing sidebar.costs, sidebar.costsSection, sidebar.costsSubtitle preserved.
Three new test files: - sidebar-monitoring-reorg.test.ts: asserts monitoring has 4 children (activity item + logs/audit/system groups), no costs-parameters group, no logs-activity in items - sidebar-costs-section.test.ts: asserts costs section exists with 4 items in correct order, costs removed from analytics, costs positioned between analytics and monitoring - sidebar-back-compat.test.ts: asserts activity added + logs-activity preserved in HIDEABLE_SIDEBAR_ITEM_IDS, admin preset shows activity and hides logs-activity (B30)
…-key mutex (B/F6)
…vailability) (B/F6)
…, generous/strict modes, cap-absolute) (B/F6)
… saturationSignals + storeFactory (B/F6)
…esolver + burnRate + saturation)
…e duplicate icon span (B/G4)
Line 68: {statusCls} string literal → \${statusCls} template literal so status color applies.
Remove duplicate <span> wrapping (lines 71-73) that rendered the icon twice via copy-paste bug.
Add stackedBarTitle and usedSuffix keys to quotaShare namespace in both pt-BR and en locales to support the new StackedAllocationBar component.
…s (B/G4) New test file stacked-allocation-bar.test.tsx covers: - empty allocations → null render - 3 segments with correct widths (50%/30%/20%) - 1 segment at 100% - labels without usedSuffix when usage=null - usedSuffix labels when usage provided (consumed/fairShare%) - fallback to apiKeyId when keyLabel missing pool-card.test.tsx updated: mock StackedAllocationBar, assert it renders when pool.allocations is non-empty.
…rowing count (B/G5)
…ive/keys/avg-util/borrowing) (B/G5)
…Aggregate (gap #5 closed)
5 gaps (G1-G5) validated and merged into pai. Coverage re-measured: St:79.84% / Br:73.68% / Fn:82% / Ln:79.84% — gate 40/40/40/40 PASS. 57 unit tests + 26 vitest UI tests pass for gap-specific suites.
…al coverage 80%) Gap closure exceeded original 75/75/75/70 requirement. Measured on Group B branch: statements 79.83%, branches 73.68%, functions 82%, lines 79.83% — all above original thresholds. No need to defer restoration to post-merge.
Two gaps found in second-pass code review of Group B: 1. B26 violation: DELETE /api/quota/plans/[connectionId] did not emit logAuditEvent. Per master plan B26, every plan mutation must audit. Now emits quota.plan.updated with metadata.reverted=true to mark the revert-to-auto/catalog semantic. Test integration extended with assertion that audit event is present after DELETE. 2. pt-BR / pt locales had "costsSection": "Costs" (English label) instead of the Portuguese "Custos". Other section labels in the same block are left in English intentionally (analytics, monitoring) — they are project-wide untranslated terms; "Custos" is the established repo translation for the Costs section title. Validation: - npm run typecheck:core: clean - tests/integration/quota-plans-crud.test.ts: 10/10 pass (includes new assertion on DELETE → audit event) - eslint --no-warn-ignored on touched files: clean
…) + fix transform bug Conflicts: migrations 073/074/075->077/078/079 (collision w/ base 073-076); localDb union (quota + tokenLimits/plugins re-exports); i18n en/pt-BR deep-merge (base translations win over __MISSING__ placeholders; sidebar.costsSection=Custos); CLAUDE.md keeps base coverage rule (>=40%). Pre-existing #2859 bugs surfaced by validation & fixed: chatCore onStreamComplete 'await import'->'import().then()' (await was outside async fn, broke tsx transform of 17 chat-* test files); documented 5 QUOTA_* env vars in ENVIRONMENT.md to fix env-doc-sync drift.
diegosouzapw
added a commit
that referenced
this pull request
Jun 1, 2026
…env-doc fixes - bump package.json / open-sse / electron / openapi / llm.txt to 3.8.8 - restructure CHANGELOG: Unreleased -> [3.8.8], dedup broken Notion/MCP block (was 12x) - add every PR since v3.8.7 that was missing: Quota Share Engine (#2859/#3022/#3032), page redesigns (#2827/#2839/#2847/#2849/#2869/#2873), and fixes #2960/#2973/#2984/ #3021/#3029/#3031/#3035/#3036/#3037/#3039/#3043/#3028; folded #2978/#2988/#3041 - insert [3.8.8] section into all 41 i18n CHANGELOGs + sync llm.txt mirrors - document OMNIROUTE_PLUGINS_ALLOW_EXEC in .env.example + ENVIRONMENT.md (env-doc-sync gap)
Merged
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…) + fix transform bug Conflicts: migrations 073/074/075->077/078/079 (collision w/ base 073-076); localDb union (quota + tokenLimits/plugins re-exports); i18n en/pt-BR deep-merge (base translations win over __MISSING__ placeholders; sidebar.costsSection=Custos); CLAUDE.md keeps base coverage rule (>=40%). Pre-existing cheaper-inference#2859 bugs surfaced by validation & fixed: chatCore onStreamComplete 'await import'->'import().then()' (await was outside async fn, broke tsx transform of 17 chat-* test files); documented 5 QUOTA_* env vars in ENVIRONMENT.md to fix env-doc-sync drift.
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…pages-v3-B-monitoring-quota-share feat(monitoring,costs,quota): Monitoring reorg + Costs section + Quota Share Engine (planos 16+22)
HouMinXi
pushed a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 2, 2026
…env-doc fixes - bump package.json / open-sse / electron / openapi / llm.txt to 3.8.8 - restructure CHANGELOG: Unreleased -> [3.8.8], dedup broken Notion/MCP block (was 12x) - add every PR since v3.8.7 that was missing: Quota Share Engine (cheaper-inference#2859/cheaper-inference#3022/cheaper-inference#3032), page redesigns (cheaper-inference#2827/cheaper-inference#2839/cheaper-inference#2847/cheaper-inference#2849/cheaper-inference#2869/cheaper-inference#2873), and fixes cheaper-inference#2960/cheaper-inference#2973/cheaper-inference#2984/ cheaper-inference#3021/cheaper-inference#3029/cheaper-inference#3031/cheaper-inference#3035/cheaper-inference#3036/cheaper-inference#3037/cheaper-inference#3039/cheaper-inference#3043/cheaper-inference#3028; folded cheaper-inference#2978/cheaper-inference#2988/cheaper-inference#3041 - insert [3.8.8] section into all 41 i18n CHANGELOGs + sync llm.txt mirrors - document OMNIROUTE_PLUGINS_ALLOW_EXEC in .env.example + ENVIRONMENT.md (env-doc-sync gap)
Poid-ZA
pushed a commit
to Poid-ZA/OmniRoute
that referenced
this pull request
Aug 5, 2026
…) + fix transform bug Conflicts: migrations 073/074/075->077/078/079 (collision w/ base 073-076); localDb union (quota + tokenLimits/plugins re-exports); i18n en/pt-BR deep-merge (base translations win over __MISSING__ placeholders; sidebar.costsSection=Custos); CLAUDE.md keeps base coverage rule (>=40%). Pre-existing cheaper-inference#2859 bugs surfaced by validation & fixed: chatCore onStreamComplete 'await import'->'import().then()' (await was outside async fn, broke tsx transform of 17 chat-* test files); documented 5 QUOTA_* env vars in ENVIRONMENT.md to fix env-doc-sync drift.
Poid-ZA
pushed a commit
to Poid-ZA/OmniRoute
that referenced
this pull request
Aug 5, 2026
…pages-v3-B-monitoring-quota-share feat(monitoring,costs,quota): Monitoring reorg + Costs section + Quota Share Engine (planos 16+22)
Poid-ZA
pushed a commit
to Poid-ZA/OmniRoute
that referenced
this pull request
Aug 5, 2026
…env-doc fixes - bump package.json / open-sse / electron / openapi / llm.txt to 3.8.8 - restructure CHANGELOG: Unreleased -> [3.8.8], dedup broken Notion/MCP block (was 12x) - add every PR since v3.8.7 that was missing: Quota Share Engine (cheaper-inference#2859/cheaper-inference#3022/cheaper-inference#3032), page redesigns (cheaper-inference#2827/cheaper-inference#2839/cheaper-inference#2847/cheaper-inference#2849/cheaper-inference#2869/cheaper-inference#2873), and fixes cheaper-inference#2960/cheaper-inference#2973/cheaper-inference#2984/ cheaper-inference#3021/cheaper-inference#3029/cheaper-inference#3031/cheaper-inference#3035/cheaper-inference#3036/cheaper-inference#3037/cheaper-inference#3039/cheaper-inference#3043/cheaper-inference#3028; folded cheaper-inference#2978/cheaper-inference#2988/cheaper-inference#3041 - insert [3.8.8] section into all 41 i18n CHANGELOGs + sync llm.txt mirrors - document OMNIROUTE_PLUGINS_ALLOW_EXEC in .env.example + ENVIRONMENT.md (env-doc-sync gap)
This was referenced Aug 14, 2026
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…) + fix transform bug Conflicts: migrations 073/074/075->077/078/079 (collision w/ base 073-076); localDb union (quota + tokenLimits/plugins re-exports); i18n en/pt-BR deep-merge (base translations win over __MISSING__ placeholders; sidebar.costsSection=Custos); CLAUDE.md keeps base coverage rule (>=40%). Pre-existing cheaper-inference#2859 bugs surfaced by validation & fixed: chatCore onStreamComplete 'await import'->'import().then()' (await was outside async fn, broke tsx transform of 17 chat-* test files); documented 5 QUOTA_* env vars in ENVIRONMENT.md to fix env-doc-sync drift.
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…pages-v3-B-monitoring-quota-share feat(monitoring,costs,quota): Monitoring reorg + Costs section + Quota Share Engine (planos 16+22)
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…env-doc fixes - bump package.json / open-sse / electron / openapi / llm.txt to 3.8.8 - restructure CHANGELOG: Unreleased -> [3.8.8], dedup broken Notion/MCP block (was 12x) - add every PR since v3.8.7 that was missing: Quota Share Engine (cheaper-inference#2859/cheaper-inference#3022/cheaper-inference#3032), page redesigns (cheaper-inference#2827/cheaper-inference#2839/cheaper-inference#2847/cheaper-inference#2849/cheaper-inference#2869/cheaper-inference#2873), and fixes cheaper-inference#2960/cheaper-inference#2973/cheaper-inference#2984/ cheaper-inference#3021/cheaper-inference#3029/cheaper-inference#3031/cheaper-inference#3035/cheaper-inference#3036/cheaper-inference#3037/cheaper-inference#3039/cheaper-inference#3043/cheaper-inference#3028; folded cheaper-inference#2978/cheaper-inference#2988/cheaper-inference#3041 - insert [3.8.8] section into all 41 i18n CHANGELOGs + sync llm.txt mirrors - document OMNIROUTE_PLUGINS_ALLOW_EXEC in .env.example + ENVIRONMENT.md (env-doc-sync gap)
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
Grupo B do refactorpages v3.8.6 — entrega consolidada de 2 planos:
AuditLogTab.tsxdeletado (duplicata confirmada),CompressionLogTabnamespace fix (settings→logs),/api/compliance/audit-logganha?level=high|all.localStorage), rastreamento real por API key, enforcement no caminho quente (chatCore.tsPRE/POST hook +combo.tssoft penalty), algoritmo fair-share work-conserving multi-dimensional (% / requests / tokens / $) com Sliding Window Counter 2-bucket, drivers SQLite (default) + Redis (opcional), 13 endpoints REST, UI redesign + página de Plans (override por provider).10 frentes paralelas executadas e mergeadas
quotaPools,quotaConsumption,providerPlans) +localDbre-exports/dashboard/activity) + audit-log?level=highfilter + delete AuditLogTabQUOTA_SOFT_DEPRIORITIZE_FACTOR+ spendRecorder)/api/quota/**+/api/settings/quota-store+ 6 integration test filescosts-quota-plansQUOTA_SHARE.md,MONITORING_SECTIONS.md) + REPOSITORY_MAP + openapi.yaml + 4 E2E specs +audit-report-B.mdMétricas
Hard Rules audit (Group B branch — F10 grep-based)
redisQuotaStore.ts:39— método nominal, não invocação)src/lib/db/err.stack/err.messageraw em response bodybuildErrorBody)/api/quota/**e/api/settings/quota-storeNÃO emLOCAL_ONLY_API_PREFIXES(correto per B18 — não spawnam processos)src/shared/schemas/quota.tsDecisões fixadas pelo orquestrador (master-plan §0)
30 decisões fechando ambiguidades dos 2 .plan.md originais. Principais:
release/v3.8.6(não v3.8.5)git mv)activityadicionado,logs-activitymantido emHIDEABLE_SIDEBAR_ITEM_IDS(back-compat de presets), nova seçãocostscom 4 items +costs-quota-plansadicionado por F9/api/quota/**NÃO LOCAL_ONLY (B19) — usarequireManagementAuthlogAuditEventcom actionsquota.pool.created|updated|deleted,quota.plan.updated,quota.store.driver_changedrecordConsumptionfail-open (drift aceitável; teto global do fetcher corrige)Documentation
_tasks/features-v3.8.6/refactorpages/_orchestration/master-plan-group-B.md(~1500 linhas)_tasks/features-v3.8.6/refactorpages/_orchestration/audit-report-B.md_tasks/features-v3.8.6/refactorpages/{16,22}-*.plan.mddocs/routing/QUOTA_SHARE.md(345 LOC — algoritmo, drivers, pipeline, UI, env vars, troubleshooting)docs/architecture/MONITORING_SECTIONS.md(146 LOC)docs/architecture/REPOSITORY_MAP.md(+6 entradas)docs/reference/openapi.yaml(+491 LOC — 13 paths + 7 schemas)Migration impact
/dashboard/logs/activity→ 308 redirect para/dashboard/activity(permanentRedirect)Costs Parametersem Monitoring)localStoragepools migram para DB transparentemente na 1ª visita à página (hookuseLocalStoragePoolMigrationidempotente — não duplica)HIGH_LEVEL_ACTIONS(allowlist emsrc/lib/audit/highLevelActions.ts); demais ainda visíveis em Audit LogDefinition of Done — 18/18 itens
Post-merge tasks (não bloqueiam este PR)
package.json::test:coverage+CLAUDE.mdHard Rule feat(proxy): enable SOCKS5 proxy support by default #9)QUOTA_SOFT_DEPRIORITIZE_FACTORem todas as 14 estratégias de combo (F7 aplicou só emauto)npm run test:e2e -- --grep "group-b"/dashboard/costs/quota-sharecom dados em localStoragenpm run buildpara verificar chunk lazy do RechartsTest plan
npm run lint— 0 errorsnpm run typecheck:core— cleannpm run typecheck:noimplicit:core— cleannpm run check:cycles— 0 novos ciclosnpm run test:coverage— PASS (gate 40/40/40/40; medido 62/69/60/62)npm run test:e2e -- --grep "group-b"— executar pós-merge (specs criadas, SKIP-ENV no audit headless)npm run build— executar pós-merge (verificar Recharts em chunk lazy)/dashboard/activityrenderiza timeline;/dashboard/costs/quota-sharecarrega pools do DB;/dashboard/costs/quota-share/planspermite override Codex/Kimi