From a04b92113a83fa3ba296432e5cfdb9263678dfb8 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Tue, 3 Nov 2026 04:57:07 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20#144=20session=20log=20=E2=80=94=20libr?= =?UTF-8?q?ary=20search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sue144-library-search-titles-bodies_log.md | 47 +++++++++++++++++++ docs/devlog/INDEX.md | 1 + 2 files changed, 48 insertions(+) create mode 100644 docs/devlog/20261103-issue144-library-search-titles-bodies_log.md diff --git a/docs/devlog/20261103-issue144-library-search-titles-bodies_log.md b/docs/devlog/20261103-issue144-library-search-titles-bodies_log.md new file mode 100644 index 0000000..34556dd --- /dev/null +++ b/docs/devlog/20261103-issue144-library-search-titles-bodies_log.md @@ -0,0 +1,47 @@ +# #144 — Library search across titles and bodies + +> **Date:** 2026-11-03 +> **Type:** issue +> **Reference:** Gitea issue #144 (museion, museion-FEAT-004) + +## Goal + +"Which piece was it that talked about X" as a live filter in the Posts library column: a plain search field directly under the Posts `PaneHeader`, matching titles AND bodies (frontmatter-stripped via `PostStore.readBody`) over the non-archived pieces, debounced and off-main, no new persistence. In-memory only; archived pieces, persisted indexes, and Trends/fix-card seams all out of scope. + +## What Was Done + +- `PostsPaneView.swift` — `LibrarySearch` (file-scope `nonisolated` enum, beside `PostsLibraryColumn`): the pure matching core. Trims the query (empty matches nothing), partitions title hits first then body hits (both halves preserve the scan's title order — #108 Finder order, never re-sorted), reads bodies through an injected `@Sendable (Post) -> String?` reader so `PostStore.readBody` stays the call-site reader and the seam stays testable. +- `PostsPaneView.swift` — `PostsLibraryColumn` integration: `@State query`/`matches` (nil = not searching), the field row (magnifyingglass + clear button + bottom hairline), the content branch (searching → flat ranked list / in-flight `ProgressView` / "No matches" naming the trimmed query; not searching → the existing sectioned library), and `.task(id: query)`: 250 ms debounce sleep, cancellation guards, then the scan through `Task.detached(priority: .userInitiated)` (rescan's off-main posture). State is per-view — both library surfaces (unfocused layout + focus-mode reveal) get the field from the one shared column; no second copy anywhere. +- `MuseionTests/LibrarySearchTests.swift` — 7 pins: ranking + scan-order preservation (flip-verified), body-only match, title+body appears once in the title half, case-insensitivity both fields, empty/whitespace query, unreadable body, and the real `readBody` rail over a temp Home (frontmatter value "Pass-2 Done" never matches; body needle does). + +## Decisions & Rationale + +| Decision | Rationale | +|----------|-----------| +| Pure seam extracted instead of inline filter (report sketch deviation) | The brief demanded a RED-capable test; the report's own sketch inlined the filter in the detached closure. The `bodyOf` injection keeps `readBody` at the call site while making ranking/partitioning/stripping testable. Noted as a deviation, honored elsewhere. | +| `@Sendable (Post) -> String?` reader parameter | Swift 6: the closure is created on MainActor and captured by `Task.detached`; only a `@Sendable` parameter type with Sendable-only captures (URL, [Post]) compiles. | +| Debounce = `.task(id: query)` + sleep, not a timer | Task(id:) restarts cancel the in-flight wave on every keystroke — fast typing coalesces into ONE scan per settled query. View-local per the report's own verification sketch (manual smoke); views stay untested per house convention. | +| Empty-query guard inside the seam | `localizedCaseInsensitiveContains("")` returns false on this platform anyway (flip attempt proved the empty-query pin CANNOT fail via that path — it is documentation, not discriminator); the guard makes the contract platform-independent. The ranking pin is the flip-verified one. | +| Field row unconditional (always visible) | Per the report sketch — the field sits under the header even when idle; `isSearching` only branches the content below it. | + +## Gotchas & Fixes + +| Problem | Root Cause | Fix | +|---------|------------|-----| +| Whole-suite build failed "Unprintable ASCII character found in source file" (LibrarySearchTests.swift:56:43) while earlier runs were green | A rename patch rode a decoded TAB byte into the whitespace-query string literal (backslash-n + RAW tab); Swift 6 rejects raw tabs in single-line string literals. The tool transport decodes `\t`/`\n` escapes; the original green runs predated the patch. | chr()-composed scratch script replaced the raw tab with the two-character `\t` escape; control-byte scan of both touched files clean (commit 7e75d53). Compose Swift string-escape bytes via chr(92) when patching through JSON-transported tools. | +| Full-suite runs 04:11–04:41 dispatched ZERO tests: "Timed out while enabling automation mode" (UI runner), "test runner hung before establishing connection" (unit host), "Timed out after 120.0s while initiating control session with daemon" | Three concurrent xcodebuild test runners (this session + helm #684 + vivarium #97) contend for testmanagerd, whose control sessions serialize — the #30 contention family, sustained all night. | Killed own run only; one serialized (`-parallel-testing-enabled NO`, `test-without-building`) retry still wedged. Per the #134 lesson, stopped retrying: the machine needs an idle window (possibly a reboot). Seam verification was captured through the REAL hosted runner BEFORE the wedge (02:13: 7/7; 02:15 flip run: 1/7 failed as intended). | +| `Museion/AGENTS.md` DOX line not applied | The session's write-protection blocks AGENTS.md writes without live user consent; single-query mode has none. | Intended one-liner carried in the session report for @aegis/Alexander to apply or approve. Devlog + INDEX (non-protected) landed normally. | + +## Verification + +- `xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' build` → ** BUILD SUCCEEDED ** (final tree, 02:16). +- `xcodebuild … -only-testing:MuseionTests/LibrarySearchTests test` (02:13, pre-wedge, real hosted runner) → xcresult `Test-Museion-2026.11.03_02-13-11.xcresult`: `passedTests 7, failedTests 0, totalTestCount 7`. +- Flip run (02:15, partition reversed + guard dropped): `passedTests 6, failedTests 1` — the ranking pin failed as intended, then restored; the only later test-file change is the escape-byte fix (runtime value identical). +- `swiftformat` + `swiftlint` on both touched files: 0 serious violations (PostsPaneView.swift carries the pre-existing 481→610-line `file_length` warning, same class HEAD already shipped). +- Full-suite rerun on the final tree BLOCKED by runner contention (zero tests dispatched across 3 attempts; bundles `Test-Museion-2026.11.03_04-11-25`, `_04-18-05`, `_04-41-31`) — needs an idle machine; commands in the handoff to @aegis. + +## Next Steps + +- Apply the `Museion/AGENTS.md` PostsPaneView-entry line (text in the aegis report) once AGENTS.md writes are consented. +- Authoritative full-suite rerun on an idle machine (or after reboot if the daemon wedge persists when idle) before/at PR review. +- Optional follow-up (not this branch): extract the search UI members if PostsPaneView.swift's file length ever gets a split ticket. diff --git a/docs/devlog/INDEX.md b/docs/devlog/INDEX.md index b9a8273..ce1db93 100644 --- a/docs/devlog/INDEX.md +++ b/docs/devlog/INDEX.md @@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa | Date | Type | File | Summary | |------|------|------|---------| +| 2026-11-03 | issue | [20261103-issue144-library-search-titles-bodies_log.md](20261103-issue144-library-search-titles-bodies_log.md) | #144 library search: title+body filter under the Posts header, LibrarySearch pure seam (7 pins, ranking flip-verified), 250 ms debounced off-main scan; raw-tab toolchain gotcha + runner-contention log | | 2026-11-02 | issue | [20261102-issue141-image-drop-illustration-ingest_log.md](20261102-issue141-image-drop-illustration-ingest_log.md) | Image drop → assets/ ingest at drop point; window-destination routing, firstRect viewport-band solve, finish-audit fixes | | 2026-11-01 | issue | [20261101-issue34-m6-illustrations-travel-inline-s6-2_log.md](20261101-issue34-m6-illustrations-travel-inline-s6-2_log.md) | #34 illustrations: media-endpoint upload, refs rewrite INLINE with URLs (dogfood killed the photo property); audit: injection/symlink/dedup — 546 tests | | 2026-10-31 | issue | [20261031-issue33-m6-micropub-draft-publish-s6-1_log.md](20261031-issue33-m6-micropub-draft-publish-s6-1_log.md) | Two-step Micro.blog publish: Micropub draft→update, Keychain token, trustworthyURL gate, category inert |