Skip to content

Add elasticgraph-proto gem with stable proto field-number mappings - #1056

Closed
jwils wants to merge 5 commits into
mainfrom
codex/proto-generator-field-mappings
Closed

Add elasticgraph-proto gem with stable proto field-number mappings#1056
jwils wants to merge 5 commits into
mainfrom
codex/proto-generator-field-mappings

Conversation

@jwils

@jwils jwils commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a new elasticgraph-proto gem that generates schema.proto artifacts from the Ruby schema DSL
  • support optional replacement of JSON schema artifacts with proto artifacts
  • add stable proto field-number mapping support via proto_field_numbers.yaml, with enforcement mode for missing mapping files
  • support sourcing enum values from app-provided proto enum mappings and scalar fallback inference from json_schema type
  • include RBS signatures and comprehensive unit/integration specs for proto generation and artifact behavior

Validation

  • script/lint elasticgraph-proto
  • COVERAGE=1 script/run_gem_specs elasticgraph-proto (100% line + branch coverage)
  • script/type_check

@jwils
jwils force-pushed the codex/proto-generator-field-mappings branch from ddd2610 to b8d156f Compare February 27, 2026 21:28
@jwils jwils closed this Feb 28, 2026
jwils added a commit that referenced this pull request Jul 20, 2026
## Why
- continue the pluggable ingestion serializer proposal after pulling
JSON Schema into its own gem
- revive the earlier protobuf prototype from #1056 on top of the new
serializer extension points

## What
- fill in the `elasticgraph-proto_ingestion` extension gem with core
generation: `schema_artifacts:dump` emits a `proto3` `schema.proto`
covering the schema's indexed types
- map built-in ElasticGraph scalars to proto types, with `t.protobuf
type:` for custom scalars (resolved via
`type_ref.with_reverted_override` so built-ins renamed with
`type_name_overrides` keep working)
- generate messages for object/interface/union types and enums (with a
zero-valued `*_UNSPECIFIED` entry), escaping proto reserved words and
wrapping lists of lists so the output stays valid
- keep `schema.proto` on public GraphQL field names; validate proto
package names
- hold extension state on a `ProtoIngestionState` container behind a
single `proto_ingestion_state` reader (matching #1281)

Field and enum value numbers are assigned sequentially in definition
order in this PR; the stacked follow-up adds the
`proto_field_numbers.yaml` sidecar that keeps them wire-stable across
schema evolution.

## Stacked follow-ups
1. this PR — core `schema.proto` generation
2. wire-stable field/enum value numbers via a `proto_field_numbers.yaml`
sidecar
3. `syntax: :proto2` support and custom file-level `headers:`
4. #1286 — enum value sourcing from existing proto enums + external
proto type references

## Verification
- `script/run_gem_specs elasticgraph-proto_ingestion` (100% line +
branch coverage at this commit)
- `script/type_check`, `script/lint`, `script/spellcheck`
- `script/quick_build` green at the stack head (whose tree is identical
to the previously reviewed single-PR revision)

## References
- #1059
- #1056
- #1079

## Update — 2026-07-10
- The current stack is #1080#1304#1306#1305#1286.
- Proto extension state now uses a mutable Struct, and keyword
package-name segments are validated without being rewritten.
- Lists of lists now raise an actionable schema error instead of
generating wrapper messages; this supersedes the earlier wrapping note
above.
---

## Update — 2026-07-15
- Interface and union messages now wrap concrete subtype messages in a
`oneof`, matching the JSON Schema `oneOf` representation.
- Concrete subtype messages omit the redundant `__typename`
discriminator.
- Proto type rendering is now stateless: the generator selects the
reachable type graph up front, then each extended type renders itself
without mutating shared traversal state.
- No-block extension coverage now completes the definitions so the
fixture remains valid under CI GraphQL-schema validation.

---

## Update — 2026-07-19
- Replaced keyword suffixing with fully qualified local message and enum
references, preserving source type and field names while disambiguating
contextual protobuf words and built-in scalar names.
- Removed the now-unnecessary keyword collision tracking and verified a
generated schema containing contextual names with `protoc` 35.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant