perf(mantis): build proof lanes runtime-only (#128007)

The proof gateways execute runtime JS only; declarations forced a ~177s
unified rebuild per lane because the declaration cache key is an
aggregate source hash. OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 on profile
full now selects the runtime artifact surface via the uncached generic
tsdown graph, both Mantis lanes pass it through, and the baseline
archive moves to an isolated mantis-runtime-v1 namespace. Measured
candidate build: 177.1s -> 33.05s.
This commit is contained in:
Ayaan Zaidi
2026-08-23 00:15:24 +05:30
committed by GitHub
parent 7d18cc4ccb
commit 2eecf3d3f2
5 changed files with 86 additions and 34 deletions
+31 -4
View File
@@ -63,6 +63,7 @@ type BuildAllStepParams = {
};
type BuildAllCacheParams = { rootDir?: string; fs?: BuildAllFs; env?: NodeJS.ProcessEnv };
const BUILD_CACHE_VERSION = 4;
const RUN_NODE_SKIP_DTS_BUILD_ENV = "OPENCLAW_RUN_NODE_SKIP_DTS_BUILD";
const TSDOWN_DECLARATION_EXTENSIONS = [".d.ts", ".d.mts", ".d.cts"];
const TSDOWN_SOURCE_EXTENSIONS = [
".cjs",
@@ -362,8 +363,25 @@ export const BUILD_ALL_PROFILES: Record<string, string[]> = {
],
};
const FULL_RUNTIME_ONLY_STEPS = [
"plugins:assets:build",
"tsdown",
"external-plugins:local-dist",
"check-cli-bootstrap-imports",
"plugins:assets:copy",
"runtime-postbuild",
"build-stamp",
"runtime-postbuild-stamp",
"ui:build",
"write-build-info",
"write-cli-startup-metadata",
];
export const BUILD_ALL_PROFILE_STEP_ENV: Record<string, Record<string, NodeJS.ProcessEnv>> = {
full: {
tsdown: {
OPENCLAW_PRESERVE_CLI_STARTUP_METADATA: "1",
},
"tsdown-unified": {
OPENCLAW_PRESERVE_CLI_STARTUP_METADATA: "1",
},
@@ -449,11 +467,20 @@ export function parseBuildAllArgs(argv: string[]) {
return args;
}
export function resolveBuildAllSteps(profile = "full"): BuildAllStep[] {
const labels = BUILD_ALL_PROFILES[profile];
if (!labels) {
export function resolveBuildAllSteps(
profile = "full",
buildEnv: NodeJS.ProcessEnv = process.env,
): BuildAllStep[] {
const profileLabels = BUILD_ALL_PROFILES[profile];
if (!profileLabels) {
throw new Error(`Unknown build profile: ${profile}`);
}
// A cold runtime-only build has no declarations for the canonical SDK gates.
// Keep the full runtime artifact surface, but use the uncached runtime graph.
const labels =
profile === "full" && buildEnv[RUN_NODE_SKIP_DTS_BUILD_ENV] === "1"
? FULL_RUNTIME_ONLY_STEPS
: profileLabels;
const selected = labels.map((label) => BUILD_ALL_STEPS.find((step) => step.label === label));
if (selected.some((step) => !step)) {
const missing = labels.filter((label) => !BUILD_ALL_STEPS.some((step) => step.label === label));
@@ -950,7 +977,7 @@ if (isMainModule()) {
const buildEnv = resolveBuildAllEnvironment();
const timings: BuildAllTiming[] = [];
let exitCode = 0;
for (const step of resolveBuildAllSteps(args.profile)) {
for (const step of resolveBuildAllSteps(args.profile, buildEnv)) {
const startedAt = performance.now();
const cacheState = resolveBuildAllStepCacheState(step, { env: buildEnv });
let stepToRun = step;
+1 -1
View File
@@ -605,7 +605,7 @@ readonly build_command='
}
trap cleanup EXIT INT TERM
corepack pnpm install --frozen-lockfile --store-dir "$store"
corepack pnpm build
OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 corepack pnpm build
'
run_network_probe() {