diff --git a/adapters/AGENTS.md b/adapters/AGENTS.md index deaa09957..58dc2b291 100644 --- a/adapters/AGENTS.md +++ b/adapters/AGENTS.md @@ -2,11 +2,11 @@ All of the Factory's I/O. `github.py` is the one transport: every request to GitHub goes through it, and nothing else in this repo reaches the network. `pull.py` reads the facts of a pull request that its own reads give, `timeline.py` its reviews, labels and who acted, -`checks.py` its checks and its place in the queue, `facts.py` the one snapshot of it all, `records.py` the Factory's own run records, -and `artifacts.py` a failed Run's outcome from its artifact. A port decides nothing +`checks.py` its checks and its place in the queue, `threads.py` its review threads, `facts.py` the one snapshot of it all, +`records.py` the Factory's own run records, and `artifacts.py` a failed Run's outcome from its artifact. A port decides nothing and hands the Kernel no text: what it cannot read whole it says is short, and the title travels beside the facts. -Not built yet, by the stories that hold their rules: threads.py, items.py, acceptance.py, issues.py, settings.py, effects.py, usage.py. +Not built yet, by the stories that hold their rules: items.py, acceptance.py, issues.py, settings.py, effects.py, usage.py. | Rule | Held by | |---|---| @@ -26,6 +26,9 @@ Not built yet, by the stories that hold their rules: threads.py, items.py, accep | A run counts only as a dispatch of a Role's workflow from this repo's default branch; its name says whose it is | `tests/test_adapters.py::test_only_a_dispatch_of_a_role_workflow_from_the_default_branch_in_this_repo_counts` | | A counted run not yet named is reported by its id after one more read 5 s later, and every read of runs is uncached | `tests/test_adapters.py::test_a_run_listed_under_its_workflows_name_is_unidentified_after_one_more_read` | | Write access is a person's alone, read from the collaborator permission, admin, maintain or write, once a login | `tests/test_adapters.py::test_an_actor_is_told_by_its_account_type_and_the_configuration` | +| Each review thread is read with who opened and resolved it, told by account; a person's is `human`, and no comment's text is read | `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human` | +| A thread is a Lens's only when its author is that Lens's own App; only a required model Lens's open thread with no category defers | `tests/test_adapters.py::test_only_a_required_lenss_own_apps_open_thread_defers` | +| Threads are whole only when every one counted was read, once, and no cursor repeats | `tests/test_adapters.py::test_threads_are_read_page_by_page_and_whole_only_when_every_one_was_read_once` | | A review's dismissal, its dismisser and its state before are read from the timeline; no text of GitHub's is kept | `tests/test_adapters.py::test_reviews_are_read_with_their_commit_content_and_who_dismissed_them` | | Every check run on the head is given with its exact name, its App and its workflow file, and none dropped | `tests/test_adapters.py::test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow` | | The snapshot is refused when the pull request moved while it was read, and is held to `facts/1` | `tests/test_adapters.py::test_a_snapshot_whose_head_moved_while_it_was_read_is_refused` | diff --git a/adapters/checks.py b/adapters/checks.py index 446503968..e1e65d9f8 100644 --- a/adapters/checks.py +++ b/adapters/checks.py @@ -1,5 +1,5 @@ -"""The checks on a pull request's head, its place in the merge queue, and how many review threads it holds, in one -GraphQL read of the head's status rollup (design section 3.3; P-32's read gives the shape). +"""The checks on a pull request's head and its place in the merge queue, in one GraphQL read of the head's status +rollup (design section 3.3; P-32's read gives the shape). Every check run the head's rollup lists is given with its name exactly as GitHub gives it, the id of the App that reported it, the path of the workflow file that ran it, null where GitHub names none, its conclusion, or its status @@ -12,8 +12,6 @@ short. Whether the pull request is in the merge queue is its entry, an object, or null: any other shape is refused. A rollup of another commit than the head is refused, and so is one read while the pull request's head moved. -A thread's resolved state and its Finding's category are `adapters/threads.py`'s, not built: here only their count is -read, so that a pull request with no thread is read whole and one with any is not. """ from __future__ import annotations @@ -29,7 +27,6 @@ pullRequest(number: $number) { headRefOid mergeQueueEntry { position } - reviewThreads(first: 1) { totalCount } commits(last: 1) { nodes { commit { @@ -82,9 +79,9 @@ def check(node: dict) -> dict: def read(transport, pull: dict) -> dict: """The head's check runs and whether they were read whole, whether the pull request is in the merge queue, and - how many review threads it holds; every page is of the head the pull request's first read named.""" + every page is of the head the pull request's first read named.""" owner, name = pull["base"]["repo"]["full_name"].split("/") - found, after, queue, threads, seen, total, ids, cursors = [], None, None, None, 0, None, [], set() + found, after, queue, seen, total, ids, cursors = [], None, None, 0, None, [], set() while True: variables = {"owner": owner, "name": name, "number": pull["number"], "after": after} answer = transport.send(request("POST", "/graphql", body={"query": QUERY, "variables": variables})) @@ -97,20 +94,17 @@ def read(transport, pull: dict) -> dict: raise Unanswered("the checks were read of another commit than the head") if pr.get("headRefOid") != pull["head"]["sha"]: raise Unanswered("the pull request's head moved while its checks were read") - count = (pr.get("reviewThreads") or {}).get("totalCount") if isinstance(pr.get("reviewThreads"), dict) else None - if not isinstance(count, int) or isinstance(count, bool) or count < 0: - raise Unanswered("the count of review threads cannot be read") entry = pr.get("mergeQueueEntry", False) if not (entry is None or isinstance(entry, dict)): raise Unanswered("the pull request's place in the merge queue cannot be read") - queue, threads = entry is not None, count + queue = entry is not None rollup = commit.get("statusCheckRollup") if rollup is None: - return {"checks": found, "complete": after is None, "queue": queue, "threads": threads} + return {"checks": found, "complete": after is None, "queue": queue} contexts = rollup.get("contexts") if isinstance(rollup, dict) else None page = (contexts or {}).get("pageInfo") if isinstance(contexts, dict) else None if not isinstance(contexts, dict) or not isinstance(contexts.get("nodes"), list) or not isinstance(page, dict): - return {"checks": found, "complete": False, "queue": queue, "threads": threads} + return {"checks": found, "complete": False, "queue": queue} counted = contexts.get("totalCount") total = counted if total is None else total for node in contexts["nodes"]: @@ -126,10 +120,10 @@ def read(transport, pull: dict) -> dict: whole = isinstance(total, int) and not isinstance(total, bool) and counted == total and seen == total if after is not None: whole = whole and all(isinstance(i, str) and i for i in ids) and len(set(ids)) == len(ids) - return {"checks": found, "complete": whole, "queue": queue, "threads": threads} + return {"checks": found, "complete": whole, "queue": queue} if page.get("hasNextPage") is not True or not isinstance(page.get("endCursor"), str) or not page["endCursor"]: - return {"checks": found, "complete": False, "queue": queue, "threads": threads} + return {"checks": found, "complete": False, "queue": queue} if page["endCursor"] in cursors or not isinstance(total, int) or isinstance(total, bool) or seen >= total: - return {"checks": found, "complete": False, "queue": queue, "threads": threads} + return {"checks": found, "complete": False, "queue": queue} cursors.add(page["endCursor"]) after = page["endCursor"] diff --git a/adapters/facts.py b/adapters/facts.py index 37717dd90..37466387d 100644 --- a/adapters/facts.py +++ b/adapters/facts.py @@ -8,9 +8,9 @@ may be of the commit between (the known limit; pinning them is still to be built). A part that cannot be read refuses the whole; a list that was not read whole says so in its `complete` flag, and the Kernel defers on it. -Two parts are not read yet, and say so: a thread's state and its Finding's category wait on `adapters/threads.py`, so -`threads` is whole only when the pull request holds none; and the acceptance contract waits on -`adapters/acceptance.py`, so `acceptance` is null and never read whole. The run records are the records port's, read +One part is not read yet, and says so: the acceptance contract waits on `adapters/acceptance.py`, so `acceptance` is +null and never read whole. A Lens's thread has no category or severity until `harness/` uploads the Finding records they +are joined from (`adapters/threads.py`). The run records are the records port's, read once a pass: the caller says whether that read was whole. `read_at` is taken after the last read, never given by the caller. `last_push_at` is the push's own time where the head @@ -25,7 +25,7 @@ import json import pathlib -from adapters import checks, pull, timeline +from adapters import checks, pull, threads, timeline from adapters.github import Unanswered from tools.jsonschema_lite import validate @@ -52,6 +52,7 @@ def snapshot(transport, repo: str, number: int, identities: dict, accounts: time writer = timeline.since_writer(events, accounts) labels = timeline.label_events(events, accounts) read = checks.read(transport, first) + found, threads_whole = threads.read(transport, first, accounts) if pusher is not None and pushed_at is None: raise Unanswered("the head's push names its pusher but no time that can be read") if not pull.unchanged(transport, first): @@ -69,12 +70,12 @@ def snapshot(transport, repo: str, number: int, identities: dict, accounts: time "last_push_at": pushed_at or now, "last_writer_action_at": writer["last_writer_action_at"], "reviews": reviews, - "threads": [], + "threads": found, "checks": read["checks"], "queue": read["queue"], "acts_since_writer": writer["acts_since_writer"], "acceptance": None, - "complete": {"acceptance": False, "reviews": reviews_whole, "threads": read["threads"] == 0, + "complete": {"acceptance": False, "reviews": reviews_whole, "threads": threads_whole, "checks": read["complete"], "diff": content["complete"], "changed_paths": paths["complete"], "runs": runs_whole is True, "timeline": timeline_whole}, "read_at": now, diff --git a/adapters/threads.py b/adapters/threads.py new file mode 100644 index 000000000..2b1b31662 --- /dev/null +++ b/adapters/threads.py @@ -0,0 +1,117 @@ +"""A pull request's review threads, as `facts/1` holds them: each thread's id, whether it is resolved and by whom, and +who opened it and when, with its Finding's category and severity where the facts can give them (design section 3.3). + +One GraphQL read of the threads, page by page. Who opened a thread is its first comment's author, and when, that +comment's time: a first comment that replies to another is not the opener's, and the thread is refused. Who resolved +it is GitHub's `resolvedBy`, which is typed a User: a resolved thread GitHub names no resolver for, as it is taken to +when an App resolved it or the account is gone, has `resolved_by` null, and the Kernel defers on that thread alone +(`unreadable_thread`). No trial has recorded either yet. Each actor is told by its account id and type, +never by a name's spelling (decision 0005, L-57), and its write access read once a login, as `adapters/timeline.py` +does. No comment's text is read. A thread whose opener GitHub no longer names, a deleted account's, is refused with the +snapshot, as an unreadable actor is anywhere: the known cost is that such a pull request is never read whole. A thread +deleted and another made between two pages leaves the count the same and one unread, as the rollup can. + +A thread a person opened is `human`, with no severity (section 3.3). Any other thread, a Lens's among them, has neither: +a required Lens's category and severity come from its own Finding record, in its Run's `applied/1`, joined by +`surface.key` (decision 0038), and no Run uploads one until `harness/` builds `apply`. A thread is a Lens's only when +its author is that Lens's own App, by account id and type, as the caller names it: an outside reviewer's, CodeRabbit's +or Codex's, is no required Lens's, and gates nothing. The Kernel reads a required model Lens's own App's open thread +with neither as unreadable, and defers on it alone (`kernel/derive.py`'s `unreadable_thread`). + +The list is whole only when its last page says there is no next one, every thread it counts was read, and none twice; +a cursor that repeats, or a next page past the count, ends the read short, as `adapters/checks.py` does for the rollup. +""" +from __future__ import annotations + +import re + +from adapters import timeline +from adapters.github import Unanswered, request + +PAGE = 100 +TIME = re.compile(r"[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]Z") +QUERY = """query FactsThreads($owner: String!, $name: String!, $number: Int!, $after: String) { + repository(owner: $owner, name: $name) { + pullRequest(number: $number) { + reviewThreads(first: %d, after: $after) { + totalCount + pageInfo { hasNextPage endCursor } + nodes { + id isResolved + resolvedBy { login databaseId } + comments(first: 1) { + nodes { + createdAt + replyTo { id } + author { __typename login ... on User { databaseId } ... on Bot { databaseId } } + } + } + } + } + } + } +}""" % PAGE + + +def _account(author, kind=None): + """A GraphQL actor as the REST user object `timeline.Accounts` reads: its login, its id and its type.""" + if not isinstance(author, dict): + raise Unanswered("a thread's actor cannot be read") + kind = kind or author.get("__typename") + return {"login": author.get("login"), "id": author.get("databaseId"), "type": kind} + + +def thread(node: dict, accounts: timeline.Accounts) -> dict: + """One thread as `facts/1` holds it; refused when any part GitHub gives cannot be read.""" + ident, resolved = node.get("id"), node.get("isResolved") + comments = node.get("comments") if isinstance(node.get("comments"), dict) else {} + first = comments.get("nodes") if isinstance(comments.get("nodes"), list) else None + if not isinstance(ident, str) or not ident or type(resolved) is not bool or not first \ + or not isinstance(first[0], dict): + raise Unanswered("a review thread's id, state or first comment cannot be read") + if first[0].get("replyTo") is not None: + raise Unanswered("a review thread's first comment replies to another: its opener cannot be read") + opened_at = first[0].get("createdAt") + if not (isinstance(opened_at, str) and TIME.fullmatch(opened_at)): + raise Unanswered("a review thread's time cannot be read") + opened_by = accounts.actor(_account(first[0].get("author"))) + by = node.get("resolvedBy") + if not resolved and by is not None: + raise Unanswered("an open review thread that names who resolved it") + resolved_by = accounts.actor(_account(by, "User")) if by is not None else None + human = opened_by["kind"] == "human" + return {"id": ident, "resolved": resolved, "opened_by": opened_by, "category": "human" if human else None, + "severity": None, "resolved_by": resolved_by, "opened_at": opened_at} + + +def read(transport, pull: dict, accounts: timeline.Accounts) -> tuple: + """Every review thread of the pull request, and whether they were read whole.""" + owner, name = pull["base"]["repo"]["full_name"].split("/") + found, after, total, ids, cursors = [], None, None, [], set() + while True: + variables = {"owner": owner, "name": name, "number": pull["number"], "after": after} + answer = transport.send(request("POST", "/graphql", body={"query": QUERY, "variables": variables})) + if answer["status"] != 200 or not isinstance(answer["body"], dict) or answer["body"].get("errors"): + raise Unanswered("the threads' read answered %d" % answer["status"]) + pr = (((answer["body"].get("data") or {}).get("repository") or {}).get("pullRequest")) or {} + listed = pr.get("reviewThreads") + page = listed.get("pageInfo") if isinstance(listed, dict) else None + if not isinstance(listed, dict) or not isinstance(listed.get("nodes"), list) or not isinstance(page, dict): + return found, False + counted = listed.get("totalCount") + total = counted if total is None else total + if not isinstance(total, int) or isinstance(total, bool) or counted != total: + return found, False + for node in listed["nodes"]: + if not isinstance(node, dict): + raise Unanswered("a review thread is not one GitHub gives") + found.append(thread(node, accounts)) + ids.append(found[-1]["id"]) + if page.get("hasNextPage") is False: + return found, len(ids) == total and len(set(ids)) == len(ids) + cursor = page.get("endCursor") + if page.get("hasNextPage") is not True or not isinstance(cursor, str) or not cursor or cursor in cursors \ + or len(ids) >= total: + return found, False + cursors.add(cursor) + after = cursor diff --git a/docs/decisions/0005-each-role-writes-through-its-own-app.md b/docs/decisions/0005-each-role-writes-through-its-own-app.md index 5304d2bb3..24a79a42f 100644 --- a/docs/decisions/0005-each-role-writes-through-its-own-app.md +++ b/docs/decisions/0005-each-role-writes-through-its-own-app.md @@ -28,7 +28,7 @@ GitHub does not count an approval from an author or a last pusher, so the approv | In the simulator, on one seed in nine and under faults, the push that left the head is now and then missing from the branch's activity and the last pusher reads null: that pass approves, enqueues and admits nothing, and a dequeue on it is refused by `apply` once the entry is there | `tests/test_simulator.py::test_the_seeds_read_a_push_missing_from_the_activity` | | Every actor in the facts has a kind: a person (`human`), a Lens's App (`lens`), any other App (`app`), or the machine user (`machine_user`). One whose kind cannot be read defers for the Maintainer, and takes a queued item out | `tests/test_decide.py::test_an_actor_whose_kind_cannot_be_read_defers`, `examples/invalid/facts.an-actor-without-its-kind.json`, `examples/invalid/facts.an-actor-of-a-kind-the-kernel-does-not-know.json` | | The machine user is the approver the configuration names, and nobody else is; an agent's or a dependency update's author is an App. Facts that say otherwise cannot be read | `tests/test_decide.py::test_the_approver_or_an_author_bot_read_as_another_kind_cannot_be_read` | -| The port tells a person, a Lens's App, any other App and the machine user apart from GitHub's account type and the configuration, never from a name's spelling | `tests/test_adapters.py::test_the_class_is_the_account_named_or_outside`, `tests/test_adapters.py::test_an_actor_is_told_by_its_account_type_and_the_configuration`; a thread's accounts are waiting on `adapters/threads.py` | +| The port tells a person, a Lens's App, any other App and the machine user apart from GitHub's account type and the configuration, never from a name's spelling | `tests/test_adapters.py::test_the_class_is_the_account_named_or_outside`, `tests/test_adapters.py::test_an_actor_is_told_by_its_account_type_and_the_configuration`, `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`; a thread's shape as GitHub gives it is not held yet: `tests/test_adapters.py::test_a_thread_a_trial_recorded_is_read_as_the_port_reads_it` | | A person whose login ends in `[bot]` cannot be read: a name's spelling only ever refuses an actor | `tests/test_decide.py::test_a_person_whose_login_is_a_bots_is_unreadable` | | Only the machine user's approval stands, and only while it has write access | `tests/test_decide.py::test_only_the_approvers_approval_stands` | | No Role owns or shadows a category of Finding about its own work | `tools/check_authority.py` | diff --git a/docs/decisions/0015-a-lens-is-read-from-its-own-app-and-only-what-gates-holds-a-merge.md b/docs/decisions/0015-a-lens-is-read-from-its-own-app-and-only-what-gates-holds-a-merge.md index abd43e442..e81ca7a95 100644 --- a/docs/decisions/0015-a-lens-is-read-from-its-own-app-and-only-what-gates-holds-a-merge.md +++ b/docs/decisions/0015-a-lens-is-read-from-its-own-app-and-only-what-gates-holds-a-merge.md @@ -44,7 +44,7 @@ the deterministic Lenses alone, they are its only judge. | A required Lens's blocking or major Finding gates; a minor one of any category but `security`, or one from a Lens that is not required, does not | `tests/test_decide.py::test_required_lens_major_finding_gates`, `tests/test_decide.py::test_minor_finding_and_unrequired_lens_do_not_gate` | | A required Lens's `security` Finding gates at any severity, in the merge queue too; one from a Lens that is not required gates only once a required Lens adopts it | `tests/test_decide.py::test_a_minor_security_finding_gates`, `tests/test_decide.py::test_a_minor_security_finding_opened_while_queued_takes_it_out_of_the_queue`, `tests/test_decide.py::test_a_security_finding_from_a_lens_that_is_not_required_does_not_gate` | | A required Lens's open thread whose category or severity is missing, null or not in the schema defers for the Maintainer, and takes a queued item out; a thread from a Lens that is not required may carry neither | `tests/test_decide.py::test_a_required_lens_thread_that_cannot_be_read_defers`, `tests/test_decide.py::test_a_read_that_fails_takes_a_pull_request_out_of_the_queue` | -| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | waiting on `adapters/threads.py` | +| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | a person's thread is `human`, and a Lens's has neither until the join: `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`; the join is waiting on `harness/`, which uploads the record | | A thread carries its Finding's category, in the authority table's terms, and the Kernel reads the Finding's categories and severities | `tests/test_tools.py::test_the_kernel_reads_the_categories_and_severities_a_finding_carries`, `examples/invalid/facts.a-thread-without-its-category.json`, `examples/invalid/facts.a-category-nobody-owns.json`, `tests/test_tools.py::test_a_thread_carries_the_categories_a_finding_does` | | A Finding that does not gate is an annotation on its Lens's check run; a Result that posts one on a thread is refused | waiting on `harness/` | | A required deterministic Lens names the check GitHub reports for it, and that check reports on every head and in the merge queue | `tests/test_adapters.py::test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow`; that the check reports on every head and in the merge queue is not held yet: `tests/test_adapters.py::test_a_required_check_reports_on_every_head_and_a_rerun_replaces_only_its_own` | diff --git a/docs/decisions/0018-a-lens-is-read-from-its-own-app-and-workflow-and-only-what-gates-holds-a-merge.md b/docs/decisions/0018-a-lens-is-read-from-its-own-app-and-workflow-and-only-what-gates-holds-a-merge.md index a5727270d..cdd26b6cc 100644 --- a/docs/decisions/0018-a-lens-is-read-from-its-own-app-and-workflow-and-only-what-gates-holds-a-merge.md +++ b/docs/decisions/0018-a-lens-is-read-from-its-own-app-and-workflow-and-only-what-gates-holds-a-merge.md @@ -68,7 +68,7 @@ platform fact not yet tried: the fake GitHub assumes it cannot. | A required Lens's blocking or major Finding gates; a minor one of any category but `security`, or one from a Lens that is not required, does not | `tests/test_decide.py::test_required_lens_major_finding_gates`, `tests/test_decide.py::test_minor_finding_and_unrequired_lens_do_not_gate` | | A required Lens's `security` Finding gates at any severity, in the merge queue too; one from a Lens that is not required gates only once a required Lens adopts it | `tests/test_decide.py::test_a_minor_security_finding_gates`, `tests/test_decide.py::test_a_minor_security_finding_opened_while_queued_takes_it_out_of_the_queue`, `tests/test_decide.py::test_a_security_finding_from_a_lens_that_is_not_required_does_not_gate` | | A required Lens's open thread whose category or severity is missing, null or not in the schema defers for the Maintainer, and takes a queued item out; a thread from a Lens that is not required may carry neither | `tests/test_decide.py::test_a_required_lens_thread_that_cannot_be_read_defers`, `tests/test_decide.py::test_a_read_that_fails_takes_a_pull_request_out_of_the_queue` | -| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | waiting on `adapters/threads.py` | +| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | a person's thread is `human`, and a Lens's has neither until the join: `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`; the join is waiting on `harness/`, which uploads the record | | A thread carries its Finding's category, in the authority table's terms, and the Kernel reads the Finding's categories and severities | `tests/test_tools.py::test_the_kernel_reads_the_categories_and_severities_a_finding_carries`, `examples/invalid/facts.a-thread-without-its-category.json`, `examples/invalid/facts.a-category-nobody-owns.json`, `tests/test_tools.py::test_a_thread_carries_the_categories_a_finding_does` | | A Finding that does not gate is an annotation on its Lens's check run; a Result that posts one on a thread is refused | waiting on `harness/` | | A required deterministic Lens names the check GitHub reports for it, and that check reports on every head and in the merge queue | `tests/test_adapters.py::test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow`; that the check reports on every head and in the merge queue is not held yet: `tests/test_adapters.py::test_a_required_check_reports_on_every_head_and_a_rerun_replaces_only_its_own` | diff --git a/docs/decisions/0022-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md b/docs/decisions/0022-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md index 3acca4e62..cca6b30cb 100644 --- a/docs/decisions/0022-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md +++ b/docs/decisions/0022-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md @@ -79,7 +79,7 @@ A job left out of its `needs:` is a check nobody requires, so it needs every oth | A required Lens's blocking or major Finding gates; a minor one of any category but `security`, or one from a Lens that is not required, does not | `tests/test_decide.py::test_required_lens_major_finding_gates`, `tests/test_decide.py::test_minor_finding_and_unrequired_lens_do_not_gate` | | A required Lens's `security` Finding gates at any severity, in the merge queue too; one from a Lens that is not required gates only once a required Lens adopts it | `tests/test_decide.py::test_a_minor_security_finding_gates`, `tests/test_decide.py::test_a_minor_security_finding_opened_while_queued_takes_it_out_of_the_queue`, `tests/test_decide.py::test_a_security_finding_from_a_lens_that_is_not_required_does_not_gate` | | A required Lens's open thread whose category or severity is missing, null or not in the schema defers for the Maintainer, and takes a queued item out; a thread from a Lens that is not required may carry neither | `tests/test_decide.py::test_a_required_lens_thread_that_cannot_be_read_defers`, `tests/test_decide.py::test_a_read_that_fails_takes_a_pull_request_out_of_the_queue` | -| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | waiting on `adapters/threads.py` | +| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | a person's thread is `human`, and a Lens's has neither until the join: `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`; the join is waiting on `harness/`, which uploads the record | | A thread carries its Finding's category, in the authority table's terms, and the Kernel reads the Finding's categories and severities | `tests/test_tools.py::test_the_kernel_reads_the_categories_and_severities_a_finding_carries`, `examples/invalid/facts.a-thread-without-its-category.json`, `examples/invalid/facts.a-category-nobody-owns.json`, `tests/test_tools.py::test_a_thread_carries_the_categories_a_finding_does` | | A Finding that does not gate is an annotation on its Lens's check run; a Result that posts one on a thread is refused | waiting on `harness/` | | A required deterministic Lens names the check GitHub reports for it, and that check reports on every head and in the merge queue | `tests/test_adapters.py::test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow`; that the check reports on every head and in the merge queue is not held yet: `tests/test_adapters.py::test_a_required_check_reports_on_every_head_and_a_rerun_replaces_only_its_own` | diff --git a/docs/decisions/0026-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md b/docs/decisions/0026-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md index 897e79dbc..e6d990cd1 100644 --- a/docs/decisions/0026-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md +++ b/docs/decisions/0026-a-lens-is-read-from-its-own-app-and-workflow-its-job-judges-every-job-it-waits-on-and-only-what-gates-holds-a-merge.md @@ -84,7 +84,7 @@ A job left out of its `needs:` is a check nobody requires, so it needs every oth | A required Lens's blocking or major Finding gates; a minor one of any category but `security`, or one from a Lens that is not required, does not | `tests/test_decide.py::test_required_lens_major_finding_gates`, `tests/test_decide.py::test_minor_finding_and_unrequired_lens_do_not_gate` | | A required Lens's `security` Finding gates at any severity, in the merge queue too; one from a Lens that is not required gates only once a required Lens adopts it | `tests/test_decide.py::test_a_minor_security_finding_gates`, `tests/test_decide.py::test_a_minor_security_finding_opened_while_queued_takes_it_out_of_the_queue`, `tests/test_decide.py::test_a_security_finding_from_a_lens_that_is_not_required_does_not_gate` | | A required Lens's open thread whose category or severity is missing, null or not in the schema defers for the Maintainer, and takes a queued item out; a thread from a Lens that is not required may carry neither | `tests/test_decide.py::test_a_required_lens_thread_that_cannot_be_read_defers`, `tests/test_decide.py::test_a_read_that_fails_takes_a_pull_request_out_of_the_queue` | -| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | waiting on `adapters/threads.py` | +| A thread's category and severity are read from the required Lens's own Finding record, joined by its surface key, never from the comment text | a person's thread is `human`, and a Lens's has neither until the join: `tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`; the join is waiting on `harness/`, which uploads the record | | A thread carries its Finding's category, in the authority table's terms, and the Kernel reads the Finding's categories and severities | `tests/test_tools.py::test_the_kernel_reads_the_categories_and_severities_a_finding_carries`, `examples/invalid/facts.a-thread-without-its-category.json`, `examples/invalid/facts.a-category-nobody-owns.json`, `tests/test_tools.py::test_a_thread_carries_the_categories_a_finding_does` | | A Finding that does not gate is an annotation on its Lens's check run; a Result that posts one on a thread is refused | waiting on `harness/` | | A required deterministic Lens names the check GitHub reports for it, and that check reports on every head and in the merge queue | `tests/test_adapters.py::test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow`; that the check reports on every head and in the merge queue is not held yet: `tests/test_adapters.py::test_a_required_check_reports_on_every_head_and_a_rerun_replaces_only_its_own` | diff --git a/docs/decisions/0038-a-result-asks-and-names-no-one-and-apply-writes-the-finding-it-posted.md b/docs/decisions/0038-a-result-asks-and-names-no-one-and-apply-writes-the-finding-it-posted.md index 3f6706aa8..5244b4d23 100644 --- a/docs/decisions/0038-a-result-asks-and-names-no-one-and-apply-writes-the-finding-it-posted.md +++ b/docs/decisions/0038-a-result-asks-and-names-no-one-and-apply-writes-the-finding-it-posted.md @@ -85,4 +85,4 @@ unverified: about 160 characters at the longest, and P-17's were shorter. | The Harness refuses a `completed` Result with a reason, and one of any other status without; it gives a text its trust class from the facts' actor, never from the text | waiting on `harness/` | | `apply` submits a Role's review as a comment on the admitted commit, never an approval | waiting on `harness/` | | `apply` writes each posted Finding's `finding/1` into the applied artifact, its source from the Task | waiting on `harness/` | -| The facts port joins a thread's category and severity from the applied artifact; the Controller names a Run by `run-name/1`, and the records port parses it | waiting on `adapters/threads.py` for the join; the parse is held by `tests/test_adapters.py::test_a_run_name_is_read_whole_or_not_at_all` | +| The facts port joins a thread's category and severity from the applied artifact; the Controller names a Run by `run-name/1`, and the records port parses it | the join is waiting on `harness/`, which uploads `applied/1`; until then a Lens's thread has neither (`tests/test_adapters.py::test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human`); the parse is held by `tests/test_adapters.py::test_a_run_name_is_read_whole_or_not_at_all` | diff --git a/tests/test_adapters.py b/tests/test_adapters.py index 5068ae113..5e1735170 100644 --- a/tests/test_adapters.py +++ b/tests/test_adapters.py @@ -15,7 +15,7 @@ import unittest import zipfile -from adapters import artifacts, checks, facts, github, pull, records, timeline +from adapters import artifacts, checks, facts, github, pull, records, threads, timeline from tests.support import pending ROOT = pathlib.Path(__file__).resolve().parent.parent @@ -1223,7 +1223,7 @@ def test_every_check_run_on_the_head_is_read_with_its_name_app_and_workflow(self "conclusion": "success", "completed_at": "2026-10-20T00:51:22Z"}) self.assertIn({"name": "checks", "app_id": 15368, "workflow": ".github/workflows/verify.yml", "conclusion": "success", "completed_at": "2026-10-20T01:01:25Z"}, got["checks"]) - self.assertEqual((got["complete"], got["queue"], got["threads"]), (True, True, 0)) + self.assertEqual((got["complete"], got["queue"]), (True, True)) def test_a_check_still_running_gives_its_status_and_no_time(self): node = {"__typename": "CheckRun", "name": "verify", "conclusion": None, "status": "IN_PROGRESS", @@ -1297,10 +1297,6 @@ def test_a_rollup_of_another_commit_or_cut_short_is_not_read_whole(self): odd = p32_pull() odd["commits"]["nodes"][0]["commit"]["statusCheckRollup"]["contexts"]["nodes"].append({"__typename": "Odd"}) checks.read(github.Replay([checks_answer(odd)]), as_pull(odd)) - uncounted = p32_pull() - uncounted["reviewThreads"] = {"totalCount": None} - with self.assertRaises(github.Unanswered): - checks.read(github.Replay([checks_answer(uncounted)]), as_pull(uncounted)) def test_a_rollup_whose_count_is_not_what_was_read_is_not_whole(self): # GitHub counts the rollup's contexts: a last page that says no next one, but leaves counted contexts unread, @@ -1353,6 +1349,119 @@ def p26_checks(head: str) -> dict: return found +PERSON = ("don-petry", MAINTAINER, "User") # the Maintainer, as the fixtures record him +LENS = ("coderabbitai", 136622811, "Bot") # a Lens's App, as GraphQL names a Bot: its login has no [bot] +APP = ("github-actions", 41898282, "Bot") # an App no Lens is + + +def thread_node(ident: str, opened=PERSON, at: str = "2026-10-21T16:18:57Z", resolved_by=None) -> dict: + """A review thread as the port's query asks it. No trial has recorded a thread's author, time or resolver yet (P-43 + recorded only its path and state); the pending test below reads the first that does.""" + login, account, kind = opened + node = {"id": ident, "isResolved": resolved_by is not None, + "resolvedBy": None if resolved_by is None else {"login": resolved_by[0], "databaseId": resolved_by[1]}, + "comments": {"nodes": [{"createdAt": at, "author": {"__typename": kind, "login": login, + "databaseId": account}}]}} + return node + + +def threads_answer(repo: str, number: int, nodes: list, total=None, after=None, cursor=None) -> dict: + """An exchange of the port's threads query, in the page shape P-43 recorded for review threads.""" + owner, name = repo.split("/") + asked = {"query": threads.QUERY, "variables": {"owner": owner, "name": name, "number": number, "after": after}} + page = {"hasNextPage": cursor is not None, "endCursor": cursor} + listed = {"totalCount": len(nodes) if total is None else total, "pageInfo": page, "nodes": nodes} + return {"request": {"via": "graphql", "call": "POST /graphql", "headers": {}, "body": asked}, + "response": {"status": 200, "headers": {}, + "body": {"data": {"repository": {"pullRequest": {"reviewThreads": listed}}}}}} + + +class Threads(unittest.TestCase): + PULL = {"number": 26, "base": {"repo": {"full_name": "o/r"}}} + + def read(self, *pages, permissions=None): + router = Router(github.Replay(list(pages)), permissions or {"don-petry": "admin", "outsider": "read"}) + accounts = timeline.Accounts(router, "o/r", MACHINE, {LENS[1:]: "coderabbit"}) + return threads.read(router, self.PULL, accounts) + + def test_each_thread_is_read_with_who_opened_and_resolved_it_and_a_persons_is_human(self): + got, whole = self.read(threads_answer("o/r", 26, [ + thread_node("PRRT_1"), thread_node("PRRT_2", LENS, resolved_by=("don-petry", MAINTAINER)), + thread_node("PRRT_3", APP), thread_node("PRRT_4", ("outsider", 7, "User")), + thread_node("PRRT_5", (APPROVER,) + MACHINE)])) + self.assertTrue(whole) + self.assertEqual(got[0], {"id": "PRRT_1", "resolved": False, "category": "human", "severity": None, + "opened_by": {"kind": "human", "name": "don-petry", "can_write": True}, + "resolved_by": None, "opened_at": "2026-10-21T16:18:57Z"}) + # A Lens's thread has no category or severity until its Finding record can be joined (decision 0038). + self.assertEqual((got[1]["opened_by"], got[1]["category"], got[1]["severity"]), + ({"kind": "lens", "name": "coderabbit", "can_write": False}, None, None)) + self.assertEqual(got[1]["resolved_by"], {"kind": "human", "name": "don-petry", "can_write": True}) + self.assertEqual((got[2]["opened_by"]["kind"], got[2]["category"]), ("app", None)) + self.assertEqual((got[3]["opened_by"], got[3]["category"]), + ({"kind": "human", "name": "outsider", "can_write": False}, "human")) + # The machine user is no person: its thread, as an App's, has no category. + self.assertEqual((got[4]["opened_by"]["kind"], got[4]["category"]), ("machine_user", None)) + # A resolved thread GitHub names no resolver for, as when an App resolved it, is read with none: the Kernel + # defers on that thread alone, never on the whole pull request. + resolved, _ = self.read(threads_answer("o/r", 26, [dict(thread_node("PRRT_6", LENS), isResolved=True)])) + self.assertEqual((resolved[0]["resolved"], resolved[0]["resolved_by"]), (True, None)) + + def test_a_thread_that_cannot_be_read_is_refused(self): + good = thread_node("PRRT_1") + broken = [dict(good, id=""), dict(good, id=None), dict(good, isResolved=None), dict(good, comments={"nodes": []}), + dict(good, comments=None), dict(good, resolvedBy={"login": "don-petry", "databaseId": MAINTAINER}), + dict(good, isResolved=0), + dict(good, isResolved=1, resolvedBy={"login": "don-petry", "databaseId": MAINTAINER}), + thread_node("PRRT_1", at="yesterday"), + thread_node("PRRT_1", ("ghost", 1, "Mannequin")), thread_node("PRRT_1", ("don-petry", None, "User")), + thread_node("PRRT_1", ("x[bot]", 9, "User")), "PRRT_1", thread_node("PRRT_1")] + broken[-1]["comments"]["nodes"][0]["author"] = None # a deleted account, which GraphQL gives as null + reply = thread_node("PRRT_1") + reply["comments"]["nodes"][0]["replyTo"] = {"id": "PRRC_0"} + broken.append(reply) + for node in broken: + with self.assertRaises(github.Unanswered, msg=node): + self.read(threads_answer("o/r", 26, [node])) + + def test_threads_are_read_page_by_page_and_whole_only_when_every_one_was_read_once(self): + one, two = [thread_node("PRRT_1")], [thread_node("PRRT_2")] + first = threads_answer("o/r", 26, one, total=2, cursor="c1") + got, whole = self.read(first, threads_answer("o/r", 26, two, total=2, after="c1")) + self.assertEqual(([t["id"] for t in got], whole), (["PRRT_1", "PRRT_2"], True)) + for second in (threads_answer("o/r", 26, one, total=2, after="c1"), # a thread read twice + threads_answer("o/r", 26, two, total=3, after="c1"), # the count moved + threads_answer("o/r", 26, [], total=2, after="c1")): # one counted never read + self.assertIs(self.read(first, second)[1], False) + # A cursor that repeats, or a next page past the count, ends the read short rather than looping. + start = threads_answer("o/r", 26, one, total=5, cursor="c1") + looping = threads_answer("o/r", 26, two, total=5, after="c1", cursor="c1") + self.assertIs(self.read(start, looping)[1], False) + self.assertIs(self.read(threads_answer("o/r", 26, one + two, total=2, cursor="c1"))[1], False) + for change in ({"pageInfo": {"hasNextPage": None}}, {"nodes": None}, {"totalCount": None}, + {"totalCount": True}, {"pageInfo": {"hasNextPage": True, "endCursor": ""}}): + page = threads_answer("o/r", 26, one) + page["response"]["body"]["data"]["repository"]["pullRequest"]["reviewThreads"].update(change) + self.assertIs(self.read(page)[1], False, change) + bare = threads_answer("o/r", 26, one) + bare["response"]["body"]["data"]["repository"]["pullRequest"]["reviewThreads"] = None + self.assertEqual(self.read(bare), ([], False)) + for status, answer_body in ((502, None), (200, {"errors": [{"message": "x"}]})): + failed = threads_answer("o/r", 26, one) + failed["response"].update(status=status, body=answer_body) + with self.assertRaises(github.Unanswered): + self.read(failed) + + @pending + def test_a_thread_a_trial_recorded_is_read_as_the_port_reads_it(self): + # A thread's author, time and resolver, as GitHub's GraphQL gives them, are not yet recorded: the first trial + # that records one, asked as the port asks, is read here. + found = [e for name in sorted((ROOT / "trials").glob("P-*.json")) + for e in json.loads(name.read_text()).get("exchanges", []) + if (e.get("request") or {}).get("body", {}) and "FactsThreads" in json.dumps(e["request"]["body"])] + self.assertTrue(found) + + class Snapshot(unittest.TestCase): NOW = "2026-10-18T03:00:00Z" @@ -1363,7 +1472,7 @@ def sequence(self, reread: int) -> list: found = exchanges("P-29.base") head = found[1]["response"]["body"]["head"]["sha"] return [found[1], found[9], exchanges("P-28")[3], found[2], p26_files(), exchanges("P-28")[4], p26_reviews(), - p26_checks(head), found[reread]] + p26_checks(head), threads_answer(canary(), 26, []), found[reread]] def read(self, reread: int): router = Router(github.Replay(self.sequence(reread)), {"don-petry": "admin"}) @@ -1424,13 +1533,35 @@ def test_a_push_that_names_its_pusher_and_no_time_is_refused(self): facts.snapshot(router, canary(), 26, person(), timeline.Accounts(router, canary(), MACHINE, {}), True, lambda: self.NOW) - def test_a_snapshot_of_a_pull_request_with_threads_is_not_read_whole_on_them(self): + def test_a_snapshot_holds_every_thread_read_and_says_whether_they_were_read_whole(self): + seq = self.sequence(1) + seq[8] = threads_answer(canary(), 26, [thread_node("PRRT_1", PERSON), thread_node("PRRT_2", LENS)]) + router = Router(github.Replay(copy.deepcopy(seq)), {"don-petry": "admin"}) + accounts = timeline.Accounts(router, canary(), MACHINE, {LENS[1:]: "coderabbit"}) + got, _ = facts.snapshot(router, canary(), 26, person(), accounts, False, lambda: self.NOW) + self.assertEqual([(t["id"], t["category"]) for t in got["threads"]], [("PRRT_1", "human"), ("PRRT_2", None)]) + self.assertEqual((got["complete"]["threads"], got["complete"]["runs"]), (True, False)) + seq[8]["response"]["body"]["data"]["repository"]["pullRequest"]["reviewThreads"]["totalCount"] = 3 + router = Router(github.Replay(seq), {"don-petry": "admin"}) + accounts = timeline.Accounts(router, canary(), MACHINE, {LENS[1:]: "coderabbit"}) + got, _ = facts.snapshot(router, canary(), 26, person(), accounts, True, lambda: self.NOW) + self.assertIs(got["complete"]["threads"], False) + + def test_only_a_required_lenss_own_apps_open_thread_defers(self): + # A thread is a Lens thread only when its author is that Lens's own App, by account id and type. An outside + # reviewer's thread, CodeRabbit's or Codex's, is no required Lens's: with no category it does not defer. + # Only a required model Lens's own App's open thread with neither defers, until harness/ uploads its record. + from kernel import derive + config = json.loads((ROOT / "config" / "defaults.json").read_text()) + role = ("combsmith-sf-pr-review", 99, "Bot") seq = self.sequence(1) - seq[7]["response"]["body"]["data"]["repository"]["pullRequest"]["reviewThreads"]["totalCount"] = 2 + seq[8] = threads_answer(canary(), 26, [thread_node("PRRT_1", LENS), thread_node("PRRT_2", role), + thread_node("PRRT_3", APP), thread_node("PRRT_4", PERSON)]) router = Router(github.Replay(seq), {"don-petry": "admin"}) - got, _ = facts.snapshot(router, canary(), 26, person(), timeline.Accounts(router, canary(), MACHINE, {}), - False, lambda: self.NOW) - self.assertEqual((got["complete"]["threads"], got["complete"]["runs"], got["threads"]), (False, False, [])) + accounts = timeline.Accounts(router, canary(), MACHINE, {LENS[1:]: "coderabbit", role[1:]: "pr-review"}) + got, _ = facts.snapshot(router, canary(), 26, person(), accounts, True, lambda: self.NOW) + self.assertEqual(config["required_lenses"]["model"], ["pr-review"]) + self.assertEqual(derive.unreadable_threads(got, dict(config, approver=APPROVER)), ["PRRT_2"]) def test_the_snapshots_time_is_taken_after_its_last_read(self): replay = github.Replay(self.sequence(1)) diff --git a/tools/mutants.py b/tools/mutants.py index a8c71c6e1..f41ce49bb 100644 --- a/tools/mutants.py +++ b/tools/mutants.py @@ -1686,6 +1686,63 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ('a malformed queue entry is read', 'adapters/checks.py', ' if not (entry is None or isinstance(entry, dict)):\n', ' if False:\n', ('tests.test_adapters',)), + ('the threads are never read', 'adapters/facts.py', + ' "threads": found,', + ' "threads": [],', ('tests.test_adapters',)), + ("a thread's category is human whoever opened it", 'adapters/threads.py', + '"category": "human" if human else None,', + '"category": "human",', ('tests.test_adapters',)), + ("a Lens's thread is given a category", 'adapters/threads.py', + '"category": "human" if human else None,', + '"category": "human" if human else "functional",', ('tests.test_adapters',)), + ('a thread with no id is read', 'adapters/threads.py', + 'if not isinstance(ident, str) or not ident or type', + 'if type', ('tests.test_adapters',)), + ("a thread's state may be any value", 'adapters/threads.py', + ' or type(resolved) is not bool or not first', + ' or not first', ('tests.test_adapters',)), + ("a thread's time is not checked", 'adapters/threads.py', + ' if not (isinstance(opened_at, str) and TIME.fullmatch(opened_at)):\n', + ' if False:\n', ('tests.test_adapters',)), + ('an open thread may name its resolver', 'adapters/threads.py', + ' if not resolved and by is not None:\n', + ' if False:\n', ('tests.test_adapters',)), + ("a reply is read as a thread's opener", 'adapters/threads.py', + ' if first[0].get("replyTo") is not None:\n', + ' if False:\n', ('tests.test_adapters',)), + ("the port never reads who resolved a thread", 'adapters/threads.py', + 'resolved_by = accounts.actor(_account(by, "User")) if by is not None else None', + 'resolved_by = None', ('tests.test_adapters',)), + ('who opened a thread is told by its name', 'adapters/threads.py', + ' opened_by = accounts.actor(_account(first[0].get("author")))\n', + ' opened_by = {"kind": "human", "name": str((first[0].get("author") or {}).get("login")), "can_write": True}\n', ('tests.test_adapters',)), + ('a resolver is read by whatever type it gives', 'adapters/threads.py', + '_account(by, "User")', + '_account(by, by.get("__typename", "Bot"))', ('tests.test_adapters',)), + ('a short page of threads is whole', 'adapters/threads.py', + ' if not isinstance(listed, dict) or not isinstance(listed.get("nodes"), list) or not isinstance(page, dict):\n return found, False\n', + ' if not isinstance(listed, dict) or not isinstance(listed.get("nodes"), list) or not isinstance(page, dict):\n return found, True\n', ('tests.test_adapters',)), + ('a threads count that moved is whole', 'adapters/threads.py', + 'if not isinstance(total, int) or isinstance(total, bool) or counted != total:', + 'if not isinstance(total, int) or isinstance(total, bool):', ('tests.test_adapters',)), + ('a thread counted but never read is whole', 'adapters/threads.py', + 'return found, len(ids) == total and len(set(ids)) == len(ids)', + 'return found, len(set(ids)) == len(ids)', ('tests.test_adapters',)), + ('a thread read twice is whole', 'adapters/threads.py', + 'return found, len(ids) == total and len(set(ids)) == len(ids)', + 'return found, len(ids) == total', ('tests.test_adapters',)), + ('a repeated threads cursor is followed', 'adapters/threads.py', + ' or cursor in cursors \\\n', + ' \\\n', ('tests.test_adapters',)), + ('threads past the count are followed', 'adapters/threads.py', + ' or len(ids) >= total:\n', + ' or False:\n', ('tests.test_adapters',)), + ('a next page of threads is never read', 'adapters/threads.py', + ' after = cursor\n', + ' return found, True\n', ('tests.test_adapters',)), + ('a threads answer that is no answer is read', 'adapters/threads.py', + ' if answer["status"] != 200 or not isinstance(answer["body"], dict) or answer["body"].get("errors"):\n raise Unanswered("the threads', + ' if False:\n raise Unanswered("the threads', ('tests.test_adapters',)), ('a status context is a check', 'adapters/checks.py', ' if node.get("__typename") == "CheckRun":\n', ' if node.get("__typename") in ("CheckRun", "StatusContext"):\n', ('tests.test_adapters',)), @@ -1709,16 +1766,13 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ' and counted == total\n', ('tests.test_adapters',)), ('a next page of checks is not read', 'adapters/checks.py', ' after = page["endCursor"]\n', - ' return {"checks": found, "complete": True, "queue": queue, "threads": threads}\n', ('tests.test_adapters',)), + ' return {"checks": found, "complete": True, "queue": queue}\n', ('tests.test_adapters',)), ('a page that names no next one is whole', 'adapters/checks.py', - '"complete": False, "queue": queue, "threads": threads}\n if page["endCursor"] in cursors', - '"complete": True, "queue": queue, "threads": threads}\n if page["endCursor"] in cursors', ('tests.test_adapters',)), + '"complete": False, "queue": queue}\n if page["endCursor"] in cursors', + '"complete": True, "queue": queue}\n if page["endCursor"] in cursors', ('tests.test_adapters',)), ('the queue is never read', 'adapters/checks.py', - ' queue, threads = entry is not None, count\n', - ' queue, threads = False, count\n', ('tests.test_adapters',)), - ('a thread count that cannot be read is read', 'adapters/checks.py', - ' if not isinstance(count, int) or isinstance(count, bool) or count < 0:\n', - ' if False:\n', ('tests.test_adapters',)), + ' queue = entry is not None\n', + ' queue = False\n', ('tests.test_adapters',)), ("a check's conclusion is passed on as GitHub's case", 'adapters/checks.py', '"conclusion": word.lower(),', '"conclusion": word,', ('tests.test_adapters',)), @@ -1749,8 +1803,8 @@ def moved_before(rel: str, block: str, anchor: str) -> tuple: ('acceptance is read whole', 'adapters/facts.py', '"complete": {"acceptance": False,', '"complete": {"acceptance": True,', ('tests.test_adapters',)), - ('threads are whole whatever their count', 'adapters/facts.py', - '"threads": read["threads"] == 0,', + ('threads are whole whatever the read', 'adapters/facts.py', + '"threads": threads_whole,', '"threads": True,', ('tests.test_adapters',)), ('the runs are whole whatever the pass read', 'adapters/facts.py', '"runs": runs_whole is True,',