Refract Guides · Practical AI safety testing patterns

Refract Gate in CI: Thresholds That Block Releases

Refract turns AI safety testing from a report into a release gate. refract gate returns a non-zero exit when a scan crosses a threshold you define.

Choose thresholds by risk

Scan, verify, gate

The gate should run after a scan and after record-chain verification so the evidence backing the decision is tamper-evident.

refract scan --target $TARGET --battery baseline --sarif refract.sarif
refract verify
refract gate --max-fn 0 --max-fp-rate 0.05 --min-mcc 0.70

GitHub Actions gate with a prerelease wheel

Place a trusted Refract wheel in wheelhouse/ before the install step. See prerelease installation for build instructions.

name: refract-safety-scan
on: [push, pull_request]
jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install the Refract prerelease wheel
        shell: bash
        run: |
          shopt -s nullglob
          wheels=(wheelhouse/refract_eval-*.whl)
          if [ "${#wheels[@]}" -ne 1 ]; then
            echo "Provide exactly one trusted Refract wheel in wheelhouse/." >&2
            exit 1
          fi
          python -m pip install "${wheels[0]}"
      - run: refract scan --target ${{ vars.REFRACT_TARGET }} --battery baseline --sarif refract.sarif
      - run: refract verify
      - run: refract gate --max-fn 0 --max-fp-rate 0.05 --min-mcc 0.70

Use SARIF for code scanning

Add github/codeql-action/upload-sarif@v4 so the same findings appear natively in GitHub Code Scanning.

Related

Silent Breach Detection with Refract

How Refract detects AI silent breaches, canary leaks that a guardrail misses, using synthetic high-entropy canaries, benign controls, and SARIF 2.1.0 CI gating.