@bridge_gpt/mcp-server 0.2.74 → 0.2.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +14 -7
  2. package/build/agent-launchers/prompt.js +9 -21
  3. package/build/agents.generated.js +6 -6
  4. package/build/authored-plan.js +542 -0
  5. package/build/bridge-permissions.js +8 -0
  6. package/build/codex-auto-recovery.js +25 -7
  7. package/build/commands.generated.js +7 -7
  8. package/build/conductor/bridge-api-client.js +807 -52
  9. package/build/conductor/declare-blocked.js +4 -0
  10. package/build/conductor/driver-pass.js +8 -0
  11. package/build/conductor/epic-implementer-cli.js +341 -96
  12. package/build/conductor/epic-server-journal.js +13 -0
  13. package/build/conductor/epic-server-recipe.js +15 -5
  14. package/build/conductor/epic-server-runtime.js +163 -45
  15. package/build/conductor/epic-server.js +13 -6
  16. package/build/conductor/gate-discovery.js +209 -9
  17. package/build/conductor/gate-settings-review.js +7 -11
  18. package/build/conductor/install-doctor.js +30 -2
  19. package/build/conductor/launch-plan.js +58 -12
  20. package/build/conductor/local-merge.js +54 -12
  21. package/build/conductor/open-decision-phrases.js +50 -0
  22. package/build/conductor/pr-ci-producer.js +12 -3
  23. package/build/conductor/prerequisite-inputs.js +181 -14
  24. package/build/conductor/readiness-sections.js +46 -13
  25. package/build/conductor/readiness.js +3 -40
  26. package/build/conductor/recovery-cli.js +12 -12
  27. package/build/conductor/repository-workflow-remedy.js +147 -7
  28. package/build/conductor/ui-readiness.js +224 -0
  29. package/build/conductor/wait-run-attention.js +9 -4
  30. package/build/conductor/wait-run-cli.js +9 -2
  31. package/build/connect-github-api.js +18 -0
  32. package/build/connect-github.js +35 -18
  33. package/build/docs.generated.js +3 -3
  34. package/build/drive-epic.js +787 -37
  35. package/build/epic-ci-workflow.js +3 -2
  36. package/build/epic-implementer-bin.js +200 -66
  37. package/build/epic-implementer-bundle-cli.js +61 -0
  38. package/build/epic-implementer-claude-hook-bin.js +1 -1
  39. package/build/epic-implementer-env.js +3 -4
  40. package/build/epic-integration-pr.js +5 -2
  41. package/build/epic-launch-context.js +8 -1
  42. package/build/epic-shared/cut-protocol.js +55 -3
  43. package/build/executor/completion-contract.js +24 -1
  44. package/build/executor/failure-reason-codes.js +2 -0
  45. package/build/executor/gate-qualification-job.js +193 -23
  46. package/build/executor/gate-qualification-tests-ran.js +232 -0
  47. package/build/executor/integration-job.js +56 -2
  48. package/build/executor/job-runner.js +13 -723
  49. package/build/executor/job-type-wrappers.js +734 -0
  50. package/build/executor/merge-job.js +45 -1
  51. package/build/executor/permissions.js +187 -2
  52. package/build/executor/preflight.js +6 -2
  53. package/build/executor/process-containment.js +8 -1
  54. package/build/executor/provider-checks.js +28 -5
  55. package/build/executor/reconcile-overlap-job.js +70 -17
  56. package/build/executor/required-verification.js +28 -2
  57. package/build/executor/required-work-ledger.js +7 -2
  58. package/build/executor/resume-pre-spawn.js +32 -8
  59. package/build/executor/runner.js +30 -5
  60. package/build/executor/types.js +9 -0
  61. package/build/executor/worker-database.js +6 -1
  62. package/build/executor/worker-guard-hook.js +24 -2
  63. package/build/executor/worktree.js +12 -1
  64. package/build/generated/ticket-status.js +20 -0
  65. package/build/index.js +627 -551
  66. package/build/init.js +16 -0
  67. package/build/install-bridge-conductor-answers.js +32 -1
  68. package/build/install-bridge-conductor-apply.js +21 -3
  69. package/build/install-bridge-conductor-assessment.js +185 -12
  70. package/build/install-bridge-conductor-compact.js +2 -0
  71. package/build/install-bridge-conductor-contracts.js +9 -1
  72. package/build/install-bridge-conductor-gate.js +257 -80
  73. package/build/install-bridge-conductor-setup.js +106 -6
  74. package/build/install-bridge-conductor-trial-report.js +170 -0
  75. package/build/install-bridge-conductor.js +740 -124
  76. package/build/mcp-host-config.js +54 -37
  77. package/build/phase-context-git-probe.js +16 -0
  78. package/build/pipelines.generated.js +15 -15
  79. package/build/plan-execution-ledger.js +27 -0
  80. package/build/plan-generation.js +17 -0
  81. package/build/plane/plane-freshness.js +43 -26
  82. package/build/printed-remedy-commands.js +62 -0
  83. package/build/readme.generated.js +1 -1
  84. package/build/repository-toolchains.js +11 -5
  85. package/build/scripts/saved-commands-config-field-driver.js +65 -0
  86. package/build/secret-redaction.js +3 -0
  87. package/build/setup-epic.js +51 -9
  88. package/build/test-support/create-preview-world.js +232 -0
  89. package/build/test-support/executor-source-files.js +1 -1
  90. package/build/ticket-delivery.js +65 -0
  91. package/build/v2-readiness-requirements.js +13 -4
  92. package/build/version.generated.js +3 -3
  93. package/build/worker-guard-hook-bin.js +2 -2
  94. package/build/worktree-core.js +51 -7
  95. package/docs/EPIC-IMPLEMENTER.md +83 -4
  96. package/docs/epic-implementer/getting-started.md +1 -1
  97. package/docs/install/github-app.md +79 -92
  98. package/package.json +1 -1
  99. package/pipelines/implement-ticket.json +2 -2
  100. package/build/conductor/epic-reconcile.js +0 -603
  101. package/build/conductor/epic-runtime.js +0 -2020
  102. package/build/conductor/epic-state.js +0 -774
@@ -378,7 +378,7 @@ const UNREADABLE = Symbol("unreadable");
378
378
  const ROOT_KEYS = [
379
379
  "type", "subtype", "session_id", "parent_tool_use_id", "message", "content",
380
380
  "task_id", "tool_use_id", "status", "patch", "task_type", "is_backgrounded",
381
- "owned_by_subagent", "tasks", "tool_use_result",
381
+ "owned_by_subagent", "tasks", "tool_use_result", "tool_result_meta",
382
382
  ];
383
383
  const BLOCK_KEYS = [
384
384
  "type", "id", "name", "tool_use_id", "is_error", "input", "text", "content",
@@ -608,7 +608,8 @@ function createStructuralParser() {
608
608
  };
609
609
  const endDrop = () => {
610
610
  dropActive = false;
611
- // Bounded message metadata (usage, model, id) is charged to the unexplained budget only.
611
+ // Bounded message metadata (usage, model, id) and the recognized top-level
612
+ // `tool_result_meta` are charged to the unexplained budget only.
612
613
  if (dropCount > MAX_OVERSIZE_SCALAR_CHARS && dropRec.w !== "meta") {
613
614
  if (proj.large.length >= MAX_OVERSIZE_DROPPED_PATHS)
614
615
  return reject();
@@ -670,6 +671,10 @@ function createStructuralParser() {
670
671
  // A user event's top-level copy of the tool output; only the block's ids carry meaning.
671
672
  if (k === "tool_use_result")
672
673
  return drop({ w: "tur", src: "", i: 0, k }, true);
674
+ // BAPI-1742: bounded top-level Edit/Write completion metadata. Recognized so it
675
+ // is discarded, but still charged to the unexplained budget, never retained.
676
+ if (k === "tool_result_meta")
677
+ return drop({ w: "meta", src: "", i: 0, k }, false);
673
678
  return drop({ w: "top", src: "", i: 0, k }, false);
674
679
  case "message":
675
680
  if (k === "content")
@@ -17,6 +17,7 @@ import { createWorktreeForTicket } from "../worktree-core.js";
17
17
  import { ContinuationLineageMismatch, ContinuationWorktreeMissing, ExecutorNamedError, WorktreeLostBeforePush, } from "./job-errors.js";
18
18
  import { assertWorktreeOnBranch, listGitWorktrees, findWorktreeByBranch, remoteBranchExists as remoteBranchExistsDefault, } from "./worktree-inspection.js";
19
19
  import { ciFixContextError } from "./prompt-spec.js";
20
+ import { executorAllowedTreePathspecs, stageExecutorAllowedTree, unstageExecutorExcludedPaths, } from "./permissions.js";
20
21
  import { fastForwardRetainedWorktreeToBoundHead } from "./worktree.js";
21
22
  /** The canonical WIP checkpoint commit message (executor-run, deterministic). */
22
23
  export const RESUME_WIP_COMMIT_MESSAGE = "wip: auto-checkpoint before resume";
@@ -117,19 +118,42 @@ export async function recreateResumeWorktreeFromPushedBranch(job, expectedBranch
117
118
  throw new ExecutorNamedError(WorktreeLostBeforePush, row.error ?? `failed to recreate worktree for '${expectedBranch}' from origin`);
118
119
  }
119
120
  /**
120
- * Commit any dirty state as a deterministic WIP checkpoint so the injected diff
121
- * is always clean and complete. No-op cleanly when the tree is already clean.
122
- * NEVER discards work.
121
+ * Commit any ALLOWED dirty state as a deterministic WIP checkpoint so the
122
+ * injected diff is always clean and complete. NEVER discards work.
123
+ *
124
+ * Executor-owned and host files (see `EXECUTOR_STAGE_EXCLUDES`) are never
125
+ * committed: forbidden changes an earlier worker left staged are first returned
126
+ * to HEAD in the index (working-tree files are untouched), and status, staging,
127
+ * and the commit all use the shared root-relative exclusions. A tree dirty only in
128
+ * excluded paths is a normal no-op, `{ committed: false }`. `committed: true` is
129
+ * returned only after `git commit` exits successfully. Any failed Git step throws
130
+ * a plain `Error`, which callers' existing catches handle.
123
131
  */
124
132
  export async function autoCheckpointDirtyState(worktreePath, seams, message = RESUME_WIP_COMMIT_MESSAGE) {
125
- const status = await seams.runCommand("git", ["status", "--porcelain"], { cwd: worktreePath });
133
+ const git = (args) => seams.runCommand("git", args, { cwd: worktreePath });
134
+ const fail = (step) => new Error(`checkpoint ${step} failed`);
135
+ const scope = executorAllowedTreePathspecs();
136
+ await unstageExecutorExcludedPaths(git);
137
+ const status = await git(["status", "--porcelain", "--", ...scope]);
138
+ if (status.exitCode !== 0)
139
+ throw fail("status");
126
140
  if (status.stdout.trim().length === 0) {
127
141
  return { committed: false };
128
142
  }
129
- await seams.runCommand("git", ["add", "-A"], { cwd: worktreePath });
130
- await seams.runCommand("git", ["commit", "-m", message], {
131
- cwd: worktreePath,
132
- });
143
+ try {
144
+ await stageExecutorAllowedTree(git);
145
+ }
146
+ catch {
147
+ throw fail("staging");
148
+ }
149
+ const staged = await git(["diff", "--cached", "--quiet"]);
150
+ if (staged.exitCode === 0)
151
+ return { committed: false };
152
+ if (staged.exitCode !== 1)
153
+ throw fail("diff");
154
+ const committed = await git(["commit", "--no-verify", "-m", message]);
155
+ if (committed.exitCode !== 0)
156
+ throw fail("commit");
133
157
  return { committed: true };
134
158
  }
135
159
  /** Read `git log --oneline origin/<base>..HEAD` in the worktree. */
@@ -360,7 +360,9 @@ export async function runExecutor(options, deps, httpClient, seams = {}) {
360
360
  * this requests the epic's existing draft integration pull request be
361
361
  * marked ready for review — it never creates a merge and never merges
362
362
  * anything; only a human merges an epic integration branch (see
363
- * `epic-integration-pr.ts`). Every failure here — a missing read
363
+ * `epic-integration-pr.ts`). It also never opens a pull request: `done`
364
+ * usually follows the integration PR's merge, so finding none open is the
365
+ * normal end of a run, not a gap to fill. Every failure here — a missing read
364
366
  * capability, a sanitized transport/validation failure, an invalid branch,
365
367
  * or an unexpected throw — is ADVISORY: it is logged (credential-free,
366
368
  * bounded) and never affects claiming, running jobs, or the runner's exit.
@@ -413,6 +415,7 @@ export async function runExecutor(options, deps, httpClient, seams = {}) {
413
415
  baseBranch: options.baseBranch,
414
416
  command: "executor wind-down",
415
417
  requestReady: true,
418
+ createIfAbsent: false,
416
419
  gh,
417
420
  cwd: deps.cwd,
418
421
  });
@@ -437,6 +440,13 @@ export async function runExecutor(options, deps, httpClient, seams = {}) {
437
440
  let lastPreflightRefusalAt = -Infinity;
438
441
  let lastCompletionReadFailure = null;
439
442
  let lastCompletionReadFailureAt = -Infinity;
443
+ // BAPI-1732: preflight warning and notice blocks each keep their own last-reported
444
+ // text and time, so a block that never changes logs once per interval instead of
445
+ // once per poll. An empty block neither logs nor clears its remembered state.
446
+ let lastPreflightWarnings = null;
447
+ let lastPreflightWarningsAt = -Infinity;
448
+ let lastPreflightNotices = null;
449
+ let lastPreflightNoticesAt = -Infinity;
440
450
  const shouldReport = (value, previous, at) => value !== previous || deps.now() - at >= 15 * 60_000;
441
451
  /**
442
452
  * Is the scoped run finished? Called only between claim cycles while this
@@ -938,13 +948,28 @@ export async function runExecutor(options, deps, httpClient, seams = {}) {
938
948
  // ~/.claude.json — was invisible to the operator. Emit them before the claim
939
949
  // decision; this only logs and never changes the existing `!report.ok`
940
950
  // claim-skipping behavior below.
941
- for (const warning of report.warnings) {
942
- deps.errorLog(`executor preflight warning: ${warning}`);
951
+ if (report.warnings.length > 0) {
952
+ const block = report.warnings.join("\n");
953
+ if (shouldReport(block, lastPreflightWarnings, lastPreflightWarningsAt)) {
954
+ for (const warning of report.warnings) {
955
+ deps.errorLog(`executor preflight warning: ${warning}`);
956
+ }
957
+ lastPreflightWarnings = block;
958
+ lastPreflightWarningsAt = deps.now();
959
+ }
943
960
  }
944
961
  // BAPI-1386: informational lines (the completion-evidence advertisement) go to
945
962
  // stderr like every other diagnostic here, never stdout.
946
- for (const notice of report.notices ?? []) {
947
- deps.errorLog(`executor preflight: ${notice}`);
963
+ const notices = report.notices ?? [];
964
+ if (notices.length > 0) {
965
+ const block = notices.join("\n");
966
+ if (shouldReport(block, lastPreflightNotices, lastPreflightNoticesAt)) {
967
+ for (const notice of notices) {
968
+ deps.errorLog(`executor preflight: ${notice}`);
969
+ }
970
+ lastPreflightNotices = block;
971
+ lastPreflightNoticesAt = deps.now();
972
+ }
948
973
  }
949
974
  if (!report.ok) {
950
975
  cycleClaimOutcome = "preflight-refused";
@@ -53,6 +53,15 @@ export const EXECUTOR_CLASSIFICATION_VALUES = [
53
53
  * `required_capabilities`, so only a claim declaring it can take such a job.
54
54
  */
55
55
  export const GATE_QUALIFICATION_CAPABILITY = "gate_qualification.v1";
56
+ /**
57
+ * BAPI-1698 — the capability a repository-wide executor declares when it can
58
+ * provision and drop a disposable worker database for a `gate_qualification`
59
+ * job whose sealed declaration carries `worker_database`. The server requires it
60
+ * only for such a job, so an older executor leaves the job queued for a newer
61
+ * one. Mirrors `GATE_QUALIFICATION_WORKER_DATABASE_CAPABILITY` in
62
+ * `src/python/llms/executor_completion_contract.py`.
63
+ */
64
+ export const GATE_QUALIFICATION_WORKER_DATABASE_CAPABILITY = "gate_qualification.worker_database.v1";
56
65
  /**
57
66
  * BAPI-1311 — the capability an executor declares when it can run a FOCUSED
58
67
  * merge-stage `rebase`: validate `payload.focused_rebase` before any worker
@@ -790,9 +790,13 @@ export function classifyWorkerDatabaseMigrationFailure(result) {
790
790
  function buildAlembicEnv(name, config, deps, workerEnvOption) {
791
791
  const env = buildExecutorBaseWorkerEnv({ PATH: deps.clientPath, HOME: deps.clientHome }, { workerDatabase: { name }, workerDatabaseConfig: config, legacyNotice: false, ...workerEnvOption });
792
792
  // Two worker-only switches the shared builder always sets; a migration never
793
- // needed them, and provisioning behavior is unchanged.
793
+ // needed them, and provisioning behavior is unchanged. A repository may also
794
+ // declare PYTHON_DOTENV_DISABLED in its worker_env for its workers; the
795
+ // migration runs from the operator checkout and may still read that
796
+ // checkout's `.env`, so it is dropped here too.
794
797
  delete env.BRIDGE_SKIP_PREPUSH;
795
798
  delete env.MAX_MCP_OUTPUT_TOKENS;
799
+ delete env.PYTHON_DOTENV_DISABLED;
796
800
  return env;
797
801
  }
798
802
  /**
@@ -1082,6 +1086,7 @@ function buildOfflineAlembicEnv(deps, options) {
1082
1086
  });
1083
1087
  delete env.BRIDGE_SKIP_PREPUSH;
1084
1088
  delete env.MAX_MCP_OUTPUT_TOKENS;
1089
+ delete env.PYTHON_DOTENV_DISABLED;
1085
1090
  return env;
1086
1091
  }
1087
1092
  /** Run one offline Alembic command and map interruption and failure to a row result. */
@@ -111,6 +111,12 @@ export function renderWorkerGuardReason(category, family, form) {
111
111
  "made outside the worker. Do not run regenerate-plan or call its route; record the " +
112
112
  "step escalated with its reason and continue.");
113
113
  }
114
+ if (category === "operator-verb" && (family === "reserve-council" || family === "record-decision")) {
115
+ return (`${WORKER_GUARD_REASON_PREFIX}: denied ${family} (${category}). ` +
116
+ "Convening or settling an open-decision council is the run driver's decision, " +
117
+ "made outside the worker. Do not run reserve-council or record-decision; record " +
118
+ "the open choice as an escalated step with its reason and continue.");
119
+ }
114
120
  if (category === "operator-verb" && family === "acknowledge-gaps") {
115
121
  return (`${WORKER_GUARD_REASON_PREFIX}: denied ${family} (${category}). ` +
116
122
  "Acknowledging the run's carried-gap list is the run owner's decision, made " +
@@ -1022,7 +1028,14 @@ function isClaudeWorkflowPrintLaunch(segment) {
1022
1028
  * the owner's one acknowledgement of the run's carried-gap list (route segment
1023
1029
  * `/acknowledge-gaps`), the same way.
1024
1030
  */
1025
- const OPERATOR_ONLY_VERBS = ["resolve-handoff", "regenerate-plan", "acknowledge-gaps"];
1031
+ // BAPI-1705: a worker never convenes or settles a driver council either.
1032
+ const OPERATOR_ONLY_VERBS = [
1033
+ "resolve-handoff",
1034
+ "regenerate-plan",
1035
+ "acknowledge-gaps",
1036
+ "reserve-council",
1037
+ "record-decision",
1038
+ ];
1026
1039
  /** The packaged MCP-server package token after `npx` (any version suffix). */
1027
1040
  const BRIDGE_PACKAGE_TOKEN = /^@bridge_gpt\/mcp-server(?:@\S+)?$/;
1028
1041
  /** Package runners whose package argument launches the packaged CLI. */
@@ -1070,7 +1083,16 @@ function namedOperatorOnlyRoute(token) {
1070
1083
  break;
1071
1084
  decoded = next;
1072
1085
  }
1073
- return OPERATOR_ONLY_VERBS.find((verb) => decoded.toLowerCase().includes(`/${verb}`) || token.toLowerCase().includes(`/${verb}`));
1086
+ const haystacks = [decoded.toLowerCase(), token.toLowerCase()];
1087
+ // BAPI-1705: the two council verbs share one route segment, `/driver-councils`.
1088
+ // A segment followed by a council row id is the settle (record-decision); the
1089
+ // bare collection is the reserve. Both are denied either way.
1090
+ for (const text of haystacks) {
1091
+ const council = /\/driver-councils(\/[^/?#\s"'`]+)?/.exec(text);
1092
+ if (council)
1093
+ return council[1] ? "record-decision" : "reserve-council";
1094
+ }
1095
+ return OPERATOR_ONLY_VERBS.find((verb) => haystacks.some((text) => text.includes(`/${verb}`)));
1074
1096
  }
1075
1097
  /** Node options whose next token is a value, not the script. */
1076
1098
  const NODE_VALUE_OPTIONS = new Set([
@@ -126,6 +126,9 @@ function toWorktreeCoreDeps(deps) {
126
126
  // stderr logger. Shared `start-tickets` callers may keep omitting this — the
127
127
  // primitive treats an absent callback as "do not report".
128
128
  onCleanupDiagnostic: deps.errorLog,
129
+ // BAPI-1742: clock and pause for the reset lock retry.
130
+ now: deps.now,
131
+ sleep: deps.sleep,
129
132
  };
130
133
  }
131
134
  /** Build the command-provisioning boundary from the executor deps (BAPI-664). */
@@ -307,7 +310,13 @@ export async function ensureExecutorWorktree(job, options, deps, policy = {}) {
307
310
  // Hard-reset a reused existing local branch onto the freshly fetched
308
311
  // pushed head; a missing local branch is instead cut from `baseStartPoint`
309
312
  // (= `origin/<branch>`) inside the primitive, so both land at origin.
310
- { freshenFromOrigin: policy.preparation ? expectedHeadSha : originRef, ...(preReset ? { preReset } : {}), ...(postSwitch ? { postSwitch } : {}) });
313
+ {
314
+ freshenFromOrigin: policy.preparation ? expectedHeadSha : originRef,
315
+ ...(preReset ? { preReset } : {}),
316
+ ...(postSwitch ? { postSwitch } : {}),
317
+ // BAPI-1742: reset retries stop before the preparation deadline.
318
+ ...(policy.preparation ? { lockRetryRemainingMs: policy.preparation.remainingMs } : {}),
319
+ });
311
320
  if (row.status === "created" && typeof row.path === "string") {
312
321
  return finalizeExecutorWorktree(row.path, branch, safeHead, deps, publication);
313
322
  }
@@ -376,6 +385,8 @@ export async function ensureExecutorWorktree(job, options, deps, policy = {}) {
376
385
  ...(postSwitch ? { postSwitch } : {}),
377
386
  alignExistingBranchTo: baseSha,
378
387
  verifyHeadMatches: baseSha,
388
+ // BAPI-1742: reset retries stop before the preparation deadline.
389
+ ...(policy.preparation ? { lockRetryRemainingMs: policy.preparation.remainingMs } : {}),
379
390
  // BAPI-862: the guard is ON for this fresh-dispatch path, and this is the
380
391
  // path finding F4 hit — a re-dispatched implement whose branch already
381
392
  // carried the previous, successful attempt's pushed commits.
@@ -0,0 +1,20 @@
1
+ // Generated by scripts/generate_ticket_status_types.py. Do not edit.
2
+ export const EPIC_TICKET_STATUS_VALUES = [
3
+ "planned",
4
+ "ready",
5
+ "dispatched",
6
+ "running",
7
+ "blocked",
8
+ "abandoned",
9
+ "done",
10
+ "ready_for_review",
11
+ "reviewing",
12
+ "spec_review",
13
+ "implementing",
14
+ "ci",
15
+ "code_review",
16
+ "merging",
17
+ "parsing",
18
+ "smoke",
19
+ "needs_human",
20
+ ];