chore(reading): lint-clean lift — local renames, tab escape, DOX pass (#76)

Spike-locals renamed at lift time (identifier_name), literal tab in a
string escape fixed (unprintable-ASCII build error), swiftlint
force_try disable for the static regex. AGENTS.md reading-mode section
rewritten for the apex HTML pipeline; native-only Work Guidance line
rescoped to the editing side per ADR-0011.
This commit is contained in:
AlexKucera committed 2026-10-06 18:30:21 +02:00
1 parent cc04ec236e
commit f1c915fed1
5 files changed
+111 -83

No files matched your search

+1 -1
View File
@@ -23,7 +23,7 @@ Owned by the root AGENTS.md contract.
- `PostLibraryTests.swift` (#17) — throwaway Homes via `makeHome`/`writePost` in temp dirs: bare corpus posts (First Draft/writer defaults), lenient + quoted frontmatter (`pass_state`/`origin`), lazy folders / hidden dirs / symlinks / noise not surfacing, localizedStandardCompare title sort, `untitled` edges (blank, marker-only, unterminated frontmatter), leading-blank-line frontmatter, default Home = `~/Documents/Museion`.
- `PostStoreTests.swift` (#18) — write side via `storeHome`/`readPost` (same temp-dir pattern): slug algorithm cases (diacritics, CJK, cap, punctuation-only → untitled), lazy first write + #59 stamp round-trip through `Post.scan`, untitled fallback, case-insensitive collision suffixes, rename (retitle + move, insert-title path, same-slug retitle-only, collision -2), trash removes from posts/, overwrite preservation + bare-post normalization, `readBody` stripping, blocked-posts failure path.
- `EditorSessionTests.swift` (#19) — session mechanics via `makeSessionHome`/`seedPost`: debounce → flush + sidecar round-trip, clean-flush no-op + ⌘S immediate, #67 conflict (echo suppressed, Yes-reload, No-keep-local → overwrite), write failure → `.failed` + retry.
- `ReadingPresenterTests.swift` (#71) — renderer coverage with inline fixture strings (no file fixtures): headings/paragraph split + markup hidden, auto-renumber (`1. 1. 1.` → 1/2/3), nesting, source-range monotonicity + exact chunk offsets (the click→edit map), table/quote/HR attribute presence (`NSTextTableBlock`/`QuoteTextBlock`/`RuleTextBlock` via paragraphStyle `textBlocks`), fenced-code font, link retention, image payload + post-folder resolution, footnote fallback, soft-joined lines, kitchen-sink smoke.
- `ReadingPresenterTests.swift` (#76, ADR-0011) — apex HTML pipeline coverage with inline fixture strings: chunker sentinel stamping, stamper attribute rewrite (multi-digit), `blocks(for:)` line↔range map (monotonic, 1-based lines, exact chunk offsets — the click→edit map), pipeline tests running the REAL bundled apex binary (headings/inline marks, `1. 1. 1.` renumber via native `<ol>`, mixed-lists stay split, table/quote/fence/link/HR constructs with exact `data-source-line` stamps, base64 image embed against `spike/prose`, native footnotes), fallback = escaped source, stylesheet carries the slot CSS vars.
## Verification
+15 -15
View File
@@ -18,14 +18,14 @@ struct ReadingPresenterTests {
/// Chunker: sentinels before chunks, blank structure preserved (spike
/// self-check fixture).
@Test
func chunkerStampsSentinels() {
func `chunker stamps sentinels`() {
let md = "# T\n\nA\n\nB\n1. x\n\n\nC"
#expect(ReadingPresenter.stampSource(md) == "<!--S:1-->\n# T\n\n<!--S:3-->\nA\n\n<!--S:5-->\nB\n1. x\n\n<!--S:9-->\nC")
}
/// Stamper: sentinel → attribute on the following element; multi-digit.
@Test
func stamperRewritesAttributes() {
func `stamper rewrites attributes`() {
let html = "<h1>T</h1>\n<!--S:1-->\n<p>A</p>\n<!--S:12-->\n<ul>\n<li>B</li>\n</ul>"
#expect(ReadingPresenter.stampHTML(html) == "<h1>T</h1>\n<p data-source-line=\"1\">A</p>\n<ul data-source-line=\"12\">\n<li>B</li>\n</ul>")
}
@@ -33,7 +33,7 @@ struct ReadingPresenterTests {
/// The #68 click→edit map: blocks are monotonic, lines are 1-based, and
/// ranges point at the exact chunk offsets in the source.
@Test
func blocksMapChunks() {
func `blocks map chunks`() {
let src = "# A\n\nfirst para\n\n- l1\n- l2\n\nlast para"
let blocks = ReadingPresenter.blocks(for: src)
#expect(blocks.count == 4)
@@ -45,7 +45,7 @@ struct ReadingPresenterTests {
/// Blocks over CRLF and multi-blank separators stay monotonic.
@Test
func blocksSurviveBlankRuns() {
func `blocks survive blank runs`() {
let src = "one\n\n\n\n two"
let blocks = ReadingPresenter.blocks(for: src)
#expect(blocks.count == 2)
@@ -57,7 +57,7 @@ struct ReadingPresenterTests {
/// Headings + paragraphs + inline marks render; markup never leaks.
@Test
func pipelineHeadingsAndInline() throws {
func `pipeline headings and inline`() throws {
let (html, blocks) = ReadingPresenter.page(for: "# Title\n\nBody with _em_ and `code`.", postFolder: nil)
try assertRendered(html, blocks: blocks, count: 2)
#expect(html.contains("<h1 data-source-line=\"1\""))
@@ -68,7 +68,7 @@ struct ReadingPresenterTests {
/// `1. 1. 1.` renumbers via native <ol> (the #69 hard requirement).
@Test
func pipelineOrderedRenumber() throws {
func `pipeline ordered renumber`() throws {
let src = "1. one\n1. two\n1. three"
let (html, blocks) = ReadingPresenter.page(for: src, postFolder: nil)
try assertRendered(html, blocks: blocks, count: 1)
@@ -82,7 +82,7 @@ struct ReadingPresenterTests {
/// `--no-mixed-lists`: an ordered list after a bullet list stays two
/// lists (default apex merges them — kills renumbering).
@Test
func pipelineMixedListsStaySplit() throws {
func `pipeline mixed lists stay split`() {
let src = "- bullet\n- another\n\n1. one\n1. two"
let (html, _) = ReadingPresenter.page(for: src, postFolder: nil)
#expect(html.contains("<ul"))
@@ -92,7 +92,7 @@ struct ReadingPresenterTests {
/// Tables, quotes, fenced code, HR, links — the #69 set on one page.
@Test
func pipelineConstructs() throws {
func `pipeline constructs`() throws {
let src = """
| A | B |
| --- | --- |
@@ -121,7 +121,7 @@ struct ReadingPresenterTests {
/// Images embed as base64 data URLs against the post folder (#69/#74).
@Test
func pipelineImageEmbeds() throws {
func `pipeline image embeds`() throws {
let prose = URL(fileURLWithPath: #filePath) // …/MuseionTests/ReadingPresenterTests.swift
.deletingLastPathComponent().deletingLastPathComponent()
.appendingPathComponent("spike/prose")
@@ -133,7 +133,7 @@ struct ReadingPresenterTests {
/// Footnotes render natively (apex upgrade over #69's fallback).
@Test
func pipelineFootnotes() throws {
func `pipeline footnotes`() {
let src = "Text with note[^1]\n\n[^1]: the note"
let (html, _) = ReadingPresenter.page(for: src, postFolder: nil)
#expect(html.contains("footnote"))
@@ -142,14 +142,14 @@ struct ReadingPresenterTests {
/// Fallback: apex failure → editing-treated source (#69 rule), escaped.
@Test
func fallbackIsSourceText() {
func `fallback is source text`() {
let page = ReadingPresenter.fallbackPage("a < b & c > d")
#expect(page.contains("<pre data-source-line=\"1\">a &lt; b &amp; c &gt; d</pre>"))
}
/// The stylesheet carries the live slot values as CSS variables.
@Test
func stylesheetCarriesSlots() {
func `stylesheet carries slots`() {
let css = ReadingPresenter.styleSheet()
#expect(css.contains("--body-face:"))
#expect(css.contains("--headings-size:"))
@@ -167,7 +167,7 @@ struct ReadingPresenterTests {
}
/// Regex count helper (Swift Testing has no XCTest import here).
private func XCTRegexMatches(_ s: String, pattern: String) throws -> Int {
let re = try NSRegularExpression(pattern: pattern)
return re.numberOfMatches(in: s, range: NSRange(s.startIndex..., in: s))
private func XCTRegexMatches(_ text: String, pattern: String) throws -> Int {
let regex = try NSRegularExpression(pattern: pattern)
return regex.numberOfMatches(in: text, range: NSRange(text.startIndex..., in: text))
}