refactor: consolidate coercion contracts (#122458)

* refactor: consolidate coercion contracts

Centralize exact string, record, numeric, date, Boolean, argument, and structured-error coercions while preserving call-site semantics.

Migrate canonical-name collisions and deprecated internal SDK bypasses, deleting 55 net production/tooling lines. Expand declaration ownership enforcement to 101 allowed helpers and add a narrow export-completeness audit.

* fix: preserve standalone script coercions

Keep copied Control UI tooling self-contained and retain the trusted release harness module-relative source seam when the harness runs against an old target cwd.
This commit is contained in:
Peter Steinberger
2026-08-11 23:26:37 -07:00
committed by GitHub
parent 66fe424590
commit b080dd1e76
276 changed files with 1685 additions and 1663 deletions
+6 -5
View File
@@ -4,6 +4,7 @@ import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { isRecord } from "@openclaw/normalization-core/record-coerce";
import { classifyBoundedUnsignedDecimal } from "./lib/arg-utils.mts";
const DEFAULT_SIZES = [24, 64, 128];
const WORKER_TIMEOUT_MS = 300_000;
@@ -127,17 +128,17 @@ Options:
}
function parseInteger(raw: string, flag: string, min: number, max: number): number {
if (!/^\d+$/u.test(raw)) {
const result = classifyBoundedUnsignedDecimal(raw, min, max);
if (result.kind === "syntax") {
throw new Error(`${flag} must be an integer`);
}
const value = Number(raw);
if (value < min) {
if (result.kind === "below") {
throw new Error(`${flag} must be at least ${min}`);
}
if (value > max) {
if (result.kind === "above") {
throw new Error(`${flag} must be at most ${max}`);
}
return value;
return result.value;
}
function parseList(raw: string, flag: string): number[] {