Skip to content

fix(manager): type unread files, and give each parser one state model - #206

Merged
sweepies merged 6 commits into
mainfrom
fix/manager-state
Nov 9, 2026
Merged

sweepies merged 6 commits into
mainfrom
fix/manager-state

Conversation

@sweepies

@sweepies sweepies commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Third PR that replaces implicit state machines with explicit ones (after #204 and #205).

Changes

  • Unread files fail closed for every reason. A file the Count did not read was stored as one of two sentinel strings, and public::verdict compared against only UNREADABLE_SETTINGS. A .npmrc, yarn.lock, Gemfile.lock or .sln that a Gradle apply from: chain reached past MORE_ROUNDS therefore got UNREADABLE_DEEP text and counted as public-only. Unread (Failed, TooDeep) now replaces both constants, and Unread::of is the only classifier, so no reader can recognise one reason and miss the other. Gradle and Maven share Unread::reason for the warning text.
  • YAML locations: each mapping frame tracks an explicit Slot (Key, Value(Option<key>)). A complex key (? [a, b]) or an alias key used to consume no key slot, which shifted every later key onto the wrong value. Now that key and its value have no pointer, and the keys after it keep their own.
  • One Gradle lexer. gradle_vars::mask and the Lexer disagreed about // inside a ${…} template. The lexer now fills two buffers in one pass: code, with string text blanked, and comments-only, with strings kept. Both views therefore agree, and lexer decisions such as slashy-string detection read the same buffer in both modes. A script the lexer can't read is skipped with a skipped: warning rather than read in part. The corpus snapshot is unchanged.
  • Dockerfile: empty lines inside a continuation are skipped, as Docker skips them, so FROM \ followed by a blank line still finds its image.
  • go.mod: an unclosed require ( block fails, as unclosed replace ( and use ( blocks already did.
  • CredentialCheck (Scan, Skip, Undecided) replaces Option<bool>.
  • Terraform: add returns the dependency it pushed, so required_version can't modify whatever was pushed last.

Tests

New tests cover both unread reasons for line-based files, complex and alias YAML keys, // inside a Gradle template plus an unterminated script, and a Dockerfile continuation with an empty line and a comment line. The patchula-manager and patchula-engine suites pass, and Clippy is clean on manager, engine and update.

View guided diff Turn on auto-fix

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula 3ed108a Commit Preview URL

Branch Preview URL
Nov 09 2026, 01:05 AM

sweepies added a commit that referenced this pull request Nov 8, 2026
…d settings

Review findings on #206:
- Nested `${` templates recursed without bound: a short build script could
  overflow the stack and abort the process. Templates now nest at most 32
  deep; deeper text does not lex and its file is skipped with a warning.
- An unread `.npmrc` parsed as empty and an unread `.yarnrc.yml` as a bare
  YAML string, so their packages fell back to npmjs. A stand-in now marks
  its directory unread, and any unread npm settings file on a package's
  path fails its lookup, even when a readable file further up names the
  scope.
- A slashy regex after `return`, `println` and similar keywords is read as
  a string, so such valid Groovy is no longer skipped.
- Build logic whose braces never close does not lex, as documented.
- Dockerfile continuations join without a space, as Docker does; a
  byte-order mark, the escape directive and heredoc bodies are handled.
sweepies added a commit that referenced this pull request Nov 8, 2026
…ontexts

Second-pass review findings on #206:
- An unread Gemfile.lock read as an empty lock, so a gem the Gemfile put
  on rubygems.org was looked up there even when the real lock recorded a
  private remote. An unread lock now makes the lookups it could steer
  fail, as Composer's does.
- An unread aube-lock.yaml read as an empty lock; it now fails like npm's
  locks.
- A slashy regex after `else`, `do`, a closing brace or a binary operator
  is read as a string, not division.
sweepies added a commit that referenced this pull request Nov 9, 2026
Two review rounds on #206 found the same class of leak: a reader parsed
the stand-in text of a file the Count did not read as an empty file, and
a package fell back to a public registry (an unread .npmrc, then an
unread Gemfile.lock). Every reader had to remember to check a magic
string. Now it cannot forget:

- Files maps paths to Text, Read(String) or Unread(Unread), and
  Text::read is the only way to a file's text, so every reader decides
  what an unread file means. The stand-in strings and Unread::of are gone.
- Manifests that were not read are skipped with a warning before any
  extractor sees them; the public-only verdict is false for any unread
  file a verdict covers; settings and lock readers fail the lookups an
  unread file could steer, as each already did by hand.
- An unread Gradle script or gradle.properties stops variable
  resolution trusting any definition, since it may redefine any name.
- The engine records unread files as Text::Unread; the update crate's
  tool trees, read from disk, go through patchula_manager::all_read.
sweepies added a commit that referenced this pull request Nov 9, 2026
…d settings

Review findings on #206:
- Nested `${` templates recursed without bound: a short build script could
  overflow the stack and abort the process. Templates now nest at most 32
  deep; deeper text does not lex and its file is skipped with a warning.
- An unread `.npmrc` parsed as empty and an unread `.yarnrc.yml` as a bare
  YAML string, so their packages fell back to npmjs. A stand-in now marks
  its directory unread, and any unread npm settings file on a package's
  path fails its lookup, even when a readable file further up names the
  scope.
- A slashy regex after `return`, `println` and similar keywords is read as
  a string, so such valid Groovy is no longer skipped.
- Build logic whose braces never close does not lex, as documented.
- Dockerfile continuations join without a space, as Docker does; a
  byte-order mark, the escape directive and heredoc bodies are handled.
sweepies added a commit that referenced this pull request Nov 9, 2026
…ontexts

Second-pass review findings on #206:
- An unread Gemfile.lock read as an empty lock, so a gem the Gemfile put
  on rubygems.org was looked up there even when the real lock recorded a
  private remote. An unread lock now makes the lookups it could steer
  fail, as Composer's does.
- An unread aube-lock.yaml read as an empty lock; it now fails like npm's
  locks.
- A slashy regex after `else`, `do`, a closing brace or a binary operator
  is read as a string, not division.
sweepies added a commit that referenced this pull request Nov 9, 2026
Two review rounds on #206 found the same class of leak: a reader parsed
the stand-in text of a file the Count did not read as an empty file, and
a package fell back to a public registry (an unread .npmrc, then an
unread Gemfile.lock). Every reader had to remember to check a magic
string. Now it cannot forget:

- Files maps paths to Text, Read(String) or Unread(Unread), and
  Text::read is the only way to a file's text, so every reader decides
  what an unread file means. The stand-in strings and Unread::of are gone.
- Manifests that were not read are skipped with a warning before any
  extractor sees them; the public-only verdict is false for any unread
  file a verdict covers; settings and lock readers fail the lookups an
  unread file could steer, as each already did by hand.
- An unread Gradle script or gradle.properties stops variable
  resolution trusting any definition, since it may redefine any name.
- The engine records unread files as Text::Unread; the update crate's
  tool trees, read from disk, go through patchula_manager::all_read.
- A file the Count did not read was one of two magic strings, and the
  public-only verdict compared only one of them: a .npmrc, yarn.lock or
  Gemfile.lock that the include chain reached too late counted as public.
  Unread is now an enum, and Unread::of is the only way to recognise one,
  so every reader sees every reason. The verdict fails closed for both.
- YAML locations track each mapping's slot explicitly. A complex or alias
  key used to shift every later key onto the wrong value; now it and its
  value go unnamed and the keys after it keep their own.
- Gradle had two comment maskers that disagreed about `//` inside a
  template. The lexer now produces both views from one pass, and a script
  it cannot read is skipped with a warning instead of read in part.
- Dockerfile continuations skip empty lines, as Docker does.
- An unclosed go.mod `require (` block fails like `replace (` and `use (`.
- CredentialCheck names the scan, skip and undecided outcomes.
- Terraform's required_version no longer edits whatever was pushed last.
…d settings

Review findings on #206:
- Nested `${` templates recursed without bound: a short build script could
  overflow the stack and abort the process. Templates now nest at most 32
  deep; deeper text does not lex and its file is skipped with a warning.
- An unread `.npmrc` parsed as empty and an unread `.yarnrc.yml` as a bare
  YAML string, so their packages fell back to npmjs. A stand-in now marks
  its directory unread, and any unread npm settings file on a package's
  path fails its lookup, even when a readable file further up names the
  scope.
- A slashy regex after `return`, `println` and similar keywords is read as
  a string, so such valid Groovy is no longer skipped.
- Build logic whose braces never close does not lex, as documented.
- Dockerfile continuations join without a space, as Docker does; a
  byte-order mark, the escape directive and heredoc bodies are handled.
…ontexts

Second-pass review findings on #206:
- An unread Gemfile.lock read as an empty lock, so a gem the Gemfile put
  on rubygems.org was looked up there even when the real lock recorded a
  private remote. An unread lock now makes the lookups it could steer
  fail, as Composer's does.
- An unread aube-lock.yaml read as an empty lock; it now fails like npm's
  locks.
- A slashy regex after `else`, `do`, a closing brace or a binary operator
  is read as a string, not division.
Two review rounds on #206 found the same class of leak: a reader parsed
the stand-in text of a file the Count did not read as an empty file, and
a package fell back to a public registry (an unread .npmrc, then an
unread Gemfile.lock). Every reader had to remember to check a magic
string. Now it cannot forget:

- Files maps paths to Text, Read(String) or Unread(Unread), and
  Text::read is the only way to a file's text, so every reader decides
  what an unread file means. The stand-in strings and Unread::of are gone.
- Manifests that were not read are skipped with a warning before any
  extractor sees them; the public-only verdict is false for any unread
  file a verdict covers; settings and lock readers fail the lookups an
  unread file could steer, as each already did by hand.
- An unread Gradle script or gradle.properties stops variable
  resolution trusting any definition, since it may redefine any name.
- The engine records unread files as Text::Unread; the update crate's
  tool trees, read from disk, go through patchula_manager::all_read.
task_files dropped an unread mise config as if it included nothing, so a
configuration it pulled in from another folder through `..` lost its
only link to it and looked its tools up on the public backends. An unread
mise config may include anything, so every mise tool now fails its lookup
while one exists.
@sweepies
sweepies merged commit d6932bd into main Nov 9, 2026
13 checks passed
@sweepies
sweepies deleted the fix/manager-state branch November 9, 2026 01:13
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant