@bridge_gpt/mcp-server 0.2.51 → 0.2.53

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 (79) hide show
  1. package/README.md +59 -13
  2. package/build/agent-capabilities/probe-context.js +15 -7
  3. package/build/agent-capabilities/probes.js +42 -6
  4. package/build/agent-launchers/claude-executor-adapter.js +98 -14
  5. package/build/commands.generated.js +7 -5
  6. package/build/conduct-epic/cut-protocol.js +17 -3
  7. package/build/conductor/bridge-api-client.js +232 -5
  8. package/build/conductor/cli.js +23 -0
  9. package/build/conductor/deny-enforcement-preflight.js +107 -10
  10. package/build/conductor/doctor.js +428 -5
  11. package/build/conductor/install-doctor.js +65 -656
  12. package/build/conductor/local-merge.js +170 -11
  13. package/build/conductor/readiness-cli.js +152 -0
  14. package/build/conductor/readiness-sections.js +666 -0
  15. package/build/conductor/readiness.js +710 -0
  16. package/build/conductor/tools.js +56 -3
  17. package/build/conductor-bin.js +21 -17
  18. package/build/connect-bitbucket-api.js +370 -0
  19. package/build/connect-bitbucket.js +437 -0
  20. package/build/docs.generated.js +1 -1
  21. package/build/doctor.js +40 -1
  22. package/build/drive-epic.js +423 -11
  23. package/build/env-file-link.js +164 -0
  24. package/build/epic-integration-pr.js +10 -0
  25. package/build/executor/cli.js +41 -6
  26. package/build/executor/deps.js +5 -1
  27. package/build/executor/env-file-guard.js +113 -0
  28. package/build/executor/env.js +78 -1
  29. package/build/executor/heartbeat.js +9 -0
  30. package/build/executor/http-client.js +90 -22
  31. package/build/executor/job-errors.js +43 -2
  32. package/build/executor/job-runner.js +130 -28
  33. package/build/executor/merge-job.js +67 -16
  34. package/build/executor/permissions.js +106 -0
  35. package/build/executor/preflight.js +38 -13
  36. package/build/executor/resume-pre-spawn.js +2 -1
  37. package/build/executor/runner.js +175 -4
  38. package/build/executor/service-unit.js +15 -0
  39. package/build/executor/terminal-mutation.js +22 -1
  40. package/build/executor/types.js +86 -0
  41. package/build/executor/worker-command.js +21 -5
  42. package/build/executor/worker-guard-hook.js +939 -0
  43. package/build/executor/worker-log.js +56 -0
  44. package/build/executor/worktree.js +11 -0
  45. package/build/git-reachability.js +147 -0
  46. package/build/index.js +4734 -4270
  47. package/build/install-bridge.js +95 -0
  48. package/build/install-doctor.js +154 -2
  49. package/build/pipelines.generated.js +6 -4
  50. package/build/plan-epic-conductor-eligibility.js +37 -7
  51. package/build/plane/alembic-head.js +40 -11
  52. package/build/plane/build-freshness.js +22 -11
  53. package/build/plane/cli.js +78 -15
  54. package/build/plane/defaults.js +165 -0
  55. package/build/plane/manifest.js +63 -8
  56. package/build/plane/member-logs.js +6 -0
  57. package/build/plane/member-roster.js +195 -11
  58. package/build/plane/preflight.js +402 -44
  59. package/build/plane/shutdown.js +25 -3
  60. package/build/plane/status.js +11 -0
  61. package/build/plane/supervisor.js +343 -14
  62. package/build/plane/test-fakes.js +43 -0
  63. package/build/plane/types.js +118 -11
  64. package/build/pr-base-contract.js +20 -0
  65. package/build/readiness-check.js +412 -0
  66. package/build/readme.generated.js +1 -1
  67. package/build/review-synthesis-config.js +60 -0
  68. package/build/scripts/executor-protocol-contract-driver.js +311 -0
  69. package/build/setup-epic.js +560 -139
  70. package/build/sfcc/log-query.js +2 -1
  71. package/build/start-tickets-conductor.js +11 -2
  72. package/build/start-tickets.js +69 -2
  73. package/build/version.generated.js +3 -3
  74. package/build/worker-containment-diagnostic.js +97 -0
  75. package/build/worker-guard-hook-bin.js +6 -0
  76. package/docs/CONDUCTOR.md +27 -0
  77. package/docs/install/mcp-tool-integrations.md +3 -2
  78. package/package.json +4 -3
  79. package/pipelines/{full-automation.json → idea-to-pr.json} +1 -1
@@ -255,6 +255,17 @@ export function buildExecutorServiceArguments(input) {
255
255
  for (const repo of input.repos)
256
256
  args.push("--repo", repo);
257
257
  args.push("--executor-id", input.executorId);
258
+ // BAPI-1026 (R54): forward the claim scope. Repeated `--epic-run-id <id>`
259
+ // pairs mirror how the operator supplied them, or the single `--repo-wide`
260
+ // opt-out. Appended last so the pre-existing prefix/repo/executor-id ordering
261
+ // — which several artifact tests pin positionally — is unchanged.
262
+ if (input.epicRunIds !== undefined) {
263
+ for (const runId of input.epicRunIds)
264
+ args.push("--epic-run-id", runId);
265
+ }
266
+ else if (input.repoWide === true) {
267
+ args.push("--repo-wide");
268
+ }
258
269
  return args;
259
270
  }
260
271
  // ---------------------------------------------------------------------------
@@ -845,6 +856,10 @@ export async function runExecutorInstallServiceCli(argv, overrides) {
845
856
  baseUrl,
846
857
  homeDir: deps.homeDir,
847
858
  envPath,
859
+ // Forwarded from the already-validated parse, so the generated unit starts
860
+ // with the same claim scope the operator typed (BAPI-1026).
861
+ ...(options.epicRunIds !== undefined ? { epicRunIds: options.epicRunIds } : {}),
862
+ ...(options.repoWide === true ? { repoWide: true } : {}),
848
863
  };
849
864
  // Windows has no generated user-service format here: print the fully resolved,
850
865
  // secret-free command line plus manual Task Scheduler guidance and stop. No
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Terminal mutation (complete/fail) retry semantics (BAPI-534, TDD §10).
3
+ *
4
+ * - `updated` → terminal success.
5
+ * - `stale_claim` → definitive loss of ownership; stop touching worktree.
6
+ * - `retry_later` / net → retryable at the heartbeat interval WHILE the dead-man
7
+ * window has not elapsed; then abandon.
8
+ * - `invalid_job_result` → (complete only) terminal non-success; the server has
9
+ * already failed the job, so DO NOT then call `/fail`.
10
+ *
11
+ * Retry diagnostics are bounded and never include raw result envelopes, secrets,
12
+ * or unbounded stdout/stderr.
13
+ */
14
+ import { normalizeMutationResult } from "./types.js";
1
15
  /**
2
16
  * Send a terminal mutation with the fencing-aware retry policy. Skips entirely
3
17
  * when ownership was already abandoned.
@@ -7,9 +21,16 @@ export async function sendTerminalMutationWithRetry(params) {
7
21
  if (ownership.abandoned)
8
22
  return { outcome: "skipped" };
9
23
  while (true) {
10
- const outcome = await params.send();
24
+ const mapped = normalizeMutationResult(await params.send());
25
+ const outcome = mapped.outcome;
11
26
  if (outcome === "updated")
12
27
  return { outcome: "success" };
28
+ if (outcome === "auth_fatal") {
29
+ // Return immediately after exactly one send attempt — no dead-man sleep
30
+ // or retry. Deliberately does NOT set `ownership.abandoned` (this is not
31
+ // a lost/stale claim) and never invokes `send()` a second time.
32
+ return { outcome: "auth_fatal", httpStatus: mapped.authHttpStatus ?? 401 };
33
+ }
13
34
  if (outcome === "stale_claim") {
14
35
  ownership.abandoned = true;
15
36
  ownership.abandonReason = "stale_claim";
@@ -1,3 +1,89 @@
1
+ /**
2
+ * Server-authoritative executor job types (T2 `ExecutorJobType` literal,
3
+ * mirrors `EXECUTOR_JOB_TYPE_VALUES` in `api/models/executor_job.py`).
4
+ *
5
+ * BAPI-997 (T4): the runtime array is the single source, and `ExecutorJobType`
6
+ * is DERIVED from it via `(typeof VALUES)[number]` rather than declared
7
+ * independently — adding or removing a value here changes the emitted
8
+ * JavaScript array (visible to a Node contract driver) and the compile-time
9
+ * union in one edit, so the two can never drift apart.
10
+ */
11
+ export const EXECUTOR_JOB_TYPE_VALUES = [
12
+ "implement",
13
+ "resume",
14
+ "spec_review",
15
+ "remediate",
16
+ "rebase",
17
+ "ci_fix",
18
+ "merge",
19
+ "smoke",
20
+ ];
21
+ /**
22
+ * Server-authoritative completion classification (T2 `ExecutorClassification`,
23
+ * mirrors `EXECUTOR_CLASSIFICATION_VALUES` in `api/models/executor_job.py`).
24
+ * The local process owner produces the first four; `no_progress`/`lease_expired`
25
+ * are reserved for server/other paths.
26
+ *
27
+ * BAPI-997 (T4): derived from the runtime array, same rationale as
28
+ * {@link EXECUTOR_JOB_TYPE_VALUES} above.
29
+ */
30
+ export const EXECUTOR_CLASSIFICATION_VALUES = [
31
+ "clean_exit",
32
+ "timeout",
33
+ "killed",
34
+ "crashed",
35
+ "no_progress",
36
+ "lease_expired",
37
+ ];
38
+ /**
39
+ * Outcome of a heartbeat/complete/fail mutation (T2 status mapping):
40
+ * - `updated` 2xx `{ ok: true }`
41
+ * - `stale_claim` 409 STALE_CLAIM — definitive dead claim (dead-man's switch)
42
+ * - `retry_later` 503 RETRY_LATER — transient; keep worker alive, retry
43
+ * - `invalid_job_result` 422 INVALID_JOB_RESULT on /complete — job failed server-side
44
+ * - `auth_fatal` 401/403 — BAPI-1021 (AC-5): a Bridge auth/access failure.
45
+ * Distinct from `fatal_http_error` because it must bypass the dead-man retry
46
+ * loop and halt the executor immediately rather than waiting out the deadman
47
+ * window on a credential that will never become valid again.
48
+ * - `fatal_http_error` parse/other non-retryable, NON-AUTH failure. Reserved
49
+ * for exactly that now that `auth_fatal` exists — 401/403 map to `auth_fatal`
50
+ * before this fallback is ever reached.
51
+ *
52
+ * BAPI-997 (T4): derived from the runtime array, same rationale as
53
+ * {@link EXECUTOR_JOB_TYPE_VALUES} above.
54
+ */
55
+ export const EXECUTOR_MUTATION_OUTCOME_VALUES = [
56
+ "updated",
57
+ "stale_claim",
58
+ "retry_later",
59
+ "invalid_job_result",
60
+ "fatal_http_error",
61
+ "auth_fatal",
62
+ ];
63
+ /** Normalize either mutation response form into the structured shape. */
64
+ export function normalizeMutationResult(response) {
65
+ return typeof response === "string" ? { outcome: response } : response;
66
+ }
67
+ /**
68
+ * Server-minted reconciler/dispatcher liveness, carried on a claim response
69
+ * header (BAPI-871).
70
+ *
71
+ * SERVER-AUTHORED, and that is the whole contract. The backend derives this from
72
+ * the durable `process_heartbeats` row; the executor only reads it. Nothing here
73
+ * may be inferred from HTTP 204, an empty queue, elapsed polling time, a response
74
+ * body, or a local scheduler setting — those are exactly the proxies that made
75
+ * "nothing to do" ambiguous in the first place.
76
+ *
77
+ * `unknown` means the verdict is UNEVALUABLE — the header was absent (an older
78
+ * backend), unrecognized, or the server could not read its own durable source.
79
+ * It is not a claim that the dispatcher is absent.
80
+ *
81
+ * BAPI-997 (T4): derived from the runtime array, same rationale as
82
+ * {@link EXECUTOR_JOB_TYPE_VALUES} above. `http-client.ts`'s
83
+ * `parseReconcilerLivenessHeader` admits values from this projection rather
84
+ * than maintaining an independent literal set.
85
+ */
86
+ export const RECONCILER_LIVENESS_VALUES = ["fresh", "stale", "never_seen", "unknown"];
1
87
  /** Normalize either heartbeat response form into the structured shape. */
