Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs: writer registration is idempotent under concurrent first writes (CHANGELOG, ENGINES.md)
garrytana632df2d3738
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ae62e9016c..a345c546a0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,16 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**Engines that make their first write at the same moment no longer fail one of the writes registering the same writer.** Two or more engines opened from the same settings on one Postgres database (the same writer id, credential and lane), or two processes that share one credential file, could both find no registration and both insert it. The loser hit the credential's unique index and failed with `duplicate key value violates unique constraint "persistence_local_writers_credential_hash_key"`; four engines on a fresh database lost three of their four first writes. Registration is now idempotent under that race, and every refusal still holds. PGLite was never affected, because its single connection runs the read and the insert one after the other. Contributed by @bradgessler.++### Itemized changes++- `src/core/persistence/identity.ts`: the registration insert names no conflict target, so a conflict on either unique index (the id or the credential hash) does nothing. When nothing was inserted, the row under the id is read again and checked exactly as an existing row is. The same credential and lane pass, while a revoked row or another credential or lane under the id refuses `permission_denied`. No row under the id means the credential belongs to another registration, which now refuses `permission_denied` with a fix where it used to raise a raw 23505.+- `test/e2e/engine-open-postgres.test.ts`: four engines opened from one writer value make their first writes at once, twelve rounds on a scratch database (master: `['23505','resolved','resolved','resolved']`). A second case forces the lost-insert branch and checks each refusal on Postgres.+- `test/engine-open.test.ts`: the same lost-insert cases on PGLite, plus four concurrent first writes on one engine landing under one registration.+## [0.60.587.0] - 2026-11-06**An HTTP MCP caller can now say which AI made a write, and attribution reads show it.** Send `X-Gbrain-Agent-Label: Claude Code` (or `Codex`, or a job name) on a request, and the writes that request makes itself show `agent_label` in `gbrain attribution` / `get_write_attribution` and in `get_versions` for admin and local readers. This answers "which of my AIs wrote this?" when several share one OAuth client or token. The label is text the caller declares and gbrain does not verify. The principal is still who was authorized, and no grant, access rule or trust tier reads it. A request without the header is recorded exactly as before, so nothing changes until a caller sends it. Contributed by @JamisonMercurio (#8664).diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex d8f078240f..e4a25c8d82 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -763,7 +763,8 @@ working directory:- **Writer.** An unauthenticated write uses `settings.writer` for its lane (a remote call needs a `stdio` writer, alocal one `cli`), registered in `persistence_local_writers` on first use with the default read/write ceiling. Anexisting registration keeps its own ceiling, another credential or lane under the id refuses `permission_denied`,- and a revoked one is never replaced. No `<brain>.<lane>.json` file is read or minted; with no writer for the lane+ and a revoked one is never replaced. Engines that make their first write at the same moment register the writer once;+ a credential already registered under another id refuses `permission_denied`. No `<brain>.<lane>.json` file is read or minted; with no writer for the lanethe write refuses `writer_registration_required`.- **Embedding identity.** `initSchema()` seeds a fresh brain from `settings.embedding` (else the built-in default),never from the process gateway, and refuses `engine_embedding_mismatch` on a database that records another model