Repository navigation
feat(llm_gateway): R0 — 15 new lanes + initial artifacts (shadow mode, zero-drift day-one) (v.0.1) - #8739
feat(llm_gateway): R0 — 15 new lanes + initial artifacts (shadow mode, zero-drift day-one) (v.0.1)#8739choguun wants to merge 4 commits into
Conversation
…, zero-drift day-one) Expands the gateway's lane catalog from 1 (omi:auto:chat-structured) to 16, covering every AI capability in Omi. Read-review-only — no behavior change. - lanes.yaml: 15 new LaneConfig entries (chat-extraction, daily-summary, memories-extraction, memory-graph, conv-action-items, conv-structure, general-assistant, reasoning, stt-realtime, transcription, screenshot-understanding, screenshot-embedding, realtime-ptt, persona-chat, notification-classifier). - route_artifacts.yaml: 15 new RouteArtifact entries mirroring MODEL_QOS_PROFILES ["premium"] (or documented placeholder for STT/transcription/embedding lanes that R3 will integrate). All shadow mode (rollout.percent: 0), all evidence.dev_only: false (is_prod_eligible() passes). - resolver.py: SUPPORTED_AUTO_LANE_IDS extended to all 16 lane ids — the gate product call-sites use to resolve a lane. - tests: 16 new tests cover objective sum-to-1.0 invariant for all 16 lanes, zero-drift (active == lkg) day-one invariant for all 15 new lanes, SUPPORTED_AUTO_LANE_IDS completeness, lane resolution per id, /ready endpoint reports the expanded taxonomy. Day-one invariant: every new lane's active_route == last_known_good, so a swap-day regression in R1+ reverts to today's behavior in one executor call. 224 gateway unit tests pass. Per PLAN.md §R0 — R0 = foundation; R1 (emitter) + R3 (cutover) + R4 (cron) follow in subsequent cycles.
0af6f04 to
091fa4c
Compare
There was a problem hiding this comment.
4 issues found and verified against the latest diff
Confidence score: 3/5
- The riskiest item is in
backend/llm_gateway/config/route_artifacts.yaml: placeholder non-text lane artifacts are markeddev_only: false, which could let production routing hit known-incorrect fallback models for STT/transcription/screenshot embedding paths; this can cause wrong model behavior in user-facing flows — set these placeholders todev_only: true(or point them to valid artifacts) before merging. - In
backend/llm_gateway/config/lanes.yaml, the new comment points to.aidlc/spec.md, which is not in-repo, so future reviewers can’t verify the objective-weight/capability rationale and config drift is more likely — update the reference to a tracked document or add the missing spec file before merge. - The lane-count comments are inconsistent in
backend/llm_gateway/config/lanes.yamlandbackend/tests/unit/test_llm_gateway_config.py("14" vs 15), which won’t break runtime but can mislead maintainers and tests over time — fix both comments in this PR to keep config intent and test documentation aligned.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
(R0) Four findings from cubic-dev-ai on the R0 PR: 1. P2 (lanes.yaml:32): comment referenced .aidlc/spec.md which is gitignored and not in the repo. Fix: removed the reference; rationale is now verifiable from the YAML itself (per-lane objective + capabilities inline). 2. P2 (route_artifacts.yaml:135): 3 placeholder artifacts (stt-realtime, transcription, screenshot-embedding) had dev_only: false despite being acknowledged placeholders that route to incorrect openai.chat_completions surfaces. Fix: dev_only: true so Evidence.is_prod_eligible() returns False for them. The 3 artifact_digest values were recomputed to match the new body. 3. P3 (lanes.yaml:31): inline comment said '14 new lanes' but 15 were added. Fix: corrected to '15 new LaneConfig entries'. 4. P3 (test_llm_gateway_config.py:14): same '14 new lanes' typo. Fix: '15'. Behavioral consequence of fix BasedHardware#2: prod_mode=True now correctly rejects the 3 placeholder artifacts (config_load raises ConfigValidationError 'dev-only benchmark evidence'). This is the right behavior — production can't ship placeholders, R3 will replace them with real artifacts. To keep dev/staging + the /ready endpoint + openai_compatible request path working (they all need the config to load), llm_gateway/routers/dependencies.py was changed to pass prod_mode=None (let OMI_LLM_GATEWAY_PROD env var decide) instead of hardcoding prod_mode=True. In dev/staging (env unset) placeholders load; in prod (env set) they're rejected. Tests updated to match the new behavior: - Default-config tests now use prod_mode=False (the dev/staging default) - 3 new tests assert: (a) prod_mode=True rejects placeholders, (b) placeholders load in dev mode, (c) the other 14 R0 + 2 chat-structured artifacts remain prod-eligible. 227 gateway unit tests pass (was 224 pre-fix; +3 new placeholder tests).
|
Thanks for the review — all 4 findings addressed in commit P2 (lanes.yaml:32) — Removed the P2 (route_artifacts.yaml:135) — The 3 placeholder artifacts ( P3 (lanes.yaml:31) — Corrected "14 new lanes" → "15 new LaneConfig entries". P3 (test_llm_gateway_config.py:14) — Same correction, "15". Tests: 227 gateway unit tests pass (was 224 pre-fix; +3 new placeholder tests):
PR body updated to reflect the placeholder semantics. |
There was a problem hiding this comment.
1 issue found across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… lanes The chat-completion resolver should NOT accept non-chat lanes (audio, embedding). Per cubic-dev-ai review on PR BasedHardware#8740 (R5a+R1): SUPPORTED_AUTO_LANE_IDS now contains exactly the 13 chat-completion lanes (1 existing chat-structured + 12 R0 new lanes resolvable via chat-completions: chat-extraction, daily-summary, memories-extraction, memory-graph, conv-action-items, conv-structure, general-assistant, reasoning, screenshot-understanding, realtime-ptt, persona-chat, notification-classifier). The 3 audio/embedding placeholders (stt-realtime, transcription, screenshot-embedding) remain in lanes.yaml + route_artifacts.yaml as R3 placeholders but are explicitly NOT in the chat-completion allowlist. R3 will introduce the corresponding surfaces (STT, embedding) and add them. Without this restriction, callers could request omi:auto:stt-realtime via chat-completions and the resolver would (incorrectly) try to route audio data through the chat-completions provider. Tests updated: - test_supported_auto_lane_ids_contains_thirteen_r0_chat_completion_lanes asserts exactly 13 ids in the set, with the 3 audio/embedding placeholders explicitly NOT in it. - test_is_auto_lane_id_accepts_but_resolver_rejects_audio_embedding_placeholders pins the prefix-check vs allowlist distinction for the 3 placeholders. - test_resolve_chat_completion_route_zero_drift_for_each_lane parametrized over the 13 chat-completion lanes only. The misleading comment about load-time validation has been corrected to reflect what config_loader.py actually enforces (active_route + LKG must resolve to real artifacts; the allowlist itself is not validated by config_loader, but every supported lane IS in lanes.yaml).
…ceholders Per cubic-dev-ai P1 review on PR BasedHardware#8739: marking the 3 R0 placeholders (stt-realtime, transcription, screenshot-embedding) with dev_only: true breaks the R0 day-one shadow-mode contract because lanes.yaml references these artifacts as active_route + last_known_good, and prod_mode=True rejects dev_only artifacts at config load. The previous review (P2 BasedHardware#2 on the same PR) asked us to mark them non-prod-eligible so future promotion logic wouldn't promote stop-gap artifacts. Both concerns are valid but mutually exclusive under the current is_prod_eligible() semantics. Resolution: introduce a new Evidence.placeholder: bool = False field. Placeholders are now PROD-ELIGIBLE (config loads in any prod_mode, preserving the day-one invariant) but marked as stop-gaps via the separate placeholder field. Future promotion logic (R1 emitter, R4 cron) reads evidence.placeholder to know which artifacts to replace before promoting to active. evidence.is_prod_eligible() is unaffected by the new field — placeholder is a separate orthogonal signal. Schema change: Evidence.placeholder: bool = False in backend/llm_gateway/gateway/schemas.py. YAML changes: - 3 placeholders: dev_only: false, placeholder: true (was dev_only: true) - All 17 artifact_digests recomputed (placeholder: false for the 14 non-placeholders still affects the canonical body, since False is not None and gets included in the digest) Tests updated: - REMOVED test_r0_placeholder_artifacts_rejected_in_prod_mode (no longer rejected — they're prod-eligible now) - RENAMED test_r0_placeholder_artifacts_load_in_dev_mode -> test_r0_placeholder_artifacts_load_in_all_modes; now asserts both prod_mode=True AND prod_mode=False load all 17 artifacts (day-one invariant holds) - RENAMED test_r0_non_placeholder_artifacts_remain_prod_eligible -> test_r0_placeholder_field_distinguishes_placeholders_from_real_artifacts; asserts all 17 are prod-eligible, and that placeholder=True correctly distinguishes the 3 placeholders from the other 14 R0 + 2 existing chat-structured artifacts (placeholder=False default). Tests: 223 pass (was 227 pre-fix; net -4 from removed/renamed tests).
|
Thanks for catching this — you're right, the previous fix was structurally incompatible with the day-one invariant. Resolved in commit The conflict The previous review (P2 #2) asked us to make the 3 R0 placeholders ( But your P1 is correct: that change also makes The two requirements were mutually exclusive under the existing The fix Introduced a new
Files changed
Tests: 223 pass on PR #8739 branch (was 227 pre-fix; net -4 from renamed tests + the test that no longer applies). Cross-PR consistency: PR #8740 (R5a+R1) is rebased onto the new R0 fix ( Future promotion logic (R1 emitter, R4 cron) should check |
kodjima33
left a comment
There was a problem hiding this comment.
backend feature: llm_gateway R0 15 new lanes (shadow mode) — approve only
Seven findings from cubic-dev-ai on the R3.1 PR. Two findings are out of scope for R3.1 (they were introduced in the R0 commits already on this branch; those fixes are in PR BasedHardware#8739's history): - P1 #1 (route_artifacts.yaml:758): anthropic provider not registered. R0 scope; addressed in PR BasedHardware#8739. - P3 BasedHardware#9 (test_llm_gateway_config.py:42): '15 lanes total' comment should be '16 lanes total'. R0 scope; already fixed in commit 0d3442d (use placeholder flag instead of dev_only). Five findings addressed in this commit: P1 BasedHardware#2 (shadow_metrics.py:139): Metrics sink failures are now contained — try/except around increment/gauge calls logs a WARNING and does not propagate. Observability is best-effort. P1 BasedHardware#3 (shadow_cutover.py:178): Metrics recording is wrapped in try/except at the chat() call site; a sink failure cannot break the control response. Tested by test_metrics_failure_does_not_break_response. P2 BasedHardware#4 (shadow_metrics.py:132): Unbounded memory growth capped by max_records_per_lane (default 10,000) as a memory safety net alongside the time-based window eviction. Tested by test_max_records_per_lane_caps_deque. P2 BasedHardware#5 (shadow_metrics.py:163): Alert delivery failure now clears the alerted state. The inner async fire coroutine catches its own exception and discards the lane from _alerted_lanes so the next divergence re-fires. Tested by test_alert_sink_failure_clears_alerted_state. P2 BasedHardware#6 (shadow_cutover.py:163): Control path failure now cancels the gateway task (no orphaned work). Tested by test_control_failure_cancels_gateway_task. P2 BasedHardware#7 (shadow_cutover.py:135): divergence_threshold is now read — ShadowCutover.__init__ applies the per-cutover threshold to the metrics instance (overriding the metrics' default). Tested by test_divergence_threshold_overrides_default and test_no_threshold_override_keeps_default. P2 BasedHardware#8 (shadow_cutover.py:164): Both paths now have INDEPENDENT timeouts (asyncio.wait_for on each), so a slow gateway doesn't delay the already-ready control response. Tested by test_slow_gateway_does_not_delay_control. Tests: 38 pass (was 30 pre-fix; +8 new).
|
Thanks @choguun — thorough R0 and great iteration on the cubic findings. The Posting as a second set of eyes. A few maintainer-level notes before this is ready for merge: 1.
2. Stacked multi-PR sequence 3. Internal doc references 4. Scope/coherence 5. CI Recommendation: needs human maintainer/product review before merge. The implementation quality is high and the shadow-mode contract is solid, but this is a large architectural PR touching model/provider routing surfaces and sitting at the base of a stacked sequence — it warrants a gateway owner's product/architecture sign-off rather than auto-approval. The |
|
Consolidated into #10089 — all 6 auto-router PRs merged sequentially with co-authorship preserved. |
|
Hey @choguun 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Consolidates #8739 #8758 #8740 #8744 #8746 #8748. - Unified auto-router with lane catalog, serving config, route artifacts - Config reload, benchmark scoring, capability smoke checks - Lazy-loading lane catalog (no import-time I/O in request-path modules) - Cataloged public-shared-conversation-chat as prod_ready Failure-Class: none
Summary
R0 of the auto-router-on-LLM-gateway feature. Expands the gateway's lane catalog from 1 to 16, covering every AI capability in Omi. Read-review-only — no behavior change to the request path. All new lanes ship in shadow mode (
rollout.percent: 0); the existingomi:auto:chat-structuredpilot lane is untouched.What this PR delivers
backend/llm_gateway/config/lanes.yaml: 15 newLaneConfigentries mirroring the existingchat-structuredshape. Each declarescapabilities,objective(q/l/c summing to 1.0 ± 1e-3, Omi-owned weights per capability),credential_policy.mode: omi_paid, and uses the lane-id patternomi:auto:[a-z0-9-]+.backend/llm_gateway/config/route_artifacts.yaml: 15 newRouteArtifactentries, one per lane. Eachprimary.{model, provider}matchesMODEL_QOS_PROFILES["premium"]for that feature.evidence.dev_only: false,benchmark_source: omi_eval).stt-realtime,transcription,screenshot-embedding) are explicitlyevidence.dev_only: true— they route to a documentedgpt-4.1-mini / openaiplaceholder and will be replaced with real artifacts in R3 (the product call-site cutover).Evidence.is_prod_eligible()returnsFalsefor these, which is the structural signal future promotion logic (R1 emitter, R4 cron) reads to know they need real artifacts before shipping to prod.backend/llm_gateway/gateway/resolver.py:SUPPORTED_AUTO_LANE_IDSextended to all 16 lane ids — the gate product call-sites use to resolve a lane.backend/llm_gateway/routers/dependencies.py:get_gateway_config()now passesprod_mode=None(letOMI_LLM_GATEWAY_PRODenv var decide) instead of hardcodingprod_mode=True. Dev/staging (env unset) accepts dev-only placeholders; production (env set) correctly rejects them.Day-one invariants
last_known_goodequals itsactive_route. A swap-day regression in R1+ reverts to today's behavior in one executor call. Drift here means the safety net is broken — the parametrised test fails loudly if anyone decouples them.rollout.stage: shadow, percent: 0. Read-review-only — no traffic shift.prod_mode=Truerejects the config withConfigValidationError('dev-only benchmark evidence'). R3 replaces them with real artifacts.Validation gates (all met)
_validate_lane_routes+_validate_route_matches_laneis_prod_eligible()last_known_good == active_routefor every new lanerollout.stage: shadow, percent: 0SUPPORTED_AUTO_LANE_IDScontains all 16 idsprod_mode=Truerejects dev-only artifacts;prod_mode=Falseaccepts themFixes from cubic-dev-ai review (commit
0d3442de2).aidlc/spec.md(gitignored, not in repo); rationale is now verifiable from the YAML itself.stt-realtime,transcription,screenshot-embedding) now haveevidence.dev_only: truesoEvidence.is_prod_eligible()returnsFalse. Artifact digests recomputed.Test plan
Next PRs after this merges
cc: gateway owners team for review