2
88
  export function normalizeHeartbeatResult(response) {
3
89
  return typeof response === "string" ? { outcome: response } : response;
@@ -89,17 +89,33 @@ export function resolveExecutorPrompt(job) {
89
89
  error: `no usable prompt for job_type '${job.job_type}' (no payload.prompt and no ticket_key)`,
90
90
  };
91
91
  }
92
- /** The ratified default — the pre-BAPI-725 behavior for every job. */
93
- export const DEFAULT_WORKER_PERMISSION_POSTURE = "skip_permissions";
92
+ /**
93
+ * The ratified default (BAPI-1020).
94
+ *
95
+ * `auto` runs the worker under Claude's own permission classifier: a flagged call
96
+ * is DENIED WITH A REASON and the worker continues. It replaces `skip_permissions`,
97
+ * which bypassed that classifier entirely — the posture Architecture Miss 28 ran
98
+ * under. `skip_permissions` is still accepted, but only as an explicit revert an
99
+ * operator asks for by name; an unset key no longer hands out full bypass.
100
+ *
101
+ * `auto` shares its spelling with the Claude CLI's own mode name. That coincidence
102
+ * does NOT make this vocabulary a passthrough for argv: the mapping still lives in
103
+ * the adapter, and `resolveWorkerPermissionPosture` still rejects every CLI-shaped
104
+ * spelling it rejected before (`acceptEdits`, `dangerously-skip-permissions`).
105
+ */
106
+ export const DEFAULT_WORKER_PERMISSION_POSTURE = "auto";
94
107
  const WORKER_PERMISSION_POSTURES = [
108
+ "auto",
95
109
  "skip_permissions",
96
110
  "accept_edits",
97
111
  ];
98
112
  /**
99
113
  * Resolve the permission posture at the payload boundary.
100
114
  *
101
- * - ABSENT (`undefined`/`null`) → the ratified `skip_permissions` default, so
102
- * legacy jobs enqueued before BAPI-725 keep working unchanged.
115
+ * - ABSENT (`undefined`/`null`) → the ratified `auto` default (BAPI-1020). A job
116
+ * enqueued by an older server, or by one whose policy omits the key, therefore
117
+ * spawns under the GUARDED posture rather than under bypass — the direction a
118
+ * missing value should fail in.
103
119
  * - a supported value → returned as-is.
104
120
  * - present but unsupported → THROWS a named contract error before argv
105
121
  * construction, so the job fails loudly instead of spawning under a posture
@@ -121,7 +137,7 @@ export function resolveWorkerPermissionPosture(payload) {
121
137
  return raw;
122
138
  }
123
139
  throw new ExecutorNamedError("ContractError.PermissionPosture", "job payload worker_permission_posture is present but is not a supported posture " +
124
- "(expected 'skip_permissions' or 'accept_edits').");
140
+ "(expected 'auto', 'skip_permissions', or 'accept_edits').");
125
141
  }
126
142
  // Argv construction, model-alias resolution, and the worker executable name all
127
143
  // live in the resolved executor adapter now (BAPI-781). `job-runner.ts` requests