Skip to content

Conversation

@kixelated
Copy link
Collaborator

@kixelated kixelated commented Nov 8, 2025

Summary by CodeRabbit

  • Refactor
    • Moved the publish-completion message handling into its dedicated module and updated references accordingly.
  • New Features
    • Publish completion message now includes an explicit stream count field and full encode/decode support.
  • Tests
    • Updated tests to construct and decode the publish-completion message directly from its new location.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 8, 2025

Walkthrough

PublishDone was moved in TypeScript from subscribe.ts to publish.ts; imports were updated in connection.ts, control.ts, publisher.ts, subscriber.ts, and ietf.test.ts. subscribe.ts no longer defines or aliases PublishDone/SubscribeDone. A new PublishDone class was added in publish.ts. In Rust, PublishDone<'a> gained a public stream_count: u64 field, and two emitted PublishDone messages in publisher.rs now include stream_count set to 0.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the changeset: fixing PUBLISH_DONE encoding by moving the class to the correct module and adding the stream_count field to the encoding logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch publish-done

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa75540 and 7922af4.

📒 Files selected for processing (1)
  • js/moq/src/ietf/publisher.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • js/moq/src/ietf/publisher.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Check

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95421aa and aa75540.

📒 Files selected for processing (9)
  • js/moq/src/ietf/connection.ts (2 hunks)
  • js/moq/src/ietf/control.ts (2 hunks)
  • js/moq/src/ietf/ietf.test.ts (2 hunks)
  • js/moq/src/ietf/publish.ts (1 hunks)
  • js/moq/src/ietf/publisher.ts (1 hunks)
  • js/moq/src/ietf/subscribe.ts (0 hunks)
  • js/moq/src/ietf/subscriber.ts (1 hunks)
  • rs/moq/src/ietf/publish.rs (2 hunks)
  • rs/moq/src/ietf/publisher.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • js/moq/src/ietf/subscribe.ts
🧰 Additional context used
📓 Path-based instructions (1)
rs/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Write Rust tests integrated within source files (unit tests alongside code).

Files:

  • rs/moq/src/ietf/publisher.rs
  • rs/moq/src/ietf/publish.rs
🧬 Code graph analysis (3)
rs/moq/src/ietf/publish.rs (1)
js/moq/src/ietf/publish.ts (6)
  • w (42-58)
  • w (124-128)
  • w (160-165)
  • r (68-88)
  • r (138-143)
  • r (175-182)
js/moq/src/ietf/publish.ts (3)
js/moq/src/ietf/publisher.ts (2)
  • requestId (114-131)
  • requestId (140-174)
js/moq/src/stream.ts (2)
  • Writer (217-303)
  • Reader (53-214)
js/moq/src/ietf/control.ts (1)
  • Message (63-63)
js/moq/src/ietf/ietf.test.ts (2)
js/moq/src/ietf/connection.ts (2)
  • msg (134-207)
  • msg (213-218)
js/moq/src/ietf/publish.ts (1)
  • PublishDone (147-183)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Check
🔇 Additional comments (9)
rs/moq/src/ietf/publisher.rs (1)

112-129: Looks good—stream_count wired up
Setting stream_count on both success and error paths keeps the wire format in sync with the updated struct. Thanks for adding the TODO for the real count.

js/moq/src/ietf/ietf.test.ts (1)

6-118: Tests updated correctly
Importing PublishDone from its new home and exercising encode/decode directly keeps coverage intact.

js/moq/src/ietf/subscriber.ts (1)

10-12: Import shuffle makes sense
Switching to type-only imports from publish.ts matches the symbol relocation without altering runtime behavior.

js/moq/src/ietf/control.ts (1)

5-39: Control registry stays consistent
Pulling PublishDone from publish.ts keeps the message map aligned with the new class location.

rs/moq/src/ietf/publish.rs (3)

120-125: LGTM! Proper field addition to PublishDone.

The new stream_count field is correctly added to the struct with appropriate type (u64) and visibility (pub), consistent with the other fields. The placement between status_code and reason_phrase aligns with the protocol encoding order.


130-135: LGTM! Encoding implementation is correct.

The stream_count field is properly encoded in the correct position within the message sequence. The encoding order (request_id → status_code → stream_count → reason_phrase) matches the protocol specification and struct layout.


137-149: LGTM! Decoding implementation is correct.

