Skip to content

feat(auto-routing): owner-configurable Efficient model pools - #4846

Merged
iscekic merged 24 commits into
mainfrom
efficient-custom-pool-e6e3
Jul 31, 2026
Merged

feat(auto-routing): owner-configurable Efficient model pools#4846
iscekic merged 24 commits into
mainfrom
efficient-custom-pool-e6e3

Conversation

@iscekic

@iscekic iscekic commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

What. kilo-auto/efficient can now be customized per owner: a personal user or an organization configures 1–10 exact (managed model, canonical catalog variant) pairs on the existing Auto routing card. Missing exact pairs are benchmarked on demand through the existing benchmark Worker; routing then decides only among ready, compatible entries and keeps the balanced fallback whenever none are usable.

Why. Owners want the Efficient auto model constrained to the exact models and variants they trust (same-model xhigh vs max stay distinct end-to-end) without losing the platform default when their pool cannot serve.

How.

  • Shared contracts for Pool entries / Benchmark profiles with exact-pair identity (packages/auto-routing-contracts), ADR 0002 updates, canonical terms in CONTEXT.md.
  • Global benchmark profile registry in the benchmark Worker: atomic all-or-nothing D1 admission (10 new/retried pairs per owner per rolling 24h, globally deduplicated), exact-pair composite keys with a rebuild-safe migration, profile-purpose runs on the existing single decider slot, and sparse custom routing tables assembled from ready/current profiles only.
  • Auto-routing Worker: pools stored beside mode on the existing routing-settings Durable Object (mixed put/delete commits in one storage transaction), custom decide path failing closed on inactive/missing capability rows, org → personal → platform inheritance resolved independently per field.
  • Gateway resolution serves the exact catalog variant (full settings, not effort-only mapping); a removed variant or unusable pool falls back to balanced. Legacy reasoningEffort decisions stay parseable.
  • Web: validated settings API (enabled/visible/managed catalog entries only; virtual, experiment, hidden, denied, BYOK-only rejected) and the pool editor on the existing Auto routing card for personal and organization settings (owners/billing managers edit; members read-only). Deploy-order safe during the web-before-worker window: the card falls back to the legacy mode route (poolSupported: false hides pool controls; mode saves stay mode-only at every worker version; a mid-session rollback answers a retryable 503 instead of mis-saving). Malformed worker settings responses degrade to a graceful 502.

Verification

  • Local E2E (full local stack: nextjs + auto-routing + auto-routing-benchmark + D1, Chromium + curl + wrangler d1 + psql) — PASSED, all 10 acceptance criteria:
    1. Personal/org pools save, clear, and inherit independently (org override served claude-haiku-4.5; clearing restored personal claude-sonnet-4.5, instrumented proof; mode and pool saves independent).
    2. Member read-only (disabled controls, PUT → 401); billing_manager flip restores full edit.
    3. Validation rejects hidden/virtual/missing-variant/unknown ids with specific reasons at API and UI.
    4. Same-model xhigh + max persist and render as distinct rows and distinct D1 PKs.
    5. Benchmarking state with 15s polling that transitions to Ready and stops at terminal.
    6. Failed → Retry re-admits (ledger +1); org-denied entry renders Unavailable with no retry and is removable; 10/24h quota rejects with retryAt copy, atomically (zero partial rows).
    7. Empty/inherited copy verified verbatim for personal and org cards.
    8. Load and save failures are retryable with Try again CTAs and recover.
    9. Real routing assertion (real kilo-auto/efficient calls only): seeded ready pool constrained the decision to pool entries (custom table, 18 routes, threshold-winner xhigh); stale profiles → balanced fallback with uncharged re-admission; no pool → default platform path.
    10. 19 state screenshots at 375px + desktop (personal + org variants of ready, benchmarking, failed/retry, unavailable, quota, empty, load-error, member read-only).
    • Deploy-order fallback matrix skipped as structurally unproducible in a single-tree local stack; covered by automated route/card tests including the rollback-503 path.
  • Automated coverage on the latest head: contracts 115 tests, benchmark 235, auto-routing 177, web focused 119 + admin-client 36; typecheck, lint, format, dependency-cycle, changes-only repo typecheck all clean; fresh cumulative review over the whole diff: no findings.

