Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
wip(#6712 PR 4a): dry-run convergence, --redact-paths, status convergence under --detail, shadow probes
garrytan3a1c97d22283
diff --git a/src/commands/sync/args.ts b/src/commands/sync/args.tsindex 12ed0bb7b0..80baf0433a 100644--- a/src/commands/sync/args.ts+++ b/src/commands/sync/args.ts@@ -85,6 +85,13 @@ Managed brains (the flags an operator or cron needs; listed first):--dry-run Show what would be synced without writing; listsevery file the content screen would hold (would_hold)and screen errors separately (screen_skipped).+ Managed sources add 'convergence' to --json: every+ path classified the way the level-triggered pass+ will (counts, predicted decisions, deletes and the+ mass-delete verdict, samples). Read-only.+ --redact-paths With --dry-run --json: sample paths become sha256+ prefixes and slugs are dropped, so the counts can+ be shared.--no-bulk Managed Postgres sync: publish one page per transactioninstead of bulk groups (each page keeps its own writerequest either way). GBRAIN_SYNC_BULK=0 does the@@ -301,6 +308,7 @@ export function parseSyncFlags(args: string[]) {console.error('[gbrain] WARN: --missing-path only applies to `sync --all`; ignored here.');}const jsonOut = args.includes('--json');+ const redactPaths = args.includes('--redact-paths');const yesFlag = args.includes('--yes');// v0.41.6.0 D3: lock-recovery flags. --break-lock (safe) verifies the// holder is local-host + (TTL-expired OR PID-dead+60s-old) before@@ -331,7 +339,7 @@ export function parseSyncFlags(args: string[]) {console.error(`--max-age cannot be combined with --force-break-lock (force skips all guards).`);process.exit(1);}- return { repoPath, watch, interval, dryRun, full, noPull, noBulk, lanes, noEmbed, noExtract, skipFailed, retryFailed, resetCheckpoint, noSchemaPack, includeGitignored, workingTree, syncAll, missingPathMode, jsonOut, yesFlag, breakLock, forceBreakLock, maxAgeSeconds };+ return { repoPath, watch, interval, dryRun, full, noPull, noBulk, lanes, noEmbed, noExtract, skipFailed, retryFailed, resetCheckpoint, noSchemaPack, includeGitignored, workingTree, syncAll, missingPathMode, jsonOut, redactPaths, yesFlag, breakLock, forceBreakLock, maxAgeSeconds };}export type SyncFlags = ReturnType<typeof parseSyncFlags>;diff --git a/src/commands/sync/run.ts b/src/commands/sync/run.tsindex 1643d9e8b7..7597ef2713 100644--- a/src/commands/sync/run.ts+++ b/src/commands/sync/run.ts@@ -789,7 +789,7 @@ async function runSingleSourceSync(): Promise<void> {const {repoPath, watch, interval, dryRun, full, noPull, noBulk, lanes, noExtract, skipFailed, retryFailed, resetCheckpoint, noSchemaPack,- includeGitignored, workingTree, jsonOut, yesFlag, noAutoEmbed, strategyArg, srcSubpath,+ includeGitignored, workingTree, jsonOut, redactPaths, yesFlag, noAutoEmbed, strategyArg, srcSubpath,excludePatterns, includeHiddenPatterns, concurrency, timeoutSeconds,} = flags;const { sourceId, companyPolicy, noEmbed, resumeCommand, args } = input;@@ -962,8 +962,12 @@ 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;if (jsonOut) {- emitJson(JSON.stringify({ ...buildSingleSyncJsonEnvelope(sourceId, result, singleEmbedBackfill, singleCostGate),+ emitJson(JSON.stringify({ ...buildSingleSyncJsonEnvelope(sourceId, result, singleEmbedBackfill, singleCostGate), ...(convergence ? { convergence } : {}),...(result.managedWrite ? { managed_write: result.managedWrite } : {}), ...drainJsonFields(result, resumeCommand, sourceId),...(result.tail ? { tail: syncTailJsonFields(result).tail } : {}), ...capacity }));}diff --git a/src/core/persistence/sync-pass.ts b/src/core/persistence/sync-pass.tsindex 3938e8c792..391c7cbff7 100644--- a/src/core/persistence/sync-pass.ts+++ b/src/core/persistence/sync-pass.ts@@ -34,7 +34,8 @@ import { movedDriftHolds, sameParser } from './sync-prescreen.ts';import { syncOriginPath } from './sync-origin.ts';import { probeDirtiness, readBlobs, readIndexLevel, readTreeLevel, type GitTreeEntry } from './sync-git-stream.ts';import { classifySyncPath, syncPassKind, type SyncClassified, type SyncIdleBlocker, type SyncPathState } from './sync-classify.ts';-import { buildConvergenceReceipt, type ConvergenceReceipt, type ConvergenceScreen } from './sync-convergence.ts';+import { buildConvergenceReceipt, readOnlySameContentScreen, type ConvergenceReceipt, type ConvergenceScreen } from './sync-convergence.ts';+import { readManagedMode } from './ownership.ts';/** The deletion marker op PR 4b writes in every page-row deletion (design v3.2 §2.5); PR 4a only reads it. */export const SYNC_ORIGIN_DELETED_OP = 'sync-origin-deleted';@@ -220,7 +221,7 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: stconst prior = byOrigin.get(key);if (!prior || (prior.deleted && !row.deleted) || (prior.deleted === row.deleted && Number(row.id) > Number(prior.id))) byOrigin.set(key, row);}- const domain = new Set<string>([...tree.keys(), ...untracked, ...[...byOrigin.keys()].filter(eligible), ...[...markers.keys()].map(gitPathOf).filter(eligible)]);+ const domain = new Set<string>([...tree.keys(), ...untracked, ...(mode === 'working' ? [...index.keys()].filter(eligible) : []), ...[...byOrigin.keys()].filter(eligible), ...[...markers.keys()].map(gitPathOf).filter(eligible)]);const spellings = new Map<string, Set<string>>();for (const path of domain) {const live = byOrigin.get(path);@@ -388,3 +389,32 @@ export async function idleTickProbe(engine: BrainEngine, input: { sourceId: stritimings.total = total();return { idle: kind.kind === 'idle', reasons: kind.blockers, timings_ms: timings, rows: newer.length + pending.length + (row ? 1 : 0) };}++/**+ * `gbrain sync --dry-run --json`'s `convergence` for one source: the receipt with the read-only screen, undefined+ * on a brain that is not managed or for a company-brain source; a read that cannot run reports why instead of failing+ * the dry run.+ */+export async function dryRunConvergence(engine: BrainEngine, input: { sourceId: string; full: boolean; workingTree?: boolean; redactPaths: boolean;+ noEmbed: boolean; noExtract: boolean; noSchemaPack: boolean }): Promise<ConvergenceReceipt | { dry_run: true; status: 'unavailable'; code: string; message: string } | undefined> {+ if (!await readManagedMode(engine)) return undefined;+ try {+ const context = await resolveManagedSyncContext(engine, { sourceId: input.sourceId, noPull: true, dryRun: true });+ return await shadowConvergence(engine, { sourceId: input.sourceId, full: input.full, workingTree: input.workingTree, redactPaths: input.redactPaths, context,+ screen: readOnlySameContentScreen(engine, context, { noEmbed: input.noEmbed, noExtract: input.noExtract, noSchemaPack: input.noSchemaPack }) }) ?? undefined;+ } catch (error) {+ const code = (error as { code?: unknown }).code;+ return { dry_run: true, status: 'unavailable', code: typeof code === 'string' ? code : 'convergence_read_failed', message: error instanceof Error ? error.message : String(error) };+ }+}++/** \`sync status --detail\`'s \`convergence\`: the receipt without the screen (status never prepares an import). */+export async function statusConvergence(engine: BrainEngine, sourceId: string): Promise<ConvergenceReceipt | { dry_run: true; status: 'unavailable'; code: string; message: string } | null> {+ if (!await readManagedMode(engine)) return null;+ try {+ return await shadowConvergence(engine, { sourceId, screen: false });+ } catch (error) {+ const code = (error as { code?: unknown }).code;+ return { dry_run: true, status: 'unavailable', code: typeof code === 'string' ? code : 'convergence_read_failed', message: error instanceof Error ? error.message : String(error) };+ }+}diff --git a/src/core/persistence/sync-status.ts b/src/core/persistence/sync-status.tsindex 525504b809..9a12742c9a 100644--- a/src/core/persistence/sync-status.ts+++ b/src/core/persistence/sync-status.ts@@ -129,6 +129,13 @@ export interface SyncStatus {checkpoint_blockers_read: SyncStatusRead;cursors_read: SyncStatusRead;terminal_failures_read: SyncStatusRead;+ /**+ * #6712 PR 4a: the read-only shadow of the level-triggered pass (sync-convergence.ts), \`dry_run: true\`; a heavy read, so+ * only \`--detail\` runs it (\`convergence_read\`). Null when not read, on a brain that is not managed, or for a company-brain+ * source; \`status: 'unavailable'\` names why a read could not run. No other field's meaning depends on it.+ */+ convergence: import('./sync-convergence.ts').ConvergenceReceipt | { dry_run: true; status: 'unavailable'; code: string; message: string } | null;+ convergence_read: SyncStatusRead;}export type SyncStatusState = 'synced' | 'resumable' | 'blocked';/** Why the source is in its state; one closed list. */@@ -305,7 +312,8 @@ export async function readSyncStatus(engine: BrainEngine, sourceId: string, optswhy: `The oldest-blocker or recovery probe did not answer within ${SYNC_STATUS_PROBE_MS / 1000} s, so this status does not know the state (it is not reported synced). Rerun it after a short wait; gbrain doctor --json checks the database if it keeps timing out.` } satisfies Action : null),state, reason: stateReason,oldest_blocker: oldest, recovery, checkpoint_blockers_read: detail ? { status: 'read' } : notRead('checkpoint blocker list'),- cursors_read: detail ? { status: 'read' } : notRead('live cursor'), terminal_failures_read: detail ? { status: 'read' } : notRead('terminal-failure summary') };+ cursors_read: detail ? { status: 'read' } : notRead('live cursor'), terminal_failures_read: detail ? { status: 'read' } : notRead('terminal-failure summary'),+ convergence: detail ? await (await import('./sync-pass.ts')).statusConvergence(engine, sourceId) : null, convergence_read: detail ? { status: 'read' } : notRead('convergence shadow') };}/** #6712 PR 2: the state and its reason, from what this read saw; a probe that did not answer never yields `synced`. */diff --git a/test/sync-pass-shadow-6712.test.ts b/test/sync-pass-shadow-6712.test.tsnew file mode 100644index 0000000000..5d30022c1e--- /dev/null+++ b/test/sync-pass-shadow-6712.test.ts@@ -0,0 +1,181 @@+/**+ * #6712 PR 4a: the read-only convergence shadow on a real managed brain (PGLite plus a Git checkout).+ *+ * Authoring gate: (1) protects \`gbrain sync --dry-run --json\`'s new \`convergence\` receipt and \`--redact-paths\`, and+ * the PR 4a promise that the shadow writes and admits nothing; (2) a shadow that writes a row, misreads a level (a+ * staged file, an uncommitted edit, a parser bump, a database-only edit), or leaks a path under redaction fails here;+ * (3) the pure classifier test cannot see the reads; (4) no seam: the CLI entry point and the library reads run as+ * production calls them.+ */+import { describe, expect, spyOn, test } from 'bun:test';+import { execFileSync } from 'node:child_process';+import { mkdirSync, rmSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import type { BrainEngine } from '../src/core/engine.ts';+import { runSync } from '../src/commands/sync.ts';+import { performManagedSync } from '../src/core/persistence/sync-run.ts';+import { shadowConvergence } from '../src/core/persistence/sync-pass.ts';+import { readSyncStatus } from '../src/core/persistence/sync-status.ts';+import { SYNC_IMPORT_PROVENANCE_OP } from '../src/core/persistence/sync-holds.ts';+import { currentExitCode, setCliExitVerdict } from '../src/core/cli-force-exit.ts';+import { declarePersistenceProtocol } from '../src/core/persistence/protocol.ts';+import { managedBrain } from './helpers/managed-brain.ts';++const git = (root: string, ...args: string[]) => execFileSync('git', ['-C', root, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();+const commit = (root: string, message: string) => { git(root, 'add', '.'); git(root, '-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-qm', message); };+const note = (title: string, body: string) => `---\ntitle: ${title}\n---\n\n${body}\n`;+const setup = ({ root }: { root: string }) => {+ git(root, 'init', '-q');+ mkdirSync(join(root, 'notes'), { recursive: true });+ for (const name of ['alpha', 'beta', 'gamma']) writeFileSync(join(root, 'notes', name + '.md'), note(name, 'Synthetic ' + name + ' one.'));+ commit(root, 'notes');+};+const SYNC = { sourceId: 'default', noPull: true, noEmbed: true, noExtract: true };++/** Every row a shadow could write: request, effect, checkpoint (holds, markers, records, pass rows, cursors) and page rows. */+async function footprint(engine: BrainEngine): Promise<string> {+ const rows = await engine.executeRaw<{ t: string; n: number; h: string | null }>(`SELECT 'requests' AS t, count(*)::int AS n, md5(string_agg(id::text||state, ',' ORDER BY id)) AS h FROM persistence_requests+ UNION ALL SELECT 'effects', count(*)::int, md5(string_agg(id::text||state, ',' ORDER BY id)) FROM persistence_effects+ UNION ALL SELECT 'checkpoints', count(*)::int, md5(string_agg(op||fingerprint||completed_keys::text, ',' ORDER BY op, fingerprint)) FROM op_checkpoints+ UNION ALL SELECT 'pages', count(*)::int, md5(string_agg(id::text||knowledge_revision::text||coalesce(deleted_at::text,''), ',' ORDER BY id)) FROM pages`);+ return JSON.stringify(rows);+}++class CliExit extends Error { constructor(readonly code: number) { super('exit ' + code); } }+async function cliSync(engine: BrainEngine, args: string[]): Promise<{ json: Record<string, unknown>; exit: number }> {+ const out: string[] = [];+ const spies = [spyOn(process.stdout, 'write').mockImplementation(((chunk: unknown) => { out.push(String(chunk)); return true; }) as never),+ spyOn(process.stderr, 'write').mockImplementation((() => true) as never), spyOn(console, 'log').mockImplementation((...parts: unknown[]) => { out.push(parts.map(String).join(' ')); }), spyOn(console, 'error').mockImplementation(() => {}),+ spyOn(process, 'exit').mockImplementation(((code?: number) => { throw new CliExit(code ?? 0); }) as never)];+ setCliExitVerdict(0);+ let exit = 0;+ try { await runSync(engine, args); exit = currentExitCode(); } catch (caught) { if (!(caught instanceof CliExit)) throw caught; exit = caught.code; }+ finally { for (const spy of spies) spy.mockRestore(); setCliExitVerdict(0); }+ const text = out.join('');+ return { json: JSON.parse(text.slice(text.indexOf('{'))), exit };+}++describe('#6712 PR 4a convergence shadow (pglite)', () => {+ test('a synced source is fully matched, and the shadow writes nothing', () => managedBrain(async ({ engine }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ const before = await footprint(engine);+ const receipt = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(receipt).toMatchObject({ dry_run: true, kind: 'full', mode: 'committed', candidates: 0, remaining: 0, counts: { matched: 3 },+ classes: { matched: { count: 3, action: 'none' } }, decisions: { both: 0, unknown: 0, deleted: 0 }, would_hold: 0 });+ expect(receipt.kind_blockers).toContain('no_converged_state');+ expect(await footprint(engine)).toBe(before);+ }, { setup }), 120_000);++ test('the level drives every class: a committed edit, a database-only edit, a two-sided edit, a deletion', () => managedBrain(async ({ engine, ctx, root }) => {+ await engine.setConfig('sync.write_through', 'false');+ for (const name of ['delta', 'epsilon']) writeFileSync(join(root, 'notes', name + '.md'), note(name, 'Synthetic ' + name + ' one.'));+ commit(root, 'more notes');+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ const { submitPageMutation } = await import('../src/core/persistence/page-mutations.ts');+ const { waitFor } = await import('./helpers/wait-for.ts');+ for (const slug of ['notes/beta', 'notes/gamma']) {+ const current = await engine.readPageSnapshot(slug, { sourceId: 'default' });+ const requestId = crypto.randomUUID();+ await submitPageMutation(ctx, { operation: 'put_page', params: { slug, request_id: requestId, expected_revision: current!.revision, content: note(slug, 'A database-only edit.') } });+ await waitFor(async () => (await engine.executeRaw<{ state: string }>('SELECT state FROM persistence_requests WHERE request_id=$1::uuid', [requestId]))[0]?.state === 'committed',+ { timeoutMs: 20_000, label: 'the database-only edit commits' });+ }+ writeFileSync(join(root, 'notes', 'alpha.md'), note('alpha', 'Synthetic alpha two.'));+ writeFileSync(join(root, 'notes', 'gamma.md'), note('gamma', 'Synthetic gamma two.'));+ rmSync(join(root, 'notes', 'delta.md'));+ commit(root, 'edits');+ // The edits' effects settle in the background consumer first, so the footprint only moves if the dry run writes.+ await waitFor(async () => !(await engine.executeRaw("SELECT 1 FROM persistence_effects WHERE state IN ('queued','running')")).length,+ { timeoutMs: 30_000, label: 'the database-only edits settle their effects' });+ const before = await footprint(engine);+ const { json, exit } = await cliSync(engine, ['--source', 'default', '--no-pull', '--dry-run', '--json', '--no-embed']);+ expect(exit).toBe(0);+ const convergence = json.convergence as Record<string, any>;+ expect(convergence).toMatchObject({ dry_run: true, counts: { matched: 1, import: 1, db_ahead: 1, drift: 1, delete: 1 },+ db_ahead: { db_only: 1, pending: 0, unproven: 0, by_prefix: { 'notes/': 1 } }, deletes: { count: 1, verdict: 'apply' } });+ // The two-sided page is screened read-only: the file differs from the database, so it is a predicted decision.+ expect(convergence.decisions).toEqual({ both: 1, unknown: 0, deleted: 0 });+ expect(convergence.classes.drift.action).toBe('repair');+ expect(convergence.samples.import[0]).toMatchObject({ path: 'notes/alpha.md', slug: 'notes/alpha', action: 'owner' });+ // The existing dry-run keys stay (additive only).+ expect(json.sync_status).toBe('dry_run');+ expect(await footprint(engine)).toBe(before);++ const redacted = await cliSync(engine, ['--source', 'default', '--no-pull', '--dry-run', '--json', '--no-embed', '--redact-paths']);+ const text = JSON.stringify(redacted.json.convergence);+ expect(text).not.toContain('notes/');+ expect(text).not.toMatch(/alpha|beta|gamma|delta|epsilon/);+ expect((redacted.json.convergence as Record<string, any>).samples.import[0]).toEqual({ path: expect.stringMatching(/^sha256:[0-9a-f]{16}$/), reason: expect.any(String), action: 'owner' });+ expect(await footprint(engine)).toBe(before);+ }, { setup }), 180_000);++ test('committed mode: an uncommitted edit of a synced file is no hold (probe 24); a dirty file whose commit moved is held, not imported', () => managedBrain(async ({ engine, root }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ writeFileSync(join(root, 'notes', 'alpha.md'), note('alpha', 'An uncommitted draft.'));+ let receipt = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(receipt.counts).toEqual({ matched: 3 });+ expect(receipt.would_hold).toBe(0);+ writeFileSync(join(root, 'notes', 'beta.md'), note('beta', 'Synthetic beta two.'));+ git(root, 'add', 'notes/beta.md'); git(root, '-c', 'user.name=Example', '-c', '[email protected]', 'commit', '-qm', 'beta two');+ writeFileSync(join(root, 'notes', 'beta.md'), note('beta', 'An uncommitted draft on top.'));+ receipt = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(receipt.counts).toMatchObject({ matched: 2, dirty: 1 });+ expect(receipt.samples.dirty![0]).toMatchObject({ path: 'notes/beta.md', reason: 'working copy modified', action: 'repair' });+ expect(receipt.would_hold).toBe(1);+ }, { setup }), 120_000);++ test('probe 41: working mode imports the physical bytes of a staged edit, a staged new file and a git rm --cached file', () => managedBrain(async ({ engine, root }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ writeFileSync(join(root, 'notes', 'alpha.md'), note('alpha', 'A staged edit.'));+ writeFileSync(join(root, 'notes', 'zeta.md'), note('zeta', 'A staged new file.'));+ git(root, 'add', 'notes/alpha.md', 'notes/zeta.md');+ git(root, 'rm', '-q', '--cached', 'notes/beta.md');+ const receipt = (await shadowConvergence(engine, { sourceId: 'default', workingTree: true }))!;+ expect(receipt.mode).toBe('working');+ // alpha and zeta import from disk; beta's bytes are still the synced ones, so it matches (nothing deletes it).+ expect(receipt.counts).toEqual({ matched: 2, import: 2 });+ expect(receipt.samples.import!.map(sample => sample.path).sort()).toEqual(['notes/alpha.md', 'notes/zeta.md']);+ // The same tree in committed mode imports nothing: the staged changes are not committed.+ const committed = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(committed.counts.import ?? 0).toBe(0);+ }, { setup }), 120_000);++ test('probe 46: a parser change on fileSame ∧ dbSame pages is reparse with zero decisions; --full makes every page reparse', () => managedBrain(async ({ engine }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ await engine.executeRaw(`UPDATE op_checkpoints SET completed_keys=jsonb_set(completed_keys, '{0,parser,parser_version}', '"import=0"')+ WHERE op=$1 AND completed_keys->0->>'origin'='notes/alpha.md'`, [SYNC_IMPORT_PROVENANCE_OP]);+ const receipt = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(receipt.counts).toEqual({ matched: 2, reparse: 1 });+ expect(receipt.decisions).toEqual({ both: 0, unknown: 0, deleted: 0 });+ expect(receipt.samples.reparse![0]).toMatchObject({ path: 'notes/alpha.md', reason: 'parser or schema pack changed', action: 'owner' });+ expect((await shadowConvergence(engine, { sourceId: 'default', full: true }))!.counts).toEqual({ reparse: 3 });+ }, { setup }), 120_000);++ test('probe 38: a page whose record predates PR 0 and whose receipt was compacted is counted legacy_unverified, never held or written', () => managedBrain(async ({ engine }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ await engine.executeRaw(`UPDATE op_checkpoints SET completed_keys=jsonb_build_array((completed_keys->0) - 'revision' - 'disk_blob_oid' - 'parser' - 'blob_oid')+ WHERE op=$1 AND completed_keys->0->>'origin'='notes/gamma.md'`, [SYNC_IMPORT_PROVENANCE_OP]);+ // Receipt compaction NULLs the intent (journal.ts), as a release before PR 0 left it.+ await engine.transaction(async tx => {+ await declarePersistenceProtocol(tx);+ await tx.executeRaw("UPDATE persistence_requests SET intent=NULL, compacted=true WHERE slug='notes/gamma'");+ });+ const before = await footprint(engine);+ const receipt = (await shadowConvergence(engine, { sourceId: 'default' }))!;+ expect(receipt.counts).toEqual({ matched: 2, legacy_unverified: 1 });+ expect(receipt.legacy_unverified).toBe(1);+ expect(receipt.would_hold).toBe(0);+ expect(await footprint(engine)).toBe(before);+ }, { setup }), 120_000);++ test('sync status: plain status skips the heavy convergence read; --detail reports it with dry_run: true', () => managedBrain(async ({ engine }) => {+ expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');+ const plain = await readSyncStatus(engine, 'default', { detail: false });+ expect(plain.convergence).toBeNull();+ expect(plain.convergence_read).toMatchObject({ status: 'not_read', fix: { argv: ['gbrain', 'sync', 'status', '--source', 'default', '--detail', '--json'] } });+ const detail = await readSyncStatus(engine, 'default', { detail: true });+ expect(detail.convergence_read).toEqual({ status: 'read' });+ expect(detail.convergence).toMatchObject({ dry_run: true, counts: { matched: 3 } });+ expect((detail.convergence as Record<string, unknown>).screen_skipped).toBeUndefined();+ }, { setup }), 120_000);+});