Skip to content

feat(net)!: rename Instance to Identity and cap it at 256 UTF-8 bytes on lite-07 - #9720

Merged
kixelated merged 7 commits into
mainfrom
quest/m2/identity-rename-and-cap
Nov 27, 2026
Merged

kixelated merged 7 commits into
mainfrom
quest/m2/identity-rename-and-cap

Conversation

@kixelated

@kixelated kixelated commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Claims quest/m2/identity-rename-and-cap.md and finishes it (the quest file is deleted here).

Problem

Publishers want to name a stream by a public key, so Instance reads wrong and the lite-07 wire put no ceiling on its length, letting a peer make a relay hold arbitrarily large claim names. moq-hls also keyed its @{instance} URLs, its Server map, and include lookups on the identity text alone, so a minted identity and a named identity with the same text shared URLs, and a long identity made every URL long.

Approach

  • Mechanical rename of Instance to Identity (types, fields, methods, errors, files, CLI flags and output, docs, drafts) across Rust, JS, moq-ffi, libmoq, and the Go, Python, Dart, Swift, Kotlin, C, and C++ wrappers. Unrelated uses of "instance" (Vulkan/wgpu, class instances, mDNS service instances, RTMP/IETF parameter instances, test fakes) are left alone. The e2ee draft keeps "publisher instance" prose and renames only its references to the moq-lite field.
  • 256-byte UTF-8 ceiling: Identity::from_str / TryFrom<String> and JS Identity.parse refuse empty or over-256-byte text. The lite-07 codecs (Rust and JS) refuse non-UTF-8 or over-256-byte identities in every message that carries one. That surfaces as PROTOCOL_VIOLATION: Rust's DecodeError path, and an explicit ProtocolViolation in JS. Empty with Minted = 0 stays legal in request messages; empty in ANNOUNCE_START or with Minted = 1 is still refused. hang-04 catalog parsing (Rust FromStr, JS IdentitySchema) applies the same ceiling, with a new parity fixture case.
  • moq-hls: a new token(&Identity) is the first 64 bits of SHA-256 over the Minted flag and the text, hex-encoded. It is now the @{token} URL segment, Broadcaster's key (Broadcaster::token()), Server's by_id key, and the include lookup key. moq export archive keys recordings <path>/@<token> with the same function, for the same two reasons: a 256-byte identity percent-encoded could pass a filesystem's 255-byte name limit, and a minted identity must not share a recording with a named one of its text.
  • JS WireRoute.normalize runs a string identity through Identity.parse, so a plain JavaScript caller bypassing the brand gets a RangeError from route()/claim() instead of a peer's PROTOCOL_VIOLATION.
  • In JS, the existing object-identity identity keys in @moq/net internals are renamed to ref so they don't collide with the new term. In the watch decoders, the playback-identity locals become playback and the broadcast-handle field becomes #stream.
  • The moq-ffi route/claim getter is identity() instead of instance_id(). The old name only dodged the C++ generator's private instance field. The Kotlin rename and the Dart extension shims go away.

Impact

