fix: observe code queue execution plane via tran

This commit is contained in:
Codex
2026-05-26 00:35:54 +00:00
parent 8af5aafb9e
commit 273fad7c24
4 changed files with 32 additions and 10 deletions
+20 -7
View File
@@ -248,6 +248,13 @@ function commandProbe(result: CommandResult): ProbeResult {
};
}
function runTran(args: string[], options: ExecutionPlaneOptions, timeoutMs = options.timeoutMs): ProbeResult {
return commandProbe(runCommand(["./scripts/tran", ...args], repoRoot, {
timeoutMs,
env: process.env,
}));
}
function safeError(probe: ProbeResult): string | null {
if (probe.ok) return null;
const text = firstLine(probe.stderr) ?? firstLine(probe.stdout);
@@ -255,10 +262,7 @@ function safeError(probe: ProbeResult): string | null {
}
function runKubectl(args: string[], options: ExecutionPlaneOptions): ProbeResult {
return commandProbe(runCommand(["kubectl", ...args], repoRoot, {
timeoutMs: options.timeoutMs,
env: { ...process.env, KUBECONFIG: options.kubeconfig },
}));
return runTran(["D601:k3s", "kubectl", ...args], options);
}
function collectGuard(options: ExecutionPlaneOptions): { guard: D601K3sGuardClassification; diagnostics: Record<string, unknown> } {
@@ -436,7 +440,7 @@ function collectServices(options: ExecutionPlaneOptions): ServiceObservation[] {
}
function collectWorktree(options: ExecutionPlaneOptions): WorktreeObservation {
const probe = commandProbe(runCommand(["git", "-C", options.worktreePath, "rev-parse", "HEAD"], repoRoot, { timeoutMs: 5_000 }));
const probe = runTran([`D601:${options.worktreePath}`, "argv", "git", "rev-parse", "HEAD"], options, 10_000);
return {
path: options.worktreePath,
ok: probe.ok,
@@ -446,7 +450,16 @@ function collectWorktree(options: ExecutionPlaneOptions): WorktreeObservation {
}
function collectResidual(): ResidualObservation {
const docker = commandProbe(runCommand(["docker", "ps", "-a", "--filter", "name=code-queue-backend", "--format", "{{.Names}}\t{{.Status}}\t{{.Image}}"], repoRoot, { timeoutMs: 8_000 }));
const remoteOptions: ExecutionPlaneOptions = {
namespace: expectedNamespace,
kubeconfig: d601NativeKubeconfig,
worktreePath: expectedWorktreePath,
full: false,
raw: false,
skipProbe: true,
timeoutMs: 15_000,
};
const docker = runTran(["D601", "argv", "docker", "ps", "-a", "--filter", "name=code-queue-backend", "--format", "{{.Names}}\t{{.Status}}\t{{.Image}}"], remoteOptions, 15_000);
const containers = docker.ok
? lines(docker.stdout).map((line) => {
const fields = line.split("\t");
@@ -454,7 +467,7 @@ function collectResidual(): ResidualObservation {
}).filter((item) => item.name === "code-queue-backend" || item.name.includes("code-queue-backend"))
: [];
const ss = commandProbe(runCommand(["ss", "-H", "-ltnp"], repoRoot, { timeoutMs: 8_000 }));
const ss = runTran(["D601", "argv", "ss", "-H", "-ltnp"], remoteOptions, 15_000);
const listeners = ss.ok
? (lines(ss.stdout)
.filter((line) => line.includes(":4222"))