Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(facts): a page write bound to a revision read before the sweep lands (#6264 stale Facts value)

garrytan5e98410e1a73
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 403e19d3da..55433ef624 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,7 +28,7 @@ Since v0.60.53.0 the facts step of the maintenance run (the sweep `gbrain serve`
- `planUnfencedFacts` (`src/core/facts/unfenced-facts.ts`) and the empty-fence guard in `src/core/cycle/extract-facts.ts` select `dimension IS NULL` rows only. The fence step stays source-wide: the rows it fences are the inline writer's database-only facts, which mostly land on pages the run's slug list doesn't name.
- `src/core/repair/ontology-facts.ts` finds ontology rows with a fence row number or a `source_markdown_slug` other than their `source` (ontology writes produce neither) and restores them through `ontology_propose`'s coordinated database-only write on managed brains.
-- `test/ontology-fence-sweep.test.ts` (PGLite, Postgres through `test/e2e/ontology-fence-sweep-postgres.test.ts`) runs the N1-7 repro (observation, sweep, page rewrite, sweep) on managed and unmanaged brains, the reconcile guard, and the repair from damage made by the old fence step.
+- `test/ontology-fence-sweep.test.ts` (PGLite, Postgres through `test/e2e/ontology-fence-sweep-postgres.test.ts`) runs the N1-7 repro (observation, sweep, page rewrite, sweep) on managed and unmanaged brains, a page write bound to a revision read before the sweep (it failed with `revision_conflict` before the fix), the reconcile guard, and the repair from damage made by the old fence step.
## To take advantage of v0.60.104.0
diff --git a/test/ontology-fence-sweep.test.ts b/test/ontology-fence-sweep.test.ts
index 78bdefba3d..157fa8ce64 100644
--- a/test/ontology-fence-sweep.test.ts
+++ b/test/ontology-fence-sweep.test.ts
@@ -129,6 +129,19 @@ for (const backend of testBackends()) {
}, 120_000);
}
+ test(`${backend}: managed: a page write bound to a revision read before the sweep still lands, so the page serves its new Facts value`, async () => {
+ await managedBrain(async ({ engine, ctx }) => {
+ await put(ctx, page('Alder Example likes example tea'));
+ await propose(ctx, 'location', 'Example City', '2026-02-01');
+ // The client reads the page, the idle sweep runs, then the client writes the page back.
+ const read = await op(ctx, 'get_page', { slug: SLUG, include_content: true });
+ await sweep(engine);
+ await op(ctx, 'put_page', { slug: SLUG, content: page('Alder Example likes example coffee'), expected_revision: read.revision });
+ const fence = parseFactsFence((await engine.getPage(SLUG, { sourceId: 'default' }))!.compiled_truth).facts;
+ expect(fence.filter(f => f.active).map(f => f.claim)).toEqual(['Alder Example likes example coffee']);
+ }, { databaseUrl });
+ }, 120_000);
+
test(`${backend}: unmanaged: an ontology observation does not hold up the extract_facts reconcile of its page`, async () => {
await unmanagedBrain(databaseUrl, async ({ engine, ctx, write }) => {
await write(page('Alder Example likes example tea'));