Skip to content

Lift residual shell-layer orchestration: TagRepository count/filter + FileRepository path-suffix + sentinel-migration hook #119

Open

Description

@utof

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions