@vite-hub/presets 0.7.0 → 0.8.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-C92vTLpo.js} +12 -5
- package/dist/babysitter.d.ts +1 -1
- package/dist/babysitter.js +1 -1
- package/dist/{host-1nLqi8HQ.js → host-Dq3z2dW8.js} +3 -3
- package/dist/{pr-workspaces-DfBICt8N.d.ts → pr-workspaces-CbTDCpFn.d.ts} +7 -0
- package/dist/{server-CWLmnhPQ.js → server-CnBPeA2q.js} +271 -130
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createGitHubAppCredentials, S as GitHubHostSecret, _ as GitHubHostCredentials, a as BabysitterAdmissionResult, b as GitHubHostPullRequest, c as PullRequestInboxStorage, d as GitHubHost, f as GitHubHostAccess, g as GitHubHostCredentialContext, h as GitHubHostCheckoutOptions, m as GitHubHostCheckout, n as PullRequestWorkspaces, o as PullRequestInbox, p as GitHubHostAccessOptions, u as GitHubAppEnvironment, v as GitHubHostForgeOptions, w as createGitHubHost, x as GitHubHostRateLimit, y as GitHubHostOptions } from "../pr-workspaces-
|
|
1
|
+
import { C as createGitHubAppCredentials, S as GitHubHostSecret, _ as GitHubHostCredentials, a as BabysitterAdmissionResult, b as GitHubHostPullRequest, c as PullRequestInboxStorage, d as GitHubHost, f as GitHubHostAccess, g as GitHubHostCredentialContext, h as GitHubHostCheckoutOptions, m as GitHubHostCheckout, n as PullRequestWorkspaces, o as PullRequestInbox, p as GitHubHostAccessOptions, u as GitHubAppEnvironment, v as GitHubHostForgeOptions, w as createGitHubHost, x as GitHubHostRateLimit, y as GitHubHostOptions } from "../pr-workspaces-CbTDCpFn.js";
|
|
2
2
|
import { AgentInput } from "@vite-hub/agent";
|
|
3
3
|
import { GitHubAppRepository } from "@vite-hub/forge";
|
|
4
4
|
import { ProcessReconcilerRunContext } from "@vite-hub/runtime/internal/node";
|
|
@@ -17,6 +17,7 @@ interface BabysitterRepositories {
|
|
|
17
17
|
*/
|
|
18
18
|
observe(event: string, payload: unknown): boolean;
|
|
19
19
|
}
|
|
20
|
+
export declare function isProviderRateLimit(error: unknown): boolean;
|
|
20
21
|
export interface BabysitterRuntimeOptions {
|
|
21
22
|
agent: AgentInput;
|
|
22
23
|
/** Discovered Agent name for per-Agent public URLs. Defaults to the definition name. */
|
|
@@ -79,8 +80,6 @@ export interface BabysitterRuntimeOptions {
|
|
|
79
80
|
* A fixed 30-second poll can run for hours on a request that GitHub never settles.
|
|
80
81
|
*/
|
|
81
82
|
export declare function pendingMergeRetryAt(startedAt: number, now: number): number;
|
|
82
|
-
/** Provider quota and rate-limit failures. Cancellation is never a rate limit. */
|
|
83
|
-
export declare function isProviderRateLimit(error: unknown): boolean;
|
|
84
83
|
/**
|
|
85
84
|
* Whether the reconcile loop still makes progress, for the health route. `stalled`: the last reconcile
|
|
86
85
|
* waited longer than `stallMs` and was stopped. `silent`: no reconcile finished for `stallMs` plus one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createBabysitterRuntime, s as createGitHubAppCredentials, c as createGitHubHost,
|
|
1
|
+
export { t as createBabysitterRuntime, s as createGitHubAppCredentials, c as createGitHubHost, i as isProviderRateLimit, n as pendingMergeRetryAt } from "../server-CnBPeA2q.js";
|
|
@@ -1244,7 +1244,11 @@ function createGitHubPullRequestOperations(github, options) {
|
|
|
1244
1244
|
if ((await snapshot()).pullRequest.body !== current.pullRequest.body) throw presetsErrorDiagnostics.PRESETS_PULL_REQUEST_BODY_CHANGED();
|
|
1245
1245
|
}
|
|
1246
1246
|
const { provider, pullRequest } = await forge();
|
|
1247
|
-
|
|
1247
|
+
const send = async () => {
|
|
1248
|
+
await provider.threads.update(pullRequest, update, { signal });
|
|
1249
|
+
};
|
|
1250
|
+
if (options.sendMetadata) await options.sendMetadata(update, send);
|
|
1251
|
+
else await send();
|
|
1248
1252
|
},
|
|
1249
1253
|
async checkDependencies() {
|
|
1250
1254
|
return await options.checkDependencies?.() ?? {
|
|
@@ -1411,6 +1415,9 @@ function mergeTarget(snapshot, legacy = false) {
|
|
|
1411
1415
|
}
|
|
1412
1416
|
/** Assessment is bound to full feedback bodies and failed check evidence, never prose heuristics. */
|
|
1413
1417
|
function mergeReviewEvidenceKey(snapshot, policy = {}, legacy = false) {
|
|
1418
|
+
return reviewEvidenceKey(snapshot, policy, legacy, true);
|
|
1419
|
+
}
|
|
1420
|
+
function reviewEvidenceKey(snapshot, policy, legacy, includeThreadAuthors) {
|
|
1414
1421
|
const head = snapshot.pr?.head?.sha;
|
|
1415
1422
|
const failures = [...Object.values(snapshot.checks), ...Object.values(snapshot.statuses)].filter((value) => !value.deleted && (value.head_sha ?? value.sha) === head && !isBabysitterCheckRun(value) && failing.has(String(value.conclusion ?? value.state).toLowerCase())).map((value) => ({
|
|
1416
1423
|
id: value.id ?? value.context,
|
|
@@ -1427,7 +1434,7 @@ function mergeReviewEvidenceKey(snapshot, policy = {}, legacy = false) {
|
|
|
1427
1434
|
comments: (Array.isArray(thread.comments) ? thread.comments : thread.comments?.nodes ?? []).filter((comment) => !comment.deleted).map((comment) => ({
|
|
1428
1435
|
id: comment.node_id ?? comment.id,
|
|
1429
1436
|
body: comment.body,
|
|
1430
|
-
user: comment.user ?? comment.author,
|
|
1437
|
+
user: includeThreadAuthors ? comment.user ?? comment.author : void 0,
|
|
1431
1438
|
commit: comment.commit_id ?? comment.commit?.oid
|
|
1432
1439
|
}))
|
|
1433
1440
|
})).sort((left, right) => String(left.id).localeCompare(String(right.id)));
|
|
@@ -1446,9 +1453,9 @@ function mergeReviewEvidenceKey(snapshot, policy = {}, legacy = false) {
|
|
|
1446
1453
|
failures
|
|
1447
1454
|
})).digest("hex");
|
|
1448
1455
|
}
|
|
1449
|
-
/** Whether a stored evidence key covers this snapshot, including
|
|
1456
|
+
/** Whether a stored evidence key covers this snapshot, including keys with the base commit or without thread authors. */
|
|
1450
1457
|
function matchesMergeReviewEvidence(key, snapshot, policy = {}) {
|
|
1451
|
-
return hasRuntimeType(key, "string") && (key === mergeReviewEvidenceKey(snapshot, policy) || key === mergeReviewEvidenceKey(snapshot, policy, true));
|
|
1458
|
+
return hasRuntimeType(key, "string") && (key === mergeReviewEvidenceKey(snapshot, policy) || key === mergeReviewEvidenceKey(snapshot, policy, true) || key === reviewEvidenceKey(snapshot, policy, false, false) || key === reviewEvidenceKey(snapshot, policy, true, false));
|
|
1452
1459
|
}
|
|
1453
1460
|
/**
|
|
1454
1461
|
* Identities of the feedback items that need an assessment. An explicit assessment covers
|
|
@@ -2309,7 +2316,7 @@ function validMainRepair(mainRepair) {
|
|
|
2309
2316
|
return names(workflows, /\S/) && (repositories === void 0 || names(repositories, /^[\w.-]+\/[\w.-]+$/)) && (stuckJobMinutes === void 0 || stuckJobMinutes === false || Number.isSafeInteger(stuckJobMinutes) && Number(stuckJobMinutes) >= 1);
|
|
2310
2317
|
}
|
|
2311
2318
|
const babysitterHost = { async create(context) {
|
|
2312
|
-
const { createBabysitterProcessHost } = await import("./host-
|
|
2319
|
+
const { createBabysitterProcessHost } = await import("./host-Dq3z2dW8.js");
|
|
2313
2320
|
return await createBabysitterProcessHost(context);
|
|
2314
2321
|
} };
|
|
2315
2322
|
function plainSecret(value) {
|
package/dist/babysitter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as AutomatedReviewClass, i as BabysitterAdmissionPause, l as GitHubRequiredCheckState, r as BabysitterAdmissionOptions, s as Snapshot, t as BabysitterWarmWorkspaces } from "./pr-workspaces-
|
|
1
|
+
import { T as AutomatedReviewClass, i as BabysitterAdmissionPause, l as GitHubRequiredCheckState, r as BabysitterAdmissionOptions, s as Snapshot, t as BabysitterWarmWorkspaces } from "./pr-workspaces-CbTDCpFn.js";
|
|
2
2
|
import { AgentDefinition, AgentInvocationContextValues, AgentInvoker, AgentRuntimeConfig, AgentSandboxDefinition, BuiltInAgentDriverName, ConfiguredAgentDefinition } from "@vite-hub/agent";
|
|
3
3
|
import { GitHubPullRequestFilter } from "@vite-hub/agent/channels";
|
|
4
4
|
import { Diagnostic } from "nostics";
|
package/dist/babysitter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { i as BabysitterPlacementCapacityError, t as babysitter, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter } from "./babysitter-
|
|
1
|
+
export { i as BabysitterPlacementCapacityError, t as babysitter, n as babysitterPassResultSchema, r as resolveBabysitterLifecycleFilter } from "./babysitter-C92vTLpo.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as isRuntimeRecord, n as hasRuntimeType, t as presetsErrorDiagnostics } from "./error-diagnostics-ba9TWgh5.js";
|
|
2
|
-
import { a as budgetParks, c as createGitHubHost,
|
|
3
|
-
import { d as resolveBabysitterAdmissionLimits, f as sharedBabysitterRead, o as createPullRequestWorkspaces, r as resolveBabysitterLifecycleFilter, u as createBabysitterAdmission } from "./babysitter-
|
|
2
|
+
import { a as budgetParks, c as createGitHubHost, o as pullRequestThreadId, r as babysitterQueueHealth, s as createGitHubAppCredentials, t as createBabysitterRuntime } from "./server-CnBPeA2q.js";
|
|
3
|
+
import { d as resolveBabysitterAdmissionLimits, f as sharedBabysitterRead, o as createPullRequestWorkspaces, r as resolveBabysitterLifecycleFilter, u as createBabysitterAdmission } from "./babysitter-C92vTLpo.js";
|
|
4
4
|
import { defineAgent } from "@vite-hub/agent";
|
|
5
5
|
import { forgeErrorStatus, githubInstallationRouting } from "@vite-hub/forge";
|
|
6
6
|
import { channelEnv } from "@vite-hub/agent/channels";
|
|
@@ -508,7 +508,7 @@ async function createBabysitterProcessHost(context) {
|
|
|
508
508
|
run: async (reason, run, accepting) => await runtime?.reconcile(reason, run, accepting)
|
|
509
509
|
});
|
|
510
510
|
const preflight = createBabysitterPreflight(agent.options.install ?? true);
|
|
511
|
-
const buildRevision = "
|
|
511
|
+
const buildRevision = "7fd99b60ad33356545ce233e0675580c666313fbf3f50e93db479920a1ba9fad";
|
|
512
512
|
const admission = createBabysitterAdmission({
|
|
513
513
|
invocations: host.invocations,
|
|
514
514
|
limits: resolveBabysitterAdmissionLimits(agent.options.admission),
|
|
@@ -471,6 +471,8 @@ interface StatusDelivery {
|
|
|
471
471
|
interface HostHead {
|
|
472
472
|
head: string;
|
|
473
473
|
parent: string;
|
|
474
|
+
/** A pass pushed this head. A base update that the host asked GitHub for has no flag. */
|
|
475
|
+
repair?: true;
|
|
474
476
|
}
|
|
475
477
|
type Snapshot = {
|
|
476
478
|
repository: string;
|
|
@@ -493,6 +495,10 @@ type Snapshot = {
|
|
|
493
495
|
dailyPassBudget?: DailyPassBudget;
|
|
494
496
|
/** Generation of the last human comment or review. A wait rejected before it stays free. */
|
|
495
497
|
humanFeedbackGeneration?: number;
|
|
498
|
+
metadataEdits?: Partial<Record<"title" | "body", {
|
|
499
|
+
generation: number;
|
|
500
|
+
externalGeneration: number;
|
|
501
|
+
}>>;
|
|
496
502
|
recoveryHead?: string;
|
|
497
503
|
sourcePushHead?: string;
|
|
498
504
|
sourcePushHeads?: string[];
|
|
@@ -783,6 +789,7 @@ declare class PullRequestInbox {
|
|
|
783
789
|
* `budgets.dailyPasses`. It changes no evidence, so the claim stays current.
|
|
784
790
|
*/
|
|
785
791
|
recordModelPass(claim: Claim, exemption?: string): Promise<number | false>;
|
|
792
|
+
recordModelPass(claim: Claim, exemption?: string, observed?: Pick<Snapshot, "generation" | "revision">): Promise<number | false | "changed">;
|
|
786
793
|
/**
|
|
787
794
|
* Gives back the pass that `recordModelPass` counted at `at`, and its exemption, when the provider
|
|
788
795
|
* failed the pass before it did any work. It changes no evidence, so the claim stays current.
|
|
@@ -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 invariant, B as createBabysitterPassResultSchema, C as approvalReviewers, D as normalizeGitHubMentionAllowlist, E as isReviewThreadOutcome, F as failed$1, I as hydrateFailedCiEvidence, L as newestCheckRun, M as hasGitHubLogin, N as matchesBabysitterPullRequestFilter, O as reviewThreadOutcomes, P as actionLocation, R as createBabysitterCheckRuns, S as snapshotCheckEvidence, T as createGitHubPullRequestOperations, _ as isAutomatedFeedback, a as isBabysitterPlacementCapacityError, b as mergeReviewEvidenceKey, c as workspaceDecision, g as headChecksUnreported, h as hasHumanComment, j as invariantError, k as reviewerLabeledSevere, l as babysitterModelAdmission, m as feedbackFingerprints, p as directMergeReadiness, r as resolveBabysitterLifecycleFilter, s as providerSessionDecision, v as liveMergeReadiness, w as maintainerApproval, x as resolveBabysitterMerge, y as matchesMergeReviewEvidence, z as isBabysitterCheckRun } from "./babysitter-
|
|
2
|
+
import { A as invariant, B as createBabysitterPassResultSchema, C as approvalReviewers, D as normalizeGitHubMentionAllowlist, E as isReviewThreadOutcome, F as failed$1, I as hydrateFailedCiEvidence, L as newestCheckRun, M as hasGitHubLogin, N as matchesBabysitterPullRequestFilter, O as reviewThreadOutcomes, P as actionLocation, R as createBabysitterCheckRuns, S as snapshotCheckEvidence, T as createGitHubPullRequestOperations, _ as isAutomatedFeedback, a as isBabysitterPlacementCapacityError, b as mergeReviewEvidenceKey, c as workspaceDecision, g as headChecksUnreported, h as hasHumanComment, j as invariantError, k as reviewerLabeledSevere, l as babysitterModelAdmission, m as feedbackFingerprints, p as directMergeReadiness, r as resolveBabysitterLifecycleFilter, s as providerSessionDecision, v as liveMergeReadiness, w as maintainerApproval, x as resolveBabysitterMerge, y as matchesMergeReviewEvidence, z as isBabysitterCheckRun } from "./babysitter-C92vTLpo.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";
|
|
@@ -1027,13 +1027,21 @@ async function publishGitHubInstallSnapshot(snapshot, signal) {
|
|
|
1027
1027
|
});
|
|
1028
1028
|
}
|
|
1029
1029
|
}
|
|
1030
|
+
// ../internal/src/object.ts
|
|
1031
|
+
/** A non-null object that is not an array. Functions do not pass. */
|
|
1032
|
+
function isRecord(value) {
|
|
1033
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1034
|
+
}
|
|
1035
|
+
/** A non-null object. Arrays pass. Functions do not. */
|
|
1036
|
+
function isObject(value) {
|
|
1037
|
+
return typeof value === "object" && value !== null;
|
|
1038
|
+
}
|
|
1030
1039
|
// src/github/install.ts
|
|
1031
1040
|
const exec$4 = promisify(execFile);
|
|
1032
1041
|
const manifest = v.object({ packageManager: v.optional(v.string()) });
|
|
1033
1042
|
const systemError = v.object({ errno: v.pipe(v.number(), v.integer(), v.maxValue(-1)) });
|
|
1034
1043
|
const exists$1 = async (path) => await access(path).then(() => true, () => false);
|
|
1035
1044
|
const isSystemError = (error) => v.safeParse(systemError, error).success;
|
|
1036
|
-
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
1037
1045
|
function githubWorkspaceInstallError(cause, retryable = true, kind = "command") {
|
|
1038
1046
|
return Object.assign(presetsErrorDiagnostics.PRESETS_GITHUB_INSTALL_FAILED({
|
|
1039
1047
|
cause,
|
|
@@ -1057,9 +1065,9 @@ function isGitHubLockfileDefect(error) {
|
|
|
1057
1065
|
const collect = (value) => {
|
|
1058
1066
|
if (value === null || value === void 0 || seen.has(value)) return;
|
|
1059
1067
|
if (typeof value === "object" || typeof value === "function") seen.add(value);
|
|
1060
|
-
parts.push(value instanceof Error ? value.message :
|
|
1068
|
+
parts.push(value instanceof Error ? value.message : isObject(value) && typeof value.message === "string" ? value.message : String(value));
|
|
1061
1069
|
if (value instanceof Error) collect(value.cause);
|
|
1062
|
-
if (
|
|
1070
|
+
if (isObject(value)) {
|
|
1063
1071
|
collect(value.cause);
|
|
1064
1072
|
collect(value.stderr);
|
|
1065
1073
|
}
|
|
@@ -1435,12 +1443,12 @@ async function readGitHubDependencyStatus(target) {
|
|
|
1435
1443
|
};
|
|
1436
1444
|
}
|
|
1437
1445
|
const record = await readFile(join(target, ".git", "vitehub-install.json"), "utf8").then(JSON.parse, () => ({}));
|
|
1438
|
-
const installed =
|
|
1446
|
+
const installed = isObject(record) ? record : {};
|
|
1439
1447
|
if (installed.status === "installed" && installed.fingerprint === fingerprint) return {
|
|
1440
1448
|
current: true,
|
|
1441
1449
|
changedInputs: []
|
|
1442
1450
|
};
|
|
1443
|
-
const previous =
|
|
1451
|
+
const previous = isObject(installed.inputs) ? installed.inputs : {};
|
|
1444
1452
|
const changedInputs = [.../* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(inputs)])].filter((path) => previous[path] !== inputs[path]).sort();
|
|
1445
1453
|
return {
|
|
1446
1454
|
current: false,
|
|
@@ -1724,7 +1732,7 @@ function mergePackageJson(base, ours, theirs) {
|
|
|
1724
1732
|
}
|
|
1725
1733
|
});
|
|
1726
1734
|
const styles = texts.map(jsonStyle);
|
|
1727
|
-
if (parsed.some((value, index) => !
|
|
1735
|
+
if (parsed.some((value, index) => !isRecord(value) || !styles[index] || serialize(value, styles[index]) !== texts[index])) return void 0;
|
|
1728
1736
|
const merged = mergeValue(parsed[0], parsed[1], parsed[2], false);
|
|
1729
1737
|
if (merged === conflict || merged === absent) return void 0;
|
|
1730
1738
|
return serialize(merged, styles[1]);
|
|
@@ -1733,7 +1741,7 @@ function mergeValue(base, ours, theirs, atomic) {
|
|
|
1733
1741
|
if (same(ours, theirs)) return ours;
|
|
1734
1742
|
if (same(base, ours)) return theirs;
|
|
1735
1743
|
if (same(base, theirs)) return ours;
|
|
1736
|
-
if (atomic || !
|
|
1744
|
+
if (atomic || !isRecord(base) || !isRecord(ours) || !isRecord(theirs)) return conflict;
|
|
1737
1745
|
const order = (value) => Object.keys(value).filter((key) => Object.hasOwn(base, key) && Object.hasOwn(ours, key) && Object.hasOwn(theirs, key)).join("\0");
|
|
1738
1746
|
if (order(ours) !== order(base) && order(theirs) !== order(base)) return conflict;
|
|
1739
1747
|
const keys = keyOrder(order(ours) !== order(base) ? ours : theirs, order(ours) !== order(base) ? theirs : ours);
|
|
@@ -1757,7 +1765,6 @@ function keyOrder(primary, other) {
|
|
|
1757
1765
|
}
|
|
1758
1766
|
const read = (value, key) => Object.hasOwn(value, key) ? value[key] : absent;
|
|
1759
1767
|
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
1768
|
function jsonStyle(text) {
|
|
1762
1769
|
const indent = /^\{\r?\n([ \t]+)"/.exec(text)?.[1];
|
|
1763
1770
|
if (indent === void 0) return text.trim() === "{}" ? {
|
|
@@ -2928,12 +2935,15 @@ function evaluateGitHubRequiredChecks(policy, evidence) {
|
|
|
2928
2935
|
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
2936
|
const status = evidence.statuses.filter((value) => value.sha === evidence.headSha && value.context === required.context).sort((a, b) => b.id - a.id)[0];
|
|
2930
2937
|
const states = [];
|
|
2931
|
-
|
|
2938
|
+
const run = runs[0];
|
|
2939
|
+
const runState = run && stateOfCheck(run);
|
|
2940
|
+
if (runState) states.push(runState);
|
|
2932
2941
|
if (status) states.push(status.state === "pending" ? "pending" : ["failure", "error"].includes(status.state) ? "failed" : status.state === "success" && required.appId === null ? "passed" : "unknown");
|
|
2933
2942
|
if (!states.length) missing.push(required.context);
|
|
2934
2943
|
return {
|
|
2935
2944
|
...required,
|
|
2936
|
-
state: states.length ? combine(states) : "pending"
|
|
2945
|
+
state: states.length ? combine(states) : "pending",
|
|
2946
|
+
...runState === "failed" && run?.conclusion?.toLowerCase() === "cancelled" ? { cancelled: true } : {}
|
|
2937
2947
|
};
|
|
2938
2948
|
});
|
|
2939
2949
|
const newest = /* @__PURE__ */ new Map();
|
|
@@ -3416,6 +3426,10 @@ const deliverySchema = v.looseObject({
|
|
|
3416
3426
|
action: v.optional(v.string()),
|
|
3417
3427
|
sender: actor,
|
|
3418
3428
|
pull_request: v.optional(pullRequestSchema),
|
|
3429
|
+
changes: v.optional(v.object({
|
|
3430
|
+
title: v.optional(v.unknown()),
|
|
3431
|
+
body: v.optional(v.unknown())
|
|
3432
|
+
})),
|
|
3419
3433
|
issue: v.optional(v.object({
|
|
3420
3434
|
number: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
3421
3435
|
pull_request: v.optional(v.unknown())
|
|
@@ -3494,7 +3508,8 @@ function parseSnapshot(value) {
|
|
|
3494
3508
|
if (input.hostUpdates !== void 0) v.parse(v.array(v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i))), input.hostUpdates);
|
|
3495
3509
|
if (input.hostHeads !== void 0) v.parse(v.array(v.object({
|
|
3496
3510
|
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))
|
|
3511
|
+
parent: v.pipe(v.string(), v.regex(/^[a-f\d]{40}$/i)),
|
|
3512
|
+
repair: v.optional(v.literal(true))
|
|
3498
3513
|
})), input.hostHeads);
|
|
3499
3514
|
if (input.threadReopens !== void 0) v.parse(v.record(v.string(), v.pipe(v.number(), v.integer(), v.minValue(0))), input.threadReopens);
|
|
3500
3515
|
if (input.sourcePushHeads !== void 0) v.parse(v.array(v.string()), input.sourcePushHeads);
|
|
@@ -3502,6 +3517,16 @@ function parseSnapshot(value) {
|
|
|
3502
3517
|
if (input.sourcePushHead !== void 0) v.parse(v.string(), input.sourcePushHead);
|
|
3503
3518
|
if (input.recoveryHead !== void 0) v.parse(v.string(), input.recoveryHead);
|
|
3504
3519
|
if (input.humanFeedbackGeneration !== void 0) v.parse(v.pipe(v.number(), v.integer(), v.minValue(0)), input.humanFeedbackGeneration);
|
|
3520
|
+
if (input.metadataEdits !== void 0) {
|
|
3521
|
+
const edit = v.optional(v.object({
|
|
3522
|
+
generation: v.number(),
|
|
3523
|
+
externalGeneration: v.number()
|
|
3524
|
+
}));
|
|
3525
|
+
v.parse(v.object({
|
|
3526
|
+
title: edit,
|
|
3527
|
+
body: edit
|
|
3528
|
+
}), input.metadataEdits);
|
|
3529
|
+
}
|
|
3505
3530
|
if (input.ciEvidence !== void 0) v.parse(v.array(v.record(v.string(), v.unknown())), input.ciEvidence);
|
|
3506
3531
|
if (input.ownedReviewCommentIds !== void 0) v.parse(v.array(v.string()), input.ownedReviewCommentIds);
|
|
3507
3532
|
if (input.wait !== void 0) parseWait(input.wait);
|
|
@@ -4587,7 +4612,7 @@ var PullRequestInbox = class {
|
|
|
4587
4612
|
if (!s.lease) s.status = s.wait ? "waiting" : "ready";
|
|
4588
4613
|
s.reasons = [.../* @__PURE__ */ new Set([...s.reasons, reason])];
|
|
4589
4614
|
}
|
|
4590
|
-
updatePr(s, pr) {
|
|
4615
|
+
updatePr(s, pr, ownChanges) {
|
|
4591
4616
|
pr = normalizePullRequest(pr);
|
|
4592
4617
|
if (s.pr && stamp(pr) < stamp(s.pr)) return false;
|
|
4593
4618
|
const previous = s.pr;
|
|
@@ -4615,6 +4640,15 @@ var PullRequestInbox = class {
|
|
|
4615
4640
|
}
|
|
4616
4641
|
if (pr.state === "closed") delete s.prospectivePush;
|
|
4617
4642
|
if (newHead && pr.head?.sha !== s.wait?.headSha || pr.state === "closed") delete s.wait;
|
|
4643
|
+
for (const field of ["title", "body"]) {
|
|
4644
|
+
if (pr[field] === void 0 || pr[field] === previous?.[field]) continue;
|
|
4645
|
+
const edits = s.metadataEdits ??= {};
|
|
4646
|
+
const generation = s.generation + 1;
|
|
4647
|
+
edits[field] = {
|
|
4648
|
+
generation,
|
|
4649
|
+
externalGeneration: ownChanges?.[field] ? edits[field]?.externalGeneration ?? 0 : generation
|
|
4650
|
+
};
|
|
4651
|
+
}
|
|
4618
4652
|
s.pr = {
|
|
4619
4653
|
...previous,
|
|
4620
4654
|
...pr
|
|
@@ -4804,7 +4838,10 @@ var PullRequestInbox = class {
|
|
|
4804
4838
|
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
4839
|
if (sha && s.pr?.head?.sha && s.pr.head.sha !== sha && !pushRefMatch && !pendingHead) continue;
|
|
4806
4840
|
let changed = false;
|
|
4807
|
-
if (payload.pull_request)
|
|
4841
|
+
if (payload.pull_request) {
|
|
4842
|
+
const ownEdit = event === "pull_request" && payload.action === "edited" && payload.sender?.type?.toLowerCase() === "bot" && this.activityAuthors.has(payload.sender.login?.toLowerCase() ?? "");
|
|
4843
|
+
changed = this.updatePr(s, payload.pull_request, ownEdit ? payload.changes : void 0);
|
|
4844
|
+
}
|
|
4808
4845
|
if (event === "pull_request" && payload.action === "synchronize" && s.hostUpdates?.length) this.settleHostUpdate(s, payload);
|
|
4809
4846
|
const upsert = (map, value, itemKey) => {
|
|
4810
4847
|
if (!value) return;
|
|
@@ -5055,7 +5092,7 @@ var PullRequestInbox = class {
|
|
|
5055
5092
|
id: thread.node_id ?? thread.id,
|
|
5056
5093
|
isResolved: thread.isResolved,
|
|
5057
5094
|
isOutdated: thread.isOutdated,
|
|
5058
|
-
comments: (Array.isArray(thread.comments) ? thread.comments : thread.comments?.nodes ?? []).map((comment) => String(comment.node_id ?? comment.id)).sort()
|
|
5095
|
+
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
5096
|
})).sort((a, b) => String(a.id).localeCompare(String(b.id)));
|
|
5060
5097
|
const changed = digest(semantic(s.threads)) !== digest(semantic(threads));
|
|
5061
5098
|
s.threads = threads;
|
|
@@ -5111,7 +5148,7 @@ var PullRequestInbox = class {
|
|
|
5111
5148
|
token: claim.token,
|
|
5112
5149
|
heads
|
|
5113
5150
|
};
|
|
5114
|
-
if (lineage?.hostOnly && /^[a-f\d]{40}$/i.test(lineage.parent)) this.addHostHead(s, head, lineage.parent);
|
|
5151
|
+
if (lineage?.hostOnly && /^[a-f\d]{40}$/i.test(lineage.parent)) this.addHostHead(s, head, lineage.parent, true);
|
|
5115
5152
|
s.revision = (s.revision ?? 0) + 1;
|
|
5116
5153
|
await this.put(tx, s);
|
|
5117
5154
|
return true;
|
|
@@ -5134,11 +5171,12 @@ var PullRequestInbox = class {
|
|
|
5134
5171
|
await this.put(tx, s);
|
|
5135
5172
|
});
|
|
5136
5173
|
}
|
|
5137
|
-
addHostHead(s, head, parent) {
|
|
5174
|
+
addHostHead(s, head, parent, repair = false) {
|
|
5138
5175
|
if (s.hostHeads?.some((entry) => entry.head === head)) return;
|
|
5139
5176
|
s.hostHeads = [...s.hostHeads ?? [], {
|
|
5140
5177
|
head,
|
|
5141
|
-
parent
|
|
5178
|
+
parent,
|
|
5179
|
+
...repair && { repair: true }
|
|
5142
5180
|
}].slice(-64);
|
|
5143
5181
|
}
|
|
5144
5182
|
/**
|
|
@@ -5172,16 +5210,13 @@ var PullRequestInbox = class {
|
|
|
5172
5210
|
return true;
|
|
5173
5211
|
});
|
|
5174
5212
|
}
|
|
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) {
|
|
5213
|
+
async recordModelPass(claim, exemption, observed) {
|
|
5180
5214
|
if (this.budgets.dailyPasses === void 0) return false;
|
|
5181
5215
|
return await this.transaction(async (tx) => {
|
|
5182
5216
|
const s = await this.getIn(tx, claim.snapshot.repository, claim.snapshot.number);
|
|
5183
5217
|
const at = this.clock();
|
|
5184
5218
|
if (!s || s.lease !== claim.token || s.leaseUntil <= at) return false;
|
|
5219
|
+
if (observed && (s.generation !== observed.generation || (s.revision ?? 0) !== (observed.revision ?? 0))) return "changed";
|
|
5185
5220
|
s.dailyPassBudget = nextDailyPassBudget(s.dailyPassBudget, at, s.humanFeedbackGeneration, exemption);
|
|
5186
5221
|
s.revision = (s.revision ?? 0) + 1;
|
|
5187
5222
|
await this.put(tx, s);
|
|
@@ -5897,7 +5932,10 @@ async function readForgePullRequestThreads(provider, repository, number, signal)
|
|
|
5897
5932
|
},
|
|
5898
5933
|
signal
|
|
5899
5934
|
})).data);
|
|
5900
|
-
}, thread.id) : thread.comments.flatMap((comment) => comment.ref ? [{
|
|
5935
|
+
}, thread.id) : thread.comments.flatMap((comment) => comment.ref ? [{
|
|
5936
|
+
id: comment.ref.id,
|
|
5937
|
+
...commentAuthor(comment.author)
|
|
5938
|
+
}] : []);
|
|
5901
5939
|
threads.push({
|
|
5902
5940
|
id: thread.id,
|
|
5903
5941
|
node_id: thread.id,
|
|
@@ -5912,6 +5950,12 @@ async function readForgePullRequestThreads(provider, repository, number, signal)
|
|
|
5912
5950
|
}
|
|
5913
5951
|
return threads;
|
|
5914
5952
|
}
|
|
5953
|
+
function commentAuthor(author) {
|
|
5954
|
+
return author ? { user: {
|
|
5955
|
+
login: author.login,
|
|
5956
|
+
type: author.isBotHint ? "Bot" : author.typeRaw ?? "User"
|
|
5957
|
+
} } : {};
|
|
5958
|
+
}
|
|
5915
5959
|
const index = (items) => Object.fromEntries(items.map((item) => [String(item.id), item]));
|
|
5916
5960
|
const pageInfo = v.object({
|
|
5917
5961
|
hasNextPage: v.boolean(),
|
|
@@ -5920,7 +5964,11 @@ const pageInfo = v.object({
|
|
|
5920
5964
|
const commentConnection = v.object({
|
|
5921
5965
|
nodes: v.array(v.object({
|
|
5922
5966
|
id: v.string(),
|
|
5923
|
-
databaseId: v.nullish(v.number())
|
|
5967
|
+
databaseId: v.nullish(v.number()),
|
|
5968
|
+
author: v.nullish(v.object({
|
|
5969
|
+
login: v.string(),
|
|
5970
|
+
__typename: v.optional(v.string())
|
|
5971
|
+
}))
|
|
5924
5972
|
})),
|
|
5925
5973
|
pageInfo
|
|
5926
5974
|
});
|
|
@@ -5950,14 +5998,17 @@ async function readThreadComments(request, id) {
|
|
|
5950
5998
|
do {
|
|
5951
5999
|
const more = v.parse(v.object({ node: v.object({ comments: commentConnection }) }), await request(`query GitHubPullRequestThreadComments($id:ID!,$after:String) {
|
|
5952
6000
|
node(id:$id) { ... on PullRequestReviewThread { comments(first:100,after:$after) {
|
|
5953
|
-
nodes { id databaseId } pageInfo { hasNextPage endCursor }
|
|
6001
|
+
nodes { id databaseId author { login __typename } } pageInfo { hasNextPage endCursor }
|
|
5954
6002
|
} } }
|
|
5955
6003
|
}`, {
|
|
5956
6004
|
id,
|
|
5957
6005
|
after
|
|
5958
6006
|
}));
|
|
5959
6007
|
after = nextCursor(more.node.comments, pages);
|
|
5960
|
-
comments.push(...more.node.comments.nodes)
|
|
6008
|
+
comments.push(...more.node.comments.nodes.map(({ author, ...comment }) => author ? {
|
|
6009
|
+
...comment,
|
|
6010
|
+
author
|
|
6011
|
+
} : comment));
|
|
5961
6012
|
} while (after);
|
|
5962
6013
|
return comments;
|
|
5963
6014
|
}
|
|
@@ -7057,6 +7108,30 @@ function repairEnvironment(environment = {}, githubConfigDirectory, identity = {
|
|
|
7057
7108
|
GIT_TERMINAL_PROMPT: "0"
|
|
7058
7109
|
};
|
|
7059
7110
|
}
|
|
7111
|
+
// src/babysitter/repair-evidence.ts
|
|
7112
|
+
function changedEvidence(before, after) {
|
|
7113
|
+
const changes = [];
|
|
7114
|
+
if (before.pr?.head?.sha !== after.pr?.head?.sha) changes.push("head");
|
|
7115
|
+
if (before.pr?.base?.ref !== after.pr?.base?.ref) changes.push("base");
|
|
7116
|
+
for (const field of [
|
|
7117
|
+
"title",
|
|
7118
|
+
"body",
|
|
7119
|
+
"draft"
|
|
7120
|
+
]) if (before.pr?.[field] !== after.pr?.[field]) changes.push(`pr.${field}`);
|
|
7121
|
+
for (const field of [
|
|
7122
|
+
"comments",
|
|
7123
|
+
"reviews",
|
|
7124
|
+
"reviewComments",
|
|
7125
|
+
"checks",
|
|
7126
|
+
"statuses"
|
|
7127
|
+
]) for (const [key, value] of Object.entries(after[field])) if (JSON.stringify(before[field][key]) !== JSON.stringify(value)) changes.push(`${field}:${key}`);
|
|
7128
|
+
const threads = new Map(before.threads.map((thread) => [String(thread.node_id ?? thread.id), JSON.stringify(thread)]));
|
|
7129
|
+
for (const thread of after.threads) {
|
|
7130
|
+
const id = String(thread.node_id ?? thread.id);
|
|
7131
|
+
if (threads.get(id) !== JSON.stringify(thread)) changes.push(`threads:${id}`);
|
|
7132
|
+
}
|
|
7133
|
+
return changes.length > 20 ? [...changes.slice(0, 20), `+${changes.length - 20} more`] : changes;
|
|
7134
|
+
}
|
|
7060
7135
|
// src/babysitter/wait.ts
|
|
7061
7136
|
const hash = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
7062
7137
|
const pending = /* @__PURE__ */ new Set([
|
|
@@ -7342,13 +7417,14 @@ function createCheckWait(observed, policy) {
|
|
|
7342
7417
|
};
|
|
7343
7418
|
}
|
|
7344
7419
|
/** Why a parked PR needs a model pass or a direct merge. Empty means it keeps waiting. */
|
|
7345
|
-
function wakeReasons(s, requiredChecks, policy) {
|
|
7420
|
+
function wakeReasons(s, requiredChecks, policy, repairOwnPush = false) {
|
|
7346
7421
|
const wait = s.wait;
|
|
7347
7422
|
if (!wait) return ["no-wait"];
|
|
7348
7423
|
if (s.pr?.state !== "open") return ["not-open"];
|
|
7349
7424
|
if (wait.headSha !== s.pr.head?.sha) return [];
|
|
7350
7425
|
const known = new Set(wait.knownFailures ?? []);
|
|
7351
7426
|
if (wait.defer === "checks") {
|
|
7427
|
+
if (repairOwnPush) return ["new-failure"];
|
|
7352
7428
|
const conflict = s.pr.mergeable === false || s.pr.mergeable_state === "dirty";
|
|
7353
7429
|
if (!conflict && checksStillRunning(s, Date.now(), policy)) return [];
|
|
7354
7430
|
const failure = actionableFailureKeys(s, policy).some((key) => !known.has(key));
|
|
@@ -7429,6 +7505,15 @@ function createProviderQuota(store, cooldownMs, now = Date.now) {
|
|
|
7429
7505
|
}
|
|
7430
7506
|
};
|
|
7431
7507
|
}
|
|
7508
|
+
function isProviderRateLimit(error) {
|
|
7509
|
+
if (error instanceof Error && error.name === "AbortError") return false;
|
|
7510
|
+
if (error instanceof RateLimitedError) return true;
|
|
7511
|
+
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));
|
|
7512
|
+
}
|
|
7513
|
+
function isProviderFailure(error) {
|
|
7514
|
+
if (error instanceof Error && error.name === "AbortError") return false;
|
|
7515
|
+
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));
|
|
7516
|
+
}
|
|
7432
7517
|
const forgeStrikesKey = "forge-quota-strikes";
|
|
7433
7518
|
const forgeLastBlockKey = "forge-quota-last-block";
|
|
7434
7519
|
const firstForgeCooldownMs = 3e5;
|
|
@@ -8865,17 +8950,6 @@ function mergeResultStatus(error) {
|
|
|
8865
8950
|
return;
|
|
8866
8951
|
}
|
|
8867
8952
|
}
|
|
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
8953
|
/** A provider failure this soon after dispatch gives the daily pass back. A longer pass did real work. */
|
|
8880
8954
|
const providerFailureReleaseMs = 6e5;
|
|
8881
8955
|
function createBabysitterRuntime(options) {
|
|
@@ -8978,7 +9052,7 @@ function createBabysitterRuntime(options) {
|
|
|
8978
9052
|
ignoreAssessedBotThreads: presetOptions.ignoreAssessedBotThreads === true
|
|
8979
9053
|
};
|
|
8980
9054
|
const schedulerEvent = (name, properties = {}) => options.event?.(name, properties);
|
|
8981
|
-
const release = baseAgent.version ?? "
|
|
9055
|
+
const release = baseAgent.version ?? "7fd99b60ad33356545ce233e0675580c666313fbf3f50e93db479920a1ba9fad";
|
|
8982
9056
|
const workspaces = options.workspaces;
|
|
8983
9057
|
const schedulerError = (name, error, properties = {}) => options.error?.(name, error, properties);
|
|
8984
9058
|
const statusComment = !!verifiedHostIdentity && presetOptions.status?.comment !== false;
|
|
@@ -9406,20 +9480,24 @@ function createBabysitterRuntime(options) {
|
|
|
9406
9480
|
}
|
|
9407
9481
|
/**
|
|
9408
9482
|
* 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.
|
|
9483
|
+
* when the base tip has no failing check. It does not wait for the head's other checks: they run on
|
|
9484
|
+
* the same old base. Two retests per PR every six hours, so a retest that lands on a base that is
|
|
9485
|
+
* still broken gets one more after the base is fixed.
|
|
9410
9486
|
*/
|
|
9411
9487
|
async function retestOnCurrentBase(snapshot, owner, signal) {
|
|
9412
9488
|
const { repository, number } = snapshot;
|
|
9413
9489
|
const pr = snapshot.pr;
|
|
9414
9490
|
const head = pr?.head?.sha;
|
|
9415
9491
|
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
|
-
|
|
9492
|
+
if (!failureKeys(snapshot).length) return false;
|
|
9493
|
+
const key = `base-retests:${repository}#${number}`;
|
|
9494
|
+
const saved = await pullRequestInbox.meta(key);
|
|
9495
|
+
const recent = (Array.isArray(saved) ? saved : []).filter((at) => hasRuntimeType(at, "number") && at > Date.now() - 216e5);
|
|
9496
|
+
if (recent.length >= 2) return false;
|
|
9419
9497
|
const ahead = await baseFixedSinceFailure(freshnessReader, snapshot, failedConclusions, signal);
|
|
9420
9498
|
if (!ahead) return false;
|
|
9421
9499
|
if (!await updateBranch(owner, repository, number, head, signal, pr)) return false;
|
|
9422
|
-
await pullRequestInbox.setMeta(key, Date.now());
|
|
9500
|
+
await pullRequestInbox.setMeta(key, [...recent, Date.now()]);
|
|
9423
9501
|
schedulerEvent("babysitter.branch.retest", {
|
|
9424
9502
|
...owner,
|
|
9425
9503
|
base_ahead: ahead
|
|
@@ -9430,9 +9508,10 @@ function createBabysitterRuntime(options) {
|
|
|
9430
9508
|
/**
|
|
9431
9509
|
* A job that a runner or network error stopped gets a fresh CI run: the host updates the branch, once
|
|
9432
9510
|
* 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.
|
|
9511
|
+
* such as a 504 from a setup action, that nothing retries. A cancelled required check gets the same
|
|
9512
|
+
* retest: a cancel or a job timeout has no code cause for a pass to repair.
|
|
9434
9513
|
*/
|
|
9435
|
-
async function retestInfrastructureFailure(snapshot, owner, signal) {
|
|
9514
|
+
async function retestInfrastructureFailure(snapshot, owner, signal, cause = "infrastructure") {
|
|
9436
9515
|
const { repository, number } = snapshot;
|
|
9437
9516
|
const pr = snapshot.pr;
|
|
9438
9517
|
const head = pr?.head?.sha;
|
|
@@ -9448,7 +9527,7 @@ function createBabysitterRuntime(options) {
|
|
|
9448
9527
|
if (!await updateBranch(owner, repository, number, head, signal, pr)) return false;
|
|
9449
9528
|
schedulerEvent("babysitter.branch.retest", {
|
|
9450
9529
|
...owner,
|
|
9451
|
-
cause
|
|
9530
|
+
cause
|
|
9452
9531
|
});
|
|
9453
9532
|
return true;
|
|
9454
9533
|
}
|
|
@@ -9759,11 +9838,11 @@ function createBabysitterRuntime(options) {
|
|
|
9759
9838
|
return hasRuntimeType(sha, "string") && /^[a-f\d]{40}$/i.test(sha) ? sha : void 0;
|
|
9760
9839
|
}
|
|
9761
9840
|
/** Current-head Actions checks that repeat the same job failure on the live base tip. */
|
|
9762
|
-
async function readInheritedBaseFailures(snapshot, signal, verificationBaseSha) {
|
|
9841
|
+
async function readInheritedBaseFailures(snapshot, signal, verificationBaseSha, whileRunning = false) {
|
|
9763
9842
|
const { repository } = snapshot;
|
|
9764
9843
|
const head = snapshot.pr?.head?.sha;
|
|
9765
9844
|
const baseRef = snapshot.pr?.base?.ref;
|
|
9766
|
-
if (!head || !baseRef || conflicted(snapshot) || checksStillRunning(snapshot)) return [];
|
|
9845
|
+
if (!head || !baseRef || conflicted(snapshot) || !whileRunning && checksStillRunning(snapshot)) return [];
|
|
9767
9846
|
const failing = currentActionRuns(snapshot, waitPolicy.pendingReviewChecks).filter((check) => failedConclusions.has(String(check.conclusion)));
|
|
9768
9847
|
if (!failing.length) return [];
|
|
9769
9848
|
const tip = verificationBaseSha ?? await liveBaseTip(repository, baseRef, signal);
|
|
@@ -9792,20 +9871,22 @@ function createBabysitterRuntime(options) {
|
|
|
9792
9871
|
return ids;
|
|
9793
9872
|
}
|
|
9794
9873
|
const inheritedFailures = /* @__PURE__ */ new Map();
|
|
9795
|
-
async function inheritedBaseFailures(snapshot, signal) {
|
|
9874
|
+
async function inheritedBaseFailures(snapshot, signal, whileRunning = false) {
|
|
9796
9875
|
try {
|
|
9797
|
-
return await readInheritedBaseFailures(snapshot, signal);
|
|
9876
|
+
return await readInheritedBaseFailures(snapshot, signal, void 0, whileRunning);
|
|
9798
9877
|
} catch (error) {
|
|
9799
9878
|
if (isAbortError(error)) throw error;
|
|
9800
9879
|
await noteForgeQuota(error, "inherited-failures");
|
|
9801
9880
|
return [];
|
|
9802
9881
|
}
|
|
9803
9882
|
}
|
|
9883
|
+
function failedSignals(snapshot) {
|
|
9884
|
+
return latestCheckSignals(snapshot).filter((check) => failedConclusions.has(String(check.conclusion ?? check.state)) && !waitPolicy.pendingReviewChecks.has(String(check.name ?? check.context).toLowerCase()));
|
|
9885
|
+
}
|
|
9804
9886
|
/** 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()));
|
|
9887
|
+
async function failureCauses(snapshot, signal, failing = failedSignals(snapshot), whileRunning = false) {
|
|
9807
9888
|
if (!failing.length) return [];
|
|
9808
|
-
const inherited = new Set(await inheritedBaseFailures(snapshot, signal));
|
|
9889
|
+
const inherited = new Set(await inheritedBaseFailures(snapshot, signal, whileRunning));
|
|
9809
9890
|
const causes = [];
|
|
9810
9891
|
for (const check of failing) {
|
|
9811
9892
|
const name = String(check.name ?? check.context);
|
|
@@ -9891,6 +9972,7 @@ function createBabysitterRuntime(options) {
|
|
|
9891
9972
|
const { provider, repo } = await forge(repository);
|
|
9892
9973
|
return await forgeBranchRules(provider, repo, branch);
|
|
9893
9974
|
});
|
|
9975
|
+
const mergeBlockers = /* @__PURE__ */ new WeakMap();
|
|
9894
9976
|
/**
|
|
9895
9977
|
* Merges a PR that inbox evidence, the merge policy, and GitHub's live state all report ready.
|
|
9896
9978
|
* Returns `not-ready` for a normal pass, and `blocked` while a merge outcome is unknown.
|
|
@@ -9899,6 +9981,14 @@ function createBabysitterRuntime(options) {
|
|
|
9899
9981
|
if (merge.mode !== "direct") return "not-ready";
|
|
9900
9982
|
const { snapshot } = claim;
|
|
9901
9983
|
const { repository, number } = snapshot;
|
|
9984
|
+
mergeBlockers.delete(claim);
|
|
9985
|
+
const mergeSkipped = (reason) => {
|
|
9986
|
+
mergeBlockers.set(claim, reason);
|
|
9987
|
+
schedulerEvent("babysitter.direct_merge.skipped", {
|
|
9988
|
+
...owner,
|
|
9989
|
+
reason
|
|
9990
|
+
});
|
|
9991
|
+
};
|
|
9902
9992
|
const base = snapshot.pr?.base?.ref;
|
|
9903
9993
|
if (!base) return "not-ready";
|
|
9904
9994
|
const pending = await pullRequestInbox.directMergeAttempt(repository, number);
|
|
@@ -10015,10 +10105,7 @@ function createBabysitterRuntime(options) {
|
|
|
10015
10105
|
}
|
|
10016
10106
|
} catch (error) {
|
|
10017
10107
|
await noteForgeQuota(error, "merge-reconcile");
|
|
10018
|
-
|
|
10019
|
-
...owner,
|
|
10020
|
-
reason: `merge outcome unknown: ${(error instanceof Error ? error.message : String(error)).slice(0, 160)}`
|
|
10021
|
-
});
|
|
10108
|
+
mergeSkipped(`merge outcome unknown: ${(error instanceof Error ? error.message : String(error)).slice(0, 160)}`);
|
|
10022
10109
|
return await parkMerge("GitHub merge outcome could not be reconciled; retrying the provider read.");
|
|
10023
10110
|
}
|
|
10024
10111
|
if (signal.aborted) return "blocked";
|
|
@@ -10068,10 +10155,7 @@ function createBabysitterRuntime(options) {
|
|
|
10068
10155
|
};
|
|
10069
10156
|
}
|
|
10070
10157
|
if (!decision.ready) {
|
|
10071
|
-
|
|
10072
|
-
...owner,
|
|
10073
|
-
reason: decision.reason
|
|
10074
|
-
});
|
|
10158
|
+
mergeSkipped(decision.reason);
|
|
10075
10159
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed merge is waiting for ${decision.reason}.`) : "not-ready";
|
|
10076
10160
|
}
|
|
10077
10161
|
const everyCheckGates = policy.status === "known" && !policy.required.length;
|
|
@@ -10084,10 +10168,7 @@ function createBabysitterRuntime(options) {
|
|
|
10084
10168
|
});
|
|
10085
10169
|
const until = since + firstCheckWaitMs;
|
|
10086
10170
|
if (until > pullRequestInbox.now()) {
|
|
10087
|
-
|
|
10088
|
-
...owner,
|
|
10089
|
-
reason: "no check reported for the head yet"
|
|
10090
|
-
});
|
|
10171
|
+
mergeSkipped("no check reported for the head yet");
|
|
10091
10172
|
return await parkMerge(`GitHub has reported no check for ${decision.head} yet; waiting until ${new Date(until).toISOString()} for its first check.`, until);
|
|
10092
10173
|
}
|
|
10093
10174
|
}
|
|
@@ -10098,10 +10179,7 @@ function createBabysitterRuntime(options) {
|
|
|
10098
10179
|
let mergeStarted = false;
|
|
10099
10180
|
const bypass = evaluation.bypassedRequiredChecks.length > 0;
|
|
10100
10181
|
if (foldInto !== void 0 && bypass) {
|
|
10101
|
-
|
|
10102
|
-
...owner,
|
|
10103
|
-
reason: "a fold never merges past failing required checks"
|
|
10104
|
-
});
|
|
10182
|
+
mergeSkipped("a fold never merges past failing required checks");
|
|
10105
10183
|
return pending?.asynchronous ? await parkMerge("Unconfirmed fold is waiting for passing required checks.") : "not-ready";
|
|
10106
10184
|
}
|
|
10107
10185
|
let inheritedProof;
|
|
@@ -10124,10 +10202,7 @@ function createBabysitterRuntime(options) {
|
|
|
10124
10202
|
...foldInto === void 0 ? {} : { foldInto: base }
|
|
10125
10203
|
});
|
|
10126
10204
|
if (!current.ready) {
|
|
10127
|
-
|
|
10128
|
-
...owner,
|
|
10129
|
-
reason: current.reason
|
|
10130
|
-
});
|
|
10205
|
+
mergeSkipped(current.reason);
|
|
10131
10206
|
if (!pending && current.reason === "mergeable_state behind") {
|
|
10132
10207
|
if (!await updateBranch(owner, repository, number, decision.head, signal, live, { reopenFork: false })) return "not-ready";
|
|
10133
10208
|
schedulerEvent("babysitter.branch.updated", {
|
|
@@ -10145,10 +10220,7 @@ function createBabysitterRuntime(options) {
|
|
|
10145
10220
|
}, signal, bypass ? /* @__PURE__ */ new Set(["success", ...failedConclusions]) : void 0);
|
|
10146
10221
|
if (overlap.length) {
|
|
10147
10222
|
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
|
-
});
|
|
10223
|
+
mergeSkipped(`${base} changed files this PR touches after its checks ran: ${files}`);
|
|
10152
10224
|
if (!await updateBranch(owner, repository, number, decision.head, signal, live)) {
|
|
10153
10225
|
const reopened = isForkHead(live, repository) ? await pullRequestInbox.meta(forkReopenKey(repository, number)) : void 0;
|
|
10154
10226
|
const at = isRuntimeRecord(reopened) ? Number(reopened.at) : NaN;
|
|
@@ -10204,10 +10276,7 @@ function createBabysitterRuntime(options) {
|
|
|
10204
10276
|
});
|
|
10205
10277
|
}
|
|
10206
10278
|
if (branchSafety !== true) {
|
|
10207
|
-
|
|
10208
|
-
...owner,
|
|
10209
|
-
reason: branchSafety
|
|
10210
|
-
});
|
|
10279
|
+
mergeSkipped(branchSafety);
|
|
10211
10280
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed merge is waiting for ${branchSafety}.`) : "not-ready";
|
|
10212
10281
|
}
|
|
10213
10282
|
if (foldInto !== void 0) {
|
|
@@ -10218,10 +10287,7 @@ function createBabysitterRuntime(options) {
|
|
|
10218
10287
|
}, signal);
|
|
10219
10288
|
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
10289
|
if (reason) {
|
|
10221
|
-
|
|
10222
|
-
...owner,
|
|
10223
|
-
reason
|
|
10224
|
-
});
|
|
10290
|
+
mergeSkipped(reason);
|
|
10225
10291
|
return pending?.asynchronous ? await parkMerge(`Unconfirmed fold is waiting: ${reason}.`) : "not-ready";
|
|
10226
10292
|
}
|
|
10227
10293
|
}
|
|
@@ -10234,29 +10300,20 @@ function createBabysitterRuntime(options) {
|
|
|
10234
10300
|
const freshEvaluation = await checkEvaluation(fresh, policy, signal);
|
|
10235
10301
|
const freshDecision = readiness(fresh, freshEvaluation.state, freshEvaluation.inheritedCheckIds);
|
|
10236
10302
|
if (!freshDecision.ready) {
|
|
10237
|
-
|
|
10238
|
-
...owner,
|
|
10239
|
-
reason: `GitHub reports checks the inbox lacks: ${freshDecision.reason}`
|
|
10240
|
-
});
|
|
10303
|
+
mergeSkipped(`GitHub reports checks the inbox lacks: ${freshDecision.reason}`);
|
|
10241
10304
|
if (await pullRequestInbox.hydrate(claim, reported)) return pending ? await parkMerge(`Unconfirmed merge is waiting for ${freshDecision.reason}.`) : "not-ready";
|
|
10242
10305
|
await pullRequestInbox.release(claim);
|
|
10243
10306
|
return "blocked";
|
|
10244
10307
|
}
|
|
10245
10308
|
}
|
|
10246
10309
|
if (!await pullRequestInbox.isClaimCurrent(claim)) {
|
|
10247
|
-
|
|
10248
|
-
...owner,
|
|
10249
|
-
reason: "claim changed before merge"
|
|
10250
|
-
});
|
|
10310
|
+
mergeSkipped("claim changed before merge");
|
|
10251
10311
|
return "not-ready";
|
|
10252
10312
|
}
|
|
10253
10313
|
if (bypass && isRuntimeRecord(live)) {
|
|
10254
10314
|
const proof = await verifyInheritedMerge(snapshot, live, signal);
|
|
10255
10315
|
if ("refused" in proof) {
|
|
10256
|
-
|
|
10257
|
-
...owner,
|
|
10258
|
-
reason: proof.refused
|
|
10259
|
-
});
|
|
10316
|
+
mergeSkipped(proof.refused);
|
|
10260
10317
|
return pending?.asynchronous ? await parkMerge("Unconfirmed merge is waiting for inherited-check verification.") : "not-ready";
|
|
10261
10318
|
}
|
|
10262
10319
|
inheritedProof = proof;
|
|
@@ -10265,10 +10322,7 @@ function createBabysitterRuntime(options) {
|
|
|
10265
10322
|
}
|
|
10266
10323
|
signal.throwIfAborted();
|
|
10267
10324
|
if (!pending && !await pullRequestInbox.beginDirectMerge(claim, decision.head, true, foldInto)) {
|
|
10268
|
-
|
|
10269
|
-
...owner,
|
|
10270
|
-
reason: "merge attempt already in flight or claim changed"
|
|
10271
|
-
});
|
|
10325
|
+
mergeSkipped("merge attempt already in flight or claim changed");
|
|
10272
10326
|
return "blocked";
|
|
10273
10327
|
}
|
|
10274
10328
|
if (inheritedProof) {
|
|
@@ -10305,10 +10359,7 @@ function createBabysitterRuntime(options) {
|
|
|
10305
10359
|
}
|
|
10306
10360
|
} catch (error) {
|
|
10307
10361
|
await noteForgeQuota(error, "direct-merge");
|
|
10308
|
-
|
|
10309
|
-
...owner,
|
|
10310
|
-
reason: (error instanceof Error ? error.message : String(error)).slice(0, 200)
|
|
10311
|
-
});
|
|
10362
|
+
mergeSkipped((error instanceof Error ? error.message : String(error)).slice(0, 200));
|
|
10312
10363
|
const rejectedStatus = forgeErrorStatus(error);
|
|
10313
10364
|
if (mergeStarted && rejectedStatus !== void 0 && rejectedStatus >= 400 && rejectedStatus < 500 && rejectedStatus !== 409) await pullRequestInbox.clearDirectMerge(repository, number, mergeToken);
|
|
10314
10365
|
return await parkMerge(`GitHub merge request failed: ${(error instanceof Error ? error.message : String(error)).slice(0, 200)}`);
|
|
@@ -10330,7 +10381,7 @@ function createBabysitterRuntime(options) {
|
|
|
10330
10381
|
return "merged";
|
|
10331
10382
|
}
|
|
10332
10383
|
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
|
|
10384
|
+
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
10385
|
terminal: true
|
|
10335
10386
|
});
|
|
10336
10387
|
schedulerEvent("babysitter.owner.merged", {
|
|
@@ -10541,6 +10592,19 @@ function createBabysitterRuntime(options) {
|
|
|
10541
10592
|
async function requiredCheckState(snapshot, signal, fold = false) {
|
|
10542
10593
|
return (await requiredCheckEvaluation(snapshot, signal, fold))?.state ?? "unknown";
|
|
10543
10594
|
}
|
|
10595
|
+
async function cancelledRequiredCheck(snapshot, signal) {
|
|
10596
|
+
if (checksStillRunning(snapshot, Date.now(), waitPolicy)) return false;
|
|
10597
|
+
return (await requiredCheckEvaluation(snapshot, signal))?.checks.some((check) => check.cancelled) ?? false;
|
|
10598
|
+
}
|
|
10599
|
+
async function ownRepairFailed(snapshot, signal) {
|
|
10600
|
+
if (!snapshot.hostHeads?.some((entry) => entry.repair && entry.head === snapshot.pr?.head?.sha)) return false;
|
|
10601
|
+
const failures = failedSignals(snapshot);
|
|
10602
|
+
if (!failures.length) return false;
|
|
10603
|
+
const required = snapshot.pr?.base?.ref ? (await requiredCheckPolicy(snapshot)).required : [];
|
|
10604
|
+
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)));
|
|
10605
|
+
if (!candidates.length) return false;
|
|
10606
|
+
return !unrelatedFailureWait(await failureCauses(snapshot, signal, candidates, true), snapshot.pr?.base?.ref ?? "the base");
|
|
10607
|
+
}
|
|
10544
10608
|
async function hasRepairableActionsFailure(snapshot, signal) {
|
|
10545
10609
|
if (!failedOwnActions(snapshot, waitPolicy.pendingReviewChecks).length || await requiredCheckState(snapshot, signal) !== "failed") return false;
|
|
10546
10610
|
return !unrelatedFailureWait(await failureCauses(snapshot, signal), snapshot.pr?.base?.ref ?? "the base");
|
|
@@ -10738,6 +10802,7 @@ function createBabysitterRuntime(options) {
|
|
|
10738
10802
|
if ((await pullRequestInbox.metaNumber(recoveryKey) ?? 0) > Date.now()) continue;
|
|
10739
10803
|
signal.throwIfAborted();
|
|
10740
10804
|
await pullRequestInbox.setMeta(recoveryKey, Date.now() + 6e5, signal);
|
|
10805
|
+
if (await ownRepairFailed(snapshot, signal)) continue;
|
|
10741
10806
|
signal.throwIfAborted();
|
|
10742
10807
|
if (await pullRequestInbox.wake(snapshot, `ci-recovery:${head}`, {
|
|
10743
10808
|
recovery: true,
|
|
@@ -10779,7 +10844,7 @@ function createBabysitterRuntime(options) {
|
|
|
10779
10844
|
const held = new Set(Array.isArray(saved) ? saved.filter((item) => hasRuntimeType(item, "string")) : []);
|
|
10780
10845
|
return new Set(snapshot.threads.filter((thread) => thread.isResolved !== true).map((thread) => String(thread.node_id ?? thread.id)).filter((id) => held.has(id)));
|
|
10781
10846
|
}
|
|
10782
|
-
/**
|
|
10847
|
+
/** Retests deferred checks on a fixed base, or wakes a parked PR when its new events need work. */
|
|
10783
10848
|
async function evaluateWaits(step, signal) {
|
|
10784
10849
|
signal.throwIfAborted();
|
|
10785
10850
|
for (const snapshot of await pullRequestInbox.waitsToEvaluate(true, true)) {
|
|
@@ -10790,10 +10855,11 @@ function createBabysitterRuntime(options) {
|
|
|
10790
10855
|
const checkSignal = AbortSignal.any([signal, AbortSignal.timeout(12e4)]);
|
|
10791
10856
|
const checks = await requiredCheckState(snapshot, checkSignal);
|
|
10792
10857
|
signal.throwIfAborted();
|
|
10858
|
+
const repairOwnPush = snapshot.wait?.defer === "checks" && snapshot.wait.headSha === snapshot.pr?.head?.sha && await ownRepairFailed(snapshot, checkSignal);
|
|
10793
10859
|
let reasons = wakeReasons(snapshot, checks, {
|
|
10794
10860
|
...waitPolicy,
|
|
10795
10861
|
heldThreads: await heldOpenThreads(snapshot)
|
|
10796
|
-
});
|
|
10862
|
+
}, repairOwnPush);
|
|
10797
10863
|
signal.throwIfAborted();
|
|
10798
10864
|
if (parentMerged) reasons.push("stack-parent-merged");
|
|
10799
10865
|
if (snapshot.wait?.reason === "non-default-base" && snapshot.pr && !nonDefaultBase(snapshot.pr)) reasons.push("base-retargeted");
|
|
@@ -10821,11 +10887,13 @@ function createBabysitterRuntime(options) {
|
|
|
10821
10887
|
repository: snapshot.repository
|
|
10822
10888
|
};
|
|
10823
10889
|
if (!reasons.length) {
|
|
10890
|
+
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
10891
|
await pullRequestInbox.acknowledgeWait(snapshot, signal);
|
|
10825
10892
|
schedulerEvent("babysitter.wait.kept", {
|
|
10826
10893
|
...owner,
|
|
10827
10894
|
head_sha: snapshot.pr?.head?.sha,
|
|
10828
|
-
avoided_invocation: true
|
|
10895
|
+
avoided_invocation: true,
|
|
10896
|
+
...retested && { reason: "retest-on-current-base" }
|
|
10829
10897
|
});
|
|
10830
10898
|
} else if (await pullRequestInbox.wake(snapshot, `evaluated:${snapshot.generation}:${snapshot.revision ?? 0}`, { signal })) schedulerEvent("babysitter.wait.woken", {
|
|
10831
10899
|
...owner,
|
|
@@ -11268,6 +11336,7 @@ function createBabysitterRuntime(options) {
|
|
|
11268
11336
|
});
|
|
11269
11337
|
const passController = new AbortController();
|
|
11270
11338
|
let evidenceChanged;
|
|
11339
|
+
let evidenceChanges;
|
|
11271
11340
|
const passSignal = AbortSignal.any([AbortSignal.timeout(36e5), passController.signal]);
|
|
11272
11341
|
let providerDirectory;
|
|
11273
11342
|
let conflictWork;
|
|
@@ -11301,7 +11370,7 @@ function createBabysitterRuntime(options) {
|
|
|
11301
11370
|
modelWorkParked = true;
|
|
11302
11371
|
outcome = "waiting";
|
|
11303
11372
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11304
|
-
text: providerBlocked ? `CI reconciliation completed; provider quota cooldown ends at ${new Date(providerBlockedUntil).toISOString()}.` : admitted ?
|
|
11373
|
+
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
11374
|
...pushedHead ? {
|
|
11306
11375
|
progress: pushProgress(pushedHead, reviewDrivenPush()),
|
|
11307
11376
|
verifiedPushHeads: [...verifiedPushHeads]
|
|
@@ -11435,13 +11504,15 @@ function createBabysitterRuntime(options) {
|
|
|
11435
11504
|
* Parks the claim before its first model dispatch when `dailyPassBudget` passes started in the
|
|
11436
11505
|
* last 24 hours, until the oldest leaves the window. Exempt work still gets a pass.
|
|
11437
11506
|
*/
|
|
11438
|
-
const parkSpentDailyPassBudget = async () => {
|
|
11507
|
+
const parkSpentDailyPassBudget = async (observed) => {
|
|
11439
11508
|
if (modelDispatched || pushedHead || dailyPassBudget === false) return false;
|
|
11509
|
+
dailyPassExemptionUsed = void 0;
|
|
11510
|
+
const snapshot = observed ?? inboxClaim.snapshot;
|
|
11440
11511
|
const now = Date.now();
|
|
11441
|
-
const budget = (await pullRequestInbox.get(repository, number))?.dailyPassBudget;
|
|
11512
|
+
const budget = observed ? observed.dailyPassBudget : (await pullRequestInbox.get(repository, number))?.dailyPassBudget;
|
|
11442
11513
|
const resumeAt = dailyPassResumeAt(budget, dailyPassBudget, now);
|
|
11443
11514
|
if (resumeAt === void 0) return false;
|
|
11444
|
-
if (pullRequestInbox.isPriority(
|
|
11515
|
+
if (pullRequestInbox.isPriority(snapshot.pr)) {
|
|
11445
11516
|
schedulerEvent("babysitter.daily_pass_budget.exempt", {
|
|
11446
11517
|
...owner,
|
|
11447
11518
|
head_sha: inboxClaim.snapshot.pr?.head?.sha,
|
|
@@ -11449,9 +11520,8 @@ function createBabysitterRuntime(options) {
|
|
|
11449
11520
|
});
|
|
11450
11521
|
return false;
|
|
11451
11522
|
}
|
|
11452
|
-
const requiredChecks = await requiredCheckState(
|
|
11453
|
-
const
|
|
11454
|
-
const exemption = dailyPassExemption(inboxClaim.snapshot, requiredChecks, budget, openPushWindow);
|
|
11523
|
+
const requiredChecks = await requiredCheckState(snapshot);
|
|
11524
|
+
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
11525
|
if (exemption) {
|
|
11456
11526
|
dailyPassExemptionUsed = exemption;
|
|
11457
11527
|
schedulerEvent("babysitter.daily_pass_budget.exempt", {
|
|
@@ -11464,10 +11534,14 @@ function createBabysitterRuntime(options) {
|
|
|
11464
11534
|
modelWorkParked = true;
|
|
11465
11535
|
outcome = "waiting";
|
|
11466
11536
|
const passes = budget?.passes.filter((at) => at > now - 864e5).length ?? 0;
|
|
11467
|
-
await pullRequestInbox.finish(
|
|
11537
|
+
await pullRequestInbox.finish({
|
|
11538
|
+
...inboxClaim,
|
|
11539
|
+
snapshot,
|
|
11540
|
+
generation: snapshot.generation
|
|
11541
|
+
}, {
|
|
11468
11542
|
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
11543
|
wait: {
|
|
11470
|
-
...createCheckWait(
|
|
11544
|
+
...createCheckWait(snapshot, waitPolicy),
|
|
11471
11545
|
reason: "daily-pass-budget",
|
|
11472
11546
|
retryAt: resumeAt
|
|
11473
11547
|
}
|
|
@@ -11630,7 +11704,8 @@ function createBabysitterRuntime(options) {
|
|
|
11630
11704
|
return;
|
|
11631
11705
|
}
|
|
11632
11706
|
}
|
|
11633
|
-
|
|
11707
|
+
const repairOwnPush = await ownRepairFailed(inboxClaim.snapshot, passSignal);
|
|
11708
|
+
if (merge.mode === "direct" && !repairOwnPush && await retestOnCurrentBase(inboxClaim.snapshot, owner, passSignal)) {
|
|
11634
11709
|
outcome = "waiting";
|
|
11635
11710
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11636
11711
|
text: inboxClaim.snapshot.lastResult || `Updated the branch with ${inboxClaim.snapshot.pr?.base?.ref} to retest its failed checks on the current base.`,
|
|
@@ -11644,7 +11719,21 @@ function createBabysitterRuntime(options) {
|
|
|
11644
11719
|
});
|
|
11645
11720
|
return;
|
|
11646
11721
|
}
|
|
11647
|
-
|
|
11722
|
+
if (merge.mode === "direct" && !repairOwnPush && await cancelledRequiredCheck(inboxClaim.snapshot, passSignal) && await retestInfrastructureFailure(inboxClaim.snapshot, owner, passSignal, "cancelled")) {
|
|
11723
|
+
outcome = "waiting";
|
|
11724
|
+
await pullRequestInbox.finish(inboxClaim, {
|
|
11725
|
+
text: `A required check was cancelled. Updated the branch with ${inboxClaim.snapshot.pr?.base?.ref} for a fresh CI run.`,
|
|
11726
|
+
wait: createCheckWait(inboxClaim.snapshot, waitPolicy)
|
|
11727
|
+
});
|
|
11728
|
+
schedulerEvent("babysitter.wait.kept", {
|
|
11729
|
+
...owner,
|
|
11730
|
+
head_sha: inboxClaim.snapshot.pr?.head?.sha,
|
|
11731
|
+
avoided_invocation: true,
|
|
11732
|
+
reason: "cancelled-check-retest"
|
|
11733
|
+
});
|
|
11734
|
+
return;
|
|
11735
|
+
}
|
|
11736
|
+
const deferral = repairOwnPush ? void 0 : await pendingGateDeferral(inboxClaim.snapshot);
|
|
11648
11737
|
if (deferral) {
|
|
11649
11738
|
await pullRequestInbox.finish(inboxClaim, {
|
|
11650
11739
|
text: inboxClaim.snapshot.lastResult || `Waiting for ${deferral} before the next pass.`,
|
|
@@ -11690,7 +11779,7 @@ function createBabysitterRuntime(options) {
|
|
|
11690
11779
|
await pullRequestInbox.release(inboxClaim);
|
|
11691
11780
|
return;
|
|
11692
11781
|
}
|
|
11693
|
-
const ciRecovery = ciRecoveryEnabled ? await rerunFailedActions(pullRequestInbox, inboxClaim, (await forge(repository, passSignal)).provider, Date.now(), passSignal) : void 0;
|
|
11782
|
+
const ciRecovery = ciRecoveryEnabled && !repairOwnPush ? await rerunFailedActions(pullRequestInbox, inboxClaim, (await forge(repository, passSignal)).provider, Date.now(), passSignal) : void 0;
|
|
11694
11783
|
if (inboxClaim.snapshot.recoveryHead && inboxClaim.snapshot.recoveryHead === inboxClaim.snapshot.pr?.head?.sha && !hasFailedActions(inboxClaim.snapshot)) {
|
|
11695
11784
|
outcome = "waiting";
|
|
11696
11785
|
const wait = createCheckWait(inboxClaim.snapshot, waitPolicy);
|
|
@@ -11848,6 +11937,13 @@ function createBabysitterRuntime(options) {
|
|
|
11848
11937
|
const abortSignal = AbortSignal.any([prepared.signal, passSignal]);
|
|
11849
11938
|
const repairOperation = new AsyncLocalStorage();
|
|
11850
11939
|
const ownedResolutions = /* @__PURE__ */ new Map();
|
|
11940
|
+
const metadataFields = ["title", "body"];
|
|
11941
|
+
const metadataWrites = /* @__PURE__ */ new Map();
|
|
11942
|
+
const ownsMetadata = (snapshot, field) => {
|
|
11943
|
+
const write = metadataWrites.get(field);
|
|
11944
|
+
const edit = snapshot.metadataEdits?.[field];
|
|
11945
|
+
return write && edit && edit.generation > write.after && edit.generation !== edit.externalGeneration && snapshot.pr?.[field] === write.value;
|
|
11946
|
+
};
|
|
11851
11947
|
const repairEvidenceKey = (snapshot, current = snapshot) => {
|
|
11852
11948
|
const published = !!pushedHead && verifiedPushHeads.has(pushedHead);
|
|
11853
11949
|
const original = published && snapshot === inboxClaim.snapshot;
|
|
@@ -11877,6 +11973,8 @@ function createBabysitterRuntime(options) {
|
|
|
11877
11973
|
} : thread),
|
|
11878
11974
|
pr: snapshot.pr && {
|
|
11879
11975
|
...snapshot.pr,
|
|
11976
|
+
title: ownsMetadata(snapshot, "title") ? inboxClaim.snapshot.pr?.title : snapshot.pr.title,
|
|
11977
|
+
body: ownsMetadata(snapshot, "body") ? inboxClaim.snapshot.pr?.body : snapshot.pr.body,
|
|
11880
11978
|
head: snapshot.pr.head && {
|
|
11881
11979
|
...snapshot.pr.head,
|
|
11882
11980
|
sha: published ? pullRequest.headRefOid : snapshot.pr.head.sha
|
|
@@ -11910,12 +12008,18 @@ function createBabysitterRuntime(options) {
|
|
|
11910
12008
|
pendingInboxHeads.add(pushedHead);
|
|
11911
12009
|
}
|
|
11912
12010
|
const selfHead = observedHead !== pullRequest.headRefOid && verifiedPushHeads.has(observedHead ?? "");
|
|
11913
|
-
|
|
12011
|
+
const sameHead = observedHead === pullRequest.headRefOid;
|
|
12012
|
+
const externalMetadata = metadataFields.some((field) => (current.metadataEdits?.[field]?.externalGeneration ?? 0) > inboxClaim.generation);
|
|
12013
|
+
if (current.generation !== inboxClaim.generation && (externalMetadata || !((selfHead || sameHead || repairOperation.getStore()) && repairEvidenceKey(current) === repairEvidenceKey(inboxClaim.snapshot, current)))) {
|
|
11914
12014
|
const changed = evidenceChanged ??= new DOMException("Pull request evidence changed.", "AbortError");
|
|
12015
|
+
evidenceChanges ??= changedEvidence(inboxClaim.snapshot, current);
|
|
11915
12016
|
schedulerEvent("babysitter.pass.evidence_changed", {
|
|
11916
12017
|
...owner,
|
|
11917
12018
|
head_sha: pullRequest.headRefOid,
|
|
11918
|
-
observed_head: observedHead
|
|
12019
|
+
observed_head: observedHead,
|
|
12020
|
+
claim_generation: inboxClaim.generation,
|
|
12021
|
+
generation: current.generation,
|
|
12022
|
+
changes: evidenceChanges
|
|
11919
12023
|
});
|
|
11920
12024
|
setTimeout(() => passController.abort(changed), 0);
|
|
11921
12025
|
throw changed;
|
|
@@ -12030,6 +12134,34 @@ function createBabysitterRuntime(options) {
|
|
|
12030
12134
|
mentionAllowlist: presetOptions.mentionAllowlist,
|
|
12031
12135
|
restrictCommentMentions: true,
|
|
12032
12136
|
commentPrefix: "<!-- vitehub-babysitter-repair:repair -->\n",
|
|
12137
|
+
sendMetadata: async (update, send) => {
|
|
12138
|
+
const current = await assertLease();
|
|
12139
|
+
const previous = new Map(metadataWrites);
|
|
12140
|
+
const writes = metadataFields.flatMap((field) => {
|
|
12141
|
+
const value = update[field];
|
|
12142
|
+
if (value === void 0 || value === current.pr?.[field]) return [];
|
|
12143
|
+
const write = {
|
|
12144
|
+
value,
|
|
12145
|
+
after: current.generation
|
|
12146
|
+
};
|
|
12147
|
+
metadataWrites.set(field, write);
|
|
12148
|
+
return [{
|
|
12149
|
+
field,
|
|
12150
|
+
write
|
|
12151
|
+
}];
|
|
12152
|
+
});
|
|
12153
|
+
try {
|
|
12154
|
+
await send();
|
|
12155
|
+
} catch (error) {
|
|
12156
|
+
for (const { field, write } of writes) {
|
|
12157
|
+
if (metadataWrites.get(field) !== write) continue;
|
|
12158
|
+
const prior = previous.get(field);
|
|
12159
|
+
if (prior) metadataWrites.set(field, prior);
|
|
12160
|
+
else metadataWrites.delete(field);
|
|
12161
|
+
}
|
|
12162
|
+
throw error;
|
|
12163
|
+
}
|
|
12164
|
+
},
|
|
12033
12165
|
signal: abortSignal,
|
|
12034
12166
|
autoMerge: merge.mode === "auto" && stackParent === void 0,
|
|
12035
12167
|
eligible: async (current) => await eligibleNow(repository, normalizePullRequest(current), await pullRequestInbox.get(repository, number), abortSignal),
|
|
@@ -12448,14 +12580,18 @@ function createBabysitterRuntime(options) {
|
|
|
12448
12580
|
if (workerSettings.sandbox && await parkBlockedModelWork()) throw new DOMException("Provider dispatch is waiting for admission.", "AbortError");
|
|
12449
12581
|
await acquireModelSlot(abortSignal, `${repository}#${number}`);
|
|
12450
12582
|
try {
|
|
12451
|
-
|
|
12583
|
+
while (!modelDispatched && dailyPassBudget !== false) {
|
|
12584
|
+
const observed = await assertLease();
|
|
12585
|
+
if (await parkSpentDailyPassBudget(observed)) throw new DOMException("Provider dispatch is waiting for its daily pass budget.", "AbortError");
|
|
12452
12586
|
const exemption = dailyPassExemptionUsed === "human-feedback" ? void 0 : dailyPassExemptionUsed;
|
|
12453
|
-
const recorded = await pullRequestInbox.recordModelPass(inboxClaim, exemption);
|
|
12454
|
-
if (
|
|
12587
|
+
const recorded = await pullRequestInbox.recordModelPass(inboxClaim, exemption, observed);
|
|
12588
|
+
if (recorded === "changed") continue;
|
|
12589
|
+
if (!recorded) throw new DOMException("Provider dispatch lost its inbox lease.", "AbortError");
|
|
12455
12590
|
recordedPass = {
|
|
12456
12591
|
at: recorded,
|
|
12457
12592
|
exemption
|
|
12458
12593
|
};
|
|
12594
|
+
break;
|
|
12459
12595
|
}
|
|
12460
12596
|
await assertLease();
|
|
12461
12597
|
modelDispatched = true;
|
|
@@ -12542,7 +12678,10 @@ function createBabysitterRuntime(options) {
|
|
|
12542
12678
|
recorded = await pullRequestInbox.finish(inboxClaim, {
|
|
12543
12679
|
text: resultText,
|
|
12544
12680
|
progress: { kind: "no-progress" },
|
|
12545
|
-
wait:
|
|
12681
|
+
wait: {
|
|
12682
|
+
...await externalWait(inboxClaim.snapshot, passResult.wait.wake, passResult.wait.reason),
|
|
12683
|
+
headSha: pullRequest.headRefOid
|
|
12684
|
+
}
|
|
12546
12685
|
});
|
|
12547
12686
|
} 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
12687
|
outcome = "waiting";
|
|
@@ -12641,6 +12780,8 @@ function createBabysitterRuntime(options) {
|
|
|
12641
12780
|
});
|
|
12642
12781
|
schedulerEvent("babysitter.owner.cancelled", {
|
|
12643
12782
|
reason: "pull-request-state-changed-or-aborted",
|
|
12783
|
+
cause: (error instanceof Error ? error.message : String(error)).slice(0, 200),
|
|
12784
|
+
...evidenceChanges ? { evidence_changes: evidenceChanges } : {},
|
|
12644
12785
|
...owner
|
|
12645
12786
|
});
|
|
12646
12787
|
} else if (error instanceof RateLimitedError) {
|
|
@@ -12772,4 +12913,4 @@ function withoutCapacity(driver) {
|
|
|
12772
12913
|
const { capacity: _capacity, ...rest } = driver;
|
|
12773
12914
|
return rest;
|
|
12774
12915
|
}
|
|
12775
|
-
export { budgetParks as a, createGitHubHost as c,
|
|
12916
|
+
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/presets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Ready-made Agents built from ViteHub primitives: Babysitter, Labeller, and the workspace preset.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@vite-hub/forge": "0.
|
|
62
|
-
"@vite-hub/gateways": "0.
|
|
63
|
-
"@vite-hub/runtime": "0.
|
|
64
|
-
"@vite-hub/sandbox": "0.
|
|
65
|
-
"@vite-hub/workspace": "0.
|
|
61
|
+
"@vite-hub/forge": "0.8.0",
|
|
62
|
+
"@vite-hub/gateways": "0.8.0",
|
|
63
|
+
"@vite-hub/runtime": "0.8.0",
|
|
64
|
+
"@vite-hub/sandbox": "0.8.0",
|
|
65
|
+
"@vite-hub/workspace": "0.8.0",
|
|
66
66
|
"@yarnpkg/parsers": "3.1.0",
|
|
67
67
|
"comark": "^0.9.2",
|
|
68
68
|
"nostics": "1.4.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
75
75
|
"@t3tools/provider-runtime": "https://pkg.pr.new/vite-hub/t3code/@t3tools/provider-runtime@1ee7ef6",
|
|
76
76
|
"@types/node": "^24.19.2",
|
|
77
|
-
"@vite-hub/agent": "0.
|
|
77
|
+
"@vite-hub/agent": "0.8.0",
|
|
78
78
|
"@vite-hub/internal": "0.0.1",
|
|
79
79
|
"publint": "^0.3.25",
|
|
80
80
|
"typescript": "^6.0.3",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"vitest": "5.1.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@vite-hub/agent": "0.
|
|
85
|
+
"@vite-hub/agent": "0.8.0"
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=24.15.0"
|