Planning cleanup !233

merged merged by cmc on 2026-10-11 03:54 UTC · krz/orgstar:plan-cleanup into main

22 files changed, +201 −195

Layout: unified · split

docs/design.md +4 −2
@@ -334,7 +334,7 @@ Fidelity is checked against Emacs itself, using the same oracle pattern as orgo'
334334
335335Seven phases, each usable on its own. Phase 1 is read-only, so it can run next to Emacs from the first build.
336336
337Status, 2026-10-06: phases 1–6 are built for macOS. Owed from phase 1: the items left open below and the gate run on the M1 Air. The gates pass on an M-series Mac except peak memory for small real files (about 20x for a 161 kB file, from fixed overhead). Phase 7 has started: the iOS app has the agenda and capture, and runs in the Simulator; device builds need signing.
337Status, 2026-10-10: phases 1–7 are built. The Mac app is released as v0.2.0 (universal, notarized DMG, Homebrew cask). The iOS app is complete for Simulator builds; device signing and TestFlight are not set up. Owed: the phase-1 gate run on the M1 Air, and the VoiceOver check on both platforms. The gates pass on an M-series Mac except peak memory for small real files (about 20x for a 161 kB file, from fixed overhead).
338338
3393391. **Core and viewer:** `OrgCore` parser, workspace, index, read-only rendering, folding, search.
3403402. **Editor:** text editing, structure and heading commands, timestamps, `M-q`, table alignment, command palette, Emacs and Mac keymaps, remaining tree-sitter grammars.
@@ -344,6 +344,8 @@ Status, 2026-10-06: phases 1–6 are built for macOS. Owed from phase 1: the ite
3443446. **Beyond Emacs:** clock reports, habit charts, table and kanban views over properties, Doom keymap.
3453457. **iOS:** same core; touch input, capture and agenda first.
346346
347Plans in `docs/plans/` are ticked when their commits land, and a step that did not ship is marked in the plan. Open work is in the repository's issues.
348
347349**Phase 1 scope**
348350
349351- [x] `OrgCore` package: lossless parser with UTF-16 ranges and the bytes-and-encoding contract; element-aware settings pass; inline rules ported from OrgSwift
@@ -387,7 +389,7 @@ Phase 2 (writable editor) does not start until every gate passes.
387389
388390## Open questions
389391
390- [ ] App name: Orgstar (chosen).
392- [x] App name: orgstar, spelt in lowercase.
391393- [x] Save model: a user setting (see Saving).
392394- [x] Minimum OS: macOS 26 and iOS 26. One release behind current (macOS 27).
393395- [x] License: 0BSD.
docs/plans/2026-10-04-document-session.md +16 −16
@@ -44,7 +44,7 @@ Per-window session objects and main-actor wiring (they belong to the app target)
4444**Interfaces:**
4545- Produces: `MergeConflict(base:ours:theirs:)`, `MergeResult` (`.merged`, `.conflict`), `threeWayMerge(base:ours:theirs:)`, `lineEdits(from:to:) -> [TextEdit]`; internal `textLines`, `matchingLines`.
4646
47- [ ] **Step 1: Add the target**
47- [x] **Step 1: Add the target**
4848
4949```swift
5050// swift-tools-version: 6.2
@@ -66,7 +66,7 @@ let package = Package(
6666)
6767```
6868
69- [ ] **Step 2: Write the failing tests**
69- [x] **Step 2: Write the failing tests**
7070
7171```swift
7272import OrgCore
@@ -118,12 +118,12 @@ struct MergeTests {
118118}
119119```
120120
121- [ ] **Step 3: Run to verify failure**
121- [x] **Step 3: Run to verify failure**
122122
123123Run: `swift test --filter MergeTests`
124124Expected: build failure, `cannot find 'threeWayMerge' in scope`.
125125
126- [ ] **Step 4: Implement**
126- [x] **Step 4: Implement**
127127
128128```swift
129129import OrgCore
@@ -303,7 +303,7 @@ private func myers(_ a: [Int], _ b: [Int]) -> [(Int, Int)] {
303303}
304304```
305305
306- [ ] **Step 5: Run to verify pass, then commit**
306- [x] **Step 5: Run to verify pass, then commit**
307307
308308Run: `swift test --filter MergeTests`
309309
@@ -324,7 +324,7 @@ git commit -m "Add OrgDocument target with three-way merge"
324324- Consumes: `threeWayMerge`, `lineEdits` (Task 1); `OrgParser.reparse`, `SourceText`, `TextEdit`.
325325- Produces: `DocumentState(bytes:defaults:)` with `source`, `text`, `tree`, `revision`, `mergeBase`, `isDirty`, `isEditable`, `canUndo`, `canRedo`, `encodedText()`, `apply(_:baseRevision:)`, `undo()`, `redo()`, `diskChanged(to:) -> ExternalChange`, `mergeOverwritten(_:base:)`, `didWrite(_:)`; `ViewState` with `mapped(through:)`, `pruned(to:)`; internal `mapOffset`, `utf16Slice`.
326326
327- [ ] **Step 1: Write the failing tests**
327- [x] **Step 1: Write the failing tests**
328328
329329```swift
330330import OrgCore
@@ -446,12 +446,12 @@ struct ViewStateTests {
446446}
447447```
448448
449- [ ] **Step 2: Run to verify failure**
449- [x] **Step 2: Run to verify failure**
450450
451451Run: `swift test --filter DocumentStateTests`
452452Expected: build failure, `cannot find 'DocumentState' in scope`.
453453
454- [ ] **Step 3: Implement `DocumentState.swift`**
454- [x] **Step 3: Implement `DocumentState.swift`**
455455
456456```swift
457457import OrgCore
@@ -612,7 +612,7 @@ func utf16Slice(_ text: String, _ range: Range<Int>) -> String {
612612}
613613```
614614
615- [ ] **Step 4: Implement `ViewState.swift`**
615- [x] **Step 4: Implement `ViewState.swift`**
616616
617617```swift
618618import OrgCore
@@ -658,7 +658,7 @@ func mapOffset(_ offset: Int, _ sortedEdits: [TextEdit]) -> Int {
658658}
659659```
660660
661- [ ] **Step 5: Run to verify pass, then commit**
661- [x] **Step 5: Run to verify pass, then commit**
662662
663663Run: `swift test --filter "DocumentStateTests|ViewStateTests"`
664664
@@ -679,7 +679,7 @@ git commit -m "Add document state and view state"
679679- Consumes: `DocumentState` (Task 2).
680680- Produces: `FileSystem`, `RecoveryStore`, `SaveOutcome`, `SaveError`, `Saver(fileSystem:recovery:)` with `save(_:to:)`, `CoordinatedFileSystem`, `FileRecoveryStore(directory:limit:)` with `versions(for:)`.
681681
682- [ ] **Step 1: Write the failing tests**
682- [x] **Step 1: Write the failing tests**
683683
684684The fault-injection cases put another writer's change in place before each read and before the replace, and check that both versions survive.
685685
@@ -880,12 +880,12 @@ struct FileStorageTests {
880880}
881881```
882882
883- [ ] **Step 2: Run to verify failure**
883- [x] **Step 2: Run to verify failure**
884884
885885Run: `swift test --filter SaveTests`
886886Expected: build failure, `cannot find type 'FileSystem' in scope`.
887887
888- [ ] **Step 3: Implement `Saving.swift`**
888- [x] **Step 3: Implement `Saving.swift`**
889889
890890```swift
891891import Foundation
@@ -971,7 +971,7 @@ public struct Saver: Sendable {
971971}
972972```
973973
974- [ ] **Step 4: Implement `FileStorage.swift`**
974- [x] **Step 4: Implement `FileStorage.swift`**
975975
976976```swift
977977import CryptoKit
@@ -1068,12 +1068,12 @@ public struct FileRecoveryStore: RecoveryStore {
10681068}
10691069```
10701070
1071- [ ] **Step 5: Run everything, including the iOS build**
1071- [x] **Step 5: Run everything, including the iOS build**
10721072
10731073Run: `swift test`, then `xcodebuild -scheme OrgDocument -destination 'generic/platform=iOS' build`
10741074Expected: all pass; `BUILD SUCCEEDED`.
10751075
1076- [ ] **Step 6: Commit**
1076- [x] **Step 6: Commit**
10771077
10781078```bash
10791079git add Sources/OrgDocument/Saving.swift Sources/OrgDocument/FileStorage.swift Tests/OrgDocumentTests/SaveTests.swift
docs/plans/2026-10-04-editing-spike.md +13 −13
@@ -39,9 +39,9 @@ Two bugs the differential test found and the plan fixes: a line split off by an
3939Work for the performance plan: reparse structural edits within the innermost section instead of the top-level section; a faster parser (about 3x for the open gate); style the visible region first on open and the rest after.
4040
4141Manual VoiceOver checklist (run `swift run OrgstarSpike <file>`, turn on VoiceOver):
42- [ ] Line by line through a folded heading skips to the next visible heading.
43- [ ] Reading a heading with tags and a TODO keyword is understandable.
44- [ ] Selection announcements are correct across a fold.
42- [ ] Line by line through a folded heading skips to the next visible heading. — did not ship: the VoiceOver check is owed (see docs/design.md, phase 1)
43- [ ] Reading a heading with tags and a TODO keyword is understandable. — did not ship: the VoiceOver check is owed (see docs/design.md, phase 1)
44- [ ] Selection announcements are correct across a fold. — did not ship: the VoiceOver check is owed (see docs/design.md, phase 1)
4545
4646## File structure
4747
@@ -65,7 +65,7 @@ Manual VoiceOver checklist (run `swift run OrgstarSpike <file>`, turn on VoiceOv
6565**Interfaces:**
6666- Produces: `StyleRole`, `StyleRun`, `IndentRun`, `Presentation.styles(_:in:)`, `Presentation.indents(_:in:)`, `Presentation.hiddenRanges(_:folds:)`, `Presentation.heading(containing:in:)`, `Presentation.headings(_:)`.
6767
68- [ ] **Step 1: Write the failing tests**
68- [x] **Step 1: Write the failing tests**
6969
7070```swift
7171import OrgCore
@@ -148,7 +148,7 @@ struct FoldTests {
148148}
149149```
150150
151- [ ] **Step 2: Implement**
151- [x] **Step 2: Implement**
152152
153153```swift
154154import OrgCore
@@ -324,7 +324,7 @@ public enum Presentation {
324324}
325325```
326326
327- [ ] **Step 3: Run, build for iOS, commit**
327- [x] **Step 3: Run, build for iOS, commit**
328328
329329Run: `swift test --filter OrgPresentationTests`, then `xcodebuild -scheme OrgPresentation -destination 'generic/platform=iOS' build`.
330330
@@ -346,7 +346,7 @@ git commit -m "Add platform-free presentation policy"
346346- Consumes: `DocumentState`, `ViewState`, `Saver`, `lineEdits` (OrgDocument); Task 1.
347347- Produces: `OrgEditor(document:frame:)` with `textView`, `document`, `view`, `onEditTiming`, `makeScrollView()`, `setFolds(_:)`, `toggleFoldAtCaret()`, `toggleAllFolds()`, `save(using:to:)`.
348348
349- [ ] **Step 1: Make pruning cheap**
349- [x] **Step 1: Make pruning cheap**
350350
351351```diff
352352@@ -22,11 +22,22 @@ public struct ViewState: Sendable, Equatable {
@@ -376,7 +376,7 @@ git commit -m "Add platform-free presentation policy"
376376 func mapOffset(_ offset: Int, _ sortedEdits: [TextEdit]) -> Int {
377377```
378378
379- [ ] **Step 2: Write the failing tests**
379- [x] **Step 2: Write the failing tests**
380380
381381The tests drive a real `NSTextView` in an offscreen window. `RestyleFuzzTests` compares the incrementally styled storage with a fresh editor after every random edit.
382382
@@ -631,7 +631,7 @@ struct RestyleFuzzTests {
631631}
632632```
633633
634- [ ] **Step 3: Implement `Theme.swift`**
634- [x] **Step 3: Implement `Theme.swift`**
635635
636636```swift
637637#if os(macOS)
@@ -710,7 +710,7 @@ struct Theme {
710710#endif
711711```
712712
713- [ ] **Step 4: Implement `OrgEditor.swift`**
713- [x] **Step 4: Implement `OrgEditor.swift`**
714714
715715```swift
716716#if os(macOS)
@@ -1062,7 +1062,7 @@ final class FoldedHeadingFragment: NSTextLayoutFragment, @unchecked Sendable {
10621062#endif
10631063```
10641064
1065- [ ] **Step 5: Run, including longer fuzz runs, then commit**
1065- [x] **Step 5: Run, including longer fuzz runs, then commit**
10661066
10671067Run: `swift test`, then `ORGSTAR_RESTYLE_EDITS=1500 ORGSTAR_FUZZ_SEED=<n> swift test --filter RestyleFuzzTests` for several seeds.
10681068
@@ -1079,7 +1079,7 @@ git commit -m "Add TextKit 2 editor with folding and incremental restyle"
10791079- Modify: `Package.swift` (add the `OrgstarSpike` executable)
10801080- Create: `Sources/OrgstarSpike/main.swift`
10811081
1082- [ ] **Step 1: Implement**
1082- [x] **Step 1: Implement**
10831083
10841084```swift
10851085#if os(macOS)
@@ -1173,7 +1173,7 @@ app.run()
11731173#endif
11741174```
11751175
1176- [ ] **Step 2: Run by hand, measure, commit**
1176- [x] **Step 2: Run by hand, measure, commit** (measured; the VoiceOver checklist did not run)
11771177
11781178Run: `swift run -c release OrgstarSpike <large file>`; type, fold with TAB and Shift-TAB, save with ⌘S, watch the printed p50/p95; then the VoiceOver checklist above.
11791179
docs/plans/2026-10-04-incremental-reparse.md +6 −6
@@ -41,7 +41,7 @@ The spec reparses structural edits from the innermost enclosing section. This pl
4141- Consumes: `Parser`, `splitRawLines`, `classifyLine`, `SyntaxNode`, `GreenNode`, `randomDocument`/`fragments`/`SeededGenerator` from `RoundTripTests.swift`.
4242- Produces: `TextEdit(range:replacement:)` with `apply(to:)`; `OrgParser.reparse(_:oldText:edit:defaults:) -> OrgTree`; internal `OrgParser.reparseWithStrategy` returning `(tree, ReparseStrategy)` with `.element`, `.sections`, `.full`; `Parser(text:settings:)`; `Parser.reparseElement(_:text:settings:) -> GreenNode?`.
4343
44- [ ] **Step 1: Write the failing tests**
44- [x] **Step 1: Write the failing tests**
4545
4646```swift
4747import Foundation
@@ -148,12 +148,12 @@ struct IncrementalTests {
148148}
149149```
150150
151- [ ] **Step 2: Run to verify failure**
151- [x] **Step 2: Run to verify failure**
152152
153153Run: `swift test --filter IncrementalTests`
154154Expected: build failure, `cannot find 'TextEdit' in scope`.
155155
156- [ ] **Step 3: Let the parser take known settings**
156- [x] **Step 3: Let the parser take known settings**
157157
158158```diff
159159@@ -16,10 +16,25 @@ struct Parser {
@@ -188,7 +188,7 @@ Expected: build failure, `cannot find 'TextEdit' in scope`.
188188 static func matchEnds(_ info: [ClassifiedLine]) -> [Int: Int] {
189189```
190190
191- [ ] **Step 4: Implement `Incremental.swift`**
191- [x] **Step 4: Implement `Incremental.swift`**
192192
193193```swift
194194import Foundation
@@ -442,7 +442,7 @@ extension Parser {
442442}
443443```
444444
445- [ ] **Step 5: Run all tests, then the gate**
445- [x] **Step 5: Run all tests, then the gate**
446446
447447Run: `swift test`
448448Expected: all pass.
@@ -450,7 +450,7 @@ Expected: all pass.
450450Run: `ORGSTAR_FUZZ_EDITS=100000 swift test -c release --filter incrementalEqualsFull`, and again with `ORGSTAR_FUZZ_SEED=1`, `2`, `3`.
451451Expected: pass. A failure prints the edit and the document; reduce it to a unit test before fixing.
452452
453- [ ] **Step 6: Commit**
453- [x] **Step 6: Commit**
454454
455455```bash
456456git add Sources Tests
docs/plans/2026-10-04-inline-objects.md +15 −15
@@ -41,7 +41,7 @@ Entities (`\alpha`), subscripts, `$...$` LaTeX, export snippets, citations, radi
4141**Interfaces:**
4242- Produces: `Timestamp` (`active`, `start: Point`, `end: Point?`, `repeater: Repeater?`, `warning: Warning?`), `Timestamp.parse(_:) -> Timestamp?`; internal `scanTimestamp(_ chars: [Character], at: Int, limit: Int) -> (stamp: Timestamp, end: Int)?`.
4343
44- [ ] **Step 1: Write the failing tests**
44- [x] **Step 1: Write the failing tests**
4545
4646```swift
4747import Testing
@@ -90,12 +90,12 @@ struct TimestampTests {
9090}
9191```
9292
93- [ ] **Step 2: Run to verify failure**
93- [x] **Step 2: Run to verify failure**
9494
9595Run: `swift test --filter TimestampTests`
9696Expected: build failure, `cannot find 'Timestamp' in scope`.
9797
98- [ ] **Step 3: Implement**
98- [x] **Step 3: Implement**
9999
100100```swift
101101public struct Timestamp: Sendable, Equatable {
@@ -281,12 +281,12 @@ private func scanSingleTimestamp(_ chars: [Character], at start: Int, limit: Int
281281}
282282```
283283
284- [ ] **Step 4: Run to verify pass**
284- [x] **Step 4: Run to verify pass**
285285
286286Run: `swift test --filter TimestampTests`
287287Expected: all pass.
288288
289- [ ] **Step 5: Commit**
289- [x] **Step 5: Commit**
290290
291291```bash
292292git add Sources/OrgCore/Timestamp.swift Tests/OrgCoreTests/TimestampTests.swift
@@ -306,7 +306,7 @@ git commit -m "Add timestamp recognizer and value type"
306306- Consumes: `scanTimestamp` (Task 1), `GreenBuilder`, `Parser`.
307307- Produces: `InlineScanner(chars:)` with `scan(_:into:inLink:)`; `Parser.inline(_ text: Substring)`; `Parser.span(from:through:)`; node kinds `title`, `tableCell`, `bold`, `italic`, `underline`, `strikeThrough`, `verbatim`, `code`, `link`, `linkDescription`, `timestamp`, `footnoteReference`, `statisticsCookie`, `target`, `macro`, `inlineSourceBlock`, `latexFragment`, `lineBreak`, `superscript`; token kinds `marker`, `linkPath`, `bullet`, `checkbox`.
308308
309- [ ] **Step 1: Write the failing tests**
309- [x] **Step 1: Write the failing tests**
310310
311311```swift
312312import Testing
@@ -429,12 +429,12 @@ Update the two `ParserSectionTests` expectations that assumed `title` was a toke
429429 @Test func todoKeywordsComeFromSettings() {
430430```
431431
432- [ ] **Step 2: Run to verify failure**
432- [x] **Step 2: Run to verify failure**
433433
434434Run: `swift test --filter InlineTests`
435435Expected: build failure on the new `SyntaxKind` cases.
436436
437- [ ] **Step 3: Replace `SyntaxKind.swift`**
437- [x] **Step 3: Replace `SyntaxKind.swift`**
438438
439439```swift
440440public enum SyntaxKind: String, Sendable {
@@ -457,7 +457,7 @@ public enum SyntaxKind: String, Sendable {
457457}
458458```
459459
460- [ ] **Step 4: Create `Inline.swift`**
460- [x] **Step 4: Create `Inline.swift`**
461461
462462```swift
463463/// Characters allowed before an emphasis opener, besides whitespace and the start of the run.
@@ -838,7 +838,7 @@ extension Parser {
838838}
839839```
840840
841- [ ] **Step 5: Wire the scanner into the parser**
841- [x] **Step 5: Wire the scanner into the parser**
842842
843843```diff
844844diff --git a/Sources/OrgCore/Parser/Lines.swift b/Sources/OrgCore/Parser/Lines.swift
@@ -1037,12 +1037,12 @@ index ac210ff..6460486 100644
10371037 builder.token(.whitespace, parts.trailing)
10381038```
10391039
1040- [ ] **Step 6: Run all tests**
1040- [x] **Step 6: Run all tests**
10411041
10421042Run: `swift test`
10431043Expected: all pass.
10441044
1045- [ ] **Step 7: Commit**
1045- [x] **Step 7: Commit**
10461046
10471047```bash
10481048git add Sources Tests
@@ -1056,7 +1056,7 @@ git commit -m "Parse inline objects"
10561056**Files:**
10571057- Modify: `Tests/OrgCoreTests/RoundTripTests.swift` (fragment list)
10581058
1059- [ ] **Step 1: Add inline fragments**
1059- [x] **Step 1: Add inline fragments**
10601060
10611061```diff
10621062@@ -20,6 +20,10 @@ let fragments = [
@@ -1072,12 +1072,12 @@ git commit -m "Parse inline objects"
10721072 func randomDocument(_ rng: inout SeededGenerator) -> String {
10731073```
10741074
1075- [ ] **Step 2: Run the fuzz test and the private corpus**
1075- [x] **Step 2: Run the fuzz test and the private corpus**
10761076
10771077Run: `swift test` then `ORGSTAR_CORPUS=~/Documents/notes swift test --filter corpusRoundTrips`
10781078Expected: all pass.
10791079
1080- [ ] **Step 3: Commit**
1080- [x] **Step 3: Commit**
10811081
10821082```bash
10831083git add Tests
docs/plans/2026-10-04-orgcore-parser.md +40 −38
@@ -1,5 +1,7 @@
11# OrgCore Parser Foundation Implementation Plan
22
3Shipped as one squashed commit, f4591a4 "OrgCore parser foundation (!1)"; the commit names below are the steps as planned.
4
35> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
46
57**Goal:** A Swift package, `OrgCore`, that turns org file bytes into a lossless syntax tree of block-level elements, with the byte and encoding contract from the design.
@@ -49,7 +51,7 @@ Inline objects (emphasis, links, timestamps), the semantic layer, incremental re
4951**Interfaces:**
5052- Produces: `SourceText(bytes: [UInt8])`, `SourceText(_ text: String)`, properties `originalBytes`, `hasBOM`, `isValidUTF8`, `isEditable`, `text`; `encode(_ newText: String) -> [UInt8]`.
5153
52- [ ] **Step 1: Create the package**
54- [x] **Step 1: Create the package**
5355
5456```swift
5557// swift-tools-version: 6.2
@@ -68,7 +70,7 @@ let package = Package(
6870)
6971```
7072
71- [ ] **Step 2: Write the failing tests**
73- [x] **Step 2: Write the failing tests**
7274
7375```swift
7476import Testing
@@ -113,12 +115,12 @@ struct SourceTextTests {
113115}
114116```
115117
116- [ ] **Step 3: Run tests to verify they fail**
118- [x] **Step 3: Run tests to verify they fail**
117119
118120Run: `swift test --filter SourceTextTests`
119121Expected: build failure, `cannot find 'SourceText' in scope`.
120122
121- [ ] **Step 4: Implement**
123- [x] **Step 4: Implement**
122124
123125```swift
124126import Foundation
@@ -163,12 +165,12 @@ public struct SourceText: Sendable {
163165}
164166```
165167
166- [ ] **Step 5: Run tests to verify they pass**
168- [x] **Step 5: Run tests to verify they pass**
167169
168170Run: `swift test --filter SourceTextTests`
169171Expected: 5 tests pass.
170172
171- [ ] **Step 6: Commit**
173- [x] **Step 6: Commit**
172174
173175```bash
174176git add Package.swift Sources Tests
@@ -188,7 +190,7 @@ git commit -m "Add OrgCore package and SourceText byte contract"
188190**Interfaces:**
189191- Produces: `SyntaxKind` (enum, `String` raw values), `GreenToken(kind:text:)`, `GreenNode(kind:children:)` with `.length`, `.text`; `GreenElement` (`.node`, `.token`); internal `GreenBuilder` with `start(_:)`, `token(_:_:)`, `finish()`, `build()`; `SyntaxNode` with `kind`, `range`, `text`, `children`, `tokens`, `descendants()`; `SyntaxToken`. `OrgTree` depends on `OrgSettings` (Task 4), so it is added in Task 5.
190192
191- [ ] **Step 1: Write the failing tests**
193- [x] **Step 1: Write the failing tests**
192194
193195```swift
194196import Testing
@@ -238,12 +240,12 @@ struct SyntaxTreeTests {
238240}
239241```
240242
241- [ ] **Step 2: Run tests to verify they fail**
243- [x] **Step 2: Run tests to verify they fail**
242244
243245Run: `swift test --filter SyntaxTreeTests`
244246Expected: build failure, `cannot find 'GreenBuilder' in scope`.
245247
246- [ ] **Step 3: Implement `SyntaxKind.swift`**
248- [x] **Step 3: Implement `SyntaxKind.swift`**
247249
248250```swift
249251public enum SyntaxKind: String, Sendable {
@@ -260,7 +262,7 @@ public enum SyntaxKind: String, Sendable {
260262}
261263```
262264
263- [ ] **Step 4: Implement `GreenTree.swift`**
265- [x] **Step 4: Implement `GreenTree.swift`**
264266
265267```swift
266268public struct GreenToken: Sendable, Equatable {
@@ -352,7 +354,7 @@ struct GreenBuilder {
352354}
353355```
354356
355- [ ] **Step 5: Implement `SyntaxNode.swift`**
357- [x] **Step 5: Implement `SyntaxNode.swift`**
356358
357359```swift
358360/// A view of a green node at an absolute offset, with a parent link. Created on demand.
@@ -408,12 +410,12 @@ public struct SyntaxToken: Sendable, Equatable {
408410}
409411```
410412
411- [ ] **Step 6: Run tests to verify they pass**
413- [x] **Step 6: Run tests to verify they pass**
412414
413415Run: `swift test --filter SyntaxTreeTests`
414416Expected: 4 tests pass.
415417
416- [ ] **Step 7: Commit**
418- [x] **Step 7: Commit**
417419
418420```bash
419421git add Sources Tests
@@ -431,7 +433,7 @@ git commit -m "Add green and red syntax tree"
431433**Interfaces:**
432434- Produces (internal): `RawLine(content: Substring, ending: Substring)`, `splitRawLines(_ text: String) -> [RawLine]`, `LineClass` enum, `ClassifiedLine(cls:indent:)`, `classifyLine(_ line: Substring) -> ClassifiedLine`, `Substring.trimmingTrailingWhitespace`.
433435
434- [ ] **Step 1: Write the failing tests**
436- [x] **Step 1: Write the failing tests**
435437
436438```swift
437439import Testing
@@ -500,12 +502,12 @@ struct LinesTests {
500502}
501503```
502504
503- [ ] **Step 2: Run tests to verify they fail**
505- [x] **Step 2: Run tests to verify they fail**
504506
505507Run: `swift test --filter LinesTests`
506508Expected: build failure, `cannot find 'splitRawLines' in scope`.
507509
508- [ ] **Step 3: Implement**
510- [x] **Step 3: Implement**
509511
510512```swift
511513/// One line of source: its content and its terminator ("", "\n" or "\r\n"), both as slices of
@@ -663,12 +665,12 @@ extension Substring {
663665}
664666```
665667
666- [ ] **Step 4: Run tests to verify they pass**
668- [x] **Step 4: Run tests to verify they pass**
667669
668670Run: `swift test --filter LinesTests`
669671Expected: all pass.
670672
671- [ ] **Step 5: Commit**
673- [x] **Step 5: Commit**
672674
673675```bash
674676git add Sources Tests
@@ -687,7 +689,7 @@ git commit -m "Add line splitting and classification"
687689- Consumes: `RawLine`, `ClassifiedLine`, `LineClass` (Task 3).
688690- Produces: `TodoKeyword`, `TodoSequence`, `Priorities`, `OrgSettings` with `.default`, `todoKeywordNames: Set<String>`, `isDone(_:)`; internal `SettingsScanner.scan(lines:info:blockEnds:defaults:) -> OrgSettings`, where `blockEnds: [Int: Int]` maps a block's begin line index to its end line index.
689691
690- [ ] **Step 1: Write the failing tests**
692- [x] **Step 1: Write the failing tests**
691693
692694```swift
693695import Testing
@@ -740,12 +742,12 @@ struct SettingsTests {
740742}
741743```
742744
743- [ ] **Step 2: Run tests to verify they fail**
745- [x] **Step 2: Run tests to verify they fail**
744746
745747Run: `swift test --filter SettingsTests`
746748Expected: build failure, `cannot find 'SettingsScanner' in scope`.
747749
748- [ ] **Step 3: Implement**
750- [x] **Step 3: Implement**
749751
750752```swift
751753public struct TodoKeyword: Sendable, Hashable {
@@ -879,12 +881,12 @@ enum SettingsScanner {
879881}
880882```
881883
882- [ ] **Step 4: Run tests to verify they pass**
884- [x] **Step 4: Run tests to verify they pass**
883885
884886Run: `swift test --filter SettingsTests`
885887Expected: all pass.
886888
887- [ ] **Step 5: Commit**
889- [x] **Step 5: Commit**
888890
889891```bash
890892git add Sources Tests
@@ -904,7 +906,7 @@ git commit -m "Add in-buffer TODO and priority settings"
904906- Consumes: Tasks 2–4.
905907- Produces: `public enum OrgParser { static func parse(_ text: String, defaults: OrgSettings = .default) -> OrgTree }`; `public struct OrgTree { green: GreenNode; settings: OrgSettings; root: SyntaxNode; text: String }`; internal `struct Parser` with `element(limit:floor:)` that Task 6 fills in. In this task `element` handles every class as a paragraph or a blank line.
906908
907- [ ] **Step 1: Write the failing tests**
909- [x] **Step 1: Write the failing tests**
908910
909911```swift
910912import Testing
@@ -975,12 +977,12 @@ struct ParserSectionTests {
975977}
976978```
977979
978- [ ] **Step 2: Run tests to verify they fail**
980- [x] **Step 2: Run tests to verify they fail**
979981
980982Run: `swift test --filter ParserSectionTests`
981983Expected: build failure, `cannot find 'OrgParser' in scope`.
982984
983- [ ] **Step 3: Append `OrgTree` to `SyntaxNode.swift`**
985- [x] **Step 3: Append `OrgTree` to `SyntaxNode.swift`**
984986
985987```swift
986988public struct OrgTree: Sendable {
@@ -992,7 +994,7 @@ public struct OrgTree: Sendable {
992994}
993995```
994996
995- [ ] **Step 4: Implement `Parser.swift`**
997- [x] **Step 4: Implement `Parser.swift`**
996998
997999```swift
9981000public enum OrgParser {
@@ -1226,12 +1228,12 @@ struct Parser {
12261228}
12271229```
12281230
1229- [ ] **Step 5: Run tests to verify they pass**
1231- [x] **Step 5: Run tests to verify they pass**
12301232
12311233Run: `swift test --filter ParserSectionTests`
12321234Expected: all pass.
12331235
1234- [ ] **Step 6: Commit**
1236- [x] **Step 6: Commit**
12351237
12361238```bash
12371239git add Sources Tests
@@ -1250,7 +1252,7 @@ git commit -m "Parse document, sections and headings"
12501252- Consumes: Task 5's `Parser`.
12511253- Produces: nodes `block`, `dynamicBlock`, `drawer`, `keyword`, `affiliatedKeyword`, `comment`, `fixedWidth`, `horizontalRule`, `table`/`tableRow`/`tableFormula`, `footnoteDefinition`, `clock`, `plainList`/`item`, `planning` (after heading only), `propertyDrawer`/`nodeProperty`.
12521254
1253- [ ] **Step 1: Write the failing tests**
1255- [x] **Step 1: Write the failing tests**
12541256
12551257```swift
12561258import Testing
@@ -1334,12 +1336,12 @@ struct ParserElementTests {
13341336}
13351337```
13361338
1337- [ ] **Step 2: Run tests to verify they fail**
1339- [x] **Step 2: Run tests to verify they fail**
13381340
13391341Run: `swift test --filter ParserElementTests`
13401342Expected: failures; every element parses as a paragraph.
13411343
1342- [ ] **Step 3: Replace `element` and `continuesParagraph`, add the element parsers**
1344- [x] **Step 3: Replace `element` and `continuesParagraph`, add the element parsers**
13431345
13441346```swift
13451347 static let affiliatedKeys: Set<String> = ["NAME", "CAPTION", "RESULTS", "HEADER", "PLOT"]
@@ -1479,12 +1481,12 @@ Expected: failures; every element parses as a paragraph.
14791481 }
14801482```
14811483
1482- [ ] **Step 4: Run all tests**
1484- [x] **Step 4: Run all tests**
14831485
14841486Run: `swift test`
14851487Expected: all pass, including Task 5's tests.
14861488
1487- [ ] **Step 5: Commit**
1489- [x] **Step 5: Commit**
14881490
14891491```bash
14901492git add Sources Tests
@@ -1502,7 +1504,7 @@ git commit -m "Parse block-level elements"
15021504- Consumes: `SourceText`, `OrgParser`, `SyntaxNode`.
15031505- Produces: a seeded fuzz test (2,000 documents), a structural invariant check, and an opt-in corpus test driven by `ORGSTAR_CORPUS`.
15041506
1505- [ ] **Step 1: Write the tests**
1507- [x] **Step 1: Write the tests**
15061508
15071509```swift
15081510import Foundation
@@ -1582,17 +1584,17 @@ struct RoundTripTests {
15821584}
15831585```
15841586
1585- [ ] **Step 2: Run the tests**
1587- [x] **Step 2: Run the tests**
15861588
15871589Run: `swift test`
15881590Expected: all pass. The corpus test is skipped.
15891591
1590- [ ] **Step 3: Run the private corpus locally**
1592- [x] **Step 3: Run the private corpus locally**
15911593
15921594Run: `ORGSTAR_CORPUS=~/org swift test --filter corpusRoundTrips`
15931595Expected: pass. Any failure names the file; reduce it to a fuzz fragment or a unit test before fixing.
15941596
1595- [ ] **Step 4: Commit**
1597- [x] **Step 4: Commit**
15961598
15971599```bash
15981600git add Tests
docs/plans/2026-10-04-performance.md +10 −10
@@ -48,7 +48,7 @@ Run the gates: `ORGSTAR_GATES=1 ORGSTAR_GATE_FILE=<a large real file> swift test
4848**Files:**
4949- Modify: `Sources/OrgCore/Parser/Inline.swift`, `Sources/OrgCore/Timestamp.swift`
5050
51- [ ] **Step 1: Rewrite the scanner and the timestamp recognizer over `[Unicode.Scalar]`**
51- [x] **Step 1: Rewrite the scanner and the timestamp recognizer over `[Unicode.Scalar]`**
5252
5353The existing inline, timestamp and round-trip tests are the specification; they don't change.
5454
@@ -572,7 +572,7 @@ index da5ac94..bd71851 100644
572572+}
573573```
574574
575- [ ] **Step 2: Run tests, the corpus and the reparse gate; commit**
575- [x] **Step 2: Run tests, the corpus and the reparse gate; commit**
576576
577577Run: `swift test`; `ORGSTAR_CORPUS=<folder> swift test -c release --filter corpusRoundTrips` for each local folder; `ORGSTAR_FUZZ_EDITS=100000 swift test -c release --filter incrementalEqualsFull`.
578578
@@ -592,7 +592,7 @@ git commit -m "Scan inline objects over unicode scalars"
592592**Interfaces:**
593593- Produces: `ReparseStrategy.region`; `SyntaxNode.children(overlapping:)`, `child(containing:)`, `firstChild(_:)`; `GreenBuilder.node(_:)`; `Parser.reusableRows`.
594594
595- [ ] **Step 1: Write the failing tests**
595- [x] **Step 1: Write the failing tests**
596596
597597```diff
598598@@ -49,8 +49,23 @@ struct IncrementalTests {
@@ -623,7 +623,7 @@ git commit -m "Scan inline objects over unicode scalars"
623623 @Test func runGrowsUntilAHeadingEndsIt() {
624624```
625625
626- [ ] **Step 2: Implement**
626- [x] **Step 2: Implement**
627627
628628```diff
629629diff --git a/Sources/OrgCore/Parser/Incremental.swift b/Sources/OrgCore/Parser/Incremental.swift
@@ -909,7 +909,7 @@ index 3473728..0430409 100644
909909 [self] + children.flatMap { $0.descendants() }
910910```
911911
912- [ ] **Step 3: Run the gate on several seeds; commit**
912- [x] **Step 3: Run the gate on several seeds; commit**
913913
914914Run: `ORGSTAR_FUZZ_SEED=<n> ORGSTAR_FUZZ_EDITS=100000 swift test -c release --filter incrementalEqualsFull` for at least five seeds.
915915
@@ -929,7 +929,7 @@ git commit -m "Reparse structural edits within one section's body"
929929**Interfaces:**
930930- Produces: `OrgEditor.finishStyling()`, `OrgEditor.styledUpTo`, `OrgEditor.firstStyleChunk`, `OrgEditor.styleChunk`; test `Harness(_:layout:)`, `Harness.drainStyling()`.
931931
932- [ ] **Step 1: Write the failing tests**
932- [x] **Step 1: Write the failing tests**
933933
934934```diff
935935@@ -10,13 +10,24 @@ final class Harness {
@@ -989,7 +989,7 @@ git commit -m "Reparse structural edits within one section's body"
989989+}
990990```
991991
992- [ ] **Step 2: Implement**
992- [x] **Step 2: Implement**
993993
994994```diff
995995diff --git a/Sources/OrgDocument/ViewState.swift b/Sources/OrgDocument/ViewState.swift
@@ -1179,7 +1179,7 @@ index 312d7f8..504e0b5 100644
11791179 node = child
11801180```
11811181
1182- [ ] **Step 3: Run the restyle fuzz on several seeds; commit**
1182- [x] **Step 3: Run the restyle fuzz on several seeds; commit**
11831183
11841184Run: `ORGSTAR_FUZZ_SEED=<n> ORGSTAR_RESTYLE_EDITS=1500 swift test -c release --filter RestyleFuzzTests` for at least three seeds.
11851185
@@ -1196,7 +1196,7 @@ git commit -m "Style the first screen first and narrow restyles"
11961196- Create: `Tests/OrgEditorAppKitTests/GateTests.swift`
11971197- Modify: `docs/design.md` (memory gate)
11981198
1199- [ ] **Step 1: Add the gate suite**
1199- [x] **Step 1: Add the gate suite**
12001200
12011201```swift
12021202import AppKit
@@ -1306,7 +1306,7 @@ struct GateTests {
13061306}
13071307```
13081308
1309- [ ] **Step 2: Run the gates; commit**
1309- [x] **Step 2: Run the gates; commit** (gates run on an M-series Mac, recorded in docs/design.md; the M1 Air run is owed)
13101310
13111311Run: `ORGSTAR_GATES=1 ORGSTAR_GATE_FILE=<large real file> swift test -c release --filter GateTests`
13121312
docs/plans/2026-10-04-semantic-layer.md +17 −17
@@ -43,7 +43,7 @@ Merging `:results` values by group (collection, type, format, handling), languag
4343**Interfaces:**
4444- Produces: `SemanticSettings` (`.default`, `PropertyInheritance` `.none`/`.all`/`.only(Set<String>)` of upper-cased keys), `ValueSource` (`.defaults`, `.file`, `.heading(Int)`, `.element`), `Resolved<Value>(_:_:)`, `Property(key:value:additive:)` and internal `Property(line:)`, `Clock(start:end:minutes:)`, `HeadingInfo`, `displayWidth(_:)`, `TableModel` (internal `init(node:heading:)`), `SrcBlockInfo`, `HeaderArguments.defaults`, `HeaderArguments.parse(_:) -> [(key: String, value: String)]`.
4545
46- [ ] **Step 1: Write the failing tests**
46- [x] **Step 1: Write the failing tests**
4747
4848```swift
4949import Testing
@@ -64,12 +64,12 @@ struct SemanticValueTests {
6464}
6565```
6666
67- [ ] **Step 2: Run to verify failure**
67- [x] **Step 2: Run to verify failure**
6868
6969Run: `swift test --filter SemanticValueTests`
7070Expected: build failure, `cannot find 'HeaderArguments' in scope`.
7171
72- [ ] **Step 3: Implement `SemanticSettings.swift`**
72- [x] **Step 3: Implement `SemanticSettings.swift`**
7373
7474```swift
7575/// App-wide settings that change what a document means without changing how it parses.
@@ -121,7 +121,7 @@ public struct Resolved<Value: Sendable & Equatable>: Sendable, Equatable {
121121}
122122```
123123
124- [ ] **Step 4: Implement `HeadingInfo.swift`**
124- [x] **Step 4: Implement `HeadingInfo.swift`**
125125
126126```swift
127127import Foundation
@@ -193,7 +193,7 @@ public struct HeadingInfo: Sendable, Equatable {
193193}
194194```
195195
196- [ ] **Step 5: Implement `DisplayWidth.swift`**
196- [x] **Step 5: Implement `DisplayWidth.swift`**
197197
198198```swift
199199/// Columns a string occupies in a monospaced table: East Asian wide and fullwidth characters
@@ -215,7 +215,7 @@ func displayWidth(of character: Character) -> Int {
215215}
216216```
217217
218- [ ] **Step 6: Implement `TableModel.swift`**
218- [x] **Step 6: Implement `TableModel.swift`**
219219
220220```swift
221221import Foundation
@@ -261,7 +261,7 @@ public struct TableModel: Sendable, Equatable {
261261}
262262```
263263
264- [ ] **Step 7: Implement `SrcBlockInfo.swift`**
264- [x] **Step 7: Implement `SrcBlockInfo.swift`**
265265
266266```swift
267267public struct SrcBlockInfo: Sendable, Equatable {
@@ -302,12 +302,12 @@ public enum HeaderArguments {
302302}
303303```
304304
305- [ ] **Step 8: Run to verify pass**
305- [x] **Step 8: Run to verify pass**
306306
307307Run: `swift test --filter SemanticValueTests`
308308Expected: all pass.
309309
310- [ ] **Step 9: Commit**
310- [x] **Step 9: Commit**
311311
312312```bash
313313git add Sources/OrgCore/Semantic Tests/OrgCoreTests/SemanticValueTests.swift
@@ -326,7 +326,7 @@ git commit -m "Add semantic value types"
326326- Consumes: Task 1 types, `OrgTree`, `SyntaxNode`, `Timestamp.parse`, `SettingsScanner.keywordValue`, `splitRawLines`.
327327- Produces: `DocumentModel(tree:settings:)` with `headings`, `fileTags`, `fileProperties`, `tables`, `srcBlocks`, `ancestors(of:)`, `outlinePath(of:)`, `inherits(_:)`, `property(_:of:) -> Resolved<String>?`, `tags(of:) -> [Resolved<String>]`.
328328
329- [ ] **Step 1: Write the failing tests**
329- [x] **Step 1: Write the failing tests**
330330
331331```swift
332332import Testing
@@ -490,12 +490,12 @@ struct TableModelTests {
490490}
491491```
492492
493- [ ] **Step 2: Run to verify failure**
493- [x] **Step 2: Run to verify failure**
494494
495495Run: `swift test --filter HeadingInfoTests`
496496Expected: build failure, `cannot find 'DocumentModel' in scope`.
497497
498- [ ] **Step 3: Implement**
498- [x] **Step 3: Implement**
499499
500500```swift
501501import Foundation
@@ -791,12 +791,12 @@ public struct DocumentModel: Sendable {
791791}
792792```
793793
794- [ ] **Step 4: Run all tests**
794- [x] **Step 4: Run all tests**
795795
796796Run: `swift test`
797797Expected: all pass.
798798
799- [ ] **Step 5: Commit**
799- [x] **Step 5: Commit**
800800
801801```bash
802802git add Sources/OrgCore/Semantic/DocumentModel.swift Tests/OrgCoreTests/SemanticTests.swift
@@ -810,7 +810,7 @@ git commit -m "Add document model with inheritance and header arguments"
810810**Files:**
811811- Modify: `Tests/OrgCoreTests/RoundTripTests.swift`
812812
813- [ ] **Step 1: Build a model for every parsed document**
813- [x] **Step 1: Build a model for every parsed document**
814814
815815```diff
816816@@ -45,6 +45,7 @@ struct RoundTripTests {
@@ -831,12 +831,12 @@ git commit -m "Add document model with inheritance and header arguments"
831831 }
832832```
833833
834- [ ] **Step 2: Run**
834- [x] **Step 2: Run**
835835
836836Run: `swift test` then `ORGSTAR_CORPUS=~/Documents/notes swift test --filter corpusRoundTrips`
837837Expected: all pass, no crashes.
838838
839- [ ] **Step 3: Commit**
839- [x] **Step 3: Commit**
840840
841841```bash
842842git add Tests/OrgCoreTests/RoundTripTests.swift
docs/plans/2026-10-04-viewer.md +11 −11
@@ -46,7 +46,7 @@
4646**Interfaces:**
4747- Produces: `FoldState`, `GlobalVisibility`, `OutlineEntry`, `Presentation.outline(_:)`, `cycle(_:in:_:)`, `cycleGlobal(from:in:)`, `foldState(for:in:)`, `foldState(showingLevels:in:)`, `startupFoldState(_:)`, `startupOptions(_:)`; `ViewState.bodyFolds`; `OrgEditor(document:frame:editable:)`, `foldState`, `setFolds(_ state: FoldState)`, `cycleAtCaret()`, `cycleGlobal()`, `reveal(_:)`, `diskChanged(to:)`, `hangingColumns(_:)`.
4848
49- [ ] **Step 1: Write the failing tests**
49- [x] **Step 1: Write the failing tests**
5050
5151```diff
5252diff --git a/Tests/OrgEditorAppKitTests/EditorTests.swift b/Tests/OrgEditorAppKitTests/EditorTests.swift
@@ -214,7 +214,7 @@ index 6e1ca3d..7007d92 100644
214214+}
215215```
216216
217- [ ] **Step 2: Implement**
217- [x] **Step 2: Implement**
218218
219219```swift
220220import OrgCore
@@ -658,7 +658,7 @@ index 504e0b5..1813443 100644
658658
659659```
660660
661- [ ] **Step 3: Run and commit**
661- [x] **Step 3: Run and commit**
662662
663663Run: `swift test`
664664
@@ -676,7 +676,7 @@ git commit -m "Cycle folds, apply #+STARTUP visibility and indent wrapped lines"
676676- Create: `Sources/OrgApp/FileTree.swift`, `Sources/OrgApp/WorkspaceModel.swift`, `Sources/OrgApp/DocumentSession.swift`
677677- Test: `Tests/OrgAppTests/AppTests.swift`
678678
679- [ ] **Step 1: Write the failing tests**
679- [x] **Step 1: Write the failing tests**
680680
681681```swift
682682import Foundation
@@ -796,7 +796,7 @@ struct DocumentSessionTests {
796796}
797797```
798798
799- [ ] **Step 2: Implement**
799- [x] **Step 2: Implement**
800800
801801```swift
802802import Foundation
@@ -1202,7 +1202,7 @@ index 517c833..556ca69 100644
12021202 /// One reconciliation's worth of changes, applied in a single transaction.
12031203```
12041204
1205- [ ] **Step 3: Run and commit**
1205- [x] **Step 3: Run and commit**
12061206
12071207Run: `swift test --filter OrgAppTests`
12081208
@@ -1219,7 +1219,7 @@ git commit -m "Add workspace and document session models"
12191219- Modify: `Package.swift` (add the `Orgstar` executable), `README.md`
12201220- Create: `Sources/Orgstar/OrgstarApp.swift`, `ContentView.swift`, `EditorView.swift`, `DevelopmentHooks.swift`, `scripts/build-app.sh`
12211221
1222- [ ] **Step 1: Implement**
1222- [x] **Step 1: Implement**
12231223
12241224```swift
12251225import OrgApp
@@ -1598,7 +1598,7 @@ codesign --force --sign - "$app"
15981598echo "$app"
15991599```
16001600
1601- [ ] **Step 2: Build, run and snapshot**
1601- [x] **Step 2: Build, run and snapshot**
16021602
16031603Run: `scripts/build-app.sh`, then with a seeded data directory:
16041604`ORGSTAR_DATA_DIR=<dir> ORGSTAR_OPEN=<file.org> ORGSTAR_SNAPSHOT=/tmp/shot.png .build/app/Orgstar.app/Contents/MacOS/Orgstar`
@@ -1606,7 +1606,7 @@ Check: outline column lists the file's headings by level; the editor shows hidde
16061606
16071607Manual: add a folder with ⇧⌘O; ⌘P opens a file; ⇧⌘F search opens results that reveal the heading; TAB and Shift-TAB fold; editing the file in Emacs reloads the view.
16081608
1609- [ ] **Step 3: Commit**
1609- [x] **Step 3: Commit**
16101610
16111611```bash
16121612git add Package.swift README.md Sources/Orgstar scripts
@@ -1622,7 +1622,7 @@ Per-line hanging indents gave every line its own `NSParagraphStyle`, which pushe
16221622**Files:**
16231623- Modify: `Sources/OrgEditorAppKit/OrgEditor.swift`
16241624
1625- [ ] **Step 1: Implement**
1625- [x] **Step 1: Implement**
16261626
16271627```diff
16281628@@ -59,6 +59,13 @@ public final class OrgEditor: NSObject {
@@ -1674,7 +1674,7 @@ Per-line hanging indents gave every line its own `NSParagraphStyle`, which pushe
16741674 return clipped.isEmpty ? nil : NSRange(clipped)
16751675```
16761676
1677- [ ] **Step 2: Run the gates; commit**
1677- [x] **Step 2: Run the gates; commit** (gates run on an M-series Mac, recorded in docs/design.md; the M1 Air run is owed)
16781678
16791679Run: `ORGSTAR_GATES=1 ORGSTAR_GATE_FILE=<large real file> swift test -c release --filter GateTests`
16801680
docs/plans/2026-10-04-workspace-index.md +18 −18
@@ -46,7 +46,7 @@ Agenda queries (phase 3), security-scoped bookmark creation in a sandbox (the Ma
4646- Consumes: `OrgParser`, `DocumentModel`, `SourceText`, `Timestamp`.
4747- Produces: `FileKind`, `IndexSettings(version:org:semantic:)`, `FileRecord(path:root:kind:bytes:mtime:settings:)`, `FileRecord.hash(_:)`, `HeadingRecord`, `TagRow`, `PropertyRow`, `TimestampRow`, `ClockRow`, `LinkRow`.
4848
49- [ ] **Step 1: Add the target**
49- [x] **Step 1: Add the target**
5050
5151```swift
5252// swift-tools-version: 6.2
@@ -74,7 +74,7 @@ let package = Package(
7474)
7575```
7676
77- [ ] **Step 2: Write the failing tests**
77- [x] **Step 2: Write the failing tests**
7878
7979```swift
8080import OrgCore
@@ -144,7 +144,7 @@ struct FileRecordTests {
144144}
145145```
146146
147- [ ] **Step 3: Implement**
147- [x] **Step 3: Implement**
148148
149149```swift
150150import CryptoKit
@@ -358,7 +358,7 @@ public struct FileRecord: Sendable, Equatable {
358358}
359359```
360360
361- [ ] **Step 4: Run to verify pass, then commit**
361- [x] **Step 4: Run to verify pass, then commit**
362362
363363Run: `swift test --filter FileRecordTests`
364364
@@ -379,7 +379,7 @@ git commit -m "Add index file records"
379379- Consumes: `FileRecord` (Task 1).
380380- Produces: `IndexStore(path:)`, `write(_:)`, `apply(_ change: IndexChange)`, `fileStates(root:) -> [String: FileState]`, `files()`, `search(_:overlay:limit:)`, `headings(withID:overlay:)`, `duplicateIDs(overlay:)`; `FileState`, `HeadingLocation`, `IndexChange`.
381381
382- [ ] **Step 1: Write the failing tests**
382- [x] **Step 1: Write the failing tests**
383383
384384```swift
385385import OrgCore
@@ -450,7 +450,7 @@ struct IndexStoreTests {
450450}
451451```
452452
453- [ ] **Step 2: Implement**
453- [x] **Step 2: Implement**
454454
455455```swift
456456import Foundation
@@ -770,7 +770,7 @@ public final class IndexStore: Sendable {
770770}
771771```
772772
773- [ ] **Step 3: Run to verify pass, then commit**
773- [x] **Step 3: Run to verify pass, then commit**
774774
775775Run: `swift test --filter IndexStoreTests`
776776
@@ -792,7 +792,7 @@ git commit -m "Add SQLite index store with search and overlay"
792792- Consumes: `FileKind` (Task 1).
793793- Produces: `WorkspaceRoot(url:)` with `resolve()`, `DiscoveredFile`, `Discovery`, `FileClassification`, `WorkspaceScanner.classify(_:)`, `WorkspaceScanner.scan(_:)`, `AgendaScope(globs:)` with `contains(relativePath:kind:)`; test helper `Folder`.
794794
795- [ ] **Step 1: Add the target**
795- [x] **Step 1: Add the target**
796796
797797```swift
798798// swift-tools-version: 6.2
@@ -823,7 +823,7 @@ let package = Package(
823823)
824824```
825825
826- [ ] **Step 2: Write the failing tests**
826- [x] **Step 2: Write the failing tests**
827827
828828```swift
829829import Foundation
@@ -900,7 +900,7 @@ struct ScanTests {
900900}
901901```
902902
903- [ ] **Step 3: Implement**
903- [x] **Step 3: Implement**
904904
905905```swift
906906import Foundation
@@ -1015,7 +1015,7 @@ public struct AgendaScope: Sendable, Equatable {
10151015}
10161016```
10171017
1018- [ ] **Step 4: Run to verify pass, then commit**
1018- [x] **Step 4: Run to verify pass, then commit**
10191019
10201020Run: `swift test --filter "ClassificationTests|ScanTests"`
10211021
@@ -1036,7 +1036,7 @@ git commit -m "Add workspace discovery and agenda scope"
10361036- Consumes: Tasks 1–3.
10371037- Produces: `Reconciler(index:settings:)` with `reconcile(root:)` and `reconcile(root:paths:)`, `ReconcileReport`.
10381038
1039- [ ] **Step 1: Write the failing tests**
1039- [x] **Step 1: Write the failing tests**
10401040
10411041```swift
10421042import Foundation
@@ -1122,7 +1122,7 @@ struct ReconcileTests {
11221122}
11231123```
11241124
1125- [ ] **Step 2: Implement**
1125- [x] **Step 2: Implement**
11261126
11271127```swift
11281128import Foundation
@@ -1228,7 +1228,7 @@ public struct Reconciler: Sendable {
12281228}
12291229```
12301230
1231- [ ] **Step 3: Run to verify pass, then commit**
1231- [x] **Step 3: Run to verify pass, then commit**
12321232
12331233Run: `swift test --filter ReconcileTests`
12341234
@@ -1248,7 +1248,7 @@ git commit -m "Add index reconciliation"
12481248**Interfaces:**
12491249- Produces (macOS): `WatchEvent` (`.changed(URL)`, `.rescan(URL)`), `FSEventsWatcher(roots:latency:handler:)` with `start()`, `stop()`.
12501250
1251- [ ] **Step 1: Write the failing test**
1251- [x] **Step 1: Write the failing test**
12521252
12531253```swift
12541254import Foundation
@@ -1291,7 +1291,7 @@ final class Received: @unchecked Sendable {
12911291}
12921292```
12931293
1294- [ ] **Step 2: Implement**
1294- [x] **Step 2: Implement**
12951295
12961296```swift
12971297#if os(macOS)
@@ -1374,12 +1374,12 @@ public final class FSEventsWatcher: @unchecked Sendable {
13741374#endif
13751375```
13761376
1377- [ ] **Step 3: Run everything, the iOS build and the gates**
1377- [x] **Step 3: Run everything, the iOS build and the gates** (gates run on an M-series Mac, recorded in docs/design.md; the M1 Air run is owed)
13781378
13791379Run: `swift test`, then `xcodebuild -scheme OrgWorkspace -destination 'generic/platform=iOS' build`.
13801380Gates: reconcile a folder of 10,000 org files into an empty index (under 30 s), then again with no changes (under 2 s), in a release build on the reference machine.
13811381
1382- [ ] **Step 4: Commit**
1382- [x] **Step 4: Commit**
13831383
13841384```bash
13851385git add Sources/OrgWorkspace/FSEventsWatcher.swift Tests/OrgWorkspaceTests/WatcherTests.swift
docs/plans/2026-10-05-commands.md +4 −4
@@ -122,7 +122,7 @@ Run `swift test`, the reparse gate and the corpus round trip; commit: `git commi
122122
123123**Files:** create `Sources/OrgCore/Commands/Command.swift`, `Sources/OrgCore/Commands/HeadingCommands.swift`, `Tests/OrgCoreTests/EmacsOracle.swift`, `Tests/OrgCoreTests/HeadingCommandTests.swift`; modify `Sources/OrgCore/Parser/Incremental.swift` (its private `EditContext` becomes `ReparseContext`).
124124
125- [ ] **Step 1: The oracle and the tests**
125- [x] **Step 1: The oracle and the tests**
126126
127127```swift
128128import Foundation
@@ -387,7 +387,7 @@ struct HeadingOracleTests {
387387}
388388```
389389
390- [ ] **Step 2: The command model**
390- [x] **Step 2: The command model**
391391
392392```swift
393393import Foundation
@@ -487,7 +487,7 @@ public enum Commands {
487487}
488488```
489489
490- [ ] **Step 3: The heading commands**
490- [x] **Step 3: The heading commands**
491491
492492```swift
493493import Foundation
@@ -893,7 +893,7 @@ index 9f8347a..976b9b4 100644
893893 let edit: TextEdit
894894```
895895
896- [ ] **Step 4: Run the oracle, including a corpus; commit**
896- [x] **Step 4: Run the oracle, including a corpus; commit**
897897
898898Run: `swift test --filter HeadingOracleTests`, then `ORGSTAR_ORACLE_CORPUS=<folder> swift test --filter headingCommandsMatchEmacsOnACorpus` for each local folder.
899899
docs/plans/2026-10-05-fill.md +3 −3
@@ -25,9 +25,9 @@
2525
2626### Task 1: Fill
2727
28- [ ] Port; oracle over 16 variants (items, comments, quotes, line breaks, timestamps, links, captions, markup at line start, extra spaces) at both fill columns, and over corpus paragraphs (src blocks excluded).
29- [ ] Commit "Port fill paragraph".
28- [x] Port; oracle over 16 variants (items, comments, quotes, line breaks, timestamps, links, captions, markup at line start, extra spaces) at both fill columns, and over corpus paragraphs (src blocks excluded).
29- [x] Commit "Port fill paragraph".
3030
3131### Task 2: App
3232
33- [ ] M-q / ⌃⌘P; Settings fill column.
33- [x] M-q / ⌃⌘P; Settings fill column.
docs/plans/2026-10-05-highlighting.md +2 −2
@@ -25,5 +25,5 @@
2525
2626### Task 1: Highlighting
2727
28- [ ] Hook, highlighter, vendored grammars and scanners, embedded queries, theme colors; tests for categories in Python, shell and Emacs Lisp and for runs in a src block; app snapshot.
29- [ ] Commit "Highlight src blocks with tree-sitter".
28- [x] Hook, highlighter, vendored grammars and scanners, embedded queries, theme colors; tests for categories in Python, shell and Emacs Lisp and for runs in a src block; app snapshot.
29- [x] Commit "Highlight src blocks with tree-sitter".
docs/plans/2026-10-05-keymaps.md +5 −5
@@ -43,8 +43,8 @@
4343
4444`KeyChord.parse`, `KeySequence.parse/format`, `TOML.parse`, `Keymap(toml:problems:)`, `Keymap.layered`, `candidates(for:mode:)`, `isPrefix`, `continuations(of:)`, `keys(for:)`, `KeyContext.holds`, `KeyDispatcher.feed` returning `.pending`, `.complete`, `.undefined`, `.unbound` or `.cancelled`.
4545
46- [ ] Tests: notation round trips and shift folding; TOML tables, escapes and error lines; bad entries skipped with problems; later layers win and `none` unbinds; prefix dispatch, undefined sequences and C-g; continuations; contexts; presets parse.
47- [ ] Commit "Add keymaps".
46- [x] Tests: notation round trips and shift folding; TOML tables, escapes and error lines; bad entries skipped with problems; later layers win and `none` unbinds; prefix dispatch, undefined sequences and C-g; continuations; contexts; presets parse.
47- [x] Commit "Add keymaps".
4848
4949### Task 2: Keys in the editor
5050
@@ -53,8 +53,8 @@
5353- `edit.set-mark` starts a region that movement extends; C-g, editing, kill and copy end it.
5454- Option as Meta per side, from the device-dependent modifier bits.
5555- `onKeysPending(String?, [(key, title)])`, `onAppCommand(String)`, and `run(_ id:)` for menus and the palette.
56- [ ] Tests with synthesized key events: C-c C-t cycles TODO; TAB folds on a heading and inserts a tab in a paragraph; C-SPC C-f C-w kills one character; M-f moves a word with left Option and types with right Option; C-x C-s reaches `onAppCommand`; an undefined sequence reports a message; pending keys are reported.
57- [ ] Commit "Run commands from keys".
56- [x] Tests with synthesized key events: C-c C-t cycles TODO; TAB folds on a heading and inserts a tab in a paragraph; C-SPC C-f C-w kills one character; M-f moves a word with left Option and types with right Option; C-x C-s reaches `onAppCommand`; an undefined sequence reports a message; pending keys are reported.
57- [x] Commit "Run commands from keys".
5858
5959### Task 3: App
6060
@@ -62,4 +62,4 @@
6262- Echo area at the bottom of the editor: pending keys and command messages. which-key popup lists the continuations with command titles.
6363- Command palette (M-x, ⇧⌘P): fuzzy search over command titles, showing each command's keys; runs on the editor.
6464- Org menu with the org commands.
65- [ ] Verify with the snapshot hook; commit "Keymaps, echo area and palette in the app".
65- [x] Verify with the snapshot hook; commit "Keymaps, echo area and palette in the app".
docs/plans/2026-10-05-lists.md +4 −4
@@ -31,10 +31,10 @@
3131
3232### Task 1: List machinery and commands
3333
34- [ ] Port the machinery and the nine commands; unit tests; oracle over 13 variants at every caret and over the corpus (`ORGSTAR_ORACLE_CORPUS`, item lines in files up to 20 KB).
35- [ ] Commit "Port plain list commands from org".
34- [x] Port the machinery and the nine commands; unit tests; oracle over 13 variants at every caret and over the corpus (`ORGSTAR_ORACLE_CORPUS`, item lines in files up to 20 KB).
35- [x] Commit "Port plain list commands from org".
3636
3737### Task 2: Keys
3838
39- [ ] Emacs preset: item bindings on M-RET, M-S-RET, M-arrows, M-S-arrows with `when = "item"`; C-c C-c on items; C-c C-x C-b. Mac preset: the same on its chords, ⌃⌘C to toggle.
40- [ ] Commit "Bind list keys".
39- [x] Emacs preset: item bindings on M-RET, M-S-RET, M-arrows, M-S-arrows with `when = "item"`; C-c C-c on items; C-c C-x C-b. Mac preset: the same on its chords, ⌃⌘C to toggle.
40- [x] Commit "Bind list keys".
docs/plans/2026-10-05-options.md +5 −5
@@ -23,11 +23,11 @@ The user's Emacs is Doom, which sets tags column 0, M-RET after the subtree with
2323
2424### Task 1: Options in commands
2525
26- [ ] `EditingOptions`; plumb through every command; alphabetical bullets.
27- [ ] Oracle: heading, structure and list suites again under the Doom options (`withOptions` binds the variables around each case), plus alphabetical list variants.
28- [ ] Commit "Make org editing options settings".
26- [x] `EditingOptions`; plumb through every command; alphabetical bullets.
27- [x] Oracle: heading, structure and list suites again under the Doom options (`withOptions` binds the variables around each case), plus alphabetical list variants.
28- [x] Commit "Make org editing options settings".
2929
3030### Task 2: App
3131
32- [ ] Settings section; options to the editor and session; default keywords to documents and the index at launch.
33- [ ] Commit "Org options in Settings".
32- [x] Settings section; options to the editor and session; default keywords to documents and the index at launch.
33- [x] Commit "Org options in Settings".
docs/plans/2026-10-05-refile-archive.md +4 −4
@@ -24,10 +24,10 @@
2424
2525### Task 1: Core
2626
27- [ ] Port refile, archive and statistics; oracles: refile within a file and to another file (4 sources × every caret × every target, 5 target files), archive (7 sources × 4 archive files), TODO cycle and TODO-heading insert with parent cookies.
28- [ ] Commit "Port refile, archive and TODO statistics from org".
27- [x] Port refile, archive and statistics; oracles: refile within a file and to another file (4 sources × every caret × every target, 5 target files), archive (7 sources × 4 archive files), TODO cycle and TODO-heading insert with parent cookies.
28- [x] Commit "Port refile, archive and TODO statistics from org".
2929
3030### Task 2: Session and app
3131
32- [ ] `DocumentBuffer.selection` and `perform`; `PrecomputedEdit`; `DocumentSession.refile(to:)`, `archive()`; `WorkspaceModel.refileTargets`; prompt choices; keys and palette entries.
33- [ ] Commit "Refile and archive in the app".
32- [x] `DocumentBuffer.selection` and `perform`; `PrecomputedEdit`; `DocumentSession.refile(to:)`, `archive()`; `WorkspaceModel.refileTargets`; prompt choices; keys and palette entries.
33- [x] Commit "Refile and archive in the app".
docs/plans/2026-10-05-structure.md +6 −6
@@ -36,12 +36,12 @@
3636
3737### Task 1: Buffer and structure commands
3838
39- [ ] Port `org-insert-heading` (with `org--blank-before-heading-p`, `org-N-empty-lines-before-current`), `org-insert-todo-heading`, `org-move-subtree-down`, `org-promote-subtree`/`org-demote-subtree` (`org-map-tree`, `org-promote`, `org-demote`, `org-fix-position-after-promote`), `org-next-visible-heading`, `org-forward-heading-same-level`, `outline-up-heading`.
40- [ ] Oracle: every command at every caret of ten variants (levels, blank lines, tags, text before the first heading, no final newline, non-BMP) and over the corpus (`ORGSTAR_ORACLE_CORPUS`, files up to 20 KB).
41- [ ] Commit "Port heading structure commands from org".
39- [x] Port `org-insert-heading` (with `org--blank-before-heading-p`, `org-N-empty-lines-before-current`), `org-insert-todo-heading`, `org-move-subtree-down`, `org-promote-subtree`/`org-demote-subtree` (`org-map-tree`, `org-promote`, `org-demote`, `org-fix-position-after-promote`), `org-next-visible-heading`, `org-forward-heading-same-level`, `outline-up-heading`.
40- [x] Oracle: every command at every caret of ten variants (levels, blank lines, tags, text before the first heading, no final newline, non-BMP) and over the corpus (`ORGSTAR_ORACLE_CORPUS`, files up to 20 KB).
41- [x] Commit "Port heading structure commands from org".
4242
4343### Task 2: Tags and prompts
4444
45- [ ] `SetTags`: prompt with the current tags, then `org-set-tags` semantics (realign even when unchanged). Oracle with `completing-read-multiple` stubbed to the answer.
46- [ ] Editor `onPrompt`; app minibuffer field (Return answers, Escape cancels); key bindings in both presets.
47- [ ] Commit "Set tags through a prompt".
45- [x] `SetTags`: prompt with the current tags, then `org-set-tags` semantics (realign even when unchanged). Oracle with `completing-read-multiple` stubbed to the answer.
46- [x] Editor `onPrompt`; app minibuffer field (Return answers, Escape cancels); key bindings in both presets.
47- [x] Commit "Set tags through a prompt".
docs/plans/2026-10-05-tables.md +3 −3
@@ -25,9 +25,9 @@
2525
2626### Task 1: Visible widths
2727
28- [ ] `VisibleLine`; tag alignment, columns and fill use it; oracle passes refontified.
28- [x] `VisibleLine`; tag alignment, columns and fill use it; oracle passes refontified.
2929
3030### Task 2: Tables
3131
32- [ ] Port; oracle over 11 tables (numbers, rules, indentation, links, emphasis, entities, cookies, TBLFM, unicode, ragged rows) × every caret × 13 commands at both option sets; table creation; real tables in all three corpora.
33- [ ] Commit "Port org tables".
32- [x] Port; oracle over 11 tables (numbers, rules, indentation, links, emphasis, entities, cookies, TBLFM, unicode, ragged rows) × every caret × 13 commands at both option sets; table creation; real tables in all three corpora.
33- [x] Commit "Port org tables".
docs/plans/2026-10-05-timestamps.md +5 −5
@@ -24,14 +24,14 @@
2424
2525### Task 1: Date prompt
2626
27- [ ] Port; oracle over 52 inputs (relative, weekdays, ISO weeks, US and European dates, am/pm, `HHhMM`, ranges, durations).
28- [ ] Commit "Port the date prompt".
27- [x] Port; oracle over 52 inputs (relative, weekdays, ISO weeks, US and European dates, am/pm, `HHhMM`, ranges, durations).
28- [x] Commit "Port the date prompt".
2929
3030### Task 2: Timestamps, planning, repeats
3131
32- [ ] Port; oracle over 7 texts × every caret × 9 commands × 6 answers, and 10 repeating entries.
33- [ ] Commit "Port timestamp and planning commands".
32- [x] Port; oracle over 7 texts × every caret × 9 commands × 6 answers, and 10 repeating entries.
33- [x] Commit "Port timestamp and planning commands".
3434
3535### Task 3: Keys
3636
37- [ ] Bind both presets; `timestamp` context.
37- [x] Bind both presets; `timestamp` context.
docs/plans/2026-10-05-writable-app.md +8 −8
@@ -63,9 +63,9 @@ extension OrgEditor: DocumentBuffer // plus `public var onChange: (() -> Void)
6363
6464`OrgEditor.update` records the text and selection, runs the change, and if the text changed: computes `lineEdits(from:to:)`, reloads the storage, maps folds and the selection through the edits, and removes the text view's undo actions (they refer to the old text). `save(using:to:)` and `diskChanged(to:)` become `update` calls; `diskChanged` returns the `ExternalChange`.
6565
66- [ ] Tests: `overwrite` writes ours and keeps the replaced version; editor `update` replacing text keeps the caret on the same line content, keeps folds, and leaves nothing to undo; typing calls `onChange`.
67- [ ] Implement; `swift test` green.
68- [ ] Commit "Add document buffers".
66- [x] Tests: `overwrite` writes ours and keeps the replaced version; editor `update` replacing text keeps the caret on the same line content, keeps folds, and leaves nothing to undo; typing calls `onChange`.
67- [x] Implement; `swift test` green.
68- [x] Commit "Add document buffers".
6969
7070### Task 2: Session saving
7171
@@ -99,9 +99,9 @@ extension WorkspaceModel {
9999
100100`fileChanged` calls `buffer.update { $0.diskChanged(to:) }` and sets `conflict` on a conflict; `diskBytes` goes away. `show(_:)` uses indexed offsets only when the buffer is clean.
101101
102- [ ] Tests: edit then `save` writes and clears dirty; automatic mode saves after the delay, explicit does not; an external change merges into an edited buffer; a conflicting change sets `conflict`, blocks saving, and `keepMine` writes ours with theirs in recovery while `useDiskVersion` loads theirs with ours in recovery; search with the overlay finds an unsaved heading.
103- [ ] Implement; `swift test` green.
104- [ ] Commit "Save from the session".
102- [x] Tests: edit then `save` writes and clears dirty; automatic mode saves after the delay, explicit does not; an external change merges into an edited buffer; a conflicting change sets `conflict`, blocks saving, and `keepMine` writes ours with theirs in recovery while `useDiskVersion` loads theirs with ours in recovery; search with the overlay finds an unsaved heading.
103- [x] Implement; `swift test` green.
104- [x] Commit "Save from the session".
105105
106106### Task 3: The app
107107
@@ -112,5 +112,5 @@ extension WorkspaceModel {
112112- File ▸ Save (⌘S); Settings (⌘,) with the save mode in `@AppStorage("saveMode")`.
113113- Switching files and quitting with unsaved edits: save in automatic mode, ask in explicit mode; a failed save cancels.
114114- Conflict alert with the three choices.
115- [ ] Verify in the built app with a scratch data dir: type, ⌘S, undo, external edit merges, conflicting external edit shows the alert, search finds unsaved text.
116- [ ] Commit "Edit and save in the app".
115- [x] Verify in the built app with a scratch data dir: type, ⌘S, undo, external edit merges, conflicting external edit shows the alert, search finds unsaved text.
116- [x] Commit "Edit and save in the app".
docs/review-2026-10-05.md +2
@@ -1,5 +1,7 @@
11# Orgstar review, 2026-10-05
22
3Historical. Every tier below shipped between a831086 and 2d3da68 (258 commits). The living list of refusals and gaps is the manual, `docs/manual/guide/15-alongside-emacs.org`, "Known differences from Emacs Org". Of the defects table, the clock report still reads files from disk (`Sources/Orgstar/ClockViews.swift`), tracked as an issue.
4
35Branch `buffers` at a831086. Emacs 31.1 / Org 9.8.7 installed, so the oracle tests ran.
46
57## 1. Current state