mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
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:
committed by
GitHub
parent
66fe424590
commit
b080dd1e76
@@ -11,6 +11,7 @@ import {
|
||||
type RetainedMemoryMetrics,
|
||||
type WorkerResult,
|
||||
} from "./bench-task-registry-sqlite.js";
|
||||
import { classifyBoundedUnsignedDecimal } from "./lib/arg-utils.mts";
|
||||
|
||||
type WorkerOptions = {
|
||||
size: number;
|
||||
@@ -44,14 +45,14 @@ type TaskRegistryQueryApi = Pick<
|
||||
>;
|
||||
|
||||
function parseInteger(raw: string | undefined, flag: string, min: number, max: number): number {
|
||||
if (!raw || !/^\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 || value > max) {
|
||||
if (result.kind !== "value") {
|
||||
throw new Error(`${flag} must be between ${min} and ${max}`);
|
||||
}
|
||||
return value;
|
||||
return result.value;
|
||||
}
|
||||
|
||||
function parseOptions(argv: string[]): WorkerOptions {
|
||||
|
||||
Reference in New Issue
Block a user