Skip to content

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

Merged
kixelated merged 1 commit into
mainfrom
fix/pattern-subtree-max-depth
Sep 26, 2026
Merged

kixelated merged 1 commit into
mainfrom
fix/pattern-subtree-max-depth

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

Pattern::subtree(path) always appended **, so a valid 32-segment path (Pattern::MAX_SEGMENTS, the wire path limit) became 33 segments and failed with TooManySegments. Effects:

  • A moq-lite or IETF peer that subscribes to announcements under a 32-segment prefix gets an empty set, because lite/publisher.rs and ietf/publisher.rs fall back to unwrap_or_default().
  • moq CLI rtc, hls, and on dev ls and fetch, reject a 32-segment broadcast before connecting. Codex flagged the fetch case on feat(cli)!: inspect a relay with moq ls and moq fetch #4032.

Fix

At max depth, subtree returns the literal path, since nothing can sit beneath it. This fixes every caller at once, instead of special-casing moq fetch.

Impact

  • moq-pattern: Pattern::subtree succeeds on a 32-segment path and returns the literal pattern. No signature change.
  • Wire: none.

Testing

literal_and_subtree_normalize_paths now covers a max-depth path (fails before this change) and a 33-segment one. just check passes.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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-26T20:13:01.435180Z 923c1df PR opened
ℹ️ 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: Pattern::subtree at MAX_SEGMENTS used to append **, hit TooManySegments, and leave publishers (unwrap_or_default) and CLI paths (rtc/hls/fetch/ls) broken on a valid 32-segment wire path. Treating max depth as the literal path is the right model—nothing can sit beneath it—and one central change fixes every caller.

Worth the complexity: yes; the diff is tiny and the new tests pin both the success and TooManySegments cases.

Different approach: special-casing moq fetch (or only the CLI) would leave the same hole in lite/ietf announce scoping. Optional follow-up only: prefix_claim in origin.rs already duplicates this literal-at-max-depth rule and can drop the branch once this lands; the Err(TooManySegments) => self.clone() fallback there also becomes unreachable for real paths.

Recommend merge as-is.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 923c1df3ec

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +410 to +411
if segments.len() < Self::MAX_SEGMENTS {
segments.push(Segment::Globstar);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Mirror the max-depth subtree case in TypeScript

When path has exactly 32 segments, Rust now returns a literal pattern, but js/pattern/src/index.ts still appends GLOBSTAR, so its constructor rejects the resulting 33 segments. Browser callers therefore continue to fail for the same valid wire path, and the Rust and TypeScript public APIs disagree. Apply this max-depth behavior to the TypeScript twin and add the case to the shared tests/pattern.json vectors instead of covering it only in the Rust inline test.

Useful? React with 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b46e59f8-37d7-489e-bb09-2019272c5dca

📥 Commits

Reviewing files that changed from the base of the PR and between f42f3ad and 923c1df.

📒 Files selected for processing (1)
  • rs/moq-pattern/src/pattern.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

Pattern::subtree now appends ** only when the normalized path has fewer than MAX_SEGMENTS segments. At the limit, it returns the literal pattern. Paths that exceed the limit still fail validation with TooManySegments. Tests cover both boundary cases.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 923c1

Valid resource paths cannot exceed 32 segments, so the boundary behavior preserves subtree coverage. No identified issue blocks merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 923c1

A maximum-length path can now be used where it was previously rejected. The resulting pattern matches that exact path, while longer paths remain invalid. No broadened access was identified, though runtime authorization coverage is incomplete.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly accepted maximum-depth input can affect legacy put/get prefixes and HLS broadcast-name scoping, but produces an exact match rather than broader descendant matching.

Trust Boundaries and Controls

  • observed — At the limit, the constructor adds no wildcard; over-limit input remains rejected, and the inspected HLS caller applies the resulting pattern when scoping its origin consumer.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: max-depth subtree patterns now return the path itself.
Description check ✅ Passed The description directly explains the max-depth failure, the fix to Pattern::subtree, affected callers, and the tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR

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.

@kixelated
kixelated enabled auto-merge (squash) September 26, 2026 20:26
@kixelated
kixelated merged commit ed7e697 into main Sep 26, 2026
4 checks passed
@kixelated
kixelated deleted the fix/pattern-subtree-max-depth branch September 26, 2026 20:28
@moq-bot moq-bot Bot mentioned this pull request Sep 26, 2026
@moq-bot moq-bot Bot mentioned this pull request Sep 27, 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