Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/gbra-120-remote-open-loops

garrytan9504d6f32f78
diff --cc CHANGELOG.md
index 6e769c61f4,68ffd8dd85..e43fbce190
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,31 -10,64 +10,89 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
- ## [0.60.267.0] - 2026-10-16
++## [0.60.268.0] - 2026-10-16
+
+**Security: remote entity cards and context packs no longer carry open loops.** Since v0.47.0.0, an `entity` card built for a remote caller (any MCP client, stdio or HTTP) listed the open loops whose counterparty is that entity: the loop summary, its due date and its `loop_id`. Loop rows have no visibility or source grant of their own, so the card showed them even when the loop's commitment fact was private, and since v0.60.167.0 (#5504) also when the loop lives in a source outside the caller's grant, such as a connected Google source. `context_pack` and `delta` build their threads from the same card, so they carried the same loops. Remote cards now skip loop-backed threads; their fact and timeline threads are unchanged.
+
+### What you'd see
+
+| Situation | Before | Now |
+|---|---|---|
+| A remote `entity`, `context_pack` or `delta` call for a person with open loops | `open_threads` listed each loop's summary, `due` and `loop_id`, whatever the loop's source | no loop-backed threads; eligible commitment facts and recent timeline events still appear |
+| A remote client needs its open loops | the card | `open_loops`, which reads only loops in sources the client is granted |
+| `gbrain entity <name>` on the brain host | loops on the card | unchanged |
+| `context_pack` / `delta` from the trusted local CLI | loops on the cards | loops only with `include_private`, the same switch that adds private facts (loop summaries come from private mail) |
+| Remote `open_loops` grouped by counterparty | groups were ranked partly by backlink counts that included pages outside the caller's grant | remote ranking leaves backlinks out; the trusted local CLI still uses them |
+
+### If you share brain access
+
+A brain without open loops (no Google source and no extracted commitments), or whose MCP clients are all your own agents, needs nothing. If you granted MCP read access to a client that should not see your mail-derived loops, run `gbrain auth clients --usage --days 60` on the brain host to see which clients called `entity`, `context_pack` or `delta` (stdio use is not logged), and revoke or rescope any you no longer trust (`gbrain auth revoke-client <client_id>`). No credentials were exposed, so no rotation is needed for this fix.
+
+### Itemized changes
+
+- `src/core/verbs/entity-card.ts`: a world-only card (`remote: true`) no longer reads `open_loops`.
+- `src/core/ops/loops.ts`: `open_loops` computes the backlink ranking boost for trusted local callers only.
+- Test: `test/entity-card-remote-loops.test.ts` drives the real `entity`, `context_pack`, `delta` and `open_loops` handlers with `remote: true` (fails on v0.60.266.0).
+- Docs: `docs/protocol/MEMORY_VERBS_v1.md` and `docs/guides/open-loops.md` say who gets loop-backed threads.
+
+ ## [0.60.267.0] - 2026-10-16
+
+ **You can ask the brain what a page said at an earlier moment, as the brain knew it then, and it tells you when it can't know.** With the belief ledger on, `get_page` and `get_versions` take `known_as_of`, an exact instant. The answer is the page as the brain had recorded it at that instant: which version was current, whether it was deleted, and how long it stayed that way. When the brain can't vouch for the answer, it says so. The ledger may not have been on yet at that instant, it may not have been recording, or a write may still have been in flight. In those cases you get a refusal with a reason instead of a guess. Purged content never comes back through a past read. A rename and a fact purge now keep the page as it stood before the change, so the history has no holes. A sync stuck behind a recovery only you can fix now stops at once and names the file.
+
+ ### How to use it
+
+ ```bash
+ gbrain beliefs status --source <id> --json # what the ledger covers
+ ```
+
+ Through MCP or the CLI op surface:
+
+ - `get_page {slug, known_as_of: "2026-10-01T12:00:00Z"}`: the page as recorded at that instant, with `certified` and the interval it was in.
+ - `get_versions {slug, known_as_of, diff: true}`: every interval recorded by that instant, newest first, each with a unified diff from the one before.
+
+ `known_as_of` is recorded time (when the brain knew it). It is not `as_of` on `get_links`, which is valid time (when it was true in the world, as a date).
+
+ ### What you'd see
+
+ | You ask about | Before | Now |
+ |---|---|---|
+ | a page at an instant the ledger covers | no way to ask | the page as recorded then, its revision, whether it was deleted, `recorded_at` and `until`, and `certified` |
+ | an instant before the ledger was on for the source | n/a | `coverage_from`: earlier times are unknown, not empty |
+ | an instant while coverage was stopped, or across a backup restore | n/a | `coverage_gap` with the gap's bounds |
+ | an instant when a write to the page was recorded but not yet provably committed | n/a | `known_as_of_unproven` (retryable), naming the write |
+ | `known_as_of: "2026-10-01"` | n/a | `clock_mismatch`: a date is valid time; pass an instant |
+ | a page whose body was later purged | n/a | the interval with `body: unavailable`, `body_reason: purged`; the purged text never returns |
+ | a body no retained version holds | n/a | `body: unavailable` with its reason; never the neighboring version's body |
+ | a remote client asking about a page it can't see | n/a | `page_not_found`, the same as for a slug that was never written |
+ | a page rename or a `purge_fact` rewrite | no version kept the page as it stood before | one more version per rename and per page a fact purge rewrites (the purged claim is stripped from it) |
+ | a sync queued behind a recovery waiting on you (a page file edited mid-publish) | waited out the 5-minute no-progress window | stops after one governor tick with `drain_stalled`, `cause: head_blocked`, naming the file and the fix |
+
+ ### Things to watch
+
+ - `get_versions` and `gbrain history` list one more snapshot per page rename and per page a `purge_fact` rewrites.
+ - History is certified only on managed sources. On other sources a read answers with `certified: false` and an `uncertified_reason`.
+ - Doctor `belief_ledger_coverage` now warns when a page moved to a new revision without a version of the one it left. Such a body shows as `version_missing` in a past read and can't be recovered. `--tier deep` lists every case beyond the last 30 days.
+ - Scripts that match `drain_stalled` should expect `cause: head_blocked` sooner on a recovery that needs a person.
+
+ ### Itemized changes
+
+ #### Recorded-time reads
+
+ - `src/core/belief/page-at-time.ts`: the page-at-time reader. It finds the interval an instant falls in from the ledger's page events, checks coverage (`coverage_from`, `coverage_gap`) and the commit proof (`known_as_of_unproven`), resolves the body (`live`, `version`, `segmented` through `body_ref`, or `unavailable` with `purged`, `expired`, `hard_deleted`, `pruned` or `version_missing`), and collapses a purged lifetime's intervals.
+ - `src/core/ops/known-as-of.ts`: `get_page {known_as_of}` and `get_versions {known_as_of, diff}` (`src/core/ops/pages.ts`, `src/core/ops/admin.ts`). `diff` and `source_id` on `get_versions` need `known_as_of`. For a remote caller, the source lookup counts only pages it can see now, and a coverage or proof refusal about a page it cannot see becomes `page_not_found`.
+ - New error codes `coverage_from`, `coverage_gap`, `clock_mismatch` and `known_as_of_unproven` (`src/core/error-registry.ts`, `src/core/error-catalogue.ts`), documented in `docs/guides/repair.md#recorded-time-reads`.
+
+ #### History without holes
+
+ - `updateSlug` (`src/core/engine-sql/pages.ts`) saves a version of the page before the rename.
+ - `purge_fact` (`src/core/facts/purge.ts`) saves a version of each page before rewriting it; version redaction then removes the purged claim from that version too.
+ - `src/core/belief/preimages.ts`: every publication that moves a page's revision must leave a version of the revision it moved off. Test runs enforce it in `finalizeBeliefEvents`. Doctor `belief_ledger_coverage` reports violations from the last 30 days (all of them under `--tier deep`).
+ - `docs/designs/BELIEF_LEDGER.md` section 14 records the page-at-time rules.
+
+ #### Sync behind a recovery that needs you
+
+ - `src/core/persistence/head-blocker.ts`, `sync-drain.ts`: a sync queued behind a fact-withdrawal mirror or page write whose file was edited while it was publishing stops after one governor tick with `drain_stalled`, `cause: head_blocked`, naming the file. A recovery that can still finish keeps the wait. A recovery stuck on `unexpected_staging_bytes` still waits out the window.
+
## [0.60.266.0] - 2026-10-16
**Managed sync tells the truth about where it stands, and every held file has a way out (#6712 PR 2).** A managed `gbrain sync` returns `synced` the moment its checkpoint commits: link extraction and planner statistics run after the drain lease is released, and a crash between the two is made up by the next sync. `gbrain sync status` stays fast on large brains and never reads a timed-out probe as "nothing pending". Each of the 14 hold codes now leads an agent to a cleared hold or to one decision sentence for the user, and a hold asks a person only after its safe action failed three times over at least a day. Every `gbrain sync` flag lives in one table, and the `sync.*` config keys are split into tunables, rollback keys and retired keys (five retired keys become `GBRAIN_SYNC_*` environment variables, and doctor names any stored value that stopped applying).
diff --cc src/core/behavior-change-notice.ts
index 887e5191c5,d66ca9f462..65e65498fe
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -717,8 -717,11 +717,13 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.266.0', text: 'A managed-sync file that `write_gate.external_mode=reject` refuses is now held as `write_gate_rejected` when sync freezes it, instead of failing its receipt and stopping the rest of the source. A held file that leaves the source (excluded with `sync.exclude`, or an image while multimodal embedding is off) is released by the next sync even when nothing new was committed. Every sync re-screens a `write_gate_rejected`, `content_rejected` or `purged_content` hold, so switching the setting, an owner allow rule or `gbrain pages unpurge` clears it.' },
{ since: '0.60.266.0', text: 'A `source_changed` write receipt\'s fix now follows its recorded reason: two-sided drift previews `gbrain repair file-drift --source <id> --slug <slug> --prefer database` (a group of them `--all-drifted --since <instant>`), a missing canonical file previews `gbrain repair ghost-pages`, an admission race is retried, and a changed binding or unsafe target names `gbrain sources writer status`. `gbrain repair file-drift` takes `--since <ISO-8601 | age>` to narrow `--all-drifted`.' },
{ since: '0.60.266.0', text: 'Doctor `managed_sync_not_moving` now fails (it used to list the source as parked) when a managed source\'s queue holds admitted requests with no consumer and nothing has moved for longer than `persistence.preparation_ceiling_ms`; its fix is the resume sync, which consumes the queue (#6552). A managed sync now prints a line when live pages of the source have no canonical file, naming the read-only `gbrain repair ghost-pages` preview; it never deletes them.' },
- // Remote open-loop hotfix (GBRA-120). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
- { since: '0.60.266.0', text: 'Remote callers (every MCP transport) no longer get open-loop-backed threads on `entity` cards, or in `context_pack` and `delta`, which build on those cards: no loop summary, `due` or `loop_id`. Use `open_loops`, which reads loops only in granted sources. The trusted local CLI still sees them on `gbrain entity`, and in `context_pack` / `delta` with `include_private`. Remote `open_loops` grouped results no longer rank counterparties by backlink counts.' },
+ // Lane 31 (mirror-recovery fast fail). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp. A sync behind a withdrawal-mirror or page-write recovery blocked on unexpected_file_bytes stops at once instead of waiting 5 minutes.
+ { since: '0.60.267.0', text: 'A sync queued behind a recovery that only the user can resolve now stops after one governor tick with `drain_stalled`, `cause: head_blocked`, instead of waiting out the 5-minute no-progress window. Two recoveries count: a fact-withdrawal mirror whose page file was edited while the mirror was publishing (`blocked_by=effect_recovery(unexpected_file_bytes …)`; the fix asks the user to put the file back to a version gbrain recorded, then rerun the sync), and a page write whose file was edited while it was publishing (`blocked_by=request_recovery(unexpected_file_bytes …)`, whether it blocks the queued head or is the head; the fix runs the `gbrain repair stuck-recovery` preview, or the user undoes the edit). Both name the file, and `gbrain sources writer status` shows the same advice. A recovery that can still finish (its file back on a recorded version) keeps the wait. Known gap: a recovery stuck on `unexpected_staging_bytes` still waits out the window.' },
+ // W2 belief ledger page-at-time. `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
+ { since: '0.60.267.0', text: 'A page rename (a sync that sees a file move, a frontmatter slug repair, a held-file or import move) now saves the page as it stood before the move as a version, as an edit does, so `get_versions` and `gbrain history` list one more snapshot per rename. The move advances the page\'s revision, and until now no version held the body from before it.' },
+ { since: '0.60.267.0', text: '`purge_fact` now saves each page it rewrites as a version before dropping the purged fence row, and its version redaction then removes the claim from that version as from every other, so `get_versions` and `gbrain history` list one more snapshot per page a fact purge rewrites. The snapshot holds the page as it stood before the purge, without the purged claim.' },
++ // Remote open-loop hotfix (GBRA-120).
++ { since: '0.60.268.0', text: 'Remote callers (every MCP transport) no longer get open-loop-backed threads on `entity` cards, or in `context_pack` and `delta`, which build on those cards: no loop summary, `due` or `loop_id`. Use `open_loops`, which reads loops only in granted sources. The trusted local CLI still sees them on `gbrain entity`, and in `context_pack` / `delta` with `include_private`. Remote `open_loops` grouped results no longer rank counterparties by backlink counts.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */