Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/mpw-integration
garrytan5812d72ef523
diff --cc test/managed-sync-foreground-priority.test.tsindex b75b8366bc,5dbbc6ce02..228c5d0046--- a/test/managed-sync-foreground-priority.test.ts+++ b/test/managed-sync-foreground-priority.test.ts@@@ -98,14 -98,19 +98,23 @@@ async function writeDuringDrain(lanes:// `laneHold`, once the write is sent each lane group that has applied its pages holds before its commit turn (no// counter lock held) until the write commits or `laneHold` ms pass, and `beside` records, for each foreground// publication in this process, whether a lane group was then open.- let laneOpen = 0, armed = false;+ let laneOpen = 0, armed = false, holdStarts = false;const beside: boolean[] = [];const written = Promise.withResolvers<void>();+ // Without `laneHold`, from the moment 4 unstarted groups are seen until `before` is read, each lane parks its group+ // at `lane:applied`, so no lane starts another group and the groups queued ahead of the write stay queued however+ // long the write takes to be admitted (each lane can take at most one more group before it parks).+ const counted = Promise.withResolvers<void>();+ // With `preparingHoldMs`, whichever process claims the write holds its preparation that long, and this process stamps+ // its claims with another process's owner, so either way the write is claimed elsewhere and unpublished meanwhile.+ let heldHere: [number, number] | undefined;+ if (preparingHoldMs) setClaimOwnerForTest({ kind: 'mcp', pid: 1, version: 'test', nonce: 'another-process' });installFaultHook(async (point, detail) => {+ if (preparingHoldMs && point === 'consumer:preparing' && detail.operation === 'put_page' && !heldHere) {+ const start = Date.now();+ await Bun.sleep(preparingHoldMs);+ heldHere = [start, Date.now()];+ }if (detail.sourceId !== source) return;if (point === 'publication:before_commit' && detail.operation !== 'submit_job') beside.push(laneOpen > 0);if (point === 'publication:after_commit' && detail.operation !== 'submit_job') written.resolve();@@@ -147,14 -149,10 +156,11 @@@&& !(row.grp && started.has(row.grp)));return true;});+ counted.resolve();- const writes = await finish();- // A request's claim is its first claim by either process (a claim released and taken again does not move it).- for (const [id, at] of Object.entries(writes.claims)) recorder.claims.set(id, Math.min(at, recorder.claims.get(id) ?? Infinity));- const [written] = writes;+ const [written] = await finish();const result = await drain;- return { source, target, before, written: written!, result, claims: recorder.claims, final: await rows(e, source), beside };- } finally { counted.resolve(); recorder.restore(); installFaultHook(undefined); }+ return { source, target, before, written: written!, result, claims: recorder.claims, final: await rows(e, source), beside, held: heldHere ?? written!.held };- } finally { recorder.restore(); installFaultHook(undefined); setClaimOwnerForTest(undefined); }++ } finally { counted.resolve(); recorder.restore(); installFaultHook(undefined); setClaimOwnerForTest(undefined); }}for (const lanes of [2, 1]) {