From 6018beea4be5d5e4542dad8abeed8cfdf47cd5ba Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:48:14 -0500 Subject: [PATCH 1/3] fix(pr-verify): trust intake-triage-briefed issues the owner has not vetoed Claim commit: the changelog fragment for the owner's standing rule at https://github.com/melodic-software/architecture/blob/main/docs/owner-decisions.md?plain=1#L318. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtViDMW2P121uLvSb35 --- .../pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md diff --git a/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md b/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md new file mode 100644 index 0000000000..d687784021 --- /dev/null +++ b/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md @@ -0,0 +1,7 @@ +--- +bump: minor +--- + +### Changed + +- pr-verify takes the body of an issue the lanes App filed as its spec once intake admission has briefed it and a listed human has not vetoed it (the owner's standing rule, 2026-11-22). Briefed: the lanes App's newest admission record (``, by its account id, canonical and never edited) names the issue's current title and body by hash. Vetoed: a listed human holds the issue at `needs-owner-decision` or `needs-human`, or its body carries a `hold:` line. An outsider's comment with the marker, an edit after the record, or a hold set by a person keeps the body out of the spec. From c045b6ebac9efde83aa5376a1be3226e32f553a6 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:01:44 -0500 Subject: [PATCH 2/3] fix(pr-verify): trust intake-triage-briefed issues the owner has not vetoed pr-verify (admit.mjs briefedIssue, called from resolve-pr.mjs linkedIssues) and the merge gate (babysit_verify_evidence.py briefed_issue) take the body of a lanes App filing as spec when the lanes App's newest admission record names its current title and body by sha256 and the issue carries no hold label, no provenance: untrusted and no hold: body line. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtViDMW2P121uLvSb35 --- .../fix-trust-briefed-bot-issues-5db14743.md | 2 +- .../fix-trust-briefed-bot-issues-5db14743.md | 7 + .github/scripts/intake-triage/admit.mjs | 39 ++++- .github/scripts/pr-verify/resolve-pr.mjs | 13 +- .github/scripts/pr-verify/resolve-pr.test.mjs | 45 ++++++ docs/conventions/pr-pipeline/README.md | 10 ++ .../scripts/babysit_verify_evidence.py | 150 +++++++++++++++++- .../test_babysit_own_agent_spec_trust.py | 132 +++++++++++++++ .../tests/test_babysit_split_child_trust.py | 5 +- 9 files changed, 391 insertions(+), 12 deletions(-) create mode 100644 .changes/source-control/fix-trust-briefed-bot-issues-5db14743.md diff --git a/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md b/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md index d687784021..50c84eba6e 100644 --- a/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md +++ b/.changes/pr-pipeline/fix-trust-briefed-bot-issues-5db14743.md @@ -4,4 +4,4 @@ bump: minor ### Changed -- pr-verify takes the body of an issue the lanes App filed as its spec once intake admission has briefed it and a listed human has not vetoed it (the owner's standing rule, 2026-11-22). Briefed: the lanes App's newest admission record (``, by its account id, canonical and never edited) names the issue's current title and body by hash. Vetoed: a listed human holds the issue at `needs-owner-decision` or `needs-human`, or its body carries a `hold:` line. An outsider's comment with the marker, an edit after the record, or a hold set by a person keeps the body out of the spec. +- pr-verify takes the body of an issue the lanes App filed as its spec once intake briefed it and no one vetoed it (the owner's standing rule, 2026-11-22). Briefed: the lanes App's newest admission record (``, by its account id, canonical and never edited) names the issue's current title and body by sha256. Vetoed: the issue carries a hold label (`needs-human`, `needs-owner-decision`, `needs-reporter-info`, `needs-spec`) or `provenance: untrusted`, or its body has a `hold:` line (`briefedIssue` in `admit.mjs`). A marker in anyone else's comment, an edit after the record, or a label list that cannot be read whole keeps the body out of the spec. diff --git a/.changes/source-control/fix-trust-briefed-bot-issues-5db14743.md b/.changes/source-control/fix-trust-briefed-bot-issues-5db14743.md new file mode 100644 index 0000000000..ac4aa023a5 --- /dev/null +++ b/.changes/source-control/fix-trust-briefed-bot-issues-5db14743.md @@ -0,0 +1,7 @@ +--- +bump: minor +--- + +### Changed + +- The babysit merge gate trusts an issue the lanes App filed whose newest admission record, posted by the lanes App's account id, canonical and never edited, names its current title and body by sha256, and that carries no hold label, no `provenance: untrusted` and no `hold:` body line (`briefed_issue`), read live at each judgment, matching pr-verify's `briefedIssue`. diff --git a/.github/scripts/intake-triage/admit.mjs b/.github/scripts/intake-triage/admit.mjs index 8856b731c5..6c094b9d92 100644 --- a/.github/scripts/intake-triage/admit.mjs +++ b/.github/scripts/intake-triage/admit.mjs @@ -143,11 +143,11 @@ import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { appCloseKind, isTrustedClose, paginate } from "../../actions/check-trusted-trigger/check-trusted-trigger.mjs"; -import { carried, DECISION_LABELS, isStatusLabel, readyWhileDeferred, StatusReadError } from "../../actions/resolve-config/read-status.mjs"; +import { carried, DECISION_LABELS, HOLD_STATES, isStatusLabel, readyWhileDeferred, StatusReadError } from "../../actions/resolve-config/read-status.mjs"; import { isDecisionComment, selectTrustedIssueComments } from "../../actions/select-trusted-text/select-trusted-text.mjs"; import { OUTSIDE_ACTOR_LABEL, UNTRUSTED_LABEL, UNTRUSTED_LABELS } from "../pr-merge/merge-holds.mjs"; import { ADMIT_MARKER, refusalText, sayWhy as writeWhy } from "../lib/admission-comment.mjs"; -import { writeAdmissionRecord } from "../lib/admission-record.mjs"; +import { matchesRecord, readAdmissionRecord, writeAdmissionRecord } from "../lib/admission-record.mjs"; import { stopLine, subIssueLeftOpen } from "../lib/done-evidence.mjs"; import { PERSON_REASONS, personReasonLines } from "../lib/stop-reason.mjs"; import { closingPulls } from "../work-resolve-issue/report-outcome.mjs"; @@ -2018,6 +2018,41 @@ export function refinementSpec(comments, appId) { return newest?.lastEditedAt == null ? newest : undefined; } +// Whether pr-verify takes the body of `issue` (a GraphQL node: title, body, +// author, labels {totalCount, nodes}, comments as an array of nodes, oldest +// first) as spec because intake briefed it and no one vetoed it: the lanes +// App (a Bot whose id is `appId`) filed it; its newest admission record +// (lib/admission-record.mjs: by the App's account id, canonical, never +// edited) names the current title and body by hash; its labels read whole +// hold no HOLD_STATES state and none of UNTRUSTED_LABELS; and its body has no +// BODY_HOLD line. A record that is not one as written counts nothing. The +// owner's standing rule: +// https://github.com/melodic-software/architecture/blob/main/docs/owner-decisions.md?plain=1#L318. +// babysit_verify_evidence.py briefed_issue is its twin. Pure. +export function briefedIssue(issue, appId) { + const labels = issue?.labels; + if (appId === undefined || issue?.author?.__typename !== "Bot" || issue.author.databaseId !== appId || !Array.isArray(labels?.nodes) || labels.totalCount !== labels.nodes.length) { + return false; + } + const held = new Set([...HOLD_STATES, ...UNTRUSTED_LABELS].map((name) => name.toLowerCase())); + if (names(labels.nodes).some((name) => held.has(String(name ?? "").toLowerCase())) || BODY_HOLD.test(String(issue.body ?? ""))) { + return false; + } + const rest = (issue.comments ?? []).map((comment) => ({ + id: comment?.databaseId, + user: { id: comment?.author?.__typename === "Bot" ? comment.author.databaseId : undefined }, + body: comment?.body, + created_at: comment?.createdAt, + updated_at: comment?.lastEditedAt ?? comment?.createdAt, + })); + try { + const newest = readAdmissionRecord(rest, appId); + return newest !== null && matchesRecord(newest.record, { title: issue.title, body: issue.body }); + } catch { + return false; + } +} + // Whether a GraphQL comment is a refinement of the lanes App's (a Bot whose // id is `appId`): it opens with REFINE_MARKER. Pure. const appRefinement = (comment, appId) => diff --git a/.github/scripts/pr-verify/resolve-pr.mjs b/.github/scripts/pr-verify/resolve-pr.mjs index 71da5eacfe..4488c3e5d1 100644 --- a/.github/scripts/pr-verify/resolve-pr.mjs +++ b/.github/scripts/pr-verify/resolve-pr.mjs @@ -72,7 +72,7 @@ import { titleRenamers } from "../../actions/select-trusted-text/select-trusted- import { issuesSuffix, isVerdictName, NAME } from "./write-verdict.mjs"; import { refsIssue, visibleLines } from "../pr-merge/merge-holds.mjs"; import { GATE_ALIAS, gateEntries } from "../maintenance-reconcile-lost-runs/infra-failure.mjs"; -import { ACTIONS_BOT_ID, actionsBotOnly, baseAdmissionRules, carriesSplit, DRIFT_TITLE, driftIssue, vendoredRows, loadRules, ownAgentIds, ownAgentText, personChecks, readSchedule, refinementSpec, SOURCE_LABEL, sourceLabels, SPLIT_CHILD_MARKER, splitChildBody, splitScope, taskItems, trustedDriftSpec, webHostsFrom } from "../intake-triage/admit.mjs"; +import { ACTIONS_BOT_ID, actionsBotOnly, baseAdmissionRules, briefedIssue, carriesSplit, DRIFT_TITLE, driftIssue, vendoredRows, loadRules, ownAgentIds, ownAgentText, personChecks, readSchedule, refinementSpec, SOURCE_LABEL, sourceLabels, SPLIT_CHILD_MARKER, splitChildBody, splitScope, taskItems, trustedDriftSpec, webHostsFrom } from "../intake-triage/admit.mjs"; import { issueBody, issueTitle, SCHEDULE_MARKER } from "../recurring-schedule/file-due.mjs"; import { FILING, incidentKey, readMarker } from "../maintenance-monitor-signals/issues.mjs"; @@ -113,7 +113,7 @@ const shortList = (message, count, cap) => (Number.isSafeInteger(count) && count const COMMENT_FIELDS = "totalCount pageInfo { hasNextPage endCursor } nodes { databaseId createdAt updatedAt body lastEditedAt author { ...actor } editor { ...actor } }"; const ISSUE_FIELDS = `number repository { nameWithOwner } title body lastEditedAt - author { ...actor } editor { ...actor } labels(first: 50) { nodes { name } } + author { ...actor } editor { ...actor } labels(first: 50) { totalCount nodes { name } } comments(first: 100) { ${COMMENT_FIELDS} }`; const ACTOR = "fragment actor on Actor { __typename login ... on User { databaseId } ... on Bot { databaseId } }"; // The pages after the first of an issue's comments. @@ -964,7 +964,9 @@ async function compareFiles(github, repository, base, head) { // body of an own-agent filing no other account edited that carries exactly // one `source:` label, as admission requires (admit.mjs ownAgentText, under // main's `own-agents`; ADR 0111, -// https://github.com/melodic-software/claude-code-plugins/blob/main/docs/adr/0111-admit-own-agent-filings-sized-small-or-medium-under-a-per-producer-cap.md). Given the +// https://github.com/melodic-software/claude-code-plugins/blob/main/docs/adr/0111-admit-own-agent-filings-sized-small-or-medium-under-a-per-producer-cap.md), +// and the body of a lanes App filing whose newest admission record names it +// as it is and that no one holds (admit.mjs briefedIssue). Given the // `base` branch, a closing issue also carries the siblings that delivered part // of it (`credited_siblings`, creditedSiblings), so its diff is judged for the // rest. An issue the recurring filer opened takes its body from its row of @@ -1114,7 +1116,8 @@ export async function linkedIssues(github, readRefs, repository, number, humans, const childBody = childBodies.get(issue.number); const sources = sourceLabels(issue.labels?.nodes); const ownBody = !written(issue) && childBody === undefined && !String(issue.body ?? "").startsWith(SPLIT_CHILD_MARKER) && sources.length === 1 && SOURCE_LABEL.test(sources[0]) && ownAgentText(issue, ownIds) ? String(issue.body ?? "") : null; - const recurring = written(issue) || childBody !== undefined || ownBody !== null ? null : recurringSpec(issue, schedule); + const briefed = !written(issue) && childBody === undefined && ownBody === null && !String(issue.body ?? "").startsWith(SPLIT_CHILD_MARKER) && briefedIssue({ ...issue, comments: issue.comments.nodes }, laneAppId) ? String(issue.body ?? "") : null; + const recurring = written(issue) || childBody !== undefined || ownBody !== null || briefed !== null ? null : recurringSpec(issue, schedule); const upstreamDrift = written(issue) || childBody !== undefined || recurring !== null ? null : (driftBodies.get(issue.number) ?? null); const incident = written(issue) || childBody !== undefined || recurring !== null || upstreamDrift !== null || !mainRedIncident(issue) ? null : MAIN_RED_SPEC; // A trusted target-subset part's Scope line (admit.mjs splitScope): @@ -1126,7 +1129,7 @@ export async function linkedIssues(github, readRefs, repository, number, humans, ...(recurring !== null && { source: "recurring-schedule" }), ...(upstreamDrift !== null && { source: "upstream-drift" }), ...(incident !== null && { source: "main-red-incident" }), - body: written(issue) && typeof issue.body === "string" ? issue.body : (childBody ?? ownBody ?? recurring ?? upstreamDrift ?? incident), + body: written(issue) && typeof issue.body === "string" ? issue.body : (childBody ?? ownBody ?? briefed ?? recurring ?? upstreamDrift ?? incident), ...(scope !== null && { scope }), comments: issue.comments.nodes.filter((comment) => written(comment) || comment === counted).map((comment) => String(comment.body ?? "")), // The body's done-when items that refinement lists as checks a diff --git a/.github/scripts/pr-verify/resolve-pr.test.mjs b/.github/scripts/pr-verify/resolve-pr.test.mjs index b870141c5e..f628c01b68 100644 --- a/.github/scripts/pr-verify/resolve-pr.test.mjs +++ b/.github/scripts/pr-verify/resolve-pr.test.mjs @@ -28,6 +28,7 @@ import { KEPT_JOBS, keptJobs, shapeJobs } from "./upstream-jobs.mjs"; import { artifactName } from "./write-verdict.mjs"; import { bodyVersion, loadRules, REFINE_MARKER, splitItemsLine } from "../intake-triage/admit.mjs"; import { holds, labelHolds } from "../pr-merge/merge-holds.mjs"; +import { recordBody } from "../lib/admission-record.mjs"; import { tempDir } from "../../../lib/test-tmp.mjs"; const REPO = "example-org/example-repo"; @@ -2572,6 +2573,50 @@ test("an own-agent filing's body is spec only while no other account edited it, } }); +test("a lanes App filing is spec once its admission record names it as it is and no one holds it", async () => { + const BODY = "## Done when\n\n- [ ] Line 3 says nineteen."; + const TITLE = "Fix line 3"; + const app = { __typename: "Bot", login: "some-app", databaseId: VECTORS.app_id }; + const human = { __typename: "User", login: "someone", databaseId: VECTORS.humans[0] }; + const record = (author, text = { title: TITLE, body: BODY }, edited = null) => ({ + databaseId: 900, + createdAt: "2026-11-17T00:00:00Z", + updatedAt: edited ?? "2026-11-17T00:00:00Z", + lastEditedAt: edited, + body: recordBody({ actorId: VECTORS.app_id, ...text }), + author, + editor: edited ? author : null, + }); + const node = ({ comments = [record(app)], labels = [], body = BODY, author = app, editor = null, total } = {}) => ({ + ...ISSUE, + number: 8, + title: TITLE, + body, + lastEditedAt: editor ? "2026-11-18T00:00:00Z" : null, + author, + editor, + labels: { totalCount: total ?? labels.length, nodes: labels.map((name) => ({ name })) }, + comments: { totalCount: comments.length, nodes: comments }, + }); + for (const [name, issue, expected] of [ + ["briefed, no hold", node(), BODY], + ["no admission record", node({ comments: [] }), null], + ["the record in a listed human's comment", node({ comments: [record(human)] }), null], + ["the record in github-actions[bot]'s comment", node({ comments: [record({ __typename: "Bot", login: "github-actions", databaseId: 41898282 })] }), null], + ["the body edited after the record", node({ body: `${BODY}\n- [ ] More.`, editor: human }), null], + ["the record names another title", node({ comments: [record(app, { title: "Other", body: BODY })] }), null], + ["an edited record", node({ comments: [record(app, undefined, "2026-11-17T01:00:00Z")] }), null], + ["held needs-human", node({ labels: ["needs-human"] }), null], + ["held Needs-Owner-Decision", node({ labels: ["Needs-Owner-Decision"] }), null], + ["provenance: untrusted", node({ labels: ["provenance: untrusted"] }), null], + ["a hold: body line", node({ body: `${BODY}\nHold: wait for the owner`, comments: [record(app, { title: TITLE, body: `${BODY}\nHold: wait for the owner` })] }), null], + ["labels not read whole", node({ total: 60 }), null], + ["filed by a listed human's bot twin, not the App", node({ author: { __typename: "Bot", login: "other", databaseId: 99 } }), null], + ]) { + assert.deepEqual(await specBody(issue, null), [[8, expected]], name); + } +}); + // A trusted target-subset part carries its Scope line's targets as `scope`, // which narrows its criteria; any other entry carries none. test("a trusted target-subset child's spec entry carries its scope", async () => { diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 49ab0e1db2..bd4f44e336 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -2923,6 +2923,16 @@ listed human or the lanes App, and no run's patch stopped over the scan job's si (`scan-refused-patch`) since a listed human last added `agent-ready`. A filing short of any of these reads `verify:untrusted-spec`, and a failed read `verify:unreadable`. github-actions[bot] never counts as an own-agent identity, even if the list names it, and comments still count only when a listed human wrote them. +A lanes App filing intake briefed and no one vetoed is spec too (the owner's standing rule, +[owner-decisions L318](https://github.com/melodic-software/architecture/blob/main/docs/owner-decisions.md?plain=1#L318)): +the newest `` comment the lanes App posted, by its account id, +canonical and never edited, names the issue's current title and body by sha256 +(`.github/scripts/lib/admission-record.mjs`), its labels read whole carry no hold state +(`needs-human`, `needs-owner-decision`, `needs-reporter-info`, `needs-spec`) and no +`provenance: untrusted`, and its body has no `hold:` line (`briefedIssue` in `admit.mjs`). The +merge gate reads the same facts again at each judgment (`briefed_issue`), and a Work status hold +on the issue still stops a lane merge (`issue_hold_refusal`). A marker in anyone else's comment, +an edit after the record, or a hold keeps the body out of the spec. The monitoring lane's main-red incident is its own spec too: when github-actions[bot] wrote it and nobody else last edited it, its title is `Restore the failing required checks on main` (`issues.mjs` `FILING`) and its first body line is the marker for `incident:main-red`, it counts for a pull diff --git a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py index 535b12f7f9..90da2e7a82 100755 --- a/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py +++ b/plugins/source-control/skills/babysit-prs/scripts/babysit_verify_evidence.py @@ -121,7 +121,10 @@ exactly one `source: ` label, a listed human or the lanes App sized it small or medium (`counted_size`), and no run's patch stopped over the scan job's cap since a listed human last added agent-ready - (`patch_cap_stopped`), else `verify:untrusted-spec`. A + (`patch_cap_stopped`), or is an issue the lanes App filed whose newest + admission record names its current title and body and that carries no + hold label and no `hold:` body line (`briefed_issue`), else + `verify:untrusted-spec`. A pass refused `verify:spec-changed` for an issue edit or a spec comment added or edited is judged again at the same head: resolve-pr.mjs judges a head whose passes all predate the spec's last change, and the lost-run @@ -815,6 +818,22 @@ def _overcount_refusal(outcome: str) -> str: "labels(first:100){totalCount nodes{name}}}}}" f"{ACTOR_FRAGMENT}" ) +BRIEFED_ISSUE_QUERY = ( + "query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){" + "issue(number:$n){title body author{...actor} " + "labels(first:100){totalCount nodes{name}} " + "comments(last:100){nodes{createdAt lastEditedAt body author{...actor}}}}}}" + f"{ACTOR_FRAGMENT}" +) +ADMISSION_RECORD_MARKER = "" +HEX64_RE = re.compile(r"[0-9a-f]{64}") +UNTRUSTED_PROVENANCE_LABEL = "provenance: untrusted" +BRIEF_HOLD_RE = re.compile( + "(?:^|(?<=[\n\r\N{LINE SEPARATOR}\N{PARAGRAPH SEPARATOR}]))[" + + "".join(c for c in JS_SPACE if c not in "\r\n") + + "]*hold:", + re.IGNORECASE | re.ASCII, +) SIZE_FIELD_KEY = "models.issue-dimensions.fields.size" AGENT_READY_LABEL = "agent-ready" PATCH_CAP_STOP_LINE = ( @@ -1015,6 +1034,100 @@ def own_agent_filing(issue: Any, ids: frozenset[int]) -> bool: ) +def admission_record(comments: list[Any], app_id: int) -> dict[str, Any] | None: + """lib/admission-record.mjs readAdmissionRecord over GraphQL comment + nodes: the newest record the lanes App (a Bot whose id is `app_id`) + posted, or None. An App comment opening with the marker that is not a + canonical, never edited record raises ValueError. Pure.""" + found: list[tuple[float, dict[str, Any]]] = [] + for comment in map(json_object, comments): + author = json_object(comment.get("author")) + text = comment.get("body") + if ( + author.get("__typename") != "Bot" + or author.get("databaseId") != app_id + or not isinstance(text, str) + or not text.startswith(ADMISSION_RECORD_MARKER) + ): + continue + try: + parsed = json.loads(text[len(ADMISSION_RECORD_MARKER) + 1 :]) + except ValueError: + parsed = None + record = json_object(parsed) + actor = record.get("actor_id") + canonical = ADMISSION_RECORD_MARKER + "\n" + json.dumps( + { + "v": 1, + "actor_id": actor, + "title_sha256": record.get("title_sha256"), + "body_sha256": record.get("body_sha256"), + }, + separators=(",", ":"), + ) + at = _event_time(comment.get("createdAt")) + edited = comment.get("lastEditedAt") + if ( + record.get("v") != 1 + or type(record.get("v")) is not int + or type(actor) is not int + or abs(actor) > MAX_SAFE_INTEGER + or not all( + isinstance(record.get(key), str) + and HEX64_RE.fullmatch(record[key]) is not None + for key in ("title_sha256", "body_sha256") + ) + or canonical != text + or at is None + or (edited is not None and edited != comment.get("createdAt")) + ): + raise ValueError("an admission record is not one as written") + found.append((at, record)) + return max(found, key=lambda item: item[0])[1] if found else None + + +def briefed_issue(issue: Any, app_id: int | None) -> bool: + """admit.mjs briefedIssue over `issue` (as `BRIEFED_ISSUE_QUERY` reads + it): the lanes App (`app_id`) filed it, its newest admission record + (`admission_record`) names its current title and body by sha256, its + labels read whole hold no `HOLD_STATES` state nor + `UNTRUSTED_PROVENANCE_LABEL`, and its body has no `hold:` line + (`BRIEF_HOLD_RE`). Pure.""" + issue = json_object(issue) + author = json_object(issue.get("author")) + labels = json_object(issue.get("labels")) + nodes = labels.get("nodes") + if ( + app_id is None + or author.get("__typename") != "Bot" + or author.get("databaseId") != app_id + or not is_json_array(nodes) + or labels.get("totalCount") != len(nodes) + ): + return False + held = {name.lower() for name in (*merge_policy.HOLD_STATES, UNTRUSTED_PROVENANCE_LABEL)} + body = issue.get("body") if isinstance(issue.get("body"), str) else "" + title = issue.get("title") if isinstance(issue.get("title"), str) else "" + if any(str(json_object(n).get("name")).lower() in held for n in nodes) or ( + BRIEF_HOLD_RE.search(body) is not None + ): + return False + comments = json_object(issue.get("comments")).get("nodes") + try: + record = admission_record(comments if is_json_array(comments) else [], app_id) + except ValueError: + return False + + def digest(text: str) -> str: + return hashlib.sha256(text.encode("utf-8", "surrogatepass")).hexdigest() + + return ( + record is not None + and record["title_sha256"] == digest(title) + and record["body_sha256"] == digest(body) + ) + + def size_field(text: str) -> dict[str, Any]: """The Size field's id and option map in the pipeline config `text`. Raises `_Unreadable` when the config names none.""" @@ -1936,6 +2049,9 @@ class Reader: _own_agent_issues: dict[int, tuple[Any, tuple[datetime, ...]]] = field( default_factory=dict ) + _briefed_issues: dict[int, tuple[bool, tuple[datetime, ...]]] = field( + default_factory=dict + ) _sizes: dict[int, tuple[str | None, tuple[datetime, ...]]] = field( default_factory=dict ) @@ -3384,6 +3500,32 @@ def _own_agent(self, issue: dict[str, Any]) -> bool: and not self._patch_capped(number) ) + def _briefed(self, issue: dict[str, Any]) -> bool: + """Whether recorded linked issue `issue`, which the lanes App wrote, + is one intake briefed and no one holds (`briefed_issue`), read live + once per Reader under the Actions token. A failed read raises + `_Unreadable`.""" + number = issue.get("number") + app_id = self._lane_app_id() + if ( + type(number) is not int + or app_id is None + or issue.get("author_type") != "Bot" + or issue.get("author_id") != app_id + ): + return False + if number not in self._briefed_issues: + with run_cache.track() as taken: + run_cache.note(run_cache.now()) + node = self._graphql( + BRIEFED_ISSUE_QUERY, number, "briefed issue", env=self._env() + ).get("issue") + self._briefed_issues[number] = (briefed_issue(node, app_id), tuple(taken)) + briefed, read_at = self._briefed_issues[number] + for at in read_at: + run_cache.note(at) + return briefed + def _drift(self, issue: dict[str, Any], pr: Any, head: Any) -> bool: """Whether recorded linked issue `issue`, which github-actions[bot] wrote, is the upstream-drift workflow's (`drift_issue`) and the pull @@ -3529,8 +3671,9 @@ def _trusted_spec( recurring issue naming its schedule row (`_recurring`), or the upstream-drift workflow's issue for a pull request `pr` that at `head` only modifies its upstream's pages (`_drift`), a main-red - incident the monitoring lane filed (`_incident`), or an own-agent - filing admission admits (`_own_agent`).""" + incident the monitoring lane filed (`_incident`), an own-agent + filing admission admits (`_own_agent`), or a lanes App filing intake + briefed and no one holds (`_briefed`).""" def trusted(issue: dict[str, Any], role: str) -> bool: return self._trusted_actor( @@ -3550,6 +3693,7 @@ def trusted(issue: dict[str, Any], role: str) -> bool: or self._recurring(issue) or self._incident(issue) or self._own_agent(issue) + or self._briefed(issue) for issue in issues ) diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_own_agent_spec_trust.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_own_agent_spec_trust.py index 2226ac5b91..d19d120e24 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_own_agent_spec_trust.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_own_agent_spec_trust.py @@ -126,7 +126,9 @@ def __init__( config: str, comments: list[dict[str, Any]] | None = None, issue_events: list[dict[str, Any]] | None = None, + briefed: list[dict[str, Any]] | None = None, ): + self.briefed = briefed or [] self.comments = comments or [] self.issue_events = issue_events or [] self.issue = issue @@ -170,6 +172,10 @@ def ok(answer: Any) -> subprocess.CompletedProcess[str]: if f"query={ve.OWN_AGENT_ISSUE_QUERY}" in args: answer = {"data": {"repository": {"issue": self.issue}}} return self.served("issue", args, kwargs, answer) + if f"query={ve.BRIEFED_ISSUE_QUERY}" in args: + issue = self.issue | {"comments": {"nodes": self.briefed}} + answer = {"data": {"repository": {"issue": issue}}} + return self.served("briefed", args, kwargs, answer) if f"query={ve.merge_policy.ISSUE_STATUS_QUERY}" in args: nodes = {"timelineItems": {"nodes": self.events}} answer = {"data": {"repository": {"issue": nodes}}} @@ -239,6 +245,7 @@ def judge( identity: str | None = IDENTITY, comments: list[dict[str, Any]] | None = None, issue_events: list[dict[str, Any]] | None = None, + briefed: list[dict[str, Any]] | None = None, ) -> tuple[bool, FakeGitHub]: names = ["source: improvement"] if labels is None else labels issue = { @@ -261,6 +268,7 @@ def judge( config, comments, issue_events, + briefed, ) with ( mock.patch.dict("os.environ", {}, clear=False) as env, @@ -814,5 +822,129 @@ def test_the_repository_own_list_never_names_github_actions(self) -> None: self.assertNotIn(ACTIONS_ID, rules["own-agents"]["identities"]) +BRIEF_BODY = "## Done when\n\n- [ ] The thing is done.\n" +BRIEF_TITLE = "Tidy the thing" + + +def record_comment( + author: dict[str, Any] = APP, + title: str = BRIEF_TITLE, + body: str = BRIEF_BODY, + edited: str | None = None, + at: str = BEFORE, +) -> dict[str, Any]: + """An admission record comment as GraphQL answers it, its text as + lib/admission-record.mjs recordBody writes it.""" + + def digest(text: str) -> str: + return ve.hashlib.sha256(text.encode()).hexdigest() + + record = { + "v": 1, + "actor_id": APP_ID, + "title_sha256": digest(title), + "body_sha256": digest(body), + } + text = f"{ve.ADMISSION_RECORD_MARKER}\n{json.dumps(record, separators=(',', ':'))}" + return {"createdAt": at, "lastEditedAt": edited, "body": text, "author": author} + + +def brief(**kwargs: Any) -> bool: + """The gate's judgment of a lanes App filing with no `source:` label, so + the own-agent rule never decides it, and the record comments given.""" + kwargs.setdefault("labels", []) + kwargs.setdefault("briefed", [record_comment()]) + return judge(**kwargs)[0] + + +class ABriefedFilingNoOneHoldsIsTrusted(unittest.TestCase): + """The owner's standing rule: a lanes App filing intake briefed (its + newest admission record names its title and body as they are) that no + one holds is spec.""" + + def test_a_briefed_filing_is_trusted(self) -> None: + self.assertIs(brief(), True) + + def test_an_older_record_for_other_text_does_not_matter(self) -> None: + older = record_comment(body="old", at="2026-11-09T00:00:00Z") + self.assertIs(brief(briefed=[older, record_comment()]), True) + + def test_an_unbriefed_or_held_filing_is_refused(self) -> None: + held = f"{BRIEF_BODY}Hold: wait for the owner\n" + for why, kwargs in { + "no admission record": {"briefed": []}, + "the record in a listed human's comment": { + "briefed": [record_comment(author=HUMAN)] + }, + "the record in github-actions' comment": { + "briefed": [record_comment(author=ACTIONS)] + }, + "an edited record": {"briefed": [record_comment(edited=AFTER)]}, + "a newer record for other text": { + "briefed": [record_comment(), record_comment(body="new", at=AFTER)] + }, + "the body changed after the record": {"body": f"{BRIEF_BODY}More.\n"}, + "held needs-human": {"labels": ["needs-human"]}, + "held Needs-Owner-Decision": {"labels": ["Needs-Owner-Decision"]}, + "provenance: untrusted": {"labels": ["provenance: untrusted"]}, + "a hold: body line": { + "body": held, + "briefed": [record_comment(body=held)], + }, + "labels cut short": {"labels_total": 101}, + "filed by another bot": {"author": OTHER_BOT}, + }.items(): + with self.subTest(why): + self.assertIs(brief(**kwargs), False) + + def test_a_malformed_app_record_refuses(self) -> None: + bad = record_comment() | {"body": f"{ve.ADMISSION_RECORD_MARKER}\n{{}}"} + self.assertIs(brief(briefed=[bad, record_comment()]), False) + + +@unittest.skipUnless(shutil.which("node"), "node not installed") +class TheGateAndPrVerifyAgreeOnABrief(unittest.TestCase): + def test_briefed_issue_matches_admit_briefed_issue(self) -> None: + held = f"{BRIEF_BODY} hold: later\n" + issues = { + "briefed": ({}, [record_comment()]), + "no record": ({}, []), + "a human's record": ({}, [record_comment(author=HUMAN)]), + "edited record": ({}, [record_comment(edited=AFTER)]), + "body changed": ({"body": "other"}, [record_comment()]), + "needs-spec": ({"labels": {"totalCount": 1, "nodes": [{"name": "needs-spec"}]}}, [record_comment()]), + "hold line": ({"body": held}, [record_comment(body=held)]), + "cut labels": ({"labels": {"totalCount": 3, "nodes": []}}, [record_comment()]), + } + nodes = { + why: { + "title": BRIEF_TITLE, + "body": BRIEF_BODY, + "author": APP, + "labels": {"totalCount": 0, "nodes": []}, + } + | extra + | {"comments": comments} + for why, (extra, comments) in issues.items() + } + script = ( + f"import {{ briefedIssue }} from {json.dumps(ADMIT.as_uri())};" + f" const nodes = {json.dumps(nodes)};" + f" console.log(JSON.stringify(Object.values(nodes).map((n) => briefedIssue(n, {APP_ID}))));" + ) + proc = subprocess.run( + ["node", "--input-type=module", "-e", script], + capture_output=True, + text=True, + check=True, + ) + js = json.loads(proc.stdout) + for (why, node), expected in zip(nodes.items(), js, strict=True): + with self.subTest(why): + gate = node | {"comments": {"nodes": node["comments"]}} + self.assertIs(ve.briefed_issue(gate, APP_ID), expected) + self.assertEqual(js, [True, False, False, False, False, False, False, False]) + + if __name__ == "__main__": unittest.main() diff --git a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_split_child_trust.py b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_split_child_trust.py index 381543578f..e8e088dc5f 100644 --- a/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_split_child_trust.py +++ b/plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_split_child_trust.py @@ -175,7 +175,10 @@ def __call__( answer = {"ref": f"refs/heads/{branch}", "object": self.tips[branch]} return subprocess.CompletedProcess(args, 0, json.dumps(answer), "") if args[:2] == ["api", "graphql"]: - if f"query={ve.OWN_AGENT_ISSUE_QUERY}" in args: + if any( + f"query={query}" in args + for query in (ve.OWN_AGENT_ISSUE_QUERY, ve.BRIEFED_ISSUE_QUERY) + ): payload = {"data": {"repository": {"issue": {}}}} return subprocess.CompletedProcess(args, 0, json.dumps(payload), "") assert any(a == f"query={ve.SPLIT_CHILD_QUERY}" for a in args), args From f8449d48bacda02a06fc85a91b315696cca42faa Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:05:24 -0500 Subject: [PATCH 3/3] test(pr-verify): declare the docs/upstream pages resolve-pr's suite reads The test-selection trace found the suite reading docs/upstream pages (upstreamPages' default directory) that the selector did not map to it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RAoAtViDMW2P121uLvSb35 --- .github/scripts/pr-verify/resolve-pr.test.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/pr-verify/resolve-pr.test.mjs b/.github/scripts/pr-verify/resolve-pr.test.mjs index f628c01b68..f0592478b3 100644 --- a/.github/scripts/pr-verify/resolve-pr.test.mjs +++ b/.github/scripts/pr-verify/resolve-pr.test.mjs @@ -1,3 +1,4 @@ +// test-scope: docs/upstream/* // Expected values come from the verdict rules in // docs/conventions/pr-pipeline/README.md ("Verifier verdict"): only a successful pr-require-checks pull_request run of this // repository starts a verdict, for exactly one open same-repository PR into