Files
Garry TanandClaude Fable 5 d42b25bee0 fix(review): wave-4 batch — takes join the dim-transition set, dual-plane think-take append, source-scoped embed lane, claim bounds
Two criticals:

1. Dim-transition hole: `takes` was missing from
   TEXT_EMBEDDING_DIM_PINNED_TABLES, so migrating embeddings to a
   different dim left takes.embedding at the old width — the embed takes
   lane then failed every write forever while still paying the gateway
   each run. takes now transitions with query_cache + facts (partial
   HNSW index recreated, #1734 dim-cap gate honored), and
   invalidateStaleSignatureEmbeddings re-stales takes on drifted pages
   in BOTH engines (same page-signature predicate + source scope as the
   chunks sweep) so a same-dim provider swap can't score old-space take
   vectors against new-space queries.

2. Fence-plane clobber: persistThinkTake wrote DB-only rows while
   `takes add` allocates row numbers from the markdown fence — the next
   fence-allocated row at the same number deterministically OVERWROTE
   the think-take via ON CONFLICT (page_id, row_num) DO UPDATE. Both
   writers now share one dual-plane helper (src/core/takes-append.ts):
   withPageLock → scoped page lookup → fence allocates the row number
   (file-first) → DB mirror. Headless/DB-only brains fall back to
   MAX(row_num)+1 with the TAKE_FILE_PLANE_UNAVAILABLE warning.

Also in this batch: countStaleTakes/listStaleTakes accept a sourceId
scope (page-join filter) and the embed takes lane threads it so
`embed --stale --source X` touches only X's takes; think-take claims
are flattened to one line and bounded at THINK_TAKE_CLAIM_MAX_CHARS
(2000) with TAKE_CLAIM_TRUNCATED; updateTakeEmbeddingsBatch routes
through batchRetry with its own BATCH_AUDIT_SITES entry (both engines);
the think op's remote gate uses the fail-closed `ctx.remote !== false`
pattern; the takes-lane failure line reports written vs skipped
(row retired mid-flight) honestly; and `gbrain think --take` resolves
the caller's ambient source (env/dotfile/local_path/brain-default
tiers) so duplicate anchor slugs land on the caller's-context page.

Includes the 5 wave-4 coverage-audit test files, new pins for the dim
transition + takes invalidation + lane scoping + claim bound, and the
"Think-ops follow-ups (Wave 4, 2026-08)" TODO section.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-08 19:51:51 -07:00
..