Repository navigation
fix(ops): restart ki-simulate on deploy to reload source + .env - #180
Merged
Merged
Conversation
ki-simulate (runner-auto.ts) is long-running and tsx loads source at process start, so without a restart it keeps executing pre-deploy code and its already-loaded process.env indefinitely. This masked the AfD/xAI outage: an invalid XAI_API_KEY latched the xai provider as auth-failed in memory (client.ts), and the stale process never picked up a corrected key. Restart on deploy so source and .env are always current.
easingthemes
added a commit
that referenced
this pull request
Nov 21, 2026
…deploy fix(ops): restart ki-simulate on deploy to reload source + .env
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.
Problem
The AfD party agent (the only party routed to xAI) was silently abstaining on every vote in production. The log showed:
Root cause (diagnosed against the live prod box)
The production
XAI_API_KEYwas invalid — xAI rejected it withHTTP 400 "Incorrect API key provided: xa***2r". On the first failure, the engine latches the xAI provider as auth-failed in memory until process restart (client.ts), so every subsequent day short-circuited to empty text →PARSE_FAIL→abstain-all.The reason a corrected key wouldn't have helped on its own:
ki-simulateis a long-runningtsxprocess. It loads source and itsprocess.envat start, so neither a source deploy nor an.envchange takes effect until it's restarted.update-env.ymlonly restartski-api, neverki-simulate— leaving the stale process running indefinitely. This same stale-process behavior previously caused the grok-3-mini incident.Fix
Add a
ki-simulaterestart toscripts/post-deploy.sh(mirroring the existingki-bothandling) so every deploy reloads its source and.env:Verification (prod)
verify_http_code=200, grok-4.3 returned valid JSON.ki-simulaterestarted → auth flag cleared,.envreloaded.PARSE_FAIL fallback=abstain-alltoOKin the live logs; aggregate fail rate back to ~1.2% normal.Notes
grok-4.3slug fix (75f40af) was correct; this was purely an invalid-key + stale-process operational issue.scripts/post-deploy.sh(1 file, +6 lines). Unrelatedpackage-lock.jsonworking-tree noise was deliberately left out.