@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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** Byte-preserving removal of managed hook spans, independent of hook runtime. */
|
|
2
|
+
import { lstat, readFile, open, rename, unlink } from "node:fs/promises";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { confirmLocalCleanup } from "../local-cleanup.js";
|
|
6
|
+
import { MANAGED_HOOK_NAMES, BRIDGE_CONDUCTOR_HOOK_START, BRIDGE_CONDUCTOR_HOOK_END, removeManagedHookSnippet, resolveGitHooksDirectory } from "./git-hooks.js";
|
|
7
|
+
export async function planConductorGitHooksUninstall(deps = {}) {
|
|
8
|
+
const directory = resolveGitHooksDirectory(deps);
|
|
9
|
+
if (!directory.hooks_dir)
|
|
10
|
+
throw new Error("hooks directory unavailable");
|
|
11
|
+
const io = deps.io ?? { lstat, readFile, open, rename, unlink };
|
|
12
|
+
const items = [];
|
|
13
|
+
for (const name of MANAGED_HOOK_NAMES) {
|
|
14
|
+
const target = join(directory.hooks_dir, name);
|
|
15
|
+
try {
|
|
16
|
+
const stat = await io.lstat(target);
|
|
17
|
+
if (stat.isSymbolicLink() || !stat.isFile() || stat.size > 1024 * 1024) {
|
|
18
|
+
items.push({ path: target, action: "retained", warning: "unsafe hook file" });
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const bytes = await io.readFile(target);
|
|
22
|
+
const content = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
23
|
+
const removal = removeManagedHookSnippet(content);
|
|
24
|
+
items.push({ path: target, ...removal, snapshot: { bytes, dev: stat.dev, ino: stat.ino, mode: stat.mode } });
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
items.push({ path: target, action: error.code === "ENOENT" ? "unchanged" : "retained", warning: error.code === "ENOENT" ? undefined : "hook bytes unavailable" });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return items;
|
|
31
|
+
}
|
|
32
|
+
export async function uninstallConductorGitHooks(items, deps = {}) {
|
|
33
|
+
const io = deps.io ?? { lstat, readFile, open, rename, unlink };
|
|
34
|
+
const results = [];
|
|
35
|
+
let ok = true;
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
if (item.action === "unchanged") {
|
|
38
|
+
results.push({ path: item.path, outcome: "nothing to remove" });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (item.action === "retained" || !item.snapshot) {
|
|
42
|
+
ok = false;
|
|
43
|
+
results.push({ path: item.path, outcome: `retained: ${item.warning}; owner repair required between ${BRIDGE_CONDUCTOR_HOOK_START} and ${BRIDGE_CONDUCTOR_HOOK_END}` });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const temp = `${item.path}.${randomUUID()}.tmp`;
|
|
47
|
+
let owned = false;
|
|
48
|
+
try {
|
|
49
|
+
if (item.action === "rewrite") {
|
|
50
|
+
const handle = await io.open(temp, "wx", 0o600);
|
|
51
|
+
owned = true;
|
|
52
|
+
try {
|
|
53
|
+
await handle.writeFile(item.content, "utf8");
|
|
54
|
+
await handle.chmod(item.snapshot.mode & 0o7777);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await handle.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const now = await io.lstat(item.path);
|
|
61
|
+
if (!now.isFile() || now.isSymbolicLink() || now.dev !== item.snapshot.dev || now.ino !== item.snapshot.ino || now.mode !== item.snapshot.mode || !(await io.readFile(item.path)).equals(item.snapshot.bytes))
|
|
62
|
+
throw new Error("changed");
|
|
63
|
+
if (item.action === "delete")
|
|
64
|
+
await io.unlink(item.path);
|
|
65
|
+
else {
|
|
66
|
+
await io.rename(temp, item.path);
|
|
67
|
+
owned = false;
|
|
68
|
+
}
|
|
69
|
+
results.push({ path: item.path, outcome: item.action === "delete" ? "deleted" : "user content restored" });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
ok = false;
|
|
73
|
+
results.push({ path: item.path, outcome: "retained: changed or unavailable; retry after owner review" });
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
if (owned)
|
|
77
|
+
await io.unlink(temp).catch(() => { });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return { ok, results };
|
|
81
|
+
}
|
|
82
|
+
export async function runUninstallGitHooksCommand(argv) {
|
|
83
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
84
|
+
process.stderr.write("Usage: epic-implementer uninstall-git-hooks [--dry-run]\nRemove only Bridge-managed hook text with interactive consent.\n");
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
if (argv.some(arg => arg !== "--dry-run")) {
|
|
88
|
+
process.stderr.write("Unsupported uninstall-git-hooks argument.\n");
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const items = await planConductorGitHooksUninstall();
|
|
93
|
+
for (const item of items)
|
|
94
|
+
process.stderr.write(`${item.path}: ${item.action}${item.warning ? ` (${item.warning})` : ""}\n`);
|
|
95
|
+
if (argv.includes("--dry-run")) {
|
|
96
|
+
process.stderr.write("dry run — nothing was removed\n");
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
if (!await confirmLocalCleanup("Remove only Bridge-managed text from these shared Git hooks?")) {
|
|
100
|
+
process.stderr.write("declined — nothing was removed\n");
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const result = await uninstallConductorGitHooks(items);
|
|
104
|
+
for (const item of result.results)
|
|
105
|
+
process.stderr.write(`${item.path}: ${item.outcome}\n`);
|
|
106
|
+
return result.ok ? 0 : 1;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
process.stderr.write("Git hook removal unavailable; files retained. Run from a Git worktree.\n");
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -296,6 +296,50 @@ export function buildReferenceTransactionHookSnippet(conductorBin) {
|
|
|
296
296
|
function looksBinary(content) {
|
|
297
297
|
return content.includes("\u0000");
|
|
298
298
|
}
|
|
299
|
+
/** Unique line-bounded managed span, rejecting ambiguous marker arrangements. */
|
|
300
|
+
export function managedHookSpan(content) {
|
|
301
|
+
const starts = [...content.matchAll(new RegExp(BRIDGE_CONDUCTOR_HOOK_START.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"))];
|
|
302
|
+
const ends = [...content.matchAll(new RegExp(BRIDGE_CONDUCTOR_HOOK_END.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"))];
|
|
303
|
+
if (!starts.length && !ends.length)
|
|
304
|
+
return null;
|
|
305
|
+
if (starts.length !== 1 || ends.length !== 1)
|
|
306
|
+
return "unsafe";
|
|
307
|
+
const start = starts[0].index, end = ends[0].index + BRIDGE_CONDUCTOR_HOOK_END.length;
|
|
308
|
+
if (end <= start || (start > 0 && content[start - 1] !== "\n") || (end < content.length && content[end] !== "\n" && content.slice(end, end + 2) !== "\r\n"))
|
|
309
|
+
return "unsafe";
|
|
310
|
+
return { start, end };
|
|
311
|
+
}
|
|
312
|
+
const SEPARATOR_METADATA = "# bridge-hook-separators-v1:";
|
|
313
|
+
function withSeparatorMetadata(block, prefix, suffix) {
|
|
314
|
+
return block.replace(BRIDGE_CONDUCTOR_HOOK_START, `${BRIDGE_CONDUCTOR_HOOK_START}\n${SEPARATOR_METADATA}${Buffer.from(prefix).toString("hex")}:${Buffer.from(suffix).toString("hex")}`);
|
|
315
|
+
}
|
|
316
|
+
export function removeManagedHookSnippet(existing) {
|
|
317
|
+
if (looksBinary(existing))
|
|
318
|
+
return { action: "retained", content: existing, warning: "unsafe hook bytes" };
|
|
319
|
+
const span = managedHookSpan(existing);
|
|
320
|
+
if (span === "unsafe")
|
|
321
|
+
return { action: "retained", content: existing, warning: "ambiguous managed markers" };
|
|
322
|
+
if (span === null)
|
|
323
|
+
return { action: "unchanged", content: existing };
|
|
324
|
+
let start = span.start, end = span.end;
|
|
325
|
+
const metadata = existing.slice(start, end).split(/\r?\n/)[1];
|
|
326
|
+
let warning;
|
|
327
|
+
if (metadata?.startsWith(SEPARATOR_METADATA)) {
|
|
328
|
+
const match = metadata.slice(SEPARATOR_METADATA.length).match(/^((?:0a)?):((?:0a)?)$/);
|
|
329
|
+
if (!match)
|
|
330
|
+
return { action: "retained", content: existing, warning: "invalid separator provenance" };
|
|
331
|
+
const prefix = Buffer.from(match[1], "hex").toString(), suffix = Buffer.from(match[2], "hex").toString();
|
|
332
|
+
if ((prefix && existing.slice(start - prefix.length, start) !== prefix) || (suffix && existing.slice(end, end + suffix.length) !== suffix))
|
|
333
|
+
return { action: "retained", content: existing, warning: "separator provenance changed" };
|
|
334
|
+
start -= prefix.length;
|
|
335
|
+
end += suffix.length;
|
|
336
|
+
}
|
|
337
|
+
else
|
|
338
|
+
warning = "legacy block: adjacent user newlines retained";
|
|
339
|
+
const content = existing.slice(0, start) + existing.slice(end);
|
|
340
|
+
const deletable = /^\s*$/.test(content) || /^\s*#![^\r\n]*(?:\r?\n)?\s*$/.test(content);
|
|
341
|
+
return { action: deletable ? "delete" : "rewrite", content, ...(warning ? { warning } : {}) };
|
|
342
|
+
}
|
|
299
343
|
/**
|
|
300
344
|
* Insert or replace ONLY the conductor-managed block within existing hook content,
|
|
301
345
|
* preserving all surrounding user content. A binary/unsafe existing hook is left
|
|
@@ -304,7 +348,7 @@ function looksBinary(content) {
|
|
|
304
348
|
*/
|
|
305
349
|
export function mergeManagedHookSnippet(existing, managedBlock) {
|
|
306
350
|
if (existing === null || existing.length === 0) {
|
|
307
|
-
const content = `#!/bin/sh\n${managedBlock}\n`;
|
|
351
|
+
const content = `#!/bin/sh\n${withSeparatorMetadata(managedBlock, "", "\n")}\n`;
|
|
308
352
|
return { ok: true, content, action: "created" };
|
|
309
353
|
}
|
|
310
354
|
if (looksBinary(existing)) {
|
|
@@ -315,17 +359,20 @@ export function mergeManagedHookSnippet(existing, managedBlock) {
|
|
|
315
359
|
warning: "existing hook appears binary/unsafe to merge; left untouched",
|
|
316
360
|
};
|
|
317
361
|
}
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
const
|
|
362
|
+
const span = managedHookSpan(existing);
|
|
363
|
+
if (span === "unsafe")
|
|
364
|
+
return { ok: false, content: existing, action: "skipped", warning: "ambiguous managed markers; left untouched" };
|
|
365
|
+
if (span) {
|
|
366
|
+
const before = existing.slice(0, span.start);
|
|
367
|
+
const after = existing.slice(span.end);
|
|
368
|
+
const metadata = existing.slice(span.start, span.end).split(/\r?\n/)[1];
|
|
369
|
+
const replacement = metadata?.startsWith(SEPARATOR_METADATA) ? managedBlock.replace(BRIDGE_CONDUCTOR_HOOK_START, `${BRIDGE_CONDUCTOR_HOOK_START}\n${metadata}`) : managedBlock;
|
|
370
|
+
const content = `${before}${replacement}${after}`;
|
|
324
371
|
return { ok: true, content, action: "replaced" };
|
|
325
372
|
}
|
|
326
373
|
// No managed block yet — append after the user's content, preserving it.
|
|
327
374
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
328
|
-
const content = `${existing}${separator}${managedBlock}\n`;
|
|
375
|
+
const content = `${existing}${separator}${withSeparatorMetadata(managedBlock, separator, "\n")}\n`;
|
|
329
376
|
return { ok: true, content, action: "appended" };
|
|
330
377
|
}
|
|
331
378
|
/** Stable discriminator for an install that never touched the filesystem. */
|
|
@@ -377,7 +424,7 @@ const DEFAULT_PUBLICATION_FS = {
|
|
|
377
424
|
lstat: (filePath) => {
|
|
378
425
|
try {
|
|
379
426
|
const st = lstatSync(filePath);
|
|
380
|
-
return { isFile: st.isFile(), isSymlink: st.isSymbolicLink(), mode: st.mode & 0o7777 };
|
|
427
|
+
return { isFile: st.isFile(), isSymlink: st.isSymbolicLink(), mode: st.mode & 0o7777, dev: st.dev, ino: st.ino };
|
|
381
428
|
}
|
|
382
429
|
catch (err) {
|
|
383
430
|
if (err.code === "ENOENT")
|
|
@@ -385,7 +432,7 @@ const DEFAULT_PUBLICATION_FS = {
|
|
|
385
432
|
throw err;
|
|
386
433
|
}
|
|
387
434
|
},
|
|
388
|
-
readFile: (filePath) =>
|
|
435
|
+
readFile: (filePath) => new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readFileSync(filePath)),
|
|
389
436
|
};
|
|
390
437
|
/**
|
|
391
438
|
* The mode a published hook gets: the ORIGINAL mode with only the missing
|
|
@@ -489,7 +536,7 @@ export function installConductorGitHooks(deps = {}) {
|
|
|
489
536
|
refused.push({ name, path: hookPath, warning: "could not read existing hook; left untouched" });
|
|
490
537
|
continue;
|
|
491
538
|
}
|
|
492
|
-
snapshot = { content, mode: stat.mode };
|
|
539
|
+
snapshot = { content, mode: stat.mode, dev: stat.dev, ino: stat.ino };
|
|
493
540
|
}
|
|
494
541
|
const merge = mergeManagedHookSnippet(snapshot?.content ?? null, snippetForHook(name, conductorBin));
|
|
495
542
|
if (!merge.ok) {
|
|
@@ -585,6 +632,8 @@ function targetMatchesSnapshot(plan, fs) {
|
|
|
585
632
|
return false;
|
|
586
633
|
if (current.mode !== plan.snapshot.mode)
|
|
587
634
|
return false;
|
|
635
|
+
if (current.dev !== plan.snapshot.dev || current.ino !== plan.snapshot.ino)
|
|
636
|
+
return false;
|
|
588
637
|
return fs.readFile(plan.path) === plan.snapshot.content;
|
|
589
638
|
}
|
|
590
639
|
function publishPlannedHook(plan, hooksDir, fs, platform) {
|
|
@@ -771,12 +820,20 @@ export function inspectConductorGitHooks(deps = {}) {
|
|
|
771
820
|
const hooks = [];
|
|
772
821
|
for (const name of MANAGED_HOOK_NAMES) {
|
|
773
822
|
const hookPath = resolve(hooks_dir, name);
|
|
774
|
-
|
|
823
|
+
let exists = false;
|
|
824
|
+
let existenceUnknown = false;
|
|
825
|
+
try {
|
|
826
|
+
lstatSync(hookPath);
|
|
827
|
+
exists = true;
|
|
828
|
+
}
|
|
829
|
+
catch (error) {
|
|
830
|
+
existenceUnknown = error.code !== "ENOENT";
|
|
831
|
+
}
|
|
775
832
|
let executable = false;
|
|
776
833
|
let managedPresent = false;
|
|
777
834
|
let embeddedBinPath = null;
|
|
778
835
|
let embeddedBinIsFile = false;
|
|
779
|
-
let state = "not-installed";
|
|
836
|
+
let state = existenceUnknown ? "unknown" : "not-installed";
|
|
780
837
|
if (exists) {
|
|
781
838
|
try {
|
|
782
839
|
const mode = statSync(hookPath).mode;
|
|
@@ -787,7 +844,12 @@ export function inspectConductorGitHooks(deps = {}) {
|
|
|
787
844
|
}
|
|
788
845
|
state = "no-managed-block";
|
|
789
846
|
try {
|
|
790
|
-
const
|
|
847
|
+
const stat = lstatSync(hookPath);
|
|
848
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1024 * 1024)
|
|
849
|
+
throw new Error("unsafe");
|
|
850
|
+
const content = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readFileSync(hookPath));
|
|
851
|
+
if (looksBinary(content) || managedHookSpan(content) === "unsafe")
|
|
852
|
+
throw new Error("unsafe");
|
|
791
853
|
managedPresent = content.includes(BRIDGE_CONDUCTOR_HOOK_START);
|
|
792
854
|
if (managedPresent) {
|
|
793
855
|
// BAPI-772: a managed block is not enough — the block written by an
|
|
@@ -801,7 +863,10 @@ export function inspectConductorGitHooks(deps = {}) {
|
|
|
801
863
|
embeddedBinPath !== null &&
|
|
802
864
|
basename(embeddedBinPath) === CONDUCTOR_BIN_FILENAME &&
|
|
803
865
|
defaultIsFile(embeddedBinPath);
|
|
804
|
-
if (
|
|
866
|
+
if (deps.presenceOnly) {
|
|
867
|
+
state = "unrecognized";
|
|
868
|
+
}
|
|
869
|
+
else if (embeddedBinPath === null) {
|
|
805
870
|
state = "unrecognized";
|
|
806
871
|
}
|
|
807
872
|
else {
|
|
@@ -825,6 +890,7 @@ export function inspectConductorGitHooks(deps = {}) {
|
|
|
825
890
|
exists,
|
|
826
891
|
executable,
|
|
827
892
|
managed_block_present: managedPresent,
|
|
893
|
+
managed_block_observation: state === "unknown" ? "unknown" : managedPresent ? "present" : "absent",
|
|
828
894
|
embedded_bin_path: embeddedBinPath,
|
|
829
895
|
embedded_bin_is_file: embeddedBinIsFile,
|
|
830
896
|
recognized_command: embeddedBinPath !== null,
|
|
@@ -35,6 +35,7 @@ export const GUIDED_REPAIR_VERBS = [
|
|
|
35
35
|
// BAPI-1388 — ticket-addressed, pinned to the same version-and-head subject as
|
|
36
36
|
// `dispatch-remediation`, and consuming the binding ExplainRun renders.
|
|
37
37
|
"rerun-ci",
|
|
38
|
+
"adopt-current-head-and-unpark",
|
|
38
39
|
];
|
|
39
40
|
/** A malformed or mismatched binding. The message never echoes the token. */
|
|
40
41
|
export class GuidedBindingError extends Error {
|
|
@@ -61,6 +62,7 @@ const ALLOWED_KEYS = {
|
|
|
61
62
|
"scope-catch-up": ["scope_id", "lifecycle_state", "required_commit_sha"],
|
|
62
63
|
"dispatch-remediation": ["ticket_key", "expected_row_version", "expected_head_sha"],
|
|
63
64
|
"rerun-ci": ["ticket_key", "expected_row_version", "expected_head_sha"],
|
|
65
|
+
"adopt-current-head-and-unpark": ["ticket_key", "expected_row_version", "external_repair_operation_id"],
|
|
64
66
|
};
|
|
65
67
|
function invalid() {
|
|
66
68
|
return new GuidedBindingError("--binding is not a valid guided-repair binding; nothing was sent. Copy the " +
|
|
@@ -152,10 +154,16 @@ export function decodeGuidedBinding(token) {
|
|
|
152
154
|
throw invalid();
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
|
-
else if (guidedVerb === "dispatch-remediation" || guidedVerb === "rerun-ci") {
|
|
157
|
+
else if (guidedVerb === "dispatch-remediation" || guidedVerb === "rerun-ci" || guidedVerb === "adopt-current-head-and-unpark") {
|
|
156
158
|
binding.ticketKey = boundedString(raw.ticket_key, 64);
|
|
157
159
|
binding.expectedRowVersion = nonNegativeInt(raw.expected_row_version);
|
|
158
160
|
binding.expectedHeadSha = optionalSha(raw.expected_head_sha);
|
|
161
|
+
if (guidedVerb === "adopt-current-head-and-unpark") {
|
|
162
|
+
const operation = boundedString(raw.external_repair_operation_id, 128);
|
|
163
|
+
if (!/^[A-Za-z0-9._:-]+$/.test(operation))
|
|
164
|
+
throw invalid();
|
|
165
|
+
binding.externalRepairOperationId = operation;
|
|
166
|
+
}
|
|
159
167
|
}
|
|
160
168
|
else {
|
|
161
169
|
binding.scopeId = boundedString(raw.scope_id, 200);
|
|
@@ -181,6 +189,7 @@ export function bindingIdentity(binding) {
|
|
|
181
189
|
["required_commit_sha", binding.requiredCommitSha],
|
|
182
190
|
["ticket_key", binding.ticketKey],
|
|
183
191
|
["expected_row_version", binding.expectedRowVersion],
|
|
192
|
+
["external_repair_operation_id", binding.externalRepairOperationId],
|
|
184
193
|
["expected_head_sha", binding.expectedHeadSha],
|
|
185
194
|
];
|
|
186
195
|
for (const [key, value] of pairs) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* doctor reports about it.
|
|
19
19
|
*
|
|
20
20
|
* BAPI-775 adds three more named sections for the LOCAL conductor capabilities
|
|
21
|
-
* `install
|
|
21
|
+
* `install epic-implementer` can now provision: host MCP profile-token presence,
|
|
22
22
|
* managed hook-target usability, and native ledger loadability. All three are
|
|
23
23
|
* DERIVED — from the shared read-only host-config inspector and from the legacy
|
|
24
24
|
* conductor report already composed above — so none of them re-probes anything
|
|
@@ -129,9 +129,7 @@ export async function runConductorInstallDoctor(deps) {
|
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
try {
|
|
132
|
-
readiness = deps.epicRunId
|
|
133
|
-
? await fetchConductorReadiness(deps.access, deps.fetch, { epicRunId: deps.epicRunId })
|
|
134
|
-
: await fetchConductorReadiness(deps.access, deps.fetch);
|
|
132
|
+
readiness = await fetchConductorReadiness(deps.access, deps.fetch, { epicRunId: deps.epicRunId, assessmentVersion: deps.assessmentVersion });
|
|
135
133
|
}
|
|
136
134
|
catch (err) {
|
|
137
135
|
const kind = err instanceof ConductorBridgeApiError ? err.kind : "network";
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BAPI-1506 — read-only launch-need probes for the `drive-epic` create preview.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* repository's required checks has an online runner
|
|
6
|
-
* branch
|
|
7
|
-
* every subprocess has a bounded
|
|
8
|
-
*
|
|
4
|
+
* One probe lives here: whether every self-hosted label set behind the
|
|
5
|
+
* repository's required checks has an online runner. (BAPI-1596 removed the
|
|
6
|
+
* epic-branch-behind-base probe: a launch neither runs nor shows it.) It is a
|
|
7
|
+
* bookkeeping read (design principle 5): every subprocess has a bounded
|
|
8
|
+
* timeout, and every failure, timeout, missing tool, or unreadable output
|
|
9
|
+
* becomes `unverifiable`. Nothing here can refuse a
|
|
9
10
|
* launch, and nothing from a subprocess, a workflow file, or a path reaches the
|
|
10
11
|
* returned facts — only closed classifications and bounded counts.
|
|
11
12
|
*/
|
|
12
13
|
import path from "node:path";
|
|
13
14
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
14
|
-
import { validateBranchName } from "../base-ref.js";
|
|
15
15
|
import { PLANE_FRESHNESS_TIMEOUT_MS } from "../plane/plane-freshness.js";
|
|
16
16
|
/** One deadline for the whole runner probe, however many pages it reads. */
|
|
17
17
|
export const LAUNCH_RUNNER_PROBE_DEADLINE_MS = PLANE_FRESHNESS_TIMEOUT_MS;
|
|
18
|
-
/** Bound on each git read the behind-base probe runs. */
|
|
19
|
-
export const LAUNCH_BRANCH_PROBE_TIMEOUT_MS = PLANE_FRESHNESS_TIMEOUT_MS;
|
|
20
18
|
const RUNNER_PAGE_SIZE = 100;
|
|
21
19
|
const RUNNER_MAX_PAGES = 10;
|
|
22
20
|
const WORKFLOW_MAX_FILES = 200;
|
|
@@ -295,48 +293,3 @@ async function probeRunners(input) {
|
|
|
295
293
|
? { state: "present", unsatisfied_label_sets: unsatisfied, label_sets: labelSets.size }
|
|
296
294
|
: { state: "absent", label_sets: labelSets.size };
|
|
297
295
|
}
|
|
298
|
-
/**
|
|
299
|
-
* How many commits `origin/<branch>` is behind `origin/<base>`. Information
|
|
300
|
-
* only: integration's `sync_base` merges the base into the epic branch. Uses
|
|
301
|
-
* the remote-tracking refs the preview already has; it fetches nothing.
|
|
302
|
-
* NEVER throws.
|
|
303
|
-
*/
|
|
304
|
-
export async function inspectEpicBranchBehindBase(input) {
|
|
305
|
-
try {
|
|
306
|
-
const { branch, baseBranch } = input;
|
|
307
|
-
if (branch === null || branch === "")
|
|
308
|
-
return { state: "not_applicable", reason: "no_epic_branch" };
|
|
309
|
-
if (baseBranch === null || baseBranch === "")
|
|
310
|
-
return { state: "unverifiable", reason: "no_base_branch" };
|
|
311
|
-
if (validateBranchName(branch) !== null || validateBranchName(baseBranch) !== null) {
|
|
312
|
-
return { state: "unverifiable", reason: "invalid_branch_name" };
|
|
313
|
-
}
|
|
314
|
-
if (branch === baseBranch)
|
|
315
|
-
return { state: "not_applicable", reason: "no_epic_branch" };
|
|
316
|
-
const git = (args) => input.execFile("git", args, {
|
|
317
|
-
cwd: input.repoRoot,
|
|
318
|
-
timeoutMs: LAUNCH_BRANCH_PROBE_TIMEOUT_MS,
|
|
319
|
-
env: { GIT_TERMINAL_PROMPT: "0" },
|
|
320
|
-
});
|
|
321
|
-
// `for-each-ref` exits 0 with no output for a ref that does not exist, so a
|
|
322
|
-
// missing branch is told apart from a git failure.
|
|
323
|
-
const ref = `refs/remotes/origin/${branch}`;
|
|
324
|
-
const listed = await git(["for-each-ref", "--format=%(refname)", ref]);
|
|
325
|
-
if (!listed.ok)
|
|
326
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
327
|
-
if (!listed.stdout.split(/\r?\n/).some((line) => line.trim() === ref)) {
|
|
328
|
-
return { state: "not_applicable", reason: "branch_not_on_origin" };
|
|
329
|
-
}
|
|
330
|
-
const counted = await git(["rev-list", "--count", `refs/remotes/origin/${branch}..refs/remotes/origin/${baseBranch}`]);
|
|
331
|
-
if (!counted.ok)
|
|
332
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
333
|
-
const text = counted.stdout.trim();
|
|
334
|
-
if (!/^\d{1,9}$/.test(text))
|
|
335
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
336
|
-
const behind = Number.parseInt(text, 10);
|
|
337
|
-
return behind === 0 ? { state: "absent" } : { state: "present", behind };
|
|
338
|
-
}
|
|
339
|
-
catch {
|
|
340
|
-
return { state: "unverifiable", reason: "git_failed" };
|
|
341
|
-
}
|
|
342
|
-
}
|