Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(facts): carry PR #6515's managed enumeration regressions for #6500

garrytand026f842197e
diff --git a/test/conversation-facts-managed.test.ts b/test/conversation-facts-managed.test.ts
index 8b2fe1f2f4..e5391b6795 100644
--- a/test/conversation-facts-managed.test.ts
+++ b/test/conversation-facts-managed.test.ts
@@ -14,6 +14,15 @@
* model call; a source this host does not own preflights only when a page
* needs work. Runs on PGLite, and on
* Postgres through test/e2e/conversation-facts-managed-postgres.test.ts.
+ *
+ * The two #6500 regressions (a slug keyset draining a 23-page timestamp tie
+ * without crossing the source, type or soft-deletion fences; a 13-page
+ * extraction walk whose oldest unvisited page is edited mid-run and is still
+ * visited exactly once with one committed request) were contributed by
+ * @javieraldape in PR #6515. They already pass on master: #6516 adopted the
+ * production fix before they were folded, and their discrimination is
+ * historical (16 pass / 2 fail against the pre-fix extractor 2895edb3). They
+ * are carried as durable regressions, not as fail-first evidence (wave 16 R28).
* Seams: the Core's injected extractor (no gateway), the persistence fault
* hook (to stall publication), the maintenance wait and batch-cap test seams.
*/
@@ -90,6 +99,57 @@ async function requests(engine: BrainEngine) {
for (const backend of testBackends()) {
const databaseUrl = backend === 'postgres' ? requirePostgresTestDatabase() : undefined;
+ // #6500 regression (PR #6515, already green on master; see the header): the keyset listing honours every fence in a tie cluster.
+ test(`${backend}: slug keysets drain timestamp ties without crossing type, source or deletion fences`, async () => {
+ const slugs = Array.from({ length: 23 }, (_, i) => `meetings/tied-${String(i).padStart(2, '0')}`);
+ await managedBrain(async ({ engine }) => {
+ const seen: string[] = [];
+ let slugAfter: string | undefined;
+ while (true) {
+ const batch = await engine.listPages({ sourceId: 'default', type: 'meeting', sort: 'slug', slugAfter, limit: 10 });
+ if (!batch.length) break;
+ seen.push(...batch.map(page => page.slug));
+ slugAfter = batch.at(-1)!.slug;
+ }
+ expect(seen).toEqual(slugs);
+ }, { databaseUrl, setup: async ({ engine }) => {
+ await engine.executeRaw("INSERT INTO sources (id, name) VALUES ('other', 'Other')");
+ const page = { type: 'meeting' as const, title: 'Tied', compiled_truth: transcript(), timeline: '', frontmatter: {} };
+ for (const slug of [...slugs].reverse()) await engine.putPage(slug, page);
+ await engine.putPage(slugs[0]!, page, { sourceId: 'other' });
+ await engine.putPage('meetings/tied-other-type', { ...page, type: 'person' });
+ await engine.putPage('meetings/tied-deleted', page);
+ await engine.softDeletePage('meetings/tied-deleted', { sourceId: 'default' });
+ await engine.executeRaw("UPDATE pages SET updated_at='2026-09-28T12:00:00Z'");
+ } });
+ }, 120_000);
+
+ // #6500 regression (PR #6515, already green on master; see the header): the production loop survives a mid-run edit.
+ test(`${backend}: corpus enumeration visits each page once when an unvisited page moves ahead of the cursor`, async () => {
+ await managedBrain(async brain => {
+ const { engine } = brain;
+ const slugs = Array.from({ length: 13 }, (_, i) => `meetings/walk-${String(i).padStart(2, '0')}`);
+ for (const slug of [...slugs].reverse()) await putPage(brain, transcript(` ${slug}`), slug);
+ // The oldest page starts outside the first ten-page batch. Editing it
+ // during extraction puts it ahead of updated_desc's OFFSET cursor.
+ const oldest = (await engine.listPages({ sourceId: 'default', type: 'meeting', sort: 'updated_asc', limit: 1 }))[0]!.slug;
+ const visited: string[] = [];
+ const result = await runExtractConversationFactsCore(engine, {
+ sourceId: 'default', types: ['meeting'], force: true, sleepMs: 0, overrideDisabled: true,
+ extractor: async ({ turnText }) => {
+ visited.push(slugs.find(slug => turnText.includes(slug))!);
+ if (visited.length === 1) await putPage(brain, transcript(` ${oldest} edited`), oldest);
+ // Empty facts still produce a durable terminal outcome in the batch.
+ return [];
+ },
+ });
+ expect([...visited].sort()).toEqual(slugs);
+ expect(result).toMatchObject({ pages_processed: slugs.length, pages_failed: 0 });
+ expect(await requests(engine)).toEqual([{ state: 'committed', error_code: null }]);
+ for (const slug of slugs) expect(await factsOf(engine, slug)).toEqual(['EXTRACTION_COMPLETE']);
+ }, { databaseUrl });
+ }, 120_000);
+
test(`${backend}: a transcript's facts and outcome commit in one receipted request; the frozen batch round-trips through JSONB`, async () => {
await managedBrain(async brain => {
const { engine } = brain;