@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseAssessmentNegotiation } from './readiness-assessment.js';
|
|
2
2
|
import { READINESS_PREREQUISITE_BY_ID } from "../readiness-prerequisites.generated.js";
|
|
3
|
+
import { EPIC_TICKET_STATUS_VALUES } from "../generated/ticket-status.js";
|
|
3
4
|
import { PREVIOUS_SERVER_READINESS_FIXES, READINESS_PREREQUISITE_FIXES } from "../printed-remedy-commands.js";
|
|
4
5
|
/**
|
|
5
6
|
* TypeScript-side Bridge API access layer for the conductor producer (BAPI-395).
|
|
@@ -25,6 +26,7 @@ import { CI_DATABASE_DEFAULT, isCiDatabase, parseDependencyInstallStrict, parseM
|
|
|
25
26
|
import { safeEpicLaunchTargetUrl } from "../epic-launch-diagnostic.js";
|
|
26
27
|
import { validateHttpBaseUrl } from "../base-url.js";
|
|
27
28
|
import { RERUN_CI_CHECK_STATUSES, RERUN_CI_NOT_RUNNABLE_REASONS, RERUN_CI_OUTCOMES, isCiResumeRefusalCode, } from "./repair-contract.js";
|
|
29
|
+
import { hashPlan } from "./plan.js";
|
|
28
30
|
/** Default Bridge API base URL when `BAPI_BASE_URL` is unset. */
|
|
29
31
|
export const CONDUCTOR_DEFAULT_BASE_URL = "https://bridgegpt-api.com";
|
|
30
32
|
/** Default per-request timeout for conductor Bridge API calls. */
|
|
@@ -911,22 +913,110 @@ export async function fetchEffectiveSupervisorConfig(access, epicKey, fetchImpl
|
|
|
911
913
|
const parsed = await fetchConductorJsonWithTimeout(url, conductorGetHeaders(access), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
912
914
|
return parsed;
|
|
913
915
|
}
|
|
916
|
+
/** Server bounds on the `required_checks` query value (BAPI-1527). */
|
|
917
|
+
export const POLL_CI_CHECKS_MAX_REQUIRED_NAMES = 64;
|
|
918
|
+
export const POLL_CI_CHECKS_MAX_REQUIRED_NAME_LENGTH = 200;
|
|
919
|
+
/** The fixed unresolved-cache reason the poll route returns without the fallback. */
|
|
920
|
+
const CI_CHECKS_UNRESOLVED_REASON = "CI checks not yet resolved";
|
|
921
|
+
/** True when `requiredChecks` satisfies the route's array, string, and size contract. */
|
|
922
|
+
function isValidRequiredChecksList(requiredChecks) {
|
|
923
|
+
return (Array.isArray(requiredChecks) &&
|
|
924
|
+
requiredChecks.length <= POLL_CI_CHECKS_MAX_REQUIRED_NAMES &&
|
|
925
|
+
requiredChecks.every((name) => typeof name === "string" && name.length <= POLL_CI_CHECKS_MAX_REQUIRED_NAME_LENGTH));
|
|
926
|
+
}
|
|
914
927
|
/**
|
|
915
928
|
* Poll CI checks for a commit through the existing `/poll-ci-checks` endpoint.
|
|
916
929
|
* Validates `commitRef` with {@link normalizeSha} and rejects BEFORE issuing the
|
|
917
930
|
* request when it is not a valid SHA. Returns the endpoint response verbatim —
|
|
918
931
|
* the client never invents `pr_number`/`head_sha` fields.
|
|
919
|
-
|
|
920
|
-
|
|
932
|
+
*
|
|
933
|
+
* BAPI-1527: the optional trailing `requiredChecks` opts into the route's
|
|
934
|
+
* read-only fallback for a repository whose CI check configuration was never
|
|
935
|
+
* resolved. It is encoded as a JSON array in `required_checks`; an explicit `[]`
|
|
936
|
+
* is sent as `[]`, never omitted. A value that breaks the route's bounds throws
|
|
937
|
+
* `invalid-input` before any request. When the route reports a transient polling
|
|
938
|
+
* failure for an opted-in call, this throws a fixed-text `server` error so the
|
|
939
|
+
* caller keeps its retryable `ci_poll_*` handling; a configuration-unavailable
|
|
940
|
+
* response is returned for {@link classifyCiPollAvailability} to read.
|
|
941
|
+
*/
|
|
942
|
+
export async function pollCiChecksForCommit(access, commitRef, fetchImpl = globalThis.fetch, requiredChecks) {
|
|
921
943
|
const sha = normalizeSha(commitRef);
|
|
922
944
|
if (sha === null) {
|
|
923
945
|
throw new ConductorBridgeApiError("invalid-input");
|
|
924
946
|
}
|
|
925
|
-
|
|
947
|
+
if (requiredChecks !== undefined && !isValidRequiredChecksList(requiredChecks)) {
|
|
948
|
+
throw new ConductorBridgeApiError("invalid-input");
|
|
949
|
+
}
|
|
950
|
+
const params = {
|
|
926
951
|
repo_name: access.repoName,
|
|
927
952
|
commit_ref: sha,
|
|
928
|
-
}
|
|
929
|
-
|
|
953
|
+
};
|
|
954
|
+
if (requiredChecks !== undefined) {
|
|
955
|
+
params.required_checks = JSON.stringify(requiredChecks);
|
|
956
|
+
}
|
|
957
|
+
const url = buildConductorJiraUrl(access.baseUrl, "/poll-ci-checks", params);
|
|
958
|
+
const response = await fetchConductorJsonWithTimeout(url, conductorGetHeaders(access), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
959
|
+
if (requiredChecks !== undefined && readUnavailabilityKind(response) === "transient") {
|
|
960
|
+
// Fixed text only: no upstream reason or body is carried forward.
|
|
961
|
+
throw new CiPollTransientUnavailableError();
|
|
962
|
+
}
|
|
963
|
+
return response;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* BAPI-1527: the route answered an opted-in poll with `unavailability_kind:
|
|
967
|
+
* "transient"` (an exception while it polled the provider). It is an ordinary
|
|
968
|
+
* `server` error to every caller, so readers that stop on a thrown poll keep
|
|
969
|
+
* doing so. The local merge wait alone tells it apart from a real 5xx or network
|
|
970
|
+
* failure: before the opt-in, the same exception came back as a plain
|
|
971
|
+
* not-green envelope and the wait kept polling, so it still does (decision A,
|
|
972
|
+
* never an earlier park).
|
|
973
|
+
*/
|
|
974
|
+
export class CiPollTransientUnavailableError extends ConductorBridgeApiError {
|
|
975
|
+
constructor() {
|
|
976
|
+
super("server");
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
/** The `unavailability_kind` of a poll envelope, or `undefined` when absent or unknown. */
|
|
980
|
+
function readUnavailabilityKind(response) {
|
|
981
|
+
if (response === null || typeof response !== "object")
|
|
982
|
+
return undefined;
|
|
983
|
+
const kind = response.unavailability_kind;
|
|
984
|
+
return kind === "configuration" || kind === "transient" ? kind : undefined;
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Classify a poll response's availability. `configuration_unavailable` means the
|
|
988
|
+
* required-check configuration or provider access could not be read — the
|
|
989
|
+
* route's fixed `unavailability_kind: "configuration"` or its legacy fixed
|
|
990
|
+
* unresolved-cache reason. It is evidence of a missing capability, never of a
|
|
991
|
+
* failed check, so a `detail: null` body must not be read as red CI.
|
|
992
|
+
*/
|
|
993
|
+
export function classifyCiPollAvailability(response) {
|
|
994
|
+
if (response === null || typeof response !== "object")
|
|
995
|
+
return "unavailable_other";
|
|
996
|
+
const obj = response;
|
|
997
|
+
if (obj.available === true)
|
|
998
|
+
return "available";
|
|
999
|
+
if (obj.available !== false)
|
|
1000
|
+
return "unavailable_other";
|
|
1001
|
+
if (readUnavailabilityKind(obj) === "configuration" || obj.reason === CI_CHECKS_UNRESOLVED_REASON) {
|
|
1002
|
+
return "configuration_unavailable";
|
|
1003
|
+
}
|
|
1004
|
+
return "unavailable_other";
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* True when a successful poll came from the route's required-checks fallback and
|
|
1008
|
+
* observed no check at all. Distinguishes "nothing reported yet" from red CI.
|
|
1009
|
+
*/
|
|
1010
|
+
export function isFallbackWithNoObservedChecks(response) {
|
|
1011
|
+
if (response === null || typeof response !== "object")
|
|
1012
|
+
return false;
|
|
1013
|
+
const detail = response.detail;
|
|
1014
|
+
if (detail === null || typeof detail !== "object")
|
|
1015
|
+
return false;
|
|
1016
|
+
const d = detail;
|
|
1017
|
+
return (d.evaluation_source === "required_checks_fallback" &&
|
|
1018
|
+
Array.isArray(d.checks) &&
|
|
1019
|
+
d.checks.length === 0);
|
|
930
1020
|
}
|
|
931
1021
|
// ---------------------------------------------------------------------------
|
|
932
1022
|
// Conductor BAPI-440: PR review status GET client
|
|
@@ -1029,8 +1119,8 @@ export async function fetchConductorJsonPostWithTimeout(url, headers, body, time
|
|
|
1029
1119
|
}
|
|
1030
1120
|
/**
|
|
1031
1121
|
* PATCH JSON with an `AbortController` timeout. Thin wrapper over
|
|
1032
|
-
* {@link fetchConductorJsonWithMethodAndTimeout}. Used by the
|
|
1033
|
-
*
|
|
1122
|
+
* {@link fetchConductorJsonWithMethodAndTimeout}. Used by the remaining live
|
|
1123
|
+
* PATCH consumers (run policy and node ticket-spec updates).
|
|
1034
1124
|
*/
|
|
1035
1125
|
export async function fetchConductorJsonPatchWithTimeout(url, headers, body, timeoutMs, fetchImpl) {
|
|
1036
1126
|
return fetchConductorJsonWithMethodAndTimeout("PATCH", url, headers, body, timeoutMs, fetchImpl);
|
|
@@ -1171,14 +1261,8 @@ function requireNoSlashPathSegment(value) {
|
|
|
1171
1261
|
throw new ConductorBridgeApiError("invalid-input");
|
|
1172
1262
|
}
|
|
1173
1263
|
}
|
|
1174
|
-
const EPIC_TICKET_STATUS_VALUES = [
|
|
1175
|
-
"planned", "ready", "dispatched", "running", "blocked", "abandoned", "done", "ready_for_review",
|
|
1176
|
-
"reviewing",
|
|
1177
|
-
// BAPI-527: asynchronous post-merge parse state (see EpicTicketStatusValue).
|
|
1178
|
-
"parse_pending",
|
|
1179
|
-
];
|
|
1180
1264
|
function requireEpicTicketStatusValue(value) {
|
|
1181
|
-
if (typeof value !== "string" || !EPIC_TICKET_STATUS_VALUES.
|
|
1265
|
+
if (typeof value !== "string" || !EPIC_TICKET_STATUS_VALUES.some((status) => status === value)) {
|
|
1182
1266
|
throw new ConductorBridgeApiError("invalid-input");
|
|
1183
1267
|
}
|
|
1184
1268
|
}
|
|
@@ -1662,7 +1746,7 @@ export async function createEpicRunWithDisposition(access, request, fetchImpl =
|
|
|
1662
1746
|
// `ConductorMutationOutcomeUnknownError`; the caller re-reads, never re-sends.
|
|
1663
1747
|
let response;
|
|
1664
1748
|
try {
|
|
1665
|
-
response = await fetchConductorJsonWithMethodStatusAndTimeout("POST", url, conductorPostHeaders(access), JSON.stringify(body),
|
|
1749
|
+
response = await fetchConductorJsonWithMethodStatusAndTimeout("POST", url, conductorPostHeaders(access), JSON.stringify(body), CONDUCTOR_READINESS_FETCH_TIMEOUT_MS, fetchImpl);
|
|
1666
1750
|
}
|
|
1667
1751
|
catch (err) {
|
|
1668
1752
|
rethrowMutationFailure("create", err);
|
|
@@ -1738,8 +1822,12 @@ export async function stopEpicRun(access, request, fetchImpl = globalThis.fetch)
|
|
|
1738
1822
|
return parsed;
|
|
1739
1823
|
}
|
|
1740
1824
|
// ---------------------------------------------------------------------------
|
|
1741
|
-
//
|
|
1825
|
+
// Shared unpark / adopt recovery-result parser
|
|
1742
1826
|
// ---------------------------------------------------------------------------
|
|
1827
|
+
/**
|
|
1828
|
+
* Parse the shared unpark / adopt-current-head-and-unpark recovery result,
|
|
1829
|
+
* including the structured `{ok: false, kind: "cas-conflict"}` envelope.
|
|
1830
|
+
*/
|
|
1743
1831
|
function parseAdvanceEpicTicketStatusResult(parsed) {
|
|
1744
1832
|
if (!parsed || typeof parsed !== "object") {
|
|
1745
1833
|
throw new ConductorBridgeApiError("server");
|
|
@@ -1768,48 +1856,14 @@ function parseAdvanceEpicTicketStatusResult(parsed) {
|
|
|
1768
1856
|
}
|
|
1769
1857
|
throw new ConductorBridgeApiError("server");
|
|
1770
1858
|
}
|
|
1771
|
-
/**
|
|
1772
|
-
* PATCH the per-ticket CAS status endpoint
|
|
1773
|
-
* (`PATCH /runs/{epic_run_id}/tickets/{ticket_key}`). Surfaces structured CAS
|
|
1774
|
-
* conflicts as a distinct non-throwing outcome where the backend returns one;
|
|
1775
|
-
* the current backend instead raises a 400 CONFLICT on a stale row_version
|
|
1776
|
-
* (BAPI-1016 — the status stays 400; only the body error_code changed from the
|
|
1777
|
-
* former VALIDATION), which surfaces as a thrown `ConductorBridgeApiError("http", 400)`.
|
|
1778
|
-
* Transport/auth/server failures still throw a sanitized {@link ConductorBridgeApiError}.
|
|
1779
|
-
*/
|
|
1780
|
-
export async function advanceEpicTicketStatus(access, request, fetchImpl = globalThis.fetch) {
|
|
1781
|
-
requireNonEmptyString(request.epicKey);
|
|
1782
|
-
requireNonEmptyString(request.ticketKey);
|
|
1783
|
-
requireNonNegativeSafeInteger(request.expectedRowVersion);
|
|
1784
|
-
requireNonNegativeSafeInteger(request.planVersion);
|
|
1785
|
-
requireEpicTicketStatusValue(request.nextStatus);
|
|
1786
|
-
if (request.dispatchRunId !== undefined) {
|
|
1787
|
-
requireNonEmptyString(request.dispatchRunId);
|
|
1788
|
-
}
|
|
1789
|
-
// The backend declares this endpoint as PATCH /runs/{epic_run_id}/tickets/{ticket_key}
|
|
1790
|
-
// (api/routes/epic_runs.py:489). The body matches PatchEpicTicketStatusRequest:
|
|
1791
|
-
// repo_name + expected_row_version are required; status/plan_version/dispatch_run_id
|
|
1792
|
-
// are optional and accepted (the model does not forbid extras).
|
|
1793
|
-
const CAS_ENDPOINT_PATH = `${epicRunApiPath(request.epicKey)}/tickets/${encodeURIComponent(request.ticketKey)}`;
|
|
1794
|
-
const url = buildConductorJiraUrl(access.baseUrl, CAS_ENDPOINT_PATH);
|
|
1795
|
-
const body = JSON.stringify({
|
|
1796
|
-
repo_name: access.repoName,
|
|
1797
|
-
status: request.nextStatus,
|
|
1798
|
-
plan_version: request.planVersion,
|
|
1799
|
-
expected_row_version: request.expectedRowVersion,
|
|
1800
|
-
...(request.dispatchRunId ? { dispatch_run_id: request.dispatchRunId } : {}),
|
|
1801
|
-
});
|
|
1802
|
-
const parsed = await fetchConductorJsonPatchWithTimeout(url, conductorPostHeaders(access), body, CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
1803
|
-
return parseAdvanceEpicTicketStatusResult(parsed);
|
|
1804
|
-
}
|
|
1805
1859
|
// ---------------------------------------------------------------------------
|
|
1806
1860
|
// Operator recovery: ticket unpark + adopt-current-head-and-unpark (BAPI-872)
|
|
1807
1861
|
// ---------------------------------------------------------------------------
|
|
1808
1862
|
/**
|
|
1809
1863
|
* Catch a stale-CAS 400 thrown by the POST transport and translate it into the
|
|
1810
1864
|
* SAME `{ok: false, kind: "cas-conflict", current_row_version}` result
|
|
1811
|
-
* {@link parseAdvanceEpicTicketStatusResult}
|
|
1812
|
-
*
|
|
1865
|
+
* {@link parseAdvanceEpicTicketStatusResult} produces for a stale-CAS
|
|
1866
|
+
* conflict — the previously dormant conflict branch that now becomes production
|
|
1813
1867
|
* behavior for both unpark lanes. Only a genuine stale-CAS shape (400 status with
|
|
1814
1868
|
* a validated `currentRowVersion`) is translated; every other failure re-throws
|
|
1815
1869
|
* unchanged, preserving `ConductorBridgeApiError` for terminal, validation,
|
|
@@ -3314,6 +3368,252 @@ export async function getEpicPlan(access, epicKey, planVersion, fetchImpl = glob
|
|
|
3314
3368
|
const parsed = await fetchConductorJsonWithTimeout(url, conductorGetHeaders(access), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
3315
3369
|
return parsed;
|
|
3316
3370
|
}
|
|
3371
|
+
/** Thrown by {@link saveAuthoredEpicPlan}. The message is fixed and value-free. */
|
|
3372
|
+
export class AuthoredEpicPlanSaveError extends Error {
|
|
3373
|
+
reason;
|
|
3374
|
+
constructor(reason) {
|
|
3375
|
+
super(`authored plan save failed (${reason})`);
|
|
3376
|
+
this.name = "AuthoredEpicPlanSaveError";
|
|
3377
|
+
this.reason = reason;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
function authoredPlansApiPath(epicKey, suffix = "") {
|
|
3381
|
+
return `${EPIC_RUNS_API_PREFIX}/epics/${encodeURIComponent(epicKey)}/authored-plans${suffix}`;
|
|
3382
|
+
}
|
|
3383
|
+
function isPlainObject(value) {
|
|
3384
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3385
|
+
}
|
|
3386
|
+
/**
|
|
3387
|
+
* Validate a snapshot body and recompute its hash. Returns `null` for any shape
|
|
3388
|
+
* problem and the string `"hash_mismatch"` when the blob does not hash to the
|
|
3389
|
+
* stored `plan_hash`. The returned blob is the server's own object, unchanged.
|
|
3390
|
+
*/
|
|
3391
|
+
export function parseAuthoredEpicPlanSnapshot(body) {
|
|
3392
|
+
if (!isPlainObject(body))
|
|
3393
|
+
return null;
|
|
3394
|
+
const { repo_name, epic_key, authored_version, plan_blob, plan_hash, eligibility_advisory, gap_check_record, saved_by, saved_at, } = body;
|
|
3395
|
+
if (typeof repo_name !== "string" || repo_name.length === 0)
|
|
3396
|
+
return null;
|
|
3397
|
+
if (typeof epic_key !== "string" || epic_key.length === 0)
|
|
3398
|
+
return null;
|
|
3399
|
+
if (typeof authored_version !== "number" ||
|
|
3400
|
+
!Number.isSafeInteger(authored_version) ||
|
|
3401
|
+
authored_version < 1) {
|
|
3402
|
+
return null;
|
|
3403
|
+
}
|
|
3404
|
+
if (typeof plan_hash !== "string" || plan_hash.length === 0)
|
|
3405
|
+
return null;
|
|
3406
|
+
if (typeof saved_by !== "string" || typeof saved_at !== "string")
|
|
3407
|
+
return null;
|
|
3408
|
+
if (eligibility_advisory !== null && !isPlainObject(eligibility_advisory))
|
|
3409
|
+
return null;
|
|
3410
|
+
if (gap_check_record !== null && !isPlainObject(gap_check_record))
|
|
3411
|
+
return null;
|
|
3412
|
+
if (!isPlainObject(plan_blob))
|
|
3413
|
+
return null;
|
|
3414
|
+
const version = plan_blob.plan_version;
|
|
3415
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 1)
|
|
3416
|
+
return null;
|
|
3417
|
+
if (!Array.isArray(plan_blob.nodes) || plan_blob.nodes.length === 0)
|
|
3418
|
+
return null;
|
|
3419
|
+
if (!Array.isArray(plan_blob.edges))
|
|
3420
|
+
return null;
|
|
3421
|
+
for (const node of plan_blob.nodes) {
|
|
3422
|
+
if (!isPlainObject(node) || typeof node.ticket_key !== "string" || node.ticket_key.trim() === "") {
|
|
3423
|
+
return null;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
let recomputed;
|
|
3427
|
+
try {
|
|
3428
|
+
recomputed = hashPlan(plan_blob);
|
|
3429
|
+
}
|
|
3430
|
+
catch {
|
|
3431
|
+
return null;
|
|
3432
|
+
}
|
|
3433
|
+
if (recomputed !== plan_hash)
|
|
3434
|
+
return "hash_mismatch";
|
|
3435
|
+
return {
|
|
3436
|
+
repo_name,
|
|
3437
|
+
epic_key,
|
|
3438
|
+
authored_version,
|
|
3439
|
+
plan_blob: plan_blob,
|
|
3440
|
+
plan_hash,
|
|
3441
|
+
eligibility_advisory: (eligibility_advisory ?? null),
|
|
3442
|
+
gap_check_record: (gap_check_record ?? null),
|
|
3443
|
+
saved_by,
|
|
3444
|
+
saved_at,
|
|
3445
|
+
};
|
|
3446
|
+
}
|
|
3447
|
+
/** True only for FastAPI's default "route does not exist" body, exactly. */
|
|
3448
|
+
function isDefaultNotFoundBody(body) {
|
|
3449
|
+
if (!isPlainObject(body))
|
|
3450
|
+
return false;
|
|
3451
|
+
const keys = Object.keys(body);
|
|
3452
|
+
return keys.length === 1 && keys[0] === "detail" && body.detail === "Not Found";
|
|
3453
|
+
}
|
|
3454
|
+
async function readJsonResponse(run, timeoutMs) {
|
|
3455
|
+
const controller = new AbortController();
|
|
3456
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
3457
|
+
try {
|
|
3458
|
+
let resp;
|
|
3459
|
+
try {
|
|
3460
|
+
resp = await run(controller.signal);
|
|
3461
|
+
}
|
|
3462
|
+
catch {
|
|
3463
|
+
return controller.signal.aborted ? { kind: "timeout" } : { kind: "network" };
|
|
3464
|
+
}
|
|
3465
|
+
try {
|
|
3466
|
+
const body = await resp.json();
|
|
3467
|
+
return { kind: "response", status: resp.status, ok: resp.ok, body, bodyReadable: true };
|
|
3468
|
+
}
|
|
3469
|
+
catch {
|
|
3470
|
+
if (controller.signal.aborted)
|
|
3471
|
+
return { kind: "timeout" };
|
|
3472
|
+
return { kind: "response", status: resp.status, ok: resp.ok, body: undefined, bodyReadable: false };
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
finally {
|
|
3476
|
+
clearTimeout(timer);
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
function unknownReasonForStatus(status) {
|
|
3480
|
+
if (status === 401 || status === 403)
|
|
3481
|
+
return "unauthorized";
|
|
3482
|
+
if (status >= 500)
|
|
3483
|
+
return "server_error";
|
|
3484
|
+
return "http_error";
|
|
3485
|
+
}
|
|
3486
|
+
/**
|
|
3487
|
+
* Read the latest authored plan for an epic (BAPI-1706).
|
|
3488
|
+
*
|
|
3489
|
+
* - `found` / `not_stored` come only from a well-formed typed 200; a found
|
|
3490
|
+
* snapshot's blob must hash to its stored `plan_hash`.
|
|
3491
|
+
* - `server_too_old` comes only from a 404 whose body is exactly
|
|
3492
|
+
* `{"detail": "Not Found"}` — the route does not exist on this server.
|
|
3493
|
+
* - Everything else (401/403, other 404s, 405, 5xx, malformed 200s, a hash
|
|
3494
|
+
* mismatch, a timeout, a dropped connection) is `unknown`, never absence.
|
|
3495
|
+
*
|
|
3496
|
+
* Never throws.
|
|
3497
|
+
*/
|
|
3498
|
+
export async function getAuthoredEpicPlan(access, epicKey, fetchImpl = globalThis.fetch, timeoutMs = CONDUCTOR_FETCH_TIMEOUT_MS) {
|
|
3499
|
+
let url;
|
|
3500
|
+
try {
|
|
3501
|
+
requireNonEmptyString(epicKey);
|
|
3502
|
+
url = buildConductorJiraUrl(access.baseUrl, authoredPlansApiPath(epicKey, "/latest"), {
|
|
3503
|
+
repo_name: access.repoName,
|
|
3504
|
+
});
|
|
3505
|
+
}
|
|
3506
|
+
catch {
|
|
3507
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3508
|
+
}
|
|
3509
|
+
const raw = await readJsonResponse((signal) => fetchImpl(url, { headers: conductorGetHeaders(access), signal }), timeoutMs);
|
|
3510
|
+
if (raw.kind !== "response")
|
|
3511
|
+
return { kind: "unknown", reason: raw.kind };
|
|
3512
|
+
if (!raw.ok) {
|
|
3513
|
+
if (raw.status === 404 && raw.bodyReadable && isDefaultNotFoundBody(raw.body)) {
|
|
3514
|
+
return { kind: "server_too_old" };
|
|
3515
|
+
}
|
|
3516
|
+
return { kind: "unknown", reason: unknownReasonForStatus(raw.status) };
|
|
3517
|
+
}
|
|
3518
|
+
if (!raw.bodyReadable || !isPlainObject(raw.body)) {
|
|
3519
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3520
|
+
}
|
|
3521
|
+
if (raw.body.status === "not_stored" && Object.keys(raw.body).length === 1) {
|
|
3522
|
+
return { kind: "not_stored" };
|
|
3523
|
+
}
|
|
3524
|
+
if (raw.body.status !== "found")
|
|
3525
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3526
|
+
const snapshot = parseAuthoredEpicPlanSnapshot(raw.body);
|
|
3527
|
+
if (snapshot === "hash_mismatch")
|
|
3528
|
+
return { kind: "unknown", reason: "hash_mismatch" };
|
|
3529
|
+
if (snapshot === null || snapshot.epic_key !== epicKey || snapshot.repo_name !== access.repoName) {
|
|
3530
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3531
|
+
}
|
|
3532
|
+
return { kind: "found", snapshot };
|
|
3533
|
+
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Read one numbered authored-plan version. A missing version is `not_found`
|
|
3536
|
+
* (an `unknown` reason), never `server_too_old`: only the latest route is used to
|
|
3537
|
+
* decide compatibility. Never throws.
|
|
3538
|
+
*/
|
|
3539
|
+
export async function getAuthoredEpicPlanVersion(access, epicKey, authoredVersion, fetchImpl = globalThis.fetch, timeoutMs = CONDUCTOR_FETCH_TIMEOUT_MS) {
|
|
3540
|
+
let url;
|
|
3541
|
+
try {
|
|
3542
|
+
requireNonEmptyString(epicKey);
|
|
3543
|
+
requirePositiveSafeInteger(authoredVersion);
|
|
3544
|
+
url = buildConductorJiraUrl(access.baseUrl, authoredPlansApiPath(epicKey, `/${authoredVersion}`), {
|
|
3545
|
+
repo_name: access.repoName,
|
|
3546
|
+
});
|
|
3547
|
+
}
|
|
3548
|
+
catch {
|
|
3549
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3550
|
+
}
|
|
3551
|
+
const raw = await readJsonResponse((signal) => fetchImpl(url, { headers: conductorGetHeaders(access), signal }), timeoutMs);
|
|
3552
|
+
if (raw.kind !== "response")
|
|
3553
|
+
return { kind: "unknown", reason: raw.kind };
|
|
3554
|
+
if (!raw.ok) {
|
|
3555
|
+
return { kind: "unknown", reason: raw.status === 404 ? "not_found" : unknownReasonForStatus(raw.status) };
|
|
3556
|
+
}
|
|
3557
|
+
const snapshot = parseAuthoredEpicPlanSnapshot(raw.body);
|
|
3558
|
+
if (snapshot === "hash_mismatch")
|
|
3559
|
+
return { kind: "unknown", reason: "hash_mismatch" };
|
|
3560
|
+
if (snapshot === null || snapshot.authored_version !== authoredVersion) {
|
|
3561
|
+
return { kind: "unknown", reason: "malformed_response" };
|
|
3562
|
+
}
|
|
3563
|
+
return { kind: "found", snapshot };
|
|
3564
|
+
}
|
|
3565
|
+
/**
|
|
3566
|
+
* Save an authored plan (BAPI-1706). Returns the server's complete selected
|
|
3567
|
+
* snapshot plus `created`; with `ifAbsent` a concurrent writer's existing
|
|
3568
|
+
* snapshot comes back with `created: false`. The response is verified the same
|
|
3569
|
+
* way a read is, including the hash recheck. Throws only
|
|
3570
|
+
* {@link AuthoredEpicPlanSaveError}, whose message is fixed and value-free.
|
|
3571
|
+
*/
|
|
3572
|
+
export async function saveAuthoredEpicPlan(access, request, fetchImpl = globalThis.fetch, timeoutMs = CONDUCTOR_FETCH_TIMEOUT_MS) {
|
|
3573
|
+
let url;
|
|
3574
|
+
let body;
|
|
3575
|
+
try {
|
|
3576
|
+
requireNonEmptyString(request.epicKey);
|
|
3577
|
+
requireNonEmptyString(request.planHash);
|
|
3578
|
+
url = buildConductorJiraUrl(access.baseUrl, authoredPlansApiPath(request.epicKey));
|
|
3579
|
+
body = JSON.stringify({
|
|
3580
|
+
repo_name: access.repoName,
|
|
3581
|
+
plan_blob: request.planBlob,
|
|
3582
|
+
plan_hash: request.planHash,
|
|
3583
|
+
eligibility_advisory: request.eligibilityAdvisory,
|
|
3584
|
+
gap_check_record: request.gapCheckRecord,
|
|
3585
|
+
if_absent: request.ifAbsent === true,
|
|
3586
|
+
});
|
|
3587
|
+
}
|
|
3588
|
+
catch {
|
|
3589
|
+
throw new AuthoredEpicPlanSaveError("validation");
|
|
3590
|
+
}
|
|
3591
|
+
const raw = await readJsonResponse((signal) => fetchImpl(url, { method: "POST", headers: conductorPostHeaders(access), body, signal }), timeoutMs);
|
|
3592
|
+
if (raw.kind !== "response")
|
|
3593
|
+
throw new AuthoredEpicPlanSaveError(raw.kind);
|
|
3594
|
+
if (!raw.ok) {
|
|
3595
|
+
if (raw.status === 404 && raw.bodyReadable && isDefaultNotFoundBody(raw.body)) {
|
|
3596
|
+
throw new AuthoredEpicPlanSaveError("server_too_old");
|
|
3597
|
+
}
|
|
3598
|
+
if (raw.status === 400 || raw.status === 422)
|
|
3599
|
+
throw new AuthoredEpicPlanSaveError("validation");
|
|
3600
|
+
throw new AuthoredEpicPlanSaveError(unknownReasonForStatus(raw.status));
|
|
3601
|
+
}
|
|
3602
|
+
if (!raw.bodyReadable || !isPlainObject(raw.body) || typeof raw.body.created !== "boolean") {
|
|
3603
|
+
throw new AuthoredEpicPlanSaveError("malformed_response");
|
|
3604
|
+
}
|
|
3605
|
+
const snapshot = parseAuthoredEpicPlanSnapshot(raw.body);
|
|
3606
|
+
if (snapshot === "hash_mismatch")
|
|
3607
|
+
throw new AuthoredEpicPlanSaveError("hash_mismatch");
|
|
3608
|
+
if (snapshot === null || snapshot.epic_key !== request.epicKey || snapshot.repo_name !== access.repoName) {
|
|
3609
|
+
throw new AuthoredEpicPlanSaveError("malformed_response");
|
|
3610
|
+
}
|
|
3611
|
+
// A newly created version must be exactly what was sent.
|
|
3612
|
+
if (raw.body.created === true && snapshot.plan_hash !== request.planHash) {
|
|
3613
|
+
throw new AuthoredEpicPlanSaveError("hash_mismatch");
|
|
3614
|
+
}
|
|
3615
|
+
return { created: raw.body.created, snapshot };
|
|
3616
|
+
}
|
|
3317
3617
|
/**
|
|
3318
3618
|
* BAPI-1252: the backend's closed canonical refusal vocabulary, mirrored as
|
|
3319
3619
|
* string literals (the Python source is `api/models/canonical_index_state.py`;
|
|
@@ -3714,6 +4014,27 @@ export function parseReadinessPrerequisites(raw) {
|
|
|
3714
4014
|
}
|
|
3715
4015
|
return result;
|
|
3716
4016
|
}
|
|
4017
|
+
/** BAPI-1526 — the four forecast outcomes the server may report. */
|
|
4018
|
+
export const MERGE_FORECAST_OUTCOMES = [
|
|
4019
|
+
"auto_merge_kept",
|
|
4020
|
+
"merge_approval_required",
|
|
4021
|
+
"not_requested",
|
|
4022
|
+
"unknown",
|
|
4023
|
+
];
|
|
4024
|
+
/** BAPI-1526 — the closed first-approval stamp reason tokens (`gate_profile.py`). */
|
|
4025
|
+
export const MERGE_FORECAST_REASON_IDS = [
|
|
4026
|
+
"local_gate_verification_disabled",
|
|
4027
|
+
"local_gate_direct_to_base",
|
|
4028
|
+
"none_profile_requires_merge_approval",
|
|
4029
|
+
"operator_no_ci_gate_override",
|
|
4030
|
+
"operator_ci_key_kept",
|
|
4031
|
+
"plan_node_required_checks_gate_the_run",
|
|
4032
|
+
"repository_policy_auto_merge_kept_without_ci",
|
|
4033
|
+
"epic_branch_ci_declined",
|
|
4034
|
+
"epic_branch_auto_merge_kept",
|
|
4035
|
+
"no_automated_check",
|
|
4036
|
+
"watched_checks_only",
|
|
4037
|
+
];
|
|
3717
4038
|
export const ESCALATION_CHANNELS = ["webhook", "email", "none", "unknown"];
|
|
3718
4039
|
export const WEBHOOK_LAST_DELIVERIES = ["failed", "handed_off", "queued", "unknown"];
|
|
3719
4040
|
/** BAPI-1452 — the three supported merge execution modes, as the server reports them. */
|
|
@@ -4104,6 +4425,32 @@ export function parseConductorReadinessResponse(body) {
|
|
|
4104
4425
|
})(),
|
|
4105
4426
|
...parseLaunchMergeFacts(root),
|
|
4106
4427
|
...parseEscalationObservations(root),
|
|
4428
|
+
...(() => {
|
|
4429
|
+
const forecast = parseMergeForecast(root.merge_forecast);
|
|
4430
|
+
return forecast === undefined ? {} : { merge_forecast: forecast };
|
|
4431
|
+
})(),
|
|
4432
|
+
};
|
|
4433
|
+
}
|
|
4434
|
+
/**
|
|
4435
|
+
* BAPI-1526 — parse the optional advisory forecast. Absent, `null`, or malformed
|
|
4436
|
+
* (an unknown outcome, a non-array, an unknown reason, or too many reasons) is
|
|
4437
|
+
* `undefined`, never an error: losing the readiness read over an advisory field
|
|
4438
|
+
* would be the wrong trade.
|
|
4439
|
+
*/
|
|
4440
|
+
export function parseMergeForecast(value) {
|
|
4441
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
4442
|
+
return undefined;
|
|
4443
|
+
const o = value;
|
|
4444
|
+
if (!MERGE_FORECAST_OUTCOMES.includes(o.outcome))
|
|
4445
|
+
return undefined;
|
|
4446
|
+
const raw = o.reason_ids === undefined ? [] : o.reason_ids;
|
|
4447
|
+
if (!Array.isArray(raw) || raw.length > MERGE_FORECAST_REASON_IDS.length)
|
|
4448
|
+
return undefined;
|
|
4449
|
+
if (!raw.every((r) => MERGE_FORECAST_REASON_IDS.includes(r)))
|
|
4450
|
+
return undefined;
|
|
4451
|
+
return {
|
|
4452
|
+
outcome: o.outcome,
|
|
4453
|
+
reason_ids: [...raw],
|
|
4107
4454
|
};
|
|
4108
4455
|
}
|
|
4109
4456
|
/**
|
|
@@ -5195,6 +5542,252 @@ export async function regeneratePlanTicket(access, request, fetchImpl = globalTh
|
|
|
5195
5542
|
}
|
|
5196
5543
|
}
|
|
5197
5544
|
// ---------------------------------------------------------------------------
|
|
5545
|
+
// BAPI-1705 — driver open-decision councils: `reserve-council` / `record-decision`
|
|
5546
|
+
// ---------------------------------------------------------------------------
|
|
5547
|
+
//
|
|
5548
|
+
// During an unattended run the driver may settle an eligible open choice by
|
|
5549
|
+
// council, at most twice per run. It first RESERVES one logical council under a
|
|
5550
|
+
// stable key (`<epic_run_id>:<ticket_key>:park-<park_generation>`), then SETTLES
|
|
5551
|
+
// that row once with every council request id it used and the outcome it
|
|
5552
|
+
// classified. Both calls are idempotent on the server: a repeated reservation key
|
|
5553
|
+
// returns the stored row, and an identical settle on a settled row is a replay.
|
|
5554
|
+
//
|
|
5555
|
+
// Like `regenerate-plan`, neither function throws for an HTTP or transport
|
|
5556
|
+
// outcome: every answer is classified, so the caller decides whether an uncertain
|
|
5557
|
+
// outcome is re-sent unchanged. Decision text travels only in the request body;
|
|
5558
|
+
// it is never placed in an error, a diagnostic, or a URL.
|
|
5559
|
+
/** The closed settle outcomes, mirroring `DRIVER_COUNCIL_OUTCOMES` on the server. */
|
|
5560
|
+
export const DRIVER_COUNCIL_OUTCOMES = ["continue", "stop", "split", "no_valid_response"];
|
|
5561
|
+
/** Server-side limit on decision text; longer text is refused, never truncated. */
|
|
5562
|
+
export const DRIVER_DECISION_TEXT_MAX_CHARS = 2000;
|
|
5563
|
+
/** The Jira comment marker prefix; the full marker is followed by the council row id. */
|
|
5564
|
+
export const DRIVER_DECISION_COMMENT_MARKER_PREFIX = "bridge-driver-decision:";
|
|
5565
|
+
/**
|
|
5566
|
+
* The closed refusal codes of the two routes, mirroring
|
|
5567
|
+
* `DRIVER_COUNCIL_REFUSAL_CODES` in `api/models/epic_run_driver_council.py`.
|
|
5568
|
+
* `DRIVER_COUNCIL_UNAVAILABLE` is deliberately absent: it means the store could
|
|
5569
|
+
* not be read or written, so the outcome is unknown, not refused.
|
|
5570
|
+
*/
|
|
5571
|
+
export const DRIVER_COUNCIL_REFUSAL_CODES = [
|
|
5572
|
+
"DECISION_ALLOWANCE_REACHED",
|
|
5573
|
+
"DRIVER_COUNCIL_RESERVATION_CONFLICT",
|
|
5574
|
+
"DRIVER_COUNCIL_CHILD_NOT_FOUND",
|
|
5575
|
+
"DRIVER_COUNCIL_NOT_FOUND",
|
|
5576
|
+
"DRIVER_COUNCIL_SETTLEMENT_CONFLICT",
|
|
5577
|
+
"DRIVER_COUNCIL_PARK_EPISODE_CHANGED",
|
|
5578
|
+
"COUNCIL_ID_INVALID",
|
|
5579
|
+
"COUNCIL_ID_NOT_FOUND",
|
|
5580
|
+
"COUNCIL_ID_MISMATCH",
|
|
5581
|
+
"COUNCIL_NOT_TERMINAL",
|
|
5582
|
+
"COUNCIL_BEFORE_RESERVATION",
|
|
5583
|
+
"NO_RESPONDING_PROVIDER",
|
|
5584
|
+
"DECISION_TEXT_MISSING",
|
|
5585
|
+
"DECISION_TEXT_TOO_LONG",
|
|
5586
|
+
"DECISION_TEXT_REDACTED",
|
|
5587
|
+
"DECISION_TEXT_NOT_ALLOWED",
|
|
5588
|
+
"DRIVER_DECISION_DUPLICATE",
|
|
5589
|
+
"SPEC_SNAPSHOT_UNAVAILABLE",
|
|
5590
|
+
"DRIVER_COUNCIL_RUN_NOT_ACTIVE",
|
|
5591
|
+
"DRIVER_COUNCIL_NOT_ELIGIBLE",
|
|
5592
|
+
"DRIVER_COUNCIL_VALIDATION",
|
|
5593
|
+
];
|
|
5594
|
+
/** True when `code` is one of the closed driver-council refusal codes. */
|
|
5595
|
+
export function isDriverCouncilRefusalCode(code) {
|
|
5596
|
+
return DRIVER_COUNCIL_REFUSAL_CODES.includes(code);
|
|
5597
|
+
}
|
|
5598
|
+
/** The stable reservation key for one park episode of one child. */
|
|
5599
|
+
export function driverCouncilReservationKey(epicRunId, ticketKey, parkGeneration) {
|
|
5600
|
+
requireNonEmptyString(epicRunId);
|
|
5601
|
+
requireNonEmptyString(ticketKey);
|
|
5602
|
+
requireNonNegativeSafeInteger(parkGeneration);
|
|
5603
|
+
return `${epicRunId}:${ticketKey}:park-${parkGeneration}`;
|
|
5604
|
+
}
|
|
5605
|
+
/** Read a safe closed code from `{"detail": {"error_code": ...}}` (`code` also accepted). */
|
|
5606
|
+
function driverCouncilDetailCode(body) {
|
|
5607
|
+
if (!isPlainRecord(body))
|
|
5608
|
+
return null;
|
|
5609
|
+
const detail = body.detail;
|
|
5610
|
+
if (!isPlainRecord(detail))
|
|
5611
|
+
return null;
|
|
5612
|
+
const code = typeof detail.error_code === "string" ? detail.error_code : detail.code;
|
|
5613
|
+
return typeof code === "string" && SAFE_ERROR_CODE_RE.test(code) ? code : null;
|
|
5614
|
+
}
|
|
5615
|
+
function isDriverCouncilOutcome(value) {
|
|
5616
|
+
return typeof value === "string" && DRIVER_COUNCIL_OUTCOMES.includes(value);
|
|
5617
|
+
}
|
|
5618
|
+
function parseDriverCouncilRow(value) {
|
|
5619
|
+
if (!isPlainRecord(value))
|
|
5620
|
+
throw new ConductorBridgeApiError("server");
|
|
5621
|
+
const v = value;
|
|
5622
|
+
if (!isNonNegativeInt(v.council_row_id) || v.council_row_id === 0 ||
|
|
5623
|
+
typeof v.reserved_at !== "string" || !v.reserved_at ||
|
|
5624
|
+
typeof v.reservation_key !== "string" || !v.reservation_key ||
|
|
5625
|
+
typeof v.epic_run_id !== "string" || !v.epic_run_id ||
|
|
5626
|
+
typeof v.ticket_key !== "string" || !v.ticket_key ||
|
|
5627
|
+
!(v.outcome === null || v.outcome === undefined || isDriverCouncilOutcome(v.outcome)) ||
|
|
5628
|
+
!Array.isArray(v.council_ids) || !v.council_ids.every((id) => typeof id === "string") ||
|
|
5629
|
+
!nullableNonNegativeInt(v.providers_responding) ||
|
|
5630
|
+
typeof v.parked_gate !== "string" ||
|
|
5631
|
+
!isNonNegativeInt(v.park_generation) ||
|
|
5632
|
+
!nullableString(v.settled_at)) {
|
|
5633
|
+
throw new ConductorBridgeApiError("server");
|
|
5634
|
+
}
|
|
5635
|
+
return {
|
|
5636
|
+
council_row_id: v.council_row_id,
|
|
5637
|
+
reserved_at: v.reserved_at,
|
|
5638
|
+
reservation_key: v.reservation_key,
|
|
5639
|
+
epic_run_id: v.epic_run_id,
|
|
5640
|
+
ticket_key: v.ticket_key,
|
|
5641
|
+
outcome: (v.outcome ?? null),
|
|
5642
|
+
council_ids: [...v.council_ids],
|
|
5643
|
+
providers_responding: (v.providers_responding ?? null),
|
|
5644
|
+
parked_gate: v.parked_gate,
|
|
5645
|
+
park_generation: v.park_generation,
|
|
5646
|
+
settled_at: (v.settled_at ?? null),
|
|
5647
|
+
};
|
|
5648
|
+
}
|
|
5649
|
+
/** Strictly parse a reserve answer; anything short of the contract throws. */
|
|
5650
|
+
export function parseReserveDriverCouncilResult(value) {
|
|
5651
|
+
const row = parseDriverCouncilRow(value);
|
|
5652
|
+
const outcomeKind = value.outcome_kind;
|
|
5653
|
+
if (outcomeKind !== "recorded" && outcomeKind !== "existing")
|
|
5654
|
+
throw new ConductorBridgeApiError("server");
|
|
5655
|
+
return { ...row, outcome_kind: outcomeKind };
|
|
5656
|
+
}
|
|
5657
|
+
/** Strictly parse a settle answer; anything short of the contract throws. */
|
|
5658
|
+
export function parseRecordDriverDecisionResult(value) {
|
|
5659
|
+
const row = parseDriverCouncilRow(value);
|
|
5660
|
+
const v = value;
|
|
5661
|
+
if (row.outcome === null ||
|
|
5662
|
+
typeof v.replayed !== "boolean" ||
|
|
5663
|
+
v.committed !== true ||
|
|
5664
|
+
!(v.fyi_recorded === null || v.fyi_recorded === undefined || typeof v.fyi_recorded === "boolean")) {
|
|
5665
|
+
throw new ConductorBridgeApiError("server");
|
|
5666
|
+
}
|
|
5667
|
+
return {
|
|
5668
|
+
...row,
|
|
5669
|
+
replayed: v.replayed,
|
|
5670
|
+
committed: true,
|
|
5671
|
+
fyi_recorded: (v.fyi_recorded ?? null),
|
|
5672
|
+
};
|
|
5673
|
+
}
|
|
5674
|
+
/**
|
|
5675
|
+
* The de-duplicated council id list, in first-seen order. Ids are trimmed and
|
|
5676
|
+
* lower-cased (they are UUIDs); every distinct id is kept.
|
|
5677
|
+
*/
|
|
5678
|
+
export function normalizeDriverCouncilIds(ids) {
|
|
5679
|
+
const seen = new Set();
|
|
5680
|
+
const out = [];
|
|
5681
|
+
for (const raw of ids) {
|
|
5682
|
+
requireNonEmptyString(raw);
|
|
5683
|
+
const id = raw.trim().toLowerCase();
|
|
5684
|
+
if (!seen.has(id)) {
|
|
5685
|
+
seen.add(id);
|
|
5686
|
+
out.push(id);
|
|
5687
|
+
}
|
|
5688
|
+
}
|
|
5689
|
+
if (out.length === 0)
|
|
5690
|
+
throw new ConductorBridgeApiError("invalid-input");
|
|
5691
|
+
return out;
|
|
5692
|
+
}
|
|
5693
|
+
async function sendDriverCouncilRequest(method, url, access, body, parse, fetchImpl, timeoutMs) {
|
|
5694
|
+
const controller = new AbortController();
|
|
5695
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
5696
|
+
try {
|
|
5697
|
+
let resp;
|
|
5698
|
+
try {
|
|
5699
|
+
resp = await fetchImpl(url, {
|
|
5700
|
+
method,
|
|
5701
|
+
headers: conductorPostHeaders(access),
|
|
5702
|
+
body,
|
|
5703
|
+
signal: controller.signal,
|
|
5704
|
+
});
|
|
5705
|
+
}
|
|
5706
|
+
catch {
|
|
5707
|
+
return { kind: "uncertain", reason: controller.signal.aborted ? "timeout" : "network" };
|
|
5708
|
+
}
|
|
5709
|
+
let parsed;
|
|
5710
|
+
let parsedOk = true;
|
|
5711
|
+
try {
|
|
5712
|
+
parsed = await resp.json();
|
|
5713
|
+
}
|
|
5714
|
+
catch {
|
|
5715
|
+
parsedOk = false;
|
|
5716
|
+
}
|
|
5717
|
+
if (resp.status >= 200 && resp.status < 300) {
|
|
5718
|
+
if (!parsedOk)
|
|
5719
|
+
return { kind: "uncertain", reason: "malformed", status: resp.status };
|
|
5720
|
+
try {
|
|
5721
|
+
return { kind: "result", result: parse(parsed) };
|
|
5722
|
+
}
|
|
5723
|
+
catch {
|
|
5724
|
+
return { kind: "uncertain", reason: "malformed", status: resp.status };
|
|
5725
|
+
}
|
|
5726
|
+
}
|
|
5727
|
+
const errorCode = parsedOk ? driverCouncilDetailCode(parsed) : null;
|
|
5728
|
+
if (errorCode !== null && isDriverCouncilRefusalCode(errorCode)) {
|
|
5729
|
+
return { kind: "refused", status: resp.status, errorCode };
|
|
5730
|
+
}
|
|
5731
|
+
if (errorCode === null && (resp.status === 404 || resp.status === 405)) {
|
|
5732
|
+
return { kind: "unsupported_server", status: resp.status };
|
|
5733
|
+
}
|
|
5734
|
+
if (resp.status >= 500) {
|
|
5735
|
+
return { kind: "uncertain", reason: "server", status: resp.status };
|
|
5736
|
+
}
|
|
5737
|
+
return { kind: "rejected", status: resp.status, errorCode };
|
|
5738
|
+
}
|
|
5739
|
+
finally {
|
|
5740
|
+
clearTimeout(timer);
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
/**
|
|
5744
|
+
* POST `/jira/epic-runs/runs/{epic_run_id}/tickets/{ticket_key}/driver-councils`.
|
|
5745
|
+
*
|
|
5746
|
+
* Reserves one logical council under `reservationKey`. A repeated key returns the
|
|
5747
|
+
* stored row (`outcome_kind: "existing"`), even after the per-run allowance is spent; a new
|
|
5748
|
+
* key past the allowance is refused with `DECISION_ALLOWANCE_REACHED`.
|
|
5749
|
+
*/
|
|
5750
|
+
export async function reserveDriverCouncil(access, request, fetchImpl = globalThis.fetch, timeoutMs = CONDUCTOR_FETCH_TIMEOUT_MS) {
|
|
5751
|
+
requireNonEmptyString(request.epicRunId);
|
|
5752
|
+
requireNonEmptyString(request.ticketKey);
|
|
5753
|
+
requireNonEmptyString(request.reservationKey);
|
|
5754
|
+
const url = buildConductorJiraUrl(access.baseUrl, `${continuationChildPath(request.epicRunId, request.ticketKey)}/driver-councils`);
|
|
5755
|
+
const body = JSON.stringify({ repo_name: access.repoName, reservation_key: request.reservationKey });
|
|
5756
|
+
return sendDriverCouncilRequest("POST", url, access, body, parseReserveDriverCouncilResult, fetchImpl, timeoutMs);
|
|
5757
|
+
}
|
|
5758
|
+
/**
|
|
5759
|
+
* PUT `/jira/epic-runs/runs/{epic_run_id}/tickets/{ticket_key}/driver-councils/{council_row_id}`.
|
|
5760
|
+
*
|
|
5761
|
+
* Settles one reserved council with every council request id it used (first
|
|
5762
|
+
* request and any provider retry). `decision_text` is sent only for `continue`
|
|
5763
|
+
* and is `null` otherwise; the client refuses a request that breaks that rule
|
|
5764
|
+
* before any network call. The text is never placed in an error.
|
|
5765
|
+
*/
|
|
5766
|
+
export async function recordDriverDecision(access, request, fetchImpl = globalThis.fetch, timeoutMs = CONDUCTOR_FETCH_TIMEOUT_MS) {
|
|
5767
|
+
requireNonEmptyString(request.epicRunId);
|
|
5768
|
+
requireNonEmptyString(request.ticketKey);
|
|
5769
|
+
requirePositiveSafeInteger(request.councilRowId);
|
|
5770
|
+
if (!isDriverCouncilOutcome(request.outcome))
|
|
5771
|
+
throw new ConductorBridgeApiError("invalid-input");
|
|
5772
|
+
const councilIds = normalizeDriverCouncilIds(request.councilIds);
|
|
5773
|
+
if (request.outcome === "continue") {
|
|
5774
|
+
if (typeof request.decisionText !== "string" || request.decisionText.trim().length === 0) {
|
|
5775
|
+
throw new ConductorBridgeApiError("invalid-input");
|
|
5776
|
+
}
|
|
5777
|
+
}
|
|
5778
|
+
else if (request.decisionText !== null) {
|
|
5779
|
+
throw new ConductorBridgeApiError("invalid-input");
|
|
5780
|
+
}
|
|
5781
|
+
const url = buildConductorJiraUrl(access.baseUrl, `${continuationChildPath(request.epicRunId, request.ticketKey)}/driver-councils/${request.councilRowId}`);
|
|
5782
|
+
const body = JSON.stringify({
|
|
5783
|
+
repo_name: access.repoName,
|
|
5784
|
+
council_ids: councilIds,
|
|
5785
|
+
outcome: request.outcome,
|
|
5786
|
+
decision_text: request.outcome === "continue" ? request.decisionText : null,
|
|
5787
|
+
});
|
|
5788
|
+
return sendDriverCouncilRequest("PUT", url, access, body, parseRecordDriverDecisionResult, fetchImpl, timeoutMs);
|
|
5789
|
+
}
|
|
5790
|
+
// ---------------------------------------------------------------------------
|
|
5198
5791
|
// BAPI-1391 — gate profile, provider history, capability probe, qualification
|
|
5199
5792
|
// ---------------------------------------------------------------------------
|
|
5200
5793
|
//
|
|
@@ -5975,6 +6568,8 @@ export const LEARNED_TEST_COMMAND_NO_COMMAND_REASONS = [
|
|
|
5975
6568
|
"not_plain_argv",
|
|
5976
6569
|
"command_not_allowed",
|
|
5977
6570
|
"invalid_command",
|
|
6571
|
+
// BAPI-1699 — the approved saved generation is no longer the current one.
|
|
6572
|
+
"generation_superseded",
|
|
5978
6573
|
];
|
|
5979
6574
|
const LEARNED_COMMAND_DISPLAY_MAX = 4096;
|
|
5980
6575
|
const LEARNED_COMMAND_MAX_DISPLAYED = 16;
|
|
@@ -6048,6 +6643,8 @@ export async function requestConductorLearnedTestCommand(access, request, fetchI
|
|
|
6048
6643
|
payload.candidates = candidates;
|
|
6049
6644
|
if (request.ownerCommand !== undefined)
|
|
6050
6645
|
payload.owner_command = request.ownerCommand;
|
|
6646
|
+
if (request.expectedGeneration !== undefined)
|
|
6647
|
+
payload.expected_generation = request.expectedGeneration;
|
|
6051
6648
|
let body;
|
|
6052
6649
|
try {
|
|
6053
6650
|
body = await fetchConductorJsonWithMethodAndTimeout("POST", buildConductorJiraUrl(access.baseUrl, `${EPIC_RUNS_API_PREFIX}/supervisor-setup/learned-test-command/`, { repo_name: access.repoName }), conductorPostHeaders(access), JSON.stringify(payload), CONDUCTOR_LEARNED_TEST_COMMAND_TIMEOUT_MS, fetchImpl);
|
|
@@ -6076,6 +6673,109 @@ export async function requestConductorLearnedTestCommand(access, request, fetchI
|
|
|
6076
6673
|
return { kind: "malformed" };
|
|
6077
6674
|
}
|
|
6078
6675
|
}
|
|
6676
|
+
// ---------------------------------------------------------------------------
|
|
6677
|
+
// BAPI-1699 — saved Epic Implementer test commands (`config_field`)
|
|
6678
|
+
// ---------------------------------------------------------------------------
|
|
6679
|
+
/** The config field that holds the pending test-command selection. */
|
|
6680
|
+
export const SAVED_TEST_COMMANDS_FIELD = "epic_implementer_test_commands";
|
|
6681
|
+
/** The four derived trial states of a saved selection. */
|
|
6682
|
+
export const SAVED_TEST_COMMANDS_TRIAL_STATES = ["passed", "queued", "failed", "not_tried"];
|
|
6683
|
+
const SAVED_COMMANDS_MAX = 4;
|
|
6684
|
+
function parseSavedTestCommandsRecord(value) {
|
|
6685
|
+
const o = requireObject(value);
|
|
6686
|
+
const commands = o.commands;
|
|
6687
|
+
if (!Array.isArray(commands) || commands.length === 0 || commands.length > SAVED_COMMANDS_MAX) {
|
|
6688
|
+
throw readinessShapeError();
|
|
6689
|
+
}
|
|
6690
|
+
const checked = commands.map((command) => {
|
|
6691
|
+
if (typeof command !== "string" || command.length === 0 || command.length > 4096) {
|
|
6692
|
+
throw readinessShapeError();
|
|
6693
|
+
}
|
|
6694
|
+
return command;
|
|
6695
|
+
});
|
|
6696
|
+
if (o.source !== "config_field" && o.source !== "owner_command")
|
|
6697
|
+
throw readinessShapeError();
|
|
6698
|
+
if (o.set_by !== null && typeof o.set_by !== "string")
|
|
6699
|
+
throw readinessShapeError();
|
|
6700
|
+
if (typeof o.set_at !== "string" || o.set_at.length === 0)
|
|
6701
|
+
throw readinessShapeError();
|
|
6702
|
+
const generation = requireInt(o, "generation");
|
|
6703
|
+
if (generation < 1)
|
|
6704
|
+
throw readinessShapeError();
|
|
6705
|
+
return { commands: checked, source: o.source, set_by: o.set_by, set_at: o.set_at, generation };
|
|
6706
|
+
}
|
|
6707
|
+
function parseSavedTestCommandsEnvelope(body) {
|
|
6708
|
+
const o = requireObject(body);
|
|
6709
|
+
if (o.field_name !== SAVED_TEST_COMMANDS_FIELD)
|
|
6710
|
+
throw readinessShapeError();
|
|
6711
|
+
if (o.value === null)
|
|
6712
|
+
return null;
|
|
6713
|
+
const record = parseSavedTestCommandsRecord(o.value);
|
|
6714
|
+
const trial = o.trial_state;
|
|
6715
|
+
if (trial !== null && trial !== undefined && !SAVED_TEST_COMMANDS_TRIAL_STATES.includes(trial)) {
|
|
6716
|
+
throw readinessShapeError();
|
|
6717
|
+
}
|
|
6718
|
+
const inForce = o.commands_in_force;
|
|
6719
|
+
if (inForce !== null && inForce !== undefined) {
|
|
6720
|
+
if (!Array.isArray(inForce) || inForce.length > 16 || inForce.some((c) => typeof c !== "string")) {
|
|
6721
|
+
throw readinessShapeError();
|
|
6722
|
+
}
|
|
6723
|
+
}
|
|
6724
|
+
return {
|
|
6725
|
+
record,
|
|
6726
|
+
trialState: (trial ?? null),
|
|
6727
|
+
commandsInForce: (inForce ?? null),
|
|
6728
|
+
};
|
|
6729
|
+
}
|
|
6730
|
+
/** GET the saved record once. NEVER throws. */
|
|
6731
|
+
export async function readConductorSavedTestCommands(access, fetchImpl = globalThis.fetch) {
|
|
6732
|
+
let body;
|
|
6733
|
+
try {
|
|
6734
|
+
body = await fetchConductorJsonWithTimeout(buildConductorJiraUrl(access.baseUrl, `/config-field/${encodeURIComponent(SAVED_TEST_COMMANDS_FIELD)}`, {
|
|
6735
|
+
repo_name: access.repoName,
|
|
6736
|
+
}), conductorGetHeaders(access), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
6737
|
+
}
|
|
6738
|
+
catch (err) {
|
|
6739
|
+
if (err instanceof ConductorBridgeApiError && (err.status === 400 || err.status === 404 || err.status === 405)) {
|
|
6740
|
+
return { kind: "unsupported" };
|
|
6741
|
+
}
|
|
6742
|
+
return { kind: "unreadable" };
|
|
6743
|
+
}
|
|
6744
|
+
try {
|
|
6745
|
+
const state = parseSavedTestCommandsEnvelope(body);
|
|
6746
|
+
return state === null ? { kind: "none" } : { kind: "saved", ...state };
|
|
6747
|
+
}
|
|
6748
|
+
catch {
|
|
6749
|
+
return { kind: "unreadable" };
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
/** PUT the whole command list (the server replaces it). NEVER throws. */
|
|
6753
|
+
export async function saveConductorSavedTestCommands(access, commands, fetchImpl) {
|
|
6754
|
+
let body;
|
|
6755
|
+
try {
|
|
6756
|
+
body = await fetchConductorJsonWithMethodAndTimeout("PUT", buildConductorJiraUrl(access.baseUrl, `/config-field/${encodeURIComponent(SAVED_TEST_COMMANDS_FIELD)}`), conductorPostHeaders(access), JSON.stringify({ repo_name: access.repoName, value: [...commands] }), CONDUCTOR_FETCH_TIMEOUT_MS, fetchImpl);
|
|
6757
|
+
}
|
|
6758
|
+
catch (err) {
|
|
6759
|
+
if (!(err instanceof ConductorBridgeApiError))
|
|
6760
|
+
return { kind: "uncertain" };
|
|
6761
|
+
if (err.kind === "unauthorized")
|
|
6762
|
+
return { kind: "refused", reason: "unauthorized" };
|
|
6763
|
+
if (err.unreadableSuccess === true)
|
|
6764
|
+
return { kind: "uncertain" };
|
|
6765
|
+
if (err.kind === "timeout" || err.kind === "network" || err.kind === "server")
|
|
6766
|
+
return { kind: "uncertain" };
|
|
6767
|
+
if (err.status === 400 || err.status === 404 || err.status === 405)
|
|
6768
|
+
return { kind: "unsupported" };
|
|
6769
|
+
return { kind: "refused", reason: "rejected" };
|
|
6770
|
+
}
|
|
6771
|
+
try {
|
|
6772
|
+
const state = parseSavedTestCommandsEnvelope(body);
|
|
6773
|
+
return state === null ? { kind: "uncertain" } : { kind: "saved", ...state };
|
|
6774
|
+
}
|
|
6775
|
+
catch {
|
|
6776
|
+
return { kind: "uncertain" };
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6079
6779
|
const QUALIFICATION_REFUSAL_CODES = Object.freeze({
|
|
6080
6780
|
PROFILE_NOT_CONFIRMED: "profile-not-confirmed",
|
|
6081
6781
|
NO_LOCAL_COMMANDS: "no-local-commands",
|
|
@@ -6129,10 +6829,64 @@ export async function enqueueConductorGateQualification(access, request, fetchIm
|
|
|
6129
6829
|
*/
|
|
6130
6830
|
export const CONDUCTOR_GATE_QUALIFICATION_PHASES = [
|
|
6131
6831
|
"dependency_preparation_failed",
|
|
6832
|
+
// BAPI-1698
|
|
6833
|
+
"worker_database_preparation_failed",
|
|
6132
6834
|
"could_not_start",
|
|
6133
6835
|
"ran_and_failed",
|
|
6836
|
+
// BAPI-1698
|
|
6837
|
+
"no_tests_ran",
|
|
6134
6838
|
"passed",
|
|
6135
6839
|
];
|
|
6840
|
+
/** BAPI-1698 — the closed per-command outcomes a qualification status read may project. */
|
|
6841
|
+
export const CONDUCTOR_GATE_QUALIFICATION_COMMAND_OUTCOMES = [
|
|
6842
|
+
"exited_zero",
|
|
6843
|
+
"exited_nonzero",
|
|
6844
|
+
"timed_out",
|
|
6845
|
+
"launch_error",
|
|
6846
|
+
"cancelled",
|
|
6847
|
+
"not_run",
|
|
6848
|
+
"no_tests_ran",
|
|
6849
|
+
];
|
|
6850
|
+
/** BAPI-1698 — the closed shared reasons a projected command fact may carry. */
|
|
6851
|
+
export const CONDUCTOR_GATE_QUALIFICATION_COMMAND_REASONS = [
|
|
6852
|
+
"declared_timeout",
|
|
6853
|
+
"reservation_exhausted",
|
|
6854
|
+
"stopped_after_interruption",
|
|
6855
|
+
"ownership_lost",
|
|
6856
|
+
"executor_cancelled",
|
|
6857
|
+
"spawn_failed",
|
|
6858
|
+
"killed_by_signal",
|
|
6859
|
+
];
|
|
6860
|
+
/** The same 16-command bound the server holds a qualification to. */
|
|
6861
|
+
const GATE_QUALIFICATION_MAX_COMMAND_RESULTS = 16;
|
|
6862
|
+
/**
|
|
6863
|
+
* BAPI-1698 — the projected command results, or `null` when absent (an older
|
|
6864
|
+
* server), malformed, or carrying any unknown token. Whole-list strict: one bad
|
|
6865
|
+
* entry makes attribution unavailable rather than partial. Never throws.
|
|
6866
|
+
*/
|
|
6867
|
+
export function parseGateQualificationCommandResults(raw) {
|
|
6868
|
+
if (!Array.isArray(raw) || raw.length === 0 || raw.length > GATE_QUALIFICATION_MAX_COMMAND_RESULTS)
|
|
6869
|
+
return null;
|
|
6870
|
+
const out = [];
|
|
6871
|
+
for (const item of raw) {
|
|
6872
|
+
if (typeof item !== "object" || item === null || Array.isArray(item))
|
|
6873
|
+
return null;
|
|
6874
|
+
const entry = item;
|
|
6875
|
+
if (Object.keys(entry).some((key) => key !== "outcome" && key !== "reason"))
|
|
6876
|
+
return null;
|
|
6877
|
+
if (!CONDUCTOR_GATE_QUALIFICATION_COMMAND_OUTCOMES.includes(entry.outcome))
|
|
6878
|
+
return null;
|
|
6879
|
+
const reason = entry.reason ?? null;
|
|
6880
|
+
if (reason !== null && !CONDUCTOR_GATE_QUALIFICATION_COMMAND_REASONS.includes(reason)) {
|
|
6881
|
+
return null;
|
|
6882
|
+
}
|
|
6883
|
+
out.push({
|
|
6884
|
+
outcome: entry.outcome,
|
|
6885
|
+
reason: reason,
|
|
6886
|
+
});
|
|
6887
|
+
}
|
|
6888
|
+
return out;
|
|
6889
|
+
}
|
|
6136
6890
|
export function parseConductorGateQualificationJob(body, expectedRepoName, expectedJobId) {
|
|
6137
6891
|
const o = requireObject(body);
|
|
6138
6892
|
if (o.repo_name !== expectedRepoName || o.job_id !== expectedJobId)
|
|
@@ -6156,6 +6910,7 @@ export function parseConductorGateQualificationJob(body, expectedRepoName, expec
|
|
|
6156
6910
|
? o.phase
|
|
6157
6911
|
: null,
|
|
6158
6912
|
dependency_install_declared: typeof o.dependency_install_declared === "boolean" ? o.dependency_install_declared : null,
|
|
6913
|
+
command_results: parseGateQualificationCommandResults(o.command_results),
|
|
6159
6914
|
};
|
|
6160
6915
|
}
|
|
6161
6916
|
/** GET one qualification job's verified state. Throws a sanitized error on failure. */
|