From c208a637cbe790399cf83e3d558f68df13021d1c Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 23 Sep 2026 03:12:48 +1000 Subject: [PATCH] fix(proto): keep EventsSinceRequest.since_id's wire name The cursor change renamed the field to 'cursor' as well as widening its type, which buf breaking flags as FIELD_SAME_NAME and FIELD_SAME_JSON_NAME on top of the type change. The name buys nothing: the field is already documented as an opaque cursor, and the number and name are the wire identity. Adopt the gate's verdict and change only the type, keeping the break confined to the one rule already recorded in proto/buf.yaml. --- internal/contracts/state/v1/state.pb.go | 18 ++++++++++-------- internal/infrastructure/staterpc/client.go | 2 +- internal/infrastructure/staterpc/server.go | 2 +- proto/buf.yaml | 21 ++++++++++++--------- proto/state/v1/state.proto | 8 +++++--- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/internal/contracts/state/v1/state.pb.go b/internal/contracts/state/v1/state.pb.go index cacdc3308..8a2d725d9 100644 --- a/internal/contracts/state/v1/state.pb.go +++ b/internal/contracts/state/v1/state.pb.go @@ -4134,10 +4134,12 @@ func (x *InsertEventResponse) GetId() int64 { type EventsSinceRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - // cursor is the opaque resume cursor returned by the previous page (the SSE + // since_id is the opaque resume cursor returned by the previous page (the SSE // id: field, echoed back as Last-Event-ID). Empty means "from the - // beginning". - Cursor string `protobuf:"bytes,1,opt,name=cursor,proto3" json:"cursor,omitempty"` + // beginning". The field keeps its name and number so the wire name stays + // put; only its type widened, from the SQLite rowid to the fixed-width + // "|" cursor. + SinceId string `protobuf:"bytes,1,opt,name=since_id,json=sinceId,proto3" json:"since_id,omitempty"` Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -4173,9 +4175,9 @@ func (*EventsSinceRequest) Descriptor() ([]byte, []int) { return file_state_v1_state_proto_rawDescGZIP(), []int{70} } -func (x *EventsSinceRequest) GetCursor() string { +func (x *EventsSinceRequest) GetSinceId() string { if x != nil { - return x.Cursor + return x.SinceId } return "" } @@ -7928,9 +7930,9 @@ const file_state_v1_state_proto_rawDesc = "" + "\x12InsertEventRequest\x12%\n" + "\x05event\x18\x01 \x01(\v2\x0f.state.v1.EventR\x05event\"%\n" + "\x13InsertEventResponse\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x12EventsSinceRequest\x12\x16\n" + - "\x06cursor\x18\x01 \x01(\tR\x06cursor\x12\x14\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"E\n" + + "\x12EventsSinceRequest\x12\x19\n" + + "\bsince_id\x18\x01 \x01(\tR\asinceId\x12\x14\n" + "\x05limit\x18\x02 \x01(\x03R\x05limit\">\n" + "\x13EventsSinceResponse\x12'\n" + "\x06events\x18\x01 \x03(\v2\x0f.state.v1.EventR\x06events\",\n" + diff --git a/internal/infrastructure/staterpc/client.go b/internal/infrastructure/staterpc/client.go index 9b18c5a7e..2bff29d64 100644 --- a/internal/infrastructure/staterpc/client.go +++ b/internal/infrastructure/staterpc/client.go @@ -216,7 +216,7 @@ func (c *Client) InsertEvent(ctx context.Context, e events.Event) (int64, error) } func (c *Client) EventsSince(ctx context.Context, cursor string, limit int) ([]events.Event, error) { - r, err := c.client.EventsSince(ctx, &pb.EventsSinceRequest{Cursor: cursor, Limit: int64(limit)}) + r, err := c.client.EventsSince(ctx, &pb.EventsSinceRequest{SinceId: cursor, Limit: int64(limit)}) if err != nil { return nil, unmapError(err) } diff --git a/internal/infrastructure/staterpc/server.go b/internal/infrastructure/staterpc/server.go index 11097ef05..68b93a3c3 100644 --- a/internal/infrastructure/staterpc/server.go +++ b/internal/infrastructure/staterpc/server.go @@ -283,7 +283,7 @@ func (s *server) InsertEvent(ctx context.Context, r *pb.InsertEventRequest) (*pb } func (s *server) EventsSince(ctx context.Context, r *pb.EventsSinceRequest) (*pb.EventsSinceResponse, error) { - evs, err := s.deps.Tasks.EventsSince(ctx, r.Cursor, int(r.Limit)) + evs, err := s.deps.Tasks.EventsSince(ctx, r.SinceId, int(r.Limit)) if err != nil { return nil, s.logErr("EventsSince", err) } diff --git a/proto/buf.yaml b/proto/buf.yaml index 6d9f7222d..17f3cea97 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -7,15 +7,18 @@ lint: breaking: use: - FILE - # The PocketBase migration moved the event-capture contract's record ids from - # the SQLite rowid (int64) to PocketBase's string record ids, in place, on the - # same field numbers: 16 fields across CapturedEvent, Mapping, Binding, - # RecordDispatchRequest, EnqueueBindingTaskRequest, Task.binding_id and the - # Id-bearing request/response messages. That is an intentional wire break, and - # both ends of the State Store contract ship from this repository together, so - # the two halves cannot be versioned apart. Only the type rule is relaxed, and - # only in this file: every other FILE breaking rule still applies here, and no - # other contract is affected. + # Two intentional wire breaks, both widening an id-shaped field from int64 to + # string in place, on the same field numbers and names. The PocketBase + # migration moved the event-capture contract's record ids to PocketBase's + # string record ids: CapturedEvent, Mapping, Binding, RecordDispatchRequest, + # EnqueueBindingTaskRequest, Task.binding_id and the Id-bearing + # request/response messages. Separately, EventsSinceRequest.since_id now + # carries the opaque "|" resume cursor instead of a rowid. + # + # The State Store contract's two halves ship from this repository together, so + # they cannot be versioned apart. Only the type rule is relaxed, and only in + # this file: every other FILE breaking rule still applies here, so a rename, + # a renumber or a removal is still caught, and no other contract is affected. ignore_only: FIELD_SAME_TYPE: - state/v1/state.proto diff --git a/proto/state/v1/state.proto b/proto/state/v1/state.proto index 7778ca162..69b40a9c4 100644 --- a/proto/state/v1/state.proto +++ b/proto/state/v1/state.proto @@ -470,10 +470,12 @@ message InsertEventRequest { Event event = 1; } message InsertEventResponse { int64 id = 1; } message EventsSinceRequest { - // cursor is the opaque resume cursor returned by the previous page (the SSE + // since_id is the opaque resume cursor returned by the previous page (the SSE // id: field, echoed back as Last-Event-ID). Empty means "from the - // beginning". - string cursor = 1; + // beginning". The field keeps its name and number so the wire name stays + // put; only its type widened, from the SQLite rowid to the fixed-width + // "|" cursor. + string since_id = 1; int64 limit = 2; } message EventsSinceResponse { repeated Event events = 1; }