Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

QM scope writes: NULL-safe owned-page predicate, writer inventory, goldens (GST-1113)

garrytanb7a9cee31264
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 6d01b732b5..9a22c92e67 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -292,3 +292,4 @@ src/core/persistence/git-conversion.ts 4 contract G8a sources canonical (trusted
src/core/connectors/api-source.ts 2 coordinator Shared Fireflies/Slack publish step (GBRA-220): a managed source imports and deletes only through ManagedConnectorSync (prepared journal publication); the importFromContent and deletePages calls run for unmanaged sources, and in git mode only after the file was committed through commitPathsLocked (git first, writer lock). Private pages are held with holdNoncanonicalPrivate.
src/core/meetings/meetings-source.ts 1 coordinator Meetings connector (GBRA-220): the one sources.last_sync_at/newest_content_at stamp (never page content) runs only for unmanaged sources; managed runs stamp through the connector checkpoint save in connector-sync.ts.
src/core/slack/slack-source.ts 1 coordinator Slack channel connector (GBRA-220): the one sources.last_sync_at/newest_content_at stamp (never page content) runs only for unmanaged sources; managed runs stamp through the connector checkpoint save in connector-sync.ts.
+src/core/access/attest-sources.ts 1 projection GST-1113: applyAttestSources sets only sources.config.qm_scope (and federated false) on a source a credential first lists in attest_sources, under the sources row lock in the binding transaction. It writes no page column, revision, content hash, generation, checkpoint or topology column, so gbrain_require_managed_writer passes it on a managed brain, as with policy.ts writeAccessStore; the mark only hides.
diff --git a/src/core/access/member-facts.ts b/src/core/access/member-facts.ts
index 9d14b4f868..7dacb7a699 100644
--- a/src/core/access/member-facts.ts
+++ b/src/core/access/member-facts.ts
@@ -133,7 +133,7 @@ export function factVisibilitySql(alias: string, visibility: readonly string[]):
* cross from one such page to another or to an ordinary page.
*/
export function onOwnedMemoryPageSql(alias: string): string {
- return `(starts_with(COALESCE(${alias}.source_markdown_slug, ''), '${MEMBER_PAGE_PREFIX}') OR ${alias}.source_markdown_slug = '${SCOPE_PAGE_SLUG}')`;
+ return `(starts_with(COALESCE(${alias}.source_markdown_slug, ''), '${MEMBER_PAGE_PREFIX}') OR COALESCE(${alias}.source_markdown_slug, '') = '${SCOPE_PAGE_SLUG}')`;
}
/**
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index 59c0a17a68..3f18526025 100644
--- a/test/fixtures/goldens/cli/tools-json.json
+++ b/test/fixtures/goldens/cli/tools-json.json
@@ -2,8 +2,8 @@
"golden": {
"exitCode": 0,
"stderr": "",
- "stdoutBytes": 269480,
- "stdoutSha256": "a5efd152d5b57d8cab862c842421d4b321090631a5c72139cc5d1195e2849563",
+ "stdoutBytes": 269780,
+ "stdoutSha256": "cda3d9e0ad1f81977a5a7dfacb8b786702ba2be1f5c278ab7d4ba09e36c6e09d",
"toolNames": [
"remember",
"entity",
@@ -7168,7 +7168,8 @@
"parameters": {
"acting_user": "string?",
"facts": "array",
- "idempotency_key": "string"
+ "idempotency_key": "string",
+ "source_id": "string?"
},
"required_scopes": [],
"schema": {
@@ -7217,6 +7218,10 @@
"idempotency_key": {
"description": "1-128 visible ASCII characters; the same key replays this write.",
"type": "string"
+ },
+ "source_id": {
+ "description": "Save on this scope source's shared page (memory/scope), read by everyone who reads that source; it must be one of the credential's scope sources. Omit to save for the person alone.",
+ "type": "string"
}
},
"required": [
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index 237f7b9d91..396dda19af 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -6570,7 +6570,7 @@
"members": [
"allowedOperations?: string[] | null | undefined",
"allowedSources?: string[] | undefined",
- "attest?: { system: string; ops: string[]; } | null | undefined",
+ "attest?: { system: string; ops: string[]; sources: string[] | null; } | null | undefined",
"boundBrainId?: string | null | undefined",
"boundMaxConcurrent?: number | undefined",
"boundSlugPrefixes?: string[] | undefined",
@@ -6675,6 +6675,7 @@
"allowedSlugPrefixes?: string[] | undefined",
"applyRemoteReadPolicy?: boolean | undefined",
"attestedOp?: string | undefined",
+ "attestedSource?: string | undefined",
"auth?: AuthInfo | undefined",
"brainId?: string | undefined",
"cliOpts?: { quiet: boolean; progressJson: boolean; progressInterval: number; } | undefined",
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index ee9ef3da61..590f423337 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -1,6 +1,6 @@
{
"golden": {
- "count": 281,
+ "count": 282,
"gaps": [
17,
18,
@@ -94,7 +94,7 @@
"verifyProjectionStatistics": "0d231b04ecfbc5a4109d6fca9567bf4e8c9e9db6c3fbbb35212e026579ed6f67",
"withSchemaLockTimeout": "95605bd3004955e11e936c7a4aa6889319b401098abf9db18ef3e48da2c3fc59"
},
- "latest": 286,
+ "latest": 287,
"records": [
{
"handler": {
@@ -4648,6 +4648,19 @@
"transaction": "absent",
"verify": "absent",
"version": 286
+ },
+ {
+ "handler": "absent",
+ "idempotent": true,
+ "name": "qm_attest_sources",
+ "sql": {
+ "length": 149,
+ "sha256": "0f0c37619839efe212cdd64cf8df61e8a88633d441b5070d1974d619d1b008b2"
+ },
+ "sqlFor": "absent",
+ "transaction": "absent",
+ "verify": "absent",
+ "version": 287
}
],
"versions": [
@@ -4931,7 +4944,8 @@
283,
284,
285,
- 286
+ 286,
+ 287
]
},
"normalizer": "migrations-record-v1"