@bridge_gpt/mcp-server 0.2.74 → 0.2.75
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 +14 -7
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +2 -2
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +666 -46
- package/build/conductor/epic-implementer-cli.js +337 -93
- package/build/conductor/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +2 -2
- package/build/drive-epic.js +387 -12
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +152 -38
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/job-runner.js +9 -722
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/required-verification.js +28 -2
- package/build/executor/runner.js +4 -1
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/generated/ticket-status.js +20 -0
- package/build/index.js +391 -257
- package/build/install-bridge-conductor-answers.js +28 -1
- package/build/install-bridge-conductor-apply.js +11 -3
- package/build/install-bridge-conductor-assessment.js +114 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +4 -4
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +303 -31
- package/build/pipelines.generated.js +7 -7
- package/build/plan-generation.js +17 -0
- package/build/printed-remedy-commands.js +54 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +11 -5
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/setup-epic.js +10 -1
- package/build/test-support/executor-source-files.js +1 -1
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/docs/EPIC-IMPLEMENTER.md +4 -4
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -57,6 +57,8 @@ import { AGENTS } from "../agents.generated.js";
|
|
|
57
57
|
import { ConductorBridgeApiError, fetchStoredTicket, resolveConductorBridgeApiAccess, } from "./bridge-api-client.js";
|
|
58
58
|
import { ConductorValidationError } from "./errors.js";
|
|
59
59
|
import { writeJsonDocument } from "./json-output.js";
|
|
60
|
+
import { findOpenDecisionPhrase } from "./open-decision-phrases.js";
|
|
61
|
+
import { redactSecrets } from "../secret-redaction.js";
|
|
60
62
|
// ---------------------------------------------------------------------------
|
|
61
63
|
// Constants
|
|
62
64
|
// ---------------------------------------------------------------------------
|
|
@@ -300,6 +302,25 @@ export function formatPrerequisiteInput(epicKey, epicDescription, childKey, chil
|
|
|
300
302
|
function hash12(inputHash) {
|
|
301
303
|
return inputHash.slice(0, 12);
|
|
302
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* BAPI-1704 — display-only protection. Open-decision text is quoted from an
|
|
307
|
+
* untrusted description, so outward JSON copies run it through `redactSecrets`.
|
|
308
|
+
* The validated result (and what is cached) stays raw; only a copy is changed.
|
|
309
|
+
*/
|
|
310
|
+
function redactItemForDisplay(item) {
|
|
311
|
+
if ("category" in item && item.category === "open-decision") {
|
|
312
|
+
return { ...item, requirement: redactSecrets(item.requirement), evidence: redactSecrets(item.evidence) };
|
|
313
|
+
}
|
|
314
|
+
return item;
|
|
315
|
+
}
|
|
316
|
+
function redactResultForDisplay(result) {
|
|
317
|
+
return result.status === "cached" ? { ...result, items: result.items.map(redactItemForDisplay) } : result;
|
|
318
|
+
}
|
|
319
|
+
function redactRecordForDisplay(result) {
|
|
320
|
+
if (result.status === "cached")
|
|
321
|
+
return { ...result, items: result.items.map(redactItemForDisplay) };
|
|
322
|
+
return result.items === undefined ? result : { ...result, items: result.items.map(redactItemForDisplay) };
|
|
323
|
+
}
|
|
303
324
|
/**
|
|
304
325
|
* The lookup result list. Human output names statuses and short hash prefixes
|
|
305
326
|
* only: never a requirement, evidence, description, or scanner text. The JSON
|
|
@@ -307,7 +328,7 @@ function hash12(inputHash) {
|
|
|
307
328
|
*/
|
|
308
329
|
export function formatPrerequisiteInputResults(results, json) {
|
|
309
330
|
if (json)
|
|
310
|
-
return JSON.stringify({ results });
|
|
331
|
+
return JSON.stringify({ results: results.map(redactResultForDisplay) });
|
|
311
332
|
return results
|
|
312
333
|
.map((r) => {
|
|
313
334
|
switch (r.status) {
|
|
@@ -326,7 +347,7 @@ export function formatPrerequisiteInputResults(results, json) {
|
|
|
326
347
|
/** The one stdout document for a record result. Human output holds no item text. */
|
|
327
348
|
export function formatPrerequisiteRecordResult(result, json) {
|
|
328
349
|
if (json)
|
|
329
|
-
return JSON.stringify({ results: [result] });
|
|
350
|
+
return JSON.stringify({ results: [redactRecordForDisplay(result)] });
|
|
330
351
|
if (result.status === "cached") {
|
|
331
352
|
return `${result.child}: cached (input ${hash12(result.inputHash)}, ${result.items.length} items)`;
|
|
332
353
|
}
|
|
@@ -385,12 +406,54 @@ function resolveAgentVersion(deps) {
|
|
|
385
406
|
const CLASSIC_KEYS = ["requirement", "dependents", "class", "env", "uncertain", "evidence"];
|
|
386
407
|
const NOT_MEASURABLE_KEYS = ["requirement", "dependents", "class", "measurable", "uncertain", "evidence"];
|
|
387
408
|
const WORKER_RUNTIME_KEYS = ["requirement", "dependents", "category", "uncertain", "evidence"];
|
|
409
|
+
const OPEN_DECISION_KEYS = ["requirement", "dependents", "category", "evidence"];
|
|
410
|
+
/**
|
|
411
|
+
* The child's own text. For a formatted input this is everything after the LAST
|
|
412
|
+
* `\n\nChild: ${child}\n` marker (the real marker is written last, so a marker
|
|
413
|
+
* spoofed inside epic text cannot move the boundary); `undefined` when absent. An
|
|
414
|
+
* isolated source is returned unchanged.
|
|
415
|
+
*/
|
|
416
|
+
export function childSegment(source, child) {
|
|
417
|
+
if (source.kind === "isolated")
|
|
418
|
+
return source.text;
|
|
419
|
+
const marker = `\n\nChild: ${child}\n`;
|
|
420
|
+
const at = source.input.lastIndexOf(marker);
|
|
421
|
+
return at < 0 ? undefined : source.input.slice(at + marker.length);
|
|
422
|
+
}
|
|
388
423
|
function codePointLength(text) {
|
|
389
424
|
return Array.from(text).length;
|
|
390
425
|
}
|
|
391
426
|
function sameKeys(actual, expected) {
|
|
392
427
|
return actual.length === expected.length && expected.every((key) => actual.includes(key));
|
|
393
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* BAPI-1704 — validate an open-decision item: exactly four keys, the usual
|
|
431
|
+
* requirement bounds, this child as the dependent, and evidence that is nonempty,
|
|
432
|
+
* one line, at most 200 code points, and a literal substring of the CHILD's own
|
|
433
|
+
* text (never the epic's).
|
|
434
|
+
*/
|
|
435
|
+
function validateOpenDecisionFields(fields, keys, child, input) {
|
|
436
|
+
if (!sameKeys(keys, OPEN_DECISION_KEYS))
|
|
437
|
+
return undefined;
|
|
438
|
+
const { requirement, dependents, evidence } = fields;
|
|
439
|
+
if (typeof requirement !== "string" || typeof dependents !== "string" || typeof evidence !== "string") {
|
|
440
|
+
return undefined;
|
|
441
|
+
}
|
|
442
|
+
if (requirement.length === 0 || codePointLength(requirement) > PREREQUISITE_TEXT_MAX_CHARS)
|
|
443
|
+
return undefined;
|
|
444
|
+
if (requirement.includes("`") || /[\r\n]/.test(requirement))
|
|
445
|
+
return undefined;
|
|
446
|
+
if (dependents !== child)
|
|
447
|
+
return undefined;
|
|
448
|
+
if (evidence.length === 0 || codePointLength(evidence) > PREREQUISITE_TEXT_MAX_CHARS)
|
|
449
|
+
return undefined;
|
|
450
|
+
if (/[\r\n]/.test(evidence))
|
|
451
|
+
return undefined;
|
|
452
|
+
const segment = childSegment({ kind: "formatted", input }, child);
|
|
453
|
+
if (segment === undefined || !segment.includes(evidence))
|
|
454
|
+
return undefined;
|
|
455
|
+
return { requirement, dependents, category: "open-decision", evidence };
|
|
456
|
+
}
|
|
394
457
|
/**
|
|
395
458
|
* Validate one item's fields against the child and the exact input. Returns the
|
|
396
459
|
* typed item, or `undefined` when any constraint fails. Evidence is only checked
|
|
@@ -403,6 +466,10 @@ function validateItemFields(fields, child, input) {
|
|
|
403
466
|
const value = fields[key];
|
|
404
467
|
return typeof value === "string" ? value : undefined;
|
|
405
468
|
};
|
|
469
|
+
if (fields.category === "open-decision") {
|
|
470
|
+
// BAPI-1704: handled before the legacy `uncertain` and worker-runtime branches.
|
|
471
|
+
return validateOpenDecisionFields(fields, keys, child, input);
|
|
472
|
+
}
|
|
406
473
|
const requirement = text("requirement");
|
|
407
474
|
const dependents = text("dependents");
|
|
408
475
|
const uncertain = text("uncertain");
|
|
@@ -453,10 +520,13 @@ const FIELD_LINE = /^([a-z]+): ?(.*)$/;
|
|
|
453
520
|
*
|
|
454
521
|
* The reply must be exactly one complete fenced `prerequisites` block and nothing
|
|
455
522
|
* else. Its body is explicit `none`, one `not verified: <reason>` line, or at most
|
|
456
|
-
* twenty items. Any structural defect in any item invalidates the whole child
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
523
|
+
* twenty items. Any structural defect in any item invalidates the whole child,
|
|
524
|
+
* with one narrow exception (BAPI-1704): a cleanly parsed item whose category is
|
|
525
|
+
* exactly `open-decision` that fails field validation is dropped alone and counted
|
|
526
|
+
* in `openDecisionDropped`. That is distinct from a parse failure (whole block
|
|
527
|
+
* invalid) and from the literal-evidence drop below. Only after every item is
|
|
528
|
+
* structurally valid are items whose evidence is not a literal substring of the
|
|
529
|
+
* input dropped, and those drops are counted in `dropped`, never described.
|
|
460
530
|
*/
|
|
461
531
|
export function validateScannerBlock(text, child, input) {
|
|
462
532
|
const normalized = text.replace(/\r\n/g, "\n").trim();
|
|
@@ -465,7 +535,7 @@ export function validateScannerBlock(text, child, input) {
|
|
|
465
535
|
return { kind: "invalid" };
|
|
466
536
|
const body = fenced[2];
|
|
467
537
|
if (body === "none")
|
|
468
|
-
return { kind: "items", items: [], dropped: 0 };
|
|
538
|
+
return { kind: "items", items: [], dropped: 0, openDecisionDropped: 0 };
|
|
469
539
|
const failure = /^not verified: (.{1,200})$/.exec(body);
|
|
470
540
|
if (failure !== null && !body.includes("\n")) {
|
|
471
541
|
return {
|
|
@@ -499,14 +569,88 @@ export function validateScannerBlock(text, child, input) {
|
|
|
499
569
|
if (parsed.length === 0 || parsed.length > PREREQUISITE_MAX_ITEMS)
|
|
500
570
|
return { kind: "invalid" };
|
|
501
571
|
const valid = [];
|
|
572
|
+
let openDecisionDropped = 0;
|
|
502
573
|
for (const fields of parsed) {
|
|
503
574
|
const item = validateItemFields(fields, child, input);
|
|
504
|
-
if (item === undefined)
|
|
575
|
+
if (item === undefined) {
|
|
576
|
+
// BAPI-1704: framing and field parsing already succeeded. Only a cleanly
|
|
577
|
+
// parsed item whose category is exactly `open-decision` is dropped alone;
|
|
578
|
+
// every other invalid item (including `Open-Decision`) invalidates the block.
|
|
579
|
+
if (fields.category === "open-decision") {
|
|
580
|
+
openDecisionDropped += 1;
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
505
583
|
return { kind: "invalid" };
|
|
584
|
+
}
|
|
506
585
|
valid.push(item);
|
|
507
586
|
}
|
|
508
587
|
const kept = valid.filter((item) => input.includes(item.evidence));
|
|
509
|
-
return { kind: "items", items: kept, dropped: valid.length - kept.length };
|
|
588
|
+
return { kind: "items", items: kept, dropped: valid.length - kept.length, openDecisionDropped };
|
|
589
|
+
}
|
|
590
|
+
// ---------------------------------------------------------------------------
|
|
591
|
+
// Open-decision backstop (BAPI-1704)
|
|
592
|
+
// ---------------------------------------------------------------------------
|
|
593
|
+
/** The most backstop items one child may produce, independent of the agent-item cap. */
|
|
594
|
+
export const OPEN_DECISION_BACKSTOP_MAX_ITEMS = 20;
|
|
595
|
+
const MARKDOWN_FENCE_LINE = /^\s*(```|~~~)/;
|
|
596
|
+
const NOFORMAT_LINE = /\{noformat(?::[^}]*)?\}/i;
|
|
597
|
+
/**
|
|
598
|
+
* Derive advisory open-decision items straight from the child's own text, without
|
|
599
|
+
* a scanner. It is pure and never cached: the caller recomputes it on every read.
|
|
600
|
+
*
|
|
601
|
+
* Fenced code blocks and Jira `{noformat}` regions are skipped (delimiter lines
|
|
602
|
+
* too), following the canonical semantics in `docs/bridge-ticket-authoring.md`.
|
|
603
|
+
* A line already covered by an agent open-decision item's unchanged evidence is
|
|
604
|
+
* suppressed. Each remaining matching line yields one item for its earliest
|
|
605
|
+
* phrase, quoting from the start of the sentence holding the match through the end
|
|
606
|
+
* of the line, bounded to 200 code points and always a literal substring of the
|
|
607
|
+
* source. At most {@link OPEN_DECISION_BACKSTOP_MAX_ITEMS} items are returned.
|
|
608
|
+
*/
|
|
609
|
+
export function openDecisionBackstop(source, child, agentItems) {
|
|
610
|
+
const segment = childSegment(source, child);
|
|
611
|
+
if (segment === undefined)
|
|
612
|
+
return [];
|
|
613
|
+
const agentEvidence = agentItems
|
|
614
|
+
.filter((item) => "category" in item && item.category === "open-decision")
|
|
615
|
+
.map((item) => item.evidence);
|
|
616
|
+
const out = [];
|
|
617
|
+
let inFence = false;
|
|
618
|
+
let inNoformat = false;
|
|
619
|
+
for (const line of segment.split("\n")) {
|
|
620
|
+
if (out.length >= OPEN_DECISION_BACKSTOP_MAX_ITEMS)
|
|
621
|
+
break;
|
|
622
|
+
if (!inNoformat && MARKDOWN_FENCE_LINE.test(line)) {
|
|
623
|
+
inFence = !inFence;
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
if (!inFence && NOFORMAT_LINE.test(line)) {
|
|
627
|
+
inNoformat = !inNoformat;
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (inFence || inNoformat)
|
|
631
|
+
continue;
|
|
632
|
+
if (agentEvidence.some((evidence) => line.includes(evidence)))
|
|
633
|
+
continue;
|
|
634
|
+
const match = findOpenDecisionPhrase(line);
|
|
635
|
+
if (match === undefined)
|
|
636
|
+
continue;
|
|
637
|
+
const sentenceBreak = line.slice(0, match.index).lastIndexOf(". ");
|
|
638
|
+
let start = sentenceBreak < 0 ? 0 : sentenceBreak + 2;
|
|
639
|
+
while (start < match.index && /\s/.test(line[start]))
|
|
640
|
+
start += 1;
|
|
641
|
+
const lineBreak = line.slice(start).search(/[\r\n]/);
|
|
642
|
+
const tail = lineBreak < 0 ? line.slice(start) : line.slice(start, start + lineBreak);
|
|
643
|
+
const evidence = Array.from(tail).slice(0, PREREQUISITE_TEXT_MAX_CHARS).join("");
|
|
644
|
+
if (evidence.length === 0)
|
|
645
|
+
continue;
|
|
646
|
+
out.push({
|
|
647
|
+
requirement: `Ticket text leaves a decision open ("${match.phrase}").`,
|
|
648
|
+
dependents: child,
|
|
649
|
+
category: "open-decision",
|
|
650
|
+
evidence,
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
return out;
|
|
510
654
|
}
|
|
511
655
|
// ---------------------------------------------------------------------------
|
|
512
656
|
// Filesystem
|
|
@@ -979,6 +1123,9 @@ function notCached(child, inputHash, reason, extra = {}) {
|
|
|
979
1123
|
verified: extra.verified ?? false,
|
|
980
1124
|
...(extra.items !== undefined ? { items: extra.items } : {}),
|
|
981
1125
|
...(extra.dropped !== undefined ? { dropped: extra.dropped } : {}),
|
|
1126
|
+
...(extra.openDecisionDropped !== undefined && extra.openDecisionDropped > 0
|
|
1127
|
+
? { openDecisionDropped: extra.openDecisionDropped }
|
|
1128
|
+
: {}),
|
|
982
1129
|
};
|
|
983
1130
|
}
|
|
984
1131
|
/**
|
|
@@ -1039,13 +1186,23 @@ async function recordResult(ctx, deps, parsed, stdinText) {
|
|
|
1039
1186
|
verified: outcome.items.length > 0,
|
|
1040
1187
|
...(outcome.items.length > 0 ? { items: outcome.items } : {}),
|
|
1041
1188
|
dropped: outcome.dropped,
|
|
1189
|
+
openDecisionDropped: outcome.openDecisionDropped,
|
|
1042
1190
|
});
|
|
1043
1191
|
}
|
|
1044
1192
|
const wrote = await writeCacheEntry(ctx, child, suppliedHash, outcome.items);
|
|
1045
1193
|
await release();
|
|
1046
|
-
if (!wrote)
|
|
1047
|
-
return notCached(child, suppliedHash, "cache unavailable"
|
|
1048
|
-
|
|
1194
|
+
if (!wrote) {
|
|
1195
|
+
return notCached(child, suppliedHash, "cache unavailable", {
|
|
1196
|
+
openDecisionDropped: outcome.openDecisionDropped,
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
return {
|
|
1200
|
+
child,
|
|
1201
|
+
status: "cached",
|
|
1202
|
+
inputHash: suppliedHash,
|
|
1203
|
+
items: outcome.items,
|
|
1204
|
+
...(outcome.openDecisionDropped > 0 ? { openDecisionDropped: outcome.openDecisionDropped } : {}),
|
|
1205
|
+
};
|
|
1049
1206
|
}
|
|
1050
1207
|
catch {
|
|
1051
1208
|
return notCached(child, suppliedHash, "cache unavailable");
|
|
@@ -1061,7 +1218,11 @@ async function recordResult(ctx, deps, parsed, stdinText) {
|
|
|
1061
1218
|
* {@link readCacheEntry}. It takes no scan claim, creates no directory, writes no
|
|
1062
1219
|
* file, and never reports a scan as needed. A child with no valid entry (a miss, a
|
|
1063
1220
|
* changed description, an unreadable or corrupt entry, an oversize input, a failed
|
|
1064
|
-
* ticket read) is simply absent from the result
|
|
1221
|
+
* ticket read) is simply absent from the result, unless the BAPI-1704 open-decision
|
|
1222
|
+
* backstop finds a match in the child's own text: then the entry holds only those
|
|
1223
|
+
* generated items. An entry may therefore carry transient enrichment (cached agent
|
|
1224
|
+
* items followed by freshly derived backstop items) rather than only persisted
|
|
1225
|
+
* scanner results; nothing derived is ever written. Only a failure that affects every
|
|
1065
1226
|
* child (an epic read failure, an unavailable scanner entry, bad keys) is
|
|
1066
1227
|
* `unavailable`. Descriptions and evidence never leave this function except as
|
|
1067
1228
|
* validated items.
|
|
@@ -1092,7 +1253,13 @@ export async function readCachedPrerequisites(input, deps = {}) {
|
|
|
1092
1253
|
if (Buffer.byteLength(content, "utf8") > PREREQUISITE_INPUT_MAX_BYTES)
|
|
1093
1254
|
return null;
|
|
1094
1255
|
const cached = await readCacheEntry(ctx, child, computeInputHash(agentVersion, content), content);
|
|
1095
|
-
|
|
1256
|
+
const cachedItems = cached.kind === "hit" ? cached.items : [];
|
|
1257
|
+
// BAPI-1704: recompute the uncached backstop from the child's own description
|
|
1258
|
+
// (isolated; never parsed out of the combined epic-and-child text).
|
|
1259
|
+
const backstop = openDecisionBackstop({ kind: "isolated", text: wrapDescription(ticket.description) }, child, cachedItems);
|
|
1260
|
+
if (cached.kind !== "hit" && backstop.length === 0)
|
|
1261
|
+
return null;
|
|
1262
|
+
return { child, items: [...cachedItems, ...backstop] };
|
|
1096
1263
|
}
|
|
1097
1264
|
catch {
|
|
1098
1265
|
return null;
|
|
@@ -32,6 +32,21 @@ const ALL_STATUSES = new Set([
|
|
|
32
32
|
"waiting",
|
|
33
33
|
...TERMINAL_STATUSES,
|
|
34
34
|
]);
|
|
35
|
+
/** GitHub logins: alphanumerics and single hyphens, at most 39 characters. */
|
|
36
|
+
const GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\[bot\])?$/;
|
|
37
|
+
/**
|
|
38
|
+
* Parse the optional proven-identity fields (BAPI-1697). Each is kept only when it
|
|
39
|
+
* looks like a GitHub login, so a malformed server value can never reach the terminal
|
|
40
|
+
* as anything but "not shown". Missing fields stay valid: the status allowlist is
|
|
41
|
+
* unchanged and older servers never send them.
|
|
42
|
+
*/
|
|
43
|
+
export function parseProvenIdentity(body) {
|
|
44
|
+
const pick = (value) => typeof value === "string" && GITHUB_LOGIN_PATTERN.test(value) ? value : null;
|
|
45
|
+
return {
|
|
46
|
+
provenGithubLogin: pick(body?.proven_github_login),
|
|
47
|
+
provenGithubAccount: pick(body?.proven_github_account),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
35
50
|
const KNOWN_INDEXING_STATUSES = new Set([
|
|
36
51
|
"started",
|
|
37
52
|
"waiting-for-setup",
|
|
@@ -196,6 +211,7 @@ export async function fetchGithubConnectionStatus(deps, repoName, state, nowMs =
|
|
|
196
211
|
// A single read has no deadline of its own to clamp against; the poller applies
|
|
197
212
|
// its own bound. POLL_DEADLINE_MS is the widest a caller could honor.
|
|
198
213
|
retryAfterMs: parseRetryAfterMs(res.value.retryAfter, POLL_DEADLINE_MS, nowMs),
|
|
214
|
+
...parseProvenIdentity(body),
|
|
199
215
|
},
|
|
200
216
|
};
|
|
201
217
|
}
|
|
@@ -285,6 +301,7 @@ function parseHandoffSnapshot(raw) {
|
|
|
285
301
|
revokedAt: asNullableString(rec.revoked_at),
|
|
286
302
|
candidates,
|
|
287
303
|
githubRepoName: asNullableString(rec.github_repo_name),
|
|
304
|
+
...parseProvenIdentity(rec),
|
|
288
305
|
};
|
|
289
306
|
}
|
|
290
307
|
/** Discover outstanding delegated handoffs for a project (the resume/revoke lookup). */
|
|
@@ -470,6 +487,7 @@ export async function pollGithubConnection(deps, poll, repoName, state) {
|
|
|
470
487
|
candidates,
|
|
471
488
|
githubRepoName: asNullableString(body.github_repo_name),
|
|
472
489
|
retryAfterMs: null,
|
|
490
|
+
...parseProvenIdentity(body),
|
|
473
491
|
},
|
|
474
492
|
};
|
|
475
493
|
}
|
package/build/connect-github.js
CHANGED
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
* The whole point of this command is that it needs no Bridge web session: a user who has
|
|
5
5
|
* a Bridge API key can connect GitHub without ever opening the setup UI. The flow is
|
|
6
6
|
*
|
|
7
|
-
* mint → browser (
|
|
7
|
+
* mint → browser (sign in to GitHub, prove access, confirm) → poll → pick a
|
|
8
|
+
* repository → confirm
|
|
8
9
|
*
|
|
9
10
|
* and the browser half authenticates to *GitHub*, not to Bridge. Bridge never asks for,
|
|
10
11
|
* accepts, echoes, or transports a GitHub credential. The only thing crossing between
|
|
11
12
|
* the browser and this process is a Bridge-issued state nonce, held in memory.
|
|
13
|
+
* BAPI-1697: the browser page proves the person can change at least one repository of
|
|
14
|
+
* the installation, and candidates are limited to those repositories.
|
|
12
15
|
*
|
|
13
16
|
* Two properties are load-bearing and easy to erode:
|
|
14
17
|
*
|
|
@@ -33,9 +36,10 @@ const USAGE = `Usage: connect-github [--repo <repo_name>] [--handoff | --resume
|
|
|
33
36
|
|
|
34
37
|
Connect a GitHub repository to a Bridge project from your terminal.
|
|
35
38
|
|
|
36
|
-
Opens
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
Opens a Bridge page in your browser. You sign in to GitHub there, choose or install
|
|
40
|
+
the GitHub App installation, and confirm. Bridge connects only repositories you can
|
|
41
|
+
change on GitHub. Then this command asks which repository to connect. You are never
|
|
42
|
+
asked for a GitHub token or password — you authenticate to GitHub in the browser.
|
|
39
43
|
|
|
40
44
|
If you do not administer the GitHub organization yourself, use the delegated
|
|
41
45
|
handoff: mint a link with --handoff, send it to whoever does, and finish with
|
|
@@ -44,7 +48,7 @@ handoff: mint a link with --handoff, send it to whoever does, and finish with
|
|
|
44
48
|
Options:
|
|
45
49
|
--repo <repo_name> Bridge project to connect (inferred from this directory
|
|
46
50
|
when omitted; you will be asked to confirm).
|
|
47
|
-
--handoff Print a shareable
|
|
51
|
+
--handoff Print a shareable connect link (valid 72 hours) instead of
|
|
48
52
|
connecting here. Does not open a browser or wait.
|
|
49
53
|
--resume Look up an outstanding handoff and finish connecting it.
|
|
50
54
|
Works from any machine holding this project's API key.
|
|
@@ -280,7 +284,7 @@ export async function openGithubInstallPage(deps, installUrl) {
|
|
|
280
284
|
// ---------------------------------------------------------------------------
|
|
281
285
|
const STEPS = [
|
|
282
286
|
"Connect GitHub",
|
|
283
|
-
"
|
|
287
|
+
"Sign in to GitHub and confirm in browser",
|
|
284
288
|
"Verify connection",
|
|
285
289
|
"Choose repository",
|
|
286
290
|
"Confirm connection",
|
|
@@ -298,7 +302,8 @@ function candidateLabel(c) {
|
|
|
298
302
|
const OUTCOME_MESSAGES = {
|
|
299
303
|
expired: "The connection request expired before GitHub reported back. Run connect-github again.",
|
|
300
304
|
invalid: "This connection request is no longer valid. Run connect-github again.",
|
|
301
|
-
"verification-failed": "Bridge could not
|
|
305
|
+
"verification-failed": "Bridge could not confirm your GitHub access to that installation. You need push " +
|
|
306
|
+
"access to at least one of its repositories. Run connect-github again.",
|
|
302
307
|
"no-repositories": "The GitHub App installation did not include any repositories Bridge can access. " +
|
|
303
308
|
"Re-run connect-github and grant access to at least one repository.",
|
|
304
309
|
conflict: "This GitHub installation or project is already connected to a different Bridge " +
|
|
@@ -315,6 +320,17 @@ const FAILURE_MESSAGES = {
|
|
|
315
320
|
deadline: "Timed out waiting for GitHub. If you completed the install, run connect-github again " +
|
|
316
321
|
"to pick up the connection.",
|
|
317
322
|
};
|
|
323
|
+
/**
|
|
324
|
+
* Show who proved GitHub access before the admin picks a repository (BAPI-1697).
|
|
325
|
+
*
|
|
326
|
+
* Both values come from the server's stored proof and were validated as GitHub logins
|
|
327
|
+
* by the parser. Nothing is printed when either is missing (an older server).
|
|
328
|
+
*/
|
|
329
|
+
function reportProvenIdentity(deps, login, account) {
|
|
330
|
+
if (!login || !account)
|
|
331
|
+
return;
|
|
332
|
+
deps.stderr(`GitHub access confirmed by ${login} for the ${account} account.`);
|
|
333
|
+
}
|
|
318
334
|
/** The no-connection-made framing, used for every unsuccessful terminal path. */
|
|
319
335
|
function reportNoConnection(deps, detail) {
|
|
320
336
|
deps.stderr("");
|
|
@@ -397,8 +413,8 @@ export async function runGithubConnectionFlow(deps, api, repoName) {
|
|
|
397
413
|
deps.stderr("Your request to install the GitHub App was sent to an organization owner for approval.");
|
|
398
414
|
deps.stderr("That approval happens on GitHub and does not return here, so this command cannot " +
|
|
399
415
|
"wait for it.");
|
|
400
|
-
deps.stderr("Once an owner approves the install,
|
|
401
|
-
"the GitHub App setup guide (docs/install/github-app.md).");
|
|
416
|
+
deps.stderr("Once an owner approves the install, run connect-github again to finish the connection. " +
|
|
417
|
+
"See the GitHub App setup guide (docs/install/github-app.md).");
|
|
402
418
|
return 1;
|
|
403
419
|
}
|
|
404
420
|
if (result.status === "connected") {
|
|
@@ -413,6 +429,7 @@ export async function runGithubConnectionFlow(deps, api, repoName) {
|
|
|
413
429
|
if (candidates.length === 0) {
|
|
414
430
|
return reportNoConnection(deps, OUTCOME_MESSAGES["no-repositories"]);
|
|
415
431
|
}
|
|
432
|
+
reportProvenIdentity(deps, result.provenGithubLogin, result.provenGithubAccount);
|
|
416
433
|
renderStep(deps, 3);
|
|
417
434
|
const selected = await chooseCandidate(deps, candidates);
|
|
418
435
|
if (!selected)
|
|
@@ -460,8 +477,8 @@ export async function runGithubHandoffMintFlow(deps, api, repoName) {
|
|
|
460
477
|
deps.stderr("");
|
|
461
478
|
deps.stderr(`Send this link to whoever administers your GitHub organization.`);
|
|
462
479
|
deps.stderr(`It works once and expires ${formatExpiry(minted.value.expiresAt)}.`);
|
|
463
|
-
deps.stderr("They'll
|
|
464
|
-
"`connect-github --resume`.");
|
|
480
|
+
deps.stderr("They'll sign in to GitHub and confirm in their browser — ask them to ping you, " +
|
|
481
|
+
"then run `connect-github --resume`.");
|
|
465
482
|
return 0;
|
|
466
483
|
}
|
|
467
484
|
/** Render an expiry for humans without pretending to know the reader's locale. */
|
|
@@ -489,7 +506,8 @@ const HANDOFF_STATUS_MESSAGES = {
|
|
|
489
506
|
pending: "Nobody has completed the link yet. Ask them to open it, then run connect-github --resume again.",
|
|
490
507
|
expired: "The link expired before it was used. Run connect-github --handoff to create a new one.",
|
|
491
508
|
revoked: "This link was revoked. Run connect-github --handoff to create a new one.",
|
|
492
|
-
"verification-failed": "Bridge could not
|
|
509
|
+
"verification-failed": "Bridge could not confirm GitHub access for this link, or the confirmation is more " +
|
|
510
|
+
"than 72 hours old. Run connect-github --handoff to create a new link.",
|
|
493
511
|
"no-repositories": "The GitHub App installation did not include any repositories Bridge can access. " +
|
|
494
512
|
"Create a new link with connect-github --handoff and ask them to grant access to at least one repository.",
|
|
495
513
|
conflict: "This GitHub installation or project is already connected to a different Bridge " +
|
|
@@ -572,14 +590,12 @@ export async function runGithubHandoffResumeFlow(deps, api, repoName) {
|
|
|
572
590
|
if (selected.status !== "staged") {
|
|
573
591
|
const message = HANDOFF_STATUS_MESSAGES[selected.status] ?? HANDOFF_STATUS_MESSAGES.failed;
|
|
574
592
|
if (selected.status === "pending" || selected.status === "expired") {
|
|
575
|
-
// AC-8
|
|
576
|
-
//
|
|
577
|
-
// detected one — it points at the documented manual path instead.
|
|
593
|
+
// AC-8 (BAPI-1697): an existing installation no longer dead-ends. The link signs
|
|
594
|
+
// the recipient in to GitHub first and offers the installations they can change.
|
|
578
595
|
deps.stderr("");
|
|
579
596
|
deps.stderr(message);
|
|
580
|
-
deps.stderr("If the GitHub App is already installed on that organization,
|
|
581
|
-
"
|
|
582
|
-
"steps in the GitHub App setup guide (docs/install/github-app.md).");
|
|
597
|
+
deps.stderr("If the GitHub App is already installed on that organization, the same link " +
|
|
598
|
+
"still works: it asks them to sign in to GitHub and choose the installation.");
|
|
583
599
|
// `pending` is a live state, not a failure; `expired` is terminal.
|
|
584
600
|
return selected.status === "pending" ? 0 : 1;
|
|
585
601
|
}
|
|
@@ -591,6 +607,7 @@ export async function runGithubHandoffResumeFlow(deps, api, repoName) {
|
|
|
591
607
|
if (candidates.length === 0) {
|
|
592
608
|
return reportNoConnection(deps, OUTCOME_MESSAGES["no-repositories"]);
|
|
593
609
|
}
|
|
610
|
+
reportProvenIdentity(deps, selected.provenGithubLogin, selected.provenGithubAccount);
|
|
594
611
|
const chosen = await chooseCandidate(deps, candidates);
|
|
595
612
|
if (!chosen)
|
|
596
613
|
return 1;
|