refactor(tools): remove remaining arbitrary workflow caps

This commit is contained in:
morluto
2026-09-29 17:00:06 +08:00
parent 4ad937c6ca
commit ecf3ed8bdb
43 changed files with 230 additions and 393 deletions
+2 -5
View File
@@ -5,14 +5,11 @@ import {
import type { ProviderProcessDiagnostic } from "../process/ProviderProcess.js";
import { parseLinuxPrivateDisplayDiagnostic } from "./LinuxPrivateDisplayDiagnostic.js";
/** Extract only a matching, versioned Linux adapter failure record. */
/** Extract only a matching Linux adapter failure record. */
export const hopperLauncherFailureDiagnostic = (
event: Extract<ProviderProcessDiagnostic, { readonly type: "exit" }>,
): HopperStartupFailureDiagnostic | undefined => {
const parsed = parseLinuxPrivateDisplayDiagnostic(
event.snapshot.stderr.text,
event.snapshot.stderr.truncated,
);
const parsed = parseLinuxPrivateDisplayDiagnostic(event.snapshot.stderr.text);
if (!parsed.ok) return undefined;
const expected = hopperStartupFailure(event.code)?.code;
return parsed.value.operation === "launch" &&
+11 -22
View File
@@ -5,15 +5,12 @@ import {
type HopperStartupDiagnostic,
} from "../domain/hopperStartupFailure.js";
export const LINUX_PRIVATE_DISPLAY_DIAGNOSTIC_PREFIX = "REA_X11_DIAGNOSTIC_V1=";
export const LINUX_PRIVATE_DISPLAY_DIAGNOSTIC_PREFIX = "REA_X11_DIAGNOSTIC=";
const diagnosticContextSchema = z.object({
component: z.literal("hopper_private_display"),
operation: z.enum(["probe", "launch"]),
reason: z
.string()
.regex(/^[a-z0-9_]+$/u)
.max(64),
reason: z.string().regex(/^[a-z0-9_]+$/u),
socket_directory: z.literal("/tmp/.X11-unix"),
socket_directory_mode: z
.string()
@@ -30,23 +27,18 @@ const diagnosticContextSchema = z.object({
fallback_reason: z
.string()
.regex(/^[a-z0-9_]+$/u)
.max(64)
.nullable(),
xvfb_stderr_bytes: z.number().int().nonnegative().safe(),
xvfb_stderr_truncated: z.boolean(),
});
const failureCodeSchema = z
.string()
.max(64)
.transform((value, context) => {
if (isHopperStartupFailureCode(value)) return value;
context.addIssue({
code: "custom",
message: "Unknown startup failure code",
});
return z.NEVER;
const failureCodeSchema = z.string().transform((value, context) => {
if (isHopperStartupFailureCode(value)) return value;
context.addIssue({
code: "custom",
message: "Unknown startup failure code",
});
return z.NEVER;
});
const diagnosticSchema = z.discriminatedUnion("status", [
diagnosticContextSchema
@@ -64,16 +56,13 @@ export type LinuxPrivateDisplayDiagnosticParse =
readonly reason:
| "diagnostic_missing"
| "diagnostic_multiple"
| "diagnostic_malformed"
| "diagnostic_truncated";
| "diagnostic_malformed";
};
/** Parse exactly one bounded, versioned helper diagnostic from stderr. */
/** Parse exactly one helper diagnostic from stderr. */
export const parseLinuxPrivateDisplayDiagnostic = (
stderr: string,
truncated: boolean,
): LinuxPrivateDisplayDiagnosticParse => {
if (truncated) return { ok: false, reason: "diagnostic_truncated" };
const records = stderr
.split("\n")
.filter((line) => line.startsWith(LINUX_PRIVATE_DISPLAY_DIAGNOSTIC_PREFIX));
+3 -14
View File
@@ -19,7 +19,6 @@ import { parseLinuxPrivateDisplayDiagnostic } from "./LinuxPrivateDisplayDiagnos
const PYTHON_PATH = "/usr/bin/python3";
const UNSHARE_PATH = "/usr/bin/unshare";
const DEFAULT_PROBE_TIMEOUT_MS = 5_000;
const PROBE_OUTPUT_LIMIT_BYTES = 64 * 1024;
export type LinuxPrivateDisplayRunnableStrategy = Exclude<
HopperPrivateDisplayStrategy,
@@ -31,7 +30,6 @@ export interface LinuxPrivateDisplayProbeProcessResult {
readonly exitCode: number | null | undefined;
readonly stderr: string;
readonly stderrBytes: number;
readonly stderrTruncated: boolean;
readonly cleanupIncomplete: boolean;
}
@@ -87,7 +85,6 @@ export const selectLinuxPrivateDisplayStrategy = async (options: {
isolated.diagnostic.effective_socket_directory_mode,
effective_mount_read_only: isolated.diagnostic.effective_mount_read_only,
xvfb_stderr_bytes: isolated.diagnostic.xvfb_stderr_bytes,
xvfb_stderr_truncated: isolated.diagnostic.xvfb_stderr_truncated,
});
return {
ok: true,
@@ -101,7 +98,7 @@ export const selectLinuxPrivateDisplayStrategy = async (options: {
};
};
/** Run one helper probe in an owned process group with a hard output bound. */
/** Run one helper probe in an owned process group and retain its full diagnostics. */
export const runLinuxPrivateDisplayProbe: LinuxPrivateDisplayProbeRunner =
async (strategy, options) => {
if (options.signal?.aborted === true)
@@ -123,9 +120,7 @@ export const runLinuxPrivateDisplayProbe: LinuxPrivateDisplayProbeRunner =
ownsProcessLifetime: true,
cleanup: () => cleanupOwnedProcessGroup(started.ownership),
};
const supervisor = new ProviderProcessSupervisor(launch, {
maxOutputBytesPerStream: PROBE_OUTPUT_LIMIT_BYTES,
});
const supervisor = new ProviderProcessSupervisor(launch);
const outcome = await waitForProbeExit(
supervisor,
options.timeoutMs,
@@ -147,7 +142,6 @@ export const runLinuxPrivateDisplayProbe: LinuxPrivateDisplayProbeRunner =
exitCode: snapshot.exitCode,
stderr: snapshot.stderr.text,
stderrBytes: snapshot.stderr.bytes,
stderrTruncated: snapshot.stderr.truncated,
cleanupIncomplete,
};
};
@@ -230,10 +224,7 @@ const evaluatedProbe = async (
ok: false,
diagnostic: syntheticDiagnostic(strategy, "cleanup_incomplete"),
};
const parsed = parseLinuxPrivateDisplayDiagnostic(
processResult.stderr,
processResult.stderrTruncated,
);
const parsed = parseLinuxPrivateDisplayDiagnostic(processResult.stderr);
if (!parsed.ok)
return {
ok: false,
@@ -281,7 +272,6 @@ const syntheticDiagnostic = (
strategy,
fallback_reason: null,
xvfb_stderr_bytes: 0,
xvfb_stderr_truncated: false,
});
const unavailable = (
@@ -303,7 +293,6 @@ const emptyProcessResult = (
exitCode: undefined,
stderr: "",
stderrBytes: 0,
stderrTruncated: false,
cleanupIncomplete: false,
});
+3 -3
View File
@@ -7,7 +7,7 @@ import { err, ok, type Result } from "../domain/result.js";
const remoteErrorSchema = z
.object({
code: z.number().int(),
message: z.string().max(512),
message: z.string(),
type: z
.enum([
"remote",
@@ -42,10 +42,10 @@ const eventSchema = z
z
.object({
type: z.literal("progress"),
phase: z.string().min(1).max(64),
phase: z.string().min(1),
completed: z.number().nonnegative().finite(),
total: z.number().nonnegative().finite().nullable(),
message: z.string().min(1).max(512),
message: z.string().min(1),
terminal: z.boolean().optional(),
})
.strict(),