Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes (pass 2)

garrytanc7440036c1fc
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index e541fd9287..2151a391de 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -1823,7 +1823,7 @@ More: [docs/guides/write-refusals.md#git_protocol_required](../../docs/guides/wr
| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
|---|---|---|---|---|---|---|
-| A strict (canonical: git) write's file changed on disk while it was being committed, so nothing was committed and the write was not published. | The door commits exactly the bytes the write published, and checks the file's hash against them before and after Git stores it. An edit landing in between would otherwise be committed while the database records other content; recovery leaves the changed file as it is. | The write is held in recovery (blocked reason unexpected_file_bytes) and the source's later writes wait behind it. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then apply --keep disk (the edit) or --keep prior with the preview's --expect hash. | agent | `repeat the read that failed` | 1 | no |
+| A strict (canonical: git) write's file changed on disk while it was being committed, so nothing was committed and the write was not published. | The door commits exactly the bytes the write published, and checks the file's hash against them before and after Git stores it. An edit landing in between would otherwise be committed while the database records other content; recovery leaves the changed file as it is. | The write is held in recovery (blocked reason unexpected_file_bytes) and the source's later writes wait behind it. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then run gbrain repair stuck-recovery --source <id> --keep disk\|prior --apply --expect <preview_hash> --yes (disk keeps the edit). Run: gbrain sources writer status --json | user | `repeat the read that failed` | 1 | no |
### git_target_ignored
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 0f74d98824..22a98c8fd7 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -329,7 +329,7 @@ export const CODES = {
git_target_pending: { class: 'retryable', summary: "Git still lists a removed canonical file in the index; the removal was not committed yet." },
git_operation_in_progress: { class: 'caller', summary: "A rebase, merge, cherry-pick or revert is in progress in the checkout, so gbrain will not commit or move it.", docs: 'docs/guides/shared-checkout-git.md#stuck-rebase' },
git_push_unavailable: { class: 'retryable', summary: "The canonical commit is durable locally; its push will retry." },
- git_target_changed: { class: 'caller', summary: "A strict (canonical: git) write's file changed on disk while it was being committed, so nothing was committed and the write was not published.", why: "The door commits exactly the bytes the write published, and checks the file's hash against them before and after Git stores it. An edit landing in between would otherwise be committed while the database records other content; recovery leaves the changed file as it is.", suggestion: "The write is held in recovery (blocked reason unexpected_file_bytes) and the source's later writes wait behind it. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then apply --keep disk (the edit) or --keep prior with the preview's --expect hash." },
+ git_target_changed: { class: 'caller', actor: 'user', summary: "A strict (canonical: git) write's file changed on disk while it was being committed, so nothing was committed and the write was not published.", why: "The door commits exactly the bytes the write published, and checks the file's hash against them before and after Git stores it. An edit landing in between would otherwise be committed while the database records other content; recovery leaves the changed file as it is.", suggestion: "The write is held in recovery (blocked reason unexpected_file_bytes) and the source's later writes wait behind it. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then run gbrain repair stuck-recovery --source <id> --keep disk|prior --apply --expect <preview_hash> --yes (disk keeps the edit).", fix: { argv: ['gbrain', 'sources', 'writer', 'status', '--json'], consent: [], actor: 'agent', why: 'Read-only: lists the held request, its source and its blocked reason.', requires_exclusive: false } },
git_target_ignored: { class: 'caller', summary: "A .gitignore rule excludes the canonical file, so its Git effect cannot commit it; the effect parks at once.", suggestion: 'Remove or narrow the rule and commit that change, then run gbrain sources writer retry-effects <source> --parked-code git_target_ignored; or keep the file out of Git and leave the effect parked.' },
git_target_unsafe: { class: 'caller', summary: "Git cannot identify the existing canonical file by its native spelling." },
git_unavailable: { class: 'retryable', summary: "A git command did not complete." },
diff --git a/src/core/persistence/git-door.ts b/src/core/persistence/git-door.ts
index dcd7a87e73..c096402061 100644
--- a/src/core/persistence/git-door.ts
+++ b/src/core/persistence/git-door.ts
@@ -367,7 +367,7 @@ function refuseChanged(root: string, targets: Iterable<Target>): void {
const moved = [...targets].filter(target => { try { return hashFile(join(root, target.rel)) !== target.planned; } catch { return true; } }).map(target => target.rel);
if (!moved.length) return;
throw opError('git_target_changed', `${moved.join(', ')} in ${root} no longer holds the bytes this write published, so nothing was committed and the write was not published.`,
- 'Another process changed the file during the write; recovery leaves the changed file as it is and holds the write, so the source\'s later writes wait. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then apply --keep disk or --keep prior with the preview\'s --expect hash.', { detail: moved.join(',') });
+ 'Another process changed the file during the write; recovery leaves the changed file as it is and holds the write, so the source\'s later writes wait. Preview with gbrain repair stuck-recovery --source <id> --json, ask the user which version to keep, then run gbrain repair stuck-recovery --source <id> --keep disk|prior --apply --expect <preview_hash> --yes (disk keeps the edit).', { detail: moved.join(',') });
}
/** Targets whose index entry differs from HEAD's and from the version their path's last commit replaced (a staged change, or a merge conflict) refuse as `git_index_conflict`. */
diff --git a/test/bench-door-write-overhead.test.ts b/test/bench-door-write-overhead.test.ts
index f680fa14da..5ee99eb7b1 100644
--- a/test/bench-door-write-overhead.test.ts
+++ b/test/bench-door-write-overhead.test.ts
@@ -9,7 +9,7 @@ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
-const BENCH = resolve(import.meta.dir, '../scripts/bench/door-write-overhead.ts');
+const BENCH = join(resolve(import.meta.dir, '..'), 'scripts/bench/door-write-overhead.ts');
describe('door write overhead bench', () => {
test('the door and trace phases run on a small checkout and report each measured write', () => {
diff --git a/test/git-door-planned-state.test.ts b/test/git-door-planned-state.test.ts
index 92df83539d..057402213a 100644
--- a/test/git-door-planned-state.test.ts
+++ b/test/git-door-planned-state.test.ts
@@ -325,7 +325,7 @@ describe('door plumbing: the planned state', () => {
const bin = mkdtempSync(join(tmpdir(), 'gbrain-git-shim-'));
roots.push(bin);
const real = execFileSync('sh', ['-c', 'command -v git'], { encoding: 'utf8' }).trim();
- writeFileSync(join(bin, 'git'), `#!/bin/sh\ncase " $* " in *" hash-object -w "*) printf 'edited during hash\\n' > '${join(root, 'notes/a.md')}';; esac\nexec '${real}' "$@"\n`, { mode: 0o755 });
+ writeFileSync(join(bin, 'git'), `#!/bin/sh\ncase " $* " in *" hash-object -w "*) printf 'edited during hash\\n' > '${join(root, 'notes/a.md')}';; esac\nPATH='${process.env.PATH}' exec '${real}' "$@"\n`, { mode: 0o755 });
put(root, 'notes/a.md', 'planned\n');
await withEnv({ PATH: `${bin}:${process.env.PATH}` }, async () => {
expect(await refusal(commitThroughDoor(root, [{ path: join(root, 'notes/a.md'), planned: sha256('planned\n') }]))).toMatchObject({ code: 'git_target_changed' });