Tunal/Plans/03 File browsing/S006-location-layer.md
2026-11-18 09:46:28 -06:00

2.2 KiB

S006 — Location layer and local backend

Category 03 File browsing · Model: Opus · Effort: medium · Depends on: S001 · Size: M · Human: no Files touched: crates/tunal-core/**

Goal

The protocol-neutral location layer every view talks to, plus the local backend: URIs, entries, errors, the Location trait, a scheme registry and folder watching.

Read

CLAUDE.md §3 (location layer rule), §4; PROMPT.md §Network connections (last bullet).

Steps

  • Types: Uri (scheme, authority, path as bytes; file:// paths keep OsString), Entry (raw name + lossy display name, kind incl. symlink target and target kind, size, mtime, mode, uid/gid, hidden), Error (NotFound, PermissionDenied, Exists, NotEmpty, Unsupported, Cancelled, Io, Remote) with needs_elevation().
  • Location trait (Send + Sync): chunked list, stat, open_read, open_write, mkdir, rename, delete, trash, symlink, capabilities(), watch(); unsupported operations default to Unsupported.
  • Locations registry: scheme → backend; resolve a Uri to its backend.
  • Local backend: lstat-based listing (symlinks not followed, target kind resolved), permission-denied folders return an error, non-UTF-8 names intact; watching with notify (inotify), debounced.
  • Mime guess by extension (mime_guess); folders/symlinks typed.
  • Example cargo run -p tunal-core --example ls -- <dir> prints entries and timing.
  • PROGRESS entry, INDEX line, commit S006: …

End criteria

  • cargo build --workspace, cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check pass.
  • On a scratch dir with a non-UTF-8 name, a broken symlink, a chmod 000 folder and 10 000 files, --example ls lists everything (the 000 folder reports PermissionDenied) in under 1 s.

Pitfalls

  • Never touch the real home in smoke runs: use the scratchpad.
  • Keep the trait object-safe; backends for MTP/AFC/SFTP will implement it later.
  • No new tests in this plan (D-013): verify with build, clippy and the smoke run; tests come in phase 12.

Handoff (→ PROGRESS.md)

Trait signatures and the URI format (file://, later trash:///, ios://, mtp://, sftp://).