Skip to content

fix(history): scale the integrity check bound with index size - #8709

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
omar391:fix/history-integrity-timeout-scale
Nov 14, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
omar391:fix/history-integrity-timeout-scale

Conversation

@omar391

@omar391 omar391 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • PRAGMA quick_check reads every index page, so its cost scales with the index file — but the lifecycle monitor bounded every check at a fixed 30 s.
  • On a ~4 GiB routing-history.sqlite the worker check cannot finish inside 30 s: every attempt times out, the generation never verifies, and GET /api/request-history answers 500 (RequestHistoryIndexBusyError) permanently even though the index itself is healthy (verified locally: quick_check returns ok in ~30 s on the affected install).
  • The bound is now derived per generation from the index file size at a conservative 32 MiB/s scan rate: 30 s floor for small indexes, 15 min cap so a wedged worker stays bounded. An explicit checkTimeoutMs option still wins for tests.
  • structure/dashboard-and-usage.md contract text updated to match.

Test plan

  • bun test tests/usage/request-history-integrity.test.ts — 25/25 pass, including two new regressions (pure bound derivation + a 4 GiB sparse index getting the scaled bound)
  • bun run typecheck — clean (2,533 files)
  • CI

Generated with Devin

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Integrity checks now receive timeouts based on the size of the request-history index, allowing more time for large indexes. Timeouts range from a 30-second minimum to a 15-minute maximum; missing or invalid file sizes retain the 30-second default.
  • Documentation
    • Updated the request-history documentation to describe the size-based timeout behavior.

quick_check reads every index page, so its cost grows with the file. The
fixed 30 s bound stopped a 4 GiB index from ever verifying: every check
timed out, the generation stayed unverified, and /api/request-history
answered 500 permanently while the index itself was healthy.

Derive the per-generation bound from the index file size at a
conservative scan rate, keeping the 30 s floor for small indexes and a
15 minute cap so a wedged worker stays bounded. An explicit
checkTimeoutMs option still wins for tests.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-13T18:26:24.713710Z
We couldn’t complete this review. Comment @codex review to try again.
eab0a2d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 18:26
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The integrity monitor now calculates a per-generation timeout from index size when no timeout is configured. The calculation uses a 30-second floor and 15-minute cap. Tests and documentation describe the sizing and scheduling behavior.

Changes: Request-history integrity timeout

Layer / File(s) Summary
Calculate and assign generation timeouts
src/routing/history/integrity.ts, tests/usage/request-history-integrity.test.ts
The timeout calculator uses index size at 32 MiB/s, with a 30-second floor and 15-minute cap. Missing, non-finite, or non-positive sizes use the 30-second default. Inspected and rebuilt generations use an explicit configured timeout when present; otherwise, they use a timeout calculated from the index path. Tests cover the sizing bounds and 4 GiB calculation.
Schedule checks with generation timeouts
src/routing/history/integrity.ts, tests/usage/request-history-integrity.test.ts, structure/dashboard-and-usage.md
Scheduled checks use each generation’s timeout. A test checks the scheduled timeout for a 4 GiB sparse index. The documentation describes the size-scaled bound and existing timeout handling.

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

Change: Bug fix

Suggested reviewers: luvs01

Merge Risk: Minimal · up to eab0a

The change scales the request-history integrity-check timeout with index size so large healthy indexes can verify instead of returning 500. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(history): scale the integrity check bound with index size" matches the main change. The integrity-check timeout for request history now scales with index file size (32 MiB/s, 30-second …
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix(history): scale the integrity check bound with index size" matches the main change. The integrity-check timeout for request history now scales with index file size (32 MiB/s, 30-second floor, 15-minute cap) instead of a fixed 30-second bound. The title is short, specific, and states the primary change. It does not cover the docs or test updates, which is expected.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 696c7b5 and eab0a2d.

Files selected for processing: 3

  • src/routing/history/integrity.ts
  • structure/dashboard-and-usage.md
  • tests/usage/request-history-integrity.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions
github-actions Bot marked this pull request as ready for review November 13, 2026 18:28
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md dev path), recorded by lidge-jun.

Thanks @omar391.

@lidge-jun
lidge-jun merged commit 53c1b4c into lidge-jun:dev Nov 14, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants