Skip to content

(chore) Split the mounts list_files service method into per-view methods and extract Git-view policy #5413

Description

@mmabrouk

The mounts list_files service method (api/oss/src/core/mounts/service.py) is really three unrelated views multiplexed by parameter shape: a shallow / with-counts view, a flat recency view, and a full browse view. The branches share about ten lines of setup and nothing else, and the mode matrix has silent edges (some flags are honored in one branch and ignored in another). Separately, roughly 500 of the file's ~1225 lines are Git-view policy (.gitignore spec loading, pruning, path-ignore matching) living inside MountsService, and the file-ops routes pass eight loose Query(...) params positionally into a wide service signature instead of the domain's parse-and-merge query-object pattern.

The goal is to make each view a named, separately-testable method and to move Git-view policy out of the service class.

  • Split list_files into named per-view service methods (e.g. list_files_shallow / list_files_flat / browse) behind the same wire endpoint. The PR already proves the shape works: the now-removed paged method was the cleanest view precisely because it was a separate named method.
  • Extract the Git-view policy (spec loading, pruned descent, _path_gitignored) into core/mounts/git_view.py; MountsService keeps its signatures and delegates. Unify the two .gitignore scopes behind one named contract (see the separate git_aware semantics issue).
  • Adopt the parse-and-merge query-object pattern for the file-ops routes, matching how the mounts domain already handles mount queries.

Follow-up from the #5400 backend review (fixes stacked in #5411/#5412). Cited findings: review finding 3.1 (list_files is three unrelated views with silent mode edges), 3.2 (about 500 lines of Git-view policy belong in their own module), 1.4 (loose GET params should use the query-object pattern). This is a refactor with no behavior change intended; the review report is not in the repo, so this summary stands alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BackendrefactoringA code change that neither fixes a bug nor adds a feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions