Repository navigation
feat(storage): read the gateway ownership of a page of Tasks in one call - #1466
Robbie Cronin (robert-cronin) wants to merge 6 commits into
Conversation
Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
🟡 Changes recommended
The cache retains full event payloads across pages, including filtered-out tasks, causing request memory to grow with the entire scan rather than just the current page.
1 open issue
9 files not reviewed
internal/storageclient/storagefault/wrappers_gen.go: Generated filepkg/storage/v1/wire/storagepb/gateway.pb.go: Generated filepkg/storage/v1/wire/storagepb/gateway_grpc.pb.go: Generated filepkg/storage/v1/wire/wiretest/zz_generated.overlay.go: Generated filepkg/storage/v1/wire/zz_generated.codecs_test.go: Generated filepkg/storage/v1/wire/zz_generated.mapping.go: Generated filepkg/storage/v1/wire/zz_generated.provider.go: Generated filepkg/storage/v1/wire/zz_generated.recorder_test.go: Generated filepkg/storage/v1/wire/zz_generated.service.go: Generated file
What changed in this PR
This PR reduces remote-storage round trips for Task gateway ownership checks, advancing the external storage support in #512 while preserving per-Task fallback on batch failures.
Changes:
- Adds a validated batch lookup for up to 500 Task keys, with SQLite support and streamed wire responses.
- Uses request-scoped prefetching for Task listings and attention scans.
- Updates contract revisions, documentation, and API and storage conformance coverage.
| File | Description |
|---|---|
pkg/storage/v1/wire/zz_generated.service.go |
Adds generated batch client and server handling. |
pkg/storage/v1/wire/zz_generated.recorder_test.go |
Records batch calls in wire tests. |
pkg/storage/v1/wire/zz_generated.provider.go |
Raises the gateway family protocol requirement. |
pkg/storage/v1/wire/zz_generated.mapping.go |
Adds Task-key wire conversions. |
pkg/storage/v1/wire/zz_generated.codecs_test.go |
Registers Task-key codec coverage. |
pkg/storage/v1/wire/wiretest/zz_generated.overlay.go |
Routes batch conformance calls over the wire. |
pkg/storage/v1/wire/storagepb/gateway_grpc.pb.go |
Adds generated streaming RPC bindings. |
pkg/storage/v1/wire/protocol.go |
Raises protocol revision to 13. |
pkg/storage/v1/store.go |
Extends the gateway store interface. |
pkg/storage/v1/storagetest/events_gateway.go |
Tests batch ordering, deduplication, and validation. |
pkg/storage/v1/storagetest/conditional.go |
Adds batch-read fence coverage. |
pkg/storage/v1/provider.go |
Raises contract revision to 20. |
pkg/storage/v1/methods.go |
Classifies the batch method as a state read. |
pkg/storage/v1/gateway_types.go |
Defines Task keys, validation, and batch limits. |
pkg/storage/proto/orka/storage/v1/gateway.proto |
Defines batch messages and streaming RPC. |
internal/store/sqlite/gateway_store.go |
Implements deduplicated lookups within one fence check. |
internal/store/public_contract.go |
Exposes internal aliases for batch types and limits. |
internal/storageclient/storagefault/wrappers_gen.go |
Adds batch fault-injection wrapping. |
internal/api/task_access.go |
Uses prefetched events for ownership checks. |
internal/api/handlers.go |
Prefetches ownership for Task listing pages. |
internal/api/gateway_task_events.go |
Implements request caching and single-lookup fallback. |
internal/api/gateway_task_events_test.go |
Tests batching, visibility, and failure fallback. |
internal/api/attention_handlers.go |
Prefetches ownership during attention scans. |
docs/development/storage-contracts.md |
Documents batch semantics and revision requirements. |
Review effort: Balanced
Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
…k-batch Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to batch Task gateway ownership lookups and reduce remote storage round trips.
No open issues 🎉
1 resolved since last review
9 files not reviewed
internal/storageclient/storagefault/wrappers_gen.go: Generated filepkg/storage/v1/wire/storagepb/gateway.pb.go: Generated filepkg/storage/v1/wire/storagepb/gateway_grpc.pb.go: Generated filepkg/storage/v1/wire/wiretest/zz_generated.overlay.go: Generated filepkg/storage/v1/wire/zz_generated.codecs_test.go: Generated filepkg/storage/v1/wire/zz_generated.mapping.go: Generated filepkg/storage/v1/wire/zz_generated.provider.go: Generated filepkg/storage/v1/wire/zz_generated.recorder_test.go: Generated filepkg/storage/v1/wire/zz_generated.service.go: Generated file
Review effort: Balanced
…k-batch Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the batch gateway-ownership lookup changes.
No open issues 🎉
9 files not reviewed
internal/storageclient/storagefault/wrappers_gen.go: Generated filepkg/storage/v1/wire/storagepb/gateway.pb.go: Generated filepkg/storage/v1/wire/storagepb/gateway_grpc.pb.go: Generated filepkg/storage/v1/wire/wiretest/zz_generated.overlay.go: Generated filepkg/storage/v1/wire/zz_generated.codecs_test.go: Generated filepkg/storage/v1/wire/zz_generated.mapping.go: Generated filepkg/storage/v1/wire/zz_generated.provider.go: Generated filepkg/storage/v1/wire/zz_generated.recorder_test.go: Generated filepkg/storage/v1/wire/zz_generated.service.go: Generated file
Review effort: Balanced
…k-batch Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
Ownership prefetching runs before context-token and visibility filtering, unnecessarily fetching full message bodies for discarded tasks and potentially triggering many remote batches even with limit=0.
1 open issue
9 files not reviewed
internal/storageclient/storagefault/wrappers_gen.go: Generated filepkg/storage/v1/wire/storagepb/gateway.pb.go: Generated filepkg/storage/v1/wire/storagepb/gateway_grpc.pb.go: Generated filepkg/storage/v1/wire/wiretest/zz_generated.overlay.go: Generated filepkg/storage/v1/wire/zz_generated.codecs_test.go: Generated filepkg/storage/v1/wire/zz_generated.mapping.go: Generated filepkg/storage/v1/wire/zz_generated.provider.go: Generated filepkg/storage/v1/wire/zz_generated.recorder_test.go: Generated filepkg/storage/v1/wire/zz_generated.service.go: Generated file
Review effort: Balanced
… return Signed-off-by: Robert Cronin <robert.owen.cronin@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the batched gateway ownership lookup change.
No open issues 🎉
1 resolved since last review
9 files not reviewed
internal/storageclient/storagefault/wrappers_gen.go: Generated filepkg/storage/v1/wire/storagepb/gateway.pb.go: Generated filepkg/storage/v1/wire/storagepb/gateway_grpc.pb.go: Generated filepkg/storage/v1/wire/wiretest/zz_generated.overlay.go: Generated filepkg/storage/v1/wire/zz_generated.codecs_test.go: Generated filepkg/storage/v1/wire/zz_generated.mapping.go: Generated filepkg/storage/v1/wire/zz_generated.provider.go: Generated filepkg/storage/v1/wire/zz_generated.recorder_test.go: Generated filepkg/storage/v1/wire/zz_generated.service.go: Generated file
Review effort: Balanced

