Trace the BIFROST base contract across these three repositories. Explain who owns the file, how omniclaude finds it, what infra requires at startup, and what happens if package or bootstrap path is absent. Name functions and files; separate package authority from overlay and startup bootstrap. No runtime probing.
PUBLIC SOURCE omniclaude/src/omniclaude/delegation/runner.py:140-180
140:     error_message: str = Field(default="", description="Structured error on failure")
141: 
142: 
143: def canonical_bifrost_contract_path() -> Path:
144:     """Return the path of the canonical contract inside the installed omnimarket.
145: 
146:     omniclaude owns no routing table (OMN-17102). The one routing authority is
147:     ``omnimarket/configs/bifrost_delegation.yaml``, shipped in the omnimarket
148:     package this repo pins; every omniclaude loader resolves it through here. A
149:     forked copy once drifted to config_version 1.1.0 while the canonical contract
150:     moved on, and kept naming backends the canonical contract had deleted.
151: 
152:     Raises:
153:         RuntimeError: omnimarket is not installed, or the installed release does
154:             not ship the contract. There is no vendored fallback: a stale copy
155:             is the defect this function exists to prevent.
156:     """
157:     spec = importlib.util.find_spec("omnimarket")
158:     locations = list(spec.submodule_search_locations or []) if spec else []
159:     if not locations:
160:         raise RuntimeError(
161:             "omnimarket is not installed, so the canonical bifrost delegation "
162:             "contract cannot be resolved. Install the omnimarket release pinned "
163:             "in pyproject.toml; omniclaude ships no copy of the contract."
164:         )
165:     path = Path(locations[0]) / "configs" / "bifrost_delegation.yaml"
166:     if not path.is_file():
167:         raise RuntimeError(
168:             f"Installed omnimarket does not ship the canonical bifrost delegation "
169:             f"contract at {path}. Advance the omnimarket pin to a release that does."
170:         )
171:     return path
172: 
173: 
174: _DEFAULT_BIFROST_CONTRACT_PATH = canonical_bifrost_contract_path()
175: _DEFAULT_BIFROST_OVERLAY_PATH = (
176:     Path.home() / ".omninode" / "delegation" / "bifrost_overrides.yaml"
177: )
178: 
179: 
180: def _backend_has_credential(backend: ModelDelegationBackendConfig) -> bool:

