@bridge_gpt/mcp-server 0.2.72 → 0.2.73
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 +3 -0
- package/build/agents.generated.js +6 -6
- package/build/bridge-permissions.js +27 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +3 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +842 -35
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +106 -21
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +222 -29
- package/build/conductor/epic-implementer-cli.js +166 -15
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +150 -5
- package/build/conductor/gate-settings-review.js +224 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +313 -156
- package/build/conductor/prerequisite-inputs.js +879 -45
- package/build/conductor/readiness-assessment.js +16 -1
- package/build/conductor/readiness-cli.js +20 -9
- package/build/conductor/readiness-prerequisites.js +28 -9
- package/build/conductor/readiness-sections.js +133 -126
- package/build/conductor/readiness.js +1 -1
- package/build/conductor/recovery-cli.js +13 -2
- package/build/conductor/tools.js +6 -5
- package/build/conductor/wait-run-attention.js +2 -2
- package/build/conductor/wait-run-cli.js +208 -22
- package/build/conductor/worker-database-doctor-inspector.js +33 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +71 -1
- package/build/dependency-install-declarations.js +55 -0
- package/build/docs.generated.js +2 -2
- package/build/doctor.js +54 -3
- package/build/drive-epic-help.js +21 -2
- package/build/drive-epic.js +1811 -351
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2101 -44
- package/build/epic-launch-context.js +607 -0
- package/build/epic-server-record.js +273 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/completion-contract.js +8 -1
- package/build/executor/env.js +59 -22
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/http-client.js +52 -5
- package/build/executor/job-runner.js +423 -69
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +114 -2
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-work-diagnostics.js +4 -2
- package/build/executor/required-work-ledger.js +936 -38
- package/build/executor/results.js +58 -0
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/worker-command.js +72 -3
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +320 -101
- package/build/executor/worker-finalization.js +7 -1
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +18 -3
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/index.js +664 -335
- package/build/init.js +26 -11
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1197 -196
- package/build/install-bridge-conductor-setup.js +535 -79
- package/build/install-bridge-conductor.js +2885 -560
- package/build/install-bridge.js +199 -21
- package/build/install-maintenance.js +26 -3
- package/build/launcher-config-inspection.js +162 -1
- package/build/mcp-grant-candidates.js +767 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +234 -109
- package/build/pipelines.generated.js +5 -5
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +100 -7
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +17 -0
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +18 -4
- package/build/printed-remedy-commands.js +206 -12
- package/build/readiness-check.js +77 -0
- package/build/readiness-prerequisites.generated.js +122 -14
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-epic.js +1190 -196
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +122 -4
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +9 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/epic-implementer/getting-started.md +3 -1
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -57,6 +57,7 @@ import { describeCheckEvidence } from "../check-evidence.js";
|
|
|
57
57
|
import fs from "node:fs/promises";
|
|
58
58
|
import path from "node:path";
|
|
59
59
|
import { LEGACY_EPIC_IMPLEMENTER_NODE_PATH_ENV } from "../epic-implementer-env.js";
|
|
60
|
+
import { MAX_MUST_ORDER_PATHS, canonicalMustOrderPaths, isValidMustOrderPath, } from "../dependency-install-declarations.js";
|
|
60
61
|
import { TOOLCHAIN_CONTENT_FILES, installArgvForJavaScript, installArgvForPython, resolveRepositoryToolchains, } from "../repository-toolchains.js";
|
|
61
62
|
// ---------------------------------------------------------------------------
|
|
62
63
|
// Bounds and fixed vocabularies
|
|
@@ -163,6 +164,32 @@ const GIT_CLIENT_HOOK_NAMES = [
|
|
|
163
164
|
"pre-rebase",
|
|
164
165
|
"prepare-commit-msg",
|
|
165
166
|
];
|
|
167
|
+
/**
|
|
168
|
+
* BAPI-1580 — the fixed migration directories probed for must-order proposals.
|
|
169
|
+
* Each one top-level directory's `migrations/` (a Django app) is probed too.
|
|
170
|
+
* BAPI-1605 adds the Prisma, Flyway, Entity Framework, and Liquibase layouts.
|
|
171
|
+
* Each is one explicit path: no glob and no recursive walk.
|
|
172
|
+
*/
|
|
173
|
+
export const MUST_ORDER_FIXED_DIRECTORIES = [
|
|
174
|
+
"alembic/versions/",
|
|
175
|
+
"db/alembic/versions/",
|
|
176
|
+
"migrations/versions/",
|
|
177
|
+
"db/migrate/",
|
|
178
|
+
"prisma/migrations/",
|
|
179
|
+
"db/migration/",
|
|
180
|
+
"src/main/resources/db/migration/",
|
|
181
|
+
"Migrations/",
|
|
182
|
+
"db/changelog/",
|
|
183
|
+
];
|
|
184
|
+
/**
|
|
185
|
+
* BAPI-1605 — fixed entries whose spelling differs from another layout only by
|
|
186
|
+
* case. A case-insensitive filesystem answers a listing of `Migrations` for a
|
|
187
|
+
* lowercase `migrations` directory, so such an entry is proposed only when the
|
|
188
|
+
* single root listing holds this exact name.
|
|
189
|
+
*/
|
|
190
|
+
const MUST_ORDER_ROOT_NAME_CHECKED = ["Migrations/"];
|
|
191
|
+
/** BAPI-1580 — top-level directories never probed for `<dir>/migrations/` (dot-directories are skipped too). */
|
|
192
|
+
export const MUST_ORDER_EXCLUDED_TOP_LEVEL = ["node_modules", "vendor", ".venv"];
|
|
166
193
|
// ---------------------------------------------------------------------------
|
|
167
194
|
// Node filesystem seam
|
|
168
195
|
// ---------------------------------------------------------------------------
|
|
@@ -957,6 +984,17 @@ export function deriveProposalKind(providerChecks, localCommandIds) {
|
|
|
957
984
|
return "local";
|
|
958
985
|
return "none";
|
|
959
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* BAPI-1603 — the provider check names the repository's CI has actually reported,
|
|
989
|
+
* in the proposal's own order. A name counts only when it is in
|
|
990
|
+
* `proposal.proposed.providerChecks` AND its candidate's outcome is `reported`; an
|
|
991
|
+
* unseen, unavailable, or unknown name is never returned, so unknown history can
|
|
992
|
+
* never be mistaken for a reported check. The proposal is not modified.
|
|
993
|
+
*/
|
|
994
|
+
export function reportedProviderChecks(proposal) {
|
|
995
|
+
const reported = new Set(proposal.providerCandidates.filter((c) => c.outcome === "reported").map((c) => c.name));
|
|
996
|
+
return proposal.proposed.providerChecks.filter((name) => reported.has(name));
|
|
997
|
+
}
|
|
960
998
|
const PROVIDER_OUTCOMES = new Set(["reported", "unseen", "evidence_unavailable"]);
|
|
961
999
|
/**
|
|
962
1000
|
* Classify a lookup response into a history state. A successful answer with no
|
|
@@ -1085,6 +1123,107 @@ function toolchainReader(fsSeam) {
|
|
|
1085
1123
|
throw Object.assign(new Error("unreadable"), { code: "EIO" });
|
|
1086
1124
|
};
|
|
1087
1125
|
}
|
|
1126
|
+
/**
|
|
1127
|
+
* BAPI-1580 — the must-order proposals: the fixed migration directories, plus
|
|
1128
|
+
* `<top-level>/migrations/` for each entry of ONE root listing. `Migrations/`
|
|
1129
|
+
* (BAPI-1605) is proposed only when that listing holds the exact name. No recursive
|
|
1130
|
+
* walk. Dot-directories and {@link MUST_ORDER_EXCLUDED_TOP_LEVEL} are skipped.
|
|
1131
|
+
* A directory counts only when the seam lists it, so a path that is absent, not
|
|
1132
|
+
* a directory, or resolves outside the repository is never proposed. Past the
|
|
1133
|
+
* cap, the first {@link MAX_MUST_ORDER_PATHS} (sorted) are kept and the rest
|
|
1134
|
+
* are counted, never silently dropped.
|
|
1135
|
+
*/
|
|
1136
|
+
export async function proposeMustOrderPaths(fsSeam) {
|
|
1137
|
+
// ONE root listing serves both the exact-name check and the `<dir>/migrations/` probes.
|
|
1138
|
+
const rootNames = (await fsSeam.listDir("")) ?? [];
|
|
1139
|
+
const probes = MUST_ORDER_FIXED_DIRECTORIES.filter((dir) => !MUST_ORDER_ROOT_NAME_CHECKED.includes(dir) || rootNames.includes(dir.slice(0, -1)));
|
|
1140
|
+
for (const name of rootNames) {
|
|
1141
|
+
if (name.startsWith(".") || MUST_ORDER_EXCLUDED_TOP_LEVEL.includes(name))
|
|
1142
|
+
continue;
|
|
1143
|
+
probes.push(`${name}/migrations/`);
|
|
1144
|
+
}
|
|
1145
|
+
const found = [];
|
|
1146
|
+
for (const probe of canonicalMustOrderPaths(probes)) {
|
|
1147
|
+
// A name the server would refuse is never probed or proposed.
|
|
1148
|
+
if (!isValidMustOrderPath(probe))
|
|
1149
|
+
continue;
|
|
1150
|
+
if ((await fsSeam.listDir(probe.slice(0, -1))) !== null)
|
|
1151
|
+
found.push(probe);
|
|
1152
|
+
}
|
|
1153
|
+
return { candidates: found.slice(0, MAX_MUST_ORDER_PATHS), overflow: Math.max(0, found.length - MAX_MUST_ORDER_PATHS) };
|
|
1154
|
+
}
|
|
1155
|
+
const COMPOSE_FILES = ["docker-compose.yml", "docker-compose.yaml", "compose.yml", "compose.yaml"];
|
|
1156
|
+
const WORKER_DATABASE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]{0,62}$/;
|
|
1157
|
+
const WORKER_DATABASE_RESERVED_PREFIXES = ["ANTHROPIC_", "BAPI_", "BRIDGE_", "CLAUDE_", "DYLD_", "GIT_CONFIG_"];
|
|
1158
|
+
const WORKER_DATABASE_SECRET_FRAGMENTS = ["TOKEN", "SECRET", "PASSWORD", "API_KEY"];
|
|
1159
|
+
const WORKER_DATABASE_MAX_ALIASES = 4;
|
|
1160
|
+
/** The default migration command timeout (seconds) proposed with an Alembic command. */
|
|
1161
|
+
const WORKER_DATABASE_PROPOSED_TIMEOUT_SECONDS = 120;
|
|
1162
|
+
function isProposableDatabaseUrlName(name) {
|
|
1163
|
+
if (!/^[A-Z][A-Z0-9_]{0,63}$/.test(name))
|
|
1164
|
+
return false;
|
|
1165
|
+
if (name !== "DATABASE_URL" && !name.endsWith("_URL"))
|
|
1166
|
+
return false;
|
|
1167
|
+
if (WORKER_DATABASE_RESERVED_PREFIXES.some((prefix) => name.startsWith(prefix)))
|
|
1168
|
+
return false;
|
|
1169
|
+
return !WORKER_DATABASE_SECRET_FRAGMENTS.some((fragment) => name.includes(fragment));
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* BAPI-1598 — propose a worker-database declaration from local repository
|
|
1173
|
+
* evidence. Alembic evidence is `alembic.ini`; the database evidence is ONE
|
|
1174
|
+
* Compose Postgres service with a literal database name and a literal, non-
|
|
1175
|
+
* superuser-looking role. A Prisma schema alone proposes nothing.
|
|
1176
|
+
*
|
|
1177
|
+
* Reads names only. No password, connection string, or other Compose value is
|
|
1178
|
+
* kept, and a Compose file holding a connection string with user information
|
|
1179
|
+
* proposes nothing at all. Any missing part (role, protected database, URL alias,
|
|
1180
|
+
* migration command, timeout) proposes nothing: a partial declaration is never
|
|
1181
|
+
* built.
|
|
1182
|
+
*/
|
|
1183
|
+
export async function proposeWorkerDatabase(fsSeam) {
|
|
1184
|
+
if (!(await fsSeam.exists("alembic.ini")))
|
|
1185
|
+
return undefined;
|
|
1186
|
+
for (const file of COMPOSE_FILES) {
|
|
1187
|
+
const text = await readBounded(fsSeam, file);
|
|
1188
|
+
if (text === null)
|
|
1189
|
+
continue;
|
|
1190
|
+
// A connection string with user information is a credential; do not guess around it.
|
|
1191
|
+
if (/[a-z][a-z0-9+.-]*:\/\/[^\s/?#'"]*@/i.test(text))
|
|
1192
|
+
return undefined;
|
|
1193
|
+
if (!/^\s*image:\s*['"]?(?:[\w.-]+\/)*postgres(?::[\w.-]+)?['"]?\s*(?:#.*)?$/m.test(text))
|
|
1194
|
+
continue;
|
|
1195
|
+
const literal = (key) => {
|
|
1196
|
+
const match = new RegExp(`^\\s*(?:-\\s*)?${key}\\s*[:=]\\s*['"]?([^\\s'"#$]+)['"]?\\s*(?:#.*)?$`, "m").exec(text);
|
|
1197
|
+
return match && WORKER_DATABASE_IDENTIFIER.test(match[1]) ? match[1] : null;
|
|
1198
|
+
};
|
|
1199
|
+
const database = literal("POSTGRES_DB");
|
|
1200
|
+
const role = literal("POSTGRES_USER");
|
|
1201
|
+
if (database === null || role === null || role === "postgres")
|
|
1202
|
+
return undefined;
|
|
1203
|
+
const aliases = [];
|
|
1204
|
+
for (const match of text.matchAll(/^\s*(?:-\s*)?([A-Z][A-Z0-9_]*_URL|DATABASE_URL)\s*[:=]/gm)) {
|
|
1205
|
+
if (isProposableDatabaseUrlName(match[1]) && !aliases.includes(match[1]))
|
|
1206
|
+
aliases.push(match[1]);
|
|
1207
|
+
}
|
|
1208
|
+
if (aliases.length === 0)
|
|
1209
|
+
return undefined;
|
|
1210
|
+
return {
|
|
1211
|
+
declaration: {
|
|
1212
|
+
mode: "disposable_postgres",
|
|
1213
|
+
worker_role: role,
|
|
1214
|
+
protected_databases: [database],
|
|
1215
|
+
env_names: aliases.slice(0, WORKER_DATABASE_MAX_ALIASES),
|
|
1216
|
+
migrate_command: {
|
|
1217
|
+
argv: [".venv/bin/alembic", "-c", "alembic.ini", "upgrade", "head"],
|
|
1218
|
+
timeout_seconds: WORKER_DATABASE_PROPOSED_TIMEOUT_SECONDS,
|
|
1219
|
+
head_check: "alembic",
|
|
1220
|
+
},
|
|
1221
|
+
},
|
|
1222
|
+
sources: ["alembic.ini", file],
|
|
1223
|
+
};
|
|
1224
|
+
}
|
|
1225
|
+
return undefined;
|
|
1226
|
+
}
|
|
1088
1227
|
/** BAPI-1551 — the root dependency-refresh proposals and the notes on what was left out. */
|
|
1089
1228
|
export async function proposeDependencyInstall(fsSeam) {
|
|
1090
1229
|
let resolution;
|
|
@@ -1427,6 +1566,7 @@ export async function discoverGate(input) {
|
|
|
1427
1566
|
const workerEnv = resolveWorkerEnv(extras.envObservations);
|
|
1428
1567
|
const hints = await proposeReproductionHints(fsSeam, providerChecks, extras.hintJobs);
|
|
1429
1568
|
const dependencyInstall = await proposeDependencyInstall(fsSeam);
|
|
1569
|
+
const mustOrder = await proposeMustOrderPaths(fsSeam);
|
|
1430
1570
|
return {
|
|
1431
1571
|
providerCandidates,
|
|
1432
1572
|
unreportedProviderNames,
|
|
@@ -1441,31 +1581,36 @@ export async function discoverGate(input) {
|
|
|
1441
1581
|
workerEnvOverflow: workerEnv.overflow,
|
|
1442
1582
|
reproductionHints: hints.proposed,
|
|
1443
1583
|
reproductionHintsSkipped: hints.skipped,
|
|
1444
|
-
...declarationFields(dependencyInstall, proposeCiDatabase(providerChecks, extras.workflowFiles)),
|
|
1584
|
+
...declarationFields(dependencyInstall, proposeCiDatabase(providerChecks, extras.workflowFiles), mustOrder, await proposeWorkerDatabase(fsSeam)),
|
|
1445
1585
|
};
|
|
1446
1586
|
}
|
|
1447
1587
|
/**
|
|
1448
1588
|
* BAPI-1551 — only the declaration proposals, for a repository whose gate is
|
|
1449
|
-
* already confirmed: the root dependency refreshes,
|
|
1450
|
-
* read from the workflow files that report one of the CONFIRMED provider checks
|
|
1589
|
+
* already confirmed: the root dependency refreshes, the CI-database value
|
|
1590
|
+
* read from the workflow files that report one of the CONFIRMED provider checks,
|
|
1591
|
+
* and (BAPI-1580) the existing migration directories as must-order paths.
|
|
1451
1592
|
* Makes no provider-history call.
|
|
1452
1593
|
*/
|
|
1453
1594
|
export async function discoverDeclarations(input) {
|
|
1454
1595
|
const extras = { envObservations: [], hintJobs: new Map(), workflowFiles: [] };
|
|
1455
1596
|
await collectWorkflows(input.fs, [], new LookupNames(), extras);
|
|
1456
1597
|
const dependencyInstall = await proposeDependencyInstall(input.fs);
|
|
1457
|
-
|
|
1598
|
+
const mustOrder = await proposeMustOrderPaths(input.fs);
|
|
1599
|
+
return declarationFields(dependencyInstall, proposeCiDatabase(input.providerChecks, extras.workflowFiles), mustOrder, await proposeWorkerDatabase(input.fs));
|
|
1458
1600
|
}
|
|
1459
1601
|
/**
|
|
1460
1602
|
* BAPI-1551 — the declaration fields of a proposal. Each is present only when it
|
|
1461
1603
|
* says something (a candidate, a note, or a value other than `unknown`), so a
|
|
1462
1604
|
* repository with nothing to propose yields exactly the pre-BAPI-1551 proposal.
|
|
1463
1605
|
*/
|
|
1464
|
-
function declarationFields(dependencyInstall, ciDatabase) {
|
|
1606
|
+
function declarationFields(dependencyInstall, ciDatabase, mustOrder, workerDatabase) {
|
|
1465
1607
|
return {
|
|
1608
|
+
...(workerDatabase !== undefined ? { workerDatabaseProposal: workerDatabase } : {}),
|
|
1466
1609
|
...(dependencyInstall.candidates.length > 0 ? { dependencyInstallCandidates: dependencyInstall.candidates } : {}),
|
|
1467
1610
|
...(dependencyInstall.notes.length > 0 ? { dependencyInstallNotes: dependencyInstall.notes } : {}),
|
|
1468
1611
|
...(ciDatabase.value !== "unknown" ? { ciDatabaseProposal: ciDatabase } : {}),
|
|
1612
|
+
...(mustOrder.candidates.length > 0 ? { mustOrderPathCandidates: mustOrder.candidates } : {}),
|
|
1613
|
+
...(mustOrder.overflow > 0 ? { mustOrderPathOverflow: mustOrder.overflow } : {}),
|
|
1469
1614
|
};
|
|
1470
1615
|
}
|
|
1471
1616
|
/**
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
* - **CI database behavior** — whether the repository's CI runs with a database
|
|
15
15
|
* (`none`, `provided`, or `unknown`).
|
|
16
16
|
*
|
|
17
|
+
* BAPI-1580 adds **must-order paths** — migration directories whose children
|
|
18
|
+
* merge one at a time. Discovery only proposes existing directories; each new
|
|
19
|
+
* one is offered on its own, stored entries are never removed here, and the
|
|
20
|
+
* 32-entry bound is respected (anything left out is named as a warning).
|
|
21
|
+
*
|
|
17
22
|
* All are high-trust: a value is confirmed by the repository owner, one decision
|
|
18
23
|
* at a time, and only in an interactive terminal. An install argv is shown and
|
|
19
24
|
* edited only here, as an argument array, never as a shell string.
|
|
@@ -33,7 +38,7 @@
|
|
|
33
38
|
* an empty `workerEnv` list is a deliberate removal of every stored variable.
|
|
34
39
|
*/
|
|
35
40
|
import { LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./gate-discovery.js";
|
|
36
|
-
import { CI_DATABASE_DEFAULT, MAX_DEPENDENCY_INSTALL_ENTRIES, MAX_DEPENDENCY_INSTALL_LOCKFILES, admitDependencyInstallDeclarations, dependencyInstallEntryIdentity, isCiDatabase, isSafeRepoRelativePath, sameDependencyInstall, } from "../dependency-install-declarations.js";
|
|
41
|
+
import { CI_DATABASE_DEFAULT, MAX_DEPENDENCY_INSTALL_ENTRIES, MAX_DEPENDENCY_INSTALL_LOCKFILES, MAX_MUST_ORDER_PATHS, admitDependencyInstallDeclarations, canonicalMustOrderPaths, dependencyInstallEntryIdentity, isCiDatabase, isSafeRepoRelativePath, sameDependencyInstall, sameMustOrderPaths, } from "../dependency-install-declarations.js";
|
|
37
42
|
/** Limits that mirror `gate_profile.py` for hand-typed hints. */
|
|
38
43
|
const MAX_HINT_WORDS = 32;
|
|
39
44
|
const MAX_HINT_WORD_CHARS = 1024;
|
|
@@ -104,6 +109,25 @@ export function dependencyInstallEqual(a, b) {
|
|
|
104
109
|
export function storedCiDatabase(stored) {
|
|
105
110
|
return stored?.ci_database ?? CI_DATABASE_DEFAULT;
|
|
106
111
|
}
|
|
112
|
+
/** BAPI-1598 — order-insensitive canonical text of a declaration, for equality only. */
|
|
113
|
+
function canonicalDeclaration(value) {
|
|
114
|
+
if (Array.isArray(value))
|
|
115
|
+
return `[${value.map(canonicalDeclaration).join(",")}]`;
|
|
116
|
+
if (typeof value === "object" && value !== null) {
|
|
117
|
+
return `{${Object.entries(value)
|
|
118
|
+
.filter(([, v]) => v !== undefined)
|
|
119
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
120
|
+
.map(([k, v]) => `${JSON.stringify(k)}:${canonicalDeclaration(v)}`)
|
|
121
|
+
.join(",")}}`;
|
|
122
|
+
}
|
|
123
|
+
return JSON.stringify(value);
|
|
124
|
+
}
|
|
125
|
+
/** BAPI-1598 — whether two worker-database declarations are the same (a declaration and `undefined` differ). */
|
|
126
|
+
export function workerDatabaseEqual(a, b) {
|
|
127
|
+
if (a === undefined || b === undefined)
|
|
128
|
+
return a === b;
|
|
129
|
+
return canonicalDeclaration(a) === canonicalDeclaration(b);
|
|
130
|
+
}
|
|
107
131
|
/**
|
|
108
132
|
* Whether `edit` leaves the stored settings exactly as they are. Omitted
|
|
109
133
|
* settings and per-check hints resolve against `stored` first, so a request
|
|
@@ -117,6 +141,12 @@ export function settingsMatchStored(edit, stored) {
|
|
|
117
141
|
}
|
|
118
142
|
if (edit.ciDatabase !== undefined && edit.ciDatabase !== storedCiDatabase(stored))
|
|
119
143
|
return false;
|
|
144
|
+
if (edit.workerDatabase !== undefined && !workerDatabaseEqual(edit.workerDatabase, stored?.worker_database)) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (edit.mustOrderPaths !== undefined && !sameMustOrderPaths(edit.mustOrderPaths, stored?.must_order_paths ?? [])) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
120
150
|
for (const [check, hint] of edit.reproduce ?? []) {
|
|
121
151
|
const current = stored?.reproduction_hints?.get(check) ?? null;
|
|
122
152
|
if (hint === null) {
|
|
@@ -214,8 +244,40 @@ export function hasDeclarationsToReview(proposal, stored) {
|
|
|
214
244
|
return ((stored?.dependency_install?.length ?? 0) > 0 ||
|
|
215
245
|
newDependencyProposals(proposal, stored).length > 0 ||
|
|
216
246
|
storedCiDatabase(stored) !== CI_DATABASE_DEFAULT ||
|
|
247
|
+
proposedCiDatabase(proposal) !== CI_DATABASE_DEFAULT ||
|
|
248
|
+
// BAPI-1598: a lone worker-database proposal must still reach the review, or it
|
|
249
|
+
// would be printed as "proposed" and never selected.
|
|
250
|
+
newWorkerDatabaseProposal(proposal, stored) !== undefined ||
|
|
251
|
+
mustOrderOffer(proposal, stored).offered.length > 0);
|
|
252
|
+
}
|
|
253
|
+
/** Whether the BAPI-1551 dependency-refresh or CI-database groups have anything to show. */
|
|
254
|
+
function hasDependencyOrCiToReview(proposal, stored) {
|
|
255
|
+
return ((stored?.dependency_install?.length ?? 0) > 0 ||
|
|
256
|
+
newDependencyProposals(proposal, stored).length > 0 ||
|
|
257
|
+
(proposal.dependencyInstallNotes?.length ?? 0) > 0 ||
|
|
258
|
+
storedCiDatabase(stored) !== CI_DATABASE_DEFAULT ||
|
|
217
259
|
proposedCiDatabase(proposal) !== CI_DATABASE_DEFAULT);
|
|
218
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* BAPI-1580 — the must-order discoveries to offer: those not already stored,
|
|
263
|
+
* limited to what still fits in the {@link MAX_MUST_ORDER_PATHS}-entry total.
|
|
264
|
+
*/
|
|
265
|
+
export function mustOrderOffer(proposal, stored) {
|
|
266
|
+
const storedList = stored?.must_order_paths ?? [];
|
|
267
|
+
const fresh = canonicalMustOrderPaths(proposal.mustOrderPathCandidates ?? []).filter((p) => !storedList.includes(p));
|
|
268
|
+
const capacity = Math.max(0, MAX_MUST_ORDER_PATHS - storedList.length);
|
|
269
|
+
const offered = fresh.slice(0, capacity);
|
|
270
|
+
return { offered, notOffered: fresh.length - offered.length + (proposal.mustOrderPathOverflow ?? 0) };
|
|
271
|
+
}
|
|
272
|
+
/** BAPI-1580 — the explicit warning when some discoveries cannot be offered, or null. */
|
|
273
|
+
export function mustOrderShortfallWarning(proposal, stored) {
|
|
274
|
+
const { notOffered } = mustOrderOffer(proposal, stored);
|
|
275
|
+
if (notOffered === 0)
|
|
276
|
+
return null;
|
|
277
|
+
return (` ⚠ ${notOffered} discovered must-order path${notOffered === 1 ? " was" : "s were"} not offered: the gate holds ` +
|
|
278
|
+
`at most ${MAX_MUST_ORDER_PATHS} must-order paths, counting the ${(stored?.must_order_paths ?? []).length} ` +
|
|
279
|
+
"already stored. Add the rest manually.");
|
|
280
|
+
}
|
|
219
281
|
/**
|
|
220
282
|
* BAPI-1551 — whether discovery proposes a declaration the stored profile does
|
|
221
283
|
* not already hold. This is the advisory gate change setup offers; it is never a
|
|
@@ -223,7 +285,10 @@ export function hasDeclarationsToReview(proposal, stored) {
|
|
|
223
285
|
*/
|
|
224
286
|
export function hasUnstoredDeclarationProposal(proposal, stored) {
|
|
225
287
|
const ci = proposedCiDatabase(proposal);
|
|
226
|
-
return newDependencyProposals(proposal, stored).length > 0 ||
|
|
288
|
+
return (newDependencyProposals(proposal, stored).length > 0 ||
|
|
289
|
+
(ci !== CI_DATABASE_DEFAULT && ci !== storedCiDatabase(stored)) ||
|
|
290
|
+
newWorkerDatabaseProposal(proposal, stored) !== undefined ||
|
|
291
|
+
mustOrderOffer(proposal, stored).offered.length > 0);
|
|
227
292
|
}
|
|
228
293
|
/** Proposed entries whose identity (cwd and lockfiles) is not stored with the same argv. */
|
|
229
294
|
function newDependencyProposals(proposal, stored) {
|
|
@@ -233,6 +298,16 @@ function newDependencyProposals(proposal, stored) {
|
|
|
233
298
|
function entryOf(candidate) {
|
|
234
299
|
return { cwd: candidate.cwd, argv: [...candidate.argv], lockfiles: [...candidate.lockfiles] };
|
|
235
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* BAPI-1598 — the proposed worker-database declaration, only when none is stored.
|
|
303
|
+
* An existing confirmed declaration is preserved over discovery output, whatever
|
|
304
|
+
* the repository now looks like.
|
|
305
|
+
*/
|
|
306
|
+
function newWorkerDatabaseProposal(proposal, stored) {
|
|
307
|
+
if (stored?.worker_database !== undefined)
|
|
308
|
+
return undefined;
|
|
309
|
+
return proposal.workerDatabaseProposal?.declaration;
|
|
310
|
+
}
|
|
236
311
|
function proposedCiDatabase(proposal) {
|
|
237
312
|
return proposal.ciDatabaseProposal?.value ?? CI_DATABASE_DEFAULT;
|
|
238
313
|
}
|
|
@@ -306,10 +381,32 @@ export function renderSettingsReview(io, proposal, stored, providerChecks, showV
|
|
|
306
381
|
}
|
|
307
382
|
// Shown only when there is something to say, so a review without either
|
|
308
383
|
// declaration renders exactly as it did before BAPI-1551.
|
|
309
|
-
if (hasDeclarationsToReview(proposal, stored) ||
|
|
384
|
+
if (hasDeclarationsToReview(proposal, stored) ||
|
|
385
|
+
(proposal.dependencyInstallNotes?.length ?? 0) > 0 ||
|
|
386
|
+
mustOrderOffer(proposal, stored).notOffered > 0) {
|
|
310
387
|
renderDeclarationsReview(io, proposal, stored, showValues);
|
|
311
388
|
}
|
|
389
|
+
renderWorkerDatabaseReview(io, proposal, stored);
|
|
390
|
+
io.log("");
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* BAPI-1598 — the "Worker database setup" and "Verification when no database
|
|
394
|
+
* checks can run" lines of the existing summary. Plain language only: the mode
|
|
395
|
+
* token, identifiers, and migration argv stay in the admin and details output.
|
|
396
|
+
*/
|
|
397
|
+
export function renderWorkerDatabaseReview(io, proposal, stored) {
|
|
398
|
+
const storedDeclaration = stored?.worker_database;
|
|
399
|
+
const state = storedDeclaration !== undefined && storedDeclaration.mode !== "none"
|
|
400
|
+
? "already confirmed"
|
|
401
|
+
: newWorkerDatabaseProposal(proposal, stored) !== undefined
|
|
402
|
+
? "proposed"
|
|
403
|
+
: "not configured";
|
|
312
404
|
io.log("");
|
|
405
|
+
io.log(` Worker database setup: ${state}.`);
|
|
406
|
+
if (state === "not configured")
|
|
407
|
+
io.log(" No database will be created for workers.");
|
|
408
|
+
const handoff = stored?.verification_handoff_default ?? "proceed";
|
|
409
|
+
io.log(` Verification when no database checks can run: ${handoff === "block" ? "stop and ask" : "continue and say so"}.`);
|
|
313
410
|
}
|
|
314
411
|
const CI_DATABASE_TEXT = Object.freeze({
|
|
315
412
|
none: "none — CI runs without a database",
|
|
@@ -330,8 +427,30 @@ function describeDependencyEntry(entry, label, showValues) {
|
|
|
330
427
|
: " (the install command is shown only in a terminal)");
|
|
331
428
|
return lines;
|
|
332
429
|
}
|
|
333
|
-
/** BAPI-1551 —
|
|
430
|
+
/** BAPI-1551 (extended by BAPI-1580) — every declaration group with something to show. */
|
|
334
431
|
function renderDeclarationsReview(io, proposal, stored, showValues) {
|
|
432
|
+
// BAPI-1580: a review with only must-order paths to show skips the BAPI-1551
|
|
433
|
+
// groups; any other review renders them exactly as before.
|
|
434
|
+
if (hasDependencyOrCiToReview(proposal, stored))
|
|
435
|
+
renderDependencyAndCiReview(io, proposal, stored, showValues);
|
|
436
|
+
renderMustOrderReview(io, proposal, stored);
|
|
437
|
+
}
|
|
438
|
+
/** BAPI-1580 — the Must-order paths group, shown only when something is new or left out. */
|
|
439
|
+
function renderMustOrderReview(io, proposal, stored) {
|
|
440
|
+
const { offered } = mustOrderOffer(proposal, stored);
|
|
441
|
+
const warning = mustOrderShortfallWarning(proposal, stored);
|
|
442
|
+
if (offered.length === 0 && warning === null)
|
|
443
|
+
return;
|
|
444
|
+
io.log("");
|
|
445
|
+
io.log(" Must-order paths — children that change these paths merge one at a time, in plan order.");
|
|
446
|
+
for (const entry of stored?.must_order_paths ?? [])
|
|
447
|
+
io.log(` ${terminalSafe(entry)} — Stored`);
|
|
448
|
+
offered.forEach((entry, index) => io.log(` [${index + 1}] ${terminalSafe(entry)} — Proposed`));
|
|
449
|
+
if (warning !== null)
|
|
450
|
+
io.log(warning);
|
|
451
|
+
}
|
|
452
|
+
/** BAPI-1551 — the Dependency refresh and CI database behavior groups. */
|
|
453
|
+
function renderDependencyAndCiReview(io, proposal, stored, showValues) {
|
|
335
454
|
io.log("");
|
|
336
455
|
io.log(" Dependency refresh — before a worker starts, reinstall dependencies when a lockfile changed.");
|
|
337
456
|
const storedList = stored?.dependency_install ?? [];
|
|
@@ -676,6 +795,24 @@ async function reviewCiDatabase(io, proposal, stored) {
|
|
|
676
795
|
}
|
|
677
796
|
return chosen === current ? undefined : chosen;
|
|
678
797
|
}
|
|
798
|
+
/**
|
|
799
|
+
* BAPI-1580 — offer each new must-order path on its own. Returns the complete
|
|
800
|
+
* canonical list (stored entries kept, accepted ones added), or `undefined`
|
|
801
|
+
* when the owner accepts none. Enter, or anything but yes, declines.
|
|
802
|
+
*/
|
|
803
|
+
async function reviewMustOrderPaths(io, proposal, stored) {
|
|
804
|
+
const { offered } = mustOrderOffer(proposal, stored);
|
|
805
|
+
const accepted = [];
|
|
806
|
+
for (const entry of offered) {
|
|
807
|
+
if (await yes(io.promptLine, `Add must-order path ${terminalSafe(entry)}? [y/N]: `))
|
|
808
|
+
accepted.push(entry);
|
|
809
|
+
else
|
|
810
|
+
io.log(" Not added. Stored must-order paths are untouched.");
|
|
811
|
+
}
|
|
812
|
+
if (accepted.length === 0)
|
|
813
|
+
return undefined;
|
|
814
|
+
return canonicalMustOrderPaths([...(stored?.must_order_paths ?? []), ...accepted]);
|
|
815
|
+
}
|
|
679
816
|
/**
|
|
680
817
|
* Show the review surface and collect the owner's decisions. Requires a
|
|
681
818
|
* terminal. Returns what changed; nothing is stored here.
|
|
@@ -701,19 +838,93 @@ export async function reviewDeclarations(io, proposal, stored) {
|
|
|
701
838
|
const edit = {};
|
|
702
839
|
if (!hasDeclarationsToReview(proposal, stored))
|
|
703
840
|
return edit;
|
|
841
|
+
// BAPI-1598: printed in the summary above and covered by the same single
|
|
842
|
+
// confirmation; it adds no question of its own.
|
|
843
|
+
const workerDatabase = newWorkerDatabaseProposal(proposal, stored);
|
|
844
|
+
if (workerDatabase !== undefined)
|
|
845
|
+
edit.workerDatabase = workerDatabase;
|
|
704
846
|
const dependencyInstall = await reviewDependencyInstall(io, proposal, stored);
|
|
705
847
|
if (dependencyInstall !== undefined)
|
|
706
848
|
edit.dependencyInstall = dependencyInstall;
|
|
707
849
|
const ciDatabase = await reviewCiDatabase(io, proposal, stored);
|
|
708
850
|
if (ciDatabase !== undefined)
|
|
709
851
|
edit.ciDatabase = ciDatabase;
|
|
852
|
+
const mustOrderPaths = await reviewMustOrderPaths(io, proposal, stored);
|
|
853
|
+
if (mustOrderPaths !== undefined)
|
|
854
|
+
edit.mustOrderPaths = mustOrderPaths;
|
|
710
855
|
return edit;
|
|
711
856
|
}
|
|
712
857
|
/** BAPI-1551 — print only the declaration groups (setup's advisory offer). */
|
|
713
858
|
export function renderDeclarationsOnly(io, proposal, stored, showValues) {
|
|
714
859
|
renderDeclarationsReview(io, proposal, stored, showValues);
|
|
860
|
+
if (newWorkerDatabaseProposal(proposal, stored) !== undefined)
|
|
861
|
+
renderWorkerDatabaseReview(io, proposal, stored);
|
|
715
862
|
io.log("");
|
|
716
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* BAPI-1604 — select the settings that need no individual confirmation, without
|
|
866
|
+
* asking: proposed worker variables (never a committed literal, which needs its
|
|
867
|
+
* own typed `yes`), proposed reproduction hints, dependency refresh entries, the
|
|
868
|
+
* CI-database proposal, and new must-order paths. Stored settings are never
|
|
869
|
+
* removed. The skipped receipts name the variable and never its value. Pure: no
|
|
870
|
+
* prompt, no write, and it uses the same committed-literal marker the interactive
|
|
871
|
+
* review uses rather than a second secret-name heuristic.
|
|
872
|
+
*/
|
|
873
|
+
export function recommendedSettingsSelection(proposal, stored, providerChecks) {
|
|
874
|
+
const edit = {};
|
|
875
|
+
const skipped = [];
|
|
876
|
+
const storedEnv = stored?.worker_env ?? [];
|
|
877
|
+
let env = storedEnv.map((e) => ({ ...e }));
|
|
878
|
+
for (const row of envRows(proposal, stored)) {
|
|
879
|
+
const entry = row.proposed;
|
|
880
|
+
if (row.status === "Stored" || entry === undefined)
|
|
881
|
+
continue;
|
|
882
|
+
if (entry.committed_literal === true) {
|
|
883
|
+
skipped.push(`Skipped for safety: ${row.name} needs your review. Use --review-ci-settings.`);
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
env = [...env.filter((e) => e.name !== row.name), { ...entry }];
|
|
887
|
+
}
|
|
888
|
+
env.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
889
|
+
if (!workerEnvEqual(env, storedEnv))
|
|
890
|
+
edit.workerEnv = env;
|
|
891
|
+
const reproduce = new Map();
|
|
892
|
+
for (const row of hintRows(proposal, stored, providerChecks)) {
|
|
893
|
+
if (row.proposed === null)
|
|
894
|
+
continue;
|
|
895
|
+
const proposed = hintFrom(row.proposed);
|
|
896
|
+
if (row.stored === null || !hintEqual(row.stored, proposed))
|
|
897
|
+
reproduce.set(row.check, proposed);
|
|
898
|
+
}
|
|
899
|
+
if (reproduce.size > 0)
|
|
900
|
+
edit.reproduce = reproduce;
|
|
901
|
+
const storedDeps = (stored?.dependency_install ?? []).map(entryOf);
|
|
902
|
+
const deps = storedDeps.map(entryOf);
|
|
903
|
+
for (const candidate of newDependencyProposals(proposal, stored)) {
|
|
904
|
+
const entry = entryOf(candidate);
|
|
905
|
+
const identity = dependencyInstallEntryIdentity(entry);
|
|
906
|
+
const at = deps.findIndex((e) => dependencyInstallEntryIdentity(e) === identity);
|
|
907
|
+
if (at === -1)
|
|
908
|
+
deps.push(entry);
|
|
909
|
+
else
|
|
910
|
+
deps[at] = entry;
|
|
911
|
+
}
|
|
912
|
+
if (deps.length <= MAX_DEPENDENCY_INSTALL_ENTRIES && !dependencyInstallEqual(deps, storedDeps)) {
|
|
913
|
+
edit.dependencyInstall = deps;
|
|
914
|
+
}
|
|
915
|
+
const current = storedCiDatabase(stored);
|
|
916
|
+
const proposedDb = proposedCiDatabase(proposal);
|
|
917
|
+
if (proposedDb !== CI_DATABASE_DEFAULT && proposedDb !== current)
|
|
918
|
+
edit.ciDatabase = proposedDb;
|
|
919
|
+
const workerDatabase = newWorkerDatabaseProposal(proposal, stored);
|
|
920
|
+
if (workerDatabase !== undefined)
|
|
921
|
+
edit.workerDatabase = workerDatabase;
|
|
922
|
+
const { offered } = mustOrderOffer(proposal, stored);
|
|
923
|
+
if (offered.length > 0) {
|
|
924
|
+
edit.mustOrderPaths = canonicalMustOrderPaths([...(stored?.must_order_paths ?? []), ...offered]);
|
|
925
|
+
}
|
|
926
|
+
return { edit, skipped };
|
|
927
|
+
}
|
|
717
928
|
/** Name-only lines describing what an edit changes, for the gate comparison. */
|
|
718
929
|
export function describeSettingsEdit(edit, stored) {
|
|
719
930
|
const lines = [];
|
|
@@ -747,5 +958,14 @@ export function describeSettingsEdit(edit, stored) {
|
|
|
747
958
|
? " CI database behavior: reset to unknown"
|
|
748
959
|
: ` CI database behavior: ${edit.ciDatabase}`);
|
|
749
960
|
}
|
|
961
|
+
if (edit.workerDatabase !== undefined) {
|
|
962
|
+
lines.push(" worker database setup: set (replaces any stored declaration)");
|
|
963
|
+
}
|
|
964
|
+
if (edit.mustOrderPaths !== undefined) {
|
|
965
|
+
const before = stored?.must_order_paths ?? [];
|
|
966
|
+
const added = edit.mustOrderPaths.filter((p) => !before.includes(p));
|
|
967
|
+
lines.push(` must-order paths: ${edit.mustOrderPaths.length} after this change` +
|
|
968
|
+
(added.length > 0 ? ` (added ${safeList(added)})` : ""));
|
|
969
|
+
}
|
|
750
970
|
return lines;
|
|
751
971
|
}
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BAPI-1506 — read-only launch-need probes for the `drive-epic` create preview.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* repository's required checks has an online runner
|
|
6
|
-
* branch
|
|
7
|
-
* every subprocess has a bounded
|
|
8
|
-
*
|
|
4
|
+
* One probe lives here: whether every self-hosted label set behind the
|
|
5
|
+
* repository's required checks has an online runner. (BAPI-1596 removed the
|
|
6
|
+
* epic-branch-behind-base probe: a launch neither runs nor shows it.) It is a
|
|
7
|
+
* bookkeeping read (design principle 5): every subprocess has a bounded
|
|
8
|
+
* timeout, and every failure, timeout, missing tool, or unreadable output
|
|
9
|
+
* becomes `unverifiable`. Nothing here can refuse a
|
|
9
10
|
* launch, and nothing from a subprocess, a workflow file, or a path reaches the
|
|
10
11
|
* returned facts — only closed classifications and bounded counts.
|
|
11
12
|
*/
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
14
|
-
import { validateBranchName } from "../base-ref.js";
|
|
15
15
|
import { PLANE_FRESHNESS_TIMEOUT_MS } from "../plane/plane-freshness.js";
|
|
16
16
|
/** One deadline for the whole runner probe, however many pages it reads. */
|
|
17
17
|
export const LAUNCH_RUNNER_PROBE_DEADLINE_MS = PLANE_FRESHNESS_TIMEOUT_MS;
|
|
18
|
-
/** Bound on each git read the behind-base probe runs. */
|
|
19
|
-
export const LAUNCH_BRANCH_PROBE_TIMEOUT_MS = PLANE_FRESHNESS_TIMEOUT_MS;
|
|
20
18
|
const RUNNER_PAGE_SIZE = 100;
|
|
21
19
|
const RUNNER_MAX_PAGES = 10;
|
|
22
20
|
const WORKFLOW_MAX_FILES = 200;
|
|
@@ -295,48 +293,3 @@ async function probeRunners(input) {
|
|
|
295
293
|
? { state: "present", unsatisfied_label_sets: unsatisfied, label_sets: labelSets.size }
|
|
296
294
|
: { state: "absent", label_sets: labelSets.size };
|
|
297
295
|
}
|
|
298
|
-
/**
|
|
299
|
-
* How many commits `origin/<branch>` is behind `origin/<base>`. Information
|
|
300
|
-
* only: integration's `sync_base` merges the base into the epic branch. Uses
|
|
301
|
-
* the remote-tracking refs the preview already has; it fetches nothing.
|
|
302
|
-
* NEVER throws.
|
|
303
|
-
*/
|
|
304
|
-
export async function inspectEpicBranchBehindBase(input) {
|
|
305
|
-
try {
|
|
306
|
-
const { branch, baseBranch } = input;
|
|
307
|
-
if (branch === null || branch === "")
|
|
308
|
-
return { state: "not_applicable", reason: "no_epic_branch" };
|
|
309
|
-
if (baseBranch === null || baseBranch === "")
|
|
310
|
-
return { state: "unverifiable", reason: "no_base_branch" };
|
|
311
|
-
if (validateBranchName(branch) !== null || validateBranchName(baseBranch) !== null) {
|
|
312
|
-
return { state: "unverifiable", reason: "invalid_branch_name" };
|
|
313
|
-
}
|
|
314
|
-
if (branch === baseBranch)
|
|
315
|
-
return { state: "not_applicable", reason: "no_epic_branch" };
|
|
316
|
-
const git = (args) => input.execFile("git", args, {
|
|
317
|
-
cwd: input.repoRoot,
|
|
318
|
-
timeoutMs: LAUNCH_BRANCH_PROBE_TIMEOUT_MS,
|
|
319
|
-
env: { GIT_TERMINAL_PROMPT: "0" },
|
|
320
|
-
});
|
|
321
|
-
// `for-each-ref` exits 0 with no output for a ref that does not exist, so a
|
|
322
|
-
// missing branch is told apart from a git failure.
|
|
323
|
-
const ref = `refs/remotes/origin/${branch}`;
|
|
324
|
-
const listed = await git(["for-each-ref", "--format=%(refname)", ref]);
|
|
325
|
-
if (!listed.ok)
|
|
326
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
327
|
-
if (!listed.stdout.split(/\r?\n/).some((line) => line.trim() === ref)) {
|
|
328
|
-
return { state: "not_applicable", reason: "branch_not_on_origin" };
|
|
329
|
-
}
|
|
330
|
-
const counted = await git(["rev-list", "--count", `refs/remotes/origin/${branch}..refs/remotes/origin/${baseBranch}`]);
|
|
331
|
-
if (!counted.ok)
|
|
332
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
333
|
-
const text = counted.stdout.trim();
|
|
334
|
-
if (!/^\d{1,9}$/.test(text))
|
|
335
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
336
|
-
const behind = Number.parseInt(text, 10);
|
|
337
|
-
return behind === 0 ? { state: "absent" } : { state: "present", behind };
|
|
338
|
-
}
|
|
339
|
-
catch {
|
|
340
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
341
|
-
}
|
|
342
|
-
}
|