@vite-hub/presets 0.7.0 → 0.9.0
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/dist/babysitter/server.d.ts +2 -3
- package/dist/babysitter/server.js +1 -1
- package/dist/{babysitter-SWX5zXIM.js → babysitter-DuE_HaHk.js} +26 -32
- package/dist/babysitter.d.ts +8 -2
- package/dist/babysitter.js +1 -1
- package/dist/{host-1nLqi8HQ.js → host-C829xI7L.js} +4 -15
- package/dist/labeller.js +0 -1
- package/dist/{pr-workspaces-DfBICt8N.d.ts → pr-workspaces-CifuNuYg.d.ts} +7 -4
- package/dist/{server-CWLmnhPQ.js → server-BsVudCg4.js} +288 -237
- package/package.json +8 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isRuntimeString, i as isRuntimeRecord, n as hasRuntimeType, r as isRuntimeNumber, t as presetsErrorDiagnostics } from "./error-diagnostics-ba9TWgh5.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as reviewerLabeledSevere, B as isBabysitterCheckRun, C as snapshotCheckEvidence, D as isReviewThreadOutcome, E as createGitHubPullRequestOperations, F as actionLocation, I as failed$1, L as hydrateFailedCiEvidence, M as invariantError, N as hasGitHubLogin, O as normalizeGitHubMentionAllowlist, P as matchesBabysitterPullRequestFilter, R as newestCheckRun, S as resolveBabysitterMerge, T as maintainerApproval, V as createBabysitterPassResultSchema, _ as isAutomatedFeedback, a as isBabysitterPlacementCapacityError, b as matchesMergeReviewEvidence, c as workspaceDecision, g as headChecksUnreported, h as hasHumanComment, j as invariant, k as reviewThreadOutcomes, l as babysitterModelAdmission, m as feedbackFingerprints, p as directMergeReadiness, r as resolveBabysitterLifecycleFilter, s as providerSessionDecision, v as isConventionalTitle, w as approvalReviewers, x as mergeReviewEvidenceKey, y as liveMergeReadiness, z as createBabysitterCheckRuns } from "./babysitter-DuE_HaHk.js";
|
|
3
3
|
import { activeProviderSandbox, agentInvocationId, agentSettings, createMessage, defineAgent, defineCapability, publishAgentActivity, recordProviderCheckout, runAgent, withoutForgeAccess } from "@vite-hub/agent";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { resolvePublicUrl } from "@vite-hub/runtime";
|
|
@@ -21,7 +21,6 @@ import { resolveRuntimeValue } from "@vite-hub/runtime/internal/context";
|
|
|
21
21
|
import { resolveRegisteredWorkspaceDefinition } from "@vite-hub/workspace/runtime";
|
|
22
22
|
// src/github/checkout.ts
|
|
23
23
|
const exec$6 = promisify(execFile);
|
|
24
|
-
/** Credentials belong to the host. Never carry saved clone authentication into a worker. */
|
|
25
24
|
async function sanitizeProviderGitConfig(git, destination) {
|
|
26
25
|
const sensitive = (key) => /^credential\.|^include(?:if)?(?:[.:].*)?\.path$|^core\.(?:askpass|sshcommand|hookspath|worktree)$|^sendemail\.(?:.*\.)?smtppass$|^imap\.pass$|^gitcvs\.dbpass$|^http\..*extraheader$|^http\.extraheader$|^http\.(?:.*\.)?(?:proxy|cookiefile|sslkey(?:type|passwordprotected)?|sslcert(?:type|passwordprotected)?|proxysslkey|proxysslcert|proxysslcertpasswordprotected)$/i.test(key) || /^remote\..*\.proxy$/i.test(key);
|
|
27
26
|
const sanitize = async (scope) => {
|
|
@@ -69,7 +68,6 @@ async function sanitizeProviderGitConfig(git, destination) {
|
|
|
69
68
|
await sanitize("--local");
|
|
70
69
|
await sanitize("--worktree");
|
|
71
70
|
}
|
|
72
|
-
/** Resolves a prepared host clone and a provider workspace that neither contains the other. */
|
|
73
71
|
async function separateCheckouts(checkout, target) {
|
|
74
72
|
const source = await realpath(checkout);
|
|
75
73
|
const destination = await realpath(target);
|
|
@@ -1027,13 +1025,21 @@ async function publishGitHubInstallSnapshot(snapshot, signal) {
|
|
|
1027
1025
|
});
|
|
1028
1026
|
}
|
|
1029
1027
|
}
|
|
1028
|
+
// ../internal/src/object.ts
|
|
1029
|
+
/** A non-null object that is not an array. Functions do not pass. */
|
|
1030
|
+
function isRecord(value) {
|
|
1031
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1032
|
+
}
|
|
1033
|
+
/** A non-null object. Arrays pass. Functions do not. */
|
|
1034
|
+
function isObject(value) {
|
|
1035
|
+
return typeof value === "object" && value !== null;
|
|
1036
|
+
}
|
|
1030
1037
|
// src/github/install.ts
|
|
1031
1038
|
const exec$4 = promisify(execFile);
|
|
1032
1039
|
const manifest = v.object({ packageManager: v.optional(v.string()) });
|
|
1033
1040
|
const systemError = v.object({ errno: v.pipe(v.number(), v.integer(), v.maxValue(-1)) });
|
|
1034
1041
|
const exists$1 = async (path) => await access(path).then(() => true, () => false);
|
|
1035
1042
|
const isSystemError = (error) => v.safeParse(systemError, error).success;
|
|
1036
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
1037
1043
|
function githubWorkspaceInstallError(cause, retryable = true, kind = "command") {
|
|
1038
1044
|
return Object.assign(presetsErrorDiagnostics.PRESETS_GITHUB_INSTALL_FAILED({
|
|
1039
1045
|
cause,
|
|
@@ -1057,9 +1063,9 @@ function isGitHubLockfileDefect(error) {
|
|
|
1057
1063
|
const collect = (value) => {
|
|
1058
1064
|
if (value === null || value === void 0 || seen.has(value)) return;
|
|
1059
1065
|
if (typeof value === "object" || typeof value === "function") seen.add(value);
|
|
1060
|
-
parts.push(value instanceof Error ? value.message :
|
|
1066
|
+
parts.push(value instanceof Error ? value.message : isObject(value) && typeof value.message === "string" ? value.message : String(value));
|
|
1061
1067
|
if (value instanceof Error) collect(value.cause);
|
|
1062
|
-
if (
|
|
1068
|
+
if (isObject(value)) {
|
|
1063
1069
|
collect(value.cause);
|
|
1064
1070
|
collect(value.stderr);
|
|
1065
1071
|
}
|
|
@@ -1112,13 +1118,11 @@ function createGitHubInstallSlots({ concurrency = 1, queueTimeoutMs = 12e4 } = {
|
|
|
1112
1118
|
} };
|
|
1113
1119
|
}
|
|
1114
1120
|
const defaultInstallSlots = createGitHubInstallSlots();
|
|
1115
|
-
/** Repository scripts, pnpmfile hooks and package-manager self-management never run on the host. */
|
|
1116
1121
|
const pnpmProtectedFlags = [
|
|
1117
1122
|
"--ignore-scripts",
|
|
1118
1123
|
"--ignore-pnpmfile",
|
|
1119
1124
|
"--config.manage-package-manager-versions=false"
|
|
1120
1125
|
];
|
|
1121
|
-
/** Host environment for package managers: no host credentials and no repository-selected Corepack behavior. */
|
|
1122
1126
|
async function packageManagerEnvironment(target) {
|
|
1123
1127
|
const home = join(target, ".git", "vitehub-install-home");
|
|
1124
1128
|
await mkdir(home, { recursive: true });
|
|
@@ -1136,7 +1140,6 @@ async function packageManagerEnvironment(target) {
|
|
|
1136
1140
|
COREPACK_ENABLE_DOWNLOAD_PROMPT: "0"
|
|
1137
1141
|
};
|
|
1138
1142
|
}
|
|
1139
|
-
/** Corepack must not execute a PR-supplied URL, devEngines override or yarnPath. Select an official version. */
|
|
1140
1143
|
async function packageManagerVersion(source) {
|
|
1141
1144
|
const { packageManager } = v.parse(manifest, await exists$1(join(source, "package.json")) ? JSON.parse(await readFile(join(source, "package.json"), "utf8")) : {});
|
|
1142
1145
|
return (name, fallback) => {
|
|
@@ -1435,12 +1438,12 @@ async function readGitHubDependencyStatus(target) {
|
|
|
1435
1438
|
};
|
|
1436
1439
|
}
|
|
1437
1440
|
const record = await readFile(join(target, ".git", "vitehub-install.json"), "utf8").then(JSON.parse, () => ({}));
|
|
1438
|
-
const installed =
|
|
1441
|
+
const installed = isObject(record) ? record : {};
|
|
1439
1442
|
if (installed.status === "installed" && installed.fingerprint === fingerprint) return {
|
|
1440
1443
|
current: true,
|
|
1441
1444
|
changedInputs: []
|
|
1442
1445
|
};
|
|
1443
|
-
const previous =
|
|
1446
|
+
const previous = isObject(installed.inputs) ? installed.inputs : {};
|
|
1444
1447
|
const changedInputs = [.../* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(inputs)])].filter((path) => previous[path] !== inputs[path]).sort();
|
|
1445
1448
|
return {
|
|
1446
1449
|
current: false,
|
|
@@ -1547,11 +1550,6 @@ async function resolveGitHubMergeConflicts(target, git, options = {}) {
|
|
|
1547
1550
|
...lockfile ? { lockfile } : {}
|
|
1548
1551
|
};
|
|
1549
1552
|
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Regeneration resolves dependencies the base lockfile never listed. pnpm 7 and older run the `prepare`
|
|
1552
|
-
* script of a Git-hosted dependency even with --ignore-scripts, so only pnpm 9 or newer, or the host's
|
|
1553
|
-
* default when package.json selects none, may resolve on the host.
|
|
1554
|
-
*/
|
|
1555
1553
|
async function scriptSafePnpm(target) {
|
|
1556
1554
|
let manifest;
|
|
1557
1555
|
try {
|
|
@@ -1564,7 +1562,6 @@ async function scriptSafePnpm(target) {
|
|
|
1564
1562
|
const major = typeof packageManager === "string" ? /^pnpm@(\d+)\./.exec(packageManager)?.[1] : void 0;
|
|
1565
1563
|
return major !== void 0 && Number(major) >= 9;
|
|
1566
1564
|
}
|
|
1567
|
-
/** Files that pnpm reads as dependency inputs. While one is conflicted, the lockfile cannot be regenerated. */
|
|
1568
1565
|
function dependencyInput(path) {
|
|
1569
1566
|
return [
|
|
1570
1567
|
"package.json",
|
|
@@ -1574,7 +1571,6 @@ function dependencyInput(path) {
|
|
|
1574
1571
|
".pnpmfile.mjs"
|
|
1575
1572
|
].includes(basename(path)) || path.startsWith("patches/");
|
|
1576
1573
|
}
|
|
1577
|
-
/** Prose where two sides adding text at the same place can both be kept. Code never qualifies. */
|
|
1578
1574
|
function unionDocument(path) {
|
|
1579
1575
|
return /^docs\/.+\.md$/.test(path) || /^packages\/[^/]+\/README\.md$/.test(path);
|
|
1580
1576
|
}
|
|
@@ -1585,7 +1581,6 @@ const markers = {
|
|
|
1585
1581
|
split: "=".repeat(markerSize),
|
|
1586
1582
|
theirs: `${">".repeat(markerSize)} theirs`
|
|
1587
1583
|
};
|
|
1588
|
-
/** Keep both sides of every conflict hunk whose merge-base side is empty: base text first, then the PR's. */
|
|
1589
1584
|
async function unionAdditions(git, entry, sides) {
|
|
1590
1585
|
const markerLines = new Set(Object.values(markers));
|
|
1591
1586
|
if (sides.some((side) => side.includes("\r") || side.split("\n").some((line) => markerLines.has(line)))) return void 0;
|
|
@@ -1636,7 +1631,6 @@ async function unionAdditions(git, entry, sides) {
|
|
|
1636
1631
|
const plain = (block) => block.kind === "plain" && block.components === 0;
|
|
1637
1632
|
const tableRow = (line) => line !== void 0 && /(?:^|[^\\])\|/.test(line);
|
|
1638
1633
|
const content = (line) => line.replace(/^(?:\s*>)+/, "");
|
|
1639
|
-
/** Markdown block state after one line: frontmatter, a code fence, an HTML block, or open MDC components. */
|
|
1640
1634
|
function nextBlock(block, line, first) {
|
|
1641
1635
|
if (block.kind === "frontmatter") return /^(?:---|\.\.\.)\s*$/.test(line) ? {
|
|
1642
1636
|
...block,
|
|
@@ -1678,10 +1672,6 @@ function nextBlock(block, line, first) {
|
|
|
1678
1672
|
};
|
|
1679
1673
|
return block;
|
|
1680
1674
|
}
|
|
1681
|
-
/**
|
|
1682
|
-
* Two additions that look like versions of the same text need a choice, not both: the same heading,
|
|
1683
|
-
* or a sentence on one side that is nearly, but not exactly, a sentence on the other.
|
|
1684
|
-
*/
|
|
1685
1675
|
function competing(ours, theirs) {
|
|
1686
1676
|
const headings = new Set(ours.filter((line) => /^#{1,6}\s/.test(line)));
|
|
1687
1677
|
if (theirs.some((line) => headings.has(line))) return true;
|
|
@@ -1700,16 +1690,11 @@ function competing(ours, theirs) {
|
|
|
1700
1690
|
}
|
|
1701
1691
|
const conflict = Symbol("conflict");
|
|
1702
1692
|
const absent = Symbol("absent");
|
|
1703
|
-
/** Keys whose object order changes meaning, such as export conditions. They merge as one value. */
|
|
1704
1693
|
const orderedKeys = /* @__PURE__ */ new Set([
|
|
1705
1694
|
"exports",
|
|
1706
1695
|
"imports",
|
|
1707
1696
|
"typesVersions"
|
|
1708
1697
|
]);
|
|
1709
|
-
/**
|
|
1710
|
-
* Merge package.json changes key by key. Unchanged against changed takes the change, equal changes
|
|
1711
|
-
* coalesce, and different changes to the same value leave the whole file conflicted.
|
|
1712
|
-
*/
|
|
1713
1698
|
function mergePackageJson(base, ours, theirs) {
|
|
1714
1699
|
const texts = [
|
|
1715
1700
|
base,
|
|
@@ -1724,7 +1709,7 @@ function mergePackageJson(base, ours, theirs) {
|
|
|
1724
1709
|
}
|
|
1725
1710
|
});
|
|
1726
1711
|
const styles = texts.map(jsonStyle);
|
|
1727
|
-
if (parsed.some((value, index) => !
|
|
1712
|
+
if (parsed.some((value, index) => !isRecord(value) || !styles[index] || serialize(value, styles[index]) !== texts[index])) return void 0;
|
|
1728
1713
|
const merged = mergeValue(parsed[0], parsed[1], parsed[2], false);
|
|
1729
1714
|
if (merged === conflict || merged === absent) return void 0;
|
|
1730
1715
|
return serialize(merged, styles[1]);
|
|
@@ -1733,7 +1718,7 @@ function mergeValue(base, ours, theirs, atomic) {
|
|
|
1733
1718
|
if (same(ours, theirs)) return ours;
|
|
1734
1719
|
if (same(base, ours)) return theirs;
|
|
1735
1720
|
if (same(base, theirs)) return ours;
|
|
1736
|
-
if (atomic || !
|
|
1721
|
+
if (atomic || !isRecord(base) || !isRecord(ours) || !isRecord(theirs)) return conflict;
|
|
1737
1722
|
const order = (value) => Object.keys(value).filter((key) => Object.hasOwn(base, key) && Object.hasOwn(ours, key) && Object.hasOwn(theirs, key)).join("\0");
|
|
1738
1723
|
if (order(ours) !== order(base) && order(theirs) !== order(base)) return conflict;
|
|
1739
1724
|
const keys = keyOrder(order(ours) !== order(base) ? ours : theirs, order(ours) !== order(base) ? theirs : ours);
|
|
@@ -1745,7 +1730,6 @@ function mergeValue(base, ours, theirs, atomic) {
|
|
|
1745
1730
|
}
|
|
1746
1731
|
return Object.fromEntries(entries);
|
|
1747
1732
|
}
|
|
1748
|
-
/** Key order of the primary side, with keys only the other side has inserted after their nearest preceding key. */
|
|
1749
1733
|
function keyOrder(primary, other) {
|
|
1750
1734
|
const keys = Object.keys(primary);
|
|
1751
1735
|
let previous;
|
|
@@ -1757,7 +1741,6 @@ function keyOrder(primary, other) {
|
|
|
1757
1741
|
}
|
|
1758
1742
|
const read = (value, key) => Object.hasOwn(value, key) ? value[key] : absent;
|
|
1759
1743
|
const same = (left, right) => left === absent || right === absent ? left === right : JSON.stringify(left) === JSON.stringify(right);
|
|
1760
|
-
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1761
1744
|
function jsonStyle(text) {
|
|
1762
1745
|
const indent = /^\{\r?\n([ \t]+)"/.exec(text)?.[1];
|
|
1763
1746
|
if (indent === void 0) return text.trim() === "{}" ? {
|
|
@@ -1770,11 +1753,6 @@ function jsonStyle(text) {
|
|
|
1770
1753
|
};
|
|
1771
1754
|
}
|
|
1772
1755
|
const serialize = (value, style) => `${JSON.stringify(value, null, style.indent)}${style.newline ? "\n" : ""}`;
|
|
1773
|
-
/**
|
|
1774
|
-
* Lockfile choices the PR made against the merge base that the merge cannot keep: the base changed the
|
|
1775
|
-
* same entry differently, or the regenerated lockfile resolves it differently. An entry that left the
|
|
1776
|
-
* graph, such as a package the base upgraded away, holds no choice. Undefined when a lockfile does not parse.
|
|
1777
|
-
*/
|
|
1778
1756
|
function lockfileChoices(ancestor, ours, theirs, regenerated) {
|
|
1779
1757
|
const [before, pr, base, after] = [
|
|
1780
1758
|
ancestor,
|
|
@@ -1786,10 +1764,6 @@ function lockfileChoices(ancestor, ours, theirs, regenerated) {
|
|
|
1786
1764
|
const differs = (side, key, value) => side.has(key) && side.get(key) !== value;
|
|
1787
1765
|
return [...pr].filter(([key, value]) => before.get(key) !== value && (differs(base, key, value) && base.get(key) !== before.get(key) || differs(after, key, value))).map(([key]) => key.replaceAll("\0", " "));
|
|
1788
1766
|
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Every choice in a pnpm lockfile: importer and catalog resolutions, package sources and the
|
|
1791
|
-
* dependency edges of each snapshot. Versions drop their peer suffix, which changes whenever a peer moves.
|
|
1792
|
-
*/
|
|
1793
1767
|
function lockfileResolutions(text) {
|
|
1794
1768
|
const resolutions = /* @__PURE__ */ new Map();
|
|
1795
1769
|
const edgeVersions = /* @__PURE__ */ new Map();
|
|
@@ -2056,13 +2030,9 @@ function createGitHubAppCredentials(app) {
|
|
|
2056
2030
|
token: app.token
|
|
2057
2031
|
};
|
|
2058
2032
|
},
|
|
2059
|
-
/** Every repository that the App's installations can access. */
|
|
2060
2033
|
repositories: (signal) => client.repositories(signal),
|
|
2061
|
-
/** Failed App webhook deliveries since `since` that no later attempt delivered, oldest first. */
|
|
2062
2034
|
failedDeliveries: (since, signal) => client.failedDeliveries(since, signal),
|
|
2063
|
-
/** Sends one App webhook delivery again. */
|
|
2064
2035
|
redeliver: (id, signal) => client.redeliver(id, signal),
|
|
2065
|
-
/** The App bot's login and noreply email, used as the commit author. */
|
|
2066
2036
|
async identity() {
|
|
2067
2037
|
return await appIdentity(client);
|
|
2068
2038
|
}
|
|
@@ -2088,7 +2058,6 @@ async function appIdentity(client, signal) {
|
|
|
2088
2058
|
email
|
|
2089
2059
|
};
|
|
2090
2060
|
}
|
|
2091
|
-
/** The App lookup or token request for a repository answered 404: the App is not installed there. */
|
|
2092
2061
|
function notInstalled(error) {
|
|
2093
2062
|
for (let cause = error, depth = 0; cause instanceof Error && depth < 4; cause = cause.cause, depth++) if (forgeErrorStatus(cause) === 404) return true;
|
|
2094
2063
|
return false;
|
|
@@ -2773,7 +2742,6 @@ v.pipe(v.object({
|
|
|
2773
2742
|
labels: labels.nodes,
|
|
2774
2743
|
statusCheckRollup: commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes ?? []
|
|
2775
2744
|
})));
|
|
2776
|
-
/** Derive stable PR thread identity, inspection annotations, and a session link. */
|
|
2777
2745
|
/** The Agent run thread of a pull request. A Babysitter pass adds `:<session>` to it. */
|
|
2778
2746
|
function pullRequestThreadId(repository, number) {
|
|
2779
2747
|
return `github:${repository.toLowerCase()}:pull-request:${number}`;
|
|
@@ -2869,7 +2837,6 @@ function createGitHubRequiredCheckPolicyReader(read, options = {}) {
|
|
|
2869
2837
|
};
|
|
2870
2838
|
return {
|
|
2871
2839
|
read: readPolicy,
|
|
2872
|
-
/** Discard cached and in-flight results. Call after a protection or ruleset change. */
|
|
2873
2840
|
invalidate(repository, branch) {
|
|
2874
2841
|
for (const key of /* @__PURE__ */ new Set([...cache.keys(), ...active.keys()])) {
|
|
2875
2842
|
const [repo, ref] = key.split("\0");
|
|
@@ -2881,7 +2848,6 @@ function createGitHubRequiredCheckPolicyReader(read, options = {}) {
|
|
|
2881
2848
|
}
|
|
2882
2849
|
};
|
|
2883
2850
|
}
|
|
2884
|
-
/** Reads one required check, or returns why the policy is unknown. */
|
|
2885
2851
|
function requiredCheck(check) {
|
|
2886
2852
|
if (typeof check.name !== "string" || !check.name.trim()) return "Invalid required-check name";
|
|
2887
2853
|
if (check.appId !== void 0 && (typeof check.appId !== "string" || !/^-?\d+$/.test(check.appId))) return "Invalid required-check app ID";
|
|
@@ -2928,12 +2894,15 @@ function evaluateGitHubRequiredChecks(policy, evidence) {
|
|
|
2928
2894
|
const runs = evidence.checkRuns.filter((value) => value.head_sha === evidence.headSha && value.name === required.context && (required.appId === null || value.app?.id === required.appId)).sort((a, b) => b.id - a.id);
|
|
2929
2895
|
const status = evidence.statuses.filter((value) => value.sha === evidence.headSha && value.context === required.context).sort((a, b) => b.id - a.id)[0];
|
|
2930
2896
|
const states = [];
|
|
2931
|
-
|
|
2897
|
+
const run = runs[0];
|
|
2898
|
+
const runState = run && stateOfCheck(run);
|
|
2899
|
+
if (runState) states.push(runState);
|
|
2932
2900
|
if (status) states.push(status.state === "pending" ? "pending" : ["failure", "error"].includes(status.state) ? "failed" : status.state === "success" && required.appId === null ? "passed" : "unknown");
|
|
2933
2901
|
if (!states.length) missing.push(required.context);
|
|
2934
2902
|
return {
|
|
2935
2903
|
...required,
|
|
2936
|
-
state: states.length ? combine(states) : "pending"
|
|
2904
|
+
state: states.length ? combine(states) : "pending",
|
|
2905
|
+
...runState === "failed" && run?.conclusion?.toLowerCase() === "cancelled" ? { cancelled: true } : {}
|
|
2937
2906
|
};
|
|
2938
2907
|
});
|
|
2939
2908
|
const newest = /* @__PURE__ */ new Map();
|
|
@@ -3063,7 +3032,6 @@ function dailyPassResumeAt(budget, limit, now) {
|
|
|
3063
3032
|
const passes = (budget?.passes ?? []).filter((at) => at > now - day).sort((left, right) => left - right);
|
|
3064
3033
|
return passes.length < limit ? void 0 : passes[passes.length - limit] + day;
|
|
3065
3034
|
}
|
|
3066
|
-
/** Past the push budget, a PR with failing required checks may push this long after its last push. */
|
|
3067
3035
|
const ciRepairPushSpacing = 72e5;
|
|
3068
3036
|
/**
|
|
3069
3037
|
* Whether a pass may push, given the times of the PR's repair pushes. A conflict repair and a PR with a
|
|
@@ -3416,6 +3384,10 @@ const deliverySchema = v.looseObject({
|
|
|
3416
3384
|
action: v.optional(v.string()),
|
|
3417
3385
|
sender: actor,
|
|
3418
3386
|
pull_request: v.optional(pullRequestSchema),
|
|
3387
|
+
changes: v.optional(v.object({
|
|
3388
|
+
title: v.optional(v.unknown()),
|
|
3389
|
+
body: v.optional(v.unknown())
|
|
3390
|
+
})),
|
|
3419
3391
|
issue: v.optional(v.object({
|
|
3420
3392
|
number: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
3421
3393
|
pull_request: v.optional(v.unknown())
|
|
@@ -3494,7 +3466,8 @@ function parseSnapshot(value) {
|
|
|
3494
3466
|
if (input.hostUpdates !== void 0) v.parse(v.array(v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i))), input.hostUpdates);
|
|
3495
3467
|
if (input.hostHeads !== void 0) v.parse(v.array(v.object({
|
|
3496
3468
|
head: v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i)),
|
|
3497
|
-
parent: v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i))
|
|
3469
|
+
parent: v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i)),
|
|
3470
|
+
repair: v.optional(v.literal(true))
|
|
3498
3471
|
})), input.hostHeads);
|
|
3499
3472
|
if (input.threadReopens !== void 0) v.parse(v.record(v.string(), v.pipe(v.number(), v.integer(), v.minValue(0))), input.threadReopens);
|
|
3500
3473
|
if (input.sourcePushHeads !== void 0) v.parse(v.array(v.string()), input.sourcePushHeads);
|
|
@@ -3502,6 +3475,16 @@ function parseSnapshot(value) {
|
|
|
3502
3475
|
if (input.sourcePushHead !== void 0) v.parse(v.string(), input.sourcePushHead);
|
|
3503
3476
|
if (input.recoveryHead !== void 0) v.parse(v.string(), input.recoveryHead);
|
|
3504
3477
|
if (input.humanFeedbackGeneration !== void 0) v.parse(v.pipe(v.number(), v.integer(), v.minValue(0)), input.humanFeedbackGeneration);
|
|
3478
|
+
if (input.metadataEdits !== void 0) {
|
|
3479
|
+
const edit = v.optional(v.object({
|
|
3480
|
+
generation: v.number(),
|
|
3481
|
+
externalGeneration: v.number()
|
|
3482
|
+
}));
|
|
3483
|
+
v.parse(v.object({
|
|
3484
|
+
title: edit,
|
|
3485
|
+
body: edit
|
|
3486
|
+
}), input.metadataEdits);
|
|
3487
|
+
}
|
|
3505
3488
|
if (input.ciEvidence !== void 0) v.parse(v.array(v.record(v.string(), v.unknown())), input.ciEvidence);
|
|
3506
3489
|
if (input.ownedReviewCommentIds !== void 0) v.parse(v.array(v.string()), input.ownedReviewCommentIds);
|
|
3507
3490
|
if (input.wait !== void 0) parseWait(input.wait);
|
|
@@ -3585,10 +3568,6 @@ function parseSummary(value) {
|
|
|
3585
3568
|
if (dailyPassBudget !== void 0) parsed.dailyPassBudget = parseDailyPassBudget(dailyPassBudget);
|
|
3586
3569
|
return parsed;
|
|
3587
3570
|
}
|
|
3588
|
-
/**
|
|
3589
|
-
* Converts a snapshot from an older inbox file. Older hosts used an `attention` status and a
|
|
3590
|
-
* `waitForChecks` record; both map to the current states. Invalid records are skipped.
|
|
3591
|
-
*/
|
|
3592
3571
|
function legacySnapshot(raw) {
|
|
3593
3572
|
const record = v.safeParse(legacyRecordSchema, raw);
|
|
3594
3573
|
if (!record.success) return void 0;
|
|
@@ -4587,7 +4566,7 @@ var PullRequestInbox = class {
|
|
|
4587
4566
|
if (!s.lease) s.status = s.wait ? "waiting" : "ready";
|
|
4588
4567
|
s.reasons = [.../* @__PURE__ */ new Set([...s.reasons, reason])];
|
|
4589
4568
|
}
|
|
4590
|
-
updatePr(s, pr) {
|
|
4569
|
+
updatePr(s, pr, ownChanges) {
|
|
4591
4570
|
pr = normalizePullRequest(pr);
|
|
4592
4571
|
if (s.pr && stamp(pr) < stamp(s.pr)) return false;
|
|
4593
4572
|
const previous = s.pr;
|
|
@@ -4615,6 +4594,15 @@ var PullRequestInbox = class {
|
|
|
4615
4594
|
}
|
|
4616
4595
|
if (pr.state === "closed") delete s.prospectivePush;
|
|
4617
4596
|
if (newHead && pr.head?.sha !== s.wait?.headSha || pr.state === "closed") delete s.wait;
|
|
4597
|
+
for (const field of ["title", "body"]) {
|
|
4598
|
+
if (pr[field] === void 0 || pr[field] === previous?.[field]) continue;
|
|
4599
|
+
const edits = s.metadataEdits ??= {};
|
|
4600
|
+
const generation = s.generation + 1;
|
|
4601
|
+
edits[field] = {
|
|
4602
|
+
generation,
|
|
4603
|
+
externalGeneration: ownChanges?.[field] ? edits[field]?.externalGeneration ?? 0 : generation
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4618
4606
|
s.pr = {
|
|
4619
4607
|
...previous,
|
|
4620
4608
|
...pr
|
|
@@ -4804,7 +4792,10 @@ var PullRequestInbox = class {
|
|
|
4804
4792
|
const pendingHead = sha && (check || event === "status") && (s.wait?.headSha === sha || s.lease && s.leaseUntil > this.clock() && (s.sourcePushHeads?.includes(sha) || s.prospectivePush?.token === s.lease && s.prospectivePush.heads.includes(sha)));
|
|
4805
4793
|
if (sha && s.pr?.head?.sha && s.pr.head.sha !== sha && !pushRefMatch && !pendingHead) continue;
|
|
4806
4794
|
let changed = false;
|
|
4807
|
-
if (payload.pull_request)
|
|
4795
|
+
if (payload.pull_request) {
|
|
4796
|
+
const ownEdit = event === "pull_request" && payload.action === "edited" && payload.sender?.type?.toLowerCase() === "bot" && this.activityAuthors.has(payload.sender.login?.toLowerCase() ?? "");
|
|
4797
|
+
changed = this.updatePr(s, payload.pull_request, ownEdit ? payload.changes : void 0);
|
|
4798
|
+
}
|
|
4808
4799
|
if (event === "pull_request" && payload.action === "synchronize" && s.hostUpdates?.length) this.settleHostUpdate(s, payload);
|
|
4809
4800
|
const upsert = (map, value, itemKey) => {
|
|
4810
4801
|
if (!value) return;
|
|
@@ -5055,7 +5046,7 @@ var PullRequestInbox = class {
|
|
|
5055
5046
|
id: thread.node_id ?? thread.id,
|
|
5056
5047
|
isResolved: thread.isResolved,
|
|
5057
5048
|
isOutdated: thread.isOutdated,
|
|
5058
|
-
comments: (Array.isArray(thread.comments) ? thread.comments : thread.comments?.nodes ?? []).map((comment) => String(comment.node_id ?? comment.id)).sort()
|
|
5049
|
+
comments: (Array.isArray(thread.comments) ? thread.comments : thread.comments?.nodes ?? []).map((comment) => `${String(comment.node_id ?? comment.id)}:${String((comment.user ?? comment.author)?.login ?? "")}`).sort()
|
|
5059
5050
|
})).sort((a, b) => String(a.id).localeCompare(String(b.id)));
|
|
5060
5051
|
const changed = digest(semantic(s.threads)) !== digest(semantic(threads));
|
|
5061
5052
|
s.threads = threads;
|
|
@@ -5111,7 +5102,7 @@ var PullRequestInbox = class {
|
|
|
5111
5102
|
token: claim.token,
|
|
5112
5103
|
heads
|
|
5113
5104
|
};
|
|
5114
|
-
if (lineage?.hostOnly && /^[a-f\d]{40}$/i.test(lineage.parent)) this.addHostHead(s, head, lineage.parent);
|
|
5105
|
+
if (lineage?.hostOnly && /^[a-f\d]{40}$/i.test(lineage.parent)) this.addHostHead(s, head, lineage.parent, true);
|
|
5115
5106
|
s.revision = (s.revision ?? 0) + 1;
|
|
5116
5107
|
await this.put(tx, s);
|
|
5117
5108
|
return true;
|
|
@@ -5134,11 +5125,12 @@ var PullRequestInbox = class {
|
|
|
5134
5125
|
await this.put(tx, s);
|
|
5135
5126
|
});
|
|
5136
5127
|
}
|
|
5137
|
-
addHostHead(s, head, parent) {
|
|
5128
|
+
addHostHead(s, head, parent, repair = false) {
|
|
5138
5129
|
if (s.hostHeads?.some((entry) => entry.head === head)) return;
|
|
5139
5130
|
s.hostHeads = [...s.hostHeads ?? [], {
|
|
5140
5131
|
head,
|
|
5141
|
-
parent
|
|
5132
|
+
parent,
|
|
5133
|
+
...repair && { repair: true }
|
|
5142
5134
|
}].slice(-64);
|
|
5143
5135
|
}
|
|
5144
5136
|
/**
|
|
@@ -5172,16 +5164,13 @@ var PullRequestInbox = class {
|
|
|
5172
5164
|
return true;
|
|
5173
5165
|
});
|
|
5174
5166
|
}
|
|
5175
|
-
|
|
5176
|
-
* Records that a claimed pass started the model, with the exemption that let it run past
|
|
5177
|
-
* `budgets.dailyPasses`. It changes no evidence, so the claim stays current.
|
|
5178
|
-
*/
|
|
5179
|
-
async recordModelPass(claim, exemption) {
|
|
5167
|
+
async recordModelPass(claim, exemption, observed) {
|
|
5180
5168
|
if (this.budgets.dailyPasses === void 0) return false;
|
|
5181
5169
|
return await this.transaction(async (tx) => {
|
|
5182
5170
|
const s = await this.getIn(tx, claim.snapshot.repository, claim.snapshot.number);
|
|
5183
5171
|
const at = this.clock();
|
|
5184
5172
|
if (!s || s.lease !== claim.token || s.leaseUntil <= at) return false;
|
|
5173
|
+
if (observed && (s.generation !== observed.generation || (s.revision ?? 0) !== (observed.revision ?? 0))) return "changed";
|
|
5185
5174
|
s.dailyPassBudget = nextDailyPassBudget(s.dailyPassBudget, at, s.humanFeedbackGeneration, exemption);
|
|
5186
5175
|
s.revision = (s.revision ?? 0) + 1;
|
|
5187
5176
|
await this.put(tx, s);
|
|
@@ -5660,7 +5649,6 @@ const commentProjection = (value, head) => ({
|
|
|
5660
5649
|
originalCommit: value.original_commit_id,
|
|
5661
5650
|
headRelation: headRelation(value.commit_id ?? value.commit?.oid, head)
|
|
5662
5651
|
});
|
|
5663
|
-
/** Whitelist useful fields while retaining every comment and review body. */
|
|
5664
5652
|
function projectSnapshotContext(snapshot) {
|
|
5665
5653
|
const pr = snapshot.pr ?? {};
|
|
5666
5654
|
const head = pr.head?.sha;
|
|
@@ -5783,7 +5771,6 @@ function projectSnapshotContext(snapshot) {
|
|
|
5783
5771
|
}
|
|
5784
5772
|
};
|
|
5785
5773
|
}
|
|
5786
|
-
/** Escape both element content and identifiers; repository data cannot create XML tags. */
|
|
5787
5774
|
function escapeSnapshotXml(value) {
|
|
5788
5775
|
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5789
5776
|
}
|
|
@@ -5897,7 +5884,10 @@ async function readForgePullRequestThreads(provider, repository, number, signal)
|
|
|
5897
5884
|
},
|
|
5898
5885
|
signal
|
|
5899
5886
|
})).data);
|
|
5900
|
-
}, thread.id) : thread.comments.flatMap((comment) => comment.ref ? [{
|
|
5887
|
+
}, thread.id) : thread.comments.flatMap((comment) => comment.ref ? [{
|
|
5888
|
+
id: comment.ref.id,
|
|
5889
|
+
...commentAuthor(comment.author)
|
|
5890
|
+
}] : []);
|
|
5901
5891
|
threads.push({
|
|
5902
5892
|
id: thread.id,
|
|
5903
5893
|
node_id: thread.id,
|
|
@@ -5912,6 +5902,12 @@ async function readForgePullRequestThreads(provider, repository, number, signal)
|
|
|
5912
5902
|
}
|
|
5913
5903
|
return threads;
|
|
5914
5904
|
}
|
|
5905
|
+
function commentAuthor(author) {
|
|
5906
|
+
return author ? { user: {
|
|
5907
|
+
login: author.login,
|
|
5908
|
+
type: author.isBotHint ? "Bot" : author.typeRaw ?? "User"
|
|
5909
|
+
} } : {};
|
|
5910
|
+
}
|
|
5915
5911
|
const index = (items) => Object.fromEntries(items.map((item) => [String(item.id), item]));
|
|
5916
5912
|
const pageInfo = v.object({
|
|
5917
5913
|
hasNextPage: v.boolean(),
|
|
@@ -5920,7 +5916,11 @@ const pageInfo = v.object({
|
|
|
5920
5916
|
const commentConnection = v.object({
|
|
5921
5917
|
nodes: v.array(v.object({
|
|
5922
5918
|
id: v.string(),
|
|
5923
|
-
databaseId: v.nullish(v.number())
|
|
5919
|
+
databaseId: v.nullish(v.number()),
|
|
5920
|
+
author: v.nullish(v.object({
|
|
5921
|
+
login: v.string(),
|
|
5922
|
+
__typename: v.optional(v.string())
|
|
5923
|
+
}))
|
|
5924
5924
|
})),
|
|
5925
5925
|
pageInfo
|
|
5926
5926
|
});
|
|
@@ -5950,14 +5950,17 @@ async function readThreadComments(request, id) {
|
|
|
5950
5950
|
do {
|
|
5951
5951
|
const more = v.parse(v.object({ node: v.object({ comments: commentConnection }) }), await request(`query GitHubPullRequestThreadComments($id:ID!,$after:String) {
|
|
5952
5952
|
node(id:$id) { ... on PullRequestReviewThread { comments(first:100,after:$after) {
|
|
5953
|
-
nodes { id databaseId } pageInfo { hasNextPage endCursor }
|
|
5953
|
+
nodes { id databaseId author { login __typename } } pageInfo { hasNextPage endCursor }
|
|
5954
5954
|
} } }
|
|
5955
5955
|
}`, {
|
|
5956
5956
|
id,
|
|
5957
5957
|
after
|
|
5958
5958
|
}));
|
|
5959
5959
|
after = nextCursor(more.node.comments, pages);
|
|
5960
|
-
comments.push(...more.node.comments.nodes)
|
|
5960
|
+
comments.push(...more.node.comments.nodes.map(({ author, ...comment }) => author ? {
|
|
5961
|
+
...comment,
|
|
5962
|
+
author
|
|
5963
|
+
} : comment));
|
|
5961
5964
|
} while (after);
|
|
5962
5965
|
return comments;
|
|
5963
5966
|
}
|
|
@@ -6063,7 +6066,6 @@ async function reconcileOneSnapshot(inbox, read, now = Date.now(), readThreads,
|
|
|
6063
6066
|
if (!s) return;
|
|
6064
6067
|
await probeSnapshot(inbox, read, s, now, readThreads, activityAuthors, signal);
|
|
6065
6068
|
}
|
|
6066
|
-
/** Reads one PR over REST and ingests it as synthetic deliveries, so missed webhooks are recovered. */
|
|
6067
6069
|
async function probeSnapshot(inbox, read, s, now, readThreads, activityAuthors = [], signal) {
|
|
6068
6070
|
signal?.throwIfAborted();
|
|
6069
6071
|
await inbox.setMeta(`snapshot-probe:${s.repository}:${s.number}`, now + 9e5, signal);
|
|
@@ -7057,6 +7059,30 @@ function repairEnvironment(environment = {}, githubConfigDirectory, identity = {
|
|
|
7057
7059
|
GIT_TERMINAL_PROMPT: "0"
|
|
7058
7060
|
};
|
|
7059
7061
|
}
|
|
7062
|
+
// src/babysitter/repair-evidence.ts
|
|
7063
|
+
function changedEvidence(before, after) {
|
|
7064
|
+
const changes = [];
|
|
7065
|
+
if (before.pr?.head?.sha !== after.pr?.head?.sha) changes.push("head");
|
|
7066
|
+
if (before.pr?.base?.ref !== after.pr?.base?.ref) changes.push("base");
|
|
7067
|
+
for (const field of [
|
|
7068
|
+
"title",
|
|
7069
|
+
"body",
|
|
7070
|
+
"draft"
|
|
7071
|
+
]) if (before.pr?.[field] !== after.pr?.[field]) changes.push(`pr.${field}`);
|
|
7072
|
+
for (const field of [
|
|
7073
|
+
"comments",
|
|
7074
|
+
"reviews",
|
|
7075
|
+
"reviewComments",
|
|
7076
|
+
"checks",
|
|
7077
|
+
"statuses"
|
|
7078
|
+
]) for (const [key, value] of Object.entries(after[field])) if (JSON.stringify(before[field][key]) !== JSON.stringify(value)) changes.push(`${field}:${key}`);
|
|
7079
|
+
const threads = new Map(before.threads.map((thread) => [String(thread.node_id ?? thread.id), JSON.stringify(thread)]));
|
|
7080
|
+
for (const thread of after.threads) {
|
|
7081
|
+
const id = String(thread.node_id ?? thread.id);
|
|
7082
|
+
if (threads.get(id) !== JSON.stringify(thread)) changes.push(`threads:${id}`);
|
|
7083
|
+
}
|
|
7084
|
+
return changes.length > 20 ? [...changes.slice(0, 20), `+${changes.length - 20} more`] : changes;
|
|
7085
|
+
}
|
|
7060
7086
|
// src/babysitter/wait.ts
|
|
7061
7087
|
const hash = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
7062
7088
|
const pending = /* @__PURE__ */ new Set([
|
|
@@ -7077,23 +7103,15 @@ const failed = /* @__PURE__ */ new Set([
|
|
|
7077
7103
|
]);
|
|
7078
7104
|
/** Check conclusions that need repair. */
|
|
7079
7105
|
const failedConclusions = failed;
|
|
7080
|
-
/** A pending commit status this old is treated as stuck. */
|
|
7081
7106
|
const stuckCheckMs = 18e5;
|
|
7082
|
-
/**
|
|
7083
|
-
* GitHub Actions keeps a job queued for up to 24 hours and runs it for up to 6, so only its check runs
|
|
7084
|
-
* past those limits are stuck. GitHub sets a queued run's `started_at` when it creates the run. A job
|
|
7085
|
-
* can wait hours for a runner, and a shorter limit lets passes push over CI runs that are only queued.
|
|
7086
|
-
*/
|
|
7087
7107
|
const stuckQueuedCheckMs = 864e5;
|
|
7088
7108
|
const stuckRunningCheckMs = 288e5;
|
|
7089
|
-
/** Check run statuses that have not reached a runner yet. */
|
|
7090
7109
|
const notStarted = /* @__PURE__ */ new Set([
|
|
7091
7110
|
"queued",
|
|
7092
7111
|
"waiting",
|
|
7093
7112
|
"pending",
|
|
7094
7113
|
"requested"
|
|
7095
7114
|
]);
|
|
7096
|
-
/** GitHub Actions' app id on github.com. */
|
|
7097
7115
|
const actionsAppId = 15368;
|
|
7098
7116
|
const isActionsCheck = (signal) => signal.app?.slug === "github-actions" || signal.app?.id === actionsAppId;
|
|
7099
7117
|
/**
|
|
@@ -7121,7 +7139,6 @@ function commentIds(value) {
|
|
|
7121
7139
|
value.databaseId
|
|
7122
7140
|
].filter((id) => id !== void 0 && id !== null).map(String);
|
|
7123
7141
|
}
|
|
7124
|
-
/** Webhook replays carry fresh transport metadata. Ignore it, so unchanged feedback keeps a wait. */
|
|
7125
7142
|
function stableFeedback(value) {
|
|
7126
7143
|
if (Array.isArray(value)) return value.map(stableFeedback);
|
|
7127
7144
|
if (!isRuntimeRecord(value)) return value;
|
|
@@ -7134,16 +7151,11 @@ function stableFeedback(value) {
|
|
|
7134
7151
|
"resolutionObservedAt"
|
|
7135
7152
|
].includes(key)).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, stableFeedback(item)]));
|
|
7136
7153
|
}
|
|
7137
|
-
/**
|
|
7138
|
-
* A comment-only review that asks for nothing. An empty body only groups inline comments, which the
|
|
7139
|
-
* context keeps. A review bot can submit that empty review first and edit it to a no-findings verdict.
|
|
7140
|
-
*/
|
|
7141
7154
|
function withoutFindings(review, policy) {
|
|
7142
7155
|
if (String(review.state ?? "").toLowerCase() !== "commented") return false;
|
|
7143
7156
|
const body = hasRuntimeType(review.body, "string") ? review.body.trimStart() : "";
|
|
7144
7157
|
return !body || policy.noFindingsReviews.some((prefix) => body.startsWith(prefix));
|
|
7145
7158
|
}
|
|
7146
|
-
/** Feedback, intent, and base that need a model pass when they change. CI results are excluded. */
|
|
7147
7159
|
function repairContextKey(s, policy) {
|
|
7148
7160
|
const pr = s.pr;
|
|
7149
7161
|
const settled = reviewPushBudgetSpent(s, policy);
|
|
@@ -7173,7 +7185,6 @@ function repairContextKey(s, policy) {
|
|
|
7173
7185
|
threads: stableFeedback(threads)
|
|
7174
7186
|
});
|
|
7175
7187
|
}
|
|
7176
|
-
/** Current-head check runs, without workflow aggregates, and commit statuses. */
|
|
7177
7188
|
function currentCheckSignals(s) {
|
|
7178
7189
|
const head = s.pr?.head?.sha;
|
|
7179
7190
|
const signals = /* @__PURE__ */ new Map();
|
|
@@ -7240,11 +7251,9 @@ function missingRequiredChecks(s, evaluation, now = Date.now()) {
|
|
|
7240
7251
|
function failureKeys(s) {
|
|
7241
7252
|
return latestCheckSignals(s).filter((signal) => failed.has(String(signal.conclusion ?? signal.state))).map((signal) => `${String(signal.id ?? signal.context)}:${String(signal.conclusion ?? signal.state)}`).sort();
|
|
7242
7253
|
}
|
|
7243
|
-
/** Failed current-head checks outside the configured review checks. */
|
|
7244
7254
|
function repairFailureKeys(s, policy) {
|
|
7245
7255
|
return latestCheckSignals(s).filter((signal) => failed.has(String(signal.conclusion ?? signal.state)) && !policy.pendingReviewChecks.has(String(signal.name).toLowerCase())).map((signal) => `${String(signal.id ?? signal.context)}:${String(signal.conclusion ?? signal.state)}`).sort();
|
|
7246
7256
|
}
|
|
7247
|
-
/** Failures that need repair. A spent review push budget leaves out the review checks. */
|
|
7248
7257
|
function actionableFailureKeys(s, policy) {
|
|
7249
7258
|
return reviewPushBudgetSpent(s, policy) ? repairFailureKeys(s, policy) : failureKeys(s);
|
|
7250
7259
|
}
|
|
@@ -7276,10 +7285,6 @@ function reviewPushBudgetWork(s, policy, assessedFeedback) {
|
|
|
7276
7285
|
if (head && !s.reviewPushBudget?.heads.includes(head)) work.push("new-head");
|
|
7277
7286
|
return work;
|
|
7278
7287
|
}
|
|
7279
|
-
/**
|
|
7280
|
-
* An unresolved review thread that needs a pass. Held threads wait for a person, and once bot threads
|
|
7281
|
-
* are settled only a person's comment counts.
|
|
7282
|
-
*/
|
|
7283
7288
|
function hasActionableThread(s, policy) {
|
|
7284
7289
|
const botThreadsSettled = policy.ignoreAssessedBotThreads === true || reviewPushBudgetSpent(s, policy);
|
|
7285
7290
|
return s.threads.some((thread) => thread.isResolved !== true && !policy.heldThreads?.has(String(thread.node_id ?? thread.id)) && (!botThreadsSettled || hasHumanComment(thread, policy.workerAuthors)));
|
|
@@ -7342,13 +7347,14 @@ function createCheckWait(observed, policy) {
|
|
|
7342
7347
|
};
|
|
7343
7348
|
}
|
|
7344
7349
|
/** Why a parked PR needs a model pass or a direct merge. Empty means it keeps waiting. */
|
|
7345
|
-
function wakeReasons(s, requiredChecks, policy) {
|
|
7350
|
+
function wakeReasons(s, requiredChecks, policy, repairOwnPush = false) {
|
|
7346
7351
|
const wait = s.wait;
|
|
7347
7352
|
if (!wait) return ["no-wait"];
|
|
7348
7353
|
if (s.pr?.state !== "open") return ["not-open"];
|
|
7349
7354
|
if (wait.headSha !== s.pr.head?.sha) return [];
|
|
7350
7355
|
const known = new Set(wait.knownFailures ?? []);
|
|
7351
7356
|
if (wait.defer === "checks") {
|
|
7357
|
+
if (repairOwnPush) return ["new-failure"];
|
|
7352
7358
|
const conflict = s.pr.mergeable === false || s.pr.mergeable_state === "dirty";
|
|
7353
7359
|
if (!conflict && checksStillRunning(s, Date.now(), policy)) return [];
|
|
7354
7360
|
const failure = actionableFailureKeys(s, policy).some((key) => !known.has(key));
|
|
@@ -7400,7 +7406,6 @@ const providerStrikesKey = "provider-quota-strikes";
|
|
|
7400
7406
|
const forgeBlockedKey = "forge-quota-blocked-until";
|
|
7401
7407
|
/** The longest provider or forge cooldown. */
|
|
7402
7408
|
const maxQuotaCooldownMs = 36e5;
|
|
7403
|
-
/** A success removes a strike only this long after the last cooldown ended. */
|
|
7404
7409
|
const strikeRecoveryMs = 18e5;
|
|
7405
7410
|
/**
|
|
7406
7411
|
* Provider rate limits are short throughput windows, not an exhausted quota. A model 429 closes
|
|
@@ -7429,10 +7434,18 @@ function createProviderQuota(store, cooldownMs, now = Date.now) {
|
|
|
7429
7434
|
}
|
|
7430
7435
|
};
|
|
7431
7436
|
}
|
|
7437
|
+
function isProviderRateLimit(error) {
|
|
7438
|
+
if (error instanceof Error && error.name === "AbortError") return false;
|
|
7439
|
+
if (error instanceof RateLimitedError) return true;
|
|
7440
|
+
return [error, error instanceof Error ? error.cause : void 0].some((candidate) => isRuntimeRecord(candidate) && candidate.code === "AGENT_R0726" && hasRuntimeType(candidate.message, "string") && /\b429\b|too many requests|rate limit|\busage limit\b/i.test(candidate.message));
|
|
7441
|
+
}
|
|
7442
|
+
function isProviderFailure(error) {
|
|
7443
|
+
if (error instanceof Error && error.name === "AbortError") return false;
|
|
7444
|
+
return isProviderRateLimit(error) || [error, error instanceof Error ? error.cause : void 0].some((candidate) => isRuntimeRecord(candidate) && hasRuntimeType(candidate.message, "string") && /stream disconnected before completion|stream closed before response\.completed/i.test(candidate.message));
|
|
7445
|
+
}
|
|
7432
7446
|
const forgeStrikesKey = "forge-quota-strikes";
|
|
7433
7447
|
const forgeLastBlockKey = "forge-quota-last-block";
|
|
7434
7448
|
const firstForgeCooldownMs = 3e5;
|
|
7435
|
-
/** A block that starts this soon after the previous one counts as a repeat. */
|
|
7436
7449
|
const forgeRepeatMs = 72e5;
|
|
7437
7450
|
const maxForgeStrikes = Math.ceil(Math.log2(maxQuotaCooldownMs / firstForgeCooldownMs)) + 1;
|
|
7438
7451
|
/**
|
|
@@ -7459,9 +7472,7 @@ function createForgeQuota(store, now = Date.now) {
|
|
|
7459
7472
|
};
|
|
7460
7473
|
}
|
|
7461
7474
|
// src/babysitter/base-freshness.ts
|
|
7462
|
-
/** Files the comparison may list before it counts as truncated. GitHub caps this at 300. */
|
|
7463
7475
|
const compareFileLimit = 300;
|
|
7464
|
-
/** Pushes this close to the run start may not be in the run's checkout. */
|
|
7465
7476
|
const pushMarginMs = 12e4;
|
|
7466
7477
|
/**
|
|
7467
7478
|
* The base tip that the earliest Actions run behind the selected current-head checks tested: the last
|
|
@@ -7585,10 +7596,6 @@ function parseFailedActionOutput(log) {
|
|
|
7585
7596
|
lines: new Set(lines.slice(commandEnd + 1, end).filter((line) => line && !line.startsWith("##[group]") && !line.startsWith("##[endgroup]")).map((line) => line.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g, "<id>").replace(/\b\d+(\.\d+)?\s?(ms|s|m)\b/g, "<time>").replace(/\b\d\d:\d\d:\d\d\b/g, "<clock>")))
|
|
7586
7597
|
};
|
|
7587
7598
|
}
|
|
7588
|
-
/**
|
|
7589
|
-
* Lines that name what failed: test runner FAIL and × lines, error totals and Actions error annotations.
|
|
7590
|
-
* Build-size and pass-count lines differ between any two runs, so they stay out.
|
|
7591
|
-
*/
|
|
7592
7599
|
const failureSignaturePatterns = [
|
|
7593
7600
|
/^\s*FAIL\s+\S/,
|
|
7594
7601
|
/^\s*[×✗]\s+\S/,
|
|
@@ -7615,10 +7622,6 @@ function sameActionFailure(own, base) {
|
|
|
7615
7622
|
}
|
|
7616
7623
|
return own.step === base.step && [...own.lines].every((line) => base.lines.has(line));
|
|
7617
7624
|
}
|
|
7618
|
-
/**
|
|
7619
|
-
* Log lines that only a runner or the network causes: a lost runner, or a registry, Git or image fetch
|
|
7620
|
-
* that failed. Errors a PR can cause, such as test timeouts or a refused local port, are left out.
|
|
7621
|
-
*/
|
|
7622
7625
|
const infrastructureFailurePatterns = [
|
|
7623
7626
|
/The runner has received a shutdown signal/,
|
|
7624
7627
|
/lost communication with the server/i,
|
|
@@ -7908,7 +7911,6 @@ function runsOnPush(workflow, branch) {
|
|
|
7908
7911
|
} else if (branchFilter(pattern).test(branch)) match = true;
|
|
7909
7912
|
return match;
|
|
7910
7913
|
}
|
|
7911
|
-
/** GitHub's branch filter pattern as a regular expression: `**` crosses `/`, `*` does not. */
|
|
7912
7914
|
function branchFilter(pattern) {
|
|
7913
7915
|
let source = "";
|
|
7914
7916
|
for (let index = 0; index < pattern.length; index++) {
|
|
@@ -8009,7 +8011,6 @@ async function pnpmInstallKey(cwd, repository = cwd) {
|
|
|
8009
8011
|
for (const file of patches.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)).sort()) hash.update(`\0${relative(cwd, file)}\0`).update(await readFile(file));
|
|
8010
8012
|
return hash.digest("hex").slice(0, 32);
|
|
8011
8013
|
}
|
|
8012
|
-
/** node_modules trees of the workspace root and its packages, relative to `cwd`. */
|
|
8013
8014
|
async function nodeModulesTrees(cwd) {
|
|
8014
8015
|
const trees = [];
|
|
8015
8016
|
const walk = async (directory, depth) => {
|
|
@@ -8050,10 +8051,6 @@ function resolveCache(install, env) {
|
|
|
8050
8051
|
configured: configured.directory !== void 0 || Boolean(env.BABYSITTER_INSTALL_CACHE)
|
|
8051
8052
|
};
|
|
8052
8053
|
}
|
|
8053
|
-
/**
|
|
8054
|
-
* Without reflinks, a restore and a save each write the full node_modules trees again. On ext4 that
|
|
8055
|
-
* cost more than a frozen install from the pnpm store, so the default cache needs reflinks.
|
|
8056
|
-
*/
|
|
8057
8054
|
async function supportsReflinks(directory, destination) {
|
|
8058
8055
|
const probe = join(directory, `.reflink-probe-${process.pid}-${Date.now()}`);
|
|
8059
8056
|
const copy = join(destination, `.reflink-probe-${process.pid}-${Date.now()}.copy`);
|
|
@@ -8835,18 +8832,12 @@ Opened automatically by the Babysitter.`;
|
|
|
8835
8832
|
};
|
|
8836
8833
|
}
|
|
8837
8834
|
// src/babysitter/server.ts
|
|
8838
|
-
/** The first and the longest wait before a reviewed head's merge gates are checked again. */
|
|
8839
8835
|
const mergeRetryMinMs = 12e4;
|
|
8840
8836
|
const mergeRetryMaxMs = 18e5;
|
|
8841
|
-
/** Inbox meta key of the review threads a worker declined while their reviewer labeled them P0 or P1. */
|
|
8842
8837
|
const heldThreadsKey = (repository, number) => `held-review-threads:${repository}#${number}`;
|
|
8843
|
-
/** How long an external blocker waits before another pass. */
|
|
8844
8838
|
const externalRetryMs = 72e5;
|
|
8845
|
-
/** How long a head may wait for GitHub to compute its mergeability before its pass runs anyway. */
|
|
8846
8839
|
const unknownMergeabilityLimitMs = 6e5;
|
|
8847
|
-
/** How long a pending GitHub merge request is polled before the Babysitter stops waiting for it. */
|
|
8848
8840
|
const pendingMergeDeadlineMs = 18e5;
|
|
8849
|
-
/** How long a stopped merge request keeps its head from a new request. */
|
|
8850
8841
|
const stoppedMergeRetryMs = 72e5;
|
|
8851
8842
|
/**
|
|
8852
8843
|
* GitHub settles most asynchronous merges in seconds, so poll a pending request less often as it ages:
|
|
@@ -8856,7 +8847,6 @@ const stoppedMergeRetryMs = 72e5;
|
|
|
8856
8847
|
function pendingMergeRetryAt(startedAt, now) {
|
|
8857
8848
|
return now + Math.min(3e5, Math.max(3e4, now - startedAt));
|
|
8858
8849
|
}
|
|
8859
|
-
/** The `status` of GitHub's merge result that a merge rejection carries in its response excerpt. */
|
|
8860
8850
|
function mergeResultStatus(error) {
|
|
8861
8851
|
try {
|
|
8862
8852
|
const body = JSON.parse(error.body);
|
|
@@ -8865,18 +8855,6 @@ function mergeResultStatus(error) {
|
|
|
8865
8855
|
return;
|
|
8866
8856
|
}
|
|
8867
8857
|
}
|
|
8868
|
-
/** Provider quota and rate-limit failures. Cancellation is never a rate limit. */
|
|
8869
|
-
function isProviderRateLimit(error) {
|
|
8870
|
-
if (error instanceof Error && error.name === "AbortError") return false;
|
|
8871
|
-
if (error instanceof RateLimitedError) return true;
|
|
8872
|
-
return [error, error instanceof Error ? error.cause : void 0].some((candidate) => isRuntimeRecord(candidate) && candidate.code === "AGENT_R0726" && hasRuntimeType(candidate.message, "string") && /\b429\b|too many requests|rate limit|\busage limit\b/i.test(candidate.message));
|
|
8873
|
-
}
|
|
8874
|
-
/** A provider failure that says nothing about the PR: a rate limit or a stream the provider dropped. */
|
|
8875
|
-
function isProviderFailure(error) {
|
|
8876
|
-
if (error instanceof Error && error.name === "AbortError") return false;
|
|
8877
|
-
return isProviderRateLimit(error) || [error, error instanceof Error ? error.cause : void 0].some((candidate) => isRuntimeRecord(candidate) && hasRuntimeType(candidate.message, "string") && /stream disconnected before completion|stream closed before response\.completed/i.test(candidate.message));
|
|
8878
|
-
}
|
|
8879
|
-
/** A provider failure this soon after dispatch gives the daily pass back. A longer pass did real work. */
|
|
8880
8858
|
const providerFailureReleaseMs = 6e5;
|
|
8881
8859
|
function createBabysitterRuntime(options) {
|
|
8882
8860
|
if (!Number.isInteger(options.concurrency) || options.concurrency < 1) throw presetsErrorDiagnostics.PRESETS_BABYSITTER_OPTION_INVALID({
|
|
@@ -8978,7 +8956,7 @@ function createBabysitterRuntime(options) {
|
|
|
8978
8956
|
ignoreAssessedBotThreads: presetOptions.ignoreAssessedBotThreads === true
|
|
8979
8957
|
};
|
|
8980
8958
|
const schedulerEvent = (name, properties = {}) => options.event?.(name, properties);
|
|
8981
|
-
const release = baseAgent.version ?? "
|
|
8959
|
+
const release = baseAgent.version ?? "4db4e0330c76cfb71d77dc83de506eac3b90993c4fd38754b88d9c2b1cad11c9";
|
|
8982
8960
|
const workspaces = options.workspaces;
|
|
8983
8961
|
const schedulerError = (name, error, properties = {}) => options.error?.(name, error, properties);
|
|
8984
8962
|
const statusComment = !!verifiedHostIdentity && presetOptions.status?.comment !== false;
|
|
@@ -9406,20 +9384,24 @@ function createBabysitterRuntime(options) {
|
|
|
9406
9384
|
}
|
|
9407
9385
|
/**
|
|
9408
9386
|
* Failed checks that ran on an older base get one retest on the current base before a model pass,
|
|
9409
|
-
* when the base tip has no failing check.
|
|
9387
|
+
* when the base tip has no failing check. It does not wait for the head's other checks: they run on
|
|
9388
|
+
* the same old base. Two retests per PR every six hours, so a retest that lands on a base that is
|
|
9389
|
+
* still broken gets one more after the base is fixed.
|
|
9410
9390
|
*/
|
|
9411
9391
|
async function retestOnCurrentBase(snapshot, owner, signal) {
|
|
9412
9392
|
const { repository, number } = snapshot;
|
|
9413
9393
|
const pr = snapshot.pr;
|
|
9414
9394
|
const head = pr?.head?.sha;
|
|
9415
9395
|
if (!head || !pr?.base?.ref || pr.draft || pr.mergeable === false || pr.mergeable_state === "dirty") return false;
|
|
9416
|
-
if (!failureKeys(snapshot).length
|
|
9417
|
-
const key = `base-
|
|
9418
|
-
|
|
9396
|
+
if (!failureKeys(snapshot).length) return false;
|
|
9397
|
+
const key = `base-retests:${repository}#${number}`;
|
|
9398
|
+
const saved = await pullRequestInbox.meta(key);
|
|
9399
|
+
const recent = (Array.isArray(saved) ? saved : []).filter((at) => hasRuntimeType(at, "number") && at > Date.now() - 216e5);
|
|
9400
|
+
if (recent.length >= 2) return false;
|
|
9419
9401
|
const ahead = await baseFixedSinceFailure(freshnessReader, snapshot, failedConclusions, signal);
|
|
9420
9402
|
if (!ahead) return false;
|
|
9421
9403
|
if (!await updateBranch(owner, repository, number, head, signal, pr)) return false;
|
|
9422
|
-
await pullRequestInbox.setMeta(key, Date.now());
|
|
9404
|
+
await pullRequestInbox.setMeta(key, [...recent, Date.now()]);
|
|
9423
9405
|
schedulerEvent("babysitter.branch.retest", {
|
|
9424
9406
|
...owner,
|
|
9425
9407
|
base_ahead: ahead
|
|
@@ -9430,9 +9412,10 @@ function createBabysitterRuntime(options) {
|
|
|
9430
9412
|
/**
|
|
9431
9413
|
* A job that a runner or network error stopped gets a fresh CI run: the host updates the branch, once
|
|
9432
9414
|
* per head and base and at most hourly per PR. Without it, a PR waits for hours on a transient error,
|
|
9433
|
-
* such as a 504 from a setup action, that nothing retries.
|
|
9415
|
+
* such as a 504 from a setup action, that nothing retries. A cancelled required check gets the same
|
|
9416
|
+
* retest: a cancel or a job timeout has no code cause for a pass to repair.
|
|
9434
9417
|
*/
|
|
9435
|
-
async function retestInfrastructureFailure(snapshot, owner, signal) {
|
|
9418
|
+
async function retestInfrastructureFailure(snapshot, owner, signal, cause = "infrastructure") {
|
|
9436
9419
|
const { repository, number } = snapshot;
|
|
9437
9420
|
const pr = snapshot.pr;
|
|
9438
9421
|
const head = pr?.head?.sha;
|
|
@@ -9448,7 +9431,7 @@ function createBabysitterRuntime(options) {
|
|
|
9448
9431
|
if (!await updateBranch(owner, repository, number, head, signal, pr)) return false;
|
|
9449
9432
|
schedulerEvent("babysitter.branch.retest", {
|
|
9450
9433
|
...owner,
|
|
9451
|
-
cause
|
|
9434
|
+
cause
|
|
9452
9435
|
});
|
|
9453
9436
|
return true;
|
|
9454
9437
|
}
|
|
@@ -9759,11 +9742,11 @@ function createBabysitterRuntime(options) {
|
|
|
9759
9742
|
return hasRuntimeType(sha, "string") && /^[a-f\d]{40}$/i.test(sha) ? sha : void 0;
|
|
9760
9743
|
}
|
|
9761
9744
|
/** Current-head Actions checks that repeat the same job failure on the live base tip. */
|
|
9762
|
-
async function readInheritedBaseFailures(snapshot, signal, verificationBaseSha) {
|
|
9745
|
+
async function readInheritedBaseFailures(snapshot, signal, verificationBaseSha, whileRunning = false) {
|
|
9763
9746
|
const { repository } = snapshot;
|
|
9764
9747
|
const head = snapshot.pr?.head?.sha;
|
|
9765
9748
|
const baseRef = snapshot.pr?.base?.ref;
|
|
9766
|
-
if (!head || !baseRef || conflicted(snapshot) || checksStillRunning(snapshot)) return [];
|
|
9749
|
+
if (!head || !baseRef || conflicted(snapshot) || !whileRunning && checksStillRunning(snapshot)) return [];
|
|
9767
9750
|
const failing = currentActionRuns(snapshot, waitPolicy.pendingReviewChecks).filter((check) => failedConclusions.has(String(check.conclusion)));
|
|
9768
9751
|
if (!failing.length) return [];
|
|
9769
9752
|
const tip = verificationBaseSha ?? await liveBaseTip(repository, baseRef, signal);
|
|
@@ -9792,20 +9775,22 @@ function createBabysitterRuntime(options) {
|
|
|
9792
9775
|
return ids;
|
|
9793
9776
|
}
|
|
9794
9777
|
const inheritedFailures = /* @__PURE__ */ new Map();
|
|
9795
|
-
async function inheritedBaseFailures(snapshot, signal) {
|
|
9778
|
+
async function inheritedBaseFailures(snapshot, signal, whileRunning = false) {
|
|
9796
9779
|
try {
|
|
9797
|
-
return await readInheritedBaseFailures(snapshot, signal);
|
|
9780
|
+
return await readInheritedBaseFailures(snapshot, signal, void 0, whileRunning);
|
|
9798
9781
|
} catch (error) {
|
|
9799
9782
|
if (isAbortError(error)) throw error;
|
|
9800
9783
|
await noteForgeQuota(error, "inherited-failures");
|
|
9801
9784
|
return [];
|
|
9802
9785
|
}
|
|
9803
9786
|
}
|
|
9787
|
+
function failedSignals(snapshot) {
|
|
9788
|
+
return latestCheckSignals(snapshot).filter((check) => failedConclusions.has(String(check.conclusion ?? check.state)) && !waitPolicy.pendingReviewChecks.has(String(check.name ?? check.context).toLowerCase()));
|
|
9789
|
+
}
|
|
9804
9790
|
/** Why each failing current-head check outside the review checks fails. A cause the host cannot prove is `pr`. */
|
|
9805
|
-
async function failureCauses(snapshot, signal) {
|
|
9806
|
-
const failing = latestCheckSignals(snapshot).filter((check) => failedConclusions.has(String(check.conclusion ?? check.state)) && !waitPolicy.pendingReviewChecks.has(String(check.name ?? check.context).toLowerCase()));
|
|
9791
|
+
async function failureCauses(snapshot, signal, failing = failedSignals(snapshot), whileRunning = false) {
|
|
9807
9792
|
if (!failing.length) return [];
|
|
9808
|
-
const inherited = new Set(await inheritedBaseFailures(snapshot, signal));
|
|
9793
|
+
const inherited = new Set(await inheritedBaseFailures(snapshot, signal, whileRunning));
|
|
9809
9794
|
const causes = [];
|
|
9810
9795
|
for (const check of failing) {
|
|
9811
9796
|
const name = String(check.name ?? check.context);
|
|
@@ -9891,14 +9876,24 @@ function createBabysitterRuntime(options) {
|
|
|
9891
9876
|
const { provider, repo } = await forge(repository);
|
|
9892
9877
|
return await forgeBranchRules(provider, repo, branch);
|
|
9893
9878
|
});
|
|
9879
|
+
const mergeBlockers = /* @__PURE__ */ new WeakMap();
|
|
9894
9880
|
/**
|
|
9895
9881
|
* Merges a PR that inbox evidence, the merge policy, and GitHub's live state all report ready.
|
|
9896
9882
|
* Returns `not-ready` for a normal pass, and `blocked` while a merge outcome is unknown.
|
|
9897
9883
|
*/
|
|
9898
9884
|
async function mergeReadyPullRequest(claim, owner, signal, foldInto) {
|
|
9899
9885
|
if (merge.mode !== "direct") return "not-ready";
|
|
9886
|
+
const conventionalTitles = merge.conventionalTitles === true && foldInto === void 0;
|
|
9900
9887
|
const { snapshot } = claim;
|
|
9901
9888
|
const { repository, number } = snapshot;
|
|
9889
|
+
mergeBlockers.delete(claim);
|
|
9890
|
+
const mergeSkipped = (reason) => {
|
|
9891
|
+
mergeBlockers.set(claim, reason);
|
|
9892
|
+
schedulerEvent("babysitter.direct_merge.skipped", {
|
|
9893
|
+
...owner,
|
|
9894
|
+
reason
|
|
9895
|
+
});
|
|
9896
|
+
};
|
|
9902
9897
|
const base = snapshot.pr?.base?.ref;
|
|
9903
9898
|
if (!base) return "not-ready";
|
|
9904
9899
|
const pending = await pullRequestInbox.directMergeAttempt(repository, number);
|
|
@@ -10015,10 +10010,7 @@ function createBabysitterRuntime(options) {
|
|
|
10015
10010
|
}
|
|
10016
10011
|
} catch (error) {
|
|
10017
10012
|
await noteForgeQuota(error, "merge-reconcile");
|
|
10018
|
-
|
|
10019
|
-
...owner,
|
|
10020
|
-
reason: `merge outcome unknown: ${(error instanceof Error ? error.message : String(error)).slice(0, 160)}`
|
|
10021
|
-
});
|
|
10013
|
+
mergeSkipped(`merge outcome unknown: ${(error instanceof Error ? error.message : String(error)).slice(0, 160)}`);
|
|
10022
10014
|
return await parkMerge("GitHub merge outcome could not be reconciled; retrying the provider read.");
|
|
10023
10015
|
}
|
|
10024
10016
|
if (signal.aborted) return "blocked";
|
|
@@ -10036,7 +10028,8 @@ function createBabysitterRuntime(options) {
|
|
|
10036
10028
|
automatedReviewSettled: reviewPushBudgetSpent(snapshot, waitPolicy),
|
|
10037
10029
|
severeReviewSettled: severeReviewSettled(snapshot, waitPolicy),
|
|
10038
10030
|
heldThreads,
|
|
10039
|
-
inheritedCheckIds: new Set(inheritedCheckIds)
|
|
10031
|
+
inheritedCheckIds: new Set(inheritedCheckIds),
|
|
10032
|
+
conventionalTitles
|
|
10040
10033
|
});
|
|
10041
10034
|
if (!pending && snapshot.pr?.draft === true && evaluation.state !== "failed" && snapshot.pr.mergeable !== false && snapshot.pr.mergeable_state !== "dirty" && await markDraftReady(snapshot, owner, signal)) {
|
|
10042
10035
|
await pullRequestInbox.finish(claim, {
|
|
@@ -10068,10 +10061,7 @@ function createBabysitterRuntime(options) {
|
|
|
10068
10061
|
};
|
|
10069
10062
|
}
|
|
10070
10063
|
if (!decision.ready) {
|
|
10071
|
-
|
|
10072
|
-
...owner,
|
|
10073
|
-
reason: decision.reason
|
|
10074
|
-
});
|
|
10064
|
+
mergeSkipped(decision.reason);
|
|
10075
10065
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed merge is waiting for ${decision.reason}.`) : "not-ready";
|
|
10076
10066
|
}
|
|
10077
10067
|
const everyCheckGates = policy.status === "known" && !policy.required.length;
|
|
@@ -10084,10 +10074,7 @@ function createBabysitterRuntime(options) {
|
|
|
10084
10074
|
});
|
|
10085
10075
|
const until = since + firstCheckWaitMs;
|
|
10086
10076
|
if (until > pullRequestInbox.now()) {
|
|
10087
|
-
|
|
10088
|
-
...owner,
|
|
10089
|
-
reason: "no check reported for the head yet"
|
|
10090
|
-
});
|
|
10077
|
+
mergeSkipped("no check reported for the head yet");
|
|
10091
10078
|
return await parkMerge(`GitHub has reported no check for ${decision.head} yet; waiting until ${new Date(until).toISOString()} for its first check.`, until);
|
|
10092
10079
|
}
|
|
10093
10080
|
}
|
|
@@ -10098,10 +10085,7 @@ function createBabysitterRuntime(options) {
|
|
|
10098
10085
|
let mergeStarted = false;
|
|
10099
10086
|
const bypass = evaluation.bypassedRequiredChecks.length > 0;
|
|
10100
10087
|
if (foldInto !== void 0 && bypass) {
|
|
10101
|
-
|
|
10102
|
-
...owner,
|
|
10103
|
-
reason: "a fold never merges past failing required checks"
|
|
10104
|
-
});
|
|
10088
|
+
mergeSkipped("a fold never merges past failing required checks");
|
|
10105
10089
|
return pending?.asynchronous ? await parkMerge("Unconfirmed fold is waiting for passing required checks.") : "not-ready";
|
|
10106
10090
|
}
|
|
10107
10091
|
let inheritedProof;
|
|
@@ -10121,13 +10105,11 @@ function createBabysitterRuntime(options) {
|
|
|
10121
10105
|
} : live, decision.head, {
|
|
10122
10106
|
automatedReviewSettled: reviewPushBudgetSpent(snapshot, waitPolicy),
|
|
10123
10107
|
reviews: liveReviews.map(parseEvidence),
|
|
10124
|
-
...foldInto === void 0 ? {} : { foldInto: base }
|
|
10108
|
+
...foldInto === void 0 ? {} : { foldInto: base },
|
|
10109
|
+
conventionalTitles
|
|
10125
10110
|
});
|
|
10126
10111
|
if (!current.ready) {
|
|
10127
|
-
|
|
10128
|
-
...owner,
|
|
10129
|
-
reason: current.reason
|
|
10130
|
-
});
|
|
10112
|
+
mergeSkipped(current.reason);
|
|
10131
10113
|
if (!pending && current.reason === "mergeable_state behind") {
|
|
10132
10114
|
if (!await updateBranch(owner, repository, number, decision.head, signal, live, { reopenFork: false })) return "not-ready";
|
|
10133
10115
|
schedulerEvent("babysitter.branch.updated", {
|
|
@@ -10145,10 +10127,7 @@ function createBabysitterRuntime(options) {
|
|
|
10145
10127
|
}, signal, bypass ? /* @__PURE__ */ new Set(["success", ...failedConclusions]) : void 0);
|
|
10146
10128
|
if (overlap.length) {
|
|
10147
10129
|
const files = overlap.slice(0, 3).join(", ") + (overlap.length > 3 ? ` and ${overlap.length - 3} more` : "");
|
|
10148
|
-
|
|
10149
|
-
...owner,
|
|
10150
|
-
reason: `${base} changed files this PR touches after its checks ran: ${files}`
|
|
10151
|
-
});
|
|
10130
|
+
mergeSkipped(`${base} changed files this PR touches after its checks ran: ${files}`);
|
|
10152
10131
|
if (!await updateBranch(owner, repository, number, decision.head, signal, live)) {
|
|
10153
10132
|
const reopened = isForkHead(live, repository) ? await pullRequestInbox.meta(forkReopenKey(repository, number)) : void 0;
|
|
10154
10133
|
const at = isRuntimeRecord(reopened) ? Number(reopened.at) : NaN;
|
|
@@ -10204,10 +10183,7 @@ function createBabysitterRuntime(options) {
|
|
|
10204
10183
|
});
|
|
10205
10184
|
}
|
|
10206
10185
|
if (branchSafety !== true) {
|
|
10207
|
-
|
|
10208
|
-
...owner,
|
|
10209
|
-
reason: branchSafety
|
|
10210
|
-
});
|
|
10186
|
+
mergeSkipped(branchSafety);
|
|
10211
10187
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed merge is waiting for ${branchSafety}.`) : "not-ready";
|
|
10212
10188
|
}
|
|
10213
10189
|
if (foldInto !== void 0) {
|
|
@@ -10218,10 +10194,7 @@ function createBabysitterRuntime(options) {
|
|
|
10218
10194
|
}, signal);
|
|
10219
10195
|
const reason = foldParent(live, owners)?.number !== foldInto ? `parent #${foldInto} no longer owns ${base}` : await pullRequestInbox.directMergeAttempt(repository, foldInto) ? `parent #${foldInto} has a merge in flight` : void 0;
|
|
10220
10196
|
if (reason) {
|
|
10221
|
-
|
|
10222
|
-
...owner,
|
|
10223
|
-
reason
|
|
10224
|
-
});
|
|
10197
|
+
mergeSkipped(reason);
|
|
10225
10198
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed fold is waiting: ${reason}.`) : "not-ready";
|
|
10226
10199
|
}
|
|
10227
10200
|
}
|
|
@@ -10234,29 +10207,20 @@ function createBabysitterRuntime(options) {
|
|
|
10234
10207
|
const freshEvaluation = await checkEvaluation(fresh, policy, signal);
|
|
10235
10208
|
const freshDecision = readiness(fresh, freshEvaluation.state, freshEvaluation.inheritedCheckIds);
|
|
10236
10209
|
if (!freshDecision.ready) {
|
|
10237
|
-
|
|
10238
|
-
...owner,
|
|
10239
|
-
reason: `GitHub reports checks the inbox lacks: ${freshDecision.reason}`
|
|
10240
|
-
});
|
|
10210
|
+
mergeSkipped(`GitHub reports checks the inbox lacks: ${freshDecision.reason}`);
|
|
10241
10211
|
if (await pullRequestInbox.hydrate(claim, reported)) return pending ? await parkMerge(`Unconfirmed merge is waiting for ${freshDecision.reason}.`) : "not-ready";
|
|
10242
10212
|
await pullRequestInbox.release(claim);
|
|
10243
10213
|
return "blocked";
|
|
10244
10214
|
}
|
|
10245
10215
|
}
|
|
10246
10216
|
if (!await pullRequestInbox.isClaimCurrent(claim)) {
|
|
10247
|
-
|
|
10248
|
-
...owner,
|
|
10249
|
-
reason: "claim changed before merge"
|
|
10250
|
-
});
|
|
10217
|
+
mergeSkipped("claim changed before merge");
|
|
10251
10218
|
return "not-ready";
|
|
10252
10219
|
}
|
|
10253
10220
|
if (bypass && isRuntimeRecord(live)) {
|
|
10254
10221
|
const proof = await verifyInheritedMerge(snapshot, live, signal);
|
|
10255
10222
|
if ("refused" in proof) {
|
|
10256
|
-
|
|
10257
|
-
...owner,
|
|
10258
|
-
reason: proof.refused
|
|
10259
|
-
});
|
|
10223
|
+
mergeSkipped(proof.refused);
|
|
10260
10224
|
return pending?.asynchronous ? await parkMerge("Unconfirmed merge is waiting for inherited-check verification.") : "not-ready";
|
|
10261
10225
|
}
|
|
10262
10226
|
inheritedProof = proof;
|
|
@@ -10265,10 +10229,7 @@ function createBabysitterRuntime(options) {
|
|
|
10265
10229
|
}
|
|
10266
10230
|
signal.throwIfAborted();
|
|
10267
10231
|
if (!pending && !await pullRequestInbox.beginDirectMerge(claim, decision.head, true, foldInto)) {
|
|
10268
|
-
|
|
10269
|
-
...owner,
|
|
10270
|
-
reason: "merge attempt already in flight or claim changed"
|
|
10271
|
-
});
|
|
10232
|
+
mergeSkipped("merge attempt already in flight or claim changed");
|
|
10272
10233
|
return "blocked";
|
|
10273
10234
|
}
|
|
10274
10235
|
if (inheritedProof) {
|
|
@@ -10288,11 +10249,14 @@ function createBabysitterRuntime(options) {
|
|
|
10288
10249
|
}
|
|
10289
10250
|
mergeStarted = true;
|
|
10290
10251
|
try {
|
|
10252
|
+
const method = foldInto === void 0 ? merge.method : foldMethod(merge.method, repositorySettings);
|
|
10253
|
+
const title = conventionalTitles && method === "squash" && isRuntimeRecord(live) && hasRuntimeType(live.title, "string") ? { title: `${live.title} (#${number})` } : {};
|
|
10291
10254
|
await forgeMerge(provider, pull(number), {
|
|
10292
|
-
method
|
|
10255
|
+
method,
|
|
10293
10256
|
sha: decision.head,
|
|
10294
10257
|
signal,
|
|
10295
|
-
bypassRules: Boolean(inheritedProof)
|
|
10258
|
+
bypassRules: Boolean(inheritedProof),
|
|
10259
|
+
...title
|
|
10296
10260
|
});
|
|
10297
10261
|
} catch (error) {
|
|
10298
10262
|
if (!(error instanceof MergeBlockedError) || error.status === 409) throw error;
|
|
@@ -10305,10 +10269,7 @@ function createBabysitterRuntime(options) {
|
|
|
10305
10269
|
}
|
|
10306
10270
|
} catch (error) {
|
|
10307
10271
|
await noteForgeQuota(error, "direct-merge");
|
|
10308
|
-
|
|
10309
|
-
...owner,
|
|
10310
|
-
reason: (error instanceof Error ? error.message : String(error)).slice(0, 200)
|
|
10311
|
-
});
|
|
10272
|
+
mergeSkipped((error instanceof Error ? error.message : String(error)).slice(0, 200));
|
|
10312
10273
|
const rejectedStatus = forgeErrorStatus(error);
|
|
10313
10274
|
if (mergeStarted && rejectedStatus !== void 0 && rejectedStatus >= 400 && rejectedStatus < 500 && rejectedStatus !== 409) await pullRequestInbox.clearDirectMerge(repository, number, mergeToken);
|
|
10314
10275
|
return await parkMerge(`GitHub merge request failed: ${(error instanceof Error ? error.message : String(error)).slice(0, 200)}`);
|
|
@@ -10330,7 +10291,7 @@ function createBabysitterRuntime(options) {
|
|
|
10330
10291
|
return "merged";
|
|
10331
10292
|
}
|
|
10332
10293
|
await pullRequestInbox.finish(claim, {
|
|
10333
|
-
text: inheritedProof ? `Merged ${decision.head} directly past ${inheritedProof.evaluation.bypassedRequiredChecks.join(", ")}, which fail the same way on base ${inheritedProof.baseSha}; every other merge rule was satisfied.` : `Merged ${decision.head} directly: required checks
|
|
10294
|
+
text: inheritedProof ? `Merged ${decision.head} directly past ${inheritedProof.evaluation.bypassedRequiredChecks.join(", ")}, which fail the same way on base ${inheritedProof.baseSha}; every other merge rule was satisfied.` : `Merged ${decision.head} directly: required checks and review gates passed.`,
|
|
10334
10295
|
terminal: true
|
|
10335
10296
|
});
|
|
10336
10297
|
schedulerEvent("babysitter.owner.merged", {
|
|
@@ -10541,6 +10502,19 @@ function createBabysitterRuntime(options) {
|
|
|
10541
10502
|
async function requiredCheckState(snapshot, signal, fold = false) {
|
|
10542
10503
|
return (await requiredCheckEvaluation(snapshot, signal, fold))?.state ?? "unknown";
|
|
10543
10504
|
}
|
|
10505
|
+
async function cancelledRequiredCheck(snapshot, signal) {
|
|
10506
|
+
if (checksStillRunning(snapshot, Date.now(), waitPolicy)) return false;
|
|
10507
|
+
return (await requiredCheckEvaluation(snapshot, signal))?.checks.some((check) => check.cancelled) ?? false;
|
|
10508
|
+
}
|
|
10509
|
+
async function ownRepairFailed(snapshot, signal) {
|
|
10510
|
+
if (!snapshot.hostHeads?.some((entry) => entry.repair && entry.head === snapshot.pr?.head?.sha)) return false;
|
|
10511
|
+
const failures = failedSignals(snapshot);
|
|
10512
|
+
if (!failures.length) return false;
|
|
10513
|
+
const required = snapshot.pr?.base?.ref ? (await requiredCheckPolicy(snapshot)).required : [];
|
|
10514
|
+
const candidates = failures.filter((check) => actionLocation(snapshot.repository, check) || required.some((rule) => rule.context === check.name && (!check.app || rule.appId === null || check.app.id === rule.appId)));
|
|
10515
|
+
if (!candidates.length) return false;
|
|
10516
|
+
return !unrelatedFailureWait(await failureCauses(snapshot, signal, candidates, true), snapshot.pr?.base?.ref ?? "the base");
|
|
10517
|
+
}
|
|
10544
10518
|
async function hasRepairableActionsFailure(snapshot, signal) {
|
|
10545
10519
|
if (!failedOwnActions(snapshot, waitPolicy.pendingReviewChecks).length || await requiredCheckState(snapshot, signal) !== "failed") return false;
|
|
10546
10520
|
return !unrelatedFailureWait(await failureCauses(snapshot, signal), snapshot.pr?.base?.ref ?? "the base");
|
|
@@ -10738,6 +10712,7 @@ function createBabysitterRuntime(options) {
|
|
|
10738
10712
|
if ((await pullRequestInbox.metaNumber(recoveryKey) ?? 0) > Date.now()) continue;
|
|
10739
10713
|
signal.throwIfAborted();
|
|
10740
10714
|
await pullRequestInbox.setMeta(recoveryKey, Date.now() + 6e5, signal);
|
|
10715
|
+
if (await ownRepairFailed(snapshot, signal)) continue;
|
|
10741
10716
|
signal.throwIfAborted();
|
|
10742
10717
|
if (await pullRequestInbox.wake(snapshot, `ci-recovery:${head}`, {
|
|
10743
10718
|
recovery: true,
|
|
@@ -10779,7 +10754,7 @@ function createBabysitterRuntime(options) {
|
|
|
10779
10754
|
const held = new Set(Array.isArray(saved) ? saved.filter((item) => hasRuntimeType(item, "string")) : []);
|
|
10780
10755
|
return new Set(snapshot.threads.filter((thread) => thread.isResolved !== true).map((thread) => String(thread.node_id ?? thread.id)).filter((id) => held.has(id)));
|
|
10781
10756
|
}
|
|
10782
|
-
/**
|
|
10757
|
+
/** Retests deferred checks on a fixed base, or wakes a parked PR when its new events need work. */
|
|
10783
10758
|
async function evaluateWaits(step, signal) {
|
|
10784
10759
|
signal.throwIfAborted();
|
|
10785
10760
|
for (const snapshot of await pullRequestInbox.waitsToEvaluate(true, true)) {
|
|
@@ -10790,10 +10765,11 @@ function createBabysitterRuntime(options) {
|
|
|
10790
10765
|
const checkSignal = AbortSignal.any([signal, AbortSignal.timeout(12e4)]);
|
|
10791
10766
|
const checks = await requiredCheckState(snapshot, checkSignal);
|
|
10792
10767
|
signal.throwIfAborted();
|
|
10768
|
+
const repairOwnPush = snapshot.wait?.defer === "checks" && snapshot.wait.headSha === snapshot.pr?.head?.sha && await ownRepairFailed(snapshot, checkSignal);
|
|
10793
10769
|
let reasons = wakeReasons(snapshot, checks, {
|
|
10794
10770
|
...waitPolicy,
|
|
10795
10771
|
heldThreads: await heldOpenThreads(snapshot)
|
|
10796
|
-
});
|
|
10772
|
+
}, repairOwnPush);
|
|
10797
10773
|
signal.throwIfAborted();
|
|
10798
10774
|
if (parentMerged) reasons.push("stack-parent-merged");
|
|
10799
10775
|
if (snapshot.wait?.reason === "non-default-base" && snapshot.pr && !nonDefaultBase(snapshot.pr)) reasons.push("base-retargeted");
|
|
@@ -10821,11 +10797,13 @@ function createBabysitterRuntime(options) {
|
|
|
10821
10797
|
repository: snapshot.repository
|
|
10822
10798
|
};
|
|
10823
10799
|
if (!reasons.length) {
|
|
10800
|
+
const retested = merge.mode === "direct" && !repairOwnPush && snapshot.wait?.defer === "checks" && snapshot.pr?.state === "open" && snapshot.wait.headSha === snapshot.pr.head?.sha && snapshot.generation > snapshot.handled && await retestOnCurrentBase(snapshot, owner, checkSignal);
|
|
10824
10801
|
await pullRequestInbox.acknowledgeWait(snapshot, signal);
|
|
10825
10802
|
schedulerEvent("babysitter.wait.kept", {
|
|
10826
10803
|
...owner,
|
|
10827
10804
|
head_sha: snapshot.pr?.head?.sha,
|
|
10828
|
-
avoided_invocation: true
|
|
10805
|
+
avoided_invocation: true,
|
|
10806
|
+
...retested && { reason: "retest-on-current-base" }
|
|
10829
10807
|
});
|
|
10830
10808
|
} else if (await pullRequestInbox.wake(snapshot, `evaluated:${snapshot.generation}:${snapshot.revision ?? 0}`, { signal })) schedulerEvent("babysitter.wait.woken", {
|
|
10831
10809
|
...owner,
|
|
@@ -11268,6 +11246,7 @@ function createBabysitterRuntime(options) {
|
|
|
11268
11246
|
});
|
|
11269
11247
|
const passController = new AbortController();
|
|
11270
11248
|
let evidenceChanged;
|
|
11249
|
+
let evidenceChanges;
|
|
11271
11250
|
const passSignal = AbortSignal.any([AbortSignal.timeout(36e5), passController.signal]);
|
|
11272
11251
|
let providerDirectory;
|
|
11273
11252
|
let conflictWork;
|
|
@@ -11291,6 +11270,8 @@ function createBabysitterRuntime(options) {
|
|
|
11291
11270
|
let modelWorkParked = false;
|
|
11292
11271
|
let modelDispatched = false;
|
|
11293
11272
|
let providerLimited = false;
|
|
11273
|
+
let foldInto;
|
|
11274
|
+
const titleNeedsRepair = (title) => merge.mode === "direct" && merge.conventionalTitles === true && foldInto === void 0 && !isConventionalTitle(title);
|
|
11294
11275
|
const parkBlockedModelWork = async () => {
|
|
11295
11276
|
const currentAdmission = await options.admission?.();
|
|
11296
11277
|
const retryAt = currentAdmission && !currentAdmission.accepting ? currentAdmission.retryAt ?? Date.now() + 6e4 : modelRetryAt;
|
|
@@ -11301,7 +11282,7 @@ function createBabysitterRuntime(options) {
|
|
|
11301
11282
|
modelWorkParked = true;
|
|
11302
11283
|
outcome = "waiting";
|
|
11303
11284
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11304
|
-
text: providerBlocked ? `CI reconciliation completed; provider quota cooldown ends at ${new Date(providerBlockedUntil).toISOString()}.` : admitted ?
|
|
11285
|
+
text: providerBlocked ? `CI reconciliation completed; provider quota cooldown ends at ${new Date(providerBlockedUntil).toISOString()}.` : admitted ? `CI reconciliation completed; the same-head repair budget is exhausted.${mergeBlockers.has(inboxClaim) ? ` It does not merge yet: ${mergeBlockers.get(inboxClaim)}.` : ""}` : "CI reconciliation completed; model work is waiting for host admission.",
|
|
11305
11286
|
...pushedHead ? {
|
|
11306
11287
|
progress: pushProgress(pushedHead, reviewDrivenPush()),
|
|
11307
11288
|
verifiedPushHeads: [...verifiedPushHeads]
|
|
@@ -11369,6 +11350,7 @@ function createBabysitterRuntime(options) {
|
|
|
11369
11350
|
const parkSpentReviewPushBudget = async () => {
|
|
11370
11351
|
if (modelDispatched || pushedHead || reviewPushBudget === false || !reviewPushBudgetSpent(inboxClaim.snapshot, waitPolicy)) return false;
|
|
11371
11352
|
const work = reviewPushBudgetWork(inboxClaim.snapshot, waitPolicy, await assessedFeedback(inboxClaim.snapshot));
|
|
11353
|
+
if (titleNeedsRepair(inboxClaim.snapshot.pr?.title)) work.push("pull-request-title");
|
|
11372
11354
|
if (work.length) {
|
|
11373
11355
|
schedulerEvent("babysitter.review_push_budget.pass", {
|
|
11374
11356
|
...owner,
|
|
@@ -11435,13 +11417,15 @@ function createBabysitterRuntime(options) {
|
|
|
11435
11417
|
* Parks the claim before its first model dispatch when `dailyPassBudget` passes started in the
|
|
11436
11418
|
* last 24 hours, until the oldest leaves the window. Exempt work still gets a pass.
|
|
11437
11419
|
*/
|
|
11438
|
-
const parkSpentDailyPassBudget = async () => {
|
|
11420
|
+
const parkSpentDailyPassBudget = async (observed) => {
|
|
11439
11421
|
if (modelDispatched || pushedHead || dailyPassBudget === false) return false;
|
|
11422
|
+
dailyPassExemptionUsed = void 0;
|
|
11423
|
+
const snapshot = observed ?? inboxClaim.snapshot;
|
|
11440
11424
|
const now = Date.now();
|
|
11441
|
-
const budget = (await pullRequestInbox.get(repository, number))?.dailyPassBudget;
|
|
11425
|
+
const budget = observed ? observed.dailyPassBudget : (await pullRequestInbox.get(repository, number))?.dailyPassBudget;
|
|
11442
11426
|
const resumeAt = dailyPassResumeAt(budget, dailyPassBudget, now);
|
|
11443
11427
|
if (resumeAt === void 0) return false;
|
|
11444
|
-
if (pullRequestInbox.isPriority(
|
|
11428
|
+
if (pullRequestInbox.isPriority(snapshot.pr)) {
|
|
11445
11429
|
schedulerEvent("babysitter.daily_pass_budget.exempt", {
|
|
11446
11430
|
...owner,
|
|
11447
11431
|
head_sha: inboxClaim.snapshot.pr?.head?.sha,
|
|
@@ -11449,9 +11433,8 @@ function createBabysitterRuntime(options) {
|
|
|
11449
11433
|
});
|
|
11450
11434
|
return false;
|
|
11451
11435
|
}
|
|
11452
|
-
const requiredChecks = await requiredCheckState(
|
|
11453
|
-
const
|
|
11454
|
-
const exemption = dailyPassExemption(inboxClaim.snapshot, requiredChecks, budget, openPushWindow);
|
|
11436
|
+
const requiredChecks = await requiredCheckState(snapshot);
|
|
11437
|
+
const exemption = dailyPassExemption(snapshot, requiredChecks, budget, (requiredChecks === "failed" ? await repairPushWindow(snapshot, requiredChecks, false) : void 0)?.allowed ? Math.max(0, ...await repairPushTimes(snapshot)) : void 0);
|
|
11455
11438
|
if (exemption) {
|
|
11456
11439
|
dailyPassExemptionUsed = exemption;
|
|
11457
11440
|
schedulerEvent("babysitter.daily_pass_budget.exempt", {
|
|
@@ -11464,10 +11447,14 @@ function createBabysitterRuntime(options) {
|
|
|
11464
11447
|
modelWorkParked = true;
|
|
11465
11448
|
outcome = "waiting";
|
|
11466
11449
|
const passes = budget?.passes.filter((at) => at > now - 864e5).length ?? 0;
|
|
11467
|
-
await pullRequestInbox.finish(
|
|
11450
|
+
await pullRequestInbox.finish({
|
|
11451
|
+
...inboxClaim,
|
|
11452
|
+
snapshot,
|
|
11453
|
+
generation: snapshot.generation
|
|
11454
|
+
}, {
|
|
11468
11455
|
text: `Daily pass budget spent: ${passes} model pass${passes === 1 ? "" : "es"} in the last 24 hours (dailyPassBudget ${dailyPassBudget}). The next pass can start at ${new Date(resumeAt).toISOString()}. A person's comment or review, the first failing required check on a head, a head whose required checks pass, or a merge conflict still starts a pass.`,
|
|
11469
11456
|
wait: {
|
|
11470
|
-
...createCheckWait(
|
|
11457
|
+
...createCheckWait(snapshot, waitPolicy),
|
|
11471
11458
|
reason: "daily-pass-budget",
|
|
11472
11459
|
retryAt: resumeAt
|
|
11473
11460
|
}
|
|
@@ -11539,6 +11526,7 @@ function createBabysitterRuntime(options) {
|
|
|
11539
11526
|
}
|
|
11540
11527
|
const retargeted = await retargetMergedStackBase(inboxClaim, passSignal);
|
|
11541
11528
|
const stackParent = retargeted && "parent" in retargeted ? retargeted.parent : void 0;
|
|
11529
|
+
foldInto = foldStacks && retargeted && "ownsBase" in retargeted && retargeted.ownsBase ? retargeted.parent : void 0;
|
|
11542
11530
|
const parkOnStackParent = async (parent, text) => {
|
|
11543
11531
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11544
11532
|
text,
|
|
@@ -11553,7 +11541,7 @@ function createBabysitterRuntime(options) {
|
|
|
11553
11541
|
parent
|
|
11554
11542
|
});
|
|
11555
11543
|
};
|
|
11556
|
-
if (
|
|
11544
|
+
if (foldInto !== void 0 && await mergeReadyPullRequest(inboxClaim, owner, passSignal, foldInto) !== "not-ready") return;
|
|
11557
11545
|
if (stackParent !== void 0 && !repairStackChildren) {
|
|
11558
11546
|
await parkOnStackParent(stackParent, `Waiting for open parent PR #${stackParent} before repairing its child.`);
|
|
11559
11547
|
return;
|
|
@@ -11577,7 +11565,7 @@ function createBabysitterRuntime(options) {
|
|
|
11577
11565
|
reviewedRetryAt = window && !window.allowed ? window.nextAt + 6e4 : void 0;
|
|
11578
11566
|
pushWindowRetry = reviewedRetryAt !== void 0;
|
|
11579
11567
|
}
|
|
11580
|
-
if (reviewedRetryAt !== void 0 && isRuntimeRecord(assessment) && assessment.version === 2 && assessment.head === inboxClaim.snapshot.pr?.head?.sha && matchesMergeReviewEvidence(assessment.evidenceKey, inboxClaim.snapshot, waitPolicy) && inboxClaim.snapshot.threads.every((thread) => thread.isResolved === true || held.has(String(thread.node_id ?? thread.id))) && inboxClaim.snapshot.pr?.mergeable !== false && inboxClaim.snapshot.pr?.mergeable_state !== "dirty") {
|
|
11568
|
+
if (reviewedRetryAt !== void 0 && isRuntimeRecord(assessment) && !titleNeedsRepair(inboxClaim.snapshot.pr?.title) && assessment.version === 2 && assessment.head === inboxClaim.snapshot.pr?.head?.sha && matchesMergeReviewEvidence(assessment.evidenceKey, inboxClaim.snapshot, waitPolicy) && inboxClaim.snapshot.threads.every((thread) => thread.isResolved === true || held.has(String(thread.node_id ?? thread.id))) && inboxClaim.snapshot.pr?.mergeable !== false && inboxClaim.snapshot.pr?.mergeable_state !== "dirty") {
|
|
11581
11569
|
if (stackParent !== void 0) {
|
|
11582
11570
|
await parkOnStackParent(stackParent, `Waiting for open parent PR #${stackParent} to merge; this child has nothing left to repair.`);
|
|
11583
11571
|
return;
|
|
@@ -11630,7 +11618,8 @@ function createBabysitterRuntime(options) {
|
|
|
11630
11618
|
return;
|
|
11631
11619
|
}
|
|
11632
11620
|
}
|
|
11633
|
-
|
|
11621
|
+
const repairOwnPush = await ownRepairFailed(inboxClaim.snapshot, passSignal);
|
|
11622
|
+
if (merge.mode === "direct" && !repairOwnPush && await retestOnCurrentBase(inboxClaim.snapshot, owner, passSignal)) {
|
|
11634
11623
|
outcome = "waiting";
|
|
11635
11624
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11636
11625
|
text: inboxClaim.snapshot.lastResult || `Updated the branch with ${inboxClaim.snapshot.pr?.base?.ref} to retest its failed checks on the current base.`,
|
|
@@ -11644,7 +11633,21 @@ function createBabysitterRuntime(options) {
|
|
|
11644
11633
|
});
|
|
11645
11634
|
return;
|
|
11646
11635
|
}
|
|
11647
|
-
|
|
11636
|
+
if (merge.mode === "direct" && !repairOwnPush && await cancelledRequiredCheck(inboxClaim.snapshot, passSignal) && await retestInfrastructureFailure(inboxClaim.snapshot, owner, passSignal, "cancelled")) {
|
|
11637
|
+
outcome = "waiting";
|
|
11638
|
+
await pullRequestInbox.finish(inboxClaim, {
|
|
11639
|
+
text: `A required check was cancelled. Updated the branch with ${inboxClaim.snapshot.pr?.base?.ref} for a fresh CI run.`,
|
|
11640
|
+
wait: createCheckWait(inboxClaim.snapshot, waitPolicy)
|
|
11641
|
+
});
|
|
11642
|
+
schedulerEvent("babysitter.wait.kept", {
|
|
11643
|
+
...owner,
|
|
11644
|
+
head_sha: inboxClaim.snapshot.pr?.head?.sha,
|
|
11645
|
+
avoided_invocation: true,
|
|
11646
|
+
reason: "cancelled-check-retest"
|
|
11647
|
+
});
|
|
11648
|
+
return;
|
|
11649
|
+
}
|
|
11650
|
+
const deferral = repairOwnPush ? void 0 : await pendingGateDeferral(inboxClaim.snapshot);
|
|
11648
11651
|
if (deferral) {
|
|
11649
11652
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11650
11653
|
text: inboxClaim.snapshot.lastResult || `Waiting for ${deferral} before the next pass.`,
|
|
@@ -11690,7 +11693,7 @@ function createBabysitterRuntime(options) {
|
|
|
11690
11693
|
await pullRequestInbox.release(inboxClaim);
|
|
11691
11694
|
return;
|
|
11692
11695
|
}
|
|
11693
|
-
const ciRecovery = ciRecoveryEnabled ? await rerunFailedActions(pullRequestInbox, inboxClaim, (await forge(repository, passSignal)).provider, Date.now(), passSignal) : void 0;
|
|
11696
|
+
const ciRecovery = ciRecoveryEnabled && !repairOwnPush ? await rerunFailedActions(pullRequestInbox, inboxClaim, (await forge(repository, passSignal)).provider, Date.now(), passSignal) : void 0;
|
|
11694
11697
|
if (inboxClaim.snapshot.recoveryHead && inboxClaim.snapshot.recoveryHead === inboxClaim.snapshot.pr?.head?.sha && !hasFailedActions(inboxClaim.snapshot)) {
|
|
11695
11698
|
outcome = "waiting";
|
|
11696
11699
|
const wait = createCheckWait(inboxClaim.snapshot, waitPolicy);
|
|
@@ -11848,6 +11851,13 @@ function createBabysitterRuntime(options) {
|
|
|
11848
11851
|
const abortSignal = AbortSignal.any([prepared.signal, passSignal]);
|
|
11849
11852
|
const repairOperation = new AsyncLocalStorage();
|
|
11850
11853
|
const ownedResolutions = /* @__PURE__ */ new Map();
|
|
11854
|
+
const metadataFields = ["title", "body"];
|
|
11855
|
+
const metadataWrites = /* @__PURE__ */ new Map();
|
|
11856
|
+
const ownsMetadata = (snapshot, field) => {
|
|
11857
|
+
const write = metadataWrites.get(field);
|
|
11858
|
+
const edit = snapshot.metadataEdits?.[field];
|
|
11859
|
+
return write && edit && edit.generation > write.after && edit.generation !== edit.externalGeneration && snapshot.pr?.[field] === write.value;
|
|
11860
|
+
};
|
|
11851
11861
|
const repairEvidenceKey = (snapshot, current = snapshot) => {
|
|
11852
11862
|
const published = !!pushedHead && verifiedPushHeads.has(pushedHead);
|
|
11853
11863
|
const original = published && snapshot === inboxClaim.snapshot;
|
|
@@ -11877,6 +11887,8 @@ function createBabysitterRuntime(options) {
|
|
|
11877
11887
|
} : thread),
|
|
11878
11888
|
pr: snapshot.pr && {
|
|
11879
11889
|
...snapshot.pr,
|
|
11890
|
+
title: ownsMetadata(snapshot, "title") ? inboxClaim.snapshot.pr?.title : snapshot.pr.title,
|
|
11891
|
+
body: ownsMetadata(snapshot, "body") ? inboxClaim.snapshot.pr?.body : snapshot.pr.body,
|
|
11880
11892
|
head: snapshot.pr.head && {
|
|
11881
11893
|
...snapshot.pr.head,
|
|
11882
11894
|
sha: published ? pullRequest.headRefOid : snapshot.pr.head.sha
|
|
@@ -11910,12 +11922,18 @@ function createBabysitterRuntime(options) {
|
|
|
11910
11922
|
pendingInboxHeads.add(pushedHead);
|
|
11911
11923
|
}
|
|
11912
11924
|
const selfHead = observedHead !== pullRequest.headRefOid && verifiedPushHeads.has(observedHead ?? "");
|
|
11913
|
-
|
|
11925
|
+
const sameHead = observedHead === pullRequest.headRefOid;
|
|
11926
|
+
const externalMetadata = metadataFields.some((field) => (current.metadataEdits?.[field]?.externalGeneration ?? 0) > inboxClaim.generation);
|
|
11927
|
+
if (current.generation !== inboxClaim.generation && (externalMetadata || !((selfHead || sameHead || repairOperation.getStore()) && repairEvidenceKey(current) === repairEvidenceKey(inboxClaim.snapshot, current)))) {
|
|
11914
11928
|
const changed = evidenceChanged ??= new DOMException("Pull request evidence changed.", "AbortError");
|
|
11929
|
+
evidenceChanges ??= changedEvidence(inboxClaim.snapshot, current);
|
|
11915
11930
|
schedulerEvent("babysitter.pass.evidence_changed", {
|
|
11916
11931
|
...owner,
|
|
11917
11932
|
head_sha: pullRequest.headRefOid,
|
|
11918
|
-
observed_head: observedHead
|
|
11933
|
+
observed_head: observedHead,
|
|
11934
|
+
claim_generation: inboxClaim.generation,
|
|
11935
|
+
generation: current.generation,
|
|
11936
|
+
changes: evidenceChanges
|
|
11919
11937
|
});
|
|
11920
11938
|
setTimeout(() => passController.abort(changed), 0);
|
|
11921
11939
|
throw changed;
|
|
@@ -12030,6 +12048,34 @@ function createBabysitterRuntime(options) {
|
|
|
12030
12048
|
mentionAllowlist: presetOptions.mentionAllowlist,
|
|
12031
12049
|
restrictCommentMentions: true,
|
|
12032
12050
|
commentPrefix: "<!-- vitehub-babysitter-repair:repair -->\n",
|
|
12051
|
+
sendMetadata: async (update, send) => {
|
|
12052
|
+
const current = await assertLease();
|
|
12053
|
+
const previous = new Map(metadataWrites);
|
|
12054
|
+
const writes = metadataFields.flatMap((field) => {
|
|
12055
|
+
const value = update[field];
|
|
12056
|
+
if (value === void 0 || value === current.pr?.[field]) return [];
|
|
12057
|
+
const write = {
|
|
12058
|
+
value,
|
|
12059
|
+
after: current.generation
|
|
12060
|
+
};
|
|
12061
|
+
metadataWrites.set(field, write);
|
|
12062
|
+
return [{
|
|
12063
|
+
field,
|
|
12064
|
+
write
|
|
12065
|
+
}];
|
|
12066
|
+
});
|
|
12067
|
+
try {
|
|
12068
|
+
await send();
|
|
12069
|
+
} catch (error) {
|
|
12070
|
+
for (const { field, write } of writes) {
|
|
12071
|
+
if (metadataWrites.get(field) !== write) continue;
|
|
12072
|
+
const prior = previous.get(field);
|
|
12073
|
+
if (prior) metadataWrites.set(field, prior);
|
|
12074
|
+
else metadataWrites.delete(field);
|
|
12075
|
+
}
|
|
12076
|
+
throw error;
|
|
12077
|
+
}
|
|
12078
|
+
},
|
|
12033
12079
|
signal: abortSignal,
|
|
12034
12080
|
autoMerge: merge.mode === "auto" && stackParent === void 0,
|
|
12035
12081
|
eligible: async (current) => await eligibleNow(repository, normalizePullRequest(current), await pullRequestInbox.get(repository, number), abortSignal),
|
|
@@ -12427,7 +12473,7 @@ function createBabysitterRuntime(options) {
|
|
|
12427
12473
|
const convergenceContext = reviewConvergencePushes !== false && !settled && reviewPushes >= reviewConvergencePushes ? `\n\n<review-convergence>\nThis PR already has ${reviewPushes} review-driven repair pushes. Before you fix a finding, check whether it is another case of a class that an earlier push or thread already addressed. If it is, do not patch the new case: change the approach so that the whole class cannot occur (for example, narrow the contract or report an unknown value as unknown), in this one push, and say so in the thread replies. If no such change fits this PR's scope, decline the remaining P2 cases of that class with outcome declined.\n</review-convergence>` : "";
|
|
12428
12474
|
const conflictContext = preparedConflicts?.resolved.length ? `\n\n<host-resolved-conflicts>\nThe host resolved and staged these merge conflicts mechanically. Review them instead of redoing them:\n${preparedConflicts.resolved.slice(0, 50).map(({ path, rule }) => `- ${path} (${rule})`).join("\n")}\n${preparedConflicts.remaining.length ? `Still conflicted: ${preparedConflicts.remaining.slice(0, 50).join(", ")}.` : "No conflicted file remains; review the merge, validate it and pass these paths to commitRepair."}\n</host-resolved-conflicts>` : "";
|
|
12429
12475
|
const inheritedIds = await inheritedBaseFailures(inboxClaim.snapshot, passSignal);
|
|
12430
|
-
const userMessage = `${prompt}${mainRepairContext}${resumeContext}\n\n${snapshotContext}${installContext}${conflictContext}${pushContext}${severityContext}${convergenceContext}${inheritedIds.length ? `\n\n<live-base-attribution>\nThe host verified matching CI failures on the live base tip for these current-head check IDs: ${inheritedIds.join(", ")}.\n</live-base-attribution>` : ""}`;
|
|
12476
|
+
const userMessage = `${prompt}${mainRepairContext}${resumeContext}\n\n${snapshotContext}${installContext}${conflictContext}${pushContext}${severityContext}${convergenceContext}${inheritedIds.length ? `\n\n<live-base-attribution>\nThe host verified matching CI failures on the live base tip for these current-head check IDs: ${inheritedIds.join(", ")}.\n</live-base-attribution>` : ""}${titleNeedsRepair(pullRequest.title) ? `\n\n<pull-request-title>\nThis PR merges only when its title is a conventional commit: \`type(scope): summary\` with build, chore, ci, docs, feat, fix, perf, refactor, revert, style or test, lowercase after the colon, and \`!\` before the colon for a breaking change. The current title is not one. Rename it with updatePullRequest before you set reviewedHead. Take the type and scope from the diff and keep the meaning of the summary.\n</pull-request-title>` : ""}`;
|
|
12431
12477
|
assertPromptFits(userMessage);
|
|
12432
12478
|
schedulerEvent("babysitter.context.prepared", {
|
|
12433
12479
|
repository,
|
|
@@ -12448,14 +12494,18 @@ function createBabysitterRuntime(options) {
|
|
|
12448
12494
|
if (workerSettings.sandbox && await parkBlockedModelWork()) throw new DOMException("Provider dispatch is waiting for admission.", "AbortError");
|
|
12449
12495
|
await acquireModelSlot(abortSignal, `${repository}#${number}`);
|
|
12450
12496
|
try {
|
|
12451
|
-
|
|
12497
|
+
while (!modelDispatched && dailyPassBudget !== false) {
|
|
12498
|
+
const observed = await assertLease();
|
|
12499
|
+
if (await parkSpentDailyPassBudget(observed)) throw new DOMException("Provider dispatch is waiting for its daily pass budget.", "AbortError");
|
|
12452
12500
|
const exemption = dailyPassExemptionUsed === "human-feedback" ? void 0 : dailyPassExemptionUsed;
|
|
12453
|
-
const recorded = await pullRequestInbox.recordModelPass(inboxClaim, exemption);
|
|
12454
|
-
if (
|
|
12501
|
+
const recorded = await pullRequestInbox.recordModelPass(inboxClaim, exemption, observed);
|
|
12502
|
+
if (recorded === "changed") continue;
|
|
12503
|
+
if (!recorded) throw new DOMException("Provider dispatch lost its inbox lease.", "AbortError");
|
|
12455
12504
|
recordedPass = {
|
|
12456
12505
|
at: recorded,
|
|
12457
12506
|
exemption
|
|
12458
12507
|
};
|
|
12508
|
+
break;
|
|
12459
12509
|
}
|
|
12460
12510
|
await assertLease();
|
|
12461
12511
|
modelDispatched = true;
|
|
@@ -12542,7 +12592,10 @@ function createBabysitterRuntime(options) {
|
|
|
12542
12592
|
recorded = await pullRequestInbox.finish(inboxClaim, {
|
|
12543
12593
|
text: resultText,
|
|
12544
12594
|
progress: { kind: "no-progress" },
|
|
12545
|
-
wait:
|
|
12595
|
+
wait: {
|
|
12596
|
+
...await externalWait(inboxClaim.snapshot, passResult.wait.wake, passResult.wait.reason),
|
|
12597
|
+
headSha: pullRequest.headRefOid
|
|
12598
|
+
}
|
|
12546
12599
|
});
|
|
12547
12600
|
} else if (disposition === "park" && current?.pr?.head?.sha === pullRequest.headRefOid && (hasPendingChecks(inboxClaim.snapshot, waitPolicy) || !rejectedAssessment && (passResult?.wait?.kind === "checks" && passResult.wait.headSha === pullRequest.headRefOid || passResult?.waitForChecksHead === pullRequest.headRefOid))) {
|
|
12548
12601
|
outcome = "waiting";
|
|
@@ -12641,6 +12694,8 @@ function createBabysitterRuntime(options) {
|
|
|
12641
12694
|
});
|
|
12642
12695
|
schedulerEvent("babysitter.owner.cancelled", {
|
|
12643
12696
|
reason: "pull-request-state-changed-or-aborted",
|
|
12697
|
+
cause: (error instanceof Error ? error.message : String(error)).slice(0, 200),
|
|
12698
|
+
...evidenceChanges ? { evidence_changes: evidenceChanges } : {},
|
|
12644
12699
|
...owner
|
|
12645
12700
|
});
|
|
12646
12701
|
} else if (error instanceof RateLimitedError) {
|
|
@@ -12764,12 +12819,8 @@ function fixedOrSource(repositories) {
|
|
|
12764
12819
|
function assertBabysitterAgent(agent) {
|
|
12765
12820
|
if (!agentSettings(agent) || !("options" in agent) || !agent.options || !hasRuntimeType(agent.options, "object") || !("merge" in agent.options) || !("filter" in agent.options) || !agent.options.filter || !hasRuntimeType(agent.options.filter, "object") || Array.isArray(agent.options.filter)) throw presetsErrorDiagnostics.PRESETS_BABYSITTER_AGENT_INVALID();
|
|
12766
12821
|
}
|
|
12767
|
-
/**
|
|
12768
|
-
* A placed Sandbox pass runs on another host and holds none of this host's memory, so it skips the
|
|
12769
|
-
* worker queue that admits passes by local memory. `placement.remoteActive()` counts it toward concurrency.
|
|
12770
|
-
*/
|
|
12771
12822
|
function withoutCapacity(driver) {
|
|
12772
12823
|
const { capacity: _capacity, ...rest } = driver;
|
|
12773
12824
|
return rest;
|
|
12774
12825
|
}
|
|
12775
|
-
export { budgetParks as a, createGitHubHost as c,
|
|
12826
|
+
export { budgetParks as a, createGitHubHost as c, isProviderRateLimit as i, pendingMergeRetryAt as n, pullRequestThreadId as o, babysitterQueueHealth as r, createGitHubAppCredentials as s, createBabysitterRuntime as t };
|