Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(contract): settle the sweep's queued loops_extract before embed_backfill and the thread facts case
garrytan389cda4bd919
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 492511cd65..fe1737c066 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ There is nothing to do. `ubi-runner.sh` is a contributor tool: `gbrain upgrade`### For contributors- `test/scripts/ubi-runner.test.ts` forces the lost trap for `up` and `run` on every run: `BASH_ENV` turns on xtrace with a `PS4` that sends the runner SIGTERM, then makes bash parse a `$(...)` with that trap pending.+- The managed connector job contract's `embed_backfill` and `extract_conversation_facts_thread` cases cancel the `loops_extract` job the Gmail sweep queued before running their own worker. Left waiting, that worker could run it afterwards: its commitment fact republished a page as a chunk not yet embedded (`embed_backfill` read 1 of 2 embedded) or wrote the facts the thread case asserts never appear.## [0.60.79.0] - 2026-10-06diff --git a/test/helpers/managed-connector-job-contract.ts b/test/helpers/managed-connector-job-contract.tsindex a45b481199..b331b60b49 100644--- a/test/helpers/managed-connector-job-contract.ts+++ b/test/helpers/managed-connector-job-contract.ts@@ -622,6 +622,9 @@ const cases: Record<ContractCase, (state: CaseState) => Promise<void>> = {*/async extract_conversation_facts_thread(state) {await gmailSweep(state, { reply: true });+ // The sweep queued loops_extract (priority 5). Left waiting, this case's worker can+ // claim it once the facts job finishes, and its commitment fact is a facts write.+ await state.brain.engine.executeRaw("UPDATE minion_jobs SET status='cancelled' WHERE id > $1 AND status IN ('waiting','delayed')", [state.detector.jobsFrom]);const [job] = await runJobs(state.brain.engine, [{ name: 'extract-conversation-facts', data: { sourceId: state.sourceId } }]);requireCompleted([job]);expect((await changesSince(state)).filter(c => c.tbl === 'facts')).toEqual([]);@@ -721,6 +724,11 @@ const cases: Record<ContractCase, (state: CaseState) => Promise<void>> = {async embed_backfill(state) {await gmailSweep(state);const { engine } = state.brain;+ // The sweep queued loops_extract (priority 5). Left waiting, the embed-backfill worker+ // can claim it once embed-backfill finishes; its commitment fact republishes+ // people/alice-example as a new chunk whose embedding effect has not run when the+ // count below is read.+ await engine.executeRaw("UPDATE minion_jobs SET status='cancelled' WHERE id > $1 AND status IN ('waiting','delayed')", [state.detector.jobsFrom]);if (engine.kind === 'pglite') {// PGLite has no persistent worker surface: the queue refuses the job up// front and names the inline command, which this lane then runs.