Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(adopt): #8755 e forced probe (adoption never reads an oversized file); BEHAVIOR_CHANGES rows for GST-1623 items 4, 6-9 and #8755
garrytan491c80a384ec
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex c208f9110f..167e0a46b6 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1473,6 +1473,11 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.594.0', id: 'file_drift_held_needs_prefer_8615', text: '`gbrain repair file-drift` with `--held`, `--side`, `--state`, `--cursor` or `--provenance` and no `--prefer` now refuses with the usage line (`invalid_params`, and `file_drift_state_required` for a deleted side without `--state`) instead of silently running the all-drifted survey, which counted a different set of pages (#8615).' },{ since: '0.60.594.0', id: 'refresh_source_changed_retry_8617', text: 'A `gbrain sources refresh` run refused `refresh_source_changed` because the checkout HEAD moved (a writer committing) or work reached the checkout after the drain check now retries once from a fresh precheck in the same run, so the tick is not lost (#8617). When the retry is refused too, the run returns the first `refresh_source_changed` refusal with the retry\'s cause appended; ownership or source-membership changes are not retried.' },{ since: '0.60.594.0', id: 'commit_push_checkout_not_a_source_8662', text: '`gbrain git commit-push` now refuses `checkout_not_a_source` before staging anything when this brain home records its source checkouts (a managed brain) and the checkout it resolved from the working directory (no `--path`) is none of them and has no `gbrain.sourceRoot`, for example a wrapper that changed into another repository (#8662). The refusal names the resolved path and the brain\'s checkouts; pass `--path` with the absolute brain checkout. Hosts whose brain records no source checkout behave as before.' },+ // GST-1623 items 4 and 6-9, #8755. release:restamp stamps since at the merge slot.+ { since: 'TBD', id: 'doctor_foreign_writers_partial_gst1623', text: 'Doctor `foreign_writers` no longer reads what it could not scan as clean. A source root inside a Git checkout whose `git rev-parse` fails or times out, roots past the 50-root scan cap, a commit ledger that exists but cannot be read, and a `git status` that failed or timed out now mark the scan partial, each listed in the new `partial_reasons` and named in the message. A scan that read no repository but skipped one warns instead of reporting not_applicable. `git status` now gets up to 30 s within doctor\'s budget instead of the fixed git timeout. A foreign commit whose trailers include a `gbrain-` trailer still fails the check, and the message names it as possibly an older gbrain without the commit ledger (`gbrain_trailer: true`).' },+ { since: 'TBD', id: 'commit_push_enclosing_repo_gst1623', text: 'On a brain home that records its source checkouts, `gbrain git commit-push` without `--path` now also refuses `checkout_not_a_source` in a repository that only encloses a registered checkout (a clone above it): a registered checkout must contain the resolved one, or be a directory of it that its HEAD tracks. A checkout registry that cannot be listed now refuses `writer_coordinator_required` instead of an internal error.' },+ { since: 'TBD', id: 'owner_guard_fail_closed_gst1623', text: 'The owner-path commit guard of `gbrain sources guard` now refuses the commit (exit 1, with a message) when `git rev-parse --absolute-git-dir` fails, instead of letting it through; a hook that belongs to another git dir still passes. A guard installed by an earlier version keeps its old script until `gbrain sources guard <source> --install` runs again.' },+ { since: 'TBD', id: 'adopt_local_edits_hardening_8755', text: 'With `persistence.adopt_local_edits` on for a source (off by default), a local edit is no longer adopted, and the write keeps its `file_database_drift` refusal, when its path has merge conflicts, while a merge, cherry-pick, revert or rebase is in progress, when the file equals one of the page\'s last 50 revisions or drops rows the current revision added (a stale editor save), when the page is segmented, or when the write\'s claim ended meanwhile. The quiet wait is capped at 30 s (it was up to three `persistence.adopt_quiet_ms` windows, 180 s at that key\'s cap), and an empty `persistence.adopt_quiet_ms` reads as the 5000 default instead of no wait. Doctor `local_edit_adoptions` still counts an adoption after its receipt is compacted.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/test/adopt-local-edit.test.ts b/test/adopt-local-edit.test.tsindex f89d85affc..6708a5c5ed 100644--- a/test/adopt-local-edit.test.ts+++ b/test/adopt-local-edit.test.ts@@ -15,9 +15,10 @@* Seams: the refresh fixture (one clone, sources alpha and beta), managedBrain for the repo-less case, the effect* worker run in-process, `localEditAdoptionSeams.beforePublish`.*/-import { afterAll, afterEach, beforeAll, expect, test } from 'bun:test';+import { afterAll, afterEach, beforeAll, expect, spyOn, test } from 'bun:test';import { execFileSync } from 'node:child_process';import { createHash, randomUUID } from 'node:crypto';+import * as fs from 'node:fs';import { readFileSync, rmSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { acquireWorktree, getWorktreeBinding } from '../src/core/persistence/ownership.ts';@@ -472,9 +473,18 @@ test('#8755 d: a stale editor save keeps the refusal: the earlier revision as itawait expectRefused(f, before.replace('The first alpha observation.', `The first alpha observation.\n\n${LOCAL}`), timeline(f), 'add_timeline_entry');}), 180_000);-test('#8755 e: a file over the page size limit keeps the refusal', () => each(async f => {+test('#8755 e: a file over the page size limit keeps the refusal, and the adoption never reads it', () => each(async f => {const { PAGE_MAX_BYTES } = await import('../src/core/page-size-policy.ts');- await expectRefused(f, page('Alpha one', `The first alpha observation.\n\n${'x'.repeat(PAGE_MAX_BYTES + 1)}`), timeline(f), 'add_timeline_entry');+ const read = fs.readFileSync, target = join(f.root, 'alpha', 'one.md');+ let adoptionReads = 0;+ const reads = spyOn(fs, 'readFileSync').mockImplementation(((path: fs.PathOrFileDescriptor, ...rest: unknown[]) => {+ if (String(path) === target && String(new Error().stack).includes('adoptionIntent')) adoptionReads++;+ return (read as (...args: unknown[]) => unknown)(path, ...rest);+ }) as typeof fs.readFileSync);+ try {+ await expectRefused(f, page('Alpha one', `The first alpha observation.\n\n${'x'.repeat(PAGE_MAX_BYTES + 1)}`), timeline(f), 'add_timeline_entry');+ } finally { reads.mockRestore(); }+ expect(adoptionReads).toBe(0);}), 180_000);test('#8755 j: an empty persistence.adopt_quiet_ms reads as the default window, not as no wait', () => each(async f => {