Plan for parity between the download and the sandboxed builds !408
1 file changed, +281 −0
Layout: unified · split
docs/plans/2026-11-20-parity.md added +281
| @@ -0,0 +1,281 @@ | ||
| 1 | # orgstar parity plan: Mac App Store and iOS vs the Developer ID build | |
| 2 | ||
| 3 | Repo: /Users/cmc/git/krz/orgstar. Everything here comes from reading the code and the four reader reports. Nothing was built or run. | |
| 4 | ||
| 5 | ## Ground rules | |
| 6 | ||
| 7 | - **The parity target is `emacs -Q`.** The fallbacks run `emacs -Q --batch` (`EmacsRunner`, `BabelRunner`). User Emacs config is not part of the target. | |
| 8 | - **Native code lives in shared modules.** Platform-neutral work goes in OrgCore: Calc, Elisp, the LaTeX and ASCII renderers, and the ODT XML writer. Code that needs a framework goes in OrgApp: JavaScriptCore, and the ODT zip if it stays there. Both are linked by all three app targets, so the Mac App Store and iOS get each feature from one change. | |
| 9 | - **What the Developer ID build uses:** | |
| 10 | - Native wherever the oracle tests show it matches Emacs: LaTeX, ASCII, ODT, and Calc formulas (already native first). | |
| 11 | - The external program when it is installed and does more than the native code: Emacs for Lisp and tables the interpreter can't handle, node for JS, gnuplot for plots, latexmk for PDF through LaTeX. | |
| 12 | - The native path when that program is missing. This fixes the case where a Developer ID user without Emacs can run fewer Emacs Lisp blocks than an App Store user (`BabelRunner.swift:55-59`). | |
| 13 | - **No file splits.** `check-file-sizes.sh` is ignored at your request. `Calc.swift` and `Elisp.swift` will grow past 1,000 lines. | |
| 14 | - **Every milestone below is one merge request** with its own tests and docs. | |
| 15 | ||
| 16 | ## How to use the Emacs oracle tests | |
| 17 | ||
| 18 | All oracle tests are gated on `ORGSTAR_SKIP_ORACLE` being unset, and on Emacs being installed where relevant. | |
| 19 | ||
| 20 | - **Calc:** add expressions to `CalcTests.fixed` (`Tests/OrgCoreTests/CalcTests.swift:40-66`). `CalcOracle.run` runs `calc-eval` with `org-calc-default-modes` and compares strings exactly. | |
| 21 | - Move cases out of `unsupported()` (`:110`) as they become supported (`pi`, `1/0`, `vmean([])`, `5%`, `2 3`). | |
| 22 | - Keep `#expect(skipped == [])`. Any new feature must match Calc or stay `Unsupported`. | |
| 23 | - **Tables:** `TableFormulaTests.compare(_:fallbacksAllowed:)` and `corpusMatchesEmacs` (`Tests/OrgCoreTests/TableFormulaTests.swift:95-165`) run `org-table-recalculate` / `org-ctrl-c-ctrl-c` through `EmacsOracle.run` and compare buffer text, point and error. Add tables that use the new functions. | |
| 24 | - **Elisp:** add a test to `ElispTests` that sends forms to `EmacsOracle.evaluate(text, "(list (format \"%S\" FORM))")` and compares with `Elisp().eval` printed by `prin1-to-string`. | |
| 25 | - **LaTeX and ASCII:** | |
| 26 | - Run `EmacsOracle.evaluate(org, "(list (org-export-as 'latex))")`, and `'ascii` with `(setq org-ascii-charset 'utf-8)` (or `'ascii` / `'latin1`) in `prelude:`. | |
| 27 | - Compare the whole string, after normalizing only `\date{\today}` and the `Created:` / Emacs-version line, which differ by run. | |
| 28 | - Run over the conformance corpus `Tests/OrgCoreTests/Conformance/*.org`, the files `ExportTests.conformance` already uses, plus targeted snippets. | |
| 29 | - Body-only: `(org-export-as 'latex nil nil t)`. | |
| 30 | - **ODT:** ox-odt's styles.xml is a large template, so a byte-for-byte match is not practical. | |
| 31 | - Oracle: `org-odt-export-to-odt` in a temp folder (needs `zip` on the dev machine), unzip `content.xml`. | |
| 32 | - Compare a reduced skeleton: element names `text:h@outline-level`, `text:p`, `text:list`, `table:table` with row/cell counts, `text:a@href`, `text:note`, `draw:image`, and text runs. This follows the `Skeleton.reduce` pattern for HTML (`ExportTests.swift:44`). | |
| 33 | - Also validate the package: `mimetype` is first and stored, `META-INF/manifest.xml` lists every part. | |
| 34 | - **JavaScript:** node is the oracle. Reuse the 8 js cases in `BabelScriptTests.scriptsMatchEmacs` (`Tests/OrgCoreTests/BabelScriptTests.swift:24-67`). Run them once through Emacs/node and once through `JavaScriptBlocks`, and compare the inserted results. Unit-test the `util.inspect` port directly against `node -p 'util.inspect(X)'` for a list of literals. | |
| 35 | ||
| 36 | ## Milestones, highest value first | |
| 37 | ||
| 38 | ### M1. Emacs Lisp interpreter growth, and Developer ID native fallback (M) | |
| 39 | ||
| 40 | Lisp is used by table formulas, Emacs Lisp blocks, `:cache`, capture and diary, so this has the widest effect. | |
| 41 | ||
| 42 | - **Fix:** look up the function or special form before evaluating its arguments (`Elisp.swift:203`). An unknown macro such as `cl-loop` or `pcase` then throws `Unsupported`, which falls back, instead of `#ERROR` from "void variable". | |
| 43 | - **Variables:** add `float-pi`, `pi`, `float-e`. An unknown free variable stays a Signal, as in Emacs. | |
| 44 | - **Math:** `expt sqrt exp log sin cos tan asin acos atan isnan random(seeded? no: real random) logand ash`. | |
| 45 | - **Strings:** | |
| 46 | - `string-match`, `match-string`, `match-beginning`, `match-end`, `replace-regexp-in-string`, `regexp-quote`, `string-join`, `string-to-char`, `char-to-string`, `string-pad`, `string-width`, `string-search`, `string-replace`. | |
| 47 | - New `ElispRegex.swift`: translate Emacs regexp syntax (`\\(`, `\\|`, `\\{n\\}`, `[[:alpha:]]`, `\\b`, `\\w`, `\\s-`, `\\_<`) into NSRegularExpression. Refuse (`Unsupported`) what it can't translate. Point `split-string` at it as well. | |
| 48 | - **Lists, seq and cl:** `sort last butlast delete-dups nreverse seq-reduce seq-filter seq-map seq-uniq seq-remove cl-reduce cl-remove-if cl-remove-if-not cl-find cl-position number-to-string(floats)`. | |
| 49 | - **Special forms:** `defun`, `defvar`, `defconst`, `let-alist`, `pcase` (literal, symbol, `` ` `` and `pred` patterns only; otherwise Unsupported), `cl-loop` (`for/in/from/to/collect/sum/do` only), `cl-incf`, `cl-decf`. | |
| 50 | - **Time:** register the existing functions from `CaptureLisp.swift:85-119` (`current-time`, `format-time-string`) and `DiarySexp.swift:135-310` (`calendar-*`) in a shared `Elisp.standardTime()`. Add `org-time-string-to-time`, `org-time-string-to-absolute`, `time-add`, `time-subtract`, `float-time`, `days-between`, `date-to-time`, `time-to-days`. Make the registration in `TableFormulas.evalLisp` (`:657`) and `Babel.evaluateNatively` call it. | |
| 51 | - **Developer ID:** | |
| 52 | - In `Programs.runBabel` (`Sources/OrgPrograms/Programs.swift:10-12`): for an `.emacs` job when `EmacsRunner.executable() == nil`, return the result of `Babel.evaluateNatively`. | |
| 53 | - In `DocumentSession.recalculateInEmacs`: when Emacs is missing, report the native reason instead of "Emacs isn't installed". | |
| 54 | - **Tests:** | |
| 55 | - `ElispTests` oracle for each new function (regexp cases especially). | |
| 56 | - `TableFormulaTests` corpus tables using `'(...)` formulas with the new functions. | |
| 57 | - `ProgramsTests` case: an Emacs Lisp block runs with `ORGSTAR_EMACS` pointing at a missing binary. | |
| 58 | - **Docs:** `docs/manual/guide/11-code-blocks.org` (Emacs Lisp coverage list), `10-tables.org` (Lisp formulas). | |
| 59 | ||
| 60 | ### M2. Tables: keep fields written before an unsupported formula (S) | |
| 61 | ||
| 62 | - **Native-only builds (App Store, iOS):** apply formulas in Emacs's order up to the first one that throws `Calc.Unsupported`. Commit the fields already written, leave the rest unchanged, and report the reason with the formula's LHS. This matches Emacs's own behaviour on an error partway through (see `docs/plans/2026-10-05-table-formulas.md`). | |
| 63 | - **Developer ID:** keep all-or-nothing with the Emacs fallback, since Emacs then computes everything. | |
| 64 | - **Files:** | |
| 65 | - `Sources/OrgCore/Compute/TableFormulaCommands.swift:26-48`: return the partial result together with the reason. | |
| 66 | - New `ExternalRequest` case or failure-with-edits. | |
| 67 | - `ContentView.swift:1002-1004` and `MobileEditor.swift:343-346`: new message text. | |
| 68 | - `TableReason.swift`. | |
| 69 | - **Tests:** `TableFormulaTests` with one unsupported formula after two supported ones. The first two fields change, the rest don't, and the message names the formula. | |
| 70 | - **Docs:** `install.org` (prose after the table), `10-tables.org`, `14-ios.org:340-343`. | |
| 71 | ||
| 72 | ### M3. Calc: constants and missing functions (M) | |
| 73 | ||
| 74 | All in `Sources/OrgCore/Compute/Calc.swift`. | |
| 75 | ||
| 76 | - **Constants:** `pi` and `e` (also `phi`, `gamma`), rounded to 12 digits as Calc's `calc-eval` result. Extend the variable switch at `:554`. | |
| 77 | - **Statistics:** `vgmean vhmean vrms vmeane vcov vpcov vcorr vflat agmean`; `vsum`/`vmax`/`vmin`/`vmean` with several vector or scalar arguments; `vmax([])`/`vmin([])` once the oracle shows what Calc prints (`-inf`? If it's symbolic, it waits for M5). | |
| 78 | - **Numeric:** `rounde roundu fdiv frac sign gcd lcm choose perm log(x,b) exp10 pow nroot hypot sinh cosh tanh arcsinh arccosh arctanh arctan2 deg rad float pfloat`. | |
| 79 | - **Function forms of operators:** `eq neq lt gt leq geq land lor lnot`. | |
| 80 | - **Grammar:** | |
| 81 | - Fraction literals `1:3`. Also read an unflagged `1:30` field as a fraction if the oracle confirms Calc does. | |
| 82 | - Postfix `!`. | |
| 83 | - Radix `16#FF`. | |
| 84 | - Implicit multiplication `2 (x)` and `2 3`, if the oracle confirms Calc's reading. | |
| 85 | - `%` as percent, only if it is unambiguous against `%` mod. Calc uses `%` for mod, so check `5%` in the oracle first and leave it Unsupported if it is symbolic. | |
| 86 | - **Precision:** `pN` for N ≤ 18 using the existing Int128 mantissa. Make `precision` a mode instead of `static let`. | |
| 87 | - **Tests:** every new function in `CalcTests.fixed` with integer, float and fraction arguments, and in fix/sci formats. A `TableFormulaTests` table using `vmean($2..$4)`-style multi-arg calls and `;p15`. | |
| 88 | - **Docs:** `10-tables.org` (list of Calc functions computed natively). | |
| 89 | ||
| 90 | ### M4. Calc dates (S–M) | |
| 91 | ||
| 92 | - Add `now()` (fixed clock injected through `Calc.Modes` for tests), `date(...)`, `year month day weekday hour minute second yearday`, `incmonth incyear newmonth newyear newweek`, `badd bsub` (weekends only; `-Q` has no holidays), `julian`, `unixtime`. | |
| 93 | - Add date × number errors as Calc gives them, `floor(date)`, and `vsum`/`vmean`/`vmin` over dates. | |
| 94 | - Build on `Days.absolute`, `Days.date` and `Days.weekday`. | |
| 95 | - **Tests:** `CalcTests.fixed` date cases. Keep `TZ=UTC`, which `EmacsOracle` already sets. | |
| 96 | - **Docs:** `10-tables.org`. | |
| 97 | ||
| 98 | ### M5. Calc symbolic layer (L) | |
| 99 | ||
| 100 | - Add a `Calc.Value.symbolic(Term)` with Calc's default simplification, limited to: | |
| 101 | - text fields as variables (`N/A + 5`) | |
| 102 | - division by zero (`x / 0`, with the "Division by zero" message Calc shows) | |
| 103 | - `inf`, `uinf` and `nan` arithmetic | |
| 104 | - `;S` mode | |
| 105 | - Add a printer that matches Calc's normal-language output (`calc-language nil`). | |
| 106 | - **Exactness:** anything whose simplified form isn't covered stays `Unsupported`. The oracle decides what is in scope: generate random expressions mixing a symbol with numbers and keep only the forms that match. | |
| 107 | - **Files:** | |
| 108 | - `Calc.swift`, plus a new `Sources/OrgCore/Compute/CalcSymbolic.swift`. | |
| 109 | - `TableFormulas.swift:334-341`: hand text fields to Calc instead of throwing "non-numeric field". | |
| 110 | - **Tests:** a CalcTests symbolic set; TableFormulaTests with blank and text cells (very common in real tables). | |
| 111 | - **Docs:** `10-tables.org`. | |
| 112 | ||
| 113 | ### M6. JavaScript blocks with JavaScriptCore (M–L) | |
| 114 | ||
| 115 | **New file `Sources/OrgApp/JavaScriptBlocks.swift`** (`#if canImport(JavaScriptCore)`): | |
| 116 | - `static func run(_ job: BabelJob, directory: URL) async throws -> BabelOutput?`. | |
| 117 | - It returns nil for jobs that aren't js or javascript. | |
| 118 | - **Shims, written in JS and bundled as a resource string:** | |
| 119 | - `require('process')` and `require('util')`. Any other module gives node's "Cannot find module 'x'". | |
| 120 | - `console.log/info/debug` go to stdout; `console.warn/error` go to stderr. | |
| 121 | - `process.stdout.write` and `process.stderr.write`. | |
| 122 | - `util.format` (`%s %d %i %f %j %o %O %%`). | |
| 123 | - `util.inspect`: depth 2, quote choice, `-0`, arrays grouped past 6 items, circular references, Map and Set. | |
| 124 | - **Value mode (no session):** evaluate the job's input unchanged; `jsWrapper` already calls `require('util').inspect` and writes to stdout. | |
| 125 | - **Sessions:** one `JSContext` per key (file folder + name). Write `inspect(completion value)` to the result file unless output mode is on. A thrown error goes to stderr with status 1, and the context stays. | |
| 126 | - **Uncaught errors:** status 1, stderr `Name: message`. | |
| 127 | - **`:dir`:** same missing-folder check as `BabelRunner.swift:63-67`. | |
| 128 | - **`:cmd`:** ignored. | |
| 129 | - **Timers:** `setTimeout`/`setInterval`/`queueMicrotask` with a run loop that drains them after the script, as node does before exit. Cap at the 300 s overall limit. | |
| 130 | ||
| 131 | **Timeout and cancel:** | |
| 132 | - Run on a dedicated `Thread`. On cancel or timeout, return an error, drop the context and leave the thread. | |
| 133 | - The public API has no execution time limit; `JSContextGroupSetExecutionTimeLimit` is private SPI and is not allowed in the App Store. | |
| 134 | - An infinite loop therefore keeps spinning one thread until the app quits. Document this. | |
| 135 | ||
| 136 | **Wiring:** | |
| 137 | - `DocumentSession.runBabel`'s `run(_:)` (`DocumentSession.swift:926-940`): when `programs` is nil, try `evaluateNatively`, then `JavaScriptBlocks.run`. | |
| 138 | - Developer ID: `Programs.runBabel` uses node when `BabelRunner.installed("node")`, and JSC otherwise. | |
| 139 | - Planner unchanged. | |
| 140 | ||
| 141 | **Tests:** | |
| 142 | - New `Tests/OrgAppTests/JavaScriptBlocksTests.swift`: the 8 node oracle cases; sessions (variable persists across runs, an error keeps the session); output vs value; `:var` tables; `hline` ReferenceError as in node; `require('fs')` message; cancel of `while(true){}` returns. | |
| 143 | - `NativeProgramsTests` (`AppTests.swift:983`): js runs without a runner. | |
| 144 | ||
| 145 | **Docs:** | |
| 146 | - `install.org`: table rows "Code blocks" and "Sessions, graphics", plus the prose after the table. | |
| 147 | - `11-code-blocks.org:83-104` (languages table: "js: JavaScriptCore in the App Store and iOS builds, node in the download version when installed"), `:213`, `:486-497` (what JSC lacks: `require` beyond `util` and `process`, `fs`, `Buffer`, network). | |
| 148 | - `14-ios.org:340-343` and `:437`. | |
| 149 | ||
| 150 | ### M7. Native LaTeX export (L) | |
| 151 | ||
| 152 | - **New `Sources/OrgCore/Export/LaTeXExport.swift`:** a `LaTeXRenderer` modelled on `HTMLRenderer`. It reuses `ExportPreprocess`, `ExportOptions`, `ExportSource`, the section selection, `Coderef`, `CiteProcessor` and `ExportScope`. | |
| 153 | - **Reproduce ox-latex 9.8.7 defaults:** | |
| 154 | - the `org-latex-default-packages-alist` preamble | |
| 155 | - `article` class sectioning, starred past `num`, levels deeper than H as lists | |
| 156 | - `hyperref` setup, title, author, date, `\maketitle`, `\tableofcontents` | |
| 157 | - text escaping | |
| 158 | - emphasis, lists, `tabular` with `ATTR_LATEX` `:environment`/`:align`/`:width`, captions and labels | |
| 159 | - verbatim src blocks, `\href`, `\ref`, `\includegraphics`, `\footnote` | |
| 160 | - math and `#+LATEX`/`@@latex:`/export blocks passed through | |
| 161 | - timestamps | |
| 162 | - `ExportDictionary` `.latex` | |
| 163 | - **`ExportOptions`:** parse `LATEX_CLASS`, `LATEX_CLASS_OPTIONS`, `LATEX_HEADER`, `LATEX_HEADER_EXTRA`, `LATEX_COMPILER`. Only `article`, `report` and `book` from the default `org-latex-classes`; anything else gives an error naming the class. | |
| 164 | - **Wiring:** | |
| 165 | - `ContentView.export` (`:614`): add `latex` → `.tex` in the native String group and take it out of the Emacs map (`:662`). | |
| 166 | - `EditorCommands.swift:176-179`: retitle "Export to LaTeX". Keep the `app.export.latex` id so key bindings still work. | |
| 167 | - `CommandTitles.swift`, string catalog. | |
| 168 | - `AppStoreCommands.hidden`: remove `app.export.latex`. | |
| 169 | - `ExportSheet.formats` (both lists), `allowsBodyOnly`. | |
| 170 | - iOS `ExportMenu.swift` `Format.latex`. | |
| 171 | - `Publish.swift:43,293`: `org-latex-publish-to-latex`. | |
| 172 | - **Developer ID:** PDF through LaTeX stays the Emacs path. | |
| 173 | - **Tests:** whole-string oracle over the conformance corpus and snippets; body-only; subtree export; `ExportOptionsTests` for the keywords; `PublishTests` for the new function. | |
| 174 | - **Docs:** `install.org:61` (export row) and `:71-73`, `12-export.org:11-23,30-32,38,49,218,226,332-343`, `14-ios.org:438`. | |
| 175 | ||
| 176 | ### M8. Native ASCII export (M) | |
| 177 | ||
| 178 | - **New public `ASCIIExport.document(_:settings:charset:bodyOnly:)` in OrgCore**, built on `ASCIIText` (`Sources/OrgCore/Export/ASCIIText.swift`). | |
| 179 | - **Add:** | |
| 180 | - title block, TOC | |
| 181 | - numbered headings with ox-ascii underlines per level and charset | |
| 182 | - footnote section; references currently return `""` (`:398`) | |
| 183 | - `ascii` / `latin1` / `utf-8` charsets for bullets, boxes and tables | |
| 184 | - `:justify`, `#+ATTR_ASCII` | |
| 185 | - `ASCII_CHARSET` / `#+OPTIONS` | |
| 186 | - **Keep the existing iCalendar use unchanged.** The iCalendar oracle tests already cover the element layout. | |
| 187 | - **Command ids:** `app.export.text` becomes the native "Export to Plain Text (ASCII)". `app.export.plain-text` stays the attributed-string text. Merging the two is a naming decision to ask you about; the plan keeps both. | |
| 188 | - **Wiring:** same places as M7, plus `org-ascii-publish-to-ascii`. | |
| 189 | - **Tests:** whole-string oracle per charset over the corpus; body-only; subtree. | |
| 190 | - **Docs:** same pages as M7. | |
| 191 | ||
| 192 | ### M9. Native ODT export (L) | |
| 193 | ||
| 194 | - **Write directly from the tree, not through the HTML importer.** The importer drops tables on iOS and loses structure. | |
| 195 | - **New `Sources/OrgCore/Export/ODTExport.swift`** produces `content.xml`, `styles.xml` and `meta.xml` from the parse tree: | |
| 196 | - `text:h` with outline-level and numbering | |
| 197 | - `text:p`, `text:list` | |
| 198 | - `table:table` with header rows | |
| 199 | - `text:a`, `text:note` for footnotes | |
| 200 | - `text:span` emphasis using ox-odt's style names (`Emphasis`, `Bold`, `Underline`, `OrgCode`, `OrgVerbatim`) | |
| 201 | - `draw:frame`/`draw:image` with sizes read via ImageIO | |
| 202 | - src blocks as `OrgSrcBlock` paragraphs, without highlighting (ox-odt `-Q` default has no htmlfontify colors? check the oracle) | |
| 203 | - **styles.xml:** a reduced styles template bundled as a resource, holding ox-odt's named styles so the structure matches. | |
| 204 | - **Math:** LaTeX fragments become images rendered with SwiftMath (`OrgPresentation/LatexPreview.swift:96`). ox-odt `-Q` without dvipng/MathToWeb leaves fragments verbatim; follow the oracle and do the same. | |
| 205 | - **Packaging:** move `ZipWriter` (`Sources/OrgApp/DocxWriter.swift:306-352`) to OrgCore as `internal` + `@testable` or `package`. Write `mimetype` first, stored. | |
| 206 | - **Wiring:** same places as M7. ODT stays whole-document only. | |
| 207 | - **Tests:** skeleton oracle as described under "How to use the Emacs oracle tests"; package-layout test; a test that the file opens with `NSAttributedString(... .openDocument? no)`. macOS can't import ODT natively, so the test unzips and parses the XML with `XMLDocument` instead. | |
| 208 | - **Docs:** same pages as M7. | |
| 209 | ||
| 210 | ### M10. Plots (M) | |
| 211 | ||
| 212 | - `PlotChart.swift`: | |
| 213 | - Interpret a `:set` subset: `title`, `xlabel`, `ylabel`, `xrange`, `yrange`, `logscale x|y`, `grid`, `key off|top|bottom|left|right`, `xtics`/`ytics` with a step. | |
| 214 | - Report an unrecognised `:set`, `:line` or `:script` in the result message instead of ignoring it silently. | |
| 215 | - Add radar plots drawn with `Canvas`/`Path`, and drop the throw at `TablePlot.swift:135-136` when there is no gnuplot. | |
| 216 | - Add SVG output through a small SVG writer for lines, points and bars. | |
| 217 | - Developer ID keeps gnuplot first when installed. | |
| 218 | - **Tests:** `PlotChartTests` for each `:set` directive, radar rendering, SVG output and the warning text. | |
| 219 | - **Docs:** `install.org` (Plots row), `10-tables.org` plot section. | |
| 220 | ||
| 221 | ### M11. iOS UI parity (S each, M together) | |
| 222 | ||
| 223 | - **Editor archive:** `app.archive` in `EditorScreen.swift:440-465` calls `session.archive(from:)`. | |
| 224 | - **iCalendar agenda/combined:** `ExportMenu.swift`, using `ICalendarFiles.exportEach` and `combine`. | |
| 225 | - **Publishing:** | |
| 226 | - Wire `Publish` into `EditorScreen.swift:462-465` with a project picker. | |
| 227 | - A security-scoped bookmark for `publishingDirectory`. | |
| 228 | - **Copy as rich text:** to `UIPasteboard` from `RichTextExport`. | |
| 229 | - **`app.export.html-open`:** Quick Look / `SFSafariViewController` of the temp file. | |
| 230 | - **Clock idle approximation:** time spent in the background while a clock runs, fed to `ClockModel.resolveIdle` on return. | |
| 231 | - **Attach link/symlink:** hide `app.attach.link`/`symlink` on iOS (reuse `AppStoreCommands.hidden`), or report a clear error. | |
| 232 | - **Import agenda folders:** a folder picker per Mac path, as `EmacsImportView.swift:162-166` does. | |
| 233 | - **Tests:** `AppTests` / `PublishTests` with an iOS-style bookmarked folder; `AppStoreCommandsTests` for the hidden set. | |
| 234 | - **Docs:** `14-ios.org:435-445` ("What the Mac has that iOS doesn't"), and the export and clock sections. | |
| 235 | ||
| 236 | ### M12. Lisp-adjacent extras (S–M) | |
| 237 | ||
| 238 | - **`elisp:` links:** run in the interpreter behind the existing `TrustStore` prompt (`LinkFollow.swift:69-70`), on all builds. | |
| 239 | - **`org-sbe` in table formulas:** for blocks that can run in-process (Emacs Lisp, JS after M6). Other languages stay Unsupported on App Store and iOS; on Developer ID they fall back to Emacs. | |
| 240 | - **Docs:** `09-links.org` (or whichever page covers link types), `10-tables.org`. | |
| 241 | ||
| 242 | ### M13 (optional, not parity). New in-process languages | |
| 243 | ||
| 244 | None of the three builds runs these today. | |
| 245 | ||
| 246 | - `calc` blocks (ob-calc) on `Calc.evaluate`. | |
| 247 | - `sqlite` blocks with `SQLite3`, emulating `sqlite3` CLI output modes. | |
| 248 | ||
| 249 | This is beyond parity, so ask you before scheduling it. | |
| 250 | ||
| 251 | ### M14 (question for you). MathJax in HTML/PDF export | |
| 252 | ||
| 253 | - `HTMLExport.swift:72-77` loads MathJax from jsdelivr, and native PDF export runs it in a WKWebView. | |
| 254 | - On App Store and iOS that is remote code executed by the app, and PDF math fails offline. | |
| 255 | - **Option:** bundle MathJax 3 (Apache-2.0) as a resource and inline it for PDF export only, keeping the CDN link in saved HTML. Size S–M. | |
| 256 | ||
| 257 | ## Gaps that can't be closed under the constraints | |
| 258 | ||
| 259 | | Gap | Why | | |
| 260 | |---|---| | |
| 261 | | Shell blocks (`sh bash zsh fish ...`) and `shell:` links | A shell's job is spawning processes. | | |
| 262 | | Python, Ruby, R blocks and their sessions | No system interpreter in-process. Embedding CPython, mruby or R means shipping a large interpreter whose output differs (mruby). Not spawning, but outside this plan's scope; Python via embedded CPython is the only one worth considering (L, large binary). | | |
| 263 | | C, C++, D, Java, Fortran, Clojure | Need a compiler/JVM and run the built binary as a process. | | |
| 264 | | PlantUML | Java process. | | |
| 265 | | Graphviz `dot`, mermaid | Possible only by compiling Graphviz into the app (C library, L, large) or rendering bundled mermaid.js in WKWebView (output parity with `mmdc` unverified). Not planned; listed as possible, not impossible. | | |
| 266 | | awk | Possible only by porting an awk interpreter into the app (L, low value). Not planned. | | |
| 267 | | PDF through LaTeX | Needs a TeX engine plus format and font files, hundreds of MB, in the bundle. Tectonic fetches support files from the network. Native `print-pdf` remains the substitute (`AppStoreCommands.swift:13`). | | |
| 268 | | Full gnuplot (`:script`, arbitrary `set`) | Needs gnuplot's interpreter. M10 covers a subset and reports the rest. | | |
| 269 | | Arbitrary user Emacs Lisp | Buffer model, `org-element`, user packages: open-ended. M1 grows coverage; the tail stays "runs only in Emacs" on App Store and iOS. Custom dynamic blocks (`org-dblock-write:NAME`) need a buffer model and are part of that tail. | | |
| 270 | | Interrupting a JS infinite loop | The public JavaScriptCore API has no execution time limit. A cancelled loop keeps running on its own thread. | | |
| 271 | | JS that needs node (`fs`, `child_process`, `http`, npm modules) | Not in JavaScriptCore, and network or file access would conflict with the no-download and sandbox rules. | | |
| 272 | | Hard links across sandbox containers (App Store, iOS) | The sandbox forbids it. Symlinks inside granted folders may work; needs a runtime check before un-hiding `app.attach.symlink` on the App Store build. | | |
| 273 | ||
| 274 | ## Decisions for you | |
| 275 | ||
| 276 | 1. **Lisp on the Developer ID build:** "Emacs when installed, native when not" (the plan as written), or native first? | |
| 277 | 2. **JS on the Developer ID build:** node when installed and JavaScriptCore otherwise (plan), or always JavaScriptCore so all builds give the same output? | |
| 278 | 3. **Plain-text exports:** keep both `plain-text` (attributed-string text) and the native ox-ascii `text`, or merge them? | |
| 279 | 4. **Optional work:** schedule M13 (calc/sqlite blocks)? Bundle MathJax (M14)? | |
| 280 | ||
| 281 | Suggested order: M1, M2, M3, M6, M7, M9, M8, M4, M5, M10, M11, M12. That puts the four things you named first after the cheap fixes that unblock tables. M3, M6, M7, M8 and M9 don't depend on each other and can be done in parallel. | |
| \ No newline at end of file | ||