CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
Exactly one #144 devlog row and one log remain: the held branch's distinct content (raw-tab toolchain gotcha, runner-contention record) folds into the canonical landing log, the no-unit-test decision row is superseded by the rework's seam + 7-pin suite, Files Changed gains the rework rows, and the AGENTS.md catalog entries are held for consent (session write-protection). No CHANGELOG change — the landed entry stands.
9.0 KiB
9.0 KiB
Library search across titles and bodies (#144)
Date: 2026-11-03 Type: issue Reference: museion-#144 — [museion-FEAT-004] Library search across titles and bodies
Goal
Ship FEAT-004 (Argus cycle-1 smallest-win, effort S): search across post titles and bodies over the whole library. Fix direction pinned in the ticket: in-memory title filter + body scan scoped to the library roots, debounce, no new persistence. Full spec (UI sketch, code, constraints) in ~/argus-audits/audit/2026-11-02/museion-features.md §FEAT-004.
What Was Done
PostsLibraryColumn(Museion/PostsPaneView.swift) gains the search:query/matchesview state belowcollapsed,isSearching/trimmedQuerycomputed, the plain-textsearchFieldrow under the Posts header (magnifyingglass + clear ✕, bottom hairline),searchResults(_:)(flat list, mono count line, title matches first) andsearchEmptyState.- The scan:
.task(id: trimmedQuery)→ 250 ms debounce →await Self.search(...)— anonisolated static funcrunning the disk reads off MainActor but inside the structured task, with a per-pieceTask.isCancelledcheck. postRow(_:)extracted (LibraryPostRow+ full context menu) — sections and search results render the same row; results carry Rename/Convert/Move/Archive/Trash too.- DOX closeout:
Museion/AGENTS.mdPostsPaneView entry gains the**#144:**line (field, debounce, off-main posture, frontmatter exclusion, ordering, both render surfaces). - Verification: build SUCCEEDED; suite 574/574 (xcresult executed count); swiftformat idempotent; swiftlint adds zero error-severity violations.
- Rework (same day, 22:00 dispatch — the dispatched branch reduced onto this landing, no behavior change):
Museion/LibrarySearch.swiftextracts the pure coreresults(for:in:bodyOf:)(nonisolated enum, injected@Sendablereader) andsearch()mounts it inside the structured scan, shape unchanged —.task(id: trimmedQuery)untouched, per-piece cancellation now carried by the reader'sTask.isCancelledguard (a superseded sweep's body reads stop between files; the in-memory title walk completes and the caller's guard discards its result). - Rework verification: build SUCCEEDED (platform=macOS); targeted suite 7/7 (xcresult: totalTestCount 7, passed 7, failed 0, skipped 0 — real hosted runner); ranking flip (
bodyHits + titleHits) fails exactly the ranking pin (6 passed / 1 failed), restored and re-verified 7/7;swiftformat --lint0/3 files; swiftlint adds nothing (PostsPaneView.swift keeps its pre-existingfile_lengthwarning at 614 lines); full suite 588/589 — the single failure isMuseionUITests.testAppLaunches(activation flake: "Failed to activate application … (current state: Running Background)", reproduced twice, untouched target; the hosted unit tests — all 7 new pins included — ran green inside the launched app, so the launch path itself is proven).
Decisions & Rationale
| Decision | Rationale |
|---|---|
nonisolated static async helper instead of the spec's Task.detached |
Finish-audit converged finding (security + general): Task.detached is unstructured — .task(id:) cancellation never reaches it, and the spec's comment claimed it did. A nonisolated async func awaited from the .task runs off MainActor (doesn't inherit the actor) while staying on the same task, so SwiftUI's cancellation actually lands; per-piece check stops superseded sweeps between files. Single pass also killed the double title-predicate. |
.task(id: trimmedQuery) not query |
Whitespace-only edits ("foo"→"foo ") must not restart the debounce+scan for identical trimmed input; the id now agrees with the render gate's source of truth. |
postRow(_:) extraction |
Search results lacked the context menu (Rename/Move/etc. unreachable from results); one row+menu source for both sites beats duplicating the menu block. |
Stale-while-revalidate during debounce (matches nils only on clear) |
Spec's exact code: later keystrokes keep showing prior results through the 250 ms window instead of a spinner flicker; ProgressView is the first-search state. |
No readBody size gate |
Post.scan already reads every post.md unbounded at startup — search adds no new exposure class; a gate would change shared-function behavior beyond this diff. Ceiling documented as a ponytail: note with the PostScanCache-style memo upgrade path (LearningsIndex posture). |
| No unit test for the filter → superseded by the rework's seam + suite | Landing posture: view-local state, no pure logic added, no component-render harness (manual smoke). The rework extracts the pure core with an injected reader — ranking/partition/stripping are now pinned (MuseionTests/LibrarySearchTests.swift, 7 pins); the view layer stays untested per house convention. |
Two PostsLibraryColumn instances (unfocused layout + focus reveal) keep separate query state |
Matches #108's documented per-view collapsed posture; only one is alive at a time; AGENTS.md row promises availability, not shared state. Reviewer confirmed fine. |
Gotchas & Fixes
| Problem | Root Cause | Fix |
|---|---|---|
swiftlint opening_brace violation after formatting |
swiftformat pushed a wrapped else if condition's brace to its own line (#142's known trap) |
Hoisted the body read into a local (let body = …) so the condition never wraps — don't fight the formatter |
| Test-run exit 1 with all tests passing | My xcresult-summary one-liner ran while the bundle was still finalizing (#33's race, live again — a piped wait isn't enough) | Read the bundle in a separate later call: 574/574, 0 failed |
| swiftlint gate exits 2 repo-wide | Pre-existing: 289 violations / 72 serious at HEAD, identical with the diff; earlier chained runs piped through tail masked the exit code |
Proven pre-existing via stash control (same 289/72); named here and in the commit; my file adds zero errors |
GitNexus detect-changes said "No changes detected" despite a dirty tree |
Stale index after an earlier incremental analyze | Re-ran analyze (full, 5,820 nodes) → detect-changes then reported the true scope (PostsLibraryColumn + docs) |
Review flag: comment claimed .task(id:) cancels the in-flight scan |
Task.detached never receives parent cancellation — the prose promised an invariant the code didn't have |
Structured-concurrency fix above; the comment is now true |
| Test source rejected as "Unprintable ASCII character" (held branch, LibrarySearchTests.swift:56:43) after earlier green runs | A JSON-transported patch rode a decoded TAB byte into the whitespace-query string literal — Swift rejects raw tabs in single-line string literals, and the transport decodes \t/\n escapes |
The literal ships as the two-character \t escape (held-branch commit 7e75d53): compose Swift string-escape bytes via chr(92) when patching through JSON transports. The rework carries the fixed file byte-identical (blob 2368676) |
| Held branch's full-suite attempts dispatched ZERO tests ×3 (04:11–04:41: automation-mode timeout, runner hung before connection) | Three concurrent xcodebuild test runners (library-search + helm + vivarium) contending for testmanagerd — the #30 contention family | #134 lesson applied: stopped retrying, captured the seam runs before the wedge (7/7 at 02:13; flip run 1/7 as intended at 02:15). Channel recovered by 20:13 (review re-run 7/7); the rework's full suite ran clean apart from the UI-launch flake above |
Files Changed
| File | Change Summary |
|---|---|
Museion/PostsPaneView.swift |
+164/−23: search state, field, results, empty state, structured scan, postRow(_:) extraction |
Museion/AGENTS.md |
**#144:** line on the PostsPaneView entry (DOX closeout) |
AGENTS.md |
write-log window refresh + gitnexus index-stats churn |
Museion/LibrarySearch.swift |
rework: the pure seam extracted from the scan (nonisolated enum, injected reader) |
Museion/PostsPaneView.swift |
rework: search() mounts the seam inside the structured task — no behavior change |
MuseionTests/LibrarySearchTests.swift |
rework: 7-pin suite, byte-identical from the held branch |
Open Items & Next Steps
- Deferred: re-filter when a watcher rescan lands while a query sits unchanged (any keystroke refreshes; a later slice if it bites)
- Deferred:
folder(of:)re-walk per piece per sweep —PostScanCache-style body memo if it ever measures hot (named insearch()'s ponytail note; see thelocal-store-cachingskill) - Manual smoke: type a known word into Search posts → flat match list; clear → sections return; right-click a result → full menu
- Held for consent:
Museion/AGENTS.md+MuseionTests/AGENTS.mdcatalog entries forLibrarySearch.swift/LibrarySearchTests.swift(text in the branch handoff) — the implementation session's write-protection blocks AGENTS.md writes without a live user; apply or approve
Log written by write-log skill