Skip to content

Vendor find-my-way router - #7013

Merged
tim-smart merged 4 commits into
mainfrom
agent/codex-engineer/5efb9a48
Aug 5, 2026
Merged

Vendor find-my-way router#7013
tim-smart merged 4 commits into
mainfrom
agent/codex-engineer/5efb9a48

Conversation

@tim-smart

@tim-smart tim-smart commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • vendor the find-my-way-ts v0.1.6 radix router and query-string parser under Effect's FindMyWay module
  • preserve the existing public API and Tomas Della Vedova's MIT attribution
  • port all seven tests from the TypeScript package plus focused upstream regression coverage
  • remove the external package from effect and the pnpm lockfile

Upstream audit

The TypeScript rewrite forked from delvedor/find-my-way v7.7.0. Applicable fixes through current upstream were ported for:

  • optional parameters at the root path
  • safe multi-parameter separator matching and distinct route patterns
  • prototype-safe method lookup and the QUERY HTTP method
  • regex mismatch backtracking, empty captures, and maxParamLength fallback

Constraint routing, off/findRoute, and pretty-print fixes do not apply to this reduced API. The later semicolon-delimiter option was not included because it is an opt-in behavior/API change rather than a bug fix.

Validation

  • pnpm lint-fix
  • all eight targeted FindMyWay test files (53 tests)
  • packages/effect/test/HttpClient.test.ts and packages/effect/test/unstable/ai/McpServer/McpServer.test.ts (24 tests)
  • pnpm check
  • pnpm install --frozen-lockfile

Closes EFF-451

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 23582f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
@effect/platform-node-shared Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/vitest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-slopcop effect-slopcop Bot added 4.0 enhancement New feature or request labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 7.06 KB 7.06 KB 0.00 KB (0.00%)
batching.ts 9.86 KB 9.86 KB 0.00 KB (0.00%)
brand.ts 6.34 KB 6.34 KB 0.00 KB (0.00%)
cache.ts 10.71 KB 10.71 KB 0.00 KB (0.00%)
config.ts 20.60 KB 20.60 KB 0.00 KB (0.00%)
differ.ts 20.20 KB 20.20 KB 0.00 KB (0.00%)
http-client.ts 21.53 KB 21.53 KB 0.00 KB (0.00%)
logger.ts 10.84 KB 10.84 KB 0.00 KB (0.00%)
metric.ts 8.98 KB 8.98 KB 0.00 KB (0.00%)
optic.ts 7.18 KB 7.18 KB 0.00 KB (0.00%)
pubsub.ts 14.99 KB 14.99 KB 0.00 KB (0.00%)
queue.ts 11.66 KB 11.66 KB 0.00 KB (0.00%)
schedule.ts 10.83 KB 10.83 KB 0.00 KB (0.00%)
schema-class.ts 19.14 KB 19.14 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.96 KB 28.96 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.29 KB 25.29 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.38 KB 13.38 KB 0.00 KB (0.00%)
schema-string.ts 10.94 KB 10.94 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.17 KB 15.17 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.94 KB 21.94 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.34 KB 24.34 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.18 KB 19.18 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 19.01 KB 19.01 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.87 KB 18.87 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.60 KB 22.60 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.52 KB 19.52 KB 0.00 KB (0.00%)
schema.ts 18.41 KB 18.41 KB 0.00 KB (0.00%)
stm.ts 12.63 KB 12.63 KB 0.00 KB (0.00%)
stream.ts 9.80 KB 9.80 KB 0.00 KB (0.00%)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This PR vendors the find-my-way-ts@0.1.6 radix router and its fast-querystring parser into the effect package, replacing the external dependency. I reviewed the public API surface, the router implementation, the query-string parser, the test port, and the consumer integration in HttpRouter.ts.

  • Dependency removal: find-my-way-ts is removed from packages/effect/package.json and pnpm-lock.yaml; no remaining references exist in the repo.
  • Public API: FindMyWay.ts exports RouterConfig, PathInput, Router, FindResult, and make, matching the shape previously provided by the dependency.
  • Runtime behavior: the vendored router preserves the defaults and matching semantics used by HttpRouter.make and asHttpEffect, including trailing-slash / duplicate-slash normalization and HEAD→GET fallback.
  • Tests: seven upstream router test files are ported and pass; HttpClient.test.ts and McpServer.test.ts also pass.
  • Validation run: pnpm install --frozen-lockfile, pnpm lint-fix, pnpm check, targeted FindMyWay tests, HttpClient.test.ts, and McpServer.test.ts all pass.

One pre-existing upstream limitation was noted: Router.has() returns false even for registered routes, identical to find-my-way-ts@0.1.6. HttpRouter uses find() exclusively, so this is not a regression.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@effect-slopcop effect-slopcop Bot added the bug Something isn't working label Aug 5, 2026
Comment thread packages/effect/src/unstable/http/FindMyWay.ts
@tim-smart
tim-smart force-pushed the agent/codex-engineer/5efb9a48 branch from 7a0966b to eb9fc9f Compare August 5, 2026 02:02

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The incremental changes port several upstream router fixes and add good regression tests, but they also introduce or leave incomplete prototype-safety and decoding issues that should be addressed before merging.

