fix: address code-review bot findings from the audit PRs (#62–#65) - #66
Merged
Conversation
…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.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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.



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)
ensureProviderState()unbounded → wedged auto-capture mutex forever on a hung host bootstrapf20a844disposeran orphaned with live toastsf20a844disposestarted new capture workf20a844Promise.resolve()microtask still blocked the host's first awaitf20a844embed()awaited warmup unbounded — first chat prompt stalled pastwarmupTimeoutMsc78740bupdateVectornulledtags_vectoron content-only re-embeds54f4bc37b2835brebuildFromShardearly-return)cc41f561ec9af5safeFtsQuerypunctuation (don't,foo.js,@) → invalid FTS5 MATCH → silent empty results146e4a0webServerHost: "0.0.0.0"rejected every remote Host (403); reverse-proxy doc guidance changed the bind interface; unbracketed IPv6 misparse146e4a0Verified and deliberately not fixed
MAX_CONNECTIONSwhen all connections are in-transaction (Copilot, fix(sqlite): transactional integrity, FTS5 for memories, decay rotation #63): real but self-healing — LRU eviction on the nextgetConnectionshrinks 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
checkis a required status check). The new tests here cover the exact files that fell short (migration-service, vector-search, connection-manager paths);required_status_checksmay still want the SonarCloud gate added as a follow-up decision for the maintainer.