Repository Public
1# SP Notes iOS / iPadOS — code audit for "SP Note Next Generation"23Audited: `/Users/simon-pierreboucher/Desktop/Cluster/apple/SPNotes-iOS` (read-only, 2026-11-19). Git: 3 commits, HEAD `b9fadb5`4(`38d74a7` = 1.0.0 (1) code; the two later commits are docs only). Nothing was built or run for this audit: every statement about5test results / TestFlight state is **quoted from the project's docs, not re-verified**. Statements about code are from reading the6sources (line refs given). Items I did not open line by line are marked *(skimmed)*.78Legend: **[V]** verified in code · **[D]** documented by the project, not re-verified · **[U]** unverified / inferred.910---1112## 0. Headline facts1314- 98 Swift files, 18 667 lines **[V]** (`wc -l`). 5 targets in `project.yml`: `SPNotes` (app), `SPNotesWidgets`, `SPNotesShare`,15 `SPNotesTests`, `SPNotesUITests`.16- Dependencies: local package `../SPNotesCore` (umbrella product `SPNotesCore` = Document + Store + API + Sync; core HEAD `267a673`,17 code commit `b06b1ed`) and SwiftMath 1.7.3 (exact). Nothing else. No web view anywhere (grep `WKWebView|SFSafari` = 0 hits) **[V]**.18- The **`Design/` directory contains only 4 SVG files** (icon sources + mark). It is *not* a token system. Design tokens live in19 `Components/Theme.swift` (80 lines), the asset catalog colour sets, and `EditorTheme` in `Editor/EditorStyler.swift`. **[V]**20- The editor engine is **separate code from macOS** (UIKit here, AppKit there, different type names); only the document model21 (`SPNotesDocument`: `NoteDocument`/`Line`/`Container`/`PMNode`) is shared. See §3.8.22- Every atom (image, table, equation, file, rule, mention…) is drawn as a **static bitmap in an `NSTextAttachment`**; there are no live23 subviews in the text. Interactive editing of an atom always happens in a sheet/cover. See §3.5.2425---2627## 1. Structure (every directory, every file)2829Line counts in brackets. Roles are the file's own header description, shortened, checked against content where I read the file.3031### `App/` — entry point, application model, system entry points32| File | Role |33|---|---|34| `SPNotesApp.swift` [54] | `@main`; single `WindowGroup`; `Boot` holds `AppRuntime.result`; `.onOpenURL`, `.onContinueUserActivity` (NoteActivity, Spotlight item, Spotlight query continuation); schedules background tasks on `.background`. |35| `AppDelegate.swift` [46] | `AppRuntime.install()`, `BackgroundSync.register()`, `UNUserNotificationCenterDelegate` (banner in foreground; tap → `pendingRoute = .note`). |36| `AppModel.swift` [390] | The application model (see §2). Also defines `SessionState`, `AppError`, `AppRoute`. |37| `AppConfiguration.swift` [47] | Base URL from `Info.plist` `SPNotesBaseURL`; data dir = App Group container `/SPNotes`; DEBUG env overrides (`SPNOTES_BASE_URL`, `_TOKEN`, `_DATA_DIR`, `_STORE=memory`, `_SEED=1`). |38| `BackgroundSync.swift` [106] | `BGAppRefreshTask` (`…ios.refresh`, ≥30 min) + `BGProcessingTask` (`…ios.sync`, network required, only when `pending > 0`); `BackgroundRun` wraps one run with expiration. |39| `SampleData.swift` [305] | French seeded workspace for UI tests/screenshots. |40| `Intents/AppRuntime.swift` [58] | Process-wide singleton `Result<AppModel, Error>`; starts `SpotlightIndexer`; `rescheduleReminders()`. |41| `Intents/AppRouting.swift` [88] | `NoteActivity` (Handoff type `ai.spboucher.spnotes.ios.openNote`), `AppModel.open(url:)`, `continueActivity`. |42| `Intents/NoteIntents.swift` [125] | 6 App Intents (§6). |43| `Intents/NoteShortcuts.swift` [57] | `SPNotesShortcuts: AppShortcutsProvider` — 5 `AppShortcut`s (README says "four"; code has five: create, append, search, open note, open search). |44| `Intents/QuickNoteActions.swift` [62] | `quickCreate`, `appendText`, `searchNotes`, `noteEntity` on `AppModel`. |45| `Intents/SpotlightIndexer.swift` [142] | `actor SpotlightIndexer` + `SearchIndexing` protocol; capacity 400 notes, 1 000-char excerpt. |4647### `Core/` — app-side services (not the shared package)48| File | Role |49|---|---|50| `AttachmentFiles.swift` [147] | Bytes of attachments in the App Group container; streaming SHA-256 import; downsampled images; `source(forAttachmentID:)` = `/api/files/<id>`. |51| `AppLock.swift` [119] | `@Observable` local biometric lock (LocalAuthentication), `UserDefaults` keys `lock.enabled`, `lock.grace` (default 60 s). |52| `NetworkMonitor.swift` [32] | `NWPathMonitor` → `isOnline`, `onReconnect`. |53| `ReminderScheduler.swift` [58] | Mirrors store reminders into `UNUserNotificationCenter`. |5455### `Editor/` — the TextKit 2 engine (UIKit), 2 237 lines56| File | Role |57|---|---|58| `EditorController.swift` [798] | The engine: load/save, paragraph identity repair, marks, links, atoms, Enter/Backspace/Tab, undo. Also `UITextViewDelegate`, `NSTextStorageDelegate`, `NSTextLayoutManagerDelegate`. |59| `AttributedCodec.swift` [150] | `NoteDocument` ⇄ `NSAttributedString` (lossless). Holds `blockAtomTypes`. |60| `EditorAttributes.swift` [119] | `LineStyle`, `LineBox`, `MarksBox`, attribute keys, `AtomAttachment`, `EditorCharacter`, `EditorNodeTypes`. |61| `EditorStyler.swift` [232] | `EditorTheme`, `LineGeometry`, `EditorStyler` (fonts/colours/paragraph styles per paragraph, `renumber`). |62| `EditorLayoutFragment.swift` [114] | `NSTextLayoutFragment` subclass drawing list markers, checkboxes, quote bars, callout/code boxes. |63| `AtomRenderer.swift` [283] | Bitmaps for block/inline atoms; `TableGrid`; `MathSource.normalize`; `PMNode` attr helpers. |64| `EditorToolbar.swift` [221] | `UIInputView` formatting bar; `enum EditorAction`. |65| `NoteTextView.swift` [193] | `UITextView` subclass: key commands, paste, tap targets (checkbox / atom / link). |66| `StructureCommands.swift` [127] | List/quote/callout/indent commands computed on the Core document, applied as new `LineStyle`s; `EditorController.Context`. |6768### `Features/` — 48 files, 17 folders69| Folder / file | Role |70|---|---|71| `Root/RootView.swift` [118] | Per-window root: welcome vs main, lock overlay, appearance, `pendingRoute` handling, banner. |72| `Root/MainInterface.swift` [178] | Adaptive shell: `CompactShell` (NavigationStack) / `RegularShell` (3-column NavigationSplitView); global sheets, toast, ⌘ shortcuts, `@SceneStorage`. |73| `Root/ShellState.swift` [256] | Per-scene navigation state; `NoteSource`, `NoteSection`, `Destination`, `SidebarItem`, `ShellSheet`, `Toast`. |74| `Root/SidebarView.swift` [158] | iPad sidebar + `NoteDropTarget`. |75| `Root/LockScreen.swift` [51] | Lock screen + `PrivacyCover`. |76| `Home/HomeScreen.swift` [156], `NewNoteButton.swift` [42] | iPhone home (search entry, pinned strip, 6 recents, list entries) + floating button. |77| `Notes/NoteListView.swift` [421] | One list: paging, sort, swipes, context menu, multi-select + bulk, drag/drop, inbox/archive/trash specifics. |78| `Notes/NoteListModel.swift` [169] | Paged summaries + pure arrangement rules. |79| `Notes/NoteActions.swift` [212] | `NoteCommands`, `NoteTransfer`, `NoteTextShare`, `NoteWindow`. |80| `Notes/NoteLinkPicker.swift` [80] | Pick a note → mention. |81| `Folders/FoldersScreen.swift` [142], `FolderTree.swift` [80] | Folder browsing + pure tree functions. |82| `Tags/TagsScreen.swift` [47] | Tag list. |83| `Organize/MoveNoteSheet.swift` [155], `TagEditorSheet.swift` [204] | Move / tag sheets. |84| `Search/SearchScreen.swift` [291], `SearchCriteria.swift` [84] | Local FTS search + filters. |85| `Editor/NoteEditorScreen.swift` [340] | Note screen, "…" menu, states (missing / trashed / database). |86| `Editor/NoteEditorModel.swift` [324] | One open note: load, debounce save, remote refresh, toolbar dispatch, insertions. |87| `Editor/NoteEditorPresentations.swift` [365] | All sheets/covers/dialogs of the note screen; atom tap menu. |88| `Editor/NoteEditorSupport.swift` [240] | Save/sync wording, statistics, export menu, `AppModel` extensions (versions, reminders, keep-offline, `webURL`). |89| `Editor/NoteEditorView.swift` [113] | `UIViewRepresentable` host; title field lives inside the text view's scroll area. |90| `Editor/NativeDocumentView.swift` [111] | Read-only rendering with the editor stack (assistant answers, history, conflicts). |91| `Editor/EditorDropHandler.swift` [115] | `UIDropInteraction` for files/pictures from other apps. |92| `Editor/EditorKeyboardAvoider.swift` [65] | Bottom content inset follows the keyboard. |93| `Editor/Sheets/LinkSheet.swift` [125], `MathEditorSheet.swift` [241], `TableEditorSheet.swift` [240] | Link / LaTeX / table editors. |94| `AI/AssistantProvider.swift` [203] | `AssistantProvider` protocol, `BackendAssistantProvider`, failures, action catalogue. |95| `AI/AssistantModels.swift` [352] | `AssistantActionModel`, `AssistantChatModel`, `AssistantSource`, `AssistantChatScope`. |96| `AI/AssistantSheet.swift` [356], `AssistantChatView.swift` [248] | Assistant UI ("Actions" / "Questions"). |97| `History/NoteHistoryView.swift` [300] | Local restore points + server versions. |98| `Conflicts/ConflictSheet.swift` [262] | Conflict resolution. |99| `Reminders/NoteRemindersView.swift` [200] | Per-note reminders. |100| `Attachments/NoteAttachmentsView.swift` [316], `AttachmentPreview.swift` [74], `MediaPickers.swift` [179], `DocumentScanner.swift` [125] | Files of a note, QuickLook, pickers, VisionKit scanner + Vision OCR. |101| `Drawing/DrawingScreen.swift` [310] | PencilKit full-screen editor. |102| `Export/NoteExporter.swift` [503], `ZipWriter.swift` [354], `ShareSheet.swift` [61] | Exports. |103| `Settings/SettingsScreen.swift` [275], `SecurityScreens.swift` [230] | Settings, passkeys, sessions. |104| `Account/WelcomeScreen.swift` [119], `SignInFailure.swift` [61] | Sign-in. |105106There is **no** `Features/Inbox`, `Features/Tasks`, `Features/Databases`, `Features/Graph` folder: the inbox is a `SmartList` case107handled inside `NoteListView`.108109### `Components/` — `Theme.swift` [80], `NoteRow.swift` [124], `FolderRow.swift` [41], `SyncIndicator.swift` [210]110### `Shared/` (app + both extensions) — `AppGroup.swift` [16], `DeepLink.swift` [84], `SharedInbox.swift` [83]111### `WidgetShared/` (app + widget ext.) — `NoteEntity.swift` [60], `WidgetDataProvider.swift` [132], `WidgetViews.swift` [294]112### `Widgets/` — `SPNotesWidgets.swift` [75] (bundle, 4 widgets), `WidgetProviders.swift` [88], `Info.plist`, entitlements, privacy manifest113### `ShareExtension/` — `ShareViewController.swift` [40], `ShareView.swift` [206], `ShareContentLoader.swift` [246], `Info.plist`, entitlements, privacy manifest114### `Design/` — `AppIcon.svg`, `AppIcon-Dark.svg`, `AppIcon-Tinted.svg`, `Mark.svg` (vector sources only)115### `Resources/` — `Info.plist`, `Info-Debug.plist` (generated, untracked), `SPNotes.entitlements`, `PrivacyInfo.xcprivacy`, `Assets.xcassets` (16 colour sets, AppIcon, Mark, LaunchMark), `Localizable.xcstrings` (65 keys, 64 with `en`), `AppShortcuts.xcstrings` (10 keys, all `en`)116### `Tests/` — 7 files, 128 `@Test` (§7) · `UITests/` — 3 files, 12 tests117### `Scripts/` — `build.sh`, `release.sh`, `test-live.sh`, `asc.py`, `ExportOptions.plist` (§7)118### `docs/` — `AUDIT.md`, `PARITY_MATRIX.md`, `IMPLEMENTATION_STATUS.md`, `UI_CONVENTIONS.md`, `DISTRIBUTION.md`, `brand/`119### Untracked build output present on disk: `build/`, `dist/export/SP Notes.ipa` (+ `Packaging.log`, `DistributionSummary.plist`)120121---122123## 2. AppModel / state architecture124125### 2.1 Ownership (`App/AppModel.swift`)126`@MainActor @Observable final class AppModel` (l.27–29) owns: `store: NotesStore` (actor, SQLite), `api: NotesAPI`,127`auth: AuthService`, `engine: SyncEngine`, `files: AttachmentFiles`, `lock: AppLock`, `network: NetworkMonitor`,128`reminders: ReminderScheduler`. One instance per process via `AppRuntime.result` (so intents / BG tasks / notification taps and129the UI share it; a second DB connection in-process is never opened).130131Observable state: `session` (`signedOut | signedIn | expired`), `syncStatus`, `revision: Int`, `lastChangedPages: Set<String>`,132`ownerName`, `banner: String?`, `pendingRoute: AppRoute?`.133134### 2.2 Read path135Screens hold `@Environment(AppModel.self) private var app`, query the store actor directly (`try await app.store.summaries(...)`,136`counts()`, `folderTree()`, `tags()`, `search(...)`, `page(id:)`…), and **reload on `.task(id: app.revision)`**. `revision` is137bumped in `storeDidChange` (l.111–120) for every `StoreChange` from `store.changes()`. There is no per-query observation or diffing:138*any* DB change re-runs every visible screen's queries. Local `@State` holds the results.139140### 2.3 Write path141Only through `AppModel` methods (l.182–334) and `extension AppModel` blocks in feature files142(`NoteEditorSupport.swift` l.165–216, `QuickNoteActions.swift`, `AppRuntime.swift`): store call → `didWrite()` →143`engine.schedule()` (or `refreshCounts()` when not signed in). Methods: `createNote`, `save`, `rename`, `setPinned`, `setFavorite`,144`setArchived`, `setTags`, `move`, `trash`, `restore`, `purge`, `duplicate`, `fileInboxItem`, `markOpened`,145`confirmPendingDeletions` (passkey step-up), `attach(fileAt:)`, `attach(data:)`, `deleteAttachment`, `importSharedItems`,146`restoreLocalVersion`, `applyServerVersion`, `addReminder`, `setReminderDone`, `removeReminder`, `setKeepOffline`.147148`createNote` (l.186) is the single creation path: it builds a `NewPage` with `section` (default `"notes"`), `properties`149`{"folder":true}` or `{}`, content = ProseMirror JSON. There is **no `type` parameter** — every page created here is a plain page.150151### 2.4 Sync / session152`start()` (l.89) spawns three unstructured `Task`s consuming `store.changes()`, `engine.statusUpdates()`,153`api.client.sessionEvents()`. `syncNow()` is a no-op unless `session == .signedIn`. Every store change also calls154`WidgetCenter.shared.reloadAllTimelines()` (l.119).155156### 2.5 Per-note state (`Features/Editor/NoteEditorModel.swift`)157`@MainActor @Observable` per open note; owns an `EditorController` and an `EditorToolbar` (`@ObservationIgnored`). Debounced save158600 ms (`markDirty`, l.124); `flush()` on disappear / `willResignActive` with `beginBackgroundTask`; snapshot `reason: "open"` at159load and `"autosave"` every 10 min. `storeChanged()` replaces the editor content only when the stored content differs **and**160nothing is dirty locally. The model communicates UI needs to the screen through a single `request: Request?` enum (l.19–27).161162### 2.6 Navigation163- **Per scene**: `RootView` creates `@State private var shell = ShellState()` (one per window).164- **iPhone / compact** (`CompactShell`, `MainInterface.swift` l.121): `NavigationStack(path: $shell.path)` rooted at `HomeScreen`,165 `enum Destination { list(NoteSource), folders, tags, search(String), note(String, isNew:) }`. No tab bar.166- **iPad / regular** (`RegularShell`, l.143): a real **three-column `NavigationSplitView`** — `SidebarView` (260–360 pt) ·167 content column (`NoteListView` or `SearchScreen`, 300–460 pt) · detail (`NoteEditorScreen` or empty state);168 `.navigationSplitViewStyle(.balanced)`. Selection: `shell.sidebar: SidebarItem?`, `shell.selectedNote: String?`.169- Switch is driven by `horizontalSizeClass` (`MainInterface` l.41) with `ShellState.adapt(toCompact:)` (l.231) carrying state both170 ways (Split View / Slide Over / Stage Manager resize).171- State restoration: `@SceneStorage("shell.sidebar")`, `@SceneStorage("shell.note")`.172- External routes: `enum AppRoute { note(String), newNote, search(String) }` set on `app.pendingRoute`, consumed in173 `RootView` l.73–77. **`AppRoute.note` carries a page id only** — no block/heading anchor.174175### 2.7 iPad specifics — what exists176- **Multi-window**: `UIApplicationSupportsMultipleScenes = true` (Info.plist); `NoteWindow.open(noteId:)`177 (`NoteActions.swift` l.201) uses `UISceneSessionActivationRequest` with an `NSUserActivity`; offered in the list context menu178 ("Ouvrir dans une nouvelle fenêtre", `NoteListView.swift` l.220). The new window is the *full* three-column shell with that note179 selected — there is no dedicated single-note scene / `WindowGroup(for:)`.180- **Keyboard shortcuts**: shell — ⌘N, ⇧⌘N, ⌘F, ⌘,, ⌘R (invisible buttons, `MainInterface.swift` l.61–73). Editor181 (`NoteTextView.keyCommands`, l.57–80) — Tab/⇧Tab, ⌘B/I/U, ⇧⌘X, ⌘E, ⌘K, ⌥⌘1/2/3/0, ⇧⌘7/8/9. No `.commands {}` menu-bar builder,182 no command palette.183- **Drag & drop**: note rows `.draggable(NoteTransfer)` (custom UTI `ai.spboucher.spnotes.note-reference`); sidebar rows and folder184 rows are `.dropDestination` (move / favourite / archive / trash); list accepts dropped `String`s (l.91: creates a note in that185 source from the text, as Markdown **[V]**); editor accepts files/pictures from other apps (`EditorDropHandler`, `UIDropInteraction`).186- **Pointer**: `UIApplicationSupportsIndirectInputEvents`, toolbar buttons `isPointerInteractionEnabled`.187- Readable column: editor capped at 760 pt (`NoteEditorContent.readableWidth`).188- Not present: inspector column, secondary detail panes, side-by-side notes inside one window, `.commands`, tab bar/`TabView`.189190---191192## 3. Editor193194### 3.1 Architecture in one paragraph195`EditorController` (NSObject, `@MainActor`) owns a `NoteTextView` (UITextView created with `textContainer: nil`, i.e. TextKit 2), an196`AtomRenderer` and an `EditorStyler`. **The `NSTextStorage` is the working document.** Model data rides in custom attributes;197presentation attributes are derived and can always be recomputed. `load(_:)` (l.53) = `AttributedCodec.attributedString(from:)` →198`styler.restyleAll` → `storage.setAttributedString`. `document()` (l.72) = `AttributedCodec.document(from: storage)` +199`ensureBlockIds()`. Save reads the whole storage back each time (debounced 600 ms).200201### 3.2 Storage ⇄ `NoteDocument` mapping (`EditorAttributes.swift`, `AttributedCodec.swift`)202The Core document is a **flat list of `Line`** (`path: [Container]`, `type`, `attrs`, `content: .inline([InlineRun]) | .blockAtom(PMNode)`).203- One `Line` = one storage paragraph, **always terminated by `\n`, the last one included**; the caret is clamped before the final204 terminator (`clampSelection`, l.281).205- `.spnLine` → `LineBox` (reference box around `LineStyle { path, type, attrs }`), uniform over the paragraph incl. its newline.206- `.spnMarks` → `MarksBox([PMMark])` on text runs (raw ProseMirror marks; unknown marks preserved, drawn as plain text).207- `.spnOrdinal`, `.spnItemHead` → presentation only (list numbering / which paragraph shows the marker), computed by `renumber`.208- Atoms → one U+FFFC with an `AtomAttachment(node: PMNode, isBlock:)`.209- Soft breaks (hardBreak node, newline inside a code block) → U+2028; a code block is therefore **one paragraph**.210- Paragraph created by Enter: detected in `fixParagraphs` (l.721) because two neighbouring paragraphs share the *same `LineBox`211 instance* (or equal style with an id) → `continuation(of:)` assigns a fresh block id / new sibling list item.212- Block ids: 10-char nanoid-style (`newBlockID`, l.115), assigned when paragraphs are created; `ensureBlockIds()` at save.213- Unknown block nodes: `AttributedCodec.style(forBlockAtom:)` (l.145) tags the storage-only style with `atomMarkerKey`214 (`"\u{1}spnAtom"`) so any node type not in `blockAtomTypes` still round-trips as an atom.215- `blockAtomTypes` (l.84): `image, fileBlock, table, blockMath, horizontalRule, youtube`.216- Container types understood by geometry/drawing: `blockquote`, `callout`, `aiBlock`, `details`, `listItem`, `taskItem`217 (+ list parents `bulletList`, `orderedList`, `taskList`).218219### 3.3 How each block renders220| Block | Where | How |221|---|---|---|222| paragraph | `EditorStyler.baseAttributes` l.112 | `.body` Dynamic Type font, `TextPrimary`, line height ×1.12, spacing 7. |223| heading 1–3 | `EditorTheme.heading` l.15 | bold `.title1/.title2/.title3`. |224| code block | styler l.103 + fragment l.58 | scaled monospaced 15, `CodeBackground` rounded box joined across neighbours (`boxKey`), char wrapping, **no syntax colouring**. |225| bullet / ordered / task list | `EditorLayoutFragment.drawDecorations` l.75–104 | marker drawn in the left gutter (28 pt per level): dot (filled/hollow by depth), `n.` in monospaced digits, or a drawn checkbox; checked item text muted + strikethrough. Tap zone `checkboxHitRect()` → `toggleTask`. |226| blockquote | fragment l.70 | 3 pt `QuoteBar` bar per nesting level, secondary text colour. |227| callout / aiBlock / details | `LineGeometry` l.54 + fragment l.58 | `Surface2` rounded box, inset 12. **The callout icon is read but not drawn** (fragment l.65–67, `_ = icon`); `details` has no disclosure control; `detailsSummary` is bold and single-line. |228| footnote | styler l.118 | footnote font, secondary colour. |229| text alignment | styler l.105 | `textAlign` attr honoured (no UI to set it). |230231### 3.4 Marks232`bold, italic, underline, strike, code, highlight, link, subscript, superscript` (`EditorStyler.apply(marks:)` l.163).233Order follows the web schema (`EditorController.markOrder`, l.312); `code` excludes other marks; sub/sup mutually exclusive.234Pending marks with an empty selection apply to the next typed characters.235236### 3.5 Atoms (`AtomRenderer.swift`)237All rendered with `UIGraphicsImageRenderer` into `attachment.image`; block atoms re-rendered when width or appearance changes238(`relayout(force:)`).239| Atom | Render (`renderBlock` l.49 / `renderInline` l.185) | Tap (`NoteEditorModel.editor(_:didTapAtom:)` l.197) |240|---|---|---|241| `image` | downscaled picture, max height 520, rounded; placeholder + `onMissingImage` download | `atomMenu` dialog: preview, edit drawing (if `drawing-*.png`), recognise text, copy, delete |242| `fileBlock` | chip (icon by mime, name, size) | QuickLook cover |243| `table` | static grid bitmap (header fill, equal columns, scaled down if wider than screen; **plain text only**, via `TableGrid`) | `TableEditorSheet` |244| `blockMath` / `inlineMath` | SwiftMath `MathImage` (fallback chip / pill showing the LaTeX) | `MathEditorSheet` |245| `horizontalRule` | 1.5 pt line | atom menu |246| `youtube` | chip "Vidéo" + URL | atom menu |247| `mention` | accent pill `@label` | `pendingRoute = .note(id)` |248| `footnoteRef` | `[id]` pill | atom menu |249| unknown block | chip "Bloc « type » — Conservé tel quel — modifiable sur le web" | atom menu (copy / delete) |250| unknown inline | `⟨type⟩` pill | atom menu |251252**Drawings** are not a node type: a PencilKit drawing = an `image` node (PNG) + a companion `.pkdrawing` attachment found by file253name convention `drawing-<uuid>.png` / `.pkdrawing` (`NoteEditorModel.insertDrawing` l.278, `drawingSource` l.288, `isDrawing` l.296).254255### 3.6 Formatting bar (`EditorToolbar.swift`)256`UIInputView` (48 pt, `inputAccessoryView`), horizontally scrollable row: **Insert menu**, **Style menu**, **Assistant**, | B I U S257highlight code | task / bullet / ordered list, outdent, indent (only in lists), quote, link, open-link (only on a link) | undo, redo;258fixed keyboard-dismiss button at the right. State from `EditorController.Context` (`StructureCommands.swift` l.89).259- Style menu (l.157): Texte, Titre 1–3 · Bloc de code, Citation, Encadré · Indice, Exposant.260- Insert menu (l.174): Photo, Prendre une photo, Numériser, Fichier, Dessin · Tableau, Séparateur, Équation, Équation en ligne, Lien vers une note.261- No slash menu, no `@` completion while typing, no Markdown input shortcuts, no block drag handles, no block-level menu for text blocks.262263### 3.7 Exactly where to add a new block / atom type264For a new **block atom** (e.g. `databaseView`, `audioNote`, `canvasEmbed`, `pdfBlock`):2651. `Editor/AttributedCodec.swift` l.84 — add the type to `blockAtomTypes` (optional: unknown types already round-trip through `atomMarkerKey`).2662. `Editor/AtomRenderer.swift` l.49 `renderBlock` — add a `case` + a drawing function (bitmap for a given width).2673. `Features/Editor/NoteEditorModel.swift` l.197 `editor(_:didTapAtom:at:)` — add a `case` producing a `Request`; add the case to `enum Request` l.19.2684. `Features/Editor/NoteEditorPresentations.swift` — `enum EditorSheet` l.13 / `EditorCover` l.43, `present(_:)` l.127, `sheetContent` l.181 / `coverContent` l.246; result goes back via `controller.insertBlockAtom(_:)` (l.383) or `controller.updateAtom(at:node:)` (l.415).2695. `Editor/EditorToolbar.swift` — `enum EditorAction` l.11 and the Insert menu l.174; dispatch in `NoteEditorModel.perform(_:)` l.229.2706. Node constructor: Core `PMNode` factory (`PMNode.table(...)`, `.blockMath`, `.image`, `.fileBlock` are Core API — other auditor).2717. Exports: `Features/Export/NoteExporter.swift` (`fallbackText(for:isBlock:)`, the per-format walkers — l.112, 197, 232, 389 reference node types) and `ZipWriter.swift`.2728. Tests: `Tests/EditorTests.swift`, `Tests/EditorRenderingTests.swift` (renders every block to PNG).273274For a new **inline atom**: `AtomRenderer.renderInline` l.185, `controller.insertInlineAtom` l.406, tap in `didTapAtom`.275276For a new **text block type** (e.g. toggle heading, column): `LineStyle` helpers (`EditorAttributes.swift`), `EditorStyler.baseAttributes`/`paragraphStyle`,277`LineGeometry` (l.49) for indents, `EditorLayoutFragment.drawDecorations` for chrome, `EditorController.setBlockType` l.530278(currently only paragraph/heading/codeBlock), `handleReturn` l.585 / `handleDeleteBackward` l.610, `boxKey` l.793.279280For a new **container** (e.g. columns, toggle you can create): Core structure commands (`toggleCallout`-style, used via281`StructureCommands.run`), `LineGeometry`, `boxKey`, `StructureCommands.lift` l.45.282283Hard limit to know: an atom is a bitmap. A block that must be **live inside the text** (inline-editable table, embedded284database view, audio player with scrubber, collapsible toggle) needs a new mechanism (`NSTextAttachmentViewProvider` or285overlay subviews); nothing of that kind exists today.286287### 3.8 Shared with macOS?288**No — duplicated concept, separate code.** macOS: `../SPNotes/Editor` is a SwiftPM library `SPNotesEditor` (AppKit, macOS 15,28912 files, 2 482 lines) depending only on `SPNotesDocument` + SwiftMath. Same design (paragraph-identity attribute + raw marks +290attachment atoms + custom layout fragment) but different names and extras:291292| | iOS (`SPNotes-iOS/Editor`) | macOS (`SPNotes/Editor`) |293|---|---|---|294| Packaging | app sources, internal types | standalone package, `public` API, own test target |295| Paragraph attr | `.spnLine` → `LineBox(LineStyle)` | `.spPara` → `ParaStyle` (keeps a `Line` template) |296| Marks attr | `.spnMarks` → `MarksBox` | `.spMarks` → `MarkSet` |297| Decorations | computed in the fragment from `LineStyle` | precomputed `.spDecoration` → `ParaDecoration` (marker / panel enums, incl. `disclosure`, callout kind+icon, `ai`) |298| Codec | `AttributedCodec` | `DocumentCodec` |299| Engine | `EditorController` + `NoteTextView` | `NoteTextView` (642 lines) + `EditorCommands` |300| Extras absent on iOS | — | `Completion.swift` (completion session/panel), `SyntaxHighlighter.swift`, `NoteFragment.swift` (rich pasteboard fragment), `ExportComposer`, `EditorTheme.FontDesign` (system/serif/rounded/mono) |301302Consequence: every new block type must be implemented twice unless a shared rendering/codec layer is extracted. *(macOS side303only skimmed for this comparison.)*304305### 3.9 Other editor behaviours worth knowing306- Paste is **plain text only** (`NoteTextView.paste`, l.113); images on the pasteboard become attachments. No rich/Markdown paste.307- Find: system find navigator (`presentFind`, `NoteEditorSupport.swift` l.155), no replace.308- Undo: `UndoManager` with whole-range attributed snapshots (`replace` l.228, `mutateAttributes` l.244).309- `lineIndex(at:)` (l.155) and `paragraphRanges()` are O(document); `renumber` is O(paragraphs) on structural edits;310 `StructureCommands.run` converts the **whole storage to a document** for each list/quote/indent command.311- Read-only reuse: `NativeDocumentView` instantiates the same stack for history / conflict / assistant previews.312313---314315## 4. Design system316317**There is no token layer beyond colours.** What exists:318319- **Colours** — asset catalog, light/dark pairs (`Components/Theme.swift` l.9–20 exposes `Color.spBackground`, `.spSurface`,320 `.spSurface2`, `.spBorder`, `.spText`, `.spTextSecondary`, `.spMuted`, `.spDanger`, `.spSuccess`, `.spWarning`; accent = `AccentColor`):321322 | Token | Light | Dark |323 |---|---|---|324 | Background | #FBFAF7 | #0E0D0B |325 | Surface | #FFFFFF | #1A1815 |326 | Surface2 | #F3F1EC | #24211C |327 | Border | #E4E0D7 | #34302A |328 | TextPrimary | #1C1A17 | #F4F1EA |329 | TextSecondary | #5E584E | #B5AEA1 |330 | Muted | #8C8578 | #857E72 |331 | AccentColor (amber) | rgb(0.89, 0.52, 0.04) | rgb(1.00, 0.69, 0.20) |332 | Danger / Success / Warning | #C8321F / #2E7D4F / #B26A00 | #FF6B57 / #5CC98A / #FFB84D |333 | CodeBackground / Highlight / QuoteBar | #F3F1EC / #FFE9A8 / #E3A53A | #1F1C18 / #6B5210 / #B8801F |334 | WidgetBackground / LaunchBackground | #FFFDF8 / #FBFAF7 | #1A1815 / #0E0D0B |335336 Widgets have their own `WidgetPalette` (`WidgetShared/WidgetViews.swift` l.13).337- **Typography** — system text styles only (no custom fonts, no type-scale constants). Editor fonts in `EditorTheme`338 (`EditorStyler.swift` l.12–37). A few fixed sizes: SF Symbol sizes 40/44 in empty states, widget `34`, PDF chrome `8.5`.339- **Spacing / radii** — literals scattered in views (corner radii 9, 10, 12, 14; paddings 12/16/18/20/28). Editor metrics in340 `EditorTheme`: `listIndent 28`, `quoteIndent 16`, `boxInset 12`, `paragraphSpacing 7`; text inset 12/18/28/18.341- **Materials** — `.regularMaterial` twice (app banner `RootView` l.105, busy overlay `NoteEditorPresentations` l.116);342 `UIBlurEffect(.systemChromeMaterial)` under the formatting bar (made ~opaque with a 0.92 `Surface` tint). The toast is a343 hard-coded dark capsule (`Color(white: 0.13)`). No glass / Liquid-Glass styling, no custom material tokens.344- **Shared components** — `EmptyStateView`, `PrimaryButtonStyle` (50 pt, radius 14), `BrandMark`, `NoteRow`, `FolderRow`,345 `SyncIndicator` / `SyncDetailsSheet`, `SessionExpiredBanner`, `ConflictBanner`.346- **Haptics** — `enum Haptics { tap, success, warning }` (`Theme.swift` l.23); ~12 call sites (move, conflict resolved, assistant347 insert, history restore, list actions, sign-in, reminders, copy atom) + a direct light impact on checkbox toggle.348- **Animations** — minimal: toast spring 0.3 s, banner `.animation(.default)`, lock `.opacity` transition, sync icon349 `.symbolEffect(.pulse)`, chat `withAnimation` scroll. No matched-geometry / zoom transitions, no custom motion tokens.350- **Reduce Motion** — read in exactly one place (`MainInterface.swift` l.15/27, toast). The banner animation and the chat scroll351 animation are not gated.352- **Dynamic Type** — text styles throughout; `adjustsFontForContentSizeCategory` on editor + title; `@ScaledMetric` in table and353 math sheets; editor re-renders atoms on content-size change (`NoteTextView.configure` l.40). Largest sizes: **[D] never checked**.354- **Dark mode** — colour-set pairs; user override `@AppStorage("appearance")` (system / light / dark) via `preferredColorScheme`;355 editor atoms re-rendered on `UITraitUserInterfaceStyle` change; exports forced to light.356- **Localization** — French source; English exists for 64 app strings + shortcuts strings only. Most screens are French-only **[D]+[V by key count]**.357- **Accessibility identifiers** — kebab-case ids on controls used by UI tests.358359---360361## 5. Features implemented (per `Features/` folder) and backend endpoints362363App code never builds URLs itself except `/api/files/<id>` (attachment `src`) and `/p/<id>` (web page link). All HTTP goes through364Core `NotesAPI` / `AuthService` / `SyncEngine`. Endpoint paths below are those named in comments/docs; exact paths inside Core were365not audited here (other auditor) — marked **[U]** where I only have the Swift method name.366367| Folder | What it does | Network use |368|---|---|---|369| `Root` | Shell, lock overlay, routing, banner, toast | none |370| `Account` | Welcome + passkey sign-in (`app.signIn()` → `auth.signIn()`, system passkey sheet, RP `note.spboucher.ai`); `SignInFailure` wording; `SessionExpiredBanner` | WebAuthn auth endpoints via `AuthService` **[U paths]** |371| `Home` | iPhone home | local |372| `Notes` | Lists, paging, sort (`modified`/title), swipe, bulk, drag/drop, new window, inbox "Classer" | local; inbox filing enqueues op `triage` `{action:"keep", section}` (`AppModel.fileInboxItem` l.253) pushed by the sync engine |373| `Folders`, `Tags`, `Organize` | Folder tree (folder = page with `properties.folder`), tags, move, tag editor | local |374| `Search` | **Local FTS5 only** (`store.search(query:filters:limit:)`, 150 ms debounce, highlighted title/snippet, filters section/folder/tags/dates/favourite/pinned/archived, recent searches) | none — the server hybrid/semantic search is never called |375| `Editor` | Note screen, toolbar actions, sheets, statistics, find, drop | local; image download via `engine.download(attachmentId:)` |376| `AI` | "Actions": 15 kinds in 3 groups (summarize, explain, toList, actionItems · rewrite, fix, simplify, expand, shorten, formal, translate (6 languages) · outline, toTasks, table, continue) + `custom` instruction; streamed preview, stop, regenerate, expensive-request confirmation; result inserted as Markdown only on user choice. "Questions": chat with modes `notes` (grounded, sources), `summarise`, `actions` (need a synced page), `general`. | `api.aiAction` → `POST /api/ai/action` (SSE); `api.aiChat` → `POST /api/ai/chat` (SSE). Model/provider are **reported** by the server (`AIMeta` → `modelLine`), never chosen by the client. Chat lives for the life of the sheet only (no local persistence; `conversationId` kept in memory). |377| `History` | Local restore points (`store.localVersions`, `restoreVersion`) + server versions | `api.pageVersions(pageID:)`, `api.pageVersion(pageID:version:)` |378| `Conflicts` | Two copies side by side / tabs, 3 choices | `engine.resolveConflict(pageId:choice:)` (server `/resolve` per docs) |379| `Reminders` | Add / done / delete per note; local notifications | local `store.createReminder/updateReminder/deleteReminder`; synced device → server as **tasks** by the engine; no pull of server tasks **[D]** |380| `Attachments` | List per note with state (local / to download / pending upload / failed), QuickLook, share, keep-offline, download, delete, eviction; photo library (PhotosUI), camera, Files importer; VisionKit document scanner; Vision OCR (`VNRecognizeTextRequest`, accurate) | upload/download through the sync engine (`/api/attachments`, `/api/files/<id>` per docs) |381| `Drawing` | Full-screen `PKCanvasView` + `PKToolPicker`, finger toggle, growing canvas, undo; returns `PKDrawing` data + PNG + optional OCR text (4 s timeout) offered — never auto-inserted | none |382| `Export` | Markdown, text, HTML, RTF, paginated PDF, ZIP (own deflate/CRC writer, no ZIP64) | none |383| `Settings` | Account/sign-out (keep or erase local data), app lock + grace period, passkeys (list/add/rename/delete), sessions (list/revoke one/revoke others), sync details, storage, appearance, about/privacy | `api.passkeys()`, `auth.addPasskey(label:)`, `api.renamePasskey`, `api.deletePasskey`, `api.sessions()`, `api.revokeSession`, `api.revokeAllSessions(includeCurrent:false)`; destructive ones wrapped in `auth.withFreshSession` (step-up) |384385Other server interactions: `engine.sync()` (change feed `GET /api/sync?since=` + pushes, per docs), `auth.stepUp()` before queued386purges (`confirmPendingDeletions`).387388**Inbox today** = list + "Classer" (file to a section) + archive + delete. No AI triage, no suggestions.389390---391392## 6. System integration393394- **Widgets** (`Widgets/SPNotesWidgets.swift`), 4 kinds:395 - `ai.spboucher.spnotes.widget.recent` — small, medium, large, accessoryRectangular (StaticConfiguration)396 - `ai.spboucher.spnotes.widget.pinned` — medium, large397 - `ai.spboucher.spnotes.widget.new` — small, medium, accessoryCircular (links `spnotes://new`, `?kind=tasks`)398 - `ai.spboucher.spnotes.widget.note` — small, medium, large; `AppIntentConfiguration` with `SelectNoteIntent`399 Data: read-only SQLite connection to the shared DB opened per query (`WidgetDataProvider`); single-entry timelines; app calls400 `reloadAllTimelines()` after every store change. No interactive widget buttons (no `Button(intent:)`), no Live Activities,401 no Control Center controls. *(WidgetViews/Providers skimmed.)*402- **App Intents / Siri** (`NoteIntents.swift`): `CreateNoteIntent`, `AppendToNoteIntent`, `SearchNotesIntent` (returns entities),403 `OpenSearchIntent`, `OpenNoteIntent: OpenIntent`, `NewNoteInAppIntent`; `NoteEntity` + query; 5 `AppShortcut`s with French404 phrases; tile colour orange. No "ask my notes" / AI intent, no task intents, no Focus filters.405- **Spotlight**: `SpotlightIndexer` actor, domain `ai.spboucher.spnotes.ios.notes`, ≤400 most recent notes, title + 1 000-char406 excerpt + tags; `CoreSpotlightContinuation = true` (search-in-app continuation → `.search(q)`).407- **Handoff**: `NoteActivity.type` declared in `NSUserActivityTypes`; `fill(...)` helper exists. **The note screen never advertises it**: the408 only `.userActivity(` in the repo is the doc comment at `AppRouting.swift` l.16, so outgoing Handoff is dead code; only the409 incoming continuation is wired **[V by grep]**.410- **Share extension**: `ShareViewController` hosts `ShareView`; `ShareContentLoader` copies file representations to staging;411 activation rule: text, 1 web URL, ≤10 images, ≤10 files. Writes one `SharedItem` folder (`item.json` last, atomic) into412 `<AppGroup>/SPNotes/SharedInbox`; the extension never opens the DB or the network. The app imports at `start()` and on every413 scene activation (`AppModel.importSharedItems`, l.340): link first, text as Markdown, files attached and appended as atoms.414 Shared items become **regular notes in `notes`**, not inbox captures (no `inboxAt` set) **[V]**.415- **Background tasks**: §1 `BackgroundSync`. Identifiers in `BGTaskSchedulerPermittedIdentifiers`; modes `fetch`, `processing`.416- **Notifications**: local only (reminders). No push / APNs entitlement, no remote-notification background mode → no417 server-triggered sync.418- **Deep links** (`Shared/DeepLink.swift`): `spnotes://note/<id>`, `spnotes://new[?kind=tasks][&text=…]`, `spnotes://search?q=…`;419 strict parsing. No universal links (`applinks:` not in entitlements — only `webcredentials:note.spboucher.ai`).420- **App Group** `group.ai.spboucher.spnotes.ios`: `SPNotes/notes.sqlite`, `SPNotes/Attachments/`, `SPNotes/SharedInbox/`.421 Session token is in the Keychain (app only; extensions don't authenticate).422- **App lock** (`Core/AppLock.swift`): `.deviceOwnerAuthentication`, grace period, `LockScreen` overlay + `PrivacyCover` when423 inactive; content `.disabled` + `accessibilityHidden` while locked. Local only; not applied to widgets (widgets show note titles/previews424 regardless of the lock: no lock check in `Widgets/` or `WidgetShared/` **[V by grep]**).425- **Home-screen Quick Actions**: none (`UIApplicationShortcutItems` absent from Info.plist; no `performActionFor` handler).426- **Exported UTI**: `ai.spboucher.spnotes.note-reference`.427- **Orientations**: iPhone portrait + landscape; iPad all four. `SUPPORTS_MACCATALYST = NO`, no "Designed for iPad" on Mac/visionOS.428429---430431## 7. Build / release432433- **Identity**: team `3YM54G49SN`; bundle ids `ai.spboucher.spnotes.ios`, `.ios.widgets`, `.ios.share`, tests `.ios.tests`,434 `.ios.uitests`; `MARKETING_VERSION 1.0.0`, `CURRENT_PROJECT_VERSION 1`; deployment target **iOS 18.0**; devices 1,2;435 Swift 6.0, `SWIFT_STRICT_CONCURRENCY: complete`; `CODE_SIGN_STYLE: Automatic`; `defaultConfig: Release`.436- **App Store Connect** **[D]**: app `6836504456` "SP Notes", SKU `spnotes-ios-001`, fr-CA; build 1.0.0 (1) uploaded 2026-11-18437 (Delivery UUID `aef1245f-7ffe-4912-9cd6-fd45a47d5b35`), `VALID`, `IN_BETA_TESTING`, internal group « Test ». API key438 `L379BDKR69`, issuer `013e761f-e05c-4d93-a50b-f3d960adae4a` (key id + issuer are **hard-coded defaults in `release.sh` and439 `asc.py`**; the `.p8` is outside the repo).440- **Scripts**:441 - `Scripts/build.sh generate|debug|release|test|uitest|core` — `generate` copies `Info.plist` → `Info-Debug.plist`442 (+`NSAllowsLocalNetworking`) then `xcodegen`; `test` = `-only-testing:SPNotesTests`; `uitest` = `-only-testing:SPNotesUITests`443 with result bundle + screenshot export to `build/shots/<sim>`; `core` = `swift test` in `../SPNotesCore`. `SPNOTES_SIM`444 selects the simulator (default `iPhone 17 Pro`). Output is grep-filtered; full logs in `build/logs`.445 - `Scripts/release.sh archive|export|upload|all` — archive Release `generic/platform=iOS` with **`-allowProvisioningUpdates` only446 (Xcode account)** because App Groups cannot be provisioned with the API key; `export` with `ExportOptions.plist`447 (`app-store-connect`, automatic signing) + API key; `upload` = `xcrun altool --upload-app`. Note: `all` does **not** upload.448 - `Scripts/test-live.sh` — SSH tunnel `8482` to M4M64c, mints a dev session token on the node (`~/dev/note-native`,449 `scripts/dev-session.ts`), runs `SPNotesTests/OfflineScenarioTests` with `TEST_RUNNER_SPNOTES_LIVE_URL/_TOKEN`. Dev DB450 `note_native_dev`, never production.451 - `Scripts/asc.py METHOD /v1/...` — minimal ES256 JWT client (openssl).452- **Tests** (counts by `grep '@Test'` / `func test` **[V]**; pass status **[D]**):453 | Target | File | Tests |454 |---|---|---|455 | SPNotesTests (Swift Testing) | `NoteFeatureTests` 33 · `MediaExportTests` 27 · `ShellTests` 24 · `SystemIntegrationTests` 23 · `EditorTests` 19 · `EditorRenderingTests` 1 · `OfflineScenarioTests` 1 (live only) | **128** |456 | SPNotesUITests (XCUITest) | `ShellUITests` 5 · `SystemUITests` 4 · `EditorUITests` 3 | **12** |457 Simulators used: **iPhone 17 Pro** and **iPad Pro 13-inch (M5)**, iOS 26.5 sims, Xcode 27.2 **[D]**. Device-specific UI tests458 `XCTSkip` on the other idiom; some `SystemUITests` use `XCTSkipUnless` on screen content (so "0 failures" can include skips).459 Core: 283 tests on the host **[D]**.460- **Documented as never verified on a physical device** (`docs/IMPLEMENTATION_STATUS.md`): passkey sign-in / step-up / adding a461 passkey; airplane-mode + restart offline scenario; software keyboard + formatting bar on a phone, hardware shortcuts on iPad,462 rotation while editing; camera, scanner, Apple Pencil (tool picker, zoom), cross-app drag & drop; widgets (Home/Lock),463 Siri phrases, Shortcuts, Spotlight results, share sheet; background refresh/processing, reminder notifications; app lock after464 grace period + privacy cover; VoiceOver, largest Dynamic Type; Instruments profiling; assistant streaming and server history465 against production (only fake provider + Core error-path live tests). **In short: build 1.0.0 (1) has not been validated on466 any device.**467- App Store submission material (screenshots, privacy questionnaire, review account) not prepared **[D]**.468469---470471## 8. Absent vs the web and vs the upgrade brief (confirmed against code)472473Grep was run over all non-test sources for each item; "none" = zero relevant hits.474475| Capability | State in this app | Evidence |476|---|---|---|477| Databases: table / board / calendar / timeline / gallery / list views | **Absent.** A page with `type == "database"` shows an empty state + "Ouvrir sur le web" (`NoteEditorScreen.swift` l.109–115); excluded from Spotlight, widgets, link picker. No property/row model in app code. | grep `kanban|board|calendar|timeline|gallery` → only `Calendar.current` |478| Knowledge graph / backlinks | **Absent.** Mentions exist as atoms; no backlinks list, no graph view. | grep `graph|backlink` = 0 |479| Global tasks list | **Absent.** Per-note reminders only; task-list checkboxes live inside documents and are not aggregated. | no Tasks feature folder |480| Inbox AI triage | **Absent.** Manual "Classer" only (`triage` op with `action:"keep"`). | `AppModel.swift` l.253 |481| Research workspace (references, BibTeX, experiments) | **Absent.** `research` is just a section name; research pages edit as notes. | `ShellState.swift` l.51 |482| Semantic search | **Absent.** Local FTS5 only; server hybrid search never called. | `SearchScreen.swift` l.150 |483| Ask-my-knowledge with citations linking to **blocks** | **Partial.** Grounded chat with sources exists, but `AssistantSource` = `{n, pageId, title, heading, excerpt}` — **no block id**; sources are de-duplicated per page and a tap only opens the note (`AppRoute.note(id)`); no scroll-to-heading/block, no inline `[n]` citation links. Chat is not persisted. | `AssistantModels.swift` l.166–188; `AssistantChatView.swift` l.221–246 |484| Infinite canvas | **Absent.** Only a bounded, growing PencilKit drawing stored as PNG + `.pkdrawing`. | grep `canvas` → PencilKit only |485| Voice notes + transcription | **Absent.** No `Speech`, `AVAudioRecorder`, `AVAudioEngine`; no microphone usage description in Info.plist. Audio files can only be attached/previewed via QuickLook. | grep = 0 |486| PDF annotation | **Absent.** PDFKit is imported only for thumbnails; preview is read-only QuickLook. | `AttachmentPreview.swift` |487| Handwriting → text | **Partial.** Vision OCR on the *rendered bitmap* of a drawing / image / scan, offered as text to insert. No PencilKit stroke recognition, no Scribble-specific handling, no searchable handwriting index. | `DrawingScreen.swift` l.143–156, `DocumentScanner.swift` l.61–95 |488| Model picker | **Absent.** Server picks; app only displays `model · provider` from the `meta` event. | `AssistantProvider.swift` l.130–135 |489| Agents | **Absent.** | grep `agent` = 0 |490| Knowledge health / daily brief / timeline | **Absent.** | none |491| Command palette | **Absent.** | grep `palette` → `WidgetPalette` only |492| Home-screen Quick Actions | **Absent.** | Info.plist has no `UIApplicationShortcutItems` |493| Stage Manager / multi-window | **Present (basic).** Multiple scenes enabled; "open in new window" opens a second full shell; per-scene `ShellState` + `@SceneStorage`. No dedicated note-only window scene, no `.commands`. Never tested on device. | §2.7 |494| Markdown shortcuts while typing, slash menu, `@` completion | **Absent** (macOS has a completion panel). | §3.6 |495| Syntax highlighting in code blocks | **Absent** on iOS (present in the macOS editor package). | §3.8 |496| In-place table editing | **Absent** (sheet, plain text cells). | `TableEditorSheet.swift` |497| Creating toggles/details, footnotes, YouTube embeds, AI blocks | **Absent** (preserved + displayed only). | §3.3/3.5 |498| Push-triggered sync, universal links, Live Activities, interactive widgets, Focus filters | **Absent.** | §6 |499| Collaboration / sharing / comments | **Absent** (single-owner product). | none |500| End-to-end encryption | **Absent** **[D]**. | status doc |501| Bulk import (Markdown/ZIP/Notion/DOCX) | **Absent** (share extension + attachments only). | parity doc |502503---504505## 9. Code smells / risks for a large upgrade506507**Assumes "everything is a page with a ProseMirror document"**508- `AppModel.createNote` has no page `type`; `NoteEditorScreen` hard-codes three states (missing / trashed / `database`) and treats509 every other type as an editable note. Lists, widgets, Spotlight, link picker each re-implement "is this a note" with string510 compares (`type != "database"`, `isFolder`) in 4 different places (`SpotlightIndexer.isSearchable`,511 `WidgetDataProvider.isNote`, `NoteLinkPicker` l.24, `HomeScreen.load`). New page kinds (canvas, database, voice note, PDF,512 research) will leak into all of them unless a typed page-kind abstraction is introduced first.513- `Destination` / `SidebarItem` / `AppRoute` / `DeepLink` enumerate only list / folders / tags / search / note. Adding514 first-class destinations (tasks, graph, databases, daily brief, a block anchor) touches `ShellState.adapt`, the storage keys,515 `RootView.handle`, `CompactShell`, `RegularShell`, and the widgets' links.516- Sections are a hard-coded string array (`NoteSection.editable`) with string switch for titles/icons.517- Stringly-typed node/mark/container names everywhere in `Editor/` (`"paragraph"`, `"taskItem"`, `"callout"`…) rather than Core518 constants (only `NodeType.paragraph` is used once, in `QuickNoteActions`).519520**Editor**521- `EditorController.swift` is the one large file (798 lines) and mixes engine, three delegates, link normalisation and keyboard522 handling. Not unmanageable, but it is the file every new block touches.523- Atoms are bitmaps (see §3.7 hard limit). Tables render plain text at reduced scale when wide; nothing is interactive in place.524- Whole-document conversions on the main actor: every save (`document()`), every structural command (`StructureCommands.run`),525 statistics, assistant context, export. Fine at note size ("3 000 paragraphs load in ~0.1 s" **[D]**), unproven for very long526 documents; no profiling was ever run **[D]**.527- iOS and macOS editors are parallel implementations (§3.8); feature drift already exists (completion, syntax highlighting,528 decorations model). Every new block = two implementations + two export paths.529- Drawings are identified by a **file-name convention** (`drawing-*.png` ↔ `.pkdrawing`) via `alt`/`title` — fragile if the web530 or another client rewrites those attributes.531- Callout icon/kind not drawn on iOS; `toggleCallout` always creates `kind:"info", icon:"💡"`.532533**State / observation**534- One global `revision` counter invalidates **all** screens on **any** store change (including the open editor's own 600 ms535 autosave): sidebar counts, folder tree, tags, lists, home all re-query. Cheap today (4 pages in production per the audit doc);536 will need scoped invalidation with real data volumes and with more panes (graph, tasks, databases).537- `WidgetCenter.shared.reloadAllTimelines()` on every store change — i.e. potentially every autosave while typing; WidgetKit538 reload budgets may throttle this **[U — not measured]**.539- `pendingRoute` is a single app-global value observed by every scene's `RootView`; with several windows, which window consumes a540 route is not deterministic **[U — inferred from code, not tested]**. `NoteWindow.activityType` is the same string as541 `NoteActivity.type`, so a "new window" activation is also seen by the `WindowGroup`-level `.onContinueUserActivity` handler in542 `SPNotesApp` (sets `pendingRoute`) *and* by `RootView` (opens in its shell) — possible double handling **[U]**.543- `NoteEditorModel` and `EditorController` are per scene: the same note open in two windows = two independent text storages; the544 second only refreshes when not dirty (`storeChanged`), so concurrent typing in two windows on one device relies on the store's545 last-writer behaviour **[U]**.546- Unstructured `Task {}` everywhere for writes (fire-and-forget; errors surfaced through `banner` / `notice` / `app.attempt`).547548**Concurrency escape hatches** (Swift 6 strict): 16 sites — `nonisolated(unsafe)` (3), `MainActor.assumeIsolated` (7),549`@unchecked Sendable` (3: `LineBox`, `MarksBox`, `ImageCache`), `@preconcurrency` delegate conformances (2). Concentrated in550`EditorController` (text storage delegate, undo closures), `BackgroundSync`, `NoteEditorModel`, `DrawingScreen`. Each new UIKit551delegate (audio, PDF, canvas) will need the same pattern.552553**AI layer**554- Thin and server-shaped: `AssistantRequest` = `.action | .chat` only; no tool calls, no agent/run concept, no model parameter,555 no persistence of conversations, sources without block anchors. The `AssistantProvider` protocol is a good seam for extension.556- `selectedPlainText()` sends plain text (atoms stripped) — tables/equations/images are invisible to actions on a selection.557558**Product / release**559- Nothing has run on a real device; passkey sign-in — the only way into the app — is in that unverified set.560- No push channel: sync happens on activation, on reconnect, on pull-to-refresh/⌘R and in opportunistic BG tasks.561- Reminders/tasks are one-way (device → server).562- Localization debt: ~65 English strings vs a French-only remainder.563- `README` drift: says 4 app shortcuts (code: 5).564- Hard-coded ASC key id / issuer id defaults in scripts (not secrets by themselves, but identifiers in the repo).565- Min iOS 18 while the toolchain is Xcode 27 / iOS 27 SDK: any iOS 26/27-only API (new glass materials, etc.) needs availability566 gates or a deployment-target decision.567- Core API coupling: the app imports the umbrella `SPNotesCore` in 57 files and calls ~48 distinct `store.*` methods directly from568 views; a Core schema change (new entity kinds) ripples widely. `SearchHit` / `Tombstone` name clash between Store and API569 modules already requires qualification.570571---572573## 10. Not covered / unverified in this audit574575- `SPNotesCore` internals (by instruction): exact endpoint paths, sync protocol, store schema, `AIActionRequest`/`AIChatRequest` fields.576- Skimmed only (headers + targeted greps, not line by line): `WidgetViews`, `WidgetProviders`, `WidgetDataProvider`, `ShareView`,577 `ShareContentLoader`, `NoteExporter`, `ZipWriter`, `ConflictSheet`, `NoteHistoryView`, `NoteAttachmentsView`, `MediaPickers`,578 `SettingsScreen`, `SecurityScreens`, `TagEditorSheet`, `MoveNoteSheet`, `FoldersScreen`, `NoteListModel`, `SearchScreen`,579 `AssistantSheet`, `NoteEditorView`, `NativeDocumentView`, `EditorKeyboardAvoider`, sheets, all test bodies, `SampleData`.580- No build, no test run, no simulator: all pass/fail and TestFlight facts are the project's own claims.581- macOS editor compared at the level of file list, package manifest and type declarations only.582