superseded: inert rate-limit wiring prototype - #49
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Target branch corrected This pull request now targets The |
|
[code]smith (@codesmith-bot) Implement the runtime activation contract in Use the contract as authoritative. Work in coherent commits:
Default-off behavior must remain byte-compatible. Never use Origin as bypass/identity, never persist buckets/secrets, never expose fingerprints or dynamic identity labels, and never touch provider routing/account selection. Keep the PR draft and push incremental commits after each focused typecheck/test gate. |
|
Got it, I'm reviewing the rate-limit runtime wiring contract first. |
|
[code]smith (@codesmith-bot) The PR now targets |
OnlineChef
left a comment
There was a problem hiding this comment.
Implement the contract incrementally. This first review item is intentionally limited to canonical configuration and focused tests; do not touch auth or server routing in the same commit.
|
|
||
| ## Canonical configuration | ||
|
|
||
| Add one optional top-level `rateLimit` object through `OcxConfig`, the canonical Zod schema, config validation/save/load reconciliation, safe DTO handling, and docs. |
There was a problem hiding this comment.
Implement configuration gate 1 now on this branch. Add OcxRateLimitConfig/related types to src/types.ts, the strict optional rateLimit object to the existing canonical Zod schema and load/save validation in src/config.ts, and safe management DTO/candidate validation through existing paths. Default absent/disabled must preserve configs exactly. Use complete documented bounded defaults for all existing RateLimitSurface policies when enabled, or require complete policies—do not permit silently unprotected surfaces. Reject unknown surfaces, invalid rates/bursts/caps, and contradictory WebSocket settings. Add a focused tests/ratelimit-config.test.ts covering absent config, valid round-trip, unknown surface, invalid values, enabled completeness/defaults, and no secret/runtime fields. Run typecheck plus the focused config and existing ratelimit tests, then push one coherent commit. Do not modify auth, server/index.ts, WebSocket data, or metrics in this commit.
There was a problem hiding this comment.
[code]smith (@codesmith-bot) The strict validator/defaults/tests now exist and the branch is synced with current dev at b40ad8f. Complete this finding with only the three existing-file connections: type-only rateLimit?: RateLimitConfigInput on OcxConfig; rateLimit: rateLimitConfigSchema.optional() in the existing top-level configSchema; explicit safeConfigDTO/management candidate projection plus round-trip tests. Do not create new schemas/defaults and do not touch runtime routes/auth/metrics.
|
Security note for the later typed-auth commit: on loopback, do not fingerprint an arbitrary |
3609d2a to
b0b2823
Compare
|
[code]smith (@codesmith-bot) The branch is now clean on current |
|
[code]smith (@codesmith-bot) Gate 1 foundation is now on head |
|
greptile-apps Review current head |
Triage 2026-08-02 ADR (OCX → Sofie / Pi-Rust)Classification: Why
Salvage (optional, into #45 if missing)
Closing as superseded. No merge. |
|
Superseded by #45 (complete admission wiring donor). See triage comment. |
|
greptile-apps Re-run the focused live WebSocket validation on current head |
|
[code]smith (@codesmith-bot) Gate 1 is now reduced to three existing-file edits. Reuse
Push one coherent commit to this branch. No auth/router/WebSocket/metrics changes. |
[WRONG BRANCH] chore: sync rate-limit wiring with current dev
|
Superseded by PR #45, which contains the complete canonical config/auth/HTTP/WebSocket integration on the current ChefVault/provider-security base. Salvage retained for #45: auth-first 401/403 precedence, Cache-Control on 429s, stricter numeric config caps, and live-sideband concurrency lifecycle. The parameterized-route P1 in this PR was fixed before closure, but #45 already classifies sideband routes through the canonical dispatcher. No merge from #49. |
Todo list reconciled — those three items were finished earlier in the session: the WebSocket lifecycle commit ( The open question from my last message stands: PR #49 was closed as superseded by PR #45, and the "inert" review finding predates the wiring push. Let me know whether to (a) reopen #49 with a correction, (b) port my branch's deltas onto #45, or (c) just leave a pointer comment on #49 for the maintainer. |
|
This session has hit its $100 spend limit, so [code]smith paused work here. To keep going, open the session in the dashboard (https://app.blacksmith.sh/OnlineChefGroep/sessions/019fc1f2-6e6a-73a5-a375-06e666dcf80d) and press Continue, or start a new session. |
Implements
structure/rate-limit-runtime-wiring.mdon currentdev.The token-bucket policy-transition fix is already present on
devasf06bffeand independently verified by Greptile/T-Rex across low→high, high→low, burst-clamp, and shared-overflow transitions.This PR remains draft until the runtime activation is complete in isolated gates:
Default-off behavior must remain byte-compatible.
Originis never identity or bypass. Raw credentials, fingerprints, addresses, provider/model/account/request/conversation fields, prompts, and errors must not escape auth/admission internals or appear in metrics/logs/responses.Greptile Summary
This change introduces the rate-limit configuration, principal derivation, admission primitives, route mapping, and endpoint-specific 429 response helpers. A real server check showed that enabling the configuration does not yet limit protected traffic: after a one-request model-discovery budget was exhausted, two
GET /v1/modelsrequests still returned200without rate-limit headers. The limiter works when invoked directly;src/server/index.tsstill needs to connect it to HTTP and WebSocket request handling.Confidence Score: 4/5
Not safe to merge until the configured rate limiter is enforced by the server runtime.
The server accepted repeated protected requests after an enabled one-request budget had been exhausted, while the same configuration correctly denied the second request when the admission helper was called directly.
Files Needing Attention: src/server/index.ts
Security Review
The rate limiter is intended to protect server resources, but enabled settings currently do not constrain production HTTP or WebSocket traffic. Operators could enable the feature believing abusive or accidental request bursts are bounded while protected endpoints continue accepting requests. Wire authentication-aware admission, denial responses, and WebSocket reservation lifecycle handling into
src/server/index.tsbefore merging.What T-Rex did
Comments Outside Diff (3)
General comment
rateLimitSurfaceForRequestreturnsnullforGET /v1/live/{callId}andGET /v1/realtime/calls/{callId}whenwebSocketis true, even though the live sideband parser recognizes both routes and the server dispatches them for WebSocket upgrades.src/server/rate-limit-admission.ts:55compares only the three literal paths/v1/live,/v1/realtime, and/v1/realtime/calls; it has no parameterized-path match.parseLiveSidebandTargetor using equivalent strict path matching so unsupported prefixes remain uncharged.src/server/index.ts, line 255 (link)The new configuration, principal, admission, and 429-rendering helpers are not connected to the server request or WebSocket lifecycle. With
rateLimit.enabled: trueand amodel-discoverypolicy capped at one request, two realGET /v1/modelsrequests both return200without rate-limit headers. This leaves the resource-protection feature inert in production. Construct the coordinator during server startup, derive a principal after successful authentication, admit each mapped HTTP route before downstream work, and return the endpoint-specific 429 response on denial. WebSocket upgrades also need token charging, reservation, failed-upgrade rollback, and release hooks.Artifacts
Command output from the check
Command output from the check
Evidence from the check
Prompt To Fix With AI
General comment
rateLimit.enabled=trueandmodel-discoveryset to one request per minute with burst one, two actualGET /v1/modelsrequests returned 200 and noX-RateLimit-*/Retry-Afterheaders. The same configuration passed directly toRuntimeRateLimitAdmissionreturnedallowedthendenied, proving the limiter itself can exhaust but production routing does not invoke it.startServerloads configuration and handles every HTTP/WebSocket route insrc/server/index.ts:255-976, but does not resolveconfig.rateLimit, instantiateRuntimeRateLimitAdmission, derive an authenticated principal, calladmit/reserveWebSocket, renderrateLimitResponse, or release WebSocket reservations. The new modules therefore have no runtime call path.server.upgrade, release on failed upgrade, retain the release function inWsData, and release it on every close/error path. Wire management metrics/snapshots as specified by the runtime-wiring contract.Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "test(ratelimit): cover canonical live si..." | Re-trigger Greptile