Reproducibility artifact and red-team prompt library for the academic paper “Parity Contracts for Polyglot LLM Commerce” by BrewHub PHL.
This repository is intentionally outside the private BrewHub application monorepo. It contains only the safety regex contract, shared test corpus, and runners — no production secrets, customer data, or payment logic.
BrewHub runs customer-facing AI (Franklin) on Next.js (TypeScript) and workflow agents on Python (Google ADK). Allergen, medical, and dietary safety queries must be blocked deterministically before an LLM can assert “nut-free” or similar — a wrong answer can cause anaphylaxis.
We enforce a parity contract between runtimes:
- Equivalence:
∀ input. f_TS(input) ≡ f_PY(input)for the safety classifiers. - Shared corpus: finite labeled prompts in
corpus/allergen-parity-corpus.json. - CI runners: TypeScript (
tests/safety/allergen.test.ts) and Python (python/tests/safety/test_allergen_parity.py).
| Section | Count (v1.0) | Purpose |
|---|---|---|
layer1_parity_cases |
71 | Pre-LLM isAllergenOrMedicalQuery — positives + benign controls |
layer2_dangerous_reply_cases |
19 | Post-LLM dangerous-assurance patterns (scrubber) |
red_team_prompts |
317 | Synthetic adversarial + benign prompts for paper evaluation (Categories A–D + controls) |
Schema for Layer 1 rows:
{ "input": "...", "expected_trigger": true, "category": "allergen", "layer": 1 }npm install
npm testPython parity (requires repo python/ tree and pytest):
pip install pytest
npm run test:pythonNote: The Python runner in this artifact still reads the canonical TypeScript regex sources from
src/allergen-safety.tsat test time (same as production). PointPYTHONPATHatpython/when running pytest from a checkout that includes both trees.
If you use this corpus in research, please cite the BrewHub PHL paper (forthcoming) and link to this repository:
BrewHub PHL. Allergen Parity Corpus (v1.0.0). https://github.com/brewhubphl/allergen-parity-corpus
MIT — see LICENSE.
Thomas @ BrewHub PHL — info@brewhubphl.com