Reviewed changes

This re-review covered the second commit (7a0966b0da) on top of the previously approved vendoring commit (fea3231f1c). The new work added a patch changeset, moved trees to a null-prototype object, added QUERY to the method list, and ported upstream fixes for optional root params, multi-parameter separator matching, regex/backtracking fallback, and maxParamLength fallback.

  • Changeset added: .changeset/fuzzy-routers-smile.md describes the patch-level router fixes.
  • Prototype-safe method lookup: trees is now Object.create(null), and a test confirms router.find("constructor", "/") returns undefined.
  • QUERY method: added to httpMethods so router.all("/all", ...) registers it.
  • Upstream bug fixes ported: optional parameters at /, multi-param separator backtracking, regex mismatch / empty-capture / maxParamLength fallback via brothersNodesStack, and empty-segment regex matching.
  • Regression tests added: new cases in methods.test.ts, optional-params.test.ts, path-params-match.test.ts, and regex.test.ts cover the ported fixes.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix all ➔Fix 👍s ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

Comment thread packages/effect/src/unstable/http/FindMyWay.ts
Comment thread packages/effect/src/unstable/http/FindMyWay/internal/router.ts Outdated
Comment thread packages/effect/src/unstable/http/FindMyWay/internal/router.ts Outdated
Comment thread packages/effect/src/unstable/http/FindMyWay/internal/router.ts
Comment thread packages/effect/src/unstable/http/FindMyWay/internal/router.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The latest commit addresses the licence placement feedback, but the previously raised prototype-safety, decoding, and regex concerns remain unaddressed.

Reviewed changes

The new commit (eb9fc9f2d1) only moved the MIT licence block below the imports in packages/effect/src/unstable/http/FindMyWay.ts, satisfying the earlier request from tim-smart. It also reconciled packages/effect/package.json and pnpm-lock.yaml against main (no net new dependencies introduced by this PR). No router implementation or test code changed.

  • Licence placement: fixed — the module JSDoc now sits above the imports and the licence block follows.
  • Remaining open items: the Pullfrog-originated threads on staticChildren prototype safety, compileCreateParams parameter loss for __proto__, out-of-bounds decoding in safeDecodeURIComponent, and the ReDoS posture of the new multi-parameter regex still apply to the current head.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@tim-smart

Copy link
Copy Markdown
Contributor Author

@pullfrog Please review the latest changes addressing the open threads.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This re-review covered the new commit (23582f3a0) since the previous Pullfrog review (eb9fc9f2d1). The incremental work addresses every open Pullfrog-originated thread from the prior review.

  • Prototype-safe static children and params: ParentNode.staticChildren and the object created by compileCreateParams now both use Object.create(null), closing the __proto__ / constructor pollution and parameter-loss vectors. New tests confirm /:__proto__ preserves its value and inherited Object.prototype properties no longer shadow registered static children.
  • Truncated percent encoding handling: safeDecodeURIComponent now breaks out of the decode loop when a % is followed by fewer than two characters, so paths like /test/a% correctly return undefined instead of producing "undefined" substrings.
  • Backtracking regression coverage: a mixed-separator /:foo-:bar- test with a-/b input was added alongside the existing 16k-separator test, both guarded by a 1s timeout.
  • Validation: all FindMyWay tests (57), HttpClient.test.ts, McpServer.test.ts, and pnpm check pass.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@tim-smart
tim-smart merged commit 306014a into main Aug 5, 2026
20 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/5efb9a48 branch August 5, 2026 02:17

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This incremental review covers the latest commit (23582f3) which addresses the open Pullfrog threads from the prior review. All five previously raised concerns are resolved.

  • Licence placement: the MIT licence block in packages/effect/src/unstable/http/FindMyWay.ts now sits below the imports, keeping the module JSDoc attached to the export.
  • Prototype-safe static children: ParentNode.staticChildren is initialized with Object.create(null), preventing inherited Object.prototype keys from affecting route lookup.
  • Prototype-safe params object: compileCreateParams now builds the parameters record with Object.create(null), so parameter names such as __proto__ are preserved.
  • ReDoS-safe multi-parameter matching: the regex for static parameter separators was changed from a greedy negative-lookahead to a bounded alternation with a lazy capture, and a mixed-separator regression test was added.
  • Truncated percent encoding: safeDecodeURIComponent now bounds-checks before reading i + 1 and i + 2, returning undefined for malformed trailing % sequences.
  • Regression coverage: new/updated tests confirm __proto__ parameter preservation, inherited static-child isolation, truncated percent encodings, and backtracking-safe separators.

Validation run on this branch: targeted FindMyWay tests pass and pnpm check succeeds.

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog

pullfrog Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog𝕏

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

Labels

4.0 bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant