Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(scale): never replay lock/sequence statements under EXPLAIN, refuse missing progress ticks, labels never cancel a scale run (F4c review)
garrytandcb72da0c95f
diff --git a/.github/workflows/scale-tier.yml b/.github/workflows/scale-tier.ymlindex 26cd61b519..83ad8a79cc 100644--- a/.github/workflows/scale-tier.yml+++ b/.github/workflows/scale-tier.yml@@ -38,8 +38,10 @@ on:permissions:contents: read+# A label other than scale-tier gets its own group, so labelling a pull+# request never cancels a scale run already in progress.concurrency:- group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'schedule' && '-nightly' || '' }}+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}${{ github.event_name == 'schedule' && '-nightly' || '' }}${{ github.event.action == 'labeled' && github.event.label.name != 'scale-tier' && format('-label-{0}', github.run_id) || '' }}cancel-in-progress: truejobs:diff --git a/scripts/scale/run.ts b/scripts/scale/run.tsindex 6396a26936..77c2611fbc 100644--- a/scripts/scale/run.ts+++ b/scripts/scale/run.ts@@ -151,7 +151,7 @@ async function explainText(engine: Engine, sql: string, params: unknown[]): Prom/** Replay each captured read statement under EXPLAIN ANALYZE; keep the slowest and the worst Nested Loop with their plan text. */async function planOf(engine: Engine, statements: Array<{ sql: string; params: unknown[] }>): Promise<OpPlan> {const reads = statements.filter(s => /^\s*(select|with)\b/i.test(s.sql) && !/^\s*select b\.oid/i.test(s.sql)- && !/\b(insert|update|delete)\b/i.test(s.sql) && !/\bset_config\b/i.test(s.sql));+ && !/\b(insert|update|delete)\b/i.test(s.sql) && !/\b(set_config|nextval|setval|pg_notify|pg_(try_)?advisory\w*)\b/i.test(s.sql));const measured: Array<PlanStatement & { params: unknown[] }> = [];for (const s of reads) {try {@@ -192,7 +192,11 @@ async function cliImport(sourceId: string): Promise<CliImport> {const event = JSON.parse(line) as { event?: string; phase?: string; done?: number; elapsed_ms?: number };if (event.event === 'tick' && event.phase === 'import.files' && typeof event.done === 'number') elapsed[event.done - 1] = event.elapsed_ms ?? 0;}- const perFileMs = elapsed.map((ms, i) => ms - (i > 0 ? elapsed[i - 1] ?? ms : 0));+ const perFileMs = Array.from(elapsed, (ms, i) => ms - (i > 0 ? elapsed[i - 1] ?? Number.NaN : 0));+ if (perFileMs.length !== Number(JSON.parse(lastJson).total_files) || perFileMs.some(ms => !Number.isFinite(ms))) {+ throw new Error(`gbrain import of source ${sourceId} emitted ${perFileMs.filter(Number.isFinite).length} usable per-file progress ticks for `+ + `${String(JSON.parse(lastJson).total_files)} files; the rate gate needs one tick per file (--progress-json --progress-interval 0).`);+ }return { perFileMs, result: JSON.parse(lastJson) as Record<string, unknown>, wallMs };}