Visual Changes

Local screenshots of the Auto routing card on /profile (desktop + 375px). Survey modal may appear for fresh seed users — dismiss it; the pool editor is underneath.

Empty pool (desktop) Add model
empty pool add model
Pool card focus Mobile 375px
pool card 375
Full profile after edit
after edit

Reviewer Notes

  • Focus: exact-pair identity at every hop (picker → contracts → D1 composite keys → assembly → decide/sticky → gateway getModelVariants); admission vs save atomicity across the two workers (quota 429 with retryAt, all-or-nothing D1 admission, one DO storage transaction); the deploy-order fallback matrix (old web + new worker, new web + old worker, rollback mid-session).
  • D1 migration 0005 rebuilds the profile tables with backfill — verify the generated SQL preserves legacy rows and exact-pair keys; 0006/0007 are additive.
  • Accepted residuals: same-owner concurrent quota-boundary racing (documented in-code; quota is throttling, per-pair charge integrity is atomic); deploy-window pool saves answer a retryable 503 by design rather than risking a silent pool clear or resurrection.

Follow-ups noted during review (non-blocking)

  • createWorkerAdminFetch keeps the throw-on-malformed convention for the sibling admin routes; the settings client now sets the safer safeParse→502 precedent those can adopt.
  • The new 502 mapping reports intermediary non-JSON failures (edge HTML error pages) as 502 rather than the upstream status; genuine worker error responses are always JSON, so this only affects edge cases that surface as the same retryable load/save error either way.
  • Degrade paths have no log/Sentry signal yet (consistent with the route's pre-existing 502 branches).

iscekic added 18 commits July 28, 2026 16:18
A bare session target intermittently resolves to a same-named window and
fails with "index 0 in use". Use the session: colon form and record the
learning.
… contracts

Add Pool entry / Efficient model pool schemas with a collision-safe
poolEntryKey, optional canonical variant on routing candidates and
benchmark decisions with legacy reasoningEffort compatibility, the sparse
CustomRoutingTableSchema, benchmark profile registry wire types, and owner
pool settings contracts. Extend ADR 0002 with owner-pool invariants and
record Auto Routing scope and canonical terms in CONTEXT.md.
…results

Composite (model, variant) primary keys across run_models, model_summaries,
and case_results with a generated migration that backfills variant from
reasoning_effort; exact-pair queue messages, container lanes, carry matching,
and summaries; routing-table candidates self-describe their variant. The
published platform routing table JSON is unchanged in shape. Bounded contract
extensions: optional variant on BenchmarkModelSummary and
BenchmarkDeciderModel with legacy reasoningEffort compatibility.
…-e6e3

# Conflicts:
#	.kilo_workflow/dispatch-role.sh
When kilo-auto/efficient decisions carry a canonical variant, apply the
full getModelVariants settings (reasoning + verbosity). Missing catalog
keys fall back to balanced; legacy effort-only decisions stay unchanged.
Store Efficient model pools on the routing-mode DO, admit profiles
before settings PUT, and resolve custom tables with exact-pair sticky
and custom-only isActive fail-closed.
…atomic admission

Add benchmark_profiles and profile_request_events D1 tables, one
all-or-nothing admission batch with 10-per-owner-per-24h quota and
global dedupe, concurrency-safe guarded upserts and conditional
charges, and the internal register/status endpoints.
Cover the charged-event, register-upsert, and status-insert builders
against node:sqlite so column-count or guard regressions fail the suite
behind the drizzle mock.
Validate Efficient pool entries against the owner's effective managed
catalog, proxy worker settings, annotate unavailable saved entries, and
preserve benchmark quota 429 retryAt for the UI.
…, sparse custom tables

Wire startRun(purpose, entries), terminal profile transitions, pending-batch
drain on the existing one-active-decider slot with platform priority,
POST /admin/custom-routing-table with provenance-bound assembly, and ops
docs. Platform artifact path unchanged.
Extend AutoRoutingModeCard to manage mode + 1-10 pool entries via
/api/auto-routing/settings, with benchmark status, polling, retry,
and org billing-manager edit permission isolation.
…-e6e3

# Conflicts:
#	.kilo_workflow/dispatch-role.sh
A mixed save (mode set + pool cleared, or the reverse) fanned out to
independent multi-key put and delete ops via Promise.all; one succeeding
while the other threw diverged mode and pool despite the 'commit or fail
together' contract. Wrap the mutation in ctx.storage.transaction and cover
rollback with an honest transactional storage stub.
Production promotes web before workers, so every merge runs new web
against workers that lack /admin/routing-settings (JSON 404). Load now
falls back to the legacy mode route and reports poolSupported: false,
hiding pool controls instead of failing the card; mode saves from that
state use the legacy mode endpoint, which never touches pool keys at any
worker version. A settings PUT that 404s (rollback mid-session from a
supported UI) answers a retryable 503 rather than silently mis-saving.
…gration truth

ADR 0002 and the benchmark README now match the shipped behavior: owner
mode+pool commit in one DO storage transaction; the web-before-worker
deploy window serves the legacy-synthesis fallback (poolSupported: false,
mode-only legacy saves, retryable 503 on settings PUT 404); admission's
DO-after-admit semantics are written down; and the rollback section stops
claiming the D1 schema is additive now that 0005 rebuilds profile tables
with backfill.
@iscekic iscekic self-assigned this Jul 28, 2026
Comment thread apps/web/src/lib/ai-gateway/auto-routing-admin-client.ts Outdated
Comment thread apps/web/src/app/api/auto-routing/settings/route.ts
Comment thread services/auto-routing-benchmark/src/profiles.ts
@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 407f33a8e (single commit since 0e09154f5): a formatting-only reflow of one await expect(...) assertion in the profile claim-failure test, semantically identical to the reviewed version — no findings, high confidence.

Files Reviewed (1 file)
  • services/auto-routing-benchmark/src/profile-runs.test.ts - the startRun(env, 'decider', { purpose: 'profile', entries }) call and .rejects.toThrow('claim failed') matcher were re-wrapped by oxfmt onto lines 201-203; the awaited expression, the rejection matcher, and the subsequent markRunFailed / queueSendBatch assertions are unchanged, so the test still exercises the real failRunAndDrain abort path
Scope Notes
  • No production code changed in this increment; findings from earlier commits are not carried forward.
  • Existing threads re-checked against current HEAD and all remain addressed or accepted: auto-routing-admin-client.ts safeParse and settings/route.ts:120 fallback fixed in 3239b9d78, run.ts:555 duplicate-run abort fixed in 0e09154f5, ADR 0002 restored with pool content moved to ADR 0003, and profiles.ts:416 quota TOCTOU is the author-accepted residual risk.
Previous Review Summaries (4 snapshots, latest commit 0e09154)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 0e09154)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 0e09154f5 (single PR commit since 061ff6fcc): aborting a profile run when markProfilesRunningForRun rejects is correct and fail-closed, and the ADR split moves pool content out of ADR 0002 into new ADR 0003 with no code impact — no unresolved findings, high confidence.

