Skip to content

fix: address code-review bot findings from the audit PRs (#62–#65) - #66

Merged
ZeR020 merged 7 commits into
mainfrom
fix/review-findings
Sep 8, 2026
Merged

fix: address code-review bot findings from the audit PRs (#62–#65)#66
ZeR020 merged 7 commits into
mainfrom
fix/review-findings

Conversation

@ZeR020

@ZeR020 ZeR020 commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

The audit PRs (#62#65) merged before the automated reviewer comments (Devin, Copilot, Codex, CodeQL) were read. This PR triages every substantive finding against real code and fixes the eleven that verified, with failing-first regression tests for each. Full gate state: format/typecheck clean, 859 tests pass (+15), build green.

Fixes (finding → commit)

Finding Source Commit
ensureProviderState() unbounded → wedged auto-capture mutex forever on a hung host bootstrap Copilot ×2, Codex P1 (#62) f20a844
Web server resolving after dispose ran orphaned with live toasts Devin (#62) f20a844
Idle events after dispose started new capture work Devin (#62) f20a844
Score recalc on a Promise.resolve() microtask still blocked the host's first await Devin, Codex P2 (#62) f20a844
embed() awaited warmup unbounded — first chat prompt stalled past warmupTimeoutMs Codex P1 (#62) c78740b
updateVector nulled tags_vector on content-only re-embeds Devin (#63) 54f4bc3
FTS update trigger fired on every UPDATE (write amplification per search/decay touch) Copilot, Codex P2 (#63) 7b2835b
Post-COMMIT backend failures misreported committed writes; dirty flag never repaired initialized indexes (rebuildFromShard early-return) Devin (#63) cc41f56
Re-embed migration never updated initialized indexes — stale similarity until restart; tags not re-embedded after dim changes Copilot, Codex P1, Devin ×3 (#63) 1ec9af5
safeFtsQuery punctuation (don't, foo.js, @) → invalid FTS5 MATCH → silent empty results Devin (#64) 146e4a0
webServerHost: "0.0.0.0" rejected every remote Host (403); reverse-proxy doc guidance changed the bind interface; unbracketed IPv6 misparse Codex P1, Copilot (#64) 146e4a0

Verified and deliberately not fixed

  • Pool overshoot past MAX_CONNECTIONS when all connections are in-transaction (Copilot, fix(sqlite): transactional integrity, FTS5 for memories, decay rotation #63): real but self-healing — LRU eviction on the next getConnection shrinks the overshoot, transactions are millisecond-scale, and the overshoot is bounded by the concurrent-transaction moment. A slot-wait queue is machinery for an adversarial edge; revisit if sqlite txns ever become long-lived by design.

Also

  • The SonarCloud new-code coverage gate on fix(sqlite): transactional integrity, FTS5 for memories, decay rotation #63 failed at 66.9% and was merged past (only check is a required status check). The new tests here cover the exact files that fell short (migration-service, vector-search, connection-manager paths); required_status_checks may still want the SonarCloud gate added as a follow-up decision for the maintainer.

…score scan

Code-review findings on #62 (Devin, Copilot, Codex):
- ensureProviderState() had no timeout: a hung host bootstrap wedged
  auto-capture (isCapturing stuck true) and profile learning forever.
  Now bounded at 10s with a warn-and-proceed fallback.
- startWebServer().then assigned webServer with no disposal guard:
  a server finishing after dispose ran orphaned with live toasts.
  Now stopped immediately on late resolution.
- Idle events arriving after dispose scheduled new capture work; the
  event handler and capture/learning pipelines now check disposed state.
- Initial recalculateAllScores ran on a Promise.resolve() microtask,
  which executes before the host resumes from awaiting the plugin
  factory — the startup-blocking claim was wrong. Now a setTimeout(0)
  macrotask, cleared on dispose.
Codex P1 on #62: embed() awaited warmup() with no bound — the
AbortController in embedWithTimeout only guarded the API-fetch path,
so a slow model download stalled the first chat.message hook past any
configured timeout (and an abort during warmup left the service
permanently disabled via embeddingAvailable=false).

- warmup wait is raced against warmupTimeoutMs and the caller's
  AbortSignal; on either it rejects AbortError-shaped, which embed()'s
  catch rethrows without disabling the service.
- searchMemories treats a warmup-pending AbortError as a degraded
  text-only search instead of propagating the failure to the prompt.
Devin finding on #63: updateVector always wrote tags_vector, so a
content-only re-embed (migration, admin re-embed) passed undefined and
null'd the tag embeddings — semantic tag search silently disappeared
for every updated memory. COALESCE preserves the stored blob when the
caller provides none.
Copilot/Codex finding on #63: AFTER UPDATE ON memories (unscoped)
fired on every UPDATE — every access_count bump on a search hit and
every decay/score touch — re-tokenizing the full content via FTS
delete+reinsert. Scoped to UPDATE OF content, tags; DROP+CREATE in
ensureMemoriesFts upgrades databases created with the old trigger.
…hards

Devin finding on #63: after COMMIT, a failing backend insert rejected
the whole write although the sqlite row was durable — callers reported
failure and retried into duplicates. Worse, the rebuild-dirty flag could
never repair an initialized index: rebuildFromShard returned early for
initialized indexes, so a dirty shard stayed missing entries until
process restart.

- rebuildFromShard gains force: replaces an initialized index by
  rebuilding from sqlite (the durable truth).
- maybeRebuild distinguishes bootstrap (first use) from repair (dirty)
  and passes force only for the latter — steady-state searches never
  pay a rebuild.
- insertVector/updateVector/replaceVector swallow post-commit backend
  failures with a warn + dirty mark; pre-commit sqlite failures still
  throw (nothing persisted).
- markShardDirty() public — the re-embed migration uses it (next commit).
Copilot/Codex P1 + Devin findings on #63: _reEmbedSingleMemory called
updateVector without the shard, so the backend-update branch was
skipped entirely — a 'successful' migration left any initialized
in-memory index serving old embeddings until restart, and left
tags_vector NULL (and after a dimension change, old-dims tag blobs
would poison a rebuilt tags index).

- resolve full ShardInfo per migrated dbPath and pass it through
- re-embed the tags text with the exact capture-time prompt shape
  (Topics: joined tags) when the row stores tags
- after a fully successful shard, markShardDirty() — the next search
  force-replaces initialized indexes with new-dimension data
Codex P1 + Copilot + Devin findings on #64:
- webServerHost doubled as bind address AND Host-allowlist entry, so
  '0.0.0.0' binds rejected every remote client (403 on the whole
  dashboard) and the documented proxy workaround silently changed the
  listen interface. webServerAllowedHosts (default []) now lists extra
  accepted Host names; bind semantics of webServerHost unchanged.
- unbracketed IPv6 Host literals (2001:db8::1) were misparsed as
  host:port ('host 2001:db8:, port 1'); multi-colon strings are now
  treated as the whole hostname.
- safeFtsQuery stripped a fixed punctuation list — apostrophes,
  periods, @ and more still reached FTS5 as invalid MATCH syntax and
  returned silently empty results. Token quoting ("tok") neutralizes
  operators and keeps punctuation matchable; shared helper serves both
  the memory (searchFTS5) and transcript paths.
Copilot AI lite review requested due to automatic review settings September 8, 2026 15:50
@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.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@ZeR020
ZeR020 merged commit 5f0fe01 into main Sep 8, 2026
7 checks passed
@ZeR020
ZeR020 deleted the fix/review-findings branch September 8, 2026 15:54
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