@bridge_gpt/mcp-server 0.2.76 → 0.2.77

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 (58) hide show
  1. package/README.md +8 -6
  2. package/build/agents.generated.js +3 -3
  3. package/build/cli-dispatch.js +333 -0
  4. package/build/commands.generated.js +5 -5
  5. package/build/conductor/bridge-api-client.js +52 -7
  6. package/build/conductor/declare-blocked.js +142 -7
  7. package/build/conductor/driver-register.js +8 -2
  8. package/build/conductor/epic-implementer-cli.js +11 -7
  9. package/build/conductor/epic-server-journal.js +39 -22
  10. package/build/conductor/launch-plan.js +28 -7
  11. package/build/conductor/local-merge.js +1 -1
  12. package/build/conductor/readiness-prerequisites.js +89 -2
  13. package/build/conductor/recovery-cli.js +2 -0
  14. package/build/docs.generated.js +67 -4
  15. package/build/doctor.js +97 -1
  16. package/build/drive-epic.js +223 -6
  17. package/build/engine-paths.js +10 -0
  18. package/build/epic-coherence-input-cli.js +105 -10
  19. package/build/epic-coherence-input.js +877 -4
  20. package/build/epic-coherence-input.test-fixtures.js +117 -0
  21. package/build/epic-implementer-bin.js +901 -94
  22. package/build/epic-implementer-env.js +2 -2
  23. package/build/executor/completion-contract.js +14 -1
  24. package/build/executor/guarded-fast-forward-push.js +25 -2
  25. package/build/executor/job-runner.js +83 -27
  26. package/build/executor/likely-tests.js +78 -6
  27. package/build/executor/provider-checks.js +73 -0
  28. package/build/executor/rebase-finalization.js +29 -27
  29. package/build/executor/rename-aside.js +265 -0
  30. package/build/executor/required-work-ledger.js +82 -4
  31. package/build/executor/types.js +121 -0
  32. package/build/executor/worktree.js +27 -1
  33. package/build/index.js +2449 -386
  34. package/build/install-bridge-conductor-assessment.js +13 -0
  35. package/build/install-bridge-conductor.js +60 -776
  36. package/build/install-bridge.js +4 -11
  37. package/build/language-catalog.generated.js +2649 -0
  38. package/build/pipelines.generated.js +45 -17
  39. package/build/plan-execution-ledger.js +8 -0
  40. package/build/plan-generation.js +34 -0
  41. package/build/plane/build-freshness.js +6 -0
  42. package/build/plane/cli.js +12 -5
  43. package/build/printed-remedy-commands.js +9 -0
  44. package/build/readiness-prerequisites.generated.js +28 -0
  45. package/build/readme.generated.js +1 -1
  46. package/build/run-unit-tests-launcher.js +3 -1
  47. package/build/server.js +7946 -0
  48. package/build/start-tickets-prereqs.js +3 -6
  49. package/build/test-support/console-guard.js +30 -0
  50. package/build/test-support/module-imports.js +155 -0
  51. package/build/test-support/server-client.js +96 -0
  52. package/build/test-support/stdio-server.js +146 -0
  53. package/build/v2-readiness-requirements.js +31 -2
  54. package/build/version.generated.js +3 -3
  55. package/docs/EPIC-IMPLEMENTER.md +71 -2
  56. package/docs/epic-implementer/getting-started.md +4 -0
  57. package/package.json +3 -3
  58. package/pipelines/learn-repository.json +19 -1
@@ -525,12 +525,9 @@ export async function resolveMainWorktreePathForDoctor(deps) {
525
525
  /**
526
526
  * Secret-free remediation hint shared by the Claude MCP shadowing descriptor.
527
527
  *
528
- * WORDING CONSTRAINT: this module is guarded by a static source scan
529
- * (`start-tickets-credential-invariants.static.test.ts`) proving the prereqs
530
- * module performs no filesystem writes. It rejects the bare filesystem-mutation
531
- * identifiers ANYWHERE in the source — including comments and user-facing prose,
532
- * which is why the advice below is phrased as "delete, or move aside". Keep every
533
- * such identifier out of this file, even inside a comment like this one.
528
+ * The prereqs module performs no filesystem or credential writes, so the advice
529
+ * below tells the user what to do rather than doing it. `module-boundaries.test.ts`
530
+ * holds the rule: this module imports no filesystem module and no credential writer.
534
531
  */
535
532
  const CLAUDE_MCP_SHADOWING_HINT = `Run \`${CLAUDE_MCP_SHADOWING_REMEDIATION_COMMAND}\` to clear the '${MCP_SERVER_NAME}' MCP ` +
536
533
  "registration in ~/.claude.json (use the matching scope if it is registered at user scope, " +
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Fail any test in the calling file that writes through `console.*`.
3
+ *
4
+ * Some modules must never log at all — the merge path handles API keys, merge
5
+ * tokens, and provider bodies, and a stray `console.error(err)` or
6
+ * `console.log(headers)` is how one leaks. Calling this once at the top level of
7
+ * a test file wraps every console method for each test and fails the test that
8
+ * used one, so every path the file's tests already drive is checked.
9
+ */
10
+ import assert from "node:assert/strict";
11
+ import { afterEach, beforeEach, mock } from "node:test";
12
+ const METHODS = ["log", "info", "warn", "error", "debug", "trace"];
13
+ export function failOnConsoleOutput() {
14
+ let calls = [];
15
+ let restore = [];
16
+ beforeEach(() => {
17
+ calls = [];
18
+ restore = METHODS.map((name) => {
19
+ const spy = mock.method(console, name, (...parts) => {
20
+ calls.push(`console.${name}(${parts.map(String).join(" ")})`);
21
+ });
22
+ return () => spy.mock.restore();
23
+ });
24
+ });
25
+ afterEach(() => {
26
+ for (const undo of restore)
27
+ undo();
28
+ assert.deepEqual(calls, [], "this module must not write through console.*");
29
+ });
30
+ }
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Read a source module's imports, for tests that guard import boundaries.
3
+ *
4
+ * Many safety rules are about what a module may depend on: a pure builder never
5
+ * imports `node:child_process`, `doctor` never imports the credential writer,
6
+ * the readiness collector never imports the MCP server. Checking those with
7
+ * `source.includes("node:fs")` is fooled by a comment and misses a dynamic
8
+ * `import("…")`. These helpers strip comments and read every static import,
9
+ * `export … from`, `import type`, and dynamic `import("…")` specifier.
10
+ *
11
+ * Paths are relative to `mcp_server/src`. Tests run from `build/`, so the
12
+ * TypeScript source is read from `src/`.
13
+ */
14
+ import assert from "node:assert/strict";
15
+ import { readFileSync } from "node:fs";
16
+ import path from "node:path";
17
+ const SRC_DIR = path.join(import.meta.dirname, "..", "..", "src");
18
+ /** Characters after which a `/` starts a regex literal rather than a division. */
19
+ const REGEX_PREFIX = new Set(["(", ",", "=", ":", "[", "!", "&", "|", "?", "{", "}", ";", "+", "-", "*", "%", "<", ">", "~", "^", ""]);
20
+ /**
21
+ * Remove `//` line comments and block comments, leaving strings and regex
22
+ * literals intact (a quote inside `/[;"']/` must not open a string).
23
+ */
24
+ export function stripComments(source) {
25
+ let out = "";
26
+ let i = 0;
27
+ while (i < source.length) {
28
+ const c = source[i];
29
+ const next = source[i + 1];
30
+ if (c === "/" && next !== "/" && next !== "*" && REGEX_PREFIX.has(out.trimEnd().slice(-1))) {
31
+ // A regex literal: copy it through, honouring escapes and character classes.
32
+ let j = i + 1;
33
+ let inClass = false;
34
+ while (j < source.length && source[j] !== "\n") {
35
+ const ch = source[j];
36
+ if (ch === "\\")
37
+ j += 2;
38
+ else if (ch === "[")
39
+ (inClass = true), (j += 1);
40
+ else if (ch === "]")
41
+ (inClass = false), (j += 1);
42
+ else if (ch === "/" && !inClass)
43
+ break;
44
+ else
45
+ j += 1;
46
+ }
47
+ out += source.slice(i, j + 1);
48
+ i = j + 1;
49
+ continue;
50
+ }
51
+ if (c === "/" && next === "/") {
52
+ const end = source.indexOf("\n", i);
53
+ i = end < 0 ? source.length : end;
54
+ continue;
55
+ }
56
+ if (c === "/" && next === "*") {
57
+ const end = source.indexOf("*/", i + 2);
58
+ i = end < 0 ? source.length : end + 2;
59
+ continue;
60
+ }
61
+ if (c === '"' || c === "'" || c === "`") {
62
+ let j = i + 1;
63
+ while (j < source.length && source[j] !== c)
64
+ j += source[j] === "\\" ? 2 : 1;
65
+ out += source.slice(i, j + 1);
66
+ i = j + 1;
67
+ continue;
68
+ }
69
+ out += c;
70
+ i += 1;
71
+ }
72
+ return out;
73
+ }
74
+ const STATIC_IMPORT = /^\s*(import|export)\s+(type\s+)?([^;]*?)\bfrom\s*["']([^"']+)["']|^\s*import\s*["']([^"']+)["']/gm;
75
+ /** Every static import and re-export statement of a source text. */
76
+ export function staticImportStatements(source) {
77
+ const code = stripComments(source);
78
+ const out = [];
79
+ for (const m of code.matchAll(STATIC_IMPORT)) {
80
+ if (m[5] !== undefined) {
81
+ out.push({ specifier: m[5], typeOnly: false, reexport: false, names: [], namespace: false });
82
+ continue;
83
+ }
84
+ const clause = m[3] ?? "";
85
+ const braced = /\{([^}]*)\}/.exec(clause)?.[1] ?? "";
86
+ const names = braced
87
+ .split(",")
88
+ .map((n) => n.trim().replace(/^type\s+/, "").split(/\s+as\s+/)[0].trim())
89
+ .filter(Boolean);
90
+ const defaultName = /^\s*([A-Za-z_$][\w$]*)\s*(,|$)/.exec(clause)?.[1];
91
+ if (defaultName && defaultName !== "type")
92
+ names.push(defaultName);
93
+ out.push({
94
+ specifier: m[4],
95
+ typeOnly: Boolean(m[2]),
96
+ reexport: m[1] === "export",
97
+ names,
98
+ namespace: /\*\s*as\s/.test(clause) || (m[1] === "export" && /^\s*\*/.test(clause)),
99
+ });
100
+ }
101
+ return out;
102
+ }
103
+ /** Specifiers loaded with a dynamic `import("…")`. */
104
+ export function dynamicImportsOfSource(source) {
105
+ const code = stripComments(source);
106
+ return [...new Set([...code.matchAll(/\bimport\s*\(\s*["']([^"']+)["']\s*\)/g)].map((m) => m[1]))];
107
+ }
108
+ /** Every module specifier a source text imports (static and dynamic), duplicates removed. */
109
+ export function importsOfSource(source) {
110
+ return [...new Set([...staticImportStatements(source).map((s) => s.specifier), ...dynamicImportsOfSource(source)])];
111
+ }
112
+ function read(relativePath) {
113
+ return readFileSync(path.join(SRC_DIR, relativePath), "utf8");
114
+ }
115
+ /** Every module specifier `mcp_server/src/<relativePath>` imports, static or dynamic. */
116
+ export function importsOf(relativePath) {
117
+ return importsOfSource(read(relativePath));
118
+ }
119
+ /** The static import statements of `mcp_server/src/<relativePath>`. */
120
+ export function staticImportsOf(relativePath) {
121
+ return staticImportStatements(read(relativePath));
122
+ }
123
+ /** Specifiers `mcp_server/src/<relativePath>` loads with a dynamic `import("…")`. */
124
+ export function dynamicImportsOf(relativePath) {
125
+ return dynamicImportsOfSource(read(relativePath));
126
+ }
127
+ /** A specifier matches a banned entry exactly, or as a path ending (`/doctor.js`). */
128
+ function matches(specifier, entry) {
129
+ return specifier === entry || specifier.endsWith(`/${entry.replace(/^\.\//, "")}`);
130
+ }
131
+ /** Fail if the module imports any banned specifier. */
132
+ export function assertImportsNone(relativePath, banned) {
133
+ const offenders = importsOf(relativePath).filter((s) => banned.some((b) => matches(s, b)));
134
+ assert.deepEqual(offenders, [], `${relativePath} must not import ${offenders.join(", ")}`);
135
+ }
136
+ /** Fail if the module imports anything outside the allowed list. */
137
+ export function assertImportsOnly(relativePath, allowed) {
138
+ const offenders = importsOf(relativePath).filter((s) => !allowed.some((a) => matches(s, a)));
139
+ assert.deepEqual(offenders, [], `${relativePath} imports outside its allow-list: ${offenders.join(", ")}`);
140
+ }
141
+ /** Fail unless the module imports every required specifier. */
142
+ export function assertImportsAll(relativePath, required) {
143
+ const imports = importsOf(relativePath);
144
+ const missing = required.filter((r) => !imports.some((s) => matches(s, r)));
145
+ assert.deepEqual(missing, [], `${relativePath} must import ${missing.join(", ")}`);
146
+ }
147
+ /** Fail if the module imports any of these names from a specifier. */
148
+ export function assertImportsNoName(relativePath, specifier, names) {
149
+ const statements = staticImportsOf(relativePath).filter((s) => matches(s.specifier, specifier));
150
+ const offenders = names.filter((n) => statements.some((s) => s.names.includes(n)));
151
+ assert.deepEqual(offenders, [], `${relativePath} must not import ${offenders.join(", ")} from ${specifier}`);
152
+ // A namespace or dynamic import of the module would reach every name.
153
+ assert.ok(!statements.some((s) => s.namespace), `${relativePath} imports ${specifier} as a namespace`);
154
+ assert.ok(!dynamicImportsOf(relativePath).some((d) => matches(d, specifier)), `${relativePath} loads ${specifier} dynamically, which could reach ${names.join(", ")}`);
155
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Drive the real MCP server's tool handlers from a test.
3
+ *
4
+ * `server.ts` builds the server and registers every tool on import and does no
5
+ * I/O until `startServer()`. This helper sets the environment, replaces `fetch`
6
+ * with a recorder, imports the module once, and connects an in-memory MCP client,
7
+ * so a test calls a tool exactly as an agent would and sees the requests it
8
+ * made. Rules that live in `startServer()` (index scope, stdio connect) are not
9
+ * reachable here; those tests mock the SDK instead.
10
+ *
11
+ * Call `connectServer` once per test file: the environment is read when the
12
+ * module loads, and each test file runs in its own process.
13
+ */
14
+ import { mkdirSync, mkdtempSync } from "node:fs";
15
+ import os from "node:os";
16
+ import path from "node:path";
17
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
18
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
19
+ function headerRecord(init) {
20
+ const out = {};
21
+ const headers = init?.headers;
22
+ if (!headers)
23
+ return out;
24
+ if (headers instanceof Headers) {
25
+ headers.forEach((value, key) => {
26
+ out[key.toLowerCase()] = value;
27
+ });
28
+ }
29
+ else if (Array.isArray(headers)) {
30
+ for (const [key, value] of headers)
31
+ out[key.toLowerCase()] = value;
32
+ }
33
+ else {
34
+ for (const [key, value] of Object.entries(headers))
35
+ out[key.toLowerCase()] = String(value);
36
+ }
37
+ return out;
38
+ }
39
+ export async function connectServer(env = {}) {
40
+ const projectRoot = mkdtempSync(path.join(os.tmpdir(), "server-client-root-"));
41
+ mkdirSync(path.join(projectRoot, ".git"));
42
+ Object.assign(process.env, {
43
+ BAPI_BASE_URL: "https://bridge.example.test",
44
+ BAPI_REPO_NAME: "server-client-repo",
45
+ BAPI_API_KEY: "server-client-sentinel-key",
46
+ BAPI_PROJECT_ROOT: projectRoot,
47
+ BAPI_MCP_UPDATE_CHECK_ENABLED: "false",
48
+ ...env,
49
+ });
50
+ const requests = [];
51
+ let responder = () => undefined;
52
+ globalThis.fetch = (async (input, init) => {
53
+ const raw = init?.body;
54
+ let body = raw;
55
+ if (typeof raw === "string") {
56
+ try {
57
+ body = JSON.parse(raw);
58
+ }
59
+ catch {
60
+ body = raw;
61
+ }
62
+ }
63
+ const request = {
64
+ url: String(input),
65
+ method: (init?.method ?? "GET").toUpperCase(),
66
+ headers: headerRecord(init),
67
+ body,
68
+ };
69
+ requests.push(request);
70
+ const answer = responder(request);
71
+ if (answer instanceof Error)
72
+ throw answer;
73
+ const status = answer?.status ?? 200;
74
+ const payload = answer?.body ?? {};
75
+ return new Response(typeof payload === "string" ? payload : JSON.stringify(payload), {
76
+ status,
77
+ headers: { "content-type": typeof payload === "string" ? "text/plain" : "application/json" },
78
+ });
79
+ });
80
+ const { bridgeServer } = await import("../server.js");
81
+ const [serverSide, clientSide] = InMemoryTransport.createLinkedPair();
82
+ await bridgeServer.connect(serverSide);
83
+ const client = new Client({ name: "server-client-test", version: "0.0.0" });
84
+ await client.connect(clientSide);
85
+ return {
86
+ requests,
87
+ projectRoot,
88
+ respond(next) {
89
+ responder = next;
90
+ },
91
+ async call(name, args = {}) {
92
+ const result = (await client.callTool({ name, arguments: args }));
93
+ return { text: result.content?.[0]?.text ?? "", isError: Boolean(result.isError) };
94
+ },
95
+ };
96
+ }
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Run the real MCP server bin over stdio against a local HTTP backend.
3
+ *
4
+ * For rules that live in `startServer()` (index scope, the project-root line,
5
+ * `roots/list` after connect, stdout reserved for the protocol), a test needs
6
+ * the whole entry point, not an imported module. This spawns `build/index.js`
7
+ * with `BAPI_BASE_URL` pointed at an in-process HTTP server that records every
8
+ * request, then speaks newline-delimited JSON-RPC on the child's stdio.
9
+ */
10
+ import { spawn } from "node:child_process";
11
+ import { createServer } from "node:http";
12
+ import path from "node:path";
13
+ const BIN = path.join(import.meta.dirname, "..", "index.js");
14
+ async function startBackend(record, respond) {
15
+ const server = createServer((req, res) => {
16
+ const chunks = [];
17
+ req.on("data", (chunk) => chunks.push(chunk));
18
+ req.on("end", () => {
19
+ const raw = Buffer.concat(chunks).toString("utf8");
20
+ let body = raw;
21
+ try {
22
+ body = raw ? JSON.parse(raw) : undefined;
23
+ }
24
+ catch {
25
+ body = raw;
26
+ }
27
+ const url = new URL(req.url ?? "/", "http://backend.test");
28
+ const request = {
29
+ method: req.method ?? "GET",
30
+ path: url.pathname,
31
+ query: url.searchParams,
32
+ headers: req.headers,
33
+ body,
34
+ };
35
+ record.push(request);
36
+ const answer = respond(request) ?? {};
37
+ res.writeHead(answer.status ?? 200, { "content-type": "application/json" });
38
+ res.end(JSON.stringify(answer.body ?? {}));
39
+ });
40
+ });
41
+ await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
42
+ return server;
43
+ }
44
+ export async function startStdioServer(options = {}) {
45
+ const backend = [];
46
+ const http = await startBackend(backend, options.respond ?? (() => undefined));
47
+ const port = http.address().port;
48
+ const child = spawn(process.execPath, [BIN], {
49
+ env: {
50
+ ...process.env,
51
+ BAPI_BASE_URL: `http://127.0.0.1:${port}`,
52
+ BAPI_REPO_NAME: "stdio-server-repo",
53
+ BAPI_API_KEY: "stdio-server-sentinel-key",
54
+ BAPI_MCP_UPDATE_CHECK_ENABLED: "false",
55
+ BAPI_MCP_TOOL_SURFACE_GATING_ENABLED: "false",
56
+ ...options.env,
57
+ },
58
+ stdio: ["pipe", "pipe", "pipe"],
59
+ });
60
+ let stdout = "";
61
+ let stderr = "";
62
+ const lines = [];
63
+ const pending = new Map();
64
+ const clientRequests = [];
65
+ let nextId = 1;
66
+ const send = (message) => child.stdin.write(JSON.stringify(message) + "\n");
67
+ child.stdout.on("data", (chunk) => {
68
+ stdout += chunk.toString("utf8");
69
+ let newline;
70
+ while ((newline = stdout.indexOf("\n")) >= 0) {
71
+ const line = stdout.slice(0, newline);
72
+ stdout = stdout.slice(newline + 1);
73
+ if (!line)
74
+ continue;
75
+ lines.push(line);
76
+ let message;
77
+ try {
78
+ message = JSON.parse(line);
79
+ }
80
+ catch {
81
+ continue;
82
+ }
83
+ if (message.method && message.id !== undefined) {
84
+ // A request from the server to this client.
85
+ clientRequests.push(message.method);
86
+ if (message.method === "roots/list") {
87
+ send({ jsonrpc: "2.0", id: message.id, result: { roots: options.roots ?? [] } });
88
+ }
89
+ else {
90
+ send({ jsonrpc: "2.0", id: message.id, result: {} });
91
+ }
92
+ }
93
+ else if (message.id !== undefined && pending.has(message.id)) {
94
+ const waiter = pending.get(message.id);
95
+ pending.delete(message.id);
96
+ if (message.error)
97
+ waiter.reject(new Error(JSON.stringify(message.error)));
98
+ else
99
+ waiter.resolve(message.result);
100
+ }
101
+ }
102
+ });
103
+ child.stderr.on("data", (chunk) => {
104
+ stderr += chunk.toString("utf8");
105
+ });
106
+ child.on("exit", () => {
107
+ for (const waiter of pending.values())
108
+ waiter.reject(new Error(`server exited: ${stderr}`));
109
+ pending.clear();
110
+ });
111
+ const handle = {
112
+ backend,
113
+ clientRequests,
114
+ request(method, params) {
115
+ const id = nextId++;
116
+ return new Promise((resolve, reject) => {
117
+ pending.set(id, { resolve, reject });
118
+ send({ jsonrpc: "2.0", id, method, params });
119
+ setTimeout(() => {
120
+ if (pending.delete(id))
121
+ reject(new Error(`timed out waiting for ${method}; stderr: ${stderr}`));
122
+ }, 20_000).unref();
123
+ });
124
+ },
125
+ notify(method, params) {
126
+ send({ jsonrpc: "2.0", method, params });
127
+ },
128
+ stdoutLines: () => [...lines],
129
+ stderr: () => stderr,
130
+ async close() {
131
+ child.kill();
132
+ await new Promise((resolve) => http.close(() => resolve()));
133
+ },
134
+ };
135
+ return handle;
136
+ }
137
+ /** `initialize` + `notifications/initialized`, with roots support declared. */
138
+ export async function initialize(server, clientName = "stdio-server-test") {
139
+ const result = await server.request("initialize", {
140
+ protocolVersion: "2025-06-18",
141
+ capabilities: { roots: { listChanged: false } },
142
+ clientInfo: { name: clientName, version: "0.0.0" },
143
+ });
144
+ server.notify("notifications/initialized");
145
+ return result;
146
+ }
@@ -1,4 +1,4 @@
1
- import { mergeReadinessPrerequisites, formatReadinessPrerequisites } from "./conductor/readiness-prerequisites.js";
1
+ import { overlayReadinessPrerequisites, formatReadinessPrerequisites } from "./conductor/readiness-prerequisites.js";
2
2
  import { READINESS_PREREQUISITE_BY_ID, READINESS_LEGACY_IDS } from "./readiness-prerequisites.generated.js";
3
3
  import { indexedWorkflowsDisplayRemedy } from "./printed-remedy-commands.js";
4
4
  /**
@@ -174,6 +174,11 @@ const LEGACY_V2_READINESS_REQUIREMENTS = [
174
174
  const LAUNCH_ONLY_BLOCKING_IDS = [
175
175
  { id: 'server.escalation-webhook-reachable', unattendedOnly: true },
176
176
  { id: 'server.provider-default-branch-readable', unattendedOnly: false },
177
+ // BAPI-1747 — the server's merge-authority finding. Only a row the server projects
178
+ // `not_met` + `blocking` (the proven universal merge denial) refuses; a warning,
179
+ // unknown, or absent row (an older server) never does. The four warning-only
180
+ // run-path IDs deliberately have no requirement here.
181
+ { id: 'server.resolved-merge-mode', unattendedOnly: false },
177
182
  ];
178
183
  const NEW_IDS = ['server.indexed-workflows', 'server.unattended-notify-default'];
179
184
  export const V2_READINESS_REQUIREMENTS = [
@@ -477,6 +482,12 @@ export function unattendedPostureCheck(readiness) {
477
482
  /** The resolved merge mode, as a supporting fact. Absent or null is a warning, never a default. */
478
483
  export function resolvedMergeModeCheck(readiness) {
479
484
  const base = { id: RESOLVED_MERGE_MODE_ROW_ID, source: "server", label: "Resolved merge mode" };
485
+ // BAPI-1747 — a server that reports its own merge-authority row is authoritative,
486
+ // as `mergeReadinessPrerequisites` already treats server rows. With no such row
487
+ // (an older server) the client-built row below is unchanged.
488
+ const serverRow = readiness.prerequisites?.find((p) => p.id === RESOLVED_MERGE_MODE_ROW_ID);
489
+ if (serverRow !== undefined)
490
+ return resolvedMergeModeFromServerRow(base, serverRow, readiness.resolved_merge_execution_mode);
480
491
  const mode = readiness.resolved_merge_execution_mode;
481
492
  if (mode === undefined) {
482
493
  return createReadinessCheckSafely({
@@ -496,6 +507,24 @@ export function resolvedMergeModeCheck(readiness) {
496
507
  }
497
508
  return createReadinessCheckSafely({ ...base, status: "pass", detail: `a new run merges in ${mode} mode` });
498
509
  }
510
+ function resolvedMergeModeFromServerRow(base, row, mode) {
511
+ const names = (row.findings ?? []).map((f) => f.reason).join(", ");
512
+ const suffix = names ? ` (${names})` : "";
513
+ if (row.check_status === "met") {
514
+ return createReadinessCheckSafely({ ...base, status: "pass", detail: typeof mode === "string" ? `a new run merges in ${mode} mode` : "the server confirmed merge authority" });
515
+ }
516
+ if (row.check_status === "not_applicable") {
517
+ return createReadinessCheckSafely({ ...base, status: "skip", detail: "merge authority does not apply to this launch" });
518
+ }
519
+ const remediation = row.fix ? { remediation: row.fix } : {};
520
+ if (row.check_status === "not_met" && row.impact === "blocking") {
521
+ return createReadinessCheckSafely({ ...base, status: "fail", detail: `the server would refuse every merge for this launch${suffix}`, ...remediation });
522
+ }
523
+ if (row.check_status === "not_met") {
524
+ return createReadinessCheckSafely({ ...base, status: "warn", detail: `the server reported a merge-authority gap${suffix}`, ...remediation });
525
+ }
526
+ return createReadinessCheckSafely({ ...base, status: "warn", detail: `Capability not verified: the server could not check merge authority${suffix}`, ...remediation });
527
+ }
499
528
  /** The provider repository, as a supporting fact. */
500
529
  export function providerRepositoryCheck(readiness) {
501
530
  const base = { id: PROVIDER_REPOSITORY_ROW_ID, source: "server", label: "Provider repository" };
@@ -584,5 +613,5 @@ export function readinessApplicabilityLabel(check) {
584
613
  }
585
614
  /** Render the compact launch summary drive-epic prints before creating a run. */
586
615
  export function formatLaunchReadinessSummary(checks, options = {}) {
587
- return formatReadinessPrerequisites(mergeReadinessPrerequisites(checks, options.prerequisites), options);
616
+ return formatReadinessPrerequisites(overlayReadinessPrerequisites(checks, options.prerequisites, options.toolVisibility), options);
588
617
  }
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED — do not edit manually. Regenerate with: npm run build
2
- export const VERSION = "0.2.76";
3
- export const BUILD_COMMIT = "693d8ca6350a";
4
- export const LAUNCHER_ARGS = ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.76", "serve"];
2
+ export const VERSION = "0.2.77";
3
+ export const BUILD_COMMIT = "dae84fcf944a";
4
+ export const LAUNCHER_ARGS = ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.77", "serve"];
@@ -251,6 +251,64 @@ npx -y @bridge_gpt/mcp-server executor --repo <name> --epic-run-id <id>
251
251
 
252
252
  Owners who run their own Bridge server have extra steps. Run `npx -y @bridge_gpt/mcp-server drive-epic --help-advanced` to read them.
253
253
 
254
+ ## Test pruning and checked-once evidence
255
+
256
+ Workers now remove edit-confirmation tests that their own change made pointless,
257
+ and they leave a record of what they removed and what they checked once.
258
+
259
+ **Touched-code-only pruning.** A worker looks only at tests for code the ticket
260
+ changed. It finds candidates by source file name and imports first, then by
261
+ targeted searches in those test paths. It never scans the whole repository.
262
+
263
+ **Assertion-level safeguards.** Each assertion is judged on its own. A search match
264
+ is only a candidate. The worker removes an assertion only when it is an
265
+ edit-confirmation pin: a check that text, source, a count, or a copy's bytes match
266
+ what an edit wrote, with no runtime code, parser, protocol, or invariant using that
267
+ value. These are never treated as pins: parsed headers, JSON keys and tool names;
268
+ protocol and CLI envelopes; security and architecture guards; migration and registry
269
+ invariants; counts that are data; API shape, status codes, data and state. A test
270
+ file that a plan step names for writing or updating is never deleted whole.
271
+
272
+ **Behavioral protection.** If a pin is the only behavioral protection, the worker
273
+ first adds a replacement behavioral test that passes. If it cannot, it keeps the
274
+ pin and updates it. A worker never changes a valid expectation to accept broken
275
+ behavior.
276
+
277
+ **Opt-out and customer requests.** Each test step in a plan ends with a deletion
278
+ line. If your repository's unit-testing instructions say `never delete tests`, the
279
+ line reads `Test deletion: not allowed (repository instruction)` and nothing is
280
+ deleted. A missing, conflicting, or unreadable line also means no deletion. If you
281
+ ask for a specific assertion, it is protected even when general deletion is
282
+ allowed.
283
+
284
+ ### Two pull request sections
285
+
286
+ Every pull request description carries two sections, rebuilt from durable records
287
+ (the branch diff, commit bodies, and the phase-result ledger), never from memory:
288
+
289
+ - `## Tests removed` lists each file, test or assertion, action (`deleted` or
290
+ `updated`), and reason. It reads `None` when there are no entries.
291
+ - `## Checked once` lists each run-once check with its command, the full commit SHA
292
+ it checked, and the outcome. It reads `None` when there are no entries. A failed
293
+ check is shown as failed. An unavailable one is shown as a named gap. An earlier
294
+ pass is marked as historical, so it never looks like it covers a later commit.
295
+
296
+ ### Run-once checks and honest failures
297
+
298
+ Some plan steps are one-time facts the diff cannot show, such as rendering the
299
+ migration SQL offline. The worker runs the targeted command once and commits no test
300
+ for it. If the environment is unavailable, the step is disclosed through the
301
+ existing hand-off. If the command runs and fails, that is a failure, not a gap.
302
+ Renewal happens only in a safe, disposable environment, and a state-changing
303
+ command is never blindly repeated.
304
+
305
+ ### Where actions are reported
306
+
307
+ Automated `ci_fix` repair reports its updated and deleted tests in its result file
308
+ and in its fix commit body. It does not edit the pull request description.
309
+ Interactive and post-PR corrections list them in the correction commit body and
310
+ refresh the two pull request sections.
311
+
254
312
  ## The CI gate
255
313
 
256
314
  Each ticket's `ci` gate reads `policy_json.required_checks` and waits for those
@@ -330,6 +388,17 @@ policy is a no-op. A different one is refused with a redacted diff unless you ad
330
388
  branches other than same-repository `feature/BAPI-*` and `epic/**` get an
331
389
  immediate green. That is cost control, not proof the suites ran.
332
390
 
391
+ ### Failing assertions: stale pin or real defect
392
+
393
+ Before a `ci_fix` job repairs a failing assertion, it reads the ticket's existing
394
+ plan once (`get_plan`; this is a read, not a new plan) and sorts the failure. A stale
395
+ pin is a text, source, count, or copy-byte expectation the ticket deliberately
396
+ changed. It may be deleted only with clear deletion permission, and otherwise is
397
+ updated. A failure in a protected contract category, including API shape, status
398
+ codes, data and state, is a production defect or a contract, so the worker repairs
399
+ production code instead. The repair stays bounded as before: the same rounds, the
400
+ same result format, and no new stop.
401
+
333
402
  ## Plan metadata: `touched_files`
334
403
 
335
404
  **Plan-time file-overlap serialization is on by default**
@@ -678,8 +747,8 @@ atomically over the target. A hook edited in the meantime is left alone
678
747
 
679
748
  **Repairing old cache-backed hooks.** Hooks installed from `npx` before durable
680
749
  hook installation point into the npx cache. Install persistently (`npm i -g @bridge_gpt/mcp-server`),
681
- then re-run `epic-implementer install-git-hooks` (or `install conductor` and
682
- accept the local-observability consent). The managed block is replaced in place.
750
+ then re-run `epic-implementer install-git-hooks`. Setup does not install hooks;
751
+ it only recommends this command. The managed block is replaced in place.
683
752
 
684
753
  **Upgrades and rollback.** `npm i -g @bridge_gpt/mcp-server@<version>` replaces
685
754
  the package in place, so hooks keep working without a rewrite. To roll back,
@@ -30,6 +30,9 @@ Setup checks every item below for you, fixes what it can, and prints the one ste
30
30
  - **Repository workflow readiness** (`server.repository-workflow-readiness`) — The CI and review workflows are confirmed on the default branch. Fix: Run setup, merge the setup pull request, then run setup again.
31
31
  - **Workflows at indexed commit** (`server.indexed-workflows`) — The repository index includes the workflow files on the default branch. Fix: Merge the setup pull request, then run setup again. It starts the re-index and reports this item as pending until the index reaches that commit.
32
32
  - **Integration branch configured** (`server.integration-branch-unset`) — The repository has an integration branch set. This is a note only and never blocks a launch. Fix: Nothing is needed. Set the repository's base branch to clear the note.
33
+ - **CI status readable by the run** (`server.ci-poll-readable`) — The run can poll CI: the CI check configuration is stored, so the MCP server shows the `poll_ci_checks` and `wait_for_ci_checks` tools, and Bridge can read CI for the default-branch head. A warning only; it never blocks a launch. Fix: Run the `resolve_ci_checks` MCP tool for this repository.
34
+ - **Watched checks run on epic branches** (`server.epic-branch-check-triggers`) — Every required or watched check (for example `claude-review`) runs for pull requests into `epic/**` branches. It names each check whose workflow does not, and each check it could not map to one workflow. A warning only. Fix: Add `epic/**` to the `pull_request` branches of each named check's workflow and merge that change.
35
+ - **Worker environment declarations** (`server.worker-environment`) — Workers will start with the database and environment variables they need: a worker database is declared when CI provides one, and a profile with local test commands declares its worker variables (without them, workers start with none of the default variables). Names and counts only, never values. A warning only. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer` and declare the worker database and worker variables for the test gate.
33
36
  - **Service availability** (`server.service-availability`) — Bridge could read this repository's readiness from the server. Fix: Retry in a few minutes. If it keeps failing, email info@bridgegpt.ai.
34
37
  - **Claude login** (`install.claude-login`) — Claude Code is signed in on this computer. Fix: Run `claude` and sign in, then run setup again.
35
38
  - **Repository identity** (`install.identity`) — Bridge knows which repository this folder is. Fix: Run setup from the repository root, or pass `--repo <name>`.
@@ -39,6 +42,7 @@ Setup checks every item below for you, fixes what it can, and prints the one ste
39
42
  - **Integration credentials** (`install.integrations`) — The integration credentials this repository uses, such as Jira or GitHub, are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install`.
40
43
  - **GitHub connection** (`install.github`) — Bridge's GitHub App is connected to this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`.
41
44
  - **Repository indexing** (`install.indexing`) — The repository has been indexed by Bridge. Fix: Run `/parse-repository`, or let setup queue the index.
45
+ - **Run tools visible in MCP sessions** (`install.run-tools-visible`) — The MCP session this computer starts loads the Epic Implementer run tools (the `full` or `epic_implementer` group). Checked on this computer only; the server reports it as unknown. A warning only; it never blocks a launch. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`, accept the tool-visibility fix, then restart your MCP client.
42
46
  - **Conductor event ledger** (`conductor.ledger`) — The local Epic Implementer event ledger can be read. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.
43
47
  - **Conductor git hooks** (`conductor.git-hooks`) — Optional: the git hooks that feed the local event ledger are installed. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer install-git-hooks`.
44
48
  - **Epic Implementer MCP profile** (`conductor.mcp-profile`) — The `epic_implementer` tool profile is on in your MCP host. Fix: Let setup add it (it asks first), then restart your MCP client.