Repository navigation
fix: apply the audited improvements across gateway and dashboard - #14
Merged
Merged
Conversation
Forty-two proposals from the audit in IMPROVEMENT_PROPOSALS.md, all of them implemented. The defects first, because they are the ones a client or an operator could observe: - A non-streaming answer whose body stopped early was recorded as a success. readBodyStrict() now reports an incomplete body and the attempt fails over instead (C1). - The total attempt budget stopped at the response headers, so a body read was bounded only by the idle timeout. send() holds the total timer for the body too (H1). - An empty ADMIN_PASSWORD in the environment created an account with the public default password. It now means what invariant 16 says it means - no account - and the generated config carries the empty string that ensureFirstAdmin() reads that way (H2). - A mistyped numeric environment variable was written into the generated config.json as null, and a bad *file* value is fatal: the container exited on every restart, blaming the operator's own file. Unparseable values are omitted so the schema default applies (H3). - The entrypoint tested booleans with === "true", so LOG_BODIES=YES was recorded as false in the file that outlives the variable (H3b). - A throw between reply.hijack() and the end of the stream escaped with the provider slot held and the connection still owned: max_concurrency 1 reads "busy" forever (M4). - failures_total counted per attempt, so it could exceed requests_total (M2). - The recent-requests ring only pruned from count(), and a provider in cooldown or at capacity is never counted (M7). - A truncated body could be answered twice, and on a keep-alive connection the "a route owns this" flag was never released at all, because onResponse read reply.raw.socket after Node had nulled it. The flag is now a depth over the socket captured at onRequest, and a request whose message never finished arriving keeps its share (M5). The improvements: revision-keyed enabled-id cache on the hot path (I2), the connect/body timeout names its own budget (I1), a bounded drain that does not splice per waiter (M9), a release on an unheld slot warns instead of going negative (L1), Retry-After derived from the earliest live cooldown (F2), the provider's rate-limit headers forwarded to the client (F1), x-ocr-attempts so a client can tell failover from a single attempt (F4), PRAGMA optimize and a quick_check at boot (F5), the schema version in /api/system (F6), and an async retention pass that yields between batches (M8). Dashboard: the probe result is attributed to the provider it belongs to (H4), the sessions table has loading/empty/error states (H5), a password change separates "wrong current password" from "new password rejected" (H6), a blocked form says why (M10), clipboard has a fallback (M11), pending states everywhere (M12), real <form> elements (M16), and a batch of accessibility and dead-code fixes (L11-L24). Also: bounds on every integer setting so a typo is a config error rather than a 400 at runtime (L7), a warn when METRICS_ENABLED is on with a short token (M6), /metrics rate-limited and answering 404 while disabled (I3), a 202 from the danger zone (I4), an ETag on GET /v1/models (F3), and the dead CSRF_COOKIE constant removed (I5).
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.
Implements all 42 proposals from the audit recorded in
IMPROVEMENT_PROPOSALS.md(the file deletes itself with this change, per its own completion rule).Defects
ADMIN_PASSWORDset but empty created an account with the public default; it now means "no account"config.jsonasnull, which is fatal at every boot=== "true", soLOG_BODIES=YESwas recorded asfalsecode, which the masker redacts, soupstreamSummarywas[REDACTED]failures_totalcounted per attempt and could exceedrequests_totalreply.hijack()escaped with the provider slot held and the connection still ownedonResponsereadreply.raw.socketafter Node had nulled itcount(), which a cooling provider never reaches<form>, weekday schedule edgeImprovements and features
x-ocr-attemptson completion replies, the provider'sx-ratelimit-*forwarded to clients (F1),Retry-Afterderived from the earliest live cooldown (F2), an ETag and304onGET /v1/models(F3),PRAGMA optimizeplus aquick_checkat boot (F5), the schema version in/api/system(F6),202from the danger zone (I4), a bounded drain that does not splice per waiter (M9), bounds on every integer setting (L7), and a revision-keyed enabled-model cache (I2).Deliberate deviations
opencode-api:latest: the image has no published tag or digest to pin to, and inventing one would breakdocker compose up. A comment says so.AGENTS.mdinvariant 2 now names both additions (the appended[DONE]and the injected keep-alive comment) instead of claiming one exception.warn, not a fatal config error:METRICS_ENABLEDis boot-only, so refusing to start would remove the scrape endpoint from an operator who already runs one. Brute force is bounded by the new per-address rate limit on/metrics.Verification
pnpm run check- 62 files, 20 pinned action refspnpm run typecheck- cleanpnpm test:unit- 6 of 6 files, 1226 checkspnpm run test:web- 31 testsSMOKE_STUB_PORT=4500 pnpm test- 444 of 444, 27 slow cases skippedsh -n docker/docker-entrypoint.sh- clean