Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Keep the soft-delete receipt unchanged when labelling derived pages fails after the delete committed

garrytanf14e76c2bf83
diff --git a/src/core/repair/origin-carry.ts b/src/core/repair/origin-carry.ts
index 1977b6218a..b4110ece3e 100644
--- a/src/core/repair/origin-carry.ts
+++ b/src/core/repair/origin-carry.ts
@@ -94,8 +94,8 @@ async function stamp(engine: BrainEngine, pages: Dependent[], batch: string): Pr
export async function carryPrivate(engine: BrainEngine, origins: Origin[], batch: string): Promise<Map<number, CarryBlock>> {
if (!origins.length) return new Map();
return withoutCallerAccess(async () => {
- await readHonorAliases(engine);
try {
+ await readHonorAliases(engine);
const pages = [...new Map((await dependentsOf(engine, origins)).map(page => [page.id, page])).values()];
if (!pages.length) return new Map<number, CarryBlock>();
const failed = await stamp(engine, pages.filter(page => !page.deleted), batch);
@@ -144,7 +144,7 @@ export async function deletePageCarryingPrivate(ctx: OperationContext, p: Record
const origin = typeof p.slug === 'string' ? await originOf(ctx.engine, sourceId, p.slug.toLowerCase()) : null;
if (p.purge !== true) {
const result = await submitPageMutation(ctx, { operation: 'delete_page', params: p });
- if (origin && (await originOf(ctx.engine, sourceId, origin.slug))?.deleted) await carryPrivate(ctx.engine, [origin], batch);
+ if (origin && (await originOf(ctx.engine, sourceId, origin.slug))?.deleted) await carryPrivate(ctx.engine, [origin], batch).catch(() => undefined);
return finishPagePurge(ctx, result);
}
const block = origin ? (await carryPrivate(ctx.engine, [origin], batch)).get(origin.id) : undefined;
diff --git a/test/derived-origin-carry-private.test.ts b/test/derived-origin-carry-private.test.ts
index e8f3942a9d..b867c0462a 100644
--- a/test/derived-origin-carry-private.test.ts
+++ b/test/derived-origin-carry-private.test.ts
@@ -37,6 +37,7 @@ import { consentedPurgeDeletedPages, purgeDeletedPagesCoordinated, selectPurgeCa
import { checkDerivedOriginParked } from '../src/commands/doctor/checks/purge-parks.ts';
import { installFaultHook } from '../src/core/persistence/fault-points.ts';
import * as labelWrite from '../src/core/repair/label-write.ts';
+import * as privateVisibility from '../src/core/search/private-visibility.ts';
import type { AuthInfo } from '../src/core/ops/contract.ts';
import { testBackends } from './helpers/test-backends.ts';
import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';
@@ -441,6 +442,26 @@ for (const kind of testBackends()) {
await expectLateHidden(k, late);
}, 240_000);
+ test('a soft delete whose carry fails after the delete committed returns the normal receipt', async () => {
+ const k = 'carryfail';
+ await seed(k);
+ const origin = slugOf(k, 'origin');
+ const original = privateVisibility.readHonorAliases;
+ const failing = spyOn(privateVisibility, 'readHonorAliases').mockImplementation(async (...args: Parameters<typeof original>) => {
+ if (new Error().stack?.includes('carryPrivate')) throw new Error('forced honor-alias failure');
+ return original(...args);
+ });
+ let out: { isError: boolean; text: string };
+ try { out = await localCall('delete_page', { slug: origin, request_id: randomUUID(), expected_revision: await revision(origin) }); }
+ finally { failing.mockRestore(); }
+ expect(out.isError ? out.text : '').toBe('');
+ expect(JSON.parse(out.text).status).toBe('soft_deleted');
+ expect((await row(origin))?.deleted_at).not.toBeNull();
+ await backdate(origin);
+ expect((await purgeDeletedPagesCoordinated(engine, 72, { automatic: true })).slugs).toContain(origin);
+ for (const shape of CARRIED) expect({ shape, visibility: (await fm(slugOf(k, shape))).visibility }).toEqual({ shape, visibility: 'private' });
+ }, 240_000);
+
test('a stamp that fails parks the origin: never purged, named by doctor with the page that blocks it, the derived page stays hidden; fixed, the next purge stamps and unparks and the one after purges', async () => {
const k = 'park';
await seed(k);