@bridge_gpt/mcp-server 0.2.71 → 0.2.73
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 +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +22 -3
- package/build/agent-notes.js +171 -95
- package/build/agents.generated.js +7 -7
- package/build/bridge-permissions.js +31 -0
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/ci-system-detection.js +50 -0
- package/build/ci-trigger-adapters.js +631 -0
- package/build/ci-trigger-install.js +106 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-launcher-pin.js +33 -2
- package/build/codex-skill-adapter.js +5 -1
- package/build/command-host.js +33 -0
- package/build/commands.generated.js +7 -6
- package/build/conductor/bridge-api-client.js +1352 -50
- package/build/conductor/bring-up-facts.js +18 -5
- package/build/conductor/command-drift-production.js +42 -17
- package/build/conductor/command-drift.js +47 -0
- package/build/conductor/declare-blocked.js +554 -0
- package/build/conductor/doctor.js +187 -28
- package/build/conductor/driver-commands.js +141 -0
- package/build/conductor/driver-guard.js +277 -0
- package/build/conductor/driver-lapse.js +321 -0
- package/build/conductor/driver-register.js +176 -0
- package/build/conductor/driver-release.js +174 -0
- package/build/conductor/driver-session-state.js +315 -0
- package/build/conductor/epic-branch-ci-inspection.js +222 -29
- package/build/conductor/epic-implementer-cli.js +213 -13
- package/build/conductor/epic-server-database.js +162 -0
- package/build/conductor/epic-server-guidance.js +278 -0
- package/build/conductor/epic-server-journal.js +239 -0
- package/build/conductor/epic-server-processes.js +324 -0
- package/build/conductor/epic-server-recipe.js +397 -0
- package/build/conductor/epic-server-runtime.js +1207 -0
- package/build/conductor/epic-server-sfcc.js +107 -0
- package/build/conductor/epic-server-state.js +427 -0
- package/build/conductor/epic-server.js +594 -0
- package/build/conductor/gate-discovery.js +281 -10
- package/build/conductor/gate-settings-review.js +525 -5
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +6 -53
- package/build/conductor/launch-plan.js +318 -121
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/prerequisite-inputs.js +1213 -0
- package/build/conductor/readiness-assessment.js +93 -0
- package/build/conductor/readiness-cli.js +30 -9
- package/build/conductor/readiness-prerequisites.js +77 -5
- package/build/conductor/readiness-sections.js +146 -126
- package/build/conductor/readiness.js +21 -3
- package/build/conductor/recovery-cli.js +236 -15
- package/build/conductor/recovery-operations.js +34 -4
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +36 -4
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +300 -21
- package/build/conductor/worker-database-doctor-inspector.js +34 -2
- package/build/conductor/worker-setup-tally.js +27 -0
- package/build/credential-store.js +96 -21
- package/build/dependency-install-declarations.js +212 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +91 -8
- package/build/drive-epic-help.js +23 -4
- package/build/drive-epic.js +1841 -340
- package/build/engine-paths.js +20 -0
- package/build/epic-branch-ci-summary.js +140 -0
- package/build/epic-capability-statement.js +107 -0
- package/build/epic-ci-workflow-drift.js +30 -15
- package/build/epic-ci-workflow-install.js +110 -42
- package/build/epic-ci-workflow-v2.js +274 -0
- package/build/epic-ci-workflow.js +38 -12
- package/build/epic-implementer-bin.js +2184 -52
- package/build/epic-launch-context.js +607 -0
- package/build/epic-launch-profile.js +1 -1
- package/build/epic-server-record.js +273 -0
- package/build/epic-shared/bridge-client.js +11 -3
- package/build/escalation-reachability.js +43 -0
- package/build/executor/ci-fix-test-runs.js +334 -0
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +119 -17
- package/build/executor/epic-server-context.js +141 -0
- package/build/executor/gate-qualification-job.js +127 -26
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +87 -6
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +659 -87
- package/build/executor/likely-tests.js +94 -97
- package/build/executor/observation.js +8 -0
- package/build/executor/pre-pr-checks.js +363 -0
- package/build/executor/prompt-spec.js +127 -5
- package/build/executor/reconcile-overlap-job.js +5 -3
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +32 -0
- package/build/executor/required-work-ledger.js +955 -39
- package/build/executor/results.js +100 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/terminal-mutation.js +8 -0
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +126 -5
- package/build/executor/worker-database-config.js +281 -0
- package/build/executor/worker-database-target.js +16 -12
- package/build/executor/worker-database.js +575 -116
- package/build/executor/worker-finalization.js +71 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +25 -3
- package/build/executor/worker-verification-guidance.js +55 -5
- package/build/executor/worktree-inspection.js +42 -0
- package/build/executor/worktree.js +20 -1
- package/build/executor-launch.js +54 -2
- package/build/generated-assets-catalog.js +2 -2
- package/build/github-sign-in.js +1 -1
- package/build/index.js +1111 -381
- package/build/init.js +29 -14
- package/build/install-bridge-conductor-answers.js +465 -0
- package/build/install-bridge-conductor-apply.js +259 -0
- package/build/install-bridge-conductor-assessment.js +895 -0
- package/build/install-bridge-conductor-compact.js +161 -0
- package/build/install-bridge-conductor-contracts.js +63 -0
- package/build/install-bridge-conductor-gate.js +1383 -188
- package/build/install-bridge-conductor-setup.js +637 -92
- package/build/install-bridge-conductor.js +3163 -740
- package/build/install-bridge.js +601 -128
- package/build/install-maintenance.js +127 -0
- package/build/install-reexec.js +1 -1
- package/build/launcher-config-inspection.js +162 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-grant-candidates.js +767 -0
- package/build/mcp-grant-doctor.js +63 -0
- package/build/mcp-grant.js +288 -0
- package/build/mcp-host-targets.js +8 -0
- package/build/mcp-identity.js +23 -0
- package/build/mcp-install-state.js +68 -2
- package/build/mcp-invoke.js +126 -13
- package/build/mcp-presets.js +107 -0
- package/build/mcp-provisioning.js +134 -2
- package/build/mcp-registration-doctor.js +31 -2
- package/build/mcp-server-invocation.js +6 -1
- package/build/merge-workflow-install.js +236 -111
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-discovery.js +97 -4
- package/build/plan-execution-ledger.js +248 -9
- package/build/plan-generation-io.js +262 -0
- package/build/plan-generation.js +424 -0
- package/build/plane/build-freshness.js +6 -1
- package/build/plane/cli.js +75 -9
- package/build/plane/plane-freshness.js +23 -7
- package/build/plane/preflight.js +50 -10
- package/build/plane/shutdown.js +19 -0
- package/build/plane/terminal-run-cleanup.js +23 -5
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +229 -15
- package/build/readiness-check.js +1 -1
- package/build/readiness-prerequisites.generated.js +311 -4
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +38 -0
- package/build/repository-toolchains.js +50 -8
- package/build/run-unit-tests-launcher.js +8 -1
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +1192 -198
- package/build/setup-progress.js +44 -0
- package/build/setup-question.js +180 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +32 -88
- package/build/test-support/notes-fs.js +40 -0
- package/build/third-party-mcp-targets.js +30 -0
- package/build/ticket-delivery-enrollment.js +30 -8
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/upgrade-cli.js +85 -2
- package/build/v2-readiness-requirements.js +28 -1
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
- package/docs/EPIC-IMPLEMENTER.md +5 -0
- package/docs/epic-implementer/getting-started.md +42 -15
- package/docs/epic-implementer/self-hosting.md +14 -1
- package/package.json +2 -2
|
@@ -167,14 +167,47 @@ function filterPatterns(node) {
|
|
|
167
167
|
}
|
|
168
168
|
return null;
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
/**
|
|
171
|
+
* BAPI-1654 — classify one pattern against ONE concrete branch name. The answer
|
|
172
|
+
* is `all` (it matches), `none` (it does not), or `some` when the pattern uses a
|
|
173
|
+
* glob form this matcher does not evaluate (`[...]` or `+`), which keeps the
|
|
174
|
+
* filter uncertain rather than guessed.
|
|
175
|
+
*/
|
|
176
|
+
export function classifyBranchPatternForTarget(pattern, branch) {
|
|
177
|
+
if (pattern.includes("[") || pattern.includes("+"))
|
|
178
|
+
return "some";
|
|
179
|
+
let re = "^";
|
|
180
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
181
|
+
const ch = pattern[i];
|
|
182
|
+
if (ch === "*" && pattern[i + 1] === "*") {
|
|
183
|
+
re += ".*";
|
|
184
|
+
i++;
|
|
185
|
+
}
|
|
186
|
+
else if (ch === "*") {
|
|
187
|
+
re += "[^/]*";
|
|
188
|
+
}
|
|
189
|
+
else if (ch === "?") {
|
|
190
|
+
re += "[^/]";
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
re += ch.replace(/[\\^$.|(){}]/g, "\\$&");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return new RegExp(`${re}$`).test(branch) ? "all" : "none";
|
|
197
|
+
}
|
|
198
|
+
function classifierFor(targetBranch) {
|
|
199
|
+
return targetBranch === undefined
|
|
200
|
+
? classifyEpicBranchPattern
|
|
201
|
+
: (pattern) => classifyBranchPatternForTarget(pattern, targetBranch);
|
|
202
|
+
}
|
|
203
|
+
function classifyBranches(node, classify) {
|
|
171
204
|
const patterns = filterPatterns(node);
|
|
172
205
|
if (patterns === null || patterns.length === 0)
|
|
173
206
|
return couldNotTell("branch_filter_uncertain");
|
|
174
207
|
let state = "none_in";
|
|
175
208
|
for (const raw of patterns) {
|
|
176
209
|
const negated = raw.startsWith("!");
|
|
177
|
-
const match =
|
|
210
|
+
const match = classify(negated ? raw.slice(1) : raw);
|
|
178
211
|
if (match === "none")
|
|
179
212
|
continue;
|
|
180
213
|
if (!negated) {
|
|
@@ -196,21 +229,21 @@ function classifyBranches(node) {
|
|
|
196
229
|
return EXCLUDES;
|
|
197
230
|
return couldNotTell("branch_filter_uncertain");
|
|
198
231
|
}
|
|
199
|
-
function classifyBranchesIgnore(node) {
|
|
232
|
+
function classifyBranchesIgnore(node, classify) {
|
|
200
233
|
if (node !== undefined && node.t === "seq" && node.items.length === 0)
|
|
201
234
|
return COVERS;
|
|
202
235
|
const patterns = filterPatterns(node);
|
|
203
236
|
if (patterns === null || patterns.some((p) => p.startsWith("!"))) {
|
|
204
237
|
return couldNotTell("branch_filter_uncertain");
|
|
205
238
|
}
|
|
206
|
-
const matches = patterns.map(
|
|
239
|
+
const matches = patterns.map((p) => classify(p));
|
|
207
240
|
if (matches.includes("all"))
|
|
208
241
|
return EXCLUDES;
|
|
209
242
|
if (matches.every((m) => m === "none"))
|
|
210
243
|
return COVERS;
|
|
211
244
|
return couldNotTell("branch_filter_uncertain");
|
|
212
245
|
}
|
|
213
|
-
function classifyPrEvent(node) {
|
|
246
|
+
function classifyPrEvent(node, classify) {
|
|
214
247
|
if (node.t === "null")
|
|
215
248
|
return COVERS;
|
|
216
249
|
if (node.t !== "map")
|
|
@@ -235,9 +268,9 @@ function classifyPrEvent(node) {
|
|
|
235
268
|
if (hasBranches && hasIgnore)
|
|
236
269
|
return couldNotTell("branch_filter_uncertain");
|
|
237
270
|
if (hasBranches)
|
|
238
|
-
return classifyBranches(e.get("s:branches"));
|
|
271
|
+
return classifyBranches(e.get("s:branches"), classify);
|
|
239
272
|
if (hasIgnore)
|
|
240
|
-
return classifyBranchesIgnore(e.get("s:branches-ignore"));
|
|
273
|
+
return classifyBranchesIgnore(e.get("s:branches-ignore"), classify);
|
|
241
274
|
return COVERS;
|
|
242
275
|
}
|
|
243
276
|
// ---------------------------------------------------------------------------
|
|
@@ -741,7 +774,7 @@ function jobsHaveUses(entries) {
|
|
|
741
774
|
}
|
|
742
775
|
return false;
|
|
743
776
|
}
|
|
744
|
-
function classifyOrThrow(text) {
|
|
777
|
+
function classifyOrThrow(text, classify) {
|
|
745
778
|
if (typeof text !== "string" || text.trim() === "")
|
|
746
779
|
return couldNotTell("unparseable");
|
|
747
780
|
const root = scanRoot(text);
|
|
@@ -776,7 +809,7 @@ function classifyOrThrow(text) {
|
|
|
776
809
|
}
|
|
777
810
|
else if (node.t === "map") {
|
|
778
811
|
triggerNames = [...node.entries.keys()].filter((k) => k.startsWith("s:")).map((k) => k.slice(2));
|
|
779
|
-
prResults = PR_TRIGGER_KEYS.filter((k) => node.entries.has(`s:${k}`)).map((k) => classifyPrEvent(node.entries.get(`s:${k}`)));
|
|
812
|
+
prResults = PR_TRIGGER_KEYS.filter((k) => node.entries.has(`s:${k}`)).map((k) => classifyPrEvent(node.entries.get(`s:${k}`), classify));
|
|
780
813
|
if (prResults.some((r) => r.coverage === "covers"))
|
|
781
814
|
return COVERS;
|
|
782
815
|
const uncertain = prResults.find((r) => r.coverage === "could_not_tell");
|
|
@@ -794,16 +827,91 @@ function classifyOrThrow(text) {
|
|
|
794
827
|
}
|
|
795
828
|
/**
|
|
796
829
|
* Does this workflow's PR trigger run for a pull request whose base is
|
|
797
|
-
* `epic/<EPIC
|
|
830
|
+
* `epic/<EPIC>` (or, with `options.targetBranch`, that branch)? Never throws;
|
|
831
|
+
* see the module truth table.
|
|
798
832
|
*/
|
|
799
|
-
export function classifyEpicPullRequestTrigger(text) {
|
|
833
|
+
export function classifyEpicPullRequestTrigger(text, options = {}) {
|
|
800
834
|
try {
|
|
801
|
-
return classifyOrThrow(text);
|
|
835
|
+
return classifyOrThrow(text, classifierFor(options.targetBranch));
|
|
802
836
|
}
|
|
803
837
|
catch (err) {
|
|
804
838
|
return couldNotTell(err instanceof UnsupportedYaml ? "unsupported_structure" : "unparseable");
|
|
805
839
|
}
|
|
806
840
|
}
|
|
841
|
+
/**
|
|
842
|
+
* BAPI-1654 — the trigger's event names, as the same scanner reads them, or
|
|
843
|
+
* `null` when the trigger cannot be read. Used to prove an edit kept every
|
|
844
|
+
* existing trigger. Never returns other workflow content.
|
|
845
|
+
*/
|
|
846
|
+
export function readWorkflowTriggerNames(text) {
|
|
847
|
+
try {
|
|
848
|
+
if (typeof text !== "string" || text.trim() === "")
|
|
849
|
+
return null;
|
|
850
|
+
const root = scanRoot(text);
|
|
851
|
+
if (root.kind !== "ok")
|
|
852
|
+
return null;
|
|
853
|
+
const trigger = findTrigger(root.entries);
|
|
854
|
+
if (trigger === null)
|
|
855
|
+
return null;
|
|
856
|
+
const node = parseEntryValue(trigger);
|
|
857
|
+
if (node.t === "str")
|
|
858
|
+
return [node.v];
|
|
859
|
+
if (node.t === "seq")
|
|
860
|
+
return node.items.every((i) => i.t === "str") ? node.items.map((i) => i.v) : null;
|
|
861
|
+
if (node.t === "map")
|
|
862
|
+
return [...node.entries.keys()].map((k) => (k.startsWith("s:") ? k.slice(2) : k));
|
|
863
|
+
return null;
|
|
864
|
+
}
|
|
865
|
+
catch {
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
export function readPullRequestBranchFilters(text) {
|
|
870
|
+
try {
|
|
871
|
+
if (typeof text !== "string" || text.trim() === "")
|
|
872
|
+
return { kind: "could_not_tell" };
|
|
873
|
+
const root = scanRoot(text);
|
|
874
|
+
if (root.kind !== "ok")
|
|
875
|
+
return { kind: "could_not_tell" };
|
|
876
|
+
const trigger = findTrigger(root.entries);
|
|
877
|
+
if (trigger === null)
|
|
878
|
+
return { kind: "could_not_tell" };
|
|
879
|
+
const node = parseEntryValue(trigger);
|
|
880
|
+
const isPr = (name) => PR_TRIGGER_KEYS.includes(name);
|
|
881
|
+
if (node.t === "str")
|
|
882
|
+
return isPr(node.v) ? { kind: "filters", branches: null } : { kind: "no_pr_trigger" };
|
|
883
|
+
if (node.t === "seq") {
|
|
884
|
+
return node.items.some((i) => i.t === "str" && isPr(i.v))
|
|
885
|
+
? { kind: "filters", branches: null }
|
|
886
|
+
: { kind: "no_pr_trigger" };
|
|
887
|
+
}
|
|
888
|
+
if (node.t !== "map")
|
|
889
|
+
return { kind: "could_not_tell" };
|
|
890
|
+
const prKey = PR_TRIGGER_KEYS.find((k) => node.entries.has(`s:${k}`));
|
|
891
|
+
if (prKey === undefined)
|
|
892
|
+
return { kind: "no_pr_trigger" };
|
|
893
|
+
const event = node.entries.get(`s:${prKey}`);
|
|
894
|
+
if (event.t === "null")
|
|
895
|
+
return { kind: "filters", branches: null };
|
|
896
|
+
if (event.t !== "map")
|
|
897
|
+
return { kind: "could_not_tell" };
|
|
898
|
+
// A `branches-ignore` list is not "every branch": report it as unread rather than misstate it.
|
|
899
|
+
if (event.entries.has("s:branches-ignore"))
|
|
900
|
+
return { kind: "could_not_tell" };
|
|
901
|
+
const branches = event.entries.get("s:branches");
|
|
902
|
+
if (branches === undefined)
|
|
903
|
+
return { kind: "filters", branches: null };
|
|
904
|
+
if (branches.t === "str")
|
|
905
|
+
return { kind: "filters", branches: [branches.v] };
|
|
906
|
+
if (branches.t === "seq" && branches.items.every((i) => i.t === "str")) {
|
|
907
|
+
return { kind: "filters", branches: branches.items.map((i) => i.v) };
|
|
908
|
+
}
|
|
909
|
+
return { kind: "could_not_tell" };
|
|
910
|
+
}
|
|
911
|
+
catch {
|
|
912
|
+
return { kind: "could_not_tell" };
|
|
913
|
+
}
|
|
914
|
+
}
|
|
807
915
|
// ---------------------------------------------------------------------------
|
|
808
916
|
// Repository aggregate
|
|
809
917
|
// ---------------------------------------------------------------------------
|
|
@@ -876,42 +984,55 @@ export async function inspectEpicBranchWorkflowCoverage(fs, budget = {}) {
|
|
|
876
984
|
return { coverage: "does_not_cover", reason: "no_workflows", workflows: [] };
|
|
877
985
|
const started = now();
|
|
878
986
|
const workflows = [];
|
|
987
|
+
const targetResults = [];
|
|
988
|
+
const target = budget.targetBranch;
|
|
879
989
|
for (const file of files) {
|
|
880
990
|
const path = `${WORKFLOWS_DIR}/${file}`;
|
|
881
991
|
const remaining = overall - (now() - started);
|
|
882
992
|
if (remaining <= 0) {
|
|
883
993
|
workflows.push({ path, coverage: "could_not_tell", reason: "read_failed" });
|
|
994
|
+
targetResults.push({ path, coverage: "could_not_tell", reason: "read_failed" });
|
|
884
995
|
continue;
|
|
885
996
|
}
|
|
886
997
|
const text = await readWithTimeout(fs, path, Math.min(perRead, remaining));
|
|
887
998
|
if (text === null) {
|
|
888
999
|
workflows.push({ path, coverage: "could_not_tell", reason: "read_failed" });
|
|
1000
|
+
targetResults.push({ path, coverage: "could_not_tell", reason: "read_failed" });
|
|
889
1001
|
continue;
|
|
890
1002
|
}
|
|
891
1003
|
workflows.push({ path, ...classifyEpicPullRequestTrigger(text) });
|
|
1004
|
+
if (target !== undefined)
|
|
1005
|
+
targetResults.push({ path, ...classifyEpicPullRequestTrigger(text, { targetBranch: target }) });
|
|
892
1006
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return { coverage: "could_not_tell", reason: "file_limit_reached", workflows };
|
|
898
|
-
if (workflows.some((w) => w.reason === "read_failed")) {
|
|
899
|
-
return { coverage: "could_not_tell", reason: "read_failed", workflows };
|
|
900
|
-
}
|
|
901
|
-
const unresolved = workflows.find((w) => w.coverage === "could_not_tell");
|
|
902
|
-
if (unresolved)
|
|
903
|
-
return { coverage: "could_not_tell", reason: unresolved.reason, workflows };
|
|
904
|
-
const excluded = workflows.some((w) => w.reason === "branch_filter_excludes_epic");
|
|
905
|
-
return {
|
|
906
|
-
coverage: "does_not_cover",
|
|
907
|
-
reason: excluded ? "branch_filter_excludes_epic" : "no_pr_trigger",
|
|
908
|
-
workflows,
|
|
909
|
-
};
|
|
1007
|
+
const aggregate = aggregateCoverage(workflows, truncated);
|
|
1008
|
+
return target === undefined
|
|
1009
|
+
? aggregate
|
|
1010
|
+
: { ...aggregate, integrationTarget: { branch: target, coverage: aggregateCoverage(targetResults, truncated).coverage } };
|
|
910
1011
|
}
|
|
911
1012
|
catch {
|
|
912
1013
|
return { coverage: "could_not_tell", reason: "listing_failed", workflows: [] };
|
|
913
1014
|
}
|
|
914
1015
|
}
|
|
1016
|
+
/** The repository aggregate over per-workflow results; see the module documentation. */
|
|
1017
|
+
function aggregateCoverage(workflows, truncated) {
|
|
1018
|
+
if (workflows.some((w) => w.coverage === "covers")) {
|
|
1019
|
+
return { coverage: "covers", reason: "pr_trigger_covers", workflows };
|
|
1020
|
+
}
|
|
1021
|
+
if (truncated)
|
|
1022
|
+
return { coverage: "could_not_tell", reason: "file_limit_reached", workflows };
|
|
1023
|
+
if (workflows.some((w) => w.reason === "read_failed")) {
|
|
1024
|
+
return { coverage: "could_not_tell", reason: "read_failed", workflows };
|
|
1025
|
+
}
|
|
1026
|
+
const unresolved = workflows.find((w) => w.coverage === "could_not_tell");
|
|
1027
|
+
if (unresolved)
|
|
1028
|
+
return { coverage: "could_not_tell", reason: unresolved.reason, workflows };
|
|
1029
|
+
const excluded = workflows.some((w) => w.reason === "branch_filter_excludes_epic");
|
|
1030
|
+
return {
|
|
1031
|
+
coverage: "does_not_cover",
|
|
1032
|
+
reason: excluded ? "branch_filter_excludes_epic" : "no_pr_trigger",
|
|
1033
|
+
workflows,
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
915
1036
|
/** Closed reason tokens returned by the `gh` functions. */
|
|
916
1037
|
export const EPIC_BRANCH_RULES_REASONS = [
|
|
917
1038
|
"invalid_input",
|
|
@@ -1097,6 +1218,78 @@ export async function readDefaultBranchClassicContextViaGh(run, ownerRepo) {
|
|
|
1097
1218
|
return NO_DEFAULT_CONTEXT;
|
|
1098
1219
|
}
|
|
1099
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Read the effective required status checks on the default branch, from BOTH
|
|
1223
|
+
* sources GitHub enforces: repository rulesets (`rules/branches/<branch>`) and
|
|
1224
|
+
* classic branch protection. GET-only and bounded; it authorizes no rule change and
|
|
1225
|
+
* returns no response text. Any call that gives no reliable answer is `unknown`, so
|
|
1226
|
+
* a caller can warn on a confirmed requirement and stay silent on an uncertain one.
|
|
1227
|
+
* Never throws.
|
|
1228
|
+
*/
|
|
1229
|
+
export async function readDefaultBranchRequiredChecksViaGh(run, ownerRepo, knownDefaultBranch) {
|
|
1230
|
+
try {
|
|
1231
|
+
if (!validOwnerRepo(ownerRepo))
|
|
1232
|
+
return { status: "unknown", reason: "invalid_input" };
|
|
1233
|
+
let defaultBranch = knownDefaultBranch;
|
|
1234
|
+
if (defaultBranch === undefined) {
|
|
1235
|
+
const repo = await ghApiJson(run, [`repos/${ownerRepo}`]);
|
|
1236
|
+
if (!repo.ok)
|
|
1237
|
+
return { status: "unknown", reason: repo.reason };
|
|
1238
|
+
if (!isRecord(repo.json) || typeof repo.json.default_branch !== "string") {
|
|
1239
|
+
return { status: "unknown", reason: "unparseable_response" };
|
|
1240
|
+
}
|
|
1241
|
+
defaultBranch = repo.json.default_branch;
|
|
1242
|
+
}
|
|
1243
|
+
if (!validBranch(defaultBranch))
|
|
1244
|
+
return { status: "unknown", reason: "invalid_input" };
|
|
1245
|
+
const rules = await readBranchRules(run, ownerRepo, defaultBranch);
|
|
1246
|
+
if (!rules.ok)
|
|
1247
|
+
return { status: "unknown", reason: rules.reason };
|
|
1248
|
+
const checks = new Set(rules.rules.statusChecks);
|
|
1249
|
+
const protection = await ghApiJson(run, [
|
|
1250
|
+
`repos/${ownerRepo}/branches/${encodeBranchPath(defaultBranch)}/protection`,
|
|
1251
|
+
]);
|
|
1252
|
+
if (protection.ok) {
|
|
1253
|
+
if (!isRecord(protection.json))
|
|
1254
|
+
return { status: "unknown", reason: "unparseable_response" };
|
|
1255
|
+
const required = protection.json.required_status_checks;
|
|
1256
|
+
if (required !== undefined && required !== null) {
|
|
1257
|
+
if (!isRecord(required))
|
|
1258
|
+
return { status: "unknown", reason: "malformed_rule" };
|
|
1259
|
+
const contexts = required.contexts;
|
|
1260
|
+
if (contexts !== undefined) {
|
|
1261
|
+
if (!Array.isArray(contexts) || contexts.some((c) => typeof c !== "string")) {
|
|
1262
|
+
return { status: "unknown", reason: "malformed_rule" };
|
|
1263
|
+
}
|
|
1264
|
+
for (const c of contexts)
|
|
1265
|
+
checks.add(c);
|
|
1266
|
+
}
|
|
1267
|
+
const entries = required.checks;
|
|
1268
|
+
if (entries !== undefined) {
|
|
1269
|
+
if (!Array.isArray(entries) || entries.some((c) => !isRecord(c) || typeof c.context !== "string")) {
|
|
1270
|
+
return { status: "unknown", reason: "malformed_rule" };
|
|
1271
|
+
}
|
|
1272
|
+
for (const c of entries)
|
|
1273
|
+
checks.add(c.context);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
else if (protection.reason === "not_found") {
|
|
1278
|
+
// A 404 can mean "no classic protection" or "cannot see it": only a branch
|
|
1279
|
+
// proven visible makes it the former.
|
|
1280
|
+
if ((await branchExists(run, ownerRepo, defaultBranch)) !== true) {
|
|
1281
|
+
return { status: "unknown", reason: "not_found" };
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
return { status: "unknown", reason: protection.reason };
|
|
1286
|
+
}
|
|
1287
|
+
return { status: "known", defaultBranch, requiredChecks: [...checks].sort(byCodeUnit) };
|
|
1288
|
+
}
|
|
1289
|
+
catch {
|
|
1290
|
+
return { status: "unknown", reason: "gh_failed" };
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1100
1293
|
function withDefaultContext(f, c) {
|
|
1101
1294
|
return {
|
|
1102
1295
|
...f,
|