Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(trust): the trust_release preparer refuses an index-existing intent without a row number (gstack /ship review, GBRA-60 lane C)
garrytan32ab534acf43
diff --git a/src/core/trust/release-publish.ts b/src/core/trust/release-publish.tsindex 23e7fed182..5b88b15463 100644--- a/src/core/trust/release-publish.ts+++ b/src/core/trust/release-publish.ts@@ -125,7 +125,7 @@ export async function submitTrustRelease(engine: BrainEngine, holdId: number, byexport async function prepareTrustReleaseMutation(engine: BrainEngine, row: WriteRequest, config: GBrainConfig): Promise<PreparedMutation> {const intent = row.intent as unknown as ReleaseIntent | null;if (row.operation !== TRUST_RELEASE_OPERATION || row.authority.remote || !intent || !Number.isSafeInteger(intent.hold_id) || typeof intent.last_seen_at !== 'string'- || typeof intent.by !== 'string' || (intent.mode !== 'append' && intent.mode !== 'index-existing')) {+ || typeof intent.by !== 'string' || (intent.mode !== 'append' && intent.mode !== 'index-existing') || (intent.mode === 'index-existing' && !Number.isSafeInteger(intent.row_num))) {throw opError('confirmation_required', 'This release is not confirmed by the owner; nothing was changed.','Run gbrain trust release on the brain host in an interactive terminal.');}@@ -145,7 +145,7 @@ export async function prepareTrustReleaseMutation(engine: BrainEngine, row: Writvalid_until: str(p.valid_until) ? new Date(String(p.valid_until)) : null, embedding: null, embedding_model: null,};const append = await prepareFenceFactAppend(engine, row, config, snapshot, intent.mode === 'index-existing'- ? { mode: 'index-existing', rowNum: Number(intent.row_num), fact, pendingTier: 'user_confirmed' }+ ? { mode: 'index-existing', rowNum: intent.row_num!, fact, pendingTier: 'user_confirmed' }: { fact, pendingTier: 'user_confirmed' });if (intent.mode === 'index-existing') {const base = await materializedPage(engine, snapshot.page);diff --git a/test/trust-release-fence.test.ts b/test/trust-release-fence.test.tsindex d362ba8c92..4d0fa5eacc 100644--- a/test/trust-release-fence.test.ts+++ b/test/trust-release-fence.test.ts@@ -436,7 +436,7 @@ describe('the trust_release preparer refuses a request the owner did not confirmconst engine = new Proxy({}, { get: (_t, key) => { throw new Error(`engine.${String(key)} read`); } }) as BrainEngine;const intent = { hold_id: 1, last_seen_at: '2026-01-01T00:00:00Z', by: 'owner:owner-example', mode: 'append' };const row = (over: Record<string, unknown>) => ({ operation: 'trust_release', source_id: 'default', slug, page_id: 1, intent, authority: { remote: false }, ...over }) as never;- for (const bad of [{ authority: { remote: true } }, { intent: null }, { intent: { ...intent, mode: 'rewrite' } }, { intent: { ...intent, hold_id: 'h1' } }, { operation: 'remember' }]) {+ for (const bad of [{ authority: { remote: true } }, { intent: null }, { intent: { ...intent, mode: 'rewrite' } }, { intent: { ...intent, hold_id: 'h1' } }, { intent: { ...intent, mode: 'index-existing' } }, { operation: 'remember' }]) {const error = await prepareTrustReleaseMutation(engine, row(bad), { engine: 'pglite' } as never).then(() => null, (e: { code?: string }) => e);expect({ bad, code: error?.code }).toEqual({ bad, code: 'confirmation_required' });}