Skip to content

Draft API: validate and generate the stable schema - #921

Draft
stephanos wants to merge 20 commits into
api-next-stephanosfrom
api-next-stephanos-followup
Draft

stephanos wants to merge 20 commits into
api-next-stephanosfrom
api-next-stephanos-followup

Conversation

@stephanos

@stephanos stephanos commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Defines the draft annotation contract and projects supported declarations into the stable schema.

Builds on #912. The descriptor oracle follows in #931.

  1. a4c1b660 Moves draft-schema validation cases into fixture files. Each invalid schema can document the requirement and expected diagnostic together.
  2. fa437510 Moves comment-ownership cases into individual fixtures. Each rejected placement now has an isolated input and documented rationale.
  3. 1664ed5a Moves import-rewrite cases into the end-to-end imports fixture. The tests now verify that rewriting works through projection and compilation.
  4. 68592779 Runs projection a second time on generated stable output and checks byte equality. Regeneration should converge after one pass.
  5. ff2c0caa Checks that randomly generated two-file schemas are accepted and that a second projection produces the same output. Combined schemas and comments exercise cases beyond hand-written fixtures.
  6. 0e785ae3 Rejects HTTP and request-header options that reference draft fields. Stable RPC options would otherwise point to fields removed during projection.
  7. 16ef18be Derives the draft option package from the schema descriptor. The generator can then accept a relocated annotation schema.
  8. a900e890 Makes source, stable, and annotation schema paths configurable and validates them. Tests and callers can use isolated layouts with clear path boundaries.
  9. 4a2907b8 Requires an empty output directory and creates files exclusively under a scoped root. Projection must avoid overwriting inputs or existing files.
  10. aee5a016 Specifies all seven draft annotations and their projection and runtime rules. The proto generator, Go generator, and server need one shared contract.
  11. 3b525b8e Validates supported annotations and their placement, containment, and RPC rules. Invalid schemas should fail before producing stable output.
  12. 37a931b5 Requires next schemas to use proto3. Proto2 defaults, groups, and extension ranges have no draft projection rules.
  13. 2f3ed6cd Removes comments that protoc attributes to pruned imports. Deleted imports should leave no orphaned comments in stable output.
  14. 738e12c1 Projects draft enums, enum values, oneofs, RPCs, and services alongside fields and messages. Stable descriptors should exclude every declaration gated by a draft feature.
  15. eeb69223 Rejects retained option literals that refer to removed declarations. Stable schemas need all surviving option references to remain valid.
  16. 096e0316 Generates random valid schemas across all draft placements and adds a missing-annotation case. The property tests can catch omissions in the expanded placement rules.
  17. 8fefb3b6 Generates a draft manifest with the effective feature gate for each declaration alongside the stable proto tree. Downstream generators can use the same inheritance rules as the stable projection.
  18. d91ac8e7 Replaces the demo workflow-update user fields with preview_note on DescribeNamespaceRequest. A singular request field exercises draft filtering without reaching history or multi-operation collections.
  19. af529227 Rejects lists and maps whose retained entries could require draft filtering and records the guarantee in manifest version 2. Binders can clear a draft collection under its own gate and keep retained entries without visiting them.
  20. 48b07668 Explains where to edit draft and stable declarations, when to remove a draft annotation, and how to regenerate both outputs. Contributors need a clear path from editing the source schema to committing the generated stable files.

stephanos and others added 20 commits November 21, 2026 09:41
What
Moves draft schema validation cases into fixture directories with their own inputs and expected diagnostics.

Why
Each validation rule can be read and exercised directly through the common fixture runner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Moves accepted and rejected draft comment placements into standalone fixtures.

Why
Reviewers can see the exact comment placement that produces each expected result.

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

What
Runs import path rewriting cases through the generator’s imports fixture.

Why
The test checks how real imports, comments, and option strings behave through projection and printing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Checks that regenerating a projected tree produces byte-identical output.

Why
A second pass should preserve the stable declarations, comments, and import order from the first pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Uses Rapid to generate small draft schemas and checks that generation is idempotent.

Why
Generated schemas exercise combinations that the handwritten fixtures may miss, and Rapid can shrink failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Rejects HTTP mappings and request-header templates on retained RPCs that refer to draft fields.

Why
Those mappings would otherwise point to fields that disappear from the stable schema.

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

What
Resolves draft option names from the package declared in the draft schema.

Why
The generator can read a relocated draft schema without hard-coding its protobuf package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Adds flags for the source tree, stable tree, and draft schema paths while keeping the existing defaults.

Why
Alternate layouts need configurable paths for both schema discovery and import rewriting.

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

What
Requires an empty or nonexistent output directory and creates generated files exclusively through `os.Root`.

Why
The generator needs to avoid overwriting existing files or writing outside its designated output directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Documents the draft annotations, validation rules, and expected behavior across the API generator, Go bindings, and server.

Why
The three implementations need one shared reference for how draft declarations are gated and removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Validates the supported draft annotations across declarations, including container rules, RPC endpoint constraints, and draft references.

Why
The generator needs to reject schemas it cannot safely project to the stable API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Requires every proto in the draft source tree to declare `proto3` explicitly.

Why
The draft rules can focus on proto3 semantics while still allowing external dependencies with other syntax.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Removes comments owned by pruned imports and preserves source order until import ownership is resolved.

Why
Deleting an unused import should also remove its comments without disturbing the comments on retained imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Projects all supported draft placements out of the stable schema.

Why
Draft enums, oneofs, RPCs, and services need the same stable-output guarantees as draft fields and messages.

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

What
Rejects draft references in option literals on retained declarations, using validation and recompilation of the stable tree.

Why
A retained option needs to reference declarations that still exist after projection.

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

What
Expands the generated schema tests to cover every draft placement and a deliberately missing field annotation.

Why
The tests exercise combinations of draft declarations and verify rejection when a required annotation is missing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Emits a manifest with the effective draft feature gate for each classified declaration.

Why
Downstream generators can reuse the stable generator’s gate decisions and inheritance rules.
What
Moves the draft example from workflow update user fields to `preview_note` on `DescribeNamespaceRequest`.

Why
A singular request field exercises draft filtering without reaching history or multi-operation collections.
…tions

What
Rejects retained lists and maps whose entries could need draft filtering and records the guarantee in manifest version 2.

Why
Go bindings can clear a draft collection under its own gate and keep retained collections without visiting their entries.
What
Explains where to edit draft and stable declarations, when to remove a draft annotation, and how to regenerate both outputs.

Why
Contributors need a clear path from editing the source schema to committing the generated stable files.
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