@bridge_gpt/mcp-server 0.2.70 → 0.2.72
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 +29 -4
- package/build/agent-notes.js +171 -95
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +12 -2
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +17 -5
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -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-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +776 -23
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +93 -13
- package/build/conductor/epic-implementer-cli.js +55 -2
- package/build/conductor/gate-discovery.js +659 -19
- package/build/conductor/gate-settings-review.js +751 -0
- 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 +16 -11
- package/build/conductor/launch-plan.js +185 -0
- 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/precheck-timings.js +14 -0
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +25 -9
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +281 -14
- package/build/conductor/recovery-operations.js +78 -5
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +240 -56
- package/build/epic-ci-workflow-drift.js +71 -23
- package/build/epic-ci-workflow-install.js +83 -26
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +174 -13
- package/build/epic-implementer-bin.js +119 -44
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- 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 +274 -5
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +355 -36
- package/build/executor/likely-tests.js +100 -98
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +84 -15
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -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/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +188 -1
- package/build/executor/worker-database.js +299 -40
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +64 -0
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +767 -310
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +416 -41
- package/build/install-bridge-conductor-setup.js +135 -32
- package/build/install-bridge-conductor.js +769 -353
- package/build/install-bridge.js +419 -124
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +22 -2
- 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-execution-ledger.js +171 -10
- package/build/plane/plane-freshness.js +12 -9
- package/build/plane/preflight.js +19 -0
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +31 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +623 -0
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +26 -9
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +61 -80
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +80 -4
- package/build/ticket-delivery-run-scope.js +128 -0
- 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.md +43 -0
- package/docs/epic-implementer/getting-started.md +95 -14
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { sanitizeHarnessCoverage } from "../executor/harness-coverage.js";
|
|
1
2
|
import { READINESS_PREREQUISITE_BY_ID } from "../readiness-prerequisites.generated.js";
|
|
2
3
|
/**
|
|
3
4
|
* The shared epic-implementer readiness SECTION layer (BAPI-1055).
|
|
@@ -36,6 +37,7 @@ import { READINESS_PREREQUISITE_BY_ID } from "../readiness-prerequisites.generat
|
|
|
36
37
|
*/
|
|
37
38
|
import { CONSUMER_GUIDE_POINTER, PRINTED_CONNECT_GITHUB_COMMAND } from "../printed-remedy-commands.js";
|
|
38
39
|
import { MANAGED_HOOK_NAMES } from "./git-hooks.js";
|
|
40
|
+
import { posixShellQuote } from "../platform-escaping.js";
|
|
39
41
|
import { MCP_PACKAGE_NAME } from "../mcp-identity.js";
|
|
40
42
|
import { CLAUDE_REVIEW_WORKFLOW_DRIFT_REMEDIATION, summarizeClaudeReviewWorkflowDrift, } from "../claude-review-workflow-drift.js";
|
|
41
43
|
import { describeNativeLedgerAvailability, GH_ACTIONS_MERGE_AUTH_REMEDIATION, GH_ACTIONS_MERGE_SKIPPED_DETAIL, GH_ACTIONS_MERGE_UNOBSERVABLE_REMEDIATION, WORKER_DATABASE_DOCTOR_OWNER, WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION, } from "./doctor.js";
|
|
@@ -48,12 +50,12 @@ export const CONDUCTOR_OPERATOR_RUNBOOK_POINTER = CONSUMER_GUIDE_POINTER;
|
|
|
48
50
|
/**
|
|
49
51
|
* Capability-matrix guidance for the executor leg.
|
|
50
52
|
*
|
|
51
|
-
* Amended by BAPI-779 (R-1): `install
|
|
53
|
+
* Amended by BAPI-779 (R-1): `install epic-implementer` can now write the unit AND
|
|
52
54
|
* start it, each behind its own consent. What did NOT change is the readiness
|
|
53
55
|
* rule — `executor_ready` still comes only from a live server observation, so
|
|
54
56
|
* neither a written unit nor a successful local start may produce that claim.
|
|
55
57
|
*/
|
|
56
|
-
export const EXECUTOR_PROVISIONING_GUIDANCE = "`install
|
|
58
|
+
export const EXECUTOR_PROVISIONING_GUIDANCE = "`install epic-implementer` writes the unit and starts it, each behind its own consent; " +
|
|
57
59
|
"readiness still comes only from a live server observation";
|
|
58
60
|
/**
|
|
59
61
|
* The `BRIDGE_MCP_PROFILE` token that makes the 8 Epic Implementer MCP tools visible.
|
|
@@ -65,22 +67,22 @@ export const EXECUTOR_PROVISIONING_GUIDANCE = "`install conductor` writes the un
|
|
|
65
67
|
export const EPIC_IMPLEMENTER_PROFILE_TOKEN = "epic_implementer";
|
|
66
68
|
/** Remediation for a host MCP config that carries no Bridge entry at all. */
|
|
67
69
|
export const CONDUCTOR_PROFILE_TOKEN_NO_ENTRY_REMEDIATION = "no supported host MCP config carries a Bridge entry — run " +
|
|
68
|
-
`\`npx ${MCP_PACKAGE_NAME} install\` to register one, then re-run \`install
|
|
70
|
+
`\`npx ${MCP_PACKAGE_NAME} install\` to register one, then re-run \`install epic-implementer\`.`;
|
|
69
71
|
/** Remediation for an entry that exists but lacks the conductor token. */
|
|
70
|
-
export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = "re-run `install
|
|
72
|
+
export const CONDUCTOR_PROFILE_TOKEN_REMEDIATION = "re-run `install epic-implementer` and accept the tool-visibility consent; the Epic Implementer " +
|
|
71
73
|
"tools become visible after the MCP client is restarted.";
|
|
72
74
|
/** Remediation surfaced whenever the managed git hooks are not usable. */
|
|
73
|
-
export const CONDUCTOR_HOOK_TARGET_REMEDIATION = "re-run `install
|
|
75
|
+
export const CONDUCTOR_HOOK_TARGET_REMEDIATION = "re-run `install epic-implementer` and accept the local-observability consent, or run " +
|
|
74
76
|
"`epic-implementer install-git-hooks` directly.";
|
|
75
77
|
/** Remediation surfaced when the ledger's native binding does not load. */
|
|
76
78
|
export const CONDUCTOR_LEDGER_LOADABILITY_REMEDIATION = "`better-sqlite3` is an optionalDependency npm silently skips on a build failure — " +
|
|
77
79
|
"reinstall it for this Node runtime to restore local Epic Implementer observability.";
|
|
78
80
|
/** Remediation surfaced whenever no healthy generated service unit is detected. */
|
|
79
|
-
export const EXECUTOR_INSTALL_SERVICE_REMEDIATION = "generate a persistent unit with `install
|
|
81
|
+
export const EXECUTOR_INSTALL_SERVICE_REMEDIATION = "generate a persistent unit with `install epic-implementer --executor-id <id> --repo-wide` or " +
|
|
80
82
|
"`executor install-service` (or run the executor by hand) — " +
|
|
81
83
|
`see ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}.`;
|
|
82
84
|
/** Remediation for a unit that exists but whose service is not running. */
|
|
83
|
-
export const EXECUTOR_SERVICE_START_REMEDIATION = "start the service (re-run `install
|
|
85
|
+
export const EXECUTOR_SERVICE_START_REMEDIATION = "start the service (re-run `install epic-implementer` and accept the start consent, or run the " +
|
|
84
86
|
`printed launchctl/systemctl command by hand) — see ${CONDUCTOR_OPERATOR_RUNBOOK_POINTER}.`;
|
|
85
87
|
// ---------------------------------------------------------------------------
|
|
86
88
|
// BAPI-1254 — the ONE required-check presentation
|
|
@@ -965,7 +967,7 @@ export function executorProvisioningSection(diagnostics) {
|
|
|
965
967
|
};
|
|
966
968
|
}
|
|
967
969
|
const unhealthy = diagnostics.units.filter((unit) => unit.warnings.length > 0 || unit.credentials.some((cred) => !cred.resolved));
|
|
968
|
-
const ids = diagnostics.units.map((unit) => unit.executorId).join(", ");
|
|
970
|
+
const ids = diagnostics.units.map((unit) => `${unit.executorId}; cleanup: npx -y ${MCP_PACKAGE_NAME} executor uninstall-service --executor-id ${posixShellQuote(unit.executorId)}`).join(", ");
|
|
969
971
|
if (unhealthy.length === 0 && diagnostics.warnings.length === 0) {
|
|
970
972
|
return {
|
|
971
973
|
...base,
|
|
@@ -1379,6 +1381,7 @@ export function workerDatabaseReadinessChecks(section) {
|
|
|
1379
1381
|
.filter((row) => row.state !== "healthy")
|
|
1380
1382
|
.map((row) => ({
|
|
1381
1383
|
id: row.id,
|
|
1384
|
+
duration_ms: row.duration_ms,
|
|
1382
1385
|
source: "conductor",
|
|
1383
1386
|
label: row.label,
|
|
1384
1387
|
status: "warn",
|
|
@@ -1386,6 +1389,12 @@ export function workerDatabaseReadinessChecks(section) {
|
|
|
1386
1389
|
// Some doctor details already lead with their state ("unknown — …").
|
|
1387
1390
|
detail: row.detail.startsWith(`${row.state} — `) ? row.detail : `${row.state} — ${row.detail}`,
|
|
1388
1391
|
remediation: `${row.owner}: see ${WORKER_DATABASE_DOCTOR_RUNBOOK_SECTION}`,
|
|
1392
|
+
...(row.id === "worker-db-harness" && sanitizeHarnessCoverage(row.harness_coverage)
|
|
1393
|
+
? { harness_coverage: sanitizeHarnessCoverage(row.harness_coverage) } : {}),
|
|
1394
|
+
// Typed owner metadata rides on the harness row only, never on another row.
|
|
1395
|
+
...(row.id === "worker-db-harness" && row.owner_roles !== undefined && row.owner_roles.length > 0
|
|
1396
|
+
? { owner_roles: row.owner_roles, owner_role_total: row.owner_role_total ?? row.owner_roles.length }
|
|
1397
|
+
: {}),
|
|
1389
1398
|
}));
|
|
1390
1399
|
}
|
|
1391
1400
|
// ---------------------------------------------------------------------------
|
|
@@ -1510,7 +1519,9 @@ export function buildSelfHostedRunnerLaunchRow(fact) {
|
|
|
1510
1519
|
case "absent":
|
|
1511
1520
|
return buildLaunchNeedRow("self_hosted_runner", "absent", `absent — every self-hosted label set behind the required checks (${fact.label_sets}) has an online runner`);
|
|
1512
1521
|
case "not_applicable":
|
|
1513
|
-
return buildLaunchNeedRow("self_hosted_runner", "not_applicable",
|
|
1522
|
+
return { ...buildLaunchNeedRow("self_hosted_runner", "not_applicable", fact.reason === "no_github_actions_workflows"
|
|
1523
|
+
? "not applicable — no_github_actions_workflows"
|
|
1524
|
+
: "not applicable — no required check runs on a self-hosted runner"), ...(fact.reason ? { reason: fact.reason } : {}) };
|
|
1514
1525
|
default:
|
|
1515
1526
|
return buildLaunchNeedRow("self_hosted_runner", "unverifiable", `unverifiable — ${RUNNER_UNVERIFIABLE_DETAIL[fact.reason] ?? RUNNER_UNVERIFIABLE_DETAIL.probe_failed}`);
|
|
1516
1527
|
}
|
|
@@ -1645,3 +1656,8 @@ export function buildEpicBranchBehindBaseLaunchRow(fact) {
|
|
|
1645
1656
|
return buildLaunchNeedRow("epic_branch_behind_base", "unverifiable", `unverifiable — ${BRANCH_UNVERIFIABLE_DETAIL[fact.reason] ?? BRANCH_UNVERIFIABLE_DETAIL.git_failed}`);
|
|
1646
1657
|
}
|
|
1647
1658
|
}
|
|
1659
|
+
/** Explicit assessment explanations alongside the unchanged legacy sections. */
|
|
1660
|
+
export function assessmentWorkflowExplanations(readiness) {
|
|
1661
|
+
return readiness.assessment?.records.filter(r => r.scope === 'default_branch' || r.scope === 'indexed_commit')
|
|
1662
|
+
.map(r => `${r.id} [${r.scope} @ ${r.inspected_sha ?? 'unknown revision'}]: ${r.applicability} (${r.basis}), ${r.observed_state}`) ?? [];
|
|
1663
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { composeReadinessAssessment, deriveAdvisoryVerdict } from './readiness-assessment.js';
|
|
2
|
+
import { formatReadinessAssessment } from './readiness-prerequisites.js';
|
|
1
3
|
import { mergeReadinessPrerequisites, formatReadinessPrerequisites } from "./readiness-prerequisites.js";
|
|
2
4
|
/**
|
|
3
5
|
* The consolidated ADVISORY epic-implementer readiness gate (BAPI-1055, AC-6/AC-7).
|
|
@@ -437,7 +439,7 @@ const ADMISSION_EVIDENCE_LABELS = {
|
|
|
437
439
|
};
|
|
438
440
|
/** Who acts, in fixed prose. Never a value from the payload. */
|
|
439
441
|
const ADMISSION_OWNER_REMEDIATION = {
|
|
440
|
-
operator: "the operator re-runs guided setup (`install
|
|
442
|
+
operator: "the operator re-runs guided setup (`install epic-implementer`) and re-observes.",
|
|
441
443
|
repository_admin: "a repository administrator resolves it (unattended consent is the 'Allow unattended Epic Implementer runs' toggle on the repository's Setup page in the Bridge admin panel); setup never grants it.",
|
|
442
444
|
bridge_operations: "email info@bridgegpt.ai; this is not something an operator command can change.",
|
|
443
445
|
};
|
|
@@ -805,7 +807,7 @@ function unattendedOutcomes(readiness) {
|
|
|
805
807
|
? {
|
|
806
808
|
id: "repository-workflow-readiness",
|
|
807
809
|
status: "pass",
|
|
808
|
-
detail:
|
|
810
|
+
detail: readiness.assessment ? readiness.assessment.records.filter(r => r.scope === 'default_branch').map(r => `${r.id}: ${r.applicability} (${r.basis}); ${r.observed_state}`).join('; ') : 'the workflow sections required by effective policy are confirmed',
|
|
809
811
|
}
|
|
810
812
|
: {
|
|
811
813
|
id: "repository-workflow-readiness",
|
|
@@ -1309,6 +1311,7 @@ export async function collectConductorReadinessGate(deps) {
|
|
|
1309
1311
|
repoName: deps.repoName ?? null,
|
|
1310
1312
|
unavailableSources,
|
|
1311
1313
|
checks: validated,
|
|
1314
|
+
...(installReport?.readiness?.assessmentNegotiation ? { assessmentNegotiation: installReport.readiness.assessmentNegotiation, ...(installReport.readiness.assessment ? { assessment: installReport.readiness.assessment, advisoryVerdict: deriveAdvisoryVerdict(composeReadinessAssessment(installReport.readiness.assessmentNegotiation)) } : {}) } : {}),
|
|
1312
1315
|
prerequisites: mergeReadinessPrerequisites(validated, installReport?.readiness?.prerequisites),
|
|
1313
1316
|
is_production: installReport?.readiness?.is_production,
|
|
1314
1317
|
...(installReport?.readiness?.diagnostics ? { diagnostics: installReport.readiness.diagnostics } : {}),
|
|
@@ -1396,5 +1399,20 @@ function readinessTag(status) {
|
|
|
1396
1399
|
* hides. It computes no overall verdict, because there is none to compute.
|
|
1397
1400
|
*/
|
|
1398
1401
|
export function formatConductorReadinessGateReport(report, options = {}) {
|
|
1402
|
+
if (report.assessmentNegotiation)
|
|
1403
|
+
return formatReadinessAssessment(composeReadinessAssessment(report.assessmentNegotiation, localReadinessFacts(report.checks)), options).join('\n');
|
|
1399
1404
|
return formatReadinessPrerequisites(report.prerequisites ?? mergeReadinessPrerequisites(report.checks), { all: options.all, isProduction: report.is_production }).join('\n');
|
|
1400
1405
|
}
|
|
1406
|
+
/** Local facts cannot satisfy a server-owned prerequisite. */
|
|
1407
|
+
export function localReadinessFacts(checks) {
|
|
1408
|
+
const ids = new Map([
|
|
1409
|
+
['conductor.claude-login', 'local.claude-login'], ['conductor.gh-cli', 'local.github-login'], ['install.identity', 'local.repository-identity'],
|
|
1410
|
+
]);
|
|
1411
|
+
const facts = checks.flatMap(c => ids.has(c.id) ? [{ id: ids.get(c.id),
|
|
1412
|
+
observed_state: c.status === 'pass' ? 'confirmed' : c.status === 'fail' ? 'deficient' : 'unknown',
|
|
1413
|
+
impact: c.blocking === true ? 'mandatory' : 'advisory' }] : []);
|
|
1414
|
+
for (const c of checks.filter(c => c.id === 'conductor.install-section-executor-provisioning')) {
|
|
1415
|
+
facts.push({ id: 'local.executor-installation', observed_state: c.status === 'pass' ? 'confirmed' : 'unknown', impact: 'optional' });
|
|
1416
|
+
}
|
|
1417
|
+
return facts;
|
|
1418
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `conductor` operator recovery and repair verbs —
|
|
2
|
+
* `conductor` operator recovery and repair verbs — seventeen CLI-only commands.
|
|
3
3
|
*
|
|
4
4
|
* The four BAPI-872 recovery verbs: `stop-run`, `abandon-run`, `unpark`,
|
|
5
5
|
* `adopt-current-head-and-unpark`. The six run-addressed repair verbs: BAPI-1154's
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
* provider re-run of failed CI workflow runs: `rerun-ci`. BAPI-1494's owner
|
|
11
11
|
* decision on verification hand-offs: `resolve-handoff`. BAPI-1532's answer to a
|
|
12
12
|
* named plan failure, one forced regeneration on a chosen route: `regenerate-plan`.
|
|
13
|
+
* BAPI-1562's owner acknowledgement of the run's carried-gap list:
|
|
14
|
+
* `acknowledge-gaps`.
|
|
13
15
|
*
|
|
14
16
|
* CLI-only by design — this is an explicit ticket non-goal, not an oversight:
|
|
15
|
-
* none of these
|
|
17
|
+
* none of these seventeen command names is ever registered as an MCP tool, tool
|
|
16
18
|
* description, or generated tool-schema input (`index-static.test.ts` guards
|
|
17
19
|
* this). They exist so an operator (or `plane down`, via
|
|
18
20
|
* `recovery-operations.ts`) can recover a stuck run or ticket WITHOUT
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
import { readFile } from "node:fs/promises";
|
|
30
32
|
import { ConductorValidationError, toConductorErrorEnvelope } from "./errors.js";
|
|
31
33
|
import { nodeGithubMergeCredentialReadDeps, readLocalGithubRemote } from "./stored-merge-credential.js";
|
|
32
|
-
import { DRIVER_CONTEXT_MAX_BYTES, HANDOFF_RESOLUTION_EVIDENCE_REF_MAX_CHARS, HANDOFF_RESOLUTION_KIND_LABELS, HANDOFF_RESOLUTION_KINDS, HANDOFF_RESOLUTION_MAX_STEPS, HANDOFF_RESOLUTION_REASON_MAX_CHARS, POLICY_PATCH_MAX_BYTES, RESUME_RUN_UNCONFIRMED_MESSAGE, } from "./repair-contract.js";
|
|
34
|
+
import { DRIVER_CONTEXT_MAX_BYTES, HANDOFF_RESOLUTION_EVIDENCE_REF_MAX_CHARS, HANDOFF_RESOLUTION_KIND_LABELS, HANDOFF_RESOLUTION_KINDS, HANDOFF_RESOLUTION_MAX_STEPS, HANDOFF_RESOLUTION_REASON_MAX_CHARS, GAP_ACKNOWLEDGEMENT_REASON_MAX_CHARS, POLICY_PATCH_MAX_BYTES, RESUME_RUN_UNCONFIRMED_MESSAGE, } from "./repair-contract.js";
|
|
33
35
|
import { CONTINUATION_CI_WAITING_REASONS, continuationDispatchedJob, } from "./epic-child-continuation.js";
|
|
34
36
|
import { decodeGuidedBinding, GuidedBindingError, } from "./guided-repair.js";
|
|
35
37
|
// ---------------------------------------------------------------------------
|
|
@@ -125,8 +127,28 @@ function parseRunRecoveryArgs(argv) {
|
|
|
125
127
|
}
|
|
126
128
|
return { epicRunId: epicRunId.trim(), json: bools.has("--json"), help: false };
|
|
127
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* BAPI-1537 — the operation-id shape the server accepts (`api/models/epic_run.py`
|
|
132
|
+
* `EXTERNAL_REPAIR_OPERATION_ID_PATTERN`): 1-128 characters of `[A-Za-z0-9._:-]`,
|
|
133
|
+
* case-sensitive. Checked here so a malformed id never reaches the network.
|
|
134
|
+
*/
|
|
135
|
+
const EXTERNAL_REPAIR_OPERATION_ID_RE = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
136
|
+
function parseExternalRepairOperationId(values) {
|
|
137
|
+
if (!values.has("--external-repair"))
|
|
138
|
+
return undefined;
|
|
139
|
+
const raw = values.get("--external-repair") ?? "";
|
|
140
|
+
// A following flag is not a value: `--external-repair --json` names no id.
|
|
141
|
+
if (raw.startsWith("--")) {
|
|
142
|
+
throw new ConductorValidationError('Flag "--external-repair" requires a value.');
|
|
143
|
+
}
|
|
144
|
+
const id = raw.trim();
|
|
145
|
+
if (!EXTERNAL_REPAIR_OPERATION_ID_RE.test(id)) {
|
|
146
|
+
throw new ConductorValidationError('"--external-repair" must be 1-128 characters of letters, digits, ".", "_", ":" or "-".');
|
|
147
|
+
}
|
|
148
|
+
return id;
|
|
149
|
+
}
|
|
128
150
|
function parseTicketRecoveryArgs(argv) {
|
|
129
|
-
const { values, bools } = tokenizeRecoveryFlags(argv, new Set([...TICKET_VALUE_FLAGS, "--reason", "--cleanup-resolution"]), RECOVERY_BOOL_FLAGS);
|
|
151
|
+
const { values, bools } = tokenizeRecoveryFlags(argv, new Set([...TICKET_VALUE_FLAGS, "--reason", "--cleanup-resolution", "--external-repair", "--binding"]), RECOVERY_BOOL_FLAGS);
|
|
130
152
|
if (bools.has("--help")) {
|
|
131
153
|
return { epicRunId: "", ticketKey: "", json: bools.has("--json"), help: true };
|
|
132
154
|
}
|
|
@@ -138,6 +160,16 @@ function parseTicketRecoveryArgs(argv) {
|
|
|
138
160
|
if (ticketKey === undefined || ticketKey.trim().length === 0) {
|
|
139
161
|
throw new ConductorValidationError('Flag "--ticket-key" is required and must be non-empty.');
|
|
140
162
|
}
|
|
163
|
+
const externalRepairOperationId = parseExternalRepairOperationId(values);
|
|
164
|
+
let expectedRowVersion;
|
|
165
|
+
if (values.has("--binding")) {
|
|
166
|
+
const binding = decodeGuidedBinding(values.get("--binding") ?? "");
|
|
167
|
+
if (binding.verb !== "adopt-current-head-and-unpark" || binding.epicRunId !== epicRunId.trim()
|
|
168
|
+
|| binding.ticketKey !== ticketKey.trim() || binding.externalRepairOperationId !== externalRepairOperationId) {
|
|
169
|
+
throw new ConductorValidationError("The external-repair binding does not match this command.");
|
|
170
|
+
}
|
|
171
|
+
expectedRowVersion = binding.expectedRowVersion;
|
|
172
|
+
}
|
|
141
173
|
return {
|
|
142
174
|
epicRunId: epicRunId.trim(),
|
|
143
175
|
ticketKey: ticketKey.trim(),
|
|
@@ -145,6 +177,8 @@ function parseTicketRecoveryArgs(argv) {
|
|
|
145
177
|
...(values.get("--cleanup-resolution") ? {
|
|
146
178
|
cleanupResolution: values.get("--cleanup-resolution"),
|
|
147
179
|
} : {}),
|
|
180
|
+
...(externalRepairOperationId !== undefined ? { externalRepairOperationId } : {}),
|
|
181
|
+
...(expectedRowVersion !== undefined ? { expectedRowVersion } : {}),
|
|
148
182
|
json: bools.has("--json"),
|
|
149
183
|
help: false,
|
|
150
184
|
};
|
|
@@ -278,7 +312,7 @@ const UNPARK_USAGE = [
|
|
|
278
312
|
"its own if the ticket changes concurrently — never accepts a version counter.",
|
|
279
313
|
].join("\n");
|
|
280
314
|
const ADOPT_CURRENT_HEAD_USAGE = [
|
|
281
|
-
"Usage: epic-implementer adopt-current-head-and-unpark --epic-run-id <id> --ticket-key <key> [--json]",
|
|
315
|
+
"Usage: epic-implementer adopt-current-head-and-unpark --epic-run-id <id> --ticket-key <key> [--external-repair <operation-id>] [--json]",
|
|
282
316
|
"",
|
|
283
317
|
"Recover a ticket parked because a human/external push drifted the PR head",
|
|
284
318
|
"off its anchored commit: adopt the CURRENT PR head and unpark in one step.",
|
|
@@ -291,6 +325,15 @@ const ADOPT_CURRENT_HEAD_USAGE = [
|
|
|
291
325
|
"resumes the ticket at CI. No worker is started and nothing is marked passed —",
|
|
292
326
|
"CI and review must pass again on the accepted head. A repeat of the same",
|
|
293
327
|
"request reports the recorded result instead of adopting twice.",
|
|
328
|
+
"",
|
|
329
|
+
"--external-repair <operation-id> adopts fast-forward repair commits pushed to",
|
|
330
|
+
"the ticket's own branch while no engine job ran (for example a checkpoint-only",
|
|
331
|
+
"park with no PR). The server proves the repair is safe — no live job, fast-",
|
|
332
|
+
"forward ancestry, the right PR base and head, and a head no other ticket owns —",
|
|
333
|
+
"then rebinds the head and unparks. The ticket still passes CI, review, and the",
|
|
334
|
+
"engine merge at that head. The id is a correlation label (1-128 characters of",
|
|
335
|
+
"letters, digits, '.', '_', ':' or '-'); the same id replays its recorded result.",
|
|
336
|
+
"Only the run's supervisor/driver uses it. Not accepted by unpark.",
|
|
294
337
|
].join("\n");
|
|
295
338
|
/** BAPI-1310 (E1): the fixed allowance sentence the adoption result carries. */
|
|
296
339
|
const REVIEW_HEAD_ALLOWANCE_LINE = "Allowance effect: repair allowances preserved; acceptance does not grant another repair.";
|
|
@@ -312,12 +355,32 @@ function renderReviewHeadRecovery(ticketKey, epicRunId, recovery) {
|
|
|
312
355
|
console.log(` WARNING: ${REVIEW_HEAD_HELD_WARNING}.`);
|
|
313
356
|
}
|
|
314
357
|
}
|
|
358
|
+
/** BAPI-1537: render an external-repair receipt (committed or replayed) to stdout. */
|
|
359
|
+
function renderExternalRepair(ticketKey, epicRunId, receipt) {
|
|
360
|
+
const outcome = receipt.result === "replayed"
|
|
361
|
+
? "replayed — this operation already committed; nothing changed now"
|
|
362
|
+
: "committed";
|
|
363
|
+
console.log(`Ticket ${ticketKey} (run ${epicRunId}): external repair ${receipt.operation_id} adopted — ${outcome}.`);
|
|
364
|
+
console.log(` Previous expected head: ${receipt.previous_expected_head_sha ?? "unbound"}`);
|
|
365
|
+
console.log(` Comparison base: ${receipt.comparison_base_sha}`);
|
|
366
|
+
console.log(` Adopted head: ${receipt.adopted_head_sha}`);
|
|
367
|
+
console.log(` Restored to: ${receipt.restored_status}`);
|
|
368
|
+
console.log(` Current gate: ${receipt.current_gate ?? "unavailable"}`);
|
|
369
|
+
console.log(" The ticket must still pass attach, CI, review, and the engine merge at the adopted head; nothing was marked passed.");
|
|
370
|
+
if (receipt.held_by_run_control) {
|
|
371
|
+
console.log(" WARNING: Head adopted; run remains held by run control.");
|
|
372
|
+
}
|
|
373
|
+
}
|
|
315
374
|
export function renderTicketRecoveryResult(result, json) {
|
|
316
375
|
if (json) {
|
|
317
376
|
console.log(JSON.stringify(result));
|
|
318
377
|
return result.ok ? 0 : 1;
|
|
319
378
|
}
|
|
320
379
|
if (result.ok) {
|
|
380
|
+
if (result.externalRepair) {
|
|
381
|
+
renderExternalRepair(result.ticketKey, result.epicRunId, result.externalRepair);
|
|
382
|
+
return 0;
|
|
383
|
+
}
|
|
321
384
|
if (result.reviewHeadRecovery) {
|
|
322
385
|
renderReviewHeadRecovery(result.ticketKey, result.epicRunId, result.reviewHeadRecovery);
|
|
323
386
|
return 0;
|
|
@@ -345,6 +408,9 @@ export function renderTicketRecoveryResult(result, json) {
|
|
|
345
408
|
export async function runUnparkCommand(argv) {
|
|
346
409
|
try {
|
|
347
410
|
const parsed = parseTicketRecoveryArgs(argv);
|
|
411
|
+
if (parsed.externalRepairOperationId !== undefined) {
|
|
412
|
+
throw new ConductorValidationError("--external-repair applies only to adopt-current-head-and-unpark.");
|
|
413
|
+
}
|
|
348
414
|
if (parsed.cleanupResolution !== undefined &&
|
|
349
415
|
!["confirmed", "risk_accepted"].includes(parsed.cleanupResolution)) {
|
|
350
416
|
throw new ConductorValidationError("--cleanup-resolution must be confirmed or risk_accepted.");
|
|
@@ -390,6 +456,10 @@ export async function runAdoptCurrentHeadAndUnparkCommand(argv) {
|
|
|
390
456
|
const result = await adoptCurrentHeadAndUnparkWithRetry(access, {
|
|
391
457
|
epicRunId: parsed.epicRunId,
|
|
392
458
|
ticketKey: parsed.ticketKey,
|
|
459
|
+
...(parsed.expectedRowVersion !== undefined ? { expectedRowVersion: parsed.expectedRowVersion } : {}),
|
|
460
|
+
...(parsed.externalRepairOperationId !== undefined
|
|
461
|
+
? { externalRepairOperationId: parsed.externalRepairOperationId }
|
|
462
|
+
: {}),
|
|
393
463
|
});
|
|
394
464
|
return renderTicketRecoveryResult(result, parsed.json);
|
|
395
465
|
}
|
|
@@ -412,6 +482,12 @@ const DISPATCH_REMEDIATION_VALUE_FLAGS = new Set([
|
|
|
412
482
|
"--binding",
|
|
413
483
|
]);
|
|
414
484
|
const MERGE_CHILD_VALUE_FLAGS = new Set(["--epic-run-id", "--pr"]);
|
|
485
|
+
/**
|
|
486
|
+
* BAPI-1564 — `--carry-gaps` is a `merge-child` switch only; no other verb
|
|
487
|
+
* accepts it. It selects the server's carried-gap admission MODE and carries no
|
|
488
|
+
* head, base, branch, or SHA.
|
|
489
|
+
*/
|
|
490
|
+
const MERGE_CHILD_BOOL_FLAGS = new Set(["--json", "--help", "--carry-gaps"]);
|
|
415
491
|
/**
|
|
416
492
|
* BAPI-1333 — attach `binding` ONLY when `--binding` was given, so an unguided
|
|
417
493
|
* parse result is exactly what it was before.
|
|
@@ -454,9 +530,21 @@ export function parseDispatchRemediationArgs(argv) {
|
|
|
454
530
|
}, values);
|
|
455
531
|
}
|
|
456
532
|
export function parseMergeChildArgs(argv) {
|
|
457
|
-
|
|
533
|
+
// BAPI-1564 — the shared tokenizer reads `--flag=value` of a boolean flag as the
|
|
534
|
+
// bare flag, so `--carry-gaps=false` would SELECT the mode. Refused outright for
|
|
535
|
+
// this authority-bearing switch: it is given bare or not at all.
|
|
536
|
+
if (argv.some((token) => token.startsWith("--carry-gaps="))) {
|
|
537
|
+
throw new ConductorValidationError('Flag "--carry-gaps" takes no value; give it bare or omit it.');
|
|
538
|
+
}
|
|
539
|
+
const { values, bools } = tokenizeRecoveryFlags(argv, MERGE_CHILD_VALUE_FLAGS, MERGE_CHILD_BOOL_FLAGS);
|
|
458
540
|
if (bools.has("--help")) {
|
|
459
|
-
return {
|
|
541
|
+
return {
|
|
542
|
+
epicRunId: "",
|
|
543
|
+
prNumber: 0,
|
|
544
|
+
json: bools.has("--json"),
|
|
545
|
+
help: true,
|
|
546
|
+
carryGaps: bools.has("--carry-gaps"),
|
|
547
|
+
};
|
|
460
548
|
}
|
|
461
549
|
const epicRunId = requireFlag(values, "--epic-run-id");
|
|
462
550
|
const rawPr = requireFlag(values, "--pr");
|
|
@@ -464,7 +552,13 @@ export function parseMergeChildArgs(argv) {
|
|
|
464
552
|
if (!Number.isSafeInteger(prNumber)) {
|
|
465
553
|
throw new ConductorValidationError('Flag "--pr" must be a positive integer pull-request number.');
|
|
466
554
|
}
|
|
467
|
-
return {
|
|
555
|
+
return {
|
|
556
|
+
epicRunId,
|
|
557
|
+
prNumber,
|
|
558
|
+
json: bools.has("--json"),
|
|
559
|
+
help: false,
|
|
560
|
+
carryGaps: bools.has("--carry-gaps"),
|
|
561
|
+
};
|
|
468
562
|
}
|
|
469
563
|
/**
|
|
470
564
|
* Validate and decode a driver-context file's BYTES.
|
|
@@ -630,13 +724,31 @@ function renderRepairResult(outcome, input, json, extraLines = () => []) {
|
|
|
630
724
|
"and is not rolled back. You ran it, so you own reconciling the missing audit " +
|
|
631
725
|
"record (the server also reported it to Sentry).");
|
|
632
726
|
}
|
|
727
|
+
if (outcome.ok &&
|
|
728
|
+
input.verb === "dispatch-remediation" &&
|
|
729
|
+
outcome.result.driver_context_delivered === false) {
|
|
730
|
+
// BAPI-1550: only an EXPLICIT false warns. The dispatch itself still succeeded
|
|
731
|
+
// (a deduplicated dispatch exits 0), so this goes to stderr, never into the
|
|
732
|
+
// stdout the operator may be parsing (so it also shows in --json mode).
|
|
733
|
+
console.error("Warning: driver context was NOT delivered. A job for this ticket was already queued or " +
|
|
734
|
+
"running and continues WITHOUT it. Dispatch again with --context-file after that job " +
|
|
735
|
+
"finishes.");
|
|
736
|
+
}
|
|
633
737
|
if (json) {
|
|
634
738
|
if (outcome.ok) {
|
|
635
739
|
console.log(JSON.stringify(outcome.result));
|
|
636
740
|
return 0;
|
|
637
741
|
}
|
|
638
742
|
console.log(JSON.stringify(outcome.kind === "refused"
|
|
639
|
-
? {
|
|
743
|
+
? {
|
|
744
|
+
ok: false,
|
|
745
|
+
kind: "refused",
|
|
746
|
+
code: outcome.code,
|
|
747
|
+
message: outcome.message,
|
|
748
|
+
...(outcome.holder
|
|
749
|
+
? { holder_job_id: outcome.holder.job_id, holder_job_type: outcome.holder.job_type }
|
|
750
|
+
: {}),
|
|
751
|
+
}
|
|
640
752
|
: { ok: false, kind: "unavailable", message: input.unavailableMessage ?? outcome.message }));
|
|
641
753
|
return 1;
|
|
642
754
|
}
|
|
@@ -644,6 +756,10 @@ function renderRepairResult(outcome, input, json, extraLines = () => []) {
|
|
|
644
756
|
if (outcome.kind === "refused") {
|
|
645
757
|
console.error(`Error: ${input.verb} refused on run ${input.epicRunId} (${input.targetLabel}) — ` +
|
|
646
758
|
`${outcome.code}: ${outcome.message}`);
|
|
759
|
+
if (outcome.holder) {
|
|
760
|
+
// BAPI-1550: one secondary detail line, only for a validated pair.
|
|
761
|
+
console.error(` lane holder: job ${outcome.holder.job_id} (${outcome.holder.job_type}), queued`);
|
|
762
|
+
}
|
|
647
763
|
}
|
|
648
764
|
else if (input.unavailableMessage) {
|
|
649
765
|
console.error(`Error: ${input.verb} on run ${input.epicRunId} (${input.targetLabel}) — ` +
|
|
@@ -803,6 +919,10 @@ export async function runDispatchRemediationCommand(argv, deps = {}) {
|
|
|
803
919
|
stateLabel: "selected gate",
|
|
804
920
|
}, parsed.json, (result) => [
|
|
805
921
|
` job: ${result.job_type || "unknown"}${result.job_id !== null ? ` (job ${result.job_id})` : ""}`,
|
|
922
|
+
...(result.driver_context_delivered === true ? [" context: delivered"] : []),
|
|
923
|
+
...(typeof result.queued_behind === "number"
|
|
924
|
+
? [` queued: queued behind job ${result.queued_behind}`]
|
|
925
|
+
: []),
|
|
806
926
|
]);
|
|
807
927
|
}
|
|
808
928
|
catch (error) {
|
|
@@ -1189,8 +1309,140 @@ export async function runResolveHandoffCommand(argv) {
|
|
|
1189
1309
|
return RESOLVE_HANDOFF_EXIT_FAILED;
|
|
1190
1310
|
}
|
|
1191
1311
|
}
|
|
1312
|
+
// ---------------------------------------------------------------------------
|
|
1313
|
+
// BAPI-1562 — acknowledge-gaps
|
|
1314
|
+
// ---------------------------------------------------------------------------
|
|
1315
|
+
const ACKNOWLEDGE_GAPS_VALUE_FLAGS = new Set(["--epic-run-id", "--digest", "--reason"]);
|
|
1316
|
+
/** Exit codes: 0 acknowledged (or already acknowledged), 1 refused, stale, or failed. */
|
|
1317
|
+
export const ACKNOWLEDGE_GAPS_EXIT_OK = 0;
|
|
1318
|
+
export const ACKNOWLEDGE_GAPS_EXIT_FAILED = 1;
|
|
1319
|
+
/** What every success ends with: the second hold, and what acknowledging is not. */
|
|
1320
|
+
export const ACKNOWLEDGE_GAPS_NEXT_ACTION = "The integration PR leaves draft only when both holds are clear: this list hold and " +
|
|
1321
|
+
"the workaround-folder hold (remove any .bridge/epic-workarounds/ records in a new " +
|
|
1322
|
+
"epic-head commit). Acknowledging verified nothing, readied nothing and merged " +
|
|
1323
|
+
"nothing: review and merge the integration PR into base yourself.";
|
|
1324
|
+
const ACKNOWLEDGE_GAPS_USAGE = [
|
|
1325
|
+
"Usage: epic-implementer acknowledge-gaps --epic-run-id <RUN> --digest <CURRENT_DIGEST> --reason <TEXT> [--json]",
|
|
1326
|
+
"",
|
|
1327
|
+
"Acknowledge, once, the run's carried-gap list: every verification hand-off, carried",
|
|
1328
|
+
"gap, driver merge and out-of-engine merge the run carried forward. The integration PR",
|
|
1329
|
+
"stays in draft until the owner acknowledges the list's CURRENT digest; a new entry",
|
|
1330
|
+
"changes the digest and holds it again. Read the list on the integration PR report or",
|
|
1331
|
+
"with `epic-implementer explain-run` (carried_gap_list) and pass its digest exactly.",
|
|
1332
|
+
"",
|
|
1333
|
+
"This is the OWNER's step. The /drive-epic-run driver never runs it and workers",
|
|
1334
|
+
"cannot. The server records your verified API-key identity as the actor; you cannot",
|
|
1335
|
+
"supply one. It never marks a step verified, never readies the PR and never merges it.",
|
|
1336
|
+
"--digest is the 64-character lowercase hex list digest. --reason is at most 1000",
|
|
1337
|
+
"characters.",
|
|
1338
|
+
"",
|
|
1339
|
+
"Exit codes: 0 acknowledged (or this digest was already acknowledged); 1 refused,",
|
|
1340
|
+
"stale (the list changed), or failed.",
|
|
1341
|
+
].join("\n");
|
|
1342
|
+
export function parseAcknowledgeGapsArgs(argv) {
|
|
1343
|
+
const { values, bools } = tokenizeRecoveryFlags(argv, ACKNOWLEDGE_GAPS_VALUE_FLAGS, RECOVERY_BOOL_FLAGS);
|
|
1344
|
+
if (bools.has("--help")) {
|
|
1345
|
+
return { epicRunId: "", digest: "", reason: "", json: bools.has("--json"), help: true };
|
|
1346
|
+
}
|
|
1347
|
+
const digest = requireFlag(values, "--digest");
|
|
1348
|
+
if (!/^[0-9a-f]{64}$/.test(digest)) {
|
|
1349
|
+
throw new ConductorValidationError("--digest must be the 64-character lowercase hex list digest from the report or explain-run.");
|
|
1350
|
+
}
|
|
1351
|
+
const reason = boundedText(values, "--reason", GAP_ACKNOWLEDGEMENT_REASON_MAX_CHARS);
|
|
1352
|
+
if (!reason.trim()) {
|
|
1353
|
+
throw new ConductorValidationError('Flag "--reason" must not be blank.');
|
|
1354
|
+
}
|
|
1355
|
+
return {
|
|
1356
|
+
epicRunId: requireFlag(values, "--epic-run-id"),
|
|
1357
|
+
digest,
|
|
1358
|
+
reason,
|
|
1359
|
+
json: bools.has("--json"),
|
|
1360
|
+
help: false,
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Exported for tests: render one `acknowledge-gaps` outcome. Success goes to
|
|
1365
|
+
* stdout and every failure to stderr (`--json` included).
|
|
1366
|
+
*/
|
|
1367
|
+
export function renderAcknowledgeGapsOutcome(outcome, parsed, json) {
|
|
1368
|
+
const label = `run ${parsed.epicRunId}`;
|
|
1369
|
+
if (outcome.ok) {
|
|
1370
|
+
const result = outcome.result;
|
|
1371
|
+
if (result.committed && !result.event_recorded) {
|
|
1372
|
+
console.error(`Warning: acknowledge-gaps for ${label} COMMITTED, but its operator_verb_applied ` +
|
|
1373
|
+
"audit event was not recorded. The acknowledgement stands; a replay will not write again.");
|
|
1374
|
+
}
|
|
1375
|
+
if (json) {
|
|
1376
|
+
console.log(JSON.stringify(result));
|
|
1377
|
+
return ACKNOWLEDGE_GAPS_EXIT_OK;
|
|
1378
|
+
}
|
|
1379
|
+
const lines = [
|
|
1380
|
+
result.committed
|
|
1381
|
+
? `acknowledge-gaps — ${label}: list acknowledged (${result.entry_count} entries)`
|
|
1382
|
+
: `acknowledge-gaps — ${label}: this digest was already acknowledged; nothing was written`,
|
|
1383
|
+
` digest: ${result.digest}`,
|
|
1384
|
+
` event recorded: ${result.committed ? String(result.event_recorded) : "not applicable (replay)"}`,
|
|
1385
|
+
` next action: ${ACKNOWLEDGE_GAPS_NEXT_ACTION}`,
|
|
1386
|
+
];
|
|
1387
|
+
console.log(lines.join("\n"));
|
|
1388
|
+
return ACKNOWLEDGE_GAPS_EXIT_OK;
|
|
1389
|
+
}
|
|
1390
|
+
if (outcome.kind === "refused") {
|
|
1391
|
+
if (json) {
|
|
1392
|
+
console.error(JSON.stringify({
|
|
1393
|
+
ok: false,
|
|
1394
|
+
outcome: "refused",
|
|
1395
|
+
code: outcome.code,
|
|
1396
|
+
message: outcome.message,
|
|
1397
|
+
nothing_written: true,
|
|
1398
|
+
}));
|
|
1399
|
+
}
|
|
1400
|
+
else if (outcome.code === "GAP_DIGEST_STALE") {
|
|
1401
|
+
console.error(`Refused: acknowledge-gaps for ${label} — GAP_DIGEST_STALE: the list changed since ` +
|
|
1402
|
+
"you read it. Nothing was written. Re-read the integration PR report or " +
|
|
1403
|
+
"`epic-implementer explain-run` (carried_gap_list) and acknowledge the new digest.");
|
|
1404
|
+
}
|
|
1405
|
+
else {
|
|
1406
|
+
console.error(`Refused: acknowledge-gaps for ${label} — ${outcome.code}: ${outcome.message} ` +
|
|
1407
|
+
"Nothing was written.");
|
|
1408
|
+
}
|
|
1409
|
+
return ACKNOWLEDGE_GAPS_EXIT_FAILED;
|
|
1410
|
+
}
|
|
1411
|
+
if (json) {
|
|
1412
|
+
console.error(JSON.stringify({ ok: false, outcome: "unavailable", message: outcome.message }));
|
|
1413
|
+
}
|
|
1414
|
+
else {
|
|
1415
|
+
console.error(`Failed: acknowledge-gaps for ${label} — ${outcome.message}. The outcome is uncertain: ` +
|
|
1416
|
+
"it is safe to run the same command again with the same digest (a repeat writes " +
|
|
1417
|
+
"nothing if it was already recorded).");
|
|
1418
|
+
}
|
|
1419
|
+
return ACKNOWLEDGE_GAPS_EXIT_FAILED;
|
|
1420
|
+
}
|
|
1421
|
+
export async function runAcknowledgeGapsCommand(argv) {
|
|
1422
|
+
try {
|
|
1423
|
+
const parsed = parseAcknowledgeGapsArgs(argv);
|
|
1424
|
+
if (parsed.help) {
|
|
1425
|
+
console.log(ACKNOWLEDGE_GAPS_USAGE);
|
|
1426
|
+
return 0;
|
|
1427
|
+
}
|
|
1428
|
+
const access = await resolveRecoveryAccess(parsed.json);
|
|
1429
|
+
if (!access)
|
|
1430
|
+
return ACKNOWLEDGE_GAPS_EXIT_FAILED;
|
|
1431
|
+
const { acknowledgeGapsRepair } = await import("./recovery-operations.js");
|
|
1432
|
+
const outcome = await acknowledgeGapsRepair(access, {
|
|
1433
|
+
epicRunId: parsed.epicRunId,
|
|
1434
|
+
digest: parsed.digest,
|
|
1435
|
+
reason: parsed.reason,
|
|
1436
|
+
});
|
|
1437
|
+
return renderAcknowledgeGapsOutcome(outcome, parsed, parsed.json);
|
|
1438
|
+
}
|
|
1439
|
+
catch (error) {
|
|
1440
|
+
console.error(`Error: ${toConductorErrorEnvelope(error).message}`);
|
|
1441
|
+
return ACKNOWLEDGE_GAPS_EXIT_FAILED;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1192
1444
|
const MERGE_CHILD_USAGE = [
|
|
1193
|
-
"Usage: epic-implementer merge-child --epic-run-id <id> --pr <number> [--json]",
|
|
1445
|
+
"Usage: epic-implementer merge-child --epic-run-id <id> --pr <number> [--carry-gaps] [--json]",
|
|
1194
1446
|
"",
|
|
1195
1447
|
"Merge the run's child pull request through the shared merge service. You give",
|
|
1196
1448
|
"ONLY the PR number: the server finds the one ticket in the run bound to it",
|
|
@@ -1202,6 +1454,15 @@ const MERGE_CHILD_USAGE = [
|
|
|
1202
1454
|
"When the repository merges locally (the default), your own `gh` performs the",
|
|
1203
1455
|
"merge — run this from inside the repository's checkout, with `gh auth status`",
|
|
1204
1456
|
"passing.",
|
|
1457
|
+
"",
|
|
1458
|
+
"--carry-gaps Merge a PARKED, green child whose only readiness blockers are",
|
|
1459
|
+
" carried verification gaps. It merges only into this run's own",
|
|
1460
|
+
" epic/<KEY> branch, after server checks: gap authority, run",
|
|
1461
|
+
" membership, the epic-branch base, the exact run-produced head,",
|
|
1462
|
+
" green required CI, mergeability, and review. It never merges into",
|
|
1463
|
+
" the default branch or the integration PR. The server records a",
|
|
1464
|
+
" driver-merge admission first; the carried gaps are listed on the",
|
|
1465
|
+
" integration PR for the owner.",
|
|
1205
1466
|
].join("\n");
|
|
1206
1467
|
export async function runMergeChildCommand(argv) {
|
|
1207
1468
|
try {
|
|
@@ -1216,7 +1477,12 @@ export async function runMergeChildCommand(argv) {
|
|
|
1216
1477
|
const { mergeChildRepair } = await import("./recovery-operations.js");
|
|
1217
1478
|
// BAPI-1461: this verb runs in the person's own session, so a merge token
|
|
1218
1479
|
// stored once for this repository is the last rung after the env keys.
|
|
1219
|
-
const outcome = await mergeChildRepair(access, {
|
|
1480
|
+
const outcome = await mergeChildRepair(access, {
|
|
1481
|
+
epicRunId: parsed.epicRunId,
|
|
1482
|
+
prNumber: parsed.prNumber,
|
|
1483
|
+
// BAPI-1564 — the key is sent only when the operator gave the flag.
|
|
1484
|
+
...(parsed.carryGaps ? { carryGaps: true } : {}),
|
|
1485
|
+
}, {
|
|
1220
1486
|
storedMergeCredential: {
|
|
1221
1487
|
allowStoredEntry: true,
|
|
1222
1488
|
localRemote: await readLocalGithubRemote(process.cwd()),
|
|
@@ -1557,8 +1823,9 @@ const CONTINUE_CHILD_USAGE = [
|
|
|
1557
1823
|
"approves a new head or episode); continuation-receipt looks the receipt up.",
|
|
1558
1824
|
"Never accepts a version counter or a park generation.",
|
|
1559
1825
|
"",
|
|
1560
|
-
"--context-file
|
|
1561
|
-
"
|
|
1826
|
+
"--context-file: driver context for the continuation's worker, delivered as quoted,",
|
|
1827
|
+
"untrusted operational context appended to the worker prompt. For a CI-repair",
|
|
1828
|
+
"continuation it is sent beside --reason (never merged into it). It must be non-empty UTF-8",
|
|
1562
1829
|
`text of at most DRIVER_CONTEXT_MAX_BYTES (${DRIVER_CONTEXT_MAX_BYTES} bytes); it is`,
|
|
1563
1830
|
"rejected, never truncated, and is never printed, logged, or echoed. A re-run of",
|
|
1564
1831
|
"a pending request must pass the same file. A server that does not support it",
|
|
@@ -1681,7 +1948,7 @@ const CI_ROUTE_GUIDANCE = {
|
|
|
1681
1948
|
"(rerun-ci). No repair was dispatched.",
|
|
1682
1949
|
ci_route_hold: "CI routing is holding; no widened repair was dispatched. Re-read the run state " +
|
|
1683
1950
|
"(explain-run) before choosing another action.",
|
|
1684
|
-
driver_context_not_supported: "--context-file
|
|
1951
|
+
driver_context_not_supported: "This continuation cannot carry --context-file into a worker prompt. Drop --context-file " +
|
|
1685
1952
|
"and re-run with --reason only. Nothing was written.",
|
|
1686
1953
|
};
|
|
1687
1954
|
/** Exported for tests: render a `continue-child` result. Returns the exit code. */
|