

























@@ -1,11 +1,14 @@
11#!/usr/bin/env node
2+// Runs additional architecture and boundary checks with sharding, concurrency,
3+// timeout handling, and grouped CI output.
24import { spawn } from "node:child_process";
35import { performance } from "node:perf_hooks";
4657const DEFAULT_CHECK_TIMEOUT_MS = 10 * 60 * 1000;
68const DEFAULT_OUTPUT_MAX_BYTES = 512 * 1024;
79const TIMEOUT_KILL_GRACE_MS = 5_000;
81011+/** Ordered list of supplemental boundary checks used by CI sharding. */
912export const BOUNDARY_CHECKS = [
1013["prompt:snapshots:check", "pnpm", ["prompt:snapshots:check"]],
1114["plugin-extension-boundary", "pnpm", ["run", "lint:plugins:no-extension-imports"]],
@@ -66,10 +69,16 @@ export const BOUNDARY_CHECKS = [
6669["lint:ui:no-raw-window-open", "pnpm", ["lint:ui:no-raw-window-open"]],
6770].map(([label, command, args]) => ({ label, command, args }));
687172+/**
73+ * Resolves the configured boundary-check concurrency.
74+ */
6975export function resolveConcurrency(value, fallback = 4, label = "concurrency") {
7076return resolvePositiveInteger(value, fallback, label);
7177}
727879+/**
80+ * Parses positive integer CLI/env options with a fallback.
81+ */
7382export function resolvePositiveInteger(value, fallback, label = "value") {
7483if (value === undefined || value === null || value === "") {
7584return fallback;
@@ -85,6 +94,9 @@ export function resolvePositiveInteger(value, fallback, label = "value") {
8594return parsed;
8695}
879697+/**
98+ * Parses one N/TOTAL shard selector into zero-based index form.
99+ */
88100export function parseShardSpec(value) {
89101if (!value) {
90102return null;
@@ -107,6 +119,9 @@ export function parseShardSpec(value) {
107119return { count, index: index - 1, label: `${index}/${count}` };
108120}
109121122+/**
123+ * Parses a comma-separated list of N/TOTAL shard selectors.
124+ */
110125export function parseShardSelection(value) {
111126if (!value) {
112127return null;
@@ -124,6 +139,9 @@ export function parseShardSelection(value) {
124139});
125140}
126141142+/**
143+ * Selects checks whose ordinal belongs to the requested shard set.
144+ */
127145export function selectChecksForShard(checks, shardSpec) {
128146const shards =
129147typeof shardSpec === "string"
@@ -141,10 +159,16 @@ export function selectChecksForShard(checks, shardSpec) {
141159);
142160}
143161162+/**
163+ * Formats a check command for CI group output.
164+ */
144165export function formatCommand({ command, args }) {
145166return [command, ...args].join(" ");
146167}
147168169+/**
170+ * Keeps only the tail of noisy check output so failure logs stay bounded.
171+ */
148172export function createBoundedOutputBuffer(maxBytes = DEFAULT_OUTPUT_MAX_BYTES) {
149173const limit = Math.max(1, maxBytes);
150174const chunks = [];
@@ -247,6 +271,9 @@ function installActiveChildCleanup(activeChildren) {
247271};
248272}
249273274+/**
275+ * Runs one boundary check with timeout and process-group termination.
276+ */
250277export function runSingleCheck(
251278check,
252279{
@@ -359,6 +386,9 @@ function writeTimingSummary(results, output) {
359386}
360387}
361388389+/**
390+ * Runs boundary checks with bounded concurrency and returns the failure count.
391+ */
362392export async function runChecks(
363393checks = BOUNDARY_CHECKS,
364394{
@@ -442,11 +472,7 @@ if (import.meta.url === `file://${process.argv[1]}`) {
442472process.env.OPENCLAW_ADDITIONAL_BOUNDARY_CONCURRENCY === undefined
443473 ? "OPENCLAW_EXTENSION_BOUNDARY_CONCURRENCY"
444474 : "OPENCLAW_ADDITIONAL_BOUNDARY_CONCURRENCY";
445-const concurrency = resolveConcurrency(
446-concurrencyRaw,
447-4,
448-concurrencyLabel,
449-);
475+const concurrency = resolveConcurrency(concurrencyRaw, 4, concurrencyLabel);
450476const checkTimeoutMs = resolvePositiveInteger(
451477process.env.OPENCLAW_ADDITIONAL_BOUNDARY_TIMEOUT_MS,
452478DEFAULT_CHECK_TIMEOUT_MS,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。