Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes

garrytan62c78cb288bc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 53c2ca2556..1b76a72857 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@ identifiers and attribution are available in the pre-removal Git revision
- `src/commands/serve-http-webhooks.ts`, `src/core/minions/handlers/ingest-capture.ts`: `POST /ingest` stores the caller's token or OAuth client on the job. The route answers `404 page_not_found` for an `X-Gbrain-Slug` the caller cannot read and `403 permission_denied` for a member fact page or the scope page, and queues nothing. The job checks the same writer again right before it writes, so a page restricted after the 202 is still refused, and a queued webhook job with no stored writer is checked as a guest. Fresh slugs and pages the caller can read import as before.
- `src/core/ops/image.ts`, `src/core/search/image-loader.ts`: `search_by_image` accepts only an http(s) `image_url` from any caller that is not the trusted local CLI, and refuses `image_path` unless the context says the caller is local. The loader reads local paths only when its caller opts in, and checks for a regular file and the size cap before it reads.
- `src/commands/serve-http-webhooks.ts`: a push event is verified against the source's secret before anything about the repository is answered. An unknown repository, a source with no secret and a bad signature all get the same `401 signature_mismatch`; the missing-secret case is logged on the server with the command that sets it.
-- `src/core/git-remote.ts`, `src/core/sources-ops.ts`, `src/core/ops/sources.ts`: a URL source a remote caller adds is cloned with git-lfs downloads off, written into the clone's own git config (`lfs.fetchexclude=*`, which outranks the repository's `.lfsconfig`), so every later pull, managed refresh and commit-push in that checkout keeps large files as pointer files. The source records `added_by_remote_caller: true` so a re-clone keeps it off. A remote caller whose clone fails gets a fixed message; git's own error goes to the brain host's log. Sources added from the local CLI keep git-lfs.
+- `src/core/git-remote.ts`, `src/core/sources-ops.ts`, `src/core/ops/sources.ts`: a URL source a remote caller adds is cloned with git-lfs downloads off, written into the clone's own git config (`lfs.fetchexclude=*`, which outranks the repository's `.lfsconfig`, with hooks off so git-lfs's pre-push hook never runs), so every later pull, managed refresh and commit-push in that checkout keeps large files as pointer files and contacts no LFS endpoint. The source records `added_by_remote_caller: true` so a re-clone keeps it off. A remote caller whose clone fails gets a fixed message; git's own error goes to the brain host's log. Sources added from the local CLI keep git-lfs.
- Tests: `test/serve-http-ingest-member-access.test.ts` (real token verifier and Express route, two members), `test/search-by-image-op.test.ts`, `test/cross-modal-phase2.test.ts`, `test/serve-http-github-push-webhook.test.ts` and `test/sources-remote-lfs.test.ts` (real git-lfs against a local LFS endpoint).
## [0.60.600.0] - 2026-11-07
diff --git a/src/core/git-remote.ts b/src/core/git-remote.ts
index ac90bbcc8a..65dcc8b007 100644
--- a/src/core/git-remote.ts
+++ b/src/core/git-remote.ts
@@ -99,7 +99,8 @@ export interface CloneOpts {
timeoutMs?: number; // default 600_000 (10 min)
/**
* Keep git-lfs from downloading, in this clone and every later git command in it: the repository's own .lfsconfig
- * picks the LFS endpoint, outside the URL gate. Written to the clone's .git/config, which outranks .lfsconfig.
+ * picks the LFS endpoint, outside the URL gate. Written to the clone's .git/config, which outranks .lfsconfig;
+ * hooks are off too, so git-lfs's pre-push hook never asks that endpoint on a push.
*/
skipLfs?: boolean;
}
@@ -168,7 +169,7 @@ export function cloneRepo(url: string, destDir: string, opts: CloneOpts = {}): v
if (opts.branch) {
args.push('--branch', opts.branch);
}
- if (opts.skipLfs) args.push('--config', 'lfs.fetchexclude=*');
+ if (opts.skipLfs) args.push('--config', 'lfs.fetchexclude=*', '--config', 'core.hooksPath=/dev/null', '--config', 'lfs.locksverify=false');
args.push(url, destDir);
try {
diff --git a/test/sources-remote-lfs.test.ts b/test/sources-remote-lfs.test.ts
index 8ad8a8aa50..59e6d09ead 100644
--- a/test/sources-remote-lfs.test.ts
+++ b/test/sources-remote-lfs.test.ts
@@ -4,7 +4,7 @@
* A repository's committed .lfsconfig names the LFS endpoint, and git-lfs contacts it outside the remote-URL gate.
* On a host with git-lfs installed globally, a remote caller's sources_add could make the brain host send requests to
* any HTTP endpoint the repository named, on the clone and on every later pull. Protects:
- * - a skipLfs clone, and every later pull or merge in it, leave pointer files and contact no LFS endpoint (real git and git-lfs);
+ * - a skipLfs clone, and every later pull, merge or push in it, leave pointer files and contact no LFS endpoint (real git and git-lfs);
* - sources_add from a remote caller clones that way, records it on the source, and a re-clone follows the record;
* - sources_add from the trusted local CLI keeps LFS downloads;
* - a remote caller's failed clone gets a fixed message instead of git's own error.
@@ -101,7 +101,7 @@ console.log(git.port + ' ' + lfs.port);
expect(hits().length).toBeGreaterThan(0);
}, 90_000);
- test('a skipLfs clone, a later pull and a plain git merge in it leave pointers and contact no LFS endpoint', async () => {
+ test('a skipLfs clone, a later pull, a plain git merge and a push leave pointers and contact no LFS endpoint', async () => {
const dest = join(ROOT, 'skipped');
await withEnv(env(), async () => { cloneRepo(url, dest, { timeoutMs: 60_000, depth: 0, skipLfs: true }); });
expect(readFileSync(join(dest, 'x.bin'), 'utf8')).toBe(pointer);
@@ -122,6 +122,10 @@ console.log(git.port + ' ' + lfs.port);
execFileSync('git', ['-C', dest, 'fetch', '-q', 'origin'], { env: plain, stdio: 'pipe' });
execFileSync('git', ['-C', dest, 'merge', '--ff-only', '-q', 'origin/main'], { env: plain, stdio: 'pipe' });
expect(readFileSync(join(dest, 'z.bin'), 'utf8')).toContain('size 7');
+ writeFileSync(join(dest, 'page.md'), '# page\n');
+ execFileSync('git', ['-C', dest, 'add', 'page.md'], { env: plain, stdio: 'pipe' });
+ execFileSync('git', ['-C', dest, '-c', 'user.name=example', '-c', '[email protected]', 'commit', '-q', '-m', 'page'], { env: plain, stdio: 'pipe' });
+ execFileSync('git', ['-C', dest, 'push', '-q', bare, 'HEAD:refs/heads/from-brain'], { env: plain, stdio: 'pipe' });
expect(hits()).toEqual([]);
}, 90_000);
});