diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 216f5503..2279bef1 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -84,23 +84,35 @@ owner call when modified production files are restored to `` and
newly added production files are removed temporarily:
```console
-$ mapfile -t mod_py < <(
- git diff --name-only -M --diff-filter=MDR ..HEAD -- '*.py' |
- rg -v '(^|/)tests?/|(^|/)conftest\.py$|(^|/)test_[^/]*\.py$|_test\.py$'
- ) &&
- mapfile -t add_py < <(
- git diff --name-only -M --diff-filter=A ..HEAD -- '*.py' |
- rg -v '(^|/)tests?/|(^|/)conftest\.py$|(^|/)test_[^/]*\.py$|_test\.py$'
- ) &&
- test $(( ${#mod_py[@]} + ${#add_py[@]} )) -gt 0 &&
- { [ "${#mod_py[@]}" -eq 0 ] ||
- git restore --source= --worktree -- "${mod_py[@]}"; } &&
- { [ "${#add_py[@]}" -eq 0 ] || rm -f -- "${add_py[@]}"; } &&
- ! uv run pytest -x &&
- git restore --source=HEAD --worktree -- "${mod_py[@]}" "${add_py[@]}" &&
- uv run pytest
+$ : "${BITE_TEST:?set BITE_TEST to the regression test}" && \
+ wt=$(mktemp -d) && \
+ git worktree add --quiet --detach "$wt" HEAD && \
+ ( cd "$wt" && \
+ base=${BITE_BASE:-origin/master} && \
+ git diff --name-only --no-renames "$base" HEAD | \
+ grep -E '\.py$' | \
+ grep -Ev '(^|/)tests?/|(^|/)conftest\.py$|(^|/)test_[^/]*\.py$|_test\.py$' \
+ > bite.files && \
+ git restore --source="$base" --worktree \
+ --pathspec-from-file=bite.files && \
+ { uv run pytest -rf "$BITE_TEST" 2>&1 | tee bite.log; \
+ grep -E '^FAILED ' bite.log | \
+ grep -F -- "$BITE_TEST" | \
+ grep -Ev 'ImportError|ModuleNotFoundError'; } ); \
+ bite=$?; \
+ git worktree remove --force "$wt"; \
+ test "$bite" -eq 0
```
+This runs in a disposable `git worktree` at `HEAD`, so the checkout and any
+uncommitted edit stay untouched; commit the change first. Set `BITE_TEST` to a
+pytest node id such as `tests/test_x.py::test_name`. `BITE_BASE` defaults to
+`origin/master`; set it to the pre-fix commit when the defect was introduced
+earlier in the same pull request. The command succeeds only when the runner
+reports that test as failed, and it prints the failure line. A missing runner,
+a build error or an import error prints no such line, so it is not a bite.
+Check that the printed failure is the assertion that describes the defect.
+
### Clean-room provenance
Apply the [clean-room review gate](../REVIEW.md#clean-room-provenance)
@@ -180,6 +192,22 @@ should pin `libvt>=0.0.1a6,<0.1` (and `>=0.x,<0.y` from `0.1.0` onward).
builds and publishes to PyPI via OIDC trusted publishing —
there is no manual upload step.
+## Posture
+
+`REVIEW.md` opens with this repository's posture. It tells a reviewer
+how to treat a compatibility shim, meaning code kept only so an older
+caller keeps working:
+
+- `experimental`: the public interface can still change between
+ releases. Repair a wrong boundary at its owner and update callers in
+ the same change. A shim is residue unless a named consumer needs it
+ and its removal condition is recorded.
+- `stable`: users depend on the released interface. A breaking change
+ ships with a shim or a deprecation path, a changelog entry and
+ migration notes. A shim stays until its removal condition is met.
+- `private`: the repository has no outside consumers. Change every
+ caller in the same pull request and keep no shim.
+
## Pull requests
Use [REVIEW.md](../REVIEW.md) for design and pull request review.
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 4623a5d6..22a9940d 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -36,7 +36,7 @@ jobs:
- name: Check types with ty
run: uv run ty check --python-version ${{ matrix.python-version }} --output-format github
- name: Check declared workarounds
- run: PYTHONDONTWRITEBYTECODE=1 uv run python -B scripts/check_workarounds.py
+ uses: libtmux/.github/actions/check-workarounds@22703e1b8ee1c176ca72d9ffc9520f2ca0ce3a85 # main
- name: Tests (pytest)
if: matrix.python-version != '3.14'
run: uv run pytest -m ""
diff --git a/REVIEW.md b/REVIEW.md
index d42554ee..f7dadad2 100644
--- a/REVIEW.md
+++ b/REVIEW.md
@@ -1,5 +1,9 @@
# Design and pull request review
+Posture: `experimental` (pre-alpha; no compatibility promise yet).
+[Posture](.github/CONTRIBUTING.md#posture) defines `experimental`, `stable`
+and `private`.
+
Review the complete change from its base, including local edits and new files.
Stop at the first failing gate and record its cause. Resume at the earliest
affected gate after a repair. Collect the pre-edit reproduction before
@@ -120,3 +124,23 @@ for screen regressions. Choose the boundaries that can trigger the defect.
rules for path handling.
- Stream and PTY EOF, cancellation, backpressure and private socket
ownership for transport and multiplexer changes.
+
+## 5. Verdict
+
+These rules decide which findings block.
+
+- **Base run**: A finding that code misbehaves shows its check run on ``
+ and on the change, with one line of output from each.
+- **Existing and separate**: Behavior `` already has does not block.
+ Report it as a `NOTE`, unless the change adds a promise the behavior breaks;
+ then the broken promise is the finding.
+- **Unverified**: A gate nobody ran is unverified. Name the command that would
+ run it. It holds the merge until someone runs it, and it does not make the
+ verdict `BLOCK`.
+- **Behavior defects**: A behavior defect blocks when a caller can reach it in
+ a supported environment, or when it breaks a promise in the pull request
+ description, a docstring, help text or the changelog. Otherwise it is a
+ `NOTE`.
+- **Checks and claims**: A weakened check, a rule written in a second place
+ and a behavior claimed as tested with no test that bites block whether or
+ not a caller reaches them.
diff --git a/scripts/check_workarounds.py b/scripts/check_workarounds.py
deleted file mode 100755
index f7cdd148..00000000
--- a/scripts/check_workarounds.py
+++ /dev/null
@@ -1,377 +0,0 @@
-#!/usr/bin/env python3
-"""Verify declared workaround removal conditions against lockfiles.
-
-Checks `.github/workarounds.toml` against `uv.lock`, `Cargo.lock`,
-`package-lock.json`, and `pnpm-lock.yaml`.
-
-Each entry in `.github/workarounds.toml` declares:
-- `id`: stable kebab-case identifier cited in the target source file
-- `path`: repository-relative code path containing the workaround
-- `owner`: upstream package or external tool that owns the root cause
-- `issue`: pinned upstream issue, pull request, commit, or specification URL
-- `remove_when` (optional only when `issue_only = true` for a non-lockfile tool):
- `":>="` where `` is `pypi`, `cargo`,
- or `npm`. The check fails once every locked copy of `` meets or
- exceeds ``, proving the workaround is ready to delete.
-
-Examples
---------
->>> sample_toml = '''
-... [[workaround]]
-... id = "vcspull-daemon-url-schemes"
-... path = "src/vcspull/validator.py"
-... owner = "libvcs"
-... issue = "https://github.com/vcs-python/libvcs/issues/546"
-... remove_when = "pypi:libvcs>=0.49.0"
-... '''
->>> locks = {"pypi": {"libvcs": "0.48.0"}, "cargo": {}, "npm": {}}
->>> check_entries(
-... parse_workarounds(sample_toml),
-... locks,
-... existing_paths={"src/vcspull/validator.py"},
-... )
-[]
->>> version_key("0.49.0-rc.1") < version_key("0.49.0") < version_key("0.49.1a1")
-True
->>> version_key("0.49") == version_key("0.49.0")
-True
->>> locks_bumped = {"pypi": {"libvcs": "0.49.0"}, "cargo": {}, "npm": {}}
->>> [
-... e["reason"]
-... for e in check_entries(
-... parse_workarounds(sample_toml),
-... locks_bumped,
-... existing_paths={"src/vcspull/validator.py"},
-... )
-... ]
-['condition met (pypi:libvcs is 0.49.0 >= 0.49.0); remove workaround']
-"""
-
-from __future__ import annotations
-
-import json
-import pathlib
-import re
-import sys
-import tomllib
-
-COND_RE = re.compile(r"^(pypi|cargo|npm):([A-Za-z0-9_./@-]+)>=([0-9][0-9A-Za-z._-]*)$")
-DATE_ONLY_RE = re.compile(r"^\d{4}-\d{2}-\d{2}$")
-ISSUE_URL_RE = re.compile(r"^https://[^/\s]+/[^/\s]+/\S+$")
-PRE_SEG_RE = re.compile(r"^(\d+)([A-Za-z]+)(\d*)$")
-EXACT_VER_RE = re.compile(r"^\d+(?:\.\d+)*(?:[-.][0-9A-Za-z.-]+)?$")
-PNPM_PKG_RE = re.compile(
- r"""(?m)^\s{2,4}['"]?/?(@?[^'"@\s:]+)@(\d[^'"(\s:]*)(?:\([^)]*\))*['"]?:"""
-)
-DOC_SUFFIXES = {".md", ".rst", ".txt", ".adoc"}
-
-
-def normalize_pkg(eco: str, name: str) -> str:
- """Normalize package names per ecosystem rules (PEP 503 for PyPI)."""
- if eco == "pypi":
- return re.sub(r"[-_.]+", "-", name).lower()
- if eco == "cargo":
- return name.lower()
- return name
-
-
-def _tag_stage(tag: str) -> int:
- if tag.startswith("post"):
- return 1
- if tag.startswith("dev"):
- return -4
- if tag in {"a", "alpha"}:
- return -3
- if tag in {"b", "beta"}:
- return -2
- return -1
-
-
-def version_key(
- ver: str,
-) -> tuple[tuple[int, ...], int, tuple[tuple[int, int, str], ...]]:
- """Order dev < alpha < beta < rc < final < post releases."""
- base = ver.split("+", 1)[0]
- nums: list[int] = []
- tail: list[tuple[int, int, str]] = []
- stage = 0
- in_tail = False
- for tok in re.split(r"[.-]", base):
- if not tok:
- continue
- if not in_tail and tok.isdigit():
- nums.append(int(tok))
- continue
- m = PRE_SEG_RE.match(tok) if not in_tail else None
- if m:
- nums.append(int(m.group(1)))
- tag = m.group(2).lower()
- in_tail = True
- stage = _tag_stage(tag)
- tail.append((0, 0, tag))
- if m.group(3):
- tail.append((1, int(m.group(3)), ""))
- continue
- low = tok.lower()
- if not in_tail:
- m2 = re.match(r"^([a-z]+)(\d+)$", low)
- if m2:
- stage = _tag_stage(m2.group(1))
- in_tail = True
- tail.append((0, 0, m2.group(1)))
- tail.append((1, int(m2.group(2)), ""))
- continue
- stage = _tag_stage(low)
- in_tail = True
- tail.append((1, int(tok), "") if tok.isdigit() else (0, 0, low))
- while len(nums) > 1 and nums[-1] == 0:
- nums.pop()
- return (tuple(nums), stage, tuple(tail))
-
-
-def _record_min(bucket: dict[str, str], name: str, ver: str) -> None:
- prev = bucket.get(name)
- if prev is None or version_key(ver) < version_key(prev):
- bucket[name] = ver
-
-
-def parse_workarounds(toml_text: str) -> list[dict[str, object]]:
- """Parse ``[[workaround]]`` tables from TOML text."""
- data = tomllib.loads(toml_text)
- raw = data.get("workaround", [])
- if not isinstance(raw, list):
- msg = "'workaround' must be an array of tables"
- raise TypeError(msg)
- return [dict(item) for item in raw if isinstance(item, dict)]
-
-
-def load_locks(repo_root: pathlib.Path) -> dict[str, dict[str, str]]:
- """Read minimum locked versions from uv, Cargo, pnpm, or npm lockfiles."""
- locks: dict[str, dict[str, str]] = {"pypi": {}, "cargo": {}, "npm": {}}
- uv_lock = repo_root / "uv.lock"
- if uv_lock.is_file():
- data = tomllib.loads(uv_lock.read_text(encoding="utf-8"))
- for pkg in data.get("package", []):
- if isinstance(pkg, dict) and "name" in pkg and "version" in pkg:
- _record_min(
- locks["pypi"],
- normalize_pkg("pypi", str(pkg["name"])),
- str(pkg["version"]),
- )
- cargo_lock = repo_root / "Cargo.lock"
- if cargo_lock.is_file():
- data = tomllib.loads(cargo_lock.read_text(encoding="utf-8"))
- for pkg in data.get("package", []):
- if isinstance(pkg, dict) and "name" in pkg and "version" in pkg:
- _record_min(
- locks["cargo"],
- normalize_pkg("cargo", str(pkg["name"])),
- str(pkg["version"]),
- )
- pnpm_lock = repo_root / "pnpm-lock.yaml"
- npm_lock = repo_root / "package-lock.json"
- if pnpm_lock.is_file():
- for m in PNPM_PKG_RE.finditer(pnpm_lock.read_text(encoding="utf-8")):
- _record_min(locks["npm"], m.group(1), m.group(2))
- elif npm_lock.is_file():
- ndata = json.loads(npm_lock.read_text(encoding="utf-8"))
- pkgs = ndata.get("packages", {})
- if isinstance(pkgs, dict):
- for k, info in pkgs.items():
- if (
- k.startswith("node_modules/")
- and isinstance(info, dict)
- and "version" in info
- ):
- pkg_name = k.rsplit("node_modules/", 1)[-1]
- _record_min(locks["npm"], pkg_name, str(info["version"]))
- else:
- pkg_json = repo_root / "package.json"
- if pkg_json.is_file():
- pdata = json.loads(pkg_json.read_text(encoding="utf-8"))
- for section in ("dependencies", "devDependencies"):
- deps = pdata.get(section, {})
- if isinstance(deps, dict):
- for name, spec in deps.items():
- spec_s = str(spec).strip()
- if EXACT_VER_RE.match(spec_s):
- _record_min(locks["npm"], str(name), spec_s)
- return locks
-
-
-def check_entries(
- entries: list[dict[str, object]],
- locks: dict[str, dict[str, str]],
- existing_paths: set[str] | None = None,
- file_texts: dict[str, str] | None = None,
-) -> list[dict[str, str]]:
- """Return violations for missing fields, decoy paths, or met predicates."""
- problems: list[dict[str, str]] = []
- for entry in entries:
- wid = str(entry.get("id") or "")
- rel_path = str(entry.get("path") or "")
- owner = str(entry.get("owner") or "")
- issue = str(entry.get("issue") or "")
- cond = str(entry.get("remove_when") or "")
- if not rel_path or not owner or not ISSUE_URL_RE.match(issue):
- problems.append(
- {
- "id": wid,
- "reason": (
- "requires path, owner, and full "
- "https:////[ issue URL"
- ),
- }
- )
- continue
- if (
- pathlib.Path(rel_path).suffix.lower() in DOC_SUFFIXES
- and entry.get("allow_doc_path") is not True
- ):
- problems.append(
- {
- "id": wid,
- "reason": (
- f"path '{rel_path}' points to documentation "
- "rather than source code"
- ),
- }
- )
- continue
- if existing_paths is not None and rel_path not in existing_paths:
- problems.append(
- {
- "id": wid,
- "reason": (
- f"path '{rel_path}' does not exist as a regular "
- "file inside repository"
- ),
- }
- )
- continue
- if file_texts is not None and rel_path in file_texts:
- src_txt = file_texts[rel_path]
- if wid not in src_txt and issue not in src_txt:
- problems.append(
- {
- "id": wid,
- "reason": (
- f"path '{rel_path}' contains neither "
- f"workaround id '{wid}' nor issue URL"
- ),
- }
- )
- continue
- if DATE_ONLY_RE.match(cond):
- problems.append(
- {
- "id": wid,
- "reason": (
- "calendar dates are not allowed in remove_when; "
- "use a lockfile predicate or issue_only = true"
- ),
- }
- )
- continue
- if not cond:
- in_locks = any(
- normalize_pkg(eco, owner) in locks.get(eco, {})
- for eco in ("pypi", "cargo", "npm")
- )
- if in_locks:
- problems.append(
- {
- "id": wid,
- "reason": (
- f"owner '{owner}' is present in lockfiles; "
- "specify remove_when instead of issue_only"
- ),
- }
- )
- continue
- if (
- entry.get("issue_only") is True
- and str(entry.get("reason_no_lock") or "").strip()
- ):
- continue
- problems.append(
- {
- "id": wid,
- "reason": (
- "missing remove_when (or issue_only = true with reason_no_lock)"
- ),
- }
- )
- continue
- m = COND_RE.match(cond)
- if not m:
- problems.append(
- {
- "id": wid,
- "reason": (
- f"invalid remove_when '{cond}'; "
- "expected ':>='"
- ),
- }
- )
- continue
- eco, pkg, target = m.group(1), m.group(2), m.group(3)
- norm_pkg = normalize_pkg(eco, pkg)
- locked = locks.get(eco, {}).get(norm_pkg)
- if locked is None:
- problems.append(
- {
- "id": wid,
- "reason": f"package '{pkg}' not found in {eco} lockfile",
- }
- )
- continue
- if version_key(locked) >= version_key(target):
- problems.append(
- {
- "id": wid,
- "reason": (
- f"condition met ({eco}:{pkg} is {locked} >= {target}); "
- "remove workaround"
- ),
- }
- )
- return problems
-
-
-def main(argv: list[str] | None = None) -> int:
- """Run the CLI check against the repository root and manifest path."""
- args = argv if argv is not None else sys.argv[1:]
- repo = pathlib.Path(args[0]).resolve() if args else pathlib.Path.cwd().resolve()
- manifest = (
- pathlib.Path(args[1]).resolve()
- if len(args) > 1
- else repo / ".github" / "workarounds.toml"
- )
- if not manifest.is_file():
- sys.stdout.write(f"{json.dumps({'ok': True, 'checked': 0, 'problems': []})}\n")
- return 0
- entries = parse_workarounds(manifest.read_text(encoding="utf-8"))
- existing: set[str] = set()
- texts: dict[str, str] = {}
- for entry in entries:
- raw_p = str(entry.get("path") or "")
- if not raw_p:
- continue
- cand = (repo / raw_p).resolve()
- if cand.is_relative_to(repo) and cand.is_file():
- existing.add(raw_p)
- texts[raw_p] = cand.read_text(encoding="utf-8", errors="replace")
- problems = check_entries(
- entries,
- load_locks(repo),
- existing_paths=existing,
- file_texts=texts,
- )
- payload = {"ok": not problems, "checked": len(entries), "problems": problems}
- sys.stdout.write(f"{json.dumps(payload)}\n")
- return 0 if not problems else 1
-
-
-if __name__ == "__main__":
- raise SystemExit(main())
diff --git a/tests/_docs_codeblocks.py b/tests/_docs_codeblocks.py
index 3bdcedaa..a204d748 100644
--- a/tests/_docs_codeblocks.py
+++ b/tests/_docs_codeblocks.py
@@ -56,7 +56,7 @@
{"list-commands", "list-commits", "show-config"}
)
_HEAVY_BENCHMARK_SUBCOMMANDS = frozenset({"run", "compare"})
-_READONLY_SCRIPTS = frozenset({"scripts/bench_vt.py", "scripts/check_workarounds.py"})
+_READONLY_SCRIPTS = frozenset({"scripts/bench_vt.py"})
_RECURSION_ENV_VAR = "LIBVT_DOCS_CODEBLOCK_ACTIVE"
_REPO_RELATIVE_HINTS = ("examples/", "docs/", "tests/", "scripts/")
]