Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Wave B PR 3: flip the append and over-ceiling upload todos; three BEHAVIOR rows (since TBD)
garrytan1009e96f200a
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 60a47a2a6e..3f19c4b103 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -967,6 +967,9 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.315.0', text: '`delete_page purge: true` (`gbrain delete --purge`) of a page stored in segments now also deletes, in the purge, the segment texts the page stopped referencing within the last hour, which used to stay in `page_segment_texts` until the hourly segment sweep removed them. A withdrawal (`forget`, `forget_fact`) followed by another write to the page (a delete and `restore_page` included) left the text that held the withdrawn row, with the page text around it, in that state, and the purge reported success. The purge also deletes every unreferenced segment text of the source that holds one of the page\'s claims (its facts, withdrawn ones included, and its takes), plain or as a facts-fence cell stores it, which covers a text another page\'s write reused after the page\'s own write record of it expired. `removed.page_segment_texts` in the purge receipt counts these texts too, and the receipt\'s `page_segment_texts` store checks for them. A text that an unpublished write of another page staged is still kept, as before for the texts the page referenced.' },{ since: '0.60.315.0', text: '`purge_fact` (`gbrain forget <id> --purge`) of a claim containing `|` now also deletes the unreferenced segment texts that hold the claim as its facts-fence cell stores it (`|` escaped as `\\|`, a line break as `<br>`), in the purge. It matched only the claim\'s exact bytes, so after a withdrawal and another write to a page stored in segments (a delete and `restore_page` included) the text holding the old fence row stayed until the hourly segment sweep, and the receipt\'s `page_segment_texts` store did not report it. The receipt now probes both forms.' },{ since: '0.60.315.0', text: 'A managed write the database interrupts under load is now retried with backoff instead of failing at the second interruption. A statement the database ends with a statement timeout or cancel (SQLSTATE 57014) and, new, a publication the owner cancels past `persistence.publication_ceiling_ms` (until now released and published again without limit, or on Postgres sometimes failed `storage_error` at once) count against their own budget, `persistence.max_transient_retries` (default 5, 0 to 20), instead of `persistence.max_preparation_attempts`: each one schedules the request\'s next claim after 1 s, 2 s, 4 s, 8 s, then 15 s (stored on the request, so nothing is held while it waits; `gbrain sources writer status` names the waiting head `transient_backoff`), and the interruption after the last retry ends it `failed` with `write_interrupted` as before. Its receipt names the interruptions (`attempts`), the retry limit (`limit`, `limit_key`), the cause (`statement_cancel` or `publication_ceiling`) and the SQLSTATE. An interruption of a grouped publication (a `put_pages` batch, a managed import batch or a sync lane group) counts against every member of the group, and a member already charged an interruption is claimed and published on its own from then on, so a batch that overruns only as a whole still commits page by page. Preparations cut off at their deadline still count against `persistence.max_preparation_attempts` alone, and lock timeouts, serialization failures, deadlocks and lost connections are still never counted. `persistence.preparation_deadlines false` turns this counting and the backoff off with the deadlines. Upgrading adds two columns to `persistence_requests` (migration v261, no rewrite of existing rows).' },+ { since: 'TBD', text: 'New `append_page` adds text to the end of a page in time proportional to the text added, idempotent by `request_id`; use it for conversation logs instead of re-putting the page. `expected_tail_sha256` (the `tail_sha256` that `get_page` with `body: \'none\'` returns) refuses `tail_changed` when another writer appended first. `gbrain append <slug> [--file f | stdin]` calls it.' },+ { since: 'TBD', text: 'New upload sessions (`begin_page_upload`, `upload_page_part`, `get_page_upload`, `commit_page_upload`, `abort_page_upload`) let remote and thin clients write pages larger than one request, up to the page ceiling; `gbrain put --file` and `gbrain capture --file` use them on remote brains. A session is bound to the principal, source and page that began it (any other caller gets `upload_not_found`), staged bytes count against `persistence.limits` upload quotas (`write_quota_exhausted`), and an idle session expires after an hour. Locally, `gbrain put --file` and `gbrain capture --file` stream a file over 24 MiB straight in.' },+ { since: 'TBD', text: '`edit_page` accepts `within` to restrict a match to a range returned by a window read (`edit_target`), and edits a page stored in segments by rewriting only the segments the match touches instead of reading the whole page back.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/test/cli-page-writes.test.ts b/test/cli-page-writes.test.tsindex 7b9dea4aa2..843c689812 100644--- a/test/cli-page-writes.test.ts+++ b/test/cli-page-writes.test.ts@@ -133,8 +133,7 @@ for (const backend of testBackends()) {expect(region.stderr).toContain('--region must be one of: auto, truth, timeline');}, 60_000);- // todo: an append over one request needs commit_page_upload mode append, which is not wired yet; flip when it lands.- test.todo('append over one request goes through an upload session and lands whole', async () => {+ test('append over one request goes through an upload session and lands whole', async () => {await cli(['put', 'notes/big-append', '--file', file('big-append.md', '# Big append\n\nstart\n')]);const line = `- ${ESCAPE_HEAVY} message\n`;const text = line.repeat(Math.ceil((1.5 * 1024 * 1024) / Buffer.byteLength(line)));@@ -146,8 +145,7 @@ for (const backend of testBackends()) {expect(printedBody(read.stdout).trimEnd()).toBe(`# Big append\n\nstart\n${text}`.trimEnd());}, 300_000);- // todo: begin_page_upload refuses total_bytes over PAGE_MAX_BYTES until segmented upload commits land; flip when they do.- test.todo('local put --file over the page ceiling on a managed brain goes through an upload session, byte-identical', async () => {+ test('local put --file over the page ceiling on a managed brain goes through an upload session, byte-identical', async () => {const managed = async () => (await sql<{ enabled: boolean }>('SELECT enabled FROM persistence_brain'))[0]!.enabled;if (!await managed()) {await registerLocalWriter(pg!, 'cli');diff --git a/test/e2e/upload-transport.test.ts b/test/e2e/upload-transport.test.tsindex d122b2d031..98379b4023 100644--- a/test/e2e/upload-transport.test.ts+++ b/test/e2e/upload-transport.test.ts@@ -241,8 +241,7 @@ for (const backend of backends) describe(`upload sessions over every transport (});}, 600_000);- // todo: commit_page_upload with mode append is not wired yet (admitStagedAppend answers unavailable); flip it, and the page count below to 5, when it lands.- test.todo('OAuth /mcp: the thin client append over one request rides an upload session (mode append)', async () => {+ test('OAuth /mcp: the thin client append over one request rides an upload session (mode append)', async () => {await withOAuthServe('append', async (_client, thinHome) => {const big = escapeHeavy(2 * MIB);writeFileSync(join(thinHome, 'big.md'), big);@@ -280,6 +279,6 @@ for (const backend of backends) describe(`upload sessions over every transport (const body = page!.timeline ? `${page!.compiled_truth}\n${page!.timeline}` : page!.compiled_truth;expect({ slug, bytes: Buffer.byteLength(body), same: body === text }).toEqual({ slug, bytes: Buffer.byteLength(text), same: true });}- expect(expected.size).toBe(4);+ expect(expected.size).toBe(5);}, 300_000);});