Skip to content

fix(gateway): stored disabled tool calling survives endpoint moves — with the contract-seam lift and LiteLLM production repairs - #3042

Merged
oscharko merged 12 commits into
devfrom
issue/toolcalling-survives-endpoint-move
Aug 9, 2026
Merged

fix(gateway): stored disabled tool calling survives endpoint moves — with the contract-seam lift and LiteLLM production repairs#3042
oscharko merged 12 commits into
devfrom
issue/toolcalling-survives-endpoint-move

Conversation

@oscharko

@oscharko oscharko commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Three review-complete work packages from the 0.3.0 hardening cycle, deferred off the collector (#3037) as agreed there:

  1. Stored disabled tool calling survives endpoint moves (owner-directed follow-up). A stored toolCalling: false no longer flips to enabled when a preserve-mode rebuild moves the endpoint or the capability entry is missing from the rebuilt set, and the Mistral limitation note travels with the disabled state instead of being stripped by applyMistralSetupDefaults on every preserve rebuild. The replaceModelCapability re-enable path stays intact.
  2. Endpoint-protocol wire unions lifted into the contract seam (ProviderEndpointStyle, RealtimeAuthMode + value arrays with Record<Union, true>-derived exhaustiveness). The UI upload parser and the server setup route now validate against the same wire values without importing the gateway package (ADR-0019: keiko-ui never imports keiko-model-gateway); keiko-model-gateway re-exports from contracts so every existing consumer keeps its import path.
  3. LiteLLM production audit repairs (owner directive: LiteLLM is mandatory in production). Chat URL trailing-slash normalization, moved-endpoint voice protocol bleed fixed via sameBaseUrlIdentity gating, 401 classification on setup failures, upload-parser LiteLLM tolerances, plus docs/troubleshooting/litellm-production-gateway.md (x-litellm-key header configuration, NO_PROXY for loopback proxies, outputTokenParameter for reasoning aliases, discovery cap) with the realtime-voice boundary stated as by-design (realtime is not offered over LiteLLM; the product detects the model and withholds the surface).

Reuse / No-Duplication

No new subsystem. The unions moved to the existing contract seam (keiko-contracts/src/gateway.ts); the gateway package re-exports them; the UI reads them through the existing @/lib/types seam. The toolCalling preservation extends the existing capability-preservation path in gateway-setup.ts; the LiteLLM repairs extend existing validators.

Verification

  • Failure-first: every behavioral fix has a pin that was red on the prior code (toolCalling flip, limitation-note stripping, trailing slash, protocol bleed, parser tolerances).
  • gateway-setup.test.ts 204/204, keiko-model-gateway 1041/1041, modals suite 225/225 — all on this branch atop current dev.
  • Root tsc -b across contracts/model-gateway/server/ui, repo ESLint (zero warnings), keiko-ui workspace lint, prettier.
  • npm run arch:check (contract boundaries green — the new edges point inward to contracts).
  • npm run check:package-surface:assembled for the new contracts exports.
  • npm run gates:sonar PASS on the final diff.

Update-Impact

Behavioral: preserve-mode rebuilds no longer silently re-enable stored-disabled tool calling; LiteLLM chat URLs tolerate trailing slashes; moved voice endpoints no longer inherit the previous endpoint's protocol shape. No wire-format change (the unions are identical values, now single-sourced). No migration required.

🤖 Generated with Claude Code

@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 19:06 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@oscharko, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c3e99bfb-a9f8-438c-b89f-e7419675f89d

📥 Commits

Reviewing files that changed from the base of the PR and between 8b31fc7 and 53f8f1e.

📒 Files selected for processing (3)
  • docs/troubleshooting/litellm-production-gateway.md
  • scripts/check-package-surface.mjs
  • scripts/root-package-surface.contract.json
📝 Walkthrough

Walkthrough

This PR centralizes gateway protocol contracts, fixes provider URL normalization, refines gateway setup preservation and error classification, strengthens UI validation, expands package exports, and adds LiteLLM troubleshooting documentation.

Changes

Gateway contracts, exports, and URL handling

Layer / File(s) Summary
Shared gateway contracts and package exports
packages/keiko-contracts/src/*, packages/keiko-model-gateway/src/*, packages/keiko-ui/src/lib/types.ts, scripts/root-package-surface.contract.json
Adds shared endpoint-style and realtime-authentication contracts. Re-exports them across packages. Synchronizes declaration and runtime exports.
Provider URL normalization and readiness probes
packages/keiko-model-gateway/src/openai-adapter.*, packages/keiko-model-gateway/src/readiness-probe.*
Removes trailing slashes before constructing chat-completions URLs. Tests verify paths, model IDs, and bearer authorization.

Gateway setup and validation

Layer / File(s) Summary
Gateway setup preservation and failure classification
packages/keiko-server/src/gateway-setup.*
Controls capability and protocol inheritance during endpoint moves. Propagates preserveExisting. Preserves classified HTTP evidence for discovery and smoke-test failures.
Gateway configuration parsing and validation
packages/keiko-ui/src/app/components/desktop/modals/gatewayConfigParsing.*
Validates endpoint styles, rejects comma-containing model IDs, normalizes API-key headers, and uses shared voice protocol values.

LiteLLM troubleshooting

Layer / File(s) Summary
LiteLLM troubleshooting documentation
docs/troubleshooting/README.md, docs/troubleshooting/litellm-production-gateway.md
Adds guidance for LiteLLM authentication, proxy routing, reasoning-model token errors, discovery truncation, and voice support.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: 🕐 40+ Minutes

🚥 Pre-merge checks | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title uses a conventional fix(gateway) prefix and names the delivered changes, but its subject is declarative rather than imperative. Rewrite the subject as an imperative outcome, such as fix(gateway): preserve disabled tool calling across endpoint moves and repair LiteLLM production behavior.
Description check ⚠️ Warning The description covers the main work and verification, but it omits required Scope, Delivery Board, Product Impact, Review And Closure, Risk Notes, and detailed Update Impact sections. Add the missing template sections, issue reference, applicable checkboxes, risk notes, release-impact fields, closure evidence, and explicit local verification and reuse rationale.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

Comment thread packages/keiko-server/src/gateway-setup.test.ts
@keiko-for-quality

keiko-for-quality Bot commented Aug 8, 2026

Copy link
Copy Markdown

Keiko for Quality — run summary

COMPLETE · head 53f8f1e · 2026-08-09T00:15:40Z · engine v1.8.4 · action 8aafc617614f06d9c90be6fb32fda112ccc1cf78

Metric Count
Total paths 18
Reviewable 16
Excluded 2
Mechanically clean 0
Critical pointer changes (content not reviewable) 0
Replayed from cache 7
Cache miss (path-set shape changed) 9
Freshly reviewed 9
Findings published 2
Suppressed (intra-run duplicate) 0
Suppressed (exact duplicate) 0
Suppressed (similar) 0
Suppressed (dispositioned) 2
Suppressed (outdated recurrence) 0
Rejected (sanitization) 0
Rejected (placement) 0
Read-back failures 0
API failures 0
Duration (s) 52
Tokens per published finding 66544

Budget: 2440464 tokens allotted, 133088 reported

Recent runs

  • 53f8f1e · complete · fresh 9 · replayed 7 · 52s
  • 8f6c074 · complete · fresh 2 · replayed 14 · 30s
  • 8e83fa8 · complete · fresh 8 · replayed 7 · 23s
  • 8b31fc7 · complete · fresh 8 · replayed 7 · 34s
  • fbdbbd3 · complete · fresh 8 · replayed 7 · 26s

@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 19:07 — with GitHub Actions Inactive
@oscharko
oscharko enabled auto-merge (squash) August 8, 2026 19:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e7c233f4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/keiko-model-gateway/src/index.ts
oscharko added a commit that referenced this pull request Aug 8, 2026
…ckage surface (#3042)

PROVIDER_ENDPOINT_STYLES and REALTIME_AUTH_MODES reach the root runtime and
declaration surface through the contracts re-export; the expectation update
was lost in the cherry-pick onto fresh dev and turned the whole CI matrix
red on the surface gate. Set-diff against the previous contract: exactly
these two additions, zero removals (the file rewrite is the checker's
deterministic sort).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 19:51 — with GitHub Actions Inactive
Comment thread scripts/root-package-surface.contract.json
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 19:51 — with GitHub Actions Inactive
@oscharko
oscharko disabled auto-merge August 8, 2026 20:07
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:08 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:09 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:10 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:11 — with GitHub Actions Inactive
@oscharko
oscharko enabled auto-merge (squash) August 8, 2026 20:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d0bbcd98f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
Comment thread packages/keiko-server/src/gateway-setup.ts Outdated
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
@oscharko
oscharko disabled auto-merge August 8, 2026 20:19
oscharko added a commit that referenced this pull request Aug 8, 2026
…antics; honest LiteLLM diagnostics (#3042)

- A fresh replacement (preserveExisting omitted) no longer inherits a stored
  disabled toolCalling onto a new endpoint — the restriction now rides the
  preserve flag through the setup request like every stored-capability
  carry-over; pin red first (Codex finding).
- Troubleshooting doc: the proxy diagnostic lists variable NAMES only (proxy
  URLs embed credentials), and the discovery-cap check counts JSON entries
  instead of lines — a capped response also never exceeds the cap, so the
  'above 100' reading was unreachable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:22 — with GitHub Actions Inactive
Comment thread packages/keiko-server/src/gateway-setup.ts Outdated
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:23 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:26 — with GitHub Actions Inactive
@oscharko
oscharko enabled auto-merge (squash) August 8, 2026 20:26
Comment thread packages/keiko-server/src/gateway-setup.ts
Comment thread packages/keiko-server/src/gateway-setup.ts
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 20:26 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 22:25 — with GitHub Actions Inactive
@oscharko
oscharko temporarily deployed to keiko-for-quality August 8, 2026 22:26 — with GitHub Actions Inactive
@oscharko
oscharko enabled auto-merge (squash) August 8, 2026 22:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0537be7333

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/keiko-server/src/gateway-setup.ts
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
…er in history or argv (#3042)

The placeholder assignment put the real LiteLLM hostname into shell history
once an operator substituted it, and the expanded URL was visible in curl's
process arguments for the duration of each request. Both blocks now read the
host and the key without echo into a 0600 mktemp curl config file (url +
header), so curl's argv carries only --config; the separate header files are
gone with it.

Executed against an unreachable host: status 7 propagates out of the
subshell, the parent shell survives. All three bash blocks syntax-checked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread packages/keiko-server/src/gateway-setup.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a16fc48303

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
…unts require an array (#3042)

- curl -S printed 'Could not resolve host: <hostname>' on stderr, putting the
  production endpoint into scrollback and support logs even though --config
  had removed it from argv. The probes run with -s only and map a non-zero
  exit to 'transport failure (curl exit N)' — 6 DNS, 7 connect, 35 TLS,
  28 timeout. Verified against an unresolvable host: the name appears nowhere
  in stdout or stderr.
- The count guarded only JSON.parse, so a valid document whose data member is
  a string printed a character count, and {"data":{"length":"..."}} printed
  attacker-controlled text. Array.isArray is required now; verified against
  object-with-length, string data, a proper array and non-JSON.

All three bash blocks syntax-checked; sonar PASS.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread packages/keiko-server/src/gateway-setup.test.ts
Comment thread packages/keiko-server/src/gateway-setup.test.ts
Comment thread packages/keiko-server/src/gateway-setup.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c89ac81b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
…xit status (#3042)

Three review findings on the diagnostics, each verified against a local
proxy stand-in rather than argued:
- The model-list download is bounded in bytes and time (--max-filesize 2MB,
  --max-time 30) and the reader refuses an oversized file, so a hostile or
  misconfigured proxy can fill neither the disk nor the reader's memory. A
  2MB+ body now ends as 'transport failure (curl exit 63)' with status 63.
- The count probe asks which key header the proxy reads; hardcoding
  Authorization made the diagnostic useless on exactly the proxies the page
  tells operators to configure. Both header choices return the real count
  (137 against the stand-in).
- probe() returns curl's status instead of swallowing it behind the echo, so
  a pasted script can tell a transport failure from a completed diagnostic;
  the auth block exits with the first non-zero status.
Additionally the unreadable-body message carries the HTTP status (a number,
still body-free): a key on the ignored header now reads 'unreadable response
(HTTP 401, ...)' instead of looking like a malformed model list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbdbbd3ff4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
…inct ids from a 2xx body (#3042)

- P1: curl reads ~/.curlrc even when --config is supplied, so a default
  'verbose' or 'trace' there would print the Authorization header this block
  exists to hide. All three keyed invocations now start with -q.
- The count claimed to predict Keiko's truncation but used the RAW array
  length, while parseModelDiscovery rejects non-2xx, drops entries it cannot
  classify, and deduplicates by id BEFORE applying MAX_DISCOVERED_MODELS. It
  now counts distinct ids from a 2xx body only, and the guidance states the
  number is an upper bound on what Keiko keeps, not an exact prediction.

Verified against a local stand-in: 137 distinct → 137; 50 entries with 5
distinct ids → 5; a body mixing a valid entry with a malformed record and a
bare string → 1; HTTP 500 carrying a data array → 'unreadable response
(HTTP 500, ...)' instead of a count.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/troubleshooting/litellm-production-gateway.md`:
- Around line 57-62: In both configuration-generation sites in
docs/troubleshooting/litellm-production-gateway.md (lines 57-62 and 209-216),
parse HDR using an explicit allowlist before prompting for the key, then escape
HOST, KEY, and HDR for their double-quoted curl configuration values before
writing the files. Apply the same validation and escaping behavior at both sites
so malformed input cannot alter the generated authorization header.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2642759-2d87-4839-86dc-0bb138c066b2

📥 Commits

Reviewing files that changed from the base of the PR and between 940935f and 8b31fc7.

📒 Files selected for processing (2)
  • docs/troubleshooting/litellm-production-gateway.md
  • packages/keiko-server/src/gateway-setup.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (13)
  • GitHub Check: Cross-platform smoke (windows-latest)
  • GitHub Check: Cross-platform smoke (ubuntu-latest)
  • GitHub Check: Cross-platform smoke (macos-latest)
  • GitHub Check: Coverage suite (keiko-ui)
  • GitHub Check: Build, scan, SBOM, smoke
  • GitHub Check: Coverage suite (scripts)
  • GitHub Check: Core quality
  • GitHub Check: Coverage shard (packages 2/3)
  • GitHub Check: ui
  • GitHub Check: Coverage shard (packages 3/3)
  • GitHub Check: Coverage shard (packages 1/3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (6)
**/*

📄 CodeRabbit inference engine (AGENTS.md)

**/*: Use English in code, comments, identifiers, documentation, commit messages, issues, and pull requests.
Respect the inward dependency direction: keiko-contracts is the leaf, keiko-security depends only on contracts, and cross-package types belong in contracts.
Inspect and reuse existing helpers, contracts, and subsystems; do not create parallel workspace, graph, policy, evidence, memory, connector, workflow, or UI subsystems without a documented capability gap.
Keep manifests, audit exports, diagnostics, logs, configuration, tests, and evidence redacted: never expose secrets, keys, raw content, endpoints, PII, memory bodies, or customer data.
Never weaken trust boundaries, evidence redaction, governance gates, required checks, or authority limits to make a change pass; fail closed.
Never directly push to dev, force-push, bypass required checks, dismiss findings to obtain green status, or merge outside the approved direct-check path.
Use branch names in the form type/short-slug, never work directly on dev, and use imperative conventional commit subjects with an issue or PR reference and no secrets.
Run the applicable local typecheck, lint, format check, tests, architecture checks, Sonar gate, and touched-area gates before claiming a change or pull request is green; report only commands actually executed.

Files:

  • docs/troubleshooting/litellm-production-gateway.md
  • packages/keiko-server/src/gateway-setup.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use strict TypeScript settings, forbid any, require explicit function return types, and model states with discriminated unions rather than casts.
Keep cyclomatic complexity at or below 10, keep functions within 50 non-comment lines, and extract helpers when necessary.
Use the intended logger or diagnostic sink instead of console.* in product code.
Validate hostile inputs before processing, fail closed at trust boundaries, and never route generated or model-produced code around the sandbox egress boundary.
Do not swallow errors with empty catches; surface sufficient diagnostic context, including a correlation ID for server-visible opaque 500 errors.

Files:

  • packages/keiko-server/src/gateway-setup.ts
**/*.{ts,tsx,js,mjs,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use Prettier formatting: 2-space indentation, double quotes, semicolons, 100-column width, trailing commas, and LF endings.

Files:

  • packages/keiko-server/src/gateway-setup.ts
**/*.{ts,tsx,js,mjs}

📄 CodeRabbit inference engine (AGENTS.md)

Delete dead code instead of commenting it out and do not leave scaffolding or TODOs hiding unfinished branches.

Files:

  • packages/keiko-server/src/gateway-setup.ts
packages/keiko-server/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

The server may use domain packages but must not depend on keiko-editor; domain packages must not depend on the server.

Files:

  • packages/keiko-server/src/gateway-setup.ts
packages/**/src/**

⚙️ CodeRabbit configuration file

packages/**/src/**: Enforce ADR-0019 package direction and the owning trust boundary. Flag provider SDK imports
outside keiko-model-gateway, cross-package wire types outside contracts, workspace escape,
raw evidence bodies, silent failures, and parallel subsystems that should extend an owner.

Files:

  • packages/keiko-server/src/gateway-setup.ts
🧠 Learnings (4)
📚 Learning: 2026-07-24T19:25:13.892Z
Learnt from: oscharko
Repo: oscharko-dev/Keiko PR: 2697
File: packages/keiko-server/src/editor/inlineCompletionRoutes.ts:616-616
Timestamp: 2026-07-24T19:25:13.892Z
Learning: In `packages/keiko-server`, follow ADR-0141 D5’s AppSession/request-authorization model for workspace root resolution. When reviewing code that performs the `resolveRequestRoot`-style authorization gate, ensure it (1) re-proves persisted workspace identity, (2) derives the request root path, (3) enforces canonical realpath containment within the expected workspace/root to prevent path traversal, (4) verifies workspace presence/validity, and (5) requires a live AppSession (launcher-attested, process-scoped authority per BFF). Do not require a task identity for this gate if AppSession does not model task identity; authorization should be uniform and based on the same-user local threat model rather than per-task/per-workspace session semantics.

Applied to files:

  • packages/keiko-server/src/gateway-setup.ts
📚 Learning: 2026-07-26T21:23:56.288Z
Learnt from: oscharko
Repo: oscharko-dev/Keiko PR: 2755
File: packages/keiko-server/src/grounded-qa-hybrid.ts:1006-1012
Timestamp: 2026-07-26T21:23:56.288Z
Learning: In Keiko’s internal “stable-ID” hash helper functions (e.g., where stable identifiers are computed for persistence/comparison), preserve the existing UTF-16 code-unit iteration semantics when modernizing. Specifically, if the current implementation iterates with `charCodeAt(i)` (code units) rather than `codePointAt(i)` (Unicode code points), keep `charCodeAt(i)` to avoid changing the resulting stable IDs. If changing from `charCodeAt` to `codePointAt` is ever desired, it must be an explicitly planned compatibility/migration decision (e.g., versioning, backfill, or dual-read/write) rather than a mechanical refactor.

Applied to files:

  • packages/keiko-server/src/gateway-setup.ts
📚 Learning: 2026-07-27T10:55:30.485Z
Learnt from: oscharko
Repo: oscharko-dev/Keiko PR: 2766
File: packages/keiko-server/src/qualityIntelligence/figmaSnapshotRoutes.test.ts:1738-1738
Timestamp: 2026-07-27T10:55:30.485Z
Learning: When reviewing TypeScript files, do not flag single-quoted string literals as a violation if they match Prettier’s formatter-approved output. Specifically, if Prettier is configured to prefer double quotes but retains a single-quoted literal solely because switching to double quotes would require escaping embedded double quotes, allow the single quotes (i.e., don’t “fix” it beyond what Prettier would produce).

Applied to files:

  • packages/keiko-server/src/gateway-setup.ts
📚 Learning: 2026-07-27T18:08:22.461Z
Learnt from: oscharko
Repo: oscharko-dev/Keiko PR: 2780
File: packages/keiko-server/src/store/migrations.test.ts:78-95
Timestamp: 2026-07-27T18:08:22.461Z
Learning: When reviewing TypeScript lint findings (e.g., from typescript-eslint/no-unsafe-assignment), ensure the issue is reproducible using the repository’s configured ESLint setup/TS project settings. Do not treat diagnostics observed under a mismatched TypeScript project/tsconfig as authoritative; only accept them as real if you can reproduce them with the same ESLint configuration the repo uses (e.g., via its full/targeted lint scripts). In related test code, prefer deriving branded identity types from the production function return types to keep RootIdentity/brand fields type-compatible and avoid unsafe assignments.

Applied to files:

  • packages/keiko-server/src/gateway-setup.ts
🔇 Additional comments (4)
packages/keiko-server/src/gateway-setup.ts (1)

32-33: LGTM!

Also applies to: 302-303, 316-319, 352-352, 403-417, 439-445, 1188-1193, 1396-1452, 1467-1471, 1480-1493, 1508-1511, 1612-1612, 1835-1838, 3151-3167, 3423-3423, 3530-3530, 3726-3726, 4168-4168

docs/troubleshooting/litellm-production-gateway.md (3)

44-56: LGTM!

Also applies to: 63-85


204-208: LGTM!

Also applies to: 217-222, 225-237


199-203: 🩺 Stability & Availability

No change needed.

--max-filesize is applied to chunked or ongoing transfers, so the documented bounded behavior is not invalidated by unknown response sizes in this script.

			> Likely an incorrect or invalid review comment.

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
…ues (#3042)

curl config values are double-quoted, so a key or host containing a quote or
backslash silently produced a DIFFERENT header than the operator intended —
an unexplained auth failure with no way to see the cause. Both blocks escape
those two characters before writing (the escaper keeps the value out of any
argv: printf is a builtin, sed reads stdin). The header NAME is allowlisted
to the two headers this proxy family supports, so a typo fails fast with
exit 2 instead of sending a header nothing reads.

Byte-exact verification against a local stand-in: the key sk-a"b\\c arrives
as 'Bearer sk-a"b\\c' unchanged; both allowlisted headers return the count;
a bogus header name exits 2 without issuing a request.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e83fa885c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/troubleshooting/litellm-production-gateway.md Outdated
… pin requires (#3042)

The regenerated contract re-sorted runtimeExports with localeCompare, while
tests/architecture/root-package-surface-contract.test.ts asserts the list
equals [...].sort() — code-unit order, uppercase before lowercase. The gate
accepted a file the pin rejected, which is how a green local
check:package-surface still failed the coverage shard.

The generator now sorts with an explicit code-unit comparator (proven to
reproduce default-sort output exactly), the committed list is reordered to
match with an unchanged SET (288 entries, verified), and the neighbouring
multi-push Sonar smell in the same file is folded into one call.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread scripts/root-package-surface.contract.json
…d claims only what it proves (#3042)

modelIdFromKnownFields takes the first usable of id / model_name / model /
deployment_name / deploymentName, TRIMS it and bounds its length before
parseModelDiscovery deduplicates — so counting raw `id` strings both missed
entries the gateway does read and double-counted ids differing by
whitespace. The one-liner mirrors that normalization now.

The guidance is corrected in the direction that matters rather than
overclaiming: 100 or fewer proves nothing is truncated; above 100 is a
strong indication only, because entries whose declared mode the gateway
rejects are still dropped before the cap. Confirming truncation means
comparing with the deployment list Keiko shows after a save.

Verified against a stand-in: whitespace-differing ids → 2, alternative id
fields → 3, unusable/absent ids → 1, a plain 137-entry list → 137.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread scripts/root-package-surface.contract.json
Comment thread scripts/root-package-surface.contract.json
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant