@bridge_gpt/mcp-server 0.2.70 → 0.2.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +5 -5
  2. package/build/agent-launchers/claude-executor-adapter.js +10 -1
  3. package/build/agent-registry.js +5 -5
  4. package/build/agents.generated.js +11 -1
  5. package/build/bounded-wait.js +9 -1
  6. package/build/bridge-permissions.js +13 -5
  7. package/build/commands.generated.js +3 -3
  8. package/build/conductor/bridge-api-client.js +260 -2
  9. package/build/conductor/command-drift-production.js +7 -2
  10. package/build/conductor/doctor.js +9 -3
  11. package/build/conductor/epic-implementer-cli.js +4 -0
  12. package/build/conductor/gate-discovery.js +524 -10
  13. package/build/conductor/gate-settings-review.js +451 -0
  14. package/build/conductor/launch-need-probes.js +16 -11
  15. package/build/conductor/launch-plan.js +145 -0
  16. package/build/conductor/precheck-timings.js +14 -0
  17. package/build/conductor/preview-observations.js +10 -0
  18. package/build/conductor/readiness-sections.js +4 -1
  19. package/build/conductor/recovery-cli.js +59 -2
  20. package/build/conductor/recovery-operations.js +45 -2
  21. package/build/docs.generated.js +1 -1
  22. package/build/drive-epic.js +188 -45
  23. package/build/epic-ci-workflow-drift.js +71 -23
  24. package/build/epic-ci-workflow-install.js +83 -26
  25. package/build/epic-ci-workflow-v1.js +132 -0
  26. package/build/epic-ci-workflow.js +174 -13
  27. package/build/epic-implementer-bin.js +18 -18
  28. package/build/executor/ci-rerun-job.js +220 -14
  29. package/build/executor/env.js +207 -3
  30. package/build/executor/gate-qualification-job.js +20 -5
  31. package/build/executor/job-runner.js +112 -11
  32. package/build/executor/likely-tests.js +6 -1
  33. package/build/executor/preflight.js +5 -0
  34. package/build/executor/process-containment.js +18 -0
  35. package/build/executor/prompt-spec.js +72 -13
  36. package/build/executor/reconcile-overlap-job.js +6 -1
  37. package/build/executor/worker-command.js +136 -1
  38. package/build/executor/worker-database.js +30 -11
  39. package/build/executor/worker-resources.js +12 -1
  40. package/build/executor/worker-verification-guidance.js +29 -0
  41. package/build/index.js +221 -165
  42. package/build/install-bridge-conductor-gate.js +195 -14
  43. package/build/install-bridge-conductor-setup.js +20 -6
  44. package/build/install-bridge-conductor.js +355 -37
  45. package/build/install-bridge.js +1 -1
  46. package/build/merge-workflow-install.js +20 -0
  47. package/build/pipelines.generated.js +2 -2
  48. package/build/plan-execution-ledger.js +23 -8
  49. package/build/plane/plane-freshness.js +6 -2
  50. package/build/plane/preflight.js +19 -0
  51. package/build/printed-remedy-commands.js +8 -1
  52. package/build/readme.generated.js +1 -1
  53. package/build/repository-toolchains.js +581 -0
  54. package/build/setup-epic.js +24 -7
  55. package/build/test-command-detection.js +58 -21
  56. package/build/ticket-delivery-artifacts.js +7 -0
  57. package/build/ticket-delivery-enrollment.js +67 -4
  58. package/build/version.generated.js +3 -3
  59. package/docs/EPIC-IMPLEMENTER.md +38 -0
  60. package/docs/epic-implementer/getting-started.md +58 -2
  61. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { monotonicNow, elapsedMs } from "../conductor/precheck-timings.js";
1
2
  /**
2
3
  * Disposable worker database lifecycle (BAPI-1479).
3
4
  *
@@ -22,8 +23,8 @@ import { constants as fsConstants } from "node:fs";
22
23
  import { access, mkdir } from "node:fs/promises";
23
24
  import path from "node:path";
24
25
  import { parseAlembicRevisions, resolveRepositoryAlembicCommand } from "../plane/alembic-head.js";
25
- import { CI_WORKER_ENV_CONSTANTS } from "./env.js";
26
- import { POSTGRES_IDENTIFIER_MAX_LENGTH, WORKER_DATABASE_HOST, WORKER_DATABASE_PORT, WORKER_DATABASE_PREFIX, WORKER_DATABASE_ROLE, buildWorkerDatabaseEnv, isValidWorkerDatabaseName, validateWorkerDatabaseName, } from "./worker-database-target.js";
26
+ import { buildExecutorBaseWorkerEnv, hasWorkerEnvOption } from "./env.js";
27
+ import { POSTGRES_IDENTIFIER_MAX_LENGTH, WORKER_DATABASE_HOST, WORKER_DATABASE_PORT, WORKER_DATABASE_PREFIX, WORKER_DATABASE_ROLE, isValidWorkerDatabaseName, validateWorkerDatabaseName, } from "./worker-database-target.js";
27
28
  /** Runbook section every worker-database diagnostic points the host operator to. */
28
29
  export const WORKER_DATABASE_RUNBOOK_SECTION = "docs/claude/runbooks/local-db-safety.md#worker-databases";
29
30
  export const WORKER_DATABASE_PROVISION_BUDGET_MS = 120_000;
@@ -587,13 +588,20 @@ async function guardedDropWorkerDatabase(name, deps, budgetMs, signal) {
587
588
  function alembicFailureCategory(ctx, r) {
588
589
  return interruption(ctx, r) ?? (r.timedOut ? "timeout" : "migration_failed");
589
590
  }
590
- function buildAlembicEnv(name, deps) {
591
- return {
592
- ...CI_WORKER_ENV_CONSTANTS,
593
- ...buildWorkerDatabaseEnv({ name }),
594
- PATH: deps.clientPath,
595
- HOME: deps.clientHome,
596
- };
591
+ /**
592
+ * The migration subprocess environment. BAPI-1521: delegated to the shared
593
+ * builder so the compatibility-versus-declaration choice, and the declaration
594
+ * rules, are the worker's own. The database target keys stay executor-owned (a
595
+ * declaration can never name them), and only `PATH`/`HOME` are taken from the
596
+ * client environment, as before.
597
+ */
598
+ function buildAlembicEnv(name, deps, workerEnvOption) {
599
+ const env = buildExecutorBaseWorkerEnv({ PATH: deps.clientPath, HOME: deps.clientHome }, { workerDatabase: { name }, legacyNotice: false, ...workerEnvOption });
600
+ // Two worker-only switches the shared builder always sets; a migration never
601
+ // needed them, and provisioning behavior is unchanged.
602
+ delete env.BRIDGE_SKIP_PREPUSH;
603
+ delete env.MAX_MCP_OUTPUT_TOKENS;
604
+ return env;
597
605
  }
598
606
  /**
599
607
  * Verify the worker role and the `bridgeapi` boundary, create and comment a
@@ -679,7 +687,7 @@ export async function provisionWorkerDatabase(options, deps) {
679
687
  if (!succeeded(commented))
680
688
  return rollback(name, interruption(ctx, commented) ?? "create_failed");
681
689
  // (d) migrate with the job worktree's migrations, then verify the head.
682
- const env = buildAlembicEnv(name, deps);
690
+ const env = buildAlembicEnv(name, deps, hasWorkerEnvOption(options) ? { workerEnv: options.workerEnv } : {});
683
691
  const runAlembic = (args) => deps.runProcess({
684
692
  file: alembic,
685
693
  args,
@@ -820,13 +828,17 @@ export async function inspectWorkerDatabaseReadiness(options, deps) {
820
828
  signal: options.signal,
821
829
  deadline: deps.now() + Math.max(1, options.budgetMs ?? WORKER_DATABASE_SWEEP_BUDGET_MS),
822
830
  };
831
+ const timings = {};
832
+ let started = monotonicNow();
823
833
  const roleOutcome = await checkWorkerRole(ctx);
834
+ timings["worker-db-role"] = elapsedMs(started);
824
835
  const role = roleOutcome.kind === "ok"
825
836
  ? { state: "healthy" }
826
837
  : { state: roleOutcome.kind === "unsafe" ? "unsafe" : "unknown", category: roleOutcome.category };
827
838
  // The boundary probe is meaningful only once the maintenance connection worked
828
839
  // (a role row came back, healthy or not).
829
840
  const maintenanceConnected = roleOutcome.kind === "ok" || (roleOutcome.kind === "unsafe" && roleOutcome.category === "role_misconfigured");
841
+ started = monotonicNow();
830
842
  let boundary;
831
843
  if (!maintenanceConnected) {
832
844
  boundary = { state: "unknown", category: "boundary_unknown" };
@@ -838,6 +850,8 @@ export async function inspectWorkerDatabaseReadiness(options, deps) {
838
850
  ? { state: "healthy" }
839
851
  : { state: b.kind === "unsafe" ? "unsafe" : "unknown", category: b.category };
840
852
  }
853
+ timings["worker-db-boundary"] = elapsedMs(started);
854
+ started = monotonicNow();
841
855
  let alembic;
842
856
  try {
843
857
  const exists = await deps.isExecutable(resolveRepositoryAlembicCommand(options.operatorRepositoryRoot, deps.platform));
@@ -846,6 +860,8 @@ export async function inspectWorkerDatabaseReadiness(options, deps) {
846
860
  catch {
847
861
  alembic = { state: "unknown" };
848
862
  }
863
+ timings["worker-db-alembic"] = elapsedMs(started);
864
+ started = monotonicNow();
849
865
  let inventory = { state: "unknown" };
850
866
  const listing = await listWorkerDatabases(ctx);
851
867
  if (listing.kind === "ok") {
@@ -875,7 +891,10 @@ export async function inspectWorkerDatabaseReadiness(options, deps) {
875
891
  inventory = { state: "known", value };
876
892
  }
877
893
  }
878
- return { role, boundary, alembic, inventory };
894
+ const inventoryMs = elapsedMs(started);
895
+ for (const id of ["worker-db-leftovers", "worker-db-unverifiable", "worker-db-harness"])
896
+ timings[id] = inventoryMs;
897
+ return { role, boundary, alembic, inventory, timings };
879
898
  }
880
899
  // ---------------------------------------------------------------------------
881
900
  // Diagnostics
@@ -39,7 +39,18 @@ export function createProductionWorkerResources(input) {
39
39
  let launcherDeps;
40
40
  const cliDeps = () => (launcherDeps ??= createDefaultWorkerCliLauncherDeps({ stateDir }));
41
41
  return {
42
- provisionDatabase: ({ jobId, worktreePath, signal }) => provisionWorkerDatabase({ jobId, operatorRepositoryRoot: input.cwd, worktreePath, executorPid, hostDigest, signal }, dbDeps()),
42
+ provisionDatabase: (request) => provisionWorkerDatabase({
43
+ jobId: request.jobId,
44
+ operatorRepositoryRoot: input.cwd,
45
+ worktreePath: request.worktreePath,
46
+ executorPid,
47
+ hostDigest,
48
+ signal: request.signal,
49
+ // BAPI-1521 — forwarded only when the request owns it, so absence survives.
50
+ ...(Object.prototype.hasOwnProperty.call(request, "workerEnv")
51
+ ? { workerEnv: request.workerEnv }
52
+ : {}),
53
+ }, dbDeps()),
43
54
  dropDatabase: (target) => dropWorkerDatabase(target, dbDeps()),
44
55
  createLauncher: ({ jobId }) => createWorkerCliLauncher({ jobId }, cliDeps()),
45
56
  sweepOrphanedDatabases: (signal) => sweepOrphanedWorkerDatabases({ hostDigest, executorPid, signal }, dbDeps()),
@@ -36,6 +36,35 @@ export function renderWorkerTimeBudgetGuidance(timeoutSeconds) {
36
36
  "Local verification must leave room for commit, push, the single renewal pass, and `.conductor/result.json`. " +
37
37
  "Do not start a verification command that cannot finish within the remaining budget.";
38
38
  }
39
+ /**
40
+ * BAPI-1533: the compact test-invocation rule a PUSHING continuation worker gets
41
+ * beside the push and commit guidance. It mirrors the launch instruction and the
42
+ * remediate prompt, so every remaining-work lane states the same rule. Literal
43
+ * plain text with no obligation identifier, and independent of the optional
44
+ * trusted comparison context. Overlap reconciliation never gets it.
45
+ *
46
+ * Compatibility: a new server carries its `Remaining plan steps` block in
47
+ * `payload.prompt`, which the resolver already renders under `Focused context:`.
48
+ * An older server's payload (no block, and an older non-blank obligation text) is
49
+ * still accepted unchanged, with no executor-side identifier migration. AC-6 and
50
+ * AC-7 acceptance needs the second release's deployed server, published MCP
51
+ * package, and rebuilt executors. There is no runtime version gate.
52
+ */
53
+ export function renderWorkerTestInvocationGuidance() {
54
+ return ("Test invocation rule: a requested test selector that collects zero tests is an invocation error, " +
55
+ "never a pass and never proof of a missing capability. Rerun every affected test-running step from the " +
56
+ "repository root with the repository's declared runner, and record the exact command and its output as " +
57
+ "that step's evidence. Run the repository's declared build command before a built-CLI smoke step. If no " +
58
+ "runner or build command is declared, do not invent one and do not report success. Only unit_tests, " +
59
+ "e2e_tests, and rendered_ui_review steps may be handed off, only when the persisted run policy allows " +
60
+ "hand-offs, and only when no_live_server, no_database, toolchain_unavailable, credential_unavailable, " +
61
+ "or mcp_unavailable stopped both the first invocation and the corrected attempt before either produced " +
62
+ "any result. The handoff records the first observation, the corrected invocation, and the full head " +
63
+ "SHA both ran against, and that SHA must equal the head the phase result is recorded at. A hand-off " +
64
+ "counts only at the head it observed, so a step that failed at one head can be handed off only from a " +
65
+ "new head. Failed assertions, application errors, unfinished work, and unclear failures keep their " +
66
+ "existing blocker or escalation handling.");
67
+ }
39
68
  export function renderWorkerPushAndCommitGuidance(rebase = false) {
40
69
  return "\n\n## PUSH AND COMMIT PROCEDURE ##\n" +
41
70
  "1. Confirm git ls-files -- .bridge-commit-msg prints nothing and the message file is absent or an ordinary untracked file, never a symlink. " +