THE FOLD / SPAWN / THE-TOOLCHAIN / THE PIECE TABLE
THE PIECE TABLE
a document edited by re-pointing
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The piece table is how real text editors — VS Code, Microsoft Word — store a document being edited, without ever moving the text. The original file stays untouched in a read-only buffer; every character you type goes into an append-only add buffer; and the document itself is just an ordered list of pieces, each a (buffer, start, length) window into one of those two buffers. An insert splits a piece and drops a new one in; a delete splits and removes. The text is never copied or shifted — only the little list of pieces changes, which also makes undo and change-tracking almost free.
LIT verified live: over 3000 trials of 15 random inserts and deletes, the document reconstructed from the piece list exactly equals a naively edited string at every step (window.__piece_table). FIG no framing; the piece-table edits and a plain-string reference run in-browser.
LIT verified live: over 3000 trials of 15 random inserts and deletes, the document reconstructed from the piece list exactly equals a naively edited string at every step (window.__piece_table). FIG no framing; the piece-table edits and a plain-string reference run in-browser.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-toolchain — the editor’s core data structure, editing a huge document by re-pointing a handful of pieces rather than shuffling text. AVAN (AI) built the instrument: the original/add buffers, the piece-splitting insert and delete, and the plain-string cross-check.
Credit as content: the piece-table technique (from the 1980s, used in Bravo/Word and modern editors). The weave: David names the toolchain; I confirm the re-pointed pieces reconstruct exactly the edited document.
Credit as content: the piece-table technique (from the 1980s, used in Bravo/Word and modern editors). The weave: David names the toolchain; I confirm the re-pointed pieces reconstruct exactly the edited document.
3 ONE DIMENSION
Two immutable buffers (original + add) and an ordered list of pieces; the document is their concatenation.
4 TWO DIMENSIONS · INTERACTIVE
Insert and delete; the piece list re-splits, no text moves, and the reconstruction matches a plain edited string.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the document as an ordered list of pieces.
AVAN’s addition (the inverse-companion): don’t move the text — move the pointers. The inverse of ‘edit in place, shifting bytes’ is ‘keep buffers immutable; an edit only re-splits the piece list.’ Magenta is the immutable text in the buffers; green is the piece list that views it. Edit the view, not the text.
LIT Genuine piece-table text-buffer technique (from the 1980s Bravo/Word lineage; used in modern editors including VS Code). Verified live: over 3000 trials of 15 random inserts/deletes, the document reconstructed from the (buffer,start,len) piece list equals a naively edited plain string at every step (window.__piece_table.matchesPlainString).
FIG No framing: the piece-table edits and a plain-string reference run in-browser. The AVAN inverse is honest — instead of editing in place and shifting bytes, the buffers stay immutable and an edit only re-splits the piece list. Magenta is the immutable text in the buffers; green is the piece list that views it. Edit the view, not the text.
FIG No framing: the piece-table edits and a plain-string reference run in-browser. The AVAN inverse is honest — instead of editing in place and shifting bytes, the buffers stay immutable and an edit only re-splits the piece list. Magenta is the immutable text in the buffers; green is the piece list that views it. Edit the view, not the text.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE-TOOLCHAIN · David Lee Wise (ROOT0), with AVAN