fix: pass config to engine.connect() on autopilot reconnect#190
Open
voidborne-d wants to merge 1 commit intogarrytan:masterfrom
Open
fix: pass config to engine.connect() on autopilot reconnect#190voidborne-d wants to merge 1 commit intogarrytan:masterfrom
voidborne-d wants to merge 1 commit intogarrytan:masterfrom
Conversation
…#167, garrytan#164) Root cause: autopilot's DB health check called engine.connect() with no arguments after disconnect. PostgresEngine.connect() dereferences config.poolSize unconditionally, so undefined config → TypeError: "undefined is not an object (evaluating 'config.poolSize')". Once reconnect crashes, the engine stays disconnected and every subsequent cycle step (sync / extract / embed / health) fails with "No database connection". After 5 such cycles the daemon exits. launchd KeepAlive restarts it, but each restart loses adaptive scheduling state and any in-progress embed batch. Fix: - autopilot.ts: re-load config from disk via loadConfig() + toEngineConfig() and pass it to engine.connect() on reconnect. Handles the case where config is missing (no brain configured). - postgres-engine.ts: guard connect() against undefined config with a descriptive GBrainError (defense in depth). - pglite-engine.ts: same guard for PGLiteEngine.connect(). Closes garrytan#167. Closes garrytan#164.
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.
Fixes #167. Fixes #164.
Problem
Autopilot's DB health-check reconnect path called
engine.connect()with no arguments:PostgresEngine.connect()dereferencesconfig.poolSizeunconditionally, soundefinedconfig →TypeError: "undefined is not an object (evaluating 'config.poolSize')".Once reconnect crashes, the engine stays disconnected and every subsequent cycle step (sync / extract / embed / health) fails with
"No database connection: connect() has not been called". After 5 such cycles the daemon exits.launchdKeepAliverestarts it, but each restart loses adaptive scheduling state and any in-progress embed batch.Fix
autopilot.ts: Re-load config from disk vialoadConfig()+toEngineConfig()and pass it toengine.connect()on reconnect. Handles the edge case where config is missing (no brain configured).postgres-engine.ts: Guardconnect()againstundefinedconfig with a descriptiveGBrainError(defense in depth — if a future caller forgets to pass config, the error message is clear instead of a cryptic TypeError).pglite-engine.ts: Same guard forPGLiteEngine.connect().Tests
New
test/autopilot-reconnect.test.ts— 10 tests covering:connect()callsconnect(undefined)guards throw descriptive errorstoEngineConfig()round-trip for postgres and pglite configsExisting test suites unaffected: