Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: managed-facts unchanged_replay restores the publish wait before replaying (flake fix)

garrytanf08cbbde4b94
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 184ea2906e..2afaa6e4f4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ identifiers and attribution are available in the pre-removal Git revision
- **`degraded_recall` shows on every affected call on stdio and the CLI.** Transient degradations (`rerank_failed`, `embed_timeout`, a failed keyword or title arm, every other per-call stage) are no longer deduped per session, so a failure after a different earlier failure, or the same failure after a recovery, always carries its notice. A notice made only of configuration-persistent stages (a keyless brain's `embed_unavailable`, about 600 characters on every search otherwise) carries an unrendered `dedupe_key` of its sorted unique stage/reason pairs, which the notice ledger dedupes on per session and the wire never shows. HTTP stays per call. `docs/protocol/AGENT_OPERATOR_v1.md` now states one rule for stdio, CLI and HTTP.
- **`entity names[]` is 5 to 17 times faster on a large brain, with byte-identical output.** On a 55,838-page PGLite brain built from the Cat 40 Hard world M generator (seed 20261021, no embeddings), a 20-name batch's median went from 2,250 ms to 129 ms with every name found, from 1,743 ms to 155 ms with half found, and from 1,112 ms to 203 ms with none found. Profiling showed the name lookup itself dominated, not the cards: each found name ran two sequential scans of the source's pages, the alias resolver's "no other live page has this exact title" check and the card's exact-title / exact-slug / slug-suffix arm, about 50 ms each. Migration v240 adds `idx_pages_source_title_lower` (`source_id, lower(title)`) and a trigram index on `slug` (`idx_pages_slug_trgm`), built online on Postgres; the queries are unchanged and now run as index scans in about 1 ms. Single-name `entity`, context_pack cards and search's alias fan-out use the same two reads. The batch also stops assembling a full card per name it then threw away: candidate selection is now one exported function, `selectEntityCandidates`, that `buildEntityCard` and `lookupEntityNames` both call; the lead reuses the candidate row's body; siblings are read without the identity excerpt (`readSiblingIdentity`); and the private-page setting, mention policy and source pack are read once per batch (`entityLookupScope`). Parity tests compare the batch with the old full-card resolver over adversarial names (colliding aliases and titles, namespaced slugs, the same slug in two sources, private, deleted and quarantined candidates, identity siblings, stale aliases, LIKE wildcards) on PGLite and Postgres, and plan tests pin both reads to the new indexes.
- **A Postgres statement timeout in the keyword or title arm is reported as a timeout (#6495).** `isTimeoutError` (`src/core/search/hybrid/degraded.ts`) now recognizes SQLSTATE 57014 through `isStatementTimeoutError`, so the arms' 8 s `SET LOCAL statement_timeout` on a large brain stamps `keyword_arm_failed` / `title_arm_failed` with reason `timeout` instead of `provider_error`. Probe in `test/hybrid-arm-rethrow.test.ts` (fails before).
+- **Flake fix: the managed-facts `unchanged_replay` case no longer replays under its 250 ms deferral wait.** The scenario shortens the maintenance publish wait so the first `extract_facts` call returns `write_pending`, but the shortened wait stayed in force for the replay that must succeed, so on a loaded host the replay's publish missed 250 ms and returned `write_pending` too (seen on a Ubicloud gate in `test/e2e/managed-facts-embedding.test.ts`). The helper restores the normal wait before the replay; a forced probe shrinking the deferral wait to 1 ms fails before and passes after.
- **Flake fix: `test/pglite-repair-command.serial.test.ts` case 1 no longer writes a fixed PID 99999 as its stale `postmaster.pid`.** On a busy host that PID can belong to a live process, so validation correctly refused ("postmaster.pid names a LIVE process") and the dry-run assertion failed (seen on a Ubicloud gate). The case now uses the file's `deadPid()` helper; a forced probe writing a live PID reproduces the failure.
## [0.60.187.0] - 2026-10-12
diff --git a/test/helpers/managed-facts-embedding-contract.ts b/test/helpers/managed-facts-embedding-contract.ts
index d29a634bf0..04f54986be 100644
--- a/test/helpers/managed-facts-embedding-contract.ts
+++ b/test/helpers/managed-facts-embedding-contract.ts
@@ -99,6 +99,8 @@ export async function exerciseManagedEmbedding(engine: BrainEngine, scenario: Ca
const result = await publishMutation(engine, row, prepared, localHostId());
expect(result.state).not.toBe('committed');
} else if (scenario === 'unchanged_replay') {
+ restoreWait();
+ restoreWait = () => {};
expect(await run()).toMatchObject({ inserted: 1 });
expect(await engine.executeRaw('SELECT id FROM facts WHERE source_id=$1 AND embedding IS NOT NULL', [sourceId])).toHaveLength(2);
} else {