Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Keep the label repair inside the CI guards: literal key patterns, a Postgres lane for its test, no new whole-body reads

garrytan4d62cfa4b18c
diff --git a/scripts/page-body-readers-baseline.tsv b/scripts/page-body-readers-baseline.tsv
index 61b0c03d2e..b3802a9608 100644
--- a/scripts/page-body-readers-baseline.tsv
+++ b/scripts/page-body-readers-baseline.tsv
@@ -672,6 +672,7 @@ src/core/transcripts/secret-audit.ts auditTranscriptSecrets field STREAM
src/core/transcripts/secret-audit.ts auditTranscriptSecrets sql STREAM
src/core/trust/held-removals.ts acceptHeldRemoval field SEGW materializeSegmentedBody within the single-string ceiling; over it assertInlineBody refuses (no fences there) and the proposal stays pending
src/core/trust/held-removals.ts heldRow sql SEGW inline body only; acceptHeldRemoval reads a segmented page within the single-string ceiling with materializeSegmentedBody
+src/core/trust/label-lowerings.ts listLabelLowerings sql INLINE read-only listing compares inline bodies in SQL (no body leaves the database); a segmented page or version (compiled_truth NULL) is classed unreadable
src/core/trust/page-handlers.ts markdownWithoutMarker call:serializeMarkdown SEGW
src/core/trust/page-handlers.ts markdownWithoutMarker field SEGW
src/core/trust/page-handlers.ts plannedProvenanceRestore call:serializeMarkdown SEGW refuses a segmented page (assertInlineBody); gbrain repair provenance lists segmented pages needs_review
diff --git a/src/core/persistence/label-edit.ts b/src/core/persistence/label-edit.ts
index ae599f4e70..c04ccace45 100644
--- a/src/core/persistence/label-edit.ts
+++ b/src/core/persistence/label-edit.ts
@@ -34,7 +34,10 @@ export function labelEditedFrontmatter(frontmatter: Record<string, unknown>, edi
return Object.assign(Object.fromEntries(Object.entries(frontmatter).filter(([key]) => !edit.remove.includes(key))), edit.set);
}
-const keyLine = (key: string) => new RegExp(`^${key}[ \t]*:(?:[ \t]|\r?\n|$)`);
+const KEY_LINES: Record<string, RegExp> = {
+ visibility: /^visibility[ \t]*:(?:[ \t]|\r?\n|$)/, access: /^access[ \t]*:(?:[ \t]|\r?\n|$)/, confidentiality: /^confidentiality[ \t]*:(?:[ \t]|\r?\n|$)/,
+};
+const keyLine = (key: string) => KEY_LINES[key] ?? /(?!)/;
/**
* text with the edit applied to its frontmatter lines, and the file's head through the closing --- line, or null when
diff --git a/src/core/repair/visibility.ts b/src/core/repair/visibility.ts
index 0e3bdd3f81..16a7be1d82 100644
--- a/src/core/repair/visibility.ts
+++ b/src/core/repair/visibility.ts
@@ -168,7 +168,7 @@ async function planAliases(engine: BrainEngine, sourceIds: string[], only?: numb
* operator's own single-page label change, which a put_page would rate as an agent edit (trust/channel.ts).
*/
async function planNamed(engine: BrainEngine, sourceIds: string[], slugs: string[]) {
- const rows = await engine.executeRaw<DerivedRow>(`SELECT p.id,p.source_id,p.slug,p.type,p.frontmatter->>'visibility' AS visibility,length(p.compiled_truth) AS chars
+ const rows = await engine.executeRaw<DerivedRow>(`SELECT p.id,p.source_id,p.slug,p.type,p.frontmatter->>'visibility' AS visibility,COALESCE(p.body_bytes, 0) AS chars
FROM pages p WHERE p.deleted_at IS NULL AND p.source_id=ANY($1::text[]) AND p.slug=ANY($2::text[]) ORDER BY p.id`, [sourceIds, slugs], bounded);
const changes = rows.flatMap(page => {
const next = tightened(page.visibility, 'private');
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index 88a04eddc1..63aaed13a8 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -160,6 +160,7 @@ test/ingest-capture-keeps-readers.test.ts
test/init-cold-home-embedding.test.ts
test/keyword-statement-timeout-knob-6495.test.ts
test/keyword-timeout-negative-cache-6495.test.ts
+test/label-only-repairs.test.ts
test/lane-apply-pipelining.test.ts
test/large-pages/append-concurrency.test.ts
test/large-pages/append-cost.test.ts