Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(native-locks): bound each data-safety suite per target from measured p99 plus margin (Windows backup suite runs 3.5-8 min; the 300 s bound killed passing runs)
garrytan8e444a51909c
diff --git a/.github/workflows/native-locks.yml b/.github/workflows/native-locks.ymlindex 584d8a2ef2..c93e97823b 100644--- a/.github/workflows/native-locks.yml+++ b/.github/workflows/native-locks.yml@@ -105,12 +105,19 @@ jobs:env:GBRAIN_CI_DISABLE_TEST_ENV_FILE: '1'GBRAIN_TEST_REQUIRE_CASE_INSENSITIVE: ${{ runner.os != 'Linux' && '1' || '0' }}- # Each file normally takes 1-50 s (darwin-x64 is the slowest). A file still running at- # 300 s is stuck: its process table and, on macOS, a native stack sample go to the log- # before it is killed, because a job the timeout cancels keeps no log at all.+ # Per-file bound for this target: the slowest suite's p99 over 68-78 runs of each+ # target (2026-10-19), plus max(60 s, 15%), rounded up to 30 s. The slowest suite is+ # backup-portability-native everywhere: p99 94 s linux-x64, 75 s linux-arm64, 36 s+ # darwin-arm64, 105 s darwin-x64, 303 s win32-arm64, 462 s win32-x64. Each bound+ # still fires inside the 15-minute job timeout after the slowest observed setup.+ GBRAIN_NATIVE_SUITE_BOUND_S: ${{ fromJSON('{"linux-x64-glibc":"180","linux-arm64-glibc":"150","darwin-arm64":"120","darwin-x64":"180","win32-x64":"540","win32-arm64":"390"}')[matrix.target] }}+ # A file still running at its target's bound is stuck: its process table and, on macOS,+ # a native stack sample go to the log before it is killed, because a job the timeout+ # cancels keeps no log at all.run: |status=0- bound_s="${GBRAIN_NATIVE_SUITE_BOUND_S:-300}"+ bound_s="$GBRAIN_NATIVE_SUITE_BOUND_S"+ case "$bound_s" in ''|*[!0-9]*) echo "::error::GBRAIN_NATIVE_SUITE_BOUND_S is not set for this target"; exit 1 ;; esacbounded() {bun --no-env-file test --timeout=180000 "$1" &pid=$!@@ -118,7 +125,7 @@ jobs:if ! kill -0 "$pid" 2>/dev/null; then wait "$pid"; return $?; fisleep 1done- echo "::error::$1 was still running after $bound_s s (it normally takes under 60 s); process table and stack sample follow, then it is killed"+ echo "::error::$1 was still running after $bound_s s, this target's bound (its slowest suite's measured p99 plus margin); process table and stack sample follow, then it is killed"ps -A -o pid,ppid,stat,etime,command 2>/dev/null || ps -efif command -v sample >/dev/null 2>&1; then sample "$pid" 3 2>&1 | head -200; fikill -TERM "$pid" 2>/dev/null; sleep 5; kill -KILL "$pid" 2>/dev/nulldiff --git a/test/scripts/data-safety-native-workflow.test.ts b/test/scripts/data-safety-native-workflow.test.tsindex dd8a74161f..a59d523918 100644--- a/test/scripts/data-safety-native-workflow.test.ts+++ b/test/scripts/data-safety-native-workflow.test.ts@@ -136,6 +136,7 @@ describe('data-safety native CI coverage', () => {expect(step!.env).toEqual({GBRAIN_CI_DISABLE_TEST_ENV_FILE: '1',GBRAIN_TEST_REQUIRE_CASE_INSENSITIVE: "${{ runner.os != 'Linux' && '1' || '0' }}",+ GBRAIN_NATIVE_SUITE_BOUND_S: expect.stringContaining('[matrix.target]'),});const lines = step!.run!.trim().split('\n');expect(lines[0]).toBe('status=0');@@ -144,6 +145,31 @@ describe('data-safety native CI coverage', () => {expect(lines.at(-1)).toBe('exit "$status"');});+ test('every native target has its own suite bound, above that target\'s slowest measured suite and inside the job timeout', () => {+ const job = workflow.jobs.native as unknown as { steps: Step[]; strategy: { matrix: { target: string[] } }; 'timeout-minutes': number };+ const step = job.steps.find(entry => entry.name === 'Verify native data-safety contracts')!;+ const mapping = /fromJSON\('(\{.*\})'\)\[matrix\.target\]/.exec(step.env!.GBRAIN_NATIVE_SUITE_BOUND_S!)![1]!;+ const bounds = JSON.parse(mapping) as Record<string, string>;+ expect(Object.keys(bounds).sort()).toEqual([...job.strategy.matrix.target].sort());+ // Slowest observed backup-portability-native durations (seconds) per target, 68-78 runs each, 2026-10-19.+ const measuredMax: Record<string, number> = { 'linux-x64-glibc': 94, 'linux-arm64-glibc': 75, 'darwin-arm64': 36, 'darwin-x64': 105, 'win32-arm64': 304, 'win32-x64': 463 };+ for (const [target, bound] of Object.entries(bounds)) {+ expect(Number(bound)).toBeGreaterThanOrEqual(measuredMax[target]! + 60);+ expect(Number(bound)).toBeLessThan(job['timeout-minutes'] * 60 - 300);+ }+ });++ test('a target with no bound fails the step before running any suite', () => {+ const step = workflow.jobs.native.steps.find(entry => entry.name === 'Verify native data-safety contracts')!;+ const result = Bun.spawnSync(['bash', '-e', '-o', 'pipefail', '-c', `+ bun() { printf '%s\\n' "$4"; }+ ${step.run}+ `], { env: { PATH: process.env.PATH ?? '' } });+ expect(result.exitCode).toBe(1);+ expect(result.stdout.toString()).toContain('::error::GBRAIN_NATIVE_SUITE_BOUND_S is not set for this target');+ expect(result.stdout.toString()).not.toContain('test/');+ });+test('a stuck native safety suite is named, sampled and killed inside the job timeout, and the step fails', () => {const step = workflow.jobs.native.steps.find(entry => entry.name === 'Verify native data-safety contracts')!;const stuck = suites[2]!;@@ -153,7 +179,7 @@ describe('data-safety native CI coverage', () => {`], { env: { PATH: process.env.PATH ?? '', GBRAIN_TEST_STUCK_SUITE: stuck, GBRAIN_NATIVE_SUITE_BOUND_S: '2' }, timeout: 60_000 });expect(result.exitCode).toBe(1);const stdout = result.stdout.toString();- expect(stdout).toContain(`::error::${stuck} was still running after 2 s`);+ expect(stdout).toContain(`::error::${stuck} was still running after 2 s, this target's bound`);expect(stdout.trim().split('\n').filter(line => line.startsWith('test/'))).toEqual(suites.filter(suite => suite !== stuck));});@@ -162,7 +188,7 @@ describe('data-safety native CI coverage', () => {const result = Bun.spawnSync(['bash', '-e', '-o', 'pipefail', '-c', `bun() { printf '%s\\n' "$4"; [[ "$4" != "$GBRAIN_TEST_FAILED_SUITE" ]]; }${step.run}- `], { env: { PATH: process.env.PATH ?? '', GBRAIN_TEST_FAILED_SUITE: failed } });+ `], { env: { PATH: process.env.PATH ?? '', GBRAIN_TEST_FAILED_SUITE: failed, GBRAIN_NATIVE_SUITE_BOUND_S: '60' } });expect(result.exitCode).toBe(failed ? 1 : 0);expect(result.stdout.toString().trim().split('\n')).toEqual(suites);});