Phase 2, plan A: the command model, the stateful Emacs oracle, and the first heading commands.
OrgCommand/EditContext/CommandStepas in the design: pure functions over text, tree, selection, injected time and prompt answers; results carry their base revision and the caret.- Heading commands: TODO cycle, priority up/down, promote/demote, with tag alignment to column 77. A
LineBuffermoves the caret by Emacs's rules for each edit kind (replace-match,insert-before-markers,insertundersave-excursion,org--align-tags-here,org-fix-position-after-promote). DocumentState.runandOrgEditor.perform(edits go through the text view, one undo step per command).- Emacs oracle: one
emacs -Q --batchrun per batch, org settings pinned, each case run as a fresh interactive command. Heading variants at every caret position, plusORGSTAR_ORACLE_CORPUSfor real headings. All cases match text and caret. - The oracle found two parser differences from org, fixed here: a heading needs a space after its stars, and a TODO keyword counts only before a space or the end of the line.
191 tests pass; reparse gate (100,000 edits) and the local corpus round trip pass after the parser change.