Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/requirements/test.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest
pytest-xdist
hypothesis
ruff
coverage
244 changes: 244 additions & 0 deletions .github/requirements/test.txt

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
name: fuzz

# Atheris (tests/fuzz_atheris.py), a coverage-guided fuzzer, throws random commands at the paid step's command
# filter (bite.command_ok) and keeps the ones that reach new code. A crash, or a command it lets through that has a
# redirect, a secret file name or a dangerous word outside quotes, is a find. 10 minutes weekly, 1 minute on pull
# requests that touch the filter. A find fails the run, which emails the maintainer. It opens no public issue on
# purpose: a way past the filter is a security hole, and SECURITY.md asks for those to stay private until fixed.
# Atheris (tests/fuzz_atheris.py), a coverage-guided fuzzer, attacks Bite's three security lines and keeps the
# inputs that reach new code: the paid step's command filter (bite.command_ok), the worker's file access
# (bite.edit_ok, bite.read_ok) and the rerun command built from test output (recent.only_these). A crash, a command
# with a redirect, a secret file name or a dangerous word outside quotes, a file outside the project copy, or a
# rerun name the shell would expand is a find. 10 minutes weekly, 1 minute on pull requests that touch that code.
# A find fails the run, which emails the maintainer. It opens no public issue on purpose: a way past these lines is
# a security hole, and SECURITY.md asks for those to stay private until fixed.
on:
schedule:
- cron: "29 6 * * 3" # Wednesdays 06:29 UTC
pull_request:
paths: ["bite.py", "tests/fuzz_atheris.py", "tests/fuzz_oracle.py", ".github/requirements/atheris.txt", ".github/workflows/fuzz.yml"]
paths: ["bite.py", "recent.py", "tests/fuzz_atheris.py", "tests/fuzz_oracle.py", ".github/requirements/atheris.txt", ".github/workflows/fuzz.yml"]
workflow_dispatch:

permissions: {}
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ jobs:
- if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13'
run: ruff check .
# 4 at a time (pytest-xdist): about 4x faster, most of all on Windows, where each test starts slower (#16).
- run: python -m pytest -v -n auto --dist worksteal --durations=20 --part ${{ matrix.part }}/${{ matrix.os == 'ubuntu-latest' && 1 || 2 }}
- if: ${{ !(matrix.os == 'ubuntu-latest' && matrix.python == '3.13') }}
run: python -m pytest -v -n auto --dist worksteal --durations=20 --part ${{ matrix.part }}/${{ matrix.os == 'ubuntu-latest' && 1 || 2 }}
# One job also measures how much of Bite's code the tests run (statement coverage, counting the Bite runs the
# tests start in subprocesses), prints it, and fails under 80% (OpenSSF Best Practices Silver asks for 80%).
- if: matrix.os == 'ubuntu-latest' && matrix.python == '3.13'
env:
COVERAGE_ROOT: ${{ github.workspace }}
run: |
python -m coverage run -m pytest -v -n auto --dist worksteal --durations=20
python -m coverage combine -q
python -m coverage report --skip-covered
python -m coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY"

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ slow-unit-*
timeout-*
oom-*
leak-*
.coverage
.coverage.*
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ left unchecked. The one real ask:
- **For a bug fix, a test that fails without your change.** That's Bite's whole point, so we hold ourselves to
it too. Not sure your test catches it? Run `bite live` before you commit: it tells you whether any test
notices your change.
- **For a new feature, tests for it** (a new command, option, language or message): added to `tests/` in the same
PR. CI also fails if the tests cover less than 80% of Bite's code.
- `python -m pytest` passes, and CI is green (those checks do block the merge).
- One fix per PR, with plain words in the description: what was wrong, what you changed, how you checked.
- A short title in the [Conventional Commit](https://www.conventionalcommits.org/) style, like
Expand All @@ -75,6 +77,17 @@ Nice to have, never required: light and dark screenshots if it changes how somet
If a small piece is left over, a maintainer may finish it for you and keep you as co-author.
Once it's merged, you're credited by name in [CONTRIBUTORS.md](CONTRIBUTORS.md) and in the next release's notes.

## Code style

- Python follows [PEP 8](https://peps.python.org/pep-0008/) naming and layout, with lines kept near 120
characters. The rules we enforce are ruff's (`[tool.ruff]` in pyproject.toml): `ruff check .` must pass, and CI
runs it. It catches unused and undefined names and syntax Python 3.10 can't read.
- Standard library only: Bite has no runtime dependencies, so don't add one.
- Use `pathlib` for paths and open text files with `encoding="utf-8"` (CI runs on Windows too).
- Messages users read are plain words, in US English (a test checks the spelling).
- How the code fits together: [docs/architecture.md](docs/architecture.md). Who decides what:
[GOVERNANCE.md](GOVERNANCE.md). What's planned: [ROADMAP.md](ROADMAP.md).

## Where things are

| | |
Expand Down
43 changes: 43 additions & 0 deletions GOVERNANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# How Bite is run

Bite is a small project with one maintainer. This page says who decides what, who does which job, and what
happens if the maintainer can't go on.

## Roles

| Role | Who | What they do |
|---|---|---|
| Maintainer | [@connabyss](https://github.com/connabyss) (CH) | Decides what goes in, reviews and merges pull requests, plans and publishes releases, answers security reports, owns the repo, the PyPI project and the MCP Registry name. |
| Contributors | anyone ([CONTRIBUTORS.md](CONTRIBUTORS.md)) | Open issues and pull requests. Follow [CONTRIBUTING.md](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md). |
| AI helpers | Claude sessions the maintainer runs | Write code, review and fix bot comments, and squash-merge pull requests only under the written rules in [CLAUDE.md](CLAUDE.md) (every check green, every bot comment handled, on the exact commit merged). They never publish a release, change who can see the repo, or merge changes to CLAUDE.md, AGENTS.md or `.github/` from outside contributors without the maintainer's own OK. |
| Review bots | CodeRabbit, CodeQL, OpenSSF Scorecard, Bite's own check | Comment on pull requests and scan the code. They advise; they never merge. |
| Security contact | the maintainer | Reads private reports from the [Security tab](https://github.com/connabyss/bite/security/advisories/new) or connabyss.code@proton.me, as [SECURITY.md](SECURITY.md) describes. |

## How decisions are made

- **Day to day:** a pull request goes in when its checks are green, its review comments are handled, and the
maintainer (or an AI helper under the CLAUDE.md rules) merges it. [CONTRIBUTING.md](CONTRIBUTING.md#how-we-review)
says how reviews work, so a contributor never has to guess when they're done.
- **Bigger changes** (a new language, a new command, a change to what Bite promises) start as an issue, so anyone
can weigh in before code is written. The maintainer makes the final call and says why on the issue.
- **Releases** are planned by the maintainer. A release is a pull request that bumps the version and adds its
CHANGELOG section; merging it and publishing the GitHub release puts it on PyPI. Nobody else publishes one.
- **Security fixes** follow [SECURITY.md](SECURITY.md): fixed in private first when the report came in
privately, then released and credited.
- **Disagreements:** say so on the issue or pull request. The maintainer decides, and a decision can always be
reopened with new facts.

## If the maintainer can't go on

Bite is MIT-licensed, so anyone may fork it and carry on under a new name at any time.

What keeps the project itself going:

- **Releases need no secret key.** PyPI publishing uses Trusted Publishing from this repo's `publish.yml`, and
release signatures are made by Sigstore at publish time. Whoever controls the GitHub repo can release.
- **Everything else lives on GitHub:** code, issues, CI, the Action and the bots.

**Open gap, said plainly:** today Bite has one maintainer (a bus factor of 1), and no second person has been
named who could take over the repo and the PyPI project within a week. Until that changes, Bite doesn't meet
the OpenSSF Silver "access continuity" rule. Want to help maintain Bite? Say so in
[an issue](https://github.com/connabyss/bite/issues/new).
39 changes: 39 additions & 0 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Roadmap

What Bite plans to do, and not do, through the end of 2027. It's a plan, not a promise of dates: the
[issues](https://github.com/connabyss/bite/issues) show what's moving now, and anyone can pick one up.

## What stays the same

Bite does one job: it checks whether the "fixed" in recent commits is true, by taking each change back out and
running the project's own tests. The free check needs no key, no account and no network beyond what the
project's tests use.

## Plans for the next year

- **More languages.** Ruby ([#86](https://github.com/connabyss/bite/issues/86)), PHP
([#184](https://github.com/connabyss/bite/issues/184)) and Deno
([#277](https://github.com/connabyss/bite/issues/277)), and monorepos with several test commands
([#187](https://github.com/connabyss/bite/issues/187)).
- **Check earlier.** A pre-commit hook ([#87](https://github.com/connabyss/bite/issues/87)), and `bite live` and
`bite mcp` tested end to end in more coding AIs ([#186](https://github.com/connabyss/bite/issues/186),
[#276](https://github.com/connabyss/bite/issues/276)).
- **Fewer wrong flags.** Every false alarm someone reports or a [Fool Bite](https://github.com/connabyss/bite/issues/156)
entry finds becomes a test, so it can't come back.
- **Easier first run.** Every place a new user gets stuck ([#185](https://github.com/connabyss/bite/issues/185),
[#246](https://github.com/connabyss/bite/issues/246)) gets fixed or explained.
- **Security.** Keep the fuzzer, CodeQL and Scorecard running, reach the OpenSSF Best Practices Silver badge,
and close the gaps [GOVERNANCE.md](GOVERNANCE.md) names (a second maintainer).
- **More READMEs in more languages** ([#253](https://github.com/connabyss/bite/issues/253)).

## What Bite won't do

- **Fix your code for you.** Bite reports, and at most writes a missing test you choose to add. It never edits
your project's code.
- **Use your Claude login or plan.** The paid step uses an Anthropic API key only (see AGENTS.md), and that
won't change.
- **Phone home.** No telemetry, no accounts, no hosted service that sees your code. Besides what you ask for
(cloning a link you give it, the paid step's API calls, git-lfs fetching your project's own files), the only
network call Bite makes is the version check against PyPI.
- **Grade coding AIs against each other.** Bite checks claims in one project; it isn't a leaderboard.
- **Promise a commit has no other bugs.** It tests what a commit claimed, nothing more.
29 changes: 29 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,35 @@ security hole in Bite matters. Please tell us about one privately first, not in
Say what you did, what happened, and which Bite version (`bite --version`). A small repo or command that shows
it helps most. You'll get an answer within a week, and credit in the release notes if you'd like it.

## What happens after you report

1. **Within a week:** we answer, say whether we could reproduce it, and keep talking in the private advisory (or
by email).
2. **Fix in private:** the fix and a test that fails without it are made in the advisory's private fork when the
report came in privately. The Atheris fuzzer (`tests/fuzz_atheris.py`) gets a case for it when it fits.
3. **Release:** a new version goes to PyPI, and the CHANGELOG says what was fixed and who to thank (unless you'd
rather stay anonymous).
4. **Publish:** the advisory is made public once the release is out, with a CVE when GitHub assigns one.

What Bite promises about security, its threat model and why we think it holds:
[docs/security-design.md](docs/security-design.md).

## Check a release

Every release on PyPI is signed when it's published: PyPI's Trusted Publishing has this repo's `publish.yml`
make a Sigstore attestation for each file, so there is no private signing key to steal. PyPI shows it under
"Provenance" on each file's page. To check a file you downloaded:

```
python -m pip install pypi-attestations
python -m pypi_attestations verify pypi --repository https://github.com/connabyss/bite bite_check-1.0.11-py3-none-any.whl
```

Pass the path of your own file (here, a wheel in the current folder): a file changed after it was published
fails. Writing `pypi:bite_check-1.0.11-py3-none-any.whl` instead checks the copy on PyPI without a download. What
a pass proves: the file is the one published to PyPI by a GitHub Actions run in connabyss/bite. It doesn't prove
which workflow in the repo built it, or that the code in it is free of bugs.

## Which versions get fixes

Only the newest release on [PyPI](https://pypi.org/project/bite-check/). Update with
Expand Down
71 changes: 71 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# How Bite is built

A map of Bite's code for people who want to change it. What each file is for is also in the table in
[CONTRIBUTING.md](../CONTRIBUTING.md#where-things-are); this page shows how the pieces work together. The
security side of the same design is in [security-design.md](security-design.md).

## The big picture

Bite is plain Python (3.10+) with no runtime dependencies. Its own steps never edit your project's code or git
history: tests run on throwaway copies. It writes its output in your project's `bite_proof/` folder, and a
JavaScript project's `node_modules/` is linked into each copy rather than copied. The tests themselves are your
project's code and run with your user's rights. Details: [security-design.md](security-design.md).

```
you, a coding AI, or the GitHub Action
|
bite / bite ask / bite live / bite mcp / python -m bite_check
|
recent.py --- finds fix claims, runs the free check, writes the report
/ | \
repo.py bite.py (paid step) Claude Agent SDK worker
git, settings engine: writes one test of a claim,
copies, test runs, inside a copy, behind
command filter bite.py's permission check
|
your project's own test command
(optionally inside contain_command, for example Docker, no network)
```

## One run of the free check (`bite --free`)

1. **Read the settings** (`repo.py`, `bite.py`): `.bite.ini` if there is one, otherwise a guessed test command
(pytest, npm test, cargo, go, dotnet, Maven, Gradle).
2. **Find the commits** (`recent.commits`): the last 40 that changed code and claim a fix, or all of them with
`--any`.
3. **Copy the project** (`recent.export`): `git archive` of each commit into a fresh folder, with submodules
and LFS files put back. Your working tree is never touched.
4. **Take the change out** (`recent.take_out`) in the copy, only in the language the tests run, and run the tests
(`bite.run_tests`). If they still pass, no test guards the change. Failed tests are rerun alone first when
their names can be read safely (`recent.only_these`), which saves whole-suite runs.
5. **Rule out harmless reasons** (other OS, tidy-up, a later fix) and look for a later commit that put the old
code back (the comeback alarm).
6. **Report** (`recent.write_free`, `write_html`, `write_comment`): `bite_proof/report.html`, `FREE_REPORT.md`,
`--json`, and for the Action a pull request comment with every @mention broken (`recent.no_pings`).

## The paid step

For the top suspects, `recent.try_claim` starts a worker through the Claude Agent SDK on a copy of the project at
that commit. The worker writes one small test of the commit's claim. Every tool call goes through
`bite.make_permission`: reads and writes must stay inside the copy (`read_ok`, `edit_ok`), shell commands must
pass the command filter (`command_ok`), and files that can run code or steer agents are held for a person to
review (`REVIEW_ONLY_DEFAULT`). Bite then runs the test itself, twice, on that commit and on today's code, and a
second fresh worker must agree the test is fair before it is shown. It needs an Anthropic API key (never a
Claude login) and stops at `--budget`.

## The other front doors

- `live.py`: `bite live` checks the changes since the last commit; `--hook` is the Claude Code Stop hook in
`plugin-live/`.
- `bite_mcp.py`: an MCP server (JSON-RPC on stdin/stdout) with `check_fix` and `ask_bite`.
- `ask.py`: `bite ask "..."` finds the commits a question means and runs the free check on them.
- `action.yml`, `open_pr.py`, `publish_badge.py`: the GitHub Action, which runs the free check on a pull request,
comments, and can open a pull request with the tests Bite wrote or publish a score badge.
- `bot/`: the repo's own helpers (welcome, PR checklist, self-check, Night Clerk). They are not shipped on PyPI.

## Tests

`tests/` holds about 670 tests, all offline. Most build a small practice repo, run `recent.py` on it in a
subprocess, and check what it prints. CI runs them on Linux, macOS and Windows with Python 3.10 and 3.13, measures
statement coverage (80% or more, counting those subprocess runs), and runs the Atheris fuzzer
(`tests/fuzz_atheris.py`) against the security checks. See [CONTRIBUTING.md](../CONTRIBUTING.md).
Loading
Loading