Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(crash-robot): finish drains its probe's effects, so a seam a count role saw is reached in every run (seed 5105)

garrytan7fb85358ff10
diff --git a/scripts/persistence/crash-robot.ts b/scripts/persistence/crash-robot.ts
index 4d5d2e6ea1..7cd5dc236b 100644
--- a/scripts/persistence/crash-robot.ts
+++ b/scripts/persistence/crash-robot.ts
@@ -91,7 +91,7 @@ export async function settlePending(world: World, model: ReferenceModel): Promis
await model.settleLate(pending, observed);
}
-/** Finish a schedule: drain, check drained invariants, prove a fresh write still admits. */
+/** Finish a schedule: drain, check drained invariants, prove a fresh write still admits, and drain that write's effects. */
export async function finish(world: World, model: ReferenceModel, label: string, drainMs: number = DRAIN_BOUND_MS[world.engine.kind]): Promise<void> {
const drained = await drain(world.engine, world, drainMs);
if (!drained) model.violate({ class: 'wedge', detail: `${label}: requests or effects did not drain within ${drainMs / 1000} s` });
@@ -104,6 +104,9 @@ export async function finish(world: World, model: ReferenceModel, label: string,
const seen = await executeOp(world, probe);
if (seen.status !== 'committed') model.violate({ class: 'wedge', detail: `${label}: a fresh write after the schedule ended ${seen.status}/${seen.code}` });
await awaitClaimPass(world);
+ // The probe's own effects (its git commit among them) reach their seams only if the worker waits for them: a count
+ // role that happened to see the probe's effect:git:mid planned a fault no run was sure to reach (seed 5105).
+ if (!await drain(world.engine, world, drainMs)) model.violate({ class: 'wedge', detail: `${label}: the probe's effects did not drain within ${drainMs / 1000} s` });
}
/**
diff --git a/test/persistence-crash-robot.test.ts b/test/persistence-crash-robot.test.ts
index 5527db2fdb..72b808c3f0 100644
--- a/test/persistence-crash-robot.test.ts
+++ b/test/persistence-crash-robot.test.ts
@@ -449,6 +449,23 @@ process.stdout.write('{"event":"continued"}\\n');
});
}, 90_000);
+ test('seed 5105: finish drains its probe\'s effects, so the probe\'s effect:git:mid a count role may see is reached in every run', async () => {
+ await robotBrain(async ({ world }) => {
+ const reached: string[] = [];
+ world.claimPasses = 0;
+ // Every effect seam is slow, so the probe's git effect reaches its seam only when finish waits for it.
+ installFaultHook(async (point, detail) => {
+ if (point === 'consumer:claiming') { world.claimPasses!++; return; }
+ if (!point.startsWith('effect:')) return;
+ await Bun.sleep(1500);
+ reached.push(`${point}:${detail.requestId}`);
+ });
+ try { await finish(world, new ReferenceModel(world), 'probe only'); }
+ finally { installFaultHook(undefined); }
+ expect(reached.filter(seam => seam.startsWith('effect:git:mid:'))).toHaveLength(1);
+ });
+ }, 90_000);
+
test('a hook that cannot report its fault emits fault_hook_error and still freezes', async () => {
const { lines, alive } = await hookChild(`const cyclic: Record<string, unknown> = {}; cyclic.self = cyclic;
await faultPoint('effect:git:mid', { requestId: 'r1', signal: cyclic as never });`);