@jesdi/skills 0.0.99 → 0.0.101
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.
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +8 -5
- package/skills/implement-spec/README.md +43 -19
- package/skills/implement-spec/SKILL.md +2 -0
- package/skills/implement-spec/driver.py +136 -30
- package/skills/implement-spec/driver_agents.py +13 -0
- package/skills/implement-spec/driver_arbiter.py +57 -11
- package/skills/implement-spec/driver_decisions.py +186 -49
- package/skills/implement-spec/driver_dispute.py +1 -1
- package/skills/implement-spec/driver_final.py +232 -242
- package/skills/implement-spec/driver_final_gate.py +152 -17
- package/skills/implement-spec/driver_gate.py +12 -0
- package/skills/implement-spec/driver_legacy.py +15 -2
- package/skills/implement-spec/driver_overturn.py +106 -0
- package/skills/implement-spec/driver_pr.py +286 -0
- package/skills/implement-spec/driver_report.py +9 -4
- package/skills/implement-spec/driver_review.py +10 -4
- package/skills/implement-spec/driver_run.py +33 -14
- package/skills/implement-spec/driver_slots.py +61 -11
- package/skills/implement-spec/driver_state.py +30 -16
- package/skills/implement-spec/driver_summary.py +10 -3
- package/skills/implement-spec/prompts/arbiter.md +8 -4
- package/skills/implement-spec/prompts/conflict.md +1 -1
- package/skills/implement-spec/prompts/pr-body.md +2 -1
- package/skills/implement-spec/recovery.md +4 -4
- package/skills/implement-spec/tests/conftest.py +1 -0
- package/skills/implement-spec/tests/test_arbiter.py +74 -17
- package/skills/implement-spec/tests/test_arbitration.py +1 -1
- package/skills/implement-spec/tests/test_decisions.py +30 -6
- package/skills/implement-spec/tests/test_driver.py +9 -1
- package/skills/implement-spec/tests/test_final.py +20 -3
- package/skills/implement-spec/tests/test_final_gate.py +144 -0
- package/skills/implement-spec/tests/test_fixloop.py +1 -1
- package/skills/implement-spec/tests/test_leave_out.py +203 -0
- package/skills/implement-spec/tests/test_legacy.py +25 -0
- package/skills/implement-spec/tests/test_lenses.py +6 -4
- package/skills/implement-spec/tests/test_overturn.py +362 -0
- package/skills/implement-spec/tests/test_scoped.py +6 -5
- package/skills/implement-spec/tests/test_ship_draft.py +203 -0
- package/skills/implement-spec/tests/test_slots.py +29 -0
- package/skills/implement-spec/tests/test_state.py +4 -2
- package/skills/implement-spec/tests/test_stops.py +19 -4
- package/skills/implement-spec/tests/test_tidy.py +4 -2
- package/skills/implement-spec/tests/test_walk.py +1 -0
- package/skills-manifest.json +3 -3
|
@@ -2,40 +2,175 @@
|
|
|
2
2
|
|
|
3
3
|
A red record is durable before repair starts. Interrupted repair resumes from it;
|
|
4
4
|
only an accepted batch spends the allowance. Ticket fix budgets never change.
|
|
5
|
+
|
|
6
|
+
A red tip that fails exactly as the base commit (`run.final.onto`) does is not the change's to repair: it passes for
|
|
7
|
+
the run, which goes on to review, and the PR opens as a draft that names both records (`run.final.gate_preexisting`):
|
|
8
|
+
a match of failure lines is a heuristic, not a proof. The full gate runs on the base once per base commit
|
|
9
|
+
(`run.final.base_gate`), in driver_slots.BASE_SLOT, so slot 1 keeps the tip. A failure is a line of the gate output
|
|
10
|
+
that names a failure, an error or an exception (`AssertionError`), but a wrapper's line (`make: ***`, `npm ERR!`,
|
|
11
|
+
`exit code 2`), with times, `:line:col` and the counts of the tests that passed masked; a count of failures, an
|
|
12
|
+
identifier and any other value stay. The tip's failures are old only when both gates judged their commit (a complete
|
|
13
|
+
run with an exit under 128, so not a signal's, on a tree clean after it) and the two have the same failure lines, as
|
|
14
|
+
often. Anything unproven is new.
|
|
5
15
|
"""
|
|
6
16
|
from __future__ import annotations
|
|
7
17
|
|
|
8
18
|
import json
|
|
19
|
+
import re
|
|
20
|
+
from collections import Counter
|
|
21
|
+
from typing import NamedTuple
|
|
9
22
|
|
|
10
23
|
import driver_gate
|
|
11
|
-
|
|
24
|
+
import driver_slots
|
|
25
|
+
from driver_run import FINAL, FINAL_RESUME, OUT, Blocked, Run, ledger
|
|
12
26
|
|
|
13
27
|
RETRY_SUBJECT = 'the full integration gate remains red after its repair'
|
|
28
|
+
# A line that names a failure; `1) Suite does x:` is the title of a failed test in mocha's list.
|
|
29
|
+
_FAILURE = re.compile(r'\b(?:fail(?:ed|ures?|s|ing)?|errors?)\b|(?-i:[a-z]Error)\b|[✗×✖●]|^\d+\) \S', re.I)
|
|
30
|
+
# The line a wrapper prints for any red command it ran: it names no failure of its own.
|
|
31
|
+
_WRAPPER = re.compile(r'^(?:make(?:\[\d+\])?: \*\*\*|npm (?:ERR!|error)|ERR_PNPM_|ELIFECYCLE)'
|
|
32
|
+
r'|\bexit(?:ed)? (?:with )?(?:code|status) -?\d+', re.I)
|
|
33
|
+
# What differs between two runs of the same failures: a time, a :line:col, the count of the tests that did not
|
|
34
|
+
# fail, the place of a failed test in mocha's list. Never a count of failures, nor a number inside an identifier:
|
|
35
|
+
# test_limit[1] keeps its 1.
|
|
36
|
+
_MASKS = ((re.compile(r'(?<![\w.\[-])\d+(?:\.\d+)?m?s(?![\w\]])'), 'Ns'),
|
|
37
|
+
(re.compile(r'(?<=\S):\d+:\d+(?=[\s:]|$)'), ':N:N'),
|
|
38
|
+
(re.compile(r'(?<![\w.\[-])\d+(?= (?:passed|passing|skipped|pending|tests?)\b)', re.I), 'N'),
|
|
39
|
+
(re.compile(r'^\d+\) '), 'N) '))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Red(NamedTuple):
|
|
43
|
+
"""A red full gate to repair: its record, and the red record of the base, "" when the base is not red with it."""
|
|
44
|
+
record: str
|
|
45
|
+
base: str = ''
|
|
14
46
|
|
|
15
47
|
|
|
16
|
-
def failure(run: Run, tip: str) ->
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
|
|
48
|
+
def failure(run: Run, tip: str) -> Red | None:
|
|
49
|
+
"""The red full gate of `tip` to repair, or None when it passed; at the repair cap it parks instead."""
|
|
50
|
+
final = run.state.read()['run']['final']
|
|
51
|
+
red = _red(run, final, tip)
|
|
52
|
+
if not red or _old(run, tip, red):
|
|
53
|
+
return None
|
|
54
|
+
run.state.update(lambda s: s['run']['final'].update(gate_failure=dict(tip=tip, record=red.record)))
|
|
55
|
+
if final['gate_repairs'] >= final['gate_allowance']:
|
|
56
|
+
subject = f'{RETRY_SUBJECT}: {tip[:7]}; read {red.record}'
|
|
57
|
+
run.ask(FINAL, [('ticket-blocked', subject)], red.record, FINAL_RESUME._replace(
|
|
58
|
+
gate_allowance=final['gate_repairs'] + 1))
|
|
59
|
+
raise Blocked(subject)
|
|
60
|
+
return red
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _red(run: Run, final: dict, tip: str) -> Red | None:
|
|
64
|
+
"""The red full gate on `tip`, saved or run now, with the record of the base when the tip's failures need it."""
|
|
65
|
+
if passed(final, tip):
|
|
66
|
+
return None
|
|
20
67
|
pending = final['gate_failure']
|
|
21
68
|
record = (pending['record'] if pending and pending['tip'] == tip
|
|
22
69
|
else run.red_gate(FINAL, '.', tip, driver_gate.FULL))
|
|
23
70
|
if not record:
|
|
71
|
+
return None
|
|
72
|
+
return Red(record, _base_record(run, final['onto']) if _judged(record) else '')
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def failures(output: str) -> Counter:
|
|
76
|
+
"""The failure lines of a gate's output, but a wrapper's, with what differs between runs masked."""
|
|
77
|
+
lines = (line.strip() for line in output.splitlines())
|
|
78
|
+
return Counter(_mask(line) for line in lines if _FAILURE.search(line) and not _WRAPPER.search(line))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _mask(line: str) -> str:
|
|
82
|
+
for pattern, mask in _MASKS:
|
|
83
|
+
line = pattern.sub(mask, line)
|
|
84
|
+
return line
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _judged(record: str) -> Counter:
|
|
88
|
+
"""The failures of a red gate record that judged its commit: a complete run, not ended by a signal, on a tree
|
|
89
|
+
clean after it. No failure for any other record, which proves nothing. An exit from 128 up may be a signal's, as
|
|
90
|
+
a shell reports a crashed child (139 for SIGSEGV), so it judged nothing either."""
|
|
91
|
+
output, code, after = driver_gate.read(record)
|
|
92
|
+
if not (isinstance(code, int) and 0 < code < 128 and after == 'clean'):
|
|
93
|
+
return Counter()
|
|
94
|
+
return failures(output)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def only_old(record: str, base: str) -> bool:
|
|
98
|
+
"""The red gate `record` fails exactly as the red gate `base`: both judged their commit, with the same failure
|
|
99
|
+
lines, as often."""
|
|
100
|
+
found = _judged(record)
|
|
101
|
+
return bool(found) and found == _judged(base)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _old(run: Run, tip: str, red: Red) -> bool:
|
|
105
|
+
"""True, recorded and in the ledger, when the red gate of `tip` fails exactly as the gate of its base."""
|
|
106
|
+
if not (red.base and only_old(red.record, red.base)):
|
|
107
|
+
return False
|
|
108
|
+
final = run.state.update(lambda s: s['run']['final'].update(
|
|
109
|
+
gate_failure=None, gate_preexisting=dict(tip=tip, record=red.record, base=red.base)))['run']['final']
|
|
110
|
+
ledger(f"End of run: {preexisting(final, tip)}, so the run goes on and the PR opens as a draft.")
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def preexisting(final: dict, tip: str) -> str:
|
|
115
|
+
"""The sentence of the full gate on `tip` that is red only as its base is; "" when it is not."""
|
|
116
|
+
old = final['gate_preexisting']
|
|
117
|
+
if not (old and old['tip'] == tip):
|
|
24
118
|
return ''
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
119
|
+
return (f"the full gate is red on {tip[:7]} only with failures that its base {final['onto'][:7]} is red with "
|
|
120
|
+
f"too: read {old['record']} and {old['base']}")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def passed(final: dict, tip: str) -> bool:
|
|
124
|
+
"""The full gate on `tip` is green, or red only as its base is."""
|
|
125
|
+
return tip in final['green_gates'][driver_gate.FULL] or bool(preexisting(final, tip))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def evidence(run: Run, tip: str) -> str:
|
|
129
|
+
"""The full gate evidence of `tip` for an agent: its record, and the sentence of its failures the base has too."""
|
|
130
|
+
record = str(driver_gate.record_path(OUT / FINAL, driver_gate.FULL, tip))
|
|
131
|
+
old = preexisting(run.state.read()['run']['final'], tip)
|
|
132
|
+
return f"{record} ({old}: they are not this change's to fix)" if old else record
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _base_record(run: Run, onto: str) -> str:
|
|
136
|
+
"""The record of the full gate on the base commit `onto` when it is red, "" when it is green or cannot run. It
|
|
137
|
+
runs once per base commit."""
|
|
138
|
+
cached = run.state.read()['run']['final']['base_gate']
|
|
139
|
+
if cached and cached['commit'] == onto:
|
|
140
|
+
return cached['record']
|
|
141
|
+
slot = driver_slots.BASE_SLOT
|
|
142
|
+
if error := (driver_slots.make(slot, 'the base slot', run.args.prepare, start=onto)
|
|
143
|
+
or driver_slots.git(slot, 'checkout', '-q', '--detach', onto).stderr.strip()):
|
|
144
|
+
ledger(f'End of run: the full gate cannot run on the base {onto[:7]}, so each failure counts as new: {error}.')
|
|
145
|
+
return ''
|
|
146
|
+
return _run_base_gate(run, slot, onto)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _run_base_gate(run: Run, slot: str, onto: str) -> str:
|
|
150
|
+
"""Run the full gate on `onto` in `slot` and keep its result. Returns its record when it is red."""
|
|
151
|
+
green, record, killed = driver_gate.run(run.args.gate, driver_gate.FULL, slot, OUT / FINAL / 'base', run.pr, [])
|
|
152
|
+
for sentence in killed:
|
|
153
|
+
ledger(f'End of run: {sentence}.')
|
|
154
|
+
kept = '' if green else str(record)
|
|
155
|
+
|
|
156
|
+
def keep(state: dict) -> None:
|
|
157
|
+
state['run']['gates'][driver_gate.FULL] += 1
|
|
158
|
+
state['run']['final']['base_gate'] = dict(commit=onto, record=kept)
|
|
159
|
+
|
|
160
|
+
run.state.update(keep)
|
|
161
|
+
ledger(f"End of run: the full gate is {'green' if green else 'red'} on the base {onto[:7]}, record {record}.")
|
|
162
|
+
return kept
|
|
32
163
|
|
|
33
164
|
|
|
34
|
-
def pointers(final: dict,
|
|
35
|
-
"""Keep gate-repair evidence separate from review findings and reports.
|
|
36
|
-
|
|
165
|
+
def pointers(final: dict, red: Red, tip: str) -> dict[str, str]:
|
|
166
|
+
"""Keep gate-repair evidence separate from review findings and reports. When the base is red too, the evidence
|
|
167
|
+
names its record: a failure in it is not this change's to repair."""
|
|
168
|
+
also = f"; the base {final['onto'][:7]} is red too, read {red.base}: its failures are not this change's" * bool(
|
|
169
|
+
red.base)
|
|
170
|
+
finding = dict(severity='critical', kind='code', source='gate', file=red.record, line=0,
|
|
37
171
|
title=f'the full integration gate is red on {tip[:7]}',
|
|
38
|
-
evidence=f'Read the exact failure log: {record}')
|
|
172
|
+
evidence=f'Read the exact failure log: {red.record}{also}')
|
|
39
173
|
path = OUT / FINAL / f"gate-findings-{final['gate_repairs']}.json"
|
|
40
174
|
path.write_text(json.dumps([finding], indent=1) + '\n')
|
|
41
|
-
return dict(gate_title=finding["title"], findings=str(path),
|
|
175
|
+
return dict(gate_title=finding["title"], findings=str(path),
|
|
176
|
+
findings_list=f"- critical: {finding['title']}; read {red.record}{also}")
|
|
@@ -70,6 +70,18 @@ def _attempt(command: str, tier: str, slot: str, commit: str, record: Path, env:
|
|
|
70
70
|
return code, after
|
|
71
71
|
|
|
72
72
|
|
|
73
|
+
def read(record: str | Path) -> tuple[str, int | str, str]:
|
|
74
|
+
"""(the command's output, its exit code or "not run", what it left behind) of a record that _attempt wrote. A
|
|
75
|
+
record with no end, as a driver stopped mid-command leaves it, has the exit "" and the after "": it judged
|
|
76
|
+
nothing."""
|
|
77
|
+
rest = Path(record).read_text(errors="replace").partition("\n\n")[2]
|
|
78
|
+
output, ended, tail = rest.rpartition("\nexit: ")
|
|
79
|
+
if not (ended and "\nend: " in tail):
|
|
80
|
+
return rest, "", ""
|
|
81
|
+
code, _, after = tail.rpartition("\nend: ")[0].partition("\nafter: ")
|
|
82
|
+
return output, int(code) if code.lstrip("-").isdigit() else code, after
|
|
83
|
+
|
|
84
|
+
|
|
73
85
|
def run(command: str, tier: str, slot: str, folder: Path, pr_branch: str,
|
|
74
86
|
locked: list[str]) -> tuple[bool, Path, list[str]]:
|
|
75
87
|
"""Gate the HEAD of `slot` on `tier`, the fast gate on the `locked` files. Returns (green, the record, a ledger
|
|
@@ -5,7 +5,8 @@ Every run of a newer driver holds `lock` (driver._hold), so a newer and an older
|
|
|
5
5
|
at the same time. The driver calls `resume` once, after the locks and before any check reads a ref: a run with no
|
|
6
6
|
`schema` in state.json gets the new names of its refs; a run before schema 3 gets its gates as the full tier; a run
|
|
7
7
|
before schema 4 keeps the ruling of each answered question, and one with an open question of a removed kind stops;
|
|
8
|
-
a run before schema 5 gets its rulings and corrections keyed by their test
|
|
8
|
+
a run before schema 5 gets its rulings and corrections keyed by their test; a run before schema 6 gets each open
|
|
9
|
+
`finding-open` question on a critical or must-fix finding as a `finding-must-fix` one, so no arbiter ships it.
|
|
9
10
|
ponytail: delete this module, tests/test_legacy.py and its one line in driver._hold and in driver._start_errors
|
|
10
11
|
once no older driver is left.
|
|
11
12
|
"""
|
|
@@ -169,9 +170,20 @@ def _all_per_test(state: dict) -> None:
|
|
|
169
170
|
_per_test(entry, [path for path in asked if path.exists()])
|
|
170
171
|
|
|
171
172
|
|
|
173
|
+
def _must_fix(run: dict) -> None:
|
|
174
|
+
"""Schema 6: an open `finding-open` question on a critical or must-fix finding of the last review becomes a
|
|
175
|
+
`finding-must-fix` one. It keeps its id and the fields decisions.json shows, and both kinds offer the same options,
|
|
176
|
+
so decisions.json keeps its revision and an answer given to it still counts."""
|
|
177
|
+
must_fix = {driver_decisions.subject(one) for one in run.get("final", {}).get("open", [])
|
|
178
|
+
if driver_decisions.finding_kind(one) == driver_decisions.MUST_FIX}
|
|
179
|
+
for q in run.get("questions", []):
|
|
180
|
+
if (q["answer"], q["kind"]) == (None, driver_decisions.FINDING_OPEN) and q["subject"] in must_fix:
|
|
181
|
+
q["kind"] = driver_decisions.MUST_FIX
|
|
182
|
+
|
|
183
|
+
|
|
172
184
|
def _upgraded(state: dict) -> None:
|
|
173
185
|
"""Schema 3: every gate of an older driver was the full gate, so its greens and its count are of the full tier.
|
|
174
|
-
Schema 4: an answered question keeps its ruling sentence. Schema 5: see `_per_test`."""
|
|
186
|
+
Schema 4: an answered question keeps its ruling sentence. Schema 5: see `_per_test`. Schema 6: see `_must_fix`."""
|
|
175
187
|
run = state["run"]
|
|
176
188
|
for q in run.get("questions", []):
|
|
177
189
|
if q["answer"] is not None:
|
|
@@ -180,6 +192,7 @@ def _upgraded(state: dict) -> None:
|
|
|
180
192
|
if isinstance(record.get("green_gates"), list):
|
|
181
193
|
record["green_gates"] = {**driver_state.tiers(), "full": record["green_gates"]}
|
|
182
194
|
_all_per_test(state)
|
|
195
|
+
_must_fix(run)
|
|
183
196
|
if isinstance(run.get("gates"), int):
|
|
184
197
|
run["gates"] = {"fast": 0, "full": run["gates"]}
|
|
185
198
|
run["schema"] = driver_state.SCHEMA
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Overturn a ruling after the run: `--answer <question id>=<other option>` on a question the driver or the arbiter
|
|
2
|
+
answered with no operator. The overturn takes effect as an answer to that question would, from where the run is: an
|
|
3
|
+
accepted finding gets a fix batch, a left-out ticket runs again, an end-of-run stop shipped as draft runs again. The
|
|
4
|
+
work it adds lands on top of the PR branch, so the push needs no force. It never undoes work, so an overturn that
|
|
5
|
+
would is refused, as is one that cannot take effect. No agent ships a `finding-must-fix` finding, so the only ruling of
|
|
6
|
+
one to overturn is the driver's `retry`, whose work ran: an overturn never ships it but by the operator's own answer."""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import driver_final
|
|
10
|
+
import driver_pr
|
|
11
|
+
from driver_decisions import FINAL, FINDINGS, OPERATOR, ruled_by
|
|
12
|
+
|
|
13
|
+
EDITS = ("edit", "edit-spec") # they keep a stop BLOCKED; an overturn lets the run go on
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def split(pairs: list[tuple[str, str]], document: dict) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]:
|
|
17
|
+
"""(the `--answer` pairs of an open question of `document`, the overturns: every other pair)."""
|
|
18
|
+
open_ids = {q["id"] for q in document["questions"]}
|
|
19
|
+
return [pair for pair in pairs if pair[0] in open_ids], [pair for pair in pairs if pair[0] not in open_ids]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def refusals(pairs: list[tuple[str, str]], state: dict) -> list[str]:
|
|
23
|
+
"""The usage error of each overturn in `pairs` that state.json `state` refuses."""
|
|
24
|
+
asked = {q["id"]: q for q in state["run"]["questions"]}
|
|
25
|
+
return [f"--answer {question}={option}: {why}" for question, option in pairs
|
|
26
|
+
if (why := _refusal(asked.get(question), question, option, state))]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _refusal(q: dict | None, question: str, option: str, state: dict) -> str:
|
|
30
|
+
"""Why the overturn of `question` to `option` is refused; "" when it takes effect."""
|
|
31
|
+
if q is None:
|
|
32
|
+
return f"there is no question {question}"
|
|
33
|
+
return next((why for check in _CHECKS if (why := check(q, option, state))), "")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _operators(q: dict, option: str, state: dict) -> str:
|
|
37
|
+
if ruled_by(q) == OPERATOR:
|
|
38
|
+
return f"you answered {q['id']}: only a ruling of the driver or the arbiter is overturned"
|
|
39
|
+
return ""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _offered(q: dict, option: str, state: dict) -> str:
|
|
43
|
+
offered = [o["id"] for o in q["options"]]
|
|
44
|
+
if option not in offered:
|
|
45
|
+
return f"{q['id']} offers {', '.join(offered)}"
|
|
46
|
+
return f"{q['id']} is answered {option} already" if option == q["answer"] else ""
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _ran(q: dict, option: str, state: dict) -> str:
|
|
50
|
+
"""A `retry` or a `correct-test` started work that is on the branch now."""
|
|
51
|
+
if q["answer"] in ("retry", "correct-test"):
|
|
52
|
+
return f"the {q['answer']} of the {q['by']} ran: its work is on the branch, and an overturn undoes no work"
|
|
53
|
+
return ""
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _edits(q: dict, option: str, state: dict) -> str:
|
|
57
|
+
if option in EDITS:
|
|
58
|
+
return (f"an overturn takes an option that lets the run go on: edit the spec or the ticket, then overturn "
|
|
59
|
+
f"{q['id']} to an option that runs the work again")
|
|
60
|
+
return ""
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _owner(ticket: str) -> str:
|
|
64
|
+
return "the end of run" if ticket == FINAL else f"ticket {ticket}"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _later(q: dict, option: str, state: dict) -> str:
|
|
68
|
+
"""Only the newest stop of a ticket, or of the end of run, is where the run is."""
|
|
69
|
+
later = [other["id"] for other in state["run"]["questions"]
|
|
70
|
+
if other["ticket"] == q["ticket"] and other["stop"] > q["stop"]]
|
|
71
|
+
if later:
|
|
72
|
+
owner = _owner(q["ticket"])
|
|
73
|
+
return f"a later stop of {owner} asked {later[-1]}: only the newest stop of {owner} is overturned"
|
|
74
|
+
return ""
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _merged(q: dict, option: str, state: dict) -> str:
|
|
78
|
+
if state["tickets"].get(q["ticket"], {}).get("phase") == "merged":
|
|
79
|
+
return f"ticket {q['ticket']} merged since: its work is on the PR branch"
|
|
80
|
+
return ""
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def _closed(q: dict, option: str, state: dict) -> str:
|
|
84
|
+
"""A `retry` of a finding needs it open after the last review: the fix batch is due for the open findings."""
|
|
85
|
+
if q["kind"] in FINDINGS and option == "retry" and not driver_final.due(state["run"]["final"], q["subject"]):
|
|
86
|
+
return "the last review leaves the finding closed: no fix batch is due for it"
|
|
87
|
+
return ""
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _written(q: dict, option: str, state: dict) -> str:
|
|
91
|
+
"""The pr-writer runs only before the PR opens."""
|
|
92
|
+
if q.get("role") == "pr-writer" and state["run"]["final"]["pr"]:
|
|
93
|
+
return "the PR is open, so the pr-writer does not run again: edit its body on GitHub"
|
|
94
|
+
return ""
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _gone(q: dict, option: str, state: dict) -> str:
|
|
98
|
+
"""The work of an overturn goes onto the open PR: a merged or closed one takes none. Last, as it asks gh."""
|
|
99
|
+
url = state["run"]["final"]["pr"]
|
|
100
|
+
shown = driver_pr.state(url) if url else "OPEN"
|
|
101
|
+
if shown == "OPEN":
|
|
102
|
+
return ""
|
|
103
|
+
return f"the PR {url} is {shown.lower() or 'not readable with gh'}: an overturn adds work to an open PR only"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
_CHECKS = (_operators, _offered, _ran, _edits, _later, _merged, _closed, _written, _gone)
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"""The PR of the end of run: its body, the pr-writer's part and the facts of the driver, and its opening with `gh`,
|
|
2
|
+
once. Once it is open, a push only adds commits to it, and its body follows what an overturn changed: the facts each
|
|
3
|
+
time, the pr-writer's part when a ticket landed after the tidy (driver_final.landed_after_tidy clears `final.body`).
|
|
4
|
+
|
|
5
|
+
`run.final` of state.json (driver_final) keeps what this module needs: `body`, the tip the pr-writer's part was written
|
|
6
|
+
for, None until it is and again once a ticket lands after the tidy; `pr`, its URL; `draft`."""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
import driver_agents
|
|
14
|
+
import driver_decisions
|
|
15
|
+
import driver_final_gate
|
|
16
|
+
from driver_review import title
|
|
17
|
+
from driver_run import FINAL, OUT, Blocked, Call, Run, during, final_values, ledger
|
|
18
|
+
from driver_slots import git
|
|
19
|
+
from driver_tickets import Ticket
|
|
20
|
+
|
|
21
|
+
BODY, WRITER = OUT / FINAL / "pr-body.md", OUT / FINAL / "pr-writer-body.md"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def pr_skill() -> Path | None:
|
|
25
|
+
"""The SKILL.md of the pr skill, which the PR body follows."""
|
|
26
|
+
return driver_agents.installed("pr")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def pr_risk_skill() -> Path | None:
|
|
30
|
+
"""The SKILL.md of the pr-risk skill, which parses and validates the merge-risk block of the PR body."""
|
|
31
|
+
return driver_agents.installed("pr-risk")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
PR_RISK_INSTALL = "`npx skills add jesdi/general-skills --skill pr-risk`"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _risk_errors(method: Path, body: str) -> str:
|
|
38
|
+
"""The errors of the merge-risk block of `body` as `pr-risk` names them, or "" when the block is valid."""
|
|
39
|
+
checked = OUT / FINAL / "pr-risk-check.md"
|
|
40
|
+
checked.write_text(body)
|
|
41
|
+
done = subprocess.run([sys.executable, str(method.parent / "merge_risk.py"), "validate", str(checked)],
|
|
42
|
+
capture_output=True, text=True)
|
|
43
|
+
return (done.stdout + done.stderr).strip() if done.returncode else ""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def left_out(run: Run) -> list[str]:
|
|
47
|
+
"""The tickets left out of the run (driver_decisions.left_out), which the end of run ships without."""
|
|
48
|
+
return sorted(driver_decisions.left_out(run.state.read()["run"]["questions"], run.tickets))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _name(run: Run) -> str:
|
|
52
|
+
"""The title of the PR: the first heading of the spec, else the PR branch."""
|
|
53
|
+
spec = Path(run.args.spec)
|
|
54
|
+
lines = spec.read_text(errors="replace").splitlines() if spec.is_file() else []
|
|
55
|
+
return next((line[2:].strip() for line in lines if line.startswith("# ")), run.pr)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _coverage(final: dict, tip: str) -> dict[str, str]:
|
|
59
|
+
"""The review coverage of the pushed tip `tip` in the PR body: the tips and the commits after the reviewed tip
|
|
60
|
+
that no review covered; the full review, which may include gate repairs made after tidy; the scoped review of the
|
|
61
|
+
remaining range. A draft shipped before any review was settled has neither review."""
|
|
62
|
+
reviewed = final["reviewed"]
|
|
63
|
+
full_tip = next(iter(final["lenses"].values()), {"tip": final["tidied"]})["tip"]
|
|
64
|
+
fields = {"tips": f"Branch tip and reviewed tip: {tip}", "full_review": f"{final['onto']}..{full_tip}",
|
|
65
|
+
"scoped": f"{full_tip}..{reviewed}" if full_tip != reviewed else "not needed"}
|
|
66
|
+
if not reviewed:
|
|
67
|
+
fields.update(full_review="not run", scoped="not run")
|
|
68
|
+
if tip != reviewed:
|
|
69
|
+
since = f"{reviewed or final['onto']}..{tip}"
|
|
70
|
+
unreviewed = git(".", "log", "--reverse", "--format=%h %s", since).stdout.strip().splitlines()
|
|
71
|
+
fields["tips"] = f"Branch tip: {tip}; reviewed tip: {reviewed or 'none'}; not reviewed: {'; '.join(unreviewed)}"
|
|
72
|
+
return fields
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _ticket_map(final: dict, titles: dict[str, str], left: list[str]) -> str:
|
|
76
|
+
"""The ticket-to-commit map, then the tickets `left` out of the run."""
|
|
77
|
+
out = "; ".join(f"{number} {titles[number]}" for number in left)
|
|
78
|
+
return ("\n".join(f"- {number}: {commit[:7]} {titles[number]}" for number, commit in final["commits"].items())
|
|
79
|
+
+ f"\n\nLeft out of the run, so not in this PR: {out}." * bool(left))
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _facts(run: Run, final: dict, tickets: list[Ticket], tip: str) -> str:
|
|
83
|
+
"""The end of the PR body for the pushed tip `tip`: the ticket-to-commit map, the fix commits, the rulings and the
|
|
84
|
+
review coverage."""
|
|
85
|
+
titles = {ticket.number: ticket.title for ticket in tickets}
|
|
86
|
+
fixes = git(".", "log", "--reverse", "--format=- %h %s", f"{final['tidied']}..{tip}").stdout.strip()
|
|
87
|
+
rulings = driver_decisions.rulings(run.state.read()["run"]["questions"])
|
|
88
|
+
return driver_agents.render("pr-body", {
|
|
89
|
+
"map": _ticket_map(final, titles, left_out(run)),
|
|
90
|
+
"fixes": fixes or "None.", "rulings": "\n".join(f"- {ruling}" for ruling in rulings) or "None.",
|
|
91
|
+
**_coverage(final, tip), "gate": _old_failures(final, tip),
|
|
92
|
+
"providers": _review_providers(run.state.read()["run"]["agents"])})
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _old_failures(final: dict, tip: str) -> str:
|
|
96
|
+
"""The body's line on the failures of the full gate on the pushed tip `tip` that its base has too; "" for none."""
|
|
97
|
+
old = driver_final_gate.preexisting(final, tip)
|
|
98
|
+
return f"- Pre-existing failures: {old}" if old else ""
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# The roles that review code, with their line in the PR body, and the roles that write it.
|
|
102
|
+
_REVIEWS = {"reviewer": "Ticket reviews", "final-correctness": "Correctness lens", "final-reviewer": "Scoped review"}
|
|
103
|
+
_AUTHORS = ("implementer", "fixer", "conflict")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _review_providers(agents: list[dict]) -> str:
|
|
107
|
+
"""One line per reviewing role that ran: the entries it ran on, and whether one of them shares a provider with an
|
|
108
|
+
entry that wrote code. It reads the agents that ran, so a preflight fallback of an earlier invocation that a later
|
|
109
|
+
one undid is not claimed."""
|
|
110
|
+
wrote = {driver_agents.split(entry)[0] for entry in _entries(agents, _AUTHORS)}
|
|
111
|
+
lines = []
|
|
112
|
+
for role, label in _REVIEWS.items():
|
|
113
|
+
if used := _entries(agents, (role,)):
|
|
114
|
+
same = any(driver_agents.split(entry)[0] in wrote for entry in used)
|
|
115
|
+
lines.append(f"- {label} ran on: {', '.join(used)}" + (", on a provider that also wrote code" * same))
|
|
116
|
+
return "\n".join(lines)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _entries(agents: list[dict], roles: tuple[str, ...]) -> list[str]:
|
|
120
|
+
"""The entries that the agents of `roles` ran on."""
|
|
121
|
+
return sorted({agent["entry"] for agent in agents if agent["role"] in roles})
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _run_pr_writer(run: Run, tip: str, risk: Path, values: dict) -> str:
|
|
125
|
+
"""Run the pr-writer, and once more with the errors of its merge-risk block. Returns the body it wrote."""
|
|
126
|
+
for round_ in range(2):
|
|
127
|
+
with during("the PR body"):
|
|
128
|
+
report = run.read_only(FINAL, ".", run.pr, tip,
|
|
129
|
+
lambda: run.agent(Call("pr-writer", FINAL, ".", values, fix_round=round_)))
|
|
130
|
+
if not (errors := _risk_errors(risk, report["body"])):
|
|
131
|
+
return report["body"]
|
|
132
|
+
values["risk_errors"] = (f"Your previous body has an invalid merge-risk block. Fix it with the pr-risk "
|
|
133
|
+
f"skill; its errors:\n{errors}\n")
|
|
134
|
+
raise Blocked(f"the merge-risk block of the PR body is invalid after a second run of the pr-writer: {errors}")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _body_skills() -> tuple[Path, Path]:
|
|
138
|
+
"""The `pr` skill the body follows and the `pr-risk` skill its merge-risk block follows; Blocked when one is
|
|
139
|
+
missing."""
|
|
140
|
+
method, risk = pr_skill(), pr_risk_skill()
|
|
141
|
+
if not method:
|
|
142
|
+
raise Blocked("the pr skill is missing: the PR body follows it; install it with "
|
|
143
|
+
"`npx skills add mattpocock/skills --skill pr`")
|
|
144
|
+
if not risk:
|
|
145
|
+
raise Blocked(f"the pr-risk skill is missing: the PR body carries its merge-risk block; install it with "
|
|
146
|
+
f"{PR_RISK_INSTALL}")
|
|
147
|
+
return method, risk
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _writer_body(run: Run, final: dict, tickets: list[Ticket], tip: str) -> str:
|
|
151
|
+
"""What the pr-writer wrote for the pushed tip `tip` with the method of the pr skill, its merge-risk block
|
|
152
|
+
validated. A body written for that tip is kept when its merge-risk block still validates, so a PR that failed to
|
|
153
|
+
open costs no second agent; once the PR is open, a body written for any tip is kept, until a ticket lands after
|
|
154
|
+
the tidy and its work is in no word of it."""
|
|
155
|
+
if kept := _kept(final, tip):
|
|
156
|
+
return kept
|
|
157
|
+
method, risk = _body_skills()
|
|
158
|
+
values = {**final_values(run), "start_sha": tip, "range": f"{final['onto']}..{tip}",
|
|
159
|
+
"gate": driver_final_gate.evidence(run, tip), "pr_skill": str(method),
|
|
160
|
+
"pr_risk_skill": str(risk), "risk_errors": "", "facts": _facts(run, final, tickets, tip)}
|
|
161
|
+
WRITER.write_text(_run_pr_writer(run, tip, risk, values).strip() + "\n")
|
|
162
|
+
run.state.update(lambda state: state["run"]["final"].update(body=tip))
|
|
163
|
+
return WRITER.read_text()
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _kept(final: dict, tip: str) -> str:
|
|
167
|
+
"""The body the pr-writer wrote that `_writer_body` keeps, when its merge-risk block still validates; "" else."""
|
|
168
|
+
risk = pr_risk_skill()
|
|
169
|
+
if not (_written(final, tip) and WRITER.is_file() and risk):
|
|
170
|
+
return ""
|
|
171
|
+
body = WRITER.read_text()
|
|
172
|
+
return "" if _risk_errors(risk, body) else body
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _written(final: dict, tip: str) -> bool:
|
|
176
|
+
"""The pr-writer's body is for `tip`, or, once the PR is open, for any tip since no ticket landed after the tidy."""
|
|
177
|
+
return final["body"] == tip or bool(final["pr"] and final["body"])
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def _gh(argv: list[str], what: str) -> str:
|
|
181
|
+
"""Run `gh` and return the URL it prints last."""
|
|
182
|
+
made = subprocess.run(["gh", *argv], capture_output=True, text=True, stdin=subprocess.DEVNULL)
|
|
183
|
+
if made.returncode:
|
|
184
|
+
raise Blocked(f"gh {what} failed: {(made.stderr or made.stdout).strip()}")
|
|
185
|
+
return (made.stdout.split() or [""])[-1]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _draft(final: dict, questions: list[dict], left: list[str], tip: str) -> str:
|
|
189
|
+
"""Why the PR of `tip` opens as draft; "" for a PR ready for review: the end-of-run stops that a `ship-draft` ruling
|
|
190
|
+
ships with, the tickets `left` out, the findings still open that the draft or an agent's ruling ships, and a full
|
|
191
|
+
gate red only as its base is, which a match of failure lines does not prove (driver_final_gate)."""
|
|
192
|
+
reasons = []
|
|
193
|
+
if final["ship"]:
|
|
194
|
+
reasons.append(f"the end of run stopped: {'; '.join(stop['subject'] for stop in final['ship']['stops'])}")
|
|
195
|
+
if left:
|
|
196
|
+
reasons.append(f"tickets are left out of the run: {', '.join(left)}")
|
|
197
|
+
if shipped := _shipped_open(final, questions):
|
|
198
|
+
reasons.append(f"a finding ships open: {'; '.join(shipped)}")
|
|
199
|
+
if preexisting := driver_final_gate.preexisting(final, tip):
|
|
200
|
+
reasons.append(preexisting)
|
|
201
|
+
return "; ".join(reasons)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _shipped_open(final: dict, questions: list[dict]) -> list[str]:
|
|
205
|
+
"""The titles of the findings still open that make a draft: all of them under a `ship-draft` ruling, else those an
|
|
206
|
+
agent's ruling shipped; the operator's own `accept` or `follow-up` keeps the PR ready."""
|
|
207
|
+
ship = final["ship"]
|
|
208
|
+
return [title(one) for one in final["open"] if ship or driver_decisions.agent_shipped(questions, one)]
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _file_follow_ups(run: Run) -> None:
|
|
212
|
+
"""File each finding ruled `follow-up` as an issue, once: the PR body then links it. The issue carries a marker
|
|
213
|
+
of the run and the question, so a run that stopped after `gh` filed it and before state.json kept its URL finds it
|
|
214
|
+
again instead of filing it twice."""
|
|
215
|
+
state = run.state.read()["run"]
|
|
216
|
+
for q in driver_decisions.follow_ups(state["questions"]):
|
|
217
|
+
marker = f"implement-spec follow-up {state['revision']}/{q['id']}"
|
|
218
|
+
body = (f"A finding the final review of {run.pr} left open, shipped with its PR by this ruling:\n\n"
|
|
219
|
+
f"{q['ruling']}\n\nEvidence: {q['evidence'][0]}\n\n{marker}\n")
|
|
220
|
+
url = (_gh(["issue", "list", "--state", "all", "--search", f'"{marker}" in:body', "--json", "url", "--jq",
|
|
221
|
+
".[].url"], "issue list")
|
|
222
|
+
or _gh(["issue", "create", "--title", q["subject"], "--body", body], "issue create"))
|
|
223
|
+
|
|
224
|
+
def record(state: dict, ruled: str = q["id"], issue: str = url) -> None:
|
|
225
|
+
next(one for one in state["run"]["questions"] if one["id"] == ruled)["issue"] = issue
|
|
226
|
+
|
|
227
|
+
run.state.update(record)
|
|
228
|
+
ledger(f"End of run: the follow-up {q['subject']} is filed as {url}.")
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _body(run: Run, final: dict, tickets: list[Ticket], tip: str) -> str:
|
|
232
|
+
"""The PR body for the pushed tip `tip`: the pr-writer's part, then the facts of the run; only the facts when the
|
|
233
|
+
pr-writer is an end-of-run stop that a `ship-draft` ruling ships. The follow-up issues are filed once the
|
|
234
|
+
pr-writer's part is valid, so a run that cannot open its PR files none, and the facts link them."""
|
|
235
|
+
stops = final["ship"]["stops"] if final["ship"] else []
|
|
236
|
+
writer = "" if any(stop["role"] == "pr-writer" for stop in stops) else _writer_body(run, final, tickets, tip)
|
|
237
|
+
_file_follow_ups(run)
|
|
238
|
+
return "\n\n".join(filter(None, [writer.strip(), _facts(run, final, tickets, tip)]))
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _open(run: Run, final: dict, tickets: list[Ticket], tip: str) -> str:
|
|
242
|
+
"""Open the PR of the pushed tip `tip`, ready for review or as draft, and return its URL."""
|
|
243
|
+
BODY.write_text(_body(run, final, tickets, tip))
|
|
244
|
+
draft = _draft(final, run.state.read()["run"]["questions"], left_out(run), tip)
|
|
245
|
+
url = _gh(["pr", "create", "--base", final["base"], "--head", run.pr, "--title", _name(run), "--body-file",
|
|
246
|
+
str(BODY), *["--draft"] * bool(draft)], "pr create")
|
|
247
|
+
run.state.update(lambda state: state["run"]["final"].update(pr=url, draft=bool(draft)))
|
|
248
|
+
ledger(f"The PR of {run.pr} into {final['base']} is open{f' as a draft: {draft}' * bool(draft)}: {url}.")
|
|
249
|
+
return url
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _refresh(run: Run, final: dict, tickets: list[Ticket], tip: str) -> None:
|
|
253
|
+
"""Write the body of the open PR again once what it says changed: an overturn's work, its ruling, its follow-up
|
|
254
|
+
issue, a ticket that landed after the tidy. The draft state stays. BODY is the body GitHub has: the new one
|
|
255
|
+
replaces it only once `gh pr edit` took it, so a failed edit is tried again by the next run."""
|
|
256
|
+
text = _body(run, final, tickets, tip)
|
|
257
|
+
if BODY.is_file() and BODY.read_text() == text:
|
|
258
|
+
return
|
|
259
|
+
require_open(final)
|
|
260
|
+
pending = BODY.with_name("pr-body.pending.md")
|
|
261
|
+
pending.write_text(text)
|
|
262
|
+
_gh(["pr", "edit", final["pr"], "--body-file", str(pending)], "pr edit")
|
|
263
|
+
pending.replace(BODY)
|
|
264
|
+
ledger(f"The body of the PR {final['pr']} is written again with the facts of the run at {tip[:7]}.")
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def pr(run: Run, final: dict, tickets: list[Ticket], tip: str) -> str:
|
|
268
|
+
"""The URL of the PR of the pushed tip `tip`: open it, once; once it is open, its body follows the run."""
|
|
269
|
+
if not final["pr"]:
|
|
270
|
+
return _open(run, final, tickets, tip)
|
|
271
|
+
_refresh(run, final, tickets, tip)
|
|
272
|
+
return final["pr"]
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def require_open(final: dict) -> None:
|
|
276
|
+
"""Once the PR is open, a push or a body goes out only while it is open: a run of an overturn that stopped may
|
|
277
|
+
resume after the PR was merged or closed."""
|
|
278
|
+
if final["pr"] and (shown := state(final["pr"])) != "OPEN":
|
|
279
|
+
raise Blocked(f"the PR {final['pr']} is {shown.lower() or 'not readable with gh'}: nothing goes out to it")
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def state(url: str) -> str:
|
|
283
|
+
"""The state of the PR at `url` as gh gives it: OPEN, MERGED or CLOSED; "" when gh cannot tell."""
|
|
284
|
+
shown = subprocess.run(["gh", "pr", "view", url, "--json", "state", "--jq", ".state"], capture_output=True,
|
|
285
|
+
text=True, stdin=subprocess.DEVNULL)
|
|
286
|
+
return shown.stdout.strip() if shown.returncode == 0 else ""
|