The stream_count field is properly decoded in the correct sequence, and the decoded value is correctly assigned to the struct field. The decoding order matches the encoding order, ensuring protocol compatibility.

js/moq/src/ietf/publisher.ts (1)

16-17: LGTM! Clean import reorganization.

The PublishDone import has been correctly moved from subscribe.ts to publish.ts, which improves module cohesion by grouping publish-related types together. The refactoring is clean with no functional changes.

js/moq/src/ietf/connection.ts (1)

11-11: LGTM! Consistent import reorganization.

The PublishDone import has been correctly relocated from subscribe.ts to publish.ts, matching the module reorganization pattern applied across the codebase. This change improves module cohesion with no functional impact.

Also applies to: 22-22

Comment on lines +150 to +182
requestId: bigint;
statusCode: number;
reasonPhrase: string;

constructor(requestId: bigint, statusCode: number, reasonPhrase: string) {
this.requestId = requestId;
this.statusCode = statusCode;
this.reasonPhrase = reasonPhrase;
}

async #encode(w: Writer): Promise<void> {
await w.u62(this.requestId);
await w.u62(BigInt(this.statusCode));
await w.u62(BigInt(0)); // stream_count = 0 (unsupported)
await w.string(this.reasonPhrase);
}

async encode(w: Writer): Promise<void> {
return Message.encode(w, this.#encode.bind(this));
}

static async decode(r: Reader): Promise<PublishDone> {
return Message.decode(r, PublishDone.#decode);
}

static async #decode(r: Reader): Promise<PublishDone> {
const requestId = await r.u62();
const statusCode = Number(await r.u62());
await r.u62(); // ignore stream_count
const reasonPhrase = await r.string();

return new PublishDone(requestId, statusCode, reasonPhrase);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve the stream_count field instead of hard‑coding zero
Right now we always transmit stream_count = 0 and drop whatever value the peer sent. That makes PublishDone messages non‑round‑trippable and prevents us from honoring draft‑14’s stream budgeting semantics (the Rust side already exposes the field). Please surface stream_count on the class, keep it when decoding, and use that value when encoding so we don’t lose the information.

 	requestId: bigint;
 	statusCode: number;
+	streamCount: bigint;
 	reasonPhrase: string;
 
-	constructor(requestId: bigint, statusCode: number, reasonPhrase: string) {
+	constructor(requestId: bigint, statusCode: number, reasonPhrase: string, streamCount: bigint = 0n) {
 		this.requestId = requestId;
 		this.statusCode = statusCode;
+		this.streamCount = streamCount;
 		this.reasonPhrase = reasonPhrase;
 	}
 
 	async #encode(w: Writer): Promise<void> {
 		await w.u62(this.requestId);
 		await w.u62(BigInt(this.statusCode));
-		await w.u62(BigInt(0)); // stream_count = 0 (unsupported)
+		await w.u62(this.streamCount);
 		await w.string(this.reasonPhrase);
 	}
@@
 	static async #decode(r: Reader): Promise<PublishDone> {
 		const requestId = await r.u62();
 		const statusCode = Number(await r.u62());
-		await r.u62(); // ignore stream_count
+		const streamCount = await r.u62();
 		const reasonPhrase = await r.string();
 
-		return new PublishDone(requestId, statusCode, reasonPhrase);
+		return new PublishDone(requestId, statusCode, reasonPhrase, streamCount);
 	}
🤖 Prompt for AI Agents
In js/moq/src/ietf/publish.ts around lines 150–182, the PublishDone class
currently hard‑codes stream_count = 0 and drops the peer value; add a
streamCount property (type bigint), accept it in the constructor, store it, read
it when decoding (assign the result of r.u62() to streamCount instead of
ignoring), and use that stored streamCount when encoding (write this.streamCount
via w.u62). Ensure constructor signature and the returned new PublishDone(...)
call include streamCount and keep types consistent (bigint) so PublishDone
round‑trips the stream_count field.

@kixelated kixelated enabled auto-merge (squash) November 8, 2025 19:05
@kixelated kixelated merged commit a455fb4 into main Nov 8, 2025
1 check passed
@kixelated kixelated deleted the publish-done branch November 8, 2025 19:07
@moq-bot moq-bot bot mentioned this pull request Nov 8, 2025
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.

2 participants