← Back to Pull requests

fix(provider): survive legacy order keys in the startup registry sync #21284

Open
unknown opened this pull request with 302 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 02, 2026 21:50 UTC
Author

Summary

Fixes #21282.

2.1.4's startup provider-registry sync feeds order keys through the fractional-indexing generator, and zz — the old end-of-list sentinel that earlier Cherry Studio builds themselves wrote — fails validateOrderKey inside generateOrderKeySequenceBetween, so DbService init force-exits and the install cannot boot. The failure is network-gated (the upsert only runs when the registry fetch succeeds), which is why it masquerades as flaky.

On the regression window: the crash path (batchUpsertTx → insertManyWithOrderKey) has existed since the v2 data layer (e59c7aa7f7); 2.1.3 avoided it only because SeedRunner skips seeders by seed version. 2.1.4's registry major bump makes the first launch re-run the seeders, which is what finally feeds a legacy zz into the generator.

The fix is single-point tolerance at the shared root: insertManyWithOrderKey probes boundary-key validity with the library's own generateKeyBetween (the validator isn't exported), re-keys offending rows after their nearest valid neighbor (a0 when none), logs a warning, and continues — ordering preserved, both first and last scopes covered. Every caller (ProviderService.batchUpsertTx, ModelService, seeders) inherits the tolerance. The issue's separate ask — a real error dialog when DbService init fatality force-exits — is intentionally out of scope here.

Verification

| Check | Result |
| --- | --- |
| New tests: legacy order_key='zz' row survives the startup sync and is re-keyed; no-neighbor fallback; first/last scopes; unrelated rows untouched | red before fix (6 cases threw invalid order key: zz), all green after |
| orderKey.test.ts + ProviderService.batchUpsert.test.ts | 49/49 passed |
| Full src/main/data suite (shared module touched) | 193 files passed, 3869 tests passed / 1 skipped |
| pnpm typecheck (node / web / e2e) | all exit 0 |
| oxfmt --check on changed files | pass |

AI Use

Implemented with GLM-5.3-Flash (ZCode). Root cause localization, patch and tests by AI; regression-window archaeology corrected during investigation and stated in the commit message; verified locally as listed above.

Checklist

  • I have read the Contributing Guide

  • Commit signed off (DCO)

  • Tests added for the changed behavior

  • pnpm typecheck passes locally
  • Diff: 302 lines (+226 / -76) across 3 files Reviewer: ggbdpq Review duration: 15610m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 302 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.342
    Real PR Conversation Timeline
    1 comments
    "Review active on #21284"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.1% (MEDIUM) · Higher = larger blast radius
    40.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.4% · Safe to merge
    21.4%