modelpin-relay
Sends the results of Modelpin checks from CI to Jira and Bitbucket. It reads
the files Modelpin writes (run records, reports, the committed baseline, modelpin watch --json output) and the
repository's git history, builds one signed JSON event, and:
- in Bitbucket Pipelines, posts a
modelpin-checkCode Insights report on the commit (through the Pipelines proxy, so no credentials are needed); - sends the event to Modelpin for Jira's web trigger, if
MODELPIN_WEBHOOK_URLandMODELPIN_WEBHOOK_SECRETare set.
It never imports or changes Modelpin, never calls a model, and never sends prompts, message histories or tool arguments. Apache-2.0.
Commands
modelpin-relay pending Post the PENDING Code Insights report (Bitbucket only)
modelpin-relay skip --reason TEXT [--config modelpin.yaml]
modelpin-relay publish --exit-code CODE --since EPOCH --to MODEL [--from MODEL] [--provider NAME]
[--config modelpin.yaml] [--store-dir .modelpin] [--scenarios-dir DIR]
[--no-insights] [--no-event] [--dry-run] [--out DIR] [--sample]
[--outcome-file PATH]
modelpin-relay publish-watch --input PATH [--no-event] [--dry-run] [--out DIR] [--sample]
modelpin-relay version
common: [--ci auto|bitbucket|github|local] [--url-env NAME] [--secret-env NAME]
Pass --exit-code the exit code of modelpin check in the same step, and --since the step's start time
(date +%s). The relay uses a run record only if Modelpin wrote it during this step for this candidate with this
exit code; otherwise the outcome is error, never clean. Only clean passes.
Exit codes: 0 done (or nothing to send), 2 usage error, 5 a send failed. The relay never changes the check's own exit code: end the CI step with that.
Bitbucket Pipelines
image: python:3.12
clone:
depth: full # history_keys need commit history
pipelines:
pull-requests:
"**":
- step:
name: Modelpin model check
caches: [pip]
script:
- export MODELPIN_MODEL_FILE="app/model.txt" # the file in your repository that holds the model id
- pip install "modelpin[providers]==0.5.3" "modelpin-relay==0.1.*"
- git fetch origin "$BITBUCKET_PR_DESTINATION_BRANCH"
- if git diff --quiet FETCH_HEAD -- "$MODELPIN_MODEL_FILE" modelpin.yaml scenarios/ .modelpin/; then modelpin-relay skip --reason "No model or scenario change in this pull request"; exit 0; fi
- export MODELPIN_CANDIDATE="$(tr -d '[:space:]' < "$MODELPIN_MODEL_FILE")"
- start=$(date +%s); modelpin-relay pending || echo "Modelpin pending report failed"; code=0; modelpin check --to "$MODELPIN_CANDIDATE" || code=$?; modelpin-relay publish --exit-code "$code" --since "$start" --to "$MODELPIN_CANDIDATE" || echo "Modelpin publish failed"; exit $code
Store MODELPIN_WEBHOOK_URL, MODELPIN_WEBHOOK_SECRET and your provider key as secured repository variables.
The event
The event is versioned ("schema": "modelpin.atlassian/v1"), and a field with no value is sent as null,
never left out. The body stays under 180,000 bytes: the relay shortens the migration report, then example outputs, then drops unchanged results,
and lists what it cut in truncated. Model ids, outputs and file paths come only from files the pull request and
Modelpin wrote; the relay reads only regular files inside the checkout and never follows a link.
Verifying the signature
Each POST carries X-Modelpin-Signature: t=<unix seconds>,v1=<hex>, where v1 is the hex HMAC-SHA256 of
<t>.<raw body>, keyed with the UTF-8 bytes of the secret exactly as shown in Modelpin for Jira's Setup tab.
A receiver checks the header is exactly t= ten digits, ,v1= and 64 lowercase hex characters, rejects a t
more than 300 seconds from now, compares the HMAC in constant time, and rejects an event_id it has seen in the
last 15 minutes. Retries reuse the event_id with a fresh timestamp and signature.
import hashlib, hmac
expected = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
ok = hmac.compare_digest(expected, v1)
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest && .venv/bin/ruff check . && .venv/bin/mypy --strict src
.venv/bin/python tests/golden.py # regenerate tests/fixtures/events after a change to the event
scripts/capture_fixtures.sh regenerates the Modelpin 0.5.3 fixtures offline with Modelpin's fake provider.
Metadata
Release files for modelpin-relay 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modelpin_relay-0.1.1.tar.gz | 32.9 kB | Without provenance | Details for modelpin_relay-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modelpin_relay-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for modelpin_relay-0.1.1-py3-none-any.whl |
Total release size: 68.4 kB
Release files / modelpin_relay-0.1.1.tar.gz
| Download URL | modelpin_relay-0.1.1.tar.gz |
|---|---|
| Size | 32.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e786a208fd8e07181fcea40b3840da3dcf1990eae4658bfacec26ebdb79e796c
|
|
BLAKE2b-256 checksum How to use checksums |
2a482db59fc724aa2ff732a7a7c689edbe55adc6064bc70a6173f97a2df9e696
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / modelpin_relay-0.1.1-py3-none-any.whl
| Download URL | modelpin_relay-0.1.1-py3-none-any.whl |
|---|---|
| Size | 35.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be53101cf580e978871a0d8f606cb17663cca1e36627dbebb234be7b99081c19
|
|
BLAKE2b-256 checksum How to use checksums |
1fde2d2f3334e4af7d292ef6878e02b2942cf6d5fa69133068f71dfd1f1e06db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for modelpin-relay 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.