@bridge_gpt/mcp-server 0.2.74 → 0.2.76
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 +14 -7
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +6 -6
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +7 -7
- package/build/conductor/bridge-api-client.js +807 -52
- package/build/conductor/declare-blocked.js +4 -0
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/epic-implementer-cli.js +341 -96
- package/build/conductor/epic-server-journal.js +13 -0
- 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/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/local-merge.js +54 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +12 -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/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +3 -3
- package/build/drive-epic.js +787 -37
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +200 -66
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +13 -723
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/provider-checks.js +28 -5
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/required-verification.js +28 -2
- package/build/executor/required-work-ledger.js +7 -2
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +30 -5
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor/worktree.js +12 -1
- package/build/generated/ticket-status.js +20 -0
- package/build/index.js +627 -551
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +32 -1
- package/build/install-bridge-conductor-apply.js +21 -3
- package/build/install-bridge-conductor-assessment.js +185 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +106 -6
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +740 -124
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +15 -15
- package/build/plan-execution-ledger.js +27 -0
- package/build/plan-generation.js +17 -0
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +62 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +11 -5
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/secret-redaction.js +3 -0
- package/build/setup-epic.js +51 -9
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/executor-source-files.js +1 -1
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +13 -4
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +83 -4
- package/docs/epic-implementer/getting-started.md +1 -1
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/pipelines/implement-ticket.json +2 -2
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -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).
|
|
@@ -12,7 +12,7 @@ import { spawnSync } from "node:child_process";
|
|
|
12
12
|
import { defaultResolveBinPath } from "../start-tickets-conductor.js";
|
|
13
13
|
import { CORRECTION_INTENT_CAPABILITY } from "./correction-dispatch.js";
|
|
14
14
|
import { resolveAllExecutorApiAccess, resolveBaseUrl, EXECUTOR_BASE_URL_REQUIRED_MESSAGE, } from "./credentials.js";
|
|
15
|
-
import { FOCUSED_REBASE_CAPABILITY, GATE_QUALIFICATION_CAPABILITY, SCOPE_WAIT_CAPABILITY, } from "./types.js";
|
|
15
|
+
import { FOCUSED_REBASE_CAPABILITY, GATE_QUALIFICATION_CAPABILITY, GATE_QUALIFICATION_WORKER_DATABASE_CAPABILITY, SCOPE_WAIT_CAPABILITY, } from "./types.js";
|
|
16
16
|
/**
|
|
17
17
|
* Environment override for the deny probe's headless timeout (BAPI-722).
|
|
18
18
|
*
|
|
@@ -674,7 +674,11 @@ export function buildClaimManifest(report, options, freeSlots) {
|
|
|
674
674
|
// pick up repository-level qualification work it was never dedicated to.
|
|
675
675
|
// Gating the token on `repoWide` keeps that work on the executor whose
|
|
676
676
|
// operator chose the whole repository.
|
|
677
|
-
|
|
677
|
+
// BAPI-1698: the worker-database qualification capability rides the same
|
|
678
|
+
// repository-wide gate, beside the base token it extends.
|
|
679
|
+
...(options.repoWide === true
|
|
680
|
+
? [GATE_QUALIFICATION_CAPABILITY, GATE_QUALIFICATION_WORKER_DATABASE_CAPABILITY]
|
|
681
|
+
: []),
|
|
678
682
|
],
|
|
679
683
|
// BAPI-1391: an optional job-type filter, present only when configured. An
|
|
680
684
|
// older server rejects the key with a 422, so it must never appear by
|
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
* process the job started is still running. This module produces that
|
|
7
7
|
* confirmation as a closed `CompletionCleanup` verdict. The verdict is
|
|
8
8
|
* SUCCESS-BLOCKING: anything other than `confirmed` with zero survivors refuses
|
|
9
|
-
* success (`successRefusalReason` in `completion-contract.ts`)
|
|
9
|
+
* success (`successRefusalReason` in `completion-contract.ts`), with ONE
|
|
10
|
+
* exception (BAPI-1690): a `failed` verdict with a positive integer survivor
|
|
11
|
+
* count and exactly the single reason `survivors_detected` (`isAllStoppedCleanup`).
|
|
12
|
+
* That reason list is only produced when the sweep terminated every detected
|
|
13
|
+
* process and the confirmation sweep then found none remaining; any other
|
|
14
|
+
* reason (ownership_unverifiable, enumeration_failed, sweep_deadline_exhausted,
|
|
15
|
+
* not_run) means termination or confirmation is unproven and still blocks.
|
|
16
|
+
* The recorded verdict stays `failed`; the sweep logic is unchanged.
|
|
10
17
|
*
|
|
11
18
|
* WHAT THIS IS NOT. It is not the adapter's configuration lifecycle cleanup in
|
|
12
19
|
* `agent-launchers/executor-adapter.ts` (temporary config files, isolation
|
|
@@ -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. */
|
|
@@ -52,6 +52,7 @@ import { classifyMergeTree } from "./merge-tree-classifier.js";
|
|
|
52
52
|
import { RECONCILE_OVERLAP_PAYLOAD_SCHEMA_VERSION, } from "./reconcile-overlap-types.js";
|
|
53
53
|
import { runRequiredVerificationCommands } from "./required-verification.js";
|
|
54
54
|
import { validateWorkerFinalization } from "./worker-finalization.js";
|
|
55
|
+
import { captureExecutorMergeIndex, executorAllowedTreePathspecs, stageExecutorAllowedTree, unstageExecutorExcludedPaths, } from "./permissions.js";
|
|
55
56
|
import { payloadWorkerDatabaseConfigOption } from "./worker-database-config.js";
|
|
56
57
|
export const RECONCILE_OVERLAP_JOB_TYPE = "reconcile_overlap";
|
|
57
58
|
/** Result-envelope bounds, mirrored from the server's result model. */
|
|
@@ -81,17 +82,6 @@ const CI_WAIT_POLL_INTERVAL_MS = 30_000;
|
|
|
81
82
|
/** Finalization settling: GitHub updates a PR's head a moment after the push. */
|
|
82
83
|
const FINALIZATION_ATTEMPTS = 6;
|
|
83
84
|
const FINALIZATION_RETRY_DELAY_MS = 2_000;
|
|
84
|
-
/**
|
|
85
|
-
* Paths the wrapper never stages: the executor's own per-worktree artifacts. They
|
|
86
|
-
* are also excluded through `.git/info/exclude`, but a foreign repository's
|
|
87
|
-
* `.gitignore` may not name `.mcp.json`, so the pathspec is the second line.
|
|
88
|
-
*/
|
|
89
|
-
const WRAPPER_STAGE_EXCLUDES = [
|
|
90
|
-
":(exclude).conductor",
|
|
91
|
-
":(exclude).mcp.json",
|
|
92
|
-
":(exclude).cursor/mcp.json",
|
|
93
|
-
":(exclude).claude/settings.local.json",
|
|
94
|
-
];
|
|
95
85
|
const SHA_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
96
86
|
class PayloadError extends Error {
|
|
97
87
|
}
|
|
@@ -365,6 +355,9 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
365
355
|
failingCommandNames: [],
|
|
366
356
|
editedReasons: new Map(),
|
|
367
357
|
};
|
|
358
|
+
// BAPI-1732: the protected-path index state of THIS attempt's conflicted merge.
|
|
359
|
+
// `null` means "not captured", which is different from a captured empty snapshot.
|
|
360
|
+
let mergeSnapshot = null;
|
|
368
361
|
const commands = verificationCommandUnion(payload.child, payload.peer);
|
|
369
362
|
// BAPI-1521: the root payload's declaration, with presence kept (absent for an
|
|
370
363
|
// older payload, which keeps the compatibility constants).
|
|
@@ -543,15 +536,35 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
543
536
|
}
|
|
544
537
|
return runs;
|
|
545
538
|
};
|
|
539
|
+
/** The shared staging scope: the whole tree minus the executor's protected paths. */
|
|
540
|
+
const stageScope = () => executorAllowedTreePathspecs();
|
|
541
|
+
/**
|
|
542
|
+
* Run a shared index-protection helper through the abort- and budget-aware git
|
|
543
|
+
* wrapper. A cancellation propagates unchanged; any other failure is `false`.
|
|
544
|
+
*/
|
|
545
|
+
const protectIndex = async (ctx, run) => {
|
|
546
|
+
try {
|
|
547
|
+
await run((args) => git(ctx, args));
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
catch (err) {
|
|
551
|
+
if (err instanceof ReconcileOverlapAborted)
|
|
552
|
+
throw err;
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
546
556
|
const commitStaged = async (ctx, message) => {
|
|
547
557
|
const r = await git(ctx, ["commit", "--no-verify", "--no-edit", "-m", message]);
|
|
548
558
|
if (r.exitCode !== 0)
|
|
549
559
|
return null;
|
|
550
560
|
return revParse(ctx, "HEAD");
|
|
551
561
|
};
|
|
562
|
+
/** `true` when changes are staged, `false` when none, `null` when the check failed. */
|
|
552
563
|
const stagedChanges = async (ctx) => {
|
|
553
564
|
const r = await git(ctx, ["diff", "--cached", "--quiet"]);
|
|
554
|
-
|
|
565
|
+
if (r.exitCode === 0)
|
|
566
|
+
return false;
|
|
567
|
+
return r.exitCode === 1 ? true : null;
|
|
555
568
|
};
|
|
556
569
|
/** Read both remote heads immediately before the push. */
|
|
557
570
|
const readRemoteHeads = async (ctx) => {
|
|
@@ -590,7 +603,7 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
590
603
|
while (ctx.remainingMs() > CI_WAIT_MARGIN_MS && !ctx.signal.aborted) {
|
|
591
604
|
let response;
|
|
592
605
|
try {
|
|
593
|
-
response = await seams.pollProviderChecks(sha);
|
|
606
|
+
response = await seams.pollProviderChecks(sha, payload.requiredChecks);
|
|
594
607
|
}
|
|
595
608
|
catch (err) {
|
|
596
609
|
if (err instanceof ProviderChecksUnobservable)
|
|
@@ -755,6 +768,20 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
755
768
|
return finish(fail(ReconcileOverlapMergeFailed, "merged", "the merge did not record the required epic commit"));
|
|
756
769
|
}
|
|
757
770
|
if (classification.kind === "conflicted") {
|
|
771
|
+
mergeSnapshot = null;
|
|
772
|
+
let captured = null;
|
|
773
|
+
try {
|
|
774
|
+
captured = await captureExecutorMergeIndex((args) => git(ctx, args));
|
|
775
|
+
}
|
|
776
|
+
catch (err) {
|
|
777
|
+
if (err instanceof ReconcileOverlapAborted)
|
|
778
|
+
throw err;
|
|
779
|
+
}
|
|
780
|
+
if (captured === null) {
|
|
781
|
+
await resetToChildHead(ctx);
|
|
782
|
+
return finish(fail(ReconcileOverlapMergeFailed, "merged", "the merge's protected index state could not be captured"));
|
|
783
|
+
}
|
|
784
|
+
mergeSnapshot = captured;
|
|
758
785
|
facts.mode = "conflicted";
|
|
759
786
|
facts.workerInvoked = true;
|
|
760
787
|
facts.preWorkerHead = payload.childHead;
|
|
@@ -787,7 +814,7 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
787
814
|
await writeReport(ctx, conflictReport(failing));
|
|
788
815
|
// `.conductor/` holds the executor's own report for the worker; it is not a
|
|
789
816
|
// change to the candidate.
|
|
790
|
-
const status = await git(ctx, ["status", "--porcelain", "--",
|
|
817
|
+
const status = await git(ctx, ["status", "--porcelain", "--", ...stageScope()]);
|
|
791
818
|
if (status.exitCode !== 0 || status.stdout.trim().length > 0) {
|
|
792
819
|
await resetToChildHead(ctx);
|
|
793
820
|
return finish(fail(ReconcileOverlapMergeFailed, "checked", "the worktree was not clean at the merge commit"));
|
|
@@ -822,7 +849,20 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
822
849
|
// Stage ONLY the resolved conflict paths: the merge commit is the
|
|
823
850
|
// conflict resolution, and any other repair becomes its own commit.
|
|
824
851
|
if (conflictPaths.length > 0) {
|
|
825
|
-
|
|
852
|
+
// `-f`: a conflicted protected path is tracked and unmerged, but `info/exclude`
|
|
853
|
+
// also names it, and Git refuses an ignored path without it.
|
|
854
|
+
const staged = await git(ctx, ["add", "-A", "-f", "--", ...conflictPaths]);
|
|
855
|
+
if (staged.exitCode !== 0) {
|
|
856
|
+
await resetToChildHead(ctx);
|
|
857
|
+
return fail(ReconcileOverlapMergeFailed, "worker-completed", "the resolved conflict paths could not be staged");
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
// BAPI-1732: undo anything the worker staged in protected paths, while
|
|
861
|
+
// keeping what the merge itself put there and the worker's resolutions.
|
|
862
|
+
const snapshot = mergeSnapshot;
|
|
863
|
+
if (snapshot === null || !(await protectIndex(ctx, (gitCall) => unstageExecutorExcludedPaths(gitCall, snapshot)))) {
|
|
864
|
+
await resetToChildHead(ctx);
|
|
865
|
+
return fail(ReconcileOverlapMergeFailed, "worker-completed", "the merge's protected index state could not be restored");
|
|
826
866
|
}
|
|
827
867
|
const unmerged = await git(ctx, ["ls-files", "-u"]);
|
|
828
868
|
if (unmerged.exitCode !== 0 || unmerged.stdout.trim().length > 0) {
|
|
@@ -837,9 +877,22 @@ export function createReconcileOverlapDriver(job, payload, seams) {
|
|
|
837
877
|
facts.mergeCommitSha = mergeCommit;
|
|
838
878
|
}
|
|
839
879
|
// Any remaining worker repair: one ordinary commit ON TOP of the merge.
|
|
840
|
-
await
|
|
841
|
-
if (await
|
|
880
|
+
const repairStaged = await protectIndex(ctx, (gitCall) => stageExecutorAllowedTree(gitCall));
|
|
881
|
+
if (!repairStaged || !(await protectIndex(ctx, (gitCall) => unstageExecutorExcludedPaths(gitCall)))) {
|
|
882
|
+
await resetToChildHead(ctx);
|
|
883
|
+
return fail(ReconcileOverlapMergeFailed, "worker-completed", "the worker's repair could not be staged safely");
|
|
884
|
+
}
|
|
885
|
+
const repairChanges = await stagedChanges(ctx);
|
|
886
|
+
if (repairChanges === null) {
|
|
887
|
+
await resetToChildHead(ctx);
|
|
888
|
+
return fail(ReconcileOverlapMergeFailed, "worker-completed", "the staged repair could not be inspected");
|
|
889
|
+
}
|
|
890
|
+
if (repairChanges) {
|
|
842
891
|
const repairPaths = await git(ctx, ["diff", "--cached", "--name-only", "-z"]);
|
|
892
|
+
if (repairPaths.exitCode !== 0) {
|
|
893
|
+
await resetToChildHead(ctx);
|
|
894
|
+
return fail(ReconcileOverlapMergeFailed, "worker-completed", "the repair's paths could not be listed");
|
|
895
|
+
}
|
|
843
896
|
const repairReason = facts.failingCommandNames.length > 0
|
|
844
897
|
? `repair for failing check(s): ${facts.failingCommandNames.join(", ")}`
|
|
845
898
|
: "repair after conflict resolution";
|
|
@@ -111,9 +111,22 @@ export async function runRequiredVerificationCommands(input) {
|
|
|
111
111
|
outcome = "cancelled";
|
|
112
112
|
reason = input.ownershipHeld && !input.ownershipHeld() ? "ownership_lost" : "executor_cancelled";
|
|
113
113
|
break;
|
|
114
|
-
|
|
114
|
+
case "killed_by_signal":
|
|
115
|
+
// BAPI-1698: the command ran and was killed by a signal nobody requested.
|
|
116
|
+
// A failure like any non-zero exit, so it keeps the non-zero stop rule.
|
|
117
|
+
outcome = "exited_nonzero";
|
|
118
|
+
reason = "killed_by_signal";
|
|
119
|
+
break;
|
|
120
|
+
case "launch_error":
|
|
121
|
+
outcome = "launch_error";
|
|
122
|
+
reason = "spawn_failed";
|
|
123
|
+
break;
|
|
124
|
+
default: {
|
|
125
|
+
const unhandled = launched.outcome;
|
|
126
|
+
void unhandled;
|
|
115
127
|
outcome = "launch_error";
|
|
116
128
|
reason = "spawn_failed";
|
|
129
|
+
}
|
|
117
130
|
}
|
|
118
131
|
facts.push({
|
|
119
132
|
identity: command.identity,
|
|
@@ -276,12 +289,25 @@ export function createSupervisedCommandLauncher(input) {
|
|
|
276
289
|
drainDeadlineMs: CHECK_DRAIN_BOUND_MS,
|
|
277
290
|
});
|
|
278
291
|
const output = `${result.stdoutExcerpt}\n${result.stderrExcerpt}`;
|
|
292
|
+
// BAPI-1698 — the order is load-bearing. Only an executor-side request
|
|
293
|
+
// (an abort, a timeout, a requested termination) is an interruption; a
|
|
294
|
+
// process that never started is a launch error; a started process killed
|
|
295
|
+
// by a signal nobody requested is a failure of the command.
|
|
279
296
|
if (cancelled)
|
|
280
297
|
return { outcome: { kind: "cancelled" }, output };
|
|
281
298
|
if (result.classification === "timeout")
|
|
282
299
|
return { outcome: { kind: "timed_out" }, output };
|
|
300
|
+
if (controller.isTerminationRequested())
|
|
301
|
+
return { outcome: { kind: "cancelled" }, output };
|
|
302
|
+
if (proc.pid === undefined && result.exitCode === null) {
|
|
303
|
+
// The spawn boundary reports a failed start (a missing program or
|
|
304
|
+
// folder) as no pid and no exit code — never inferred from exit 127.
|
|
305
|
+
return { outcome: { kind: "launch_error" }, output };
|
|
306
|
+
}
|
|
307
|
+
if (result.signal !== null)
|
|
308
|
+
return { outcome: { kind: "killed_by_signal" }, output };
|
|
283
309
|
if (result.exitUnconfirmed || result.exitCode === null) {
|
|
284
|
-
//
|
|
310
|
+
// Vanished without an exit code we can trust: not an exit.
|
|
285
311
|
return { outcome: { kind: "cancelled" }, output };
|
|
286
312
|
}
|
|
287
313
|
return { outcome: { kind: "exited", exitCode: result.exitCode }, output };
|