|
6 | 6 | // Criteria 1, 5 and 6 (exact intent, no very-high security risk, no charge) |
7 | 7 | // are already in `status: ready`: apply-verdict withholds it on any flag |
8 | 8 | // (triage flags security only for a very-high risk) or a hold label, and the |
9 | | -// cost rule adds needs-human. Criterion 4 (no protected path named) applies |
10 | | -// only to the paths the issue lane cannot push (unpushablePaths). This checks |
11 | | -// the rest: |
| 9 | +// cost rule adds needs-human; criterion 6 is checked here too, on the charge |
| 10 | +// words rule-admit.sh refuses (chargePattern), whatever the verdict flagged. |
| 11 | +// Criterion 4 (no protected path named) applies only to the paths the issue |
| 12 | +// lane cannot push (unpushablePaths). This checks the rest: |
12 | 13 | // |
13 | 14 | // - 2: the Issue Type is in `types`, or in `types-under-parent` under an open |
14 | 15 | // parent issue a listed human filed that awaits no decision; a type in |
|
40 | 41 | // - a `recurring` item's schedule row, read from the default branch's |
41 | 42 | // .github/recurring-schedule.json, does not set |
42 | 43 | // requires_operator_confirmation (operatorConfirmation); |
| 44 | +// - the body was not edited after the lane comment the verdict came from; |
43 | 45 | // - lane-runnable done-when: no task-list item asks for what an unattended |
44 | 46 | // lane run cannot do (unrunnableCriteria below): a run on a named host or |
45 | 47 | // OS, a paid eval, a run repeated N times, a measurement over time, or a |
46 | 48 | // page on a host outside resolve-issue's web-access domains. The refusal |
47 | 49 | // recommends splitting those items into a needs-human child issue, which |
48 | 50 | // refine.mjs files when some items are left for the lane; |
49 | | -// - 10: check-wip-cap's status: over the queued cap, or with the lane paused |
50 | | -// over the WIP or held cap (from wip.pause-from), the issue gets |
| 51 | +// - 10: check-wip-cap's status: over the queued cap, with a queued count it |
| 52 | +// could not read (fail-open), or with the lane paused over the WIP or held |
| 53 | +// cap (from wip.pause-from), the issue gets |
51 | 54 | // `admission-deferred`, which work-unblock's hourly sweep admits once there |
52 | 55 | // is room. With room, an issue still waits behind an older open issue in |
53 | 56 | // `admission-deferred`, so admission takes the oldest first (owner Q95). |
@@ -362,6 +365,23 @@ export function issuePushRefusals() { |
362 | 365 | return pushRefusalNames; |
363 | 366 | } |
364 | 367 |
|
| 368 | +let chargeWords; |
| 369 | +// The charge-word pattern rule-admit.sh matches too, read once from its one |
| 370 | +// definition in the default branch's checkout beside this script. |
| 371 | +export function chargePattern() { |
| 372 | + if (chargeWords === undefined) { |
| 373 | + const { cost } = JSON.parse(readFileSync(new URL("../../../plugins/work-items/scripts/charge-words.json", import.meta.url), "utf8")); |
| 374 | + if (typeof cost !== "string" || cost === "") { |
| 375 | + throw new Error("plugins/work-items/scripts/charge-words.json: `cost` must be a pattern"); |
| 376 | + } |
| 377 | + chargeWords = new RegExp(cost, "gi"); |
| 378 | + } |
| 379 | + return chargeWords; |
| 380 | +} |
| 381 | + |
| 382 | +// The charge words `text` holds by `pattern`, lowercased, each once. Pure. |
| 383 | +export const chargeHits = (text, pattern) => [...new Set([...String(text ?? "").matchAll(pattern)].map((m) => m[0].toLowerCase()))]; |
| 384 | + |
365 | 385 | // A repository path a criterion names: a backticked span or a word, less a |
366 | 386 | // trailing `:12` or `:3-9` and punctuation. Only a relative path with a `/`, |
367 | 387 | // or a root CODEOWNERS or .gitmodules, counts: a bare file name or an |
@@ -457,12 +477,16 @@ export function admissionSettled(labels, events, isMark) { |
457 | 477 |
|
458 | 478 | // {verdict: admit | refuse | wait | skip, reasons}, plus `hold: true` on a |
459 | 479 | // refusal that parks at needs-decision: an untrusted author or provenance or |
460 | | -// a person-held label (the owner's 2026-10-26 rule keeps a person out of |
461 | | -// every other refusal), or done-when items a lane run cannot perform, which |
462 | | -// refine splits only from needs-decision (refine.mjs splitOf). Pure but for |
463 | | -// `pushRefusals`, read from patch-rules.json when not given; a file that does |
464 | | -// not read throws out of decide, so no issue is admitted on a guess. |
465 | | -export function decide({ issue, verdict, rules, parent, blockers, trustedCloses, pulls = [], subIssues = [], events, spec, schedule, humans, appId, repository, webHosts, pushRefusals = issuePushRefusals() }) { |
| 480 | +// a person-held label or a charge word (the owner's 2026-10-26 rule keeps a |
| 481 | +// person out of every other refusal), or done-when items a lane run cannot |
| 482 | +// perform, which refine splits only from needs-decision (refine.mjs splitOf). |
| 483 | +// `verdict.writtenAt` is when the lane comment the verdict came from was last |
| 484 | +// written; a body edited after it refuses, since the verdict judged an older |
| 485 | +// body. The sweep reads no lane comment and passes none. Pure but for |
| 486 | +// `pushRefusals` and `charges`, read from patch-rules.json and |
| 487 | +// charge-words.json when not given; a file that does not read throws out of |
| 488 | +// decide, so no issue is admitted on a guess. |
| 489 | +export function decide({ issue, verdict, rules, parent, blockers, trustedCloses, pulls = [], subIssues = [], events, spec, schedule, humans, appId, repository, webHosts, pushRefusals = issuePushRefusals(), charges = chargePattern() }) { |
466 | 490 | const labels = names(issue.labels); |
467 | 491 | if (!labels.includes(READY)) { |
468 | 492 | return { verdict: "skip", reasons: [`no ${READY}`] }; |
@@ -539,6 +563,20 @@ export function decide({ issue, verdict, rules, parent, blockers, trustedCloses, |
539 | 563 | if (unpushable.length > 0) { |
540 | 564 | refuse.push(`a criterion names ${unpushable.join(", ")}, which the issue lane cannot push (patch-protected-path); a builder session takes it`); |
541 | 565 | } |
| 566 | + // A metered or renewing charge needs the owner's decision, whatever the |
| 567 | + // verdict flagged. |
| 568 | + const charged = chargeHits(`${issue.title ?? ""}\n${issue.body ?? ""}`, charges); |
| 569 | + if (charged.length > 0) { |
| 570 | + refuse.push(`its title or body names a charge (${charged.join(", ")}), which needs an owner decision`); |
| 571 | + hold = true; |
| 572 | + } |
| 573 | + if (verdict.writtenAt !== undefined) { |
| 574 | + const judged = Date.parse(verdict.writtenAt); |
| 575 | + const edited = spec?.lastEditedAt == null ? null : Date.parse(spec.lastEditedAt); |
| 576 | + if (!Number.isFinite(judged) || (edited !== null && !(edited <= judged))) { |
| 577 | + refuse.push("its body was edited after the triage verdict, which judged the body as it stood before"); |
| 578 | + } |
| 579 | + } |
542 | 580 | for (const label of rules["refuse-labels"]) { |
543 | 581 | if (labels.includes(label)) { |
544 | 582 | refuse.push(`it carries ${label}`); |
@@ -1158,13 +1196,18 @@ export async function admit({ github, repository, number, verdict, rules, humans |
1158 | 1196 | return { outcome: "waiting", reasons: decision.reasons }; |
1159 | 1197 | } |
1160 | 1198 | const s = await status(); |
1161 | | - const full = s.paused || !s.admission_open || (s.admission_room ?? 1) <= 0; |
| 1199 | + // A queued count check-wip-cap could not read (fail-open) admits nothing, |
| 1200 | + // as an incomplete search answer admits nothing. |
| 1201 | + const unread = s.admission_basis === "fail-open"; |
| 1202 | + const full = s.paused || unread || !s.admission_open || (s.admission_room ?? 1) <= 0; |
1162 | 1203 | if (full || (await deferredAhead(github, repository, issue))) { |
1163 | 1204 | const why = !full |
1164 | 1205 | ? `an older ${DEFERRED} issue is ahead of it` |
1165 | 1206 | : s.paused |
1166 | 1207 | ? `the lane is paused (${s.pause_reason})` |
1167 | | - : `admissions are closed (${s.admission_reason})`; |
| 1208 | + : unread |
| 1209 | + ? "the issue lane's queued count could not be read (admission_basis fail-open)" |
| 1210 | + : `admissions are closed (${s.admission_reason})`; |
1168 | 1211 | await github("POST", `${base}/labels`, { labels: [DEFERRED] }); |
1169 | 1212 | log(`admit: #${number} deferred: ${why}`); |
1170 | 1213 | return { outcome: "deferred", reasons: [why] }; |
|
0 commit comments