Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Renumber the provisional personal-source migration to v298 (after #8480's v297) and regenerate the registry and migration records

garrytan3d50a007a79d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7efe28e47c..a1fcb56503 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -339,7 +339,7 @@ Install commands now name `stable` (`bun install -g github:garrytan/gbrain#stabl
## [0.60.595.0] - 2026-11-06
-**An attested person can now read their own DM and member sources through a shared QM client, and nobody else's.** Until now an attested client read only its credential's grant, usually the default source, so facts ingested into a member's own source were never recalled; granting every DM source to the client would have let every attested person read every other person's DM. `gbrain access member source add <member> <source>` now binds a source to the member it belongs to, and a bound source is personal: an attested call (`x-qm-actor`) reads its credential's grant minus every personal source bound to someone else, and a scope read (an attested read that names `source_id` or `source_ids` without `--attest-read person`) reads no personal source at all, not even the speaker's own. A personal source that is hidden is refused exactly like a source outside the grant (`permission_denied`, same message), and an unnamed read simply skips it. The rule only hides inside each credential's grant, so it never makes a source readable: add the DM sources to the client's `federated_read` and bind each to its member. It applies once in MCP dispatch (and to the tool calls of an agent job submitted for an attested person), so `memory_recall`, `query`, `search`, `get_page` and every other read inherit it. Unattested calls and member-bound credentials are unchanged, and nothing changes on upgrade until an operator binds a source. `gbrain access member source remove` previews first and says when the source would stop being personal; `list` shows the bindings. Database state (migration v295), so a repo-less brain works the same. `v1.json` and `v2.json` are unchanged.
+**An attested person can now read their own DM and member sources through a shared QM client, and nobody else's.** Until now an attested client read only its credential's grant, usually the default source, so facts ingested into a member's own source were never recalled; granting every DM source to the client would have let every attested person read every other person's DM. `gbrain access member source add <member> <source>` now binds a source to the member it belongs to, and a bound source is personal: an attested call (`x-qm-actor`) reads its credential's grant minus every personal source bound to someone else, and a scope read (an attested read that names `source_id` or `source_ids` without `--attest-read person`) reads no personal source at all, not even the speaker's own. A personal source that is hidden is refused exactly like a source outside the grant (`permission_denied`, same message), and an unnamed read simply skips it. The rule only hides inside each credential's grant, so it never makes a source readable: add the DM sources to the client's `federated_read` and bind each to its member. It applies once in MCP dispatch (and to the tool calls of an agent job submitted for an attested person), so `memory_recall`, `query`, `search`, `get_page` and every other read inherit it. Unattested calls and member-bound credentials are unchanged, and nothing changes on upgrade until an operator binds a source. `gbrain access member source remove` previews first and says when the source would stop being personal; `list` shows the bindings. Database state (migration v298), so a repo-less brain works the same. `v1.json` and `v2.json` are unchanged.
**An attested read that names its sources now reads as those sources' audience for every read QM can list, and an operator can say whether a credential serves rooms or one person's own turns.** `get_page`, `entity`, `whois`, `get_backlinks`, `get_timeline`, `find_experts`, `volunteer_context` and `query`, called with `x-qm-actor` and `source_id` or `source_ids`, now read the way `memory_recall` does: the person's restricted pages and their member page read as missing, a source outside the grant is refused, and `__all__` or `all_sources` is refused, so a shared turn can never pull one member's private pages into a channel. `get_timeline` gains `source_id` and `source_ids`, and `find_experts` and `volunteer_context` gain `source_ids`; `volunteer_context` refuses `stats: true` under that read. `gbrain auth rescope --attest-read person|scope|none` sets how a credential reads named sources: `person` narrows to them but reads as the person (for a DM client), and `scope` keeps the audience read and also refuses any call that names no person (`actor_not_attested`, reason `actor_required`). Unset keeps today's behavior, so no existing client changes. `gbrain doctor` warns (`attest_read_shared_scope`) when a person credential reads a source another attest credential reads as the scope. `context_pack` is not covered yet. `v1.json` and `v2.json` are unchanged; on a repo-less brain all of it is database state and works the same.
@@ -403,7 +403,7 @@ QM clients that read v1 keep working unchanged. A shared-scope turn should name
- `src/core/repair/failed-writes.ts`: recovered fact requests are read once for all refused writes instead of inside the candidate read; replay attempts are read for every refused write together (`request_id = ANY`); the later requests of each refused write's page are read for groups of writes sized by how long their pages' later history is, so one page with hundreds of refused writes and a long history cannot make one read outlast the statement timeout; the file check runs once per page. The listing, classes, residuals and preview hash are unchanged.
- New refusal `repair_preview_timeout`. When the request indexes the preview reads are missing or INVALID, it names them and its fix is the read-only `gbrain repair request-indexes --json` preview, whose apply command builds them; when they are valid, it tells the brain host to run the same preview once with a longer statement timeout.
-- Schema migration v295 builds two request-table indexes online (`persistence_requests_replay_id` on the request id, `persistence_requests_slug_sequence` on source, slug and sequence). They join the indexes `gbrain repair request-indexes` and doctor's `persistence_request_indexes` check report. Without them the preview is still bounded, only slower. PGLite and repo-less brains get them unchanged.
+- Schema migration v298 builds two request-table indexes online (`persistence_requests_replay_id` on the request id, `persistence_requests_slug_sequence` on source, slug and sequence). They join the indexes `gbrain repair request-indexes` and doctor's `persistence_request_indexes` check report. Without them the preview is still bounded, only slower. PGLite and repo-less brains get them unchanged.
- The request-index states doctor and `gbrain repair request-indexes` print now come back in the order the indexes are declared on Postgres as well as PGLite.
- `test/repair-failed-writes-bounded-8707.test.ts` (PGLite and Postgres) seeds a journal with refused writes of every class and checks that the preview's request-table reads stay flat as refused writes grow, that each write gets its class, and that a read ended at the statement timeout refuses `repair_preview_timeout` and saves nothing, and (Postgres) that 500 refused writes on one page followed by 20,000 later commits preview inside a 1 s statement timeout.
@@ -668,7 +668,7 @@ On a keyless 60-question fixture (old confirmed truth against fresh agent and ex
| `gbrain trust review` | proposals, lowered pages, preferences, holds | also `contradiction` items (`dp<id>`) with supersede, forget, confirm and drop; `--accept-all` skips them |
| `recall` of a fact in a pending decide proposal | no label | `contested` with the other fact's id, only when the caller can read that fact |
-A run files at most `dream.claim_conflicts.max_pairs` (default 500) proposals per source and leaves the rest for the next run. A new unique index keeps concurrent runs to one proposal per pair (migration v295); it rewrites no data. Everything reads and writes database rows, so it works the same on a brain with no git repository. Guide: the "Old and conflicting facts" section of `docs/guides/memory-trust.md`.
+A run files at most `dream.claim_conflicts.max_pairs` (default 500) proposals per source and leaves the rest for the next run. A new unique index keeps concurrent runs to one proposal per pair (migration v298); it rewrites no data. Everything reads and writes database rows, so it works the same on a brain with no git repository. Guide: the "Old and conflicting facts" section of `docs/guides/memory-trust.md`.
### Page versions carry a human reason, and pages read by date (#7798, #7804)
diff --git a/src/core/access/member-sources.ts b/src/core/access/member-sources.ts
index 70b946dfe1..b8c161f3f0 100644
--- a/src/core/access/member-sources.ts
+++ b/src/core/access/member-sources.ts
@@ -1,5 +1,5 @@
/**
- * GBRA-284 (GST-359 G1 wave 2): personal sources. `access_member_sources` (v295) binds a source (a person's DM or
+ * GBRA-284 (GST-359 G1 wave 2): personal sources. `access_member_sources` (v298) binds a source (a person's DM or
* member source) to the member it belongs to; a source with at least one binding is personal. Sources are not keyed to
* members otherwise, so without this an attest client granted every person's DM source would let every attested person
* read every other person's DM source.
@@ -79,7 +79,7 @@ async function sourceOwners(engine: BrainEngine, source: string): Promise<string
/**
* The personal sources among `sources` an attested call for `member` must not read: every personal source not bound to
- * that member, or every personal source under a scope read. A schema before v295 has no personal source.
+ * that member, or every personal source under a scope read. A schema before v298 has no personal source.
*/
export async function hiddenPersonalSources(engine: Pick<BrainEngine, 'executeRaw'>, sources: readonly string[], member: string, scopeRead: boolean): Promise<Set<string>> {
const ids = [...new Set(sources)];
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 7b419261a2..2af4017db8 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -1491,7 +1491,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;
{ since: '0.60.620.0', id: 'refresh_publish_diverged_default_gbra386', text: 'A diverged managed checkout now publishes its local commits on `gbrain sources refresh` by default when the worktree\'s Git durability is on: `sources.refresh_publish_diverged` unset now means on there (it used to mean off), merged with the upstream in memory, never rebased or forced. The refresh publish first scans what the local commits add (messages, added lines, merge resolutions) and refuses the new `publish_secret_found` naming the file, line and rule, never the value, when one looks like a secret; `gbrain git commit-push --push-only --scan-secrets` runs the same gate. Unset with durability not on still refuses, naming `gbrain sources writer git-durability <source> --enable`; `false` turns it off.' },
{ since: 'TBD', id: 'attest_scope_read_ops_gst1158', text: 'An attested call (`x-qm-actor`) to `get_page`, `entity`, `whois`, `get_backlinks`, `get_timeline`, `find_experts`, `volunteer_context` or `query` that names `source_id` or `source_ids` now reads as those sources\' audience, as `memory_recall` already did: the person\'s pages restricted to named readers and their member page `memory/members/<member>` read as missing, a source outside the credential\'s read grant is refused, and `__all__` or `all_sources` beside a named source is refused (`invalid_params`). `get_timeline` gains `source_id` and `source_ids`, `find_experts` and `volunteer_context` gain `source_ids`, and `volunteer_context` refuses `stats: true` under that read. `gbrain auth rescope --attest-read person|scope|none` sets how an attest credential reads named sources: `person` narrows to them but reads as the person; `scope` reads them as their audience and refuses every call that names no person (`actor_not_attested` reason `actor_required`), reading nothing; unset (the default) keeps the scope read and still serves calls that name no person. `gbrain doctor` warns (`attest_read_shared_scope`) when a person credential reads a source another attest credential reads as the scope.' },
{ since: 'TBD', id: 'attest_direct_page_writes_deferred_gst1158', text: 'An attested call (`x-qm-actor`) may no longer run `add_timeline_entry`, `add_link`, `put_page` or `edit_page`: they write pages every reader of the page sees, so they wait for owner-approved proposals. `gbrain auth rescope --attest-ops` refuses a list that names one, a credential whose list already names one is refused for it on every attested call (`actor_not_attested`, reason `op_not_attested`), and a queued attested write of one fails when it publishes. Unattested calls and member-bound credentials are unchanged.' },
- { since: 'TBD', id: 'personal_sources_gbra284', text: 'An operator can bind a source to the member it belongs to (`gbrain access member source add <member> <source>`, migration v295); a bound source is personal. An attested call (`x-qm-actor`) now reads its credential\'s grant minus every personal source bound to another member, and a read that names sources as their audience (the scope read) reads no personal source at all, not even the speaker\'s own. A hidden personal source named in `source_id` or `source_ids` is refused exactly like a source outside the grant (`permission_denied`); an unnamed read skips it. The rule only hides inside the grant and never makes a source readable, so it is within the existing trust posture (gate_rev 6). On an existing install nothing changes until an operator binds a source; after that, a credential whose grant already includes the bound source stops showing it to attested callers for anyone else. Unattested calls and member-bound credentials are unchanged.' },
+ { since: 'TBD', id: 'personal_sources_gbra284', text: 'An operator can bind a source to the member it belongs to (`gbrain access member source add <member> <source>`, migration v298); a bound source is personal. An attested call (`x-qm-actor`) now reads its credential\'s grant minus every personal source bound to another member, and a read that names sources as their audience (the scope read) reads no personal source at all, not even the speaker\'s own. A hidden personal source named in `source_id` or `source_ids` is refused exactly like a source outside the grant (`permission_denied`); an unnamed read skips it. The rule only hides inside the grant and never makes a source readable, so it is within the existing trust posture (gate_rev 6). On an existing install nothing changes until an operator binds a source; after that, a credential whose grant already includes the bound source stops showing it to attested callers for anyone else. Unattested calls and member-bound credentials are unchanged.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/schema-migrations/latest.generated.ts b/src/core/schema-migrations/latest.generated.ts
index 23b6b67130..5a896707f7 100644
--- a/src/core/schema-migrations/latest.generated.ts
+++ b/src/core/schema-migrations/latest.generated.ts
@@ -4,4 +4,4 @@
// The highest schema migration version (migrate.ts LATEST_VERSION), importable without
// loading the migrations themselves.
-export const LATEST_SCHEMA_VERSION = 297;
+export const LATEST_SCHEMA_VERSION = 298;
diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.ts
index abc373237e..cf2eca74f4 100644
--- a/src/core/schema-migrations/registry.generated.ts
+++ b/src/core/schema-migrations/registry.generated.ts
@@ -298,6 +298,7 @@ import { v294 } from './v294-refresh-barrier-import-deferral.ts';
import { v295 } from './v295-refresh-retry-hint-history-index.ts';
import { v296 } from './v296-ingest-applied-captures.ts';
import { v297 } from './v297-attest-read.ts';
+import { v298 } from './v298-access-member-sources.ts';
// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the
// runner sorts by version before applying.
@@ -594,4 +595,5 @@ export const MIGRATIONS: Migration[] = [
v295,
v296,
v297,
+ v298,
];
diff --git a/src/core/schema-migrations/v295-access-member-sources.ts b/src/core/schema-migrations/v298-access-member-sources.ts
similarity index 97%
rename from src/core/schema-migrations/v295-access-member-sources.ts
rename to src/core/schema-migrations/v298-access-member-sources.ts
index 4b8dcb846e..32a327a109 100644
--- a/src/core/schema-migrations/v295-access-member-sources.ts
+++ b/src/core/schema-migrations/v298-access-member-sources.ts
@@ -14,8 +14,8 @@ import type { Migration } from './types.ts';
// gets it unchanged. Nothing is rewritten on upgrade; with no binding every read
// is unchanged. No schema.sql mirror, like v286. Numbered on the GBRA-284
// branch; expect a renumber at the merge slot.
-export const v295: Migration = {
- version: 295,
+export const v298: Migration = {
+ version: 298,
name: 'access_member_sources',
idempotent: true,
sql: `
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 28dea9313d..d9e20155ce 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -1,6 +1,6 @@
{
"golden": {
- "count": 292,
+ "count": 293,
"gaps": [
17,
18,
@@ -97,7 +97,7 @@
"verifyProjectionStatistics": "0d231b04ecfbc5a4109d6fca9567bf4e8c9e9db6c3fbbb35212e026579ed6f67",
"withSchemaLockTimeout": "95605bd3004955e11e936c7a4aa6889319b401098abf9db18ef3e48da2c3fc59"
},
- "latest": 297,
+ "latest": 298,
"records": [
{
"handler": {
@@ -4839,6 +4839,19 @@
"transaction": "absent",
"verify": "absent",
"version": 297
+ },
+ {
+ "handler": "absent",
+ "idempotent": true,
+ "name": "access_member_sources",
+ "sql": {
+ "length": 573,
+ "sha256": "63da00dc6df6d19b1da78d752ab0e5566c1511a1cff16a2838e54b5fbf701ff9"
+ },
+ "sqlFor": "absent",
+ "transaction": "absent",
+ "verify": "absent",
+ "version": 298
}
],
"versions": [
@@ -5133,7 +5146,8 @@
294,
295,
296,
- 297
+ 297,
+ 298
]
},
"normalizer": "migrations-record-v1"
diff --git a/test/qm-personal-sources.test.ts b/test/qm-personal-sources.test.ts
index ac663dfc00..e402e73de0 100644
--- a/test/qm-personal-sources.test.ts
+++ b/test/qm-personal-sources.test.ts
@@ -1,5 +1,5 @@
/**
- * GBRA-284 (GST-359 G1 wave 2): personal sources. A source bound to a member (access_member_sources, v295) is read by an
+ * GBRA-284 (GST-359 G1 wave 2): personal sources. A source bound to a member (access_member_sources, v298) is read by an
* attested call only for that member, and never by a scope read; the rule only hides inside the credential's grant.
*
* 1. Protects: the HARN-1 gate shape. An attest client granted {source-a, dm-alice-example, dm-bob-example}, each DM