Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: the Git privacy class sends question pages to the lineage check like remote reads do

garrytan249770bb854e
diff --git a/src/core/persistence/git-declared.ts b/src/core/persistence/git-declared.ts
index 21aebd3682..25b6d9f4c3 100644
--- a/src/core/persistence/git-declared.ts
+++ b/src/core/persistence/git-declared.ts
@@ -88,7 +88,7 @@ export async function privacyClass(engine: BrainEngine, sourceId: string, page:
if (isPrivacyPrivatePage(page)) return 'private';
if (isPrivacyDerivationPrivate(page)) return 'alias_private';
const frontmatter = typeof page.frontmatter === 'object' && page.frontmatter !== null ? page.frontmatter as Record<string, unknown> : {};
- if (frontmatter.derived_from == null && !['atom', 'concept', 'event'].includes(page.type ?? '')) return null;
+ if (frontmatter.derived_from == null && !['atom', 'concept', 'event', 'question'].includes(page.type ?? '')) return null;
const [row] = await engine.executeRaw<{ lineage: boolean }>(`SELECT NOT ${privacyPartSql('p')} AS lineage
FROM (SELECT $1::text AS source_id, $2::text AS slug, $3::text AS type, $4::text::jsonb AS frontmatter, $5::bigint AS id) p`,
[sourceId, page.slug, page.type ?? null, JSON.stringify(frontmatter), page.id ?? null]);
diff --git a/test/edge-whitespace-twins.test.ts b/test/edge-whitespace-twins.test.ts
index c068fd99fa..c3fccc634b 100644
--- a/test/edge-whitespace-twins.test.ts
+++ b/test/edge-whitespace-twins.test.ts
@@ -22,6 +22,7 @@ import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';
import { databaseOnlyPageSql, isDatabaseOnlyPage } from '../src/core/persistence/unbound-pages.ts';
import { memberIdentityFor, stdioMemberId, STDIO_MEMBER_KEY } from '../src/core/access/caller.ts';
import { addMember } from '../src/core/access/members.ts';
+import { privacyClass } from '../src/core/persistence/git-declared.ts';
import {
PRIVACY_ALIASES, __resetPrivateVisibilityCacheForTests, isPrivacyPrivatePage, privacyAliasSql,
privatePagesFilterFastForCaller, privatePagesFilterForCaller, privatePagesFilterFragment, privatePagesFilterFragmentFast,
@@ -132,6 +133,21 @@ describe.each(testBackends())('%s', (backend) => {
expect(await visible(privatePagesFilterFastForCaller('p'))).toEqual(await visible(privatePagesFilterForCaller('p')));
});
+ test('privacyClass keeps a question page with a private synthesized input out of Git, as remote reads hide it', async () => {
+ __resetPrivateVisibilityCacheForTests();
+ const sourceId = `lineage-${randomUUID().slice(0, 8)}`;
+ await engine().executeRaw('INSERT INTO sources(id,name) VALUES($1,$1)', [sourceId]);
+ const insert = async (slug: string, type: string, frontmatter: Record<string, unknown>) => Number((await engine().executeRaw<{ id: number }>(
+ `INSERT INTO pages(slug,type,title,compiled_truth,source_id,frontmatter) VALUES($1,$2,'T','body',$3,$4::text::jsonb) RETURNING id`,
+ [slug, type, sourceId, JSON.stringify(frontmatter)]))[0]!.id);
+ const input = await insert('atoms/input-example', 'atom', { visibility: 'private' });
+ const question = await insert('questions/q-example', 'question', { visibility: 'world' });
+ await engine().executeRaw("INSERT INTO links (from_page_id,to_page_id,link_type,link_source) VALUES ($1,$2,'synthesized_from','concept-provenance')", [question, input]);
+ const [row] = await engine().executeRaw<{ visible: boolean }>(`SELECT ${privatePagesFilterFragment('p')} AS visible FROM pages p WHERE p.id = $1`, [question]);
+ expect(row!.visible).toBe(false);
+ expect(await privacyClass(engine(), sourceId, { id: question, slug: 'questions/q-example', type: 'question', frontmatter: { visibility: 'world' } })).toBe('lineage_private');
+ });
+
test('the stdio member binding trims like stdioMemberId', async () => {
await addMember(engine(), 'carol-example');
try {