Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
typecheck: the script owns its tsc heap ceiling (--max-old-space-size=6144)
garrytan4d3297a0f391
diff --git a/.github/workflows/macos-validation.yml b/.github/workflows/macos-validation.ymlindex d949c60d38..391367880f 100644--- a/.github/workflows/macos-validation.yml+++ b/.github/workflows/macos-validation.yml@@ -90,11 +90,11 @@ jobs:env:GBRAIN_BASH32: /bin/bashGBRAIN_TEST_BASH32_REQUIRE: '1'- # tsc peaks near 3 GB of heap on this repo; Node's default limit on- # the 7 GB runner is lower, so typecheck aborted on heap exhaustion.- NODE_OPTIONS: --max-old-space-size=4096+ # tsc peaks near 3.5 GB of heap; the typecheck script sets its own+ # --max-old-space-size, so no NODE_OPTIONS here (it reached every node+ # process verify spawns).run: |- NODE_OPTIONS='' node -p '"default node heap limit MB " + require("v8").getHeapStatistics().heap_size_limit / 1048576'+ node -p '"default node heap limit MB " + require("v8").getHeapStatistics().heap_size_limit / 1048576'mkdir -p "$RUNNER_TEMP/bash32"ln -sf /bin/bash "$RUNNER_TEMP/bash32/bash"export PATH="$RUNNER_TEMP/bash32:$PATH"diff --git a/package.json b/package.jsonindex 5c77b8ef0d..b96b2bdded 100644--- a/package.json+++ b/package.json@@ -96,7 +96,7 @@"ci:ubicloud": "bun run scripts/ci-ubicloud.ts","ci:ubicloud:diff": "bun run scripts/ci-ubicloud.ts --diff","ci:select-e2e": "bun run scripts/select-e2e.ts",- "typecheck": "tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/gbrain-typecheck.tsbuildinfo",+ "typecheck": "node --max-old-space-size=6144 node_modules/typescript/bin/tsc --noEmit --incremental --tsBuildInfoFile node_modules/.cache/gbrain-typecheck.tsbuildinfo","check:jsonb": "bash scripts/check-jsonb-pattern.sh","check:jsonb-params": "node scripts/check-jsonb-params.mjs","check:search-path": "bash scripts/check-search-path.sh",diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 295cb8c9c3..1a57e0704f 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -56,7 +56,7 @@ test/canonical-writer-inventory.test.ts (file-level) 4 readFileSynctest/chat-key-plane.test.ts #3944 both planner surfaces share the helper (source guard) 2 readFileSync,source-surface-helpertest/check-bootstrap-guards.test.ts check-grok-pin.sh 9 readFileSynctest/check-bootstrap-guards.test.ts check-opencode-pin.sh 6 readFileSync-test/check-bootstrap-guards.test.ts verify + workflow wiring 4 readFileSync+test/check-bootstrap-guards.test.ts verify + workflow wiring 5 readFileSynctest/check-update.test.ts check-update CLI 3 source-surface-helpertest/child-worker-supervisor.test.ts issue #1801 — restartCurrentChild + killChild liveness fix 3 readFileSynctest/chronicle-extract.test.ts runChronicleExtract 9 readFileSyncdiff --git a/test/scripts/typecheck-incremental.test.ts b/test/scripts/typecheck-incremental.test.tsindex 4ab5276e78..6118d946fb 100644--- a/test/scripts/typecheck-incremental.test.ts+++ b/test/scripts/typecheck-incremental.test.ts@@ -6,7 +6,12 @@ import { dirname, join, resolve } from 'node:path';import pkg from '../../package.json';const tsc = resolve(import.meta.dir, '../../node_modules/typescript/bin/tsc');-const [command, ...args] = pkg.scripts.typecheck.split(/\s+/);+const [command, heapFlag, tscPath, ...args] = pkg.scripts.typecheck.split(/\s+/);+// tsc peaks near 3.5 GB of heap on this repo (--extendedDiagnostics "Memory+// used"); Node's default limit is about 2 GB on an 8 GB host, so the+// 2-vCPU/8 GB runner aborted typecheck on heap exhaustion. The script owns+// its ceiling instead of each workflow's NODE_OPTIONS.+const HEAP_MB_FLOOR = 4096;const roots: string[] = [];afterEach(() => {@@ -31,9 +36,16 @@ function fixture(source = 'export const answer: number = 42;\n', strict = true)return root;}+test('typecheck runs tsc under node with an explicit heap ceiling above its measured peak', () => {+ expect(command).toBe('node');+ expect(tscPath).toBe('node_modules/typescript/bin/tsc');+ const heapMb = Number(/^--max-old-space-size=(\d+)$/.exec(heapFlag ?? '')?.[1]);+ expect(heapMb).toBeGreaterThanOrEqual(HEAP_MB_FLOOR);+});+function check(root: string) {- expect(command).toBe('tsc');- const result = spawnSync(Bun.which('node') ?? process.execPath, [tsc, ...args], { cwd: root, encoding: 'utf8', timeout: 30_000 });+ expect(command).toBe('node');+ const result = spawnSync(Bun.which('node') ?? process.execPath, [heapFlag!, tsc, ...args], { cwd: root, encoding: 'utf8', timeout: 30_000 });expect(result.error).toBeUndefined();expect(result.signal).toBeNull();expect(existsSync(join(root, 'node_modules/.cache/gbrain-typecheck.tsbuildinfo'))).toBe(true);