@bridge_gpt/mcp-server 0.2.74 → 0.2.76
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 +6 -6
- package/build/authored-plan.js +542 -0
- package/build/bridge-permissions.js +8 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +7 -7
- package/build/conductor/bridge-api-client.js +807 -52
- package/build/conductor/declare-blocked.js +4 -0
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/epic-implementer-cli.js +341 -96
- package/build/conductor/epic-server-journal.js +13 -0
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/gate-discovery.js +209 -9
- package/build/conductor/gate-settings-review.js +7 -11
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/local-merge.js +54 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +12 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/docs.generated.js +3 -3
- package/build/drive-epic.js +787 -37
- package/build/epic-ci-workflow.js +3 -2
- package/build/epic-implementer-bin.js +200 -66
- 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 +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +13 -723
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/provider-checks.js +28 -5
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/required-verification.js +28 -2
- package/build/executor/required-work-ledger.js +7 -2
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +30 -5
- 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/worktree.js +12 -1
- package/build/generated/ticket-status.js +20 -0
- package/build/index.js +627 -551
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +32 -1
- package/build/install-bridge-conductor-apply.js +21 -3
- package/build/install-bridge-conductor-assessment.js +185 -12
- package/build/install-bridge-conductor-compact.js +2 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-gate.js +257 -80
- package/build/install-bridge-conductor-setup.js +106 -6
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +740 -124
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +15 -15
- package/build/plan-execution-ledger.js +27 -0
- package/build/plan-generation.js +17 -0
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +62 -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/secret-redaction.js +3 -0
- package/build/setup-epic.js +51 -9
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/executor-source-files.js +1 -1
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +13 -4
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +83 -4
- package/docs/epic-implementer/getting-started.md +1 -1
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/pipelines/implement-ticket.json +2 -2
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -21,7 +21,8 @@ import { formatReadinessAssessment } from './conductor/readiness-prerequisites.j
|
|
|
21
21
|
* row for the same fact. An unmet blocking item is counted once.
|
|
22
22
|
*/
|
|
23
23
|
import { READINESS_PREREQUISITE_BY_ID, READINESS_PREREQUISITE_CATALOG, } from "./readiness-prerequisites.generated.js";
|
|
24
|
-
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, resolveReadinessRemedy, PRE_SETUP_READINESS_REMEDY, } from "./printed-remedy-commands.js";
|
|
24
|
+
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, indexedWorkflowsDisplayRemedy, resolveReadinessRemedy, PRE_SETUP_READINESS_REMEDY, CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION, PRINTED_QUALIFY_GATE_COMMAND, } from "./printed-remedy-commands.js";
|
|
25
|
+
import { DUPLICATE_REGISTRATION_GUIDANCE } from "./launcher-config-inspection.js";
|
|
25
26
|
import { COMMAND_DRIFT_DIVERGENT_REMEDIATION, COMMAND_DRIFT_UNASSESSABLE_REMEDIATION } from "./conductor/command-drift.js";
|
|
26
27
|
import { shellQuote } from "./epic-launch-profile.js";
|
|
27
28
|
import { decodeCanonicalProvenance } from "./conductor/bridge-api-client.js";
|
|
@@ -53,6 +54,12 @@ export const SETUP_ITEM_IDS = Object.freeze({
|
|
|
53
54
|
* the server catalog. It never changes the verdict.
|
|
54
55
|
*/
|
|
55
56
|
epicServer: "local.epic-server",
|
|
57
|
+
/**
|
|
58
|
+
* BAPI-1719: a LOCAL advisory item for whether the Epic Implementer MCP tools
|
|
59
|
+
* are loaded by the project's Bridge MCP entries. Never blocking, and
|
|
60
|
+
* deliberately not in the server readiness catalog.
|
|
61
|
+
*/
|
|
62
|
+
toolVisibility: "local.tool-visibility",
|
|
56
63
|
/** BAPI-1635: a LOCAL advisory item for default-branch index lag. Never blocking. */
|
|
57
64
|
indexFreshness: "local.index-freshness",
|
|
58
65
|
/** BAPI-1635: the committed-asset drift advisory, a catalog row labeled "Command versions". */
|
|
@@ -64,6 +71,10 @@ export const INDEX_FRESHNESS_ITEM_LABEL = "Repository index freshness";
|
|
|
64
71
|
export const MCP_GRANT_ITEM_LABEL = "Worker MCP servers (owner approval)";
|
|
65
72
|
/** BAPI-1546: the explicit label of the local epic-server item. */
|
|
66
73
|
export const EPIC_SERVER_ITEM_LABEL = "Epic server for UI checks (owner opt-in)";
|
|
74
|
+
/** BAPI-1719: the explicit label of the local tool-visibility item. */
|
|
75
|
+
export const TOOL_VISIBILITY_ITEM_LABEL = "Epic Implementer tools in your editor (MCP profile)";
|
|
76
|
+
/** BAPI-1719: the one remedy for a profile that setup can add (or could not re-check). */
|
|
77
|
+
export const TOOL_VISIBILITY_MERGE_REMEDY = "setup adds it; then restart your MCP client.";
|
|
67
78
|
/** The catalog label for an id, falling back to the id itself. */
|
|
68
79
|
export function catalogLabel(id) {
|
|
69
80
|
return READINESS_PREREQUISITE_BY_ID.get(id)?.label ?? id;
|
|
@@ -136,7 +147,7 @@ const ACTIVE_INDEX_STATES = ["in_progress", "queued_by_setup", "recovery_pending
|
|
|
136
147
|
function needsSetupFirst(setupPresent, id, scope) {
|
|
137
148
|
return setupPresent === false && (scope === "self_host" || id === "server.service-availability");
|
|
138
149
|
}
|
|
139
|
-
export function fromServerPrerequisite(p, isProduction, setupPresent) {
|
|
150
|
+
export function fromServerPrerequisite(p, isProduction, setupPresent, report) {
|
|
140
151
|
if (p.check_status === "met" || p.check_status === "not_applicable") {
|
|
141
152
|
return { id: p.id, label: p.label, state: "met", blocking: p.impact === "blocking", remedy: null };
|
|
142
153
|
}
|
|
@@ -158,7 +169,7 @@ export function fromServerPrerequisite(p, isProduction, setupPresent) {
|
|
|
158
169
|
label: p.label,
|
|
159
170
|
state: p.check_status === "unknown" ? "unknown" : "needs_action",
|
|
160
171
|
blocking,
|
|
161
|
-
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : p.fix.length > 0 ? p
|
|
172
|
+
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : p.fix.length > 0 ? indexedWorkflowsDisplayRemedy(p, report) : READINESS_PREREQUISITE_FIXES.retry,
|
|
162
173
|
};
|
|
163
174
|
}
|
|
164
175
|
function upsert(items, item) {
|
|
@@ -193,7 +204,7 @@ export function projectSetupItems(evidence) {
|
|
|
193
204
|
}
|
|
194
205
|
else if (readiness.prerequisites !== undefined) {
|
|
195
206
|
for (const p of readiness.prerequisites) {
|
|
196
|
-
const item = fromServerPrerequisite(p, isProduction, readiness.supervisor?.setup_present);
|
|
207
|
+
const item = fromServerPrerequisite(p, isProduction, readiness.supervisor?.setup_present, readiness);
|
|
197
208
|
if (item !== null)
|
|
198
209
|
items.push(item);
|
|
199
210
|
}
|
|
@@ -228,10 +239,21 @@ export function projectSetupItems(evidence) {
|
|
|
228
239
|
const epicServer = projectEpicServerItem(evidence.epicServer, evidence.path);
|
|
229
240
|
if (epicServer !== null)
|
|
230
241
|
upsert(items, epicServer);
|
|
242
|
+
// --- BAPI-1719: tool visibility (advisory, never the verdict) ------------
|
|
243
|
+
const toolVisibility = projectToolVisibilityItem(evidence.toolVisibility);
|
|
244
|
+
if (toolVisibility !== null)
|
|
245
|
+
upsert(items, toolVisibility);
|
|
231
246
|
// --- BAPI-1635: a known unmet row never keeps the generic retry -----------
|
|
232
247
|
// `fromServerPrerequisite` stays as it was; a blank wire fix is resolved here by ID.
|
|
233
248
|
for (const item of items)
|
|
234
249
|
normalizeKnownRemedy(item);
|
|
250
|
+
// BAPI-1526: an unqualified stored local gate names the qualification fix.
|
|
251
|
+
if (storedGateNeedsQualification(evidence.readiness)) {
|
|
252
|
+
for (const item of items) {
|
|
253
|
+
if (item.id === "server.gate-profile" && item.state === "needs_action")
|
|
254
|
+
item.remedy = QUALIFY_GATE_REMEDY;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
235
257
|
// --- Escalation channel: the selected launch profile's route, or its remedy -
|
|
236
258
|
applyNotificationEvidence(items, evidence);
|
|
237
259
|
// --- BAPI-1635: index lag and committed-asset drift (advisory, never the verdict) ---
|
|
@@ -483,6 +505,37 @@ export function projectEpicServerItem(state, path = "terminal") {
|
|
|
483
505
|
: "the epic-server record is unusable, so runs have no epic server; re-run setup to replace it");
|
|
484
506
|
}
|
|
485
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* BAPI-1719: the advisory tool-visibility item, one pure projection shared by
|
|
510
|
+
* both assessment paths. Non-blocking in every state, so it never changes the
|
|
511
|
+
* verdict, the remaining-step count, or the server readiness records.
|
|
512
|
+
*/
|
|
513
|
+
export function projectToolVisibilityItem(state) {
|
|
514
|
+
if (state === undefined)
|
|
515
|
+
return null;
|
|
516
|
+
const item = (s, remedy) => ({
|
|
517
|
+
id: SETUP_ITEM_IDS.toolVisibility,
|
|
518
|
+
label: TOOL_VISIBILITY_ITEM_LABEL,
|
|
519
|
+
state: s,
|
|
520
|
+
blocking: false,
|
|
521
|
+
remedy: s === "met" ? null : remedy,
|
|
522
|
+
});
|
|
523
|
+
switch (state.state) {
|
|
524
|
+
case "met":
|
|
525
|
+
return item("met", null);
|
|
526
|
+
case "needs_merge":
|
|
527
|
+
return item("needs_action", TOOL_VISIBILITY_MERGE_REMEDY);
|
|
528
|
+
case "duplicate_registration":
|
|
529
|
+
// Not a fix setup can make: Bridge never chooses which registration to keep.
|
|
530
|
+
return item("needs_action", `${state.configPaths.join(", ")}: ${DUPLICATE_REGISTRATION_GUIDANCE}`);
|
|
531
|
+
case "no_entry":
|
|
532
|
+
return item("needs_action", CONDUCTOR_PROFILE_EMPTY_MERGE_REMEDIATION);
|
|
533
|
+
case "unknown":
|
|
534
|
+
return item("unknown", state.reason === "verification"
|
|
535
|
+
? "the profile was written but could not be read back; restart your MCP client, then run `doctor` to confirm"
|
|
536
|
+
: "the MCP profile could not be checked; re-run setup");
|
|
537
|
+
}
|
|
538
|
+
}
|
|
486
539
|
function projectMergeCredential(state) {
|
|
487
540
|
const id = SETUP_ITEM_IDS.mergeCredential;
|
|
488
541
|
switch (state.state) {
|
|
@@ -502,6 +555,29 @@ function projectMergeCredential(state) {
|
|
|
502
555
|
return local(id, "unknown", true, "the merge token could not be checked right now; re-run setup later");
|
|
503
556
|
}
|
|
504
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* BAPI-1526: the server reports a STORED gate whose local command is not qualified
|
|
560
|
+
* for its current revision (unqualified or stale) — a proven denial. Never true for
|
|
561
|
+
* `unable_to_verify`, a malformed profile, a `none` or `provider` gate, or an older
|
|
562
|
+
* server that sends no gate-profile block.
|
|
563
|
+
*/
|
|
564
|
+
export function storedGateNeedsQualification(readiness) {
|
|
565
|
+
const profile = readiness?.gate_profile;
|
|
566
|
+
if (profile === undefined || profile === null)
|
|
567
|
+
return false;
|
|
568
|
+
return profile.source === "stored"
|
|
569
|
+
&& profile.stored_malformed === false
|
|
570
|
+
&& (profile.kind === "local" || profile.kind === "mixed")
|
|
571
|
+
&& profile.verdict === "denied"
|
|
572
|
+
&& profile.reason === "local_command_unqualified";
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* BAPI-1526: the `server.gate-profile` remedy for an unqualified stored local gate. It
|
|
576
|
+
* names the real fix, never the generic "plan the repository gate" text, which a
|
|
577
|
+
* re-run without the flag could not clear.
|
|
578
|
+
*/
|
|
579
|
+
export const QUALIFY_GATE_REMEDY = `re-run setup and approve qualifying the local gate, or run ${PRINTED_QUALIFY_GATE_COMMAND}; ` +
|
|
580
|
+
"the local gate must pass once under the executor before an unattended run is admitted.";
|
|
505
581
|
/**
|
|
506
582
|
* Pick the permitted fixes for the unmet items, in the order they must run.
|
|
507
583
|
*
|
|
@@ -552,6 +628,18 @@ export function planSetupFixes(evidence, context) {
|
|
|
552
628
|
(evidence.epicServer.state === "needs_action" || context.epicServerChangeRequested === true)) {
|
|
553
629
|
fixes.push("epic_server");
|
|
554
630
|
}
|
|
631
|
+
// BAPI-1719: the local MCP profile merge, last, behind its own consent. Planned
|
|
632
|
+
// only on a CONCLUSIVE needed merge; no-entry and unknown plan nothing, and the
|
|
633
|
+
// item itself stays outside the server readiness catalog.
|
|
634
|
+
if (evidence.toolVisibility?.state === "needs_merge")
|
|
635
|
+
fixes.push("tool_visibility");
|
|
636
|
+
// BAPI-1526: offer to qualify the local gate, from server facts only, behind its own
|
|
637
|
+
// consent. The verdict already blocks on it; this clears it inside setup. Not planned
|
|
638
|
+
// when `--qualify-gate` was passed: that flag qualifies with no question, as before.
|
|
639
|
+
if (context.qualifyGateRequested !== true
|
|
640
|
+
&& (storedGateNeedsQualification(evidence.readiness) || context.explicitLocalGateUnproven === true)) {
|
|
641
|
+
fixes.push("qualify_gate");
|
|
642
|
+
}
|
|
555
643
|
return fixes;
|
|
556
644
|
}
|
|
557
645
|
const SHA_RE = /^[0-9a-f]{40}$/;
|
|
@@ -705,7 +793,7 @@ const STATE_WORD = Object.freeze({
|
|
|
705
793
|
unknown: "could not verify",
|
|
706
794
|
});
|
|
707
795
|
/** The advisory findings setup adds beside the server's own rows. */
|
|
708
|
-
const ADVISORY_FINDING_IDS = new Set([SETUP_ITEM_IDS.indexFreshness, SETUP_ITEM_IDS.commandDrift]);
|
|
796
|
+
const ADVISORY_FINDING_IDS = new Set([SETUP_ITEM_IDS.indexFreshness, SETUP_ITEM_IDS.commandDrift, SETUP_ITEM_IDS.toolVisibility]);
|
|
709
797
|
/**
|
|
710
798
|
* BAPI-1635: the lines for the advisory findings setup adds (index lag, command
|
|
711
799
|
* versions) in the compact summary and in read-only runs, where the full assessment
|
|
@@ -713,7 +801,10 @@ const ADVISORY_FINDING_IDS = new Set([SETUP_ITEM_IDS.indexFreshness, SETUP_ITEM_
|
|
|
713
801
|
*/
|
|
714
802
|
export function advisoryFindingLines(items) {
|
|
715
803
|
// Only a finding (needs action, or indexing already running); an unreadable comparison is not advice.
|
|
716
|
-
|
|
804
|
+
// BAPI-1719: tool visibility also names its fixed unknown guidance; other findings do not.
|
|
805
|
+
const found = items.filter((i) => !i.blocking
|
|
806
|
+
&& (i.state === "needs_action" || i.state === "pending" || (i.state === "unknown" && i.id === SETUP_ITEM_IDS.toolVisibility))
|
|
807
|
+
&& ADVISORY_FINDING_IDS.has(i.id) && i.remedy !== null);
|
|
717
808
|
return found.length === 0 ? [] : ["", "Also worth doing (advisory)", ...found.map((i) => ` - ${i.label}: ${i.remedy}`)];
|
|
718
809
|
}
|
|
719
810
|
/**
|
|
@@ -885,6 +976,11 @@ function projectAssessmentSetupItems(evidence) {
|
|
|
885
976
|
const recordRemedy = (r) => {
|
|
886
977
|
if (r.blocking_effect === 'none')
|
|
887
978
|
return null;
|
|
979
|
+
// BAPI-1526: a proven-unqualified stored local gate names the qualification fix, not the
|
|
980
|
+
// generic gate-planning text a re-run without the flag could never clear.
|
|
981
|
+
if (r.id === 'server.gate-profile' && r.blocking_effect === 'blocker' && storedGateNeedsQualification(evidence.readiness)) {
|
|
982
|
+
return QUALIFY_GATE_REMEDY;
|
|
983
|
+
}
|
|
888
984
|
// BAPI-1657: only a known-missing gate with a readable basis and a planned write says approval stores it.
|
|
889
985
|
if (r.id === 'server.gate-profile' && r.observed_state === 'unknown' && r.basis !== undefined
|
|
890
986
|
&& r.basis !== 'policy_unreadable' && evidence.plannedGateWrite === true) {
|
|
@@ -943,6 +1039,10 @@ function projectAssessmentSetupItems(evidence) {
|
|
|
943
1039
|
const epicServerItem = projectEpicServerItem(evidence.epicServer, evidence.path);
|
|
944
1040
|
if (epicServerItem !== null)
|
|
945
1041
|
items.push(epicServerItem);
|
|
1042
|
+
// BAPI-1719: the same local tool-visibility projection as the legacy path; server records untouched.
|
|
1043
|
+
const toolVisibilityItem = projectToolVisibilityItem(evidence.toolVisibility);
|
|
1044
|
+
if (toolVisibilityItem !== null)
|
|
1045
|
+
items.push(toolVisibilityItem);
|
|
946
1046
|
// BAPI-1635: advisory findings beside the server's records; neither changes the verdict.
|
|
947
1047
|
const freshnessItem = projectFreshnessItem(evidence.freshness);
|
|
948
1048
|
if (freshnessItem !== null)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One plain-language presentation of a test-command trial result (BAPI-1698).
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS MODULE EXISTS. Setup used to answer every failed trial the same way:
|
|
5
|
+
* "run setup again". For a deterministic failure (a missing program, a failing
|
|
6
|
+
* test, a command that runs no tests) an unchanged retry fails again, and the
|
|
7
|
+
* owner learns nothing. This module turns the server's closed phase token and
|
|
8
|
+
* the optional per-command facts into ONE headline, ONE explanation, ONE remedy,
|
|
9
|
+
* and plain per-command statuses, so every setup path tells the owner the same
|
|
10
|
+
* true thing.
|
|
11
|
+
*
|
|
12
|
+
* Pure: no terminal output, no server call, no file read. It never invents a
|
|
13
|
+
* command-level outcome: per-command statuses are paired with command text only
|
|
14
|
+
* when the server's validated list matches the commands one for one.
|
|
15
|
+
*/
|
|
16
|
+
import { CONDUCTOR_GATE_QUALIFICATION_PHASES, } from "./conductor/bridge-api-client.js";
|
|
17
|
+
/** True for a closed phase token; anything else reads as no phase. */
|
|
18
|
+
export function isTrialPhase(value) {
|
|
19
|
+
return CONDUCTOR_GATE_QUALIFICATION_PHASES.includes(value);
|
|
20
|
+
}
|
|
21
|
+
/** The instruction a remedy points to when the command itself should change. */
|
|
22
|
+
export const CHANGE_TEST_COMMAND_TEXT = 'change the command with --test-command "<your command>"';
|
|
23
|
+
/** The success wording every setup path uses. Never "proven". */
|
|
24
|
+
export const PASSED_TRIAL_RUN_TEXT = "passed the trial run";
|
|
25
|
+
function anyKilledBySignal(results) {
|
|
26
|
+
return (results ?? []).some((r) => r.reason === "killed_by_signal");
|
|
27
|
+
}
|
|
28
|
+
/** The one advice table. Every failed kind has its own explanation and remedy. */
|
|
29
|
+
export function presentTrialResult(input) {
|
|
30
|
+
if (input.interrupted === true) {
|
|
31
|
+
return {
|
|
32
|
+
kind: "interrupted",
|
|
33
|
+
headline: "Did not finish",
|
|
34
|
+
explanation: "The trial run did not produce a result: a clean checkout of your default branch was not available, " +
|
|
35
|
+
"or the run was interrupted before every command finished.",
|
|
36
|
+
treatment: "notice",
|
|
37
|
+
remedy: "Nothing about the command was learned, so it is fine to try again.",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
switch (input.phase) {
|
|
41
|
+
case "passed":
|
|
42
|
+
return {
|
|
43
|
+
kind: "passed",
|
|
44
|
+
headline: "Passed the trial run",
|
|
45
|
+
explanation: "Every command ran in a clean checkout of your default branch and passed.",
|
|
46
|
+
treatment: "success",
|
|
47
|
+
remedy: null,
|
|
48
|
+
};
|
|
49
|
+
case "could_not_start":
|
|
50
|
+
return {
|
|
51
|
+
kind: "could_not_start",
|
|
52
|
+
headline: "Could not start",
|
|
53
|
+
explanation: "A command could not be started. A program or folder it needs is probably not in a clean checkout " +
|
|
54
|
+
"of your default branch (for example, a virtual environment that exists only on your computer).",
|
|
55
|
+
treatment: "failure",
|
|
56
|
+
remedy: `Declare the install that creates it, or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
57
|
+
};
|
|
58
|
+
case "ran_and_failed":
|
|
59
|
+
return {
|
|
60
|
+
kind: "ran_and_failed",
|
|
61
|
+
headline: "Ran and failed",
|
|
62
|
+
explanation: anyKilledBySignal(input.commandResults)
|
|
63
|
+
? "A command started and was then killed by a signal from outside Bridge (not a timeout), so it did not pass."
|
|
64
|
+
: "The commands ran, and at least one did not pass.",
|
|
65
|
+
treatment: "failure",
|
|
66
|
+
remedy: `Fix the failing tests, or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
67
|
+
};
|
|
68
|
+
case "no_tests_ran":
|
|
69
|
+
return {
|
|
70
|
+
kind: "no_tests_ran",
|
|
71
|
+
headline: "No tests ran",
|
|
72
|
+
explanation: "The command finished without an error, but Bridge found no sign that it ran any test, " +
|
|
73
|
+
`so it has not ${PASSED_TRIAL_RUN_TEXT}.`,
|
|
74
|
+
treatment: "failure",
|
|
75
|
+
remedy: `Give a command that runs your tests: ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
76
|
+
};
|
|
77
|
+
case "dependency_preparation_failed":
|
|
78
|
+
return {
|
|
79
|
+
kind: "dependency_preparation_failed",
|
|
80
|
+
headline: "Dependency install failed",
|
|
81
|
+
explanation: "The dependency install failed, so the tests did not run.",
|
|
82
|
+
treatment: "failure",
|
|
83
|
+
remedy: "Correct the install step (for example, a lockfile that no longer matches the manifest), then run setup again.",
|
|
84
|
+
};
|
|
85
|
+
case "worker_database_preparation_failed":
|
|
86
|
+
return {
|
|
87
|
+
kind: "worker_database_preparation_failed",
|
|
88
|
+
headline: "Test database not ready",
|
|
89
|
+
explanation: "The test database the trial needs could not be prepared, so the tests did not run. This is not a test failure.",
|
|
90
|
+
treatment: "failure",
|
|
91
|
+
remedy: "Repair the worker database setup on the computer that ran the trial (its executor log names the reason), " +
|
|
92
|
+
"then run setup again.",
|
|
93
|
+
};
|
|
94
|
+
default:
|
|
95
|
+
return {
|
|
96
|
+
kind: "evidence_unavailable",
|
|
97
|
+
headline: "Result unclear",
|
|
98
|
+
explanation: input.dependencyInstallDeclared === true
|
|
99
|
+
? "Bridge cannot tell whether the dependency install ran before the tests, so it cannot say why the check did not pass."
|
|
100
|
+
: "The trial did not pass, but Bridge cannot tell which part failed. The server or the executor that ran it may be older.",
|
|
101
|
+
treatment: "notice",
|
|
102
|
+
remedy: "Update the Bridge executor and server to the latest version so setup can say what happened, " +
|
|
103
|
+
`or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** One command's plain status. Never a raw token. */
|
|
108
|
+
export function commandStatusText(result) {
|
|
109
|
+
switch (result.outcome) {
|
|
110
|
+
case "exited_zero":
|
|
111
|
+
return "passed";
|
|
112
|
+
case "exited_nonzero":
|
|
113
|
+
return result.reason === "killed_by_signal" ? "killed by a signal" : "failed";
|
|
114
|
+
case "no_tests_ran":
|
|
115
|
+
return "ran no tests";
|
|
116
|
+
case "timed_out":
|
|
117
|
+
return "ran out of time";
|
|
118
|
+
case "launch_error":
|
|
119
|
+
return "could not start";
|
|
120
|
+
case "cancelled":
|
|
121
|
+
return "did not finish";
|
|
122
|
+
case "not_run":
|
|
123
|
+
return result.reason === "stopped_after_interruption"
|
|
124
|
+
? "did not run (an earlier command stopped the run)"
|
|
125
|
+
: "did not run";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Replace control characters, as the success path always has, so a command line prints safely. */
|
|
129
|
+
export function sanitizeCommandText(text) {
|
|
130
|
+
return text.replace(/[\u0000-\u001F\u007F]/g, "?");
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Pair command text with per-command statuses ONLY when the server's validated
|
|
134
|
+
* list has exactly one fact per command. Otherwise every command is listed
|
|
135
|
+
* without a status beneath the overall result. For an interrupted run every
|
|
136
|
+
* command reads "did not finish": Bridge does not know which ones started.
|
|
137
|
+
*/
|
|
138
|
+
export function trialCommandLines(input) {
|
|
139
|
+
const commands = input.commands.map(sanitizeCommandText);
|
|
140
|
+
if (input.interrupted === true)
|
|
141
|
+
return commands.map((command) => ({ command, status: "did not finish" }));
|
|
142
|
+
const results = input.commandResults ?? null;
|
|
143
|
+
if (results === null || results.length !== commands.length) {
|
|
144
|
+
return commands.map((command) => ({ command, status: null }));
|
|
145
|
+
}
|
|
146
|
+
return commands.map((command, index) => ({ command, status: commandStatusText(results[index]) }));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The lines a terminal prints, in order: headline, consequence, commands, remedy.
|
|
150
|
+
* `consequence` is the caller's own sentence (what was or was not stored).
|
|
151
|
+
*/
|
|
152
|
+
export function renderTrialReport(input) {
|
|
153
|
+
const indent = input.indent ?? " ";
|
|
154
|
+
const { presentation } = input;
|
|
155
|
+
const severity = presentation.treatment === "success" ? "" : presentation.treatment === "failure" ? "Failed: " : "Note: ";
|
|
156
|
+
const lines = [
|
|
157
|
+
`${indent}Test trial — ${severity}${presentation.headline}. ${presentation.explanation}`,
|
|
158
|
+
`${indent}${input.consequence}`,
|
|
159
|
+
];
|
|
160
|
+
if (input.commands.length > 0) {
|
|
161
|
+
const attributed = input.commands.some((line) => line.status !== null);
|
|
162
|
+
lines.push(`${indent}${attributed ? "Commands:" : "Commands tried (the result above covers them together):"}`);
|
|
163
|
+
for (const line of input.commands) {
|
|
164
|
+
lines.push(`${indent} - ${line.command}${line.status !== null ? ` — ${line.status}` : ""}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (presentation.remedy !== null)
|
|
168
|
+
lines.push(`${indent}Next: ${presentation.remedy}`);
|
|
169
|
+
return lines;
|
|
170
|
+
}
|