Skip to content

feat(filters): add grid_route#339

Open
nerdalert wants to merge 2 commits into
praxis-proxy:mainfrom
nerdalert:grid-route
Open

feat(filters): add grid_route#339
nerdalert wants to merge 2 commits into
praxis-proxy:mainfrom
nerdalert:grid-route

Conversation

@nerdalert

@nerdalert nerdalert commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Adds grid_route to praxis-ai-filters and registers it from praxis-ai-proxy.

Architecturally, this is the AI/Grid-owned routing filter that consumes a static site/capability descriptor and selects the upstream cluster for the request. The Grid operator can render candidate overlays from provider state, and the AI proxy can consume those candidates without requiring Praxis core to understand models, tools, sites, freshness, or Grid-specific routing policy.

This keeps the split intentional:

  • Praxis core provides generic proxy mechanics: filter runtime, request context, pipeline validation, and load_balancer.
  • The AI repo owns AI/Grid semantics: model routing, MCP tool routing, freshness preference, locality preference, and Grid candidate shape.

In a gateway pipeline, grid_route sits after request classification and before load_balancer:

filters:
  - filter: json_body_field
    field: model
    header: X-Model

  - filter: grid_route
    local_site: site-a
    candidates:
      - kind: inference_model
        name: granite-3.3-8b
        site: site-a
        cluster: granite-local
        fresh: true

  - filter: load_balancer
    clusters:
      - name: granite-local
        endpoints:
          - "127.0.0.1:8001"

grid_route is the cluster-selecting filter for this path. It writes ctx.cluster, and load_balancer forwards to that selected cluster. No router filter is required between them.

What changed

  • Adds grid_route inference and MCP tool routing
  • Registers grid_route from the AI proxy
  • Routes inference_model candidates by model header, defaulting to X-Model
  • Routes mcp_tool candidates by mcp.method=tools/call and mcp.name
  • Gives MCP metadata precedence over model-header routing
  • Selects ctx.cluster directly for downstream load_balancer
  • Prefers fresh candidates over stale candidates
  • Prefers local-site candidates over remote candidates when freshness is equal
  • Adds docs, examples, and schema coverage

Boundary

This PR keeps AI/Grid-specific semantics in the AI repo:

  • model/provider candidate routing
  • MCP tool candidate routing
  • freshness/locality preference
  • Grid route docs and examples

Praxis core remains responsible for generic proxy primitives:

  • filter runtime
  • pipeline validation
  • request context
  • load balancing
  • generic routing/security filters

Additional reviewer context

This PR adds the Praxis AI grid_route filter, which is the request-time half of the Grid routing handoff.

Grid does not route live HTTP requests itself. Grid renders a routing overlay from GridNetwork, GridSite, InferenceProvider, metrics, SWIM/CRDT state, and access-policy decisions. Praxis AI then consumes that overlay through grid_route.

Grid side quests:

Grid/Praxis AI responsibility split:

  • Grid owns provider discovery, policy filtering, scoring, and overlay rendering.
  • Praxis AI owns request parsing, grid_route candidate selection, and forwarding to a preconfigured load_balancer cluster.
  • grid_route does not call Kubernetes, Grid, SWIM, or CRDT at request time.
  • grid_route does not create upstream clusters dynamically. Any cluster named by a Grid candidate must already exist in the Praxis AI load_balancer config.
  • Credential-bearing candidates carry only credential references. Secret/token resolution is handled by the separate grid_credential_inject path.

Validation

  • cargo +nightly-2026-03-28 fmt --all -- --check
  • cargo test -p praxis-ai-filters grid
  • cargo test -p praxis-tests-schema grid_route
  • cargo clippy -p praxis-ai-filters -- -D warnings
  • cargo clippy -p praxis-ai-proxy -- -D warnings
  • RUSTDOCFLAGS="-D warnings" cargo doc -p praxis-ai-filters -p praxis-ai-proxy --no-deps
  • git diff --check

@nerdalert
nerdalert force-pushed the grid-route branch 2 times, most recently from 1ad1e9f to acd6e4a Compare July 16, 2026 01:55
@nerdalert nerdalert added the Blocker This is blocking other work significantly label Jul 16, 2026
@nerdalert
nerdalert force-pushed the grid-route branch 4 times, most recently from 44c354a to ad0b52e Compare July 23, 2026 14:23
@nerdalert
nerdalert marked this pull request as ready for review July 23, 2026 15:09
@nerdalert
nerdalert requested review from a team and crstrn13 July 23, 2026 15:09

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: feat(filters): add grid_route

Clean, well-structured PR. The filter design is sound: static candidate scoring, deterministic selection, MCP precedence over model header, proper fail-closed behavior. Validation is thorough (bounds on all identifiers, reserved header prefix rejection, duplicate detection). Unit test coverage in route.rs and descriptor.rs is excellent.

Findings

Severity Count
Critical 0
Large 0
Medium 1

One medium finding below regarding test coverage for the MCP example config.

Comment thread tests/schema/tests/suite/examples/ai/grid_route.rs
Add AI-owned grid_route inference and MCP tool routing under praxis-ai-filters and register it from praxis-ai-proxy.

The filter selects ctx.cluster from static candidates, prefers fresh candidates over stale, applies local-site preference on equal freshness, and routes MCP tools/call by mcp metadata with precedence over model-header routing.

Add docs, examples, and schema coverage for the new filter.

Signed-off-by: Brent Salisbury <bsalisbu@redhat.com>
Add an end-to-end schema test for the MCP grid_route example. The test runs the mcp filter, routes a tools/call request through grid_route, and verifies the selected tool-owning backend responds.

Signed-off-by: Brent Salisbury <bsalisbu@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocker This is blocking other work significantly skip/pr-conventions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants