|
| 1 | +# Releasing aibug-gate |
| 2 | + |
| 3 | +Two questions, kept separate: |
| 4 | + |
| 5 | +1. **Is it ready?** — the checklist below. Deterministic; run it every time. |
| 6 | +2. **Does it ship?** — a published PyPI version is *permanent* (yankable, not |
| 7 | + deletable) and ships under the **patchwright** identity. So: |
| 8 | + - **new public surface** (new AB rule, new exported symbol, behavior |
| 9 | + change) → assemble the filled checklist + diff, get a human go, then |
| 10 | + publish. |
| 11 | + - **routine patch** (test-only, docs, a fix that doesn't change a rule's |
| 12 | + surface) → green checklist → publish + report. |
| 13 | + |
| 14 | +The checklist replaces "because I said so." If an item is red, it doesn't ship — |
| 15 | +no exceptions for vibes. A gate with substance, not caution dressed as a rule. |
| 16 | + |
| 17 | +## Readiness checklist — every release |
| 18 | + |
| 19 | +- [ ] full suite green: `uv run python -m pytest -q` (43+ tests; includes the |
| 20 | + corpus-integrity, generator-attribution, and per-rule build-honesty |
| 21 | + fixture pairs). |
| 22 | +- [ ] `ruff check src tests scripts` clean (CI-enforced in the `lint` job). |
| 23 | +- [ ] `ruff format --check src tests scripts` clean (CI-enforced in the `lint` |
| 24 | + job). |
| 25 | +- [ ] `mypy --strict src/aibug_gate` clean (CI-enforced in the `type` job). |
| 26 | +- [ ] **provenance-resolution gate green**: `GITHUB_TOKEN=… python |
| 27 | + scripts/verify_provenance.py` resolves every `dataset.jsonl` |
| 28 | + `upstream_fix_url` against the GitHub API and asserts the live PR's |
| 29 | + merged/open state matches the entry's `upstream_status`. CI-enforced in |
| 30 | + the `provenance` job. A stale status, a typo'd PR number, or a |
| 31 | + re-opened/denied PR fails here with a named step. |
| 32 | +- [ ] **corpus-diff gate green**: `uv run python scripts/corpus_diff.py` shows |
| 33 | + no drift vs `scripts/corpus_baseline.json` (per-rule finding counts over |
| 34 | + a pinned flask/jinja2/click/werkzeug corpus). CI-enforced in the `corpus` |
| 35 | + job. A jump — e.g. an AB003 guard-detection regression taking werkzeug |
| 36 | + from 2 to 20 hits — fails here before the tag, not after release via |
| 37 | + external red-teaming. If a count change is intended (a real fix), re-run |
| 38 | + with `--update` and record why in the commit. Default tier |
| 39 | + (AB001/AB004/AB006) must stay FP-near-zero on the corpus; pedantic-tier |
| 40 | + counts are tracked but advisory. |
| 41 | +- [ ] **every rule's provenance pinned** to a real, verifiable upstream PR. |
| 42 | + `upstream_fix_url` must match |
| 43 | + `^https://github\.com/{owner}/{repo}/pull/\d+$` (format-validated in CI) |
| 44 | + AND resolve to a PR whose actual merged/open state matches the entry's |
| 45 | + `upstream_status` (resolution-validated in the `provenance` job). Do NOT |
| 46 | + invent PRs, PR numbers, or repo paths. If a rule's origin PR is unknown, |
| 47 | + the rule does not ship — full stop. |
| 48 | +- [ ] **build-honesty gate per rule**: the checker goes RED on the vulnerable |
| 49 | + fixture (origin-bug shape) and GREEN on the fixed fixture (and on the |
| 50 | + negative fixtures that exercise the guard-detection suppressions). For |
| 51 | + AB003, that means the `len(s) >= K` / `try/except IndexError` guards |
| 52 | + silence the finding; for AB005, the parenthesized `(not A and B) or C` |
| 53 | + form is suppressed; etc. Mirrors wildlint / mcp-lint. |
| 54 | +- [ ] **merged-backed rules outnumber open-backed** (`test_merged_backed_rules |
| 55 | + _outnumber_open_backed_at_v0_2`). The open-PR tail (AB003/AB004/AB005, |
| 56 | + where the bug is verified on master and the fix is under review) must |
| 57 | + never grow past the merged-PR body. A new open-PR rule requires either a |
| 58 | + matching merged rule or an explicit floor bump in the test. |
| 59 | +- [ ] version bumped **consistently** in `src/aibug_gate/__init__.py` AND |
| 60 | + `pyproject.toml` AND `scripts/corpus_baseline.json`'s |
| 61 | + `_scanned_at_version` field (semver: new rule/surface = minor; internal |
| 62 | + fix = patch). A version mismatch between the package and the baseline |
| 63 | + metadata is a release-blocker — the baseline must record which package |
| 64 | + version produced the counts. |
| 65 | +- [ ] `python -m build` succeeds; `twine check dist/*` PASSED. |
| 66 | +- [ ] `git status` clean apart from the release diff (no stray unrelated |
| 67 | + changes — use pathspec-limited commits per the commit-discipline rule). |
| 68 | +- [ ] **push access verified** — ensure you can push to `patchwright/aibug-gate` |
| 69 | + (the `[DECISION GATE]` / patchwright PAT lives outside the repo; see the |
| 70 | + patchwright push mechanism in project memory). |
| 71 | + |
| 72 | +### Adding a new AB rule (the surface-changing case) |
| 73 | + |
| 74 | +A new rule is three artifacts + four gates: |
| 75 | + |
| 76 | +1. **One `src/aibug_gate/dataset.jsonl` line** with `id`, `code`, `name`, |
| 77 | + `bug_class`, `upstream_fix_url` (real, verifiable PR), `upstream_status`, |
| 78 | + `pattern`, `ast_signature`, `severity`, `tier`, `symptom`, `origin`, |
| 79 | + `generator` (always `"bug-class commonly shipped by AI generators"` — never |
| 80 | + attribute a specific bug to a specific LLM without verified evidence; the |
| 81 | + CI gate rejects entries naming copilot/chatgpt/claude/gemini/cursor/codex). |
| 82 | +2. **One `src/aibug_gate/checkers.py` class** with the matching `code`, |
| 83 | + exposing `check(tree, path, source) -> list[Finding]`. |
| 84 | +3. **Build-honesty fixtures** in `tests/test_rules.py`: positive (origin-bug |
| 85 | + shape → finding fires) + negative (fixed shape AND each guard-detection |
| 86 | + suppression → finding silent). |
| 87 | + |
| 88 | +Then: |
| 89 | + |
| 90 | +- [ ] `corpus_diff.py --update` run, the baseline diff reviewed, and the |
| 91 | + commit message records *why* the count moved (or confirms it didn't). |
| 92 | +- [ ] `verify_provenance.py` run if the new rule adds a new `upstream_fix_url` |
| 93 | + (it always does) — confirms the PR resolves to the recorded status. |
| 94 | +- [ ] README corpus table updated with the new row. |
| 95 | +- [ ] `corpus_baseline.json` `_rules` block amended with an honest |
| 96 | + characterization of the new rule's behaviour on the Pallets corpus. |
| 97 | + |
| 98 | +## Provenance honesty (the product's core claim) |
| 99 | + |
| 100 | +`aibug-gate`'s differentiator is *auditable* provenance: every finding inlines |
| 101 | +a real upstream fix URL. Three honesty invariants, all CI-enforced: |
| 102 | + |
| 103 | +- **URL format gate** (test_every_entry_has_verifiable_upstream_fix_url): every |
| 104 | + `upstream_fix_url` matches the GitHub PR regex. No issue links, no commit |
| 105 | + links, no third-party trackers — only `github.com/{owner}/{repo}/pull/{n}`. |
| 106 | +- **Resolution gate** (the `provenance` CI job): the PR exists and its live |
| 107 | + state matches `upstream_status`. A rule that cites a non-existent PR, or a |
| 108 | + "merged" status on a PR that is actually still open, fails the build. |
| 109 | +- **Generator-attribution gate** (test corpus): the `generator` field is the |
| 110 | + honest frame ("bug-class commonly shipped by AI generators"), never a |
| 111 | + specific tool attribution without verified evidence. |
| 112 | + |
| 113 | +If a rule's origin PR cannot be verified, the rule does not ship. This is the |
| 114 | +one place `aibug-gate` refuses to punt: a finding without its evidence link is |
| 115 | +just another lint hit, and the corpus is the moat. |
| 116 | + |
| 117 | +## CVE-signature honesty |
| 118 | + |
| 119 | +aibug-gate's rules are pinned to **real upstream PRs found by the gift-PR |
| 120 | +fleet**, not to CVE advisories. This is a deliberate difference from mcp-lint |
| 121 | +(which pins to MCP CVEs). The discipline is the same: when a bug report's |
| 122 | +summary and its fix diverge, the **fix is the source of truth**. AB006 |
| 123 | +(shortuuid) is the canonical example — the bug was described as "wrong |
| 124 | +numbers" but the actual shape was `alpha_len = len(alphabet)` instead of |
| 125 | +`len(alphabet_index)` after an override guard. The rule is written against the |
| 126 | +patched code shape, not the report summary. |
| 127 | + |
| 128 | +If a future rule cites a CVE/GHSA directly (not just a PR), verify the CVE |
| 129 | +exists in NVD before citing it. Do NOT invent CVE ids or signatures. |
| 130 | + |
| 131 | +## Publish mechanics |
| 132 | + |
| 133 | +aibug-gate does not yet have an OIDC trusted-publishing workflow (no |
| 134 | +`.github/workflows/release.yml`); publishing is currently a manual step under |
| 135 | +the patchwright identity. The mechanics: |
| 136 | + |
| 137 | +```bash |
| 138 | +# 1. all checklist items green, working tree clean. |
| 139 | +git commit -am "release: vX.Y.Z" # or stage precisely |
| 140 | +git tag -a vX.Y.Z -m "vX.Y.Z — <one-line>" |
| 141 | + |
| 142 | +# 2. build + check locally. |
| 143 | +uv run python -m build |
| 144 | +uv run twine check dist/* |
| 145 | + |
| 146 | +# 3. publish under patchwright (credential held outside the repo). |
| 147 | +uv run twine upload dist/aibug_gate-X.Y.Z* |
| 148 | + |
| 149 | +# 4. push. |
| 150 | +git push origin main vX.Y.Z |
| 151 | +``` |
| 152 | + |
| 153 | +A future `release.yml` (trusted publishing, `skip-existing: true` for |
| 154 | +idempotent re-tags) is the natural follow-up; until then, publish is a |
| 155 | +human-go step because a PyPI version is permanent and the patchwright |
| 156 | +identity is shared infrastructure. |
| 157 | + |
| 158 | +Release notes live in the **tag annotation** (or an optional GitHub Release) |
| 159 | +— there is no CHANGELOG file by project convention. |
| 160 | + |
| 161 | +## Post-publish smoke (runs AFTER publish — the closing item) |
| 162 | + |
| 163 | +- [ ] fresh install in a clean venv: `pip install aibug-gate==X.Y.Z` |
| 164 | +- [ ] `aibug-gate --version` reports the new version |
| 165 | +- [ ] `aibug-gate --list-rules` shows the full corpus including the new row |
| 166 | + (if any) |
| 167 | +- [ ] the new rule fires on its origin-bug shape: construct a minimal repro |
| 168 | + from the `ast_signature` field and confirm `aibug-gate --pedantic` exits |
| 169 | + non-zero on it |
| 170 | +- [ ] `python -c "import aibug_gate; print(aibug_gate.__version__, |
| 171 | + [c.code for c in aibug_gate.checkers.CHECKERS])"` |
| 172 | + |
| 173 | +## What this gate is not |
| 174 | + |
| 175 | +- Not a substitute for judgment on *what* ships under patchwright's name — that |
| 176 | + is the human-go tier for new surfaces. |
| 177 | +- Not static — amend this file when the release process changes (e.g. when a |
| 178 | + `release.yml` lands), so the gate reflects reality rather than rotting into |
| 179 | + a fiction. |
| 180 | +- Not a substitute for the gift-PR fleet — the corpus grows as the fleet finds |
| 181 | + and fixes more real bugs; this gate ensures the corpus that ships stays |
| 182 | + honest, not that the corpus grows. |
0 commit comments