Stacked on the adapter E2E layer.
GET /tasksand the attention scan look up each Task's gateway ownership on its own, oneGetGatewayEventForTaskcall per Task. On embedded SQLite that is cheap. With an out-of-tree adapter, every call is a round trip to the database, so listing a namespace's Tasks costs one round trip per Task before anything comes back. This layer adds a batch read to the contract and uses it in both places.Base is
stack/512/31-adapter-e2e; the diff below is this layer only.What changes
GatewayEventStore.ListGatewayEventsForTasks(ctx, keys []GatewayTaskKey)returns the eventGetGatewayEventForTaskwould return for each distinct key that has one, in key order. Keys without an event are left out.MaxGatewayTaskKeys(500) keys. More keys, or a key without a namespace, Task name or Task UID, isErrValidation;ValidateGatewayTaskKeysgives adapters the same check.Gateway.ListGatewayEventsForTasksstreams its events as a list. An event carries its message text, so 500 of them aren't bounded in size.GatewayEventStoreis now served from revision 13, so the controller requires an adapter on that revision.GET /taskspage function and the attention scan each read a page's gateway events in one batch into a request-scoped map. The gateway identity check reads through that map and falls back to the per-Task lookup for any Task the batch didn't cover.storage-contracts.mdrecords revision 20, protocol revision 13 and the new list stream.Left alone:
/tracemust read the latest event sequence first, because that sequence bounds its event listing, so its two reads can't run together./eventscould run its two reads in parallel. That would save one round trip but weaken the ordering clients see betweenlatestSeqand the last listed event.An out-of-tree adapter needs
ListGatewayEventsForTasksto report revision 20.Testing
go test ./internal/store/sqlite -run 'Conformance|OverWire|Wire').go test ./internal/api/...:TestListTasksReadsGatewayOwnershipInOneBatch: one batch and no single lookups, and a Task that only its durable record marks as gateway-owned stays hidden.TestListTasksFallsBackToSingleLookupsWhenTheBatchFails: single lookups give the same result, and the request answers503when they fail too.TestAttentionReadsGatewayOwnershipInOneBatch.make test, fullgolangci-linton the root andpkg/storagemodules,go test ./cmd/build/helmify/..., a cleanmake manifests generate,make verify-generatedandgo test ./hack/repocheck: pass.Part of #512.