Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Master merge follow-up: read budget names a remote segmented read's projected size, streamed-crash probe lapses the dead drain lease, migrations golden for the shared index helpers

garrytana7eace6c3802
diff --git a/src/core/minions/tools/read-budget.ts b/src/core/minions/tools/read-budget.ts
index 444bdf9bdf..130e974578 100644
--- a/src/core/minions/tools/read-budget.ts
+++ b/src/core/minions/tools/read-budget.ts
@@ -8,7 +8,9 @@
*
* Sizes are the bytes of the returned result, never a page body read here, so
* a segmented page (no body string) is sized like any other read; the summary
- * names its stored `size.body_bytes` when the result carries it. The excerpt
+ * names the body size the result carries: `size.body_bytes`, or a segmented
+ * page's read-view `size.total_bytes` for a remote caller, who is never told
+ * the stored size (as an inline page reports its privacy-stripped body). The excerpt
* is a bounded prefix of the rendered `content` (or a window's `text`) the
* result already holds.
*/
@@ -34,7 +36,8 @@ export async function budgetedPageRead(engine: BrainEngine, jobId: number, budge
const page = (output && typeof output === 'object' ? output : {}) as Record<string, unknown>;
const rendered = typeof page.content === 'string' ? page.content : typeof page.text === 'string' ? page.text : '';
const excerpt = boundedRawPrefix(rendered, Math.max(0, Math.min(READ_BUDGET_EXCERPT_BYTES, budgetBytes - used)));
- const bodyBytes = (page.size as { body_bytes?: unknown } | undefined)?.body_bytes;
+ const size = page.size as { body_bytes?: unknown; total_bytes?: unknown } | undefined;
+ const bodyBytes = size?.body_bytes ?? size?.total_bytes;
return {
slug: typeof page.slug === 'string' ? page.slug : slug,
...(typeof page.title === 'string' ? { title: page.title } : {}),
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 41aab8b127..47f527e31d 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -3838,10 +3838,13 @@
"form": "arrow",
"helpers": [
"CONTENT_CHUNKS_GENERATION_INDEX",
+ "PLANNER_REPAIR_TABLES",
+ "analyzeAfterIndexBuild",
"buildIndexOnline",
"dropInvalidConcurrentIndex",
"migrationNotice",
- "quietMigrationNotices"
+ "quietMigrationNotices",
+ "tableRows"
],
"sha256": "04311e56cedf0fa4c64828548231ceda89ed68f6e2038d7ece7a907d3e3c413f"
},
@@ -3874,10 +3877,13 @@
"form": "arrow",
"helpers": [
"INGEST_LOG_UNMARKED_INDEX",
+ "PLANNER_REPAIR_TABLES",
+ "analyzeAfterIndexBuild",
"buildIndexOnline",
"dropInvalidConcurrentIndex",
"migrationNotice",
- "quietMigrationNotices"
+ "quietMigrationNotices",
+ "tableRows"
],
"sha256": "27ceabcd9bfa28c5d7a44c370130e228e786127d7770032bde890d2caa7e9b27"
},
diff --git a/test/large-pages/managed-sync-streamed-crash.test.ts b/test/large-pages/managed-sync-streamed-crash.test.ts
index 93ead4ccae..4f80dd7193 100644
--- a/test/large-pages/managed-sync-streamed-crash.test.ts
+++ b/test/large-pages/managed-sync-streamed-crash.test.ts
@@ -25,6 +25,7 @@ import { PAGE_MAX_BYTES } from '../../src/core/page-size-policy.ts';
import { BODY_STAGING_HARD_MS } from '../../src/core/page-body/limits.ts';
import { claimWorktree } from '../../src/core/persistence/ownership.ts';
import { performManagedSync } from '../../src/core/persistence/sync-run.ts';
+import { syncLockId } from '../../src/core/db-lock.ts';
import { disposePersistenceConsumer } from '../../src/core/persistence/service.ts';
import { withEnv } from '../helpers/with-env.ts';
import { conversationPage } from '../helpers/conversation-page.ts';
@@ -87,6 +88,8 @@ test('an owner killed between preparation and publication: the next run re-prepa
// The dead owner's claim lapses, as its lease would; the next run's owner reclaims the request and prepares it again.
await engine.executeRaw("UPDATE persistence_requests SET claim_expires_at=now()-interval '1 second' WHERE source_id=$1 AND state='running'", [sourceId]);
+ // So does its drain lease (#6712): a dead same-host holder is taken over once its lease is older than the takeover grace.
+ await engine.executeRaw("UPDATE gbrain_cycle_locks SET acquired_at=now()-interval '2 minutes' WHERE id=$1 AND holder_pid=$2", [syncLockId(sourceId), child.pid]);
let result = await performManagedSync(engine, { sourceId, noPull: true, noEmbed: true });
for (let pass = 0; result.status === 'partial' && pass < 30; pass++) result = await performManagedSync(engine, { sourceId, noPull: true, noEmbed: true });
expect(result.status).toBe('first_sync');