fix(selfhost): route the last two bare-Number() env knobs through parsePositiveIntEnv + preflight - #10108
Conversation
…sePositiveIntEnv + preflight LOOPOVER_SHUTDOWN_LOCK_RELEASE_AFTER_MS (src/server.ts) and OLLAMA_NUM_CTX (src/selfhost/ai.ts) were the only self-host numeric knobs still read with a bare Number(process.env.X ?? ""), the exact form JSONbored#9157 replaced everywhere else. Both fail the two ways that comment names: a unit-suffixed/separator value ("30s", "30_000") NaN's and silently disables the opt-in with no signal, and a fractional value ("0.5") is accepted — the shutdown deadline loses every race (bulk lock release fires on every shutdown) and ollamaNumCtx floors 0.5 to 0. Read both via parsePositiveIntEnv (server: { min: 0, fallback: 0 } to keep unset ⇒ wait-for-the-drain; ollama: { min: 1, fallback: 32_768 }), and add the paired positiveInteger preflight entries so a malformed value hard-fails boot with a clear message instead of only warning at use time. Defaults, the shutdown drain-first ordering, and the ollama provider gate are unchanged. Closes JSONbored#10056
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-31 07:59:40 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Decision record
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10108 +/- ##
===========================================
- Coverage 91.88% 79.79% -12.09%
===========================================
Files 930 284 -646
Lines 113827 59345 -54482
Branches 27466 8882 -18584
===========================================
- Hits 104588 47354 -57234
- Misses 7940 11695 +3755
+ Partials 1299 296 -1003
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Summary
LOOPOVER_SHUTDOWN_LOCK_RELEASE_AFTER_MS(src/server.ts) andOLLAMA_NUM_CTX(src/selfhost/ai.ts) were the only two self-host numeric knobs still on the bare-Number(process.env.X ?? "")form (#9157's contract everywhere else). Both fail the two ways #9157 named: a unit-suffixed/separator value ("30s","30_000") NaN's and silently disables the opt-in with no signal, and a fractional value ("0.5") is accepted — the shutdown deadline loses every race (bulk lock release fires on every shutdown) andollamaNumCtxfloors0.5to0.Fix
src/server.tsreads viaparsePositiveIntEnv("LOOPOVER_SHUTDOWN_LOCK_RELEASE_AFTER_MS", { min: 0, fallback: 0 }), keeping the> 0gate (unset ⇒ drain-first, byte-identical).ollamaNumCtxreads viaparsePositiveIntEnv("OLLAMA_NUM_CTX", { min: 1, fallback: 32_768 }).preflightEnvgains the two pairedpositiveInteger(...)entries so a malformed value hard-fails boot.apps/loopover-ui/src/lib/selfhost-env-reference.ts(npm run selfhost:env-reference), since the structuredpositiveInteger/parsePositiveIntEnvcalls makeOLLAMA_NUM_CTXdiscoverable to the generated reference and re-attribute the shutdown knob's source file.Defaults, the shutdown drain-first ordering,
parsePositiveIntEnv/positiveIntegerthemselves, the three existingpositiveIntegercalls, and the ollama provider gate are unchanged.src/server.tsis incodecov.yml's ignore list (entrypoint).Tests
test/unit/selfhost-preflight.test.ts:preflightEnvreports a problem for both knobs on"30s"/"30_000"/"0.5"/"-1"(plus"0"forOLLAMA_NUM_CTX), andok: truefor unset/""/valid integers.test/unit/selfhost-ai.test.ts:ollamaNumCtx()returns32768(not0) for"0.5"and65536for"65536".Closes #10056