@bridge_gpt/mcp-server 0.2.70 → 0.2.71
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 +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +10 -1
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +11 -1
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +13 -5
- package/build/commands.generated.js +3 -3
- package/build/conductor/bridge-api-client.js +260 -2
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +9 -3
- package/build/conductor/epic-implementer-cli.js +4 -0
- package/build/conductor/gate-discovery.js +524 -10
- package/build/conductor/gate-settings-review.js +451 -0
- package/build/conductor/launch-need-probes.js +16 -11
- package/build/conductor/launch-plan.js +145 -0
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-sections.js +4 -1
- package/build/conductor/recovery-cli.js +59 -2
- package/build/conductor/recovery-operations.js +45 -2
- package/build/docs.generated.js +1 -1
- package/build/drive-epic.js +188 -45
- 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 +18 -18
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/env.js +207 -3
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/job-runner.js +112 -11
- package/build/executor/likely-tests.js +6 -1
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +72 -13
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/worker-command.js +136 -1
- package/build/executor/worker-database.js +30 -11
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +29 -0
- package/build/index.js +221 -165
- package/build/install-bridge-conductor-gate.js +195 -14
- package/build/install-bridge-conductor-setup.js +20 -6
- package/build/install-bridge-conductor.js +355 -37
- package/build/install-bridge.js +1 -1
- package/build/merge-workflow-install.js +20 -0
- package/build/pipelines.generated.js +2 -2
- package/build/plan-execution-ledger.js +23 -8
- package/build/plane/plane-freshness.js +6 -2
- package/build/plane/preflight.js +19 -0
- package/build/printed-remedy-commands.js +8 -1
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +581 -0
- package/build/setup-epic.js +24 -7
- package/build/test-command-detection.js +58 -21
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +67 -4
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER.md +38 -0
- package/docs/epic-implementer/getting-started.md +58 -2
- package/package.json +2 -2
|
@@ -193,6 +193,66 @@ const CONDUCTOR_BRIDGE_API_ERROR_KINDS = [
|
|
|
193
193
|
"server",
|
|
194
194
|
"http",
|
|
195
195
|
];
|
|
196
|
+
const WORKER_ENV_REFUSAL_REASONS = new Set([
|
|
197
|
+
"worker_env_reserved_name",
|
|
198
|
+
"worker_env_secret_name",
|
|
199
|
+
"worker_env_duplicate",
|
|
200
|
+
]);
|
|
201
|
+
const GATE_EVIDENCE_FIELD_RE = /^[a-z_]{1,40}$/;
|
|
202
|
+
const GATE_EVIDENCE_NAME_RE = /^[A-Z_][A-Z0-9_]{0,63}$/;
|
|
203
|
+
const GATE_EVIDENCE_LOC_PART_RE = /^[A-Za-z0-9_]{1,64}$/;
|
|
204
|
+
const GATE_EVIDENCE_TYPE_RE = /^[a-z_.]{1,64}$/;
|
|
205
|
+
const GATE_EVIDENCE_MAX_ISSUES = 4;
|
|
206
|
+
const GATE_EVIDENCE_MAX_LOC_PARTS = 8;
|
|
207
|
+
/**
|
|
208
|
+
* Extract the BAPI-1520 structural evidence from a parsed error body. Only the
|
|
209
|
+
* `detail.field`/`reason`/`name` of the route's own envelope and the `type` and
|
|
210
|
+
* `loc` of validation issues are read; `input`, `ctx`, and `msg` never are.
|
|
211
|
+
*/
|
|
212
|
+
function extractGateProfileEvidence(detail) {
|
|
213
|
+
const evidence = {};
|
|
214
|
+
if (Array.isArray(detail)) {
|
|
215
|
+
const issues = [];
|
|
216
|
+
for (const item of detail.slice(0, GATE_EVIDENCE_MAX_ISSUES)) {
|
|
217
|
+
if (!item || typeof item !== "object")
|
|
218
|
+
continue;
|
|
219
|
+
const rec = item;
|
|
220
|
+
const type = rec["type"];
|
|
221
|
+
const loc = rec["loc"];
|
|
222
|
+
if (typeof type !== "string" || !GATE_EVIDENCE_TYPE_RE.test(type))
|
|
223
|
+
continue;
|
|
224
|
+
if (!Array.isArray(loc) || loc.length === 0 || loc.length > GATE_EVIDENCE_MAX_LOC_PARTS)
|
|
225
|
+
continue;
|
|
226
|
+
const parts = [];
|
|
227
|
+
let ok = true;
|
|
228
|
+
for (const part of loc) {
|
|
229
|
+
if (typeof part === "number" && Number.isSafeInteger(part) && part >= 0)
|
|
230
|
+
parts.push(part);
|
|
231
|
+
else if (typeof part === "string" && GATE_EVIDENCE_LOC_PART_RE.test(part))
|
|
232
|
+
parts.push(part);
|
|
233
|
+
else
|
|
234
|
+
ok = false;
|
|
235
|
+
}
|
|
236
|
+
if (ok)
|
|
237
|
+
issues.push({ loc: parts, type });
|
|
238
|
+
}
|
|
239
|
+
if (issues.length > 0)
|
|
240
|
+
evidence.issues = issues;
|
|
241
|
+
}
|
|
242
|
+
else if (detail && typeof detail === "object") {
|
|
243
|
+
const d = detail;
|
|
244
|
+
if (typeof d["field"] === "string" && GATE_EVIDENCE_FIELD_RE.test(d["field"])) {
|
|
245
|
+
evidence.field = d["field"];
|
|
246
|
+
}
|
|
247
|
+
if (typeof d["reason"] === "string" && WORKER_ENV_REFUSAL_REASONS.has(d["reason"])) {
|
|
248
|
+
evidence.reason = d["reason"];
|
|
249
|
+
}
|
|
250
|
+
if (typeof d["name"] === "string" && GATE_EVIDENCE_NAME_RE.test(d["name"])) {
|
|
251
|
+
evidence.name = d["name"];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return Object.keys(evidence).length > 0 ? evidence : undefined;
|
|
255
|
+
}
|
|
196
256
|
/** Max length of the sanitized body preview embedded in error diagnostics. */
|
|
197
257
|
const CONDUCTOR_ERROR_PREVIEW_MAX = 200;
|
|
198
258
|
/** BAPI-1455 — the stable readiness refusal code for a proven-missing local schema object. */
|
|
@@ -347,6 +407,9 @@ export function extractSanitizedErrorDiagnostics(body) {
|
|
|
347
407
|
diagnostics.errorCode = boundedErrorPreview(errorCode);
|
|
348
408
|
if (message)
|
|
349
409
|
diagnostics.bodyPreview = boundedErrorPreview(message);
|
|
410
|
+
const gateEvidence = extractGateProfileEvidence(detail);
|
|
411
|
+
if (gateEvidence)
|
|
412
|
+
diagnostics.gateProfileEvidence = gateEvidence;
|
|
350
413
|
// BAPI-872: extract the allowlisted stale-CAS `current_row_version`, from
|
|
351
414
|
// either the nested `detail` object or (defensively) the top level. Only a
|
|
352
415
|
// genuine non-negative safe integer is accepted — never a boolean (JS has no
|
|
@@ -382,6 +445,9 @@ function redactDiagnosticValues(diagnostics, secrets) {
|
|
|
382
445
|
if (typeof diagnostics.currentRowVersion === "number") {
|
|
383
446
|
out.currentRowVersion = diagnostics.currentRowVersion;
|
|
384
447
|
}
|
|
448
|
+
// BAPI-1520: pattern-checked at extraction, so there is nothing left to scrub.
|
|
449
|
+
if (diagnostics.gateProfileEvidence)
|
|
450
|
+
out.gateProfileEvidence = diagnostics.gateProfileEvidence;
|
|
385
451
|
return out;
|
|
386
452
|
}
|
|
387
453
|
/**
|
|
@@ -444,6 +510,8 @@ export class ConductorBridgeApiError extends Error {
|
|
|
444
510
|
* that need it read this field directly.
|
|
445
511
|
*/
|
|
446
512
|
currentRowVersion;
|
|
513
|
+
/** BAPI-1520 — sanitized structural evidence of a gate-profile refusal. */
|
|
514
|
+
gateProfileEvidence;
|
|
447
515
|
constructor(kindOrMessage, status, diagnostics) {
|
|
448
516
|
const isKnownKind = CONDUCTOR_BRIDGE_API_ERROR_KINDS.includes(kindOrMessage);
|
|
449
517
|
const errorCode = diagnostics?.errorCode;
|
|
@@ -473,6 +541,8 @@ export class ConductorBridgeApiError extends Error {
|
|
|
473
541
|
if (typeof diagnostics?.currentRowVersion === "number") {
|
|
474
542
|
this.currentRowVersion = diagnostics.currentRowVersion;
|
|
475
543
|
}
|
|
544
|
+
if (diagnostics?.gateProfileEvidence)
|
|
545
|
+
this.gateProfileEvidence = diagnostics.gateProfileEvidence;
|
|
476
546
|
}
|
|
477
547
|
}
|
|
478
548
|
/**
|
|
@@ -814,6 +884,28 @@ export const REVIEW_HEAD_REFUSAL_CODES = [
|
|
|
814
884
|
"REVIEW_HEAD_LIVE_WORK",
|
|
815
885
|
"REVIEW_HEAD_UNAVAILABLE",
|
|
816
886
|
];
|
|
887
|
+
/**
|
|
888
|
+
* BAPI-1537 — the server's closed refusal codes for the external-repair case.
|
|
889
|
+
* Each is an HTTP 409 that writes nothing and leaves the ticket parked.
|
|
890
|
+
*/
|
|
891
|
+
export const EXTERNAL_REPAIR_REFUSAL_CODES = [
|
|
892
|
+
"EXTERNAL_REPAIR_RUN_NOT_RECOVERABLE",
|
|
893
|
+
"EXTERNAL_REPAIR_NOT_PARKED",
|
|
894
|
+
"EXTERNAL_REPAIR_LIVE_WORK",
|
|
895
|
+
"EXTERNAL_REPAIR_BRANCH_MISMATCH",
|
|
896
|
+
"EXTERNAL_REPAIR_ANCESTRY",
|
|
897
|
+
"EXTERNAL_REPAIR_PR_MISMATCH",
|
|
898
|
+
"EXTERNAL_REPAIR_PR_AMBIGUOUS",
|
|
899
|
+
"EXTERNAL_REPAIR_HEAD_CLAIMED",
|
|
900
|
+
"EXTERNAL_REPAIR_OPERATION_CONFLICT",
|
|
901
|
+
"EXTERNAL_REPAIR_UNAVAILABLE",
|
|
902
|
+
"EXTERNAL_REPAIR_ALREADY_INTEGRATED",
|
|
903
|
+
];
|
|
904
|
+
/**
|
|
905
|
+
* BAPI-1537 — the external-repair refusals that may be retried with the SAME
|
|
906
|
+
* operation id once the cause clears. Never retried automatically.
|
|
907
|
+
*/
|
|
908
|
+
export const EXTERNAL_REPAIR_RETRYABLE_CODES = ["EXTERNAL_REPAIR_UNAVAILABLE"];
|
|
817
909
|
// ---------------------------------------------------------------------------
|
|
818
910
|
// Local boundary validators (reject before any fetch call)
|
|
819
911
|
// ---------------------------------------------------------------------------
|
|
@@ -1528,6 +1620,9 @@ export async function adoptCurrentHeadAndUnparkTicket(access, request, fetchImpl
|
|
|
1528
1620
|
expected_row_version: request.expectedRowVersion,
|
|
1529
1621
|
...(request.idempotencyKey !== undefined ? { idempotency_key: request.idempotencyKey } : {}),
|
|
1530
1622
|
...(request.reason !== undefined ? { reason: request.reason } : {}),
|
|
1623
|
+
...(request.externalRepairOperationId !== undefined
|
|
1624
|
+
? { external_repair_operation_id: request.externalRepairOperationId }
|
|
1625
|
+
: {}),
|
|
1531
1626
|
});
|
|
1532
1627
|
return postUnparkLikeRequest(url, conductorPostHeaders(access), body, fetchImpl);
|
|
1533
1628
|
}
|
|
@@ -4374,6 +4469,81 @@ const GATE_MAX_LOCAL_COMMANDS = 16;
|
|
|
4374
4469
|
const GATE_MAX_CUSTOMIZED = 64;
|
|
4375
4470
|
/** The provider-history walk makes bounded provider calls; give it longer. */
|
|
4376
4471
|
const GATE_CHECK_HISTORY_TIMEOUT_MS = 90_000;
|
|
4472
|
+
const GATE_MAX_WORKER_ENV = 32;
|
|
4473
|
+
const GATE_WORKER_ENV_VALUE_MAX_BYTES = 1024;
|
|
4474
|
+
const GATE_WORKER_ENV_NAME_RE = /^[A-Z_][A-Z0-9_]{0,63}$/;
|
|
4475
|
+
const GATE_MAX_ARGV_ENTRIES = 32;
|
|
4476
|
+
/** Whether `value` is an acceptable worker-variable value (limits mirror the server). */
|
|
4477
|
+
export function isValidWorkerEnvValue(value) {
|
|
4478
|
+
if (typeof value !== "string")
|
|
4479
|
+
return false;
|
|
4480
|
+
if (/[\u0000\r\n]/.test(value))
|
|
4481
|
+
return false;
|
|
4482
|
+
// A lone surrogate cannot be encoded as UTF-8; the server refuses it too.
|
|
4483
|
+
if (/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/.test(value))
|
|
4484
|
+
return false;
|
|
4485
|
+
return Buffer.byteLength(value, "utf8") <= GATE_WORKER_ENV_VALUE_MAX_BYTES;
|
|
4486
|
+
}
|
|
4487
|
+
/** Whether `name` matches the worker-variable name syntax. */
|
|
4488
|
+
export function isValidWorkerEnvName(name) {
|
|
4489
|
+
return typeof name === "string" && GATE_WORKER_ENV_NAME_RE.test(name);
|
|
4490
|
+
}
|
|
4491
|
+
/**
|
|
4492
|
+
* Parse a returned `worker_env` list, fail-closed. Malformed data throws the
|
|
4493
|
+
* field-free shape error; it is never turned into an empty list and its
|
|
4494
|
+
* contents never reach the message.
|
|
4495
|
+
*/
|
|
4496
|
+
function parseWorkerEnvList(raw) {
|
|
4497
|
+
if (raw === undefined || raw === null)
|
|
4498
|
+
return undefined;
|
|
4499
|
+
if (!Array.isArray(raw) || raw.length > GATE_MAX_WORKER_ENV)
|
|
4500
|
+
throw readinessShapeError();
|
|
4501
|
+
const seen = new Set();
|
|
4502
|
+
const entries = [];
|
|
4503
|
+
for (const item of raw) {
|
|
4504
|
+
const o = requireObject(item);
|
|
4505
|
+
for (const key of Object.keys(o)) {
|
|
4506
|
+
if (key !== "name" && key !== "value" && key !== "committed_literal")
|
|
4507
|
+
throw readinessShapeError();
|
|
4508
|
+
}
|
|
4509
|
+
if (!isValidWorkerEnvName(o.name) || !isValidWorkerEnvValue(o.value) || seen.has(o.name)) {
|
|
4510
|
+
throw readinessShapeError();
|
|
4511
|
+
}
|
|
4512
|
+
seen.add(o.name);
|
|
4513
|
+
const entry = { name: o.name, value: o.value };
|
|
4514
|
+
if (o.committed_literal !== undefined) {
|
|
4515
|
+
if (typeof o.committed_literal !== "boolean")
|
|
4516
|
+
throw readinessShapeError();
|
|
4517
|
+
// False and omitted are the same state, so only true is carried.
|
|
4518
|
+
if (o.committed_literal)
|
|
4519
|
+
entry.committed_literal = true;
|
|
4520
|
+
}
|
|
4521
|
+
entries.push(entry);
|
|
4522
|
+
}
|
|
4523
|
+
return entries.length > 0 ? entries : undefined;
|
|
4524
|
+
}
|
|
4525
|
+
/** Parse a returned or proposed reproduction hint, fail-closed. */
|
|
4526
|
+
function parseReproductionHint(raw) {
|
|
4527
|
+
const o = requireObject(raw);
|
|
4528
|
+
for (const key of Object.keys(o)) {
|
|
4529
|
+
if (key !== "argv" && key !== "timeout_seconds")
|
|
4530
|
+
throw readinessShapeError();
|
|
4531
|
+
}
|
|
4532
|
+
const argv = o.argv;
|
|
4533
|
+
if (!Array.isArray(argv) ||
|
|
4534
|
+
argv.length === 0 ||
|
|
4535
|
+
argv.length > GATE_MAX_ARGV_ENTRIES ||
|
|
4536
|
+
argv.some((a) => typeof a !== "string" ||
|
|
4537
|
+
a.trim().length === 0 ||
|
|
4538
|
+
a.length > GATE_ARGV_ENTRY_MAX ||
|
|
4539
|
+
a.includes("\u0000"))) {
|
|
4540
|
+
throw readinessShapeError();
|
|
4541
|
+
}
|
|
4542
|
+
const timeout = requireInt(o, "timeout_seconds");
|
|
4543
|
+
if (timeout < 1 || timeout > 1800)
|
|
4544
|
+
throw readinessShapeError();
|
|
4545
|
+
return { argv: [...argv], timeout_seconds: timeout };
|
|
4546
|
+
}
|
|
4377
4547
|
function gateName(value, max) {
|
|
4378
4548
|
if (typeof value !== "string")
|
|
4379
4549
|
throw readinessShapeError();
|
|
@@ -4390,6 +4560,14 @@ function parseGateProfileBody(raw) {
|
|
|
4390
4560
|
if (!Array.isArray(checksRaw) || checksRaw.length > GATE_MAX_PROVIDER_CHECKS)
|
|
4391
4561
|
throw readinessShapeError();
|
|
4392
4562
|
const providerChecks = checksRaw.map((c) => gateName(requireObject(c).name, GATE_MEMBER_NAME_MAX));
|
|
4563
|
+
const reproductionHints = new Map();
|
|
4564
|
+
checksRaw.forEach((c, index) => {
|
|
4565
|
+
const reproduce = requireObject(c).reproduce;
|
|
4566
|
+
if (reproduce === undefined || reproduce === null)
|
|
4567
|
+
return;
|
|
4568
|
+
reproductionHints.set(providerChecks[index], parseReproductionHint(reproduce));
|
|
4569
|
+
});
|
|
4570
|
+
const workerEnv = parseWorkerEnvList(o.worker_env);
|
|
4393
4571
|
const commandsRaw = o.local_commands;
|
|
4394
4572
|
if (!Array.isArray(commandsRaw) || commandsRaw.length > GATE_MAX_LOCAL_COMMANDS)
|
|
4395
4573
|
throw readinessShapeError();
|
|
@@ -4446,6 +4624,8 @@ function parseGateProfileBody(raw) {
|
|
|
4446
4624
|
return {
|
|
4447
4625
|
kind,
|
|
4448
4626
|
provider_checks: providerChecks,
|
|
4627
|
+
...(workerEnv ? { worker_env: workerEnv } : {}),
|
|
4628
|
+
...(reproductionHints.size > 0 ? { reproduction_hints: reproductionHints } : {}),
|
|
4449
4629
|
local_commands: localCommands,
|
|
4450
4630
|
migration_guard: guard,
|
|
4451
4631
|
customized_commands: customized.map((n) => gateName(n, GATE_MEMBER_NAME_MAX)),
|
|
@@ -4454,6 +4634,18 @@ function parseGateProfileBody(raw) {
|
|
|
4454
4634
|
revision,
|
|
4455
4635
|
};
|
|
4456
4636
|
}
|
|
4637
|
+
/** The qualification's optional worker-variable digest, fail-closed. */
|
|
4638
|
+
function parseQualificationWorkerEnvDigest(raw) {
|
|
4639
|
+
if (raw === undefined || raw === null)
|
|
4640
|
+
return undefined;
|
|
4641
|
+
const q = requireObject(raw);
|
|
4642
|
+
const digest = q.worker_env_digest;
|
|
4643
|
+
if (digest === undefined || digest === null)
|
|
4644
|
+
return undefined;
|
|
4645
|
+
if (typeof digest !== "string" || !GATE_DIGEST_RE.test(digest))
|
|
4646
|
+
throw readinessShapeError();
|
|
4647
|
+
return digest;
|
|
4648
|
+
}
|
|
4457
4649
|
/** Validate a gate-profile body, fail-closed. */
|
|
4458
4650
|
export function parseConductorGateProfileResponse(body, expectedRepoName) {
|
|
4459
4651
|
const o = requireObject(body);
|
|
@@ -4477,6 +4669,7 @@ export function parseConductorGateProfileResponse(body, expectedRepoName) {
|
|
|
4477
4669
|
if (outcome !== undefined && outcome !== null && (typeof outcome !== "string" || !GATE_PROFILE_WRITE_OUTCOMES.has(outcome))) {
|
|
4478
4670
|
throw readinessShapeError();
|
|
4479
4671
|
}
|
|
4672
|
+
const qualificationDigest = parseQualificationWorkerEnvDigest(o.qualification);
|
|
4480
4673
|
return {
|
|
4481
4674
|
repo_name: expectedRepoName,
|
|
4482
4675
|
source,
|
|
@@ -4486,6 +4679,7 @@ export function parseConductorGateProfileResponse(body, expectedRepoName) {
|
|
|
4486
4679
|
profile,
|
|
4487
4680
|
qualification_state: requireEnum(o, "qualification_state", GATE_QUALIFICATION_STATES),
|
|
4488
4681
|
outcome: (outcome ?? null),
|
|
4682
|
+
...(qualificationDigest ? { qualification_worker_env_digest: qualificationDigest } : {}),
|
|
4489
4683
|
};
|
|
4490
4684
|
}
|
|
4491
4685
|
function gateProfileUrl(access, suffix = "") {
|
|
@@ -4496,9 +4690,68 @@ export async function fetchConductorGateProfile(access, fetchImpl) {
|
|
|
4496
4690
|
const body = await fetchConductorJsonWithTimeout(gateProfileUrl(access), conductorGetHeaders(access), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
4497
4691
|
return parseConductorGateProfileResponse(body, access.repoName);
|
|
4498
4692
|
}
|
|
4499
|
-
|
|
4693
|
+
/**
|
|
4694
|
+
* BAPI-1520 — which extension fields the older server rejected, and only when
|
|
4695
|
+
* the request actually carried them. `worker_env` counts only at exactly
|
|
4696
|
+
* `["body","worker_env"]`; `reproduce` only at exactly
|
|
4697
|
+
* `["body","provider_checks",<index>,"reproduce"]`. Any other 422 returns
|
|
4698
|
+
* `null`, so an unrelated 422 is never read as an older-server case.
|
|
4699
|
+
*/
|
|
4700
|
+
export function classifyGateProfileExtensionRejection(err, request) {
|
|
4701
|
+
if (!(err instanceof ConductorBridgeApiError) || err.status !== 422)
|
|
4702
|
+
return null;
|
|
4703
|
+
const issues = err.gateProfileEvidence?.issues;
|
|
4704
|
+
if (!issues || issues.length === 0)
|
|
4705
|
+
return null;
|
|
4706
|
+
const confirm = request.action === "confirm" ? request : null;
|
|
4707
|
+
let workerEnv = false;
|
|
4708
|
+
let reproduce = false;
|
|
4709
|
+
for (const issue of issues) {
|
|
4710
|
+
if (issue.type !== "extra_forbidden")
|
|
4711
|
+
return null;
|
|
4712
|
+
const loc = issue.loc;
|
|
4713
|
+
if (loc.length === 2 && loc[0] === "body" && loc[1] === "worker_env") {
|
|
4714
|
+
if (!confirm || confirm.worker_env === undefined)
|
|
4715
|
+
return null;
|
|
4716
|
+
workerEnv = true;
|
|
4717
|
+
}
|
|
4718
|
+
else if (loc.length === 4 &&
|
|
4719
|
+
loc[0] === "body" &&
|
|
4720
|
+
loc[1] === "provider_checks" &&
|
|
4721
|
+
typeof loc[2] === "number" &&
|
|
4722
|
+
loc[3] === "reproduce") {
|
|
4723
|
+
const check = confirm?.provider_checks?.[loc[2]];
|
|
4724
|
+
if (!check || check.reproduce === undefined)
|
|
4725
|
+
return null;
|
|
4726
|
+
reproduce = true;
|
|
4727
|
+
}
|
|
4728
|
+
else {
|
|
4729
|
+
return null;
|
|
4730
|
+
}
|
|
4731
|
+
}
|
|
4732
|
+
return { worker_env: workerEnv, reproduce };
|
|
4733
|
+
}
|
|
4734
|
+
/** The safe refusal context of a failed write, or `undefined` when there is none. */
|
|
4735
|
+
function gateProfileRefusalDetail(err) {
|
|
4736
|
+
if (!(err instanceof ConductorBridgeApiError))
|
|
4737
|
+
return undefined;
|
|
4738
|
+
const evidence = err.gateProfileEvidence;
|
|
4739
|
+
if (!evidence)
|
|
4740
|
+
return undefined;
|
|
4741
|
+
const detail = {};
|
|
4742
|
+
if (evidence.field)
|
|
4743
|
+
detail.field = evidence.field;
|
|
4744
|
+
if (evidence.reason)
|
|
4745
|
+
detail.reason = evidence.reason;
|
|
4746
|
+
if (evidence.name)
|
|
4747
|
+
detail.name = evidence.name;
|
|
4748
|
+
return Object.keys(detail).length > 0 ? detail : undefined;
|
|
4749
|
+
}
|
|
4750
|
+
export function classifyGateProfileWriteFailure(err, request) {
|
|
4500
4751
|
if (!(err instanceof ConductorBridgeApiError))
|
|
4501
4752
|
return "network";
|
|
4753
|
+
if (request && classifyGateProfileExtensionRejection(err, request))
|
|
4754
|
+
return "extension-unsupported";
|
|
4502
4755
|
if (err.errorCode === "STALE_REVISION")
|
|
4503
4756
|
return "stale-revision";
|
|
4504
4757
|
if (err.errorCode === "UNKNOWN_STORED_STATE")
|
|
@@ -4532,7 +4785,12 @@ export async function putConductorGateProfile(access, request, fetchImpl) {
|
|
|
4532
4785
|
return { ok: true, profile: parseConductorGateProfileResponse(body, access.repoName) };
|
|
4533
4786
|
}
|
|
4534
4787
|
catch (err) {
|
|
4535
|
-
|
|
4788
|
+
const detail = gateProfileRefusalDetail(err);
|
|
4789
|
+
return {
|
|
4790
|
+
ok: false,
|
|
4791
|
+
refusal: classifyGateProfileWriteFailure(err, request),
|
|
4792
|
+
...(detail ? { detail } : {}),
|
|
4793
|
+
};
|
|
4536
4794
|
}
|
|
4537
4795
|
}
|
|
4538
4796
|
const EPIC_BRANCH_CI_AUDITED_FIELD_LIMIT = 8;
|
|
@@ -19,13 +19,18 @@ import { probeCommandDrift, } from "./command-drift.js";
|
|
|
19
19
|
/** Bounded timeout for one Git subprocess. */
|
|
20
20
|
const GIT_TIMEOUT_MS = 5_000;
|
|
21
21
|
const BLOB_ID = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* `timeoutMs` bounds each Git subprocess. Production keeps the 5 s default;
|
|
24
|
+
* tests that run real Git on a shared, loaded CI machine pass a longer bound so
|
|
25
|
+
* a slow process start is not mistaken for "Git could not be inspected".
|
|
26
|
+
*/
|
|
27
|
+
export function createGitRunner(cwd, timeoutMs = GIT_TIMEOUT_MS) {
|
|
23
28
|
return (args, input) => {
|
|
24
29
|
const result = spawnSync("git", args, {
|
|
25
30
|
cwd,
|
|
26
31
|
input,
|
|
27
32
|
encoding: "utf-8",
|
|
28
|
-
timeout:
|
|
33
|
+
timeout: timeoutMs,
|
|
29
34
|
stdio: [input === undefined ? "ignore" : "pipe", "pipe", "ignore"],
|
|
30
35
|
});
|
|
31
36
|
if (result.error)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { monotonicNow, elapsedMs } from "./precheck-timings.js";
|
|
1
2
|
/**
|
|
2
3
|
* Combined, strictly read-only epic-implementer doctor report (BAPI-395, BAPI-418).
|
|
3
4
|
*
|
|
@@ -344,7 +345,7 @@ export function buildWorkerDatabaseDoctorSection(inspection) {
|
|
|
344
345
|
boundaryRow(insp.boundary),
|
|
345
346
|
alembicRow(insp.alembic),
|
|
346
347
|
...inventoryRows(inventory),
|
|
347
|
-
],
|
|
348
|
+
].map((row) => ({ ...row, duration_ms: inspection?.timings?.[row.id] ?? elapsedMs(monotonicNow()) })),
|
|
348
349
|
inventory,
|
|
349
350
|
};
|
|
350
351
|
}
|
|
@@ -358,6 +359,11 @@ export function buildWorkerDatabaseDoctorSection(inspection) {
|
|
|
358
359
|
* say that the inspection failed without echoing exception text.
|
|
359
360
|
*/
|
|
360
361
|
export async function collectWorkerDatabaseDoctorSection(inspect, timeoutMs = WORKER_DATABASE_DOCTOR_TIMEOUT_MS, onFailure) {
|
|
362
|
+
const started = monotonicNow();
|
|
363
|
+
const failedSection = () => {
|
|
364
|
+
const section = buildWorkerDatabaseDoctorSection(null);
|
|
365
|
+
return { ...section, rows: section.rows.map((row) => ({ ...row, duration_ms: elapsedMs(started) })) };
|
|
366
|
+
};
|
|
361
367
|
let timer;
|
|
362
368
|
try {
|
|
363
369
|
const timeout = new Promise((resolve) => {
|
|
@@ -367,11 +373,11 @@ export async function collectWorkerDatabaseDoctorSection(inspect, timeoutMs = WO
|
|
|
367
373
|
const inspection = await Promise.race([Promise.resolve().then(inspect), timeout]);
|
|
368
374
|
if (inspection === null)
|
|
369
375
|
onFailure?.("timeout");
|
|
370
|
-
return buildWorkerDatabaseDoctorSection(inspection);
|
|
376
|
+
return inspection === null ? failedSection() : buildWorkerDatabaseDoctorSection(inspection);
|
|
371
377
|
}
|
|
372
378
|
catch {
|
|
373
379
|
onFailure?.("error");
|
|
374
|
-
return
|
|
380
|
+
return failedSection();
|
|
375
381
|
}
|
|
376
382
|
finally {
|
|
377
383
|
if (timer)
|
|
@@ -279,6 +279,10 @@ export function getConductorUsage() {
|
|
|
279
279
|
" anchored PR head to whatever the PR's head currently is, for a ticket parked",
|
|
280
280
|
" by a human/external push. Both retry internally on a concurrent row change —",
|
|
281
281
|
" neither accepts, nor ever asks for, a version counter.",
|
|
282
|
+
" --external-repair <operation-id> (adopt only) adopt fast-forward repair",
|
|
283
|
+
" commits pushed to the ticket's own branch while no engine job ran. The server",
|
|
284
|
+
" proves ancestry, the PR, no live work, and head ownership first; the ticket",
|
|
285
|
+
" then passes the ordinary gates. Run only by the run's supervisor/driver.",
|
|
282
286
|
"",
|
|
283
287
|
"Incident examples:",
|
|
284
288
|
" # A run is misbehaving and must stop immediately:",
|