@bridge_gpt/mcp-server 0.2.75 → 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 +5 -5
- package/build/cli-dispatch.js +333 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +8 -8
- package/build/conductor/bridge-api-client.js +193 -13
- package/build/conductor/declare-blocked.js +146 -7
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +15 -10
- package/build/conductor/epic-server-journal.js +52 -22
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +55 -13
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +14 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +625 -33
- 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 +947 -120
- package/build/epic-implementer-env.js +2 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +87 -28
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/provider-checks.js +101 -5
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +89 -6
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +26 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +39 -2
- package/build/index.js +2500 -495
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +4 -0
- package/build/install-bridge-conductor-apply.js +10 -0
- package/build/install-bridge-conductor-assessment.js +84 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-setup.js +103 -3
- package/build/install-bridge-conductor.js +440 -812
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +47 -19
- package/build/plan-execution-ledger.js +35 -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/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +17 -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/secret-redaction.js +3 -0
- package/build/server.js +7946 -0
- package/build/setup-epic.js +41 -8
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/create-preview-world.js +232 -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/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +39 -5
- package/build/version.generated.js +3 -3
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +150 -2
- package/docs/epic-implementer/getting-started.md +5 -1
- package/package.json +3 -3
- package/pipelines/implement-ticket.json +2 -2
- package/pipelines/learn-repository.json +19 -1
|
@@ -89,6 +89,7 @@ export function readMergeJobPayloadFields(job, repositoryBaseBranch) {
|
|
|
89
89
|
const requiredChecks = Array.isArray(payload.required_checks)
|
|
90
90
|
? payload.required_checks.filter((c) => typeof c === "string")
|
|
91
91
|
: [];
|
|
92
|
+
const noCiGateDeclared = payload.no_ci_gate === true && requiredChecks.length === 0;
|
|
92
93
|
const actionKey = asString(payload.action_key) ?? `merge:pr-${prNumber}:${expectedHeadSha}`;
|
|
93
94
|
const ciWaitTimeoutMs = nonNegativeIntOrUndefined(payload.ci_wait_timeout_ms);
|
|
94
95
|
const ciWaitPollIntervalMs = nonNegativeIntOrUndefined(payload.ci_wait_poll_interval_ms);
|
|
@@ -100,6 +101,7 @@ export function readMergeJobPayloadFields(job, repositoryBaseBranch) {
|
|
|
100
101
|
expectedHeadSha,
|
|
101
102
|
method,
|
|
102
103
|
requiredChecks,
|
|
104
|
+
noCiGateDeclared,
|
|
103
105
|
actionKey,
|
|
104
106
|
ciWaitTimeoutMs,
|
|
105
107
|
ciWaitPollIntervalMs,
|
|
@@ -159,6 +161,10 @@ export function buildMergeJobResult(response, fields) {
|
|
|
159
161
|
result.commit_sha = mergeCommitSha;
|
|
160
162
|
result.head_sha = mergeCommitSha;
|
|
161
163
|
}
|
|
164
|
+
if (fields.noCiGateDeclared) {
|
|
165
|
+
// BAPI-1724: a declaration-based skipped wait, never a CI pass.
|
|
166
|
+
result.ci_wait = "skipped_no_ci_gate_declared";
|
|
167
|
+
}
|
|
162
168
|
return result;
|
|
163
169
|
}
|
|
164
170
|
/**
|
|
@@ -190,6 +196,22 @@ export const MERGE_REF_MISMATCH = "MergeRefMismatch";
|
|
|
190
196
|
* `merge_credential_no_access`.
|
|
191
197
|
*/
|
|
192
198
|
export const MERGE_CREDENTIAL_NO_ACCESS = "MergeCredentialNoAccess";
|
|
199
|
+
/**
|
|
200
|
+
* BAPI-1527 — a DELIBERATE, fail-closed refusal to merge: through the whole CI
|
|
201
|
+
* wait budget, the latest poll said the required-check configuration or provider
|
|
202
|
+
* access could not be read. That is not red CI, and it is never green evidence,
|
|
203
|
+
* so no merge happens. It is not a crash, so it is reported as `clean_exit`, and
|
|
204
|
+
* it is never a rebase target. Emitted only with the `ci_checks_unavailable`
|
|
205
|
+
* reason. It has its own kind (not {@link MERGE_RETRYABLE}) only so the server can
|
|
206
|
+
* name it: the server re-fires and retries it through the same merge budget as
|
|
207
|
+
* `ci_not_green`, and parks it as `merge_ci_checks_unavailable` only once that
|
|
208
|
+
* budget is spent — never earlier than a `ci_not_green` merge would park.
|
|
209
|
+
*
|
|
210
|
+
* Its sibling reason `ci_no_checks_observed` (a fallback poll saw no check at all
|
|
211
|
+
* before the wait budget ended) is a different shape: bounded absence of
|
|
212
|
+
* evidence, classified {@link MERGE_RETRYABLE}, with its own reason preserved.
|
|
213
|
+
*/
|
|
214
|
+
export const MERGE_CI_CHECKS_UNAVAILABLE = "MergeCiChecksUnavailable";
|
|
193
215
|
/**
|
|
194
216
|
* BAPI-1234 — the server's migration-graph merge guard refused the merge. Two
|
|
195
217
|
* kinds, kept distinct because they call for different human responses:
|
|
@@ -212,9 +234,24 @@ const MIGRATION_GRAPH_ERROR_KINDS = new Map([
|
|
|
212
234
|
const DELIBERATE_REFUSAL_ERROR_KINDS = new Set([
|
|
213
235
|
MERGE_REF_MISMATCH,
|
|
214
236
|
MERGE_CREDENTIAL_NO_ACCESS,
|
|
237
|
+
MERGE_CI_CHECKS_UNAVAILABLE,
|
|
215
238
|
MERGE_MIGRATION_GRAPH_INVALID,
|
|
216
239
|
MERGE_MIGRATION_GRAPH_UNREADABLE,
|
|
217
240
|
]);
|
|
241
|
+
/** BAPI-1527 — the local merge reason for unreadable check configuration. */
|
|
242
|
+
const CI_CHECKS_UNAVAILABLE_REASON = "ci_checks_unavailable";
|
|
243
|
+
/**
|
|
244
|
+
* BAPI-1527 — plain-language operator wording for the two new CI reasons. Fixed
|
|
245
|
+
* text only: it carries no provider body, credential, or exception text, and the
|
|
246
|
+
* named technical reason stays in the message as secondary context.
|
|
247
|
+
*/
|
|
248
|
+
const CI_REASON_SUMMARIES = new Map([
|
|
249
|
+
[
|
|
250
|
+
CI_CHECKS_UNAVAILABLE_REASON,
|
|
251
|
+
"CI checks unavailable: required-check configuration or provider access could not be read",
|
|
252
|
+
],
|
|
253
|
+
["ci_no_checks_observed", "No provider checks observed for this commit yet"],
|
|
254
|
+
]);
|
|
218
255
|
/** Reasons whose failure is transient/infrastructure and safe to retry. */
|
|
219
256
|
const RETRYABLE_MERGE_REASONS = new Set([
|
|
220
257
|
"gh_pr_view_timeout",
|
|
@@ -222,6 +259,7 @@ const RETRYABLE_MERGE_REASONS = new Set([
|
|
|
222
259
|
"gh_pr_view_unparseable",
|
|
223
260
|
"ci_poll_failed",
|
|
224
261
|
"ci_not_green",
|
|
262
|
+
"ci_no_checks_observed",
|
|
225
263
|
"gh_merge_timeout",
|
|
226
264
|
"gh_merge_failed",
|
|
227
265
|
"merge_aborted",
|
|
@@ -259,6 +297,8 @@ export function classifyMergeFailureErrorKind(response) {
|
|
|
259
297
|
return MERGE_CREDENTIAL_NO_ACCESS;
|
|
260
298
|
if (reason === "ref_mismatch")
|
|
261
299
|
return MERGE_REF_MISMATCH;
|
|
300
|
+
if (reason === CI_CHECKS_UNAVAILABLE_REASON)
|
|
301
|
+
return MERGE_CI_CHECKS_UNAVAILABLE;
|
|
262
302
|
const migrationGraphKind = reason ? MIGRATION_GRAPH_ERROR_KINDS.get(reason) : undefined;
|
|
263
303
|
if (migrationGraphKind)
|
|
264
304
|
return migrationGraphKind;
|
|
@@ -293,7 +333,9 @@ export function buildMergeJobFailure(response) {
|
|
|
293
333
|
const errorKind = classifyMergeFailureErrorKind(response);
|
|
294
334
|
return {
|
|
295
335
|
error_kind: errorKind,
|
|
296
|
-
error_message: secretFreeErrorMessage(new Error(
|
|
336
|
+
error_message: secretFreeErrorMessage(new Error(CI_REASON_SUMMARIES.has(reason)
|
|
337
|
+
? `local merge ${response.status}: ${CI_REASON_SUMMARIES.get(reason)} (reason=${reason})`
|
|
338
|
+
: `local merge ${response.status}: ${reason}`)),
|
|
297
339
|
classification: DELIBERATE_REFUSAL_ERROR_KINDS.has(errorKind) ? "clean_exit" : "crashed",
|
|
298
340
|
telemetry: { failure_reason_code: mergeResponseReasonCode(response) },
|
|
299
341
|
};
|
|
@@ -366,6 +408,8 @@ export async function runExecutorMergeJob(job, seams) {
|
|
|
366
408
|
method: fields.method,
|
|
367
409
|
ciWaitTimeoutMs: fields.ciWaitTimeoutMs,
|
|
368
410
|
ciWaitPollIntervalMs: fields.ciWaitPollIntervalMs,
|
|
411
|
+
// BAPI-1724: separate from `skipCiWait`, which has its own meaning.
|
|
412
|
+
noCiGateDeclared: fields.noCiGateDeclared,
|
|
369
413
|
// BAPI-1021 (AC-11): pass the already-resolved expectations through
|
|
370
414
|
// unchanged so verification and the post-merge enrichment below use one
|
|
371
415
|
// authoritative value — neither re-resolves it independently.
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
import { randomUUID } from "node:crypto";
|
|
39
39
|
import path from "node:path";
|
|
40
40
|
import { acquireExcludeLock } from "../git-exclude-lock.js";
|
|
41
|
+
import { PHASE_RESULT_SUBDIR } from "../phase-result-artifacts.js";
|
|
41
42
|
import { mergeClaudeSettingsWithAutoMemoryDisabled, mergeClaudeSettingsWithCommandHook, provisionClaudeSettingsForWorktree, DEFAULT_PRE_TOOL_USE_MATCHER, } from "../claude-settings.js";
|
|
42
43
|
/**
|
|
43
44
|
* BAPI-1647: one exact `Read(<path>)` rule per distinct restricted source path,
|
|
@@ -323,11 +324,52 @@ export const EXECUTOR_CONDUCTOR_EXCLUDE_LINE = ".conductor/";
|
|
|
323
324
|
* Every line the executor provisions into a worktree's `.git/info/exclude`, in
|
|
324
325
|
* the order they are appended. Named once so the writer and its tests cannot
|
|
325
326
|
* disagree about the set.
|
|
327
|
+
*
|
|
328
|
+
* These lines are ADDITIONAL protection only: they keep untracked host files out
|
|
329
|
+
* of a plain `git add`. They do not protect a file that is already tracked or
|
|
330
|
+
* already staged. The executor's real boundary is the pathspec list built from
|
|
331
|
+
* {@link EXECUTOR_STAGE_EXCLUDES}, which every executor-owned `git add` and
|
|
332
|
+
* `git status` passes. The phase-result directory is a filesystem-only ledger
|
|
333
|
+
* (`../phase-result-artifacts.ts`): it never needs to be committed, so it is
|
|
334
|
+
* excluded at every depth, including a customer directory of the same name.
|
|
326
335
|
*/
|
|
327
336
|
export const EXECUTOR_EXCLUDE_LINES = [
|
|
328
337
|
EXECUTOR_SETTINGS_EXCLUDE_LINE,
|
|
329
338
|
EXECUTOR_CONDUCTOR_EXCLUDE_LINE,
|
|
339
|
+
".mcp.json",
|
|
340
|
+
".cursor/mcp.json",
|
|
341
|
+
`${PHASE_RESULT_SUBDIR}/`,
|
|
342
|
+
];
|
|
343
|
+
/** The phase-result staging pattern: any directory of that name, at any depth. */
|
|
344
|
+
const PHASE_RESULT_STAGE_PATTERN = `**/${PHASE_RESULT_SUBDIR}/**`;
|
|
345
|
+
/**
|
|
346
|
+
* Paths no executor-owned commit may stage (the shared staging policy).
|
|
347
|
+
*
|
|
348
|
+
* Host configuration (`.mcp.json`, `.cursor/mcp.json`) is excluded by its
|
|
349
|
+
* ROOT-RELATIVE path only: there is deliberately no any-depth MCP glob, so a
|
|
350
|
+
* customer's nested `packages/app/.mcp.json` stays committable. Phase results are
|
|
351
|
+
* the one any-depth entry, written as a glob. Executor-owned settings and
|
|
352
|
+
* conductor artifacts complete the list.
|
|
353
|
+
*/
|
|
354
|
+
export const EXECUTOR_STAGE_EXCLUDES = [
|
|
355
|
+
".mcp.json",
|
|
356
|
+
".cursor/mcp.json",
|
|
357
|
+
PHASE_RESULT_STAGE_PATTERN,
|
|
358
|
+
EXECUTOR_SETTINGS_EXCLUDE_LINE,
|
|
359
|
+
EXECUTOR_CONDUCTOR_EXCLUDE_LINE,
|
|
330
360
|
];
|
|
361
|
+
function stagePathspec(entry, exclude) {
|
|
362
|
+
const magic = ["top", ...(exclude ? ["exclude"] : []), ...(entry === PHASE_RESULT_STAGE_PATTERN ? ["glob"] : [])];
|
|
363
|
+
return `:(${magic.join(",")})${entry}`;
|
|
364
|
+
}
|
|
365
|
+
/** `:(top,exclude)<path>` pathspecs for `git add` / `git status` (root-relative). */
|
|
366
|
+
export function executorStageExcludePathspecs() {
|
|
367
|
+
return EXECUTOR_STAGE_EXCLUDES.map((entry) => stagePathspec(entry, true));
|
|
368
|
+
}
|
|
369
|
+
/** `:(top)<path>` pathspecs selecting the same entries, for index inspection and reset. */
|
|
370
|
+
export function executorStagePositivePathspecs() {
|
|
371
|
+
return EXECUTOR_STAGE_EXCLUDES.map((entry) => stagePathspec(entry, false));
|
|
372
|
+
}
|
|
331
373
|
/**
|
|
332
374
|
* Build the one bounded shape every exclude-provisioning warning takes: a
|
|
333
375
|
* failure CATEGORY plus the affected worktree path, and nothing else.
|
|
@@ -339,7 +381,7 @@ export const EXECUTOR_EXCLUDE_LINES = [
|
|
|
339
381
|
*/
|
|
340
382
|
function excludeWarning(worktreePath, category) {
|
|
341
383
|
return (`worktree git-exclude provisioning did not complete for ${worktreePath}: ${category}. ` +
|
|
342
|
-
`${EXECUTOR_EXCLUDE_LINES.join("
|
|
384
|
+
`${EXECUTOR_EXCLUDE_LINES.join(", ")} are not protected from worker commits on this ` +
|
|
343
385
|
"worktree; inspect it before trusting the worktree's staged changes; continuing fail-open.");
|
|
344
386
|
}
|
|
345
387
|
const EXCLUDE_UNRESOLVED_CATEGORY = {
|
|
@@ -491,7 +533,9 @@ export async function resolveWorktreeSettingsExclude(worktreePath, deps) {
|
|
|
491
533
|
}
|
|
492
534
|
/**
|
|
493
535
|
* Keep the executor-owned `.claude/settings.local.json` and the conductor's
|
|
494
|
-
* `.conductor/` artifacts
|
|
536
|
+
* `.conductor/` artifacts, plus host MCP files and phase-result directories, out
|
|
537
|
+
* of worker commits (BAPI-740/F2, BAPI-814/D2, BAPI-1732). This is untracked-file
|
|
538
|
+
* protection only; the staging pathspecs are the executor's boundary.
|
|
495
539
|
* Worker-config isolation redirects `XDG_CONFIG_HOME`, so the
|
|
496
540
|
* operator's global git excludes (`~/.config/git/ignore`) no longer apply inside
|
|
497
541
|
* a worker — empirically, a worker `git add -A` commits the deny-layer file this
|
|
@@ -590,6 +634,147 @@ export async function provisionWorktreeSettingsExclude(worktreePath, deps) {
|
|
|
590
634
|
await lock.release();
|
|
591
635
|
}
|
|
592
636
|
}
|
|
637
|
+
const INDEX_HEADER = /^([0-7]{6}) ([0-9a-f]{40}|[0-9a-f]{64}) ([0-3])$/;
|
|
638
|
+
// Bounded, fixed messages: never Git output, environment values, or file content.
|
|
639
|
+
function indexError(category) {
|
|
640
|
+
return new Error(`executor index protection failed: ${category}`);
|
|
641
|
+
}
|
|
642
|
+
function parseIndexRecords(stdout) {
|
|
643
|
+
const parts = stdout.split("\0");
|
|
644
|
+
if (parts.length > 0 && parts[parts.length - 1] === "")
|
|
645
|
+
parts.pop();
|
|
646
|
+
return parts.map((record) => {
|
|
647
|
+
const tab = record.indexOf("\t");
|
|
648
|
+
if (tab < 0)
|
|
649
|
+
throw indexError("malformed index listing");
|
|
650
|
+
const header = INDEX_HEADER.exec(record.slice(0, tab));
|
|
651
|
+
const entryPath = record.slice(tab + 1);
|
|
652
|
+
if (!header || entryPath.length === 0)
|
|
653
|
+
throw indexError("malformed index listing");
|
|
654
|
+
return { mode: header[1], sha: header[2], stage: Number(header[3]), path: entryPath };
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
async function listProtectedIndex(git) {
|
|
658
|
+
const listed = await git([
|
|
659
|
+
"ls-files", "--stage", "--full-name", "-z", "--", ...executorStagePositivePathspecs(),
|
|
660
|
+
]);
|
|
661
|
+
if (listed.exitCode !== 0)
|
|
662
|
+
throw indexError("index listing failed");
|
|
663
|
+
return parseIndexRecords(listed.stdout);
|
|
664
|
+
}
|
|
665
|
+
/** `:(top)` plus every protected exclusion: the whole repository minus protected paths. */
|
|
666
|
+
export function executorAllowedTreePathspecs() {
|
|
667
|
+
return [":(top)", ...executorStageExcludePathspecs()];
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Stage every allowed change (`git add -A`) without ever staging a protected path.
|
|
671
|
+
*
|
|
672
|
+
* Git exits 1 from `add` when a pathspec literally names a file that
|
|
673
|
+
* `info/exclude` also ignores, and the exclusion entries count as such a mention.
|
|
674
|
+
* In a provisioned worktree that is the normal case (`.conductor/` and the
|
|
675
|
+
* settings file always exist), so exit 1 alone is not a failure. It is accepted
|
|
676
|
+
* only when a status read then proves nothing allowed is left unstaged; any other
|
|
677
|
+
* exit, or a leftover allowed change, throws. This never depends on Git's
|
|
678
|
+
* localized message text.
|
|
679
|
+
*/
|
|
680
|
+
export async function stageExecutorAllowedTree(git) {
|
|
681
|
+
const scope = executorAllowedTreePathspecs();
|
|
682
|
+
const added = await git(["add", "-A", "--", ...scope]);
|
|
683
|
+
if (added.exitCode === 0)
|
|
684
|
+
return;
|
|
685
|
+
if (added.exitCode !== 1)
|
|
686
|
+
throw indexError("staging failed");
|
|
687
|
+
const status = await git(["status", "--porcelain", "--", ...scope]);
|
|
688
|
+
if (status.exitCode !== 0)
|
|
689
|
+
throw indexError("staging check failed");
|
|
690
|
+
const unmerged = /^(?:DD|AU|UD|UA|DU|AA|UU)$/;
|
|
691
|
+
for (const line of status.stdout.split("\n")) {
|
|
692
|
+
if (line.length < 3)
|
|
693
|
+
continue;
|
|
694
|
+
const xy = line.slice(0, 2);
|
|
695
|
+
// An unmerged entry is the caller's conflict check to judge, not a staging fault.
|
|
696
|
+
if (unmerged.test(xy))
|
|
697
|
+
continue;
|
|
698
|
+
if (xy[1] !== " ")
|
|
699
|
+
throw indexError("staging incomplete");
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Capture the protected-path index state of a freshly started merge. Fails closed:
|
|
704
|
+
* a failed or malformed listing rejects rather than returning an empty snapshot.
|
|
705
|
+
*/
|
|
706
|
+
export async function captureExecutorMergeIndex(git) {
|
|
707
|
+
const records = await listProtectedIndex(git);
|
|
708
|
+
const conflicted = new Set();
|
|
709
|
+
const restore = [];
|
|
710
|
+
for (const rec of records) {
|
|
711
|
+
if (rec.stage !== 0)
|
|
712
|
+
conflicted.add(rec.path);
|
|
713
|
+
}
|
|
714
|
+
for (const rec of records) {
|
|
715
|
+
if (rec.stage === 0 && !conflicted.has(rec.path)) {
|
|
716
|
+
restore.push({ mode: rec.mode, sha: rec.sha, path: rec.path });
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return { restore, conflicted };
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Undo executor-created index changes to protected paths, touching the index only.
|
|
723
|
+
* Working-tree files are never modified.
|
|
724
|
+
*
|
|
725
|
+
* - Without a snapshot (not a merge): `git reset -q HEAD -- <protected>` returns
|
|
726
|
+
* tracked entries to HEAD and drops newly staged protected files.
|
|
727
|
+
* - With a snapshot (a conflicted merge): protected entries the merge itself
|
|
728
|
+
* produced are restored, entries added since are removed, and paths that were
|
|
729
|
+
* conflicted at capture are left to the worker's resolution. HEAD is not used,
|
|
730
|
+
* because that would erase legitimate merge content.
|
|
731
|
+
*/
|
|
732
|
+
export async function unstageExecutorExcludedPaths(git, snapshot) {
|
|
733
|
+
if (snapshot === undefined) {
|
|
734
|
+
const reset = await git(["reset", "-q", "HEAD", "--", ...executorStagePositivePathspecs()]);
|
|
735
|
+
if (reset.exitCode !== 0)
|
|
736
|
+
throw indexError("reset failed");
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const current = await listProtectedIndex(git);
|
|
740
|
+
const currentStageZero = new Map();
|
|
741
|
+
for (const rec of current) {
|
|
742
|
+
if (rec.stage === 0)
|
|
743
|
+
currentStageZero.set(rec.path, { mode: rec.mode, sha: rec.sha, path: rec.path });
|
|
744
|
+
}
|
|
745
|
+
const wanted = new Map(snapshot.restore.map((rec) => [rec.path, rec]));
|
|
746
|
+
const removals = [];
|
|
747
|
+
for (const rec of current) {
|
|
748
|
+
if (snapshot.conflicted.has(rec.path) || wanted.has(rec.path))
|
|
749
|
+
continue;
|
|
750
|
+
if (!removals.includes(rec.path))
|
|
751
|
+
removals.push(rec.path);
|
|
752
|
+
}
|
|
753
|
+
const restores = snapshot.restore.filter((rec) => {
|
|
754
|
+
const now = currentStageZero.get(rec.path);
|
|
755
|
+
return !now || now.mode !== rec.mode || now.sha !== rec.sha;
|
|
756
|
+
});
|
|
757
|
+
if (removals.length === 0 && restores.length === 0)
|
|
758
|
+
return;
|
|
759
|
+
// `update-index` takes cwd-relative paths while the listing is root-relative, so
|
|
760
|
+
// pin these calls to the repository root through the same injected closure.
|
|
761
|
+
const top = await git(["rev-parse", "--show-toplevel"]);
|
|
762
|
+
const root = top.stdout.replace(/\r?\n$/, "");
|
|
763
|
+
if (top.exitCode !== 0 || root.length === 0)
|
|
764
|
+
throw indexError("repository root lookup failed");
|
|
765
|
+
for (const entryPath of removals) {
|
|
766
|
+
const removed = await git(["-C", root, "update-index", "--force-remove", "--", entryPath]);
|
|
767
|
+
if (removed.exitCode !== 0)
|
|
768
|
+
throw indexError("index removal failed");
|
|
769
|
+
}
|
|
770
|
+
for (const rec of restores) {
|
|
771
|
+
const restored = await git([
|
|
772
|
+
"-C", root, "update-index", "--add", "--cacheinfo", `${rec.mode},${rec.sha},${rec.path}`,
|
|
773
|
+
]);
|
|
774
|
+
if (restored.exitCode !== 0)
|
|
775
|
+
throw indexError("index restoration failed");
|
|
776
|
+
}
|
|
777
|
+
}
|
|
593
778
|
/**
|
|
594
779
|
* Provision the executor deny layer into `<worktree>/.claude/settings.local.json`,
|
|
595
780
|
* and shield that file from worker commits via `.git/info/exclude` (BAPI-740/F2).
|
|
@@ -10,28 +10,51 @@
|
|
|
10
10
|
* worktree, pushes nothing, and decides no gate — the server's completion
|
|
11
11
|
* verifier stays the authority for both lanes (R14 rule 3).
|
|
12
12
|
*/
|
|
13
|
-
import { pollCiChecksForCommit, resolveConductorBridgeApiAccess, } from "../conductor/bridge-api-client.js";
|
|
13
|
+
import { pollCiChecksForCommit, classifyCiPollAvailability, resolveConductorBridgeApiAccess, } from "../conductor/bridge-api-client.js";
|
|
14
14
|
import { allRequiredChecksGreen } from "../conductor/local-merge.js";
|
|
15
15
|
export { allRequiredChecksGreen };
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Thrown by a provider-check poller that cannot observe checks at all: it has no
|
|
18
|
+
* Bridge API access, or the server reported the check configuration unreadable.
|
|
19
|
+
* Waiting cannot fix either, so a caller ends its wait instead of reading the
|
|
20
|
+
* missing evidence as pending checks.
|
|
21
|
+
*/
|
|
17
22
|
export class ProviderChecksUnobservable extends Error {
|
|
23
|
+
reason;
|
|
24
|
+
constructor(message, reason = "access_unavailable") {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ProviderChecksUnobservable";
|
|
27
|
+
this.reason = reason;
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
31
|
* A provider-check poller that resolves Bridge API access once, on first use —
|
|
21
32
|
* the same read-only CI poll the `merge` job waits on. Without access it throws
|
|
22
33
|
* {@link ProviderChecksUnobservable}, so a caller can end its wait immediately
|
|
23
34
|
* rather than sleeping out the job budget on evidence it can never read.
|
|
35
|
+
*
|
|
36
|
+
* BAPI-1527: `requiredChecks` is forwarded on every poll so a repository with no
|
|
37
|
+
* CI check cache is judged on live provider evidence. A caller that learns its
|
|
38
|
+
* list only per job may pass it as the second argument of the returned poller,
|
|
39
|
+
* which then overrides the constructed list. A response saying the check
|
|
40
|
+
* configuration or provider access could not be read throws
|
|
41
|
+
* {@link ProviderChecksUnobservable} with reason `checks_configuration_unavailable`
|
|
42
|
+
* rather than passing through as an unremarkable "not green yet".
|
|
24
43
|
*/
|
|
25
|
-
export function lazyProviderCheckPoller(accessDeps) {
|
|
44
|
+
export function lazyProviderCheckPoller(accessDeps, requiredChecks = []) {
|
|
26
45
|
let access;
|
|
27
|
-
return async (sha) => {
|
|
46
|
+
return async (sha, requiredChecksOverride) => {
|
|
28
47
|
if (access === undefined) {
|
|
29
48
|
const resolved = await resolveConductorBridgeApiAccess(accessDeps);
|
|
30
49
|
access = resolved.ok ? resolved.access : null;
|
|
31
50
|
}
|
|
32
51
|
if (access === null)
|
|
33
52
|
throw new ProviderChecksUnobservable("bridge api access unavailable");
|
|
34
|
-
|
|
53
|
+
const response = await pollCiChecksForCommit(access, sha, undefined, requiredChecksOverride ?? requiredChecks);
|
|
54
|
+
if (classifyCiPollAvailability(response) === "configuration_unavailable") {
|
|
55
|
+
throw new ProviderChecksUnobservable("required-check configuration or provider access could not be read", "checks_configuration_unavailable");
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
35
58
|
};
|
|
36
59
|
}
|
|
37
60
|
/** Conclusions that PROVE a check failed, as opposed to not having finished. */
|
|
@@ -67,3 +90,76 @@ export function anyRequiredCheckFailed(pollResponse, required) {
|
|
|
67
90
|
return wanted.has(name) && FAILED_CHECK_CONCLUSIONS.has(conclusion);
|
|
68
91
|
});
|
|
69
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,
|