Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(#6712 PR 4b): CI on the merged head: #6749 slug-conflict hold beside NUL bytes, receipt and attribution inventories, #3665 tag, fence-repair index row, win32 kept-page spelling
garrytanf6716741feda
diff --git a/docs/architecture/KEY_FILES.md b/docs/architecture/KEY_FILES.mdindex 4574d8d5c6..0a883c273b 100644--- a/docs/architecture/KEY_FILES.md+++ b/docs/architecture/KEY_FILES.md@@ -46,7 +46,7 @@ link it here rather than raising the cap.| [Core Minions (1/2)](key-files/core-minions-1.md) | `src/core/minions/` through `src/core/minions/protected-names.ts` || [Core Minions (2/2)](key-files/core-minions-2.md) | `src/core/minions/queue.ts` through `src/core/minions/worker.ts` || [Core Persistence](key-files/core-persistence.md) | `src/core/persistence/` journal, coordinator, effects, managed sync |-| [Core Persistence (continued)](key-files/core-persistence-continued.md) | `worktree-refresh*.ts`, `persistence/connector-*.ts`, `connectors/item-holds*.ts`, receipts |+| [Core Persistence (continued)](key-files/core-persistence-continued.md) | `worktree-refresh*.ts`, connectors, item holds, receipts; [fence repair](key-files/core-fence-repair.md) || [Persistence capacity](key-files/core-persistence-capacity.md) | write caps, true-up || [Core Persistence (seams)](key-files/core-persistence-request-indexes.md) | `checkpoint-validation`, `fault-points`, `native-file-target`, `admission-retry`, `unbound-source` || [Core Persistence (managed facts)](key-files/core-persistence-facts.md) | `facts-maintenance.ts`, `facts-prepare.ts`, `derived-facts.ts`, `same-page-shadow.ts` |diff --git a/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.mdindex a521cf0401..cde45c0b6a 100644--- a/docs/architecture/system-of-record.md+++ b/docs/architecture/system-of-record.md@@ -257,7 +257,7 @@ or a physical projection that leaves attribution untouched):- `src/core/facts/relink-publish.ts` (2): `relink_facts` request preparer.- `src/core/facts/unfenced-facts.ts` (1): the cycle and v0.32.2 fence of `row_num`-NULL facts: a maintenance request on managed brains; the unmanaged row-number stamp runs in `maintenanceTransaction` (the body mirror goes through `facts/file-body-guard.ts`).- `src/core/facts/withdrawal.ts` (1): runs inside the `forget` request's coordinated write.-- `src/core/persistence/twin-merge.ts` (5): the #6948 twin merge runs in the `managed_maintenance_resolve_origin_twin` preparer's coordinated transaction on managed brains and in one `maintenanceTransaction` on unmanaged brains (`gbrain repair origin-twins` and the post-sync heal).+- `src/core/persistence/twin-merge.ts` (5): the #6948 twin merge runs in the `managed_maintenance_resolve_origin_twin` preparer's coordinated transaction on managed brains and in one `maintenanceTransaction` on unmanaged brains (`gbrain repair origin-twins` and the post-sync heal); `gbrain repair legacy-twins` calls it from a receipted `managed_maintenance_merge_legacy_twin` request on managed brains and from one `maintenanceTransaction` under both page locks on unmanaged brains.- `src/core/trust/timeline-projection.ts` (2): `gbrain extract` timeline walks (file, incremental, stale) and the per-entry fallback write through it: one `maintenanceTransaction` per page tier.- `src/core/facts/write-single.ts` (2): the legacy single-fact insert and its supersession link each run in `maintenanceTransaction`; managed brains publish through the fact request.- `src/core/import-file.ts` (12): direct markdown, code and image imports, the moved-file rename (`updateSlug`) and the #3694 legacy-hash re-stamp run in `maintenanceTransaction`; managed imports go through the page request preparer.@@ -296,7 +296,6 @@ or a physical projection that leaves attribution untouched):- `src/core/repair/facts-rehome.ts` (1): `gbrain repair facts-rehome` moves facts inside `coordinatedDatabaseWrite` on managed brains (the `relink_facts` operation) and in one `maintenanceTransaction` per slug on unmanaged brains.- `src/core/repair/frontmatter.ts` (1): a `managed_file_repair` request on managed sources; the unmanaged rename runs in `maintenanceTransaction`.- `src/core/repair/ghost-pages.ts` (2): `gbrain repair ghost-pages` retirement: a receipted `managed_maintenance_retire_ghost_page` request (a prepared `delete_page` with no file bytes) on managed brains; the unmanaged version and soft delete run in `maintenanceTransaction` after the same recheck.-- `src/core/repair/legacy-twins.ts` (5): `gbrain repair legacy-twins` merge: a receipted `managed_maintenance_merge_legacy_twin` request (on the twin, holding the legacy page's key, no file bytes) on managed brains; the unmanaged merge runs in `maintenanceTransaction` under both page locks after the same recheck.- `src/core/repair/ontology-facts.ts` (1): a coordinated database-only write (`coordinatedDatabaseWrite`, the `ontology_propose` path) on managed brains; the unmanaged ontology-facts restore runs in `maintenanceTransaction`.- `src/core/repair/rename-identity.ts` (5): `gbrain repair rename-identity` carry, unmanaged brains only (a managed brain refuses `managed_remedy_unavailable` before writing); the fence-row merge, the provisional page's retirement, the slug move and the import run in one `maintenanceTransaction` under both page locks after the plan-hash recheck.- `src/core/repair/stale-atoms.ts` (3): a request on managed brains; the unmanaged retirement runs in `maintenanceTransaction`.diff --git a/src/core/persistence/sync-screen.ts b/src/core/persistence/sync-screen.tsindex fd07f132b7..9b3392bb03 100644--- a/src/core/persistence/sync-screen.ts+++ b/src/core/persistence/sync-screen.ts@@ -338,11 +338,12 @@ export async function screenFrozenImport(engine: BrainEngine, input: FrozenImporreturn { ...held, meta: { ...held.meta, legacy_slugs: entry.legacySlugs } };}if (content === null) return null;- // GBRA-133 S-39: text holding NUL cannot be stored or carried in the write intent; only this file is held.+ // GBRA-133 S-39: text holding NUL cannot be stored or carried in the write intent; only this file is held. A slug conflict+ // still names the hold (#6749): its message carries the path alone, and the slug-conflicts lane reports NULL_BYTES as still_invalid.const nul = nullBytesRefusal(entry.path, content);- if (nul) return heldEntry(entry, slug, pageId, nul, content, blob);// #6188: a fence Tier 1 rewrites is admitted (publication writes the normalized file back); with fences.normalize=false it is held.const screen = await screenFrozenContent(await frozenImportScreenInput(engine, { ...input, content }, run), run);+ if (nul && !(screen.status === 'refused' && screen.refusal.code === 'frontmatter_slug_conflict')) return heldEntry(entry, slug, pageId, nul, content, blob);if (screen.status === 'importable' && screen.fences?.fixes.length) input.onNormalized?.(screen.fences.fixes);if (screen.status !== 'refused') return null;const refusal = screen.refusal;diff --git a/test/behavior-change-notice-6712-block.test.ts b/test/behavior-change-notice-6712-block.test.tsindex c617337892..0a6fbd65aa 100644--- a/test/behavior-change-notice-6712-block.test.ts+++ b/test/behavior-change-notice-6712-block.test.ts@@ -32,6 +32,7 @@ function locateBlock(source: string): { rowLines: number; first: number; count:return { rowLines, first, count };}+// test-reads-source-ok[structural]: the block's position, contiguity and since stamp are properties of the array's source order, which the runtime list does not keep apart from master's rows.const source = readFileSync(join(import.meta.dir, '..', 'src', 'core', 'behavior-change-notice.ts'), 'utf8');describe('#6712 PR 4b BEHAVIOR_CHANGES block', () => {diff --git a/test/persistence-sync-origin-native.test.ts b/test/persistence-sync-origin-native.test.tsindex 9cda89a794..33c14ee1db 100644--- a/test/persistence-sync-origin-native.test.ts+++ b/test/persistence-sync-origin-native.test.ts@@ -113,6 +113,9 @@ async function legacyDeletion(engine: BrainEngine, f: Awaited<ReturnType<typeofauthority: authority.writer, callerIntent: intent, intent });return { requestId, intent, cursor: cursor as { runId: string; authority: typeof authority }, entry, key };}+/** The page the pass keeps: on Windows it re-spells a stored backslash origin with '/' in place, revision unchanged (as the separator identity test asserts). */+const keptSnapshot = (f: Awaited<ReturnType<typeof fixture>>) => process.platform === 'win32'+ ? { ...f.snapshot, page: { ...f.snapshot.page, source_path: syncOriginPath(f.snapshot.page.source_path!, 'win32') } } : f.snapshot;const legacyRows = (engine: BrainEngine, legacy: Awaited<ReturnType<typeof legacyDeletion>>) => engine.executeRaw<{ op: string }>("SELECT op FROM op_checkpoints WHERE (op='managed-sync' AND fingerprint=$1) OR (op='managed-sync-manifest' AND fingerprint=$2)", [legacy.key, legacy.cursor.runId]);const deleteRequests = (engine: BrainEngine, id: string) => engine.executeRaw<{ request_id: string; state: string; error_code: string | null }>(@@ -414,7 +417,7 @@ check("an older binary's unfinished cursor freezing a present file's deletion isconst legacy = await legacyDeletion(engine, f, false);expect(await performManagedSync(engine, f.opts)).toMatchObject({ status: 'first_sync', deleted: 0, pass: { outcome: 'synced' } });expect(await deleteRequests(engine, f.id)).toEqual([]);- expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id })).toEqual(f.snapshot);+ expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id })).toEqual(keptSnapshot(f));expect(await legacyRows(engine, legacy)).toEqual([]);expect((await engine.executeRaw<{ last_commit: string | null }>('SELECT last_commit FROM sources WHERE id=$1', [f.id]))[0].last_commit).toBe(f.head);expect(readFileSync(join(f.root, 'notes/example.md'), 'utf8')).toBe(content);@@ -431,7 +434,7 @@ check('an already-admitted legacy deletion is cancelled under its original ID wiexpect(row.intent).toEqual(legacy.intent);expect(await deleteRequests(engine, f.id)).toEqual([{ request_id: legacy.requestId, state: 'cancelled', error_code: 'cancelled' }]);expect(await legacyRows(engine, legacy)).toEqual([]);- expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id })).toEqual(f.snapshot);+ expect(await engine.readPageSnapshot(f.slug, { sourceId: f.id })).toEqual(keptSnapshot(f));expect(['synced', 'up_to_date']).toContain((await performManagedSync(engine, f.opts)).status);expect(await getWriteRequest(engine, legacy.cursor.authority.writer.principal, legacy.requestId)).toEqual(row);expect(await deleteRequests(engine, f.id)).toHaveLength(1);diff --git a/test/receipt-coverage.test.ts b/test/receipt-coverage.test.tsindex 711f18c582..ba988ef357 100644--- a/test/receipt-coverage.test.ts+++ b/test/receipt-coverage.test.ts@@ -28,7 +28,7 @@ type Coverage =| { sites: number; tables: GuardedTable[]; other: string };const RECEIPT_COVERAGE: Record<string, Coverage> = {- 'src/core/persistence/coordinator.ts': { sites: 1, receipted: 'the publication of an admitted request: every maintenance intent (conversation facts, fence reconcile, deleted-page expiry, takes reextract, take reprojection) applies here' },+ 'src/core/persistence/coordinator.ts': { sites: 2, receipted: 'the publication of an admitted request: every maintenance intent (conversation facts, fence reconcile, deleted-page expiry, takes reextract, take reprojection) applies here; a writeback import\'s folded pass stamp (afterEffects, #6712 PR 4b) runs inside that same receipted publication' },'src/core/persistence/group-publish.ts': { sites: 1, receipted: 'the grouped publication of admitted requests; each member is the attributed actor' },'src/core/persistence/memory-mutations.ts': { sites: 1, receipted: 'forget/withdraw: admitWriteInTransaction admits the request in the same transaction' },'src/core/facts/purge.ts': { sites: 1, receipted: 'purge_fact: admitWriteInTransaction admits the request and completeWrite records its terminal receipt in the same transaction' },