Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes

garrytanfd4fd14915a1
diff --git a/docs/ci-event-parity.md b/docs/ci-event-parity.md
index 08172adb1b..a2d941824c 100644
--- a/docs/ci-event-parity.md
+++ b/docs/ci-event-parity.md
@@ -117,7 +117,9 @@ since. A full run
on the tree still in progress is waited for (90 minutes at most, a progress
line every minute), also while the other workflow has no full run on the tree:
full-ci's second dispatch can still appear, and a failure of the run in
-progress refuses instead of starting VMs. The newest full run on the tree decides,
+progress refuses instead of starting VMs. A passed run whose executed-test receipt
+is refused (an unreadable, stale or empty ledger) ends the wait at once, since no
+later run makes reuse possible. The newest full run on the tree decides,
across the head and every recent head with the same tree, so neither an empty
commit nor an older pass elsewhere skips a newer failure; a failed one refuses
with no receipt. A run that did not run the full job (a diagnostic dispatch, a
diff --git a/scripts/ci-reuse.ts b/scripts/ci-reuse.ts
index 86113dee53..ee7c9ef8c2 100644
--- a/scripts/ci-reuse.ts
+++ b/scripts/ci-reuse.ts
@@ -146,9 +146,10 @@ function accept(run: FullRun, tree: string, rejected: Rejection[], where: string
* the identical tree reuses; a stamp-only difference goes through gstack-pregate's stamp rule, never through here.
* The newest full run on the tree decides, across `head` and every other recent head with the same tree: in progress
* waits, a failure refuses (no receipt, no VMs), cancelled or not a full run (its full job skipped or absent: a
- * diagnostic dispatch, a push that reused) looks further back; anything else is `none` and the caller runs the VM gate.
+ * diagnostic dispatch, a push that reused) looks further back; a passed run whose executed-test receipt is refused is
+ * `rejected`, which no later run on the tree changes; anything else is `none` and the caller runs the VM gate.
*/
-export type GateState = 'reuse' | 'pending' | 'failed' | 'none';
+export type GateState = 'reuse' | 'pending' | 'failed' | 'rejected' | 'none';
/**
* Executed test counts; `partial` names the attempt when they cover only the jobs that attempt re-ran, and
* `ledgerAttempt` the earlier attempt that wrote the ledger when it is older than the run's latest attempt.
@@ -200,7 +201,7 @@ const runUrl = (repo: string, run: FullRun) => `https://github.com/${repo}/actio
async function gateAccept(deps: GateDeps, p: Profile, run: FullRun, tree: string, repo: string): Promise<GateDecision> {
const got = await deps.executed(run);
- if ('reason' in got) return { state: 'none', detail: `${p.workflow}: ${got.reason}` };
+ if ('reason' in got) return { state: 'rejected', detail: `${p.workflow}: ${got.reason}` };
const { ledgerAttempt, ...counts } = got;
// A re-run that leaves the ledger job alone carries it into the new attempt with its original start; a ledger job
// that ran again but uploaded nothing leaves the older attempt's ledger behind, now stale.
@@ -208,10 +209,10 @@ async function gateAccept(deps: GateDeps, p: Profile, run: FullRun, tree: string
const started = async (attempt: number) => (await deps.jobs(run.id, attempt)).filter(j => j.name === LEDGER_JOB).map(j => j.started_at);
const [wrote, latest] = await Promise.all([started(ledgerAttempt), started(run.run_attempt)]);
if (wrote.length !== 1 || latest.length !== 1 || !wrote[0] || wrote[0] !== latest[0]) {
- return { state: 'none', detail: `${p.workflow}: run ${run.id}'s executed-identities.json is from attempt ${ledgerAttempt}, but its ${LEDGER_JOB} job ran again by attempt ${run.run_attempt} without replacing it` };
+ return { state: 'rejected', detail: `${p.workflow}: run ${run.id}'s executed-identities.json is from attempt ${ledgerAttempt}, but its ${LEDGER_JOB} job ran again by attempt ${run.run_attempt} without replacing it` };
}
}
- if (counts.tests <= 0) return { state: 'none', detail: `${p.workflow}: run ${run.id}'s executed-identities artifact lists no executed test` };
+ if (counts.tests <= 0) return { state: 'rejected', detail: `${p.workflow}: run ${run.id}'s executed-identities artifact lists no executed test` };
return { state: 'reuse', detail: `${p.workflow} run ${runUrl(repo, run)} passed the complete full suite on tree ${tree}`, url: runUrl(repo, run), ...counts };
}
@@ -222,7 +223,7 @@ export const GATE_POLL_SECONDS = 60;
* The gate's decision over Test and E2E, waiting while a full run on the tree is still in progress, up to the wait
* bound. A workflow with no full run on the tree does not end the wait: full-ci dispatches Test and E2E separately, so
* its run can still appear, and a failure of the run in progress refuses (exit 3) instead of starting VMs on a tree
- * GitHub already failed (#8096). Prints progress
+ * GitHub already failed (#8096). A `rejected` workflow ends the wait at once: reuse needs both. Prints progress
* at least every poll (gstack's stall timeout kills a silent gate) and, on reuse, a last line
* `GBRAIN_REUSE_RESULT tests=<n> failed=<n>`. Exit codes: 0 reuse, 3 a full run on this tree failed, 4 no reuse.
*/
@@ -242,7 +243,7 @@ export async function runGate(deps: GateDeps, o: { head: string; tree: string; r
return 0;
}
const pending = ds.filter(d => d.state === 'pending');
- if (!pending.length || now() >= deadline) {
+ if (!pending.length || ds.some(d => d.state === 'rejected') || now() >= deadline) {
for (const d of ds.filter(x => x.state !== 'reuse')) o.log(`[ci-reuse] gate: no reuse: ${inert(d.detail, 600)}`);
return 4;
}
diff --git a/test/scripts/ci-reuse.test.ts b/test/scripts/ci-reuse.test.ts
index 3e236238ef..554fca5152 100644
--- a/test/scripts/ci-reuse.test.ts
+++ b/test/scripts/ci-reuse.test.ts
@@ -514,12 +514,24 @@ describe('ci-reuse remote-gate decision', () => {
expect(await decideGate(carried, PROFILES.test, A, T, REPO)).toEqual({ state: 'reuse', detail: expect.any(String), url: expect.any(String), tests: 600, failed: 0 });
// The ledger job ran again in attempt 2 but uploaded nothing: attempt 1's ledger is stale and never the receipt.
const stale = gate({ runs, executed, jobs: { '600/1': [fullJob, ledgerJob('2026-10-30T17:46:56Z')], '600/2': [fullJob, ledgerJob('2026-10-30T18:20:00Z')] } });
- expect(await decideGate(stale, PROFILES.test, A, T, REPO)).toMatchObject({ state: 'none', detail: expect.stringContaining('is from attempt 1, but its executed-receipts job ran again by attempt 2') });
+ expect(await decideGate(stale, PROFILES.test, A, T, REPO)).toMatchObject({ state: 'rejected', detail: expect.stringContaining('is from attempt 1, but its executed-receipts job ran again by attempt 2') });
const r = await go(stale);
expect(r.code).toBe(4);
expect(r.lines.join('\n')).not.toContain('GBRAIN_REUSE_RESULT');
// A listing without the ledger job proves nothing either.
- expect(await decideGate(gate({ runs, executed }), PROFILES.test, A, T, REPO)).toMatchObject({ state: 'none' });
+ expect(await decideGate(gate({ runs, executed }), PROFILES.test, A, T, REPO)).toMatchObject({ state: 'rejected' });
+ });
+
+ test('a completed run on the tree whose receipt is refused ends the wait at once: the other run cannot make reuse possible', async () => {
+ const live = run('e2e.yml', { status: 'in_progress', conclusion: null });
+ for (const executed of [{ 600: { reason: 'no executed-identities artifact' } }, { 600: { tests: 0, failed: 0 } }]) {
+ const deps = gate({ runs: [run('test.yml'), live], executed });
+ expect(await decideGate(deps, PROFILES.test, A, T, REPO)).toMatchObject({ state: 'rejected' });
+ const r = await go(deps, A, T, 90 * 60_000);
+ expect(r.code).toBe(4);
+ expect(r.lines.some(l => l.includes('waiting for'))).toBe(false);
+ expect(r.lines.join('\n')).toContain('[ci-reuse] gate: no reuse: Test');
+ }
});
test('a same-tree other head whose newest run skipped the full job, or was cancelled, looks further back (#7927)', async () => {