Skip to content

Add protoscope language, assembler, disassembler - #734

Open
sudorandom wants to merge 4 commits into
bufbuild:mainfrom
sudorandom:protoscope
Open

Add protoscope language, assembler, disassembler#734
sudorandom wants to merge 4 commits into
bufbuild:mainfrom
sudorandom:protoscope

Conversation

@sudorandom

@sudorandom sudorandom commented Jun 10, 2026

Copy link
Copy Markdown

Description

Adds the protoscope format to protocompile. It enables writing, parsing, compiling, and de-compiling without requiring a schema. It supports multi-frame documents (separated by ---) and transport framing (gRPC, ConnectRPC, and Varint delimited). The current implementation does NOT have the ability to use a schema for more accurate de-compiling.

Changes

  • Adds a Parser & AST for the protoscope text format (internal/protoscope/parser, internal/protoscope/ast)
  • Adds a Disassembler (internal/protoscope/disassembler)
  • Adds an Assembler (internal/protoscope/assembler)
  • The public API exposes: Assemble, Disassemble, Diagnostics, Hover, and Possibilities for integrations (e.g. Buf LSP)

Adds `protoscope`, a human-readable text format for raw Protobuf binary wire payloads, to `protocompile`. It enables writing, parsing, compiling (assembly), and decompiling (disassembly) without requiring a schema. It supports multi-frame documents (separated by `---`) and transport framing (gRPC, ConnectRPC, and Varint delimited).

- **Parser & AST (`internal/protoscope/parser`, `internal/protoscope/ast`)**: Parses tokens into an AST of fields, blocks (groups/length-delimited), values, and options.
- **Assembler (`internal/protoscope/assembler`)**: Compiles AST nodes into raw Protobuf wire format.
- **Disassembler (`internal/protoscope/disassembler`)**: Decompiles binary Protobuf payloads back to protoscope text format using heuristics.
- **Public API (`protoscope`)**: Exposes public endpoints (`Assemble`, `Disassemble`, `Diagnostics`, `Hover`, and `Possibilities`) for integrations (e.g. Buf LSP). Handles frame splitting/joining, flags parsing, and context-aware hover info.
- `Fuzz tests` and a few related fixes as a result of the fuzz testing. Changes in `experimental/internal/lexer/number.go` is an example of changes made to avoid a DoS vector that was revealed with this testing.
@sudorandom

sudorandom commented Jul 22, 2026

Copy link
Copy Markdown
Author

I updated Assemble() to return *report.Report and made a few more code quality improvements.

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