Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

#6712 PR 2 L4: doctor fails a stranded parked queue (#6552) and reports soak counters

garrytan9d511bff4409
diff --git a/src/commands/doctor/checks/managed-sync-movement.ts b/src/commands/doctor/checks/managed-sync-movement.ts
index 5d44b10fa2..65fed77cc2 100644
--- a/src/commands/doctor/checks/managed-sync-movement.ts
+++ b/src/commands/doctor/checks/managed-sync-movement.ts
@@ -6,11 +6,14 @@
* cursor has had neither a committed page nor a head step advance for longer
* than `persistence.preparation_ceiling_ms` while a drain or consumer is live.
* A cursor left between runs with nothing live is `parked`: listed, never
- * warned. Reads the database only.
+ * warned, unless (#6552 §2, #6712 PR 2) admitted requests wait in its queue
+ * with no consumer and no progress for longer than that ceiling: nothing will
+ * ever drain them, so the check fails and names the resume sync (which runs
+ * its own consumer) as the safe action. Reads the database only.
*/
import type { Check } from '../../doctor.ts';
import { connectedEngine, type DoctorContext, type DoctorEntry } from '../context.ts';
-import { readSourceMovement } from '../../../core/persistence/sync-movement.ts';
+import { readSourceMovement, type SourceMovement } from '../../../core/persistence/sync-movement.ts';
import { agentFix, checkError } from '../check-fix.ts';
const DOCS = 'docs/guides/troubleshooting.md#managed-sync-not-moving';
@@ -22,10 +25,19 @@ async function runManagedSyncMovementCheck(ctx: DoctorContext): Promise<Check[]>
const pending = movement.filter(m => m.movement_state !== 'nothing_pending');
const stuck = pending.filter(m => m.movement_state === 'not_moving');
const parked = pending.filter(m => m.movement_state === 'parked');
- const details = { count: stuck.length, parked: parked.length, sources: pending.map(m => ({ source_id: m.source_id, movement_state: m.movement_state, data_moving: m.data_moving,
+ const stranded = parked.filter(strandedQueue);
+ const details = { count: stuck.length, parked: parked.length, stranded: stranded.length, sources: pending.map(m => ({ source_id: m.source_id, movement_state: m.movement_state, data_moving: m.data_moving,
not_moving_since: m.not_moving_since, last_commit_at: m.last_commit_at, last_progress_at: m.last_progress_at, cursor: m.cursor, head: m.head, live: m.live, admitted: m.admitted,
ceiling_ms: m.ceiling_ms, writer_status_command: m.writer_status_command })), docs: DOCS };
- if (stuck.length) {
+ if (stranded.length) {
+ const first = stranded[0]!;
+ checks.push({ name: 'managed_sync_not_moving', status: 'fail', readiness_state: 'degraded', details,
+ message: `${stranded.map(m => `${m.source_id} (${m.admitted} admitted request(s), no progress since ${m.last_progress_at})`).join('; ')}: managed sync is parked with a non-empty `
+ + `write queue and no consumer for longer than the ${Math.round(first.ceiling_ms / 1000)}s ceiling, so nothing will drain it. Resuming the sync runs its own consumer beside the queue.`,
+ fix: agentFix(['gbrain', 'sync', ...(first.cursor?.resume_args ?? ['--source', first.source_id, '--no-pull'])],
+ `Resumes ${first.source_id}'s unfinished cursor with its stored options; the run consumes the queued requests itself (one drainer per source) and finishes the frozen manifest.`,
+ 'managed_sync_not_moving', { docs: DOCS }) });
+ } else if (stuck.length) {
const first = stuck[0]!;
checks.push({ name: 'managed_sync_not_moving', status: 'warn', readiness_state: 'degraded', details,
message: `${stuck.map(m => `${m.source_id} (since ${m.not_moving_since}${m.head?.step ? `, head at step ${m.head.step}` : ''}${m.head?.owner ? `, ${m.head.owner.kind} pid ${m.head.owner.pid}` : ''})`).join('; ')}: `
@@ -44,5 +56,11 @@ async function runManagedSyncMovementCheck(ctx: DoctorContext): Promise<Check[]>
return checks;
}
+/** #6552 §2: parked, yet admitted requests wait with no consumer, and nothing has moved for longer than the ceiling. */
+function strandedQueue(m: SourceMovement): boolean {
+ const since = m.last_progress_at ? Date.parse(m.last_progress_at) : NaN;
+ return m.admitted > 0 && m.live.consumer === null && Number.isFinite(since) && Date.parse(m.sampled_at) - since > m.ceiling_ms;
+}
+
/** #6696 B1: an ops section (sync cursor movement and age); it reads request and checkpoint tables, so on PGLite the ops tier skips it. */
export const managedSyncMovementEntry: DoctorEntry = { name: 'managed_sync_not_moving', emits: ['managed_sync_not_moving'], tier: 'ops', opsPglite: 'not_applicable', run: runManagedSyncMovementCheck };
diff --git a/src/commands/doctor/checks/ops-sections.ts b/src/commands/doctor/checks/ops-sections.ts
index dee206c4ba..6765d1aba7 100644
--- a/src/commands/doctor/checks/ops-sections.ts
+++ b/src/commands/doctor/checks/ops-sections.ts
@@ -7,7 +7,8 @@
* Sections owned here: managed write capacity and its forecast, terminal write
* failures, receipt compaction freshness (`persistence_compaction`, the
* consumer's `persistence.maintenance.last_compaction` record) and schema-pack
- * consistency. The other ops sections are
+ * consistency, and (#6712 PR 2) the managed-sync soak counters (`sync_soak_counters`:
+ * interventions and content decisions over the last seven days). The other ops sections are
* tagged where they live: `embedding_state` (embedding coverage),
* `managed_sync_not_moving` (sync cursor movement and age) and
* `serve_build_drift` (serve build drift).
@@ -22,6 +23,7 @@ import { checkPersistenceCapacity } from './persistence-capacity.ts';
import { terminalFailuresCheck } from './persistence-requests.ts';
import { checkSchemaPackConsistency } from '../schema-pack-checks.ts';
import { checkPersistenceCompaction } from './persistence-compaction.ts';
+import { readSoakCounters } from '../../../core/persistence/soak-counters.ts';
async function runPersistenceCapacity(ctx: DoctorContext): Promise<Check[]> {
const checks: Check[] = [];
@@ -82,3 +84,25 @@ export const schemaPackConsistencyEntry: DoctorEntry = {
opsPglite: 'not_applicable',
run: runSchemaPackConsistency,
};
+
+/**
+ * #6712 PR 2: what the seven-day soak reads. Informational (never scored): interventions are the steps a person took to
+ * keep managed sync converging, content decisions the drift choices on pages outside `storage.keep_db` (Garry's d1b).
+ */
+async function runSoakCounters(ctx: DoctorContext): Promise<Check[]> {
+ const checks: Check[] = [];
+ ctx.progress.heartbeat('sync_soak_counters');
+ const counters = await readSoakCounters(connectedEngine(ctx));
+ const kinds = (record: Record<string, number>) => Object.entries(record).filter(([kind, n]) => kind !== 'total' && n > 0).map(([kind, n]) => `${kind} ${n}`).join(', ');
+ checks.push({ name: 'sync_soak_counters', status: 'ok', severity: 'info', details: { ...counters, docs: 'docs/guides/sync-unblock-runbook.md#soak-counters' },
+ message: `Last ${counters.window_days} days: ${counters.interventions.total} managed-sync intervention(s)${counters.interventions.total ? ` (${kinds(counters.interventions)})` : ''}, `
+ + `${counters.content_decisions.total} content decision(s)${counters.content_decisions.total ? ` (${kinds(counters.content_decisions)})` : ''}.` });
+ return checks;
+}
+
+export const soakCountersEntry: DoctorEntry = {
+ name: 'sync_soak_counters',
+ emits: ['sync_soak_counters'],
+ tier: 'ops',
+ run: runSoakCounters,
+};
diff --git a/src/commands/doctor/registry.ts b/src/commands/doctor/registry.ts
index 13da7fe1d3..f44791b246 100644
--- a/src/commands/doctor/registry.ts
+++ b/src/commands/doctor/registry.ts
@@ -119,6 +119,7 @@ import {
persistenceCapacityEntry,
terminalFailuresEntry,
persistenceCompactionEntry,
+ soakCountersEntry,
schemaPackConsistencyEntry,
} from './checks/ops-sections.ts';
import { STOP_DOCTOR, type DoctorContext, type DoctorEntry, type DoctorTier } from './context.ts';
@@ -158,6 +159,7 @@ export const DOCTOR_CHECK_REGISTRY: readonly DoctorEntry[] = [
terminalFailuresEntry,
managedSyncMovementEntry,
persistenceCompactionEntry,
+ soakCountersEntry,
serveBuildDriftEntry,
schemaPackConsistencyEntry,
embeddingStateEntry,
diff --git a/src/commands/sources-retry-held.ts b/src/commands/sources-retry-held.ts
index ae730b7e4e..3a30f4f851 100644
--- a/src/commands/sources-retry-held.ts
+++ b/src/commands/sources-retry-held.ts
@@ -134,6 +134,8 @@ export async function runRetryHeld(engine: BrainEngine, args: string[]): Promise
if (unknown) throw new OperationError('invalid_params', `Unknown option: ${unknown}.`, 'Usage: gbrain sources retry-held <id> [--dry-run] [--json]');
if (positional.length !== 1) throw new OperationError('invalid_params', 'Name one source.', 'Usage: gbrain sources retry-held <id> [--dry-run] [--json]');
const receipt = await retryHeld(engine, positional[0], { dryRun: args.includes('--dry-run') });
+ // #6712 PR 2: a soak intervention (soak-counters.ts).
+ if (!args.includes('--dry-run')) await (await import('../core/persistence/soak-counters.ts')).recordSoakEvent(engine, 'retry_held');
if (json) { console.log(JSON.stringify(receipt, null, 2)); return; }
for (const item of receipt.items) console.log(` ${item.key} (${item.code}${item.reason ? `, ${item.reason}` : ''}): ${item.action}`);
console.log(receipt.next_action);
diff --git a/src/commands/sync/run.ts b/src/commands/sync/run.ts
index c8de79ddb8..7a728a1387 100644
--- a/src/commands/sync/run.ts
+++ b/src/commands/sync/run.ts
@@ -90,6 +90,9 @@ export async function runSyncInner(engine: BrainEngine, args: string[]) {
return;
}
+ // #6712 PR 2: a run with a recovery flag is a soak intervention (soak-counters.ts); a scheduler's plain run is not.
+ const soak = await import('../../core/persistence/soak-counters.ts');
+ if (soak.nonPlainSyncFlags(args).length) await soak.recordSoakEvent(engine, 'sync_non_plain');
if (args.includes('--acknowledge-managed')) return runAcknowledgeManaged(engine, args);
const flags = parseSyncFlags(args);
diff --git a/src/core/doctor-categories.ts b/src/core/doctor-categories.ts
index 85ba5b7973..1ff7bffa32 100644
--- a/src/core/doctor-categories.ts
+++ b/src/core/doctor-categories.ts
@@ -268,6 +268,8 @@ export const OPS_CHECK_NAMES: ReadonlySet<string> = new Set([
'orphan_clones',
'persistence_capacity',
'persistence_compaction',
+ // #6712 PR 2: the managed-sync soak counters (interventions, content decisions), informational.
+ 'sync_soak_counters',
'persistence_counter_drift',
'worktree_refresh_stuck',
'managed_guard_schema_drift',
diff --git a/src/core/persistence/soak-counters.ts b/src/core/persistence/soak-counters.ts
new file mode 100644
index 0000000000..07c10f3494
--- /dev/null
+++ b/src/core/persistence/soak-counters.ts
@@ -0,0 +1,95 @@
+/**
+ * #6712 PR 2 (L4): the soak counters. The seven-day soak passes on zero mechanical interventions, so every step a person
+ * (or an agent standing in for one) took to keep managed sync converging is counted where it happens:
+ *
+ * - interventions: a sync run with a recovery flag (`sync_non_plain`: `--retry-failed`, `--full`, `--skip-failed`,
+ * `--break-lock`, ...; a scheduler's plain `--all --no-pull --hard-deadline` run is not one), a repair apply
+ * (`repair_apply`, any kind but file-drift), `sync unblock --apply` (`unblock_apply`), `sources retry-held`
+ * (`retry_held`), and a hold that turned `needs_human` (`needs_human`: by its code, a judged content verdict, or
+ * escalation after failed attempts over a day);
+ * - content decisions (Garry's d1b): drift on a page outside the `storage.keep_db` prefixes is the user's choice, not a
+ * mechanical failure, so a `file_drift` hold (`file_drift_hold`) and a `repair file-drift` apply (`file_drift_apply`)
+ * are reported on their own line. A keep_db page reconciles from the database with no decision and counts nowhere.
+ *
+ * Storage: one `op_checkpoints` row per UTC day (op `sync-soak-counters`, fingerprint `YYYY-MM-DD`), each counter
+ * incremented in one upsert; the 7-day checkpoint purge drops a day once it leaves the window. A hold's transition is
+ * counted once: `needs_human_at` is stamped on the hold (and kept across re-holds with the same code), and the sweep
+ * after each managed sync counts holds that turned since. Recording is best effort and never fails the command.
+ * Reader: doctor `sync_soak_counters` (`readSoakCounters`).
+ */
+import type { BrainEngine } from '../engine.ts';
+import { classifySyncFault } from './sync-fault-class.ts';
+import { GIT_HOLD_OP, holdEscalation, type GitHoldRecord } from './sync-holds.ts';
+
+export const SOAK_COUNTERS_OP = 'sync-soak-counters';
+export const SOAK_WINDOW_DAYS = 7;
+export const INTERVENTION_KINDS = ['sync_non_plain', 'repair_apply', 'unblock_apply', 'retry_held', 'needs_human'] as const;
+export const CONTENT_DECISION_KINDS = ['file_drift_apply', 'file_drift_hold'] as const;
+export type SoakKind = typeof INTERVENTION_KINDS[number] | typeof CONTENT_DECISION_KINDS[number];
+/** Sync flags an operator reaches for to recover a run; a scheduler's run carries none of them. */
+export const NON_PLAIN_SYNC_FLAGS = ['--retry-failed', '--full', '--skip-failed', '--break-lock', '--force-break-lock', '--reset-checkpoint', '--no-delegate', '--acknowledge-managed'] as const;
+/** Holds the sweep stamps per sync; the rest are counted by the next sync. */
+const SWEEP_LIMIT = 500;
+
+type Exec = Pick<BrainEngine, 'executeRaw'>;
+const day = (at: number) => new Date(at).toISOString().slice(0, 10);
+
+/** Adds `n` to one counter of today's row. Never throws. */
+export async function recordSoakEvent(engine: Exec, kind: SoakKind, n = 1): Promise<void> {
+ if (n <= 0) return;
+ const today = day(Date.now());
+ await engine.executeRaw(`INSERT INTO op_checkpoints(op,fingerprint,completed_keys) VALUES($1,$2,jsonb_build_array(jsonb_build_object('day',$2::text,$3::text,$4::int)))
+ ON CONFLICT(op,fingerprint) DO UPDATE SET completed_keys=jsonb_build_array(op_checkpoints.completed_keys->0
+ || jsonb_build_object($3::text, COALESCE((op_checkpoints.completed_keys->0->>$3)::int,0)+$4::int)), updated_at=now()`, [SOAK_COUNTERS_OP, today, kind, n]).catch(() => undefined);
+}
+
+/** The intervention a sync invocation's flags make, if any. */
+export function nonPlainSyncFlags(args: readonly string[]): string[] {
+ return NON_PLAIN_SYNC_FLAGS.filter(flag => args.some(arg => arg === flag || arg.startsWith(`${flag}=`)));
+}
+
+/**
+ * Counts and stamps the holds of `sourceId` that need a person now and were not counted yet: a `file_drift` hold is a
+ * content decision, every other one a `needs_human` intervention. Returns what it counted.
+ */
+export async function sweepNeedsHumanHolds(engine: Exec, sourceId: string, now = Date.now()): Promise<{ needs_human: number; file_drift_hold: number }> {
+ const rows = await engine.executeRaw<{ fingerprint: string; record: GitHoldRecord }>(`SELECT h.fingerprint, h.completed_keys->0 AS record FROM op_checkpoints h
+ JOIN sources s ON s.id=h.completed_keys->0->>'source_id' AND s.incarnation::text=h.completed_keys->0->>'incarnation'
+ WHERE h.op=$1 AND s.id=$2 AND NOT (h.completed_keys->0->'meta' ? 'needs_human_at') ORDER BY h.fingerprint LIMIT ${SWEEP_LIMIT}`, [GIT_HOLD_OP, sourceId]);
+ const counted = { needs_human: 0, file_drift_hold: 0 };
+ const stamp = new Date(now).toISOString();
+ for (const { fingerprint, record } of rows) {
+ const content = record.meta.content_repair ? { content_repair: { ...record.meta.content_repair, path: record.path, slug: record.slug } } : {};
+ if (!classifySyncFault({ code: record.code, ...holdEscalation(record, now), ...content }).needs_human) continue;
+ const updated = await engine.executeRaw(`UPDATE op_checkpoints SET completed_keys=jsonb_set(completed_keys,'{0,meta,needs_human_at}',to_jsonb($3::text))
+ WHERE op=$1 AND fingerprint=$2 AND NOT (completed_keys->0->'meta' ? 'needs_human_at') RETURNING 1`, [GIT_HOLD_OP, fingerprint, stamp]);
+ if (updated.length) counted[record.code === 'file_drift' ? 'file_drift_hold' : 'needs_human']++;
+ }
+ await recordSoakEvent(engine, 'needs_human', counted.needs_human);
+ await recordSoakEvent(engine, 'file_drift_hold', counted.file_drift_hold);
+ return counted;
+}
+
+export interface SoakCounters {
+ window_days: number;
+ since: string;
+ interventions: { total: number } & Record<typeof INTERVENTION_KINDS[number], number>;
+ content_decisions: { total: number } & Record<typeof CONTENT_DECISION_KINDS[number], number>;
+ by_day: Array<{ day: string; interventions: number; content_decisions: number }>;
+}
+
+/** The last `days` UTC days (today included), summed per counter and per day. */
+export async function readSoakCounters(engine: Exec, days = SOAK_WINDOW_DAYS, now = Date.now()): Promise<SoakCounters> {
+ const window = Array.from({ length: days }, (_, i) => day(now - i * 86_400_000));
+ const rows = await engine.executeRaw<{ counts: Record<string, unknown> }>('SELECT completed_keys->0 AS counts FROM op_checkpoints WHERE op=$1 AND fingerprint=ANY($2::text[])',
+ [SOAK_COUNTERS_OP, window]);
+ const sum = (counts: Record<string, unknown>, kinds: readonly string[]) => kinds.reduce((total, kind) => total + (Number(counts[kind]) || 0), 0);
+ const total = (kind: string) => rows.reduce((n, row) => n + (Number(row.counts[kind]) || 0), 0);
+ const interventions = Object.fromEntries(INTERVENTION_KINDS.map(kind => [kind, total(kind)])) as SoakCounters['interventions'];
+ const decisions = Object.fromEntries(CONTENT_DECISION_KINDS.map(kind => [kind, total(kind)])) as SoakCounters['content_decisions'];
+ interventions.total = INTERVENTION_KINDS.reduce((n, kind) => n + interventions[kind], 0);
+ decisions.total = CONTENT_DECISION_KINDS.reduce((n, kind) => n + decisions[kind], 0);
+ return { window_days: days, since: `${window[window.length - 1]}T00:00:00.000Z`, interventions, content_decisions: decisions,
+ by_day: rows.map(row => ({ day: String(row.counts.day), interventions: sum(row.counts, INTERVENTION_KINDS), content_decisions: sum(row.counts, CONTENT_DECISION_KINDS) }))
+ .sort((a, b) => a.day.localeCompare(b.day)) };
+}
diff --git a/src/core/persistence/sync-movement.ts b/src/core/persistence/sync-movement.ts
index ece292da02..c7654d624f 100644
--- a/src/core/persistence/sync-movement.ts
+++ b/src/core/persistence/sync-movement.ts
@@ -62,7 +62,7 @@ export interface SourceMovement {
last_commit_at: string | null;
/** The watermark the verdict used: the newest of a commit, a head step advance and the drain's cursor advance. */
last_progress_at: string | null;
- cursor: (Pick<ManagedSyncBacklog, 'index' | 'total' | 'remaining' | 'held' | 'last_progress_at' | 'resume_command'>) | null;
+ cursor: (Pick<ManagedSyncBacklog, 'index' | 'total' | 'remaining' | 'held' | 'last_progress_at' | 'resume_command' | 'resume_args'>) | null;
head: MovementHead | null;
holds: MovementHolds;
/** Managed requests admitted on the worktree and not yet settled (queued or running). */
@@ -156,7 +156,7 @@ export async function readSourceMovement(engine: BrainEngine, opts: { sourceIds?
const progressAt = newest(lastCommitAt, claimLive ? head?.step_since : null, cursor?.last_progress_at);
const sampledAt = new Date(now).toISOString();
const base = { source_id: binding.source_id, sampled_at: sampledAt, last_commit_at: lastCommitAt, last_progress_at: progressAt,
- cursor: cursor ? { index: cursor.index, total: cursor.total, remaining: cursor.remaining, held: cursor.held, last_progress_at: cursor.last_progress_at, resume_command: cursor.resume_command } : null,
+ cursor: cursor ? { index: cursor.index, total: cursor.total, remaining: cursor.remaining, held: cursor.held, last_progress_at: cursor.last_progress_at, resume_command: cursor.resume_command, resume_args: cursor.resume_args } : null,
head, holds, admitted, live: { drain: !!drain || !!jobDrain, drain_pid: drain?.holder_pid ?? null, drain_job_id: jobDrain, consumer }, ceiling_ms: policy.ceilingMs, owner_is_this_host: ownerHere,
writer_status_command: writerStatusCommand(binding.source_id) };
out.push({ ...base, ...verdict(base, now) });
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index daf18eb2f1..d87fa5f85e 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -620,7 +620,8 @@
"count": 0,
"docs": "docs/guides/troubleshooting.md#managed-sync-not-moving",
"parked": 0,
- "sources": []
+ "sources": [],
+ "stranded": 0
},
"elapsed_ms": "<volatile>",
"message": "No managed sync is pending.",
@@ -647,6 +648,33 @@
"name": "persistence_compaction",
"status": "ok"
},
+ {
+ "category": "ops",
+ "details": {
+ "by_day": [],
+ "content_decisions": {
+ "file_drift_apply": 0,
+ "file_drift_hold": 0,
+ "total": 0
+ },
+ "docs": "docs/guides/sync-unblock-runbook.md#soak-counters",
+ "interventions": {
+ "needs_human": 0,
+ "repair_apply": 0,
+ "retry_held": 0,
+ "sync_non_plain": 0,
+ "total": 0,
+ "unblock_apply": 0
+ },
+ "since": "<ts>",
+ "window_days": 7
+ },
+ "elapsed_ms": "<volatile>",
+ "message": "Last 7 days: 0 managed-sync intervention(s), 0 content decision(s).",
+ "name": "sync_soak_counters",
+ "severity": "info",
+ "status": "ok"
+ },
{
"category": "ops",
"details": {
@@ -1036,8 +1064,34 @@
},
{
"category": "meta",
+ "details": {
+ "baseline": "<version>",
+ "shown": {
+ "cli": false,
+ "stdio": false
+ },
+ "since": "0.60.256.0"
+ },
"elapsed_ms": "<volatile>",
- "message": "Nothing to disclose: this brain is a fresh install at v<version>, after every disclosed behavior change, so the one-time behavior-change notice does not apply.",
+ "fix": {
+ "actor": "agent",
+ "argv": [
+ "gbrain",
+ "doctor",
+ "--only",
+ "behavior_changes",
+ "--json",
+ "--brain",
+ "host"
+ ],
+ "command": "gbrain doctor --only behavior_changes --json --brain host",
+ "consent": [],
+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/chat-fallback.md",
+ "next": "run",
+ "requires_exclusive": false,
+ "why": "Shows this disclosure again; read-only."
+ },
+ "message": "gbrain v0.60.256.0 changed 4 behaviors on this brain. All stay on; this is a one-time disclosure, not a request for consent. (1) A held file now asks for a person (`needs_human`) only after its safe action failed three times and at least 24 hours have passed since it was first held (#6712). Three re-holds within an hour stay the agent's to retry. A `worktree_dirty` file whose uncommitted bytes changed in the last day, and an image held while multimodal embedding is off, never escalate this way. A failed `sync unblock --apply` (still dirty) or a repair that holds the file again counts as an attempt. (2) A managed-sync file that `write_gate.external_mode=reject` refuses is now held as `write_gate_rejected` when sync freezes it, instead of failing its receipt and stopping the rest of the source. A held file that leaves the source (excluded with `sync.exclude`, or an image while multimodal embedding is off) is released by the next sync even when nothing new was committed. (3) A `source_changed` write receipt's fix now follows its recorded reason: two-sided drift previews `gbrain repair file-drift --source <id> --slug <slug> --prefer database` (a group of them `--all-drifted --since <instant>`), a missing canonical file previews `gbrain repair ghost-pages`, an admission race is retried, and a changed binding or unsafe target names `gbrain sources writer status`. `gbrain repair file-drift` takes `--since <ISO-8601 | age>` to narrow `--all-drifted`. (4) Doctor `managed_sync_not_moving` now fails (it used to list the source as parked) when a managed source's queue holds admitted requests with no consumer and nothing has moved for longer than `persistence.preparation_ceiling_ms`; its fix is the resume sync, which consumes the queue (#6552). A managed sync now prints a line when live pages of the source have no canonical file, naming the read-only `gbrain repair ghost-pages` preview; it never deletes them. gbrain doctor --only behavior_changes shows this again.",
"name": "behavior_changes",
"status": "ok"
},