Files Reviewed (4 files)
  • services/auto-routing-benchmark/src/run.ts - verified the new failRunAndDrain(env, runId, ...) + rethrow at the profile-claim failure path: the run row is flipped to failed (freeing the single decider slot), claimed profile rows are transitioned, and the function returns before enqueueRunMessages, so no queue work is dispatched for a run whose profile rows never left pending; log level raised warnerror and formatError output contains no credentials
  • services/auto-routing-benchmark/src/profile-runs.test.ts - new test rejects markProfilesRunningForRun and asserts the rethrow, markRunFailed on the profile- run id, and no sendBatch; ./db is mocked while run.ts is real, so the assertion exercises the production failRunAndDrain path rather than a stub
  • docs/adr/0003-efficient-model-pools.md - new ADR; single h1, sequential headings, relative link to ./0002-auto-routing-efficient.md (target exists), no images/HTML tags; invariant 4's fail-closed claim matches the run.ts behavior in this commit
  • docs/adr/0002-auto-routing-efficient.md - now byte-identical to origin/main, so ADR 0002 carries no PR change and the pool architecture lives only in ADR 0003
Scope Notes
  • Both open human threads are addressed by this commit: run.ts:555 (profile claim failure launching duplicate runs) is fixed by the abort + drain, and the ADR-editing nit is addressed by restoring ADR 0002 to baseline and adding ADR 0003.
  • Prior bot threads re-verified as still resolved or accepted: the auto-routing-admin-client.ts safeParse→502 change and settings/route.ts:120 fallback remain in place; services/auto-routing-benchmark/src/profiles.ts:416 quota TOCTOU is the author-accepted residual risk and is untouched here.
  • Observation, not a finding: failRunAndDrain internally calls drainPendingProfileBatch, which can call startRun again for the same pending batch. A deterministic claim-update failure could re-enter this path, but the drain's own errors are already swallowed and the pending list read shares the failing table, so it is bounded in practice; this is the same drain-after-failure pattern already used by enqueueRunMessages.

Previous review (commit 061ff6f)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of 061ff6fcc (the only PR-authored commit since 3239b9d7; the rest of the range is a main merge): reordering the spread in the settings PUT so auth-resolved ownerType/ownerId override any client-supplied values is correct and strictly hardens owner identity — no new findings, and all previously raised findings are resolved or accepted by the author.

Files Reviewed (1 file)
  • apps/web/src/app/api/auto-routing/settings/route.ts - owner-identity spread order in PUT; verified parsed.data.ownerType/ownerId can no longer be influenced by the request body, downstream calls still use owner.*, and the surrounding validation/502/503 paths are unchanged
Scope Notes
  • The 3239b9d7..061ff6fc range includes merge commit 9a4a8868 bringing in origin/main; those files are not PR changes and were excluded from review scope.
  • Prior threads: the auto-routing-admin-client.ts .parse() and route.ts:120 graceful-502 findings were verified fixed in 3239b9d7; the services/auto-routing-benchmark/src/profiles.ts:416 quota TOCTOU is an author-accepted residual risk and is untouched by this diff.

Previous review (commit 3239b9d)

Status: No Issues Found | Recommendation: Merge

Executive Summary

This incremental review confirms the prior admin-client/route.ts graceful-502 findings are fixed (JSON parse errors and schema-mismatched 2xx bodies now safely degrade to 502 instead of throwing), and the profiles.ts quota-race finding is unchanged, out of scope for this diff, and recorded as an accepted residual risk by the author.

Files Reviewed (4 files)
  • apps/web/src/lib/ai-gateway/auto-routing-admin-client.ts - fix verified (safeParse + guarded response.json())
  • apps/web/src/lib/ai-gateway/auto-routing-admin-client.test.ts - new regression tests for the fix
  • .kilo_workflow/learnings/auto-routing-benchmark-d1-fixtures.md - documentation only
  • .kilo_workflow/learnings/web-gateway-org-context-and-fake-login.md - documentation only

Previous review (commit 608e3d5)

Status: 3 Issues Found | Recommendation: Address before merge

Executive Summary

The most notable risk is in services/auto-routing-benchmark/src/profiles.ts, where the per-owner benchmark-admission quota check is not atomic with the event insert, letting concurrent requests exceed the documented 10-per-24h cap; two additional findings show the intended graceful-502 fallback for a stale/rolled-back auto-routing worker response is actually unreachable because the admin client throws first.

Overview

Severity Count
CRITICAL 0
WARNING 3
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/ai-gateway/auto-routing-admin-client.ts 136 .parse() on a 2xx worker body throws instead of degrading gracefully
apps/web/src/app/api/auto-routing/settings/route.ts 120 Graceful-502 fallback for malformed worker responses is unreachable
services/auto-routing-benchmark/src/profiles.ts 416 TOCTOU race in per-owner benchmark-admission quota check
Files Reviewed (60 files)
  • .kilo_workflow/learnings/tmux-new-window-index-in-use-name-prefix-collision.md
  • CONTEXT.md
  • apps/web/src/app/api/auto-routing/settings/route.ts - 1 issue
  • apps/web/src/app/api/auto-routing/settings/route.test.ts
  • apps/web/src/components/auto-routing/AutoRoutingModeCard.tsx
  • apps/web/src/components/auto-routing/AutoRoutingModeCard.test.ts
  • apps/web/src/components/organizations/providers-and-models/OrganizationProvidersAndModelsPage.tsx
  • apps/web/src/lib/ai-gateway/auto-model/resolution.ts
  • apps/web/src/lib/ai-gateway/auto-model/resolution.test.ts
  • apps/web/src/lib/ai-gateway/auto-routing-admin-client.ts - 1 issue
  • apps/web/src/lib/ai-gateway/auto-routing-admin-client.test.ts
  • apps/web/src/lib/ai-gateway/auto-routing-pool-validation.ts
  • apps/web/src/lib/ai-gateway/auto-routing-pool-validation.test.ts
  • docs/adr/0002-auto-routing-efficient.md
  • packages/auto-routing-contracts/src/benchmark.ts
  • packages/auto-routing-contracts/src/contracts.test.ts
  • packages/auto-routing-contracts/src/index.ts
  • packages/auto-routing-contracts/src/routing-table.test.ts
  • packages/auto-routing-contracts/src/routing-table.ts
  • services/auto-routing-benchmark/README.md
  • services/auto-routing-benchmark/migrations/0005_fuzzy_senator_kelly.sql
  • services/auto-routing-benchmark/migrations/0006_hard_blizzard.sql
  • services/auto-routing-benchmark/migrations/0007_complex_makkari.sql
  • services/auto-routing-benchmark/migrations/meta/0005_snapshot.json
  • services/auto-routing-benchmark/migrations/meta/0006_snapshot.json
  • services/auto-routing-benchmark/migrations/meta/0007_snapshot.json
  • services/auto-routing-benchmark/migrations/meta/_journal.json
  • services/auto-routing-benchmark/src/admin.ts
  • services/auto-routing-benchmark/src/admin.test.ts
  • services/auto-routing-benchmark/src/auto-decider-sync.ts
  • services/auto-routing-benchmark/src/auto-decider-sync.test.ts
  • services/auto-routing-benchmark/src/cli-runner.ts
  • services/auto-routing-benchmark/src/cli-runner.test.ts
  • services/auto-routing-benchmark/src/custom-routing-table.ts
  • services/auto-routing-benchmark/src/custom-routing-table.test.ts
  • services/auto-routing-benchmark/src/db-replace-summaries.test.ts
  • services/auto-routing-benchmark/src/db-save-routing-table.test.ts
  • services/auto-routing-benchmark/src/db-schema.ts
  • services/auto-routing-benchmark/src/db.test.ts
  • services/auto-routing-benchmark/src/db.ts
  • services/auto-routing-benchmark/src/profile-runs.test.ts
  • services/auto-routing-benchmark/src/profile-transition-sql.test.ts
  • services/auto-routing-benchmark/src/profiles-sql.test.ts
  • services/auto-routing-benchmark/src/profiles.test.ts
  • services/auto-routing-benchmark/src/profiles.ts - 1 issue
  • services/auto-routing-benchmark/src/reasoning-effort.ts
  • services/auto-routing-benchmark/src/routing-table-builder.ts
  • services/auto-routing-benchmark/src/routing-table-builder.test.ts
  • services/auto-routing-benchmark/src/run-process-job.test.ts
  • services/auto-routing-benchmark/src/run.test.ts
  • services/auto-routing-benchmark/src/run.ts
  • services/auto-routing/src/admin-routing-settings.ts
  • services/auto-routing/src/benchmark-origin.ts
  • services/auto-routing/src/decide.ts
  • services/auto-routing/src/decision-cache.ts
  • services/auto-routing/src/decision-cache.test.ts
  • services/auto-routing/src/decision-engine.ts
  • services/auto-routing/src/decision-engine.test.ts
  • services/auto-routing/src/index.ts
  • services/auto-routing/src/index.test.ts
  • services/auto-routing/src/model-capabilities.ts
  • services/auto-routing/src/model-capabilities.test.ts
  • services/auto-routing/src/routing-mode.ts
  • services/auto-routing/src/routing-mode.test.ts

