Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(dream): a replayed synthesis output is verified against the current transcript, not stamped verification-deferred (#6757)
garrytan6d22a2dec876
diff --git a/docs/architecture/key-files/core-cycle-continued.md b/docs/architecture/key-files/core-cycle-continued.mdindex ee980a7fe6..3e0ec792c6 100644--- a/docs/architecture/key-files/core-cycle-continued.md+++ b/docs/architecture/key-files/core-cycle-continued.md@@ -5,7 +5,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGELSynthesis, patterns, consolidation and connector atom gating.- `src/core/cycle/synthesize-postprocess.ts` — Managed synthesis quote repair and provenance stamping publish together through a deterministic maintenance request bound to the source incarnation, transcript hash, child output, and original committed page revision. `loadCommittedSynthesisOutputs` finds each child's committed output by canonicalizing the retained `brain_put_page` input (`parseWriteRequestId` for the request id, `journaledPageSlug` for the slug) before matching request id, source, incarnation, committed put_page, slug and revision (#6616); slug discovery (`collectChildPutPageSlugs`) and postprocessing share that set. The immutable committed receipt is the completion checkpoint: later runs skip finalized output rather than repairing user edits. Pending work replays its retained intent under the original revision and existing authority/file guards; missing provenance fails closed. A publish still `write_pending` after the job's shared maintenance wait is deferred, never written or finalized: `withPublishPending` turns the phase result into `warn` with `publish_pending` and `SYNTH_PUBLISH_DEFERRED` ("publish deferred (writer busy); finishes next cycle, no action needed"), `synthesize.ts` leaves `dream.synthesize.last_completion_ts` unstamped, and the next ordinary cycle resumes the same deterministic request id. Runs the same claim verification as the unmanaged path (`groundSource` + `resolveVerifyPrior` + `verifyDreamPage` from `synthesize-verify.ts`, scoped by the ref's `first_write_at`, else the child write epochs passed as `sinceByTranscript`) and stamps the dream provenance fields only on dream-owned pages (`isDreamOwnedPage`); the published page reconciles its automatic links like an ordinary put_page (`page-prepare.ts` treats `managed_maintenance_page` intents as auto-linked); the unmanaged path retains its fail-open behavior. Covered by `test/managed-synthesis-postprocess.test.ts` and its PostgreSQL E2E wrapper. The optional `grounding` pass (System One S8) runs after `verifyDreamPage` and before `publishMaintenancePage`, so the published revision never carries a unit S8 quarantined; pinned by `test/decide/writepath-phase.serial.test.ts`. The postprocess stamps the transcript's `seat` next to `raw_source` on dream-owned output. `deferPublishOrThrow` defers an output or summary publish that is still pending or whose admission gave up on database contention (`publicationHold` in `persistence/accepted-pending.ts`, one stderr line per contended publish) exactly like the pending case: `publish_pending`, phase warn, no cooldown stamp; every other error fails the phase. Pinned by `test/managed-synthesis-postprocess.test.ts`. #5575 I2: each output publishes with `derivation` from its transcript (`dream-taint.ts` `transcriptDerivation`; `meetingTranscriptsDir` in opts); a retained request replays the declaration it was admitted with. #6360: when the page moved after the child commit, a drift made only by committed local `managed_maintenance_page` requests (for example the next cycle's lint `created:` fix) over a body equal to the child's is adopted: the postprocess runs on the current snapshot under a request id that also binds that base revision (found again on replay among the later requests). Any other later write leaves the page alone as a `PostprocessConflict` (`withPostprocessConflicts`: phase `warn`, `details.postprocess_conflicts` with the read-only `gbrain get` fix); it is reported once (config `dream.synthesize.postprocess_conflicts`, 30-day memory) and does not block the cooldown stamp. #6757: the committed-outputs join (`COMMITTED_OUTPUT_REQUESTS_SQL`) compares `request_id` as a uuid within the source, served by `persistence_requests_request_id`. The phase loads it through `loadCommittedOutputsOrDefer`; a statement timeout there, or on an output's own `getWriteRequest`, defers the pass instead of failing it (`withPublishPending` with `details.postprocess_deferred`: phase warn, no cooldown stamp, no summary). Deferred and publish-pending outputs are carried by `synthesize-postprocess-deferral.ts` and finished by a later pass from the carried fields, with no child; `finishDeferredPostprocess` (run after the phase body by `runPhaseSynthesize`) finishes them when that pass returned before postprocessing.-- `src/core/cycle/synthesize-postprocess-deferral.ts` — #6757: config row `dream.synthesize.postprocess_pending`, keyed by source and bound to its incarnation: each pending output (child request id, journaled and input slug, revision, job key, transcript path, content hash, seat, first write) and the source's consecutive deferred passes with the last read and its elapsed time. `isPostprocessReadTimeout` unwinds a cancelled cycle first, then accepts only SQLSTATE 57014 with the statement-timeout message (a user cancel is not deferred). `recordPostprocessPass` drops settled outputs, adds deferred and carried ones and resets the count on a pass that deferred nothing; `repeatedPostprocessDeferrals` lists sources at three or more for doctor `persistence_request_indexes`. The replay runs no child job; a replayed output whose transcript no longer hashes to the one it was synthesized from is not quote-verified against the rewritten file but stamped `quote_verification: verification-deferred` (`details.verification_deferred` on a replay-only pass).+- `src/core/cycle/synthesize-postprocess-deferral.ts` — #6757: config row `dream.synthesize.postprocess_pending`, keyed by source and bound to its incarnation: each pending output (child request id, journaled and input slug, revision, job key, transcript path, content hash, seat, first write) and the source's consecutive deferred passes with the last read and its elapsed time. `isPostprocessReadTimeout` unwinds a cancelled cycle first, then accepts only SQLSTATE 57014 with the statement-timeout message (a user cancel is not deferred). `recordPostprocessPass` drops settled outputs, adds deferred and carried ones and resets the count on a pass that deferred nothing; `repeatedPostprocessDeferrals` lists sources at three or more for doctor `persistence_request_indexes`. The replay runs no child job and verifies a replayed output's quotes against the transcript as it is now, even when it grew after synthesis; a quote not found there goes to `unverified_claims` like any failed quote.- `src/core/cycle/patterns.ts` — Patterns phase: cross-session theme detection over reflections within `dream.patterns.lookback_days` (default 30). Names a pattern only when ≥`dream.patterns.min_evidence` (default 3) reflections support it. Reflection excerpts use the shared UTF-16-safe truncator; a raw `.slice(0, 600)` can split an emoji pair and make Postgres reject the subagent job's JSONB payload. Single Sonnet subagent; same allow-list path as synthesize (imports `loadAllowedSlugPrefixes` + `loadOutputRoot` from synthesize.ts — the reflections lookup, prompt slug templates, and allow-list all honor `dream.synthesize.output_root`, default 'wiki'). Subagent job/wait timeouts are config keys `dream.patterns.subagent_timeout_ms` / `dream.patterns.subagent_wait_timeout_ms` (defaults 30/35 min, mirroring the `dream.synthesize.*` pair). The phase status reflects the child outcome: non-`completed` outcome with zero writes → `fail` (error code `PATTERNS_CHILD_<OUTCOME>`); non-`completed` with partial writes → `warn`. Runs AFTER `extract` so the graph is fresh. The fan-out sets `require_writes: true` so an all-writes-failed child dead-letters instead of reporting completed. Budget clamping: clamped to the remaining parent-job budget via `clampSubagentBudgets` when the cycle threads `deadlineAtMs` — the clamp template synthesize.ts reuses; `MIN_PATTERNS_SUBAGENT_BUDGET_MS` gates an honest skip, and `CYCLE_DEADLINE_RESERVE_MS` is re-exported here from its base-phase.ts home. Evidence watermark: a `completed` child stamps the newest consumed reflection `updated_at` into the state row `dream.patterns.last_evidence_ts` (never `now()`; fail/warn/timeout paths don't stamp, so a dead child retries next tick), and a later run skips `no_new_evidence` while no reflection in the window is newer — autopilot's hourly global tick becomes a free skip until a reflection actually changes; an absent/unparseable stamp fails open; `--once` bypasses the gate but a completed forced run still stamps. Managed local evidence is source-incarnation-scoped and live/non-private; unchanged evidence coalesces the admitted child request instead of inventing a remote maintenance grant. Maintenance runs (the only keyed patterns runs) consult the paid-loop breaker before submission and skip with `dream_breaker_tripped`. A managed grounding publish or provenance stamp that is accepted-but-pending or rolled back by admission contention is held (`publishOrHold`): a held page is not provenance-stamped, it is left out of `patterns_written` and of `verifyMaintenanceOutputs` (only for refs in the cycle's own source, so a ref in another source is always verified), `publish_deferred` counts held pages, the phase returns `warn`, and the evidence watermark stays unstamped so the next cycle retries; other publication errors still fail. `groundPatternPages` holds only when its caller passes the `heldSlugs` set; direct callers keep the throwing behavior. Pages the child wrote under `dream.patterns.output_slug_prefix` get the dream-output identity stamp (`dream_generated`, `dream_cycle_date`, `dream_created_cycle_date`) before the reverse-write: through `stampMaintenancePage` on a managed brain, through `stampDreamProvenance` (`dream-provenance.ts`) otherwise. A pattern page also gets `seat` when every input reflection carries the same seat, and none otherwise; the managed submission key digests the reflections without their seats. Quote grounding (`groundPatternPages`, `dream.quote_verify`, default on): right after the subagent's writes and before provenance stamping, pattern pages are checked against the full reflection pages with `verifyBody(…, { checks: 'quotes' })`; failing units move to frontmatter `unverified_claims`, `quote_verified_at` marks the page, and pages a crashed run left without it are verified on the next run. Write-back goes through `publishMaintenancePage` on managed brains, else `importFromContent`. Phase details carry `quote_verify` counts. Pinned by `test/cycle-patterns-quote-verify.test.ts`. #6177: `cycle/patterns-plan.ts` — every child records `dream.patterns.last_run` (`{duration_ms, reflections, at, outcome, budget_skips}`, DB-only state; `config set` refuses it, `config unset` resets it) and pure `planPatternsRun` sizes an in-cycle run from it (1.25× margin; a timeout halves the next submission; no usable history → first batch of max(25, min_evidence); 3 budget skips or a 7-day-old record → a min_evidence probe; below min_evidence → skip `insufficient_cycle_budget` with `cause: budget_below_recent_runtime` before any submit); the newest n reflections are submitted; direct runs (no deadline) keep full size. Guide: `docs/guides/dream-patterns.md`; tests `test/cycle-patterns-plan.test.ts`. Quarantined claim records store the run's reflection list once per page in `unverified_claim_sources` and reference it (`cycle/pattern-claim-sources.ts`: `withClaimSources`, `resolveClaimSources` recovers every path); before submitting the child the phase de-duplicates pages still carrying inline lists (`dedupePatternClaimSources`, frontmatter-only maintenance writes) and skips as `pattern_claims_pending`, with no child and no model call, while any rewrite is held (`test/cycle-patterns-quote-verify.test.ts`, `test/managed-maintenance.test.ts`). #5575 ENG-3 partition: `gatherReflections` reads each reflection's `trust_tier` (`ReflectionRef.taint`, never in the submission key); `runPhasePatterns` runs the owner pass (`runPatternsPass`) over every non-external reflection and, when the external_untrusted reflections reach `min_evidence` on their own, a separate pass with watermark `<evidence key>.external`; `details.reflections_external`, `details.external_pass`, and `patterns_written` sums both. Each pass's outputs are written back (grounding publish or `importFromContent`, provenance stamp) at `patternsDerivation(submitted)` with edges to that pass's reflections. Pinned by `test/trust-taint-dream.test.ts`. #6302: `collectChildTimelineAppends` selects the entries the child newly published with `brain_add_timeline_entry` by write receipt (`persistence_requests` committed with outcome status `ok`, joined on the call's input `request_id`), once per request id and per entry identity, so a replay or a re-append of an existing entry (`skipped`) is not a new append. On pages the child did not `put_page`, `groundTimelineAppends` quote-verifies only those entry blocks against this run's reflections: a failing entry (with its materialized marker line) leaves the timeline for `unverified_claims` (its timeline row is deleted on the import path; a managed publish projects rows from the Markdown), a near/normalized quote is repaired in place, and everything else on the page, `quote_verified_at` and stored claim sources included, is kept. Those pages are provenance-stamped, reverse-written and counted in `patterns_written`; `details.timeline_appends` counts the entries and `quote_verify.timeline_appends` the grounding. `details.appended_unverified` (`countChildTimelineAppends`, completed calls) is a deprecated alias. Segmented storage: `loadGroundingSources` reads a segmented reflection through `materializeSegmentedBody` (over `PAGE_MAX_BYTES` it is not a source, logged), and `groundTimelineAppends` reads pattern pages through `materializedSnapshot`, skipping an over-ceiling page (`segmented_skipped`). Pinned by `test/cycle-patterns-timeline-appends.serial.test.ts` and `test/cycle-patterns-segmented.test.ts` (both engines). #6296: `recordPatternsLastRun` maps a `dead` child whose error is `timeout exceeded` / `wall-clock timeout exceeded` to `timeout`. #6297: an in-cycle run (not `--once`, not a direct `--phase patterns`, `CycleOpts.directPhases`) is skipped with `patterns_min_interval` while the partition's last COMPLETED child ended less than `dream.patterns.min_interval_hours` (default 6, 0 off) ago (`patternsCadenceSkip` in `patterns-plan.ts`; stamp `dream.patterns.last_completed_at.<source>.<incarnation>`, `.external` for the external partition), and the child gets `read_budget_bytes` from `dream.patterns.child_read_budget_kb` (default 200). Pinned by `test/cycle-patterns-cadence.serial.test.ts` and `test/cycle-patterns-read-budget.serial.test.ts`. #6779: the OUTPUT POLICY tells the child to keep an existing page's slug, skip it when its evidence covers the pattern, else rewrite it with get_page's `revision` as `expected_revision`, and to append with `add_timeline_entry` or skip a `read_budget_exhausted` summary (`test/cycle-patterns-revision-6779.test.ts`).- `src/core/cycle/drift.ts` report publication (#6052): a managed drift report whose publish is held (`publishOrHold`) is not linked in the detail, `reports_written` is 0 and `publish_deferred` 1, the detail names the hold (accepted and still publishing, or not admitted under database contention), and the phase is `partial`; every other publish error still throws.diff --git a/src/core/cycle/synthesize-postprocess.ts b/src/core/cycle/synthesize-postprocess.tsindex c483b415aa..05f20f2c6a 100644--- a/src/core/cycle/synthesize-postprocess.ts+++ b/src/core/cycle/synthesize-postprocess.ts@@ -1,4 +1,3 @@-import { createHash } from 'node:crypto';import { readFileSync } from 'node:fs';import type { BrainEngine } from '../engine.ts';import { throwIfAborted } from '../abort-check.ts';@@ -135,35 +134,23 @@ export async function loadCommittedOutputsOrDefer(engine: BrainEngine, authority/** A transcript as postprocessing reads it: the discovered one, or a carried output's file read again (#6757). */type TranscriptInput = Pick<DiscoveredTranscript, 'filePath' | 'contentHash' | 'content' | 'seat'>;-/** `drifted`: a replayed output whose transcript no longer has the hash it was synthesized from (#6757). */-interface Item { ref: OutputRef; output?: RetainedOutput; path?: string; transcript?: TranscriptInput; hash?: string; drifted?: boolean }+interface Item { ref: OutputRef; output?: RetainedOutput; path?: string; transcript?: TranscriptInput; hash?: string }const pendingOf = (item: Item): PendingOutput[] => item.output && item.path && item.hash && typeof item.output.request.outcome?.revision === 'string'? [{ request_id: String(item.output.request.request_id), slug: item.output.request.slug, input_slug: item.output.input_slug,revision: item.output.request.outcome.revision, job_key: item.output.job_key, raw_source: item.path, transcript_hash: item.hash,...(item.transcript?.seat ? { seat: item.transcript.seat } : {}), ...(item.ref.first_write_at ? { first_write_at: item.ref.first_write_at.toISOString() } : {}) }] : [];-/**- * A carried output's transcript: the one discovered this pass at its path, else its file; null for one no longer- * readable. `drifted` when its current content no longer hashes to the transcript the output was synthesized from:- * the replay then never grounds the output against the rewritten file (a file read raw compares its raw hash, so a- * filtered .txt can read as drifted; that only defers verification).- */-function carriedTranscript(p: PendingOutput, byPath: Map<string, DiscoveredTranscript>): (TranscriptInput & { drifted: boolean }) | null | undefined {+/** A carried output's transcript: the one discovered this pass at its path, else its file; null for one no longer readable. */+function carriedTranscript(p: PendingOutput, byPath: Map<string, DiscoveredTranscript>): TranscriptInput | null | undefined {const found = byPath.get(p.raw_source);- if (found) return { ...found, drifted: found.contentHash !== p.transcript_hash };+ if (found) return found;// A conversation page is discovered from the database, never read here; it stays pending until a pass discovers it.if (!p.raw_source.startsWith('/')) return undefined;- try {- const content = readFileSync(p.raw_source, 'utf8');- const drifted = createHash('sha256').update(content, 'utf8').digest('hex') !== p.transcript_hash;- return { filePath: p.raw_source, contentHash: p.transcript_hash, content, drifted, ...(p.seat ? { seat: p.seat } : {}) };- } catch { return null; }+ try { return { filePath: p.raw_source, contentHash: p.transcript_hash, content: readFileSync(p.raw_source, 'utf8'), ...(p.seat ? { seat: p.seat } : {}) }; }+ catch { return null; }}-/** Frontmatter stamp of a replayed output whose transcript changed after synthesis: its quotes were not verified. */-export const VERIFICATION_DEFERRED = 'verification-deferred';-export async function postprocessManagedSynthesis(engine: BrainEngine,authority: MaintenanceAuthority,@@ -181,7 +168,6 @@ export async function postprocessManagedSynthesis(const writtenRefs: OutputRef[] = [];const finalizedRefs: OutputRef[] = [];const conflicts: PostprocessConflict[] = [];- const verificationDeferred: string[] = [];let pending = 0;const { sourceId, sourceIncarnation } = authority.writer;// #6757: outputs an earlier pass deferred are finished here, whether or not their child is in this pass.@@ -190,9 +176,9 @@ export async function postprocessManagedSynthesis(let deferred: CommittedOutputs['deferred'];if (opts.committedOutputs?.deferred) {const deferral = await recordPostprocessPass(engine, sourceId, sourceIncarnation, { settled, deferred: opts.committedOutputs.deferred });- return { writtenRefs, finalizedRefs, stats, pending: deferral?.outputs ?? 0, conflicts, deferral, verificationDeferred };+ return { writtenRefs, finalizedRefs, stats, pending: deferral?.outputs ?? 0, conflicts, deferral };}- if (!refs.length && !carried.length) return { writtenRefs, finalizedRefs, stats, pending, conflicts, deferral: null, verificationDeferred };+ if (!refs.length && !carried.length) return { writtenRefs, finalizedRefs, stats, pending, conflicts, deferral: null };const reported = await readReportedConflicts(engine);const supersession = opts.quoteVerify ? await attributionChecksEnabled(engine) : false; // #5425 [UC4], default offconst outputs = opts.committedOutputs?.outputs ?? await loadCommittedSynthesisOutputs(engine, authority, childIds);@@ -226,7 +212,7 @@ export async function postprocessManagedSynthesis(continue;}items.push({ ref: { slug: output.request.slug, source_id: sourceId, raw_source: p.raw_source, ...(p.seat ? { seat: p.seat } : {}),- ...(p.first_write_at ? { first_write_at: new Date(p.first_write_at) } : {}) }, output, path: p.raw_source, transcript, hash: p.transcript_hash, drifted: transcript.drifted });+ ...(p.first_write_at ? { first_write_at: new Date(p.first_write_at) } : {}) }, output, path: p.raw_source, transcript, hash: p.transcript_hash });}}// #6757: a statement timeout on this request's own read defers it and every output after it.@@ -241,7 +227,7 @@ export async function postprocessManagedSynthesis(}};let grounded: GroundedSource | undefined;- for (const [index, { ref, output, path, transcript, hash, drifted }] of items.entries()) {+ for (const [index, { ref, output, path, transcript, hash }] of items.entries()) {throwIfAborted(opts.signal, '[dream] synthesis postprocessing');if (ref.source_id !== authority.writer.sourceId) {throw opError('source_changed', 'The synthesis output source changed.',@@ -310,12 +296,7 @@ export async function postprocessManagedSynthesis(const since = ref.first_write_at ?? opts.sinceByTranscript.get(transcript.filePath);let page = isDreamOwnedPage(snapshot.page, since) ? { ...snapshot.page, frontmatter: { ...snapshot.page.frontmatter, dream_generated: true,dream_cycle_date: firstDate, dream_created_cycle_date: firstDate, raw_source: path, ...(transcript.seat ? { seat: transcript.seat } : {}) } } : snapshot.page;- if (opts.quoteVerify && drifted) {- // #6757: the transcript changed after this output was synthesized; grounding it against the rewritten file- // could quarantine quotes the original said, so its quotes stay unverified and the page says so.- page = { ...page, frontmatter: { ...page.frontmatter, quote_verification: VERIFICATION_DEFERRED } };- verificationDeferred.push(ref.slug);- } else if (opts.quoteVerify) {+ if (opts.quoteVerify) {const prior = since ? await resolveVerifyPrior(engine, snapshot.page, ref.source_id, since) : null;if (prior === 'unchanged') stats.skipped_unchanged++;else {@@ -351,10 +332,7 @@ export async function postprocessManagedSynthesis(if (deferred?.read === 'postprocess_request') pending += items.length - readsFrom;if (conflicts.length) await rememberConflicts(engine, reported, conflicts);const deferral = await recordPostprocessPass(engine, sourceId, sourceIncarnation, { settled, carry, deferred });- if (verificationDeferred.length) {- process.stderr.write(`[dream] synthesize: ${verificationDeferred.length} replayed output page(s) stamped quote_verification: ${VERIFICATION_DEFERRED}; their transcript changed after synthesis, so their quotes were not verified against the rewritten file: ${verificationDeferred.join(', ')}\n`);- }- return { writtenRefs, finalizedRefs, stats, pending, conflicts, deferral, verificationDeferred };+ return { writtenRefs, finalizedRefs, stats, pending, conflicts, deferral };}async function readReportedConflicts(engine: BrainEngine): Promise<Map<string, string>> {@@ -437,7 +415,6 @@ export async function finishDeferredPostprocess(engine: BrainEngine,const written = processed.writtenRefs.map(r => r.slug);const resumed = written.length ? { ...result, summary: `${result.summary}; ${written.length} deferred output page(s) postprocessed`,details: { ...result.details, pages_written: Number(result.details?.pages_written ?? 0) + written.length,- written_slugs: [...(Array.isArray(result.details?.written_slugs) ? result.details.written_slugs as string[] : []), ...written], postprocess_resumed: written,- ...(processed.verificationDeferred.length ? { verification_deferred: processed.verificationDeferred } : {}) } } : result;+ written_slugs: [...(Array.isArray(result.details?.written_slugs) ? result.details.written_slugs as string[] : []), ...written], postprocess_resumed: written } } : result;return withPostprocessConflicts(processed.conflicts, withPublishPending(processed.pending, resumed, processed.deferral));}diff --git a/test/managed-synthesis-postprocess.test.ts b/test/managed-synthesis-postprocess.test.tsindex eb0cbb4835..934090f0b2 100644--- a/test/managed-synthesis-postprocess.test.ts+++ b/test/managed-synthesis-postprocess.test.ts@@ -758,7 +758,7 @@ const quietly = async <T>(fn: () => Promise<T>): Promise<T> => {try { return await fn(); } finally { write.mockRestore(); }};-test('#6757: a committed-outputs read past the statement timeout defers the pass; after the transcript grows and the child rows are pruned, the replay itself runs zero child jobs and stamps the output verification-deferred instead of grounding it against the rewritten file', async () => {+test('#6757: a committed-outputs read past the statement timeout defers the pass; after the transcript grows and the child rows are pruned, the replay itself runs zero child jobs and verifies the output\'s quotes against the current transcript', async () => {await fixture(async ({ engine, sourceId, root, opts, calls }) => {const timeout = failCommittedOutputsRead(engine);let deferred: Awaited<ReturnType<typeof runPhaseSynthesize>>;@@ -798,12 +798,12 @@ test('#6757: a committed-outputs read past the statement timeout defers the passexpect(await engine.executeRaw("SELECT id FROM minion_jobs WHERE name = 'subagent' AND data->>'source_id'=$1", [sourceId])).toEqual([]);expect(next.details.postprocess_resumed).toEqual([slug]);expect(next.details.written_slugs).toEqual([slug]);- expect(next.details.verification_deferred).toEqual([slug]);const stamped = (await engine.readPageSnapshot(slug, { sourceId }))!.page;expect(stamped.frontmatter.dream_generated).toBe(true);- expect(stamped.frontmatter.quote_verification).toBe('verification-deferred');- expect(stamped.frontmatter.quote_verified_at).toBeUndefined();- expect(stamped.compiled_truth).toContain('"an entirely invented');+ // The grown transcript still lacks the invented quotation, so it fails grounding the way any unfound quote does.+ expect(stamped.compiled_truth).not.toContain('"an entirely invented');+ expect(stamped.frontmatter.unverified_claims).toEqual([expect.objectContaining({ reason: 'quote_not_in_source', detail: 'an entirely invented quotation that should lose its marks' })]);+ expect(stamped.frontmatter.quote_verification).toBeUndefined();expect(readFileSync(join(root, `${slug}.md`), 'utf8')).toContain('dream_generated: true');expect(JSON.parse(await engine.getConfig(POSTPROCESS_PENDING_KEY) ?? '{}')[sourceId]).toBeUndefined();});