Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(persistence): history fixture waits for in-flight Git effects before planting its stale index.lock
garrytan8d5e4b9565c4
diff --git a/scripts/persistence/history-fixture.ts b/scripts/persistence/history-fixture.tsindex 5f158bdce6..2ebe7bf5b8 100644--- a/scripts/persistence/history-fixture.ts+++ b/scripts/persistence/history-fixture.ts@@ -254,6 +254,14 @@ export async function buildHistoryFixture(engine: BrainEngine,// A Git effect that fails on a stale index.lock reschedules into the future. A lock younger than// 10 minutes is contention (`git_index_locked`, retried after 250 ms), so the lock is dated// 11 minutes back: the effect fails as `git_index_stale` and requeues 30 s out.+ // A committed op's Git effect can still be queued or running (always so when replies outlive+ // their wait); a lock planted under a running effect is renamed away by Git's own commit.+ const drainDeadline = Date.now() + 60_000;+ while ((await engine.executeRaw<{ n: number }>(`SELECT count(*)::int AS n FROM persistence_effects+ WHERE kind='git' AND state IN ('queued','running')`))[0].n > 0) {+ assert(Date.now() < drainDeadline, 'history fixture: Git effects were still in flight 60 s after every op committed');+ await Bun.sleep(100);+ }const delayedSource = fixtureSources[0];const lock = join(checkouts[delayedSource.worktree], '.git', 'index.lock');writeFileSync(lock, '');