CODE-021: be/ JS dedup — net ≥1000 LoC reduction target + accounting
A 7-agent re-scan of be/ (JS jab; 65 files, 15,711 LoC; 2026-07-03) quantified the CODE-020 duplication as 900–1,050 net-removable LoC (6–7% of the tree), dominated by 12 recurring micro-helpers. This ticket sets an explicit ≥1000-LoC net-deletion GOAL for the be/ dedup and tallies landed savings against it, so CODE-020's extraction TODOs are measured, not vibes. It also captures extraction opportunities the CODE-020 list omitted (verb-entry factory, beCtx shim, intra-file twins in spot/bro/store/argline). Accounting-only: the mechanical work lands under CODE-020; this page holds the budget and the running tally. JS-only, behavior-preserving; net LoC = lines deleted minus lines added for the shared homes.
Input
Context
7 agents partitioned be/ by subsystem (verbs/core/shared/view/views), each returning file:line dup-candidates WITH per-finding LoC; this ticket sums them into a budget.
CODE-020 lists the extraction homes + fold sites; its TODO set OMITS four opportunities this ticket adds (verb-entry factory, beCtx shim, intra-file twins, store scanners).
Goals
Land ≥1000 LoC NET deletion across the be/ JS tree via the CODE-020 extractions, measured per group with wc -l before/after.
Add the missed extractions to the plan: verb-entry factory, beCtx(ctx) shim, and intra-file twins (spot block-bind, bro cell/row walk, store val-decode + eachRef, cat/blob CAP feed, argline quote scanner).
Keep a running landed-savings tally in Outcome so the goal is auditable, not asserted.
Constraints
be/ JS only; never touch beagle/ (C twin); drive via jab, never native be.
Behavior-preserving; full ctest suite green; net LoC counts shared-home lines ADDED against the lines deleted.
Comments ≤2 lines; skip-and-note marginal swaps (the CODE-001..015 bullshit-quality lesson); one worktree per group.
WIP
Design decisions
Budget by CODE-020 group (est. net LoC removed): resolveHashlet 80, wtblob 90, hunkbuild (concat+span+writeFd) 150, tok32+palette 85, tree-walk/descend 55, uriarg 45, fs probes 25, path 30, wire internals 55, ingest refs+ron60 65, isMeta 15, weave-merge 30 = ~725.
Added opportunities (this ticket, fold under CODE-020): verb-entry factory 90, beCtx shim 50, spot block-bind 60, bro cell/row walk 70, store val-decode + eachRef 35, cat/blob CAP feed 20, argline scanner 18 = 343.
Sum 1,070 gross; expect 1000 net after the shared-home code is added back — the goal is reachable, not padded.
Accounting rule: count net LoC per LANDED group only; a helper surfacing in many slices (concatBytes, tok32) is counted ONCE at its home, never per call site.
TODOs
verb-entry factory makeArgsVerb(default, one): fold the .jab="args" fan-over-arguments + synthetic-ctx boilerplate across ~15 verbs/views (get/put/delete/diff/log/status/commit/tree/cat/blob/sha1/type/size/regex). 2026-07-07: JAB-004 (11e4dddc) landed the plain-args convention — 20 files now carry .jab="args"; RE-SIZE this item against the post-JAB-004 boilerplate before folding.
spot block-bind: extract tryBlockBind(b,flat,from,htoks,src,brace) from the twin branches match.js:194 vs match.js:297 (~60).
bro row/cell walk: one walkRow(text,toks,off,end,onCell) for bro.js rowEnd/rowEndPass/paintDiffRow{,Str} + pager paintRow/_screenToByte (~70).
store scanners: decodeVal(onDisk,key,val) (store.js:274↔326) + eachRef(wantLocal,cb) (eachTip↔eachRemote 432↔450) (~35).
cat/blob CAP feed: feedFileHunks(sink,key,verb,bytes,mode,ext) cat.js:141↔blob.js:171 (~20).
argline: single quote-state pass emitting token,wasQuoted; fold shellSplit↔markQuoted argline.js:36↔60 (~18).
roll each landed CODE-020 group delta into the Outcome tally; stop counting once net ≥1000.
Blockers and bummers
Overlap trap: concatBytes/tok32/span surface in many slices but land ONCE at their home — do not re-credit them per call site or the tally inflates past reality.
The reconcile groups (resolveHashlet, isMeta, weave-merge) are behavior-sensitive → repro-first under CODE-020; their LoC may land last or shrink.
Net, not gross: adding shared-home files costs LoC; only the DELTA counts toward the ≥1000 goal.
Spin-offs stay separate per todo own-ticket rule (dead code, eval() address-bar) — already itemized in CODE-020, not re-tracked here.
Outcome
Tally (per landed CODE-020 group; goal ≥1000 net): wtblob→shared/wtread.js 57ff502a (budgeted 90, actual delta unmeasured); wire internals 69e56b20 (budgeted 55, actual delta unmeasured) — measure both wc -l deltas when the next group lands.
2026-07-07 audit: everything else unlanded; budget assumptions shifted by JAB-003/JAB-004 (hunk-output + plain-args reworks) — re-scan before crediting.