Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

repair facts-home: a source that is not strict previews nothing instead of refusing, so the remediation plan's preview runs as pasted

garrytanaa7781ee0132
diff --git a/docs/guides/repair.md b/docs/guides/repair.md
index 80cee93985..84f44af5f2 100644
--- a/docs/guides/repair.md
+++ b/docs/guides/repair.md
@@ -2823,8 +2823,8 @@ The preview puts each fact in one group:
The apply writes exactly the facts the preview listed. A hash that no longer
matches refuses with `preview_changed` and prints the preview to run again; a
fact that changed since the preview is kept and reported. Facts keep their ids,
-provenance and embeddings. A source that is not strict is refused with
-`not_strict`, because its database keeps such facts by design;
+provenance and embeddings. On a source that is not strict the preview lists
+nothing and says why, because its database keeps such facts by design.
`gbrain sources git-gap <id>` shows how far it is from its commit.
<a id="consolidate-ties"></a>
diff --git a/src/core/repair/facts-home.ts b/src/core/repair/facts-home.ts
index bd0d3697ec..87f7739c08 100644
--- a/src/core/repair/facts-home.ts
+++ b/src/core/repair/facts-home.ts
@@ -7,7 +7,8 @@
* entity under a folder access rule, a held row its page cannot take, and a held row older than 30 days (with the nearest
* existing page the resolver finds) are listed and left alone. `--apply --expect <hash>` writes exactly the previewed set
* in one maintenance publication through the write door; the facts rows move in place (ids, vectors and provenance kept).
- * A source that isn't strict refuses `invalid_params` (`not_strict`). Runs only when named; never on upgrade.
+ * A source that isn't strict lists nothing and says so (its database keeps such facts by design), so the bare preview a
+ * remediation plan prints runs as pasted. Runs only when named; never on upgrade.
*/
import type { BrainEngine } from '../engine.ts';
import { opError, OperationError, type OperationContext } from '../ops/contract.ts';
@@ -72,9 +73,9 @@ export const factsHomeRepair: RepairHandler = {
const sourceId = scope.source_ids[0]!;
const scan = await scanFactsHome(engine, sourceId);
if (!scan.strict) {
- throw opError('invalid_params', `Source ${sourceId} is not strict (its pages are not canonical in Git), so its database-only facts are not a gap; nothing was listed or changed.`,
- 'On a source that is not strict the database keeps these facts by design. gbrain sources git-gap shows how far the source is from its commit.',
- { reason: 'not_strict', fix: readFix(`Shows how far source ${sourceId} is from its commit, read-only.`, { argv: ['gbrain', 'sources', 'git-gap', sourceId] }), docs: FACTS_HOME_DOCS });
+ return { items: [], preview_hash: previewHash(hashParts(scope, scan, [])), residuals: {},
+ warnings: [`Source ${sourceId} is not strict (its pages are not canonical in Git), so the database keeps its facts by design and none is a gap; nothing is listed.`],
+ details: { docs: FACTS_HOME_DOCS, strict: false, verify: gitGapArgv(sourceId).join(' ') } };
}
const approved = await approvedFacts(engine, scan);
const hash = previewHash(hashParts(scope, scan, approved));
diff --git a/src/core/repair/registry.ts b/src/core/repair/registry.ts
index a9cfc4d155..96fd1e7d8d 100644
--- a/src/core/repair/registry.ts
+++ b/src/core/repair/registry.ts
@@ -658,7 +658,7 @@ const SPECS: Record<RepairKind, Omit<RepairKindSpec, 'kind'>> = {
'facts-home': {
handler: factsHomeRepair, embeds: 'none', checks: ['strict_facts_outside_git'], explicit_only: true, preview_bound: true,
summary: 'Give the facts of a strict source (pages canonical in Git) that live in the database alone a home in Git (GST-2492). Needs --source; '
- + 'a source that is not strict refuses not_strict. The preview lists every such fact by group and writes nothing: a fact with no entity, or for an '
+ + 'a source that is not strict lists nothing. The preview lists every such fact by group and writes nothing: a fact with no entity, or for an '
+ 'entity with no page, is written to memory/unattributed (a held row names its entity and moves to the page of its entity once that page exists); a fact whose '
+ 'entity has a page is left to the extract_facts upkeep step; facts the Facts table cannot render, facts for an entity under a folder access rule, '
+ 'held rows their page cannot take and held rows older than 30 days (with the nearest existing page) are listed and left alone. --apply --expect '
diff --git a/test/repair-facts-home-gst2492.test.ts b/test/repair-facts-home-gst2492.test.ts
index 7bf3b60097..a9d54b73bd 100644
--- a/test/repair-facts-home-gst2492.test.ts
+++ b/test/repair-facts-home-gst2492.test.ts
@@ -6,7 +6,8 @@
* with no entity, or for an entity with no page, to memory/unattributed in one commit (a held row names its entity) and
* moves their rows in place (same ids); every other group stays as it is and is listed. A rebuild from a clone of HEAD
* brings the written facts back. A stale hash refuses preview_changed with the preview as its fix and the git-gap census
- * as its verify step; a source that isn't strict refuses invalid_params (not_strict).
+ * as its verify step; a source that isn't strict lists nothing, writes nothing and says why, so the bare preview a
+ * remediation plan prints exits 0.
* 2. Fails when: the preview writes, the apply writes a fact the preview did not list, an entity under a folder rule is
* named on the holding page, a written fact gets a new id or is lost on a rebuild, or a stale hash applies anything.
* 3. Existing coverage: none for this kind; test/strict-background-writers-gst2492.test.ts covers the writers.
@@ -168,11 +169,12 @@ for (const backend of testBackends()) describe(`[${backend}] gbrain repair facts
expect(await factRow(engine, SUBJECTLESS)).toMatchObject({ entity_slug: null, source_markdown_slug: HOLD, row_num: 1 });
}), 120_000);
- test('a source that is not strict refuses not_strict and names the census', () => brain(async ({ engine }) => {
+ test('a source that is not strict lists nothing, writes nothing and names the census', () => brain(async ({ engine }) => {
await legacy(engine, SUBJECTLESS, null);
- const refusal = await repair(engine).then(() => null, (error: Record<string, any>) => error);
- expect(refusal).toMatchObject({ code: 'invalid_params', reason: 'not_strict' });
- expect(refusal!.fix.argv).toEqual(['gbrain', 'sources', 'git-gap', 'default']);
+ const preview = await repair(engine);
+ expect(classes(preview)).toEqual([]);
+ expect(preview.warnings).toEqual([expect.stringContaining('Source default is not strict')]);
+ expect(preview.details).toMatchObject({ strict: false, verify: 'gbrain sources git-gap default --json' });
expect(await factRow(engine, SUBJECTLESS)).toMatchObject({ row_num: null });
}), 120_000);
});