Skip to content

feat(mapper): add entity-proto mappers#224

Merged
yushan8 merged 1 commit into
mainfrom
yushan/streaming-split
Jul 22, 2026
Merged

feat(mapper): add entity-proto mappers#224
yushan8 merged 1 commit into
mainfrom
yushan/streaming-split

Conversation

@yushan8

@yushan8 yushan8 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds entity-proto mapping functions for the controller and orchestrator layers:

  • internal/mapper/ — proto↔entity converters (GetTargetGraphResponseToProto, ChangedTargetsResponseToProto, ProtoToGetTargetGraphRequest, ProtoToBuildDescription, ToProtoError)
  • mapper/ — top-level ResultToTargetGraph for converting targethasher.Result into ID-mapped entity types (importable by external consumers)

Stack

  1. feat(streaming): add streaming split utilities for gRPC message sizing #226 (streaming utilities)
  2. This PR (entity-proto mappers)
  3. refactor: replace proto serialization with JSON and migrate callsites #222 (storage JSON + entity migration)

Test plan

  • make build && make test && make gazelle

@yushan8
yushan8 force-pushed the yushan/streaming-split branch from 2f87a76 to eacdca8 Compare July 20, 2026 19:31
@yushan8
yushan8 marked this pull request as ready for review July 20, 2026 19:40
@yushan8
yushan8 requested review from a team as code owners July 20, 2026 19:40
@yushan8 yushan8 changed the title feat(streaming): add streaming split utilities for gRPC message sizing feat(streaming): add streaming split response sizes for gRPC message sizing Jul 20, 2026
@yushan8 yushan8 changed the title feat(streaming): add streaming split response sizes for gRPC message sizing feat(streaming): add split methods to split the message by maxBytes size Jul 20, 2026
yushan8 added a commit that referenced this pull request Jul 20, 2026
## Summary
- Adds entity-proto mappers for target graph and changed targets
responses
- `ResultToTargetGraph` — converts `targethasher.Result` into ID-mapped
entity types
- `GetTargetGraphResponseToProto` / `ChangedTargetsResponseToProto` —
entity→proto conversions for gRPC streaming
- `ProtoToGetTargetGraphRequest` — proto→entity request conversion

This PR is addresses this comment to split up the Result -> Optimized
target entity conversion, and OptimizedTarget ->
`GetTargetGraphResponseToProto` #206.
These mappers are used to avoid leaking proto definitions into internals
such as storage and orchestrator.

## Stack
1. #224 (streaming split utilities)
2. **This PR** (entity-proto mappers)
3. #222 (storage JSON rewrite)
4. #212 (callsite migration)

## Test plan
- [x] `make build && make test && make gazelle`

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread mapper/mapper.go
@@ -0,0 +1,97 @@
package mapper

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.

for #222 (comment)
I meant the naming, we have 2 mapper pakage? internal/mapper and mapper

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.

Internally we're importing ResultToTargetGraph so we need the API to be visible. There could be custom orchestrator implementations that's running bazel query -> targethasher -> ResultToTargetGraph -> upload to storage.

@yushan8
yushan8 changed the base branch from main to yushan/streaming-utils July 21, 2026 19:31
@yushan8 yushan8 changed the title feat(streaming): add split methods to split the message by maxBytes size feat(mapper): add entity-proto mappers Jul 21, 2026
@yushan8
yushan8 changed the base branch from yushan/streaming-utils to main July 21, 2026 20:38
@yushan8
yushan8 changed the base branch from main to yushan/streaming-utils July 21, 2026 20:45
@yushan8
yushan8 marked this pull request as draft July 21, 2026 20:56
yushan8 added a commit that referenced this pull request Jul 21, 2026
#226)

## Summary

Adds `internal/streaming` package for splitting gRPC stream messages by
wire size to stay under the per-message size limit. Also adds `Size()`
to `entity.OptimizedTarget` for proto wire size estimation without
importing protobuf.

Target graphs are split into bounded chunks before writing to storage.
When the controller reads back, each `Read()` returns one pre-split
chunk that fits in a single `stream.Send()`. Without splitting, large
monorepos would exceed the gRPC message size limit.

## Stack
1. **This PR** (streaming utilities)
2. #224 (entity-proto mappers, retargeted)
3. #222 (storage JSON + entity migration)

## Test plan
- [x] `make build && make test && make gazelle`

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
yushan8 added a commit that referenced this pull request Jul 21, 2026
## Summary
- Adds entity-proto mappers for target graph and changed targets
responses
- `ResultToTargetGraph` — converts `targethasher.Result` into ID-mapped
entity types
- `GetTargetGraphResponseToProto` / `ChangedTargetsResponseToProto` —
entity→proto conversions for gRPC streaming
- `ProtoToGetTargetGraphRequest` — proto→entity request conversion

This PR is addresses this comment to split up the Result -> Optimized
target entity conversion, and OptimizedTarget ->
`GetTargetGraphResponseToProto` #206.
These mappers are used to avoid leaking proto definitions into internals
such as storage and orchestrator.

## Stack
1. #224 (streaming split utilities)
2. **This PR** (entity-proto mappers)
3. #222 (storage JSON rewrite)
4. #212 (callsite migration)

## Test plan
- [x] `make build && make test && make gazelle`

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 force-pushed the yushan/streaming-split branch from 60f3ec2 to f988cfc Compare July 21, 2026 22:29
@yushan8
yushan8 changed the base branch from yushan/streaming-utils to main July 21, 2026 22:29
@yushan8
yushan8 marked this pull request as ready for review July 21, 2026 22:39
## Summary
- Adds entity-proto mappers for target graph and changed targets
responses
- `ResultToTargetGraph` — converts `targethasher.Result` into ID-mapped
entity types
- `GetTargetGraphResponseToProto` / `ChangedTargetsResponseToProto` —
entity→proto conversions for gRPC streaming
- `ProtoToGetTargetGraphRequest` — proto→entity request conversion

This PR is addresses this comment to split up the Result -> Optimized
target entity conversion, and OptimizedTarget ->
`GetTargetGraphResponseToProto` #206.
These mappers are used to avoid leaking proto definitions into internals
such as storage and orchestrator.

## Stack
1. #224 (streaming split utilities)
2. **This PR** (entity-proto mappers)
3. #222 (storage JSON rewrite)
4. #212 (callsite migration)

## Test plan
- [x] `make build && make test && make gazelle`

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 force-pushed the yushan/streaming-split branch from f988cfc to a1ca3d7 Compare July 21, 2026 22:40
@yushan8
yushan8 merged commit 8559729 into main Jul 22, 2026
20 of 24 checks passed
@yushan8
yushan8 deleted the yushan/streaming-split branch July 22, 2026 00:18
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