Skip to content

fix(events): normalize path separators so file.changed globs match on Windows - #966

Merged
will-lamerton merged 1 commit into
Nano-Collective:mainfrom
addyCooks:fix/windows-event-glob-separators
Aug 30, 2026
Merged

fix(events): normalize path separators so file.changed globs match on Windows#966
will-lamerton merged 1 commit into
Nano-Collective:mainfrom
addyCooks:fix/windows-event-glob-separators

Conversation

@addyCooks

Copy link
Copy Markdown
Contributor

Description

chokidar reports changed files using the platform separator, so on Windows the router was asked to match a /-authored pattern like docs/** against docs\guide.md a comparison that can never succeed. Path-scoped file.changed subscriptions therefore never fired, and nothing reported a problem: the daemon started, reported healthy and logged nothing, because no code path treats a non-match as an error.

The same mismatch ran the other way too. globToRegex compiles * to [^/]*, which does not exclude a backslash, so a root-scoped pattern such as *.md matched the nested sub\a.md and dispatched an unattended agent run against a file that was deliberately scoped out.

Normalize in FileWatcherSource.emit rather than only in the matcher, so the router, activity reports and the payload handed to a triggered agent all read one path shape; matchGlob normalizes both pattern and path defensively. Once the path uses /, [^/] stops at a real separator and the over-match disappears along with the under-match.

The picomatch swap noted at event-router.ts:100 is left as a follow-up it is not resolvable as a transitive dependency under pnpm's strict linking and would need adding as a direct one.

Closes #964.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this change for the changelog

Testing

Automated Tests

  • New features include passing tests in .spec.ts/tsx files
  • All existing tests pass (pnpm test:all completes successfully)
  • Tests cover both success and error scenarios

Manual Testing

  • Tested with Ollama
  • Tested with OpenRouter
  • Tested with OpenAI-compatible API
  • Tested MCP integration (if applicable)

Checklist

  • If this was for an open issue, I was assigned to it
  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)
  • Appropriate logging added using structured logging (see CONTRIBUTING.md)

chokidar reports changed files using the platform separator, so on Windows
the router was asked to match a `/`-authored pattern like `docs/**` against
`docs\guide.md` — a comparison that can never succeed. Path-scoped
`file.changed` subscriptions therefore never fired, and nothing reported a
problem: the daemon started, reported healthy and logged nothing, because no
code path treats a non-match as an error.

The same mismatch ran the other way too. `globToRegex` compiles `*` to
`[^/]*`, which does not exclude a backslash, so a root-scoped pattern such as
`*.md` matched the nested `sub\a.md` and dispatched an unattended agent run
against a file that was deliberately scoped out.

Normalize in `FileWatcherSource.emit` rather than only in the matcher, so the
router, activity reports and the payload handed to a triggered agent all read
one path shape; `matchGlob` normalizes both pattern and path defensively.
Once the path uses `/`, `[^/]` stops at a real separator and the over-match
disappears along with the under-match.

The picomatch swap noted at event-router.ts:100 is left as a follow-up — it
is not resolvable as a transitive dependency under pnpm's strict linking and
would need adding as a direct one.

Closes Nano-Collective#964.
@will-lamerton

Copy link
Copy Markdown
Member

Looking great @addyCooks :)

@will-lamerton
will-lamerton merged commit b96d2d4 into Nano-Collective:main Aug 30, 2026
11 checks passed
@addyCooks

Copy link
Copy Markdown
Contributor Author

Thankyou @will-lamerton !

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.

[Bug] Windows: event-router glob matching assumes "/" separators, so file.changed subscriptions silently miss files or fire out of scope

2 participants