@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
|
@@ -5,7 +5,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { findWorktreeByBranch, parseGitWorktreePorcelain } from "./worktree-inspection.js";
|
|
7
7
|
import { resolveExecutorBranch, configureExecutorBranch } from "./worktree.js";
|
|
8
|
-
import { renderWorkerVerificationGuidance, renderWorkerPrBaseGuidance, renderWorkerPushEachCommitGuidance, renderWorkerTimeBudgetGuidance } from "./worker-verification-guidance.js";
|
|
8
|
+
import { renderWorkerVerificationGuidance, renderWorkerPrBaseGuidance, renderWorkerPushEachCommitGuidance, renderWorkerTimeBudgetGuidance, } from "./worker-verification-guidance.js";
|
|
9
9
|
/**
|
|
10
10
|
* Claimed-job execution engine (BAPI-534 core, BAPI-535 job behaviors; TDD §7/§8/§9).
|
|
11
11
|
*
|
|
@@ -22,19 +22,18 @@ import { renderWorkerVerificationGuidance, renderWorkerPrBaseGuidance, renderWor
|
|
|
22
22
|
* `spec_review`, plus per-job worker-log tee, watch registry, and optional
|
|
23
23
|
* read-only viewer tabs wired around every spawned worker.
|
|
24
24
|
*/
|
|
25
|
-
import { rm, readdir, lstat, unlink, realpath, rename as fsRename, stat as fsStat } from "node:fs/promises";
|
|
26
|
-
import { accessSync, constants as fsConstants, realpathSync, statSync } from "node:fs";
|
|
27
|
-
import { provisionWorktreeSettingsExclude } from "./permissions.js";
|
|
25
|
+
import { rm, readdir, lstat, unlink, realpath, rename as fsRename, stat as fsStat, } from "node:fs/promises";
|
|
26
|
+
import { accessSync, constants as fsConstants, realpathSync, statSync, } from "node:fs";
|
|
27
|
+
import { provisionWorktreeSettingsExclude, } from "./permissions.js";
|
|
28
28
|
import os from "node:os";
|
|
29
29
|
import { runHeartbeatLoop, sendImmediateHeartbeat } from "./heartbeat.js";
|
|
30
|
+
import { createFlowProcess, runCiRerunExecutorJob, runGateQualificationExecutorJob, runMergeJob, runSmokeJob, sendTerminalMutationWithAuthReport, superviseProcess, terminalToRunResult, toWireClassification, } from "./job-type-wrappers.js";
|
|
31
|
+
export { DEFAULT_SMOKE_DURATION_MS, GATE_QUALIFICATION_SETTLE_MAX_MS, createFlowProcess, createMergeFlowProcess, createNoopProcess, defaultRunMergeForClaimed, runCiRerunExecutorJob, runGateQualificationExecutorJob, runMergeJob, runSmokeJob, sendTerminalMutationWithAuthReport, superviseProcess, terminalToRunResult, toWireClassification, } from "./job-type-wrappers.js";
|
|
30
32
|
import { cleanupReportPermitsRecordRemoval, retryWakeCleanupReport, submitCleanupReport, } from "./cleanup-report.js";
|
|
31
33
|
import { isExecutorNamedError, toExecutorFailure, RebaseNotVerified, secretFreeErrorMessage, secretFreeWorktreeMessage, WorktreeSetupRefused, MissingVerdictArtifact, PackagedRecipeUndeliverable, PreSpawnVerification, RequiredMcpRegistration, McpSurfaceMismatch, WorkerStartupFatal, WORKER_STARTUP_FATAL_MESSAGE, WorkerEndedWithPendingBackgroundWork, WORKER_ENDED_WITH_PENDING_BACKGROUND_WORK_MESSAGE, formatMcpSurfaceMismatch, ClaudeNotAuthenticated, CLAUDE_NOT_AUTHENTICATED_MESSAGE, ExecutorAdapterUnavailable, ExecutorNamedError, WorktreeBusy, StaleArtifactCleanupFailed, CiFixContext, WORKTREE_BUSY_MESSAGE, WorkerEnvFilePresent, WORKER_ENV_FILE_PRESENT_MESSAGE, } from "./job-errors.js";
|
|
32
|
-
import { buildConductorMergeAccessForExecutorJob, buildMergeLocalDepsForJob, runExecutorMergeJob, MERGE_RETRYABLE, MERGE_FAILED, MERGE_ACCESS_UNAVAILABLE, MERGE_FLOW_ERROR, MERGE_FLOW_TIMEOUT, MERGE_NO_OUTCOME, } from "./merge-job.js";
|
|
33
|
-
import { createProductionCiRerunDeps, runCiRerunJob, } from "./ci-rerun-job.js";
|
|
34
|
-
import { createProductionGateQualificationDeps, runGateQualificationJob, GATE_QUALIFICATION_FAILED, GATE_QUALIFICATION_INTERRUPTED, } from "./gate-qualification-job.js";
|
|
35
34
|
import { createObservationState } from "./observation.js";
|
|
36
35
|
import { getWorktreeMcpRegistrationTargets, normalizeWorktreePathForRegistration, provisionMcpRegistrationForWorktree, } from "../mcp-provisioning.js";
|
|
37
|
-
import { hasBridgeConsumer, legacyReferenceBackedTargets } from "../credential-delivery.js";
|
|
36
|
+
import { hasBridgeConsumer, legacyReferenceBackedTargets, } from "../credential-delivery.js";
|
|
38
37
|
import { credentialNoticeLines, formatCredentialAuditLines, prepareExecutorCredentialDelivery, readExecutorCredentialApprovals, } from "./credential-delivery-step.js";
|
|
39
38
|
import { resolveExecutorAgentAdapter } from "../agent-launchers/executor-adapter-registry.js";
|
|
40
39
|
import { redactAdapterDiagnostic } from "../agent-launchers/executor-adapter.js";
|
|
@@ -55,8 +54,7 @@ const WORKAROUND_CONTRACT_JOB_TYPES = new Set(["implement"]);
|
|
|
55
54
|
import { defaultResolveBinPath } from "../start-tickets-conductor.js";
|
|
56
55
|
/** The packaged bin basename of the deterministic worker guard (BAPI-1020). */
|
|
57
56
|
const WORKER_GUARD_BIN_FILENAME = "worker-guard-hook-bin.js";
|
|
58
|
-
import { buildGenericSuccessResult, CI_FIX_CLAIMS_STATUS_KEY, readCiFixResultArtifact, readCiFixTestRunsArtifact,
|
|
59
|
-
import { sendTerminalMutationWithRetry } from "./terminal-mutation.js";
|
|
57
|
+
import { buildGenericSuccessResult, CI_FIX_CLAIMS_STATUS_KEY, readCiFixResultArtifact, readCiFixTestRunsArtifact, commitResidue, readCompletionArtifacts, RESULT_JSONB_MAX_BYTES, resolveJobTimeoutSeconds, } from "./results.js";
|
|
60
58
|
import { removeStaleVerdictArtifacts } from "./stale-artifacts.js";
|
|
61
59
|
import { stripWorkerEnvFiles } from "./env-file-guard.js";
|
|
62
60
|
import { buildDependencyInstallEnv, payloadCiDatabase, payloadDependencyInstallOption, payloadPrePrChecksOption, payloadWorkerEnvOption, validateDependencyInstallDeclarations, } from "./env.js";
|
|
@@ -71,7 +69,7 @@ import { createWorkerLogClaimId, createWorkerLogTee, closeWorkerLogTee, distinct
|
|
|
71
69
|
import { acquireExecutorWorktreeLock, } from "./worktree-lock.js";
|
|
72
70
|
import { resolveExecutorStateDir, activateJobLog, deactivateJobLog, registerExecutorJobLog, markExecutorJobLogFinished, } from "./job-log-registry.js";
|
|
73
71
|
import { EXECUTOR_JOB_END_LOG_CHUNK, executorViewerTabsEnabled, openExecutorViewerTab, } from "./viewer-tabs.js";
|
|
74
|
-
import { isImplementationStyleJobType, isRecoveryJobType, isSpawnJobType } from "./job-types.js";
|
|
72
|
+
import { isImplementationStyleJobType, isRecoveryJobType, isSpawnJobType, } from "./job-types.js";
|
|
75
73
|
import { cleanupInterruptedWorktree } from "./interrupted-worktree.js";
|
|
76
74
|
import { lazyProviderCheckPoller, runReconcileOverlapJob, } from "./reconcile-overlap-job.js";
|
|
77
75
|
import { resolveExecutorJobBaseBranch } from "./base-branch.js";
|
|
@@ -106,8 +104,6 @@ const ENV_FILE_TRACKED_LOOKUP_TIMEOUT_MS = 5_000;
|
|
|
106
104
|
* exempted.
|
|
107
105
|
*/
|
|
108
106
|
const ENV_FILE_TRACKED_LOOKUP_FAILED_MESSAGE = "[executor] tracked env-file lookup unavailable; exempting nothing";
|
|
109
|
-
/** Default runtime for the no-op smoke process (ms). */
|
|
110
|
-
const DEFAULT_SMOKE_DURATION_MS = 100;
|
|
111
107
|
/**
|
|
112
108
|
* BAPI-1426: implementation-style job types that never read a delivery outcome.
|
|
113
109
|
* `reconcile_overlap`'s push is the wrapper's own, not a ticket delivery attempt.
|
|
@@ -195,9 +191,6 @@ function unresolvedKindsSuffix(envelope) {
|
|
|
195
191
|
const tokens = requiredWorkKindTokens(unresolvedRequiredTasks(envelope).map((task) => task.kind));
|
|
196
192
|
return tokens.length > 0 ? `; unresolved: ${tokens.join(", ")}` : "";
|
|
197
193
|
}
|
|
198
|
-
function toWireClassification(c) {
|
|
199
|
-
return c;
|
|
200
|
-
}
|
|
201
194
|
function classificationToErrorKind(c) {
|
|
202
195
|
switch (c) {
|
|
203
196
|
case "timeout":
|
|
@@ -634,85 +627,6 @@ async function checkAdapterMcpAdvisoryForPreparedWorktree(worktreePath, deps, ad
|
|
|
634
627
|
deps.errorLog("worker MCP advisory inspection did not complete; continuing without an advisory verdict");
|
|
635
628
|
}
|
|
636
629
|
}
|
|
637
|
-
/**
|
|
638
|
-
* Default merge dispatch: resolve Bridge API access, then run the deterministic
|
|
639
|
-
* merge. Exported for unit tests (access-resolution failure → retryable). The
|
|
640
|
-
* `controls.signal` (overall-timeout abort) is threaded into local merge deps
|
|
641
|
-
* without changing the local `gh` credential model.
|
|
642
|
-
*/
|
|
643
|
-
export async function defaultRunMergeForClaimed(job, deps, options, controls) {
|
|
644
|
-
const accessResult = await buildConductorMergeAccessForExecutorJob({
|
|
645
|
-
env: deps.env,
|
|
646
|
-
cwd: deps.cwd,
|
|
647
|
-
homedir: deps.homedir,
|
|
648
|
-
platform: deps.platform,
|
|
649
|
-
readFile: deps.readFile,
|
|
650
|
-
stat: deps.stat,
|
|
651
|
-
});
|
|
652
|
-
if (!accessResult.ok) {
|
|
653
|
-
// Access resolution feeds only the executor's read-only CI re-poll; a missing
|
|
654
|
-
// or temporarily-unavailable Bridge API access is transient infrastructure, so
|
|
655
|
-
// it is RETRYABLE (BAPI-572). The local `gh` credential model is unchanged.
|
|
656
|
-
return {
|
|
657
|
-
ok: false,
|
|
658
|
-
failure: {
|
|
659
|
-
error_kind: MERGE_RETRYABLE,
|
|
660
|
-
error_message: accessResult.error,
|
|
661
|
-
classification: "crashed",
|
|
662
|
-
telemetry: { failure_reason_code: MERGE_ACCESS_UNAVAILABLE },
|
|
663
|
-
},
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
return runExecutorMergeJob(job, {
|
|
667
|
-
access: accessResult.access,
|
|
668
|
-
// Thread the overall-timeout abort signal into local merge deps WITHOUT
|
|
669
|
-
// changing the local `gh` credential model (the signal is not a credential).
|
|
670
|
-
// BAPI-1453: the same signal bounds the post-`gh_pr_view_failed` permission
|
|
671
|
-
// probe, so it can never outlive the merge flow's own timeout.
|
|
672
|
-
// BAPI-1461: resolved when the job runs, with the stored-entry fallback for
|
|
673
|
-
// an executor started in the person's own session. A durable-host service
|
|
674
|
-
// executor declared itself with --scrub-inherited-github-credentials and
|
|
675
|
-
// never reads a stored GitHub credential.
|
|
676
|
-
localMergeDeps: await buildMergeLocalDepsForJob(job, deps, { allowStoredEntry: options.scrubInheritedGithubCredentials !== true }, controls?.signal),
|
|
677
|
-
// BAPI-951: the executor's own configured base — resolveExecutorJobBaseBranch
|
|
678
|
-
// (called inside runExecutorMergeJob) resolves the CHILD PR's base from the
|
|
679
|
-
// job's persisted run base, falling back to this value for a legacy job.
|
|
680
|
-
repositoryBaseBranch: options.baseBranch,
|
|
681
|
-
epicIntegrationAdvisoryLog: deps.errorLog,
|
|
682
|
-
diagnosticLog: deps.errorLog,
|
|
683
|
-
cwd: deps.cwd,
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
/** An in-memory owned process for the no-op `smoke` acceptance job. */
|
|
687
|
-
function createNoopProcess(deps, durationMs, message) {
|
|
688
|
-
let killResolve = null;
|
|
689
|
-
const killed = new Promise((res) => {
|
|
690
|
-
killResolve = res;
|
|
691
|
-
});
|
|
692
|
-
let done = false;
|
|
693
|
-
async function* stdout() {
|
|
694
|
-
if (message)
|
|
695
|
-
yield message;
|
|
696
|
-
}
|
|
697
|
-
return {
|
|
698
|
-
pid: undefined,
|
|
699
|
-
stdout: stdout(),
|
|
700
|
-
stderr: null,
|
|
701
|
-
async wait() {
|
|
702
|
-
const natural = deps
|
|
703
|
-
.sleep(durationMs)
|
|
704
|
-
.then(() => ({ exitCode: 0, signal: null }));
|
|
705
|
-
const result = await Promise.race([natural, killed]);
|
|
706
|
-
done = true;
|
|
707
|
-
return result;
|
|
708
|
-
},
|
|
709
|
-
kill(signal) {
|
|
710
|
-
if (done)
|
|
711
|
-
return;
|
|
712
|
-
killResolve?.({ exitCode: null, signal });
|
|
713
|
-
},
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
630
|
/**
|
|
717
631
|
* Bounded newline assembly of worker stdout into logical lines for a
|
|
718
632
|
* {@link RequiredWorkLedger} (BAPI-1301 covered path, BAPI-1364 legacy
|
|
@@ -807,132 +721,6 @@ export function createLedgerLineFeeder(ledger, onLine) {
|
|
|
807
721
|
},
|
|
808
722
|
};
|
|
809
723
|
}
|
|
810
|
-
/**
|
|
811
|
-
* Run the process and heartbeat loop concurrently; return the process outcome.
|
|
812
|
-
*
|
|
813
|
-
* BAPI-731: `serverStopRequested` is carried ALONGSIDE the process
|
|
814
|
-
* classification rather than folded into it. When the server cancels a run the
|
|
815
|
-
* worker is SIGKILLed, so its raw classification would read as `killed` — which
|
|
816
|
-
* the caller would otherwise report as a worker fault. Keeping the flag separate
|
|
817
|
-
* is what lets the caller report a deliberate server cancellation distinctly.
|
|
818
|
-
*/
|
|
819
|
-
async function superviseProcess(params) {
|
|
820
|
-
const isDoneRef = { value: false };
|
|
821
|
-
const heartbeatStop = new AbortController();
|
|
822
|
-
const heartbeatDeps = params.cancelHeartbeatSleepOnExit ? { ...params.deps, sleep: (ms) => new Promise((resolve) => {
|
|
823
|
-
if (heartbeatStop.signal.aborted) {
|
|
824
|
-
resolve();
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
let timer;
|
|
828
|
-
const done = () => { params.deps.clearTimer(timer); heartbeatStop.signal.removeEventListener("abort", done); resolve(); };
|
|
829
|
-
timer = params.deps.setTimer(done, ms);
|
|
830
|
-
heartbeatStop.signal.addEventListener("abort", done, { once: true });
|
|
831
|
-
}) } : params.deps;
|
|
832
|
-
const hb = runHeartbeatLoop({
|
|
833
|
-
job: params.job,
|
|
834
|
-
httpClient: params.httpClient,
|
|
835
|
-
options: params.options,
|
|
836
|
-
deps: heartbeatDeps,
|
|
837
|
-
ownership: params.ownership,
|
|
838
|
-
proc: params.proc,
|
|
839
|
-
observation: params.observation,
|
|
840
|
-
collectTelemetry: params.collectTelemetry,
|
|
841
|
-
collectRemoteMarker: params.collectRemoteMarker,
|
|
842
|
-
isDone: () => isDoneRef.value,
|
|
843
|
-
});
|
|
844
|
-
const mcpSurface = params.mcpSurface;
|
|
845
|
-
const result = await runProcessWithTimeout(params.proc, params.timeoutSeconds, params.deps, {
|
|
846
|
-
termGraceMs: params.options.termGraceMs,
|
|
847
|
-
...(params.terminationController
|
|
848
|
-
? { terminationController: params.terminationController }
|
|
849
|
-
: {}),
|
|
850
|
-
onStdout: (chunk) => {
|
|
851
|
-
params.observation.recordStdout(chunk);
|
|
852
|
-
params.onStdoutObserved?.(chunk);
|
|
853
|
-
},
|
|
854
|
-
...(mcpSurface
|
|
855
|
-
? {
|
|
856
|
-
onStdoutTerminationCheck: (chunk) => {
|
|
857
|
-
mcpSurface.observeStdout(chunk);
|
|
858
|
-
return mcpSurface.shouldTerminate();
|
|
859
|
-
},
|
|
860
|
-
}
|
|
861
|
-
: {}),
|
|
862
|
-
});
|
|
863
|
-
isDoneRef.value = true;
|
|
864
|
-
heartbeatStop.abort();
|
|
865
|
-
const loopOutcome = await hb;
|
|
866
|
-
if (params.recordProcessExit !== false)
|
|
867
|
-
params.observation.setExitCode(result.exitCode);
|
|
868
|
-
if (loopOutcome.kind === "auth_fatal") {
|
|
869
|
-
// BAPI-1021 (AC-5): notify the runner immediately with ONLY the bounded
|
|
870
|
-
// identifiers — never carried onto `result` itself, so the process's own
|
|
871
|
-
// classification/completion handling is unaffected and the job continues
|
|
872
|
-
// to drain normally.
|
|
873
|
-
params.control?.reportAuthFatal?.({
|
|
874
|
-
jobId: params.job.id,
|
|
875
|
-
repoName: params.job.repo_name,
|
|
876
|
-
category: "heartbeat",
|
|
877
|
-
httpStatus: loopOutcome.httpStatus,
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
return loopOutcome.kind === "server_stop"
|
|
881
|
-
? { ...result, serverStopRequested: true }
|
|
882
|
-
: result;
|
|
883
|
-
}
|
|
884
|
-
function terminalToRunResult(terminal, successStatus) {
|
|
885
|
-
switch (terminal.outcome) {
|
|
886
|
-
case "success":
|
|
887
|
-
return { status: successStatus };
|
|
888
|
-
case "invalid_job_result":
|
|
889
|
-
return { status: "failed", reason: "invalid_job_result" };
|
|
890
|
-
case "stale_claim":
|
|
891
|
-
return { status: "abandoned", reason: "stale_claim" };
|
|
892
|
-
case "abandoned":
|
|
893
|
-
return { status: "abandoned", reason: "deadman" };
|
|
894
|
-
case "skipped":
|
|
895
|
-
return { status: "abandoned", reason: "already_abandoned" };
|
|
896
|
-
case "auth_fatal":
|
|
897
|
-
// BAPI-1021 (AC-5): a halted authentication/access condition, not an
|
|
898
|
-
// ordinary job failure or a lost/stale claim — `reportAuthFatal` (called
|
|
899
|
-
// by the wrapper below, before this mapping runs) is what actually
|
|
900
|
-
// notifies the runner.
|
|
901
|
-
return { status: "abandoned", reason: "auth_fatal" };
|
|
902
|
-
case "completion_evidence_refused":
|
|
903
|
-
// BAPI-1590: the wrapper below hands this outcome to the caller only when
|
|
904
|
-
// that caller opted into the immediate `/fail` fallback, and that caller
|
|
905
|
-
// handles it before mapping. Reaching here means it did not, so keep the
|
|
906
|
-
// historical reading of a refused `/complete`: a lost claim.
|
|
907
|
-
return { status: "abandoned", reason: "stale_claim" };
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* BAPI-1021 (AC-5): send a terminal mutation via
|
|
912
|
-
* {@link sendTerminalMutationWithRetry}, and — on an `auth_fatal` outcome —
|
|
913
|
-
* notify the runner exactly once via `control.reportAuthFatal`, carrying ONLY
|
|
914
|
-
* the job ID, repository, operation category, and HTTP status. Every other
|
|
915
|
-
* outcome passes through completely unchanged.
|
|
916
|
-
*/
|
|
917
|
-
async function sendTerminalMutationWithAuthReport(params, job, control) {
|
|
918
|
-
const { completionEvidenceFallback, ...sendParams } = params;
|
|
919
|
-
const terminal = await sendTerminalMutationWithRetry(sendParams);
|
|
920
|
-
if (terminal.outcome === "completion_evidence_refused" && completionEvidenceFallback !== true) {
|
|
921
|
-
params.ownership.abandoned = true;
|
|
922
|
-
params.ownership.abandonReason = "stale_claim";
|
|
923
|
-
return { outcome: "stale_claim" };
|
|
924
|
-
}
|
|
925
|
-
if (terminal.outcome === "auth_fatal") {
|
|
926
|
-
const notice = {
|
|
927
|
-
jobId: job.id,
|
|
928
|
-
repoName: job.repo_name,
|
|
929
|
-
category: params.kind,
|
|
930
|
-
httpStatus: terminal.httpStatus,
|
|
931
|
-
};
|
|
932
|
-
control?.reportAuthFatal?.(notice);
|
|
933
|
-
}
|
|
934
|
-
return terminal;
|
|
935
|
-
}
|
|
936
724
|
/** Dispatch and run a single claimed job. */
|
|
937
725
|
/**
|
|
938
726
|
* Run ONE integration-correction worker under a spawn-job driver (BAPI-1259).
|
|
@@ -1087,507 +875,6 @@ control) {
|
|
|
1087
875
|
});
|
|
1088
876
|
return { status: "failed", reason: "unsupported_job_type" };
|
|
1089
877
|
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Bound on waiting for a killed `gate_qualification` body to finish its own
|
|
1092
|
-
* teardown (terminating a running command, removing the detached checkout)
|
|
1093
|
-
* before the terminal report is sent.
|
|
1094
|
-
*/
|
|
1095
|
-
const GATE_QUALIFICATION_SETTLE_MAX_MS = 180_000;
|
|
1096
|
-
/**
|
|
1097
|
-
* Run a deterministic `gate_qualification` job (BAPI-1391).
|
|
1098
|
-
*
|
|
1099
|
-
* The same lifecycle as {@link runCiRerunExecutorJob}: the payload timeout is
|
|
1100
|
-
* resolved first, the body runs as a flow under {@link superviseProcess} (the
|
|
1101
|
-
* one ownership, heartbeat, dead-man, and timeout protocol), and every terminal
|
|
1102
|
-
* report goes through {@link sendTerminalMutationWithAuthReport}.
|
|
1103
|
-
*
|
|
1104
|
-
* The completion carries only the bounded result envelope from
|
|
1105
|
-
* `gate-qualification-job.ts`. An inability goes to `/fail` with a closed
|
|
1106
|
-
* error kind and fixed text; command output never reaches either.
|
|
1107
|
-
*/
|
|
1108
|
-
async function runGateQualificationExecutorJob(job, httpClient, options, deps, ownership, observation, seams, control) {
|
|
1109
|
-
const timeout = resolveJobTimeoutSeconds(job, options.defaultJobTimeoutSeconds);
|
|
1110
|
-
if (!timeout.ok) {
|
|
1111
|
-
await httpClient.fail(job, {
|
|
1112
|
-
error_kind: "ContractError.Timeout",
|
|
1113
|
-
error_message: timeout.error,
|
|
1114
|
-
classification: "crashed",
|
|
1115
|
-
});
|
|
1116
|
-
return { status: "failed", reason: "timeout_contract" };
|
|
1117
|
-
}
|
|
1118
|
-
const timeoutSeconds = timeout.timeoutSeconds;
|
|
1119
|
-
const runGateQualification = seams.runGateQualification ??
|
|
1120
|
-
((claimed, input) => runGateQualificationJob(claimed, input, createProductionGateQualificationDeps({
|
|
1121
|
-
deps,
|
|
1122
|
-
options,
|
|
1123
|
-
registerLive: (controller) => control?.liveWorkers.register(controller),
|
|
1124
|
-
ownershipHeld: () => !ownership.abandoned,
|
|
1125
|
-
})));
|
|
1126
|
-
const flow = createFlowProcess((signal) => runGateQualification(job, { timeoutSeconds, signal }), (result) => result.ok);
|
|
1127
|
-
const procResult = await superviseProcess({
|
|
1128
|
-
job,
|
|
1129
|
-
httpClient,
|
|
1130
|
-
options,
|
|
1131
|
-
deps,
|
|
1132
|
-
ownership,
|
|
1133
|
-
observation,
|
|
1134
|
-
proc: flow.proc,
|
|
1135
|
-
timeoutSeconds,
|
|
1136
|
-
collectTelemetry: async () => ({}),
|
|
1137
|
-
control,
|
|
1138
|
-
});
|
|
1139
|
-
// A killed flow keeps running until its own `finally` has terminated any
|
|
1140
|
-
// command and removed the detached checkout. Wait for that, bounded, so the
|
|
1141
|
-
// terminal report never races the teardown of a checkout it describes.
|
|
1142
|
-
let settleTimer;
|
|
1143
|
-
try {
|
|
1144
|
-
await Promise.race([
|
|
1145
|
-
flow.settled,
|
|
1146
|
-
new Promise((resolve) => {
|
|
1147
|
-
settleTimer = deps.setTimer(resolve, GATE_QUALIFICATION_SETTLE_MAX_MS);
|
|
1148
|
-
}),
|
|
1149
|
-
]);
|
|
1150
|
-
}
|
|
1151
|
-
finally {
|
|
1152
|
-
if (settleTimer !== undefined)
|
|
1153
|
-
deps.clearTimer(settleTimer);
|
|
1154
|
-
}
|
|
1155
|
-
if (ownership.abandoned) {
|
|
1156
|
-
return { status: "abandoned", reason: ownership.abandonReason };
|
|
1157
|
-
}
|
|
1158
|
-
const sendFail = async (errorKind, message, classification) => {
|
|
1159
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1160
|
-
kind: "fail",
|
|
1161
|
-
send: () => httpClient.fail(job, {
|
|
1162
|
-
error_kind: errorKind,
|
|
1163
|
-
error_message: message,
|
|
1164
|
-
classification,
|
|
1165
|
-
telemetry: observation.snapshot(),
|
|
1166
|
-
}),
|
|
1167
|
-
deps,
|
|
1168
|
-
options,
|
|
1169
|
-
ownership,
|
|
1170
|
-
log: deps.log,
|
|
1171
|
-
}, job, control);
|
|
1172
|
-
return terminalToRunResult(terminal, "failed");
|
|
1173
|
-
};
|
|
1174
|
-
if (procResult.classification === "timeout") {
|
|
1175
|
-
return sendFail(GATE_QUALIFICATION_FAILED, "gate_qualification exceeded its job timeout", "timeout");
|
|
1176
|
-
}
|
|
1177
|
-
const outcome = flow.getOutcome();
|
|
1178
|
-
if (outcome === undefined) {
|
|
1179
|
-
// Killed without a timeout (a server stop) — the commands were cut short —
|
|
1180
|
-
// or the body threw, which it is built never to do.
|
|
1181
|
-
return procResult.serverStopRequested
|
|
1182
|
-
? sendFail(GATE_QUALIFICATION_INTERRUPTED, "gate qualification was stopped before it finished", "killed")
|
|
1183
|
-
: sendFail(GATE_QUALIFICATION_FAILED, "gate_qualification completed without an outcome", "crashed");
|
|
1184
|
-
}
|
|
1185
|
-
if (outcome.ok) {
|
|
1186
|
-
const completion = {
|
|
1187
|
-
job_type: "gate_qualification",
|
|
1188
|
-
exit_code: 0,
|
|
1189
|
-
classification: "clean_exit",
|
|
1190
|
-
// The bounded result envelope, verbatim. The backend model is
|
|
1191
|
-
// `extra="forbid"` and recomputes the outcome against the STORED payload.
|
|
1192
|
-
result: outcome.result,
|
|
1193
|
-
telemetry: observation.snapshot(),
|
|
1194
|
-
};
|
|
1195
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1196
|
-
kind: "complete",
|
|
1197
|
-
send: () => httpClient.complete(job, completion),
|
|
1198
|
-
deps,
|
|
1199
|
-
options,
|
|
1200
|
-
ownership,
|
|
1201
|
-
log: deps.log,
|
|
1202
|
-
}, job, control);
|
|
1203
|
-
return terminalToRunResult(terminal, "completed");
|
|
1204
|
-
}
|
|
1205
|
-
// An inability: a closed error kind and fixed text, never command output.
|
|
1206
|
-
return sendFail(outcome.failure.errorKind, outcome.failure.message, "crashed");
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Run a deterministic `ci_rerun` job (BAPI-1160).
|
|
1210
|
-
*
|
|
1211
|
-
* Supervised through the SAME ownership, heartbeat, dead-man, and timeout
|
|
1212
|
-
* protocol as {@link runMergeJob} — via {@link createFlowProcess} — so a
|
|
1213
|
-
* deterministic job is not a second, weaker lifecycle. The body itself spawns no
|
|
1214
|
-
* subprocess of its own beyond the bounded `gh` invocations inside
|
|
1215
|
-
* `ci-rerun-job.ts`, and there is NO fallback to a worker on failure.
|
|
1216
|
-
*
|
|
1217
|
-
* The completion carries only the job's fact envelope. It names no gate,
|
|
1218
|
-
* requests no transition, and asserts no verdict: the reconciler re-observes the
|
|
1219
|
-
* head independently and remains the sole transition authority (R14 rule 3).
|
|
1220
|
-
*/
|
|
1221
|
-
async function runCiRerunExecutorJob(job, httpClient, options, deps, ownership, observation, seams, control) {
|
|
1222
|
-
// Resolve + enforce payload.timeout_seconds BEFORE any provider work, exactly
|
|
1223
|
-
// as the merge branch does.
|
|
1224
|
-
const timeout = resolveJobTimeoutSeconds(job, options.defaultJobTimeoutSeconds);
|
|
1225
|
-
if (!timeout.ok) {
|
|
1226
|
-
await httpClient.fail(job, {
|
|
1227
|
-
error_kind: "ContractError.Timeout",
|
|
1228
|
-
error_message: timeout.error,
|
|
1229
|
-
classification: "crashed",
|
|
1230
|
-
});
|
|
1231
|
-
return { status: "failed", reason: "timeout_contract" };
|
|
1232
|
-
}
|
|
1233
|
-
const runCiRerun = seams.runCiRerun ??
|
|
1234
|
-
((payload) => runCiRerunJob(payload, createProductionCiRerunDeps()));
|
|
1235
|
-
const flow = createFlowProcess(() => runCiRerun(job.payload), (result) => result.ok);
|
|
1236
|
-
const procResult = await superviseProcess({
|
|
1237
|
-
job,
|
|
1238
|
-
httpClient,
|
|
1239
|
-
options,
|
|
1240
|
-
deps,
|
|
1241
|
-
ownership,
|
|
1242
|
-
observation,
|
|
1243
|
-
proc: flow.proc,
|
|
1244
|
-
timeoutSeconds: timeout.timeoutSeconds,
|
|
1245
|
-
collectTelemetry: async () => ({}),
|
|
1246
|
-
control,
|
|
1247
|
-
});
|
|
1248
|
-
if (ownership.abandoned) {
|
|
1249
|
-
return { status: "abandoned", reason: ownership.abandonReason };
|
|
1250
|
-
}
|
|
1251
|
-
if (procResult.classification === "timeout") {
|
|
1252
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1253
|
-
kind: "fail",
|
|
1254
|
-
send: () => httpClient.fail(job, {
|
|
1255
|
-
error_kind: "CiRerunFailed",
|
|
1256
|
-
error_message: "ci_rerun exceeded its job timeout",
|
|
1257
|
-
classification: "timeout",
|
|
1258
|
-
telemetry: observation.snapshot(),
|
|
1259
|
-
}),
|
|
1260
|
-
deps,
|
|
1261
|
-
options,
|
|
1262
|
-
ownership,
|
|
1263
|
-
log: deps.log,
|
|
1264
|
-
}, job, control);
|
|
1265
|
-
return terminalToRunResult(terminal, "failed");
|
|
1266
|
-
}
|
|
1267
|
-
const outcome = flow.getOutcome();
|
|
1268
|
-
if (outcome === undefined) {
|
|
1269
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1270
|
-
kind: "fail",
|
|
1271
|
-
send: () => httpClient.fail(job, {
|
|
1272
|
-
error_kind: "CiRerunFailed",
|
|
1273
|
-
error_message: "ci_rerun completed without an outcome",
|
|
1274
|
-
classification: "crashed",
|
|
1275
|
-
telemetry: observation.snapshot(),
|
|
1276
|
-
}),
|
|
1277
|
-
deps,
|
|
1278
|
-
options,
|
|
1279
|
-
ownership,
|
|
1280
|
-
log: deps.log,
|
|
1281
|
-
}, job, control);
|
|
1282
|
-
return terminalToRunResult(terminal, "failed");
|
|
1283
|
-
}
|
|
1284
|
-
if (outcome.ok) {
|
|
1285
|
-
const completion = {
|
|
1286
|
-
job_type: "ci_rerun",
|
|
1287
|
-
exit_code: 0,
|
|
1288
|
-
classification: "clean_exit",
|
|
1289
|
-
// The FACT ENVELOPE, verbatim. No gate, no transition, no verdict — the
|
|
1290
|
-
// backend model is `extra="forbid"`, so anything else fails validation
|
|
1291
|
-
// rather than being silently ignored.
|
|
1292
|
-
result: outcome.result,
|
|
1293
|
-
telemetry: observation.snapshot(),
|
|
1294
|
-
};
|
|
1295
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1296
|
-
kind: "complete",
|
|
1297
|
-
send: () => httpClient.complete(job, completion),
|
|
1298
|
-
deps,
|
|
1299
|
-
options,
|
|
1300
|
-
ownership,
|
|
1301
|
-
log: deps.log,
|
|
1302
|
-
}, job, control);
|
|
1303
|
-
return terminalToRunResult(terminal, "completed");
|
|
1304
|
-
}
|
|
1305
|
-
// A refused or failed re-run. The reserved infrastructure attempt stays
|
|
1306
|
-
// CONSUMED — see `ci-rerun-job.ts` — and the reason is a closed token, never
|
|
1307
|
-
// provider text.
|
|
1308
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1309
|
-
kind: "fail",
|
|
1310
|
-
send: () => httpClient.fail(job, {
|
|
1311
|
-
error_kind: outcome.failure.errorKind,
|
|
1312
|
-
error_message: outcome.failure.reason,
|
|
1313
|
-
classification: "crashed",
|
|
1314
|
-
telemetry: observation.snapshot(),
|
|
1315
|
-
}),
|
|
1316
|
-
deps,
|
|
1317
|
-
options,
|
|
1318
|
-
ownership,
|
|
1319
|
-
log: deps.log,
|
|
1320
|
-
}, job, control);
|
|
1321
|
-
return terminalToRunResult(terminal, "failed");
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* Adapt a `runMerge(...)` promise into an {@link OwnedChildProcess} so the merge
|
|
1325
|
-
* flow is supervised by the SAME heartbeat/deadman/timeout path as spawn/smoke
|
|
1326
|
-
* jobs even though it spawns no worker. `wait()` resolves when the merge outcome
|
|
1327
|
-
* is available (exit_code 0 on `ok`, 1 otherwise); `kill()` aborts the internal
|
|
1328
|
-
* {@link AbortController} (cancelling in-flight local `gh` work) and resolves the
|
|
1329
|
-
* owned process as killed. The stored outcome/error let the runner map the
|
|
1330
|
-
* supervised result to `/complete` or `/fail` afterwards (killed/timeout is read
|
|
1331
|
-
* from the supervised `ProcessRunResult`/`ownership`, not from this adapter).
|
|
1332
|
-
*/
|
|
1333
|
-
function createMergeFlowProcess(startMerge) {
|
|
1334
|
-
const flow = createFlowProcess(startMerge, (result) => result.ok);
|
|
1335
|
-
return { proc: flow.proc, getOutcome: flow.getOutcome, getError: flow.getError };
|
|
1336
|
-
}
|
|
1337
|
-
/**
|
|
1338
|
-
* The generic form of {@link createMergeFlowProcess} (BAPI-1152): adapt any
|
|
1339
|
-
* in-process flow into an {@link OwnedChildProcess} so it is supervised by the
|
|
1340
|
-
* SAME heartbeat/deadman/timeout path as a worker. `settled` resolves once the
|
|
1341
|
-
* flow's own promise has settled — after a timeout or kill the supervised
|
|
1342
|
-
* process resolves immediately, but the flow may still be finishing a bounded
|
|
1343
|
-
* subprocess, and a caller that is about to reset the worktree must wait for it.
|
|
1344
|
-
*/
|
|
1345
|
-
function createFlowProcess(start, isOk) {
|
|
1346
|
-
const controller = new AbortController();
|
|
1347
|
-
let outcome;
|
|
1348
|
-
let error;
|
|
1349
|
-
let done = false;
|
|
1350
|
-
let settleWait = () => { };
|
|
1351
|
-
const waitPromise = new Promise((resolve) => {
|
|
1352
|
-
settleWait = resolve;
|
|
1353
|
-
});
|
|
1354
|
-
// Start the flow immediately; capture its resolution/rejection.
|
|
1355
|
-
const settled = start(controller.signal).then((result) => {
|
|
1356
|
-
outcome = result;
|
|
1357
|
-
if (!done) {
|
|
1358
|
-
done = true;
|
|
1359
|
-
settleWait({ exitCode: isOk(result) ? 0 : 1, signal: null });
|
|
1360
|
-
}
|
|
1361
|
-
}, (err) => {
|
|
1362
|
-
error = err;
|
|
1363
|
-
if (!done) {
|
|
1364
|
-
done = true;
|
|
1365
|
-
settleWait({ exitCode: 1, signal: null });
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1368
|
-
const proc = {
|
|
1369
|
-
pid: undefined,
|
|
1370
|
-
stdout: null,
|
|
1371
|
-
stderr: null,
|
|
1372
|
-
async wait() {
|
|
1373
|
-
return waitPromise;
|
|
1374
|
-
},
|
|
1375
|
-
kill(signal) {
|
|
1376
|
-
if (done)
|
|
1377
|
-
return;
|
|
1378
|
-
controller.abort();
|
|
1379
|
-
done = true;
|
|
1380
|
-
settleWait({ exitCode: null, signal });
|
|
1381
|
-
},
|
|
1382
|
-
};
|
|
1383
|
-
return {
|
|
1384
|
-
proc,
|
|
1385
|
-
getOutcome: () => outcome,
|
|
1386
|
-
getError: () => error,
|
|
1387
|
-
settled,
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* Run a deterministic `merge` job: NO worktree ensured, NO worker spawned. Unlike
|
|
1392
|
-
* the pre-BAPI-572 version, the merge flow now runs under the SHARED heartbeat/
|
|
1393
|
-
* deadman/timeout supervision path (via {@link superviseProcess}) so a live merge
|
|
1394
|
-
* heartbeats (the janitor never re-queues a healthy multi-minute merge) and the
|
|
1395
|
-
* whole flow honors `payload.timeout_seconds`. A timeout is reported as a
|
|
1396
|
-
* RETRYABLE failure and a late merge resolution after timeout/abandonment is
|
|
1397
|
-
* ignored. The local merge executor's outcome otherwise drives `/complete`
|
|
1398
|
-
* (success) or `/fail`; stale/retry/invalid terminal outcomes reuse T3a handling.
|
|
1399
|
-
*/
|
|
1400
|
-
async function runMergeJob(job, httpClient, options, deps, ownership, observation, seams, control) {
|
|
1401
|
-
// Resolve + enforce payload.timeout_seconds BEFORE starting any merge work.
|
|
1402
|
-
const timeout = resolveJobTimeoutSeconds(job, options.defaultJobTimeoutSeconds);
|
|
1403
|
-
if (!timeout.ok) {
|
|
1404
|
-
await httpClient.fail(job, {
|
|
1405
|
-
error_kind: "ContractError.Timeout",
|
|
1406
|
-
error_message: timeout.error,
|
|
1407
|
-
classification: "crashed",
|
|
1408
|
-
});
|
|
1409
|
-
return { status: "failed", reason: "timeout_contract" };
|
|
1410
|
-
}
|
|
1411
|
-
const timeoutSeconds = timeout.timeoutSeconds;
|
|
1412
|
-
const runMerge = seams.runMerge ?? defaultRunMergeForClaimed;
|
|
1413
|
-
const flow = createMergeFlowProcess((signal) => runMerge(job, deps, options, { signal }));
|
|
1414
|
-
const procResult = await superviseProcess({
|
|
1415
|
-
job,
|
|
1416
|
-
httpClient,
|
|
1417
|
-
options,
|
|
1418
|
-
deps,
|
|
1419
|
-
ownership,
|
|
1420
|
-
observation,
|
|
1421
|
-
proc: flow.proc,
|
|
1422
|
-
timeoutSeconds,
|
|
1423
|
-
collectTelemetry: async () => ({}),
|
|
1424
|
-
control,
|
|
1425
|
-
});
|
|
1426
|
-
// Ownership abandonment (stale-claim / dead-man) wins: never send a terminal
|
|
1427
|
-
// mutation for a claim we no longer own, and never process a late outcome.
|
|
1428
|
-
if (ownership.abandoned) {
|
|
1429
|
-
return { status: "abandoned", reason: ownership.abandonReason };
|
|
1430
|
-
}
|
|
1431
|
-
// Overall merge flow timed out: fail the active claim as RETRYABLE and ignore
|
|
1432
|
-
// any later merge promise resolution (the abort has already been signalled).
|
|
1433
|
-
if (procResult.classification === "timeout") {
|
|
1434
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1435
|
-
kind: "fail",
|
|
1436
|
-
send: () => httpClient.fail(job, {
|
|
1437
|
-
error_kind: MERGE_RETRYABLE,
|
|
1438
|
-
error_message: `merge flow timed out after ${timeoutSeconds} seconds`,
|
|
1439
|
-
classification: "timeout",
|
|
1440
|
-
telemetry: { failure_reason_code: MERGE_FLOW_TIMEOUT, ...observation.snapshot() },
|
|
1441
|
-
}),
|
|
1442
|
-
deps,
|
|
1443
|
-
options,
|
|
1444
|
-
ownership,
|
|
1445
|
-
log: deps.log,
|
|
1446
|
-
}, job, control);
|
|
1447
|
-
return terminalToRunResult(terminal, "failed");
|
|
1448
|
-
}
|
|
1449
|
-
// A thrown error inside the merge flow maps to a bounded MergeFailed.
|
|
1450
|
-
const flowError = flow.getError();
|
|
1451
|
-
if (flowError !== undefined) {
|
|
1452
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1453
|
-
kind: "fail",
|
|
1454
|
-
send: () => httpClient.fail(job, {
|
|
1455
|
-
error_kind: MERGE_FAILED,
|
|
1456
|
-
error_message: secretFreeErrorMessage(flowError),
|
|
1457
|
-
classification: "crashed",
|
|
1458
|
-
telemetry: { failure_reason_code: MERGE_FLOW_ERROR, ...observation.snapshot() },
|
|
1459
|
-
}),
|
|
1460
|
-
deps,
|
|
1461
|
-
options,
|
|
1462
|
-
ownership,
|
|
1463
|
-
log: deps.log,
|
|
1464
|
-
}, job, control);
|
|
1465
|
-
return terminalToRunResult(terminal, "failed");
|
|
1466
|
-
}
|
|
1467
|
-
const outcome = flow.getOutcome();
|
|
1468
|
-
if (outcome === undefined) {
|
|
1469
|
-
// Clean process result with no stored outcome — an internal invariant break;
|
|
1470
|
-
// fail loud rather than silently reporting success.
|
|
1471
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1472
|
-
kind: "fail",
|
|
1473
|
-
send: () => httpClient.fail(job, {
|
|
1474
|
-
error_kind: MERGE_FAILED,
|
|
1475
|
-
error_message: "merge flow completed without an outcome",
|
|
1476
|
-
classification: "crashed",
|
|
1477
|
-
telemetry: { failure_reason_code: MERGE_NO_OUTCOME, ...observation.snapshot() },
|
|
1478
|
-
}),
|
|
1479
|
-
deps,
|
|
1480
|
-
options,
|
|
1481
|
-
ownership,
|
|
1482
|
-
log: deps.log,
|
|
1483
|
-
}, job, control);
|
|
1484
|
-
return terminalToRunResult(terminal, "failed");
|
|
1485
|
-
}
|
|
1486
|
-
if (outcome.ok) {
|
|
1487
|
-
const completion = {
|
|
1488
|
-
job_type: "merge",
|
|
1489
|
-
exit_code: 0,
|
|
1490
|
-
classification: "clean_exit",
|
|
1491
|
-
result: outcome.result,
|
|
1492
|
-
telemetry: observation.snapshot(),
|
|
1493
|
-
};
|
|
1494
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1495
|
-
kind: "complete",
|
|
1496
|
-
send: () => httpClient.complete(job, completion),
|
|
1497
|
-
deps,
|
|
1498
|
-
options,
|
|
1499
|
-
ownership,
|
|
1500
|
-
log: deps.log,
|
|
1501
|
-
}, job, control);
|
|
1502
|
-
return terminalToRunResult(terminal, "completed");
|
|
1503
|
-
}
|
|
1504
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1505
|
-
kind: "fail",
|
|
1506
|
-
// BAPI-1453: MERGE the builder's telemetry with the snapshot rather than
|
|
1507
|
-
// replacing it, so `failure_reason_code` survives. Observation state never
|
|
1508
|
-
// carries a code, so the snapshot cannot overwrite it.
|
|
1509
|
-
send: () => httpClient.fail(job, {
|
|
1510
|
-
...outcome.failure,
|
|
1511
|
-
telemetry: { ...outcome.failure.telemetry, ...observation.snapshot() },
|
|
1512
|
-
}),
|
|
1513
|
-
deps,
|
|
1514
|
-
options,
|
|
1515
|
-
ownership,
|
|
1516
|
-
log: deps.log,
|
|
1517
|
-
}, job, control);
|
|
1518
|
-
return terminalToRunResult(terminal, "failed");
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
* BAPI-724 design note (deliberate, not an accidental AC-5 gap): `smoke` stays
|
|
1522
|
-
* on this no-worktree, no-real-worker-LLM `createNoopProcess` path and does
|
|
1523
|
-
* NOT receive MCP registration. The ratified requirement anchors MCP
|
|
1524
|
-
* provisioning to "the executor's worktree-preparation path
|
|
1525
|
-
* (`job-runner.ts`), alongside the existing deny-layer provisioning call"
|
|
1526
|
-
* (which BAPI-781 moved behind the adapter's `provisionWorktreeDenyLayer` hook)
|
|
1527
|
-
* — that call, like the new MCP provisioning call, exists ONLY inside
|
|
1528
|
-
* `runSpawnJob`, which `smoke` never reaches (see `isSpawnJobType` /
|
|
1529
|
-
* `job-types.ts`, and this module's own "no real worker LLM" framing of the
|
|
1530
|
-
* acceptance spine). Converting smoke into a worktree-having, worker-spawning
|
|
1531
|
-
* job to give it something to register MCP into would be a materially larger,
|
|
1532
|
-
* unratified change to that architectural boundary, not a wiring task.
|
|
1533
|
-
*/
|
|
1534
|
-
async function runSmokeJob(job, httpClient, options, deps, ownership, observation, control) {
|
|
1535
|
-
const timeout = resolveJobTimeoutSeconds(job, options.defaultJobTimeoutSeconds);
|
|
1536
|
-
if (!timeout.ok) {
|
|
1537
|
-
// Consistent with runSpawnJob: a timeout-contract failure fails the job
|
|
1538
|
-
// rather than silently substituting a default.
|
|
1539
|
-
await httpClient.fail(job, {
|
|
1540
|
-
error_kind: "ContractError.Timeout",
|
|
1541
|
-
error_message: timeout.error,
|
|
1542
|
-
classification: "crashed",
|
|
1543
|
-
});
|
|
1544
|
-
return { status: "failed", reason: "timeout_contract" };
|
|
1545
|
-
}
|
|
1546
|
-
const timeoutSeconds = timeout.timeoutSeconds;
|
|
1547
|
-
const payload = job.payload && typeof job.payload === "object" ? job.payload : {};
|
|
1548
|
-
const durationMs = typeof payload.duration_ms === "number" && payload.duration_ms > 0
|
|
1549
|
-
? payload.duration_ms
|
|
1550
|
-
: DEFAULT_SMOKE_DURATION_MS;
|
|
1551
|
-
const message = typeof payload.message === "string" ? payload.message : "smoke ok";
|
|
1552
|
-
const proc = createNoopProcess(deps, durationMs, message);
|
|
1553
|
-
const procResult = await superviseProcess({
|
|
1554
|
-
job,
|
|
1555
|
-
httpClient,
|
|
1556
|
-
options,
|
|
1557
|
-
deps,
|
|
1558
|
-
ownership,
|
|
1559
|
-
observation,
|
|
1560
|
-
proc,
|
|
1561
|
-
timeoutSeconds,
|
|
1562
|
-
collectTelemetry: async () => ({}),
|
|
1563
|
-
control,
|
|
1564
|
-
});
|
|
1565
|
-
if (ownership.abandoned) {
|
|
1566
|
-
return { status: "abandoned", reason: ownership.abandonReason };
|
|
1567
|
-
}
|
|
1568
|
-
const evidence = {
|
|
1569
|
-
message,
|
|
1570
|
-
exit_code: procResult.exitCode,
|
|
1571
|
-
classification: procResult.classification,
|
|
1572
|
-
};
|
|
1573
|
-
const result = buildSmokeResult(evidence, procResult.classification === "clean_exit" ? "pass" : "fail");
|
|
1574
|
-
const completion = {
|
|
1575
|
-
job_type: "smoke",
|
|
1576
|
-
exit_code: procResult.exitCode ?? 0,
|
|
1577
|
-
classification: toWireClassification(procResult.classification),
|
|
1578
|
-
result,
|
|
1579
|
-
telemetry: observation.snapshot(),
|
|
1580
|
-
};
|
|
1581
|
-
const terminal = await sendTerminalMutationWithAuthReport({
|
|
1582
|
-
kind: "complete",
|
|
1583
|
-
send: () => httpClient.complete(job, completion),
|
|
1584
|
-
deps,
|
|
1585
|
-
options,
|
|
1586
|
-
ownership,
|
|
1587
|
-
log: deps.log,
|
|
1588
|
-
}, job, control);
|
|
1589
|
-
return terminalToRunResult(terminal, "completed");
|
|
1590
|
-
}
|
|
1591
878
|
/** Build the reconcile module's seams from executor deps (BAPI-1152). */
|
|
1592
879
|
function buildReconcileOverlapSeams(deps) {
|
|
1593
880
|
return {
|
|
@@ -2407,7 +1694,10 @@ async function superviseFocusedRebaseWait(params) {
|
|
|
2407
1694
|
platform: deps.platform,
|
|
2408
1695
|
readFile: deps.readFile,
|
|
2409
1696
|
stat: deps.stat,
|
|
2410
|
-
}
|
|
1697
|
+
},
|
|
1698
|
+
// BAPI-1527: the rebase's own required-check list, so a repository with no
|
|
1699
|
+
// CI check cache is still read from live provider evidence.
|
|
1700
|
+
params.context.requiredChecks);
|
|
2411
1701
|
const phase = await superviseDriverPhase({
|
|
2412
1702
|
job,
|
|
2413
1703
|
httpClient,
|