mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
fix(scripts): reject inherited tsgo profile graph names
## What Problem This Solves
`pnpm tsgo:profile constructor` treated an inherited object property as a configured graph, created artifact directories, and failed with an unrelated TypeError.
## User Impact
Inherited names now receive the existing `Unknown graph` diagnostic before artifacts or compiler work. Valid graph names, flags, and output remain unchanged.
## Why This Change Was Made
Require an own property in the graph registry instead of accepting JavaScript's prototype chain.
## Evidence
- Blacksmith Testbox `tbx_01m3v0m906fej4qb20j8wy64gd`: the CLI regression fails on the original source with the misleading profiling/error output, then passes with the fix. It exercises the supported CLI preload and verifies exit 1, the existing diagnostic, no stdout, no artifacts, and no compiler launch.
- Single-worker regression suite wall time: 1.63s. One CLI process is necessary to cover admission before the private parser's side effects; there is no production test hook, timer, sleep, or polling.
- Changed checks and SDK surface passed. Madge and runtime import-cycle checks both reported zero.
- Independent isolated Codex review completed with no P0–P2 findings.
No configuration option, schema, dependency, or protocol change.
### Hosted CI evidence
Exact-head run https://github.com/openclaw/openclaw/actions/runs/36825865133 failed `check-lint-core-1` and `check-lint-core-2`; fail-fast cancelled sibling coverage. Security checks and independent review passed. Cancelled checks remain incomplete, not green.
All twenty root diagnostics have independent executed CI witnesses. Nineteen match current unrelated PR CI: core-1 in https://github.com/openclaw/openclaw/actions/runs/36823091648 (head `488d5300b95fa56568284d014f43c44d3fdc2143`), and core-2 in https://github.com/openclaw/openclaw/actions/runs/36822965519 (head `2ca2ff4326be38e6c890f2c80dddb03c84e06c79`). The remaining `update-candidate-canary.test.ts` failure is independently witnessed by scheduled main run https://github.com/openclaw/openclaw/actions/runs/36827062752, head `867a82ce61`, job `check-lint-core-5` (`110255224713`): `File has too many lines (1006). Maximum allowed is 1000.` The executed job annotation names the same file at line 1035. All root failures therefore qualify for the explicitly approved inherited-failure exception; cancelled coverage remains incomplete. This PR changes only the profile CLI and its own regression; none of the listed core files or their lint configuration is changed.
| File | Rule | Diagnostic |
| --- | --- | --- |
| `src/skills/library/store.ts` | `typescript(no-redundant-type-constituents)` | 'StateDatabase' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/agents/harness/native-hook-relay-store.kernel.ts` | `typescript(no-redundant-type-constituents)` | 'OpenClawStateKyselyDatabase' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication-store.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-personal-publication-store.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication-recovery.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-repository-publication-store.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-repository-publication.kernel.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication-coordinator-methods.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-repository-publication-recovery.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication-personal-pending.test.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/gateway/github-publication-shared-read.kernel.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/proxy-capture/store.kernel.ts` | `typescript(no-redundant-type-constituents)` | 'OpenClawStateKyselyDatabase' is an 'error' type that acts as 'any' and overrides all other types in this intersection type. |
| `src/channels/message/ingress-queue.test.ts` | `typescript(no-unnecessary-type-parameters)` | Type parameter TColumn is used only once in the function signature. |
| `src/config/sessions/session-transcript-projection-rebuild.ts` | `typescript(no-redundant-type-constituents)` | 'OpenClawAgentKyselyDatabase' is an 'error' type that acts as 'any' and overrides all other types in this intersection type. |
| `src/state/openclaw-state-read.types.ts` | `typescript(no-redundant-type-constituents)` | 'DB' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/infra/update-candidate-canary.test.ts` | `eslint(max-lines)` | File has too many lines (1006). |
| `src/infra/delivery-queue-sqlite.ts` | `typescript(no-redundant-type-constituents)` | 'OpenClawStateKyselyDatabase' is an 'error' type that acts as 'any' and overrides all other types in this union type. |
| `src/infra/deferred-plugin-migrations.test.ts` | `typescript(require-array-sort-compare)` | Require 'compare' argument. |
| `src/infra/update-repair-agent.self-lease.test.ts` | `typescript(require-array-sort-compare)` | Require 'compare' argument. |
This commit is contained in:
parent
35b08169d2
commit
af80e86b3a
2 changed files with 50 additions and 1 deletions
|
|
@ -120,7 +120,7 @@ function parseArgs(argv: string[]): { options: ProfileOptions; selectedGraphs: G
|
|||
options.outDir = path.resolve(repoRoot, arg.slice("--out=".length));
|
||||
continue;
|
||||
}
|
||||
if (!(arg in GRAPH_DEFINITIONS)) {
|
||||
if (!Object.hasOwn(GRAPH_DEFINITIONS, arg)) {
|
||||
throw new Error(`Unknown graph: ${arg}\n\n${usage()}`);
|
||||
}
|
||||
graphNames.push(arg as GraphName);
|
||||
|
|
|
|||
49
test/scripts/profile-tsgo.test.ts
Normal file
49
test/scripts/profile-tsgo.test.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { afterEach, expect, it } from "vitest";
|
||||
import { resolveTestNodeExecPath } from "../../src/test-utils/node-process.js";
|
||||
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
|
||||
|
||||
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
|
||||
|
||||
it("rejects inherited graph names before creating artifacts or starting a compiler", () => {
|
||||
const root = tempDirs.make("openclaw-profile-tsgo-");
|
||||
const outDir = path.join(root, "profile");
|
||||
const compilerStarted = path.join(root, "compiler-started");
|
||||
const preload = path.join(root, "block-compiler.mjs");
|
||||
// A broken admission path must not launch an expensive compiler in this regression.
|
||||
writeFileSync(
|
||||
preload,
|
||||
`import childProcess from "node:child_process";
|
||||
import { writeFileSync } from "node:fs";
|
||||
import { syncBuiltinESMExports } from "node:module";
|
||||
childProcess.spawnSync = () => {
|
||||
writeFileSync(${JSON.stringify(compilerStarted)}, "attempted");
|
||||
throw new Error("Compiler launch blocked by fixture");
|
||||
};
|
||||
syncBuiltinESMExports();
|
||||
`,
|
||||
);
|
||||
|
||||
const result = spawnSync(
|
||||
resolveTestNodeExecPath(),
|
||||
[
|
||||
"--import",
|
||||
"./scripts/tsx.mjs",
|
||||
"--import",
|
||||
preload,
|
||||
"scripts/profile-tsgo.mts",
|
||||
"constructor",
|
||||
`--out=${outDir}`,
|
||||
],
|
||||
{ cwd: process.cwd(), encoding: "utf8", timeout: 10_000, killSignal: "SIGKILL" },
|
||||
);
|
||||
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.status).toBe(1);
|
||||
expect(result.stdout).toBe("");
|
||||
expect(result.stderr).toMatch(/^Unknown graph: constructor\n\nUsage: pnpm tsgo:profile/u);
|
||||
expect(existsSync(outDir)).toBe(false);
|
||||
expect(existsSync(compilerStarted)).toBe(false);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue