@bridge_gpt/mcp-server 0.2.71 → 0.2.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +19 -3
- package/build/agent-notes.js +171 -95
- package/build/agents.generated.js +4 -4
- package/build/bridge-permissions.js +4 -0
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +518 -23
- package/build/conductor/doctor.js +84 -10
- package/build/conductor/epic-implementer-cli.js +51 -2
- package/build/conductor/gate-discovery.js +136 -10
- package/build/conductor/gate-settings-review.js +305 -5
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-plan.js +42 -2
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +21 -8
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +223 -13
- package/build/conductor/recovery-operations.js +34 -4
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +52 -11
- package/build/epic-implementer-bin.js +118 -43
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +67 -2
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +246 -28
- package/build/executor/likely-tests.js +94 -97
- package/build/executor/prompt-spec.js +13 -3
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +54 -2
- package/build/executor/worker-database.js +271 -31
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-verification-guidance.js +37 -2
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +679 -278
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +236 -42
- package/build/install-bridge-conductor-setup.js +115 -26
- package/build/install-bridge-conductor.js +448 -350
- package/build/install-bridge.js +418 -123
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +2 -2
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +5 -5
- package/build/plan-execution-ledger.js +148 -2
- package/build/plane/plane-freshness.js +6 -7
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +24 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +50 -8
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +2 -2
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +32 -88
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-enrollment.js +21 -8
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER.md +5 -0
- package/docs/epic-implementer/getting-started.md +40 -15
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeHarnessCoverage } from "../executor/harness-coverage.js";
|
|
1
2
|
import { monotonicNow, elapsedMs } from "./precheck-timings.js";
|
|
2
3
|
/**
|
|
3
4
|
* Combined, strictly read-only epic-implementer doctor report (BAPI-395, BAPI-418).
|
|
@@ -85,7 +86,7 @@ export const DENY_ENFORCEMENT_SKIP_REMEDIATION = "run `epic-implementer doctor`
|
|
|
85
86
|
/** Explicit display value for an unset `BRIDGE_MCP_PROFILE`. */
|
|
86
87
|
export const MCP_PROFILE_UNSET = "(unset)";
|
|
87
88
|
/** BAPI-1461: the printed setup command, used in stored-token remedies. */
|
|
88
|
-
const PRINTED_SETUP_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install
|
|
89
|
+
const PRINTED_SETUP_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install epic-implementer`;
|
|
89
90
|
/** BAPI-1461: the fix for a stored token GitHub rejected. */
|
|
90
91
|
export const STORED_MERGE_TOKEN_REJECTED_REMEDIATION = `replace the stored merge token: run \`${PRINTED_SETUP_COMMAND}\` and accept the offer to ` +
|
|
91
92
|
`replace it, or remove it with \`${PRINTED_SETUP_COMMAND} --remove-merge-token\`.`;
|
|
@@ -162,6 +163,48 @@ export const WORKER_DATABASE_DOCTOR_OWNER = "host operator";
|
|
|
162
163
|
export const WORKER_DATABASE_DOCTOR_TIMEOUT_MS = 20_000;
|
|
163
164
|
/** Maximum validated names listed per inventory group; the rest are counted. */
|
|
164
165
|
export const WORKER_DATABASE_DOCTOR_NAME_LIMIT = 20;
|
|
166
|
+
const MIGRATION_CAUSE_LABELS = {
|
|
167
|
+
multiple_heads: "Multiple heads",
|
|
168
|
+
revision_missing: "Missing revision",
|
|
169
|
+
ssl_refused: "SSL refused",
|
|
170
|
+
connection_refused: "Connection refused",
|
|
171
|
+
permission_denied: "Permission denied",
|
|
172
|
+
timeout: "Timed out",
|
|
173
|
+
other: "Other failure",
|
|
174
|
+
};
|
|
175
|
+
/** Most owner roles ever displayed. */
|
|
176
|
+
export const WORKER_DATABASE_DOCTOR_OWNER_ROLE_LIMIT = 5;
|
|
177
|
+
const OWNER_ROLE_PATTERN = /^[A-Za-z_][A-Za-z0-9_$-]{0,62}$/;
|
|
178
|
+
/** True only for a whole-string valid PostgreSQL role name; nothing is trimmed into validity. */
|
|
179
|
+
export function isDisplayableOwnerRole(value) {
|
|
180
|
+
return typeof value === "string" && OWNER_ROLE_PATTERN.test(value);
|
|
181
|
+
}
|
|
182
|
+
/** Revalidate, deduplicate, sort (byte order), and cap an untrusted owner list. */
|
|
183
|
+
export function sanitizeOwnerRoles(value) {
|
|
184
|
+
if (!Array.isArray(value))
|
|
185
|
+
return [];
|
|
186
|
+
const roles = new Set();
|
|
187
|
+
for (const entry of value)
|
|
188
|
+
if (isDisplayableOwnerRole(entry))
|
|
189
|
+
roles.add(entry);
|
|
190
|
+
return [...roles]
|
|
191
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
192
|
+
.slice(0, WORKER_DATABASE_DOCTOR_OWNER_ROLE_LIMIT);
|
|
193
|
+
}
|
|
194
|
+
/** Exact owner total when it is a safe integer no smaller than the displayed list; otherwise the list length. */
|
|
195
|
+
export function sanitizeOwnerRoleTotal(value, displayed) {
|
|
196
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= displayed ? value : displayed;
|
|
197
|
+
}
|
|
198
|
+
/** `postgres, ci_owner (+1 more)` — validated roles only. */
|
|
199
|
+
export function formatOwnerRoles(roles, total) {
|
|
200
|
+
const more = total - roles.length;
|
|
201
|
+
return roles.join(", ") + (more > 0 ? ` (+${more} more)` : "");
|
|
202
|
+
}
|
|
203
|
+
function safeMigrationCause(value) {
|
|
204
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(MIGRATION_CAUSE_LABELS, value)
|
|
205
|
+
? value
|
|
206
|
+
: undefined;
|
|
207
|
+
}
|
|
165
208
|
const ROW_STATES = new Set(["healthy", "unsafe", "unknown"]);
|
|
166
209
|
const RETAIN_REASONS = new Set([
|
|
167
210
|
"owner_alive",
|
|
@@ -254,13 +297,19 @@ function boundaryRow(boundary) {
|
|
|
254
297
|
return makeRow("worker-db-boundary", "bridgeapi boundary", state, detail);
|
|
255
298
|
}
|
|
256
299
|
function alembicRow(alembic) {
|
|
257
|
-
const
|
|
300
|
+
const a = (alembic ?? {});
|
|
301
|
+
const state = safeState(a.state);
|
|
302
|
+
// A cause is meaningful only on an unsafe result; it is dropped everywhere else.
|
|
303
|
+
const cause = state === "unsafe" ? safeMigrationCause(a.cause) : undefined;
|
|
258
304
|
const detail = state === "healthy"
|
|
259
|
-
? "the operator checkout
|
|
305
|
+
? "the operator checkout has one migration head and renders base:head offline " +
|
|
306
|
+
"(no live database connection, object permission, or worker-branch check)"
|
|
260
307
|
: state === "unsafe"
|
|
261
|
-
?
|
|
262
|
-
|
|
263
|
-
|
|
308
|
+
? cause
|
|
309
|
+
? `the operator checkout's offline migration check failed: ${MIGRATION_CAUSE_LABELS[cause]} (cause: ${cause})`
|
|
310
|
+
: "the operator checkout's .venv Alembic is missing"
|
|
311
|
+
: "unknown — the operator checkout's offline migration check could not be completed";
|
|
312
|
+
return { ...makeRow("worker-db-alembic", "operator-checkout Alembic", state, detail), ...(cause ? { cause } : {}) };
|
|
264
313
|
}
|
|
265
314
|
function safeNameList(value, redacted) {
|
|
266
315
|
if (!Array.isArray(value))
|
|
@@ -284,7 +333,7 @@ function sanitizeInventory(inventory) {
|
|
|
284
333
|
!Array.isArray(value.leftovers) ||
|
|
285
334
|
!Array.isArray(value.unverifiable) ||
|
|
286
335
|
typeof value.harnessCount !== "number" ||
|
|
287
|
-
!Number.
|
|
336
|
+
!Number.isSafeInteger(value.harnessCount) ||
|
|
288
337
|
value.harnessCount < 0) {
|
|
289
338
|
return { state: "unknown" };
|
|
290
339
|
}
|
|
@@ -303,15 +352,37 @@ function sanitizeInventory(inventory) {
|
|
|
303
352
|
: "unrecognized";
|
|
304
353
|
unverifiable.push({ name: e.name, reason });
|
|
305
354
|
}
|
|
355
|
+
const harnessOwners = sanitizeOwnerRoles(value.harnessOwners);
|
|
306
356
|
return {
|
|
307
357
|
state: "known",
|
|
308
358
|
active,
|
|
309
359
|
leftovers,
|
|
310
360
|
unverifiable,
|
|
311
361
|
harness_count: value.harnessCount,
|
|
362
|
+
...(sanitizeHarnessCoverage(value.harnessCoverage, value.harnessCount)
|
|
363
|
+
? { harness_coverage: sanitizeHarnessCoverage(value.harnessCoverage, value.harnessCount) } : {}),
|
|
364
|
+
harness_owners: harnessOwners,
|
|
365
|
+
harness_owner_total: sanitizeOwnerRoleTotal(value.harnessOwnerCount, harnessOwners.length),
|
|
312
366
|
redacted_count: redacted.count,
|
|
313
367
|
};
|
|
314
368
|
}
|
|
369
|
+
function harnessRow(inventory) {
|
|
370
|
+
const healthy = inventory.harness_count === 0;
|
|
371
|
+
const owners = healthy ? [] : inventory.harness_owners;
|
|
372
|
+
const coverage = inventory.harness_coverage;
|
|
373
|
+
const coverageClause = coverage?.activity === "known"
|
|
374
|
+
? `; ${coverage.covered} in use or CI-owned; ${coverage.uncovered} uncovered; activity known ` +
|
|
375
|
+
`(overlapping categories: ${coverage.inUse} in use, ${coverage.ciOwned} CI-owned)`
|
|
376
|
+
: "; activity unknown";
|
|
377
|
+
const ownerClause = owners.length > 0
|
|
378
|
+
? `; owners shown: ${formatOwnerRoles(owners, inventory.harness_owner_total)} — ` +
|
|
379
|
+
"drop as the owning role, not the CI role (see the harness reaper and owner-role guidance in the runbook)"
|
|
380
|
+
: "";
|
|
381
|
+
const row = makeRow("worker-db-harness", "conductor_harness databases", healthy ? "healthy" : "unsafe", `${inventory.harness_count} present (owned by the Python harness reaper; the executor never cleans them)` +
|
|
382
|
+
coverageClause + ownerClause);
|
|
383
|
+
return { ...row, ...(coverage ? { harness_coverage: coverage } : {}),
|
|
384
|
+
...(owners.length > 0 ? { owner_roles: owners, owner_role_total: inventory.harness_owner_total } : {}) };
|
|
385
|
+
}
|
|
315
386
|
function inventoryRows(inventory) {
|
|
316
387
|
if (inventory.state === "unknown") {
|
|
317
388
|
const detail = "unknown — the database inventory could not be read";
|
|
@@ -329,7 +400,7 @@ function inventoryRows(inventory) {
|
|
|
329
400
|
"(dead executor on this host; the next executor start sweeps them)"),
|
|
330
401
|
makeRow("worker-db-unverifiable", "unverifiable worker databases", unverifiableCount === 0 ? "healthy" : "unsafe", `${unverifiableCount} with unreadable, malformed, foreign-host, or unknown ownership ` +
|
|
331
402
|
"(left in place; review manually)"),
|
|
332
|
-
|
|
403
|
+
harnessRow(inventory),
|
|
333
404
|
];
|
|
334
405
|
}
|
|
335
406
|
/** Project a (possibly hostile or malformed) inspection into the sanitized advisory section. */
|
|
@@ -430,7 +501,7 @@ export function formatWorkerDatabaseDoctorSection(section) {
|
|
|
430
501
|
* therefore resolve credentials themselves (CLAUDE.md "Shell-Spawned Credential
|
|
431
502
|
* Resolution"): the four BAPI-872 recovery verbs, the six run-addressed repair
|
|
432
503
|
* verbs (BAPI-1154's three and BAPI-1176's three), and BAPI-1300's parked-child
|
|
433
|
-
* continuation pair
|
|
504
|
+
* continuation pair, and BAPI-1557's `prerequisite-inputs`. `.mcp.json` env is invisible to
|
|
434
505
|
* them — only `BAPI_API_KEY` in the parent env and the user-scoped credential
|
|
435
506
|
* store count.
|
|
436
507
|
*/
|
|
@@ -450,6 +521,8 @@ export const CREDENTIALED_RECOVERY_COMMANDS = [
|
|
|
450
521
|
"continuation-receipt",
|
|
451
522
|
// BAPI-1469: the read-only bounded wait on a run's state.
|
|
452
523
|
"wait-run",
|
|
524
|
+
// BAPI-1557: reads stored tickets and writes private local scanner inputs.
|
|
525
|
+
"prerequisite-inputs",
|
|
453
526
|
];
|
|
454
527
|
/** Remediation for recovery/repair verbs that cannot resolve Bridge credentials. */
|
|
455
528
|
export const REPAIR_CREDENTIAL_REMEDIATION = "export BAPI_API_KEY in the shell that runs `conductor`, or store a credential for this " +
|
|
@@ -1449,7 +1522,8 @@ export const CONDUCTOR_LEDGER_REMEDIATION = "run `epic-implementer doctor` for t
|
|
|
1449
1522
|
"owner-only permissions; the ledger is local observability and never blocks a run.";
|
|
1450
1523
|
/** Remediation for degraded or missing managed git hooks. */
|
|
1451
1524
|
export const CONDUCTOR_GIT_HOOKS_REMEDIATION = "run `epic-implementer install-git-hooks` from a persistent install to install the managed post-commit and " +
|
|
1452
|
-
"reference-transaction hooks;
|
|
1525
|
+
"reference-transaction hooks; use `epic-implementer uninstall-git-hooks` for consented removal. " +
|
|
1526
|
+
"They are local, opportunistic, and bypassable, and never gate engine admission.";
|
|
1453
1527
|
/** Remediation for a Claude login this host cannot confirm. */
|
|
1454
1528
|
export const CONDUCTOR_CLAUDE_LOGIN_REMEDIATION = "run `claude login` on the host that will run conductor workers; Bridge stores no Anthropic " +
|
|
1455
1529
|
"credential and can only advise here.";
|
|
@@ -69,7 +69,7 @@ export function getConductorUsage() {
|
|
|
69
69
|
"Local append-only event ledger for multi-agent coordination, plus run-control",
|
|
70
70
|
"commands. The ledger commands talk ONLY to the local SQLite store",
|
|
71
71
|
"(~/.config/bridge/events.db); the run-control commands (stop-run through",
|
|
72
|
-
"
|
|
72
|
+
"acknowledge-gaps), epic-status, readiness, and the read-only wait-run call the Bridge API.",
|
|
73
73
|
"",
|
|
74
74
|
"Commands:",
|
|
75
75
|
" emit-event Append one semantic event to the ledger",
|
|
@@ -86,6 +86,7 @@ export function getConductorUsage() {
|
|
|
86
86
|
" Remediations are NOT run automatically; always exits 0.",
|
|
87
87
|
" purge Delete ALL ledger rows (events, messages, supervisor_projection)",
|
|
88
88
|
" install-git-hooks Install local, opportunistic, non-blocking git hooks",
|
|
89
|
+
" uninstall-git-hooks Remove Bridge-managed hook text [--dry-run]",
|
|
89
90
|
" git-hook post-commit Run the post-commit producer (invoked by the installed hook)",
|
|
90
91
|
" git-hook reference-transaction --phase <p> --stdin-file <f>",
|
|
91
92
|
" Run the reference-transaction producer (invoked by the hook)",
|
|
@@ -144,10 +145,21 @@ export function getConductorUsage() {
|
|
|
144
145
|
" Record the OWNER's decision on verification hand-offs (a human decision,",
|
|
145
146
|
" never automatic). Also remove .bridge/epic-workarounds/<KEY>.md in a new",
|
|
146
147
|
" epic-head commit: the PR leaves draft only when both holds are clear.",
|
|
147
|
-
"
|
|
148
|
+
" acknowledge-gaps --epic-run-id <id> --digest <CURRENT_DIGEST> --reason <text> [--json]",
|
|
149
|
+
" The OWNER's one acknowledgement of the run's carried-gap list, by its",
|
|
150
|
+
" current digest (from the PR report or explain-run). Never run by the",
|
|
151
|
+
" driver or a worker; it verifies, readies and merges nothing.",
|
|
152
|
+
" wait-run --epic-run-id <id> [--ticket-key <key>] [--since <token>] [--timeout <seconds>]",
|
|
153
|
+
" [--until change|attention] [--json]",
|
|
148
154
|
" Read-only: wait until the run's observable state changes, the run finishes,",
|
|
149
155
|
" or the window closes (default 110 s; values above 240 are clamped to 240).",
|
|
156
|
+
" --until attention wakes only when a new incident appears (a park, a",
|
|
157
|
+
" needs-human reason, a failed job, a paused/stopped or non-active run).",
|
|
150
158
|
" Pass the previous result's token as --since. Changes nothing.",
|
|
159
|
+
" prerequisite-inputs --epic-key <KEY> --child <KEY> [--child <KEY> ...] [--json]",
|
|
160
|
+
" Reads stored ticket descriptions and writes one private scanner input file per",
|
|
161
|
+
" child under ~/.local/state/bapi-conductor-runs/<EPIC>/. Changes nothing on",
|
|
162
|
+
" the server.",
|
|
151
163
|
"",
|
|
152
164
|
"supervise options:",
|
|
153
165
|
" --run-id <id> Run/session identifier to supervise (required)",
|
|
@@ -342,6 +354,7 @@ const VALID_COMMANDS = new Set([
|
|
|
342
354
|
"readiness",
|
|
343
355
|
"purge",
|
|
344
356
|
"install-git-hooks",
|
|
357
|
+
"uninstall-git-hooks",
|
|
345
358
|
"git-hook",
|
|
346
359
|
"file-scope-guard",
|
|
347
360
|
"likely-tests",
|
|
@@ -369,10 +382,14 @@ const VALID_COMMANDS = new Set([
|
|
|
369
382
|
"rerun-ci",
|
|
370
383
|
// BAPI-1494: CLI-only owner decision on verification hand-offs — never an MCP tool.
|
|
371
384
|
"resolve-handoff",
|
|
385
|
+
// BAPI-1562: CLI-only owner acknowledgement of the carried-gap list — never an MCP tool.
|
|
386
|
+
"acknowledge-gaps",
|
|
372
387
|
// BAPI-1532: CLI-only answer to a named plan failure — never an MCP tool.
|
|
373
388
|
"regenerate-plan",
|
|
374
389
|
// BAPI-1469: CLI-only read-only bounded wait on a run's state — never an MCP tool.
|
|
375
390
|
"wait-run",
|
|
391
|
+
// BAPI-1557: CLI-only stored-ticket reader and private local-state writer — never an MCP tool.
|
|
392
|
+
"prerequisite-inputs",
|
|
376
393
|
// Private, and deliberately ABSENT from the usage text: `__hook-bin` exists as
|
|
377
394
|
// the bundled-artifact regression guard for BAPI-772 (mirroring `plane
|
|
378
395
|
// __entrypoint`), not as a supported operator workflow.
|
|
@@ -1417,6 +1434,11 @@ export async function runPurgeCommand(argv) {
|
|
|
1417
1434
|
].join("\n"));
|
|
1418
1435
|
return 0;
|
|
1419
1436
|
}
|
|
1437
|
+
/** BAPI-1551 — the stderr note naming how many leading references are always-run guards. */
|
|
1438
|
+
export function likelyTestsRequiredNote(count) {
|
|
1439
|
+
return `The first ${count} references are this repository's always-run guards. ` +
|
|
1440
|
+
"Run them before you push, whatever you changed.";
|
|
1441
|
+
}
|
|
1420
1442
|
const LIKELY_TESTS_FAILURE_NOTE = "Likely-tests discovery unavailable: internal discovery failure (not an empty result).\n";
|
|
1421
1443
|
export async function runLikelyTestsCommand(argv, deps = {}) {
|
|
1422
1444
|
const stdout = deps.stdout ?? ((text) => { process.stdout.write(text); });
|
|
@@ -1445,6 +1467,11 @@ export async function runLikelyTestsCommand(argv, deps = {}) {
|
|
|
1445
1467
|
printed += 1;
|
|
1446
1468
|
}
|
|
1447
1469
|
}
|
|
1470
|
+
// BAPI-1551 — the always-run guards print first; say so on stderr only, so
|
|
1471
|
+
// stdout stays references and nothing else.
|
|
1472
|
+
const required = (result.required ?? []).filter(validTestReference).length;
|
|
1473
|
+
if (required > 0)
|
|
1474
|
+
stderr(likelyTestsRequiredNote(required) + "\n");
|
|
1448
1475
|
const failed = result.diagnostics.some(d => d === "git_unavailable" || d === "invalid_arguments");
|
|
1449
1476
|
for (const diagnostic of new Set(result.diagnostics)) {
|
|
1450
1477
|
if (diagnostic !== "empty")
|
|
@@ -1513,6 +1540,10 @@ export async function runEpicImplementerCli(argv, likelyTestsDeps) {
|
|
|
1513
1540
|
return await runPurgeCommand(parsed.argv);
|
|
1514
1541
|
case "install-git-hooks":
|
|
1515
1542
|
return runInstallGitHooksCommand(parsed.argv);
|
|
1543
|
+
case "uninstall-git-hooks": {
|
|
1544
|
+
const { runUninstallGitHooksCommand } = await import("./git-hooks-uninstall.js");
|
|
1545
|
+
return runUninstallGitHooksCommand(parsed.argv);
|
|
1546
|
+
}
|
|
1516
1547
|
case "git-hook":
|
|
1517
1548
|
return await runGitHookCommand(parsed.argv);
|
|
1518
1549
|
case CONDUCTOR_HOOK_BIN_ACTION:
|
|
@@ -1605,6 +1636,11 @@ export async function runEpicImplementerCli(argv, likelyTestsDeps) {
|
|
|
1605
1636
|
const { runResolveHandoffCommand } = await import("./recovery-cli.js");
|
|
1606
1637
|
return await runResolveHandoffCommand(parsed.argv);
|
|
1607
1638
|
}
|
|
1639
|
+
case "acknowledge-gaps": {
|
|
1640
|
+
// BAPI-1562: delegates only to the owner's list acknowledgement.
|
|
1641
|
+
const { runAcknowledgeGapsCommand } = await import("./recovery-cli.js");
|
|
1642
|
+
return await runAcknowledgeGapsCommand(parsed.argv);
|
|
1643
|
+
}
|
|
1608
1644
|
case "regenerate-plan": {
|
|
1609
1645
|
// BAPI-1532: delegates only to the pinned plan-regeneration operation.
|
|
1610
1646
|
const { runRegeneratePlanCommand } = await import("./recovery-cli.js");
|
|
@@ -1623,6 +1659,19 @@ export async function runEpicImplementerCli(argv, likelyTestsDeps) {
|
|
|
1623
1659
|
}
|
|
1624
1660
|
return await runWaitRunCommand(parsed.argv);
|
|
1625
1661
|
}
|
|
1662
|
+
case "prerequisite-inputs": {
|
|
1663
|
+
// BAPI-1557: dispatched before any MCP server is built or connected. A
|
|
1664
|
+
// module-load failure gets fixed wording, never exception text.
|
|
1665
|
+
let runPrerequisiteInputsCommand;
|
|
1666
|
+
try {
|
|
1667
|
+
({ runPrerequisiteInputsCommand } = await import("./prerequisite-inputs.js"));
|
|
1668
|
+
}
|
|
1669
|
+
catch {
|
|
1670
|
+
console.error("Error: prerequisite-inputs could not be loaded; no scanner input was written.");
|
|
1671
|
+
return 1;
|
|
1672
|
+
}
|
|
1673
|
+
return await runPrerequisiteInputsCommand(parsed.argv);
|
|
1674
|
+
}
|
|
1626
1675
|
default:
|
|
1627
1676
|
console.error('Error: Unknown command. Run "epic-implementer --help" for usage.');
|
|
1628
1677
|
return 1;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { describeCheckEvidence } from "../check-evidence.js";
|
|
1
2
|
/**
|
|
2
3
|
* Deterministic, read-only CI gate discovery (BAPI-1391).
|
|
3
4
|
*
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
import fs from "node:fs/promises";
|
|
57
58
|
import path from "node:path";
|
|
58
59
|
import { LEGACY_EPIC_IMPLEMENTER_NODE_PATH_ENV } from "../epic-implementer-env.js";
|
|
60
|
+
import { TOOLCHAIN_CONTENT_FILES, installArgvForJavaScript, installArgvForPython, resolveRepositoryToolchains, } from "../repository-toolchains.js";
|
|
59
61
|
// ---------------------------------------------------------------------------
|
|
60
62
|
// Bounds and fixed vocabularies
|
|
61
63
|
// ---------------------------------------------------------------------------
|
|
@@ -75,7 +77,9 @@ export const JENKINS_LOOKUP_NAMES = [
|
|
|
75
77
|
"continuous-integration/jenkins/pr-merge",
|
|
76
78
|
];
|
|
77
79
|
/** The script body `npm init` writes; it is a placeholder, not a test command. */
|
|
78
|
-
export
|
|
80
|
+
export { NPM_PLACEHOLDER_TEST_SCRIPT } from "../package-script-semantics.js";
|
|
81
|
+
import { isUsablePackageScript } from "../package-script-semantics.js";
|
|
82
|
+
export { isUsablePackageScript };
|
|
79
83
|
/** BAPI-1520 — at most this many worker-variable names are proposed. */
|
|
80
84
|
export const MAX_WORKER_ENV_CANDIDATES = 32;
|
|
81
85
|
/** BAPI-1520 — the longest value, in UTF-8 bytes, that may be proposed. */
|
|
@@ -920,12 +924,6 @@ export function packageScriptArgv(pm, script) {
|
|
|
920
924
|
return [pm, "run", script];
|
|
921
925
|
}
|
|
922
926
|
/** True when a package.json script value is a usable command (not empty, not the npm placeholder). */
|
|
923
|
-
export function isUsablePackageScript(value) {
|
|
924
|
-
if (typeof value !== "string")
|
|
925
|
-
return false;
|
|
926
|
-
const trimmed = value.trim();
|
|
927
|
-
return trimmed !== "" && trimmed !== NPM_PLACEHOLDER_TEST_SCRIPT;
|
|
928
|
-
}
|
|
929
927
|
/** True when `name` is a valid local command name. */
|
|
930
928
|
export function isGateCommandName(name) {
|
|
931
929
|
return GATE_COMMAND_NAME_PATTERN.test(name);
|
|
@@ -1029,6 +1027,96 @@ function jobDetail(job) {
|
|
|
1029
1027
|
detail += ` (name may vary: ${VARIANCE_TEXT[job.variance]})`;
|
|
1030
1028
|
return detail;
|
|
1031
1029
|
}
|
|
1030
|
+
/** Environment names whose literal value shows that CI provides a database. */
|
|
1031
|
+
const CI_DATABASE_ENV_NAME = /^(?:DATABASE_URL|POSTGRES_[A-Z0-9_]+|PG[A-Z0-9_]+)$/;
|
|
1032
|
+
/** BAPI-1551 — classify one readable workflow file's database evidence. */
|
|
1033
|
+
function workflowDatabaseEvidence(text, jobsReadable) {
|
|
1034
|
+
const lines = significantLines(text);
|
|
1035
|
+
const hasServices = lines.some((l) => l.indent > 0 && splitKeyLine(l.text)?.key === "services");
|
|
1036
|
+
const env = scanEnvMaps(text, "github");
|
|
1037
|
+
const databaseNames = env.declarations.filter((d) => CI_DATABASE_ENV_NAME.test(d.name));
|
|
1038
|
+
if (hasServices || databaseNames.some((d) => d.value !== null))
|
|
1039
|
+
return "present";
|
|
1040
|
+
// A database name with a non-literal value (an expression, a number) cannot
|
|
1041
|
+
// prove absence, and neither can an env map or a jobs block that was unclear.
|
|
1042
|
+
if (!jobsReadable || env.unclear || databaseNames.length > 0)
|
|
1043
|
+
return "unclear";
|
|
1044
|
+
return "absent";
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* BAPI-1551 — the `ci_database` proposal from the workflow files that hold a job
|
|
1048
|
+
* reporting one of `providerChecks`. `provided` wins when any such file has
|
|
1049
|
+
* definite evidence; `none` needs every reported check mapped to a workflow file
|
|
1050
|
+
* and every such file clearly without a database; anything else is `unknown`.
|
|
1051
|
+
*/
|
|
1052
|
+
export function proposeCiDatabase(providerChecks, workflowFiles) {
|
|
1053
|
+
if (providerChecks.length === 0)
|
|
1054
|
+
return { value: "unknown", sources: [] };
|
|
1055
|
+
const relevant = workflowFiles.filter((f) => f.reportedNames.some((n) => providerChecks.includes(n)));
|
|
1056
|
+
const sources = relevant.map((f) => f.source);
|
|
1057
|
+
if (relevant.some((f) => f.database === "present")) {
|
|
1058
|
+
return { value: "provided", sources: relevant.filter((f) => f.database === "present").map((f) => f.source) };
|
|
1059
|
+
}
|
|
1060
|
+
const allMapped = providerChecks.every((check) => relevant.some((f) => f.reportedNames.includes(check)));
|
|
1061
|
+
// A workflow file whose jobs could not be named might report a check too.
|
|
1062
|
+
const unnamedFiles = workflowFiles.some((f) => !f.jobsReadable);
|
|
1063
|
+
if (relevant.length === 0 || !allMapped || unnamedFiles || relevant.some((f) => f.database !== "absent")) {
|
|
1064
|
+
return { value: "unknown", sources };
|
|
1065
|
+
}
|
|
1066
|
+
return { value: "none", sources };
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* BAPI-1551 — read the toolchain resolver's files through the bounded discovery
|
|
1070
|
+
* seam. The seam answers `null` for an absent, unreadable, or over-size file, so
|
|
1071
|
+
* `exists` tells them apart: a file that exists but cannot be read throws a
|
|
1072
|
+
* non-missing error (the resolver then reports `unknown`), except a file the
|
|
1073
|
+
* resolver checks only for existence, which reads as present.
|
|
1074
|
+
*/
|
|
1075
|
+
function toolchainReader(fsSeam) {
|
|
1076
|
+
return async (relPath) => {
|
|
1077
|
+
const text = await readBounded(fsSeam, relPath);
|
|
1078
|
+
if (text !== null)
|
|
1079
|
+
return text;
|
|
1080
|
+
if (!(await fsSeam.exists(relPath))) {
|
|
1081
|
+
throw Object.assign(new Error("absent"), { code: "ENOENT" });
|
|
1082
|
+
}
|
|
1083
|
+
if (!TOOLCHAIN_CONTENT_FILES.includes(relPath))
|
|
1084
|
+
return "";
|
|
1085
|
+
throw Object.assign(new Error("unreadable"), { code: "EIO" });
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
/** BAPI-1551 — the root dependency-refresh proposals and the notes on what was left out. */
|
|
1089
|
+
export async function proposeDependencyInstall(fsSeam) {
|
|
1090
|
+
let resolution;
|
|
1091
|
+
try {
|
|
1092
|
+
resolution = await resolveRepositoryToolchains(toolchainReader(fsSeam));
|
|
1093
|
+
}
|
|
1094
|
+
catch {
|
|
1095
|
+
return { candidates: [], notes: ["dependency_install_toolchain_unresolved"] };
|
|
1096
|
+
}
|
|
1097
|
+
if (resolution.status !== "resolved") {
|
|
1098
|
+
return { candidates: [], notes: ["dependency_install_toolchain_unresolved"] };
|
|
1099
|
+
}
|
|
1100
|
+
const candidates = [];
|
|
1101
|
+
const notes = [];
|
|
1102
|
+
const js = resolution.toolchains.javascript;
|
|
1103
|
+
if (js !== null) {
|
|
1104
|
+
candidates.push({
|
|
1105
|
+
cwd: ".",
|
|
1106
|
+
argv: installArgvForJavaScript(js),
|
|
1107
|
+
lockfiles: [js.dependencyFile],
|
|
1108
|
+
label: js.manager === "yarn" ? `yarn (${js.generation})` : js.manager,
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
const py = resolution.toolchains.python;
|
|
1112
|
+
if (py !== null) {
|
|
1113
|
+
if (py.manager === "pip")
|
|
1114
|
+
notes.push("dependency_install_pip_not_proposed");
|
|
1115
|
+
else
|
|
1116
|
+
candidates.push({ cwd: ".", argv: installArgvForPython(py), lockfiles: [py.dependencyFile], label: py.manager });
|
|
1117
|
+
}
|
|
1118
|
+
return { candidates, notes };
|
|
1119
|
+
}
|
|
1032
1120
|
async function collectWorkflows(fsSeam, evidence, lookups, extras) {
|
|
1033
1121
|
const entries = await fsSeam.listDir(WORKFLOWS_DIR);
|
|
1034
1122
|
if (entries === null)
|
|
@@ -1040,9 +1128,19 @@ async function collectWorkflows(fsSeam, evidence, lookups, extras) {
|
|
|
1040
1128
|
for (const file of files) {
|
|
1041
1129
|
const source = `${WORKFLOWS_DIR}/${file}`;
|
|
1042
1130
|
const text = await readBounded(fsSeam, source);
|
|
1043
|
-
if (text === null)
|
|
1131
|
+
if (text === null) {
|
|
1132
|
+
// BAPI-1551: an unreadable workflow file can neither prove nor rule out a database.
|
|
1133
|
+
extras.workflowFiles.push({ source, reportedNames: [], jobsReadable: false, database: "unclear" });
|
|
1044
1134
|
continue;
|
|
1135
|
+
}
|
|
1045
1136
|
const scan = scanWorkflowJobs(text, { structure: true });
|
|
1137
|
+
const facts = {
|
|
1138
|
+
source,
|
|
1139
|
+
reportedNames: [],
|
|
1140
|
+
jobsReadable: scan.jobs.length > 0,
|
|
1141
|
+
database: workflowDatabaseEvidence(text, scan.jobs.length > 0),
|
|
1142
|
+
};
|
|
1143
|
+
extras.workflowFiles.push(facts);
|
|
1046
1144
|
for (const declaration of scanEnvMaps(text, "github").declarations) {
|
|
1047
1145
|
extras.envObservations.push({ source, declaration });
|
|
1048
1146
|
}
|
|
@@ -1067,6 +1165,7 @@ async function collectWorkflows(fsSeam, evidence, lookups, extras) {
|
|
|
1067
1165
|
};
|
|
1068
1166
|
evidence.push(e);
|
|
1069
1167
|
if (reported !== null) {
|
|
1168
|
+
facts.reportedNames.push(reported);
|
|
1070
1169
|
lookups.add(reported, e);
|
|
1071
1170
|
if (job.structure) {
|
|
1072
1171
|
const jobs = extras.hintJobs.get(reported) ?? [];
|
|
@@ -1288,7 +1387,7 @@ export async function discoverGate(input) {
|
|
|
1288
1387
|
const evidence = [];
|
|
1289
1388
|
const localCandidates = [];
|
|
1290
1389
|
const lookups = new LookupNames();
|
|
1291
|
-
const extras = { envObservations: [], hintJobs: new Map() };
|
|
1390
|
+
const extras = { envObservations: [], hintJobs: new Map(), workflowFiles: [] };
|
|
1292
1391
|
await collectWorkflows(fsSeam, evidence, lookups, extras);
|
|
1293
1392
|
await collectCircleCi(fsSeam, evidence, lookups, extras);
|
|
1294
1393
|
await collectOtherProviders(fsSeam, evidence, lookups);
|
|
@@ -1306,7 +1405,8 @@ export async function discoverGate(input) {
|
|
|
1306
1405
|
// When history is not `available`, no outcome is trusted, even one the response carried.
|
|
1307
1406
|
const outcome = history.status === "available" ? outcomeFor(outcomes, entry.name) : null;
|
|
1308
1407
|
if (outcome === "reported") {
|
|
1309
|
-
providerCandidates.push({ name: entry.name, outcome, confidence: "high", evidence: entry.evidence
|
|
1408
|
+
providerCandidates.push({ name: entry.name, outcome, confidence: "high", evidence: entry.evidence,
|
|
1409
|
+
checkEvidence: describeCheckEvidence(entry.name, "reported", "provider history") });
|
|
1310
1410
|
}
|
|
1311
1411
|
else {
|
|
1312
1412
|
unreportedProviderNames.push({
|
|
@@ -1326,6 +1426,7 @@ export async function discoverGate(input) {
|
|
|
1326
1426
|
const localCommandIds = providerChecks.length > 0 ? [] : validLocal.filter((c) => c.confidence === "high").map((c) => c.id);
|
|
1327
1427
|
const workerEnv = resolveWorkerEnv(extras.envObservations);
|
|
1328
1428
|
const hints = await proposeReproductionHints(fsSeam, providerChecks, extras.hintJobs);
|
|
1429
|
+
const dependencyInstall = await proposeDependencyInstall(fsSeam);
|
|
1329
1430
|
return {
|
|
1330
1431
|
providerCandidates,
|
|
1331
1432
|
unreportedProviderNames,
|
|
@@ -1340,6 +1441,31 @@ export async function discoverGate(input) {
|
|
|
1340
1441
|
workerEnvOverflow: workerEnv.overflow,
|
|
1341
1442
|
reproductionHints: hints.proposed,
|
|
1342
1443
|
reproductionHintsSkipped: hints.skipped,
|
|
1444
|
+
...declarationFields(dependencyInstall, proposeCiDatabase(providerChecks, extras.workflowFiles)),
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* BAPI-1551 — only the declaration proposals, for a repository whose gate is
|
|
1449
|
+
* already confirmed: the root dependency refreshes, and the CI-database value
|
|
1450
|
+
* read from the workflow files that report one of the CONFIRMED provider checks.
|
|
1451
|
+
* Makes no provider-history call.
|
|
1452
|
+
*/
|
|
1453
|
+
export async function discoverDeclarations(input) {
|
|
1454
|
+
const extras = { envObservations: [], hintJobs: new Map(), workflowFiles: [] };
|
|
1455
|
+
await collectWorkflows(input.fs, [], new LookupNames(), extras);
|
|
1456
|
+
const dependencyInstall = await proposeDependencyInstall(input.fs);
|
|
1457
|
+
return declarationFields(dependencyInstall, proposeCiDatabase(input.providerChecks, extras.workflowFiles));
|
|
1458
|
+
}
|
|
1459
|
+
/**
|
|
1460
|
+
* BAPI-1551 — the declaration fields of a proposal. Each is present only when it
|
|
1461
|
+
* says something (a candidate, a note, or a value other than `unknown`), so a
|
|
1462
|
+
* repository with nothing to propose yields exactly the pre-BAPI-1551 proposal.
|
|
1463
|
+
*/
|
|
1464
|
+
function declarationFields(dependencyInstall, ciDatabase) {
|
|
1465
|
+
return {
|
|
1466
|
+
...(dependencyInstall.candidates.length > 0 ? { dependencyInstallCandidates: dependencyInstall.candidates } : {}),
|
|
1467
|
+
...(dependencyInstall.notes.length > 0 ? { dependencyInstallNotes: dependencyInstall.notes } : {}),
|
|
1468
|
+
...(ciDatabase.value !== "unknown" ? { ciDatabaseProposal: ciDatabase } : {}),
|
|
1343
1469
|
};
|
|
1344
1470
|
}
|
|
1345
1471
|
/**
|