Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(persistence): key-files entry for the G2 door; Postgres arm lane for its test (GBRA-133)
garrytan11f34a4c8af3
diff --git a/docs/architecture/key-files/core-persistence-continued.md b/docs/architecture/key-files/core-persistence-continued.mdindex da598cc42c..93194e6781 100644--- a/docs/architecture/key-files/core-persistence-continued.md+++ b/docs/architecture/key-files/core-persistence-continued.md@@ -41,3 +41,4 @@ The #6188 fence check and fence repair live in [fence repair](core-fence-repair.- `src/core/postgres-engine/reserved-transactions.ts` with `isPersistenceDeclaration` (`src/core/persistence/protocol.ts`) — BEGIN pipelining. `isPersistenceDeclaration` (GBRA-156) accepts exactly the `protocol.ts` declarations (transaction-local `set_config` calls and the brain row FOR SHARE). Admission, the FIFO claim, the effect claims and source guards, the receipt true-up, the single publication (`coordinator.ts`) and the consumer's lent lane transactions (`consumer.ts` `onLane`, through `reservedTransactions`) pass it as `TransactionOptions.pipelineFirst`, so behind a transaction-mode pooler the declaration goes out with BEGIN (one round trip less per transaction) while every later statement still waits for BEGIN's answer; if BEGIN fails, only the declaration has run, in autocommit, where it changes nothing. A reserved transaction gates every statement its body can reach, savepoint and nested-transaction bodies and `file()` included. A sync lane group's publication passes none: its begun mark must follow BEGIN's answer (`sync-lanes.ts` `awaitLaneBegin`). Tests: `test/persistence-pipeline-first.test.ts` (the predicate and the reviewed call sites), `test/e2e/pgbouncer-transaction-pipeline-6930.test.ts`.- `src/core/persistence/checkout-state.ts` (`readCheckoutState`) — Q1: a canonical checkout against its last fetched upstream, read-only and time-bounded (no fetch): ahead/behind, `diverged`, each commit the upstream lacks (sha, author, date, subject, paths; at most 20) and porcelain counts. `sources writer status` reports it as `checkouts`; doctor `git_convergence` adds the commits and counts for a managed checkout and warns at once on a diverged one.+- `src/core/persistence/git-door.ts`: G2, the door of git-canonical memory (Git is the source of truth, the database derives from it). A source with `sources.config.canonical = "git"` (strict, default off; nothing sets it yet) commits each published file before its database row. `publishMutation` (`coordinator.ts`) and `publishGroup` (`group-publish.ts`, one commit per group, after its lane turn) call `commitThroughDoor`, a path-only `commitGitTargets` under the writer lock, between the file rename and the transaction commit, and stamp the commit as `outcome.persistence.git_commit` (`git_state: committed`); a target Git refuses rolls the publication back. The Git effect carries `push_only` and joins the push without staging (`effects.ts`). The recovery record carries `door` (checkout and starting HEAD); `recoverPublication` keeps a file whose commit landed (`doorCommitLanded`) instead of restoring it, and the replay completes against it: `replayAfterDoorCommit` in `publishMutation` and the strict exceptions in `page-prepare.ts` (own bytes committed, or a removal HEAD already holds). Old binaries ignore `door`; strict stays off until conversion fences them. Tests: `test/git-door-strict-gbra133.test.ts` (both engines).diff --git a/src/core/persistence/git-door.ts b/src/core/persistence/git-door.tsindex f56fd06722..3242f56995 100644--- a/src/core/persistence/git-door.ts+++ b/src/core/persistence/git-door.ts@@ -1,5 +1,5 @@/**- * G2, the door (plans/git-canonical-build.md): a source whose row says `config.canonical = "git"` (strict, default off)+ * G2, the door of git-canonical memory (Git is the source of truth; the database derives from it): a source whose row says `config.canonical = "git"` (strict, default off)* commits each published file to Git before its database row commits. publishMutation and publishGroup commit the* published paths with one path-only `commit --only` under the worktree's writer lock, after the files are renamed into* place and before the database transaction commits, and stamp the commit on the receiptdiff --git a/test/git-door-strict-gbra133.test.ts b/test/git-door-strict-gbra133.test.tsindex 0cc89413f2..dc15023751 100644--- a/test/git-door-strict-gbra133.test.ts+++ b/test/git-door-strict-gbra133.test.ts@@ -1,5 +1,5 @@/**- * G2, the door (plans/git-canonical-build.md; src/core/persistence/git-door.ts). On a strict source+ * G2, the door of git-canonical memory (src/core/persistence/git-door.ts). On a strict source* (`sources.config.canonical = "git"`, default off) a page write is committed to Git before its database row:* - the commit exists at the publication's before_commit seam, inside the transaction, and the receipt names it;* - a publication interrupted after that commit (the before_commit seam, a dropped connection) keeps the committeddiff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txtindex 557d5fde77..bb65741f26 100644--- a/test/postgres-unit-arms.txt+++ b/test/postgres-unit-arms.txt@@ -78,6 +78,7 @@ test/file-drift-soft-delete-hold-release-gbra133.test.tstest/forecast-journal.test.tstest/frontmatter-reserved-keys-6454.test.tstest/get-chunks-paging.test.ts+test/git-door-strict-gbra133.test.tstest/google-connector-facts-fence-7292.test.tstest/grade-takes-window.test.tstest/graduation-copy.test.ts