Skip to content

Introduce a typed RoutePlan seam for Gateway routing and mutation policy #61

Closed

Description

@NOirBRight

Problem

Gateway behavior is represented partly by RouteDecision, but request execution still recomputes policy from overlapping booleans and string comparisons such as transparent metering, Codex App external adaptation, official passthrough, same-format transparency, lightweight fallback, semantic repair, vision, usage, retry, and transport choices.

This makes it difficult to prove what a route exposes or mutates, and risky to add #58 without another cross-product of conditions.

#5 owns upstream opening/error mapping. #25 owns protocol conversion. This issue owns the higher-level route-plan interface and must compose those seams.

Scope

Introduce one typed, immutable RoutePlan produced at a pure/testable seam before request mutation or network I/O.

The plan should explicitly contain or reference:

  • upstream/provider/model and alias mapping;
  • authentication strategy;
  • inbound/upstream wire formats and conversion mode;
  • semantic adapter mode;
  • request and response/SSE mutation policies;
  • retry policy and request kind;
  • usage/telemetry mode;
  • Vision Proxy policy;
  • Codex compatibility policy;
  • tool exposure policy and evidence state;
  • upstream transport policy including official keepalive.

Tool exposure must be represented without assuming unresolved #57 results. The type should be able to distinguish at least:

  • current compatibility behavior;
  • native deferred search candidate;
  • native no-search candidate with an explicit proven tool subset;
  • unsupported/unknown.

In this behavior-preserving issue, all existing third-party Codex App routes continue to resolve to current compatibility behavior. Candidate/unknown states must not enable passthrough or remove repair logic until #57/#58 authorize them.

The executor should consume the plan instead of re-deriving policy. Add a mutation summary suitable for tests/telemetry, such as model alias, namespace flattening, wire conversion, semantic repair, hard-coded schema injection, official tool-search preservation, or synthetic terminal failure. Do not record secrets or request content.

Spike boundary

This architecture extraction does not answer whether native search/no-search routes work. If implementation exposes an unresolved Codex behavior not already covered by #57, record it on #57 or create a narrower spike; do not choose production behavior inside this refactor.

Acceptance criteria

Required verification

python -m pytest tests/test_routing.py tests/test_chat_completions_gateway.py tests/test_proxy_event_logging.py
python -m pytest
python scripts/report_quality_gates.py

Related

Activity

  1. NOirBRight commented on Jul 11, 2026

    @NOirBRight
    OwnerAuthor

    Planning update (2026-07-11): this behavior-preserving RoutePlan seam is on the Issue #57 decision gate milestone and can proceed in parallel with #62 during Jul 13–17. Candidate/unknown capability states must continue to resolve to existing compatibility behavior; this issue does not wait for the final #57 route decision.

  2. 12 remaining items

  3. NOirBRight commented on Jul 30, 2026

    @NOirBRight
    OwnerAuthor

    Third independent-review repair is frozen and pushed to PR #262 at 76b02adf43efcdee8dcccd502338c63d96c0f77d (76b02ad).

    What changed:

    • RouteAttemptPlan now owns endpoint URL plus typed auth/stream/usage/transport/mutation choices and a frozen retry execution contract (eligibility, timeout, attempt counts, failure expansion, elapsed/open/pre-response budgets, retry notices, and lifecycle eligibility).
    • The executor consumes those attempt fields; the focused contract tests patch URL/retry/tool-policy derivation helpers to fail if execution re-derives them.
    • Chat inbound auto routes now record and execute the real body chain: Chat→Responses first, then Chat→Responses→Chat after an eligible 404 fallback. Planned-union telemetry is explicitly separate from selected/executed-attempt telemetry.
    • Compact caller-tool removal is an explicit caller_tool_stripping mutation.
    • Capability-manifest state fails closed for missing, partial, or malformed version/hash identities; only a complete valid pair plus explicit Supported state reports supported.
    • Handler-level Vision tests cover proxy success, proxy failure, reject, native image support, and no-image requests, including upstream I/O, telemetry, and mutation assertions.

    Verification:

    • affected pytest: 701 passed, 226 subtests in 44.98s
    • Python core candidate: 1,477 passed, 1 skipped, 451 subtests in 100.23s with Python 3.13 first on PATH
    • py_compile: passed
    • git diff --check: passed
    • report-only quality: 2 unused imports / 83 dead functions / 146 duplicate names / 0 parse errors
    • commit stat: 3 files, 1,922 insertions, 211 deletions

    The earlier core attempt whose nested replay process resolved Python 3.11 produced only two issue-108 syntax-parser failures; the authoritative Python 3.13 rerun is green and both results are recorded in docs/evidence/issue-61/README.md. GitHub Actions is now running on the frozen SHA; this update does not merge or close the issue.

  4. NOirBRight commented on Jul 30, 2026

    @NOirBRight
    OwnerAuthor

    Fourth independent-review repair is pushed at exact SHA 013e1daa72e7b7a53878dbef9ff64267044daed4 (013e1daa).

    Actionable findings repaired:

    • attempt-owned, deeply immutable/redacted outbound header snapshots freeze provider, incoming, Ollama, and Codex auth plus generated request identities before execution; current requests cannot drift after planning and later requests refresh;
    • capability manifests accept only the supported provider-capabilities.v3 schema with a valid version/hash pair; future/unknown versions fail closed;
    • safe body observations are computed for each real protocol/lifecycle attempt, so fallback evidence describes the failed body and final evidence describes the final executed body;
    • success, streaming, final HTTPError, and official-control response paths require a typed RelayExecutionPlan; the relay profile/optional-policy re-derivation entry was removed;
    • planned/selected/fallback/final telemetry aliases derive from one canonical attempt snapshot without changing the event schema.

    Verification:

    • focused Gateway + shutdown delta: 705 passed, 227 subtests
    • authoritative Python 3.13.11 core: 1,481 passed, 1 skipped, 452 subtests
    • py_compile: passed
    • git diff --check: passed
    • report-only quality: 2 unused imports / 83 dead functions / 146 duplicate names / 0 parse errors

    Exact red/green and environment notes are recorded in docs/evidence/issue-61/README.md. This update does not merge or close #61; exact-SHA CI and renewed independent Standards/Spec review remain required.

  5. NOirBRight commented on Jul 30, 2026

    @NOirBRight
    OwnerAuthor

    Phase 1 ownership clarification: protocol-switch restart contract

    No end-to-end requirement is removed. The overlapping protocol-switch sentence is split at the existing issue boundary:

    A process restart is the clearing boundary because the new Codex process reloads the regenerated binding; Gateway restart or another save is not a truthful substitute. Beta1 requires both #61 and #250, and merging #61 alone does not claim the #250 end-to-end disclosure is complete.

  6. NOirBRight commented on Aug 1, 2026

    @NOirBRight
    OwnerAuthor

    Resolved by merged PR #262 (3c73a7a). Exact head passed two-axis review and Hosted CI / gate.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Priority 1: current iteration goalenhancementNew feature or requestready-for-agentFully specified, ready for an AFK agentwayfinder:taskWayfinder implementation task

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions