Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
remember: refuse share onto a page whose facts stay private, and name page and visibility on replays (GST-2243 review)
garrytan27773ca7f5df
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 53dc13666a..4d54268c13 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,18 +12,18 @@ identifiers and attribution are available in the pre-removal Git revision## [Unreleased]-**A team member's `remember` can now share a fact with the team, and every `remember` reply says where the fact went.** A member credential still saves privately by default, on its own page `memory/members/<member>`, so only that member recalls it. Passing `share: true` saves the fact on its subject's page instead, where everyone who reads the source recalls it, as every other caller's `remember` already does. The tool description tells agents to share facts about the team's work and keep facts about a person private. Before this, a member's `visibility: "world"` was quietly saved as private; it is now refused with `member_share_required` and nothing is saved, so no one believes they shared a fact the team cannot see. Nothing already saved moves.+**A team member's `remember` can now share a fact with the team, and every `remember` reply says where the fact went.** A member credential still saves privately by default, on its own page `memory/members/<member>`, so only that member recalls it. Passing `share: true` saves the fact on its subject's page instead, where everyone who reads the source recalls it, as every other caller's `remember` already does. The tool description tells agents to share facts about the team's work and keep facts about a person private. Before this, a member's `visibility: "world"` was quietly saved as private; it is now refused with `member_share_required` and nothing is saved, so no one believes they shared a fact the team cannot see. For the same reason, `share: true` onto a page whose facts are kept private (a page with readers named, or a brain whose fact default is private) is refused with `share_target_restricted`. A shared fact belongs to the team: only the brain host can withdraw it. Nothing already saved moves.### Itemized changes- `src/core/verbs.ts`: `remember` takes a `share` boolean on every MCP surface, starter included. A non-boolean `share`, `share: true` with `visibility: "private"`, and a member's `visibility: "world"` (`member_share_required`) are refused with `invalid_params` before anything is saved, so one such item refuses a whole batch.-- `src/core/persistence/memory-mutations.ts`: a member's `share: true` saves on the entity page with world visibility. New and replayed replies carry `page` and `visibility`.+- `src/core/persistence/memory-mutations.ts`: a member's `share: true` saves on the entity page with world visibility; when that page's facts would be private, the call is refused (`share_target_restricted`) before anything is admitted. New and replayed replies carry `page` and `visibility`.- `src/core/remember-batch.ts`: `share` is accepted per item and as a shared top-level key, and each item's receipt carries `page` and `visibility`.- `test/mcp-schema-budget.test.ts`: the starter tool-list ceilings and the `remember` budget grow by what `share` costs (+144 characters, 200 headroom kept).- QM's `memory_write` and its per-person contract (`docs/contracts/qm-memory-provider/v1.json`) are unchanged.- `src/core/behavior-change-notice.ts`: one row for the changed `remember` behavior.- Docs: `docs/tutorials/company-brain.md`, `docs/mcp/ADMIN.md`, `docs/TOOL_CATALOG.md` (regenerated).-- Tests: `test/remember-share-gst2243.test.ts` (a shared fact is recalled by another member and an unbound reader, an unshared one is not; both refusals; batch `share`; `memory_write` still saves on the member page); `test/access-member-facts.test.ts` drops the `visibility: "world"` an attested member save no longer accepts.+- Tests: `test/remember-share-gst2243.test.ts` (a shared fact is recalled by another member and an unbound reader, an unshared one is not; all three refusals; replayed and non-member replies; batch `share`; `memory_write` still saves on the member page); `test/access-member-facts.test.ts` drops the `visibility: "world"` an attested member save no longer accepts.## [0.60.626.0] - 2026-11-09diff --git a/docs/mcp/ADMIN.md b/docs/mcp/ADMIN.mdindex 95f3f3ec89..4245f51762 100644--- a/docs/mcp/ADMIN.md+++ b/docs/mcp/ADMIN.md@@ -258,7 +258,8 @@ pages; see [attested-actor refusals](../guides/write-refusals.md#attested-actor-`remember` saves to the person's own page `memory/members/<member>` (private,read back only by that member, written remotely by no one else) unless the callpasses `share: true`, which saves on the subject's page for everyone who reads-the source; the reply names the `page` and `visibility`. `delta` cursors, write receipts+the source (refused with `share_target_restricted` on a page whose facts are kept private;+only the brain host withdraws a shared fact); the reply names the `page` and `visibility`. `delta` cursors, write receipts(`get_write_request`, `list_write_requests`, `cancel_write_request`) and agentjobs (`submit_agent`, `get_agent_job`) belong to the person they were made for.QM's memory pair, `memory_recall` and `memory_write`, reads and saves thatdiff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 41794175e0..6f58e5c18e 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1494,7 +1494,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;{ since: '0.60.622.0', id: 'purge_cancels_deferred_write_gst1602', text: 'With `persistence.refresh_barrier` on, `gbrain forget <id> --purge` no longer refuses `purge_blocked_pending_recovery` while a write deferred behind a refresh holds the claim in its staged body: the deferred write was never claimed, so the purge cancels it with `purged_content`, as it does a queued one, and removes the content at once instead of up to 15 minutes later.' },{ since: '0.60.623.0', id: 'owner_reads_private_gst2059', text: 'A brain can now name its owner: `gbrain access owner set <member>` (config `access.owner_member`, an enabled member). Every remote credential or stdio server bound to that member reads the whole brain, `visibility: private` pages, privacy-alias pages (`access: private`, ...), derived and pinned-question pages included, through `get_page`, `search`, `query`, `recall` and the other page reads in the sources its grant reads, and `recall` returns its private facts. `readable_by` and folder rules still bind it, and it is not relaxed when it speaks for a shared-room audience. A page the owner\'s credential creates in `default` through `put_page` is not kept to the owner (no `readable_by: [member:<id>]`). Other members, unbound and public callers are unchanged. `_meta.access.relaxation` reads `owner` for such a call, and `gbrain access check --token <name>` reports it. `gbrain repair private-labels` (named runs only) previews the `access: private` labels stamped on ordinary pages with counts per category, keeps real restrictions, and clears the rest in reviewed batches (`--apply --expect <hash>`), recording each change so `--class restore` can put it back. The bulk-ingestion page template no longer writes an `access:` line; what each designation means is in docs/guides/access-designations.md.' },{ since: '0.60.626.0', id: 'record_origin_checkout_lockdown_8888', text: '`gbrain sources record-origin <id>... --remote --apply` now also turns git-lfs downloads and hooks off in each recorded source\'s existing checkout (its `.git/config`: `lfs.fetchexclude=*`, `core.hooksPath=/dev/null`, `lfs.locksverify=false`), not only on later reclones, in the repository\'s shared config, and refuses `write_failed` naming the key when a worktree-scoped or included setting still overrides one; a source already recorded as remote gets the lock-down on the next `--remote --apply` when its checkout lacks it, even when its files now use git-lfs, and a key that holds several values in that config is replaced by the one clone-time value. On a managed brain it takes the same worktree locks a reclone takes, refusing the id `source_busy` while a reclone, refresh or write holds them, and a reclone reads the record under its own locks. A write that fails is reported for its own id (`write_failed`) instead of ending the run. The git-lfs check reads a committed `.gitattributes` under a directory whose name holds a tab, ignores commented-out `filter=lfs` lines, says when a committed rule only declares an LFS filter, records a clone of an empty repository instead of refusing it, and names the cause of an `lfs_unknown` refusal.' },- { since: 'TBD', id: 'remember_share_gst2243', text: 'A member credential\'s `remember` still saves privately on `memory/members/<member>` by default, and can now pass `share: true` to save the fact on its subject\'s page for everyone who reads the source, as every non-member caller does. A member\'s explicit `visibility: "world"`, which used to be saved as private without a word, is now refused (`invalid_params`, reason `member_share_required`) and nothing is saved; `share: true` with `visibility: "private"` is refused too. Every `remember` reply, for any caller, now names the `page` the fact went to and its `visibility`. QM\'s `memory_write` is unchanged.' },+ { since: 'TBD', id: 'remember_share_gst2243', text: 'A member credential\'s `remember` still saves privately on `memory/members/<member>` by default, and can now pass `share: true` to save the fact on its subject\'s page for everyone who reads the source, as every non-member caller does. A member\'s explicit `visibility: "world"`, which used to be saved as private without a word, is now refused (`invalid_params`, reason `member_share_required`) and nothing is saved; `share: true` with `visibility: "private"`, or onto a page whose facts are kept private, is refused too (`share_target_restricted` for the page). Only the brain host can withdraw a shared fact. Every `remember` reply, for any caller, now names the `page` the fact went to and its `visibility`. QM\'s `memory_write` is unchanged.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/persistence/memory-mutations.ts b/src/core/persistence/memory-mutations.tsindex 4f0b7a94fd..17c4f16638 100644--- a/src/core/persistence/memory-mutations.ts+++ b/src/core/persistence/memory-mutations.ts@@ -218,6 +218,10 @@ export async function submitRememberMutation(ctx: OperationContext, params: Recoconst visibility = call.visibilityDefaulted && p.replaces !== undefined && p.replaces !== null? await replacementVisibility(ctx.engine, sourceId, Number(p.replaces), defaultedVisibility, { remote: ctx.remote !== false }): defaultedVisibility;+ if (p.share === true && visibility !== 'world') {+ throw Object.assign(verbError('invalid_params', `remember: share: true cannot share a fact on ${slug}, whose facts are kept private (restricted page or the brain's private fact default); nothing was saved.`,+ 'Share it on a page every reader of this source can read, or drop share to keep the fact on your own page.'), { reason: 'share_target_restricted' });+ }const factIntent = { fact: String(p.fact).trim(), kind: (p.kind ?? 'fact') as never, visibility, entity_slug: entitySlug, ...(memberPage ? { page_slug: memberPage } : {}) };// Fail fast on an invalid target or a withdrawn claim; the coordinator re-checks both under its locks before publishing.if (p.replaces !== undefined && p.replaces !== null) {diff --git a/test/remember-share-gst2243.test.ts b/test/remember-share-gst2243.test.tsindex ed488d795b..5e581ae839 100644--- a/test/remember-share-gst2243.test.ts+++ b/test/remember-share-gst2243.test.ts@@ -21,18 +21,11 @@ import { sqlQueryForEngine } from '../src/core/sql-query.ts';import { dispatchToolCall, type ToolResult } from '../src/mcp/dispatch.ts';import { __resetPrivateVisibilityCacheForTests } from '../src/core/search/private-visibility.ts';import { __resetHotMemoryCacheForTests, getBrainHotMemoryMeta } from '../src/core/facts/meta-hook.ts';-import { addGroup, addMember, bindCredential } from '../src/core/access/members.ts';+import { addMember, bindCredential } from '../src/core/access/members.ts';import { linkMember } from '../src/core/access/actor.ts';-import { memberPageSlug } from '../src/core/access/member-facts.ts';-import { decideSingleFact, type SingleFactIntent } from '../src/core/facts/single-prepare.ts';-import { prepareMemoryMutation } from '../src/core/persistence/memory-prepare.ts';-import { runFactsRelink } from '../src/core/facts/relink.ts';-import { runPhaseConsolidate } from '../src/core/cycle/phases/consolidate.ts';-import { serializePageToMarkdown } from '../src/core/markdown.ts';import type { AuthInfo } from '../src/core/ops/contract.ts';import { testBackends } from './helpers/test-backends.ts';import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';-import { withEnv } from './helpers/with-env.ts';const DIMS = 1536;function vectorFor(text: string): number[] {@@ -50,7 +43,7 @@ const SRC = 'qm-members';const ALICE_ID = 'U0ALICE';const BOB_ID = '[email protected]';const ACME = 'companies/acme-example';-const CANARY = { alice: 'canaryfactalice', bob: 'canaryfactbob' } as const;+const TEAM_PAGE = 'companies/globex-example';const ATTEST_OPS = ['memory_write', 'cancel_write_request', 'context_pack', 'delete_page', 'delta', 'edit_page', 'get_page', 'get_write_request', 'list_write_requests', 'put_page', 'recall', 'remember', 'search', 'whoami'];for (const kind of testBackends()) {@@ -64,10 +57,6 @@ for (const kind of testBackends()) {type Who = { token: string; actor?: string };const who = {alice: (): Who => ({ token: 'qm', actor: ALICE_ID }),- bob: (): Who => ({ token: 'qm', actor: BOB_ID }),- bobToken: (): Who => ({ token: 'bob' }),- bare: (): Who => ({ token: 'qm' }),- unbound: (): Who => ({ token: 'plain' }),};async function call(as: Who, op: string, params: Record<string, unknown>, extra: { sessionId?: string } = {}) {const out: ToolResult = await dispatchToolCall(engine, op, { ...params }, {@@ -93,6 +82,7 @@ for (const kind of testBackends()) {await engine.executeRaw('INSERT INTO sources (id, name) VALUES ($1, $1) ON CONFLICT (id) DO NOTHING', [SRC]);for (const id of ['alice-example', 'bob-example']) await addMember(engine, id);await importFromContent(engine, ACME, '---\ntype: company\ntitle: Acme Example\n---\n# Acme Example\n\nAcme example builds harbor ledgers.', { sourceId: SRC });+ await importFromContent(engine, TEAM_PAGE, '---\ntype: company\ntitle: Globex Example\nreadable_by: [alice-example]\n---\n# Globex Example\n\nGlobex example runs a private pilot.', { sourceId: SRC });const register = async (name: string) => {const c = await provider().registerClientManual('c2-' + name + '-' + randomUUID().slice(0, 8), ['client_credentials'], 'read write', [], SRC);return { id: c.clientId, secret: c.clientSecret ?? '' };@@ -109,7 +99,8 @@ for (const kind of testBackends()) {await linkMember(engine, 'bob-example', 'qm', BOB_ID);}, 120_000);- afterAll(async () => { __setEmbedTransportForTests(null); resetGateway(); await close?.(); }); const A = { token: 'alice' }, B = { token: 'bob' }, U = { token: 'plain' };+ afterAll(async () => { __setEmbedTransportForTests(null); resetGateway(); await close?.(); });+ const A = { token: 'alice' }, B = { token: 'bob' }, U = { token: 'plain' };const factRow = async (canary: string) => (await engine.executeRaw<Record<string, unknown>>('SELECT visibility, source_markdown_slug, entity_slug FROM facts WHERE fact LIKE $1', ['%' + canary + '%']))[0];test('share: true lands world on the subject page and another member recalls it; without share it stays private to the saver', async () => {@@ -142,6 +133,23 @@ for (const kind of testBackends()) {expect([own.isError, own.json.page, own.json.visibility]).toEqual([false, 'memory/members/alice-example', 'private']);}, 120_000);+ test('share onto a page whose facts are kept private is refused with share_target_restricted and nothing is saved', async () => {+ const out = await remember(A, 'Globex pilot ends in March canaryrestricted', { entity: TEAM_PAGE, share: true });+ expect(out.isError).toBe(true);+ expect(out.all).toContain('share_target_restricted');+ expect(await factRow('canaryrestricted')).toBeUndefined();+ }, 120_000);++ test('a replayed remember and a non-member remember both name page and visibility', async () => {+ const request_id = randomUUID();+ const first = await remember(A, 'Acme signs in April canaryreplay', { entity: ACME, share: true, request_id });+ const again = await remember(A, 'Acme signs in April canaryreplay', { entity: ACME, share: true, request_id });+ expect([again.isError, again.json.page, again.json.visibility]).toEqual([false, first.json.page, first.json.visibility]);+ expect([first.json.page, first.json.visibility]).toEqual([ACME, 'world']);+ const plain = await remember(U, 'Acme ships weekly canaryplain', { entity: ACME });+ expect([plain.isError, plain.json.page, plain.json.visibility]).toEqual([false, ACME, 'world']);+ }, 120_000);+test('a batch shares every item with a top-level share: true', async () => {const out = await call(A, 'remember', { items: [{ fact: 'Acme pays net 30 canarybatchone', entity: ACME }, { fact: 'Acme has 3 sites canarybatchtwo', entity: ACME }], provenance: 'qm test', share: true });expect(out.isError).toBe(false);