Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Opt-in and MCP train: writer claim moves to its own function, think remote-model test joins the Postgres lane
garrytan65232d16fb31
diff --git a/src/core/persistence/administration.ts b/src/core/persistence/administration.tsindex bebc9117c0..857b8390ca 100644--- a/src/core/persistence/administration.ts+++ b/src/core/persistence/administration.ts@@ -132,6 +132,25 @@ async function writerStatusMovement(engine: BrainEngine, sourceId: string | undefix: readFix('Reads source movement on its own, read-only.', { argv: ['gbrain', 'sources', 'writer', 'movement', ...(sourceId === undefined ? [] : [sourceId]), '--json'] }) }));}+async function writerClaim(engine: BrainEngine, params: Record<string, unknown>): Promise<Record<string, unknown>> {+ keys(params, ['source_id', 'path', 'dry_run', 'admin_intent', 'expected_state']);+ const sourceId = source(params.source_id), root = path(params.path);+ // #5198: say at claim time what the claim retires, before and after the fact.+ const notice = await readManagedMode(engine) ? {} : { activation_required: CLAIM_BEFORE_ACTIVATION_NOTICE };+ // #8625: a moved checkout at the root the claim reserves is named with its exit.+ const worktree = claimedWorktreeRoot(root);+ if (params.dry_run) {+ if (worktree) await inspectClaimedPhysicalRoot(engine, sourceId, worktree, 'claim', existingHostIdFor(engine));+ return { dry_run: true, action: 'writer_claim', source_id: sourceId, path: root, current: await getWorktreeBinding(engine, sourceId, existingHostIdFor(engine)), ...notice };+ }+ const expectedState = await requireWriterAdminIntent(engine, 'writer_claim', params);+ try { return { claimed: true, binding: await claimWorktree(engine, sourceId, root, undefined, expectedState), ...notice }; }+ catch (error) {+ if (!(error instanceof OperationError) || error.detail !== 'physical_root_moved' || !worktree) throw error;+ throw await movedPhysicalRootRefusal(engine, worktree, { sourceId, operation: 'claim' }, existingHostIdFor(engine)) ?? error;+ }+}+export async function runPersistenceAdministration(engine: BrainEngine, operation: PersistenceAdminOperation,params: Record<string, unknown>, config?: GBrainConfig, embeddingRetryPolicy: 'owner' | 'mounted_database' = 'owner'): Promise<Record<string, unknown>> {if (operation === 'writer_reconcile_preview') return (await import('./reconcile.ts')).runReconcilePreview(engine, params);@@ -334,24 +353,7 @@ export async function runPersistenceAdministration(engine: BrainEngine, operatio// #6317 (B4): per managed source, whether sync data moves (shares the reader of sources status, doctor and writer movement).movement: await writerStatusMovement(engine, params.source_id === undefined ? undefined : source(params.source_id)) };}- if (operation === 'writer_claim') {- keys(params, ['source_id', 'path', 'dry_run', 'admin_intent', 'expected_state']);- const sourceId = source(params.source_id), root = path(params.path);- // #5198: say at claim time what the claim retires, before and after the fact.- const notice = await readManagedMode(engine) ? {} : { activation_required: CLAIM_BEFORE_ACTIVATION_NOTICE };- // #8625: a moved checkout at the root the claim reserves is named with its exit.- const worktree = claimedWorktreeRoot(root);- if (params.dry_run) {- if (worktree) await inspectClaimedPhysicalRoot(engine, sourceId, worktree, 'claim', existingHostIdFor(engine));- return { dry_run: true, action: operation, source_id: sourceId, path: root, current: await getWorktreeBinding(engine, sourceId, existingHostIdFor(engine)), ...notice };- }- const expectedState = await requireWriterAdminIntent(engine, operation, params);- try { return { claimed: true, binding: await claimWorktree(engine, sourceId, root, undefined, expectedState), ...notice }; }- catch (error) {- if (!(error instanceof OperationError) || error.detail !== 'physical_root_moved' || !worktree) throw error;- throw await movedPhysicalRootRefusal(engine, worktree, { sourceId, operation: 'claim' }, existingHostIdFor(engine)) ?? error;- }- }+ if (operation === 'writer_claim') return writerClaim(engine, params);if (operation === 'writer_activate') {keys(params, ['confirm_quiesced', 'dry_run', 'shared_skills', 'admin_intent', 'expected_state', 'cleanup_dead_local_locks']);bool(params, 'cleanup_dead_local_locks');diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txtindex 8b09cade03..0ba85ba716 100644--- a/test/postgres-unit-arms.txt+++ b/test/postgres-unit-arms.txt@@ -620,6 +620,7 @@ test/sync-waiver-run-imports.test.tstest/take-resolution-survives-publish.test.tstest/takes-vector-lifecycle-5885.serial.test.tstest/terminal-failures-6650.test.ts+test/think-remote-model.test.tstest/timeline-chunk-reuse.test.tstest/transcript-redaction-key-names.test.tstest/trust-channel-writes.test.ts