Skip to content

fix(pattern): JS subtree of a max-depth path is the path itself - #4360

Merged
kixelated merged 2 commits into
mainfrom
fix/js-pattern-subtree-max-depth
Sep 28, 2026
Merged

kixelated merged 2 commits into
mainfrom
fix/js-pattern-subtree-max-depth

Conversation

@kixelated

@kixelated kixelated commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#4284 fixed Rust so Pattern::subtree of a 32-segment (MAX_SEGMENTS) path returns the literal instead of appending ** and overflowing the limit. @moq/pattern was not mirrored, so Pattern.subtree still throws too-many-segments for a max-depth path. The shared vectors had no case for it, so the drift went unnoticed.

Approach

  • js/pattern: Pattern.subtree appends ** only when the path has fewer than MAX_SEGMENTS segments, matching Rust.
  • rs/moq-pattern/tests/pattern.json: add a 32-segment subtree case (yields the literal) and a 33-segment case (too-many-segments). Both harnesses now accept an error on subtree vectors, like literal. The new vector fails on JS without the fix.
  • Fix the stale $comment that still named moq-net/js/net.
  • Drop fix(pattern): subtree of a max-depth path is the path itself #4284's Rust unit-test copy of the max-depth subtree case; the shared vector now covers it.

Impact

  • Public API: Pattern.subtree (JS) returns the literal for a 32-segment path instead of throwing. No signature change.
  • Wire: none.

Alternatives

None; this is a straight mirror of #4284.

Follow-ups

None.

Completes and deletes quest/m1/js-pattern-depth.md.

(Written by Opus 5.5)

🤖 Generated with Claude Code

Mirror #4284 in @moq/pattern: Pattern.subtree no longer appends ** to a
32-segment path, which overflowed the segment limit. Add max-depth and
over-depth subtree cases to the shared vectors so Rust and JS both test it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7776a0a6-b9e5-43ab-8a1a-7225807c8404

📥 Commits

Reviewing files that changed from the base of the PR and between ca47661 and 89dca13.

📒 Files selected for processing (7)
  • js/pattern/src/index.test.ts
  • js/pattern/src/index.ts
  • quest/m1/README.md
  • quest/m1/js-pattern-depth.md
  • rs/moq-pattern/src/pattern.rs
  • rs/moq-pattern/tests/pattern.json
  • rs/moq-pattern/tests/pattern.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T17:31:01.745151Z 89dca13 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated

Copy link
Copy Markdown
Collaborator Author

MERGE

Positive improvement: @moq/pattern Pattern.subtree still appended ** on a 32-segment path and threw too-many-segments, while Rust #4284 already returns the literal because nothing can sit under MAX_SEGMENTS. That JS/Rust drift is real and silent until a max-depth subscriber path hits JS.

Worth the complexity: yes — tiny, local change. Append ** only when segments.length < MAX_PATTERN_SEGMENTS, same guard as Rust. No signature or wire change.

Different approach: none better. Mirroring #4284 is the right fix; special-casing callers would leave the API wrong. Shared vectors plus harness support for subtree error cases are the right regression lock (32-segment → literal, 33-segment → too-many-segments). Stale $comment path update is fine cleanup.

Checks were still pending at review time; merge once CI is green.

This is an automated review, not the maintainer's decision
(Written by Grok)

Delete the quest and its m1 entry. Drop the Rust unit-test copy of the
max-depth subtree case now that the shared vector covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary

  • No changes pushed. Head 89dca13 is mergeable with no conflicts, CI is green, and Codex gave a thumbs up on this head with no findings.
  • No open review threads. CodeRabbit was rate-limited (optional). The bot MERGE comment is an AI review, not approval; the maintainer approved this merge separately.
  • Checked the diff: Pattern.subtree appends ** only below MAX_SEGMENTS, matching Rust. The shared vectors hold exactly 32 segments (literal) and 33 (too-many-segments), and both harnesses check subtree errors.
  • Enabling squash auto-merge pinned to 89dca1366b8e3c3f7fc7f3d5fd5e137a8727577d.

(Written by Opus 5.5)

@kixelated
kixelated merged commit 1a7a8ae into main Sep 28, 2026
5 checks passed
@kixelated
kixelated deleted the fix/js-pattern-subtree-max-depth branch September 28, 2026 18:28
This was referenced Sep 28, 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