Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(doctor): #6712 PR 4b the post-upgrade blocked-source note reads the pass row's blocked outcome

garrytand65e60f30227
diff --git a/src/commands/doctor/checks/git-holds.ts b/src/commands/doctor/checks/git-holds.ts
index 2cab76f690..2cd8febf1a 100644
--- a/src/commands/doctor/checks/git-holds.ts
+++ b/src/commands/doctor/checks/git-holds.ts
@@ -106,7 +106,8 @@ function fenceAutoSentence(auto: FenceAutoRepair | undefined): string {
}
/**
- * Sources whose unfinished managed sync cursor is stopped on a failed content refusal (fixed by the next sync, which converts it in place).
+ * Sources stopped on a failed content refusal: a company (or not yet retired) cursor pending on it, or a non-company source whose
+ * newest pass ended blocked on it. The next sync fixes either (the file is held and the rest imports).
* `fence` marks a source whose refusal is a facts or takes fence (#6188); it is held and repaired by `gbrain repair fences`, not by frontmatter repair.
*/
export async function contentBlockedSources(engine: BrainEngine): Promise<Array<{ source_id: string; fence: boolean }>> {
@@ -115,6 +116,15 @@ export async function contentBlockedSources(engine: BrainEngine): Promise<Array<
AND r.source_id = c.completed_keys->0->>'sourceId'
WHERE c.op = 'managed-sync' AND COALESCE(c.completed_keys->0->>'done','false') <> 'true' AND r.state IN ('failed','conflict','cancelled')
ORDER BY 1`).catch(() => []);
+ // #6712 PR 4b (design v3.2 §3.7): a non-company source has no cursor; it is blocked when its newest pass ended blocked on a
+ // receipt that pass admitted (the receipt's intent carries the pass id).
+ const { readPassReadings } = await import('../../../core/persistence/sync-pass-readers.ts');
+ for (const { source_id, row, health } of await readPassReadings(engine, { head: false }).catch(() => [])) {
+ if (health.reason !== 'blocked') continue;
+ rows.push(...await engine.executeRaw<{ source_id: string; error_code: string | null; error_message: string | null; error_detail: unknown }>(`SELECT source_id,
+ error_code, error_message, error_detail FROM persistence_requests WHERE source_id=$1 AND intent->>'passId'=$2 AND state IN ('failed','conflict','cancelled')`,
+ [source_id, row.value.telemetry.pass_id]).catch(() => []));
+ }
const out = new Map<string, boolean>();
for (const row of rows) {
const fence = fenceReceiptLocation(row) !== null;
diff --git a/test/doctor-frontmatter-holds.test.ts b/test/doctor-frontmatter-holds.test.ts
index 42b5492307..c7eead3e1b 100644
--- a/test/doctor-frontmatter-holds.test.ts
+++ b/test/doctor-frontmatter-holds.test.ts
@@ -218,6 +218,9 @@ test('post-upgrade: a source a file blocked is told the next sync recovers it, w
+ `to do it now run gbrain sync --source ${s.id} --no-pull.`);
expect(banner).toContain(`gbrain repair frontmatter --source ${s.id}`);
- expect(await s.sync()).toMatchObject({ status: 'first_sync', held_count: 1, converted_from_failed: [failed!.request_id] });
+ // #6712 PR 4b: no cursor converts in place; the next pass holds the file, imports the rest and leaves the old receipt as it was.
+ expect(await s.sync()).toMatchObject({ status: 'first_sync', held_count: 1, held: [{ code: 'invalid_frontmatter' }] });
+ expect(await engine.executeRaw('SELECT state,error_code,error_message FROM persistence_requests WHERE request_id=$1::uuid', [failed!.request_id]))
+ .toEqual([{ state: 'failed', error_code: 'invalid_params', error_message: 'Invalid YAML frontmatter: bad indentation of a mapping entry (3:1)' }]);
expect((await postUpgradeRecoveryBanner(engine, 'host')).join('\n')).not.toContain('frontmatter_holds:');
}), 180_000);