Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(edit_page): shares put_page's preparation deadline and its DB-only write_through warning (#5616)

garrytan1feb4038afe3
diff --git a/src/core/persistence/consumer.ts b/src/core/persistence/consumer.ts
index 006f783c6b..afdfd2d02f 100644
--- a/src/core/persistence/consumer.ts
+++ b/src/core/persistence/consumer.ts
@@ -438,7 +438,8 @@ export class PersistenceConsumer {
this.preparing.set(row.id, observation);
const stop = () => abort.abort({ code: 'consumer_stopping' });
this.abort.signal.addEventListener('abort', stop, { once: true });
- const bounded = row.operation === 'remember' || row.operation === 'put_page' && !row.intent?.kind;
+ // edit_page (#5616) builds its content during preparation like put_page, so it shares the deadline.
+ const bounded = row.operation === 'remember' || (row.operation === 'put_page' || row.operation === 'edit_page') && !row.intent?.kind;
const budget = this.opts.preparationMs ?? 30_000;
const deadline = performance.now() + budget;
const timeout = bounded ? setTimeout(() => {
diff --git a/src/core/persistence/coordinator.ts b/src/core/persistence/coordinator.ts
index 4e50864449..d116634461 100644
--- a/src/core/persistence/coordinator.ts
+++ b/src/core/persistence/coordinator.ts
@@ -246,7 +246,7 @@ export async function publishMutation(engine: BrainEngine, row: WriteRequest, pr
outcome.persistence = { mode: files.length ? 'filesystem' : 'database', ...(files.length ? { file_written: !prepared.noop } : {}), ...(skill ? { git_state: 'not_requested' } : {}) };
outcome.write_through = files.length ? { written: !prepared.noop } : { written: false, skipped: prepared.databaseOnlyReason ?? row.authority.databaseOnlyReason ?? 'no_repo_configured' };
if (prepared.databaseOnlyReason === 'mirror_read_only') outcome.storage = 'database_only';
- if (row.operation === 'put_page' && row.authority.remote && row.authority.databaseOnlyReason === 'no_repo_configured') outcome.write_through = withNoRepoWriteThroughWarning(outcome.write_through as { written: boolean; skipped?: string }, row.source_id);
+ if ((row.operation === 'put_page' || row.operation === 'edit_page') && row.authority.remote && row.authority.databaseOnlyReason === 'no_repo_configured') outcome.write_through = withNoRepoWriteThroughWarning(outcome.write_through as { written: boolean; skipped?: string }, row.source_id, row.operation);
if ((outcome.write_through as { skipped?: string }).skipped === 'unbound_source') {
outcome.write_through = { ...outcome.write_through as object, warning: unboundWriteWarning(row.operation, row.source_id, row.authority.databaseOnlyReason === 'unbound_source') };
}
diff --git a/src/core/write-through.ts b/src/core/write-through.ts
index a5085a5120..e0f0074fc8 100644
--- a/src/core/write-through.ts
+++ b/src/core/write-through.ts
@@ -103,12 +103,12 @@ export interface WritePageThroughOpts {
logger?: WriteThroughLogger;
}
-export function withNoRepoWriteThroughWarning<T extends { written: boolean; skipped?: string; warning?: string }>(result: T, sourceId: string): T {
+export function withNoRepoWriteThroughWarning<T extends { written: boolean; skipped?: string; warning?: string }>(result: T, sourceId: string, operation = 'put_page'): T {
if (result.written || result.skipped !== 'no_repo_configured') return result;
return {
...result,
warning:
- `put_page wrote only to the database for source '${sourceId}': no repo/local_path is configured, so no durable markdown file was created. ` +
+ `${operation} wrote only to the database for source '${sourceId}': no repo/local_path is configured, so no durable markdown file was created. ` +
'Bind this MCP server/token to a git-backed source or configure source local_path/sync.repo_path before relying on the write.',
} as T;
}
diff --git a/test/ingestion/put-page-write-through.test.ts b/test/ingestion/put-page-write-through.test.ts
index 1e17dabef0..77a5058208 100644
--- a/test/ingestion/put-page-write-through.test.ts
+++ b/test/ingestion/put-page-write-through.test.ts
@@ -461,6 +461,21 @@ describe('put_page write-through — config edge cases', () => {
expect(result.write_through?.warning).toContain('no durable markdown file');
});
+ test('remote edit_page with no repo configured warns that the edit is DB-only too (#5616)', async () => {
+ await engine.executeRaw("DELETE FROM config WHERE key = 'sync.repo_path'");
+ const ctx = makeCtx({ remote: true });
+ await putPage.handler(ctx, { slug: 'inbox/no-repo-edit', content: '---\ntitle: Edit\n---\n\nalpha line' });
+ const { operations } = await import('../../src/core/operations.ts');
+ const getPage = operations.find(op => op.name === 'get_page')!;
+ const editPage = operations.find(op => op.name === 'edit_page')!;
+ const read = await getPage.handler(ctx, { slug: 'inbox/no-repo-edit', include_content: true }) as { revision: string };
+ const result = (await editPage.handler(ctx, {
+ slug: 'inbox/no-repo-edit', expected_revision: read.revision, edits: [{ old_text: 'alpha line', new_text: 'beta line' }],
+ })) as { write_through?: { skipped?: string; warning?: string } };
+ expect(result.write_through?.skipped).toBe('no_repo_configured');
+ expect(result.write_through?.warning).toContain('edit_page wrote only to the database');
+ });
+
test.each([false, true])('missing directory returns a private typed error before admission (remote=%s)', async (remote) => {
await engine.setConfig('sync.repo_path', path.join(tmpRoot, 'does-not-exist'));
const ctx = makeCtx({ remote });
diff --git a/test/persistence-consumer-scheduling.test.ts b/test/persistence-consumer-scheduling.test.ts
index d76bbcfb0a..7af912f80a 100644
--- a/test/persistence-consumer-scheduling.test.ts
+++ b/test/persistence-consumer-scheduling.test.ts
@@ -232,6 +232,29 @@ for (const cooperates of [true, false]) test(`preparation deadline retains track
}
}), 5000);
+test('an edit_page preparation shares the preparation deadline (#5616)', async () => withEnv(env, async () => {
+ const sources = await fixtures(engine, config);
+ const row = await admitWrite(engine, admission(config, sources[0], 'edit-page-deadline', 'edited body', 0, { operation: 'edit_page' }));
+ const release = Promise.withResolvers<void>();
+ let aborted = false;
+ const consumer = new PersistenceConsumer(engine, { engine: 'pglite' }, async (_e, current, _c, signal?: AbortSignal) => {
+ signal?.addEventListener('abort', () => { aborted = true; release.resolve(); }, { once: true });
+ await release.promise;
+ signal?.throwIfAborted();
+ return prepared(current, sources);
+ }, { hostId: config.hostId, pollMs: 60_000, preparationMs: 50 });
+ try {
+ consumer.start();
+ await waitFor(() => aborted);
+ await waitFor(() => consumer.status().active_preparations === 0);
+ expect((await getWriteRequestById(engine, row.id))?.state).toBe('queued');
+ } finally {
+ release.resolve();
+ await consumer.stop();
+ await cancelWriteRequest(engine, { kind: 'local_cli', id: config.principalIds[0] }, row.request_id);
+ }
+}), 5000);
+
test('publication entering before the preparation deadline keeps its protected terminal outcome', async () => withEnv(env, async () => {
const sources = await fixtures(engine, config);
const row = await admitWrite(engine, admission(config, sources[0], 'publication-wins', 'protected body'));