Skip to main content

ForkBridge

A clean merge is not evidence that your fork still meets its requirements.

ForkBridge is a dependency-free CLI and GitHub Action that checks explicit file and configuration contracts against both a Git fork and a hypothetical upstream merge. It reports reproducible evidence for humans, CI pipelines and AI coding agents, without checking out or executing project code.

Quick start

Download the wheel from GitHub Releases and install it with python -m pip install /path/to/downloaded-wheel.whl. Use the commands below from a source checkout to install and verify.

Requires Python 3.11+ and Git 2.38+ with merge-tree --write-tree support. Use a trusted local repository with complete history and both refs already available.

python -m pip install .
forkbridge capabilities
forkbridge verify --repo /path/to/repo --fork HEAD --upstream upstream/main --contracts /path/to/contracts.json

The contract file is external policy: do not allow the candidate update to rewrite it. See example contracts and agent integration.

{"version":1,"contracts":[{"id":"sqlite-enabled","kind":"json_equals","path":"config.json","pointer":"/database/sqlite","value":true}]}
Contract What it verifies
exists Regular tracked file exists
contains UTF-8 file contains a literal string
sha256 Exact file bytes match a SHA-256 digest
json_equals JSON pointer resolves to the expected typed JSON value (numbers use Python JSON representation)

Run in GitHub Actions

This workflow checks upstream on demand from your fork's default branch. Set the two upstream values for your project, and commit a contract file at .github/forkbridge.json on your fork. Policy comes from the selected fork commit.

name: Verify upstream update
on:
  workflow_dispatch:
permissions:
  contents: read
jobs:
  verify:
    runs-on: ubuntu-latest
    env:
      UPSTREAM_URL: https://github.com/UPSTREAM_OWNER/UPSTREAM_REPO.git
      UPSTREAM_REF: refs/heads/main
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
        with:
          fetch-depth: 0
          persist-credentials: false
      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
        with:
          python-version: '3.11'
      - name: Fetch upstream and extract the fork policy
        run: |
          git fetch --no-tags "$UPSTREAM_URL" "$UPSTREAM_REF:refs/forkbridge/upstream"
          git show HEAD:.github/forkbridge.json > "$RUNNER_TEMP/forkbridge-policy.json"
      - uses: kexyz254/forkbridge@v0.3.0
        id: verify
        with:
          fork: HEAD
          upstream: refs/forkbridge/upstream
          contracts: ${{ runner.temp }}/forkbridge-policy.json
      - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        if: always() && steps.verify.outputs.report != ''
        with:
          name: forkbridge-report
          path: ${{ steps.verify.outputs.report }}

The action fails the job for regressions, merge conflicts, inconclusive results and errors. Open the uploaded report to see the commit IDs and per-contract evidence. On self-hosted runners, use the action with a trusted local checkout and Python 3.11+ and Git 2.38+ on the path.

Agent and CI protocol

verify emits one JSON object on stdout. It includes resolved fork and upstream commit IDs, merge base, candidate tree ID, contract digest and per-contract baseline/candidate blob IDs and outcomes. A passing result means only that the listed static contracts are preserved. Unknown data, a failing baseline, or unrelated histories cannot produce a pass.

Exit Status Action
0 verified Listed contracts preserved; continue normal review
10 regression Block update and investigate failed contracts
11 conflict Resolve merge conflict separately
12 inconclusive Investigate missing or invalid evidence
2 error Correct inputs or infrastructure

ForkBridge never fetches remote upstream refs itself, pushes, merges into the source repository, or executes contract commands. It uses a temporary bare mirror and native Git merge-tree. It may read committed secrets in the selected files, but reports only identifiers, paths and verdicts, not file contents. Contract literals and paths are not intended for secrets.

Connect an MCP client

Install the optional MCP adapter from a checkout with python -m pip install '.[mcp]'. In your client's local stdio server configuration, set the command to the absolute path of the installed forkbridge-mcp executable and pass these arguments.

{
  "command": "/absolute/path/to/forkbridge-mcp",
  "args": ["--repo", "/path/to/local/fork", "--contracts", "/path/to/trusted/policy.json"]
}

The server exposes verify_merge(fork_oid, upstream_oid) and returns the same structured evidence as the CLI. Both arguments are full Git commit IDs already present in the configured checkout. The operator selects the one checkout and the policy file outside it at startup. Run the server with a trusted local repository and complete history.

See the difference

python examples/demo.py

This generates a synthetic Git fork whose upstream change merges cleanly yet disables a required feature. Expected exit status: 10. The example prints the full JSON report. The yt-dlp case study replays two updates from a real upstream history.

Development

python -m pip install -e '.[test,mcp]'
pytest -q

Boundaries

ForkBridge checks committed content using static policies. Runtime behavior, dependency analysis and automatic remediation are outside the current release. The candidate merge uses native default Git semantics in a disposable mirror; custom merge drivers and local configuration may yield a different result in an actual merge. Trusted local repositories only; use OS/container isolation when processing untrusted repositories. Timeouts and blob/config limits are not a complete resource-exhaustion defense. Shallow/partial histories, large repositories, non-UTF-8 paths and exotic Git layouts may fail or be inconclusive. CI tests the CLI and MCP adapter on Linux, Windows and macOS, and exercises the Action and Python distributions on Linux.

See security, contributing, protocol, roadmap, and publishing. Apache-2.0 licensed. No affiliation with GitHub.

Metadata

Release files for forkbridge 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forkbridge 0.3.0
File Size Uploaded Provenance Actions
forkbridge-0.3.0.tar.gz 18.8 kB With provenance Details for forkbridge-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forkbridge 0.3.0
File Interpreter ABI Platform Actions
forkbridge-0.3.0-py3-none-any.whl Python 3 none any Details for forkbridge-0.3.0-py3-none-any.whl

Total release size: 34.6 kB

Release files / forkbridge-0.3.0.tar.gz

Download URL forkbridge-0.3.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c73585f678c0392a862fb6beb4a96504fe631145eb01cba367dae8f136fc9240
BLAKE2b-256 checksum
How to use checksums
909b4bf3a17442c54cd8ebe0a856c0b59df14e2b91563afac057048e6afb519c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / forkbridge-0.3.0-py3-none-any.whl

Download URL forkbridge-0.3.0-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f14ea918abad500add357ec1182dc22fdf0913faf664dfd16e75dad99d626d8
BLAKE2b-256 checksum
How to use checksums
3ff9953e36ee48758beda2b9d1c8635fa0551da06b60801b121ab7a25e237eac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for forkbridge 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for forkbridge-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page