Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci: run tsc in its own typecheck job beside verify, with a measured 6-minute step timeout and a cache saved on every outcome

garrytan00730cd81f4b
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 4d0f0e6b57..2c5402d6e2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -332,7 +332,7 @@ jobs:
verify:
if: ${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}
- # Pre-test gates: privacy/jsonb/source-id/etc + typecheck + admin-build.
+ # Pre-test gates: privacy/jsonb/source-id/etc + admin-build (tsc runs in the typecheck job).
# Lives in its own runner so the matrix shards aren't carrying ~2-3min
# of verify work in addition to their test files (the old shape stuffed
# this into `test (1)` via `if: matrix.shard == 1`, which made shard 1
@@ -367,26 +367,15 @@ jobs:
- name: Install dependencies (bounded, retried once)
timeout-minutes: 8
run: bun scripts/ci-bun-install.ts --frozen-lockfile
- # #6056: typecheck is the slowest verify check and ran cold on every
- # job. `bun run typecheck` is incremental against this tsbuildinfo, so
- # a restored one from an earlier run lets tsc recheck only what changed.
- # Rolling key: every run saves under its own SHA and the next run
- # restores the newest one for the same bun.lock + tsconfig.json
- # (a dependency or compiler-option change starts cold). After
- # `bun install`, which (re)creates node_modules.
- - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
- with:
- path: node_modules/.cache/gbrain-typecheck.tsbuildinfo
- key: tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-${{ github.sha }}
- restore-keys: |
- tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-
# check:schema-migration-order compares new schema migrations with
# origin/master's latest version; a depth-1 fetch of the ref is enough.
- run: git fetch --no-tags --depth=1 origin +refs/heads/master:refs/remotes/origin/master
# Receipts (X2): verify records every check's real outcome (pass, fail,
# timeout, self-skip) as one JUnit testcase; logs stay on failure.
+ # The typecheck job below runs tsc, so verify skips its own copy here.
- run: bun run verify
env:
+ GBRAIN_VERIFY_SKIP_TYPECHECK: '1'
GBRAIN_TEST_RECEIPT_DIR: ${{ runner.temp }}/receipts
GBRAIN_VERIFY_LOG_DIR: ${{ runner.temp }}/verify-logs
- name: Upload verify logs
@@ -428,6 +417,57 @@ jobs:
if-no-files-found: warn
overwrite: true
+ typecheck:
+ if: ${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}
+ # tsc runs here, in parallel with verify, instead of inside verify's pool
+ # with its 120 s per-check cap. A change to a widely imported type (any new
+ # error code in src/core/error-registry.ts) makes the incremental check
+ # almost cold. On master c8354664 (run 39140170894), the cold check took
+ # 121 s in verify's pool and timed out at the cap. A timed-out tsc also
+ # writes no tsbuildinfo, so every rerun restored the same stale state.
+ # Step timeout from measurement: 3 x the worst cold CI time (121 s) is
+ # about 6 minutes. tsc is single-threaded, so 4 vCPUs (16 GB; peak heap
+ # is about 5.3 GB) do the work of verify's 8.
+ runs-on: ubicloud-standard-4-ubuntu-2404
+ timeout-minutes: 15
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version: 1.4.3
+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: ~/.bun/install/cache
+ key: bun-cache-${{ runner.os }}-${{ hashFiles('bun.lock', 'admin/bun.lock') }}
+ restore-keys: bun-cache-${{ runner.os }}-
+ - name: Install dependencies (bounded, retried once)
+ timeout-minutes: 8
+ run: bun scripts/ci-bun-install.ts --frozen-lockfile
+ # #6056: `bun run typecheck` is incremental against this tsbuildinfo, so
+ # a restored one from an earlier run lets tsc recheck only what changed.
+ # Rolling key: every run saves under its own SHA and the next run
+ # restores the newest one for the same bun.lock + tsconfig.json
+ # (a dependency or compiler-option change starts cold). After
+ # `bun install`, which (re)creates node_modules.
+ - uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: node_modules/.cache/gbrain-typecheck.tsbuildinfo
+ key: tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-${{ github.sha }}
+ restore-keys: |
+ tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-
+ - name: Typecheck (tsc, incremental)
+ timeout-minutes: 6
+ run: bun run typecheck
+ # Saved even when this check finds type errors, and whatever the other
+ # jobs do: tsc writes its state on an error too, so the next master run
+ # starts from this commit instead of an older, colder state.
+ - name: Save the typecheck state
+ if: always()
+ uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: node_modules/.cache/gbrain-typecheck.tsbuildinfo
+ key: tsbuildinfo-${{ runner.os }}-${{ hashFiles('bun.lock', 'tsconfig.json') }}-${{ github.sha }}
+
serial-tests:
if: ${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}
# *.serial.test.ts — one bun process per file (module-registry isolation),
@@ -1085,7 +1125,7 @@ jobs:
# Coverage percentages remain advisory until their separate graduation.
test-status:
name: ${{ github.event_name == 'workflow_dispatch' && (inputs.native_only == true || inputs.race_hunt == true || inputs.stress_files != '' || inputs.stress_base != '') && 'full-suite-not-run' || 'test-status' }}
- needs: [gitleaks, security-regressions, dependency-audit, verify, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, brainbench, test, native-locks, persistence-validation, admin-browser, shared-skills-compatibility, stress-changed-tests]
+ needs: [gitleaks, security-regressions, dependency-audit, verify, typecheck, serial-tests, slow-entity-resolve-perf, slow-brainbench-e2e, brainbench, test, native-locks, persistence-validation, admin-browser, shared-skills-compatibility, stress-changed-tests]
if: ${{ always() && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}
runs-on: ubicloud-standard-2-ubuntu-2404
timeout-minutes: 5
@@ -1096,6 +1136,7 @@ jobs:
SECURITY="${{ needs.security-regressions.result }}"
AUDIT="${{ needs.dependency-audit.result }}"
VERIFY="${{ needs.verify.result }}"
+ TYPECHECK="${{ needs.typecheck.result }}"
SERIAL="${{ needs.serial-tests.result }}"
SLOW_PERF="${{ needs.slow-entity-resolve-perf.result }}"
SLOW_BRAINBENCH="${{ needs.slow-brainbench-e2e.result }}"
@@ -1106,9 +1147,9 @@ jobs:
ADMIN_BROWSER="${{ needs.admin-browser.result }}"
SKILL_COMPATIBILITY="${{ needs.shared-skills-compatibility.result }}"
STRESS="${{ needs.stress-changed-tests.result }}"
- echo "gitleaks=$GITLEAKS security-regressions=$SECURITY dependency-audit=$AUDIT verify=$VERIFY serial-tests=$SERIAL slow-entity-resolve-perf=$SLOW_PERF slow-brainbench-e2e=$SLOW_BRAINBENCH brainbench=$BRAINBENCH test=$TEST native-locks=$NATIVE_LOCKS persistence=$PERSISTENCE admin-browser=$ADMIN_BROWSER"
+ echo "gitleaks=$GITLEAKS security-regressions=$SECURITY dependency-audit=$AUDIT verify=$VERIFY typecheck=$TYPECHECK serial-tests=$SERIAL slow-entity-resolve-perf=$SLOW_PERF slow-brainbench-e2e=$SLOW_BRAINBENCH brainbench=$BRAINBENCH test=$TEST native-locks=$NATIVE_LOCKS persistence=$PERSISTENCE admin-browser=$ADMIN_BROWSER"
echo "shared-skills-compatibility=$SKILL_COMPATIBILITY stress-changed-tests=$STRESS"
- for r in "$GITLEAKS" "$SECURITY" "$AUDIT" "$VERIFY" "$SERIAL" "$SLOW_PERF" "$SLOW_BRAINBENCH" "$BRAINBENCH" "$TEST" "$NATIVE_LOCKS" "$PERSISTENCE" "$ADMIN_BROWSER" "$SKILL_COMPATIBILITY" "$STRESS"; do
+ for r in "$GITLEAKS" "$SECURITY" "$AUDIT" "$VERIFY" "$TYPECHECK" "$SERIAL" "$SLOW_PERF" "$SLOW_BRAINBENCH" "$BRAINBENCH" "$TEST" "$NATIVE_LOCKS" "$PERSISTENCE" "$ADMIN_BROWSER" "$SKILL_COMPATIBILITY" "$STRESS"; do
if [ "$r" != "success" ]; then
echo "✗ gated job did not succeed (got $r) — CI fail"
exit 1
diff --git a/docs/TESTING.md b/docs/TESTING.md
index 272097646e..2ff4493074 100644
--- a/docs/TESTING.md
+++ b/docs/TESTING.md
@@ -444,8 +444,8 @@ self-test" below).
`bun run typecheck` ([heap ceiling](operations/verify-and-nightly-e2e.md#typecheck-heap)) uses TypeScript's native incremental analysis in
`node_modules/.cache/gbrain-typecheck.tsbuildinfo`. Every invocation still runs
the compiler; source, root-file, configuration and dependency changes invalidate
-the affected analysis, and cached diagnostics remain failures. CI restores it
-(#6056) and `ci:ubicloud` uploads it (scripts/ubicloud/README.md).
+the affected analysis, and cached diagnostics remain failures. CI's `typecheck`
+job restores and always saves it (#6056), as `ci:ubicloud` does.
The local Docker runner isolates root and admin `node_modules`, plus the generated
admin bundle, in named volumes. Admin build dependencies, Vite's generated cache
@@ -1270,7 +1270,7 @@ there even though they pass on Linux and macOS.
### CI vs local: intentionally divergent file sets
-- **CI matrix** (`.github/workflows/test.yml`) runs `scripts/test-shard.sh` across 18 shards split by weight-aware LPT bin-packing (`scripts/sharding.ts`; unweighted files get the p75 weight) and includes `*.slow.test.ts` files without a dedicated job, plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 18`) and print their predicted weight (`sharding.ts --sum`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs; the runner's hash check is authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify` and the BrainBench memory-conformance gate (`scripts/ci-brainbench-gate.sh`, compared against `evals/brainbench/baselines/main.json`) have their own jobs, all aggregated by `test-status`. `e2e.yml` aggregates through `e2e-status`, with jsonb-parity gating Tier 2's token spend; scheduled runs also require the full-corpus lanes. Both aggregates reject failures, cancellations and unexpected skips, and successful test results are never reused. CI is the ground truth for "did everything pass."
+- **CI matrix** (`.github/workflows/test.yml`) runs `scripts/test-shard.sh` across 18 shards split by weight-aware LPT bin-packing (`scripts/sharding.ts`; unweighted files get the p75 weight) and includes `*.slow.test.ts` files without a dedicated job, plus keyless-allowlisted `evals/**/*.test.ts` (`test/scripts/evals-collection.test.ts`). Shards keep planned file order (`test-shard.sh --dry-run-list <i> 18`) and print their predicted weight (`sharding.ts --sum`). Every Bun job activates the PGLite schema snapshot (built in-runner, cached across jobs; the runner's hash check is authoritative). Serial files run across four `serial-tests` workers via `bun run test:serial`; `verify`, `typecheck` and the BrainBench memory-conformance gate (`scripts/ci-brainbench-gate.sh`, compared against `evals/brainbench/baselines/main.json`) have their own jobs, all aggregated by `test-status`. `e2e.yml` aggregates through `e2e-status`, with jsonb-parity gating Tier 2's token spend; scheduled runs also require the full-corpus lanes. Both aggregates reject failures, cancellations and unexpected skips, and successful test results are never reused. CI is the ground truth for "did everything pass."
- **Local fast loop** (`scripts/run-unit-shard.sh` via the parallel wrapper) uses the same weighted partitioner as CI and EXCLUDES `*.slow.test.ts` AND `*.serial.test.ts`. Each shard runs its complete ordered selection with a fresh Bun process per file, without adding workers. Later groups still run after failures; missing summaries or file-completion evidence fail the shard. Local trades coverage for inner-loop speed; CI catches what local skips.
`test/scripts/run-unit-shard.test.ts` pins what the local loop includes, and
diff --git a/scripts/run-verify-parallel.sh b/scripts/run-verify-parallel.sh
index 1ea3ccd9b9..4ed1f75a54 100755
--- a/scripts/run-verify-parallel.sh
+++ b/scripts/run-verify-parallel.sh
@@ -18,6 +18,8 @@
#
# Env overrides:
# GBRAIN_VERIFY_TIMEOUT per-check wallclock cap, seconds (default 120)
+# GBRAIN_VERIFY_SKIP_TYPECHECK=1 leave typecheck out: test.yml's typecheck job
+# runs tsc in parallel under its own measured timeout
# GBRAIN_VERIFY_LOG_DIR where to write per-check logs (default tempdir,
# removed on success and kept on failure)
# GBRAIN_TEST_RECEIPT_DIR also write the verify receipt (X2): one JUnit
@@ -232,6 +234,11 @@ SOLO_CHECKS=(
# Budget: 30 s wall clock (scripts/guard-self-test.sh BUDGET_SECONDS).
"check:guard-self-test"
)
+if [ "${GBRAIN_VERIFY_SKIP_TYPECHECK:-}" = "1" ]; then
+ KEPT=()
+ for c in "${CHECKS[@]}"; do [ "$c" = "typecheck" ] || KEPT+=("$c"); done
+ CHECKS=("${KEPT[@]}")
+fi
ALL_CHECKS=("${CHECKS[@]}" "${SOLO_CHECKS[@]}")
if [ "${#CHECKS[@]}" -eq 0 ]; then
diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsv
index fb514b30ed..1bdadbbde7 100644
--- a/scripts/structural-suites.tsv
+++ b/scripts/structural-suites.tsv
@@ -289,7 +289,7 @@ test/scripts/check-item-allowlist-catches.test.ts CLI 2 readFileSync
test/scripts/chunk-visibility-ratchet.test.ts check-chunk-visibility.ts 6 readFileSync
test/scripts/ci-bounded-run.test.ts (file-level) 7 readFileSync
test/scripts/ci-executed-counts.test.ts CLI 2 readFileSync
-test/scripts/ci-gates.test.ts CI execution evidence 8 readFileSync
+test/scripts/ci-gates.test.ts CI execution evidence 9 readFileSync
test/scripts/ci-gates.test.ts test:full exit status 0 readFileSync
test/scripts/ci-hydrate-admin-dist.test.ts #6756 ci:local hydrates the admin/dist volume from the worktree 7 readFileSync
test/scripts/ci-local-rendering.test.ts ci-local command rendering 1 readFileSync
diff --git a/test/scripts/ci-gates.test.ts b/test/scripts/ci-gates.test.ts
index c2f5a0a5bc..147c218a8a 100644
--- a/test/scripts/ci-gates.test.ts
+++ b/test/scripts/ci-gates.test.ts
@@ -7,7 +7,7 @@ import { load } from 'js-yaml';
import { UNIT_SHARDS } from '../../scripts/sharding.ts';
const root = join(import.meta.dir, '..', '..');
-type Job = { needs?: string | string[]; if?: string; steps: Array<{ name?: string; run?: string; uses?: string; env?: Record<string, string> }> };
+type Job = { needs?: string | string[]; if?: string; steps: Array<{ name?: string; run?: string; uses?: string; env?: Record<string, string>; if?: string; with?: Record<string, string>; 'timeout-minutes'?: number }> };
type Workflow = { on: Record<string, { paths?: string[] }>; jobs: Record<string, Job> };
const loadWorkflow = (name: string) => load(readFileSync(join(root, '.github/workflows', name), 'utf8')) as Workflow;
const unit = loadWorkflow('test.yml');
@@ -38,7 +38,7 @@ describe('CI execution evidence', () => {
expect(source).toContain('pglite-snapshot-');
expect(workflow.on.pull_request.paths).toBeUndefined();
}
- for (const name of ['gitleaks', 'verify']) {
+ for (const name of ['gitleaks', 'verify', 'typecheck']) {
expect(unit.jobs[name].needs).toBeUndefined();
expect(unit.jobs[name].if).toBe("${{ github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base) }}");
}
@@ -53,10 +53,30 @@ describe('CI execution evidence', () => {
expect(pkg.scripts.verify).toContain('scripts/run-verify-parallel.sh');
});
+ test('typecheck runs as its own job beside verify, under a measured step timeout, saves its state on every outcome and gates test-status', () => {
+ const job = unit.jobs.typecheck;
+ const tsc = job.steps.find(step => step.run === 'bun run typecheck')!;
+ expect(tsc['timeout-minutes']).toBe(6);
+ const restore = job.steps.find(step => step.uses?.startsWith('actions/cache/restore@') && step.with?.path === 'node_modules/.cache/gbrain-typecheck.tsbuildinfo')!;
+ const save = job.steps.find(step => step.uses?.startsWith('actions/cache/save@'))!;
+ expect(save.if).toBe('always()');
+ expect(save.with).toEqual({ path: restore.with!.path, key: restore.with!.key });
+ expect(job.steps.indexOf(save)).toBeGreaterThan(job.steps.indexOf(tsc));
+ const verify = unit.jobs.verify.steps.find(step => step.run === 'bun run verify')!;
+ expect(verify.env?.GBRAIN_VERIFY_SKIP_TYPECHECK).toBe('1');
+ expect(JSON.stringify(unit.jobs.verify.steps)).not.toContain('gbrain-typecheck.tsbuildinfo');
+ const skipped = spawnSync('bash', [join(root, 'scripts/run-verify-parallel.sh'), '--dry-list'], { cwd: root, encoding: 'utf8', env: { ...process.env, GBRAIN_VERIFY_SKIP_TYPECHECK: '1' } });
+ const full = spawnSync('bash', [join(root, 'scripts/run-verify-parallel.sh'), '--dry-list'], { cwd: root, encoding: 'utf8' });
+ expect(full.stdout.split('\n')).toContain('typecheck');
+ expect(skipped.stdout.split('\n').filter(Boolean)).toEqual(full.stdout.split('\n').filter(line => line && line !== 'typecheck'));
+ expect(unit.jobs['test-status'].needs).toContain('typecheck');
+ expect(aggregate(unit, 'test-status', 'push', { typecheck: 'failure' })).toBe(1);
+ });
+
test('unit aggregate rejects failed, cancelled or skipped required jobs', () => {
expect(unit.jobs['test-status'].if).toBe("${{ always() && (github.event_name != 'workflow_dispatch' || (inputs.native_only != true && inputs.race_hunt != true && !inputs.stress_files && !inputs.stress_base)) }}");
expect(unit.jobs['test-status'].needs).toEqual([
- 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'serial-tests',
+ 'gitleaks', 'security-regressions', 'dependency-audit', 'verify', 'typecheck', 'serial-tests',
'slow-entity-resolve-perf', 'slow-brainbench-e2e', 'brainbench', 'test', 'native-locks', 'persistence-validation',
'admin-browser', 'shared-skills-compatibility', 'stress-changed-tests',
]);