polyctl 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. polyctl/__init__.py +7 -0
  2. polyctl/__main__.py +5 -0
  3. polyctl/a2a.py +226 -0
  4. polyctl/a2a_mcp.py +546 -0
  5. polyctl/acp.py +417 -0
  6. polyctl/adapters/README.md +101 -0
  7. polyctl/adapters/aider.json +32 -0
  8. polyctl/adapters/amazon-q.json +15 -0
  9. polyctl/adapters/amp.json +16 -0
  10. polyctl/adapters/antigravity.json +120 -0
  11. polyctl/adapters/claude-code.json +229 -0
  12. polyctl/adapters/cloud-generic.json +57 -0
  13. polyctl/adapters/codex.json +47 -0
  14. polyctl/adapters/command-code.json +45 -0
  15. polyctl/adapters/copilot.json +17 -0
  16. polyctl/adapters/cursor-agent.json +29 -0
  17. polyctl/adapters/deepseek.json +13 -0
  18. polyctl/adapters/droid.json +34 -0
  19. polyctl/adapters/gemini.json +30 -0
  20. polyctl/adapters/grok.json +22 -0
  21. polyctl/adapters/hermes.json +34 -0
  22. polyctl/adapters/kilocode.json +30 -0
  23. polyctl/adapters/kimi.json +23 -0
  24. polyctl/adapters/kiro.json +332 -0
  25. polyctl/adapters/ollama.json +29 -0
  26. polyctl/adapters/omp.json +34 -0
  27. polyctl/adapters/openai-api.json +68 -0
  28. polyctl/adapters/opencode.json +162 -0
  29. polyctl/adapters/pi.json +24 -0
  30. polyctl/adapters/pr-agent.json +54 -0
  31. polyctl/adapters/profiles.json +9 -0
  32. polyctl/adapters/qoder.json +163 -0
  33. polyctl/adapters/qwen.json +27 -0
  34. polyctl/adapters/reasonix.json +25 -0
  35. polyctl/adapters/rewriters/rtk.json +24 -0
  36. polyctl/adapters/trae.json +31 -0
  37. polyctl/adapters/vendors.json +42 -0
  38. polyctl/adapters/warp.json +88 -0
  39. polyctl/allowlist.py +1756 -0
  40. polyctl/api_review.py +920 -0
  41. polyctl/cli.py +835 -0
  42. polyctl/conformance_harness.py +9 -0
  43. polyctl/demo.py +503 -0
  44. polyctl/drivers.py +146 -0
  45. polyctl/email.py +160 -0
  46. polyctl/features.py +98 -0
  47. polyctl/journal.py +144 -0
  48. polyctl/language.py +945 -0
  49. polyctl/lib.py +1296 -0
  50. polyctl/matrix.py +660 -0
  51. polyctl/mcp.py +1362 -0
  52. polyctl/ntfy.py +169 -0
  53. polyctl/outbound.py +39 -0
  54. polyctl/parts/__init__.py +5 -0
  55. polyctl/parts/cli_authority.py +2615 -0
  56. polyctl/parts/cli_channels.py +1325 -0
  57. polyctl/parts/cli_checks.py +2293 -0
  58. polyctl/parts/cli_completion.py +686 -0
  59. polyctl/parts/cli_evidence.py +141 -0
  60. polyctl/parts/cli_gain.py +375 -0
  61. polyctl/parts/cli_harness.py +392 -0
  62. polyctl/parts/cli_hooks.py +1816 -0
  63. polyctl/parts/cli_install.py +638 -0
  64. polyctl/parts/cli_lanes.py +106 -0
  65. polyctl/parts/cli_maintenance.py +2536 -0
  66. polyctl/parts/cli_next.py +248 -0
  67. polyctl/parts/cli_pr.py +53 -0
  68. polyctl/parts/cli_project.py +2857 -0
  69. polyctl/parts/cli_review.py +5158 -0
  70. polyctl/parts/cli_status.py +898 -0
  71. polyctl/parts/lib_adapters.py +2933 -0
  72. polyctl/parts/lib_alarms.py +2106 -0
  73. polyctl/parts/lib_events.py +224 -0
  74. polyctl/parts/lib_evidence.py +412 -0
  75. polyctl/parts/lib_gates.py +2099 -0
  76. polyctl/parts/lib_lanes.py +829 -0
  77. polyctl/parts/lib_mail.py +1541 -0
  78. polyctl/parts/lib_next.py +652 -0
  79. polyctl/parts/lib_pr.py +331 -0
  80. polyctl/parts/lib_slices.py +3337 -0
  81. polyctl/parts/lib_state.py +2415 -0
  82. polyctl/parts/lib_transcript.py +4118 -0
  83. polyctl/pressure.py +325 -0
  84. polyctl/prices.json +47 -0
  85. polyctl/procs.py +1194 -0
  86. polyctl/settings.py +505 -0
  87. polyctl/skill/SKILL.md +365 -0
  88. polyctl/skillkit.py +503 -0
  89. polyctl/storage.py +2055 -0
  90. polyctl/telegram.py +327 -0
  91. polyctl/tiers.py +123 -0
  92. polyctl/verdicts.py +41 -0
  93. polyctl/watchdog.py +3887 -0
  94. polyctl/web.py +337 -0
  95. polyctl-0.7.0.dist-info/METADATA +235 -0
  96. polyctl-0.7.0.dist-info/RECORD +99 -0
  97. polyctl-0.7.0.dist-info/WHEEL +4 -0
  98. polyctl-0.7.0.dist-info/entry_points.txt +5 -0
  99. polyctl-0.7.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,331 @@
