Skip to content

refactor!: delete moq-pattern and @moq/pattern, folding prefixes into moq-net - #9800

Open
kixelated wants to merge 26 commits into
mainfrom
quest/m2/delete-moq-pattern
Open

kixelated wants to merge 26 commits into
mainfrom
quest/m2/delete-moq-pattern

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes quest/m2/delete-moq-pattern.md, which this PR deletes.

Summary

Deletes moq-pattern and @moq/pattern. Grants and listings already traveled as prefixes, so wildcards were only a local discovery filter. The prefix algebra moves into moq-net and @moq/net, and every listing now takes a prefix set.

  • moq_net::path::{Prefix, Prefixes, InvalidPrefix} (re-exported at the crate root) and moq_net::path::{parts, Parts, escape, unescape} replace the moq-pattern crate. In JS, Path.Prefix and Path.Prefixes replace @moq/pattern, with a lean @moq/net/prefix subpath for @moq/auth.
  • The origin route table loses its pattern cursor. Consumer::filter and Announce.captures are gone, and Consumer::scope(root, &Prefixes) is the only way to narrow a listing. Interest prefixes come straight from the listed Prefixes.
  • A path still may not hold a *: no prefix can name one, and pre-0.22 subscribers would read it as a wildcard. An origin refuses one wherever it publishes, mounts, or looks up a path, with Error::InvalidPath (now a unit variant) in Rust and an error in JS, which now refuses it on route and claim too. Prefix refuses * likewise, so a pattern written where a prefix belongs fails loudly.
  • moq-auth's temporary grant alias still writes foo/** for older verifiers, through written() in wire.rs.
  • Every caller moved: relay, CLI, stats, gst, tokio, FFI, libmoq, the Python, Go, Kotlin, Swift, Dart, C, and C++ wrappers, JS watch, room, and stats, the demos, CARLA, interop clients, docs, benches, fuzz targets, CI, and quests.

Impact

Breaking API, no wire change.

Wire: none. Announce interest is still a prefix set, and no path holding * is published or watched, as before.

Behavior: when a broader route of another identity takes over a path whose route was lost, listings now report a Restart instead of Offline followed by Start. Capture changes no longer exist, so their unannounce-then-announce is gone.

Migration:

  • Rust
    • moq_pattern::{Prefix, Prefixes, InvalidPrefix} becomes moq_net::{Prefix, Prefixes, InvalidPrefix}; moq_pattern::parts becomes moq_net::path::parts. Pattern, Patterns, Segment, Specificity, IntersectionError, and InvalidPattern are removed. InvalidPrefix has new variants (Wildcard, EmptySegment, InvalidSegment, TooManySegments).
    • consumer.filter(&pattern) becomes consumer.scope(root, &prefixes). For a shape a prefix cannot express (such as */camera), list the enclosing prefix and filter locally.
    • Announce.captures is gone. Derive the value from announce.prefix.
    • Error::InvalidPath no longer carries an InvalidPattern: it is a unit variant for a path holding *.
    • request and follow refuse a path whose rooted form exceeds 32 segments with BoundsExceeded, instead of registering an interest no session can encode.
    • moq_net::stats::Config::with_exclude and with_exclude_rooted take a Prefix, and the exclude and exclude_rooted fields are Prefixes.
    • moq_relay::session::Filter::path: Option<Pattern> becomes prefix: Option<Prefix>.
  • JS
    • announced(Path.Pattern.subtree(p)) becomes announced(p), and routes(...) likewise. captures is gone.
    • @moq/pattern becomes @moq/net (Path.Prefix, Path.Prefixes) or @moq/net/prefix.
    • route and claim now throw on a path holding *, as follow and request already did.
    • Connection.announced and routes throw synchronously on a prefix holding * or more than 32 segments, instead of returning a listing that never fills. A peer's announcement of a path holding * is skipped rather than ending the session's discovery.
  • Relay and CLI
    • The relay /sessions filter takes prefix=. path= is refused with an error naming prefix.
    • moq CLI --path becomes --prefix.
    • A --stats-prefix holding * is refused at config time.
  • Bindings (every language): a prefix with a leading, trailing, or doubled /, or any *, is now an error, so "live/" becomes "live". A listing prefix outside the consumer's scope now fails with Unauthorized instead of listing nothing, since the prefix scopes the listing rather than filtering it.
    • Python: announced(prefix, filter=...) becomes announced(prefix). Announce.captures is gone, and moq.Error.InvalidPrefix replaces InvalidPattern.
    • Go: drop AnnounceOptions.Filter. ErrInvalidPattern becomes ErrInvalidPrefix. Derive what Captures held from Prefix.
    • Kotlin: AnnounceConfig(prefix). No captures, and MoqException.InvalidPrefix replaces the old exception.
    • Swift: announced(prefix:hidden:). No captures, and MoqError.InvalidPrefix replaces the old error.
    • Dart: the filter is removed, and InvalidPrefixMoqException replaces the old exception.
    • C: moq_announce_config loses filter and filter_len, and moq_announce_event loses captures and captures_len. The struct layout changed, so recompile.
    • C++: no filter or captures. Regenerate.

