P0-1: Wire up guardrail config loading from etcd / YAML
Nobody has claimed this yet.
- 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.rshas noguardrails:section.crates/aisix-server/src/main.rsnever callswith_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 toConfig(aisix-core/src/config.rs). - Add etcd resource kind
guardrailsparallel tomodels/apikeysin the snapshot loader (crates/aisix-etcd/src/loader.rs). - Construct
GuardrailChainat startup from config + etcd, wire viawith_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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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