1
+ """Pull requests: what GitHub says about this checkout's branches, read through gh, each fact mailed once.
2
+
3
+ A part of src/polyctl/lib.py, run in its namespace by `_part` as the parts moved out of it are (#44); it is
4
+ not importable on its own (PR-WATCH).
5
+ """
6
+
7
+
8
+ # ---- pull requests, read and never written (PR-WATCH) ------------------------------------------
9
+ #
10
+ # polyctl governs what lands in a checkout; what becomes of a branch once a person pushes it is GitHub's to
11
+ # say. A check that failed there, a conflict with the base branch or a reviewer asking for changes
12
+ # waited until somebody opened the page. `polyctl pr watch --once` reads the open pull requests of this
13
+ # checkout's branches and mails the implementer each such fact once. gh is asked `pr list` and
14
+ # `pr view` and nothing else, so nothing here can write to GitHub.
15
+
16
+ PR_FACTS = ("check-failed", "conflict", "changes-requested")
17
+ PR_LIST_LIMIT = 200
18
+ PR_LIST_FIELDS = "number,headRefName,headRefOid,isCrossRepository"
19
+ PR_VIEW_FIELDS = ("number,title,url,headRefName,baseRefName,headRefOid,mergeable,reviewDecision,"
20
+ "statusCheckRollup,reviews")
21
+ # A check's latest run failed when it ended in one of these, a check run's conclusion or a commit
22
+ # status's state: gh's fail bucket, and STARTUP_FAILURE, a workflow that could not start, which gh
23
+ # counts as pending although nothing runs it again until somebody fixes it. A run cancelled, skipped
24
+ # or neutral has not failed; a required check that failed ended as any other did, which is why
25
+ # whether GitHub requires a check is not asked.
26
+ PR_CHECK_FAILED = ("FAILURE", "ERROR", "TIMED_OUT", "ACTION_REQUIRED", "STARTUP_FAILURE")
27
+ # A run that has not ended: a check run's status before it completes, a commit status pending or expected.
28
+ PR_CHECK_RUNNING = ("EXPECTED", "PENDING", "QUEUED", "IN_PROGRESS", "WAITING", "REQUESTED")
29
+ # A review that says what its author makes of the change, and says it until they review again or it
30
+ # is dismissed. A comment says nothing of it, and a reply in a review thread is a comment.
31
+ PR_REVIEW_OPINIONS = ("APPROVED", "CHANGES_REQUESTED", "DISMISSED")
32
+ # What makes gh write for a terminal into a pipe, and so wrap its JSON in colour codes.
33
+ GH_TERMINAL_ONLY = ("CLICOLOR_FORCE", "GH_FORCE_TTY")
34
+ GH_AUTH_REQUIRED = 4 # gh's documented exit status for a command that needs `gh auth login`
35
+ _HEAD = re.compile(r"^[0-9a-fA-F]{7,64}$")
36
+
37
+
38
+ class GhUnreadable(RuntimeError):
39
+ """gh gave no answer a pass can act on: it failed, timed out, is not authenticated or wrote no JSON."""
40
+
41
+
42
+ def pr_watch_path(root):
43
+ return os.path.join(root, ".polyctl", "pr-watch.json")
44
+
45
+
46
+ def gh_json(root, program, *args, timeout=60):
47
+ """gh's answer to one read in this checkout, parsed; GhUnreadable naming why when there is none.
48
+
49
+ gh finds the repository from the checkout's remotes. It is started without a shell and with no
50
+ terminal to prompt on, so a gh that would ask which repository is meant fails and says so,
51
+ rather than a pass guessing. Nor is it let colour what it writes: in a shell that forces colour
52
+ (GH_TERMINAL_ONLY), gh wrapped its JSON in escape codes even into a pipe, and every pass failed.
53
+ """
54
+ asked = "gh " + " ".join(args[:2])
55
+ env = {key: value for key, value in os.environ.items() if key not in GH_TERMINAL_ONLY}
56
+ try:
57
+ done = subprocess.run([program, *args], cwd=root, stdin=subprocess.DEVNULL, capture_output=True, text=True,
58
+ encoding=UTF8, errors="replace", timeout=timeout,
59
+ env=dict(env, GH_PROMPT_DISABLED="1", NO_COLOR="1"))
60
+ except subprocess.TimeoutExpired:
61
+ raise GhUnreadable(f"`{asked}` gave no answer in {timeout}s") from None
62
+ except OSError as exc:
63
+ raise GhUnreadable(f"`{asked}` could not start: {exc}") from None
64
+ if done.returncode == GH_AUTH_REQUIRED:
65
+ raise GhUnreadable("gh is not authenticated: run `gh auth login`")
66
+ if done.returncode:
67
+ said = "; ".join(line.strip() for line in (done.stderr or "").splitlines() if line.strip())
68
+ raise GhUnreadable(f"`{asked}` failed with exit {done.returncode}: {redact(said)[:300] or 'it said nothing'}")
69
+ try:
70
+ return json.loads(done.stdout)
71
+ except ValueError:
72
+ raise GhUnreadable(f"`{asked}` answered with something that is not JSON") from None
73
+
74
+
75
+ def checkout_branches(root):
76
+ """The names of this checkout's branches: a pull request whose head is one of them is this project's."""
77
+ refs = _git_output(root, "for-each-ref", "--format=%(refname)", "refs/heads").decode(UTF8, "replace")
78
+ return {ref[len("refs/heads/"):] for ref in refs.splitlines() if ref.startswith("refs/heads/")}
79
+
80
+
81
+ def read_pull_requests(root, program):
82
+ """(the open pull requests of this checkout's branches as `gh pr view` describes each, whether gh's list was cut).
83
+
84
+ Every one is read before anything is decided, and a read that fails raises: a pull request left
85
+ unread would look as if its facts had cleared, and they would be mailed again when they "returned".
86
+ A fork's branch that shares a name with one of ours is not ours.
87
+ """
88
+ branches = checkout_branches(root)
89
+ listed = gh_json(root, program, "pr", "list", "--state", "open", "--limit", str(PR_LIST_LIMIT),
90
+ "--json", PR_LIST_FIELDS)
91
+ if not isinstance(listed, list):
92
+ raise GhUnreadable("`gh pr list` answered with something that is not a list")
93
+ numbers = sorted({pr["number"] for pr in listed
94
+ if isinstance(pr, dict) and isinstance(pr.get("number"), int) and not pr.get("isCrossRepository")
95
+ and isinstance(pr.get("headRefName"), str) and pr["headRefName"] in branches})
96
+ pulls = []
97
+ for number in numbers:
98
+ pr = gh_json(root, program, "pr", "view", str(number), "--json", PR_VIEW_FIELDS)
99
+ if not isinstance(pr, dict) or pr.get("number") != number or not _HEAD.match(str(pr.get("headRefOid") or "")):
100
+ raise GhUnreadable(f"`gh pr view {number}` did not describe pull request #{number} and its head commit")
101
+ pulls.append(pr)
102
+ return pulls, len(listed) >= PR_LIST_LIMIT
103
+
104
+
105
+ def _check_state(check):
106
+ """A run's state as gh reads it: a check run's conclusion once completed, its status before; a status's state."""
107
+ if check.get("__typename") != "CheckRun":
108
+ return str(check.get("state") or "").upper()
109
+ status = str(check.get("status") or "").upper()
110
+ return str(check.get("conclusion") or "").upper() if status in ("", "COMPLETED") else status
111
+
112
+
113
+ def pr_latest_checks(rollup):
114
+ """[(a check's latest run, whether an earlier run of it failed)] for each check, in the order GitHub lists them.
115
+
116
+ GitHub's rollup keeps every run of a check: a job re-run after it failed stands beside the
117
+ failure, which read as a failed check long after the re-run passed. Only the run that started
118
+ last counts, as `gh pr checks` counts it: a check run is one check by its name and workflow, a
119
+ commit status by its context. gh also tells apart the event that started a run, which
120
+ `gh pr view` does not say, so two runs of one workflow started by two events on one head - push
121
+ and pull_request - are one check here, the later-started. A run not started yet, which gh dates
122
+ to year 1, or whose start cannot be read is the earliest; of two started together the one listed
123
+ later counts.
124
+ """
125
+ runs = {}
126
+ for index, check in enumerate(rollup or []):
127
+ if not isinstance(check, dict):
128
+ continue
129
+ key = (("run", str(check.get("name") or ""), str(check.get("workflowName") or ""))
130
+ if check.get("__typename") == "CheckRun" else ("status", str(check.get("context") or "")))
131
+ runs.setdefault(key, []).append((_ledger_time(check.get("startedAt")), index, check))
132
+ latest = []
133
+ for attempts in runs.values():
134
+ attempts.sort(key=lambda attempt: attempt[:2])
135
+ *earlier, (_, index, last) = attempts
136
+ latest.append((index, last, any(_check_state(check) in PR_CHECK_FAILED for _, _, check in earlier)))
137
+ return [(check, failed_before) for _, check, failed_before in sorted(latest, key=lambda row: row[0])]
138
+
139
+
140
+ def pr_changes_requested_by(reviews):
141
+ """The logins of the reviewers whose opinion of the change asks for changes, sorted.
142
+
143
+ A reviewer's opinion is their latest review in PR_REVIEW_OPINIONS, the one submitted last. gh's
144
+ `latestReviews` is each reviewer's latest review of any kind, so a reviewer who asked for changes
145
+ and then replied in a thread was read as asking for nothing: every review is read instead.
146
+ """
147
+ opinion = {}
148
+ for index, review in enumerate(reviews or []):
149
+ state = str(review.get("state") or "").upper() if isinstance(review, dict) else ""
150
+ if state not in PR_REVIEW_OPINIONS:
151
+ continue
152
+ author = review.get("author") if isinstance(review.get("author"), dict) else {}
153
+ login, when = str(author.get("login") or "a reviewer"), (_ledger_time(review.get("submittedAt")), index)
154
+ if login not in opinion or when > opinion[login][0]:
155
+ opinion[login] = (when, state)
156
+ return sorted(login for login, (_, state) in opinion.items() if state == "CHANGES_REQUESTED")
157
+
158
+
159
+ def pr_facts(pr):
160
+ """({fact: what shows it}, {facts GitHub has not decided}) for one pull request.
161
+
162
+ A failed check is one whose latest run on the head commit failed (pr_latest_checks). While a
163
+ check that failed runs again its failure is neither new nor cleared - the run decides it - as a
164
+ conflict is neither while GitHub is still computing `mergeable` (UNKNOWN): a failure mailed,
165
+ re-run and failed again on one head is not mailed twice. Changes are requested when the review
166
+ decision says so or a reviewer's opinion does (pr_changes_requested_by): a repository that
167
+ requires no review has no decision to read.
168
+ """
169
+ found, undecided, failed, rerun = {}, set(), [], False
170
+ for check, failed_before in pr_latest_checks(pr.get("statusCheckRollup")):
171
+ run, state = check.get("__typename") == "CheckRun", _check_state(check)
172
+ if state in PR_CHECK_FAILED:
173
+ failed.append({"name": str((check.get("name") if run else check.get("context")) or "?"),
174
+ "workflow": str((check.get("workflowName") if run else "") or ""), "state": state,
175
+ "link": str((check.get("detailsUrl") if run else check.get("targetUrl")) or "")})
176
+ elif failed_before and state in PR_CHECK_RUNNING:
177
+ rerun = True
178
+ if failed:
179
+ found["check-failed"] = failed
180
+ elif rerun:
181
+ undecided.add("check-failed")
182
+ mergeable = str(pr.get("mergeable") or "").upper()
183
+ if mergeable == "CONFLICTING":
184
+ found["conflict"] = []
185
+ elif mergeable != "MERGEABLE":
186
+ undecided.add("conflict")
187
+ asked = pr_changes_requested_by(pr.get("reviews"))
188
+ if asked or str(pr.get("reviewDecision") or "").upper() == "CHANGES_REQUESTED":
189
+ found["changes-requested"] = asked
190
+ return found, undecided
191
+
192
+
193
+ def _github_text(value):
194
+ """Text GitHub supplied, on one line and unable to carry a mail marker.
195
+
196
+ A marker is two hashes and a word (`## URGENT`, `## STOP`), and polyctl reads one anywhere in a
197
+ message: a title, a check's name or the link an integration gave its check holding one would
198
+ make this mail urgent, or a stop, for every reader. Every double hash is broken with a space,
199
+ and a value that would break a line is written as a JSON string (#55).
200
+ """
201
+ return review_header_value(re.sub(r"#(?=#)", "# ", str(value)))
202
+
203
+
204
+ def pr_mail_body(pr, fact, shown):
205
+ """The mail for one new fact: the pull request, what GitHub says of its head, and what to look at."""
206
+ number, head = pr["number"], pr["headRefOid"]
207
+ branch, base = _github_text(pr.get("headRefName") or "?"), _github_text(pr.get("baseRefName") or "?")
208
+ heading = {"check-failed": "a check failed", "conflict": f"it conflicts with {base}",
209
+ "changes-requested": "changes were requested"}[fact]
210
+ lines = [f"# Pull request #{number}: {heading}", "",
211
+ f"Pull request #{number} from `{branch}` into `{base}`: {_github_text(pr.get('url') or '')}",
212
+ f"Title: {_github_text(pr.get('title') or '')}", "",
213
+ f"GitHub says this of its head commit {head}:", ""]
214
+ if fact == "check-failed":
215
+ for check in shown:
216
+ workflow = f" ({_github_text(check['workflow'])})" if check["workflow"] else ""
217
+ link = f": {_github_text(check['link'])}" if check["link"] else ""
218
+ lines.append(f"- `{_github_text(check['name'])}`{workflow} {check['state']}{link}")
219
+ look = f"`gh pr checks {number}`, and the log behind each link"
220
+ elif fact == "conflict":
221
+ lines.append(f"- mergeable: CONFLICTING, against `{base}`")
222
+ look = f"bring `{base}` into `{branch}` and resolve the conflicting files; `gh pr view {number}` shows the rest"
223
+ else:
224
+ lines.append(f"- changes requested by {', '.join(_github_text(login) for login in shown) or 'a reviewer'}")
225
+ look = f"`gh pr view {number} --comments`, for what each reviewer asked"
226
+ lines += ["", f"What to look at: {look}.", "",
227
+ "polyctl read this through gh and wrote nothing to GitHub. It mails this fact once for this head "
228
+ "commit: again after a new head, or when the fact clears and returns."]
229
+ return "\n".join(lines) + "\n"
230
+
231
+
232
+ def write_pr_mail(root, cfg, pr, fact, shown):
233
+ """Mail one new fact to whoever holds the implementer role, through the writer every message polyctl writes takes.
234
+
235
+ The name carries the pull request, the fact and the head it stands at, so two facts never share
236
+ a file; the envelope carries them too, for a program that reads it.
237
+ """
238
+ implementer, _ = mail_names(cfg)
239
+ to, head = safe_slug(implementer, "implementer"), pr["headRefOid"]
240
+ stem = f"{time.strftime('%Y%m%d-%H%M')}-pr-watch-to-{to}-PR-{pr['number']}-{fact}-{head[:12]}"
241
+ return write_mail(root, cfg, f"{stem}.md", pr_mail_body(pr, fact, shown),
242
+ {"kind": "pr", "class": "needs-read", "from": "pr-watch", "to": to,
243
+ "pr": pr["number"], "condition": fact, "head": head})
244
+
245
+
246
+ def pr_watch_state(root):
247
+ """(what was mailed, as {number: {fact: {head, mail, at}}}; why the record could not be read, or None).
248
+
249
+ A record polyctl cannot read is set aside rather than trusted: what stands is mailed once more, and the
250
+ pass says so.
251
+ """
252
+ try:
253
+ with open(pr_watch_path(root), encoding=UTF8) as fh:
254
+ document = json.load(fh)
255
+ except FileNotFoundError:
256
+ return {}, None
257
+ except (OSError, ValueError) as exc:
258
+ return {}, f"{type(exc).__name__}: {exc}"
259
+ reported = document.get("reported") if isinstance(document, dict) else None
260
+ if not isinstance(reported, dict) or not all(isinstance(facts, dict) for facts in reported.values()):
261
+ return {}, "it holds no record of mailed facts in the shape polyctl writes"
262
+ return reported, None
263
+
264
+
265
+ def _pr_watch_document(state):
266
+ """What the record holds for `state`: each pull request that has a fact mailed and standing."""
267
+ return (json.dumps({"reported": {number: facts for number, facts in state.items() if facts}}, indent=2,
268
+ sort_keys=True) + "\n").encode(UTF8)
269
+
270
+
271
+ def pr_watch(root, cfg, program):
272
+ """One pass: read every open pull request of this checkout's branches, mail each new fact, record what stands.
273
+
274
+ A fact is new when the pull request's head is not the one it was last mailed at, or when it was
275
+ not standing at the last pass; a fact that cleared is forgotten, so it is mailed again if it
276
+ returns, and so is a pull request that is no longer open. A fact is recorded as soon as it is
277
+ mailed, so a pass stopped part way - killed, or its terminal closed - never mails it twice. One
278
+ pass runs at a time, under a lock beside the record: two would read one record and both mail
279
+ every new fact. Returns None when another pass holds the lock, else {"read", "sent", "standing",
280
+ "cut", "problem"}.
281
+ """
282
+ from .storage import LedgerLockTimeout, _exclusive_lock
283
+ lock = pr_watch_path(root) + ".lock"
284
+ try:
285
+ with _exclusive_lock(lock, timeout=0):
286
+ return _pr_watch_pass(root, cfg, program)
287
+ except LedgerLockTimeout as exc:
288
+ if exc.path != lock:
289
+ raise
290
+ return None
291
+
292
+
293
+ def _pr_watch_pass(root, cfg, program):
294
+ """The pass pr_watch runs under its lock; the record is written whenever what it holds changed."""
295
+ from .storage import replace_file_durably
296
+ pulls, cut = read_pull_requests(root, program)
297
+ reported, problem = pr_watch_state(root)
298
+ state = {number: dict(facts) for number, facts in reported.items()}
299
+ sent, standing = [], []
300
+ on_disk = None if problem else _pr_watch_document(reported) # a record polyctl could not read is replaced
301
+
302
+ def save():
303
+ nonlocal on_disk
304
+ document = _pr_watch_document(state)
305
+ if document != on_disk:
306
+ replace_file_durably(pr_watch_path(root), document)
307
+ on_disk = document
308
+
309
+ try:
310
+ for pr in pulls:
311
+ number, head = str(pr["number"]), pr["headRefOid"]
312
+ before = reported.get(number) or {}
313
+ found, undecided = pr_facts(pr)
314
+ after = state[number] = {fact: mailed for fact, mailed in before.items()
315
+ if fact in found or fact in undecided}
316
+ for fact in PR_FACTS:
317
+ if fact not in found:
318
+ continue
319
+ if isinstance(before.get(fact), dict) and before[fact].get("head") == head:
320
+ standing.append((pr["number"], fact, head))
321
+ continue
322
+ mail = write_pr_mail(root, cfg, pr, fact, found[fact])
323
+ after[fact] = {"head": head, "mail": mail, "at": int(time.time())}
324
+ save() # before the next mail is written, not when the pass ends
325
+ sent.append((pr["number"], fact, head, mail))
326
+ if not cut: # a list gh cut short leaves a pull request unread, not closed
327
+ read = {str(pr["number"]) for pr in pulls}
328
+ state = {number: facts for number, facts in state.items() if number in read}
329
+ finally:
330
+ save()
331
+ return {"read": len(pulls), "sent": sent, "standing": standing, "cut": cut, "problem": problem}