Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

large pages switch-on: one getConfig site in readPageBodyPolicy; tag the writer-floor structural source read

garrytan0f15bcfbe032
diff --git a/src/core/page-body/limits.ts b/src/core/page-body/limits.ts
index b454cc60cd..7bf6b80202 100644
--- a/src/core/page-body/limits.ts
+++ b/src/core/page-body/limits.ts
@@ -198,8 +198,8 @@ export function pageRecoveryBytes(kind: BrainEngine['kind'], switchRaw: string |
* (only a missing row is unset, which means on). A configured `pages.max_bytes` never exceeds the engine ceiling.
*/
export async function readPageBodyPolicy(engine: PolicyEngine): Promise<PageBodyPolicy> {
- const read = (key: string) => engine.getConfig(key).catch(() => null);
const readOrFail = (key: string) => engine.getConfig(key).then(value => ({ value }), () => null);
+ const read = async (key: string) => (await readOrFail(key))?.value ?? null;
const [switchRead, maxRead, retireRaw, versionsRaw, pinnedRaw] = await Promise.all([
readOrFail(PAGE_BODY_CONFIG_KEYS.segmentedStorage), readOrFail(PAGE_BODY_CONFIG_KEYS.maxBytes), read(PAGE_BODY_CONFIG_KEYS.flipRetireMaxRows),
read(PAGE_BODY_CONFIG_KEYS.versionsMaxPerPage), read(PAGE_BODY_CONFIG_KEYS.versionsMaxPinnedBytes),
diff --git a/test/large-pages/segmented-writer-floor.test.ts b/test/large-pages/segmented-writer-floor.test.ts
index 24c2ac9832..4cb85a8ce4 100644
--- a/test/large-pages/segmented-writer-floor.test.ts
+++ b/test/large-pages/segmented-writer-floor.test.ts
@@ -26,6 +26,7 @@ test('SEGMENTED_WRITER_FLOOR follows the switch-on BEHAVIOR_CHANGES row\'s since
// The merge-slot stamp edits only allowlisted lines (the row's since, VERSION, the CHANGELOG header): the floor
// holds no version of its own. A stamp that writes the CHANGELOG entry turning the switch on but forgets the since
// fails here.
+ // test-reads-source-ok[structural]: the stamp contract is that writer-floor.ts carries no version literal of its own.
expect(readFileSync(join(import.meta.dir, '../../src/core/page-body/writer-floor.ts'), 'utf8')).not.toMatch(/'\d+\.\d+\.\d+\.\d+'/);
const announcing = readFileSync(join(import.meta.dir, '../../CHANGELOG.md'), 'utf8').split(/^## /m).slice(1)
.filter(entry => /`pages\.segmented_storage`\)? (?:is )?(?:now )?on by default/i.test(entry)).map(entry => /^\[([^\]]+)\]/.exec(entry)?.[1]);