fix(search): move scope→item-type taxonomy into Rust (UR-049, DR-063)
Stage 1 of scoped-search-boundary-implementation.md — the query side.
scoped-search-boundary.md diagnosed this leak, specified the fix in
detail, and became the justification for the boundary rule in CLAUDE.md,
the check:boundary tripwire, and the spec-review checklist. The fix was
never built: SCOPE_ITEM_TYPES was still live in searchScope.ts, called by
library.ts, and no SearchScope existed anywhere in src-tauri/. The rule's
own founding violation was still shipping.
Rust now owns the taxonomy:
pub enum SearchScope { All, Music, Movies, Tv }
impl SearchScope { pub fn item_types(self) -> Option<Vec<String>> }
- SearchOptions gains `scope`, resolved by resolve_scope(). Scope wins
over include_item_types, which stays for the non-search get_items
callers that legitimately request one concrete type.
- repository_search resolves the scope ONCE, before the cache/server
paths diverge, so online and offline filter identically — the failure
mode most likely to go unnoticed.
- All expands to None (no filter), not the union of the other scopes:
an explicit includeItemTypes list would silently drop People, folders,
and any type nobody enumerated.
- searchScope.ts re-exports SearchScope from generated bindings instead
of a hand-written union, and no longer names an item type for search.
- library.ts sends { scope }.
8 Rust tests written first, confirmed failing on "use of undeclared type
SearchScope" before the implementation existed.
The frontend tests that asserted includeItemTypes contents were rewritten
to assert the opaque scope is sent and includeItemTypes is absent —
keeping the old assertions would require the frontend to know the
taxonomy again, defeating the fix. The expansion is now asserted in Rust.
Verified the spec's headline criterion by hashing every src/ file, adding
"AudioBook" to the Music scope in Rust, and re-hashing: zero frontend
files change. That criterion failed before this commit.
Stage 2 (result-side grouping: GROUP_ITEM_TYPES, GroupedSearchResult on
both search payloads) remains open.
This commit is contained in:
@@ -395,7 +395,12 @@ pub struct SearchUpdateEvent {
|
||||
pub result: SearchResult,
|
||||
}
|
||||
|
||||
/// Search for items
|
||||
/// Search for items.
|
||||
///
|
||||
/// Resolves `SearchOptions::scope` into concrete Jellyfin item types before
|
||||
/// dispatching, so scope taxonomy stays in Rust.
|
||||
///
|
||||
/// TRACES: UR-049, UR-050 | DR-063
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn repository_search(
|
||||
@@ -408,6 +413,16 @@ pub async fn repository_search(
|
||||
) -> Result<SearchResult, String> {
|
||||
let repo = manager.0.get(&handle).ok_or("Repository not found")?;
|
||||
|
||||
// Expand the opaque scope into item types HERE — once, before the cache and
|
||||
// server paths diverge — so both phases filter identically. Doing it later
|
||||
// (or in only one path) makes offline results disagree with online ones.
|
||||
// The frontend sends `scope` and never names a Jellyfin item type for
|
||||
// search; see docs/specs/scoped-search-boundary.md.
|
||||
let options = options.map(|mut o| {
|
||||
o.resolve_scope();
|
||||
o
|
||||
});
|
||||
|
||||
// Phase 1: instant local results from the cache (downloaded content) so the
|
||||
// UI can render immediately while the server is still being queried.
|
||||
let mut cache_result = repo
|
||||
|
||||
Reference in New Issue
Block a user