refactor: replace proto serialization with JSON and migrate callsites#222
Conversation
6fc3266 to
0f5a89c
Compare
1a54757 to
2252f29
Compare
5fb83ae to
7f55e85
Compare
8677311 to
614cddf
Compare
7f55e85 to
e762db8
Compare
dff47a4 to
9c060bc
Compare
7ec0e66 to
2870453
Compare
…210) ## Summary - Add `entity.OptimizedTarget`, `entity.Metadata`, and `entity.GetTargetGraphResponse` as compact, proto-free representations of the target graph wire types - Add `entity.ChangedTarget` and `entity.GetChangedTargetsResponse` for the changed-targets path - These entity types mirror the proto definitions but live in a dependency-free package, preventing proto from leaking into storage, orchestrator, and other non-transport layers ## Test plan - [x] `make build && make test && make gazelle` ## Stack 1. **#210 — this PR** (entity types) 2. #211 (mappers + streaming) 3. #222 (storage JSON rewrite) 4. #212 (callsite migration + cleanup) --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
9c060bc to
63d2138
Compare
140a936 to
1f1b327
Compare
63d2138 to
7b87081
Compare
1f1b327 to
6d0f3a7
Compare
7b87081 to
23bf3ac
Compare
e57a2e1 to
1f8366f
Compare
e762709 to
8f360d1
Compare
1f8366f to
e9517ce
Compare
| totalDuration += elapsed | ||
| fmt.Printf("run %d: targethasher: %v (%d targets)\n", i+1, elapsed.Round(time.Millisecond), len(targethasherResult.TargetNames)) | ||
| start = time.Now() | ||
| response, err := common.ResultToGetTargetGraphResponse( |
There was a problem hiding this comment.
reminder to remove dead code in common, now that a bunch of functions in common are not used
There was a problem hiding this comment.
yes, common is completely removed in this PR.
| @@ -1,4 +1,4 @@ | |||
| // Copyright (c) 2026 Uber Technologies, Inc. | |||
| // Copyright (c) 2025 Uber Technologies, Inc. | |||
| isEmpty: isEmpty, | ||
| return &reader[T]{ | ||
| rc: resp.ReadCloser, | ||
| dec: json.NewDecoder(resp.ReadCloser), |
There was a problem hiding this comment.
could be backwards incompatible here, the old cache is still proto based. Would that be an accepted risk?
There was a problem hiding this comment.
we can bump the storage version, so new instances of the service will write/read from the json entity, not the proto object.
## 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. #226 (streaming utilities) 2. **This PR** (entity-proto mappers) 3. #222 (storage JSON + entity migration) ## Test plan - [x] `make build && make test && make gazelle` Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
- Export DefaultMaxMessageBytes in config package and use it from controller instead of hardcoded value - Update copyright year to 2026 in core/storage/reader.go - Add Size() to entity.ChangedTarget and inline size-based splitting in compareTargetGraphs, eliminating the wasteful proto conversion that was only used for size measurement - Add ProtoToChangedTargetsResponse mapper for cache read boundary Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Update copyright year to 2026 in changedtargetsreader.go - Remove dead code from core/common/utils.go (ResultToGetTargetGraphResponse, ChunkMetadata, chunkTargets, splitMap, and chunk size constants) - Fix defer syntax in compareTargetGraphs - Remove unused common import from orchestrator - Update entity/changed_targets.go to use wire.VarintSize Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4860e6e to
2010498
Compare
| rc: gogio.NewDelimitedReader(resp.ReadCloser, maxMessageSize), | ||
| isEmpty: isEmpty, | ||
| return &reader[T]{ | ||
| rc: resp.ReadCloser, |
There was a problem hiding this comment.
Prior we were calling the messages to a max size. What was the reason to remove it?
There was a problem hiding this comment.
https://pkg.go.dev/github.com/gogo/protobuf/io#NewDelimitedReader protobuf reader requires a MaxSize input. json.NewDecoder doesn't need a max-size parameter.
Since we are already splitting the entities by bytes when writing to the storage, every Read() call will read at most max_message_bytes from the storage.
806404a to
90e1e60
Compare
Remove all proto from core/storage, replacing with encoding/json. Migrate controller and orchestrator to entity types, converting to proto only at the gRPC boundary. Consolidate chunking config into max_message_bytes. Remove old chunking code from core/common. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ation Update toChangeType to return entity.ChangeType, mapper to cast via int32, and test assertions to use entity constants. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Run gazelle to remove stale //config and //core/common deps from controller BUILD.bazel. Replace context.Background() with t.Context() in test helper. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Remove _defaultMaxMessageBytes constant and inline the value with a TODO to provide it via config.Parse. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Export DefaultMaxMessageBytes in config package and use it from controller instead of hardcoded value - Update copyright year to 2026 in core/storage/reader.go - Add Size() to entity.ChangedTarget and inline size-based splitting in compareTargetGraphs, eliminating the wasteful proto conversion that was only used for size measurement - Add ProtoToChangedTargetsResponse mapper for cache read boundary Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Update copyright year to 2026 in changedtargetsreader.go - Remove dead code from core/common/utils.go (ResultToGetTargetGraphResponse, ChunkMetadata, chunkTargets, splitMap, and chunk size constants) - Fix defer syntax in compareTargetGraphs - Remove unused common import from orchestrator - Update entity/changed_targets.go to use wire.VarintSize Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…efactor Restore explanatory comments in linkRequestCtx that were incidentally deleted while migrating to the max_message_bytes config field.
Add streaming.SplitChangedTargets, mirroring SplitTargetGraph, and use it in getchangedtargets instead of an inlined split loop.
…argets Switch OptimizedTarget.Size() and ChangedTarget.Size() to value receivers so []OptimizedTarget and []ChangedTarget satisfy Sizer, then have SplitTargetGraph and SplitChangedTargets call the shared SplitBySize for item-grouping instead of duplicating the same loop.
90e1e60 to
5589819
Compare
5589819 to
02f6a52
Compare
…ites Both target-graph and changed-targets response chunking need the same two independent things: split items by size (SplitBySize) and split metadata by size (SplitMetadata), then wrap each group into the caller's own response type. Rather than a combinator function that blurs those two concerns together, each of the three callers (native orchestrator, query-bench example, controller) composes SplitBySize and SplitMetadata directly and does its own wrapping — so SplitBySize now handles OptimizedTarget and ChangedTarget the same way, and SplitMetadata does only what its name says.
02f6a52 to
fb4b255
Compare
Summary
Intent: Proto definitions are currently leaking into the storage. We should
Putthe actual entities to be encoded/decoded from the storage, not the proto definitions.core/storage/— serialize entity structs directly viaencoding/jsongraphwriter.goentity.GetTargetGraphResponseandentity.GetChangedTargetsResponseinternally, converting to proto via mapper only atstream.Sendmapper.ResultToTargetGraph+SplitBySizeservice.chunking.*into a singlemax_message_bytesconfig fieldcore/commonquery-benchexampleTest plan
grep -r "tangopb\|gogo/protobuf" core/storage/returns zero resultsmake build && make test— all 19 test targets passmake gazelle— BUILD files in syncStack
Ran
integration testsandmake benchto make sure storage is compatible with current changes.