api7 / api7/aisix

P0-1: Wire up guardrail config loading from etcd / YAML

Open
#43 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-repo gap-with-litellm P0
Dominant language
Rust
Stars
157
Forks
32
Avg merge
1h 25m
Merged PRs (30d)
145

Description

Problem

crates/aisix-guardrails/ ships keyword/regex/length/chain rules and the Guardrail trait is wired into the proxy hot path (crates/aisix-proxy/src/state.rs:40, called at chat.rs:184 input + chat.rs:393 output). But:

  • aisix-core/src/config.rs has no guardrails: section.
  • crates/aisix-server/src/main.rs never calls with_guardrails.
  • Default state ships GuardrailChain::empty() (state.rs:62,85,111).

Result: an operator literally cannot turn on guardrails outside of unit-test code paths — it's scaffold-only.

Scope

This is the 0→1 fix to make every other guardrail issue (Bedrock, Lakera, Presidio, OpenAI Moderation) actually plug-in-able.

DP (moonming/ai-gateway)
  • Add guardrails: config section to Config (aisix-core/src/config.rs).
  • Add etcd resource kind guardrails parallel to models / apikeys in the snapshot loader (crates/aisix-etcd/src/loader.rs).
  • Construct GuardrailChain at startup from config + etcd, wire via with_guardrails.
CP (api7/api7ee-3-control-plane)
  • New CRUD endpoints /api/ai_gateway_groups/:gid/guardrails[/:id] (env-scoped, per api7ee-3-control-plane#2625).
  • Persist + push to kine under /aisix/<group>/guardrails/<id>.
Dashboard UI (api7/AISIX-Cloud)
  • Add Guardrails page under Environment scope.
  • CRUD form: type (keyword/regex/length/chain) + config JSON editor + applies-to model picker.
e2e
  • Go: create guardrail via SaaS API → verify DP enforces (block keyword in chat completion → expect rejection).
  • Playwright: dashboard create/edit/delete guardrail flow.

Estimate

2d (DP-only); +2d CP, +1.5d UI, +0.5d e2e

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading aisix-core/src/config.rs, crates/aisix-etcd/src/loader.rs, crates/aisix-server/src/main.rs, and the GuardrailChain defaults and call sites in crates/aisix-proxy. Trace how models and API keys are loaded, then verify the stated DP, control-plane, dashboard, and e2e flows are covered. Done means configured guardrails reach the proxy and the CRUD and verification flows work across the listed components.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, yaml
Domain
api, backend, frontend, security, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.