Skip to content

File provider: add ReadString method and List support for nf-ops migration #222

Closed

Description

@David-Noble-at-work

Summary

The noblefactor-ops FileReceiver is being replaced by the devlore-cli file provider (noblefactor-ops #98). Several capabilities are missing or broken.

Broken: Read returns Resource metadata, not file content

file.Read(path) docstring says "Returns: result: the contents of the file" but the code returns a Resource struct (metadata: inode, size, mode, checksum). It never reads the actual file content. Only callers are tests and plan.source() (indirect). This appears to be an AI implementation error.

Fix: Read should return the file content as a string. The current Resource-metadata behavior is useless — Exists, IsFile, and IsDir already cover metadata needs. If the Resource return is needed for plan.source() graph semantics, rename it to Stat or Resolve and make Read return (string, error).

Missing: List (directory listing)

nf-ops file.list(path, gitignore?) returns [{name, path, is_dir}] for directory entries. devlore has no equivalent. Glob("dir/*") returns paths but not the is_dir metadata. WalkTree is recursive (not single-level).

Options:

  1. Add a List(path Resource, honorGitignore bool) ([]map[string]any, error) method
  2. Accept that glob("dir/*") + is_dir() on each result is sufficient (nf-ops scripts don't currently call file.list() anyway)

Missing: DryRun in immediate mode

nf-ops FileReceiver checks a global DryRun flag before write, mkdir, remove, remove_all. The devlore file provider only enforces DryRun at the graph execution layer (action_reflect.go). In immediate mode (nf-ops style), write operations execute unconditionally.

Options:

  1. Add p.Context().DryRun checks to write-side provider methods
  2. Accept that immediate-mode callers handle DryRun externally

Context

  • noblefactor-ops docs: add Phase 1 plan for GoReceiver AST primitives #98: Migrate all hand-coded receivers to the provider model
  • The FileReceiver is one of 9 receivers being migrated
  • Current nf-ops usage: only lint-copyright.star calls file.read(), file.write(), file.exists(), file.glob() — but the new Go style linter will use more file operations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions