Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Measure the new test's Postgres-arm weight; make the detection loop one git log pass
garrytanca1672f9e8f9
diff --git a/docs/guides/shared-checkout-git.md b/docs/guides/shared-checkout-git.mdindex 71eac7a3ee..1c1eefde7d 100644--- a/docs/guides/shared-checkout-git.md+++ b/docs/guides/shared-checkout-git.md@@ -346,19 +346,22 @@ and the next sync imports it; when the file still holds gbrain's bytes, theeffect stages them again and commits them on top. A strict source's writerefuses `git_target_changed` instead.-To find edits a brain already lost this way, look for a gbrain commit whose-parent is someone else's commit, made at most two minutes earlier, that changed-the same file. This loop only reads history:+To find edits a brain already lost this way, look for a gbrain commit (its+subject starts with `gbrain:`) whose one parent is someone else's commit, made at+most two minutes earlier, that changed a file the gbrain commit also changed.+The loop reads the history reachable from `HEAD` in one `git log` pass and then+diffs only those pairs. It writes nothing, takes no lock and doesn't run gbrain,+so it works the same before and after upgrading. On a synthetic history of+200,000 commits it took about 5 seconds and 360 MB of memory.```bashBRAIN=/path/to/brain-checkoutTOP=$(git -C "$BRAIN" rev-parse --show-toplevel)g() { git -C "$TOP" -c core.quotePath=false "$@"; }-g log --no-merges --format='%H %P' | while read -r c p extra; do- [ -n "$p" ] && [ -z "$extra" ] || continue- case "$(g log -1 --format=%s "$c")" in gbrain:*) ;; *) continue ;; esac- case "$(g log -1 --format=%s "$p")" in gbrain:*) continue ;; esac- [ $(( $(g log -1 --format=%ct "$c") - $(g log -1 --format=%ct "$p") )) -le 120 ] || continue+g log --format='%H%x09%P%x09%ct%x09%s' | awk -F'\t' '+ { parent[$1] = $2; at[$1] = $3; ours[$1] = ($4 ~ /^gbrain:/) }+ END { for (c in parent) { p = parent[c]; if (ours[c] && p != "" && p !~ / / && (p in at) && !ours[p] && at[c] - at[p] <= 120) print c, p } }' |+while read -r c p; dog diff-tree -r --no-commit-id --name-only "$c" | while IFS= read -r f; dog diff-tree -r --no-commit-id --name-only --root -m --first-parent "$p" -- ":(literal)$f" | grep -qxF -- "$f" \&& echo "$f: edit in $(g log -1 --format='%h (%an, %ci)' "$p") replaced by gbrain commit $(g log -1 --format=%h "$c")"@@ -366,6 +369,12 @@ g log --no-merges --format='%H %P' | while read -r c p extra; dodone```+A hit looks like this, one line per file:++```text+notes/alice-example.md: edit in 9ee21f7422 (Alice Example, 2026-11-12 10:23:27 +0000) replaced by gbrain commit 15134a6136+```+Each line is a candidate, not proof: a gbrain write made right after someoneelse's commit on purpose looks the same. To confirm one, read both versions(`git show <their commit>:<file>` and `git show <gbrain commit>:<file>`).diff --git a/scripts/postgres-arm-weights.json b/scripts/postgres-arm-weights.jsonindex 9fa9b13ae3..7c5ead96e1 100644--- a/scripts/postgres-arm-weights.json+++ b/scripts/postgres-arm-weights.json@@ -80,7 +80,7 @@"test/doctor-strict-facts-outside-git.test.ts": 7643,"test/doctor-sync-freshness-skill-pack-6076.test.ts": 5394,"test/edge-whitespace-twins.test.ts": 9721,- "test/effect-commit-moved-head.test.ts": 22000,+ "test/effect-commit-moved-head.test.ts": 22118,"test/embed-once-per-content-version.serial.test.ts": 17930,"test/embed-stale-images-managed-6529.test.ts": 11128,"test/embedding-completion-atomic.serial.test.ts": 8616,