@bridge_gpt/mcp-server 0.2.76 → 0.2.77
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/README.md +8 -6
- package/build/agents.generated.js +3 -3
- package/build/cli-dispatch.js +333 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +52 -7
- package/build/conductor/declare-blocked.js +142 -7
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +11 -7
- package/build/conductor/epic-server-journal.js +39 -22
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +1 -1
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/recovery-cli.js +2 -0
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +223 -6
- package/build/engine-paths.js +10 -0
- package/build/epic-coherence-input-cli.js +105 -10
- package/build/epic-coherence-input.js +877 -4
- package/build/epic-coherence-input.test-fixtures.js +117 -0
- package/build/epic-implementer-bin.js +901 -94
- package/build/epic-implementer-env.js +2 -2
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/job-runner.js +83 -27
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/provider-checks.js +73 -0
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +82 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +27 -1
- package/build/index.js +2449 -386
- package/build/install-bridge-conductor-assessment.js +13 -0
- package/build/install-bridge-conductor.js +60 -776
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/pipelines.generated.js +45 -17
- package/build/plan-execution-ledger.js +8 -0
- package/build/plan-generation.js +34 -0
- package/build/plane/build-freshness.js +6 -0
- package/build/plane/cli.js +12 -5
- package/build/printed-remedy-commands.js +9 -0
- package/build/readiness-prerequisites.generated.js +28 -0
- package/build/readme.generated.js +1 -1
- package/build/run-unit-tests-launcher.js +3 -1
- package/build/server.js +7946 -0
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/module-imports.js +155 -0
- package/build/test-support/server-client.js +96 -0
- package/build/test-support/stdio-server.js +146 -0
- package/build/v2-readiness-requirements.js +31 -2
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER.md +71 -2
- package/docs/epic-implementer/getting-started.md +4 -0
- package/package.json +3 -3
- package/pipelines/learn-repository.json +19 -1
|
@@ -51,8 +51,8 @@ const renamed = (suffix) => [
|
|
|
51
51
|
* `mcp_server/src/**\/*.ts` at HEAD `45d854081` (re-confirmed at `315572187`).
|
|
52
52
|
*
|
|
53
53
|
* Deliberately absent: `PUBLISHED_IDENTITY_FIXTURE` (removed from source), the
|
|
54
|
-
* retired `LLM_*` names (
|
|
55
|
-
*
|
|
54
|
+
* retired `LLM_*` names (the supervisor judgment they configured was removed), and
|
|
55
|
+
* test-only sentinels. All of
|
|
56
56
|
* those still fall through to the generic prefix pointer.
|
|
57
57
|
*
|
|
58
58
|
* These 37 prefix-derived suffixes are distinct from the three BAPI-1237
|
|
@@ -452,7 +452,7 @@ export function successRefusalReason(envelope) {
|
|
|
452
452
|
* order as the server's `derive_park_cause`; the server re-derives it and never
|
|
453
453
|
* lets this value widen what the rest of the envelope proves.
|
|
454
454
|
*/
|
|
455
|
-
export function deriveCompletionCause(envelope) {
|
|
455
|
+
export function deriveCompletionCause(envelope, options = {}) {
|
|
456
456
|
const reasons = new Set(envelope.insufficient_reasons);
|
|
457
457
|
if (reasons.has("unsupported_runtime"))
|
|
458
458
|
return "unsupported_completion_evidence";
|
|
@@ -485,6 +485,19 @@ export function deriveCompletionCause(envelope) {
|
|
|
485
485
|
return "verification_runner_unavailable";
|
|
486
486
|
if (envelope.verification === "failed")
|
|
487
487
|
return "required_check_failed";
|
|
488
|
+
// BAPI-1779 rank 7 — a covered job that ran out of time before finalization
|
|
489
|
+
// finished is unfinished required work, so the existing required-work park
|
|
490
|
+
// and its automatic continuation take it. Only the claimed job type decides:
|
|
491
|
+
// a missing type, `rebase` (a renewal-mode rebase also carries completion
|
|
492
|
+
// evidence) and `merge` never activate it. The server re-derives this with the
|
|
493
|
+
// job row's own type, so an older executor's `null` cause is fixed there.
|
|
494
|
+
if (typeof options.jobType === "string" &&
|
|
495
|
+
isCoveredJobType(options.jobType) &&
|
|
496
|
+
envelope.end_cause === "job_timeout" &&
|
|
497
|
+
envelope.finalization !== "ok" &&
|
|
498
|
+
envelope.finalization !== "not_required") {
|
|
499
|
+
return "required_work_incomplete";
|
|
500
|
+
}
|
|
488
501
|
// Nothing completion-specific is wrong: an unmet finalization (or success)
|
|
489
502
|
// keeps its existing executor/server classification.
|
|
490
503
|
return null;
|
|
@@ -2,6 +2,30 @@ export const PUSH_TIMEOUT_MS = 180_000;
|
|
|
2
2
|
export const PUSH_AUTH_FAILURE_RE = /authentication failed|could not read username|permission denied|terminal prompts disabled|invalid username or password|returned error: 403|requested url returned error: 401/i;
|
|
3
3
|
const PUSH_LEASE_FAILURE_RE = /stale info|\[rejected\]|non-fast-forward|fetch first/i;
|
|
4
4
|
const SHA = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i;
|
|
5
|
+
/**
|
|
6
|
+
* The ONE lease expression the executor builds (BAPI-1686): create-only leaves
|
|
7
|
+
* the expected value empty, otherwise the remote ref must hold exactly `baseSha`.
|
|
8
|
+
* `guardedFastForwardPush` pushes `HEAD`; BAPI-1781's rename-aside pushes an
|
|
9
|
+
* exact SHA through {@link leasedRefPushArgs}. There is no unleased variant.
|
|
10
|
+
*/
|
|
11
|
+
function leasedPushArgv(destination, creating, baseSha, source) {
|
|
12
|
+
return ["push", "--no-verify", "--porcelain",
|
|
13
|
+
`--force-with-lease=${destination}:${creating ? "" : baseSha}`, "origin", `${source}:${destination}`];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* BAPI-1781 — a rename-aside's leased push: the create-only backup
|
|
17
|
+
* (`expected === ""`) or the move of an ended run's branch (`expected` = the
|
|
18
|
+
* exact old tip). Returns `null` unless `sha` and a non-empty `expected` are full
|
|
19
|
+
* 40-hex SHAs and `ref` is a safe branch name.
|
|
20
|
+
*/
|
|
21
|
+
export function leasedRefPushArgs(sha, ref, expected) {
|
|
22
|
+
const full = /^[0-9a-f]{40}$/;
|
|
23
|
+
if (!full.test(sha) || (expected !== "" && !full.test(expected)))
|
|
24
|
+
return null;
|
|
25
|
+
if (!isSafePublicationBranch(ref))
|
|
26
|
+
return null;
|
|
27
|
+
return leasedPushArgv(`refs/heads/${ref}`, expected === "", expected, sha);
|
|
28
|
+
}
|
|
5
29
|
export function isSafePublicationBranch(branch) {
|
|
6
30
|
return branch.length > 0 && !branch.startsWith("-") && !branch.startsWith("/") &&
|
|
7
31
|
!branch.endsWith("/") && !branch.endsWith(".") && branch !== "@" &&
|
|
@@ -109,8 +133,7 @@ export async function guardedFastForwardPush(input) {
|
|
|
109
133
|
if ((!input.mayMutate() || input.signal?.aborted) || input.remainingMs() <= 0)
|
|
110
134
|
return refuse("timeout");
|
|
111
135
|
const destination = `refs/heads/${input.branch}`;
|
|
112
|
-
const push = await git(
|
|
113
|
-
`--force-with-lease=${destination}:${creating ? "" : baseSha}`, "origin", `HEAD:${destination}`]);
|
|
136
|
+
const push = await git(leasedPushArgv(destination, creating, baseSha, "HEAD"));
|
|
114
137
|
const text = `${push.stdout}\n${push.stderr}`;
|
|
115
138
|
if (timedOut || push.exitCode === 124 || /timed out|timeout/i.test(text))
|
|
116
139
|
return refuse("timeout");
|
|
@@ -82,7 +82,7 @@ import { CI_FIX_JOB_TYPE, renderCiFixOperatorNote, renderLocalEnvironmentLimits,
|
|
|
82
82
|
import { CORRECTION_INTENT_CAPABILITY, isRemainingWork, validateCorrectionIntent, } from "./correction-dispatch.js";
|
|
83
83
|
import { collectGitTelemetry, collectRemoteTrackingSha, createMcpSurfaceObserver, evaluatePreSpawnGitVerification, formatWorkerRateLimitAdvisory, normalizeMcpServerNames, } from "./observation.js";
|
|
84
84
|
import { failureReasonCode, isFailureReasonCode } from "./failure-reason-codes.js";
|
|
85
|
-
import { readCustomizedCommands, TERMINAL_CAPACITY_PROTOCOL_VERSIONS, TERMINAL_CAPACITY_RUNTIME_CONTRACTS, TERMINAL_CAPACITY_RUNTIMES, } from "./types.js";
|
|
85
|
+
import { parseRenameAsidePlan, readCustomizedCommands, RENAME_ASIDE_PLAN_PAYLOAD_KEY, RENAME_ASIDE_RESULT_KEY, TERMINAL_CAPACITY_PROTOCOL_VERSIONS, TERMINAL_CAPACITY_RUNTIME_CONTRACTS, TERMINAL_CAPACITY_RUNTIMES, } from "./types.js";
|
|
86
86
|
import { resolvePackagedRecipes } from "./packaged-recipe.js";
|
|
87
87
|
import { recordObservedPr, recordVerificationFacts, recordVerificationObservation, withDeliveryObservations, } from "./delivery-observations.js";
|
|
88
88
|
import { probeInstalledCorrectionHook } from "./preflight.js";
|
|
@@ -1107,6 +1107,50 @@ function readFencedResumeHead(payload) {
|
|
|
1107
1107
|
const head = raw.trim().toLowerCase();
|
|
1108
1108
|
return /^[0-9a-f]{40}$/.test(head) ? head : null;
|
|
1109
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* BAPI-1781: the server's rename-aside plan, validated at the payload boundary and
|
|
1112
|
+
* bound to the job's claimed branch, for a fresh `implement`/`spec_review` only.
|
|
1113
|
+
* Absent or malformed degrades to `null`: the ordinary stale-branch guard applies.
|
|
1114
|
+
*/
|
|
1115
|
+
export function readRenameAsidePlan(job) {
|
|
1116
|
+
if (job.job_type !== "implement" && job.job_type !== "spec_review")
|
|
1117
|
+
return null;
|
|
1118
|
+
if (!job.payload || typeof job.payload !== "object")
|
|
1119
|
+
return null;
|
|
1120
|
+
const raw = job.payload[RENAME_ASIDE_PLAN_PAYLOAD_KEY];
|
|
1121
|
+
if (raw === undefined || raw === null)
|
|
1122
|
+
return null;
|
|
1123
|
+
const branch = resolveExecutorBranch(job);
|
|
1124
|
+
if (!branch.ok)
|
|
1125
|
+
return null;
|
|
1126
|
+
return parseRenameAsidePlan(raw, branch.branch);
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* BAPI-1781: a client view whose `complete` carries the executor-owned
|
|
1130
|
+
* rename-aside confirmation as `result.rename_aside`, set last so worker-authored
|
|
1131
|
+
* result data cannot replace it. `fail` and every other call are unchanged, so a
|
|
1132
|
+
* failed job never claims a confirmation.
|
|
1133
|
+
*/
|
|
1134
|
+
export function withRenameAsideConfirmation(client, confirmation) {
|
|
1135
|
+
const confirmed = {
|
|
1136
|
+
old_branch: confirmation.old_branch,
|
|
1137
|
+
backup_name: confirmation.backup_name,
|
|
1138
|
+
old_run_id: confirmation.old_run_id,
|
|
1139
|
+
short_sha: confirmation.short_sha,
|
|
1140
|
+
};
|
|
1141
|
+
return new Proxy(client, {
|
|
1142
|
+
get(target, property, receiver) {
|
|
1143
|
+
if (property === "complete") {
|
|
1144
|
+
return (job, completion) => target.complete(job, {
|
|
1145
|
+
...completion,
|
|
1146
|
+
result: { ...completion.result, [RENAME_ASIDE_RESULT_KEY]: confirmed },
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
const value = Reflect.get(target, property, receiver);
|
|
1150
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
1151
|
+
},
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1110
1154
|
/**
|
|
1111
1155
|
* Prepare a job's worktree. A job the server dispatched as a parked-child
|
|
1112
1156
|
* CONTINUATION (BAPI-1300; `payload.continuation.retained_worktree === true`)
|
|
@@ -1358,6 +1402,9 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1358
1402
|
// BAPI-1530: forwarded separately from the claim's prior-attempt head so
|
|
1359
1403
|
// same-row retry preservation keeps its own semantics.
|
|
1360
1404
|
...(readFencedResumeHead(job.payload) ? { fencedImplementResumeHeadSha: readFencedResumeHead(job.payload) } : {}),
|
|
1405
|
+
// BAPI-1781: the server's dispatch-time rename-aside plan (fresh implement and
|
|
1406
|
+
// spec_review only). Spread only when present so other jobs keep their policy.
|
|
1407
|
+
...(!reuseExistingBranch && readRenameAsidePlan(job) ? { renameAsidePlan: readRenameAsidePlan(job) } : {}),
|
|
1361
1408
|
});
|
|
1362
1409
|
if (!wt.ok) {
|
|
1363
1410
|
await httpClient.fail(job, jobWorktreeFailure(wt));
|
|
@@ -1379,6 +1426,7 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1379
1426
|
...(wt.publication ? { publication: wt.publication } : {}),
|
|
1380
1427
|
...(wt.priorWork ? { priorWork: wt.priorWork } : {}),
|
|
1381
1428
|
...(focusedRebase ? { focusedRebase } : {}),
|
|
1429
|
+
...("renameAside" in wt && wt.renameAside ? { renameAside: wt.renameAside } : {}),
|
|
1382
1430
|
};
|
|
1383
1431
|
}
|
|
1384
1432
|
// No explicit/synthesized prompt: render the structured `payload.prompt_spec`
|
|
@@ -1403,6 +1451,7 @@ async function prepareSpawn(job, httpClient, options, deps, seams, preparation)
|
|
|
1403
1451
|
expectedHeadSha: wt.expectedHeadSha,
|
|
1404
1452
|
...(wt.publication ? { publication: wt.publication } : {}),
|
|
1405
1453
|
...(wt.priorWork ? { priorWork: wt.priorWork } : {}),
|
|
1454
|
+
...("renameAside" in wt && wt.renameAside ? { renameAside: wt.renameAside } : {}),
|
|
1406
1455
|
};
|
|
1407
1456
|
}
|
|
1408
1457
|
catch (err) {
|
|
@@ -1643,9 +1692,11 @@ async function readFocusedRebaseStartTip(deps, worktreePath, branch, remainingMs
|
|
|
1643
1692
|
* BAPI-1311 — run the focused rebase's post-push wait and, unless it is `ready`,
|
|
1644
1693
|
* report the job's ONE terminal outcome.
|
|
1645
1694
|
*
|
|
1646
|
-
* Returns `null` when the wait is `ready
|
|
1647
|
-
*
|
|
1648
|
-
*
|
|
1695
|
+
* Returns `null` when the wait is `ready` — including BAPI-1780's CI-deferred
|
|
1696
|
+
* `ready` (verified push, required checks still pending with none failed): the
|
|
1697
|
+
* caller then submits the ordinary `/complete` exactly once, and the server's
|
|
1698
|
+
* completion verifier re-reads the provider as the final authority. Every other
|
|
1699
|
+
* ending is reported here, once:
|
|
1649
1700
|
*
|
|
1650
1701
|
* - a PROVEN failure (red required check, closed or conflicting pull request, a
|
|
1651
1702
|
* moved number/head/head branch/base) → `ContractError.RebaseNotVerified`, the
|
|
@@ -1715,7 +1766,6 @@ async function superviseFocusedRebaseWait(params) {
|
|
|
1715
1766
|
expectedBaseBranch: params.expectedBaseBranch,
|
|
1716
1767
|
readPullRequest: (timeoutMs) => readFocusedPullRequest(deps.runCommand, params.worktreePath, params.context.prNumber, { timeoutMs }),
|
|
1717
1768
|
pollChecks,
|
|
1718
|
-
...(params.readDelivery ? { readDelivery: params.readDelivery } : {}),
|
|
1719
1769
|
now: deps.now,
|
|
1720
1770
|
sleep: deps.sleep,
|
|
1721
1771
|
signal,
|
|
@@ -2191,6 +2241,10 @@ resolvedTimeoutSeconds) {
|
|
|
2191
2241
|
prep = await prepareSpawn(job, httpClient, jobOptions, deps, seams);
|
|
2192
2242
|
if (!prep.ok)
|
|
2193
2243
|
return prep.result;
|
|
2244
|
+
// BAPI-1781: from here every successful `/complete` for this job carries the
|
|
2245
|
+
// executor-owned rename-aside confirmation; failures never do.
|
|
2246
|
+
if (prep.renameAside)
|
|
2247
|
+
httpClient = withRenameAsideConfirmation(httpClient, prep.renameAside);
|
|
2194
2248
|
deps = executionDeps;
|
|
2195
2249
|
if (preparation)
|
|
2196
2250
|
prep = { ...prep, deadlineMs: deps.now() + preparation.remainingMs() };
|
|
@@ -4245,21 +4299,29 @@ async function runPreparedSpawn(params) {
|
|
|
4245
4299
|
// exited cleanly and finalization PROVED its push is the origin tip, so what
|
|
4246
4300
|
// remains is evidence the server's completion verifier will read: the bound
|
|
4247
4301
|
// pull request at that head, mergeable, with its effective required checks
|
|
4248
|
-
// green
|
|
4249
|
-
//
|
|
4250
|
-
//
|
|
4251
|
-
//
|
|
4302
|
+
// green — or pending with none failed (DEFERRED CI below). The wait runs under
|
|
4303
|
+
// the SAME claim, heartbeat, dead-man, and timeout supervision a worker gets,
|
|
4304
|
+
// bounded by the job's ORIGINAL absolute deadline. It launches no worker,
|
|
4305
|
+
// enqueues nothing, and resets nothing: a pending check is never repaired
|
|
4306
|
+
// again. Only `ready` reaches `/complete`, once.
|
|
4252
4307
|
//
|
|
4253
|
-
//
|
|
4254
|
-
// exactly once below and leaving the server's completion
|
|
4255
|
-
// delivery guard as the authority:
|
|
4256
|
-
// - NO PUSH: the verified origin tip equals the tip recorded
|
|
4257
|
-
// so the worker only renewed evidence. Skip the
|
|
4258
|
-
// - DEFERRED CI: the wait
|
|
4259
|
-
//
|
|
4260
|
-
//
|
|
4261
|
-
//
|
|
4262
|
-
//
|
|
4308
|
+
// Two narrower successful ends, both still submitting the ordinary
|
|
4309
|
+
// `/complete` exactly once below and leaving the server's completion
|
|
4310
|
+
// contract and delivery guard as the authority:
|
|
4311
|
+
// - NO PUSH (BAPI-1473): the verified origin tip equals the tip recorded
|
|
4312
|
+
// before launch, so the worker only renewed evidence. Skip the wait.
|
|
4313
|
+
// - DEFERRED CI (BAPI-1780): the wait ends `ready` with `ciDeferred` once
|
|
4314
|
+
// the push is verified (same open PR, at the pushed head, bound head
|
|
4315
|
+
// branch and base, mergeable) and the required checks at that head are
|
|
4316
|
+
// readably pending or absent with none concluded non-success. It no
|
|
4317
|
+
// longer asks the server for renewed delivery evidence. This is a
|
|
4318
|
+
// successful rebase awaiting CI, not green CI or delivery completion.
|
|
4319
|
+
// A missing or unverified push still refuses (`pushed_head_unverified`), a
|
|
4320
|
+
// lost claim still abandons with no terminal mutation, and red checks,
|
|
4321
|
+
// identity changes, conflicts, unresolved mergeability, and unavailable reads
|
|
4322
|
+
// still stop the wait. Neither end is merge behavior: the merge guard keeps
|
|
4323
|
+
// the child in `merging` until readiness is `complete`, which needs green
|
|
4324
|
+
// checks at the head.
|
|
4263
4325
|
const focusedRebasePushedNothing = prep.focusedRebase !== undefined &&
|
|
4264
4326
|
focusedRebaseStartTip !== null &&
|
|
4265
4327
|
typeof finalization.pushedHeadSha === "string" &&
|
|
@@ -4273,14 +4335,6 @@ async function runPreparedSpawn(params) {
|
|
|
4273
4335
|
job, httpClient, options, jobOptions, deps, ownership, observation, seams, control,
|
|
4274
4336
|
context: prep.focusedRebase,
|
|
4275
4337
|
pushedHeadSha: finalization.pushedHeadSha ?? null,
|
|
4276
|
-
readDelivery: () => readDeliveryOutcomeForFinalization({
|
|
4277
|
-
job,
|
|
4278
|
-
branch,
|
|
4279
|
-
deps,
|
|
4280
|
-
seams,
|
|
4281
|
-
remainingMs,
|
|
4282
|
-
resolvedBaseUrl: options.resolvedBaseUrl,
|
|
4283
|
-
}),
|
|
4284
4338
|
expectedBaseBranch: effectiveBaseBranch,
|
|
4285
4339
|
worktreePath,
|
|
4286
4340
|
jobDeadlineMs,
|
|
@@ -4632,6 +4686,7 @@ async function runCoveredAttempt(params) {
|
|
|
4632
4686
|
lifecycleSupported: true,
|
|
4633
4687
|
optionalWatchers: readOptionalWatchers(job.payload),
|
|
4634
4688
|
obligations,
|
|
4689
|
+
jobType: job.job_type,
|
|
4635
4690
|
});
|
|
4636
4691
|
// --- Ownership persisted BEFORE the spawn (BAPI-1504) ---------------------------
|
|
4637
4692
|
// A job stamped with `cleanup_report.v1` stores `NULL` ownership only if no worker
|
|
@@ -4974,6 +5029,7 @@ async function runCoveredAttempt(params) {
|
|
|
4974
5029
|
...(facts.prSatisfied ? [obligations[1]] : []),
|
|
4975
5030
|
],
|
|
4976
5031
|
...(facts.verificationFacts ? { verificationFacts: facts.verificationFacts } : {}),
|
|
5032
|
+
endCause: processEndCause,
|
|
4977
5033
|
}),
|
|
4978
5034
|
end_cause: processEndCause,
|
|
4979
5035
|
});
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import path from "node:path";
|
|
27
27
|
import { execFile } from "node:child_process";
|
|
28
28
|
import { normalizeDeclaredTouchedFiles } from "../conductor/file-scope-guard.js";
|
|
29
|
+
import { LANGUAGE_CATALOG } from "../language-catalog.generated.js";
|
|
29
30
|
import { containedKind, containedText, object, readVerificationHints, validReference, validRepoPath, MAX_OPTIONAL_JSON_BYTES, } from "./verification-hints.js";
|
|
30
31
|
export { validTestReference } from "./verification-hints.js";
|
|
31
32
|
export const RECENTLY_FAILED_TESTS_PATH = ".conductor/recently-failed-tests.json";
|
|
@@ -82,14 +83,85 @@ function nulPaths(output) {
|
|
|
82
83
|
return output.split("\0").filter(Boolean);
|
|
83
84
|
}
|
|
84
85
|
const ordinal = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
86
|
+
const NAME_KINDS = new Set(["basename", "basename_prefix", "basename_suffix"]);
|
|
87
|
+
/**
|
|
88
|
+
* Python's `str.strip()` whitespace set. It adds U+001C-U+001F and U+0085 to, and
|
|
89
|
+
* omits U+FEFF from, what `String.prototype.trim()` removes, so `trim()` is not used.
|
|
90
|
+
*/
|
|
91
|
+
const PY_WHITESPACE = "\\t\\n\\v\\f\\r\\x1c-\\x1f \\x85\\xa0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000";
|
|
92
|
+
const PY_STRIP = new RegExp(`^[${PY_WHITESPACE}]+|[${PY_WHITESPACE}]+$`, "g");
|
|
93
|
+
/** Maps only `A`-`Z` to `a`-`z`; never `toLowerCase()`, which folds non-ASCII too. */
|
|
94
|
+
function asciiFold(text) {
|
|
95
|
+
return text.replace(/[A-Z]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) + 32));
|
|
96
|
+
}
|
|
97
|
+
function normalizeTestPath(file) {
|
|
98
|
+
const normalized = file.replace(/\\/g, "/").replace(PY_STRIP, "");
|
|
99
|
+
return normalized.startsWith("./") ? normalized.slice(2) : normalized;
|
|
100
|
+
}
|
|
101
|
+
function compareForm(convention, text) {
|
|
102
|
+
return convention.case_sensitive ? text : asciiFold(text);
|
|
103
|
+
}
|
|
104
|
+
function nameMatches(convention, basename) {
|
|
105
|
+
const name = compareForm(convention, basename);
|
|
106
|
+
const value = compareForm(convention, convention.value);
|
|
107
|
+
if (convention.kind === "basename")
|
|
108
|
+
return name === value;
|
|
109
|
+
if (convention.kind === "basename_suffix")
|
|
110
|
+
return name.endsWith(value) && name.length > value.length;
|
|
111
|
+
if (convention.kind === "basename_prefix") {
|
|
112
|
+
if (!name.startsWith(value))
|
|
113
|
+
return false;
|
|
114
|
+
if (convention.extensions.length === 0)
|
|
115
|
+
return name.length > value.length;
|
|
116
|
+
return convention.extensions.some((extension) => {
|
|
117
|
+
const folded = compareForm(convention, extension);
|
|
118
|
+
return name.endsWith(folded) && name.length > value.length + folded.length;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Path-only classification, the TypeScript twin of Python `classify_test_path`.
|
|
125
|
+
* Name conventions outrank directory conventions; within each category catalog
|
|
126
|
+
* order decides. `conventions` is a test seam and defaults to the generated catalog.
|
|
127
|
+
*/
|
|
128
|
+
export function classifyTestPath(file, conventions = LANGUAGE_CATALOG.test_conventions) {
|
|
129
|
+
const segments = normalizeTestPath(file).split("/");
|
|
130
|
+
const basename = segments[segments.length - 1] ?? "";
|
|
131
|
+
if (!basename)
|
|
132
|
+
return null;
|
|
133
|
+
for (const convention of conventions) {
|
|
134
|
+
if (NAME_KINDS.has(convention.kind) && nameMatches(convention, basename)) {
|
|
135
|
+
return { conventionId: convention.id, basis: "name", role: convention.role };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const directories = segments.slice(0, -1).filter(Boolean);
|
|
139
|
+
if (directories.length > 0) {
|
|
140
|
+
for (const convention of conventions) {
|
|
141
|
+
if (convention.kind !== "segment")
|
|
142
|
+
continue;
|
|
143
|
+
const value = compareForm(convention, convention.value);
|
|
144
|
+
if (directories.some((segment) => compareForm(convention, segment) === value)) {
|
|
145
|
+
return { conventionId: convention.id, basis: "directory", role: convention.role };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
export function isTestPath(file) { return classifyTestPath(file) !== null; }
|
|
152
|
+
/**
|
|
153
|
+
* Runnable-target rule: classification is wider than runnability. Accept a
|
|
154
|
+
* name-matched `test` role file, or a lowercase `.rs` file under a test directory.
|
|
155
|
+
* Support files (`conftest.py`) and directory-only non-Rust files are classified
|
|
156
|
+
* but never inferred or declared as runnable targets.
|
|
157
|
+
*/
|
|
85
158
|
function testCandidate(file) {
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
if (/_test\.go$|_test\.rs$|(?:Test|Tests|IT)\.java$|_spec\.rb$/.test(base))
|
|
159
|
+
const match = classifyTestPath(file);
|
|
160
|
+
if (!match)
|
|
161
|
+
return false;
|
|
162
|
+
if (match.basis === "name" && match.role === "test")
|
|
91
163
|
return true;
|
|
92
|
-
return
|
|
164
|
+
return match.basis === "directory" && file.endsWith(".rs");
|
|
93
165
|
}
|
|
94
166
|
/** Proximity tiers for an inferred test candidate; lower is scanned first. */
|
|
95
167
|
const TIER_NEARBY_NAME = 0;
|
|
@@ -90,3 +90,76 @@ export function anyRequiredCheckFailed(pollResponse, required) {
|
|
|
90
90
|
return wanted.has(name) && FAILED_CHECK_CONCLUSIONS.has(conclusion);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
+
/** BAPI-1780: provider status spellings that mean a check has finished. */
|
|
94
|
+
const CONCLUDED_STATUS_SPELLINGS = new Set([
|
|
95
|
+
"success",
|
|
96
|
+
"successful",
|
|
97
|
+
"failure",
|
|
98
|
+
"failed",
|
|
99
|
+
"error",
|
|
100
|
+
"stopped",
|
|
101
|
+
]);
|
|
102
|
+
/** BAPI-1780: the only finished spellings that mean the check succeeded. */
|
|
103
|
+
const SUCCESS_SPELLINGS = new Set(["success", "successful", "pass"]);
|
|
104
|
+
/**
|
|
105
|
+
* BAPI-1780: true only when the poll is READABLE and every observation of a
|
|
106
|
+
* required check is either still running or concluded `success`, so the required
|
|
107
|
+
* set is "pending or absent, none concluded non-success". Used by the focused
|
|
108
|
+
* rebase wait to accept a verified push while CI is still running.
|
|
109
|
+
*
|
|
110
|
+
* This is deliberately NOT "not green and not known failed". It is false for:
|
|
111
|
+
*
|
|
112
|
+
* - an unreadable poll (not `available: true`, or no `detail.checks` array);
|
|
113
|
+
* - a malformed check record (not an object, or no string name);
|
|
114
|
+
* - a required check whose duplicate observations could not be ordered
|
|
115
|
+
* (`recency_ambiguous`);
|
|
116
|
+
* - a required check that finished with anything other than success —
|
|
117
|
+
* including `skipped`, `neutral`, and a commit status of `failure`/`error`,
|
|
118
|
+
* which {@link anyRequiredCheckFailed} does not read;
|
|
119
|
+
* - a record that contradicts itself (`complete: false` with a conclusion, or
|
|
120
|
+
* `status: completed` with no conclusion).
|
|
121
|
+
*
|
|
122
|
+
* A required name with no record at all is ABSENT, which counts as pending. The
|
|
123
|
+
* caller decides green first; this predicate says nothing about green.
|
|
124
|
+
*/
|
|
125
|
+
export function requiredChecksPendingOrAbsent(pollResponse, required) {
|
|
126
|
+
if (classifyCiPollAvailability(pollResponse) !== "available")
|
|
127
|
+
return false;
|
|
128
|
+
const detail = pollResponse.detail;
|
|
129
|
+
if (detail === null || typeof detail !== "object" || Array.isArray(detail))
|
|
130
|
+
return false;
|
|
131
|
+
const checks = detail.checks;
|
|
132
|
+
if (!Array.isArray(checks))
|
|
133
|
+
return false;
|
|
134
|
+
const wanted = new Set(required);
|
|
135
|
+
for (const raw of checks) {
|
|
136
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
137
|
+
return false;
|
|
138
|
+
const c = raw;
|
|
139
|
+
if (typeof c.name !== "string")
|
|
140
|
+
return false;
|
|
141
|
+
if (!wanted.has(c.name))
|
|
142
|
+
continue;
|
|
143
|
+
if (c.recency_ambiguous === true)
|
|
144
|
+
return false;
|
|
145
|
+
const conclusion = typeof c.conclusion === "string" ? c.conclusion.trim().toLowerCase() : "";
|
|
146
|
+
const status = typeof c.status === "string" ? c.status.trim().toLowerCase() : "";
|
|
147
|
+
const bucket = typeof c.bucket === "string" ? c.bucket.trim().toLowerCase() : "";
|
|
148
|
+
if (c.complete === false && conclusion !== "")
|
|
149
|
+
return false;
|
|
150
|
+
let finished = null;
|
|
151
|
+
if (conclusion !== "")
|
|
152
|
+
finished = conclusion;
|
|
153
|
+
else if (CONCLUDED_STATUS_SPELLINGS.has(status))
|
|
154
|
+
finished = status;
|
|
155
|
+
else if (bucket !== "" && bucket !== "pending")
|
|
156
|
+
finished = bucket;
|
|
157
|
+
else if (status === "completed" || c.complete === true)
|
|
158
|
+
return false;
|
|
159
|
+
if (finished !== null && !SUCCESS_SPELLINGS.has(finished))
|
|
160
|
+
return false;
|
|
161
|
+
if (finished !== null && c.complete === true && c.passed === false)
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
* finalization PROVED its push landed, wait for the evidence the server's
|
|
19
19
|
* completion verifier will read: the same open pull request, at the exact
|
|
20
20
|
* pushed head, on the expected head branch and base, mergeable, with every
|
|
21
|
-
* effective required check
|
|
22
|
-
*
|
|
21
|
+
* effective required check at that head either green or (BAPI-1780) still
|
|
22
|
+
* pending or absent with none concluded non-success. Every read and sleep is
|
|
23
|
+
* bounded by the claim's remaining absolute deadline and abort signal.
|
|
23
24
|
*
|
|
24
25
|
* The wait READS; it never acts. It launches no worker, enqueues nothing, resets
|
|
25
26
|
* nothing, and pushes nothing. `ready` is permission to submit `/complete` once,
|
|
@@ -28,9 +29,8 @@
|
|
|
28
29
|
*/
|
|
29
30
|
import { ExecutorNamedError, FocusedRebaseContext } from "./job-errors.js";
|
|
30
31
|
import { readRequiredVerification } from "./completion-supervision.js";
|
|
31
|
-
import { allRequiredChecksGreen, anyRequiredCheckFailed, ProviderChecksUnobservable, } from "./provider-checks.js";
|
|
32
|
+
import { allRequiredChecksGreen, anyRequiredCheckFailed, ProviderChecksUnobservable, requiredChecksPendingOrAbsent, } from "./provider-checks.js";
|
|
32
33
|
import { FOCUSED_REBASE_CAPABILITY, FOCUSED_REBASE_CONTEXT_VERSION, } from "./types.js";
|
|
33
|
-
import { deliveryRenewedWithRemoteCiDeferrals } from "./delivery-outcome.js";
|
|
34
34
|
/** The job type the focused context is valid on. */
|
|
35
35
|
export const FOCUSED_REBASE_JOB_TYPE = "rebase";
|
|
36
36
|
/** The payload key the server writes the context under. */
|
|
@@ -241,15 +241,18 @@ function boundedRace(work, ms, signal) {
|
|
|
241
241
|
* explicitly empty server-derived check set is satisfied vacuously, but only once
|
|
242
242
|
* every pull-request condition holds.
|
|
243
243
|
*
|
|
244
|
-
* BAPI-
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
244
|
+
* BAPI-1780: once every pull-request condition holds, a READABLE check poll at
|
|
245
|
+
* the pushed head whose required checks are pending or absent, with none
|
|
246
|
+
* concluded non-success ({@link requiredChecksPendingOrAbsent}), also ends
|
|
247
|
+
* `ready` with `ciDeferred: true`. That is a successful rebase awaiting CI — not
|
|
248
|
+
* green CI, renewed evidence, or merge readiness. `readDelivery` is never called.
|
|
249
|
+
* An unreadable or malformed poll, or a required check that finished skipped,
|
|
250
|
+
* neutral, or otherwise non-success without being proven red, is NOT pending in
|
|
251
|
+
* this sense: it keeps waiting and never ends `ready` on its own.
|
|
248
252
|
*
|
|
249
253
|
* Proven failures stop at once: a required check concluded red, the pull request
|
|
250
254
|
* closed or reads `CONFLICTING`, or its number, head, head branch, or base moved.
|
|
251
|
-
*
|
|
252
|
-
* pending while time remains. When the deadline (less the report margin) arrives
|
|
255
|
+
* `UNKNOWN` mergeability and unavailable reads stay pending while time remains. When the deadline (less the report margin) arrives
|
|
253
256
|
* first, the outcome is an UNVERIFIED stop naming what was still missing — never
|
|
254
257
|
* a red-CI claim.
|
|
255
258
|
*/
|
|
@@ -310,18 +313,12 @@ export async function waitForFocusedRebase(input) {
|
|
|
310
313
|
return { kind: "stopped", reason: "required_check_failed" };
|
|
311
314
|
if (allRequiredChecksGreen(poll, ctx.requiredChecks))
|
|
312
315
|
return { kind: "ready", ciVacuous: false };
|
|
313
|
-
// BAPI-
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
return "aborted";
|
|
320
|
-
if (delivery !== "timeout" &&
|
|
321
|
-
!(delivery instanceof ProviderChecksUnobservable) &&
|
|
322
|
-
deliveryRenewedWithRemoteCiDeferrals(delivery, pushed)) {
|
|
323
|
-
return { kind: "ready", ciVacuous: false, ciDeferred: true };
|
|
324
|
-
}
|
|
316
|
+
// BAPI-1780: every pull-request condition above holds, so the push is
|
|
317
|
+
// verified. Required checks that are readably pending or absent, with none
|
|
318
|
+
// concluded non-success, end the wait as a successful rebase awaiting CI. No
|
|
319
|
+
// delivery read: the server's completion contract re-checks the same rule.
|
|
320
|
+
if (requiredChecksPendingOrAbsent(poll, ctx.requiredChecks)) {
|
|
321
|
+
return { kind: "ready", ciVacuous: false, ciDeferred: true };
|
|
325
322
|
}
|
|
326
323
|
return { kind: "pending", reason: "checks_pending" };
|
|
327
324
|
};
|
|
@@ -347,13 +344,18 @@ export async function waitForFocusedRebase(input) {
|
|
|
347
344
|
if (reading === "timeout")
|
|
348
345
|
continue;
|
|
349
346
|
if (reading.kind === "ready") {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
347
|
+
if (reading.ciDeferred) {
|
|
348
|
+
input.errorLog(`[executor] Ready: focused rebase succeeded, awaiting CI — pushed work at the pull request head is ` +
|
|
349
|
+
`mergeable and required checks are still pending (none failed); this is not green CI or merge ` +
|
|
350
|
+
`readiness; submitting completion once; ${ids}; elapsed=${secs()}`);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
const checksText = reading.ciVacuous
|
|
353
354
|
? "no required checks are configured (vacuous CI)"
|
|
354
355
|
: "every required check is green";
|
|
355
|
-
|
|
356
|
-
|
|
356
|
+
input.errorLog(`[executor] Ready: focused rebase evidence current — pushed work at the pull request head is mergeable ` +
|
|
357
|
+
`and ${checksText}; submitting completion once; ${ids}; elapsed=${secs()}`);
|
|
358
|
+
}
|
|
357
359
|
return {
|
|
358
360
|
kind: "ready",
|
|
359
361
|
ciVacuous: reading.ciVacuous,
|