Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(security): strip gate-owned markers from every writer unless an owner-tier path preserves them (#6259)
time-attack1834f1bd1678
diff --git a/docs/architecture/key-files/commands-4-continued.md b/docs/architecture/key-files/commands-4-continued.mdindex 22d7f57058..009ed8d8fa 100644--- a/docs/architecture/key-files/commands-4-continued.md+++ b/docs/architecture/key-files/commands-4-continued.md@@ -9,7 +9,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/commands/publish.ts` — Deterministic brain page publisher (code+skill pair, zero LLM calls)-- `src/core/quarantine-override.ts` — #6259 (fix wave 12): the `quarantine_override` frontmatter key `gbrain quarantine clear --force` records: `{ binding, cleared_at }`, where `binding` is a sha256 over the classifier's inputs (title, type, body) as the gate canonicalizes them (`quarantineOverrideFor`). `assessImportSanity` (`import-screen.ts`) wraps its verdict in `withQuarantineOverride`, which removes the junk-pattern, literal and markup-flag outcomes while the binding is current (size outcomes stay). `importFromContent` calls `settleGateOwnedMarkers` (which also owns the #1699 remote strip of `quarantine`, `content_flag`, `embed_skip` and `atoms_scan_hash`): remote input loses any override; trusted input keeps its own only while current, and a current override drops classifier markers the content still carries. For a remote write the classifier would hide or markup-flag, `carryStoredQuarantineOverride` reads the stored override and keeps it when it still binds (so a remote tag edit does not re-hide the page); a clean remote write reads nothing extra (#6007 statement budget). Company-brain inspection refuses files carrying it (`hidden_input`). Doctor's quarantine row names `clear <slug> --force` and `content_sanity.disabled_patterns`.+- `src/core/quarantine-override.ts` — #6259 (fix wave 12): the `quarantine_override` frontmatter key `gbrain quarantine clear --force` records: `{ binding, cleared_at }`, where `binding` is a sha256 over the classifier's inputs (title, type, body) as the gate canonicalizes them (`quarantineOverrideFor`). `assessImportSanity` (`import-screen.ts`) wraps its verdict in `withQuarantineOverride`, which removes the junk-pattern, literal and markup-flag outcomes while the binding is current (size outcomes stay). `importFromContent` calls `stripGateOwnedMarkers` (`import-screen.ts`, `GATE_OWNED_FRONTMATTER_KEYS`): every writer loses `quarantine`, `content_flag`, `embed_skip`, `atoms_scan_hash` and `quarantine_override` unless an owner-tier path passes `preserveGateMarkers: true` (`importFromFile`, managed sync and file import, reindex, file repair, reconcile, the cycle derivers and their `managed_maintenance_page` intents, `quarantine clear/scan` and the owner-internal `managed_quarantine_clear` put_page kind); local put_page, connectors and ingest lanes do not. A preserving path keeps its own override only while current, and a current override drops classifier markers the content still carries. `opts.remote` keeps only its fence-merge/hidden-row meaning. Tests: `test/gate-marker-strip.test.ts`. For a stripped write the classifier would hide or markup-flag, `carryStoredQuarantineOverride` reads the stored override and keeps it when it still binds (so a remote tag edit does not re-hide the page); a clean remote write reads nothing extra (#6007 statement budget). Company-brain inspection refuses files carrying it (`hidden_input`). Doctor's quarantine row names `clear <slug> --force` and `content_sanity.disabled_patterns`.- `src/commands/quarantine.ts` — `gbrain quarantine <list|clear|scan>` operator surface for the content-quality gate. `list [--json] [--include-flagged]` paginates `listPages` and reports quarantined (HIDDEN) pages, optionally also `content_flag` (FLAGGED, searchable) pages. `clear <slug> [--force] [--no-embed] [--json]` drops both markers and re-imports through the normal pipeline so the page re-chunks + re-embeds and becomes searchable; the gate re-runs on import so genuinely-junk pages re-quarantine (exit 1) unless `--force` sets `GBRAIN_NO_SANITY=1` for that one import. `scan [--limit N] [--apply] [--no-embed] [--json]` re-assesses already-ingested pages so junk predating the gate gets marked (unchanged content short-circuits normal sync, so it never re-assesses otherwise); dry-run uses the SAME effective `content_sanity` config thresholds `--apply` will use, idempotent (skips already-marked pages), `--apply` re-imports with `forceRechunk` to set markers + (for quarantine) drop chunks. Dispatched in `cli.ts`. Pinned by `test/quarantine-cli.test.ts`. #6259: `clear` reads one snapshot (page, tags, revision) and, on a managed brain, publishes through `submitPageMutation` with that `expected_revision` (a concurrent edit is a `revision_conflict`, a pending receipt is reported as pending); `--force` writes a `quarantine_override` (see `src/core/quarantine-override.ts`) instead of disabling the gate, never mutation `force`. `scan --apply` refuses `writer_coordinator_required` on a managed brain. It is a router (`QUARANTINE_SUBCOMMANDS`, `printUsage`). Tests: `test/quarantine-override.serial.test.ts`, `test/quarantine-cli.test.ts`.- `src/commands/recall.ts` — the `gbrain recall` CLI (facts-first by default; local engine or thin-client). A malformed `--limit` (not a positive safe integer, or missing) throws `invalid_params` from `parseFlags`, so the CLI exits 2 through `renderCliError`: the v1 envelope under `--json` with `why` and a `fix` that reruns the same argv with `--limit 50`, and the Error/Fix/Why lines otherwise (`test/recall-limit-envelope.test.ts`). Optional `--budget-policy facts_first|query_first` routes a one-shot read through the shared operation, forwarding fact filters and using remote recall on thin clients. Enum validation uses the shared operation definition; option order does not affect budget parsing. Only query-first with a nonblank query preserves numeric fractions until server packing; omitted/explicit facts-first keeps legacy integer parsing. The new option rejects watch/cursor/rollup/as-context combinations rather than silently ignoring them. Opt-in selector failures use stamped v1 errors; JSON mode emits structured local and remote errors on stdout with a nonzero exit, preserving remote read-error details without requiring a mutation receipt. Omitted-policy validation and fallback remain unchanged. Entity→text fallback: a bare positional without verb options is entity-first, but when the entity arm matches ZERO facts (and no `--grep`/`--supersessions`/`--session-id` narrows the read), the query retries as SQL-level fact-text grep with a stderr note. One predicate and note formatter are shared by the local path and thin-client mirror; explicit grep callers keep exact semantics. `--since` composes with entity and session in one query before LIMIT, on event time unless `--since-last-run`. Local `--grep` is passed to every engine arm (ILIKE with escaped metacharacters, before LIMIT); only `--supersessions` keeps the client-side filter. Pinned by `test/recall-grep-local-cli.test.ts`. Pinned by `test/facts-recall-since-composition.test.ts`, `test/recall-budget-policy-transports.test.ts`, `test/recall-budget-policy-thin-cli.test.ts`, and `test/recall-budget-policy-thin.serial.test.ts`.diff --git a/src/commands/quarantine.ts b/src/commands/quarantine.tsindex 8344fb6152..7f9b6fb9f5 100644--- a/src/commands/quarantine.ts+++ b/src/commands/quarantine.ts@@ -246,8 +246,9 @@ async function runClear(engine: BrainEngine, args: string[]): Promise<void> {writeWaitMs: resolveCliWriteWaitMs({ config: loadConfig() }),logger: { info: () => {}, warn: (m: string) => console.error(m), error: (m: string) => console.error(m) } } as unknown as OperationContext;try {- await submitPageMutation(ctx, { operation: 'put_page', params: { slug, source_id: page.source_id, content: markdown,- expected_revision: snapshot.revision, request_id: randomUUID() } });+ // #6259: the owner-internal kind keeps the override this clear writes (a plain put_page has gate markers stripped).+ await submitPageMutation(ctx, { operation: 'put_page', managedFileImport: true, params: { slug, source_id: page.source_id, content: markdown,+ kind: 'managed_quarantine_clear', expected_revision: snapshot.revision, request_id: randomUUID() } });} catch (error) {if (await reportPersistenceCliError(error, json)) return;throw error;@@ -257,7 +258,7 @@ async function runClear(engine: BrainEngine, args: string[]): Promise<void> {flagReason = getContentFlag(after)?.reason;flagged = !!flagReason;} else {- const result = await importFromContent(engine, slug, markdown, { sourceId: page.source_id, noEmbed, forceRechunk: true });+ const result = await importFromContent(engine, slug, markdown, { sourceId: page.source_id, noEmbed, forceRechunk: true, preserveGateMarkers: true });reQuarantined = result.quarantined === true;flagged = result.flagged ?? false;flagReason = result.flag_reason;@@ -359,7 +360,7 @@ async function runScan(engine: BrainEngine, args: string[]): Promise<void> {const tags = await engine.getTags(ref.slug, { sourceId: ref.source_id });const markdown = serializePageToMarkdown(page, tags);const result = await importFromContent(engine, ref.slug, markdown, {- sourceId: ref.source_id,+ sourceId: ref.source_id, preserveGateMarkers: true,noEmbed,forceRechunk: true,});diff --git a/src/commands/reindex.ts b/src/commands/reindex.tsindex 6c610dfe2e..de3efa7b56 100644--- a/src/commands/reindex.ts+++ b/src/commands/reindex.ts@@ -483,7 +483,7 @@ export async function runReindex(engine: BrainEngine, args: string[], runOpts: R{ type: page.type, title: page.title, tags },);const imported = await importFromContent(engine, row.slug, fullMarkdown, {- sourceId: row.source_id,+ sourceId: row.source_id, preserveGateMarkers: true,noEmbed: !!opts.noEmbed,forceRechunk: true,});diff --git a/src/core/cycle/extract-atoms.ts b/src/core/cycle/extract-atoms.tsindex eafa49e0f7..d63e871ce8 100644--- a/src/core/cycle/extract-atoms.ts+++ b/src/core/cycle/extract-atoms.ts@@ -1257,7 +1257,7 @@ export async function runPhaseExtractAtoms();if (managed) managedAtoms.push({ slug, content: md, links: [] });else await importFromContent(engine, slug, md, {- sourceId,+ sourceId, preserveGateMarkers: true,noEmbed: !isAvailable('embedding'),});importedSlugs.push(slug);diff --git a/src/core/cycle/pattern-claim-sources.ts b/src/core/cycle/pattern-claim-sources.tsindex bc38f55df0..215ddba67c 100644--- a/src/core/cycle/pattern-claim-sources.ts+++ b/src/core/cycle/pattern-claim-sources.ts@@ -120,7 +120,7 @@ export async function dedupePatternClaimSources(engine: BrainEngine, maintenance}} else {const [{ importFromContent }, { isAvailable }] = await Promise.all([import('../import-file.ts'), import('../ai/gateway.ts')]);- await importFromContent(engine, slug, content, { noEmbed: !isAvailable('embedding'), sourceId });+ await importFromContent(engine, slug, content, { noEmbed: !isAvailable('embedding'), sourceId, preserveGateMarkers: true });}rewritten.push(slug);} catch (error) {diff --git a/src/core/cycle/patterns.ts b/src/core/cycle/patterns.tsindex 94e7d4ae00..53691db85f 100644--- a/src/core/cycle/patterns.ts+++ b/src/core/cycle/patterns.ts@@ -724,7 +724,7 @@ export async function groundPatternPages(engine: BrainEngine, maintenance: Maintelse if (await publishOrHold(publish)) heldSlugs.add(slug);} else {const [{ importFromContent }, { isAvailable }] = await Promise.all([import('../import-file.ts'), import('../ai/gateway.ts')]);- await importFromContent(engine, slug, content, { noEmbed: !isAvailable('embedding'), sourceId });+ await importFromContent(engine, slug, content, { noEmbed: !isAvailable('embedding'), sourceId, preserveGateMarkers: true });}}return stats;diff --git a/src/core/cycle/synthesize-concepts.ts b/src/core/cycle/synthesize-concepts.tsindex 4267a4cf5c..8f330b2ed1 100644--- a/src/core/cycle/synthesize-concepts.ts+++ b/src/core/cycle/synthesize-concepts.ts@@ -501,7 +501,7 @@ export async function runPhaseSynthesizeConcepts(// #4416: target the cycle's resolved source, not the 'default' literal.baseline = await publishClassicConcept(engine, conceptSlug, opts.sourceId ?? 'default', synthesized(pageVisibility), narrative,baseline, { writeThrough: conceptFiles !== null, importPage: (markdown) => importFromContent(engine, conceptSlug, markdown, {- noEmbed: !isAvailable('embedding'), sourceId: opts.sourceId,+ noEmbed: !isAvailable('embedding'), sourceId: opts.sourceId, preserveGateMarkers: true,}) });};// A publication that lost a revision race or would lose canonicaldiff --git a/src/core/cycle/synthesize-verify.ts b/src/core/cycle/synthesize-verify.tsindex 9c7d9aff1f..c2ecb6bcf7 100644--- a/src/core/cycle/synthesize-verify.ts+++ b/src/core/cycle/synthesize-verify.ts@@ -1425,7 +1425,7 @@ export async function verifyAndRepairDreamPages(// noEmbed: the phase-end embed sweep backfills. Provenance fields// null → engine COALESCE keeps the first-write record intact.await importFromContent(engine, ref.slug, md, {- noEmbed: true, remote: false, sourceId: ref.source_id,+ noEmbed: true, remote: false, preserveGateMarkers: true, sourceId: ref.source_id,beforeCommit: async tx => { await project(tx); await links?.apply(tx); },});stats.pages_repaired++;diff --git a/src/core/import-file.ts b/src/core/import-file.tsindex 120670006c..153e38077e 100644--- a/src/core/import-file.ts+++ b/src/core/import-file.ts@@ -3,7 +3,7 @@ import { suffixedFrontmatterSlugHold } from './persistence/suffixed-slug.ts';import { maintenanceTransaction } from './persistence/attribution.ts';import { assertImportBase, sameCanonicalImport, sameContentAnyKeyOrder } from './page-state/import-guard.ts';import { stabilizeSafetyAssessments } from './persistence/reconcile-safety.ts';-import { carryStoredQuarantineOverride, settleGateOwnedMarkers } from './quarantine-override.ts';+import { carryStoredQuarantineOverride } from './quarantine-override.ts';import { decideImportIdentity, collidingSlugOwner, fileOriginUri } from './import-identity.ts';import { readSourceFileSync } from './minions/source-filesystem.ts';import { readFileSync, statSync, lstatSync } from 'fs';@@ -11,7 +11,7 @@ import { basename, extname, resolve } from 'path';import { createHash } from 'crypto';import type { BrainEngine, FileSpec } from './engine.ts';import { classifyImportHold, parseMarkdown, resolveParsedSubtype, type ParseOpts, type ParsedMarkdown } from './markdown.ts';-import { assessImportSanity, loadImportSanityConfig, MAX_FILE_SIZE, screenImportContent, type ContentRefusal, type FenceScreen } from './import-screen.ts';+import { assessImportSanity, loadImportSanityConfig, MAX_FILE_SIZE, screenImportContent, stripGateOwnedMarkers, type ContentRefusal, type FenceScreen } from './import-screen.ts';import { applyImportFences } from './fence-repair/import-step.ts';import type { FenceIssueWire } from './fence-repair/tier1.ts';import type { FenceFix } from './fence-repair/types.ts';@@ -299,20 +299,16 @@ export async function importFromContent(source_kind?: string | null;source_uri?: string | null;ingested_via?: string | null;+ /** Untrusted caller (remote MCP put_page: `ctx.remote !== false`); drives the remote fence merge and hidden rows. */+ remote?: boolean;/**- * v0.42 (#1699 trust boundary). When `true` (untrusted caller — remote MCP- * put_page), gate-owned frontmatter markers (`quarantine`, `content_flag`,- * `embed_skip`) are STRIPPED from the incoming content before the content-- * sanity gate runs, so only the gate itself can set them. Without this, a- * write-scoped OAuth client could `put_page` clean content carrying a- * hand-crafted `quarantine` marker to hide arbitrary pages from search, or- * a `content_flag.detail` to inject text into the agent-trusted warning- * channel. `put_page` passes `ctx.remote !== false` (fail-closed: anything- * not strictly local is untrusted, matching the v0.26.9 F7b posture).- * Local/trusted callers (sync, capture, dream, `quarantine clear/scan`)- * leave it unset → markers preserved (the gate + CLI own them).+ * #1699/#6259: gate-owned markers (`quarantine`, `content_flag`, `embed_skip`,+ * `atoms_scan_hash`, `quarantine_override`) are stripped from incoming content+ * unless an owner-tier path (owner sync/import, reindex, file repair,+ * reconcile, cycle derivers, `quarantine clear/scan`) sets this+ * (`stripGateOwnedMarkers`, import-screen.ts). Local put_page does not.*/- remote?: boolean;+ preserveGateMarkers?: boolean;/*** Threaded to `tx.putPage` as its empty-overwrite escape hatch (the* engine refuses to blank a non-empty body otherwise). Only two callers@@ -353,8 +349,8 @@ export async function importFromContent(parsed.compiled_truth = sanitizeText(parsed.compiled_truth);parsed.timeline = sanitizeText(parsed.timeline);- // #1699 trust boundary: only the gate and trusted local callers set gate-owned markers (quarantine-override.ts).- settleGateOwnedMarkers(parsed, opts.remote === true);+ // #1699/#6259 trust boundary: only the gate and owner-tier paths keep gate-owned markers (import-screen.ts).+ stripGateOwnedMarkers(parsed, opts);// Vendor-neutral guardrail seam (observe-only, fail-open). Runs AFTER// parseMarkdown and the size guard, BEFORE content-sanity, hash compute,@@ -414,7 +410,7 @@ export async function importFromContent(// Disposition for the high-confidence junk path: quarantine (hide) by// default, or reject (throw → sync-failure) when the operator opts in.const junkDisposition = sanityCfg.junkDisposition;- const sanityResult = await carryStoredQuarantineOverride(engine, parsed, assessImportSanity(parsed, sanityCfg), { slug, sourceId, remote: opts.remote === true });+ const sanityResult = await carryStoredQuarantineOverride(engine, parsed, assessImportSanity(parsed, sanityCfg), { slug, sourceId, stripped: opts.preserveGateMarkers !== true });if (!sanityDisabled && !sanityResult.shouldQuarantine && sanityResult.flag_reason !== 'oversized' && (parsed.frontmatter[EMBED_SKIP_KEY] as { reason?: unknown } | undefined)?.reason === 'oversized') {delete parsed.frontmatter[EMBED_SKIP_KEY];if ((parsed.frontmatter[CONTENT_FLAG_KEY] as { reason?: unknown } | undefined)?.reason === 'oversized') delete parsed.frontmatter[CONTENT_FLAG_KEY];@@ -1274,7 +1270,7 @@ export async function importFromFile(// filename `2024-03-15`.const fileBasename = basename(relativePath, '.md');const imported = await importFromContent(engine, resolvedSlug, content, {- ...opts,+ ...opts, preserveGateMarkers: true,filename: fileBasename,sourcePath: relativePath,// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal -- walks up from the caller's own file path by the depth of its own relative path to recover the import root; import-identity confines every probe under that rootdiff --git a/src/core/import-screen.ts b/src/core/import-screen.tsindex 0dcd5ec7fe..612adc70af 100644--- a/src/core/import-screen.ts+++ b/src/core/import-screen.ts@@ -11,7 +11,10 @@import type { BrainEngine } from './engine.ts';import { loadConfig, loadConfigWithEngine } from './config.ts';import { assessContentSanity, type ContentSanityResult } from './content-sanity.ts';-import { withQuarantineOverride } from './quarantine-override.ts';+import { dropClassifierMarkers, hasCurrentQuarantineOverride, QUARANTINE_OVERRIDE_KEY, withQuarantineOverride } from './quarantine-override.ts';+import { CONTENT_FLAG_KEY, QUARANTINE_KEY } from './quarantine.ts';+import { EMBED_SKIP_KEY } from './embed-skip.ts';+import { ATOMS_SCAN_HASH_KEY } from './utils.ts';import { loadOperatorLiterals } from './content-sanity-literals.ts';import { classifyImportHold, contentSizeHold, parseMarkdown, type ContentHold, type ParseOpts, type ParsedMarkdown } from './markdown.ts';import { isCodeFilePath } from './sync.ts';@@ -57,6 +60,30 @@ export async function loadImportSanityConfig(engine: BrainEngine): Promise<Impor};}+/** Frontmatter keys only the content-quality gate, the extract_atoms phase and the operator's clear may set. */+export const GATE_OWNED_FRONTMATTER_KEYS = [QUARANTINE_KEY, CONTENT_FLAG_KEY, EMBED_SKIP_KEY, ATOMS_SCAN_HASH_KEY, QUARANTINE_OVERRIDE_KEY] as const;++/**+ * #1699/#6259 trust boundary, fail closed: incoming content loses every+ * gate-owned marker unless an owner-tier path passes `preserveGateMarkers`+ * (owner sync and file import, reindex, file repair, reconcile, the cycle+ * derivers, `quarantine clear/scan`). Otherwise any writer, a local put_page,+ * a connector or an ingest lane included, could hide a page from search+ * (`quarantine`), inject text into the agent's warning channel+ * (`content_flag.detail`), stop its embedding (`embed_skip`), suppress atom+ * mining (`atoms_scan_hash`) or forge a cleared state (`quarantine_override`).+ * A preserving path keeps its own override only while it binds the content,+ * and a current override drops classifier markers the content still carries.+ */+export function stripGateOwnedMarkers(parsed: Pick<ParsedMarkdown, 'frontmatter' | 'title' | 'type' | 'compiled_truth' | 'timeline'>, opts: { preserveGateMarkers?: boolean }): void {+ if (opts.preserveGateMarkers !== true) {+ for (const key of GATE_OWNED_FRONTMATTER_KEYS) delete parsed.frontmatter[key];+ return;+ }+ if (Object.hasOwn(parsed.frontmatter, QUARANTINE_OVERRIDE_KEY) && !hasCurrentQuarantineOverride(parsed)) delete parsed.frontmatter[QUARANTINE_OVERRIDE_KEY];+ dropClassifierMarkers(parsed as ParsedMarkdown);+}+/** #6259: a page carrying a current `quarantine_override` keeps the classifier's verdict off (see quarantine-override.ts). */export function assessImportSanity(page: Pick<ParsedMarkdown, 'compiled_truth' | 'timeline' | 'title' | 'type'> & { frontmatter?: Record<string, unknown> }, cfg: ImportSanityConfig): ContentSanityResult {return withQuarantineOverride(assessContentSanity({diff --git a/src/core/persistence/file-repair.ts b/src/core/persistence/file-repair.tsindex c4c150fbee..6439205fae 100644--- a/src/core/persistence/file-repair.ts+++ b/src/core/persistence/file-repair.ts@@ -182,7 +182,7 @@ export async function prepareRepairPublication(engine: BrainEngine, input: Repailet prepared: PreparedContentImport | undefined;let result;try {- result = await importFromContent(engine, renamed ? input.base!.page.slug : input.slug, content, { sourceId: input.sourceId, noEmbed: true, remote: false,+ result = await importFromContent(engine, renamed ? input.base!.page.slug : input.slug, content, { sourceId: input.sourceId, noEmbed: true, remote: false, preserveGateMarkers: true,activePack: input.activePack, filename: basename(input.sourcePath).replace(/\.mdx?$/i, ''), sourcePath: input.sourcePath, allowEmptyOverwrite: true,prepare: async value => { prepared = value; return value.result; } });} catch (error) {@@ -299,7 +299,7 @@ export async function prepareManagedFileRepairMutation(engine: BrainEngine, row:const ready = publication.ready;const project = await prepareCanonicalProjections(engine, ready.parsedPage, row.slug, row.source_id, base, 'file');const importContent = p.content.replace(/^\uFEFF/, '');- const importOptions = { ...source, noEmbed: true, remote: false, activePack: screenConfig.activePack, filename: basename(p.sourcePath).replace(/\.mdx?$/i, ''), sourcePath: p.sourcePath, allowEmptyOverwrite: true };+ const importOptions = { ...source, noEmbed: true, remote: false, preserveGateMarkers: true, activePack: screenConfig.activePack, filename: basename(p.sourcePath).replace(/\.mdx?$/i, ''), sourcePath: p.sourcePath, allowEmptyOverwrite: true };return { observedRevision: snapshot?.revision ?? null, noop: ready.noop && !fileChanges && !moved, contentUnchanged: ready.noop && !fileChanges && !moved,deferEmbedding: p.noEmbed, ...(moved ? { additionalPageKeys: [{ sourceId: row.source_id, slug: moved.slug }] } : {}),...(fileChanges ? { file: { root, path: target, content: bytes, expectedBeforeHash: p.beforeHash, ...(fenceRepair ? { commit: fenceRepairCommit(p.path, fenceRepair.classes) } : {}) } } : {}),diff --git a/src/core/persistence/import-prepare.ts b/src/core/persistence/import-prepare.tsindex 564d98f657..e216586a10 100644--- a/src/core/persistence/import-prepare.ts+++ b/src/core/persistence/import-prepare.ts@@ -181,7 +181,7 @@ export async function prepareManagedImportMutation(engine: BrainEngine, row: Wri? await importImageFile(engine, p.inputPath, p.sourcePath, { ...source, noEmbed: p.noEmbed, bytes: imageBytes, prepare }): code? await importCodeFile(engine, p.sourcePath, p.content, { ...source, noEmbed: true, prepare })- : await importFromContent(engine, row.slug, p.content, { ...source, noEmbed: true, remote: false, prepare, fences: 'coordinated',+ : await importFromContent(engine, row.slug, p.content, { ...source, noEmbed: true, remote: false, preserveGateMarkers: true, prepare, fences: 'coordinated',activePack: p.activePack, sourcePath: p.sourcePath, filename: basename(p.sourcePath, '.md'), allowEmptyOverwrite: true });if (!prepared && result.refusal?.code === 'invalid_fence') throw managedImportRefusal(result.refusal, p.sourcePath);if (!prepared) throw opError('invalid_params', result.error ?? 'The file could not be prepared.',diff --git a/src/core/persistence/page-mutations.ts b/src/core/persistence/page-mutations.tsindex 140dd8c697..830f9051a2 100644--- a/src/core/persistence/page-mutations.ts+++ b/src/core/persistence/page-mutations.ts@@ -164,8 +164,8 @@ export function emitFenceNotice(ctx: Pick<OperationContext, 'emitNotice'>, respoif (report) ctx.emitNotice?.(fenceNormalizedNotice(report, slug));}-/** Owner-internal `put_page` kinds the trusted local file writers (import, frontmatter repair) submit; every other caller is refused them. */-const OWNER_FILE_INTENTS: ReadonlySet<string> = new Set(['managed_file_import', 'managed_file_repair']);+/** Owner-internal `put_page` kinds the trusted local file writers (import, frontmatter repair, quarantine clear) submit; every other caller is refused them. */+const OWNER_FILE_INTENTS: ReadonlySet<string> = new Set(['managed_file_import', 'managed_file_repair', 'managed_quarantine_clear']);/** #6007: a `put_pages` child: its batch, its position and the batch size are part of its identity. */export interface PageBatchMember { id: string; index: number; size: number; requestId: string }diff --git a/src/core/persistence/page-prepare.ts b/src/core/persistence/page-prepare.tsindex 3434030537..04a2df78e9 100644--- a/src/core/persistence/page-prepare.ts+++ b/src/core/persistence/page-prepare.ts@@ -372,6 +372,8 @@ export async function preparePageMutation(engine: BrainEngine, row: WriteRequestlet provenance: CanonicalProvenance | undefined;const result = await importFromContent(engine, row.slug, content, {...source, noEmbed: true, remote: row.authority.remote, activePack, fences: projected ? 'coordinated' : 'lenient',+ // #6259: only owner-tier intents keep gate-owned markers; an ordinary put_page, local or remote, has them stripped.+ preserveGateMarkers: !row.authority.remote && (p.kind === 'managed_maintenance_page' || p.kind === 'managed_quarantine_clear'),forceRechunk: row.operation === 'restore_page' || row.operation === 'revert_version',allowEmptyOverwrite: p.allow_empty === true || row.operation === 'restore_page' || row.operation === 'revert_version',source_kind: typeof p.source_kind === 'string' ? p.source_kind : null,diff --git a/src/core/persistence/reconcile-prepare.ts b/src/core/persistence/reconcile-prepare.tsindex 8c76e60f07..27cdeb30bd 100644--- a/src/core/persistence/reconcile-prepare.ts+++ b/src/core/persistence/reconcile-prepare.ts@@ -100,7 +100,7 @@ export async function prepareReconcileResult(engine: BrainEngine, state: Reconcilet ready: PreparedContentImport | undefined;const imported = await importFromContent(engine, state.pins.slug, content, {sourceId: state.pins.source_id, sourcePath: state.snapshot.page.source_path ?? state.originSourcePath ?? undefined,- filename: basename(state.path).replace(/\.mdx?$/i, ''), noEmbed: true, remote: false, allowEmptyOverwrite: true,+ filename: basename(state.path).replace(/\.mdx?$/i, ''), noEmbed: true, remote: false, preserveGateMarkers: true, allowEmptyOverwrite: true,prepareFrontmatter: page => stabilizeSafetyAssessments(page.frontmatter, state.snapshot.page.frontmatter, state.pins.assessment_at),prepare: async prepared => { ready = prepared; return prepared.result; },});diff --git a/src/core/persistence/sync-prepare.ts b/src/core/persistence/sync-prepare.tsindex ef6da2f984..47fdecf412 100644--- a/src/core/persistence/sync-prepare.ts+++ b/src/core/persistence/sync-prepare.ts@@ -417,7 +417,7 @@ export async function prepareManagedSyncMutation(engine: BrainEngine, row: Write}let prepared: PreparedContentImport | undefined;// #6188: the import reuses this screen's fence verdict for the same bytes (one fence scan per file at prepare).- const importOptions = { ...source, noEmbed: true, remote: row.authority.remote, activePack, coordinated: true, fences: 'coordinated' as const,+ const importOptions = { ...source, noEmbed: true, remote: row.authority.remote, preserveGateMarkers: true, activePack, coordinated: true, fences: 'coordinated' as const,...(importContent === p.content && screen.status === 'importable' ? { fenceScreen: screen.fences ?? null } : {}),filename: basename(p.sourcePath).replace(/\.mdx?$/i, ''), sourcePath: p.sourcePath, allowEmptyOverwrite: true };const result = await importFromContent(engine, renamed?.slug ?? row.slug, importContent, { ...importOptions,diff --git a/src/core/quarantine-override.ts b/src/core/quarantine-override.tsindex 8348837d51..c174ec7533 100644--- a/src/core/quarantine-override.ts+++ b/src/core/quarantine-override.ts@@ -11,11 +11,11 @@* the override and the gate decides again. Size gates (oversize `embed_skip`)* are not overridden.*- * Trust: only trusted local callers set it. Every untrusted ingress strips it- * (`settleGateOwnedMarkers`, called by `importFromContent`, which remote put_page,- * put_pages, HTTP and ingest-capture all reach through `remote: true`); a- * remote edit that leaves title, type and body unchanged carries the stored- * override forward, so an unrelated tag edit does not re-hide the page.+ * Trust: only owner-tier paths (`preserveGateMarkers`) keep it; every other+ * writer, local or remote, has it stripped (`stripGateOwnedMarkers` in+ * import-screen.ts). An edit that leaves title, type and body unchanged+ * carries the stored override forward, so an unrelated tag edit does not+ * re-hide the page.* Company-brain inspection refuses files that carry it.*/import type { BrainEngine } from './engine.ts';@@ -24,8 +24,6 @@ import { parseMarkdown, type ParsedMarkdown } from './markdown.ts';import { sanitizeText } from './batch-rows.ts';import { sha256 } from './persistence/digest.ts';import { CONTENT_FLAG_KEY, QUARANTINE_KEY } from './quarantine.ts';-import { EMBED_SKIP_KEY } from './embed-skip.ts';-import { ATOMS_SCAN_HASH_KEY } from './utils.ts';export const QUARANTINE_OVERRIDE_KEY = 'quarantine_override';@@ -57,53 +55,25 @@ export function hasCurrentQuarantineOverride(page: Bound & { frontmatter?: Recorreturn !!override && override.binding === quarantineOverrideBinding(page);}-/**- * Called by `importFromContent` before the gate assesses `parsed` (already canonicalized).- *- * v0.42 (#1699 trust boundary): gate-owned markers are stripped from- * UNTRUSTED input. parseMarkdown preserves every frontmatter key except- * type/title/tags/slug, so a remote MCP put_page (ctx.remote !== false,- * threaded as opts.remote) could otherwise plant `quarantine` (hide a page- * from search + suppress chunks), `content_flag.detail` (inject text into the- * agent's trusted "this looks odd" channel) or `embed_skip` on clean content.- * #1699 part 2: the extract_atoms completion marker is phase-owned; a remote- * writer planting a matching one would suppress atom mining for the page.- * Trusted local sync/export round-trips keep them. Fail-closed: strip- * whenever `remote` is true.- *- * #6259: remote input also loses any `quarantine_override` (the gate may- * carry the stored one forward, `carryStoredQuarantineOverride`); trusted- * input keeps its own override only while it binds. A stale or malformed- * override is dropped, and a current one drops classifier markers the content- * still carries.- */-export function settleGateOwnedMarkers(parsed: ParsedMarkdown, remote: boolean): void {- if (remote) {- for (const key of [QUARANTINE_KEY, CONTENT_FLAG_KEY, EMBED_SKIP_KEY, ATOMS_SCAN_HASH_KEY, QUARANTINE_OVERRIDE_KEY]) delete parsed.frontmatter[key];- return;- }- if (Object.hasOwn(parsed.frontmatter, QUARANTINE_OVERRIDE_KEY) && !hasCurrentQuarantineOverride(parsed)) delete parsed.frontmatter[QUARANTINE_OVERRIDE_KEY];- dropClassifierMarkers(parsed);-}-/** A classifier marker the content still carries (a file written before the clear) goes with a current override. */-function dropClassifierMarkers(parsed: ParsedMarkdown): void {+export function dropClassifierMarkers(parsed: ParsedMarkdown): void {if (!hasCurrentQuarantineOverride(parsed)) return;delete parsed.frontmatter[QUARANTINE_KEY];if ((parsed.frontmatter[CONTENT_FLAG_KEY] as { reason?: unknown } | undefined)?.reason !== 'oversized') delete parsed.frontmatter[CONTENT_FLAG_KEY];}/**- * The gate verdict for a remote write: when the classifier would hide or+ * The gate verdict for a write whose gate-owned markers were stripped (every+ * caller except an owner-tier path): when the classifier would hide or* markup-flag the page, the stored override is carried forward if it still- * binds this exact title, type and body, so a remote edit that leaves them+ * binds this exact title, type and body, so an edit that leaves them* unchanged (a tag edit) does not re-hide a cleared page. The stored row is- * read only on that path, so a clean remote write costs no extra statement- * (#6007 statement budget).+ * read only on that path, so a clean write costs no extra statement (#6007+ * statement budget).*/export async function carryStoredQuarantineOverride(engine: Pick<BrainEngine, 'executeRaw'>, parsed: ParsedMarkdown, result: ContentSanityResult,- page: { slug: string; sourceId: string | undefined; remote: boolean }): Promise<ContentSanityResult> {- if (!page.remote || !(result.shouldQuarantine || result.flag_reason === 'markup_heavy')) return result;+ page: { slug: string; sourceId: string | undefined; stripped: boolean }): Promise<ContentSanityResult> {+ if (!page.stripped || !(result.shouldQuarantine || result.flag_reason === 'markup_heavy')) return result;const [stored] = await engine.executeRaw<{ override: unknown }>(`SELECT frontmatter->'${QUARANTINE_OVERRIDE_KEY}' AS override FROM pages WHERE source_id=$1 AND slug=$2 AND deleted_at IS NULL`, [page.sourceId ?? 'default', page.slug]);const carried = overrideOf(stored?.override);diff --git a/test/atoms-scan-hash-rearm.test.ts b/test/atoms-scan-hash-rearm.test.tsindex f99d15f1d2..d03f6ecdb7 100644--- a/test/atoms-scan-hash-rearm.test.ts+++ b/test/atoms-scan-hash-rearm.test.ts@@ -129,8 +129,9 @@ A perfectly normal note that has never actually been mined for atoms.`;expect(fm[ATOMS_SCAN_HASH_KEY]).toBeUndefined();});- test('trusted caller (remote unset) preserves the marker (export -> sync round trip)', async () => {- await importFromContent(engine, 'notes/trusted-scan-hash', planted, { noEmbed: true });+ // #6259: the export -> sync round trip is an owner-tier path; a call that does not say so strips the marker.+ test('an owner-tier caller (preserveGateMarkers) preserves the marker (export -> sync round trip)', async () => {+ await importFromContent(engine, 'notes/trusted-scan-hash', planted, { noEmbed: true, preserveGateMarkers: true });const page = await engine.getPage('notes/trusted-scan-hash'); // gbrain-allow-unscoped-getpageconst fm = page!.frontmatter as Record<string, unknown>;expect(fm[ATOMS_SCAN_HASH_KEY]).toBe('deadbeefdeadbeef');diff --git a/test/cli-input-plumbing-2822.test.ts b/test/cli-input-plumbing-2822.test.tsindex bd5ce54118..9d2625d35a 100644--- a/test/cli-input-plumbing-2822.test.ts+++ b/test/cli-input-plumbing-2822.test.ts@@ -131,15 +131,25 @@ describe('#2822 — chunk_skip_reason on 0-chunk puts', () => {expect(result.chunk_skip_reason).toBe('empty_body');});- test('embed_skip-marked content (trusted local) → embed_skip', async () => {+ test('oversized content the gate marks embed_skip → embed_skip', async () => {const result = (await putPage.handler(makeCtx(), {slug: 'inbox/skipped-embed',- content: '---\ntitle: Big\nembed_skip: true\n---\n\nSome body text that will not be chunked.',+ content: `---\ntitle: Big\n---\n\n${'Some prose that keeps going past the block threshold. '.repeat(10_000)}`,})) as { chunks: number; chunk_skip_reason?: string };expect(result.chunks).toBe(0);expect(result.chunk_skip_reason).toBe('embed_skip');});+ // #6259: a local put_page is not an owner-tier path, so an embed_skip it plants is stripped.+ test('an embed_skip marker planted by a local put_page is stripped and the page chunks', async () => {+ const result = (await putPage.handler(makeCtx(), {+ slug: 'inbox/planted-skip',+ content: '---\ntitle: Big\nembed_skip: true\n---\n\nSome body text that a planted marker must not hide.',+ })) as { chunks: number; chunk_skip_reason?: string };+ expect(result.chunks).toBeGreaterThan(0);+ expect(result.chunk_skip_reason).toBeUndefined();+ });+test('normal content chunks → no chunk_skip_reason', async () => {const result = (await putPage.handler(makeCtx(), {slug: 'inbox/normal',diff --git a/test/gate-marker-strip.test.ts b/test/gate-marker-strip.test.tsnew file mode 100644index 0000000000..35a01c3faa--- /dev/null+++ b/test/gate-marker-strip.test.ts@@ -0,0 +1,77 @@+/**+ * #6259 follow-up (quarantine leaks, item 1): gate-owned frontmatter markers+ * are stripped from every writer unless an owner-tier path passes+ * `preserveGateMarkers`. The strip used to run only for `remote: true`, so a+ * connector-shaped import, a local put_page or a call with neither flag could+ * hide a page (`quarantine`), forge a cleared state (`quarantine_override`),+ * stop its embedding (`embed_skip`) or suppress atom mining (`atoms_scan_hash`).+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import type { OperationContext } from '../src/core/ops/contract.ts';+import { operations } from '../src/core/operations.ts';+import { importFromContent, importFromFile } from '../src/core/import-file.ts';+import { GATE_OWNED_FRONTMATTER_KEYS, stripGateOwnedMarkers } from '../src/core/import-screen.ts';+import { withEnv } from './helpers/with-env.ts';++const PLANTED = `quarantine:\n reason: junk_pattern\n detail: planted\nembed_skip:\n reason: oversized\natoms_scan_hash: deadbeefdeadbeef\nquarantine_override:\n binding: ${'a'.repeat(64)}\n cleared_at: 2026-10-07T00:00:00.000Z\n`;+const page = (title: string) => `---\ntitle: ${title}\ntype: note\n${PLANTED}---\n\nA perfectly normal note with real prose and nothing wrong with it.\n`;++let engine: PGLiteEngine;+const home = mkdtempSync(join(tmpdir(), 'gbrain-gate-strip-'));+const env = { GBRAIN_HOME: home, GBRAIN_AUDIT_DIR: home };+beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); });+afterAll(async () => { await engine.disconnect(); rmSync(home, { recursive: true, force: true }); });++const frontmatter = async (slug: string) => (await engine.getPage(slug, { sourceId: 'default' }))!.frontmatter as Record<string, unknown>;+const expectStripped = async (slug: string) => {+ const fm = await frontmatter(slug);+ for (const key of GATE_OWNED_FRONTMATTER_KEYS) expect({ key, value: fm[key] }).toEqual({ key, value: undefined });+ expect((await engine.getChunks(slug, { sourceId: 'default' })).length).toBeGreaterThan(0);+};++describe('writers that are not owner-tier cannot plant gate-owned markers', () => {+ test('a call with neither flag', () => withEnv(env, async () => {+ await importFromContent(engine, 'notes/no-flag', page('No flag'), { noEmbed: true });+ await expectStripped('notes/no-flag');+ }));++ test('a connector-shaped import', () => withEnv(env, async () => {+ await importFromContent(engine, 'notes/connector', page('Connector'), { noEmbed: true, sourcePath: 'connector/item.md',+ source_kind: 'connector', source_uri: 'https://example.invalid/item/1', ingested_via: 'connector_sync' });+ await expectStripped('notes/connector');+ }));++ test('a local put_page', () => withEnv(env, async () => {+ const ctx = { engine, config: { engine: 'pglite' }, logger: { info() {}, warn() {}, error() {} }, dryRun: false, remote: false,+ sourceId: 'default', deferEmbeds: true } as unknown as OperationContext;+ await operations.find(o => o.name === 'put_page')!.handler(ctx, { slug: 'notes/local-put', content: page('Local put') });+ await expectStripped('notes/local-put');+ }));+});++describe('owner-tier paths keep them', () => {+ test('an owner file import (importFromFile) keeps every marker but a stale override', () => withEnv(env, async () => {+ const dir = join(home, 'brain'); mkdirSync(join(dir, 'notes'), { recursive: true });+ writeFileSync(join(dir, 'notes', 'owner-file.md'), page('Owner file'));+ await importFromFile(engine, join(dir, 'notes', 'owner-file.md'), 'notes/owner-file.md', { noEmbed: true });+ const fm = await frontmatter('notes/owner-file');+ expect(fm.quarantine).toMatchObject({ detail: 'planted' });+ expect(fm.atoms_scan_hash).toBe('deadbeefdeadbeef');+ // (A stale oversized embed_skip on a small page is the gate's own recovery case, so it is not asserted here.)+ // The planted override binds nothing on this page, so even an owner path drops it.+ expect(fm.quarantine_override).toBeUndefined();+ }));++ test('preserveGateMarkers keeps them; the helper strips exactly the gate-owned keys otherwise', () => withEnv(env, async () => {+ await importFromContent(engine, 'notes/owner-flag', page('Owner flag'), { noEmbed: true, preserveGateMarkers: true });+ expect((await frontmatter('notes/owner-flag')).atoms_scan_hash).toBe('deadbeefdeadbeef');+ const parsed = { title: 't', type: 'note', compiled_truth: 'b', timeline: '', frontmatter: { quarantine: {}, content_flag: {}, embed_skip: {},+ atoms_scan_hash: 'x', quarantine_override: {}, kept: 1 } as Record<string, unknown> };+ stripGateOwnedMarkers(parsed as never, {});+ expect(parsed.frontmatter).toEqual({ kept: 1 });+ }));+});diff --git a/test/import-file-content-sanity.test.ts b/test/import-file-content-sanity.test.tsindex 29d183339a..e8ab76cb3b 100644--- a/test/import-file-content-sanity.test.ts+++ b/test/import-file-content-sanity.test.ts@@ -346,7 +346,7 @@ describe('importFromContent — stale size-gate recovery', () => {test('with the sanity gate bypassed (GBRAIN_NO_SANITY=1) a stale oversized marker is left alone', async () => {await withIsolatedHome(async () => withEnv({ GBRAIN_NO_SANITY: '1' }, async () => {const content = FRONTMATTER.replace('---\n\n', 'embed_skip:\n reason: oversized\n---\n\n') + 'A small useful note.';- await importFromContent(engine, 'notes/bypassed', content, { noEmbed: true, remote: false });+ await importFromContent(engine, 'notes/bypassed', content, { noEmbed: true, remote: false, preserveGateMarkers: true });expect(isEmbedSkipped((await engine.getPage('notes/bypassed'))!.frontmatter)).toBe(true);expect((await engine.getChunks('notes/bypassed')).length).toBe(0);}));@@ -355,7 +355,7 @@ describe('importFromContent — stale size-gate recovery', () => {test('unknown local skip reasons stay skipped', async () => {await withIsolatedHome(async () => {const content = FRONTMATTER.replace('---\n\n', 'embed_skip:\n reason: manual\n---\n\n') + 'A small useful note.';- await importFromContent(engine, 'notes/manual-skip', content, { noEmbed: true, remote: false });+ await importFromContent(engine, 'notes/manual-skip', content, { noEmbed: true, remote: false, preserveGateMarkers: true });expect(isEmbedSkipped((await engine.getPage('notes/manual-skip'))!.frontmatter)).toBe(true);expect((await engine.getChunks('notes/manual-skip')).length).toBe(0);});@@ -421,7 +421,9 @@ A perfectly normal note with real prose and nothing wrong with it.`;});});- test('trusted caller (remote unset) preserves a user-authored marker', async () => {+ // #6259: only an owner-tier path (sync or import of the owner's own file) keeps gate markers;+ // a call that does not say so strips them (test/gate-marker-strip.test.ts).+ test('an owner-tier caller (preserveGateMarkers) preserves a user-authored marker', async () => {await withIsolatedHome(async () => {// A local user deliberately editing their own file is trusted.const content = `---@@ -433,7 +435,7 @@ content_flag:---my own note.`;- await importFromContent(engine, 'notes/mine', content, { noEmbed: true });+ await importFromContent(engine, 'notes/mine', content, { noEmbed: true, preserveGateMarkers: true });const page = await engine.getPage('notes/mine');expect(getContentFlag(page!.frontmatter as Record<string, unknown>)?.reason).toBe('markup_heavy');});diff --git a/test/ingestion/ingest-capture.test.ts b/test/ingestion/ingest-capture.test.tsindex b9397930b6..677a6590a8 100644--- a/test/ingestion/ingest-capture.test.ts+++ b/test/ingestion/ingest-capture.test.ts@@ -686,10 +686,11 @@ describe('ingest_capture handler — write-source attribution', () => {expect(updated.status).not.toBe('error');});- test('a trusted daemon event KEEPS gate-owned markers (stripping is untrusted-only)', async () => {- // The mirror of the case above: local/trusted emitters own these markers- // (the quarantine CLI and the sanity gate write them), so stripping must be- // conditioned on the event's trust flag, not applied unconditionally.+ test('a trusted daemon event cannot plant gate-owned markers either (#6259)', async () => {+ // Gate-owned markers are stripped from every writer except an owner-tier+ // path (sync/import of the owner's files, reindex, repair, reconcile, the+ // cycle derivers, quarantine clear); an ingest lane is not one, whatever+ // the event's trust flag says.await engine.executeRaw(`INSERT INTO sources (id, name) VALUES ('trusted-marker-source', 'trusted-marker-source')`,);@@ -706,7 +707,7 @@ describe('ingest_capture handler — write-source attribution', () => {`SELECT frontmatter FROM pages WHERE slug = $1`,['inbox/trusted-markers'],);- expect((rows[0]?.frontmatter ?? {}).quarantine).toBe(true);+ expect((rows[0]?.frontmatter ?? {}).quarantine).toBeUndefined();});});diff --git a/test/quarantine-override.serial.test.ts b/test/quarantine-override.serial.test.tsindex 0cecf65738..19a78bca07 100644--- a/test/quarantine-override.serial.test.ts+++ b/test/quarantine-override.serial.test.ts@@ -126,6 +126,15 @@ describe('quarantine clear on a managed brain (#6259)', () => {expect(fm[QUARANTINE_OVERRIDE_KEY]).toBeUndefined();}), 120_000);+ test('a local managed put_page cannot plant gate-owned markers (only the clear\'s owner kind keeps its override)', () => run(async () => {+ const clean = '---\ntitle: Clean notes\ntype: note\nquarantine:\n reason: junk_pattern\n detail: planted\natoms_scan_hash: deadbeefdeadbeef\n---\n\nOrdinary prose with nothing junk-like in it.\n';+ const slug = 'notes/planted-managed';+ await submitPageMutation(ctx(), { operation: 'put_page', params: { slug, content: clean, request_id: randomUUID() } });+ const fm = (await engine.getPage(slug, { sourceId: 'default' }))!.frontmatter as Record<string, unknown>;+ expect(fm.quarantine).toBeUndefined();+ expect(fm.atoms_scan_hash).toBeUndefined();+ }), 120_000);+test('an edit landing after the clear read the page is a revision conflict, not an overwrite', () => run(async () => {const original = engine.readPageSnapshot.bind(engine);let raced = false, inside = false;