Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(#6712 PR 4a): the shadow counts write-through-off open requests, reads an absent working path as absent, and keeps the receipt on a refused dry run
garrytan5edb3988199a
diff --git a/scripts/bench/sync-convergence-seeded.ts b/scripts/bench/sync-convergence-seeded.tsindex 6f49efc768..76490b68c7 100644--- a/scripts/bench/sync-convergence-seeded.ts+++ b/scripts/bench/sync-convergence-seeded.ts@@ -61,8 +61,6 @@ const note = (title: string, body: string) => `---\ntitle: ${title}\n---\n\n${boconst titleOf = (path: string) => path.replace(/^.*[\\/]/, '').replace(/\.md$/, '');export const FINDINGS = {- inFlightDbOnly: { kind: 'a', ref: 'sync-pass.ts readOpenWork (WHERE worktree_id=$1); page-mutations.ts:400',- text: 'U_db reads open requests by worktree_id, but a put_page admitted with sync.write_through=false carries worktree_id NULL (page-mutations.ts:400), so a queued agent write on a page whose file changed is not in_flight and the shadow predicts a plain import (v3.2 §2.3 overlay).' },dirtyAbsorbed: { kind: 'b', ref: 'v3.2 §2.3 row 11 before row 12 vs §2.1 (Dp is read for candidates only); sync-pass.ts settledBeforeDirtiness',text: 'The design contradicts itself on an uncommitted edit of a matched path: row order puts it in row 11 dirty (settled, absorbed), but §2.1 reads Dp for candidates only, so the dirtiness of a matched path is never known. 4a follows §2.1 and says matched. Settlement and the action tag agree (settled, none); only the class differs.' },fullLegacy: { kind: 'b', ref: 'v3.1 §2.7 ("--full imports legacy-marked paths"), which v3.2 §2.7 keeps, vs v3.2 §2.3 row 10 (no episode clause)',@@ -73,10 +71,6 @@ export const FINDINGS = {text: 'frontmatter_slug_conflict and legacy_slug_conflict holds are always rescreen-due, so row 1 never holds them; with no page and an unchanged file they fall to row 10 legacy_same (settled, none) while the hold row still exists, so the class contradicts the hold that status shows.' },dirtyGlossary: { kind: 'b', ref: 'v3.2 §9 class glossary; sync-classify.ts syncClassAction',text: 'Row 11 dirty is settled when absorbed or published, but the glossary gives a class one action and 4a tags every dirty path repair, so a settled write-through publication waiting for its commit reads as needing a person.' },- spellingDryRun: { kind: 'a', ref: 'commands/sync dry run (master discovery throws page_identity_changed before dryRunConvergence runs); v3.2 §11 step 2',- text: 'One case- or separator-only collision (row 2) makes gbrain sync --dry-run --json exit 1 with page_identity_changed and no convergence block, so the redacted receipt that §11 makes the evidence channel cannot be produced for such a source; sync status --detail still reports the same counts.' },- workingAbsent: { kind: 'a', ref: 'sync-git-stream.ts probeDirtiness (dp untracked before the absence check, :226-236); sync-pass.ts levelOf (rawOid ?? unreadable:<path>)',- text: 'In working mode a domain path that is in neither T nor the index and is not on disk probes as untracked with no bytes, and levelOf turns that into the level unreadable:<path> instead of absent. So a committed git rm of a synced file is predicted import (not row 5 delete or row 6 delete_drift), and a tombstone whose file left the checkout is deleted_edited, a hold, instead of row 7 gone.' },twinInvisible: { kind: 'b', ref: 'v3.2 §2.3 domain (pages with a recorded origin only)',text: 'A #6885 legacy twin (source_path NULL) is outside the domain: the pair reads as one matched path and nothing in convergence counts it, so PR 4 can neither report nor converge already-forked pairs.' },} as const satisfies Record<string, Finding>;@@ -159,7 +153,7 @@ export function mixCases(): SeededCase[] {c('spelling: separator-only', 'mix/sep-pair.md', { key: 'spelling', action: 'refuse' }, 'row 2', 'git commit'),c('legacy_unverified', 'mix/legacy-unverified.md', { key: 'legacy_unverified', action: 'none', settled: true }, 'row 17', 'sync, raw SQL (record stripped, receipt compacted)'),c('in_flight: open write-through put_page on a changed file', 'mix/inflight-wt.md', { key: 'in_flight', action: 'import', settled: false }, 'overlay on row 16', 'sync, git commit, admitWrite (consumer stopped)'),- c('in_flight: open put_page (write-through off) on a changed file', 'mix/inflight-dbonly.md', { key: 'in_flight', action: 'import', settled: false }, 'overlay on row 16', 'sync, git commit, admitWrite (consumer stopped)', FINDINGS.inFlightDbOnly, { key: 'import', action: 'import', settled: false }),+ c('in_flight: open put_page (write-through off) on a changed file', 'mix/inflight-dbonly.md', { key: 'in_flight', action: 'import', settled: false }, 'overlay on row 16', 'sync, git commit, admitWrite (consumer stopped)'),c('#6885 legacy twin pair (file side)', 'mix/Twin Page.md', { key: 'matched', ...settledNone }, 'row 12', 'sync, raw SQL (legacy twin page without source_path)', FINDINGS.twinInvisible),];}@@ -317,12 +311,10 @@ export function seedMassDelete(root: string, cases: SeededCase[]): SeededCase[]* class. Only the paths whose working-mode class this mix pins are listed; the rest of the domain is left unchecked.*/export function workingCases(cases: SeededCase[]): SeededCase[] {- const absent = { finding: FINDINGS.workingAbsent };const want: Record<string, { expect: Expected; row: string; finding?: Finding; today?: Expected }> = {- 'mix/tomb-gone.md': { expect: { key: 'gone', action: 'none', settled: true }, row: 'row 7 (working mode: L absent, no live page)', ...absent,- today: { key: 'deleted_edited', action: 'hold', settled: false } },- 'mix/delete-proof.md': { expect: { key: 'delete', action: 'delete', settled: false }, row: 'row 5 (L absent, not present, proof)', ...absent, today: { key: 'import', action: 'import', settled: false } },- 'mix/delete-drift.md': { expect: { key: 'delete_drift', action: 'hold', settled: false }, row: 'row 6 (L absent, not present, no proof)', ...absent, today: { key: 'drift', action: 'hold', settled: false } },+ 'mix/tomb-gone.md': { expect: { key: 'gone', action: 'none', settled: true }, row: 'row 7 (working mode: L absent, no live page)' },+ 'mix/delete-proof.md': { expect: { key: 'delete', action: 'delete', settled: false }, row: 'row 5 (L absent, not present, proof)' },+ 'mix/delete-drift.md': { expect: { key: 'delete_drift', action: 'hold', settled: false }, row: 'row 6 (L absent, not present, no proof)' },'mix/untracked-new.md': { expect: { key: 'import', action: 'import', settled: false }, row: 'row 16 (in U, no page, no marker)' },'mix/dirty-absorbed.md': { expect: { key: 'import', action: 'import', settled: false }, row: 'row 16 (L = the disk bytes, proof)' },'mix/dirty-held.md': { expect: { key: 'import', action: 'import', settled: false }, row: 'row 16 (L = the disk bytes, proof)' },@@ -459,7 +451,9 @@ export async function cliChecks(engine: BrainEngine, run: EvalRun): Promise<CliCelse if (result.predicted?.key !== key) mismatches.push(`${result.entry.path}: redacted sample under ${key}, library ${result.predicted?.key}`);else if (result.predicted.glossary !== sample.action) mismatches.push(`${result.entry.path}: redacted action ${sample.action}, library ${result.predicted.glossary}`);}- return { dryRunExit: dry.exit, statusExit: status.exit, ...(dry.error ? { dryRunError: dry.error } : {}), ...(status.error ? { statusError: status.error } : {}), dryRunCounts: counts(dryConvergence), statusCounts: counts(statusConvergence), libraryCounts: counts(run.receipt),+ // A refused dry run reports its refusal as the envelope's code, beside its convergence receipt.+ const dryRunError = dry.error ?? (typeof dry.json?.code === 'string' ? { code: dry.json.code, message: String(dry.json.message ?? '') } : undefined);+ return { dryRunExit: dry.exit, statusExit: status.exit, ...(dryRunError ? { dryRunError } : {}), ...(status.error ? { statusError: status.error } : {}), dryRunCounts: counts(dryConvergence), statusCounts: counts(statusConvergence), libraryCounts: counts(run.receipt),redactionLeaks: leaks, redactedSamplesChecked: checked, redactedSampleMismatches: mismatches, dryRunConvergence: dryConvergence, statusConvergence };}@@ -692,7 +686,7 @@ async function main(): Promise<number> {const mass = await evaluate(brain.engine, seedMassDelete(brain.root, cases), { label: 'committed mode, after a mass removal (the valve)' });body = [renderRun(committed), '', renderCli(cli), ` The re-read after the CLI runs ${JSON.stringify(after.receipt.counts) === JSON.stringify(committed.receipt.counts) ? 'has the same counts' : '**has different counts**'}.`, '',renderRun(spelled), '', `With the spelling collisions: ${renderCli(spelledCli)}`, '', renderRun(full), '', renderRun(working), '', renderRun(mass), '',- renderFindings([committed, spelled, full, working, mass], spelledCli.dryRunError ? [FINDINGS.spellingDryRun] : [])].join('\n');+ renderFindings([committed, spelled, full, working, mass])].join('\n');}, { ...(databaseUrl ? { databaseUrl } : {}), setup: mixSetup });}mkdirSync(dirname(out), { recursive: true });diff --git a/src/cli/cli-error.ts b/src/cli/cli-error.tsindex 815a40ba9e..cdce45b4a5 100644--- a/src/cli/cli-error.ts+++ b/src/cli/cli-error.ts@@ -38,6 +38,10 @@ export interface CliErrorWriteOpts {* (line-reading consumers of the old shape keep working).*/legacy?: Record<string, unknown>;+ /** Fields the document carries after the envelope's own (a refused dry run's `convergence` receipt). */+ extra?: Record<string, unknown>;+ /** Where the document goes instead of fd 1 (a command's own JSON document writer). */+ emit?: (doc: string) => void;}/** The command word of an argv (first token that is not a flag), for E11 records. */@@ -56,8 +60,9 @@ export function writeCliError(e: unknown, command: string, opts: CliErrorWriteOpnoteRenderedErrorCode(env.code);// An NDJSON stream ends a failure with one `{status:"error", …envelope}` line (D2).const legacy = opts.legacy ?? (jsonGuardActive() === 'ndjson' ? { status: 'error' } : undefined);- const doc = legacy ? `${JSON.stringify({ ...legacy, ...withoutUndefined(env), ...legacy })}\n` : r.stdout;- void writeStdoutFinal(doc).catch(() => { /* fd 1 gone */ });+ const doc = legacy || opts.extra ? `${JSON.stringify({ ...legacy, ...withoutUndefined(env), ...legacy, ...opts.extra })}\n` : r.stdout;+ if (opts.emit) opts.emit(doc);+ else void writeStdoutFinal(doc).catch(() => { /* fd 1 gone */ });// stderr stays the human channel under --json (same TTY order as renderCliError).stderr = [`Error [${env.code}]: ${env.message}`, `Fix: ${env.fix?.command ?? env.suggestion}`,...(env.why ? [`Why: ${env.why}`] : [])].join('\n') + '\n';diff --git a/src/commands/sync/run.ts b/src/commands/sync/run.tsindex 7597ef2713..3b2a559a5a 100644--- a/src/commands/sync/run.ts+++ b/src/commands/sync/run.ts@@ -883,12 +883,25 @@ async function runSingleSourceSync(// v0.41.13.0 (T6): try/finally clears the single-source timer so it// doesn't fire after performSync resolves OR throws.let result: SyncResult;+ // #6712 PR 4a: a managed dry run also reports the read-only convergence shadow (sync-convergence.ts).+ const readConvergence = async () => (await import('../../core/persistence/sync-pass.ts')).dryRunConvergence(engine,+ { sourceId, full: !!full, workingTree, redactPaths: !!redactPaths, noEmbed, noExtract: !!noExtract, noSchemaPack: !!noSchemaPack });process.on('SIGINT', onSingleSourceSigint);try {// #6317 (D1 a′): on a managed Postgres brain whose host a live serve owns, the drain runs inside that serve as this// CLI's writer and returns the same SyncResult; every other case keeps this process's own consumer.const delegated = companyPolicy ? null : await (await import('../sync-delegate.ts')).maybeDelegateManagedSyncToServe(engine, args, opts);result = delegated?.kind === 'delegated' ? delegated.result : await performSync(engine, opts);+ } catch (error) {+ // A refused managed dry run (a case- or separator-only spelling pair) still carries its convergence receipt in the+ // refusal's envelope; the refusal and its exit code are unchanged.+ const { OperationError } = await import('../../core/ops/contract.ts');+ if (!(dryRun && jsonOut && !companyPolicy && error instanceof OperationError)) throw error;+ const convergence = await readConvergence();+ if (!convergence) throw error;+ const [{ writeCliError }, { setCliExitVerdict }] = await Promise.all([import('../../cli/cli-error.ts'), import('../../core/cli-force-exit.ts')]);+ setCliExitVerdict(writeCliError(error, 'sync', { json: true, extra: { convergence }, emit: emitJson }));+ return;} finally {if (singleSourceTimer !== undefined) clearTimeout(singleSourceTimer);process.off('SIGINT', onSingleSourceSigint);@@ -962,10 +975,7 @@ async function runSingleSourceSync(}}const capacity = await syncCapacityNotices(engine, jsonOut, result);- // #6712 PR 4a: a managed dry run also reports the read-only convergence shadow (sync-convergence.ts).- const convergence = jsonOut && result.status === 'dry_run' && !companyPolicy- ? await (await import('../../core/persistence/sync-pass.ts')).dryRunConvergence(engine, { sourceId, full: !!full, workingTree, redactPaths: !!redactPaths, noEmbed, noExtract: !!noExtract, noSchemaPack: !!noSchemaPack })- : undefined;+ const convergence = jsonOut && result.status === 'dry_run' && !companyPolicy ? await readConvergence() : undefined;if (jsonOut) {emitJson(JSON.stringify({ ...buildSingleSyncJsonEnvelope(sourceId, result, singleEmbedBackfill, singleCostGate), ...(convergence ? { convergence } : {}),...(result.managedWrite ? { managed_write: result.managedWrite } : {}), ...drainJsonFields(result, resumeCommand, sourceId),diff --git a/src/core/persistence/sync-pass.ts b/src/core/persistence/sync-pass.tsindex 21668a6ca1..add9f3558a 100644--- a/src/core/persistence/sync-pass.ts+++ b/src/core/persistence/sync-pass.ts@@ -139,10 +139,15 @@ async function readAttestations(exec: Exec, kind: 'postgres' | 'pglite', sourceIreturn statements;}-/** `U_db`: open requests of the worktree (the `persistence_requests_pending` index) and pending Git effects of the source. */-async function readOpenWork(exec: Exec, sourceId: string, worktreeId: string): Promise<{ pageIds: Set<number>; origins: Set<string>; statements: number }> {+/**+ * `U_db`: open requests of the worktree (the `persistence_requests_pending` index) and of the source incarnation with no+ * worktree (a write-through-off put_page, page-mutations.ts; `persistence_requests_database_pending`), and pending Git+ * effects of the source.+ */+async function readOpenWork(exec: Exec, sourceId: string, worktreeId: string, incarnation: string): Promise<{ pageIds: Set<number>; origins: Set<string>; statements: number }> {const [requests, effects] = await Promise.all([exec.executeRaw<{ page_id: number | null; source_path: string | null; path: string | null }>(`SELECT page_id, intent->>'sourcePath' AS source_path, intent->>'path' AS path- FROM persistence_requests WHERE worktree_id=$1 AND state IN ('queued','running','recovering') AND source_id=$2`, [worktreeId, sourceId]),+ FROM persistence_requests WHERE (worktree_id=$1 OR (worktree_id IS NULL AND source_incarnation=$3::uuid)) AND state IN ('queued','running','recovering') AND source_id=$2`,+ [worktreeId, sourceId, incarnation]),exec.executeRaw<{ page_id: number | null; path: string | null }>(`SELECT r.page_id, e.data->>'relative_path' AS pathFROM persistence_requests r JOIN persistence_effects e ON e.request_id=r.idWHERE r.worktree_id=$1 AND r.source_id=$2 AND e.kind='git' AND e.state IN ('queued','running')`, [worktreeId, sourceId])]);@@ -249,7 +254,7 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: st// Issued together, the snapshot's statements pipeline on its one connection (PGLite runs them in turn).timed('I⋈P', () => withRoundSnapshot(engine, async exec => {const [read, work, markers, passRow] = await Promise.all([timed('pages', () => readPages(exec, engineKind, sourceId, incarnation)),- timed('open_work', () => readOpenWork(exec, sourceId, context.binding.worktree_id)), timed('markers', () => readMarkers(exec, sourceId, incarnation)),+ timed('open_work', () => readOpenWork(exec, sourceId, context.binding.worktree_id, incarnation)), timed('markers', () => readMarkers(exec, sourceId, incarnation)),timed('pass_row', () => readPassRow(exec, sourceId, incarnation))]);return { pages: read.rows, open: work, markers, passRow, statements: read.statements + work.statements + 2 };})),@@ -297,11 +302,13 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: stconst probes = mode === 'working' ? await probeDirtiness(root, gitRoot, [...domain], tree, index) : new Map();timings.Dp = t();- const levelOf = (path: string, probe: { dp: string; rawOid: string | null } | undefined): string | null => {+ const levelOf = (path: string, probe: { dp: string; rawOid: string | null; rawSha256: string | null } | undefined): string | null => {const committed = tree.get(path) ?? null;return mode === 'committed' ? committed?.oid ?? null: !probe || probe.dp === 'deleted' ? null- : ['clean', 'clean_eol', 'clean_lfs'].includes(probe.dp) ? committed?.oid ?? probe.rawOid : probe.rawOid ?? `unreadable:${path}`;+ : ['clean', 'clean_eol', 'clean_lfs'].includes(probe.dp) ? committed?.oid ?? probe.rawOid+ // A path in neither T nor the index (untracked) or only staged has no `deleted` verdict: no bytes and no file is absent.+ : probe.rawOid ?? (probe.rawSha256 === null && !readPresent(root, path, scope) ? null : `unreadable:${path}`);};// `A` only matters where the file or the database moved (no row settles on `fileSame ∧ dbSame` with a proof): read it// for those pages alone, so a converged source reads none.@@ -434,7 +441,9 @@ export async function shadowConvergence(engine: BrainEngine, input: { sourceId:/*** The idle tick's reads (design v3.2 §2.2): `rev-parse`, the per-source request probe above the converged watermark- * (a range on the unique `sequence` index), the open-set probe (`persistence_requests_pending`) and the pass row. PR 4a+ * (a range on the unique `sequence` index), the open-set probe (`persistence_requests_pending`, plus+ * `persistence_requests_database_pending` for the source's write-through-off requests, which carry no worktree) and the+ * pass row; both request probes count those requests too. PR 4a* writes no pass row, so a real tick is never idle yet; `assumeConverged` lets the bench time the reads PR 4b's idle* tick will make, with `request_hwm` at the current maximum.*/@@ -453,9 +462,11 @@ export async function idleTickProbe(engine: BrainEngine, input: { sourceId: striconst [probe] = await engine.executeRaw<{ pass_row: Record<string, unknown> | null; newer: boolean; pending: boolean }>(`WITH pass AS (SELECT completed_keys->0 AS value FROM op_checkpoints WHERE op=$1 AND fingerprint=$2)SELECT (SELECT value FROM pass) AS pass_row,- EXISTS (SELECT 1 FROM persistence_requests WHERE sequence > COALESCE($3::bigint, ((SELECT value FROM pass)->'converged'->>'request_hwm')::bigint, 0) AND worktree_id = $4) AS newer,- EXISTS (SELECT 1 FROM persistence_requests WHERE worktree_id = $4 AND state IN ('queued','running','recovering')) AS pending`,- [MANAGED_SYNC_PASS_OP, `${context.sourceId}:${context.incarnation}`, input.assumeConverged?.requestHwm ?? null, context.binding.worktree_id]);+ EXISTS (SELECT 1 FROM persistence_requests WHERE sequence > COALESCE($3::bigint, ((SELECT value FROM pass)->'converged'->>'request_hwm')::bigint, 0)+ AND (worktree_id = $4 OR (worktree_id IS NULL AND source_incarnation = $5::uuid))) AS newer,+ EXISTS (SELECT 1 FROM persistence_requests WHERE (worktree_id = $4 OR (worktree_id IS NULL AND source_incarnation = $5::uuid))+ AND state IN ('queued','running','recovering')) AS pending`,+ [MANAGED_SYNC_PASS_OP, `${context.sourceId}:${context.incarnation}`, input.assumeConverged?.requestHwm ?? null, context.binding.worktree_id, context.incarnation]);timings.probes = t();const row = probe?.pass_row ?? null;const converged = input.assumeConverged ?? (row?.converged as { target: string; request_hwm: number } | undefineddiff --git a/test/sync-convergence-seeded-6712.test.ts b/test/sync-convergence-seeded-6712.test.tsindex a5a66e7f52..43ef79c324 100644--- a/test/sync-convergence-seeded-6712.test.ts+++ b/test/sync-convergence-seeded-6712.test.ts@@ -10,8 +10,9 @@* seeding and the reads are the production calls (scripts/bench/sync-convergence-seeded.ts names the raw SQL it needs).** Cases whose 4a prediction differs from the design carry it as today: the mix asserts today, so a fix turns the mix red- * until the case drops it. The (a) findings also have a focused probe each, written as test.failing: red on 4a, and- * a failure once PR 4b fixes it, when it becomes a plain test.+ * until the case drops it. The (a) findings this validation found (a write-through-off request outside U_db, an absent+ * working-mode path read as unreadable, a spelling refusal without its dry-run receipt) are fixed in 4a; each keeps a+ * focused test below.** PGLite, and Postgres with DATABASE_URL (test/e2e/sync-convergence-seeded-6712-postgres.test.ts). Synthetic content only.*/@@ -21,12 +22,12 @@ import { mkdirSync, rmSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import type { BrainEngine } from '../src/core/engine.ts';import { performManagedSync } from '../src/core/persistence/sync-run.ts';-import { shadowConvergence } from '../src/core/persistence/sync-pass.ts';+import { idleTickProbe, shadowConvergence } from '../src/core/persistence/sync-pass.ts';import { preparePageAdmission } from '../src/core/persistence/page-mutations.ts';import { admitWrite } from '../src/core/persistence/journal.ts';import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';import { runSync } from '../src/commands/sync.ts';-import { captureCli, cliChecks, evaluate, FINDINGS, fullCases, mixSetup, seedMassDelete, seedMix, seedSpelling, workingCases, type EvalRun } from '../scripts/bench/sync-convergence-seeded.ts';+import { captureCli, cliChecks, evaluate, fullCases, mixSetup, seedMassDelete, seedMix, seedSpelling, workingCases, type EvalRun } from '../scripts/bench/sync-convergence-seeded.ts';import { managedBrain } from './helpers/managed-brain.ts';import { testBackends } from './helpers/test-backends.ts';@@ -96,9 +97,12 @@ for (const backend of testBackends()) {const spelled = await evaluate(engine, cases, { label: 'spelled' });expectRun(spelled);const spelledCli = await cliChecks(engine, spelled);- // Pinned (a) finding spellingDryRun: master's refusal aborts the dry run, so it carries no convergence block.+ // The real run would refuse the spelling pairs; the refused dry run still carries the convergence receipt.expect(spelledCli.dryRunError?.code).toBe('page_identity_changed');+ expect(spelledCli.dryRunCounts).toBe(spelledCli.libraryCounts);expect(spelledCli.statusCounts).toBe(spelledCli.libraryCounts);+ expect(spelledCli.redactionLeaks).toEqual([]);+ expect(spelledCli.redactedSampleMismatches).toEqual([]);expectRun(await evaluate(engine, fullCases(cases), { label: 'full', full: true }));expectRun(await evaluate(engine, workingCases(cases), { label: 'working', workingTree: true, partial: true }), { partial: true });@@ -111,7 +115,7 @@ for (const backend of testBackends()) {expect(await footprint(engine)).toBe(before);}, mixSetup), 600_000);- test.failing(`finding (a) inFlightDbOnly: a queued put_page admitted with write-through off is open work, so the changed file is in_flight (${FINDINGS.inFlightDbOnly.ref})`, () => brain(async ({ engine, ctx, root }) => {+ test('a queued put_page admitted with write-through off (no worktree) is open work, so the changed file is in_flight', () => brain(async ({ engine, ctx, root }) => {expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');await engine.setConfig('sync.write_through', 'false');writeFileSync(join(root, 'notes', 'alpha.md'), note('alpha', 'Synthetic alpha two.'));@@ -119,11 +123,15 @@ for (const backend of testBackends()) {await disposePersistenceConsumer(engine);const snapshot = (await engine.readPageSnapshot('notes/alpha', { sourceId: 'default' }))!;const prepared = await preparePageAdmission(ctx, { operation: 'put_page', params: { slug: 'notes/alpha', request_id: crypto.randomUUID(), expected_revision: snapshot.revision, content: note('alpha', 'A queued agent edit.') } });+ const [{ hwm }] = await engine.executeRaw<{ hwm: number }>('SELECT COALESCE(max(sequence), 0)::int AS hwm FROM persistence_requests');expect((await admitWrite(engine, prepared.admission!)).state).toBe('queued');expect((await shadowConvergence(engine, { sourceId: 'default' }))!.counts).toEqual({ matched: 2, in_flight: 1 });+ // The idle tick sees the same request above a watermark taken before it, so the source is not idle.+ const idle = await idleTickProbe(engine, { sourceId: 'default', assumeConverged: { target: git(root, 'rev-parse', 'HEAD'), requestHwm: hwm! } });+ expect(idle.idle).toBe(false);}, small), 120_000);- test.failing(`finding (a) workingAbsent: in working mode a committed git rm of a synced file is a delete, not an import (${FINDINGS.workingAbsent.ref})`, () => brain(async ({ engine, root }) => {+ test('in working mode a committed git rm of a synced file is a delete, not an import (its absent level is absent)', () => brain(async ({ engine, root }) => {expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');git(root, 'rm', '-q', 'notes/beta.md');git(root, '-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-qm', 'remove beta');@@ -131,12 +139,13 @@ for (const backend of testBackends()) {expect((await shadowConvergence(engine, { sourceId: 'default', workingTree: true }))!.counts).toEqual({ matched: 2, delete: 1 });}, small), 120_000);- test.failing(`finding (a) spellingDryRun: a spelling collision still leaves the dry run its convergence receipt (${FINDINGS.spellingDryRun.ref})`, () => brain(async ({ engine, root }) => {+ test('a spelling collision still leaves the refused dry run its convergence receipt, the pair under spelling', () => brain(async ({ engine, root }) => {expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');writeFileSync(join(root, 'notes', 'Pair.md'), note('Pair', 'Synthetic pair.'));writeFileSync(join(root, 'notes', 'pair.md'), note('pair', 'Synthetic pair.'));commit(root, 'a case-only pair');const dry = await captureCli(() => runSync(engine, ['--source', 'default', '--no-pull', '--dry-run', '--json', '--no-embed', '--redact-paths']));+ expect({ exit: dry.exit !== 0, code: dry.json?.code }).toEqual({ exit: true, code: 'page_identity_changed' });expect((dry.json?.convergence as { counts?: Record<string, number> } | undefined)?.counts).toEqual({ matched: 3, spelling: 2 });}, small), 120_000);});