Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

GBRA-161 PR 1a: atom input size reads body_bytes only for a segmented page (reviewed META reader row)

garrytan08e2ad90e353
diff --git a/scripts/page-body-readers-baseline.tsv b/scripts/page-body-readers-baseline.tsv
index 0718e53554..4642f7f7e7 100644
--- a/scripts/page-body-readers-baseline.tsv
+++ b/scripts/page-body-readers-baseline.tsv
@@ -609,3 +609,4 @@ src/core/generations/adapters/page.ts preimageIdentity field NONE hashes a ledge
src/core/generations/adapters/page.ts preimageMarkdown call:serializeMarkdown NONE serializes a ledger preimage JSON copy for restore; segmented and oversize pages have no preimage
src/core/generations/adapters/page.ts preimageMarkdown field NONE reads the body field of a ledger preimage JSON copy; segmented and oversize pages have no preimage
src/core/generations/adapters/page.ts pageVersionEvidence sql INLINE legacy-adoption evidence: hashes retained page_versions copies of derived atom pages and compares identity hashes only; segmented versions (compiled_truth NULL) are skipped
+src/core/generations/adapters/atoms.ts atomGenerationAdapter sql META input size only: body_bytes for a segmented page, octet_length of an inline page columns (pages leave body_bytes NULL inline)
diff --git a/src/core/generations/adapters/atoms.ts b/src/core/generations/adapters/atoms.ts
index 701535f973..fdce66b518 100644
--- a/src/core/generations/adapters/atoms.ts
+++ b/src/core/generations/adapters/atoms.ts
@@ -62,7 +62,7 @@ export const atomGenerationAdapter: GenerationAdapter<AtomGenerationContext> = {
if (origin.field === 'source_path') return context?.transcriptInput ?? null;
const [row] = await engine.executeRaw<{ id: number; content_hash: string | null; revision: string | null; body_bytes: number | null }>(
`SELECT id, content_hash, knowledge_revision::text AS revision,
- COALESCE(body_bytes, octet_length(COALESCE(compiled_truth, '')) + octet_length(COALESCE(timeline, ''))) AS body_bytes
+ CASE WHEN body_storage = 'segmented' THEN body_bytes ELSE octet_length(COALESCE(compiled_truth, '')) + octet_length(COALESCE(timeline, '')) END AS body_bytes
FROM pages WHERE source_id=$1 AND slug=$2 AND deleted_at IS NULL`, [key.sourceId, origin.value]);
return row?.content_hash ? { pin: atomPagePin(row.content_hash, row.revision ? { pageId: Number(row.id), revision: row.revision } : undefined), size: Number(row.body_bytes ?? 0) } : null;
},