Skip to content

Add reproduction for Trie issue - #6862

Merged
tim-smart merged 2 commits into
mainfrom
audit/repro-core-trie-longest-prefix-mismatch
Aug 3, 2026
Merged

Add reproduction for Trie issue#6862
tim-smart merged 2 commits into
mainfrom
audit/repro-core-trie-longest-prefix-mismatch

Conversation

@fubhy

@fubhy fubhy commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • fix Trie.longestPrefixOf so valued sibling nodes are not accepted as prefixes
  • retain the regression test covering a non-matching sibling
  • add a patch changeset for effect

Root cause

The traversal recorded a node's value before checking whether the current input character matched that node. Values on left or right siblings could therefore be returned as prefixes.

Validation

  • pnpm test --run packages/effect/test/Trie.test.ts
  • pnpm lint
  • pnpm check

Closes EFF-316

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Aug 1, 2026
@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: acc9713

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/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue 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/docgen Patch
@effect/doctest Patch
@effect/openapi-generator 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 the 4.0 label Aug 1, 2026

@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 — a single reproduction test for a Trie.longestPrefixOf bug.

  • Reproduction test for sibling-node prefix misattributionlongestPrefixOf on Trie.make(["a", 1], ["b", 2]) with input "c" incorrectly returns Option.some(["c", 2]) instead of Option.none(), because the algorithm records every valued node it traverses (including siblings reached via left/right comparisons) using the input key slice rather than the actual stored key.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@effect-slopcop effect-slopcop Bot added the bug Something isn't working label Aug 2, 2026
@tim-smart
tim-smart enabled auto-merge (squash) August 2, 2026 23:25
@tim-smart
tim-smart force-pushed the audit/repro-core-trie-longest-prefix-mismatch branch from f39ea8b to 81063f4 Compare August 2, 2026 23:26

@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 — since the prior Pullfrog review, one commit added the fix and a patch changeset.

  • Fixed longestPrefixOf sibling-node prefix misattribution — moved the value-check from before the character comparison into the else (match) branch, so only nodes whose key matches the current input character are considered candidate prefixes.
  • Added patch changeset for effect.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@github-actions

github-actions Bot commented Aug 2, 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 6.77 KB 6.77 KB 0.00 KB (0.00%)
batching.ts 9.57 KB 9.57 KB 0.00 KB (0.00%)
brand.ts 6.45 KB 6.45 KB 0.00 KB (0.00%)
cache.ts 10.31 KB 10.31 KB 0.00 KB (0.00%)
config.ts 20.47 KB 20.47 KB 0.00 KB (0.00%)
differ.ts 20.08 KB 20.08 KB 0.00 KB (0.00%)
http-client.ts 21.16 KB 21.16 KB 0.00 KB (0.00%)
logger.ts 10.46 KB 10.46 KB 0.00 KB (0.00%)
metric.ts 8.70 KB 8.70 KB 0.00 KB (0.00%)
optic.ts 7.46 KB 7.46 KB 0.00 KB (0.00%)
pubsub.ts 14.60 KB 14.60 KB 0.00 KB (0.00%)
queue.ts 11.26 KB 11.26 KB 0.00 KB (0.00%)
schedule.ts 10.44 KB 10.44 KB 0.00 KB (0.00%)
schema-class.ts 19.02 KB 19.02 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.82 KB 28.82 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.14 KB 25.14 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.12 KB 13.12 KB 0.00 KB (0.00%)
schema-string.ts 10.79 KB 10.79 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.00 KB 15.00 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.80 KB 21.80 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.21 KB 24.21 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.06 KB 19.06 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.88 KB 18.88 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.75 KB 18.75 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.50 KB 22.50 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.41 KB 19.41 KB 0.00 KB (0.00%)
schema.ts 18.27 KB 18.27 KB 0.00 KB (0.00%)
stm.ts 12.25 KB 12.25 KB 0.00 KB (0.00%)
stream.ts 9.49 KB 9.49 KB 0.00 KB (0.00%)

@tim-smart
tim-smart force-pushed the audit/repro-core-trie-longest-prefix-mismatch branch from 81063f4 to 4ea3463 Compare August 2, 2026 23:57
@tim-smart
tim-smart force-pushed the audit/repro-core-trie-longest-prefix-mismatch branch from 4ea3463 to acc9713 Compare August 2, 2026 23:58
@tim-smart
tim-smart merged commit 4b3460d into main Aug 3, 2026
15 checks passed
@tim-smart
tim-smart deleted the audit/repro-core-trie-longest-prefix-mismatch branch August 3, 2026 00:03
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Aug 3, 2026
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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants