Skip to content

Let editor hosts validate one file without re-reading the whole space #183

Open

Description

@mindsocket

Problem

validateFile reads and validates the whole space on every call. That fits the CLI, but editor hosts call it on every pause in typing, for the same space each time.

  • measured: validateResolvedFile (src/validate.ts:569) calls readSpace(context) and then validateNodes over every node, then filters the issues down to the one file.
  • measured: validateFile (src/validate.ts:605) builds a fresh SpaceContext per call, so nothing is reused across calls.
  • measured: the space is read from disk, so a host can't validate unsaved editor contents.
  • hypothesis: on a large space (thousands of notes) each validation takes long enough for the Obsidian plugin to lag visibly. Check by timing validateFile on a 5,000-note folder.

Options

  1. A stateful session. The host creates it once per space, tells it which files changed (with optional in-memory contents), and asks for one file's issues. It re-reads only the changed files and reuses the parsed nodes and schema.
  2. Reuse a read space. An option to pass an already-read readSpace result (or a cache object) into validateFile, so the host decides when to invalidate.
  3. A cache inside core, keyed by file path and mtime. Hosts change nothing, but core takes on process-global state.

Leaning towards 1 or 2: the host already knows what changed (Obsidian's vault events), and core stays free of global state.

Graph-level checks (broken links, hierarchy, duplicates) still need the whole graph, so this is about not re-reading and re-parsing unchanged files, not about skipping cross-file validation.

Context

Raised by a review of the Obsidian plugin (mindsocket/obsidian-structured-context), which validates the active note after each debounced edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions