Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/gbra217-trailer-mirror
garrytanf7b12794641a
diff --cc CHANGELOG.mdindex 84c202edf5,a196fa35b7..cfb8bc805e--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,25 -10,26 +10,45 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**A page write can say why it was made, and page history shows it.**++`put_page`, `edit_page`, `revert_version` and each `put_pages` item take an optional `reason` (one line, at most 500 characters; `--reason` on the CLI). It is stored on the version the write replaced, and `get_versions` returns it as `replaced_because`, so the newest version explains the text you read now; `gbrain history` prints it as `changed because: …`. When the page's file reaches Git, the commit carries it as a trailer naming the file, `gbrain-reason: <path>: <text>`, beside any `gbrain-repair:` trailer. A brain with no Git repository gets the same history from the database. Every write result reports where the reason went in `reason_recorded`.++### What changed++| Situation | Before | Now |+|---|---|---|+| A write passes `reason` | refused as an unknown parameter | stored with the replaced version and, for a world-visible file, in the commit |+| A reason over 500 characters, or one that looks like a credential | n/a | refused before admission: `change_reason_rejected` (`reason_too_long`, `reason_contains_secret`), and no journal row keeps it |+| A remote caller reads `get_versions` | no reasons | `replaced_because` when the version and the one that replaced it are both world-visible and the replacement was not pruned |+| A private page's write has a reason | n/a | the reason stays out of every commit message |+| A write without a reason | | the same commit message and history as before |+| A newer write to the same file commits first (non-strict source) | n/a | the receipt says `git: superseded` with a `reason_not_committed` notice; the reason stays in history |++Guide: [page history](docs/guides/page-history.md).++ ## [0.60.475.0] - 2026-10-27++ **A repository's own commit checks now apply to commits gbrain makes.**++ `gbrain git commit-push` and gbrain's own page writes told Git to read every file path literally. Git passes that setting on to the repository's hooks, so a pre-commit check that picks files by pattern (all `*.json` files, say) found no files and let the commit through. A JSON file with merge-conflict markers could be committed and pushed by gbrain while a plain `git commit` of the same file was refused. Hooks that build their own path patterns, such as a post-commit step that runs `git add -- ':(literal)<file>'`, failed for the same reason.++ gbrain now marks each of its own paths as literal one at a time and no longer turns the setting on for the whole command. Its hooks, filters and helpers start without it, even when gbrain's own environment sets it. Files whose names contain `*`, `?`, `[` or a leading `:` still commit only themselves.++ ### What changed++ | Situation | Before | Now |+ |---|---|---|+ | A pre-commit hook lists staged files with a pattern (`git diff --cached --name-only -- '*.json'`) and refuses a bad one | the hook saw no files; gbrain committed and pushed | the hook refuses; `gbrain git commit-push` exits 1 with `git_unavailable` and the hook's message, leaves the file unstaged and pushes nothing |+ | A post-commit hook runs `git add -- ':(literal)<file>'` | `did not match any files` | works as after a plain `git commit` |+ | A clean filter, push helper or hook started for a gbrain commit | inherited `GIT_LITERAL_PATHSPECS=1` | sees no pathspec setting |+ | `GIT_LITERAL_PATHSPECS`, `GIT_GLOB_PATHSPECS`, `GIT_NOGLOB_PATHSPECS` or `GIT_ICASE_PATHSPECS` set in the environment gbrain runs in | passed to every Git command gbrain ran | dropped from Git commands gbrain runs |+ | A new page file whose name starts with `:` | the ignore check read it as the name without the colon | checked under its real name |++ Release 0.60.474.0 also updated the `qs` dependency to 6.16.1 for security advisory GHSA-6pq8-jhm2-2vcw.+## [0.60.474.0] - 2026-10-27**A database role that can't read the writer state is now refused instead of let through.**diff --cc src/core/persistence/effect-git.tsindex a8b668390b,a040058648..0e59669dbe--- a/src/core/persistence/effect-git.ts+++ b/src/core/persistence/effect-git.ts@@@ -361,15 -347,8 +362,15 @@@ export async function commitGitTargets(const commitPaths = [...new Set(changed.map(c => c.path))];const noted = new Map<string, GitCommitNote>();for (const c of changed) { const note = notes?.get(c.requested); if (note && !noted.has(c.path)) noted.set(c.path, note); }- const message = commitMessage(commitPaths, noted).flatMap(paragraph => ['-m', paragraph]);- const result = await git(session, [...(commitPaths.some(path => removed.has(path)) ? NO_FSCACHE : []), 'commit', '--only', ...message, '--', ...literalPathspecs(commitPaths)]);+ let messageDir: string | undefined;+ let result;+ try {+ const message = commitMessageArgs(commitMessage(commitPaths, noted), () => {+ mkdirSync(persistenceHome(), { recursive: true, mode: 0o700 });+ return messageDir = mkdtempSync(join(persistenceHome(), 'commit-message-'));+ });- result = await git(session, [...(commitPaths.some(path => removed.has(path)) ? NO_FSCACHE : []), 'commit', '--only', ...message, '--', ...commitPaths]);++ result = await git(session, [...(commitPaths.some(path => removed.has(path)) ? NO_FSCACHE : []), 'commit', '--only', ...message, '--', ...literalPathspecs(commitPaths)]);+ } finally { if (messageDir) rmSync(messageDir, { recursive: true, force: true }); }const outcome = result.code === 0 ? { git: 'committed' } : gitFailure('Cannot commit the canonical Git target.',`git commit failed for ${commitPaths.length} file(s); a missing Git identity (user.name, user.email) in that checkout is one cause to check.`);for (const c of changed) results.set(c.requested, outcome);diff --cc src/core/persistence/git-door.tsindex 432625120c,d26bdbca2f..88c9d93bc9--- a/src/core/persistence/git-door.ts+++ b/src/core/persistence/git-door.ts@@@ -42,8 -42,9 +42,9 @@@ import { createHash, randomBytes } froimport { closeSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';import { join, relative, resolve, sep } from 'node:path';import type { Notice } from '../agent-output.ts';+ import { literalPathspecs } from '../git-env.ts';import { OperationError, opError } from '../ops/contract.ts';-import { commitMessage, git, gitBytes, gitFailure, gitStepTimeoutMs, ignoredTargetError, reclaimAbandonedIndexLock, withSession, type GitSession } from './effect-git.ts';+import { commitMessage, commitMessageArgs, git, gitBytes, gitFailure, gitStepTimeoutMs, ignoredTargetError, reclaimAbandonedIndexLock, withSession, type GitSession } from './effect-git.ts';import type { GitCommitNote } from './effect-model.ts';import { persistenceHome } from './identity.ts';import { ignoreCandidates } from './ignore-rules.ts';