Files
jellytau/specs/scoped-search-boundary-implementation.html
T

464 lines
34 KiB
HTML

<!DOCTYPE HTML>
<html lang="en" class="navy" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Scoped Search Boundary — Implementation - JellyTau Documentation</title>
<!-- Custom HTML head -->
<meta name="description" content="Requirements, traceability, and architecture for the JellyTau Jellyfin client.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "navy";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('navy')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">Introduction</a></li><li class="chapter-item expanded affix "><li class="part-title">Requirements & Traceability</li><li class="chapter-item expanded "><a href="../requirements.html"><strong aria-hidden="true">1.</strong> Requirements Specification</a></li><li class="chapter-item expanded "><a href="../traceability.html"><strong aria-hidden="true">2.</strong> Traceability Matrix</a></li><li class="chapter-item expanded "><a href="../traceability-ci.html"><strong aria-hidden="true">3.</strong> Traceability CI</a></li><li class="chapter-item expanded "><a href="../traces-quick-ref.html"><strong aria-hidden="true">4.</strong> Traces Quick Reference</a></li><li class="chapter-item expanded affix "><li class="part-title">Architecture</li><li class="chapter-item expanded "><a href="../architecture/index.html"><strong aria-hidden="true">5.</strong> Overview</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../architecture/01-rust-backend.html"><strong aria-hidden="true">5.1.</strong> Rust Backend</a></li><li class="chapter-item "><a href="../architecture/02-svelte-frontend.html"><strong aria-hidden="true">5.2.</strong> Svelte Frontend</a></li><li class="chapter-item "><a href="../architecture/03-data-flow.html"><strong aria-hidden="true">5.3.</strong> Data Flow</a></li><li class="chapter-item "><a href="../architecture/04-type-sync-and-threading.html"><strong aria-hidden="true">5.4.</strong> Type Sync & Threading</a></li><li class="chapter-item "><a href="../architecture/05-platform-backends.html"><strong aria-hidden="true">5.5.</strong> Platform Backends</a></li><li class="chapter-item "><a href="../architecture/06-downloads-and-offline.html"><strong aria-hidden="true">5.6.</strong> Downloads & Offline</a></li><li class="chapter-item "><a href="../architecture/07-connectivity.html"><strong aria-hidden="true">5.7.</strong> Connectivity</a></li><li class="chapter-item "><a href="../architecture/08-database-design.html"><strong aria-hidden="true">5.8.</strong> Database Design</a></li><li class="chapter-item "><a href="../architecture/09-security.html"><strong aria-hidden="true">5.9.</strong> Security</a></li></ol></li><li class="chapter-item expanded "><li class="part-title">UX</li><li class="chapter-item expanded "><a href="../ux-flows.html"><strong aria-hidden="true">6.</strong> UX Flows</a></li><li class="chapter-item expanded affix "><li class="part-title">Specs — Pending Work</li><li class="chapter-item expanded "><a href="../specs/index.html"><strong aria-hidden="true">7.</strong> Specs Index</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-TEMPLATE.html"><strong aria-hidden="true">8.</strong> Spec Template</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-REVIEW-CHECKLIST.html"><strong aria-hidden="true">9.</strong> Spec Review Checklist</a></li><li class="chapter-item expanded "><a href="../specs/playback-backend-unification.html"><strong aria-hidden="true">10.</strong> Playback Backend Unification</a></li><li class="chapter-item expanded "><a href="../specs/linux-native-video-spike.html"><strong aria-hidden="true">11.</strong> Linux Native Video Spike</a></li><li class="chapter-item expanded "><a href="../specs/backend-owned-stream-selection.html"><strong aria-hidden="true">12.</strong> Backend-Owned Stream Selection</a></li><li class="chapter-item expanded "><a href="../specs/player-facade-enforcement.html"><strong aria-hidden="true">13.</strong> Player Facade Enforcement</a></li><li class="chapter-item expanded "><a href="../specs/windows-native-audio-backend.html"><strong aria-hidden="true">14.</strong> Windows Native Audio Backend</a></li><li class="chapter-item expanded "><a href="../specs/libmpv2-migration.html"><strong aria-hidden="true">15.</strong> libmpv2 Migration</a></li><li class="chapter-item expanded "><a href="../specs/read-through-media-cache.html"><strong aria-hidden="true">16.</strong> Read-Through Media Cache</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search.html"><strong aria-hidden="true">17.</strong> Scoped Search</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary.html"><strong aria-hidden="true">18.</strong> Scoped Search Boundary</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary-implementation.html" class="active"><strong aria-hidden="true">19.</strong> Scoped Search Boundary — Implementation</a></li><li class="chapter-item expanded "><a href="../specs/frontend-domain-model.html"><strong aria-hidden="true">20.</strong> Frontend Domain Model</a></li><li class="chapter-item expanded "><a href="../specs/desktop-native-video.html"><strong aria-hidden="true">21.</strong> Desktop Native Video</a></li><li class="chapter-item expanded "><a href="../specs/build-provenance.html"><strong aria-hidden="true">22.</strong> Build Provenance</a></li><li class="chapter-item expanded affix "><li class="part-title">Build & Release</li><li class="chapter-item expanded "><a href="../build/build-release.html"><strong aria-hidden="true">23.</strong> Build & Release</a></li><li class="chapter-item expanded "><a href="../release-checklist.html"><strong aria-hidden="true">24.</strong> Release Checklist</a></li><li class="chapter-item expanded "><a href="../native-player-verification.html"><strong aria-hidden="true">25.</strong> Native Player Verification</a></li><li class="chapter-item expanded "><a href="../build/build-desktop-packages.html"><strong aria-hidden="true">26.</strong> Desktop Packaging</a></li><li class="chapter-item expanded "><a href="../build/build-windows.html"><strong aria-hidden="true">27.</strong> Windows Build</a></li><li class="chapter-item expanded "><a href="../defect-windows.html"><strong aria-hidden="true">28.</strong> Defect Windows</a></li><li class="chapter-item expanded "><a href="../build/docker.html"><strong aria-hidden="true">29.</strong> Docker</a></li><li class="chapter-item expanded "><a href="../build/build-builder-image.html"><strong aria-hidden="true">30.</strong> Builder Image</a></li><li class="chapter-item expanded affix "><li class="spacer"></li><li class="chapter-item expanded affix "><a href="../api-redirect.html">Rust API Reference (rustdoc)</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">JellyTau Documentation</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau/_edit/master/docs/../docs/specs/scoped-search-boundary-implementation.md" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa fa-edit"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="spec-land-the-scoped-search-boundary-fix-implementation"><a class="header" href="#spec-land-the-scoped-search-boundary-fix-implementation">Spec: Land the scoped-search boundary fix (implementation)</a></h1>
<p><strong>Status:</strong> Stage 1 Implemented — Stage 2 (result-side grouping) outstanding
<strong>Requirements:</strong> UR-049, UR-050 | DR-063, DR-066, DR-067 (existing — no new IDs)
<strong>UX spec:</strong> n/a — zero user-visible change is the point (see Acceptance criteria).
<strong>Supersedes / revises:</strong> implements <a href="scoped-search-boundary.html">scoped-search-boundary.md</a>,
which specified this fix but was never built. That spec remains the <strong>design
authority</strong>; this one is the delivery plan and status correction.</p>
<h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
<p><a href="scoped-search-boundary.html">scoped-search-boundary.md</a> diagnosed a domain-taxonomy
leak, specified the fix in full detail, and became the justification for the
project's boundary rule in CLAUDE.md, the <code>check:boundary</code> tripwire, and the
spec-review checklist. <strong>The fix was never implemented.</strong> The leak it describes
is still live in <code>main</code>. This spec exists to close that gap and to correct the
record — the codebase currently enforces a rule against a violation it still
contains.</p>
<h2 id="motivation"><a class="header" href="#motivation">Motivation</a></h2>
<p>The mapping the rule forbids is present and in use:</p>
<pre><code class="language-ts">// src/lib/utils/searchScope.ts:29-32
const SCOPE_ITEM_TYPES: Record&lt;Exclude&lt;SearchScope, "all"&gt;, string[]&gt; = {
music: ["MusicAlbum", "MusicArtist", "Audio", "Playlist"],
movies: ["Movie"],
tv: ["Series", "Episode"],
};
</code></pre>
<p>This is not dead code. <a href="../../src/lib/stores/library.ts#L262">library.ts:262</a>
calls <code>scopeItemTypes(scope)</code> and puts the result straight into
<code>options.includeItemTypes</code>. Meanwhile there is <strong>no <code>SearchScope</code> anywhere in
<code>src-tauri/</code></strong>:</p>
<pre><code class="language-console">$ grep -rn "SearchScope" src-tauri/src --include='*.rs'
(no output)
</code></pre>
<p>Three things make this the highest-value item found in the design-principles
audit:</p>
<ol>
<li><strong>The rule's own founding incident is unremediated.</strong> CLAUDE.md cites this
spec as "the incident this rule came from." A rule whose originating
violation is still shipping is not credible.</li>
<li><strong>The tripwire cannot see it.</strong> <code>bun run check:boundary</code> passes — it greps for
a multi-type array literal <em>at the query site</em>, and this one is assigned to a
named const and dereferenced elsewhere. Broadening the tripwire is specified
separately by the tripwire hardening (DR-094, shipped);
note that hardening it <strong>without</strong> landing this fix would turn <code>master</code> red.</li>
<li><strong>The spec's own acceptance criterion fails today.</strong> "Adding a hypothetical
new type to a scope requires editing only Rust" — adding a type to the Music
scope right now requires editing <code>searchScope.ts</code>.</li>
</ol>
<h2 id="layer-assignment"><a class="header" href="#layer-assignment">Layer assignment</a></h2>
<p>Unchanged from <a href="scoped-search-boundary.html">scoped-search-boundary.md</a> §Design;
restated so this spec is reviewable on its own.</p>
<div class="table-wrapper"><table><thead><tr><th>Logic / responsibility</th><th>Layer</th><th>Why it belongs there</th></tr></thead><tbody>
<tr><td>Scope → Jellyfin item types (<code>music</code><code>MusicAlbum</code>, <code>MusicArtist</code>, <code>Audio</code>, <code>Playlist</code>)</td><td><strong>Rust</strong></td><td>Domain vocabulary. Changes if Jellyfin adds/renames an item type — the litmus test's "yes" case. This is the leak being fixed.</td></tr>
<tr><td>Result item → search group bucketing</td><td><strong>Rust</strong></td><td>Same taxonomy, result side. Classifying a <code>MediaItem</code> as a Song vs Album is Jellyfin vocabulary, not layout.</td></tr>
<tr><td><code>All</code> sends no filter at all (≠ union of enumerated types)</td><td><strong>Rust</strong></td><td>A query-shaping rule with a correctness consequence (Person/folder results would be silently dropped). Belongs with the expansion it qualifies.</td></tr>
<tr><td>Group display order, labels, reordering, persistence</td><td>Frontend</td><td>Pure presentation — changes only if the UI is redesigned. Explicitly retained frontend-side.</td></tr>
<tr><td><code>resolveSearchScope(pathname)</code> — route → initial scope</td><td>Frontend</td><td>Routing/navigation, no Jellyfin vocabulary. Stays exactly as-is.</td></tr>
<tr><td>Chip labels (<code>SCOPE_LABELS</code>), scope order (<code>SEARCH_SCOPES</code>)</td><td>Frontend</td><td>Display strings over an opaque enum.</td></tr>
<tr><td><code>GROUP_SCOPE</code> (which group belongs to which scope)</td><td><strong>Delete</strong></td><td>Borderline taxonomy, made redundant: once Rust filters by scope, out-of-scope groups arrive empty and drop via the empty-omit rule. Borderline defaults to Rust; here it defaults to <em>gone</em>.</td></tr>
</tbody></table>
</div>
<p>The <code>SearchScope</code> and <code>SearchGroupId</code> <strong>types</strong> come to the frontend from
generated <code>bindings.ts</code>. Naming an opaque enum variant is not taxonomy; knowing
what item types it expands to is.</p>
<h2 id="design"><a class="header" href="#design">Design</a></h2>
<p><strong>Follow <a href="scoped-search-boundary.html">scoped-search-boundary.md</a> §Design as
written</strong><code>SearchScope</code> enum + <code>item_types()</code> in <code>repository/types.rs</code>,
<code>SearchOptions.scope</code>, <code>SearchGroupId</code>/<code>SearchGroup</code>/<code>GroupedSearchResult</code>,
scope-wins precedence, <code>All</code><code>None</code> → no filter. It is not restated here;
duplicating it would create two drifting copies of the same design.</p>
<p>This spec adds only the delivery sequencing that the original left implicit.</p>
<h3 id="staging-land-it-in-two-reviewable-pieces"><a class="header" href="#staging-land-it-in-two-reviewable-pieces">Staging: land it in two reviewable pieces</a></h3>
<p>The original bundles the query side and the result side into one change. That is
a large diff touching Rust types, <code>bindings.ts</code>, the store, and a component, with
the <code>search-event</code> dual-payload hazard in the middle. Split it:</p>
<p><strong>Stage 1 — query side (closes the leak).</strong>
<code>SearchScope</code> enum, <code>SearchOptions.scope</code>, command resolves scope →
<code>include_item_types</code> in Rust, <code>library.ts</code> sends <code>{ scope }</code>, delete
<code>SCOPE_ITEM_TYPES</code> and <code>scopeItemTypes()</code>. Result grouping stays as it is.</p>
<p>After Stage 1 the actual boundary violation is gone and
the hardened tripwire (DR-094) can pass.</p>
<p><strong>Stage 2 — result side.</strong> <code>SearchGroupId</code>/<code>SearchGroup</code>/<code>GroupedSearchResult</code>,
Rust bucketing, both payloads converted, <code>composeSearchGroups()</code> shrunk,
<code>GROUP_ITEM_TYPES</code>/<code>groupItemTypes()</code>/<code>GROUP_SCOPE</code> deleted.</p>
<p>Both stages are required for the original spec's acceptance criteria to pass;
Stage 1 alone leaves <code>GROUP_ITEM_TYPES</code> in the frontend. <strong>Stage 1 is not a
stopping point</strong> — it is a review boundary. Do not mark the parent spec
Implemented until Stage 2 lands.</p>
<h3 id="stage-1--delivered-july-2026"><a class="header" href="#stage-1--delivered-july-2026">Stage 1 — delivered (July 2026)</a></h3>
<ul>
<li><code>SearchScope</code> enum + <code>item_types()</code> in <a href="../../src-tauri/src/repository/types.rs">repository/types.rs</a>;
<code>All</code><code>None</code> → no filter.</li>
<li><code>SearchOptions.scope</code> with <code>resolve_scope()</code>; scope wins over
<code>include_item_types</code>, which stays for the non-search <code>get_items</code> callers.</li>
<li><code>repository_search</code> resolves the scope <strong>once, before</strong> the cache/server split,
so both phases filter identically.</li>
<li><code>SCOPE_ITEM_TYPES</code> and <code>scopeItemTypes()</code> deleted; <code>searchScope.ts</code> now
re-exports <code>SearchScope</code> from the generated bindings instead of a hand-written
union.</li>
<li><a href="../../src/lib/stores/library.ts">library.ts</a> sends <code>{ scope }</code>.</li>
<li>8 Rust tests (<code>search_scope_tests</code>); the frontend suite now asserts the
<em>opaque scope</em> is sent rather than an item-type list.</li>
</ul>
<p>Verified: adding <code>"AudioBook"</code> to the Music scope changed <strong>zero</strong> files under
<code>src/</code> — the criterion that failed before this work.</p>
<p><strong>Stage 2 remains open</strong>: <code>GROUP_ITEM_TYPES</code> / <code>groupItemTypes()</code> (result-side
bucketing, single-type-per-group) are still in <code>searchScope.ts</code>, and both search
payloads still carry a flat <code>MediaItem[]</code> rather than <code>GroupedSearchResult</code>.</p>
<h3 id="-the-search-event-dual-payload-stage-2"><a class="header" href="#-the-search-event-dual-payload-stage-2">🔴 The <code>search-event</code> dual payload (Stage 2)</a></h3>
<p>The original flags this as "the single largest part of the change and the
easiest to half-do." Restating because it is the one thing that silently breaks:
search resolves <strong>twice</strong> — the command returns instant cache results, then the
merged cache+server union arrives via <code>search-event</code>. Both payloads must carry
<code>GroupedSearchResult</code>. Convert one and the UI flickers between shapes as server
results land.</p>
<p>Write the failing test for the <em>event</em> payload first — the command return is the
obvious half, the event is the half that gets forgotten.</p>
<h3 id="note-on-searchoptionsscope-and-specta"><a class="header" href="#note-on-searchoptionsscope-and-specta">Note on <code>SearchOptions.scope</code> and specta</a></h3>
<p><code>SearchOptions</code> is already <code>#[serde(rename_all = "camelCase")]</code> with
<code>skip_serializing_if = "Option::is_none"</code>. Add <code>scope: Option&lt;SearchScope&gt;</code>
following that pattern so <code>All</code>/absent omits the key. Regenerate <code>bindings.ts</code>
<code>SearchOptions</code> there is currently
<code>{ limit?, includeItemTypes?, searchTerm? }</code> and must gain <code>scope?</code>. Never
hand-edit it.</p>
<h2 id="out-of-scope"><a class="header" href="#out-of-scope">Out of scope</a></h2>
<ul>
<li>Redesigning anything in <a href="scoped-search-boundary.html">scoped-search-boundary.md</a>.
If implementation shows the design wrong, revise <strong>that</strong> spec, don't fork it.</li>
<li>Online/offline <code>include_item_types</code> <strong>filtering</strong> — already correct; only the
source of the type list moves.</li>
<li>Ranking within or across groups (DR-090 territory).</li>
<li>Chip UX, scope persistence, group-order persistence — unchanged.</li>
<li>The two lesser type-set sites in <code>DownloadedBrowse.svelte</code> and
<code>GenericMediaListPage.svelte</code>, handled in
the hardened tripwire (DR-094, see <code>scripts/check-frontend-boundary.sh</code>).</li>
<li>Broadening the tripwire itself — same sibling spec.</li>
</ul>
<h2 id="acceptance-criteria"><a class="header" href="#acceptance-criteria">Acceptance criteria</a></h2>
<p>Inherits every criterion from <a href="scoped-search-boundary.html">scoped-search-boundary.md</a>
§Acceptance criteria. Additionally:</p>
<ul>
<li><input disabled="" type="checkbox"/>
<code>grep -rn "SearchScope" src-tauri/src --include='*.rs'</code> returns matches —
the enum exists in Rust (it does not today).</li>
<li><input disabled="" type="checkbox"/>
<code>grep -n "SCOPE_ITEM_TYPES\|scopeItemTypes\|GROUP_ITEM_TYPES\|groupItemTypes" src/lib/utils/searchScope.ts</code>
returns nothing.</li>
<li><input disabled="" type="checkbox"/>
<code>grep -rn "scopeItemTypes" src/</code> returns nothing — including the
<code>library.ts</code> import and call site.</li>
<li><input disabled="" type="checkbox"/>
<code>SearchOptions</code> in <code>bindings.ts</code> includes <code>scope</code>; regenerated, not
hand-edited.</li>
<li><input disabled="" type="checkbox"/>
<strong>Behaviour is byte-identical for the user</strong>: same scoping, same groups,
same order, same empty-group omission, offline included. This spec is a
pure refactor — any visible change is a defect.</li>
<li><input disabled="" type="checkbox"/>
<code>All</code> scope sends no <code>includeItemTypes</code> (asserted in a Rust test, not by
inspection).</li>
<li><input disabled="" type="checkbox"/>
Adding a type to the Music scope requires editing <strong>only</strong> Rust —
demonstrate by making the edit and confirming no <code>src/</code> file changes.</li>
<li><input disabled="" type="checkbox"/>
<code>scoped-search-boundary.md</code> status flips to <strong>Implemented</strong>, and
<code>scoped-search.md</code>'s "frontend only, no Rust changes" framing gets a
banner pointing at the corrected design.</li>
<li><input disabled="" type="checkbox"/>
<code>bun run check</code> and <code>bun run test</code> pass.</li>
<li><input disabled="" type="checkbox"/>
<code>cargo fmt</code> clean, <code>cargo clippy</code> clean, <code>bun run test:rust</code> passes.</li>
<li><input disabled="" type="checkbox"/>
<code>bun run check:boundary</code> passes.</li>
<li><input disabled="" type="checkbox"/>
Changed code carries <code>// TRACES:</code> comments (IDs below).</li>
</ul>
<h2 id="testing"><a class="header" href="#testing">Testing</a></h2>
<p>Follow <a href="scoped-search-boundary.html">scoped-search-boundary.md</a> §Testing. Emphases:</p>
<p><strong>Rust</strong> (<code>cargo test</code>):</p>
<ul>
<li><code>SearchScope::item_types()</code> per scope; <code>All</code><code>None</code>.</li>
<li>Scope resolution happens <strong>before</strong> the online/offline split, so both paths
get the same filter — a regression here is invisible until someone searches
offline.</li>
<li><code>scope</code> set + <code>include_item_types</code> set → scope wins (the documented
precedence; assert it rather than trusting the doc).</li>
<li>Stage 2: mixed <code>Vec&lt;MediaItem&gt;</code> buckets correctly; unknown types dropped;
canonical group order; <strong>the <code>search-event</code> payload is the grouped shape</strong>.</li>
</ul>
<p><strong>Frontend</strong> (<code>bun run test</code>):</p>
<ul>
<li><code>resolveSearchScope()</code> tests in <code>searchScope.test.ts</code> must pass <strong>unchanged</strong>
they cover the part that is not moving, and are the regression net proving the
refactor didn't disturb routing.</li>
<li><code>library.ts</code> sends <code>{ scope }</code> and never <code>includeItemTypes</code> for search.</li>
<li><code>composeSearchGroups()</code> over fixture <code>SearchGroup[]</code> with no <code>.type</code>
inspection in the implementation.</li>
</ul>
<p><strong>Offline parity:</strong> run a scoped search with the server unreachable and confirm
identical grouping. The offline repository path honours <code>include_item_types</code>
independently, and this is the case most likely to be missed.</p>
<h2 id="traces"><a class="header" href="#traces">TRACES</a></h2>
<p>No new requirement IDs — this implements existing ones. Retag as the code moves:</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>// src-tauri/src/repository/types.rs
/// TRACES: UR-049 | DR-063
pub enum SearchScope { … }
<span class="boring">}</span></code></pre></pre>
<pre><code class="language-typescript">// src/lib/utils/searchScope.ts — keep the file header; it retains
// resolveSearchScope + group-order presentation logic.
// TRACES: UR-049, UR-050 | DR-063, DR-066, DR-067
</code></pre>
<p>Update DR-063's text in <code>requirements.md</code> to state that scope expansion is owned
by Rust, so the requirement stops describing the leaked design. New Rust tests
take <code>@req-test: UT-089</code> onward (next free UT is <strong>UT-089</strong>).</p>
<h2 id="notes-for-the-implementer"><a class="header" href="#notes-for-the-implementer">Notes for the implementer</a></h2>
<ul>
<li>A parallel Claude session may be active in this repo — <code>git diff</code> before
"repairing" unexpected changes (CLAUDE.md §Gotchas).</li>
<li><strong>Read <a href="scoped-search-boundary.html">scoped-search-boundary.md</a> first.</strong> This
spec is deliberately thin on design; that one is the authority.</li>
<li>Sequence with the sibling specs: <strong>Stage 1 here → then
the hardened tripwire (DR-094)</strong>. Hardening
the tripwire first turns <code>master</code> red on a known-unfixed violation.</li>
<li><code>git log --oneline -- docs/specs/scoped-search-boundary.md</code> is worth a look
before starting — understanding why the fix stalled may surface a constraint
the spec didn't record.</li>
<li>The user-visible-change count for this spec is zero. If QA reports a
difference in search results, that is a bug in the refactor, not an
improvement.</li>
</ul>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../specs/scoped-search-boundary.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../specs/frontend-domain-model.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="../specs/scoped-search-boundary.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../specs/frontend-domain-model.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
</div>
</body>
</html>