Repository navigation
fix(main): avoid historical scans during startup sequence repair - #1203
Merged
Merged
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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.
Intent
Fix issue #1182: Startup sequence repair scans all historical orders and bills (ARCH-012b)
What Changed
sequence_repair_pendingandsequence_repair_completed_atsettings flags.executeSequenceRepair) that update sequence counters directly, wired into migrations and backup restores.tests/sequence-repair-performance.test.tsto benchmark sequence repair and startup duration up to 365,000 records, and updated architecture documentation indocs/architecture/data-and-migrations.md.Risk Assessment
✅ Low: The change cleanly replaces JavaScript heap materialization with atomic SQLite aggregations and introduces constant-time startup guards while preserving sequence monotonicity, data safety, and offline invariants.
Testing
Validated Issue #1182 (ARCH-012b) against the real running product in an isolated environment. Executed all 6 live scenarios (ordinary boot fast-path, set-based atomic SQL repair, adversarial gap/higher counter integrity, malformed suffix filters, self-healing recovery, and end-to-end HTTP API order creation on a running Express server) and scale benchmarks up to 365k rows (10 years of data). Ordinary boot took ~0.05 ms without scanning historical records, heap delta remained strictly bounded (< 11 KB), and all 6 scenarios passed. No UI surface was modified by this backend database change, so visual artifacts were not applicable.Evidence: Live Verification Log
[2026-10-17T11:50:51.276Z] FloCafe Issue #1182 (ARCH-012b) Live Product Verification Driver >>> Scenario 1: Ordinary startup with historical orders (Fast-path) Seeding 10,000 historical orders and bills across 100 days... Ordinary boot check completed in: 0.066 ms Result: repaired=false, ordersUpdated=0, billsUpdated=0 >>> Scenario 2: Pending startup repair executes SQL aggregation Pending repair completed in: 7.77 ms, heap delta: 9.7 KB >>> Scenario 3: Gapped order history & higher counter integrity (Adversarial) Gapped date (20261017) counter: 5 (expected 5) Higher counter date (20261018) counter: 25 (expected 25) >>> Scenario 4: Non-canonical prefixes & malformed suffixes (Adversarial) Malformed date (20261020) sequence record: undefined Valid date (20261021) sequence current_value: 3 >>> Scenario 5: Self-healing fallback when sequences table is missing Self-healing boot result: repaired=true >>> Scenario 6: Live Express server & HTTP API order creation end-to-end Express server listening on live port: http://127.0.0.1:49662 Sending live HTTP POST http://127.0.0.1:49662/api/orders ... Response status: 201 Created order: id=10017, order_number=ORD-20261017-0011 ✓ All 6 live scenarios executed and passed successfully!Evidence: Scale Benchmark Output
100k Rows (1,000 dates): - Repair duration: 88.00 ms - Heap delta: 9.9 KB - Ordinary boot duration: 0.055 ms (< 15 ms required) 365k Rows (3,650 dates / 10 years): - Repair duration: 354.62 ms (< 1,500 ms required) - Heap delta: 8.4 KB (< 2 MB required) - Ordinary boot duration: 0.051 ms (< 15 ms required)Evidence: HTTP API Order Creation Response
Evidence: Live Scenario Execution Results
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
node tests/run-electron-node-test.cjs tests/sequence-generation.test.tsnode tests/run-electron-node-test.cjs tests/sequence-repair-performance.test.tsnode tests/run-electron-node-test.cjs tests/order-numbering-settings.test.tsnpm run test:backupnode tests/run-electron-node-test.cjs ~/.no-mistakes/evidence/01M54TQQCNZZ1SGG7AZ30EPD9K/live-driver.js✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.