@bridge_gpt/mcp-server 0.2.73 → 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/claude-executor-adapter.js +12 -0
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +4 -4
- package/build/authored-plan.js +542 -0
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +11 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +692 -47
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +370 -93
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +253 -13
- package/build/conductor/gate-settings-review.js +58 -25
- 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/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +684 -49
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +129 -7
- package/build/epic-implementer-bin.js +288 -83
- 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/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +167 -738
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/prompt-spec.js +37 -3
- 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/executor-launch.js +4 -2
- package/build/generated/ticket-status.js +20 -0
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +589 -326
- package/build/install-bridge-conductor-answers.js +112 -22
- package/build/install-bridge-conductor-apply.js +38 -1
- package/build/install-bridge-conductor-assessment.js +482 -53
- package/build/install-bridge-conductor-compact.js +29 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +379 -89
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +925 -141
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +8 -7
- package/build/plan-generation.js +17 -0
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +59 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +16 -7
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/setup-epic.js +126 -16
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-credential-delivery.js +340 -0
- 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
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
* untouched setting is omitted from the write, so the server keeps what it has;
|
|
38
38
|
* an empty `workerEnv` list is a deliberate removal of every stored variable.
|
|
39
39
|
*/
|
|
40
|
-
import {
|
|
40
|
+
import { redactSecretString } from "./redaction.js";
|
|
41
|
+
import { dependencyInstallNoteSentences, LOCAL_COMMAND_TIMEOUT_SECONDS, } from "./gate-discovery.js";
|
|
41
42
|
import { CI_DATABASE_DEFAULT, MAX_DEPENDENCY_INSTALL_ENTRIES, MAX_DEPENDENCY_INSTALL_LOCKFILES, MAX_MUST_ORDER_PATHS, admitDependencyInstallDeclarations, canonicalMustOrderPaths, dependencyInstallEntryIdentity, isCiDatabase, isSafeRepoRelativePath, sameDependencyInstall, sameMustOrderPaths, } from "../dependency-install-declarations.js";
|
|
42
43
|
/** Limits that mirror `gate_profile.py` for hand-typed hints. */
|
|
43
44
|
const MAX_HINT_WORDS = 32;
|
|
@@ -53,6 +54,14 @@ const MAX_REVIEW_ATTEMPTS = 3;
|
|
|
53
54
|
* formatting characters are written as `\u{hex}`. Nothing is truncated; callers
|
|
54
55
|
* pass values already bounded by the validated input limits.
|
|
55
56
|
*/
|
|
57
|
+
/**
|
|
58
|
+
* BAPI-1677 — text a person reads as it is, unquoted: credential shapes redacted and
|
|
59
|
+
* every control or bidirectional character removed. For values already known not to
|
|
60
|
+
* need the visible quoting of {@link terminalSafe}.
|
|
61
|
+
*/
|
|
62
|
+
export function plainDisplayText(text) {
|
|
63
|
+
return redactSecretString(text).replace(/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/g, "");
|
|
64
|
+
}
|
|
56
65
|
export function terminalSafe(text) {
|
|
57
66
|
let out = "";
|
|
58
67
|
for (const ch of text) {
|
|
@@ -254,7 +263,7 @@ export function hasDeclarationsToReview(proposal, stored) {
|
|
|
254
263
|
function hasDependencyOrCiToReview(proposal, stored) {
|
|
255
264
|
return ((stored?.dependency_install?.length ?? 0) > 0 ||
|
|
256
265
|
newDependencyProposals(proposal, stored).length > 0 ||
|
|
257
|
-
(proposal.
|
|
266
|
+
dependencyInstallNoteSentences(proposal).length > 0 ||
|
|
258
267
|
storedCiDatabase(stored) !== CI_DATABASE_DEFAULT ||
|
|
259
268
|
proposedCiDatabase(proposal) !== CI_DATABASE_DEFAULT);
|
|
260
269
|
}
|
|
@@ -295,6 +304,36 @@ function newDependencyProposals(proposal, stored) {
|
|
|
295
304
|
const storedList = stored?.dependency_install ?? [];
|
|
296
305
|
return (proposal.dependencyInstallCandidates ?? []).filter((c) => !storedList.some((e) => dependencyInstallEqual([entryOf(c)], [e])));
|
|
297
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* BAPI-1677 — the one rule for a proposal against a stored list. A proposed entry
|
|
309
|
+
* with a stored identity replaces it in place, a new identity is added at the end,
|
|
310
|
+
* and a stored entry the proposal does not name stays. Nothing is sorted.
|
|
311
|
+
*
|
|
312
|
+
* `additive` means every stored entry survives in its place, with the same trigger
|
|
313
|
+
* files and with its command only extended. Anything else is `replacing`.
|
|
314
|
+
*/
|
|
315
|
+
export function mergeDependencyProposal(stored, proposed) {
|
|
316
|
+
const merged = stored.map(entryOf);
|
|
317
|
+
for (const candidate of proposed) {
|
|
318
|
+
const entry = entryOf(candidate);
|
|
319
|
+
const identity = dependencyInstallEntryIdentity(entry);
|
|
320
|
+
const at = merged.findIndex((e) => dependencyInstallEntryIdentity(e) === identity);
|
|
321
|
+
if (at === -1)
|
|
322
|
+
merged.push(entry);
|
|
323
|
+
else
|
|
324
|
+
merged[at] = entry;
|
|
325
|
+
}
|
|
326
|
+
const withinBounds = merged.length <= MAX_DEPENDENCY_INSTALL_ENTRIES;
|
|
327
|
+
if (dependencyInstallEqual(merged, [...stored]))
|
|
328
|
+
return { merged, drift: "same", withinBounds };
|
|
329
|
+
const additive = stored.every((before, index) => {
|
|
330
|
+
const after = merged[index];
|
|
331
|
+
return (JSON.stringify(after.lockfiles) === JSON.stringify(before.lockfiles) &&
|
|
332
|
+
after.cwd === before.cwd &&
|
|
333
|
+
before.argv.every((arg, at) => after.argv[at] === arg));
|
|
334
|
+
});
|
|
335
|
+
return { merged, drift: additive ? "additive" : "replacing", withinBounds };
|
|
336
|
+
}
|
|
298
337
|
function entryOf(candidate) {
|
|
299
338
|
return { cwd: candidate.cwd, argv: [...candidate.argv], lockfiles: [...candidate.lockfiles] };
|
|
300
339
|
}
|
|
@@ -382,7 +421,7 @@ export function renderSettingsReview(io, proposal, stored, providerChecks, showV
|
|
|
382
421
|
// Shown only when there is something to say, so a review without either
|
|
383
422
|
// declaration renders exactly as it did before BAPI-1551.
|
|
384
423
|
if (hasDeclarationsToReview(proposal, stored) ||
|
|
385
|
-
(proposal.
|
|
424
|
+
dependencyInstallNoteSentences(proposal).length > 0 ||
|
|
386
425
|
mustOrderOffer(proposal, stored).notOffered > 0) {
|
|
387
426
|
renderDeclarationsReview(io, proposal, stored, showValues);
|
|
388
427
|
}
|
|
@@ -413,11 +452,6 @@ const CI_DATABASE_TEXT = Object.freeze({
|
|
|
413
452
|
provided: "provided — CI provides a database",
|
|
414
453
|
unknown: "unknown — not declared",
|
|
415
454
|
});
|
|
416
|
-
const DEPENDENCY_NOTE_TEXT = Object.freeze({
|
|
417
|
-
dependency_install_pip_not_proposed: "A pip requirements file was found. It is not proposed: a bare pip install would use whatever " +
|
|
418
|
-
"Python is first on the executor's PATH, not this worktree's environment. Add an entry by hand if you need one.",
|
|
419
|
-
dependency_install_toolchain_unresolved: "The repository's toolchains could not be read with certainty, so nothing is proposed.",
|
|
420
|
-
});
|
|
421
455
|
/** One entry as a person reads it: where it runs and what it watches first, then the command. */
|
|
422
456
|
function describeDependencyEntry(entry, label, showValues) {
|
|
423
457
|
const where = entry.cwd === "." ? "repository root" : terminalSafe(entry.cwd);
|
|
@@ -425,6 +459,10 @@ function describeDependencyEntry(entry, label, showValues) {
|
|
|
425
459
|
lines.push(showValues
|
|
426
460
|
? ` runs: ${entry.argv.map(terminalSafe).join(" ")}`
|
|
427
461
|
: " (the install command is shown only in a terminal)");
|
|
462
|
+
// BAPI-1677: why each extra is there, as the smallest matched text and its field.
|
|
463
|
+
for (const evidence of entry.extraEvidence ?? []) {
|
|
464
|
+
lines.push(` because ${evidence.field} says: ${plainDisplayText(evidence.span)}`);
|
|
465
|
+
}
|
|
428
466
|
return lines;
|
|
429
467
|
}
|
|
430
468
|
/** BAPI-1551 (extended by BAPI-1580) — every declaration group with something to show. */
|
|
@@ -469,8 +507,12 @@ function renderDependencyAndCiReview(io, proposal, stored, showValues) {
|
|
|
469
507
|
for (const line of rest)
|
|
470
508
|
io.log(line);
|
|
471
509
|
});
|
|
472
|
-
|
|
473
|
-
|
|
510
|
+
// BAPI-1698: the same sentences every setup surface shows, each fact once. Advisory only.
|
|
511
|
+
for (const sentence of dependencyInstallNoteSentences(proposal))
|
|
512
|
+
io.log(` ${plainDisplayText(sentence)}`);
|
|
513
|
+
for (const line of proposal.dependencyInstallLimitations ?? [])
|
|
514
|
+
io.log(` Could not check: ${plainDisplayText(line)}`);
|
|
515
|
+
io.log(" Each command runs in every fresh worker worktree, and again only when a file it names changes.");
|
|
474
516
|
io.log(" Discovery looks at the repository root only, so it can miss a subdirectory project. Stored entries stay " +
|
|
475
517
|
"as they are unless you change them; you can add a subdirectory entry by hand below.");
|
|
476
518
|
io.log("");
|
|
@@ -682,7 +724,7 @@ async function reviewDependencyInstall(io, proposal, stored) {
|
|
|
682
724
|
const prompt = io.promptLine;
|
|
683
725
|
const storedList = (stored?.dependency_install ?? []).map(entryOf);
|
|
684
726
|
const proposals = newDependencyProposals(proposal, stored);
|
|
685
|
-
if (storedList.length === 0 && proposals.length === 0 && (proposal.
|
|
727
|
+
if (storedList.length === 0 && proposals.length === 0 && dependencyInstallNoteSentences(proposal).length === 0) {
|
|
686
728
|
return undefined;
|
|
687
729
|
}
|
|
688
730
|
const letters = [
|
|
@@ -898,20 +940,11 @@ export function recommendedSettingsSelection(proposal, stored, providerChecks) {
|
|
|
898
940
|
}
|
|
899
941
|
if (reproduce.size > 0)
|
|
900
942
|
edit.reproduce = reproduce;
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
const at = deps.findIndex((e) => dependencyInstallEntryIdentity(e) === identity);
|
|
907
|
-
if (at === -1)
|
|
908
|
-
deps.push(entry);
|
|
909
|
-
else
|
|
910
|
-
deps[at] = entry;
|
|
911
|
-
}
|
|
912
|
-
if (deps.length <= MAX_DEPENDENCY_INSTALL_ENTRIES && !dependencyInstallEqual(deps, storedDeps)) {
|
|
913
|
-
edit.dependencyInstall = deps;
|
|
914
|
-
}
|
|
943
|
+
// BAPI-1677: a safe default takes only additive drift. A change that drops or
|
|
944
|
+
// rewrites what is stored is the owner's decision, so it stays as stored here.
|
|
945
|
+
const deps = mergeDependencyProposal(stored?.dependency_install ?? [], proposal.dependencyInstallCandidates ?? []);
|
|
946
|
+
if (deps.withinBounds && deps.drift === "additive")
|
|
947
|
+
edit.dependencyInstall = deps.merged;
|
|
915
948
|
const current = storedCiDatabase(stored);
|
|
916
949
|
const proposedDb = proposedCiDatabase(proposal);
|
|
917
950
|
if (proposedDb !== CI_DATABASE_DEFAULT && proposedDb !== current)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EPIC_KEY_PATTERN } from "../drive-epic-key.js";
|
|
2
2
|
import { WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION } from "./doctor.js";
|
|
3
|
+
import { redactSecrets } from "../secret-redaction.js";
|
|
3
4
|
import { LAUNCH_NEED_REMEDIES, LAUNCH_NEED_ROW_IDS, LAUNCH_NEEDS } from "./readiness-sections.js";
|
|
4
5
|
export const NO_LAUNCH_PLAN_FACTS = Object.freeze({
|
|
5
6
|
prerequisites: { status: "not_collected" },
|
|
@@ -112,13 +113,16 @@ function summaryLine(preview, blocked) {
|
|
|
112
113
|
parts.push(where);
|
|
113
114
|
return `${preview.epic_key} is ready to launch: ${parts.join(", ")}.`;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
/** BAPI-1704 — appended to the ready branch's launch option when open decisions exist. */
|
|
117
|
+
const OPEN_DECISION_LAUNCH_SENTENCE = "If an open decision blocks a child, the driver may settle it by council.";
|
|
118
|
+
function launchOption(number, label, local, recommended, extra) {
|
|
119
|
+
const base = local
|
|
120
|
+
? "Creates the run and starts it on your local plane."
|
|
121
|
+
: "Creates the run and starts it on the server.";
|
|
116
122
|
return {
|
|
117
123
|
number,
|
|
118
124
|
label,
|
|
119
|
-
description:
|
|
120
|
-
? "Creates the run and starts it on your local plane."
|
|
121
|
-
: "Creates the run and starts it on the server.",
|
|
125
|
+
description: extra === undefined ? base : `${base} ${extra}`,
|
|
122
126
|
duration: local ? LAUNCH_PLAN_DURATION.local : LAUNCH_PLAN_DURATION.remote,
|
|
123
127
|
recommended,
|
|
124
128
|
};
|
|
@@ -169,7 +173,8 @@ function generatedPlanItem(preview) {
|
|
|
169
173
|
const source = plan.inline ?? plan.generation;
|
|
170
174
|
if (source === undefined)
|
|
171
175
|
return null;
|
|
172
|
-
|
|
176
|
+
// BAPI-1706 — a server plan's inline nodes carry no summary; read as unusable.
|
|
177
|
+
const summary = source.summary ?? null;
|
|
173
178
|
const parts = [];
|
|
174
179
|
if (summary?.serialized_reason) {
|
|
175
180
|
parts.push(SERIALIZED_REASON_COPY[summary.serialized_reason]?.(summary.unknown_files) ?? "It runs one child at a time.");
|
|
@@ -178,6 +183,9 @@ function generatedPlanItem(preview) {
|
|
|
178
183
|
parts.push(summary.order_source === "epic_manifest"
|
|
179
184
|
? "Order and dependencies come from the epic's ordered child manifest."
|
|
180
185
|
: "Order is ascending ticket key.");
|
|
186
|
+
if (summary.order_fallback_reason === "manifest_unreadable") {
|
|
187
|
+
parts.push("The epic has an ordered child manifest section, but it could not be read, so the plan uses ascending ticket-key order.");
|
|
188
|
+
}
|
|
181
189
|
for (const entry of summary.excluded) {
|
|
182
190
|
parts.push(`Left out: ${entry.ticket_key} (${entry.reason}; the Epic Implementer cannot run an unfinished spike).`);
|
|
183
191
|
}
|
|
@@ -245,6 +253,18 @@ export function buildLaunchPlan(preview, facts = NO_LAUNCH_PLAN_FACTS) {
|
|
|
245
253
|
reason: `${entry.dependents} will stop without it. Tickets that don't depend on it keep going.${sure}`,
|
|
246
254
|
}, entry.name);
|
|
247
255
|
}
|
|
256
|
+
// BAPI-1704 — open decisions follow the missing-core items. Display text is redacted
|
|
257
|
+
// here; the raw facts stay untouched. Detail ids count from one per child.
|
|
258
|
+
const openDecisions = refusal === null && prerequisiteFacts.status === "collected" ? prerequisiteFacts.openDecisions : [];
|
|
259
|
+
const openDecisionCounts = new Map();
|
|
260
|
+
for (const entry of openDecisions) {
|
|
261
|
+
const n = (openDecisionCounts.get(entry.child) ?? 0) + 1;
|
|
262
|
+
openDecisionCounts.set(entry.child, n);
|
|
263
|
+
add("needs_choice", {
|
|
264
|
+
summary: `${entry.child} leaves a decision open: "${redactSecrets(entry.clause)}"`,
|
|
265
|
+
reason: "Settling it now avoids an overnight decision.",
|
|
266
|
+
}, `open-decision-${entry.child}-${n}`);
|
|
267
|
+
}
|
|
248
268
|
// --- worth knowing: surviving non-blocking evidence ------------------------------
|
|
249
269
|
if (refusal === null) {
|
|
250
270
|
const roleRow = presentNeed(rows, "worker_db_role");
|
|
@@ -306,16 +326,42 @@ export function buildLaunchPlan(preview, facts = NO_LAUNCH_PLAN_FACTS) {
|
|
|
306
326
|
}
|
|
307
327
|
else {
|
|
308
328
|
const missing = missingCore.length > 0;
|
|
309
|
-
|
|
310
|
-
|
|
329
|
+
const decisions = openDecisions.length > 0;
|
|
330
|
+
push(launchOption(1, missing ? "Launch now and supply it later" : "Launch now", local, !decisions, decisions ? OPEN_DECISION_LAUNCH_SENTENCE : undefined), "launch");
|
|
331
|
+
if (decisions) {
|
|
332
|
+
push(nothingOption(options.length + 1, missing ? "Stop so you can supply or settle it" : "Stop so you can settle it first", true), "create_nothing");
|
|
333
|
+
}
|
|
334
|
+
else if (missing) {
|
|
311
335
|
push(nothingOption(options.length + 1, "Stop so you can supply it", false), "create_nothing");
|
|
336
|
+
}
|
|
312
337
|
push(nothingOption(options.length + 1, "Don't launch yet", false), "create_nothing");
|
|
313
|
-
recommendation =
|
|
314
|
-
|
|
315
|
-
? "Every check that protects your code passed."
|
|
338
|
+
recommendation = !decisions
|
|
339
|
+
? "launch now."
|
|
316
340
|
: missing
|
|
317
|
-
? "
|
|
318
|
-
: "
|
|
341
|
+
? "stop so you can supply or settle it."
|
|
342
|
+
: "stop so you can settle it first.";
|
|
343
|
+
// BAPI-1694 — the positive claim is made only when nothing in the preview is unverified.
|
|
344
|
+
const partialValidation = preview.summary?.server_validation === "partial";
|
|
345
|
+
const tallyLines = Array.isArray(preview.tally_lines) ? preview.tally_lines : [];
|
|
346
|
+
const unprovenTally = tallyLines.some((line) => isObject(line) && typeof line.code === "string" && line.code.endsWith("_unproven"));
|
|
347
|
+
const unverifiableNeed = rows.some((row) => isObject(row.launch_need) && row.launch_need.state === "unverifiable");
|
|
348
|
+
const uncertain = partialValidation || unprovenTally || unverifiableNeed;
|
|
349
|
+
const tail = verdict === "ready"
|
|
350
|
+
? null
|
|
351
|
+
: decisions && missing
|
|
352
|
+
? "Some children need something you can supply later or leave a decision open."
|
|
353
|
+
: decisions
|
|
354
|
+
? "Some children leave a decision open."
|
|
355
|
+
: missing
|
|
356
|
+
? "Some children need something you can supply later."
|
|
357
|
+
: "A few things are worth knowing.";
|
|
358
|
+
reason = [
|
|
359
|
+
uncertain
|
|
360
|
+
? "Some checks returned no verifiable result; no check that protects your code failed."
|
|
361
|
+
: "Every check that protects your code passed.",
|
|
362
|
+
partialValidation ? "The server checks again when it creates the run." : null,
|
|
363
|
+
tail,
|
|
364
|
+
].filter((sentence) => sentence !== null).join(" ");
|
|
319
365
|
}
|
|
320
366
|
const plan = {
|
|
321
367
|
version: 2,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The open-decision phrase list and its pure matcher (BAPI-1704).
|
|
3
|
+
*
|
|
4
|
+
* The list is an exact, ordered, case-sensitive copy of the canonical block in
|
|
5
|
+
* `docs/bridge-ticket-authoring.md` (BAPI-1703). `tests/pytest/static/
|
|
6
|
+
* test_open_decision_phrases_parity.py` fails if the two drift. A match is an
|
|
7
|
+
* advisory signal for a person to review; it never decides anything here.
|
|
8
|
+
*/
|
|
9
|
+
/** The canonical phrases, in canonical order. Order is the tie-breaker. */
|
|
10
|
+
export const OPEN_DECISION_PHRASES = Object.freeze([
|
|
11
|
+
"must settle",
|
|
12
|
+
"settle this before",
|
|
13
|
+
"before planning",
|
|
14
|
+
"the caller must",
|
|
15
|
+
"owner confirms",
|
|
16
|
+
"owner must confirm",
|
|
17
|
+
"confirm with the owner",
|
|
18
|
+
"stop if not met",
|
|
19
|
+
"check the precondition first",
|
|
20
|
+
"TBD",
|
|
21
|
+
"to be decided",
|
|
22
|
+
]);
|
|
23
|
+
function escapeRegExp(text) {
|
|
24
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25
|
+
}
|
|
26
|
+
const PHRASE_PATTERNS = OPEN_DECISION_PHRASES.map((phrase) => ({
|
|
27
|
+
phrase,
|
|
28
|
+
// Whole-phrase boundaries at both ends: no word character may touch either end.
|
|
29
|
+
pattern: new RegExp(`(?<![\\p{L}\\p{N}_])${escapeRegExp(phrase)}(?![\\p{L}\\p{N}_])`, "iu"),
|
|
30
|
+
}));
|
|
31
|
+
/**
|
|
32
|
+
* Find the earliest open-decision phrase in one line.
|
|
33
|
+
*
|
|
34
|
+
* Matching is case-insensitive and whole-phrase. The result carries the phrase as
|
|
35
|
+
* spelled in {@link OPEN_DECISION_PHRASES} and `index`, a position usable to slice
|
|
36
|
+
* the original JavaScript string. Matches at the same position go to the phrase
|
|
37
|
+
* that comes first in the canonical list. Pure: no normalization, environment
|
|
38
|
+
* access, logging, or policy decision.
|
|
39
|
+
*/
|
|
40
|
+
export function findOpenDecisionPhrase(line) {
|
|
41
|
+
let best;
|
|
42
|
+
for (const { phrase, pattern } of PHRASE_PATTERNS) {
|
|
43
|
+
const match = pattern.exec(line);
|
|
44
|
+
if (match === null)
|
|
45
|
+
continue;
|
|
46
|
+
if (best === undefined || match.index < best.index)
|
|
47
|
+
best = { phrase, index: match.index };
|
|
48
|
+
}
|
|
49
|
+
return best;
|
|
50
|
+
}
|
|
@@ -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
|
}
|