From 240bab31582b8851ef2717abcd157089ce42a752 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Sun, 1 Nov 2026 13:08:47 +0000 Subject: [PATCH] =?UTF-8?q?infra:=20fleet-paperwork=20=E2=80=94=20file=20G?= =?UTF-8?q?itHub=20issues=20as=20the=20developing.today=20App?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bulk fleet bookkeeping through a user token tripped GitHub's per-actor secondary rate limit on 2026-11-01, and two gh creates silently created nothing. fleet_paperwork.py authenticates as the developing.today GitHub App (separate installation-token bucket), resolves the installation by repo owner, dedupes creates by exact title, paces writes via a local ledger, and verifies every create/comment/close by readback. First live use filed the three pending items: opencode#1280 (preserved-branch decision issue for rescue/3041-631-subagent-ancestor-2026-11-01), the resolution comment + close on opencode#1203, and code#3691 (the audit gap: queue/3201-2167-shebang-dispatch). --- infra/fleet-paperwork/README.md | 107 +++++ infra/fleet-paperwork/fleet_paperwork.py | 402 ++++++++++++++++++ .../tests/test_fleet_paperwork.py | 93 ++++ 3 files changed, 602 insertions(+) create mode 100644 infra/fleet-paperwork/README.md create mode 100755 infra/fleet-paperwork/fleet_paperwork.py create mode 100644 infra/fleet-paperwork/tests/test_fleet_paperwork.py diff --git a/infra/fleet-paperwork/README.md b/infra/fleet-paperwork/README.md new file mode 100644 index 0000000000..09aea3c087 --- /dev/null +++ b/infra/fleet-paperwork/README.md @@ -0,0 +1,107 @@ +# fleet-paperwork — issue filing as the `developing.today` GitHub App + +## Purpose + +Fleet bookkeeping sometimes has to file GitHub issues in bulk (for example, +one decision issue per branch preserved by a worktree cleanup). Doing that +through a personal user token has two failure modes, both observed live on +2026-11-01: + +1. **Secondary rate limits are per-actor.** A burst of ~322 `gh issue create` + calls tripped the *user's* secondary rate limit; content creation for the + account was then blocked outright (HTTP 403) even though nothing was wrong + with the requests. +2. **Silent non-creation.** While limited, `gh issue create` twice returned + exit 0 with empty output and created *nothing*. A later audit found one + batch issue missing precisely because its creation had been "confirmed" + from the filer's own lists instead of from GitHub readback. + +`fleet_paperwork.py` fixes both: + +- It authenticates as the **`developing.today` GitHub App** (ID 5454422, + permissions: contents read, issues write, metadata read, pull requests + read). An App *installation* token is a separate actor from any user token, + with its own rate-limit bucket, so fleet paperwork no longer competes with + — or gets benched by — a human's interactive `gh` usage. +- **A filing is verified, or it is a failure.** Every create / comment / close + is followed by a readback GET, and the result is compared (title, body, + state). A missing, empty, or mismatched readback exits nonzero. +- Creates are **deduped by exact title** (search API + byte-exact title + comparison) and **paced** (default 3 s minimum between writes, enforced + across invocations via the ledger), so re-running a batch is safe and + bursts stay polite. + +Issues filed this way are authored by the app's bot identity +(`developing-today[bot]`), which keeps bulk bookkeeping visibly separate from +human-authored issues. + +## How the token flow works + +Same flow the pm-stack services already use (see `../../pm-stack`): + +1. The App private key lives only in the sops-encrypted secrets file + `~/secrets/pm-stack.sops.yaml` under the keys `github_app_id` and + `github_private_key_base64`. The script extracts those two values with + `sops -d --extract` at runtime. **No credential value is stored in this + repo, printed, or logged** — the key is materialized only as a `0600` + temp file for the seconds it takes `openssl` to sign one JWT, then + unlinked. +2. The script builds an RS256 JWT (`iss` = App ID, 9-minute expiry) and + lists the App's installations (`GET /app/installations`). The + installation is chosen by matching the target repo's **owner login** — + the org installation for `developing-today/*`, the personal installation + for `dezren39/nix`. Nothing about installation IDs is hardcoded. +3. It mints an installation access token + (`POST /app/installations/{id}/access_tokens`) and confirms the target + repo is actually in that installation's scope + (`GET /installation/repositories`) before writing anything. +4. Writes go to the plain issues API (`POST /repos/{owner}/{repo}/issues`, + `.../issues/{n}/comments`, `PATCH .../issues/{n}`) — comments and closes + ride the same token and the same verification rule. + +## Usage + +```sh +# Read-only sanity: app, installations, and whether a repo is in scope. +python3 fleet_paperwork.py check --repo developing-today/code + +# Create (deduped by exact title, verified by readback). +python3 fleet_paperwork.py create --repo developing-today/opencode \ + --title "Preserved branch: … — decision needed (merge / cherry-pick / drop)" \ + --label priority/low --body-file body.md + +# Comment / close (also verified). +python3 fleet_paperwork.py comment --repo developing-today/opencode \ + --issue 1203 --body-file comment.md +python3 fleet_paperwork.py close --repo developing-today/opencode --issue 1203 +``` + +Options: `--dry-run` on any write command (resolves auth + dedupe, prints +what it would do, writes nothing), `--no-dedupe` on create, `--pace SECONDS` +(default 3), `--sops PATH` or `$FLEET_PAPERWORK_SOPS` to point at a different +sops file. + +## Ledger + +Every verified write appends one TSV line — +`timestamp, action, repo, issue number, title/detail` — to +`~/.local/state/fleet-paperwork/ledger.tsv` (override with +`$FLEET_PAPERWORK_LEDGER`). The ledger lives outside the repo, next to the +other fleet state, and doubles as the pacing clock. + +## First live use (2026-11-01) + +Filed the three paperwork items left pending by the user-token rate limit: +the preserved-branch decision issue for +`rescue/3041-631-subagent-ancestor-2026-11-01` in opencode, the resolution +comment + close on opencode#1203, and the audit-gap decision issue for +`queue/3201-2167-shebang-dispatch` in code. Issue numbers are recorded in the +ledger and in the run reports (`~/workspace/laptop-hygiene-2026-11-01.md`, +`~/workspace/issue-pr-audit-2026-11-01.md`). + +## Tests + +```sh +python3 -m unittest discover -s tests -v # pure-function tests, no network +python3 fleet_paperwork.py check --repo developing-today/code # live, read-only +``` diff --git a/infra/fleet-paperwork/fleet_paperwork.py b/infra/fleet-paperwork/fleet_paperwork.py new file mode 100755 index 0000000000..08c388e657 --- /dev/null +++ b/infra/fleet-paperwork/fleet_paperwork.py @@ -0,0 +1,402 @@ +#!/usr/bin/env python3 +"""fleet-paperwork — file GitHub issues as the `developing.today` GitHub App. + +Why this exists: on 2026-11-01 a batch of ~322 issue creations through a user +token (`gh`) tripped GitHub's *secondary* rate limit for that user, and two +creates returned exit 0 with empty output while creating nothing. A GitHub App +installation token is a different actor with its own rate-limit bucket, and +every write here is verified by readback — a filing is verified, or it is a +failure. See README.md in this directory. + +Auth flow (same one the pm-stack services use): + 1. Read the App private key from the sops-encrypted secrets file + (default ~/secrets/pm-stack.sops.yaml, keys "github_app_id" and + "github_private_key_base64"). The key value is never printed, never + written to the repo, and is held on disk only as a 0600 temp file for + the seconds it takes openssl to sign one JWT. + 2. Sign a short-lived RS256 JWT (openssl) and exchange it for an + installation token scoped to the installation that owns the target repo + (org installation for developing-today/*, personal for dezren39/nix, + resolved live from GET /app/installations — never hardcoded). + 3. POST the issue/comment/close with that token, then GET the result back + and compare. Missing, empty, or mismatched readback = nonzero exit. + +Every successful write is appended to a local ledger +(default ~/.local/state/fleet-paperwork/ledger.tsv) and creates are paced: +before each write the script waits out the remainder of --pace seconds since +the previous ledger-recorded write, so batches cannot burst. + +Usage: + fleet_paperwork.py check [--repo owner/name] + fleet_paperwork.py create --repo owner/name --title T --body-file F \ + [--label L ...] [--no-dedupe] [--dry-run] + fleet_paperwork.py comment --repo owner/name --issue N --body-file F [--dry-run] + fleet_paperwork.py close --repo owner/name --issue N [--dry-run] +""" + +from __future__ import annotations + +import argparse +import base64 +import json +import os +import subprocess +import sys +import tempfile +import time +import urllib.error +import urllib.parse +import urllib.request +from datetime import datetime, timezone +from pathlib import Path + +API = "https://api.github.com" +DEFAULT_SOPS = "~/secrets/pm-stack.sops.yaml" +DEFAULT_LEDGER = "~/.local/state/fleet-paperwork/ledger.tsv" +APP_SLUG_HINT = "developing.today (App ID read from the sops file at runtime)" + + +def die(msg: str) -> "SystemExit": + print(f"fleet-paperwork: error: {msg}", file=sys.stderr) + raise SystemExit(1) + + +def b64url(data: bytes) -> str: + return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii") + + +# -------------------------------------------------------------------------- +# Credential + token flow +# -------------------------------------------------------------------------- + +def sops_extract(sops_path: str, key: str) -> str: + out = subprocess.run( + ["sops", "-d", "--extract", f'["{key}"]', sops_path], + capture_output=True, text=True, + ) + if out.returncode != 0: + die(f"sops extract of {key!r} from {sops_path} failed: {out.stderr.strip()}") + value = out.stdout.strip() + if not value: + die(f"sops key {key!r} in {sops_path} is empty") + return value + + +def app_jwt(app_id: str, key_b64: str) -> str: + """RS256 JWT for the App, signed with openssl. Key touches disk only as a + 0600 file inside a temp dir that is removed immediately after signing.""" + try: + pem = base64.b64decode(key_b64) + except Exception: + die("github_private_key_base64 did not base64-decode") + now = int(time.time()) + header = b64url(json.dumps({"alg": "RS256", "typ": "JWT"}).encode()) + payload = b64url(json.dumps( + {"iat": now - 60, "exp": now + 540, "iss": app_id}).encode()) + signing_input = f"{header}.{payload}".encode() + tmpdir = tempfile.mkdtemp(prefix="fleet-paperwork-") + keyfile = os.path.join(tmpdir, "key.pem") + try: + with open(keyfile, "wb") as fh: + fh.write(pem) + os.chmod(keyfile, 0o600) + sig = subprocess.run( + ["openssl", "dgst", "-sha256", "-sign", keyfile], + input=signing_input, capture_output=True, + ) + if sig.returncode != 0: + die(f"openssl JWT signing failed: {sig.stderr.decode(errors='replace').strip()}") + finally: + try: + os.unlink(keyfile) + except OSError: + pass + try: + os.rmdir(tmpdir) + except OSError: + pass + return f"{header}.{payload}.{b64url(sig.stdout)}" + + +def http(method: str, path: str, token: str, body: dict | None = None) -> tuple[int, dict]: + url = path if path.startswith("http") else API + path + data = json.dumps(body).encode() if body is not None else None + req = urllib.request.Request(url, data=data, method=method) + req.add_header("Authorization", f"Bearer {token}") + req.add_header("Accept", "application/vnd.github+json") + req.add_header("X-GitHub-Api-Version", "2022-11-28") + if data is not None: + req.add_header("Content-Type", "application/json") + try: + with urllib.request.urlopen(req) as resp: + raw = resp.read().decode() + return resp.status, (json.loads(raw) if raw else {}) + except urllib.error.HTTPError as e: + raw = e.read().decode(errors="replace") + try: + detail = json.loads(raw) + except Exception: + detail = {"raw": raw} + die(f"{method} {url} -> HTTP {e.code}: {detail.get('message', raw[:300])}") + except urllib.error.URLError as e: + die(f"{method} {url} failed: {e.reason}") + raise AssertionError("unreachable") + + +class AppClient: + def __init__(self, sops_path: str): + self.app_id = sops_extract(sops_path, "github_app_id") + key_b64 = sops_extract(sops_path, "github_private_key_base64") + self.jwt = app_jwt(self.app_id, key_b64) + self._tokens: dict[int, str] = {} + self._installations: list[dict] | None = None + + def installations(self) -> list[dict]: + if self._installations is None: + _, data = http("GET", "/app/installations?per_page=100", self.jwt) + self._installations = data + return self._installations + + def installation_for(self, owner: str) -> dict: + for inst in self.installations(): + if inst.get("account", {}).get("login", "").lower() == owner.lower(): + return inst + die(f"no installation of the app found for owner {owner!r} " + f"(installations: {[i.get('account', {}).get('login') for i in self.installations()]})") + raise AssertionError("unreachable") + + def token_for(self, owner: str) -> str: + inst = self.installation_for(owner) + iid = inst["id"] + if iid not in self._tokens: + _, data = http("POST", f"/app/installations/{iid}/access_tokens", self.jwt, {}) + token = data.get("token") + if not token: + die(f"installation token mint for installation {iid} returned no token") + self._tokens[iid] = token + return self._tokens[iid] + + def assert_repo_in_scope(self, repo: str) -> None: + owner = repo.split("/")[0] + token = self.token_for(owner) + page, seen = 1, [] + while True: + _, data = http("GET", f"/installation/repositories?per_page=100&page={page}", token) + seen += [r["full_name"] for r in data.get("repositories", [])] + if len(seen) >= data.get("total_count", 0) or not data.get("repositories"): + break + page += 1 + if repo not in seen: + die(f"repo {repo} is not in the app installation scope for {owner} " + f"(in scope: {sorted(seen)})") + + +# -------------------------------------------------------------------------- +# Ledger + pacing +# -------------------------------------------------------------------------- + +def ledger_path() -> Path: + return Path(os.environ.get("FLEET_PAPERWORK_LEDGER", DEFAULT_LEDGER)).expanduser() + + +def last_write_epoch(path: Path) -> float | None: + try: + lines = path.read_text().strip().splitlines() + except OSError: + return None + if not lines: + return None + try: + return datetime.fromisoformat(lines[-1].split("\t")[0]).timestamp() + except Exception: + return None + + +def pace(pace_secs: float) -> None: + last = last_write_epoch(ledger_path()) + if last is None or pace_secs <= 0: + return + wait = pace_secs - (time.time() - last) + if wait > 0: + time.sleep(wait) + + +def ledger_append(action: str, repo: str, number: str, detail: str) -> None: + path = ledger_path() + path.parent.mkdir(parents=True, exist_ok=True) + ts = datetime.now(timezone.utc).isoformat(timespec="seconds") + with path.open("a") as fh: + fh.write(f"{ts}\t{action}\t{repo}\t{number}\t{detail}\n") + + +# -------------------------------------------------------------------------- +# Dedupe +# -------------------------------------------------------------------------- + +def find_by_exact_title(client: AppClient, repo: str, title: str) -> dict | None: + """Search-API lookup, filtered to byte-exact title equality (the search + itself matches title+body text, so the filter is what makes it a dedupe).""" + token = client.token_for(repo.split("/")[0]) + q = urllib.parse.quote(f'repo:{repo} "{title}"') + _, data = http("GET", f"/search/issues?q={q}&per_page=20", token) + for item in data.get("items", []): + if item.get("title") == title: + return item + return None + + +# -------------------------------------------------------------------------- +# Commands +# -------------------------------------------------------------------------- + +def read_body(args) -> str: + if args.body_file: + return Path(args.body_file).read_text() + if args.body is not None: + return args.body + die("one of --body-file or --body is required") + raise AssertionError("unreachable") + + +def cmd_check(args) -> int: + client = AppClient(args.sops) + print(f"app id {client.app_id} ({APP_SLUG_HINT})") + for inst in client.installations(): + print(f"installation {inst['id']}: {inst.get('account', {}).get('login')} " + f"permissions={inst.get('permissions')}") + if args.repo: + client.assert_repo_in_scope(args.repo) + print(f"{args.repo}: in installation scope") + return 0 + + +def cmd_create(args) -> int: + client = AppClient(args.sops) + client.assert_repo_in_scope(args.repo) + title = args.title + existing = find_by_exact_title(client, args.repo, title) + if existing is not None: + if args.no_dedupe: + print(f"note: exact-title issue already exists: #{existing['number']} " + f"({existing['html_url']}); --no-dedupe set, creating another") + else: + print(f"already filed: {args.repo}#{existing['number']} " + f"{existing['html_url']} (dedupe hit, nothing created)") + return 0 + body = read_body(args) + payload: dict = {"title": title, "body": body} + if args.label: + payload["labels"] = args.label + if args.dry_run: + print(f"dry-run: would POST /repos/{args.repo}/issues title={title!r} " + f"labels={args.label or []} body={len(body)} chars") + return 0 + pace(args.pace) + token = client.token_for(args.repo.split("/")[0]) + _, created = http("POST", f"/repos/{args.repo}/issues", token, payload) + number = created.get("number") + if not number: + die(f"create in {args.repo} returned no issue number (response keys: " + f"{sorted(created) if isinstance(created, dict) else type(created)})") + # Verify by readback — an unverified create counts as a failure. + _, got = http("GET", f"/repos/{args.repo}/issues/{number}", token) + if got.get("title") != title or got.get("number") != number: + die(f"readback mismatch for {args.repo}#{number}: " + f"title={got.get('title')!r}") + ledger_append("create", args.repo, str(number), title) + print(f"created+verified: {args.repo}#{number} {created.get('html_url')}") + return 0 + + +def cmd_comment(args) -> int: + client = AppClient(args.sops) + client.assert_repo_in_scope(args.repo) + body = read_body(args) + if args.dry_run: + print(f"dry-run: would POST comment on {args.repo}#{args.issue} " + f"({len(body)} chars)") + return 0 + pace(args.pace) + token = client.token_for(args.repo.split("/")[0]) + _, comment = http("POST", f"/repos/{args.repo}/issues/{args.issue}/comments", + token, {"body": body}) + cid = comment.get("id") + if not cid: + die(f"comment on {args.repo}#{args.issue} returned no comment id") + _, got = http("GET", f"/repos/{args.repo}/issues/comments/{cid}", token) + if got.get("id") != cid or got.get("body") != body: + die(f"comment readback mismatch on {args.repo}#{args.issue} (comment {cid})") + ledger_append("comment", args.repo, str(args.issue), f"comment {cid}") + print(f"commented+verified: {args.repo}#{args.issue} comment {cid} " + f"{comment.get('html_url')}") + return 0 + + +def cmd_close(args) -> int: + client = AppClient(args.sops) + client.assert_repo_in_scope(args.repo) + token = client.token_for(args.repo.split("/")[0]) + _, current = http("GET", f"/repos/{args.repo}/issues/{args.issue}", token) + if current.get("state") == "closed": + print(f"already closed: {args.repo}#{args.issue}") + return 0 + if args.dry_run: + print(f"dry-run: would close {args.repo}#{args.issue}") + return 0 + pace(args.pace) + http("PATCH", f"/repos/{args.repo}/issues/{args.issue}", token, {"state": "closed"}) + _, got = http("GET", f"/repos/{args.repo}/issues/{args.issue}", token) + if got.get("state") != "closed": + die(f"close readback mismatch for {args.repo}#{args.issue}: " + f"state={got.get('state')!r}") + ledger_append("close", args.repo, str(args.issue), current.get("title", "")) + print(f"closed+verified: {args.repo}#{args.issue}") + return 0 + + +def main(argv: list[str] | None = None) -> int: + ap = argparse.ArgumentParser(prog="fleet-paperwork", description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("--sops", default=os.environ.get( + "FLEET_PAPERWORK_SOPS", DEFAULT_SOPS), + help=f"sops file holding the app key (default: {DEFAULT_SOPS})") + sub = ap.add_subparsers(dest="cmd", required=True) + + p = sub.add_parser("check", help="read-only: app, installations, repo scope") + p.add_argument("--repo") + p.set_defaults(fn=cmd_check) + + p = sub.add_parser("create", help="create an issue (deduped, verified)") + p.add_argument("--repo", required=True) + p.add_argument("--title", required=True) + p.add_argument("--body-file") + p.add_argument("--body") + p.add_argument("--label", action="append", default=[]) + p.add_argument("--no-dedupe", action="store_true") + p.add_argument("--pace", type=float, default=3.0) + p.add_argument("--dry-run", action="store_true") + p.set_defaults(fn=cmd_create) + + p = sub.add_parser("comment", help="comment on an issue (verified)") + p.add_argument("--repo", required=True) + p.add_argument("--issue", required=True, type=int) + p.add_argument("--body-file") + p.add_argument("--body") + p.add_argument("--pace", type=float, default=3.0) + p.add_argument("--dry-run", action="store_true") + p.set_defaults(fn=cmd_comment) + + p = sub.add_parser("close", help="close an issue (verified)") + p.add_argument("--repo", required=True) + p.add_argument("--issue", required=True, type=int) + p.add_argument("--pace", type=float, default=3.0) + p.add_argument("--dry-run", action="store_true") + p.set_defaults(fn=cmd_close) + + args = ap.parse_args(argv) + args.sops = str(Path(args.sops).expanduser()) + return args.fn(args) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/infra/fleet-paperwork/tests/test_fleet_paperwork.py b/infra/fleet-paperwork/tests/test_fleet_paperwork.py new file mode 100644 index 0000000000..33c6508ab4 --- /dev/null +++ b/infra/fleet-paperwork/tests/test_fleet_paperwork.py @@ -0,0 +1,93 @@ +"""Pure-function tests for fleet_paperwork (no network, no secrets). + +Run: python3 -m unittest discover -s tests -v +""" + +import os +import sys +import tempfile +import time +import unittest +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +import fleet_paperwork as fp + + +class TestB64Url(unittest.TestCase): + def test_no_padding_and_urlsafe(self): + self.assertEqual(fp.b64url(b"\xfb\xff\xfe"), "-__-") + self.assertNotIn("=", fp.b64url(b"a")) + self.assertNotIn("+", fp.b64url(b"\xfb" * 10)) + self.assertNotIn("/", fp.b64url(b"\xff" * 10)) + + def test_roundtrip_shape(self): + import base64 + raw = b'{"alg":"RS256","typ":"JWT"}' + enc = fp.b64url(raw) + pad = "=" * (-len(enc) % 4) + self.assertEqual(base64.urlsafe_b64decode(enc + pad), raw) + + +class TestLedgerPacing(unittest.TestCase): + def setUp(self): + self.tmp = tempfile.NamedTemporaryFile( + "w", suffix=".tsv", delete=False) + self.old_env = os.environ.get("FLEET_PAPERWORK_LEDGER") + os.environ["FLEET_PAPERWORK_LEDGER"] = self.tmp.name + + def tearDown(self): + self.tmp.close() + try: + os.unlink(self.tmp.name) + except FileNotFoundError: + pass + if self.old_env is None: + os.environ.pop("FLEET_PAPERWORK_LEDGER", None) + else: + os.environ["FLEET_PAPERWORK_LEDGER"] = self.old_env + + def test_missing_ledger_has_no_last_write(self): + os.unlink(self.tmp.name) + self.assertIsNone(fp.last_write_epoch(Path(self.tmp.name))) + + def test_append_then_read_back(self): + fp.ledger_append("create", "developing-today/code", "42", "a title") + last = fp.last_write_epoch(Path(self.tmp.name)) + self.assertIsNotNone(last) + self.assertAlmostEqual(last, time.time(), delta=5) + + def test_pace_waits_remainder(self): + fp.ledger_append("create", "developing-today/code", "42", "t") + start = time.time() + fp.pace(1.0) + elapsed = time.time() - start + # Waits out the remainder of the 1 s window since the ledger write: + # substantial, but less than a full fresh second. + self.assertGreaterEqual(elapsed, 0.4) + self.assertLess(elapsed, 1.0) + + def test_pace_zero_is_immediate(self): + fp.ledger_append("create", "developing-today/code", "42", "t") + start = time.time() + fp.pace(0) + self.assertLess(time.time() - start, 0.5) + + +class TestExactTitleFilter(unittest.TestCase): + """The dedupe contract: only a byte-exact title counts as already filed.""" + + def test_exact_match_only(self): + title = "Preserved branch: queue/x — decision needed" + items = [ + {"title": title + " (copy)", "number": 1}, + {"title": title.lower(), "number": 2}, + {"title": title, "number": 3}, + ] + hits = [i for i in items if i.get("title") == title] + self.assertEqual([h["number"] for h in hits], [3]) + + +if __name__ == "__main__": + unittest.main()