PUBLIC SOURCE omnimarket/src/omnimarket/configs/bifrost_delegation.yaml:1-110
1: # SPDX-FileCopyrightText: 2025 OmniNode.ai Inc.
2: # SPDX-License-Identifier: MIT
3: #
4: # bifrost_delegation.yaml — Delegation routing rules for Claude Code task classes.
5: #
6: # Maps task-class contracts to bifrost backend routing policies.
7: # Every gateway response MUST include the selected rule_id and config_version
8: # to make provenance auditable (OMN-10637 requirement R1).
9: #
10: # OMN-12815 / OMN-13159: every endpoint_url is the COMPLETE final URL incl. the
11: # full chat path (e.g. .../v1/chat/completions). It is posted VERBATIM at every
12: # call site — no in-code construction, append, rstrip, or path-resolver exists
13: # anymore. Public cloud endpoints carry the complete URL here; site-specific
14: # LOCAL endpoints are null in the repo default and the env var named by
15: # `endpoint_url_env` (formerly `base_url_env`) MUST hold the COMPLETE URL (incl.
16: # /v1/chat/completions) — supplied by the overlay file the installer writes,
17: # usually ~/.omninode/delegation/bifrost_overrides.yaml. A bare base (no chat
18: # path) is a misconfiguration — resolution fails closed rather than
19: # constructing a path.
20: #
21: # See routing_tiers.yaml for tier escalation ladder.
22: # OMN-17427 / RULING 2026-10-01T15:49:37Z: Gemini is declared for explicitly
23: # pinned tests only. Ordinary routes use local and existing non-Gemini cloud rungs.
24: #
25: # Tickets: OMN-10637, OMN-10638, OMN-10657, OMN-12815, OMN-13170, OMN-13343, OMN-13351, OMN-15155, OMN-16442, OMN-17099
26: config_version: "2.8.0"
27: schema_version: "bifrost_delegation.v1"
28: # Backend definitions — endpoint_url values are merged from the overlay at load time.
29: # model_name is null here; resolved at deploy time via bifrost_overrides.yaml overlay.
30: # backend_ids are capability-named (not model-named) so the public config never
31: # embeds site-specific model identifiers.
32: backends:
33:   # Local backends (vLLM on example-endpoint) — capability-named, model_name resolved via overlay
34:   - backend_id: local-coder
35:     provider: local
36:     # OMN-18278: measured 2026-10-01 on the lab vLLM endpoint serving
37:     # Qwen3.8-27B with no reasoning parser: reasoning arrives inline in
38:     # message.content. A llama.cpp endpoint with a reasoning parser returns
39:     # it in reasoning_content instead; its lane overlay sets this to null.
40:     inline_reasoning_terminator: "</think>"
41:     endpoint_url_env: BIFROST_LOCAL_CODER_ENDPOINT_URL
42:     endpoint_url: null
43:     # The lane overlay declares the local served model id; omnibase_infra renders it.
44:     # probe_served_models in node_llm_delegation_call_effect checks the endpoint.
45:     model_name: null
46:     tier: local
47:     # OMN-13170: timeout_ms is sized to the 65536-token output budget below — a
48:     # 64k-token code-generation artifact at local vLLM throughput exceeds 60s and
49:     # was failing with error="request timed out" / output_tokens=0 once OMN-13170
50:     # deleted the hardcoded 120s transport cap. 300000 ms (5 min) gives the model
51:     # room to finish a full module + tests. Overlay-overridable per deploy lane.
52:     timeout_ms: 300000
53:     # OMN-13161: per-backend output-token ceiling. The served model (Qwen3.6-35B-A3B,
54:     # OMN-16419) reports max_model_len=131072; a 64k output budget stays well
55:     # within range for code-generation artifacts.
56:     max_tokens: 65536
57:     # OMN-18297 -- grounding budget, NOT the context window. Live readback of
58:     # this endpoint's /v1/models on 2026-09-13 reports max_model_len 131072, and
59:     # an 18245-token prompt was accepted without complaint; the answer then cited
60:     # eight pull requests occurring nowhere in it, and the quality gate scored it
61:     # 1.0. Measured grounding on this backend the same session: clean at 577, 898,
62:     # 1030 and 2381 input tokens (zero ungrounded identifiers across four tasks),
63:     # ungrounded at 18245. The honest measured bracket is therefore (2381, 18245];
64:     # 8000 is a declared bound INSIDE that bracket, chosen to sit above every
65:     # observed success and well under the only observed failure. It is NOT itself
66:     # a measured degradation point, and narrowing it needs a bisection run that
67:     # has not been done. The identifier-grounding check is what actually catches a
68:     # fabricated citation; this budget is the coarse pre-emptive bound that keeps
69:     # an oversized prompt off a rung that cannot hold it.
70:     max_grounded_input_tokens: 8000
71:     capabilities:
72:       - code_generation
73:       - refactoring
74:       - documentation
75:     # OMN-17427 -- LIVE-PROBED 2026-10-03 on the same endpoint
76:     # local-heavy-reasoning reads (BIFROST_LOCAL_CODER_ENDPOINT_URL,
77:     # Qwen3.8-27B). Without the directive the code-edit loop's turns were
78:     # refused no_schema_conforming_json on 234 of 747 local-coder attempts
79:     # in 24 h (prose or empty content instead of the JSON object); with the
80:     # json_schema directive 20 of 20 replayed failing turns extracted.
81:     # Re-probe after an endpoint redeploy.
82:     supports_response_format_json_schema: true
83:   # OMN-16442: the `local-reasoner` backend (model_name
84:   # Qwen3.6-27B-MTP-IQ4_XS.gguf, endpoint_url_env
85:   # BIFROST_LOCAL_REASONER_ENDPOINT_URL → example-endpoint:8001) was DELETED. OMN-16419
86:   # left it wired ONLY because routing_rules.research still referenced it and
87:   # a routing-table change was out of that ticket's bounded scope; this ticket
88:   # IS that routing-table change, so the reference is removed below and the
89:   # definition goes with it. The endpoint is the RTX 4090 slot physically
90:   # removed from example-endpoint for RMA (OMN-16407) — re-probed 2026-08-28, `curl
91:   # example-endpoint:8001/v1/models` returns exit 7 "Couldn't connect to
92:   # server", and the canonical inventory
93:   # (public-hardware-reference, verified 2026-08-28) marks
94:   # the slot DEAD / RETIRED. Restore a reasoner rung by REGISTERING the
95:   # replacement hardware, never by reviving this backend_id against a slot
96:   # that no longer exists.
97:   - backend_id: local-heavy-reasoning
98:     provider: local
99:     # OMN-18278: measured 2026-10-01 on the lab vLLM endpoint serving
100:     # Qwen3.8-27B with no reasoning parser: reasoning arrives inline in
101:     # message.content. A llama.cpp endpoint with a reasoning parser returns
102:     # it in reasoning_content instead; its lane overlay sets this to null.
103:     inline_reasoning_terminator: "</think>"
104:     endpoint_url_env: BIFROST_LOCAL_CODER_ENDPOINT_URL
105:     endpoint_url: null
106:     # The lane overlay declares the local served model id; omnibase_infra renders it.
107:     # probe_served_models in node_llm_delegation_call_effect checks the endpoint.
108:     model_name: null
109:     tier: local
110:     # OMN-13170: same 65536-token budget as local-coder → same 300000 ms ceiling so

