@bridge_gpt/mcp-server 0.2.50 → 0.2.52
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.
- package/README.md +24 -8
- package/build/agent-capabilities/probe-context.js +15 -7
- package/build/agent-capabilities/probes.js +42 -6
- package/build/agent-launchers/claude-executor-adapter.js +98 -14
- package/build/commands.generated.js +1 -1
- package/build/conduct-epic/bridge-client.js +115 -1
- package/build/conduct-epic/cli.js +351 -33
- package/build/conduct-epic/cut-protocol.js +65 -0
- package/build/conductor/bridge-api-client.js +171 -5
- package/build/conductor/deny-enforcement-preflight.js +107 -10
- package/build/conductor/local-merge.js +170 -11
- package/build/conductor-bin.js +2 -2
- package/build/connect-bitbucket-api.js +370 -0
- package/build/connect-bitbucket.js +437 -0
- package/build/docs.generated.js +1 -1
- package/build/doctor.js +230 -1
- package/build/drive-epic.js +423 -11
- package/build/env-file-link.js +164 -0
- package/build/epic-integration-pr.js +290 -0
- package/build/executor/cli.js +41 -6
- package/build/executor/deps.js +5 -1
- package/build/executor/env-file-guard.js +113 -0
- package/build/executor/env.js +78 -1
- package/build/executor/heartbeat.js +9 -0
- package/build/executor/http-client.js +90 -22
- package/build/executor/job-errors.js +43 -2
- package/build/executor/job-runner.js +137 -29
- package/build/executor/merge-job.js +102 -6
- package/build/executor/permissions.js +106 -0
- package/build/executor/preflight.js +38 -13
- package/build/executor/resume-pre-spawn.js +2 -1
- package/build/executor/runner.js +175 -4
- package/build/executor/service-unit.js +15 -0
- package/build/executor/terminal-mutation.js +22 -1
- package/build/executor/types.js +86 -0
- package/build/executor/worker-command.js +21 -5
- package/build/executor/worker-guard-hook.js +939 -0
- package/build/executor/worker-log.js +56 -0
- package/build/executor/worktree.js +11 -0
- package/build/git-reachability.js +147 -0
- package/build/index.js +535 -95
- package/build/install-bridge.js +95 -0
- package/build/pipelines.generated.js +10 -2
- package/build/plan-epic-conductor-eligibility.js +213 -0
- package/build/plane/cli.js +78 -15
- package/build/plane/defaults.js +165 -0
- package/build/plane/manifest.js +63 -8
- package/build/plane/member-logs.js +6 -0
- package/build/plane/member-roster.js +195 -11
- package/build/plane/preflight.js +43 -0
- package/build/plane/shutdown.js +25 -3
- package/build/plane/status.js +11 -0
- package/build/plane/supervisor.js +343 -14
- package/build/plane/test-fakes.js +43 -0
- package/build/plane/types.js +82 -11
- package/build/pr-base-contract.js +20 -0
- package/build/readme.generated.js +1 -1
- package/build/review-synthesis-config.js +60 -0
- package/build/scripts/executor-protocol-contract-driver.js +311 -0
- package/build/setup-epic.js +592 -139
- package/build/sfcc/log-query.js +2 -1
- package/build/sfcc/reads-custom-object-def.js +10 -13
- package/build/sfcc/reads-site-preference.js +5 -5
- package/build/sfcc/reads-system-object.js +4 -4
- package/build/sfcc/writes-custom-object-def.js +7 -7
- package/build/sfcc/writes-site-preference.js +4 -3
- package/build/sfcc/writes-system-object.js +7 -6
- package/build/start-tickets-conductor.js +11 -2
- package/build/start-tickets.js +69 -2
- package/build/version.generated.js +3 -3
- package/build/worker-containment-diagnostic.js +97 -0
- package/build/worker-guard-hook-bin.js +6 -0
- package/docs/CONDUCTOR.md +27 -0
- package/docs/install/mcp-tool-integrations.md +3 -2
- package/package.json +5 -3
- package/pipelines/plan-epic.json +5 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `connect-bitbucket` — sessionless Bitbucket Forge connection from the terminal
|
|
3
|
+
* (BAPI-966).
|
|
4
|
+
*
|
|
5
|
+
* The whole point of this command is that it needs no Bridge web session: a user who has
|
|
6
|
+
* a Bridge API key can connect Bitbucket without ever opening the setup UI. The flow is
|
|
7
|
+
*
|
|
8
|
+
* mint → browser (install the Forge app on Bitbucket, paste the printed code into its
|
|
9
|
+
* admin panel) → poll → pick a repository → confirm
|
|
10
|
+
*
|
|
11
|
+
* and the browser half authenticates to *Bitbucket*, not to Bridge. Bridge never asks
|
|
12
|
+
* for, accepts, echoes, or transports a Bitbucket credential. The only thing crossing
|
|
13
|
+
* between the browser and this process is a Bridge-issued state nonce, held in memory.
|
|
14
|
+
*
|
|
15
|
+
* Two properties are load-bearing and easy to erode:
|
|
16
|
+
*
|
|
17
|
+
* 1. **The nonce and install URL are never printed to output the CLI narrates around.**
|
|
18
|
+
* The URL carries the state as a query parameter, so putting it in a log line or an
|
|
19
|
+
* error message would paste a live credential-equivalent into the user's scrollback.
|
|
20
|
+
* The printed code shown to the user for pasting into Bitbucket's own admin panel is
|
|
21
|
+
* the one deliberate exception — see `runBitbucketConnectionFlow` below.
|
|
22
|
+
* 2. **Nothing binds without an explicit human choice.** Even a single-repository
|
|
23
|
+
* installation is confirmed by hand — the server stages candidates and this command
|
|
24
|
+
* asks. There is deliberately no `--yes`.
|
|
25
|
+
*
|
|
26
|
+
* Unlike `connect-github`, there is no delegated-handoff mode (BAPI-686 is GitHub-only)
|
|
27
|
+
* and no `--installation-id`/`--api-key` acceptance path.
|
|
28
|
+
*/
|
|
29
|
+
import { readFile, stat } from "fs/promises";
|
|
30
|
+
import { spawn } from "child_process";
|
|
31
|
+
import os from "os";
|
|
32
|
+
import path from "path";
|
|
33
|
+
import readline from "readline";
|
|
34
|
+
import { DEFAULT_BAPI_BASE_URL } from "./install-bridge.js";
|
|
35
|
+
import { validateRepoName } from "./bridge-config.js";
|
|
36
|
+
import { resolveStartTicketsRepoName } from "./start-tickets-repo.js";
|
|
37
|
+
import { resolveBapiCredentials, } from "./credential-store.js";
|
|
38
|
+
import { POLL_DEADLINE_MS, confirmBitbucketConnection, mintBitbucketConnection, pollBitbucketConnection, } from "./connect-bitbucket-api.js";
|
|
39
|
+
const USAGE = `Usage: connect-bitbucket [--repo <repo_name>]
|
|
40
|
+
|
|
41
|
+
Connect a Bitbucket repository to a Bridge project from your terminal.
|
|
42
|
+
|
|
43
|
+
Opens the Bitbucket Forge app's install page in your browser and prints a
|
|
44
|
+
connection code. Install the app, then paste the printed code into its admin
|
|
45
|
+
panel — that is how you authenticate to Bitbucket; Bridge never asks for a
|
|
46
|
+
Bitbucket token or app password. Once the app reports the code back, this
|
|
47
|
+
command asks which single repository to connect.
|
|
48
|
+
|
|
49
|
+
Options:
|
|
50
|
+
--repo <repo_name> Bridge project to connect (inferred from this directory
|
|
51
|
+
when omitted; you will be asked to confirm).
|
|
52
|
+
--help Show this message.`;
|
|
53
|
+
/**
|
|
54
|
+
* Parse argv. Deliberately strict — an unknown flag is an error, not something to
|
|
55
|
+
* ignore. In particular there is NO `--yes` (every bind is confirmed by a human), no
|
|
56
|
+
* `--installation-id` (the server derives it; accepting one from the caller would let an
|
|
57
|
+
* API-key holder claim an installation they do not own), and no `--api-key` (credentials
|
|
58
|
+
* resolve only through the shared credential-store seam).
|
|
59
|
+
*/
|
|
60
|
+
export function parseConnectBitbucketArgs(argv) {
|
|
61
|
+
const out = { help: false };
|
|
62
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
63
|
+
const arg = argv[i];
|
|
64
|
+
if (arg === "--help" || arg === "-h") {
|
|
65
|
+
out.help = true;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (arg === "--repo") {
|
|
69
|
+
const value = argv[i + 1];
|
|
70
|
+
if (!value || value.startsWith("-")) {
|
|
71
|
+
return { ok: false, error: "--repo requires a value (e.g. --repo my-project)." };
|
|
72
|
+
}
|
|
73
|
+
out.repo = value;
|
|
74
|
+
i += 1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (arg.startsWith("--repo=")) {
|
|
78
|
+
const value = arg.slice("--repo=".length);
|
|
79
|
+
if (!value) {
|
|
80
|
+
return { ok: false, error: "--repo requires a value (e.g. --repo my-project)." };
|
|
81
|
+
}
|
|
82
|
+
out.repo = value;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (arg === "--yes" || arg === "-y") {
|
|
86
|
+
return {
|
|
87
|
+
ok: false,
|
|
88
|
+
error: "connect-bitbucket does not support --yes: connecting a repository always " +
|
|
89
|
+
"requires an explicit confirmation.",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (arg === "--installation-id" || arg.startsWith("--installation-id=")) {
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
error: "connect-bitbucket does not accept --installation-id: the installation is " +
|
|
96
|
+
"resolved by Bridge from the connection code, not supplied by the caller.",
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
if (arg === "--api-key" || arg.startsWith("--api-key=")) {
|
|
100
|
+
return {
|
|
101
|
+
ok: false,
|
|
102
|
+
error: "connect-bitbucket does not accept --api-key: credentials resolve only " +
|
|
103
|
+
"through the Bridge credential store.",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (arg.startsWith("-")) {
|
|
107
|
+
return { ok: false, error: `Unknown option: ${arg}` };
|
|
108
|
+
}
|
|
109
|
+
return { ok: false, error: `Unexpected argument: ${arg}` };
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, value: out };
|
|
112
|
+
}
|
|
113
|
+
/** Echoed single-line prompt on stderr. */
|
|
114
|
+
function defaultPromptLine(promptText) {
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
117
|
+
// `rl.close()` emits `close` SYNCHRONOUSLY, so without this guard the close handler
|
|
118
|
+
// would settle the promise empty and discard a real answer. EOF must also resolve
|
|
119
|
+
// rather than deadlock a top-level await.
|
|
120
|
+
let answered = false;
|
|
121
|
+
rl.on("close", () => {
|
|
122
|
+
if (!answered)
|
|
123
|
+
resolve("");
|
|
124
|
+
});
|
|
125
|
+
rl.question(promptText, (answer) => {
|
|
126
|
+
answered = true;
|
|
127
|
+
rl.close();
|
|
128
|
+
resolve(answer.trim());
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Open *url* in the platform browser.
|
|
134
|
+
*
|
|
135
|
+
* `shell: false` is mandatory: the URL carries the state nonce, and handing it to a
|
|
136
|
+
* shell would expose it to word-splitting and metacharacter interpretation. Passing it
|
|
137
|
+
* as a single argv entry means the OS opener receives it verbatim.
|
|
138
|
+
*/
|
|
139
|
+
function defaultOpenBrowser(platform, url) {
|
|
140
|
+
const [command, args] = platform === "darwin"
|
|
141
|
+
? ["open", [url]]
|
|
142
|
+
: platform === "win32"
|
|
143
|
+
? // `start` is a cmd builtin; the empty string is its window-title argument,
|
|
144
|
+
// without which a quoted URL would be swallowed as the title.
|
|
145
|
+
["cmd", ["/c", "start", "", url]]
|
|
146
|
+
: ["xdg-open", [url]];
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
try {
|
|
149
|
+
const child = spawn(command, args, {
|
|
150
|
+
stdio: "ignore",
|
|
151
|
+
detached: false,
|
|
152
|
+
shell: false,
|
|
153
|
+
});
|
|
154
|
+
child.on("error", () => resolve(false));
|
|
155
|
+
child.on("spawn", () => resolve(true));
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
resolve(false);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export function createDefaultConnectBitbucketDeps() {
|
|
163
|
+
return {
|
|
164
|
+
env: process.env,
|
|
165
|
+
cwd: process.cwd(),
|
|
166
|
+
platform: process.platform,
|
|
167
|
+
homedir: os.homedir,
|
|
168
|
+
isTTY: Boolean(process.stdin.isTTY),
|
|
169
|
+
readFile: (filePath) => readFile(filePath, "utf-8"),
|
|
170
|
+
stat: async (filePath) => {
|
|
171
|
+
const s = await stat(filePath);
|
|
172
|
+
return { mode: s.mode };
|
|
173
|
+
},
|
|
174
|
+
fetch: globalThis.fetch,
|
|
175
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
176
|
+
now: () => Date.now(),
|
|
177
|
+
jitter: () => Math.random(),
|
|
178
|
+
promptLine: defaultPromptLine,
|
|
179
|
+
openBrowser: (url) => defaultOpenBrowser(process.platform, url),
|
|
180
|
+
stdout: (message) => process.stdout.write(`${message}\n`),
|
|
181
|
+
stderr: (message) => process.stderr.write(`${message}\n`),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Resolve the Bridge project name: explicit `--repo`, then repository identity from the
|
|
186
|
+
* environment / project-local config (confirmed interactively, since an inferred name is
|
|
187
|
+
* a guess and connecting the wrong project is not cheap to undo).
|
|
188
|
+
*/
|
|
189
|
+
export async function resolveConnectBitbucketRepoName(args, deps) {
|
|
190
|
+
if (args.repo) {
|
|
191
|
+
const validated = validateRepoName(args.repo);
|
|
192
|
+
return validated.ok ? { ok: true, value: validated.value } : { ok: false, error: validated.error };
|
|
193
|
+
}
|
|
194
|
+
let inferred = await resolveStartTicketsRepoName({
|
|
195
|
+
env: deps.env,
|
|
196
|
+
cwd: deps.cwd,
|
|
197
|
+
readFile: deps.readFile,
|
|
198
|
+
});
|
|
199
|
+
if (!inferred) {
|
|
200
|
+
const validated = validateRepoName(path.basename(deps.cwd));
|
|
201
|
+
if (validated.ok)
|
|
202
|
+
inferred = validated.value;
|
|
203
|
+
}
|
|
204
|
+
if (!inferred) {
|
|
205
|
+
return {
|
|
206
|
+
ok: false,
|
|
207
|
+
error: "Could not determine the Bridge project. Pass --repo <repo_name>.",
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const answer = (await deps.promptLine(`Bridge project [${inferred}]: `)).trim();
|
|
211
|
+
const chosen = answer.length > 0 ? answer : inferred;
|
|
212
|
+
const validated = validateRepoName(chosen);
|
|
213
|
+
return validated.ok ? { ok: true, value: validated.value } : { ok: false, error: validated.error };
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// Browser handoff
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
/**
|
|
219
|
+
* Hand the install URL to the browser.
|
|
220
|
+
*
|
|
221
|
+
* On failure this returns a FIXED message and never falls back to printing the URL —
|
|
222
|
+
* that URL contains the state nonce, and a copy-paste fallback would defeat the reason
|
|
223
|
+
* the nonce is kept in memory in the first place.
|
|
224
|
+
*/
|
|
225
|
+
export async function openBitbucketInstallPage(deps, installUrl) {
|
|
226
|
+
const opened = await deps.openBrowser(installUrl);
|
|
227
|
+
if (opened)
|
|
228
|
+
return { ok: true };
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
error: "Could not open your browser automatically. Re-run this command from a desktop " +
|
|
232
|
+
"session with a browser available.",
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// ---------------------------------------------------------------------------
|
|
236
|
+
// Flow
|
|
237
|
+
// ---------------------------------------------------------------------------
|
|
238
|
+
const STEPS = [
|
|
239
|
+
"Connect Bitbucket",
|
|
240
|
+
"Complete Bitbucket Forge install in browser",
|
|
241
|
+
"Verify connection",
|
|
242
|
+
"Choose repository",
|
|
243
|
+
"Confirm connection",
|
|
244
|
+
];
|
|
245
|
+
function renderStep(deps, index) {
|
|
246
|
+
deps.stderr(`[${index + 1}/${STEPS.length}] ${STEPS[index]}`);
|
|
247
|
+
}
|
|
248
|
+
/** Display identity for a candidate: prefer the unambiguous workspace/repo slug form. */
|
|
249
|
+
function candidateLabel(c) {
|
|
250
|
+
const slugForm = `${c.workspace_slug}/${c.repository_slug}`;
|
|
251
|
+
if (c.display_name && c.display_name !== slugForm && c.display_name !== c.repository_slug) {
|
|
252
|
+
return `${slugForm} (${c.display_name})`;
|
|
253
|
+
}
|
|
254
|
+
return slugForm;
|
|
255
|
+
}
|
|
256
|
+
/** One remediation line per terminal non-success outcome. Never any upstream detail. */
|
|
257
|
+
const OUTCOME_MESSAGES = {
|
|
258
|
+
expired: "The connection request expired before the Forge app reported back. Run connect-bitbucket again.",
|
|
259
|
+
invalid: "This connection request is no longer valid. Run connect-bitbucket again.",
|
|
260
|
+
"no-repositories": "The Bitbucket Forge app installation did not include any repositories Bridge can " +
|
|
261
|
+
"access. Re-run connect-bitbucket and grant access to at least one repository.",
|
|
262
|
+
};
|
|
263
|
+
const FAILURE_MESSAGES = {
|
|
264
|
+
network: "Could not reach Bridge API. Check your network, then run connect-bitbucket again.",
|
|
265
|
+
timeout: "Bridge API did not respond in time. Run connect-bitbucket again.",
|
|
266
|
+
unauthorized: "Bridge rejected your API key for this project. Re-run install-bridge with a current key.",
|
|
267
|
+
"not-found": "Bridge does not recognize this project. Check --repo matches your Bridge project name.",
|
|
268
|
+
server: "Bridge API returned an error. Run connect-bitbucket again shortly.",
|
|
269
|
+
malformed: "Bridge API returned an unexpected response. Run connect-bitbucket again shortly.",
|
|
270
|
+
deadline: "Timed out waiting for the Bitbucket Forge app. If you completed the install and pasted " +
|
|
271
|
+
"the code, run connect-bitbucket again to pick up the connection.",
|
|
272
|
+
};
|
|
273
|
+
/** The no-connection-made framing, used for every unsuccessful terminal path. */
|
|
274
|
+
function reportNoConnection(deps, detail) {
|
|
275
|
+
deps.stderr("");
|
|
276
|
+
deps.stderr("No Bitbucket connection was made.");
|
|
277
|
+
deps.stderr(detail);
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Ask which repository to bind. Returns null when the user declined or chose nothing.
|
|
282
|
+
* Never renders a workspace/repository UUID or installation identifier.
|
|
283
|
+
*/
|
|
284
|
+
async function chooseCandidate(deps, candidates) {
|
|
285
|
+
if (candidates.length === 1) {
|
|
286
|
+
const only = candidates[0];
|
|
287
|
+
// Even with one option: show the full identity and require a yes. The user is
|
|
288
|
+
// authorizing a binding, not acknowledging a notice.
|
|
289
|
+
const answer = (await deps.promptLine(`Connect ${candidateLabel(only)}? [y/N]: `))
|
|
290
|
+
.trim()
|
|
291
|
+
.toLowerCase();
|
|
292
|
+
if (answer !== "y" && answer !== "yes") {
|
|
293
|
+
deps.stderr("");
|
|
294
|
+
deps.stderr("No Bitbucket connection was made. Nothing was changed.");
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
return only;
|
|
298
|
+
}
|
|
299
|
+
deps.stderr("");
|
|
300
|
+
deps.stderr("Your Bitbucket Forge installation includes multiple repositories:");
|
|
301
|
+
candidates.forEach((c, i) => {
|
|
302
|
+
deps.stderr(` ${String(i + 1).padStart(2, " ")}. ${candidateLabel(c)}`);
|
|
303
|
+
});
|
|
304
|
+
deps.stderr("");
|
|
305
|
+
// No default: a stray Enter must not bind anything.
|
|
306
|
+
const answer = (await deps.promptLine(`Choose a repository [1-${candidates.length}]: `)).trim();
|
|
307
|
+
const index = Number(answer);
|
|
308
|
+
if (answer.toLowerCase() === "q" ||
|
|
309
|
+
!/^\d+$/.test(answer) ||
|
|
310
|
+
!Number.isInteger(index) ||
|
|
311
|
+
index < 1 ||
|
|
312
|
+
index > candidates.length) {
|
|
313
|
+
deps.stderr("");
|
|
314
|
+
deps.stderr("No Bitbucket connection was made. No repository was selected.");
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
const selected = candidates[index - 1];
|
|
318
|
+
deps.stderr(`Selected ${candidateLabel(selected)}.`);
|
|
319
|
+
return selected;
|
|
320
|
+
}
|
|
321
|
+
export async function runBitbucketConnectionFlow(deps, api, repoName) {
|
|
322
|
+
renderStep(deps, 0);
|
|
323
|
+
const minted = await mintBitbucketConnection(api, repoName);
|
|
324
|
+
if (!minted.ok) {
|
|
325
|
+
return reportNoConnection(deps, FAILURE_MESSAGES[minted.kind]);
|
|
326
|
+
}
|
|
327
|
+
renderStep(deps, 1);
|
|
328
|
+
deps.stderr("Opening Bitbucket…");
|
|
329
|
+
// The URL goes straight from memory to the opener — never through a log line.
|
|
330
|
+
const opened = await openBitbucketInstallPage(deps, minted.value.installUrl);
|
|
331
|
+
if (!opened.ok) {
|
|
332
|
+
return reportNoConnection(deps, opened.error);
|
|
333
|
+
}
|
|
334
|
+
// The code itself is not a bearer credential the way the URL's state parameter is
|
|
335
|
+
// treated elsewhere in this flow — it must be visible so the user can paste it into
|
|
336
|
+
// the installed Forge app's admin panel, which is how redemption actually happens for
|
|
337
|
+
// a Forge app (there is no GitHub-style browser redirect back to Bridge).
|
|
338
|
+
deps.stderr(`Paste this code into the installed app's admin panel: ${minted.value.state}`);
|
|
339
|
+
renderStep(deps, 2);
|
|
340
|
+
const minutes = Math.floor(POLL_DEADLINE_MS / 60_000);
|
|
341
|
+
deps.stderr(`Waiting for the Bitbucket Forge app… (up to ~${minutes} minutes)`);
|
|
342
|
+
const pollDeps = { sleep: deps.sleep, now: deps.now, jitter: deps.jitter };
|
|
343
|
+
const started = deps.now();
|
|
344
|
+
const polled = await pollBitbucketConnection(api, pollDeps, repoName, minted.value.state);
|
|
345
|
+
if (!polled.ok) {
|
|
346
|
+
return reportNoConnection(deps, FAILURE_MESSAGES[polled.kind]);
|
|
347
|
+
}
|
|
348
|
+
const elapsedSec = Math.max(0, Math.round((deps.now() - started) / 1_000));
|
|
349
|
+
deps.stderr(`Waited ${elapsedSec}s.`);
|
|
350
|
+
const result = polled.value;
|
|
351
|
+
if (result.status === "connected") {
|
|
352
|
+
// Already bound (e.g. a re-run against a finished handshake).
|
|
353
|
+
deps.stdout(`Connected ${result.repoDisplayName ?? repoName}.`);
|
|
354
|
+
return 0;
|
|
355
|
+
}
|
|
356
|
+
if (result.status !== "staged") {
|
|
357
|
+
return reportNoConnection(deps, OUTCOME_MESSAGES[result.status] ?? OUTCOME_MESSAGES.invalid);
|
|
358
|
+
}
|
|
359
|
+
const candidates = result.candidates;
|
|
360
|
+
if (candidates.length === 0) {
|
|
361
|
+
return reportNoConnection(deps, OUTCOME_MESSAGES["no-repositories"]);
|
|
362
|
+
}
|
|
363
|
+
renderStep(deps, 3);
|
|
364
|
+
const selected = await chooseCandidate(deps, candidates);
|
|
365
|
+
if (!selected)
|
|
366
|
+
return 1;
|
|
367
|
+
renderStep(deps, 4);
|
|
368
|
+
const confirmed = await confirmBitbucketConnection(api, repoName, minted.value.state, selected.workspace_uuid, selected.repository_uuid);
|
|
369
|
+
if (!confirmed.ok) {
|
|
370
|
+
return reportNoConnection(deps, FAILURE_MESSAGES[confirmed.kind]);
|
|
371
|
+
}
|
|
372
|
+
const displayName = confirmed.value.workspaceSlug && confirmed.value.repositorySlug
|
|
373
|
+
? `${confirmed.value.workspaceSlug}/${confirmed.value.repositorySlug}`
|
|
374
|
+
: confirmed.value.repoName;
|
|
375
|
+
deps.stdout(`Connected ${displayName}.`);
|
|
376
|
+
return 0;
|
|
377
|
+
}
|
|
378
|
+
// ---------------------------------------------------------------------------
|
|
379
|
+
// Process boundary
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
/**
|
|
382
|
+
* Entry point. Catches everything and always resolves to a numeric exit code — an
|
|
383
|
+
* unhandled rejection here would surface a stack trace that could contain the install
|
|
384
|
+
* URL (and therefore the nonce).
|
|
385
|
+
*/
|
|
386
|
+
export async function runConnectBitbucketCli(argv, injected) {
|
|
387
|
+
const deps = injected ?? createDefaultConnectBitbucketDeps();
|
|
388
|
+
try {
|
|
389
|
+
const parsed = parseConnectBitbucketArgs(argv);
|
|
390
|
+
if (!parsed.ok) {
|
|
391
|
+
deps.stderr(parsed.error);
|
|
392
|
+
deps.stderr("");
|
|
393
|
+
deps.stderr(USAGE);
|
|
394
|
+
return 1;
|
|
395
|
+
}
|
|
396
|
+
if (parsed.value.help) {
|
|
397
|
+
deps.stdout(USAGE);
|
|
398
|
+
return 0;
|
|
399
|
+
}
|
|
400
|
+
// Checked BEFORE minting: the flow always ends in a human choice (which repository
|
|
401
|
+
// to bind), so a non-interactive run can only ever strand a code it can never
|
|
402
|
+
// confirm.
|
|
403
|
+
if (!deps.isTTY) {
|
|
404
|
+
deps.stderr("connect-bitbucket needs an interactive terminal: it opens a browser and asks " +
|
|
405
|
+
"you to confirm which repository to connect. Run it directly in your terminal.");
|
|
406
|
+
return 1;
|
|
407
|
+
}
|
|
408
|
+
const repo = await resolveConnectBitbucketRepoName(parsed.value, deps);
|
|
409
|
+
if (!repo.ok) {
|
|
410
|
+
deps.stderr(repo.error);
|
|
411
|
+
return 1;
|
|
412
|
+
}
|
|
413
|
+
const cred = await resolveBapiCredentials(repo.value, {
|
|
414
|
+
env: deps.env,
|
|
415
|
+
homedir: deps.homedir,
|
|
416
|
+
platform: deps.platform,
|
|
417
|
+
readFile: deps.readFile,
|
|
418
|
+
stat: deps.stat,
|
|
419
|
+
stderr: () => { },
|
|
420
|
+
});
|
|
421
|
+
if (!cred.ok) {
|
|
422
|
+
deps.stderr(cred.error);
|
|
423
|
+
return 1;
|
|
424
|
+
}
|
|
425
|
+
const api = {
|
|
426
|
+
fetch: deps.fetch,
|
|
427
|
+
baseUrl: deps.env.BAPI_BASE_URL?.trim() || DEFAULT_BAPI_BASE_URL,
|
|
428
|
+
apiKey: cred.credentials.apiKey,
|
|
429
|
+
};
|
|
430
|
+
return await runBitbucketConnectionFlow(deps, api, repo.value);
|
|
431
|
+
}
|
|
432
|
+
catch {
|
|
433
|
+
// Never forward the caught value: it may carry the install URL or the nonce.
|
|
434
|
+
deps.stderr("No Bitbucket connection was made. An unexpected error occurred.");
|
|
435
|
+
return 1;
|
|
436
|
+
}
|
|
437
|
+
}
|
package/build/docs.generated.js
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
export const DOCS = {
|
|
4
4
|
"docs/mcp-tool-integrations.md": "# MCP tool integrations — the human \"why\" behind the capability report\n\nThis catalog is **explanatory prose only**. It exists so the `/install-bridge`\ncapability report can cite a human-readable \"why\" for each gate. It is **not** a\nsource of truth for gating: the server computes every `locked_tools` /\n`unlocked_tools` membership decision itself and the agent must never recompute a\ntool's dependencies from this document.\n\n**Authoritative source of gating.** The enforced rules — which tools are blocked,\nwhich are degraded, and what each requires — live in\n`api/library/vcs/vcs_route_operations.py`:\n\n- `VCS_ROUTE_REQUIREMENTS` — routes that **BLOCK** (are unavailable) without a\n VCS connection.\n- `VCS_ROUTE_WARNINGS` — routes that **DEGRADE** (stay usable, but without\n codebase context) without a VCS connection.\n- `NEVER_GATED_ROUTE_KEYS` — routes that are never gated on any integration.\n- `INDEX_REQUIRED_ROUTE_KEYS`, `INDEX_REQUIRED_COUNCIL_MODES`,\n `CREATE_DOC_CODEBASE_CONTEXT_DOC_TYPES`, `CREATE_DOC_WARN_DOC_TYPES` — the\n conditional \"requires a successful code index\" dimension.\n- The resolver helpers `get_required_vcs_operation()`, `get_warn_vcs_operation()`,\n and `requires_successful_index()` are the authoritative functions that decide a\n case. The capability report is derived from these; this catalog explains them.\n\n## Reading the capability report\n\nEach tool entry the server returns has the exact shape\n`{tool, effect, missing, semantics}`:\n\n- **`effect`**\n - **`BLOCK`** — the tool is **unavailable** until every listed dependency is\n met. It will refuse to run without them.\n - **`DEGRADE`** — the tool is **usable right now**, but **without codebase\n context** (it cannot ground its output in your repository). Connecting the\n listed dependency upgrades it from \"works blind\" to \"works with full context\".\n A `DEGRADE` tool is never \"failed\".\n- **`missing`** — the server-computed dependency identifiers still needed:\n integration ids such as `github_app` / `vcs_access_token`, and the synthetic\n `code_index` (a successful repository index).\n- **`semantics`**\n - **`all_of`** — every id in `missing` is required.\n - **`any_of`** — the VCS-provider candidates in `missing` are alternatives:\n **either** `github_app` **or** `vcs_access_token` satisfies the VCS\n requirement (this is the \"provider unknown\" case). When `code_index` also\n appears, it remains separately required — `semantics` describes only the VCS\n provider candidates, and a code index is always mandatory in addition.\n\nThe three readiness dimensions `configured` / `learned` / `indexed` are reported\nindependently. `indexed` may be `true`, `false`, or `null` — a `null` means the\nindex status could not be confirmed and must **not** be read as \"indexed\".\n\n## The integrations\n\n| Integration id | What it is | What it unlocks |\n| --- | --- | --- |\n| `jira` | Jira API access | Ticket reads/writes, estimation and review automations, status transitions. |\n| `github_app` | GitHub App installation | Pull requests, code review, and private-repo parsing on GitHub projects. |\n| `vcs_access_token` | VCS access token | Pull requests, code review, and private-repo parsing on Bitbucket projects. |\n| `vcs_webhook` | VCS webhook secret | Merge webhooks and CI follow-up triggers. |\n| `code_index` | A successful repository index | Codebase-grounded planning, architecture, reimplementation, and technical/discovery councils. Produced by `/parse-repository`. |\n\nA project's `github_app` **or** `vcs_access_token` provides the VCS connection;\nwhich one applies depends on the project's version-control system. When the\nproject's provider is unknown, either credential satisfies the requirement — the\nreport expresses that as `semantics: any_of`.\n\n## The gates, by capability\n\n### Pull requests and CI (BLOCK on VCS)\n\nTools like `create_pull_request`, `resolve_ci_checks`, `poll_ci_checks`, and\n`fresh_base` are **unavailable** (`BLOCK`) until a VCS connection is\nconfigured. They act directly on the version-control host, so without a\nconnection there is nothing for them to talk to.\n\n### Repository indexing and maps (BLOCK on VCS)\n\n`parse_repository` and `regenerate_directory_map` need a VCS connection to read\nthe repository. They **BLOCK** until VCS is connected.\n\n### Codebase-grounded generation (BLOCK on VCS **and** a code index)\n\nPlanning and architecture tools — `generate_plan_direct`,\n`generate_architecture_direct`, `request_reimplement_context`,\n`code_writer_generate_plan`, `code_writer_generate_architecture`, and\n`create_doc` for **TDD** / **architecture** documents — ground their output in\nyour indexed codebase. They **BLOCK** until BOTH a VCS connection AND a\nsuccessful code index exist (`all_of`, with `code_index` in `missing`).\n\n### Council (BLOCK on a code index, mode-dependent)\n\n`request_council` in **technical** or **discovery** mode searches your indexed\ncodebase, so it **BLOCK**s on `code_index`. **Design**-mode council requests never\nquery the index and are never gated.\n\n### Document generation that DEGRADEs (usable without codebase context)\n\nTools like `generate_prd_direct`, `generate_fsd_direct`,\n`code_writer_generate_fsd`, `generate_clarifying_questions_direct`,\n`generate_ticket_critique_direct`, `generate_ticket_review_direct`, and\n`create_doc` for **PRD** / **FSD** documents **DEGRADE** rather than block: they\nrun today from the ticket alone, and connecting VCS simply lets them ground their\noutput in your codebase. They always appear under \"Tools you can use now\", with a\nreduced-context caveat when the VCS connection is missing.\n\n### Never gated\n\nSetup and bootstrap tools (`ping`, `config_field`, `get_install_manifest`,\n`apply_install_manifest`, `persist_routing_credential`, and the\nbootstrap-invite exchange) are always available — they\nare how you configure everything else.\n",
|
|
5
5
|
"docs/install/sfcc-integration.md": "# Installing the SFCC Integration (OCAPI)\n\nBridge's Salesforce B2C Commerce (SFCC) tools give an AI coding agent read access to\na sandbox's object model, custom object definitions, and site preferences — plus a\nsmall set of sandbox-only writes — through the **OCAPI Data API**. This guide covers\nsetting up the OCAPI client that those tools authenticate against.\n\n> **Sandbox / local development only.** This integration is intended for a **developer\n> sandbox**, and that restriction is **enforced in code**: before any SFCC tool runs,\n> Bridge validates the hostname your credentials actually resolve to — from `dw.json`\n> or `SFCC_*` — against the sandbox forms listed below. An unrecognized host is refused\n> with a `403` (`error.code: \"TARGET_NOT_SANDBOX\"`) before any request leaves your\n> machine. The check reads the resolved hostname, never the `instance` tool argument,\n> so omitting `instance` or passing `\"sandbox\"` cannot bypass it.\n>\n> Accepted sandbox hostname forms:\n>\n> - `<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.dx.commercecloud.salesforce.com`\n>\n> Anything else — a `production-`/`staging-`/`development-` prefixed host, or any\n> `*.demandware.net` host — is rejected.\n>\n> Still do not configure the grants below on an instance that holds real data.\n> Credentials stay local (in `dw.json` or `SFCC_*` env vars) and are never sent to\n> Bridge.\n\nFor the full per-tool list and what each SFCC tool depends on, see\n[MCP Tool Integration Dependencies](./mcp-tool-integrations.md). For the tool reference\nand the `BRIDGE_MCP_PROFILE` gating, see the SFCC section of the\n[package README](../../README.md).\n\n## Prerequisites\n\n- A running SFCC **developer sandbox** and its hostname\n (e.g. `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`).\n- An **Account Manager API client** — a `client-id` and `client-secret`. This is the\n OCAPI client the tools use to obtain an OAuth token. Create one in Account Manager\n (**API Client** → *Add API Client*) if you don't already have it, and note its\n `client_id`.\n- Business Manager access to the sandbox with permission to edit **Open Commerce API\n Settings**.\n\n## 1. Grant the OCAPI client access in Business Manager\n\nIn Business Manager for the sandbox:\n\n**Administration → Site Development → Open Commerce API Settings → Data API** tab.\n\nAdd the client entry below to the `clients` array of the Data API settings, then\n**Save**. It grants only the resource families and HTTP methods Bridge's SFCC tools\nactually call — not a global `/**` grant. `check_permissions` prints the same JSON on\na 401/403, split into the two blocks.\n\n**READ/SEARCH TOOL GRANTS** — required by the `sfcc` read tools. (`post` is OCAPI's\nconvention for its `*_search` endpoints, not a mutation.)\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\n**MUTATION GRANTS** — required **only if you enable `BRIDGE_MCP_PROFILE=sfcc-write`**,\nwhich registers the nine destructive write tools. These are shipped capabilities, not\nfuture work. No `delete` is granted, because no shipped write tool performs one; the\n`get` entries are needed for the If-Match ETag round trip that precedes each `PATCH`.\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\nNotes:\n\n- The `client_id` **must match** the Account Manager API client whose credentials you\n put in `dw.json` / `SFCC_*` below. Replace the value above with your own client id if\n it differs.\n- If the Data API settings are empty, wrap the entries in the standard settings\n envelope. Merge the resource lists from the block(s) above into one `resources`\n array — do not substitute a global `\"resource_id\": \"/**\"` grant:\n\n ```json\n {\n \"_v\": \"23.2\",\n \"clients\": [\n {\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n }\n ]\n }\n ```\n\n- `check_permissions` (below) prints a ready-to-paste grant JSON on a 401/403, so you can\n also let the tool tell you exactly what to add.\n\n## 2. Provide credentials locally\n\nCreate a `dw.json` in your project root (auto-added to git exclude — never commit it):\n\n```json\n{\n \"hostname\": \"zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com\",\n \"client-id\": \"<your-client-id-here>\",\n \"client-secret\": \"<account-manager-client-secret>\"\n}\n```\n\nAccepted key spellings: `hostname`/`host`, `client-id`/`clientId`/`client_id`,\n`client-secret`/`clientSecret`/`client_secret`. Prefer a single config — a multi-entry\n`configs[]` array forces an explicit `instance` on every call. Alternatively, export\n`SFCC_HOSTNAME` / `SFCC_CLIENT_ID` / `SFCC_CLIENT_SECRET` in the MCP server environment.\n\n## 3. Set the repo `version` config field\n\nSet the repo's `version` config to your SFCC project type — one of\n`sfra | pwakit | sitegenesis | storefrontnext | hybrid`. The call-time gate reads this;\na non-SFCC value blocks every SFCC tool except `sfcc_setup_status`. Set it via your\nnormal config path, the `config_field` MCP tool (operation `update`, field `version`),\nor the `/teach-bridge` skill.\n\n## 4. Enable the SFCC tools\n\nThe two diagnostic tools (`sfcc_setup_status`, `check_permissions`) are always\nregistered. Everything else is gated, behind **two independent profile groups**:\n\n| Group | Registers |\n|---|---|\n| `sfcc` | the 8 OCAPI read tools + `sfcc_log_query` — read-only |\n| `sfcc-write` | the 9 destructive write tools |\n\nNeither implies the other. Add what you need to `BRIDGE_MCP_PROFILE` in the MCP server\n`env` block (it is comma-separated), then **restart the MCP client**:\n\n```json\n\"env\": { \"BRIDGE_MCP_PROFILE\": \"sfcc\" }\n```\n\nFor reads plus writes, use `\"sfcc,sfcc-write\"`. `full` expands to every group and is\ntherefore write-capable.\n\n> **Migration.** `sfcc` used to register the nine write tools too. It no longer does.\n> If you were relying on SFCC writes through `BRIDGE_MCP_PROFILE=sfcc`, change it to\n> `BRIDGE_MCP_PROFILE=sfcc,sfcc-write`. `full` users keep write access and need no\n> change.\n\n## 5. Verify\n\nAsk your agent to run:\n\n1. `sfcc_setup_status` — expect all prerequisite checks ✓ (Bridge API key, repo name,\n `version` config, `dw.json` presence/uniqueness, AM/OCAPI token acquisition).\n2. `check_permissions` — probes OCAPI via `GET /system_object_definitions`. A 200 (with\n the OCAPI version) confirms the grant. On 401/403 it prints the exact grant JSON to\n paste back in step 1.\n\nRestart the MCP client after any credential, grant, or env change — a running session\ndoes not pick them up.\n\n## Notes\n\n- **WebDAV logs are separate.** `sfcc_log_query` authenticates with a Business Manager\n username + a 40-character **WebDAV access key** over HTTP Basic auth — *not* the OCAPI\n OAuth token configured here. `sfcc_setup_status` reports OCAPI (step 5) and WebDAV\n (step 6) independently; one can be green while the other is not.\n- **Writes are sandbox-only.** The write tools (attribute/preference create/update) target\n a developer sandbox and echo a paste-ready grant JSON on a 403.\n",
|
|
6
|
-
"docs/bridge-ticket-authoring.md": "# Bridge ticket-authoring posture\n\nBridge has several surfaces that can create a ticket. Without a shared posture\neach one behaves differently, and the most-used surface carries none of the\nmaintainer's preferences at all. This document is the deep reference behind the\nshort posture block that every one of those surfaces carries verbatim.\n\nThe block itself is short on purpose — it competes for attention inside prompts\nthat are already long. Everything that explains *why* lives here.\n\n## The canonical block\n\nThis file **is** the canonical source. The marker-delimited block below is\nduplicated byte-identically onto every carrier — every surface that decides\nticket shape holds these exact bytes, so no surface can quietly drift into its\nown house style.\n\nCarriers (all four hold the block verbatim):\n\n- `agents/src/jira-ticket-writer.md` — the writer itself, plus a compressed\n posture line in its `description:` frontmatter, which is the only coverage a\n bare-chat session gets with no file read and no `tools/list` cost.\n- `commands/src/explore-ticket.md` — Stage 9, the most-used authoring surface.\n- `mcp_server/instructions/decompose-epic-candidate.md` — the `idea-to-ticket`\n decomposition step.\n- `mcp_server/instructions/decompose-epic.md` — the `plan-epic` decomposition\n step.\n\nEdit the block here, copy it verbatim to each carrier, and let\n`tests/pytest/mcp_server/test_ticket_authoring_posture_assets.py` prove it\nlanded. That test permits **no** per-surface variation.\n\n<!-- BEGIN BRIDGE TICKET-AUTHORING POSTURE -->\n<!-- Canonical source: docs/bridge-ticket-authoring.md.\n This block is duplicated byte-identically onto every carrier. Never edit a\n copy: edit the canonical source and re-copy it verbatim. A cross-surface\n byte-equality test fails the build if any copy drifts by a single byte. -->\n\n## Ticket-authoring posture\n\nDeep reference: `docs/bridge-ticket-authoring.md`.\n\n**Draft through the writer.** Every ticket body — an epic parent, an epic child,\nand an ordinary sibling alike — is drafted by the `jira-ticket-writer` agent\nbefore `create_ticket` is called. Do not compose a ticket description inline.\n\n**Size the work.** Size each ticket by file-touch breadth and depth plus rough\nlines of code (LOC) changed:\n\n- `S = 1-2 files / <~80 LOC`\n- `M = ~3-8 files / ~80-400 LOC`\n- `L = ~8-15 files / ~400-900 LOC`\n- `XL = >15 files / >~900 LOC`\n\nTarget size priority: **L (target) -> XL (when the work does not fit in L) -> M\n(third choice) -> S (only when unavoidable)**. This applies equally to a\nstandalone ticket and to an epic child.\n\nAim each slice at L. When one will not fit, grow it to XL rather than splitting\nit — split only when the slice is genuinely two independent pieces of work,\nnever merely to land inside a band. Bridge's grooming and implementation process\nhandles a large vertical slice well and is overkill on small ones: every extra\nticket is another worktree, another PR, another rebase, and another chance for\ntwo workers to touch the same file. Reach for M because the work genuinely is\nthat size, not to avoid an XL.\n\nBeyond roughly 40 files or ~3000 LOC, split anyway. Past that point review\nturnaround and rebase cost dominate the run's budget, and a review that wedges\nholds the gate to its full retry ceiling before anyone notices.\n\n**Group at three.** Three or more implementable tickets is an epic: propose an\nepic parent plus an ordered child manifest, and resolve this surface's own\napproval gate before anything is created. One or two tickets are ordinary\nsiblings — no epic parent, no manifest. The threshold is exactly three.\n\n**Hand off once.** An epic handoff names exactly one conductor entry point,\n`drive-epic`, which selects the runnable path itself. Never present a choice\nbetween conductors.\n\n**Departure is closed-list only.** These three exceptions, and no others, permit\ndeparting from the rules above. Invoking one requires no announcement.\n\n- **E1 External-tracker mirroring** — a recorded upstream identifier exists and\n its granularity is contractual. Bypasses sizing and the epic threshold.\n- **E2 Discovery-only spike** — no committed production-code deliverable.\n Bypasses sizing only; does not bypass drafting through the writer.\n- **E3 Authorized incident containment** — tied to an active incident record,\n not to schedule pressure. Bypasses sizing and the epic threshold.\n\nThe list is closed. Anything outside it is an escalation to the operator, not a\njudgement call. Explicitly refused as grounds for departure: a single-file\ntrivial fix (that is `S` reached through the normal path, not an exception),\ngeneric time pressure, \"already well specified\", \"faster without the writer\",\ndeveloper discretion, minor refactor, unattended mode, context limits, and \"hard\nto decompose\" (XL is the normal overflow, so that is the ordinary path and not a\ndeparture). Writer unavailability escalates; it never silently authorizes inline\ndrafting.\n\n<!-- END BRIDGE TICKET-AUTHORING POSTURE -->\n\nThe rest of this document is the rationale the block is deliberately too short to\ncarry.\n\n## Decision: Jira ticket authoring ships through the Jira Ticket Writer (BAPI-900)\n\nBridge ships two very different kinds of ticket-authoring surface, and customers\nneed to know which one they actually have.\n\n**Shipped customer surface.** A customer project gets the `jira-ticket-writer`\nagent — the same writer this posture requires every ticket body to go through —\nplus the agent-directed capability to revise an existing ticket's description.\nAsk your agent to draft a ticket with the Jira Ticket Writer, and ask your agent\nto update an existing ticket's description when it needs revising. Both reach a\ncustomer project because they are packaged: the writer through `AGENTS`\n(`mcp_server/src/agents.generated.ts`) and the description-update path through\nthe registered `update_ticket_description` / `request_ticket_update` MCP tools.\n\n**Repository-local workflows.** `.claude/commands/write-ticket.md` and\n`.claude/commands/update-ticket.md` are bridge-api's own repository-maintenance\ncommands. They are **not** scaffolded into a customer project by `--init`, have\nno `commands/src/` source, and have no generated Cursor or `mcp_server/`\nmirror — deliberately, not by omission. A customer asking their agent to run\nthe write-ticket or update-ticket slash command will not find either one,\nbecause neither ships.\n\n**Why (Option B, not a promotion to shipped status).** The Jira Ticket Writer is\nalready the packaged drafting surface this posture mandates, so shipping\n`write-ticket.md` as a second drafting entry point would duplicate it. More\nimportantly, `write-ticket.md` is today an autonomous, single-ticket, no-halt\npipeline (\"No human confirmation gates — run end-to-end\") with no decomposition\nstep and no approval gate — it cannot honor the \"group at three\" epic rule or\nthe epic approval gate this posture requires, because it was never built to\npropose an epic at all. Promoting it to a shipped surface without that redesign\nwould ship a customer-facing command that silently violates this file's own\nposture. Until that redesign happens, `write-ticket.md` and `update-ticket.md`\nstay repository-local, and every packaged surface directs customers to the Jira\nTicket Writer and to agent-directed description updates instead.\n\n\n## The four rules\n\n### 1. Draft through `jira-ticket-writer`\n\nEvery ticket body is drafted by the `jira-ticket-writer` agent before\n`create_ticket` is called — an epic parent, an epic child, and an ordinary\nsibling alike. Nothing composes a ticket description inline.\n\nThe writer is not a formatter. It runs a codebase-research pass first, so its\ntickets cite the files, functions, and extension points a change actually\ntouches. A description written inline skips that pass, and the difference shows\nup two steps later: plan generation and implementation both ground themselves in\nthe ticket body, so a body with no code references produces a plan with no code\nreferences.\n\n\"The ticket is already well specified\" is not a reason to skip the writer. A\nwell-specified *request* is the writer's input, not a substitute for its output.\n\n### 2. Size toward L\n\nSize each ticket by file-touch breadth and depth plus rough lines of code\nchanged:\n\n| Band | Files | LOC |\n| --- | --- | --- |\n| `S` | 1–2 | `<~80` |\n| `M` | ~3–8 | ~80–400 |\n| `L` | ~8–15 | ~400–900 |\n| `XL` | >15 | `>~900` |\n\nPriority: **L (target) → XL (when the work does not fit in L) → M (third choice)\n→ S (only when unavoidable)**.\n\nThe target is L because the Bridge implementation tooling works best on\nindependently implementable vertical slices. What matters as much as the target\nis the **direction you move when a slice misses it**: upward, not downward.\n\nA slice that will not fit in L becomes **one XL ticket**, not two L ones. Split\nonly when the slice is genuinely two independent pieces of work — never merely to\nland inside a band. Fragmenting a coherent slice to fit is the failure this\nladder exists to prevent: every extra ticket is another worktree, another PR,\nanother rebase, and another chance for two workers to touch the same file, and\nBridge's grooming process is overkill on small tickets. Fewer, larger slices\nspend less of the run's budget on coordination.\n\nThis applies equally to a standalone ticket and to an epic child. There is no\nsize ceiling on a child that a lone ticket does not also have.\n\n`M` is where you land when the work genuinely is three to eight files — not\nsomewhere to retreat to in order to avoid an XL. `S` is likewise not forbidden:\nit is simply what you reach when the work genuinely is one or two files. A\nsingle-file trivial fix is `S` arrived at through the normal path. It is not an\nexception to anything, and it does not license skipping the writer.\n\n**Beyond roughly 40 files or ~3000 LOC, split anyway.** XL is the preferred\noverflow, not an unbounded one. Past that point review turnaround and rebase cost\ndominate the run's budget, and a review that wedges holds the gate to its full\nretry ceiling before anyone notices. That is a real bound, not a preference — and\nit is high enough that reaching it means the work really is two things.\n\n### 3. Group at three\n\nThree or more implementable tickets is an epic. The surface proposes an epic\nparent plus an **ordered child manifest**, and resolves its own approval gate\nbefore anything is created.\n\nOne or two tickets are ordinary siblings: no epic parent, no manifest. The\nthreshold is exactly three — not \"several\", not \"a lot\".\n\nThe manifest carries, per child: the boundary of its scope, its size band,\n`depends_on` (hard prerequisites that must land first), `recommended_after` (soft\nsequencing preferences that are not blockers), and a one-line order rationale.\nHard prerequisites and soft sequencing stay strictly separate, because the\nrecommended implementation order is derived from them and conflating the two\nproduces a serialized order where a parallel one was available.\n\nApproval follows each surface's **existing** attended/unattended rule. Nothing\nhere introduces a new gate policy: `/explore-ticket` requires an explicit\naffirmative because creation is irreversible, and the recipe path gates on the\npipeline's own auto-approval variable. What is *not* conditional is the grouping\nitself — an unattended run still produces the epic; only the gate's behavior\nvaries.\n\nDecomposition happens **once**. The pass that decides the split freezes the\nmanifest; body rendering then fans out one writer invocation per entry against\nthat frozen manifest. A rendering invocation may not re-split, merge, reorder,\nrenumber, or rescope. Two independent decisions about the same split disagree,\nand the disagreement surfaces as children that overlap or contradict their\nparent.\n\n### 4. Hand off to exactly one conductor\n\nAn epic handoff names exactly one conductor entry point: `drive-epic`.\n\nBridge currently has two conductors — the v2 server-side engine and the LLM\nconductor pilot — and a standing rule that they must never operate on the same\nepic, because two transition authorities on one epic wedge it permanently. Asking\na model to pick correctly every time is not a control. `drive-epic` makes the\nchoice structural instead: it reads conductor readiness and routes to the one\npath the project can actually run, so no prompt names either underlying conductor\nand no prompt can present both.\n\nTwo conductors is a transitional state. When one is eliminated, `drive-epic` is\nthe only thing that changes — no prompt, bundled doc, command mirror, or posture\ntest moves.\n\n## The closed exception list\n\nExactly three exceptions permit departing from the rules above. Invoking one\nrequires **no announcement** — the departure is silent by design, because a\nmandatory announcement would be one more instruction to drift from, and the cost\nof silence was weighed and accepted.\n\n| Id | Exception | Objective trigger | Bypasses |\n| --- | --- | --- | --- |\n| **E1** | External-tracker mirroring | A recorded upstream identifier exists and its granularity is contractual | Sizing and the epic threshold |\n| **E2** | Discovery-only spike | No committed production-code deliverable | Sizing only — **not** drafting through the writer |\n| **E3** | Authorized incident containment | Tied to an active incident record, not to schedule pressure | Sizing and the epic threshold |\n\nEach trigger is objective: an identifier that exists, a deliverable that is\nabsent, an incident record that is open. None of them is a judgement about how\nthe work feels.\n\n### The list is closed\n\nAnything outside the three rows above is an **escalation to the operator**, not a\njudgement call. The following are explicitly refused as grounds for departure:\n\n- a single-file trivial fix — that is `S` reached through the normal path;\n- generic time pressure;\n- \"the request is already well specified\";\n- \"it would be faster without the writer\";\n- developer discretion;\n- \"it's just a minor refactor\";\n- running unattended;\n- context limits;\n- \"this is hard to decompose\" — XL is the normal overflow, so that is the\n ordinary path and not a departure.\n\n**Writer unavailability escalates.** It never silently authorizes inline\ndrafting. A surface that cannot reach `jira-ticket-writer` stops and says so.\n\n## Accepted trade-off: silent departure is unobservable\n\nObservability was deliberately dropped when this posture was ratified. A model\nmay invoke E1, E2, or E3 without recording that it did, so posture drift is only\ndetectable through ticket quality — not through a log, a counter, or a report.\n\nThis is known and accepted. The alternative was another mandatory instruction on\nevery surface, and an instruction that is skipped silently is worse than one that\ndoes not exist: it reads as coverage while providing none.\n\n## Why duplication, not a shared include\n\nCommands, agents, instructions, and docs have four separate build paths in this\nrepository and no shared compiler. Introducing a generated include step to share\none block would mean a fifth build path, a placeholder that can go unresolved,\nand a failure mode where a carrier ships with the placeholder text still in it.\n\nMarker-delimited duplication plus one byte-equality test is the right mechanism\nat this scale. The test reads the canonical sources directly — never the\ngenerated command mirrors, whose byte-identity the command tests already cover —\nand permits **no** per-surface variation. Any drift, down to a single byte, fails.\n\n## A fresh install inherits this\n\nNo configuration step, no server call. The posture reaches a new project through\nthe packaged bundles that `--init` scaffolds:\n\n- `COMMANDS` (`mcp_server/src/commands.generated.ts`) — carries\n `commands/src/explore-ticket.md`;\n- `AGENTS` (`mcp_server/src/agents.generated.ts`) — carries\n `agents/src/jira-ticket-writer.md`, including the compressed posture line in\n its `description:` frontmatter;\n- `INSTRUCTIONS` (`mcp_server/src/pipelines.generated.ts`) — carries the\n canonical source and both decomposition instructions;\n- `DOCS` (`mcp_server/src/docs.generated.ts`) — carries this document.\n\nThe compressed frontmatter line matters more than its size suggests: agent\ndescriptions land in every session's system prompt with no file read and no\n`tools/list` cost, so it is the entire bare-chat coverage story.\n\n## Worked examples\n\n**One ticket.** \"Add a `--json` flag to `doctor`.\" Two files and a test, ~90 LOC.\nThat is `M`. One ticket, drafted by the writer, no epic, no manifest, no\nconductor handoff.\n\n**Two tickets.** \"Add rate limiting to the LLM client, and surface the limit in\nthe config UI.\" Backend and frontend are independently implementable and land\nseparately: two ordinary siblings. Still no epic — the threshold is three.\n\n**Four tickets → an epic.** \"Make local ticket mode a first-class system.\"\nDecomposition freezes a parent plus four children, each `L`, with `depends_on`\nnaming the one child that must land first. The full manifest goes to the approval\ngate; on approval, four writer invocations render four bodies against their\nfrozen entries; creation follows `upload-epic-hierarchy.md`; the handoff names\n`drive-epic` and nothing else.\n\n**A child that outgrows `L`.** A proposed child comes out at 19 files. It ships\nas one `XL` child. Do not split it into two `L` children to make it fit — the\nslice is one coherent piece of work, and halving it buys a second worktree, a\nsecond PR, and a rebase between them in exchange for nothing. Split only if the\n19 files really are two independent deliverables.\n\n**Past the ceiling.** A proposed ticket comes out at 60 files and ~5000 LOC.\nThat is over the bound, so it splits — but into the largest coherent pieces\navailable, not into a swarm. Two `XL` tickets is the right answer here; six `M`\nones is not.\n"
|
|
6
|
+
"docs/bridge-ticket-authoring.md": "# Bridge ticket-authoring posture\n\nBridge has several surfaces that can create a ticket. Without a shared posture\neach one behaves differently, and the most-used surface carries none of the\nmaintainer's preferences at all. This document is the deep reference behind the\nshort posture block that every one of those surfaces carries verbatim.\n\nThe block itself is short on purpose — it competes for attention inside prompts\nthat are already long. Everything that explains *why* lives here.\n\n## The canonical block\n\nThis file **is** the canonical source. The marker-delimited block below is\nduplicated byte-identically onto every carrier — every surface that decides\nticket shape holds these exact bytes, so no surface can quietly drift into its\nown house style.\n\nCarriers (all four hold the block verbatim):\n\n- `agents/src/jira-ticket-writer.md` — the writer itself, plus a compressed\n posture line in its `description:` frontmatter, which is the only coverage a\n bare-chat session gets with no file read and no `tools/list` cost.\n- `commands/src/explore-ticket.md` — Stage 9, the most-used authoring surface.\n- `mcp_server/instructions/decompose-epic-candidate.md` — the `idea-to-ticket`\n decomposition step.\n- `mcp_server/instructions/decompose-epic.md` — the `plan-epic` decomposition\n step.\n\nEdit the block here, copy it verbatim to each carrier, and let\n`tests/pytest/mcp_server/test_ticket_authoring_posture_assets.py` prove it\nlanded. That test permits **no** per-surface variation.\n\n<!-- BEGIN BRIDGE TICKET-AUTHORING POSTURE -->\n<!-- Canonical source: docs/bridge-ticket-authoring.md.\n This block is duplicated byte-identically onto every carrier. Never edit a\n copy: edit the canonical source and re-copy it verbatim. A cross-surface\n byte-equality test fails the build if any copy drifts by a single byte. -->\n\n## Ticket-authoring posture\n\nDeep reference: `docs/bridge-ticket-authoring.md`.\n\n**Draft through the writer.** Every ticket body — an epic parent, an epic child,\nand an ordinary sibling alike — is drafted by the `jira-ticket-writer` agent\nbefore `create_ticket` is called. Do not compose a ticket description inline.\n\n**Size the work.** Size each ticket by file-touch breadth and depth plus rough\nlines of code (LOC) changed:\n\n- `S = 1-2 files / <~80 LOC`\n- `M = ~3-8 files / ~80-400 LOC`\n- `L = ~8-15 files / ~400-900 LOC`\n- `XL = >15 files / >~900 LOC`\n\nTarget size priority: **L (target) -> XL (when the work does not fit in L) -> M\n(third choice) -> S (only when unavoidable)**. This applies equally to a\nstandalone ticket and to an epic child.\n\nAim each slice at L. When one will not fit, grow it to XL rather than splitting\nit — split only when the slice is genuinely two independent pieces of work,\nnever merely to land inside a band. Bridge's grooming and implementation process\nhandles a large vertical slice well and is overkill on small ones: every extra\nticket is another worktree, another PR, another rebase, and another chance for\ntwo workers to touch the same file. Reach for M because the work genuinely is\nthat size, not to avoid an XL.\n\nBeyond roughly 40 files or ~3000 LOC, split anyway. Past that point review\nturnaround and rebase cost dominate the run's budget, and a review that wedges\nholds the gate to its full retry ceiling before anyone notices.\n\n**Group at three.** Three or more implementable tickets is an epic: propose an\nepic parent plus an ordered child manifest, and resolve this surface's own\napproval gate before anything is created. One or two tickets are ordinary\nsiblings — no epic parent, no manifest. The threshold is exactly three.\n\n**Hand off once.** An epic handoff names exactly one conductor entry point,\n`drive-epic`, which selects the runnable path itself. Never present a choice\nbetween conductors.\n\n**Departure is closed-list only.** These three exceptions, and no others, permit\ndeparting from the rules above. Invoking one requires no announcement.\n\n- **E1 External-tracker mirroring** — a recorded upstream identifier exists and\n its granularity is contractual. Bypasses sizing and the epic threshold.\n- **E2 Discovery-only spike** — no committed production-code deliverable.\n Bypasses sizing only; does not bypass drafting through the writer.\n- **E3 Authorized incident containment** — tied to an active incident record,\n not to schedule pressure. Bypasses sizing and the epic threshold.\n\nThe list is closed. Anything outside it is an escalation to the operator, not a\njudgement call. Explicitly refused as grounds for departure: a single-file\ntrivial fix (that is `S` reached through the normal path, not an exception),\ngeneric time pressure, \"already well specified\", \"faster without the writer\",\ndeveloper discretion, minor refactor, unattended mode, context limits, and \"hard\nto decompose\" (XL is the normal overflow, so that is the ordinary path and not a\ndeparture). Writer unavailability escalates; it never silently authorizes inline\ndrafting.\n\n<!-- END BRIDGE TICKET-AUTHORING POSTURE -->\n\nThe rest of this document is the rationale the block is deliberately too short to\ncarry.\n\n## Decision: Jira ticket authoring ships through the Jira Ticket Writer (BAPI-900)\n\nBridge ships two very different kinds of ticket-authoring surface, and customers\nneed to know which one they actually have.\n\n**Shipped customer surface.** A customer project gets the `jira-ticket-writer`\nagent — the same writer this posture requires every ticket body to go through —\nplus the agent-directed capability to revise an existing ticket's description.\nAsk your agent to draft a ticket with the Jira Ticket Writer, and ask your agent\nto update an existing ticket's description when it needs revising. Both reach a\ncustomer project because they are packaged: the writer through `AGENTS`\n(`mcp_server/src/agents.generated.ts`) and the description-update path through\nthe registered `update_ticket_description` / `request_ticket_update` MCP tools.\n\n**Repository-local workflows.** `.claude/commands/write-ticket.md` and\n`.claude/commands/update-ticket.md` are bridge-api's own repository-maintenance\ncommands. They are **not** scaffolded into a customer project by `--init`, have\nno `commands/src/` source, and have no generated Cursor or `mcp_server/`\nmirror — deliberately, not by omission. A customer asking their agent to run\nthe write-ticket or update-ticket slash command will not find either one,\nbecause neither ships.\n\n**Why (Option B, not a promotion to shipped status).** The Jira Ticket Writer is\nalready the packaged drafting surface this posture mandates, so shipping\n`write-ticket.md` as a second drafting entry point would duplicate it. More\nimportantly, `write-ticket.md` is today an autonomous, single-ticket, no-halt\npipeline (\"No human confirmation gates — run end-to-end\") with no decomposition\nstep and no approval gate — it cannot honor the \"group at three\" epic rule or\nthe epic approval gate this posture requires, because it was never built to\npropose an epic at all. Promoting it to a shipped surface without that redesign\nwould ship a customer-facing command that silently violates this file's own\nposture. Until that redesign happens, `write-ticket.md` and `update-ticket.md`\nstay repository-local, and every packaged surface directs customers to the Jira\nTicket Writer and to agent-directed description updates instead.\n\n\n## The four rules\n\n### 1. Draft through `jira-ticket-writer`\n\nEvery ticket body is drafted by the `jira-ticket-writer` agent before\n`create_ticket` is called — an epic parent, an epic child, and an ordinary\nsibling alike. Nothing composes a ticket description inline.\n\nThe writer is not a formatter. It runs a codebase-research pass first, so its\ntickets cite the files, functions, and extension points a change actually\ntouches. A description written inline skips that pass, and the difference shows\nup two steps later: plan generation and implementation both ground themselves in\nthe ticket body, so a body with no code references produces a plan with no code\nreferences.\n\n\"The ticket is already well specified\" is not a reason to skip the writer. A\nwell-specified *request* is the writer's input, not a substitute for its output.\n\n### 2. Size toward L\n\nSize each ticket by file-touch breadth and depth plus rough lines of code\nchanged:\n\n| Band | Files | LOC |\n| --- | --- | --- |\n| `S` | 1–2 | `<~80` |\n| `M` | ~3–8 | ~80–400 |\n| `L` | ~8–15 | ~400–900 |\n| `XL` | >15 | `>~900` |\n\nPriority: **L (target) → XL (when the work does not fit in L) → M (third choice)\n→ S (only when unavoidable)**.\n\nThe target is L because the Bridge implementation tooling works best on\nindependently implementable vertical slices. What matters as much as the target\nis the **direction you move when a slice misses it**: upward, not downward.\n\nA slice that will not fit in L becomes **one XL ticket**, not two L ones. Split\nonly when the slice is genuinely two independent pieces of work — never merely to\nland inside a band. Fragmenting a coherent slice to fit is the failure this\nladder exists to prevent: every extra ticket is another worktree, another PR,\nanother rebase, and another chance for two workers to touch the same file, and\nBridge's grooming process is overkill on small tickets. Fewer, larger slices\nspend less of the run's budget on coordination.\n\nThis applies equally to a standalone ticket and to an epic child. There is no\nsize ceiling on a child that a lone ticket does not also have.\n\n`M` is where you land when the work genuinely is three to eight files — not\nsomewhere to retreat to in order to avoid an XL. `S` is likewise not forbidden:\nit is simply what you reach when the work genuinely is one or two files. A\nsingle-file trivial fix is `S` arrived at through the normal path. It is not an\nexception to anything, and it does not license skipping the writer.\n\n**Beyond roughly 40 files or ~3000 LOC, split anyway.** XL is the preferred\noverflow, not an unbounded one. Past that point review turnaround and rebase cost\ndominate the run's budget, and a review that wedges holds the gate to its full\nretry ceiling before anyone notices. That is a real bound, not a preference — and\nit is high enough that reaching it means the work really is two things.\n\n### 3. Group at three\n\nThree or more implementable tickets is an epic. The surface proposes an epic\nparent plus an **ordered child manifest**, and resolves its own approval gate\nbefore anything is created.\n\nOne or two tickets are ordinary siblings: no epic parent, no manifest. The\nthreshold is exactly three — not \"several\", not \"a lot\".\n\nThe manifest carries, per child: the boundary of its scope, its size band,\n`depends_on` (hard prerequisites that must land first), `recommended_after` (soft\nsequencing preferences that are not blockers), and a one-line order rationale.\nHard prerequisites and soft sequencing stay strictly separate, because the\nrecommended implementation order is derived from them and conflating the two\nproduces a serialized order where a parallel one was available.\n\nApproval follows each surface's **existing** attended/unattended rule. Nothing\nhere introduces a new gate policy: `/explore-ticket` requires an explicit\naffirmative because creation is irreversible, and the recipe path gates on the\npipeline's own auto-approval variable. What is *not* conditional is the grouping\nitself — an unattended run still produces the epic; only the gate's behavior\nvaries.\n\nDecomposition happens **once**. The pass that decides the split freezes the\nmanifest; body rendering then fans out one writer invocation per entry against\nthat frozen manifest. A rendering invocation may not re-split, merge, reorder,\nrenumber, or rescope. Two independent decisions about the same split disagree,\nand the disagreement surfaces as children that overlap or contradict their\nparent.\n\n### 4. Hand off to exactly one conductor\n\nAn epic handoff names exactly one conductor entry point: `drive-epic`.\n\nBridge currently has two conductors — the v2 server-side engine and the LLM\nconductor pilot — and a standing rule that they must never operate on the same\nepic, because two transition authorities on one epic wedge it permanently. Asking\na model to pick correctly every time is not a control. `drive-epic` makes the\nchoice structural instead: it reads conductor readiness and routes to the one\npath the project can actually run, so no prompt names either underlying conductor\nand no prompt can present both.\n\nTwo conductors is a transitional state. When one is eliminated, `drive-epic` is\nthe only thing that changes — no prompt, bundled doc, command mirror, or posture\ntest moves.\n\n## The closed exception list\n\nExactly three exceptions permit departing from the rules above. Invoking one\nrequires **no announcement** — the departure is silent by design, because a\nmandatory announcement would be one more instruction to drift from, and the cost\nof silence was weighed and accepted.\n\n| Id | Exception | Objective trigger | Bypasses |\n| --- | --- | --- | --- |\n| **E1** | External-tracker mirroring | A recorded upstream identifier exists and its granularity is contractual | Sizing and the epic threshold |\n| **E2** | Discovery-only spike | No committed production-code deliverable | Sizing only — **not** drafting through the writer |\n| **E3** | Authorized incident containment | Tied to an active incident record, not to schedule pressure | Sizing and the epic threshold |\n\nEach trigger is objective: an identifier that exists, a deliverable that is\nabsent, an incident record that is open. None of them is a judgement about how\nthe work feels.\n\n### The list is closed\n\nAnything outside the three rows above is an **escalation to the operator**, not a\njudgement call. The following are explicitly refused as grounds for departure:\n\n- a single-file trivial fix — that is `S` reached through the normal path;\n- generic time pressure;\n- \"the request is already well specified\";\n- \"it would be faster without the writer\";\n- developer discretion;\n- \"it's just a minor refactor\";\n- running unattended;\n- context limits;\n- \"this is hard to decompose\" — XL is the normal overflow, so that is the\n ordinary path and not a departure.\n\n**Writer unavailability escalates.** It never silently authorizes inline\ndrafting. A surface that cannot reach `jira-ticket-writer` stops and says so.\n\n## Isolation binding for shared-state test support\n\nA ticket that builds or changes test support which resets shared state — a\nharness, a fixture, a reset helper, anything that truncates, drops, or\nreinitializes state another process or another run can also read or write —\nmust state its isolation binding as a requirement: which database, directory,\nor other shared resource the reset targets, and how the ticket's own\ndeliverable proves that target's identity before it destroys anything.\n\nThis doctrine exists because BAPI-1006 shipped a conductor integration-test\nharness with nothing in its ticket stating what the harness's destructive\nreset was bound to, and a v2 worker dispatched to build it truncated the\noperator's operational `bridgeapi` database (Architecture Miss 28). The\ncontainment-hazard classifier this repository runs at planning time\n(`api/library/github/workflow_planning_prediction.py`) can flag such a ticket\nfrom its text, but the flag is advisory — it surfaces the hazard before\ndispatch, it does not prevent a destructive worker on its own. Stating the\nisolation binding in the ticket itself is the durable requirement; treat this\nas an authoring-posture rule, not as runtime enforcement.\n\n## Accepted trade-off: silent departure is unobservable\n\nObservability was deliberately dropped when this posture was ratified. A model\nmay invoke E1, E2, or E3 without recording that it did, so posture drift is only\ndetectable through ticket quality — not through a log, a counter, or a report.\n\nThis is known and accepted. The alternative was another mandatory instruction on\nevery surface, and an instruction that is skipped silently is worse than one that\ndoes not exist: it reads as coverage while providing none.\n\n## Why duplication, not a shared include\n\nCommands, agents, instructions, and docs have four separate build paths in this\nrepository and no shared compiler. Introducing a generated include step to share\none block would mean a fifth build path, a placeholder that can go unresolved,\nand a failure mode where a carrier ships with the placeholder text still in it.\n\nMarker-delimited duplication plus one byte-equality test is the right mechanism\nat this scale. The test reads the canonical sources directly — never the\ngenerated command mirrors, whose byte-identity the command tests already cover —\nand permits **no** per-surface variation. Any drift, down to a single byte, fails.\n\n## A fresh install inherits this\n\nNo configuration step, no server call. The posture reaches a new project through\nthe packaged bundles that `--init` scaffolds:\n\n- `COMMANDS` (`mcp_server/src/commands.generated.ts`) — carries\n `commands/src/explore-ticket.md`;\n- `AGENTS` (`mcp_server/src/agents.generated.ts`) — carries\n `agents/src/jira-ticket-writer.md`, including the compressed posture line in\n its `description:` frontmatter;\n- `INSTRUCTIONS` (`mcp_server/src/pipelines.generated.ts`) — carries the\n canonical source and both decomposition instructions;\n- `DOCS` (`mcp_server/src/docs.generated.ts`) — carries this document.\n\nThe compressed frontmatter line matters more than its size suggests: agent\ndescriptions land in every session's system prompt with no file read and no\n`tools/list` cost, so it is the entire bare-chat coverage story.\n\n## Worked examples\n\n**One ticket.** \"Add a `--json` flag to `doctor`.\" Two files and a test, ~90 LOC.\nThat is `M`. One ticket, drafted by the writer, no epic, no manifest, no\nconductor handoff.\n\n**Two tickets.** \"Add rate limiting to the LLM client, and surface the limit in\nthe config UI.\" Backend and frontend are independently implementable and land\nseparately: two ordinary siblings. Still no epic — the threshold is three.\n\n**Four tickets → an epic.** \"Make local ticket mode a first-class system.\"\nDecomposition freezes a parent plus four children, each `L`, with `depends_on`\nnaming the one child that must land first. The full manifest goes to the approval\ngate; on approval, four writer invocations render four bodies against their\nfrozen entries; creation follows `upload-epic-hierarchy.md`; the handoff names\n`drive-epic` and nothing else.\n\n**A child that outgrows `L`.** A proposed child comes out at 19 files. It ships\nas one `XL` child. Do not split it into two `L` children to make it fit — the\nslice is one coherent piece of work, and halving it buys a second worktree, a\nsecond PR, and a rebase between them in exchange for nothing. Split only if the\n19 files really are two independent deliverables.\n\n**Past the ceiling.** A proposed ticket comes out at 60 files and ~5000 LOC.\nThat is over the bound, so it splits — but into the largest coherent pieces\navailable, not into a swarm. Two `XL` tickets is the right answer here; six `M`\nones is not.\n"
|
|
7
7
|
};
|