Gate a build on Integrity Lens
Scan the model on every push and fail the build when it is tampered or no longer the approved version.
One CI step starts a scan, waits for it, and fails the build when:
- the verdict is
tampered, or - the scanned commit is no longer the version you approved (
against_approvedis notmatches_approved).
Before you start
- Approve a version of the model, in the app under Scanned models or with
POST /v1/integrity/models/{id}/approve. - Create an API key under Profile → API keys for your organization, and store it as the CI secret
NEURONLENS_API_KEY. - For a private repository, make sure an admin has connected a Hugging Face read token (Connect).
GitHub Actions
# .github/workflows/integrity.yml
name: Integrity Lens
on: [push]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Scan the model and fail on tampering
env:
KEY: ${{ secrets.NEURONLENS_API_KEY }}
MODEL: hf://acme/kyc-assistant-v3
run: |
API=https://api.neuronlens.com/v1/integrity
ID=$(curl -sf $API/scans -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d "{\"model\": \"$MODEL\", \"compare\": \"approved\"}" | jq -r .scan_id)
for i in $(seq 1 120); do
R=$(curl -sf $API/scans/$ID -H "Authorization: Bearer $KEY")
S=$(echo "$R" | jq -r .status)
[ "$S" = done ] || [ "$S" = failed ] && break
sleep 10
done
echo "$R" | jq '{status, verdict, against_approved, report_url}'
[ "$(echo "$R" | jq -r .status)" = done ] || exit 1
[ "$(echo "$R" | jq -r .verdict)" != tampered ] || exit 1
[ "$(echo "$R" | jq -r .against_approved)" = matches_approved ] || exit 1
Change MODEL to your model. To check the exact commit you are shipping, pin it: hf://acme/kyc-assistant-v3@<sha>.
What you will see:
| Model | Result | Build |
|---|---|---|
| the approved version | no_issue, matches_approved | passes |
| a new commit, nothing found | no_issue, changed | fails until someone reviews and approves it |
| a stripped model | tampered | fails |
a scan that could not finish (for example needs_token) | failed | fails |
The job log prints the report_url of the signed report.
GitLab CI and other systems
The step is plain curl and jq, so the same lines work anywhere. In GitLab CI, put them under script: in a job
with an image that has both (for example alpine with apk add curl jq), and the key in a masked CI/CD variable.
To avoid polling, pass "webhook": "https://ci.example.com/hooks/neuronlens" and we call it when the scan finishes
(see Webhooks).
Cost
Each started scan counts as one run against your daily allowance; polling does not.