Decisions

The user was away, so I took my recommendation in each case.

  • A path still refuses *, as does Prefix, until grant-alias-delete. A pattern such as room/* typed where a prefix belongs fails loudly, and no broadcast exists that no listing can root at or that a pre-0.22 JS subscriber would read as a wildcard (review round 1). Rejected: making * an ordinary path byte now, which this PR first did; it left such a broadcast publishable but undiscoverable, and broke older subscribers' announce streams. That quest decides whether both refusals lift together.
  • moq-auth and @moq/auth depend on moq-net and @moq/net. This follows the repo's preference for a module in an existing package over a one-off package. The cost is that auth now compiles moq-net. JS keeps the bundle small through the @moq/net/prefix subpath. Rejected: a tiny moq-prefix crate, which is the same package this quest deletes under a new name.
  • Prefixes are parsed strictly in the FFI, libmoq, and listings. "live/" errors rather than normalizing, as the bindings already do for paths (each binding's MIGRATE.md: "a path with a leading, trailing, or doubled / raises instead of collapsing it"). Rejected: normalizing before parsing, which a reviewer suggested; it would make a listing prefix the one binding path that still collapses slashes.
  • The relay refuses path= loudly via Error::Path. An ignored filter would silently widen /sessions output. Rejected: aliasing path= to prefix=, since its semantics (an exact pattern) differ.
  • The grant label is validated as a Prefix.
  • A Restart replaces the capture-change unannounce and announce. With no captures, a takeover by a broader route is the same path under a new identity, which is exactly a Restart.
  • The prefix bench moved to moq-net (benches/prefixes.rs), and the JS algebra and pattern browser benches were dropped. The wildcard mask and chain rows had nothing left to measure. The JS prefix rows are owned by peer-grant-bound.
  • .github/compile-time-audit.json is left as is. It is a historical measurement snapshot, not a build input.
  • The player's coverage watch gets an internal exact listing (review round 3, next decide). Codex kept a finding after two rounds: a prefix listing with covering also lists routes beneath the path and waits on initial sets owed there, which the literal pattern never did, so a player's offline decision could wait on a session scoped beneath the rendition. Picked: fix as recommended, with an @internal exact option on Announce.Options that reports only routes at or above the path and waits only on initial sets there (Rust's lookup cursor already does this internally). Round 4 hit next decide again on two gaps in that option, and the same pick applied: an exact listing is empty when the scope cannot reach the path, and the player also passes covering and keeps its ancestry check, so a Reader that ignores exact stays correct. Round 5 passed with no findings. Rejected: accepting the delay, which is a real regression in offline detection; and dropping the PR.
  • moq-stats keeps an expect when parsing its prefix, documented on Config::prefix, and the relay refuses a * stats prefix at config time. Rejected: making Producer::new fallible for a config no deployment uses.

Overlap

moq-dev/moq#9719 also touches rs/moq-net/src/model/origin.rs, doc/concept/moq-lite.md, and the binding alias files. Expect a mechanical rebase conflict for whichever lands second.

Validation

  • just check origin/main passed: 13966 Rust tests, plus the JS, Python, Go, Kotlin, Dart, CARLA, bench, quest, markdown, shell, and tooling checks.
  • just test interop --all passed, including the C, C++, Python, Go, JS, and GStreamer clients.
  • moq-relay and moq-stats nextest passed after the stats prefix check (570 tests).
  • After review rounds 1 to 3: just check origin/main passed on each fixed head, and nextest over moq-net, moq-cli, moq-relay, moq-ffi, libmoq, moq-tokio, moq-auth, and moq-stats (6938 tests), plus the JS net and watch suites. Interop was not rerun: those fixes change no wire or FFI code.
  • New tests: a_star_is_refused_everywhere_a_path_is_named, a_lookup_past_the_depth_limit_is_refused, and a_broader_route_taking_over_a_lost_one_restarts (origin), the JS twin of the * refusal, announced_lists_a_prefix_and_refuses_a_wildcard (FFI), the relay /sessions path= refusal, and the stats prefix refusal.
  • moq-net prefixes bench, one local run at a whole 64 KiB AUTH_OK: collect 179 µs, covers 1.6 ms, intersect 3.6 ms.
  • Swift was not run: there is no Swift toolchain on this host.
  • After merging main at 5a7973d818: just check origin/main passed except for host-only failures that also hit main (Swift without Xcode, the cross-lint without LLD, and rpm crashing in the tooling check). Workspace nextest passed 13126 of 13129; the three failures also fail on main on this macOS host and go to a follow-up. just test interop --all passed.
  • After review rounds 1 and 2 of the new sessions: just check origin/main failed only where main does on this host (the same three macOS Rust tests, Swift, the cross-lint, and rpm in tooling), plus two JS load flakes in files this PR leaves alone: fit widens only what does not fit hit bun's 5 s timeout, and the lite tail test a group stream that arrives after the subscribe stream's FIN is delivered failed once. Run alone, fit.test.ts and tail.test.ts passed two of three and three of three times. The JS lite, origin, and reload suites passed (1246 tests), as did CARLA's pytest and paths.test.ts.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Implementer: Claude Code, claude-opus-5-5, high effort (iterate, L, arm A)

Follow-ups

  • Three Rust tests that fail every run on macOS pass there: identities::ietf22, same_tick_fetch_protects, and fetch_refresh_survives_eviction fail on main on Apple Silicon while the Linux queue passes. No open decisions.
  • A Restart and an Unannounce coalesced for one lost identity may report End rather than Offline. This predates this PR; it is worth a candidate quest after review confirms it.
  • The JS browser prefix-bench rows are now owned by peer-grant-bound.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 5f453c6

  • Base: origin/main at 065a4c1

  • Risk: high, it changes .github/workflows/release-gate.yml, which is always high: workflows run with the repository's secrets

  • Classified: high by the always-high paths

  • Risk file: bb7b1c0de60b

  • Reviewer: Codex, gpt-6.2-sol, xhigh effort

  • Session: 01a21f8b-c2fc-7c60-8a96-2d56526fd4ae, round 5

  • Score: 10/10, The head fixes both remaining findings, and the incremental review found no new regressions.

  • Rounds: 5; first round 3 (high 1, medium 2); findings 6 (high 1, medium 5): fixed 6, refuted 0, open 0

  • Findings: none

  • The last round's findings, at c0e329d:

    • Fixed: medium, js/net/src/origin.ts:2749: Keep exact listings anchored to the requested path; At js/net/src/origin.ts:2753, exact mode checks the scope against the original requested path and uses an empty listing when that path is outside the scope.
    • Fixed: medium, js/watch/src/broadcast.ts:58: Preserve coverage for public Reader adapters; At js/watch/src/broadcast.ts:59, the player passes `covering: true` and filters descendant events at line 67, preserving coverage for Reader adapters that ignore `exact`.
  • Reviewer: Claude Code, claude-opus-5-5, high effort, second

  • Session: 59b4502c-7c57-44d0-b863-d4623b1b79e6, round 5

  • Score: 9/10, Since the last round, an `exact` listing on a reader whose scope reaches only beneath the path lists and waits on nothing, using the existing `Scope.covers` that also decides whether a request is allowed. `watchCovered` also keeps `covering` plus a `hasPrefix` filter, so it stays correct with a `Reader` that ignores the internal `exact` option. A test covers the change, and nothing here introduces a bug.

  • Rounds: 5; first round 2 (high 1, medium 1); findings 2 (high 1, medium 1): fixed 1, refuted 1, open 0

  • Findings: none

kixelated and others added 14 commits November 27, 2026 14:09
…ard filters (Rust)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Prefix, Prefixes, InvalidPrefix, and the segment helpers (parts, escape,
unescape) move into @moq/net, at Path.* as before and at a new
`@moq/net/prefix` entrypoint that loads no wire stack. @moq/auth depends
on @moq/net and imports from that entrypoint.

Discovery filters are prefixes now: announced/routes take an optional
`prefix: Path.Valid` (relative to the handle's root) instead of a
Path.Pattern, and announcements carry no `captures`. Callers that wanted
a subset filter the announced paths themselves. A request or follow no
longer refuses a path holding `*`, an ordinary byte now.

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

Each wrapper's announced() lists a prefix and everything beneath it; the
pattern filter and Announce.captures are gone, and the InvalidPattern error
is now InvalidPrefix. The CARLA sim derives a driver id from the direct
child path beneath its prefix instead of a wildcard capture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Delete moq-pattern and @moq/pattern refactor!: delete moq-pattern and @moq/pattern, folding prefixes into moq-net Nov 28, 2026
kixelated and others added 5 commits November 27, 2026 17:07
…epth

A prefix still refuses *, so a broadcast holding one could be published
but never listed, scoped, or watched, and pre-0.22 subscribers read it as
a wildcard. Refuse it again wherever an origin publishes, mounts, or looks
up a path, in Rust and JS, and refuse a lookup whose rooted path exceeds
the wire's depth before it registers an interest.

The player's coverage watch skips routes beneath its path instead of
holding and rescanning them on every event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ees it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The player's coverage watch listed its path with covering, which a prefix
listing extends to every route beneath the path and every initial set
owed there. An internal exact listing reports only routes at or above the
path and waits only on initial sets there, as the literal pattern did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reader whose scope reaches only beneath the path can never request it,
so its exact listing names nothing. The player also asks for covering and
keeps its own ancestry check, so a Reader that ignores exact stays correct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 28, 2026 02:40
Luke Curley and others added 3 commits November 27, 2026 23:21
…attern

# Conflicts:
#	quest/m2/README.md
#	quest/m2/delete-moq-pattern.md
#	quest/m2/remove-catalog-identity.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Luke Curley and others added 3 commits November 28, 2026 00:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…starred route, keep escaped slashes

- Connection.routes and the lite subscriber parse the prefix before registering a reader, so a
  starred or overlong prefix throws instead of leaving an empty listing or a stuck reader.
- An origin skips a peer's announced path holding `*` rather than letting receive throw and end
  the session's discovery.
- CARLA's driver and camera parsing split only at unescaped slashes.
- Nightly no longer schedules the deleted pattern fuzz target; two examples drop a trailing slash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…before registering

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

This branch has not been deployed

No deployments
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