Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

quarantine scan: list segmented pages it does not re-check (wip)

garrytana667daae1ecc
diff --git a/src/commands/quarantine.ts b/src/commands/quarantine.ts
index 9f11074162..bdd3e3340d 100644
--- a/src/commands/quarantine.ts
+++ b/src/commands/quarantine.ts
@@ -8,6 +8,10 @@
* `quarantine` (hidden) marks high-confidence junk; `content_flag` (warned,
* still searchable) marks fuzzy markup-heavy / oversize pages. See
* src/core/quarantine.ts for the marker contract.
+ *
+ * `scan` re-checks a page by holding its whole body as one string (and
+ * `--apply` re-imports it), so a segmented page (Wave B) is not re-checked:
+ * it is listed in the scan's `skipped` with the reason, and the scan goes on.
*/
import type { BrainEngine } from '../core/engine.ts';
import { isQuarantined, getContentFlag, QUARANTINE_KEY, CONTENT_FLAG_KEY } from '../core/quarantine.ts';
@@ -23,6 +27,7 @@ import { resolveCliWriteWaitMs } from '../core/persistence/write-wait.ts';
import { QUARANTINE_OVERRIDE_KEY, quarantineOverrideFor } from '../core/quarantine-override.ts';
import { reportPersistenceCliError } from './persistence-delegate.ts';
import type { PageType } from '../core/types.ts';
+import { isSegmentedPage } from '../core/page-body/page-shape.ts';
import { listWriteGateHolds, type WriteGateHold } from '../core/write-gate-store.ts';
export interface QuarantineRow {
@@ -336,6 +341,7 @@ async function runScan(engine: BrainEngine, args: string[]): Promise<void> {
let quarantined = 0;
let flagged = 0;
const touched: Array<{ slug: string; outcome: 'quarantine' | 'flag' }> = [];
+ const skipped: Array<{ slug: string; source_id: string; reason: 'page_body_segmented'; message: string }> = [];
for (const ref of refs) {
if (scanned >= limit) break;
@@ -346,6 +352,11 @@ async function runScan(engine: BrainEngine, args: string[]): Promise<void> {
// so --apply doesn't re-chunk/re-embed already-flagged pages every run.
const pfm = page.frontmatter as Record<string, unknown> | null;
if (isQuarantined(pfm) || getContentFlag(pfm)) continue;
+ if (isSegmentedPage(page)) {
+ skipped.push({ slug: ref.slug, source_id: ref.source_id, reason: 'page_body_segmented',
+ message: 'The page stores its body in segments and this scan re-checks a page by reading its whole body as one string, so it was not re-checked.' });
+ continue;
+ }
if (!apply) {
// Dry-run: assess read-only (re-import would mutate). Same thresholds as --apply.
@@ -388,11 +399,15 @@ async function runScan(engine: BrainEngine, args: string[]): Promise<void> {
}
if (json) {
- console.log(JSON.stringify({ schema_version: 1, applied: apply, scanned, quarantined, flagged, touched }, null, 2));
+ console.log(JSON.stringify({ schema_version: 1, applied: apply, scanned, quarantined, flagged, touched, ...(skipped.length ? { skipped } : {}) }, null, 2));
return;
}
const verb = apply ? '' : '(dry-run) would ';
console.log(`Scanned ${scanned} page(s): ${verb}quarantine ${quarantined}, ${verb}flag ${flagged}.`);
+ if (skipped.length) {
+ console.log(`Not re-checked: ${skipped.length} segmented page(s) (this scan reads a whole body as one string):`);
+ for (const page of skipped) console.log(` ${page.source_id}:${page.slug}`);
+ }
if (!apply && (quarantined > 0 || flagged > 0)) {
console.log('Re-run with --apply to set the markers.');
}