Fix these issues in Kilo Cloud


Reviewed by claude-opus-5 · Input: 22 · Output: 2.6K · Cached: 384.6K

Review guidance: REVIEW.md from base branch main

iscekic added 2 commits July 29, 2026 01:08
Verifier-authored from the owner-pool E2E run: deterministic benchmark
profile D1 fixture facts (engine identity, switch_cost_factor floor,
config prerequisites, provenance binding, uncharged stale re-admission)
and local gateway/auth facts (org-context bearer path, balance top-up
counter, fake-login cookie behavior, org deny-list fixture lever).
fetchAutoRoutingSettingsAdmin parsed success bodies with .parse(), so an
unexpected-shape or non-JSON 2xx (old/rolled-back worker, proxy error
page) threw through the route and surfaced as an unhandled 500 instead of
the intended graceful 502. safeParse plus a guarded .json() now return
the 502 result the route already maps, making the deploy-order safety net
reachable. Addresses two Kilobot review threads on PR #4846.
@iscekic

iscekic commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

(bot) @kilocode-bot please review the latest head 3239b9d — it addresses your two malformed-response findings from the previous head; the third thread was replied to with rationale and resolved.

@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Follow-up review at 3239b9d78 (diff vs 608e3d5)

Scope of the delta: apps/web/src/lib/ai-gateway/auto-routing-admin-client.ts (+21/-2), its test file (+50), and two .kilo_workflow/learnings/*.md notes. Nothing else changed.

Finding 1 — malformed JSON from worker: fixed

fetchAutoRoutingSettingsAdmin now wraps response.json() in try/catch and returns { status: 502, body: { error: 'Invalid worker settings response' } } instead of letting the SyntaxError escape into route.ts. Regression test: "returns 502 for 2xx non-JSON bodies without throwing" (exercised through updateAutoRoutingSettings).

Finding 2 — schema-mismatched 2xx body: fixed

The AutoRoutingSettingsResponseSchema.parse(body) throw site is replaced with safeParse + a 502 degrade, matching the existing 502 contract in workerResultResponse. Regression tests: "returns 502 for 2xx bodies that fail settings schema validation" plus "passes through non-2xx worker error bodies", which guards the 404 status passthrough that GET relies on for the legacy-mode fallback. Coverage looks adequate; CI (test, typecheck, lint, format-check) is green on this head.

Finding 3 — quota race in services/auto-routing-benchmark/src/profiles.ts: unchanged, as expected

git diff 608e3d5..3239b9d78 -- services/auto-routing-benchmark/ is empty, so the accepted-residual-risk decision was not silently altered by the fix. No further comment.

New observations (non-blocking)

  1. Non-JSON non-2xx responses now lose the upstream status. The try/catch sits before the !response.ok branch, so any non-2xx whose body isn't JSON (edge/CF HTML error page, empty body, plain-text 429/503 from an intermediary) is reported as 502 Invalid worker settings response rather than the real status. This is strictly better than the previous throw, but it bypasses three status-specific paths in route.ts: the GET 404 → getAutoRoutingMode legacy fallback, the PUT 404 → 503 pool_temporarily_unavailable mapping, and the 429 quota-body passthrough. The worker's own createNotFoundHandler returns JSON { error: 'Not found' }, so genuine worker 404s are unaffected — only intermediary/edge failures hit this. If you want it tightened: on parse failure, preserve response.status for non-2xx (body: { error: \Request failed: ${response.status}` }`) and reserve 502 for 2xx only. There is also no test for the "non-2xx + non-JSON body" combination, which is exactly this case.
  2. No observability on either degrade path. Both 502 returns are silent, so worker contract drift is indistinguishable from an unparseable/edge body in logs. A console.error/Sentry breadcrumb carrying response.status and the zod issue paths (no body contents, per the logging baseline) would make this diagnosable. The pre-existing 502 branches in route.ts have the same gap, so this is consistent rather than a regression.
  3. The shared helper still has the original bug shape. worker-admin-fetch.ts (createWorkerAdminFetch) still does bare await response.json() and schema.parse(body), so sibling callers in this same module — getAutoRoutingMode (used by the GET legacy fallback), updateAutoRoutingMode, and the classifier endpoints — can still throw on malformed or mismatched worker responses. Pre-existing and out of scope for this diff, but worth a follow-up now that the settings path sets the safer precedent.

No blocking issues; both reported findings are genuinely fixed.

@kilo-code-bot

kilo-code-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review already posted at #4846 (comment) — both findings confirmed fixed, third thread confirmed unchanged/out of scope. No further action needed from my side; the non-blocking observations (404-body edge case, missing logging, worker-admin-fetch.ts follow-up) are informational only and don't block merge.

@iscekic iscekic added the human-ready The PR is ready for human review. label Jul 28, 2026
…-e6e3

# Conflicts:
#	.kilo_workflow/learnings/tmux-new-window-index-in-use-name-prefix-collision.md
…ngs PUT

Spread the request body first so parsed.data.ownerType/ownerId always come
from resolveOwner (auth/query), matching the comment's claim structurally.
Benign today (downstream uses owner.*), but removes the future-trap of
parsed.data looking authoritative for owner identity.

@iscekic iscekic left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review pass complete — all 65 files read in full against the ADR invariants.

Verified end-to-end: exact-pair identity holds at every hop (picker → contracts XOR rules → D1 composite keys with rollback-safe rebuild/backfill → provenance-bound sparse assembly → fail-closed custom decide → variant-aware stickiness → gateway getModelVariants); admission-before-persist ordering with all-or-nothing quota and globally deduplicated charging; platform/profile single-slot sharing with platform priority; the deploy-order matrix (404→legacy synthesis with poolSupported: false, mode-only legacy saves, PUT 404→retryable 503, no legacy PUT fallback).

One finding, fixed directly in 061ff6f: the settings PUT contract parse spread the client body after auth-resolved owner identity, letting the body override ownerType/ownerId in parsed.data (benign today since downstream uses owner.*, but a future-trap contradicting the comment). Now auth identity always wins; 26/26 route tests pass.

Non-blocking nits noted but not actioned: BenchmarkProfileOwnerTypeSchema/AutoRoutingModeOwnerTypeSchema enum sync rests on a comment; a dead unknown_variant fallback branch in validateSingleEntry.

@jeanduplessis jeanduplessis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review finding: profile claim failures can repeatedly launch duplicate benchmark runs.

Comment thread docs/adr/0002-auto-routing-efficient.md Outdated
Comment thread services/auto-routing-benchmark/src/run.ts
iscekic added 2 commits July 31, 2026 13:07
Swallowing markProfilesRunningForRun errors left profiles pending while
work still enqueued, so drain could start duplicate runs after transient
D1 failures. Fail the inserted run, free the slot, and rethrow before
enqueue. Split Efficient model pools into ADR 0003; restore ADR 0002.
@iscekic
iscekic requested a review from jeanduplessis July 31, 2026 11:44
@iscekic
iscekic merged commit 9a95361 into main Jul 31, 2026
19 checks passed
@iscekic
iscekic deleted the efficient-custom-pool-e6e3 branch July 31, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants