picatz / picatz/flowstate

lsp: the test diagnostic pass reads the sibling defaults file once per problem

Open
#1,272 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug lsp
Dominant language
Go
Stars
9
Forks
0
Avg merge
3h 3m
Merged PRs (30d)
509

Description

Problem

On main after #1266 merged (verified at 6c152e3), diagnoseTestPublications calls sourceForTestDiagnostic inside its per-problem loop (pkg/flowstate/v1/flowfile/lsp/testfile.go, the loop over problems.Problems), and that falls through to readCalleeSource(path) for every problem whose owning URI is not the suite and not an open defaults buffer — with no memoization. testProblemRange then re-splits the returned source into lines per diagnostic.

Measured during the #1266 review with a temporary counter on readCalleeSource: a suite whose sibling testdefaults.yaml declares 30 bad defaults.inputs entries produced 20 file reads for a single publication — one per problem, capped only by MaxLoadProblems. Worst case is 20 × maxDocumentBytes of file I/O plus 20 whole-file line splits per publication, and the publication fires on every keystroke in any open suite whose directory has a broken testdefaults.yaml that is not itself open, and once per suite at didOpen (33 open suites → 660 reads).

This crosses the rule written on the function being called — callinputs.go: "The reads are on an explicit completion or hover request rather than on every keystroke of a diagnostic pass" — and AGENTS.md invariant 5, since both the file size and the problem count are controlled by the workspace's author.

Desired outcome

One publication of a suite's diagnostics reads any given sibling source at most once, however many problems it owns, and converts positions from a line slice split once per file.

Acceptance criteria

  • A publication with N sibling-owned problems performs one read of that sibling (assertable with a counter or a counting filesystem seam, the way the review measured it).
  • testProblemRange (or its replacement) receives pre-split lines rather than re-splitting per diagnostic.
  • Existing loader-position tests stay green.

Raised in the Claude review on #1266 inside the merge window; filed so it does not sit in a closed PR's threads.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pkg/flowstate/v1/flowfile/lsp/testfile.go, tracing diagnoseTestPublications, sourceForTestDiagnostic, readCalleeSource, and testProblemRange; compare the read rule in callinputs.go and invariant 5 in AGENTS.md. Verify that one publication reads each sibling source once, splits its lines once, and keeps the existing loader-position tests green.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools, performance
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.