Cross-language conformance
Python, the HTTP server and every official client must give exactly the same answer for every case in tests/corpus/.
tests/conformance/export_corpus.pywritesconformance/cases.json: the non-pending corpus cases grouped by policy (the corpusstandard_policyplus its overrides), each with the in-processGuard.checkanswer (ok,sql, sorted violationcodes).tests/conformance/test_http.pyserves each group over HTTP and compares with that answer, and checkscases.jsonis up to date.tests/conformance/test_stdio.pyruns each group through a realsqlguardllm engine --stdiochild process (PROTOCOL.md) and compares with the same answer.clients/node/test/conformance.test.tsandclients/dotnet/tests/SqlGuardLlm.Tests/ConformanceTests.csstart a realsqlguardllm serveper group (port 0) and compare the client's result with the same expectations.- The
Conformanceworkflow runs all three withSQLGUARD_REQUIRE_CONFORMANCE=1.
After changing tests/corpus/*.yaml run uv run python tests/conformance/export_corpus.py and commit conformance/cases.json.
Running locally
The client tests launch uv run --project <repo> --extra serve sqlguardllm. Override with SQLGUARD_SERVER_CMD (for example sqlguardllm or python -m sqlguardllm). If it cannot run, the tests skip with a warning; SQLGUARD_REQUIRE_CONFORMANCE=1 makes that an error.
Adding a client
- Read
conformance/cases.json:{"groups": [{"name", "policy", "cases": [...]}]}. - For each group write
policyto a JSON file and startsqlguardllm serve --policy FILE --port 0; the port is on stderr (listening on http://...). - For each case call the client's
check(sql, context)and assertok,sql(exact) and the set of violation codes equalexpected, and thatokmatchesexpect(allow/reject). - Add the job to
.github/workflows/conformance.yml.
Any disagreement is a bug in the client or the server, never in expected.