Repository navigation
Description
Context
The 2026-04-21 architecture-audit Batch B migrated crates/cli to delegate through crates/app::AppContainer::{scan,search,tag,volume,metadata} UseCases. Five areas of shell-layer orchestration remain residual — acceptable for Batch B scope but worth lifting in a follow-up.
Residuals
1. Path → hash resolution (tag add/rm path)
crates/cli/src/cmd/tag.rs currently opens a fresh SqliteFileRepository to call list_file_locations(usize::MAX, None) and walk results comparing relative paths. Shell-layer orchestration.
Lift direction: Add FileRepository::find_by_relative_path(volume, path) -> Result<Option<BlakeHash>> or equivalent, consumed via a new TagCommand variant (e.g., AttachByPath { path, tag }).
2. Tag-count / tag-filter summaries (ls --tag <name>, tag --count)
crates/cli/src/cmd/ls.rs + crates/cli/src/cmd/tag.rs call TagRepository::{files_with_tag, count_files_for_tag} + FileRepository::list_file_locations directly to implement the --tag <name> filter and the tag count column.
Lift direction: Extend TagCommand with ListFilesByTag { tag, limit, offset } + CountFilesByTag { tag }; return populated TagOutput variants.
3. ls --volume <id> post-filter
crates/cli/src/cmd/ls.rs applies --volume filtering in the shell after fetching all metadata rows. Shell-layer orchestration.
Lift direction: MetadataCommand::ListFiles + ::ListFilesWithMetadata already have an implicit Option<VolumeId> filter position; wire the actual filter through the repo call (MetadataRepository::list_with_metadata(limit, volume) already takes it — plumb volume from MetadataCommand).
4. Sentinel-migration on_persist closure
crates/cli/src/main.rs::dispatch_scan opens a 6th SqliteFileRepository connection purely to close over migrate_sentinel_row and pass as Option<Arc<dyn Fn>> into ScanCommand::Full.on_persist. Acceptable temporary residual per Batch B Task 2 design notes — Batch E's event-bus redesign can replace via FileEvent::LocationUpserted + a dedicated migration handler in crates/db.
Lift direction: Emit FileEvent::LocationUpserted from ScanUseCase after every successful upsert_location; register a SentinelMigrationHandler: EventBus in crates/db that wraps SqliteFileRepository::migrate_sentinel_row. Removes the OnPersist type alias entirely.
5. cmd/metadata.rs single-file extract
Currently untouched by Batch B (the UseCase only covers list flows, not extract flows). The 297-LOC single-file metadata extraction orchestration still lives in the shell.
Lift direction: New MetadataCommand::ExtractOne { hash, path, volume } variant backed by MetadataQueue::spawn refactored to work inside a UseCase call path.
Priority
Low — these are cleanup items. Batch B delivered the headline goal (ScanUseCase at -59% LOC, single bus-construction invariant, AppContainer shared across 5 UseCases). These residuals were explicitly accepted in the Batch B review as "fix-vs-file threshold: file as issue".
Blocker for future batches?
- rustfmt nightly-only options produce warnings on stable #4 (sentinel migration) is the only item explicitly coupled to a batch — Batch E should handle it alongside the
async-broadcastbus swap. - Upgrade actions/checkout to v5 (Node 24 deprecation) #1/Extract shared Config module from CLI + desktop duplication #2/Refactor scan::run into a ScanContext struct #3 are independent cleanup, suitable as a single follow-up PR.
- macOS watcher event-mapping: delete coalesced to Modify, rename split into Creates #5 pairs with any future extractor-related work (existing Error granularity: MediaSource + MediaParser errors silently swallowed in extractor #110 / perf(media): amortize fast_image_resize Resizer scratch buffers across thumbnail-worker iterations #111 area).
Activity
fix(desktop): clear 11 latent clippy errors blocking CI
test(desktop): ignore 3 _inner tests deadlocking via SQLite #131
test: scope SQLite-deadlock workarounds to the still-affected surface