Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(GBRA-130 A-5): a publication that keeps timing out is charged and fails publication_timeout at the attempt limit
garrytan9b2dfa887944
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.mdindex c2f4128018..2683ad46ed 100644--- a/docs/guides/error-codes.md+++ b/docs/guides/error-codes.md@@ -2810,6 +2810,16 @@ More: [docs/guides/repair.md#projection-owner-resident](../../docs/guides/repair|---|---|---|---|---|---|---|| The catalog adoption is accepted but not fully committed. | A temporary condition (a lock, a pending write, a rate limit); the same request can succeed later. | Wait briefly, then retry the same request (writes: reuse the same request_id). | agent | `repeat the read that failed` | 1 | yes |+### publication_timeout++<a id="publication_timeout"></a>++| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |+|---|---|---|---|---|---|---|+| A managed write's publication transaction hit its statement or lock timeout persistence.max_preparation_attempts times (default 2), so the owner finished it failed instead of claiming it again; nothing was committed. | A publication that times out on every attempt (a very large page or fact batch, or a slow lookup inside the 5-second publication transaction) used to be released as database_contention without being counted and claimed again forever, holding every later write on its root. Each timeout now counts one attempt and the write is terminal at the limit, so the rest of the root keeps moving. | Report the request id, the size the receipt names and gbrain sources writer status --source <id> --json; a smaller write (split the page or batch) needs a new request_id. Run: gbrain sources writer status --source '{source_id}' --json | host_admin | `gbrain doctor --json` | 1 | no |++More: [docs/guides/write-refusals.md#publication_timeout](../../docs/guides/write-refusals.md#publication_timeout)+### purge_blocked_pending_recovery<a id="purge_blocked_pending_recovery"></a>diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.mdindex 3ce9c5698a..45d84e7ef1 100644--- a/docs/guides/write-refusals.md+++ b/docs/guides/write-refusals.md@@ -98,6 +98,8 @@ of making a duplicate.| <a id="purge_lookup_timeout"></a>`purge_lookup_timeout` | `purge_lookup_timeout` | A page purge (`gbrain delete <slug> --purge`) ran one of the journal lookups that still execute inside its publication transaction (the lookup of stored intents for the slug, the re-check of requests admitted after its preparation scan or pending at that scan, the locking read of the requests to redact) and that statement hit the transaction's 5-second statement budget on a large `persistence_requests` table. The request failed terminally instead of being released as `database_contention` and claimed again: nothing of the page was removed or tombstoned, nothing in the journal was redacted, and later writes to the source move again. Do not assume the requested content was erased. The substring search for the page's claims no longer runs here: it runs at preparation in bounded keyset chunks under the preparation budget, and a sweep that outruns that budget twice ends [`preparation_stalled`](#preparation_stalled) instead. A committed purge's receipt reports `journal_sweep` (`scanned`, `ceiling`, `tail`, `pending_rechecked`, `complete`); `complete: false` means a cap was hit (the 10,000-match cap or the tail bound) and some requests were not tested. | If the receipt says the slug index `persistence_requests_slug_intent` is missing or INVALID, run `gbrain repair request-indexes --apply` (the `persistence_request_slug_intent_index` migration builds it online; the index serves the slug lookup, not the substring sweep), then submit the purge again with a new `request_id`. Otherwise submit it again with a new `request_id` (a retry with the same id returns this failure); if it times out again, report the request id with the `persistence_request_indexes` and `persistence_request_growth` entries of `gbrain doctor --json`. || <a id="purge_mirror_unwritable"></a>`purge_mirror_unwritable` | `purge_mirror_unwritable` | A fact or page purge appends a text-free `intent` line to the purge mirror (`<brain home>/.gbrain/purge-events.jsonl`) and fsyncs it before it commits, so a later restore of an older backup can replay the purge. The mirror could not be written (a directory in its place, a read-only home, a full disk), so the purge was refused: nothing was removed, tombstoned or redacted. Do not assume the requested content was erased. | Make the mirror a writable regular file owned by the brain's user (mode 0600), then run the purge again with a new `request_id`. || <a id="preparation_stalled"></a>`preparation_stalled` | `preparation_stalled` | The write's owner could not finish *preparing* it. Every write has a preparation budget (`persistence.sync_preparation_ms` for a managed sync member, `persistence.maintenance_preparation_ms` for every other managed kind, 120 s each; `remember`, `put_page` and `edit_page` keep 30 s), the owner releases the claim at the budget and tries again, and a request cut off `persistence.max_preparation_attempts` times (default 2; a process killed mid-preparation counts too) is finished `failed` with this code instead of being claimed again and holding the rest of its root. The receipt names the last recorded step and what it was waiting on (`git`, `fs`, `db`, `pool` or `unknown`); while the write was still running, `gbrain sources writer status --json` showed the same on `claim.stall` (`preparation_overdue`). The rest of the root keeps publishing. A **managed sync member** (an import, delete or rename of a file) is also **held**: the sync turns the failed receipt into a `preparation_stalled` hold and carries on, so the file is not imported until it is retried. The file is fine; this is the write owner stalling (a database or pool wait, a hung step), never a frontmatter or fence problem, so no repair applies. The hold's `message` names the request and the step; a held deletion keeps its page. A stalled hold re-screens by itself only when the gbrain version changes; a run that stalls many files in a row stops with [`preparation_systemic`](#preparation_systemic) instead of holding them all. A **foreground write** (`put_page`, `edit_page`, `remember`) or a **maintenance write** (fact-fence adoption, maintenance page writes) gets the terminal receipt only. The deadlines sit behind `persistence.preparation_deadlines` (`false` restores the old behaviour, where only `remember`, `put_page` and `edit_page` had a 30 s budget). | Run `gbrain sources writer status --source <source> --json` (read-only: the step, its wait cause, the owner process and its gbrain version), fix what it names (restart or upgrade an owner that predates deadlines, free the pool, let the lock holder finish), then for a sync hold run `gbrain sources retry-held <source>` and the same `gbrain sync` with the same options (the hold's `fix.then.then` and `retry-held` print it, for example `gbrain sync --source <source> --no-pull --no-embed`). When that sync still has a backlog to finish, it finishes it first and re-screens the scheduled files in the same invocation (the drain yields at the checkpoint and discovers again), so one run of the printed command clears the hold. A foreground write needs a new `request_id`; the next maintenance run submits its write again. Runbook: [catch-up stuck / held N files](troubleshooting.md#catch-up-stuck). |+| <a id="page_write_failed"></a>`page_write_failed` (sync hold) | `page_write_failed` | A managed sync held one file because its write failed the same way three times (the same code, origin, error class and SQLSTATE in this source), with an error gbrain cannot classify: an owner exception (for example Postgres 54000 when a frontmatter tag is too long for its index), or a refusal the receipt does not explain. A write that ended [`publication_timeout`](#publication_timeout) is held on its first receipt. Until GBRA-130 every sync stopped `blocked_by_failures` at that file and the rest of the source never imported; now the file is held and the rest of the source syncs. The first two failures still stop the run, so a one-off defect never holds a file. | Read the receipt the hold names (`gbrain write-request <request_id>`, read-only). Fix the file when the error names its content (shorten the tag, split the page), or report the receipt with the gbrain version. Then `gbrain sources retry-held <source>` and the same sync. An upgrade re-tests the file on its own. |+| <a id="publication_timeout"></a>`publication_timeout` | `publication_timeout` | The write's publication transaction (which runs under a 5-second local statement timeout) hit its statement timeout (57014) or lock timeout (55P03) on every attempt, `persistence.max_preparation_attempts` times (default 2). Each timeout counts one attempt; before GBRA-130 it was released as `database_contention` without being counted and claimed again forever, holding every later write on its root. Nothing was committed; a worktree-backed page's file is restored by its recovery record. The receipt's detail names the SQLSTATE, the attempts and the intent size. | Report the request id, its size and `gbrain sources writer status --source <id> --json`. A smaller write (split the page or the batch) needs a new `request_id`; a retry with the same id returns this failure. || <a id="write_outcome_unknown"></a>`write_outcome_unknown` | `write_outcome_unknown` | The database session dropped while the write was being admitted (a pooler reap, a failover, `pg_terminate_backend`), and it kept dropping through the re-reads, so whether the write was accepted is unknown (#6355). A single drop never reaches you: the admission attempt is re-run after 100, 300 and 900 ms, and every attempt begins by reading the retained `request_id`, so a re-run replays an admitted row instead of admitting again. Before this code existed the raw socket error (`write CONNECTION_CLOSED …`, `57P01`) reached the caller while the write went on to commit, and a receipt oracle took it for a refusal. | Read the request first: `gbrain write-request -- <request_id>` or `get_write_request { request_id }` (the error's `fix` names it). A committed or pending row means the write was accepted: replay the same `request_id` to wait for it. No row means it was not: submit it again with the same `request_id`. Never resubmit under a new `request_id` without that read. || <a id="page_body_segmented"></a>`page_body_segmented` | `page_body_segmented` (a memory verb: `invalid_params` with `write_error: page_body_segmented`) | The target page stores its body in segments (a page over 1 MiB written while `pages.segmented_storage` was on), and this write needs the whole body as one string: `remember` against an entity page over 24 MiB (named, or inferred from the fact), and the other whole-body writers listed under [page_body_segmented](windowed-reads.md#page_body_segmented). It refused before changing anything and is not retryable. | For `remember`, save the claim without an entity (`infer_entity: false`); remembering it with `entity` once that page accepts fact rows replaces that copy. Otherwise edit the page's file and sync it, or read it with `get_page` `body: "auto"`. || <a id="fence_unrenderable"></a>`fence_unrenderable` | `fence_unrenderable` | A legacy fact row (an active `facts` row with no fence row number) was not adopted into its page's `## Facts` fence because the fence codec reads the rendered row back as something other than the stored fact: a whitespace-only claim comes back empty, `~~x~~` comes back struck, a literal `<br>` comes back as a line break, or another column changes. Surrounding whitespace and CRLF line endings are the one accepted difference: such a row is adopted and `facts.fact` takes the fence's text. A second legacy row whose normalized claim, source and visibility the page already carries is left too (`duplicate_claim`; a private and a world row with one text are two facts and both adopt). The cycle and the v0.32.2 migration print `FACTS_FENCE_FAILED: <slug> (fence_unrenderable: N row(s), <class>)`; doctor `fence_integrity` lists the pages, fact ids and reason classes under `unrenderable_legacy_facts` (never the claim text). The same code refuses a planned adoption whose rendered fence does not read back as its facts; that is a gbrain planning defect, not caller input. The planner runs the publisher's own read-back check on the whole rendered fence first, so such a page is reported as unadoptable (class `whole_fence`) instead of being submitted. A managed adoption refused in the last day is not resubmitted: the cycle reports it as class `prior_refusal` with the refused request id (`gbrain write-request -- <id>` reads it), and a direct `submitFactFenceAdoption` call refuses with `The same fact-fence adoption was already refused.`. It is retried a day after the refusal, or at once by a build whose adoption planner revision changed. Unadopted rows hold only their own page: the phantom-redirect pass skips a phantom that owns one and redirects the others. Before v0.60.218.0 the planner could reuse a leftover fence row (one with no database owner) whose visibility differed from the legacy fact's. On a managed brain the publisher refused that page here every cycle, so no private fact was published as world. An unmanaged brain had no such check: it fenced the fact into the leftover row, and the same cycle's reconcile copied that row's visibility into the fact, so a private fact could become world. The current planner never reuses a leftover row for a fact with a different visibility unless the fact is private, and re-renders a reused row from the fact. To count what an older build left in the writer table, run the read-only `scripts/diagnose/fence-adoption-census.sql` on the brain host against the brain's Postgres database (its header shows the `psql` command). | Nothing to fix in the page: the rows stay active and searchable, nothing is lost, and their pages skip destructive fact reconciliation until the rows are adopted. Report the pages and reason classes with the gbrain version. Never `forget_fact` a row to clear the count. |diff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex 9121b2cfa3..eb54961f39 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -470,6 +470,12 @@ export const CODES = {suggestion: 'Inspect the owner with gbrain sources writer status --source <id> --json (the step and its wait cause), fix or report the cause, then gbrain sources retry-held <id> and the same gbrain sync with the same options; a foreground write needs a new request_id.',fix: { argv: ['gbrain', 'sources', 'status', '{source_id}', '--json'], consent: [], actor: 'host_admin', why: 'Read-only: lists the held files of the source with their repair route.', requires_exclusive: false } },preview_changed: { class: 'caller', summary: "The state changed since the approved preview." },+ publication_timeout: { class: 'server', retryable: false, actor: 'host_admin',+ summary: "A managed write's publication transaction hit its statement or lock timeout persistence.max_preparation_attempts times (default 2), so the owner finished it failed instead of claiming it again; nothing was committed.",+ why: 'A publication that times out on every attempt (a very large page or fact batch, or a slow lookup inside the 5-second publication transaction) used to be released as database_contention without being counted and claimed again forever, holding every later write on its root. Each timeout now counts one attempt and the write is terminal at the limit, so the rest of the root keeps moving.',+ docs: 'docs/guides/write-refusals.md#publication_timeout',+ suggestion: 'Report the request id, the size the receipt names and gbrain sources writer status --source <id> --json; a smaller write (split the page or batch) needs a new request_id.',+ fix: { argv: ['gbrain', 'sources', 'writer', 'status', '--source', '{source_id}', '--json'], consent: [], actor: 'host_admin', why: 'Read-only: names the failed request and its root.', requires_exclusive: false } },profile_incompatible: { class: 'caller', summary: "The stored profile is incompatible with this operation." },projection_owner_resident: { class: 'host_only', summary: "A resident owner holds the projection." },// #6643, retired by #6712 (one page, one fate): no page waits on another page's fate any more, so nothing re-freezes knock-ons.diff --git a/src/core/persistence/coordinator.ts b/src/core/persistence/coordinator.tsindex 9d88066a3f..0b6e5248d6 100644--- a/src/core/persistence/coordinator.ts+++ b/src/core/persistence/coordinator.ts@@ -25,6 +25,7 @@ import type { WriteTrust } from '../trust/tier.ts';import { withFilesystemPublication } from './filesystem-guard.ts';import { mayReprepare } from './semantic.ts';import { tryAcquirePublicationCapacity } from './pool-capacity.ts';+import { readPreparationPolicy } from './switches.ts';import { queuePublicationEffects } from './effect-journal.ts';import { timePublicationStep } from './publication-timing.ts';import type { GitCommitNote } from './effect-model.ts';@@ -252,9 +253,35 @@ export async function finishPreparationStalled(engine: BrainEngine, row: WriteRereturn engine.transaction(tx => completeWrite(tx, row, 'failed', {}, failure));}+/** GBRA-130 A-5: the statement (57014) or lock (55P03) timeout that cut off a publication transaction, else null. */+function publicationTimeout(error: unknown): string | null {+ const code = String((error as { code?: string } | null)?.code);+ return code === '57014' || code === '55P03' ? code : null;+}+/**+ * GBRA-130 A-5: a publication cut off by its timeout charges one attempt (`preparation_attempts`, the #6278 counter). Below+ * `persistence.max_preparation_attempts` it is released and claimed again; at the limit this returns the terminal+ * `publication_timeout` failure, so a write that times out every time stops holding every later write on its root (FIFO).+ */+async function chargePublicationTimeout(engine: BrainEngine, row: WriteRequest, sqlstate: string, stage: PublicationStage): Promise<PublicationFailure | null> {+ const attempts = await chargePreparationAttempt(engine, row);+ const { maxAttempts: limit } = await readPreparationPolicy(engine);+ if (attempts < limit) return null;+ return withAttempt({ code: 'publication_timeout',+ message: `The publication transaction of this ${row.operation} write timed out (${sqlstate === '57014' ? 'statement timeout' : 'lock timeout'}) ${attempts} time(s), the limit of persistence.max_preparation_attempts (${limit}); nothing was committed and it is not claimed again. Report the request id with its size (${row.intent_bytes} intent bytes) and gbrain sources writer status --source ${row.source_id} --json; a smaller write needs a new request_id.`,+ detail: { origin: 'publication_timeout', sqlstate, attempts, limit, intent_bytes: Number(row.intent_bytes) } as unknown as PublicationFailureDetail }, stage);+}+export async function finishUnpublishedFailure(engine: BrainEngine, row: WriteRequest, error: unknown,stage: PublicationStage = 'publication'): Promise<WriteRequest> {const failure = withAttempt(requestError(error), stage);+ const timedOut = stage === 'publication' && !mayReprepare(row, failure) ? publicationTimeout(error) : null;+ if (timedOut) {+ const terminal = await chargePublicationTimeout(engine, row, timedOut, stage);+ if (terminal) return engine.transaction(tx => completeWrite(tx, row, 'failed', {}, terminal));+ await releaseUnpublishedClaim(engine, row, 'database_contention');+ return (await getWriteRequestById(engine, row.id))!;+ }if (mayReprepare(row, failure) || transientDatabaseFailure(error)) {await releaseUnpublishedClaim(engine, row, transientDatabaseFailure(error) ? 'database_contention' : 'revision_changed_repreparing');return (await getWriteRequestById(engine, row.id))!;@@ -524,8 +551,10 @@ export async function publishMutation(engine: BrainEngine, row: WriteRequest, prif (recovery) {// Even a rejected prepare can retain a journal record; do not leave that// record unaccounted or let a sibling publication bypass its recovery.- const failure = !transactionBodyCompleted && !mayReprepare(row, requestError(error)) && !transientDatabaseFailure(error)- ? withAttempt(requestError(error), published ? 'after_file_publication' : 'publication') : undefined;+ const stage = published ? 'after_file_publication' : 'publication';+ const timedOut = !transactionBodyCompleted && !mayReprepare(row, requestError(error)) ? publicationTimeout(error) : null;+ const failure = timedOut ? await chargePublicationTimeout(engine, row, timedOut, stage).catch(() => null) ?? undefined+ : !transactionBodyCompleted && !mayReprepare(row, requestError(error)) && !transientDatabaseFailure(error) ? withAttempt(requestError(error), stage) : undefined;try { await markRecovering(engine, row, failure ? 'publication_failed' : published ? 'commit_outcome_uncertain' : 'publication_not_started', failure); }catch { /* database outage: durable recovery record remains discoverable */ }if (lock) {diff --git a/test/publication-timeout-charge-gbra130.test.ts b/test/publication-timeout-charge-gbra130.test.tsnew file mode 100644index 0000000000..fbb8099569--- /dev/null+++ b/test/publication-timeout-charge-gbra130.test.ts@@ -0,0 +1,93 @@+/**+ * GBRA-130 A-5 (#6712 PR 4b): a publication whose transaction always hits its statement timeout (57014) or lock timeout+ * (55P03) was released as `database_contention` without charging an attempt and claimed again without limit; as the+ * oldest unresolved row of its worktree it held every later write on that root (FIFO).+ *+ * Protects (red before: the timed-out write stays queued/running with `database_contention` and the write behind it+ * does not commit):+ * - each timeout charges one attempt (`preparation_attempts`), and at `persistence.max_preparation_attempts` the write+ * ends `failed`/`publication_timeout` with nothing committed;+ * - a later write to the same source then commits;+ * - both arms: a database-only page and a worktree-backed page (whose recovery record restores the canonical state).+ * Semantic injection: `installFaultHook` on the `publication:before_commit` seam, inside the publication transaction.+ * Runs on PGLite and, with DATABASE_URL, on Postgres.+ */+import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';+import { randomUUID } from 'node:crypto';+import { existsSync, mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import type { BrainEngine } from '../src/core/engine.ts';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { operations, type OperationContext } from '../src/core/operations.ts';+import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';+import { installFaultHook } from '../src/core/persistence/fault-points.ts';+import { claimWorktree } from '../src/core/persistence/ownership.ts';+import { _resetWriteThroughCacheForTest } from '../src/core/write-through.ts';+import { isolatedPersistencePostgres } from './helpers/persistence-postgres.ts';+import { testBackends } from './helpers/test-backends.ts';+import { withEnv } from './helpers/with-env.ts';++const op = (name: string) => operations.find(o => o.name === name)!;+const timeout = (code: '57014' | '55P03') => Object.assign(new Error(code === '57014' ? 'canceling statement due to statement timeout' : 'canceling statement due to lock timeout'), { code });+type Row = { state: string; error_code: string | null; error_message: string | null; blocked_reason: string | null; preparation_attempts: number; has_recovery: boolean };++for (const backend of testBackends()) describe(`[${backend}] GBRA-130 A-5: a publication that keeps timing out`, () => {+ let engine: BrainEngine;+ let closePostgres: (() => Promise<void>) | undefined;+ const home = mkdtempSync(join(tmpdir(), `gbrain-a5-${backend}-`));+ let brainDir = '';+ const managed = `wt-${randomUUID().slice(0, 8)}`;+ const context = (sourceId: string): OperationContext => ({ engine, config: { engine: backend, embedding_disabled: true } as never,+ logger: { info() {}, warn() {}, error() {} }, dryRun: false, remote: false, sourceId });+ const put = (sourceId: string, slug: string, requestId = randomUUID()) => withEnv({ GBRAIN_HOME: home }, () => op('put_page').handler(context(sourceId),+ { slug, source_id: sourceId, content: `---\ntitle: ${slug}\ntype: note\n---\nBody of ${slug}.\n`, request_id: requestId })) as Promise<Record<string, any>>;+ const row = async (requestId: string): Promise<Row> => (await engine.executeRaw<Row>(`SELECT state,error_code,error_message,blocked_reason,preparation_attempts,+ recovery IS NOT NULL AS has_recovery FROM persistence_requests WHERE request_id=$1::uuid`, [requestId]))[0]!;+ async function settled(requestId: string, ms = 20_000): Promise<Row> {+ const until = performance.now() + ms;+ for (;;) {+ const current = await row(requestId);+ if (['committed', 'failed', 'conflict', 'cancelled'].includes(current.state) || performance.now() > until) return current;+ await Bun.sleep(100);+ }+ }++ beforeAll(async () => {+ if (backend === 'pglite') { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); }+ else { const pg = await isolatedPersistencePostgres(process.env.DATABASE_URL!); engine = pg.engine; closePostgres = pg.close; }+ brainDir = mkdtempSync(join(home, 'brain-'));+ await engine.executeRaw('UPDATE persistence_brain SET enabled=false WHERE singleton=1');+ await engine.executeRaw('INSERT INTO sources(id,name,local_path) VALUES($1,$1,$2)', [managed, brainDir]);+ await withEnv({ GBRAIN_HOME: home }, () => claimWorktree(engine, managed, brainDir));+ await engine.executeRaw('UPDATE persistence_brain SET enabled=true WHERE singleton=1');+ _resetWriteThroughCacheForTest();+ }, 120_000);+ afterAll(async () => {+ installFaultHook(undefined);+ await disposePersistenceConsumer(engine); await engine.disconnect(); await closePostgres?.();+ _resetWriteThroughCacheForTest();+ rmSync(home, { recursive: true, force: true });+ }, 60_000);+ afterEach(async () => { installFaultHook(undefined); await disposePersistenceConsumer(engine); });++ for (const [arm, sourceId] of [['database-only page', 'default'], ['worktree-backed page', managed]] as const) {+ for (const code of ['57014', '55P03'] as const) test(`${arm}: a ${code} at every publication ends failed/publication_timeout at the attempt limit, and the next write commits`, async () => {+ const slug = `a5/t${code.toLowerCase()}-${randomUUID().slice(0, 8)}`;+ const requestId = randomUUID();+ let timedOut = 0;+ installFaultHook(async (point, detail) => {+ if (detail.requestId === requestId && point === 'publication:before_commit') { timedOut++; throw timeout(code); }+ });+ await put(sourceId, slug, requestId).catch(() => null);+ const done = await settled(requestId);+ expect(done).toMatchObject({ state: 'failed', error_code: 'publication_timeout', preparation_attempts: 2, has_recovery: false });+ expect(done.error_message).toContain('persistence.max_preparation_attempts (2)');+ expect(timedOut).toBeGreaterThanOrEqual(2);+ expect(await engine.readPageSnapshot(slug, { sourceId })).toBeNull();+ if (sourceId === managed) expect(existsSync(join(brainDir, `${slug}.md`))).toBe(false);+ const next = await put(sourceId, `${slug}-next`);+ expect(next.state).toBe('committed');+ }, 60_000);+ }+});