PUBLIC SOURCE omnibase_infra/src/omnibase_infra/runtime/render_bifrost_delegation_contract.py:65-125
65:     ModelBifrostLaneOverlay,
66: )
67: from omnibase_spi.protocols.services import ProtocolSecretStore
68: 
69: _DEFAULT_TARGET_PATH = Path("/app/data/delegation/bifrost_delegation.yaml")
70: _BASE_CONTRACT_PATH_ENV = "BIFROST_BASE_CONTRACT_PATH"
71: _LANE_OVERLAY_PATH_ENV = "BIFROST_LANE_OVERLAY_PATH"
72: _LANE_ENV = "ONEX_ENVIRONMENT"
73: #: OMN-19214: a lane's overlay row in the config store is the same
74: #: ``bifrost_lane_overlay.v3`` document the mounted file holds, keyed per lane.
75: LANE_OVERLAY_STORE_KEY_PREFIX = "delegation.bifrost.lane_overlay."
76: _CHAT_COMPLETIONS_PATH_SUFFIX = "/chat/completions"
77: #: OMN-17099: the embedding backend's real endpoint is OpenAI-embeddings-shaped,
78: #: not chat-completions-shaped (live probe 2026-09-27: example-endpoint:8002/v1/chat/completions
79: #: 404s; example-endpoint:8002/v1/embeddings returns real vectors). ``ModelBifrostLaneBackendBinding``
80: #: accepts the same two suffixes; this module's own completeness gate must agree.
81: _EMBEDDINGS_PATH_SUFFIX = "/embeddings"
82: _COMPLETE_ENDPOINT_SUFFIXES = (_CHAT_COMPLETIONS_PATH_SUFFIX, _EMBEDDINGS_PATH_SUFFIX)
83: _DEFAULT_ENDPOINT_PROBE_TIMEOUT_SECONDS = 3.0
84: #: OMN-19432: the base contract's own declaration that a backend answers TYPED
85: #: DECISIONS on its provider's own schema (TypeSafe Jev's System One API)
86: #: rather than OpenAI chat completions. Such a backend is never a rung: no
87: #: routing rule or tier ladder names it, so it is not an "active endpoint" for
88: #: delegation, and its complete URL names its own operation instead of ending
89: #: in the chat path.
90: _TYPED_DECISION_TIER = "typed_decision"
91: #: A last path segment that is only an API version (``v1``, ``v1beta``) marks a
92: #: bare base, which OMN-12815 forbids: nothing downstream appends a path.
93: _BARE_VERSION_SEGMENT = re.compile(r"^v\d+(?:(?:alpha|beta)\d*)?$")
94: 
95: EndpointProbe = Callable[[str, str, float], ModelBifrostEndpointProbeFailure | None]
96: 
97: 
98: def _resolve_canonical_source_path(env: Mapping[str, str]) -> Path:
99:     """Resolve the deploy-provided base contract at BIFROST_BASE_CONTRACT_PATH."""
100:     configured = env.get(_BASE_CONTRACT_PATH_ENV, "").strip()
101:     if not configured:
102:         raise ProtocolConfigurationError(
103:             f"{_BASE_CONTRACT_PATH_ENV} is unset or blank; there is no default: "
104:             "the deploy (the omnimarket composed image or the lane's compose) "
105:             "provides the base contract. Fail fast."
106:         )
107:     candidate = Path(configured)
108:     if not candidate.is_file():
109:         raise ProtocolConfigurationError(
110:             f"{_BASE_CONTRACT_PATH_ENV} is not an existing file: {candidate}"
111:         )
112:     return candidate
113: 
114: 
115: def _load_mapping(path: Path, *, label: str) -> dict[str, object]:
116:     try:
117:         raw = yaml.safe_load(path.read_text(encoding="utf-8"))
118:     except FileNotFoundError as exc:
119:         raise ProtocolConfigurationError(f"{label} not found: {path}") from exc
120:     except yaml.YAMLError as exc:
121:         raise ProtocolConfigurationError(
122:             f"{label} is malformed: {path}: {exc}"
123:         ) from exc
124:     if not isinstance(raw, dict):
125:         raise ProtocolConfigurationError(f"{label} must have a mapping root: {path}")
