fix(lab): redesigned draft surface - in-memory drafts map, transparent Read/Edit, gen-8 delta

↗ view on GitHub · Eli Ziff · 2026-08-07 · 9e2e271e

The gen-7 draft-edit shadowing fix (68cce2b4) made Edit(draft.md) reach the
in-memory handler, but the surface stayed asymmetric: the schema only
advertised "draft.md", multi-draft was impossible, and real-file edits were
reachable but unadvertised. Redesign per Eli:

- requirementsState.draftMarkdown → drafts: Record<string,string> keyed by
  lowercased filename; "draft.md" canonical + per-title aliases
  (draftKeyFor(title)). A second generate_docx refusal preserves earlier
  drafts under their own names.
- Read/Edit/Glob treat drafts exactly like any other file: no in-memory
  backstory in the tool descriptions, draft.md addressable by any name it
  has been saved under. draftTarget computed at the top of the dispatch
  chain so the lean-batch Read handler can't intercept a draft path first.
- Real-file (source) edits go through the normal FS text-ops surface and are
  counted in sourceEditCount - observable behavior, never a hidden path.
- CODING_EDIT_TOOL rewritten dead-simple (plain Claude Code semantics, both
  targets); DRAFT_EDIT_DELTA bumped draft-edit-v4 → draft-edit-v8 (gen-8;
  receipt deltas mark generations, arms don't fork).

Regression test drives the real dispatch end-to-end: bodied generate_docx
captures draft → Read(draft.md) returns buffer → Edit applies (draftEditCount
up, sourceEditCount stays 0) → per-title alias is its own buffer → render
without markdown uses the edited draft → Glob lists canonical + alias and
invents no phantom drafts. tsc --noEmit clean; localAssistantTools 48/49
(the one failure, "keeps oversized research results", is a stale mock broken
at HEAD, confirmed via stash-independent isolation run); libraryApplyTextOps
+ localPdfLookup green.

Co-Authored-By: Claude <noreply@anthropic.com>
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents ff7bbadd
Stats 3 files changed , +205 , -75
Part of Evaluation harness: Beaver-CAN and LegalBench-RAG adapters

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-9e2e271e.md from inside the repo you want the change in.

⬇ Download capture-commit-9e2e271e.md