Skip to content

fix(projection): scope route_period reconciliation estimates to their route - #50

Merged
TargiX merged 1 commit into
mainfrom
fix/signalops-reconciliation-route-estimate
Sep 26, 2026
Merged

TargiX merged 1 commit into
mainfrom
fix/signalops-reconciliation-route-estimate

Conversation

@TargiX

@TargiX TargiX commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Follow-up to #49. A route_period observation reconciles one route, but the estimate side summed every attempt of the provider key in the period. On fal all routes share the same connection key, so a single h3 bucket inherited the wan attempts' estimate and the delta lied.

  • Period rows now expose scope.
  • route_period rows match attempt-terminal costs on providerKey and route modelKey; provider_period rows keep summing the whole provider.
  • Regression test: a second route's attempt in the same window moves the provider_period estimate (0.053 → 0.123) and leaves the route_period estimate at 0.053.

pnpm test:ops:v1 and pnpm typecheck green.

Summary by CodeRabbit

  • Bug Fixes
    • Reconciliation estimates for a specific route now include only that route’s attempt costs. Provider-period estimates continue to include attempt costs across all routes for the provider.
    • This keeps route-level and provider-level totals aligned with their respective scopes.

… route

A route_period observation reconciles one route, but the estimate side summed
every attempt of the provider key in the period. On fal all routes share the
'fal' connection key, so one h3 bucket inherited the wan attempts' estimate.
Period rows now carry scope, and route_period rows match attempts on
providerKey plus route modelKey while provider_period keeps summing the whole
provider. Regression test asserts both behaviours with a second route's attempt
in the same window.
@vercel

vercel Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
signalops Ready Ready Preview Sep 26, 2026 11:30am UTC

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: 9d07eaf3-1be1-452a-8f89-e3a9e1d17e00

📥 Commits

Reviewing files that changed from the base of the PR and between 9159b3f and 989df92.

📒 Files selected for processing (2)
  • scripts/test-signalops-ops-v1.mjs
  • src/lib/signalops/v1/ops-snapshot.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Reconciliation period rows now include the event scope. Route-period cost estimates match attempt costs by model key; provider-period estimates continue to include all provider attempt costs in the period.

Changes

Reconciliation estimate scope

Layer / File(s) Summary
Scope-aware estimate calculation
src/lib/signalops/v1/ops-snapshot.ts, scripts/test-signalops-ops-v1.mjs
Attempt-terminal cost records retain the model key. Route-period estimates filter costs by model key, while provider-period estimates include costs from both routes. Reconciliation rows include the event scope. The test checks estimates of USD 0.053 for the route and USD 0.123 for the provider.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 989df

The route-scoped estimate change has no identified merge-blocking issue; it is ready for normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: limiting route_period reconciliation estimates to the relevant route.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@TargiX
TargiX merged commit 6e9cbef into main Sep 26, 2026
4 checks passed
@TargiX
TargiX deleted the fix/signalops-reconciliation-route-estimate branch September 26, 2026 11:31

This branch was successfully deployed

1 active deployment
Preview — 989df920 Deployed Sep 26, 2026 by vercel[bot]
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.

2 participants