Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

BrewHub LLM Allergen Safety Corpus

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.

What this is

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:

  1. Equivalence: ∀ input. f_TS(input) ≡ f_PY(input) for the safety classifiers.
  2. Shared corpus: finite labeled prompts in corpus/allergen-parity-corpus.json.
  3. CI runners: TypeScript (tests/safety/allergen.test.ts) and Python (python/tests/safety/test_allergen_parity.py).

Corpus layout (corpus/allergen-parity-corpus.json)

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 }

Run tests locally

npm install
npm test

Python parity (requires repo python/ tree and pytest):

pip install pytest
npm run test:python

Note: The Python runner in this artifact still reads the canonical TypeScript regex sources from src/allergen-safety.ts at test time (same as production). Point PYTHONPATH at python/ when running pytest from a checkout that includes both trees.

Citation

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

License

MIT — see LICENSE.

Contact

Thomas @ BrewHub PHL — info@brewhubphl.com

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages