@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
@@ -66,8 +66,11 @@ const JAVASCRIPT_LOCKFILES = [
66
66
  "bun.lockb",
67
67
  ];
68
68
  const PYTHON_LOCKFILES = ["uv.lock", "poetry.lock", "requirements.txt"];
69
- /** Python manifests that name dependencies but that Bridge does not install. */
70
- const UNSUPPORTED_PYTHON_MANIFESTS = ["pyproject.toml", "Pipfile", "setup.py", "environment.yml"];
69
+ /**
70
+ * Python manifests that name dependencies but that Bridge does not install.
71
+ * BAPI-1698: exported so dependency discovery can name them as coverage gaps.
72
+ */
73
+ export const UNSUPPORTED_PYTHON_MANIFESTS = ["pyproject.toml", "Pipfile", "setup.py", "environment.yml"];
71
74
  /** Whether the set provisions nothing. */
72
75
  export function hasNoProvisionedToolchain(toolchains) {
73
76
  return toolchains.javascript === null && toolchains.python === null && toolchains.go === null;
@@ -530,11 +533,14 @@ export function installArgvForJavaScript(js) {
530
533
  }
531
534
  /**
532
535
  * BAPI-1551 — the fixed install argv for a Python toolchain. pip's argv is kept
533
- * for the description only: a bare `pip install` targets whatever interpreter is
534
- * first on `PATH`, so a dependency refresh never proposes it.
536
+ * for the toolchain description only: a bare `pip install` targets whatever
537
+ * interpreter is first on `PATH`, so a dependency refresh never proposes THIS
538
+ * argv. BAPI-1698: discovery may instead propose a separate, checkout-local
539
+ * `.venv` bootstrap for pip (see `proposeDependencyInstall`); this function and
540
+ * its description are unchanged by that.
535
541
  *
536
542
  * BAPI-1677 — `extras` holds only keys the install target declares. With none, every
537
- * caller's argv is byte-identical to before. pip takes none: it is never proposed.
543
+ * caller's argv is byte-identical to before. pip takes none.
538
544
  */
539
545
  export function installArgvForPython(py, extras = []) {
540
546
  switch (py.manager) {
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Saved Epic Implementer test commands: built-MCP `config_field` driver (BAPI-1699).
4
+ *
5
+ * A Python `subprocess` boundary that lets a real pytest suite drive the REAL built
6
+ * MCP server (`build/index.js`) over its normal stdio transport against the real
7
+ * FastAPI `/jira/config-field/*` routes, using only the registered `config_field`
8
+ * tool. It is test-support infrastructure, not an MCP tool.
9
+ *
10
+ * node saved-commands-config-field-driver.js <commandsJsonPath> <resultsJsonPath>
11
+ *
12
+ * `commandsJsonPath` holds `{ baseUrl, apiKey, repoName, calls: [...] }` and each call is
13
+ * `{ operation: "get" | "update", field_name, value? }`. Credentials arrive through the
14
+ * file and the child environment only, never argv. One MCP session serves every call;
15
+ * the results file gets `{ tools: string[], results: [{ isError, text }] }`. stdout stays
16
+ * empty so a caller never captures incidental noise.
17
+ */
18
+ import fs from "node:fs";
19
+ import path from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
22
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
23
+ async function main() {
24
+ const [commandsPath, resultsPath] = process.argv.slice(2);
25
+ if (!commandsPath || !resultsPath) {
26
+ process.stderr.write("usage: saved-commands-config-field-driver <commandsJsonPath> <resultsJsonPath>\n");
27
+ process.exit(2);
28
+ }
29
+ const input = JSON.parse(fs.readFileSync(commandsPath, "utf-8"));
30
+ const here = path.dirname(fileURLToPath(import.meta.url));
31
+ const transport = new StdioClientTransport({
32
+ command: "node",
33
+ args: [path.join(here, "..", "index.js")],
34
+ env: {
35
+ ...process.env,
36
+ BAPI_BASE_URL: input.baseUrl,
37
+ BAPI_API_KEY: input.apiKey,
38
+ BAPI_REPO_NAME: input.repoName,
39
+ BAPI_MCP_UPDATE_CHECK_ENABLED: "false",
40
+ },
41
+ stderr: "ignore",
42
+ });
43
+ const client = new Client({ name: "saved-commands-contract-driver", version: "0.0.1" });
44
+ const results = [];
45
+ let tools = [];
46
+ try {
47
+ await client.connect(transport);
48
+ tools = (await client.listTools()).tools.map((t) => t.name);
49
+ for (const call of input.calls) {
50
+ const response = (await client.callTool({ name: "config_field", arguments: { ...call } }));
51
+ const text = (response.content ?? []).map((c) => (c.type === "text" ? c.text ?? "" : "")).join("\n");
52
+ results.push({ isError: response.isError === true, text });
53
+ }
54
+ }
55
+ finally {
56
+ await transport.close();
57
+ }
58
+ const tmp = `${resultsPath}.tmp`;
59
+ fs.writeFileSync(tmp, JSON.stringify({ tools, results }), "utf-8");
60
+ fs.renameSync(tmp, resultsPath);
61
+ }
62
+ main().catch((error) => {
63
+ process.stderr.write(`saved-commands-config-field-driver failed: ${error instanceof Error ? error.message : String(error)}\n`);
64
+ process.exit(1);
65
+ });
@@ -15,6 +15,7 @@ const SECRET_PATTERNS = [
15
15
  // Well-known provider key shapes.
16
16
  [/\b(sk|pk|rk)-[A-Za-z0-9_-]{16,}/g, REDACTED],
17
17
  [/\bgh[pousr]_[A-Za-z0-9]{16,}/g, REDACTED],
18
+ [/\bgithub_pat_[A-Za-z0-9_]{16,}/g, REDACTED],
18
19
  // key/secret/password/token assignments in prose, env, JSON, or CLI form.
19
20
  [
20
21
  /\b([A-Za-z0-9_-]*(?:api[_-]?key|secret|password|passwd|token|credential)[A-Za-z0-9_-]*)\s*[:=]\s*("[^"]*"|'[^']*'|\S+)/gi,
@@ -22,6 +23,8 @@ const SECRET_PATTERNS = [
22
23
  ],
23
24
  // Credentials embedded in a URL.
24
25
  [/\b([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+:[^/\s@]+@/gi, `$1${REDACTED}@`],
26
+ // A bare token as the whole userinfo of an http(s) URL (`https://<token>@host`).
27
+ [/\b(https?:\/\/)[^/\s:@]+@/gi, `$1${REDACTED}@`],
25
28
  ];
26
29
  /** Redact secret-bearing substrings while leaving safe technical text intact. */
27
30
  export function redactSecrets(value) {
@@ -95,7 +95,8 @@ import { formatEpicLaunchChannelIdentity, getPinnedEpicLaunchPolicy, readEpicLau
95
95
  import { mapLegacyMergeExecutionModeToPolicyMode, resolveMergeExecutionMode, } from "./merge-pull-request.js";
96
96
  import { MERGE_EXECUTION_INELIGIBLE, MERGE_EXECUTION_MODE_GITHUB_ACTIONS, MERGE_WORKFLOW_CODEOWNER_INSTRUCTION, MERGE_WORKFLOW_REMEDY_COMMAND, } from "./conductor/merge-execution-contract.js";
97
97
  import { classifyMergeExecutionEligibility } from "./conductor/merge-execution-eligibility.js";
98
- import { repositoryWorkflowRemedy } from "./conductor/repository-workflow-remedy.js";
98
+ import { repositoryReadinessVerdict, requiredChecksAdmissionRemedy, requiredChecksAdmissionVerdict, } from "./conductor/repository-workflow-remedy.js";
99
+ import { gateProfileAwareRepositoryWorkflowRemedy } from "./conductor/readiness.js";
99
100
  import { resolveTrackedPaths } from "./git-reachability.js";
100
101
  import { validateBranchName } from "./base-ref.js";
101
102
  import { TICKET_KEY_PATTERN } from "./ticket-key-utils.js";
@@ -1827,6 +1828,10 @@ function uncertainty(reason) {
1827
1828
  export function isSetupEpicPrerequisiteWarning(value) {
1828
1829
  return typeof value === "object" && value !== null && value.warning === true;
1829
1830
  }
1831
+ /** BAPI-1714 — confirmed -> true, denied -> false, unknown -> null. */
1832
+ function verdictToFact(verdict) {
1833
+ return verdict === "confirmed" ? true : verdict === "denied" ? false : null;
1834
+ }
1830
1835
  /** The unattended facts of either input, each `null` when the input does not establish it. */
1831
1836
  function unattendedFactsOf(input) {
1832
1837
  if (input === null)
@@ -1849,7 +1854,10 @@ function unattendedFactsOf(input) {
1849
1854
  return {
1850
1855
  conductorAllowed: bool(unattended.conductor_allowed),
1851
1856
  webhookDefaultDeclared: bool(unattended.notify_webhook_default_declared),
1852
- repositoryReadinessConfirmed: bool(unattended.repository_readiness_confirmed),
1857
+ // BAPI-1714 — the shared verdict: `false` only for a PROVEN deficiency (the
1858
+ // server flag is false AND its admission record says denied). An unverifiable
1859
+ // read is `null`, which continues as uncertainty and never refuses.
1860
+ repositoryReadinessConfirmed: verdictToFact(repositoryReadinessVerdict(input)),
1853
1861
  emailAvailable: bool(unattended.escalation_email_available),
1854
1862
  emailTransport: transport !== undefined &&
1855
1863
  transport.severity !== null &&
@@ -1859,6 +1867,9 @@ function unattendedFactsOf(input) {
1859
1867
  : "unknown",
1860
1868
  };
1861
1869
  }
1870
+ /** BAPI-1714 — the snapshot-false refusal: a snapshot holds no workflow detail to name. */
1871
+ const SNAPSHOT_REPOSITORY_READINESS_REMEDY = "The repository's review or CI workflow is missing something an auto-merging run needs. " +
1872
+ `Run \`npx -y ${MCP_PACKAGE_NAME} epic-implementer readiness\` to see what; fix it, or pass \`--attended\`.`;
1862
1873
  export function evaluateSetupEpicUnattendedPrerequisites(readiness, requestedPolicy) {
1863
1874
  const facts = unattendedFactsOf(readiness);
1864
1875
  // A missing `unattended` block proves nothing (an older server, or an unreadable
@@ -1919,13 +1930,20 @@ export function evaluateSetupEpicUnattendedPrerequisites(readiness, requestedPol
1919
1930
  }
1920
1931
  if (facts.repositoryReadinessConfirmed === false) {
1921
1932
  // BAPI-1359: the shared formatter names the specific missing item; the reason
1922
- // code and the trailing sentence are unchanged. A snapshot carries no workflow
1923
- // detail, so it gets the formatter's own generic fallback.
1933
+ // code and the trailing sentence are unchanged.
1934
+ //
1935
+ // BAPI-1714: a full report gets the gate-aware remedy, which names only the
1936
+ // failing workflow section (no fixed opening that could name a workflow that
1937
+ // is fine). A snapshot carries no workflow detail, so it gets one fixed,
1938
+ // truthful message that points at the read-only readiness command. Neither
1939
+ // says "could not verify" or "Retry readiness": this refusal is a PROVEN
1940
+ // deficiency, never an unknown.
1941
+ const remedy = readiness !== null && !isReadinessSnapshot(readiness)
1942
+ ? gateProfileAwareRepositoryWorkflowRemedy(readiness)
1943
+ : SNAPSHOT_REPOSITORY_READINESS_REMEDY;
1924
1944
  return {
1925
1945
  reason: "repository_readiness_unconfirmed",
1926
- message: "the unattended default authorizes automatic merge, which requires the review and " +
1927
- "epic-implementer-ci workflows to be CONFIRMED on the default branch, and they are not. " +
1928
- `${repositoryWorkflowRemedy(readiness !== null && !isReadinessSnapshot(readiness) ? readiness : null)} No run was created.`,
1946
+ message: `${remedy} No run was created.`,
1929
1947
  };
1930
1948
  }
1931
1949
  if (facts.repositoryReadinessConfirmed === null)
@@ -2993,6 +3011,8 @@ export async function runSetupEpicWorkflow(argv, overrides = {}, handoff) {
2993
3011
  ...(sink.runPosture !== undefined ? { runPosture: sink.runPosture } : {}),
2994
3012
  ...(sink.launchOutcome !== undefined ? { launchOutcome: sink.launchOutcome } : {}),
2995
3013
  ...(sink.runStatus !== undefined ? { runStatus: sink.runStatus } : {}),
3014
+ ...(sink.storedPlanHash !== undefined ? { storedPlanHash: sink.storedPlanHash } : {}),
3015
+ ...(sink.orderingEdgesAdded !== undefined ? { orderingEdgesAdded: sink.orderingEdgesAdded } : {}),
2996
3016
  ...(sink.observations !== undefined && sink.observations.length > 0
2997
3017
  ? { observations: [...sink.observations] }
2998
3018
  : {}),
@@ -4009,8 +4029,12 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
4009
4029
  if (classified.status === "behind_target") {
4010
4030
  // One plain push (no force, no leading '+'). Whatever it returns, the remote
4011
4031
  // is re-read once; only an exact match with the cut lets setup continue.
4032
+ // `--no-verify`, as in the exact cut (epic-shared/cut-protocol.ts): this push
4033
+ // sends no new code, only moves the branch forward to the canonical indexed
4034
+ // commit. A repository's pre-push hook (tests, Husky, pre-commit) would
4035
+ // otherwise run here with an inherited environment and can block the launch.
4012
4036
  try {
4013
- await runGit(gitDeps, ["push", "origin", `${cutCommitSha}:refs/heads/${branch}`]);
4037
+ await runGit(gitDeps, ["push", "--no-verify", "origin", `${cutCommitSha}:refs/heads/${branch}`]);
4014
4038
  }
4015
4039
  catch { /* judged by the re-read below */ }
4016
4040
  let reread;
@@ -4231,6 +4255,17 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
4231
4255
  deps.errorLog(`setup-epic REFUSED (${unattended.reason}): ${unattended.message}`);
4232
4256
  return 1;
4233
4257
  }
4258
+ // BAPI-1526 — first approval would refuse this create's required checks.
4259
+ // `launchReadiness` is the policy-aware report for this same
4260
+ // `composedForCreate`, so the server already exempted any policy approval
4261
+ // would exempt. Only a proven denial refuses, and only before a run exists:
4262
+ // a `null` report (the POST failed) or any other record continues, and
4263
+ // approval stays the authority. A drive-epic create delegates here, so both
4264
+ // entry points refuse before the run row exists.
4265
+ if (existingRunId === null && requiredChecksAdmissionVerdict(launchReadiness) === "denied") {
4266
+ deps.errorLog(`setup-epic REFUSED (required_checks_admission_denied): ${requiredChecksAdmissionRemedy(launchReadiness)} No run was created.`);
4267
+ return 1;
4268
+ }
4234
4269
  }
4235
4270
  }
4236
4271
  try {
@@ -4527,8 +4562,15 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
4527
4562
  result.plan_stored = true;
4528
4563
  runIdSink.planStored = true;
4529
4564
  const serverHash = stored?.plan_hash;
4530
- if (typeof serverHash === "string")
4565
+ if (typeof serverHash === "string") {
4531
4566
  result.plan_hash = serverHash;
4567
+ runIdSink.storedPlanHash = serverHash;
4568
+ }
4569
+ // BAPI-1706 — optional: an older server omits it, and absence stays absence.
4570
+ const edgesAdded = stored?.ordering_edges_added;
4571
+ if (typeof edgesAdded === "number" && Number.isSafeInteger(edgesAdded) && edgesAdded >= 0) {
4572
+ runIdSink.orderingEdgesAdded = edgesAdded;
4573
+ }
4532
4574
  say(`Plan: stored v${plan.plan_version}`);
4533
4575
  }
4534
4576
  catch (err) {
@@ -0,0 +1,232 @@
1
+ /**
2
+ * A small, hermetic `drive-epic` CREATE-preview world for tests outside `drive-epic.test.ts`.
3
+ *
4
+ * It is the same recipe the drive-epic suite uses: every boundary is an in-memory fake, every
5
+ * plane or launch seam throws when reached, and the plan comes from a supplied `--plan-file`
6
+ * whose DAG is served from memory. A preview built here reaches the decision `create`, so the
7
+ * launch-plan facts, and with them the BAPI-1718 UI readiness advisory, are collected.
8
+ *
9
+ * `runDriveEpicCli` merges its overrides over the production defaults. Every seam a create
10
+ * preview could reach is therefore named here, so a test never touches the network, `gh`, `git`,
11
+ * the owner's home, or a real credential.
12
+ */
13
+ import { resolve as nativePath } from "node:path";
14
+ import { runDriveEpicCli } from "../drive-epic.js";
15
+ import { buildEpicLaunchContext } from "../epic-launch-context.js";
16
+ import { inspectHostSleep } from "../plane/plane-freshness.js";
17
+ export const PREVIEW_WORLD_SENTINEL_KEY = "preview-world-secret-do-not-print";
18
+ export const PREVIEW_WORLD_EPIC = "BAPI-1275";
19
+ export const PREVIEW_WORLD_PLAN_PATH = nativePath("/supplied/plan.json");
20
+ export const PREVIEW_WORLD_ACCESS = {
21
+ repoName: "bapi",
22
+ apiKey: PREVIEW_WORLD_SENTINEL_KEY,
23
+ baseUrl: "https://example.invalid",
24
+ };
25
+ /** A fully green readiness report: the preview reaches `create`. */
26
+ export function greenPreviewReadiness(repoName = "bapi") {
27
+ return {
28
+ repo_name: repoName,
29
+ merge_execution: {
30
+ branch_scope: "default_branch",
31
+ branch_protection_probe_succeeded: true,
32
+ branch_protection_actions_bot_admitted: true,
33
+ merge_workflow_probe_succeeded: true,
34
+ merge_workflow_present: true,
35
+ merge_workflow_enabled: true,
36
+ merge_workflow_version: 1,
37
+ merge_workflow_token_write_authority: true,
38
+ },
39
+ bring_up: {
40
+ migration_readable: true,
41
+ database_migration_current: true,
42
+ heartbeat_readable: true,
43
+ worker_present: true,
44
+ fresh_reconciler_count: 1,
45
+ single_transition_authority: true,
46
+ },
47
+ supervisor: {
48
+ setup_present: true,
49
+ setup_source: "project_default",
50
+ setup_created_at: null,
51
+ setup_updated_at: null,
52
+ config_present: true,
53
+ config_source: "project_default",
54
+ config_created_at: null,
55
+ config_updated_at: null,
56
+ required_checks_count: 2,
57
+ required_checks_empty: false,
58
+ auto_merge_enabled: true,
59
+ merge_approval_required_set: true,
60
+ review_policy_alignment: null,
61
+ review_policy_present: true,
62
+ },
63
+ github: {
64
+ credentials_readable: true,
65
+ owner_resolved: true,
66
+ repo_id_resolved: true,
67
+ installation_id_resolved: true,
68
+ credentials_complete: true,
69
+ actions_probe_succeeded: true,
70
+ actions_permission_present: true,
71
+ actions_permission_level: "read",
72
+ actions_write: false,
73
+ },
74
+ reconciler: {
75
+ liveness_readable: true,
76
+ last_tick_at: "2026-08-21T00:00:00Z",
77
+ last_tick_age_seconds: 5,
78
+ stale: false,
79
+ active_run_count: 0,
80
+ expired_lease_count: 0,
81
+ },
82
+ executor: {
83
+ liveness_readable: true,
84
+ last_seen_at: "2026-08-21T00:00:00Z",
85
+ last_seen_age_seconds: 5,
86
+ ready: true,
87
+ },
88
+ thresholds: { reconciler_stale_after_seconds: 120, executor_stale_after_seconds: 120 },
89
+ review_workflow: null,
90
+ conductor_ci_workflow: null,
91
+ unattended: {
92
+ conductor_allowed: true,
93
+ notify_webhook_default_declared: true,
94
+ notify_webhook_default_verified: true,
95
+ repository_readiness_confirmed: true,
96
+ },
97
+ };
98
+ }
99
+ function refuse(name) {
100
+ throw new Error(`${name} must not be reached by a create preview`);
101
+ }
102
+ export function createPreviewWorld(o) {
103
+ const out = [];
104
+ const err = [];
105
+ const mutations = [];
106
+ const repoName = o.repoName ?? PREVIEW_WORLD_ACCESS.repoName;
107
+ const access = { ...PREVIEW_WORLD_ACCESS, repoName };
108
+ const readiness = greenPreviewReadiness(repoName);
109
+ const dag = JSON.stringify({
110
+ plan_version: 1,
111
+ nodes: o.keys.map((ticket_key, i) => ({
112
+ ticket_key,
113
+ status: "planned",
114
+ depends_on: i === 0 ? [] : [o.keys[i - 1]],
115
+ automations: [],
116
+ ...(o.touchedFiles?.[ticket_key] !== undefined ? { touched_files: o.touchedFiles[ticket_key] } : {}),
117
+ })),
118
+ edges: o.keys.slice(1).map((key, i) => ({ from: o.keys[i], to: key })),
119
+ });
120
+ const deps = {
121
+ inspectRepositoryIdentity: async () => ({ repoRoot: nativePath("/repo"), isBridge: true }),
122
+ resolveAccess: async () => ({ ok: true, access }),
123
+ adoptLaunchTarget: () => undefined,
124
+ readReadiness: async () => readiness,
125
+ // A launch reads no readiness; the preview's stored snapshot is never read back here.
126
+ readScopeBaseBranch: async () => "main",
127
+ readLaunchContext: async (binding) => ({
128
+ kind: "usable",
129
+ value: {
130
+ sourceVersion: 2,
131
+ context: buildEpicLaunchContext({
132
+ epicKey: binding.epicKey,
133
+ baseBranch: binding.baseBranch,
134
+ targetBaseUrl: binding.targetBaseUrl,
135
+ writtenAt: binding.now,
136
+ readiness: { kind: "ready", readiness, attempts: 1 },
137
+ repoName: binding.repository?.repoName ?? null,
138
+ isBridge: binding.repository?.isBridge ?? null,
139
+ serverPlanDigest: "digest-0123456789",
140
+ }),
141
+ },
142
+ }),
143
+ writeLaunchContext: async () => ({ ok: true, path: "(not written in tests)" }),
144
+ writeLaunchOutcome: async () => ({ ok: true, path: "(not written in tests)" }),
145
+ reportLaunch: () => undefined,
146
+ resolveDocsDir: async () => ({ ok: true, docsDir: nativePath("/repo/docs/tmp") }),
147
+ discoveryFs: {
148
+ readdir: async () => { throw Object.assign(new Error("ENOENT"), { code: "ENOENT" }); },
149
+ readFile: async () => { throw new Error("ENOENT"); },
150
+ },
151
+ readPlanDag: async () => dag,
152
+ readPolicyFile: async () => { throw new Error("ENOENT: no fixture policy"); },
153
+ readLiveEpicRun: async () => ({ kind: "none" }),
154
+ readEligibilityArtifact: async () => { throw new Error("ENOENT: no fixture artifact"); },
155
+ previewSetupEpic: async () => ({
156
+ exitCode: 0,
157
+ stdout: [JSON.stringify({
158
+ dry_run: true,
159
+ epic_key: PREVIEW_WORLD_EPIC,
160
+ repo_name: repoName,
161
+ plan_version: 1,
162
+ local_plan_hash: "sha256:abc",
163
+ existing_run_id: null,
164
+ feature_branch: `epic/${PREVIEW_WORLD_EPIC}`,
165
+ server_validated: true,
166
+ policy_applied: "absent",
167
+ warnings: [],
168
+ create_policy: {
169
+ posture: "unattended",
170
+ v2_auto_merge_enabled: true,
171
+ merge_execution_mode: "machine_token",
172
+ integration_preparation: { enabled: true },
173
+ },
174
+ })],
175
+ stderr: [],
176
+ }),
177
+ inspectRunExecutorPrecondition: async () => ({ ok: true }),
178
+ // Nothing that creates, prepares, or starts a run may run.
179
+ runSetupEpic: async () => { mutations.push("runSetupEpic"); return refuse("runSetupEpic"); },
180
+ prepareRunExecutor: async () => { mutations.push("prepareRunExecutor"); return refuse("prepareRunExecutor"); },
181
+ ensureRunExecutor: async () => { mutations.push("ensureRunExecutor"); return refuse("ensureRunExecutor"); },
182
+ runPlane: async () => { mutations.push("runPlane"); return refuse("runPlane"); },
183
+ launchControlPlane: async () => { mutations.push("launchControlPlane"); return refuse("launchControlPlane"); },
184
+ requestScopedLanes: async () => { mutations.push("requestScopedLanes"); return refuse("requestScopedLanes"); },
185
+ runPlanePreflight: async () => refuse("runPlanePreflight"),
186
+ probePlanePort: async () => refuse("probePlanePort"),
187
+ readRunState: async () => refuse("readRunState"),
188
+ readPlaneReconcilerState: async () => refuse("readPlaneReconcilerState"),
189
+ readPlaneManifest: async () => refuse("readPlaneManifest"),
190
+ cleanupTerminalRunPlane: async () => refuse("cleanupTerminalRunPlane"),
191
+ listLiveRunIds: async () => refuse("listLiveRunIds"),
192
+ resolvePlaneEndpoint: () => ({
193
+ ok: true,
194
+ endpoint: { host: "127.0.0.1", port: 8000, baseUrl: "http://127.0.0.1:8000" },
195
+ }),
196
+ cwd: () => nativePath("/repo"),
197
+ // Hermetic launch-need probes: each answers "could not tell".
198
+ inspectRequiredRunners: async () => ({ state: "unverifiable", reason: "probe_failed" }),
199
+ inspectHostSleep: (root) => inspectHostSleep(root, { execFile: async () => refuse("pmset"), platform: "linux" }),
200
+ execEngineStatus: undefined,
201
+ runCommand: async () => ({ exitCode: 0, stdout: "", stderr: "" }),
202
+ launchSleep: async () => undefined,
203
+ attemptPlanGeneration: undefined,
204
+ publishGeneratedPlan: undefined,
205
+ lookupAuthoredPlan: undefined,
206
+ uploadAuthoredPlan: undefined,
207
+ materializeAuthoredPlan: undefined,
208
+ readPrerequisiteCache: async () => ({ kind: "unavailable" }),
209
+ // The advisory UI readiness reads are the test's to install; absent means unavailable.
210
+ readUiTicketDescription: undefined,
211
+ listUiTrackedFiles: undefined,
212
+ readUiMcpGrant: undefined,
213
+ readUiEpicServerRecord: undefined,
214
+ log: (line) => out.push(line),
215
+ errorLog: (line) => err.push(line),
216
+ ...o.seams,
217
+ };
218
+ return {
219
+ deps,
220
+ out,
221
+ err,
222
+ mutations,
223
+ preview: async (extraArgv = [], options = {}) => {
224
+ out.length = 0;
225
+ err.length = 0;
226
+ const json = options.json !== false;
227
+ const code = await runDriveEpicCli([PREVIEW_WORLD_EPIC, "--plan-file", PREVIEW_WORLD_PLAN_PATH, "--dry-run", ...(json ? ["--json"] : []), ...extraArgv], deps);
228
+ const doc = (json ? JSON.parse(out[0] ?? "null") : null);
229
+ return { code, doc, text: [...out, ...err].join("\n") };
230
+ },
231
+ };
232
+ }
@@ -53,6 +53,7 @@ export const EXECUTOR_FLAT_IMPORT_BASELINE = [
53
53
  "./interrupted-worktree.js",
54
54
  "./job-errors.js",
55
55
  "./job-log-registry.js",
56
+ "./job-type-wrappers.js",
56
57
  "./job-types.js",
57
58
  "./live-worker-registry.js",
58
59
  "./merge-job.js",
@@ -74,7 +75,6 @@ export const EXECUTOR_FLAT_IMPORT_BASELINE = [
74
75
  "./resume-pre-spawn.js",
75
76
  "./spawn-job-driver.js",
76
77
  "./stale-artifacts.js",
77
- "./terminal-mutation.js",
78
78
  "./types.js",
79
79
  "./verdict-artifact.js",
80
80
  "./verification-hints.js",
@@ -13,6 +13,71 @@
13
13
  */
14
14
  import { redactSecrets } from "./secret-redaction.js";
15
15
  export const READINESS_BOUNDARIES = ["publish", "merge", "complete"];
16
+ // ---------------------------------------------------------------------------
17
+ // Presentation: a draft opened because verification gaps are recorded (BAPI-1712)
18
+ // ---------------------------------------------------------------------------
19
+ /** The server's publication reason for a draft opened over admitted gaps. */
20
+ export const PUBLICATION_REASON_VERIFICATION_GAPS = "verification_gaps_recorded";
21
+ const GAP_DRAFT_MESSAGE = "A draft pull request is the successful publication for this run. It is not a hold " +
22
+ "and not proof that verification passed: the recorded gaps stay unverified and are " +
23
+ "disclosed in the PR body's managed Unverified gaps section. Continue the recipe.";
24
+ function isPlainRecord(value) {
25
+ return value !== null && typeof value === "object" && !Array.isArray(value);
26
+ }
27
+ /**
28
+ * The gap-draft note for a readiness view, or `undefined` for any other outcome.
29
+ *
30
+ * Presentation only: it reads the server's publication decision and never decides
31
+ * anything. It applies when the action is `draft_pr` and either the reason is
32
+ * `verification_gaps_recorded` or readiness lists recorded gaps (an explicit draft
33
+ * request can change the reason the server reports).
34
+ */
35
+ export function gapDraftPublicationNote(readiness) {
36
+ if (!isPlainRecord(readiness))
37
+ return undefined;
38
+ const publication = readiness.publication;
39
+ if (!isPlainRecord(publication) || publication.action !== "draft_pr")
40
+ return undefined;
41
+ const gaps = Array.isArray(readiness.recorded_gaps)
42
+ ? readiness.recorded_gaps
43
+ : undefined;
44
+ const reason = typeof publication.reason === "string" ? publication.reason : "";
45
+ if (reason !== PUBLICATION_REASON_VERIFICATION_GAPS && !(gaps && gaps.length > 0)) {
46
+ return undefined;
47
+ }
48
+ const disclosure = readiness.disclosure;
49
+ const markdown = isPlainRecord(disclosure) && typeof disclosure.markdown === "string" ? disclosure.markdown : undefined;
50
+ return {
51
+ outcome: "draft_published_with_verification_gaps",
52
+ published: true,
53
+ held: false,
54
+ verification_complete: false,
55
+ reason,
56
+ message: GAP_DRAFT_MESSAGE,
57
+ ...(gaps ? { recorded_gaps: gaps } : {}),
58
+ ...(markdown !== undefined ? { disclosure_markdown: markdown } : {}),
59
+ };
60
+ }
61
+ /**
62
+ * Annotate a successful `create_pull_request` reply (`detail.delivery` is the
63
+ * readiness view) with the gap-draft note. Any other reply, or text that is not
64
+ * a JSON object, is returned byte for byte.
65
+ */
66
+ export function annotateGapDraftPublication(text) {
67
+ let parsed;
68
+ try {
69
+ parsed = JSON.parse(text);
70
+ }
71
+ catch {
72
+ return text;
73
+ }
74
+ if (!isPlainRecord(parsed) || !isPlainRecord(parsed.detail))
75
+ return text;
76
+ const note = gapDraftPublicationNote(parsed.detail.delivery);
77
+ if (!note)
78
+ return text;
79
+ return JSON.stringify({ ...parsed, publication_outcome: note }, null, 2);
80
+ }
16
81
  const STATUS_CODES = {
17
82
  400: "BAD_REQUEST",
18
83
  401: "UNAUTHORIZED",
@@ -1,5 +1,6 @@
1
1
  import { mergeReadinessPrerequisites, formatReadinessPrerequisites } from "./conductor/readiness-prerequisites.js";
2
2
  import { READINESS_PREREQUISITE_BY_ID, READINESS_LEGACY_IDS } from "./readiness-prerequisites.generated.js";
3
+ import { indexedWorkflowsDisplayRemedy } from "./printed-remedy-commands.js";
3
4
  /**
4
5
  * The v2 readiness requirement catalog and its row projection (BAPI-1452).
5
6
  *
@@ -24,7 +25,7 @@ import { READINESS_PREREQUISITE_BY_ID, READINESS_LEGACY_IDS } from "./readiness-
24
25
  * names (from the dependency-free `conductor/merge-credential.ts`), nothing else.
25
26
  */
26
27
  import { gateProfileWaivesCiWorkflow, isProviderRepositoryIdentity, } from "./conductor/bridge-api-client.js";
27
- import { repositoryWorkflowRemedy } from "./conductor/repository-workflow-remedy.js";
28
+ import { repositoryReadinessVerdict, repositoryWorkflowRemedy, } from "./conductor/repository-workflow-remedy.js";
28
29
  import { LOCAL_MERGE_CREDENTIAL_ENV_KEYS } from "./conductor/merge-credential.js";
29
30
  import { createReadinessCheckSafely } from "./readiness-check.js";
30
31
  /**
@@ -137,7 +138,13 @@ const LEGACY_V2_READINESS_REQUIREMENTS = [
137
138
  // profile is never told to add a file it does not need. Gate-profile WARNINGS
138
139
  // (epic-branch rows) are not requirements and are never read here.
139
140
  remedyFor: (r) => repositoryWorkflowRemedy(gateProfileWaivesCiWorkflow(r) ? { ...r, conductor_ci_workflow: null } : r),
140
- satisfied: (r) => r.unattended?.repository_readiness_confirmed === true,
141
+ // BAPI-1714: only a PROVEN deficiency refuses. The verdict is `denied` when
142
+ // the server's aggregate flag is false AND its `repository_readiness`
143
+ // admission record says denied; an unverifiable read is `unknown` and passes
144
+ // here (first approval re-checks it). This replaces the client-side override
145
+ // that used to bypass this predicate whenever the server sent prerequisites,
146
+ // which is why preview was green while create refused.
147
+ satisfied: (r) => repositoryReadinessVerdict(r) !== "denied",
141
148
  },
142
149
  // BAPI-1135 — merge-execution eligibility is deliberately NOT a requirement here.
143
150
  //
@@ -175,7 +182,6 @@ export const V2_READINESS_REQUIREMENTS = [
175
182
  const descriptor = READINESS_PREREQUISITE_BY_ID.get(id);
176
183
  return { ...req, id, describe: descriptor?.label ?? req.describe,
177
184
  governedRowIds: req.governedRowIds.map(row => READINESS_LEGACY_IDS[row] ?? row),
178
- ...(req.id === 'repository_readiness' ? { satisfied: (r) => r.prerequisites !== undefined ? true : req.satisfied(r) } : {}),
179
185
  ...(req.id === 'unattended_notify_default' ? {
180
186
  satisfied: (r) => !r.prerequisites?.some(p => p.id === id && p.check_status === 'not_met' && p.impact === 'blocking'),
181
187
  remedyFor: (r) => r.prerequisites?.find(p => p.id === id)?.fix ?? 'Retry readiness.',
@@ -185,7 +191,10 @@ export const V2_READINESS_REQUIREMENTS = [
185
191
  ...NEW_IDS.filter(id => id !== 'server.unattended-notify-default').map(id => ({
186
192
  id, describe: READINESS_PREREQUISITE_BY_ID.get(id).label, governedRowIds: [id], unattendedOnly: true,
187
193
  satisfied: (r) => !r.prerequisites?.some(p => p.id === id && p.check_status === 'not_met' && p.impact === 'blocking'),
188
- remedyFor: (r) => r.prerequisites?.find(p => p.id === id)?.fix ?? 'Retry readiness.',
194
+ remedyFor: (r) => {
195
+ const row = r.prerequisites?.find(p => p.id === id);
196
+ return row === undefined ? 'Retry readiness.' : indexedWorkflowsDisplayRemedy(row, r);
197
+ },
189
198
  })),
190
199
  // BAPI-1585 — two launch checks the server evaluates only on a launch path. The
191
200
  // webhook row is unattended-only (it is not_applicable otherwise). The provider
@@ -1,4 +1,4 @@
1
1
  // AUTO-GENERATED — do not edit manually. Regenerate with: npm run build
2
- export const VERSION = "0.2.74";
3
- export const BUILD_COMMIT = "0d017bd07c69";
4
- export const LAUNCHER_ARGS = ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.74", "serve"];
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"];