Skip to content

Initial commit of Bedrock Wire Protocol (BWP) Specification Doc - #2754

Draft
fukawi2 wants to merge 4 commits into
mainfrom
phs/addProtocolSpec
Draft

fukawi2 wants to merge 4 commits into
mainfrom
phs/addProtocolSpec

Conversation

@fukawi2

@fukawi2 fukawi2 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Initial documentation of the Bedrock Wire Protocol specification.

@fukawi2
fukawi2 requested a review from nathanmetcalf August 31, 2026 01:31
@fukawi2 fukawi2 self-assigned this Aug 31, 2026
@nathanmetcalf

Copy link
Copy Markdown
Contributor

I've read this document and can understand it, but I do not attest to its accuracy. Please get a further review before merging.

nathanmetcalf
nathanmetcalf previously approved these changes Sep 23, 2026
@fukawi2

fukawi2 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@tylerkaraszewski Could I get your eyes/thoughts on this please? 🙏

Comment thread docs/protocol.md Outdated

This document describes the protocol as deployed. Section 15 lists behaviour
that appears to be defective; that behaviour is documented but is not normative,
and implementations should not rely on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Weird statement, as if we're writing a spec for a standard that multiple implementers will build.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair. Reworded to drop the multiple-implementers framing:

"Section 15 lists behaviour that appears to be defective. That behaviour is recorded so it is not mistaken for design, and is subject to change without notice."

Comment thread docs/protocol.md Outdated
2. **A blank line ends the fields.** Everything after it is the body.
3. **`Content-Length` gives the body length in octets.** Send it, and make it
exact, on any connection you will reuse. See section 4.4; this is the rule
most often got wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

List examples where this was often gotten wrong, please.

If I were making this an actual spec, I would just make Content-Length mandatory, even though we accept requests that lack it (which is useful for handwritten commands and such)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Took your suggestion instead: Content-Length is now mandatory in section 4.4. A sender MUST send it and it MUST be exact; a receiver MUST accept its absence so hand-written commands still work. That deleted the section I'd built to explain the ambiguity.

Comment thread docs/protocol.md Outdated
6. **Connections are persistent.** Send `Connection: close` when finished, or
the server waits for another request.

Two things that surprise newcomers:

@tylerkaraszewski tylerkaraszewski Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Who was surprised? Come on, did you actually read this? I question the value of using AI to generate a document that nobody will read and will quickly become out-of-date over just asking AI to freshly answer a specific question about the code based on the current state of the code when the question is asked.

And if we want this for some sort of compliance reason get the AI to write it as an RFC type document without the editorializing.

I am stopping with the review for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed, along with seven more instances you hadn't reached: "commonly misunderstood", "In practice", "the notable exception", "the subtle one", and others. The doc no longer asserts anything about readers.

On staleness: added test/tests/ProtocolDocTest.cpp. It feeds all 16 example messages through SParseHTTP and fails the build if any stops matching. Verified it catches a Content-Length off by one in either direction.

That covers the examples, not the prose. If it's not enough, the alternatives are cutting this to sections 3-8 (wire format only) or closing it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Data from this PR:

  • Five of seven example Content-Length values were wrong. 68 vs 55, 24 vs 19, 62 vs 52, 178 vs 218, and one off by a single octet, 34 vs 33. The two correct ones had been copied from docs/index.md.
  • More than a dozen of the 182 file:line citations pointed at the wrong line. Now replaced with function names.
  • Two sections contradicted each other. 6.6 said a sender's Content-Length is discarded; 7.1 said a sender MUST send it. Both true of different messages, nonsense together.

All caught in review. That's the difference: this got two reviewers and a test. An on-demand answer gets neither, and a wrong byte count reads exactly like a right one.

It also found two real defects, both in section 15: Content-Length is converted with no validation and the failure escapes the peer error handler, and chunked parsing hardcodes a two-octet terminator so a bare LF loses a byte.

The test only checks the examples. It does not stop the rest of the doc going stale.

The document asserted things it had no basis for: which rule is 'most often
got wrong', what 'surprises newcomers', and which case is 'the subtle one'.
State the protocol and let the reader judge.
A sender MUST now send Content-Length on every message, and it MUST be exact.
A receiver still MUST accept its absence, so a command can be typed by hand.
This replaces the section that documented the ambiguity instead of resolving
it.
Parses all 16 example messages in docs/protocol.md with SParseHTTP, so an
example that stops matching the protocol fails the build.

Markdown cannot represent a trailing newline or a CRLF inside a fence, so each
example fence carries an info string saying how to rebuild its body: bwp,
bwp-lf, or bwp-crlf.

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.

3 participants