BEE-005: a diff is a projection of ONE weave rooted at the nearest common ancestor

Now
OPEN
Sev
MED
Ask
gritzko
Rep
///bee
On1
BEE-001
See
LITE-010
See
LITE-014

This ticket was MIS-SPECIFIED as a git external DIFF driver and the first attempt built exactly what that spec asked for: a pairwise blob-blob fold over the two temp files git hands a driver (Blockers, commit 4847470). That is not what be does. A be diff is a PROJECTION of one CFOLD weave that is seeded with the path's blob at the LCA FLOOR of the two tips and folds every commit above it, so the emitted tokens carry real provenance (which commit inserted, which removed) instead of an anonymous 2-way delta re-derived from two byte arrays. The adaptation source is /home/gritzko/src/journal/be/views/diff/diff.js plus be/shared/{pathdag,dag,weave,expected}.js; moving that code over into ./ is sanctioned (gritzko).

Input

Context

bee today folds a PAIR of blob byte arrays under two FAKE layer ids (view/diff.js ID_FROM/ID_TO) — every form does, diff, diff <path> and diff <hex> alike — while index/weave.js carries fold/merge but no DAG walker at all (its own header says build/buildDag/foldCommit are NOT here).

Goals

bee diff between any two revisions is a token-wise projection of one weave built from the path's blob at their merge base upward, and no code path re-derives a 2-way delta from two loose blobs.

Constraints

WIP

Design decisions

  1. REVERSED (was ruling 1 and 2): the git EXTERNAL DIFF driver is NOT the deliverable of this ticket. Git's contract hands a driver path old-file old-hex old-mode new-file new-hex new-mode and nothing else — no commit, no ancestry — so a driver can only ever compute the pairwise delta this ticket now rejects. The wiring may return as its own ticket once the weave differ exists (and even then it can only serve the degraded lane).
  2. RULED: the base of a diff is the LCA of the two tips (dag.mergeBase), and the weave's seed is the path's blob AT that floor — not the from-side blob, and never null.
  3. RULED: weave layer ids are real commit hashlets (weaveId(sha)), so blame/alive name commits. The ID_FROM/ID_TO constants go, except where a genuinely anonymous pair remains (a wt layer, an empty side).
  4. OPEN: the empty-FROM addition workaround (fold the sides in the other order, invert the revs) is a blob-pair artefact — with a floor seed an addition is a normal insert above the floor, so it should DIE. Confirm.
  5. KEPT from the first pass: the 4 MB source cap, the binary probe, the ext-from-the-PATH rule and the plain-lexer refold (index/weave.js).
  6. RULED (gritzko): the indexes are LAZY, so an UNINDEXED commit is not a fallback case — it gets INDEXED and the answer then comes off the index. bringUp grows a tip option; nothing else in the diff ever walks the commit graph or a path's history by hand.
  7. RULED: pathdag.of is NOT ported. bee's REV lane already IS the condensed path-DAG (only path-changing commits, each with its blob, its commit and its parent revs), so the floor is found INSIDE the lane over REV-PARS edges, in 20-bit rev space, and the seed is the floor rev's REV-BLOB.
  8. RULED: a commit that did NOT touch the path has no rev of its own; its view is its first parent's rev — foldCommit's carry rule, resolved on the lane.

TODOs

The stages land in order; each is testable on its own and leaves the tree green.

Blockers and bummers

Outcome

Pending. The prior attempt's commits (4847470, acae009, branch worktree1) are to be discarded, not merged — see Blockers.