Breaking API. Instance was never released, so migrating is a rename. Per AGENTS.md and just check, the release cut writes these notes into MIGRATE.md, so this PR leaves MIGRATE.md alone even though the quest asked for it, following the newer repository rule.

  • Rust moq_net::Instance / InvalidInstance → Identity / InvalidIdentity (now also refused above 256 UTF-8 bytes). RouteOptions::with_instance → with_identity, Route::instance() → identity(), broadcast::Info::instance → identity, and likewise in hang, moq-mux, moq-cli, moq-relay, and moq-e2ee (Epoch::instance → Epoch::identity). Migrate: rename.
  • JS @moq/net Instance namespace → Identity, { instance } options and fields → { identity }. @moq/hang InstanceSchema / ReferenceInstance → IdentitySchema / ReferenceIdentity. @moq/e2ee Epoch.instance → Epoch.identity. Migrate: rename.
  • hang-04 catalog JSON key "instance" → "identity" (unreleased hang-04). Over-256-byte values refuse the catalog.
  • moq-ffi: MoqInstance → MoqIdentity, MoqError::InvalidInstance → InvalidIdentity, MoqRoute::instance_id() / MoqClaim::instance_id() → identity(). libmoq: moq_instance_* → moq_identity_*, moq_route_instance → moq_route_identity, option fields instance/instance_len → identity/identity_len. The Go, Python, Dart, Swift, Kotlin, C, and C++ wrappers follow the same renames.
  • moq-cli: --instance → --identity, and log/output fields renamed.
  • moq-hls: URLs are @{token} (16 hex chars) instead of @{identity text}. New moq_hls::export::token(&Identity). Public fields export::Include::identity and export::Resource::{Media, Init, Segment}::identity → token. Migrate: rename the field. It now holds the token, so compare it with token(&identity).
  • moq-cli export archive (unreleased) records under <broadcast>/@<token> instead of <broadcast>/@<identity>, logging the identity beside each key. libmoq's moq_identity_parse now reports why it refused an identity.
  • Wire (moq-lite-07-wip only, unpublished): field renamed in the draft. Identity is capped at 256 UTF-8 bytes in ANNOUNCE_START, SUBSCRIBE, TRACK, TRACKS, and DATAGRAMS, and an over-long one is a PROTOCOL_VIOLATION. No byte layout change. Published versions are unaffected.

Choices made

  • Kept the existing "track identity" (decoder identity) terms (same_identity, moq_mux::Error::IdentityChanged, the hang draft's Track Identity section) beside the new stream Identity. They are qualified and live in a different layer, so renaming them would be churn without a clear win.
  • Archive keys reuse moq_hls::export::token (moq-cli already depends on moq-hls) rather than a new moq_net::Identity method, which would pull a SHA-256 dependency into moq-net. The upside is that a recording's key matches its HLS URL token.
  • The token is 64 bits, matching init.{hash}.mp4. It only has to tell apart the identities one path ever serves.

Alternatives

Per the quest's recorded decisions: a 1024-byte cap, keeping raw identity text in moq-hls URLs, no wire cap, and keeping Instance were all rejected by the maintainer on 2026-11-26.

Validation

All checks ran on head 35b79187f7 (after merging main):

  • just check passed. It covers Rust tests (nextest), JS checks and tests, Kotlin, Swift, Go, Dart, Python, drafts, markdown, and migrate.
  • just test interop --all passed, covering Rust, the JS clients, and the FFI bindings across moq-lite-05/06/07-wip and moq-transport.
  • cargo clippy --workspace --all-targets --all-features is clean.
  • The new tests pass:
    • moq-net: identity::tests::caps_at_256_utf8_bytes and lite::identity::test::caps_the_identity_at_256_bytes.
    • JS: "an identity holds at most 256 UTF-8 bytes".
    • hang: the shared catalog parity fixture, with a new over-256-byte case that both Rust and JS refuse.
    • moq-hls: restart::a_named_identity_never_shares_urls_with_a_minted_one_of_its_text.
  • Mutation check: dropping the Minted byte from token() makes the moq-hls collision test fail, so the test does pin the minted/named split.
  • moq-hls route tests pin the token format: @82dbe9b7c7e4dd2d is the first 64 bits of SHA-256 over 0x00 || "01920000-0000-7000-8000-000000000000".
  • After the review fixes, on head e7ce7f3039: just check and workspace clippy passed again.
    • moq-cli archive::tests::an_identity_keys_one_segment now covers a 256-byte identity keying a 17-byte segment.
    • JS "routes and claims refuse an unchecked identity a peer would refuse" covers a raw empty or 257-byte string.
    • Interop was not rerun, since the fixes after it touched no wire or FFI behavior.
  • After merging main at 54c862e955 (which brought moq-dev/moq#9695 and moq-dev/moq#9700), on head a8bb04c313:
    • Conflicts in moq-hls route tests, rendition.rs, and moq-cli hls/record.rs were resolved to main's code with this PR's names: the route tests use the @{AT} token with main's new segment hash, and the two comments main added that said "instance" (in moq-hls and moq-gst) now say "identity". Main brought no other old-name uses.
    • just check passed.
    • just test interop --all passed on its second run (see Follow-ups for the first run's flake).

Follow-ups

  • Interop flaked once on head a8bb04c313: the python and go publishers' audio showed timestamp gaps (python -> cpp/c/gst, go -> js-native-node/bun), then the rerun passed. The branch touches no audio or publish timing, so it looks like a pre-existing load-dependent flake in the FFI publishers.
  • The unreleased MIGRATE.md sections on main still name Instance, with_instance, moq_instance_*, and instance_id(). The release cut needs to write them with this PR's names.
  • Under a loaded host, moq-tokio migrate::a_replacement_does_not_check_what_its_predecessor_learned failed once in just check with a skipped group: [.., 15, 17, ..]. It passed 30/30 under --stress-count, and this branch changes only comments in that file. It looks like a pre-existing load-dependent flake.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown
Implementer: Claude Code, claude-opus-5-5, unknown

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: a8bb04c

  • Base: origin/main at fc55051

  • Risk: high, A published API rename: the public Rust, JS, C, Go, Python, Swift, Kotlin, and Dart surfaces are rewritten from "instance" to "identity" (for example rs/moq-net/src/instance.rs becomes identity.rs, js/net/src/instance.ts is removed, and rs/moq-ffi/src/instance.rs becomes identity.rs), and the CLI docs and integration tests change with it. Consumers and bindings built against the old names break on the next cut, and undoing it means reverting a 420-file rename across every binding, so it is hard to undo once published.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 12400e76-02ad-4da7-8479-1a27b8af3ffe

  • Risk file: bb7b1c0de60b

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

  • Session: 01a21a85-d012-7663-86d3-ae129358994e, round 4

  • Score: 10/10, The JavaScript identity validation remains in place, and the merge introduced no new findings attributable to the branch.

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

  • Findings: none

  • Reviewer: Claude Code, claude-opus-5-5, high effort, second

  • Session: f36f6d9d-70fc-431a-a5c5-ab19f824041c, round 4

  • Score: 10/10, Since the last round the branch only merged origin/main: the HLS grid and playlist, QUIC, moq-gst and quest changes come from base commits, the merged hunks in files this branch also touches keep its identity naming, and no findings remain open.

  • Rounds: 4; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 4 commits November 26, 2026 11:34
… (WIP checkpoint)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TE.md to the release cut

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

# Conflicts:
#	js/net/src/ietf/subscriber.ts
#	js/net/src/lite/routed.ts
#	js/net/src/lite/subscriber.ts
@kixelated kixelated changed the title Rename Instance to Identity and cap it at 256 UTF-8 bytes on lite-07 feat(net)!: rename Instance to Identity and cap it at 256 UTF-8 bytes on lite-07 Nov 27, 2026
kixelated and others added 2 commits November 26, 2026 17:37
…oken, report the identity cap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es or claims with one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 27, 2026 01:56
…ame-and-cap

# Conflicts:
#	rs/moq-cli/src/hls/record.rs
#	rs/moq-hls/src/export/rendition.rs
#	rs/moq-hls/src/server/routes.rs
@kixelated
kixelated added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit d1f4f7a Nov 27, 2026
7 checks passed
@kixelated
kixelated deleted the quest/m2/identity-rename-and-cap branch November 27, 2026 03:27
kixelated added a commit that referenced this pull request Nov 27, 2026
#9720 finished the Identity rename: cite it in ffi-exporter and drop
e2ee-format's now-met Required. #9736's multipath quests link
quic-path-return at its new m1 path and drop the link to the deleted
quinn differential spike.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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