Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
bump: minor
---

### Changed

- A trusted upstream-drift issue (github-actions[bot] wrote it, nobody else last edited it, and its title and first body line are the filer's) reaches the issue lane with no owner step. One rule in `admit.mjs` (`driftIssueId`, through `authorTrust` for a REST read) decides it at every author gate: the triage sweep, which now dispatches intake for it while still skipping every other github-actions[bot] issue; `apply-verdict.mjs`; admission criteria 7 and 9; `check-blockers.mjs`; and `write-issue.mjs`. pr-verify reads the same rule. Its spec is one fixed template (`driftSpecText`) built from the upstream id, with done-when items and the design-change stop, never from its body; pr-verify's drift spec gains those lines. Such an issue is never split: admission takes it at any Size and the lane runs it at `split-child-size`. The filer's own body rewrite after admission no longer stops the lane run.
118 changes: 100 additions & 18 deletions .github/scripts/intake-triage/admit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
// body or a comment written,
// and last edited if ever, by a listed human; on an issue whose body a
// listed human wrote, refine.mjs's newest refinement comment while unedited
// (refinementSpec); and the body of a sub-issue a size split filed, under
// the split-child trust rule (splitChildBody). Nothing else the lanes App wrote counts,
// (refinementSpec); the body of a sub-issue a size split filed, under
// the split-child trust rule (splitChildBody); and, on a trusted drift
// issue (driftIssueId), the fixed driftSpecText in place of its body.
// Nothing else the lanes App wrote counts,
// an App-filed issue included, and an issue with more comments than the
// 100 pr-verify reads is refused, since pr-verify stops on it. On a triage
// verdict, when the criteria are all that is missing and intake's
Expand All @@ -53,9 +55,11 @@
// repository's, and no open pull request in this repository is for
// the issue: one GitHub says closes it, or whose body has the issue lane's
// `Refs: #<issue>` line (report-outcome.mjs). A passing mention is not one;
// - 9: the author is a listed human, or the lanes App on a trusted size-split
// sub-issue (splitChildBody); any other issue the App filed holds for a
// listed human to file as their own (owner decision on #10735);
// - 9: the author is a listed human, the lanes App on a trusted size-split
// sub-issue (splitChildBody), or github-actions[bot] on a trusted drift
// issue (driftIssueId; owner decision on #14215); any other issue the App
// filed holds for a listed human to file as their own (owner decision on
// #10735), and any other bot's for security;
// - no body line opens with `Hold:` (BODY_HOLD), a person's hold;
// - a `recurring` item's body has a `<!-- recurring-schedule id=<id> -->`
// line naming a row of the default branch's .github/recurring-schedule.json,
Expand Down Expand Up @@ -189,6 +193,9 @@ export const PATCH_SPLIT_PENDING = "its last run's patch was over the scan job's
// splits again. It parks at status: confirmed and, as the only refusal, adds
// host-run.
export const PATCH_SPLIT_CHILD = "its last run's patch was over the scan job's size cap (scan-refused-patch), and a size-split sub-issue never splits again (owner Q93), so a builder session takes it";
// The same refusal on a trusted drift issue (driftIssueId), which is never
// split.
export const PATCH_DRIFT = "its last run's patch was over the scan job's size cap (scan-refused-patch), and a trusted upstream-drift issue is never split, so a builder session takes it";
// Every wait reason refine.mjs splits on.
export const SPLIT_PENDING = new Set([SIZE_SPLIT_PENDING, PATCH_SPLIT_PENDING]);
// The refusal a Size Large issue gets once it has sub-issues and every one is
Expand Down Expand Up @@ -1035,6 +1042,68 @@ export function authorAdmitted(issue, humans, appId) {
return author !== undefined && (humans.has(author) || (Number.isInteger(appId) && author === appId));
}

// The github-actions Bot, as which a job's GITHUB_TOKEN acts: the
// upstream-drift workflow files its issues with it.
export const ACTIONS_BOT_ID = 41898282;
// scripts/upstream-drift-issues.sh's title, and its lead line for an upstream
// with a drifted hex-pin page (write_body), both built from the upstream id.
export const DRIFT_TITLE = /^Upstream drift: ([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/;
export const driftLead = (id) => `Upstream \`${id}\` changed since the pin on its docs/upstream page.`;
const driftShape = (title, body) => {
const id = DRIFT_TITLE.exec(String(title ?? ""))?.[1];
return id !== undefined && String(body ?? "").split("\n", 1)[0].replace(/\r$/, "") === driftLead(id) ? id : null;
};
const actionsBot = (actor) => actor?.__typename === "Bot" && actor.databaseId === ACTIONS_BOT_ID;

// The trusted drift-issue rule, its one home (owner decision on #14215,
// Q195 (a)): the upstream id of an issue the upstream-drift workflow filed,
// or null. `item` is the issue as GraphQL answers it ({title, body, author,
// editor, lastEditedAt}): github-actions[bot] wrote it and nobody else last
// edited it, and its title and first body line are the two lines the filer
// writes for one upstream id with a drifted hex-pin page. Nothing else of
// the body is read: its rows hold names and paths an upstream controls, so a
// caller takes the spec from driftSpecText. Admission, the triage sweep, the
// issue lane and pr-verify judge it here. Pure.
export const driftIssueId = (item) => (actionsBot(item?.author) && (item.lastEditedAt == null || actionsBot(item.editor)) ? driftShape(item.title, item.body) : null);

// Whether a REST issue has the drift shape apart from its edit history, which
// REST does not return: a caller confirms it with driftIssueId on a GraphQL
// read. Pure.
export const driftShaped = (issue) => issue?.user?.id === ACTIONS_BOT_ID && driftShape(issue.title, issue.body) !== null;

// Which author rule admits the REST issue `issue` in `repository`: "listed"
// (authorAdmitted), "drift" (a trusted drift issue, confirmed by one specOf
// read made only for a drift-shaped issue), or null. Every author gate on a
// drift issue's way from intake to the issue lane asks here. A failed read
// throws.
export async function authorTrust(github, repository, issue, humans, appId) {
if (authorAdmitted(issue, humans, appId)) {
return "listed";
}
return driftShaped(issue) && driftIssueId(await specOf(github, repository, issue.number)) !== null ? "drift" : null;
}

// The fixed spec of a trusted drift issue for upstream `id`, built from `id`
// and `pages` (the docs/upstream pages pinned to it, when the caller read
// them) alone. pr-verify (resolve-pr.mjs driftSpec), admission's criteria
// (trustedSpecTexts) and the issue lane's issue.json (write-issue.mjs) all
// read this text. Pure.
export function driftSpecText(id, pages = []) {
const one = pages.length === 1;
const where = pages.length > 0 ? `the docs/upstream page${one ? "" : "s"} pinned to upstream \`${id}\`: ${pages.map((page) => `\`${page}\``).join(", ")}` : `each docs/upstream page whose \`**Last audited upstream state:**\` marker pins upstream \`${id}\``;
return [
`# Upstream drift: ${id}`,
"",
`Re-audit ${where}. For each upstream change since the page's pin, record its disposition (take, adapt or reject, or already-have on a page whose rows use it) on the page as docs/contracts/upstream-drift/README.md, "When a trigger fires", requires, and move the pin to the upstream head re-audited. The pull request changes only ${one ? "that page" : "those pages"}: a take or adapt is recorded there, and applying it to any other file is outside this spec. A take or adapt that would change the design of one of this repository's skills is not applied: the run stops with \`design-change\` naming it, so the owner decides it (docs/contracts/upstream-drift/README.md, "One case goes to the owner"). The pull request body closes this issue with \`Closes #<this issue>\`.`,
"",
"## Done when",
"",
`- [ ] Every upstream change since the pin of each page pinned to \`${id}\` has a take, adapt, reject or already-have disposition recorded on that page.`,
"- [ ] Each of those pages pins the upstream head it was re-audited against.",
"- [ ] The pull request changes only those pages, and its body closes this issue with `Closes`.",
].join("\n");
}

// Whether status: confirmed is the issue's only status label and agent-ready is
// off, whether admission parked it there or a person confirmed it. Pure.
export const confirmedOnly = (labels) =>
Expand Down Expand Up @@ -1247,11 +1316,16 @@ export function decide({ issue, verdict, rules, parent, blockers, trustedCloses,
const holdFor = (code) => holdCodes.add(code);
// A trusted size-split sub-issue never splits again, so Size Large neither
// parks nor refuses it; a run has no turn or time cap (owner Q93, C13).
// A trusted drift issue is never split either: its spec is one fixed
// template for one upstream's pages, which no split partitions, and the
// issue lane runs it at split-child-size (check-blockers.mjs).
const splitChild = splitChildBody(spec, humans, taskList) !== null;
if (splitChild && !rules.sizes.includes("large")) {
const drift = issue.user?.id === ACTIONS_BOT_ID && driftIssueId(spec) !== null;
const unsplit = splitChild || drift;
if (unsplit && !rules.sizes.includes("large")) {
rules = { ...rules, sizes: [...rules.sizes, "large"] };
}
if (!authorAdmitted(issue, humans, appId)) {
if (!authorAdmitted(issue, humans, appId) && !drift) {
Comment thread
kyle-sexton marked this conversation as resolved.
Resolved
refuse.push("the author is neither a listed human nor the lanes App");
holdFor("security");
} else if (isAppId(issue.user?.id, appId) && !splitChild) {
Expand Down Expand Up @@ -1302,11 +1376,13 @@ export function decide({ issue, verdict, rules, parent, blockers, trustedCloses,
} else if (openSubs.length === 0 && !finished) {
refuse.push(SIZE_SPLIT_DONE);
}
} else if (overCap && splitChild) {
// A sub-issue never splits again, so the same work would only stop at the
// same cap: it parks for a builder instead of re-admitting unchanged.
refuse.push(PATCH_SPLIT_CHILD);
hostWork.add(PATCH_SPLIT_CHILD);
} else if (overCap && unsplit) {
// A sub-issue never splits again, nor does a drift issue, so the same work
// would only stop at the same cap: it parks for a builder instead of
// re-admitting unchanged.
const reason = splitChild ? PATCH_SPLIT_CHILD : PATCH_DRIFT;
refuse.push(reason);
hostWork.add(reason);
} else if (!rules.sizes.includes(size)) {
refuse.push(`Size ${size} is not one of ${rules.sizes.join(", ")}`);
}
Expand Down Expand Up @@ -1686,15 +1762,15 @@ export const sayWhy = (github, repository, base, comments, text) => writeWhy(git
export const SPEC_COMMENTS = 100;
const SPEC_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) { issue(number: $number) {
body lastEditedAt author { ...actor } editor { ...actor }
title body lastEditedAt author { ...actor } editor { ...actor }
comments(first: ${SPEC_COMMENTS}) { totalCount nodes { databaseId createdAt updatedAt body lastEditedAt author { ...actor } editor { ...actor } } }
} }
}
fragment actor on Actor { __typename ... on User { databaseId } ... on Bot { databaseId } }`;

// {body, lastEditedAt, author, editor, commentCount, comments: [{databaseId,
// createdAt, updatedAt, body, lastEditedAt, author, editor}]} for the issue,
// as GraphQL answers them. An unexpected shape throws.
// {title, body, lastEditedAt, author, editor, commentCount, comments:
// [{databaseId, createdAt, updatedAt, body, lastEditedAt, author, editor}]}
// for the issue, as GraphQL answers them. An unexpected shape throws.
export async function specOf(github, repository, number) {
const [owner, name] = repository.split("/");
const issue = (await github("POST", "/graphql", { query: SPEC_QUERY, variables: { owner, name, number: Number(number) } }))?.data?.repository?.issue;
Expand All @@ -1703,8 +1779,8 @@ export async function specOf(github, repository, number) {
if (!text(issue) || !Array.isArray(issue.comments?.nodes) || !issue.comments.nodes.every(text) || !Number.isSafeInteger(issue.comments.totalCount)) {
throw new Error("the issue's text, authors and edit times have an unexpected shape");
}
const { body, lastEditedAt, author, editor } = issue;
return { body, lastEditedAt, author, editor, commentCount: issue.comments.totalCount, comments: issue.comments.nodes };
const { title, body, lastEditedAt, author, editor } = issue;
return { title, body, lastEditedAt, author, editor, commentCount: issue.comments.totalCount, comments: issue.comments.nodes };
}

// refine.mjs isThin's task-list prefix.
Expand Down Expand Up @@ -1863,11 +1939,17 @@ export const withoutItems = (body, taskList, moved) => {
// (.github/scripts/pr-verify/resolve-pr.mjs linkedIssues). No other Bot or
// App text counts, except the body of a sub-issue a size split filed
// (splitChildBody, which reads `taskList`, the rules' `task-list`). Pure.
// A trusted drift issue's body is never spec: its first text is
// driftSpecText, and comments count as on any issue.
export function trustedSpecTexts(spec, humans, appId, taskList) {
const written = writtenBy(humans);
if (!spec) {
return [];
}
const drift = driftIssueId(spec);
if (drift !== null) {
return [driftSpecText(drift), ...(spec.comments ?? []).filter(written).map((item) => String(item.body ?? ""))];
}
const refinement = countedRefinement(spec, humans, appId);
const own = (item) => written(item) || item === refinement || (item === spec && splitChildBody(spec, humans, taskList) !== null);
return [spec, ...(spec.comments ?? [])].filter(own).map((item) => String(item.body ?? ""));
Expand Down
Loading
Loading