@bridge_gpt/mcp-server 0.2.70 → 0.2.72
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 +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +29 -4
- package/build/agent-notes.js +171 -95
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +12 -2
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +17 -5
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +776 -23
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +93 -13
- package/build/conductor/epic-implementer-cli.js +55 -2
- package/build/conductor/gate-discovery.js +659 -19
- package/build/conductor/gate-settings-review.js +751 -0
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +16 -11
- package/build/conductor/launch-plan.js +185 -0
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +25 -9
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +281 -14
- package/build/conductor/recovery-operations.js +78 -5
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +240 -56
- package/build/epic-ci-workflow-drift.js +71 -23
- package/build/epic-ci-workflow-install.js +83 -26
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +174 -13
- package/build/epic-implementer-bin.js +119 -44
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +274 -5
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +355 -36
- package/build/executor/likely-tests.js +100 -98
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +84 -15
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +188 -1
- package/build/executor/worker-database.js +299 -40
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +64 -0
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +767 -310
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +416 -41
- package/build/install-bridge-conductor-setup.js +135 -32
- package/build/install-bridge-conductor.js +769 -353
- package/build/install-bridge.js +419 -124
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +22 -2
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-execution-ledger.js +171 -10
- package/build/plane/plane-freshness.js +12 -9
- package/build/plane/preflight.js +19 -0
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +31 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +623 -0
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +26 -9
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +61 -80
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +80 -4
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER.md +43 -0
- package/docs/epic-implementer/getting-started.md +95 -14
- package/package.json +2 -2
|
@@ -46,7 +46,7 @@ export const EPIC_LAUNCH_PROFILE_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]{0,62}$/;
|
|
|
46
46
|
export const EPIC_LAUNCH_EXECUTION_MODES = ["local", "durable"];
|
|
47
47
|
/** One-time migration guidance for a profile this build cannot read. */
|
|
48
48
|
export function epicLaunchProfileSetupGuidance(name) {
|
|
49
|
-
return (`Re-run guided setup to (re)write it: npx -y ${MCP_PACKAGE_NAME} install
|
|
49
|
+
return (`Re-run guided setup to (re)write it: npx -y ${MCP_PACKAGE_NAME} install epic-implementer ` +
|
|
50
50
|
`--launch-profile ${EPIC_LAUNCH_PROFILE_NAME_PATTERN.test(name) ? diagnosticComponent(name) : "<name>"} --base-url <url> ...`);
|
|
51
51
|
}
|
|
52
52
|
// ---------------------------------------------------------------------------
|
|
@@ -31,6 +31,16 @@
|
|
|
31
31
|
* is actuated by the executor machine's own `gh`, so no token, credential
|
|
32
32
|
* bundle, or environment credential is injected, added to argv, or returned.
|
|
33
33
|
*
|
|
34
|
+
* BAPI-1523 adds a second, check-run variant. When a no-push repair is held for an
|
|
35
|
+
* external CI provider, the server asks the executor to send ONE
|
|
36
|
+
* `POST repos/<owner>/<repo>/check-runs/<id>/rerequest` through the same ambient
|
|
37
|
+
* `gh`. It has no polling, no worktree, and no transition authority. It reports
|
|
38
|
+
* only `rerequested`, or `not_rerequestable` with a closed `forbidden` /
|
|
39
|
+
* `not_found` reason for a reliably identified HTTP 403 / 404. Anything else —
|
|
40
|
+
* 422, a timeout, a network, authentication, rate-limit, or server failure — is a
|
|
41
|
+
* closed job failure the server records as `rerequest_not_performed`. An absent
|
|
42
|
+
* `variant` is the workflow-run form above, so existing payloads stay valid.
|
|
43
|
+
*
|
|
34
44
|
* Diagnostics go to `console.error` only. MCP stdout is a protocol channel and
|
|
35
45
|
* writing child output to it corrupts the session.
|
|
36
46
|
*/
|
|
@@ -45,6 +55,10 @@ export const CI_RERUN_POLL_DEADLINE_MS = 3 * 60 * 1000;
|
|
|
45
55
|
export const CI_RERUN_POLL_INTERVAL_MS = 10 * 1000;
|
|
46
56
|
/** Per-`gh`-invocation timeout. */
|
|
47
57
|
export const CI_RERUN_GH_TIMEOUT_MS = 60 * 1000;
|
|
58
|
+
/** Bounds aligned with the Python result boundary (`CI_RERUN_LANE_MAX_CHARS`). */
|
|
59
|
+
export const CI_RERUN_LANE_MAX_CHARS = 200;
|
|
60
|
+
const CI_RERUN_APP_SLUG_MAX_CHARS = 100;
|
|
61
|
+
const GITHUB_ACTIONS_APP_SLUG = "github-actions";
|
|
48
62
|
const OWNER_REPO_RE = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
|
49
63
|
const CLAUDE_REVIEW_WORKFLOW_BASENAME = CLAUDE_REVIEW_WORKFLOW_RELPATH.split("/").pop() ?? "claude-review.yml";
|
|
50
64
|
/**
|
|
@@ -66,6 +80,44 @@ export function identifiesClaudeReviewWorkflow(identity) {
|
|
|
66
80
|
normalized.includes("claude-review") ||
|
|
67
81
|
normalized.includes("claude review"));
|
|
68
82
|
}
|
|
83
|
+
function hasControlCharacter(value) {
|
|
84
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
85
|
+
const code = value.charCodeAt(i);
|
|
86
|
+
if (code < 32 || code === 127)
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
function isPositiveSafeInteger(value) {
|
|
92
|
+
return (typeof value === "number" &&
|
|
93
|
+
Number.isSafeInteger(value) &&
|
|
94
|
+
value > 0);
|
|
95
|
+
}
|
|
96
|
+
/** A bounded, printable lane: non-empty, within the Python bound, no control characters. */
|
|
97
|
+
function validLane(value) {
|
|
98
|
+
if (typeof value !== "string")
|
|
99
|
+
return null;
|
|
100
|
+
const trimmed = value.trim();
|
|
101
|
+
if (!trimmed || trimmed.length > CI_RERUN_LANE_MAX_CHARS)
|
|
102
|
+
return null;
|
|
103
|
+
if (hasControlCharacter(trimmed))
|
|
104
|
+
return null;
|
|
105
|
+
return trimmed;
|
|
106
|
+
}
|
|
107
|
+
/** A normalized `owner/repo`; `.` and `..` components are never accepted. */
|
|
108
|
+
function validRepoFullName(value) {
|
|
109
|
+
if (typeof value !== "string")
|
|
110
|
+
return null;
|
|
111
|
+
const trimmed = value.trim();
|
|
112
|
+
if (!OWNER_REPO_RE.test(trimmed))
|
|
113
|
+
return null;
|
|
114
|
+
const parts = trimmed.split("/");
|
|
115
|
+
if (parts.length !== 2)
|
|
116
|
+
return null;
|
|
117
|
+
if (parts.some((part) => part === "." || part === ".."))
|
|
118
|
+
return null;
|
|
119
|
+
return trimmed.toLowerCase();
|
|
120
|
+
}
|
|
69
121
|
/**
|
|
70
122
|
* Validate a raw server payload into typed fields, SYNCHRONOUSLY and before any
|
|
71
123
|
* subprocess is invoked.
|
|
@@ -73,6 +125,10 @@ export function identifiesClaudeReviewWorkflow(identity) {
|
|
|
73
125
|
* Fails closed on every unusable shape. A job that cannot prove what it is about
|
|
74
126
|
* to re-run must not run `gh` and then discover the problem — that is how a
|
|
75
127
|
* malformed payload becomes a re-run of the wrong workflow.
|
|
128
|
+
*
|
|
129
|
+
* BAPI-1523 — the payload is a union selected by `variant`. An absent
|
|
130
|
+
* discriminator is the workflow-run form; an unknown one, or a payload carrying
|
|
131
|
+
* the other variant's actuator field, is refused.
|
|
76
132
|
*/
|
|
77
133
|
export function parseCiRerunPayload(payload) {
|
|
78
134
|
const refuse = (reason) => ({ ok: false, failure: { errorKind: CI_RERUN_REFUSED, reason } });
|
|
@@ -80,38 +136,92 @@ export function parseCiRerunPayload(payload) {
|
|
|
80
136
|
return refuse("payload_not_an_object");
|
|
81
137
|
}
|
|
82
138
|
const raw = payload;
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
139
|
+
const variantRaw = raw.variant;
|
|
140
|
+
if (variantRaw !== undefined &&
|
|
141
|
+
variantRaw !== null &&
|
|
142
|
+
variantRaw !== "workflow_run" &&
|
|
143
|
+
variantRaw !== "check_run") {
|
|
144
|
+
return refuse("variant_unknown");
|
|
86
145
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
146
|
+
const variant = variantRaw === "check_run" ? "check_run" : "workflow_run";
|
|
147
|
+
// Cross-variant actuator fields are contradictory, never ignored.
|
|
148
|
+
if (variant === "check_run" && raw.workflow_run_id !== undefined) {
|
|
149
|
+
return refuse("variant_contradictory");
|
|
150
|
+
}
|
|
151
|
+
if (variant === "workflow_run" && raw.check_run_id !== undefined) {
|
|
152
|
+
return refuse("variant_contradictory");
|
|
153
|
+
}
|
|
154
|
+
const repoFullName = validRepoFullName(raw.repo_full_name);
|
|
155
|
+
if (repoFullName === null) {
|
|
156
|
+
return refuse("repo_full_name_invalid");
|
|
92
157
|
}
|
|
93
|
-
const lane = raw.required_check_lane;
|
|
94
|
-
if (
|
|
95
|
-
return refuse("
|
|
158
|
+
const lane = validLane(raw.required_check_lane);
|
|
159
|
+
if (lane === null) {
|
|
160
|
+
return refuse(typeof raw.required_check_lane === "string" && raw.required_check_lane.trim()
|
|
161
|
+
? "required_check_lane_invalid"
|
|
162
|
+
: "required_check_lane_missing");
|
|
96
163
|
}
|
|
97
164
|
const attempt = raw.conductor_infra_attempt;
|
|
98
|
-
if (
|
|
165
|
+
if (!isPositiveSafeInteger(attempt)) {
|
|
99
166
|
return refuse("conductor_infra_attempt_invalid");
|
|
100
167
|
}
|
|
101
168
|
const identityRaw = raw.workflow_identity;
|
|
102
169
|
const workflowIdentity = typeof identityRaw === "string" && identityRaw.trim() ? identityRaw.trim() : null;
|
|
170
|
+
if (workflowIdentity !== null && hasControlCharacter(workflowIdentity)) {
|
|
171
|
+
return refuse("workflow_identity_invalid");
|
|
172
|
+
}
|
|
103
173
|
// The review-workflow refusal, evaluated on the SERVER-SUPPLIED identity and
|
|
104
174
|
// on the lane name, before any subprocess exists.
|
|
105
175
|
if (identifiesClaudeReviewWorkflow(workflowIdentity) ||
|
|
106
176
|
identifiesClaudeReviewWorkflow(lane)) {
|
|
107
177
|
return refuse("claude_review_workflow_refused");
|
|
108
178
|
}
|
|
179
|
+
// An `action_required` identity or conclusion is never actuated.
|
|
180
|
+
if (raw.conclusion === "action_required" || raw.observed_conclusion === "action_required") {
|
|
181
|
+
return refuse("action_required_refused");
|
|
182
|
+
}
|
|
183
|
+
if (variant === "check_run") {
|
|
184
|
+
const checkRunId = raw.check_run_id;
|
|
185
|
+
if (!isPositiveSafeInteger(checkRunId)) {
|
|
186
|
+
return refuse("check_run_id_invalid");
|
|
187
|
+
}
|
|
188
|
+
const appSlugRaw = raw.app_slug;
|
|
189
|
+
if (typeof appSlugRaw !== "string" ||
|
|
190
|
+
!appSlugRaw.trim() ||
|
|
191
|
+
appSlugRaw.trim().length > CI_RERUN_APP_SLUG_MAX_CHARS ||
|
|
192
|
+
hasControlCharacter(appSlugRaw)) {
|
|
193
|
+
return refuse("app_slug_invalid");
|
|
194
|
+
}
|
|
195
|
+
const appSlug = appSlugRaw.trim().toLowerCase();
|
|
196
|
+
if (appSlug === GITHUB_ACTIONS_APP_SLUG) {
|
|
197
|
+
return refuse("github_actions_refused");
|
|
198
|
+
}
|
|
199
|
+
if (identifiesClaudeReviewWorkflow(appSlug)) {
|
|
200
|
+
return refuse("claude_review_workflow_refused");
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
ok: true,
|
|
204
|
+
fields: {
|
|
205
|
+
variant: "check_run",
|
|
206
|
+
repoFullName,
|
|
207
|
+
checkRunId,
|
|
208
|
+
requiredCheckLane: lane,
|
|
209
|
+
conductorInfraAttempt: attempt,
|
|
210
|
+
appSlug,
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const workflowRunId = raw.workflow_run_id;
|
|
215
|
+
if (!isPositiveSafeInteger(workflowRunId)) {
|
|
216
|
+
return refuse("workflow_run_id_invalid");
|
|
217
|
+
}
|
|
109
218
|
return {
|
|
110
219
|
ok: true,
|
|
111
220
|
fields: {
|
|
112
|
-
|
|
221
|
+
variant: "workflow_run",
|
|
222
|
+
repoFullName,
|
|
113
223
|
workflowRunId,
|
|
114
|
-
requiredCheckLane: lane
|
|
224
|
+
requiredCheckLane: lane,
|
|
115
225
|
conductorInfraAttempt: attempt,
|
|
116
226
|
workflowIdentity,
|
|
117
227
|
},
|
|
@@ -156,6 +266,9 @@ export async function runCiRerunJob(payload, deps) {
|
|
|
156
266
|
console.error(`[ci_rerun] payload refused: ${parsed.failure.reason}`);
|
|
157
267
|
return parsed;
|
|
158
268
|
}
|
|
269
|
+
if (parsed.fields.variant === "check_run") {
|
|
270
|
+
return runCheckRunRerequest(parsed.fields, deps);
|
|
271
|
+
}
|
|
159
272
|
const fields = parsed.fields;
|
|
160
273
|
const gh = deps.gh;
|
|
161
274
|
const now = deps.now ?? (() => Date.now());
|
|
@@ -263,6 +376,99 @@ export async function runCiRerunJob(payload, deps) {
|
|
|
263
376
|
`conclusion=${observedConclusion ?? "pending"}`);
|
|
264
377
|
return { ok: true, result };
|
|
265
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* The explicit HTTP status in `gh api` failure output, or `null`.
|
|
381
|
+
*
|
|
382
|
+
* Reads only the CLI's own status marker — `(HTTP 403)` or `HTTP 403:` — never
|
|
383
|
+
* generic prose or an exit code, so a permission failure is never inferred from
|
|
384
|
+
* wording. The status is the only thing taken from the text; the text itself is
|
|
385
|
+
* never returned or logged.
|
|
386
|
+
*/
|
|
387
|
+
export function extractGhHttpStatus(stderr) {
|
|
388
|
+
const match = /\(HTTP (\d{3})\)|\bHTTP (\d{3}):/.exec(stderr);
|
|
389
|
+
if (match === null)
|
|
390
|
+
return null;
|
|
391
|
+
const status = Number(match[1] ?? match[2]);
|
|
392
|
+
return Number.isInteger(status) ? status : null;
|
|
393
|
+
}
|
|
394
|
+
/** GitHub also answers 403 for rate limiting; that is not a permission fact. */
|
|
395
|
+
function looksRateLimited(stderr) {
|
|
396
|
+
return /rate limit|abuse|retry-after/i.test(stderr);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Send ONE check-run re-request and report only the actuator fact (BAPI-1523).
|
|
400
|
+
*
|
|
401
|
+
* `gh api -X POST repos/<owner>/<repo>/check-runs/<id>/rerequest`, an argument
|
|
402
|
+
* array with no shell, no credential argument, no custom header, and no injected
|
|
403
|
+
* environment: the executor machine's ambient `gh` login is the only authority.
|
|
404
|
+
* It returns straight after the request — no polling, no worker, no worktree.
|
|
405
|
+
*/
|
|
406
|
+
async function runCheckRunRerequest(fields, deps) {
|
|
407
|
+
let response;
|
|
408
|
+
try {
|
|
409
|
+
response = await deps.gh([
|
|
410
|
+
"api",
|
|
411
|
+
"-X",
|
|
412
|
+
"POST",
|
|
413
|
+
`repos/${fields.repoFullName}/check-runs/${fields.checkRunId}/rerequest`,
|
|
414
|
+
], { timeoutMs: CI_RERUN_GH_TIMEOUT_MS });
|
|
415
|
+
}
|
|
416
|
+
catch {
|
|
417
|
+
// Contained: no exception text is returned or logged.
|
|
418
|
+
console.error("[ci_rerun] check-run rerequest invocation threw");
|
|
419
|
+
return {
|
|
420
|
+
ok: false,
|
|
421
|
+
failure: { errorKind: CI_RERUN_FAILED, reason: "rerequest_invocation_failed" },
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
if (response.exitCode === 0 && !response.timedOut) {
|
|
425
|
+
console.error(`[ci_rerun] check_run=${fields.checkRunId} rerequested`);
|
|
426
|
+
return {
|
|
427
|
+
ok: true,
|
|
428
|
+
result: {
|
|
429
|
+
check_run_id: fields.checkRunId,
|
|
430
|
+
lane: fields.requiredCheckLane,
|
|
431
|
+
outcome: "rerequested",
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
if (!response.timedOut) {
|
|
436
|
+
const status = extractGhHttpStatus(response.stderr);
|
|
437
|
+
if (status === 403 && !looksRateLimited(response.stderr)) {
|
|
438
|
+
console.error(`[ci_rerun] check_run=${fields.checkRunId} not rerequestable (403)`);
|
|
439
|
+
return {
|
|
440
|
+
ok: true,
|
|
441
|
+
result: {
|
|
442
|
+
check_run_id: fields.checkRunId,
|
|
443
|
+
lane: fields.requiredCheckLane,
|
|
444
|
+
outcome: "not_rerequestable",
|
|
445
|
+
reason: "forbidden",
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
if (status === 404) {
|
|
450
|
+
console.error(`[ci_rerun] check_run=${fields.checkRunId} not rerequestable (404)`);
|
|
451
|
+
return {
|
|
452
|
+
ok: true,
|
|
453
|
+
result: {
|
|
454
|
+
check_run_id: fields.checkRunId,
|
|
455
|
+
lane: fields.requiredCheckLane,
|
|
456
|
+
outcome: "not_rerequestable",
|
|
457
|
+
reason: "not_found",
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
console.error(`[ci_rerun] check_run=${fields.checkRunId} rerequest not performed ` +
|
|
463
|
+
`(exit=${response.exitCode ?? "null"}${response.timedOut ? ", timed out" : ""})`);
|
|
464
|
+
return {
|
|
465
|
+
ok: false,
|
|
466
|
+
failure: {
|
|
467
|
+
errorKind: CI_RERUN_FAILED,
|
|
468
|
+
reason: response.timedOut ? "rerequest_timed_out" : "rerequest_not_performed",
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
}
|
|
266
472
|
/** Production dependency bundle: the existing bounded `execFile`-based runner. */
|
|
267
473
|
export function createProductionCiRerunDeps() {
|
|
268
474
|
return { gh: createProductionEpicIntegrationGhRunner() };
|
package/build/executor/cli.js
CHANGED
|
@@ -96,6 +96,8 @@ export function getExecutorUsage() {
|
|
|
96
96
|
" -h, --help Show this help.",
|
|
97
97
|
"",
|
|
98
98
|
"Subcommands:",
|
|
99
|
+
" executor uninstall-service List units; use --executor-id <id> to remove with",
|
|
100
|
+
" interactive consent, or --dry-run to preview.",
|
|
99
101
|
" executor watch <job> Attach (read-only) to a running job's worker log.",
|
|
100
102
|
" executor install-service Generate a launchd/systemd user service unit for a",
|
|
101
103
|
" stable --executor-id so the executor survives reboot.",
|
|
@@ -279,6 +279,22 @@ export const COMPLETION_CAUSE_VALUES = [
|
|
|
279
279
|
"cleanup_unconfirmed",
|
|
280
280
|
"verification_runner_unavailable",
|
|
281
281
|
];
|
|
282
|
+
/**
|
|
283
|
+
* BAPI-1563 — the closed vocabulary of supplementary executor OBSERVATION causes,
|
|
284
|
+
* in this exact order. Mirrors `VERIFICATION_OBSERVATION_CAUSE_VALUES` in
|
|
285
|
+
* `src/python/llms/executor_completion_contract.py` (a parity test pins both).
|
|
286
|
+
* These are diagnostic facts the executor reports beside a terminal report; they
|
|
287
|
+
* are deliberately NOT completion causes, park causes or end causes, share no value
|
|
288
|
+
* with {@link COMPLETION_CAUSE_VALUES}, and never select an evidence version.
|
|
289
|
+
*/
|
|
290
|
+
export const VERIFICATION_OBSERVATION_CAUSE_VALUES = [
|
|
291
|
+
"no_database",
|
|
292
|
+
"no_live_server",
|
|
293
|
+
"check_timed_out",
|
|
294
|
+
"check_not_runnable",
|
|
295
|
+
];
|
|
296
|
+
/** BAPI-1563 — most observations one terminal report may carry (server bound). */
|
|
297
|
+
export const MAX_VERIFICATION_OBSERVATIONS = 64;
|
|
282
298
|
export const END_CAUSE_VALUES = [
|
|
283
299
|
"worker_exit", "completion_window", "job_timeout", "executor_abort",
|
|
284
300
|
"executor_shutdown", "server_stop", "lease_lost",
|
|
@@ -93,7 +93,7 @@ export async function resolveExecutorApiAccess(repoName, deps, explicitBaseUrl)
|
|
|
93
93
|
ok: false,
|
|
94
94
|
error: `the stored credential for repo '${trimmed}' is approved for a different Bridge API ` +
|
|
95
95
|
"endpoint than this executor's base URL; it was not sent. Re-run guided setup " +
|
|
96
|
-
"(install
|
|
96
|
+
"(install epic-implementer) to re-bind it, or correct --base-url.",
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1563 — executor-side memory of the facts a terminal report carries beside
|
|
3
|
+
* its outcome: the pull request the executor discovered and the bounded
|
|
4
|
+
* supplementary observation causes it accumulated.
|
|
5
|
+
*
|
|
6
|
+
* The executor REPORTS facts; the server decides. Nothing here grants permission
|
|
7
|
+
* and nothing here marks a check as passed. A failed, unavailable or unrun check
|
|
8
|
+
* yields an observation (or none), never a positive claim.
|
|
9
|
+
*
|
|
10
|
+
* Memory is held per claimed job and attached to every `/complete` and `/fail`
|
|
11
|
+
* by one client wrapper ({@link withDeliveryObservations}), so a failure emitted
|
|
12
|
+
* before finalization, from a catch block, a supervision stop, or cleanup carries
|
|
13
|
+
* the same discovered PR as the happy path. Whether the fields reach the wire is
|
|
14
|
+
* decided later, by the HTTP client, from the claim's advertised capability.
|
|
15
|
+
*
|
|
16
|
+
* Diagnostics go through the caller's error log (stderr), never stdout.
|
|
17
|
+
*/
|
|
18
|
+
import { MAX_VERIFICATION_OBSERVATIONS, VERIFICATION_OBSERVATION_CAUSE_VALUES, } from "./completion-contract.js";
|
|
19
|
+
import { observationsFromVerificationFacts } from "./required-verification.js";
|
|
20
|
+
const FULL_SHA_RE = /^[0-9a-f]{40}$/;
|
|
21
|
+
const memories = new WeakMap();
|
|
22
|
+
/** The memory for `job`, created empty on first use. */
|
|
23
|
+
export function deliveryObservationMemory(job) {
|
|
24
|
+
let memory = memories.get(job);
|
|
25
|
+
if (!memory) {
|
|
26
|
+
memory = { observedPr: null, observations: [] };
|
|
27
|
+
memories.set(job, memory);
|
|
28
|
+
}
|
|
29
|
+
return memory;
|
|
30
|
+
}
|
|
31
|
+
/** True when `value` is a usable discovered-PR fact: positive int, full SHA, non-blank base. */
|
|
32
|
+
export function isObservedPr(value) {
|
|
33
|
+
if (value === null || typeof value !== "object")
|
|
34
|
+
return false;
|
|
35
|
+
const v = value;
|
|
36
|
+
return (typeof v.number === "number" &&
|
|
37
|
+
Number.isInteger(v.number) &&
|
|
38
|
+
v.number > 0 &&
|
|
39
|
+
typeof v.head_sha === "string" &&
|
|
40
|
+
FULL_SHA_RE.test(v.head_sha) &&
|
|
41
|
+
typeof v.base_ref === "string" &&
|
|
42
|
+
v.base_ref.trim().length > 0);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Remember the discovered PR. A later usable observation replaces an earlier one;
|
|
46
|
+
* an unusable one (missing head or base, as a provider may report) is ignored, so
|
|
47
|
+
* the report never carries a half-formed PR.
|
|
48
|
+
*/
|
|
49
|
+
export function recordObservedPr(job, pr) {
|
|
50
|
+
const candidate = {
|
|
51
|
+
number: pr.number ?? undefined,
|
|
52
|
+
head_sha: typeof pr.headSha === "string" ? pr.headSha.trim().toLowerCase() : undefined,
|
|
53
|
+
base_ref: typeof pr.baseRef === "string" ? pr.baseRef.trim() : undefined,
|
|
54
|
+
};
|
|
55
|
+
if (isObservedPr(candidate))
|
|
56
|
+
deliveryObservationMemory(job).observedPr = candidate;
|
|
57
|
+
}
|
|
58
|
+
/** Remember one observation. Unknown causes, duplicates and overflow are dropped. */
|
|
59
|
+
export function recordVerificationObservation(job, observation) {
|
|
60
|
+
if (!VERIFICATION_OBSERVATION_CAUSE_VALUES.includes(observation.cause))
|
|
61
|
+
return;
|
|
62
|
+
const memory = deliveryObservationMemory(job);
|
|
63
|
+
const key = (o) => `${o.step_id ?? ""}|${o.check_identity ?? ""}|${o.cause}`;
|
|
64
|
+
if (memory.observations.some((o) => key(o) === key(observation)))
|
|
65
|
+
return;
|
|
66
|
+
if (memory.observations.length >= MAX_VERIFICATION_OBSERVATIONS)
|
|
67
|
+
return;
|
|
68
|
+
memory.observations.push({
|
|
69
|
+
...(typeof observation.step_id === "number" ? { step_id: observation.step_id } : {}),
|
|
70
|
+
...(typeof observation.check_identity === "string" && observation.check_identity !== ""
|
|
71
|
+
? { check_identity: observation.check_identity }
|
|
72
|
+
: {}),
|
|
73
|
+
cause: observation.cause,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Fold derived verification observations into a job's memory. */
|
|
77
|
+
export function recordVerificationFacts(job, facts) {
|
|
78
|
+
for (const observation of observationsFromVerificationFacts(facts)) {
|
|
79
|
+
recordVerificationObservation(job, observation);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** The fields to add to a terminal body, each only when the report does not set it. */
|
|
83
|
+
function withMemory(job, body) {
|
|
84
|
+
const memory = memories.get(job);
|
|
85
|
+
if (!memory)
|
|
86
|
+
return body;
|
|
87
|
+
const additions = {};
|
|
88
|
+
if (body.observed_pr === undefined && memory.observedPr !== null)
|
|
89
|
+
additions.observed_pr = memory.observedPr;
|
|
90
|
+
if (body.verification_observations === undefined && memory.observations.length > 0) {
|
|
91
|
+
additions.verification_observations = [...memory.observations];
|
|
92
|
+
}
|
|
93
|
+
return Object.keys(additions).length === 0 ? body : { ...body, ...additions };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap a client so every terminal report of `job` carries its observation memory.
|
|
97
|
+
* Only `complete` and `fail` are touched; every other method passes through. The
|
|
98
|
+
* wire gate (the claim's capability) is applied by the real HTTP client.
|
|
99
|
+
*/
|
|
100
|
+
export function withDeliveryObservations(httpClient) {
|
|
101
|
+
return new Proxy(httpClient, {
|
|
102
|
+
get(target, key) {
|
|
103
|
+
if (key === "complete") {
|
|
104
|
+
return (job, completion) => target.complete(job, withMemory(job, completion));
|
|
105
|
+
}
|
|
106
|
+
if (key === "fail") {
|
|
107
|
+
return (job, failure) => target.fail(job, withMemory(job, failure));
|
|
108
|
+
}
|
|
109
|
+
const value = Reflect.get(target, key);
|
|
110
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -95,6 +95,30 @@ export function summarizeDeliveryBlockers(value) {
|
|
|
95
95
|
}
|
|
96
96
|
return out;
|
|
97
97
|
}
|
|
98
|
+
/** Reduce the server's carried-gap list to closed tokens and integer step ids. */
|
|
99
|
+
export function summarizeCarriedGaps(value) {
|
|
100
|
+
if (!Array.isArray(value))
|
|
101
|
+
return [];
|
|
102
|
+
const out = [];
|
|
103
|
+
for (const entry of value) {
|
|
104
|
+
if (out.length >= MAX_BLOCKERS * 4)
|
|
105
|
+
break;
|
|
106
|
+
const rec = asRecord(entry);
|
|
107
|
+
if (!rec)
|
|
108
|
+
continue;
|
|
109
|
+
const step = rec.step_id;
|
|
110
|
+
const refusal = rec.refusal_token;
|
|
111
|
+
out.push({
|
|
112
|
+
...(typeof step === "number" && Number.isInteger(step) && step >= 0 && step <= 1_000_000
|
|
113
|
+
? { step_id: step }
|
|
114
|
+
: {}),
|
|
115
|
+
gap_kind: typeof rec.gap_kind === "string" && TOKEN_RE.test(rec.gap_kind) ? rec.gap_kind : "unrecognized",
|
|
116
|
+
cause: typeof rec.cause === "string" && TOKEN_RE.test(rec.cause) ? rec.cause : "unrecognized",
|
|
117
|
+
...(typeof refusal === "string" && TOKEN_RE.test(refusal) ? { refusal_token: refusal } : {}),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
98
122
|
function isDeliveryOutcomeToken(value) {
|
|
99
123
|
return typeof value === "string" && DELIVERY_OUTCOMES.includes(value);
|
|
100
124
|
}
|
|
@@ -171,6 +195,12 @@ export async function fetchServerDeliveryOutcome(job, branch, deps) {
|
|
|
171
195
|
// so a response without them parses exactly as it did before.
|
|
172
196
|
...(FULL_SHA_RE.test(rawObserved) ? { observedHeadSha: rawObserved } : {}),
|
|
173
197
|
...(readiness.post_pr_remote_ci_only === true ? { postPrRemoteCiOnly: true } : {}),
|
|
198
|
+
// Additive (BAPI-1563): the evidence outcome and carried gaps, only when
|
|
199
|
+
// the server supplied usable values. No outcome token is added or reinterpreted.
|
|
200
|
+
...(isDeliveryOutcomeToken(readiness.evidence_outcome) ? { evidenceOutcome: readiness.evidence_outcome } : {}),
|
|
201
|
+
...(Array.isArray(readiness.carried_gaps) && readiness.carried_gaps.length > 0
|
|
202
|
+
? { carriedGaps: summarizeCarriedGaps(readiness.carried_gaps) }
|
|
203
|
+
: {}),
|
|
174
204
|
};
|
|
175
205
|
}
|
|
176
206
|
catch {
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1551 — the stream-draining, abortable install runner for the executor's
|
|
3
|
+
* dependency refresh.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT `deps.runCommand`: that is `execFile` with a 10 MiB
|
|
6
|
+
* `maxBuffer`, so a noisy `npm ci` would be killed for its output size and read
|
|
7
|
+
* as a failed install. This runner drains both streams continuously and keeps
|
|
8
|
+
* only a bounded tail.
|
|
9
|
+
*
|
|
10
|
+
* - The command is an argv array, spawned with `shell: false`. No shell ever
|
|
11
|
+
* parses it.
|
|
12
|
+
* - On POSIX the child leads its own process group (`detached: true`), so a
|
|
13
|
+
* timeout or a cancellation terminates the WHOLE install tree (lifecycle
|
|
14
|
+
* scripts, `node-gyp`, and so on): SIGTERM to the group, a short grace, then
|
|
15
|
+
* SIGKILL. The runner resolves only after the child has exited, so nothing it
|
|
16
|
+
* started is still writing when the worker is spawned.
|
|
17
|
+
* - The result is a closed outcome. Raw process errors are never propagated.
|
|
18
|
+
* - The retained tail is returned to the caller for an executor-local diagnostic
|
|
19
|
+
* only. It must never reach a log line, Sentry, a server request, a job result,
|
|
20
|
+
* or a worker prompt: install output can echo argv, paths, or tokens.
|
|
21
|
+
*/
|
|
22
|
+
import { spawn } from "node:child_process";
|
|
23
|
+
/** Bytes of combined stdout/stderr kept for an executor-local diagnostic. */
|
|
24
|
+
export const DEPENDENCY_INSTALL_OUTPUT_TAIL_BYTES = 8 * 1024;
|
|
25
|
+
/** Grace between SIGTERM and SIGKILL of the install process group. */
|
|
26
|
+
export const DEPENDENCY_INSTALL_KILL_GRACE_MS = 5_000;
|
|
27
|
+
/** Keep the last `limit` bytes of a growing buffer. */
|
|
28
|
+
class BoundedTail {
|
|
29
|
+
limit;
|
|
30
|
+
chunks = [];
|
|
31
|
+
size = 0;
|
|
32
|
+
constructor(limit) {
|
|
33
|
+
this.limit = limit;
|
|
34
|
+
}
|
|
35
|
+
push(chunk) {
|
|
36
|
+
this.chunks.push(chunk);
|
|
37
|
+
this.size += chunk.length;
|
|
38
|
+
while (this.size > this.limit && this.chunks.length > 0) {
|
|
39
|
+
const first = this.chunks[0];
|
|
40
|
+
const excess = this.size - this.limit;
|
|
41
|
+
if (first.length <= excess) {
|
|
42
|
+
this.chunks.shift();
|
|
43
|
+
this.size -= first.length;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.chunks[0] = first.subarray(excess);
|
|
47
|
+
this.size -= excess;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
text() {
|
|
52
|
+
return Buffer.concat(this.chunks).toString("utf8");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** The real runner. Never throws. */
|
|
56
|
+
export const runDependencyInstall = (request) => new Promise((resolve) => {
|
|
57
|
+
const tail = new BoundedTail(DEPENDENCY_INSTALL_OUTPUT_TAIL_BYTES);
|
|
58
|
+
const posix = process.platform !== "win32";
|
|
59
|
+
if (request.argv.length === 0 || request.signal?.aborted) {
|
|
60
|
+
resolve({ outcome: request.signal?.aborted ? "cancelled" : "spawn_failed", outputTail: "" });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let child;
|
|
64
|
+
try {
|
|
65
|
+
child = spawn(request.argv[0], request.argv.slice(1), {
|
|
66
|
+
cwd: request.cwd,
|
|
67
|
+
env: request.env,
|
|
68
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
69
|
+
shell: false,
|
|
70
|
+
detached: posix,
|
|
71
|
+
windowsHide: true,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
resolve({ outcome: "spawn_failed", outputTail: "" });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let stopping = null;
|
|
79
|
+
let spawnFailed = false;
|
|
80
|
+
let settled = false;
|
|
81
|
+
let killTimer;
|
|
82
|
+
const signalGroup = (signal) => {
|
|
83
|
+
const pid = child.pid;
|
|
84
|
+
if (pid === undefined)
|
|
85
|
+
return;
|
|
86
|
+
try {
|
|
87
|
+
if (posix)
|
|
88
|
+
process.kill(-pid, signal);
|
|
89
|
+
else
|
|
90
|
+
child.kill(signal);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
try {
|
|
94
|
+
child.kill(signal);
|
|
95
|
+
}
|
|
96
|
+
catch { /* already exited */ }
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const stop = (reason) => {
|
|
100
|
+
if (stopping !== null || settled)
|
|
101
|
+
return;
|
|
102
|
+
stopping = reason;
|
|
103
|
+
signalGroup("SIGTERM");
|
|
104
|
+
killTimer = setTimeout(() => signalGroup("SIGKILL"), DEPENDENCY_INSTALL_KILL_GRACE_MS);
|
|
105
|
+
};
|
|
106
|
+
const timer = setTimeout(() => stop("timeout"), Math.max(1, request.timeoutMs));
|
|
107
|
+
const onAbort = () => stop("cancelled");
|
|
108
|
+
request.signal?.addEventListener("abort", onAbort, { once: true });
|
|
109
|
+
child.stdout?.on("data", (chunk) => tail.push(chunk));
|
|
110
|
+
child.stderr?.on("data", (chunk) => tail.push(chunk));
|
|
111
|
+
const finish = (code) => {
|
|
112
|
+
if (settled)
|
|
113
|
+
return;
|
|
114
|
+
settled = true;
|
|
115
|
+
clearTimeout(timer);
|
|
116
|
+
if (killTimer)
|
|
117
|
+
clearTimeout(killTimer);
|
|
118
|
+
request.signal?.removeEventListener("abort", onAbort);
|
|
119
|
+
// A group member that outlived the leader still gets the hard stop.
|
|
120
|
+
if (stopping !== null && posix)
|
|
121
|
+
signalGroup("SIGKILL");
|
|
122
|
+
const outcome = stopping ?? (spawnFailed ? "spawn_failed" : code === 0 ? "exit_zero" : "nonzero");
|
|
123
|
+
resolve({ outcome, outputTail: tail.text() });
|
|
124
|
+
};
|
|
125
|
+
child.on("error", () => {
|
|
126
|
+
spawnFailed = true;
|
|
127
|
+
// A child that never started emits no `close` on every Node version.
|
|
128
|
+
if (child.pid === undefined)
|
|
129
|
+
finish(null);
|
|
130
|
+
});
|
|
131
|
+
child.on("close", (code) => finish(code));
|
|
132
|
+
});
|