Repository navigation
Description
Env numbers are arguments — one strict parse for boot-time configuration
Design doc: files/designs/code-env-config-strict-parse.md in the keep-the-four-repos-healthy goal workspace (design-architect pass 22, 2026-10-30). Audited against origin/main 69cc1813.
The problem in one paragraph
Seven open issues are one mechanism: services parse boot-time environment numbers with bare Number(), and a bare Number() is not a validator. It fails in three costumes — silent reinterpretation (0x1234 → port 4660, 1e4 → 10000, port 0 → a random bind), starts-healthy-then-fails-per-request (a typo'd/negative/>2³¹ timeout makes every request "time out" in ~1ms and blames the upstream), and garbage-as-unset or serve-nothing (a non-numeric GITHUB_APP_INSTALL_ID is silently skipped as if unset; an all-separator *_HOSTS exits 0 serving nothing). The repo already designed this away once — for ports only, in bin/proxy-port.mjs (#483/#494: digits-only, 1–65535, error names the variable; "a bare parseInt is not a validator"). This design generalises that embodiment to every boot-time numeric the repo's long-lived JS/TS services read. The measurement-parsing half of the loose-number family (#2789/#2791/#2743/#2510) is NOT this design — those parse documents and belong to #2576's exporter-adoption question (recorded in the doc).
The contract
An environment variable a service reads at boot is an argument, and it is parsed like one: (1) plain decimal only —
/^[0-9]+$/on the non-empty value that remains after the surface's existing absent/empty handling (''/undefined → fallback in bin; empty-after-trim → default via pm-stacks()); (2) ranges by kind — port 1–65535 (0 invalid: a named service never intends a random bind), millis 1–2³¹−1 (thesetTimeoutcliff; 0 invalid — "disabled" is not a duration), count ≥1 with a per-site sane ceiling (a 0 cap crashes agy-proxy's eviction loop), id positive decimal integer with absent/empty as the only "unset" spelling; (3) hosts lists must be non-empty after split/trim/filter; (4) failure is at boot, names the variable, the offending value, and the expected kind/range, and exits non-zero before serving — never start-healthy-fail-per-request, never reinterpret, never garbage-as-unset; (5) implementation follows deployment shape —bin/*shares extended helpers inbin/proxy-port.mjs(the existing sibling-import pattern), pm-stack apps each carry the same semantics as a smallconfig.tshelper with the shared probe matrix as tests (independent deploys, zero cross-app imports — pass 20's rule).
The shared probe matrix, asserted at every covered site: unset, "", a valid value, abc, 12.5, -1, 0, 0x10, 1e3, out-of-range, 2147483648 (millis), junk-suffixed spellings; for hosts lists: unset, one, several, ",", " , ,".
The seven open instances
- antigravity-direct: ANTIGRAVITY_DIRECT_PORT / _TIMEOUT_MS are bare Number() — bypasses the house strict port helper, so bad ports crash with a stack or bind the wrong port, and bad timeouts start healthy then 502 every request #2823 antigravity-direct
bin/antigravity-direct.mjs:60,62— port + timeout; the one bin proxy bypassing the house helper entirely. - opencode-route-proxy: OPENCODE_ROUTE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value starts healthy, then every routed request 'times out' in ~1ms and blames the leaf #2786 opencode-route-proxy
bin/opencode-route-proxy.mjs:51— timeout; every request 502s in ~1ms blaming the leaf. - commandcode-proxy: COMMANDCODE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value makes every request 'time out' in ~1ms instead of failing at startup #1809 commandcode-proxy
bin/commandcode-proxy.mjs:60— timeout drives every timer in the proxy. - agy-proxy: four numeric env vars parsed with bare Number() — 'abc' disables the worker cap and idle eviction and freezes the model catalog, a typo'd turn timeout fires in ~1ms, and MAX_LIVE_WORKERS=0 crashes the eviction loop #2096 agy-proxy
bin/agy-proxy.mjs:168,453,456,457— four knobs:abcdisables the worker cap and idle eviction and freezes the model catalog;MAX_LIVE_WORKERS=0crashes the eviction loop. - aggregator(config): PM_AGG_PORT / PM_AGG_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError that names neither variable, and an all-separator PM_AGG_HOSTS exits 0 serving nothing #2161 aggregator
src/config.ts—PM_AGG_PORTbareNumber(),PM_AGG_HOSTSno non-empty check. - pm-dispatch(config): DISPATCH_PORT / DISPATCH_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError naming neither variable, hex/scientific spellings become other ports, and an all-separator DISPATCH_HOSTS exits 0 serving nothing #2758 pm-dispatch
src/config.ts:87-91— identical shape forDISPATCH_PORT/DISPATCH_HOSTS. - projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset #2172 projector
src/index.ts:6(PORT) +src/github.ts:121(GITHUB_APP_INSTALL_ID: garbage → NaN → falsy → silently unset, credentials blamed;12.5interpolated verbatim into the installations URL).
Unfiled remainder found by the audit (grep over bin/ + pm-stack/ on origin/main 69cc1813): pm-stack/aggregator/scripts/gather-quota.ts:103 QUOTA_GATHER_TIMEOUT_MS — Phase 3's scope, not a parallel filing.
Phases
- Phase 1 = antigravity-direct: ANTIGRAVITY_DIRECT_PORT / _TIMEOUT_MS are bare Number() — bypasses the house strict port helper, so bad ports crash with a stack or bind the wrong port, and bad timeouts start healthy then 502 every request #2823 + opencode-route-proxy: OPENCODE_ROUTE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value starts healthy, then every routed request 'times out' in ~1ms and blames the leaf #2786 + commandcode-proxy: COMMANDCODE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value makes every request 'time out' in ~1ms instead of failing at startup #1809 + agy-proxy: four numeric env vars parsed with bare Number() — 'abc' disables the worker cap and idle eviction and freezes the model catalog, a typo'd turn timeout fires in ~1ms, and MAX_LIVE_WORKERS=0 crashes the eviction loop #2096 (bin/ proxies, ADOPTED). Extend
bin/proxy-port.mjswith millis/count helpers on the existing pure-value + env-wrapper pattern, probe-matrix tests, and put all four proxies' bare sites on them (antigravity-direct's port goes through the existingparseProxyPort). Independent. - Phase 2 = aggregator(config): PM_AGG_PORT / PM_AGG_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError that names neither variable, and an all-separator PM_AGG_HOSTS exits 0 serving nothing #2161 + pm-dispatch(config): DISPATCH_PORT / DISPATCH_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError naming neither variable, hex/scientific spellings become other ports, and an all-separator DISPATCH_HOSTS exits 0 serving nothing #2758 + projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset #2172 (pm-stack services, ADOPTED). Per-app config helpers with identical semantics + probe matrix per app; aggregator/dispatch validate port + non-empty hosts in
loadConfig; projector validatesPORTat boot and the install id at itsgithub.tsread site (bad value throws namingGITHUB_APP_INSTALL_IDinstead of falling through to token/no-credentials). Independent of Phase 1. - Phase 3 — closing inventory audit (NEW issue, filed with this design, gated on Phases 1–2). Grep inventory of every remaining numeric env parse in service/script entry points (known: gather-quota's
QUOTA_GATHER_TIMEOUT_MS, fleet-merge'sFLEET_MAX_RETRIES), each converted or explicitly exempted with a named reason (expected exemptions: test-onlyTEST_PORT, docs examples), plus the contract written intopm-stack/README.mdand thebin/proxy-port.mjsheader. Phase 3 closes this issue with the inventory evidence.
Alternatives (per-site status quo; validate at serve/supervisor layer; clamp instead of refuse; one shared pm-stack library), risks (a loosely-spelled value in a shipped unit file refusing at boot — mitigated by named errors + phases checking unit files first), and open questions (string/URL env values; boot-failure visibility on the dashboard; measurement parsing stays #2576's question; Rust/Go env idioms out of scope) are in the design doc.
agent-note:v1 — filed by design-architect pass 22 (2026-10-30). The seven origins keep their own queued triage packets; agent notes on each record the phase structure and instruct triage not to re-file/re-scope/split.
Acceptance criteria
- Phase 1 (antigravity-direct: ANTIGRAVITY_DIRECT_PORT / _TIMEOUT_MS are bare Number() — bypasses the house strict port helper, so bad ports crash with a stack or bind the wrong port, and bad timeouts start healthy then 502 every request #2823, opencode-route-proxy: OPENCODE_ROUTE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value starts healthy, then every routed request 'times out' in ~1ms and blames the leaf #2786, commandcode-proxy: COMMANDCODE_PROXY_TIMEOUT_MS is parsed with a bare Number() — a typo'd, negative, or >2^31 value makes every request 'time out' in ~1ms instead of failing at startup #1809, agy-proxy: four numeric env vars parsed with bare Number() — 'abc' disables the worker cap and idle eviction and freezes the model catalog, a typo'd turn timeout fires in ~1ms, and MAX_LIVE_WORKERS=0 crashes the eviction loop #2096): every numeric env parse in the four bin/ proxies goes through the strict helpers in
bin/proxy-port.mjs(port/millis/count per kind), with the shared probe matrix asserted in tests; a bad value fails at startup naming the variable. - Phase 2 (aggregator(config): PM_AGG_PORT / PM_AGG_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError that names neither variable, and an all-separator PM_AGG_HOSTS exits 0 serving nothing #2161, pm-dispatch(config): DISPATCH_PORT / DISPATCH_HOSTS are never validated — port 0 silently binds a random port, a typo crashes with a Bun RangeError naming neither variable, hex/scientific spellings become other ports, and an all-separator DISPATCH_HOSTS exits 0 serving nothing #2758, projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset #2172): aggregator, dispatch, and projector validate port (1–65535, never 0), non-empty hosts lists, and (projector) the install id per the contract, each app carrying the probe matrix as tests; failures name the variable and happen at boot (install id: at its read site, naming the variable instead of blaming credentials).
- Phase 3 (closing audit): the repo inventory of numeric env parses is dispositioned site-by-site (converted / exempted with reason) in the closing evidence, and the contract is written into
pm-stack/README.mdand thebin/proxy-port.mjsheader. - This issue closes only with the Phase 3 audit evidence attached; no covered site silently reinterprets, starts healthy with a bad value, or treats garbage as unset.
Activity
dezren39 commentedon Oct 30, 2026
agent-note:v1 — design-architect pass 22 (2026-10-30): this design was filed this pass with its design doc (
files/designs/code-env-config-strict-parse.md, keep-the-four-repos-healthy goal workspace), audited against origin/main69cc1813. All three phases are linked as sub-issues (verified in this issue's sub_issues list: 2823, 2786, 1809, 2096, 2161, 2758, 2172, 2837): Phase 1 (bin/ proxies) and Phase 2 (pm-stack services) ADOPT the seven origin issues — no parallel implementation issues were filed; Phase 3 (#2837, closing inventory audit + contract docs) is new,status/blockedon Phases 1–2, with a triage packet enqueued to the pilot queue this pass. The seven origins keep their own queued triage packets; notes on each record the phase structure. Nouser/review: the contract generalises the repo's own #483 embodiment and every origin carries explicit acceptance; the judgment calls (port 0 invalid, millis ceiling 2^31-1, garbage-id-is-an-error) are recorded in the design doc.38 remaining items
developing-today commentedon Nov 8, 2026
🤖 Agent note · triaged — remainder confirmed, parent stays open on its existing phase children
Fresh verification (2026-11-08T13:2xZ), confirming the task 12085 verdict of 08:18Z still holds exactly:
Verdict: issue #2835 remains OPEN and correctly structured. The remainder is fully covered by the existing child issues and their PRs; the design note says not to re-file or split them, so no new small_fix packet is warranted. The parent closes only after #1809/#2096 land and #2837 supplies its inventory audit and contract-doc evidence. Completing task 13220 as triaged.
dezren39 commentedon Nov 8, 2026
🤖 Agent note · triaged — remainder already owned by existing phase children
dezren39 commentedon Nov 14, 2026
Program tending — epic completion (tracking: #1352)
Merge pull request #10770 from developing-today/fix/2837-env-number-c…
dezren39 commentedon Nov 16, 2026
Closing on the Phase 3 audit evidence, as this issue's own acceptance criteria require.
Phases complete
bin/proxies parse ports/millis/counts throughbin/proxy-port.mjs.a756d084), which carries the site-by-site inventory:pm-stack/aggregator/scripts/gather-quota.tsQUOTA_SUBCOMMAND_TIMEOUT_MS(successor of the audit'sQUOTA_GATHER_TIMEOUT_MS) andpm-stack/aggregator/src/config.tsALERT_ACK_WINDOW_MIN;FLEET_MAX_RETRIES(file no longer in the tree);bin/socket-activation.mjsLISTEN_FDS/LISTEN_PID(systemd protocol,null= direct bind),bin/opencode-route-proxy.mjsOPENCODE_ROUTE_PROXY_NOW_MS(clock pin),pkgs/id/e2e/playwright.config.tsTEST_PORT(test-only),pkgs/pkarr-worker/src/index.tsDNS_TTL(optional, tolerant default),pkgs/bedside-and-away/.../proxy.mjsGATEWAY_PORT(vendored, already integer-checked 1024–65535).pm-stack/README.md("Environment numbers") and thebin/proxy-port.mjsheader.No covered site reinterprets, starts healthy with a bad value, or treats garbage as unset; no straggler required a follow-up issue. Measurement/document parsing stays with #2576 as recorded in the design.