Command model and Emacs oracle !10

merged merged by cmc on 2026-10-05 03:36 UTC · krz/orgstar:phase2-commands into main

Discussion

cmc

Phase 2, plan A: the command model, the stateful Emacs oracle, and the first heading commands.

  • OrgCommand / EditContext / CommandStep as 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 LineBuffer moves the caret by Emacs's rules for each edit kind (replace-match, insert-before-markers, insert under save-excursion, org--align-tags-here, org-fix-position-after-promote).
  • DocumentState.run and OrgEditor.perform (edits go through the text view, one undo step per command).
  • Emacs oracle: one emacs -Q --batch run per batch, org settings pinned, each case run as a fresh interactive command. Heading variants at every caret position, plus ORGSTAR_ORACLE_CORPUS for 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.