Skip to content

db/connection.ts: hardcoded busy_timeout literal + duplicated busy/locked regex #1749

Description

@carlos-alm

GAUNTLET (Titan phase 15 audit, rules 7 and 11) flagged two small out-of-scope cleanups in src/db/connection.ts, not addressed by phase 15's commit (scoped narrowly to the openReadonlyWithNative leak-ordering fix + engine-resolution dedup, per sync.json's phase-15 label):

  1. Rule 7 (warn): 'busy_timeout = 5000' is hardcoded as a literal pragma string at two call sites (openDb and openReadonlyOrFail). No DEFAULTS entry exists in src/infrastructure/config.ts for it, violating the project convention against hardcoded magic numbers (per CLAUDE.md: "When adding new behavioral constants, always add them to DEFAULTS").

  2. Rule 11 remainder (warn): The busy/locked detection regex /\b(busy|locked|SQLITE_BUSY|SQLITE_LOCKED)\b/i is duplicated identically between openRepo's catch block and openReadonlyWithNative's catch block. (Note: the other half of rule 11 — the duplicated engine-resolution block — was already fixed in phase 15 via a new shared resolveDbEngine helper.)

Recommendation: add DEFAULTS.db.busyTimeoutMs (or similar) and wire both pragma call sites to it; extract an isBusyOrLockedError(msg: string): boolean helper shared by both catch blocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions