Skip to content

namespace replication: add CHASM contracts (PR1a) - #12135

Draft
qyc5937 wants to merge 4 commits into
prep/nsrepl-shared-converterfrom
qian/feat-nsrepl-chasm-contracts
Draft

qyc5937 wants to merge 4 commits into
prep/nsrepl-shared-converterfrom
qian/feat-nsrepl-chasm-contracts

Conversation

@qyc5937

@qyc5937 qyc5937 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Splits the wire contracts and generated API surface out of #12113 so schema/API compatibility can be reviewed independently from the CHASM state-machine implementation.

  • adds namespace-mutation state, task, and internal service protobufs
  • adds the receiver-side ApplyNamespaceMutation AdminService contract
  • regenerates protobufs, service clients, mocks, and interceptors
  • adds the stable CHASM library/component naming constants

This is inert: it does not register a handler, wire the library into a service graph, or alter namespace replication routing. The CHASM implementation remains in the stacked PR.

Validation

  • make proto
  • go test -tags test_dep ./chasm/... ./client/admin ./common/rpc/interceptor/logtags ./api/adminservice/v1 ./api/adminservicemock/v1
  • make lint-code-fast

Copilot AI left a comment

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.

🟡 Changes recommended

The peer destination contract must preserve fan-out to removed replication cells.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds inert CHASM namespace-replication contracts and generated API surfaces for the stacked implementation PR.

Changes:

  • Defines mutation state, task, and internal RPC protobufs.
  • Adds the receiver-side AdminService RPC and generated clients/mocks.
  • Adds stable CHASM naming constants.
File summaries
File Description
proto/internal/temporal/server/api/adminservice/v1/service.proto Declares the receiver RPC.
proto/internal/temporal/server/api/adminservice/v1/request_response.proto Defines receiver request and outcomes.
common/rpc/interceptor/logtags/admin_service_server_gen.go Handles new RPC messages.
client/admin/retryable_client_gen.go Adds retrying RPC client support.
client/admin/metric_client_gen.go Adds RPC client metrics.
client/admin/client_gen.go Adds the base client method.
chasm/namespacereplication.go Defines stable CHASM identifiers.
chasm/lib/namespacereplication/proto/v1/tasks.proto Defines local, peer, and backoff tasks.
chasm/lib/namespacereplication/proto/v1/service.proto Defines the internal trigger service.
chasm/lib/namespacereplication/proto/v1/message.proto Defines mutation and persisted state contracts.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.pb.go Generates task message types.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.go-helpers.pb.go Generates task serialization helpers.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.pb.go Generates service message types.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.go-helpers.pb.go Generates service message helpers.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_grpc.pb.go Generates gRPC service bindings.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_client.pb.go Generates the layered history client.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.pb.go Generates mutation and state types.
chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.go-helpers.pb.go Generates message helpers.
api/adminservicemock/v1/service_grpc.pb.mock.go Adds AdminService mocks.
api/adminservice/v1/service.pb.go Updates the generated service descriptor.
api/adminservice/v1/service_grpc.pb.go Adds generated RPC bindings.
api/adminservice/v1/request_response.go-helpers.pb.go Adds request/response helpers.
Review details

Files not reviewed (16)

  • api/adminservice/v1/request_response.go-helpers.pb.go: Generated file
  • api/adminservice/v1/service.pb.go: Generated file
  • api/adminservice/v1/service_grpc.pb.go: Generated file
  • api/adminservicemock/v1/service_grpc.pb.mock.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_client.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_grpc.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.pb.go: Generated file
  • client/admin/client_gen.go: Generated file
  • client/admin/metric_client_gen.go: Generated file
  • client/admin/retryable_client_gen.go: Generated file
  • common/rpc/interceptor/logtags/admin_service_server_gen.go: Generated file

Suppressed comments (6)

chasm/lib/namespacereplication/proto/v1/message.proto:12

  • Details
small — The mutation documentation promises a field that does not exist.

NamespaceMutation has no correlation-ID field; the per-invocation identity is carried separately by TriggerNamespaceMutationRequest.business_id. This description is misleading about what is persisted in component state.

Suggestion: Remove the correlation-ID claim.

// NamespaceMutation is the input to a NamespaceMutationComponent — the full target
// state of the namespace plus the CAS guard and an optional correlation ID.

chasm/lib/namespacereplication/proto/v1/service.proto:38

  • Details
small — The mutation request field is undocumented.

This field carries the mutation sent to the history-side component, but it has no field-level description. The new proto contract requires each field to document its semantics.

Suggestion: Describe what the embedded mutation is used for.

  NamespaceMutation mutation = 2;

chasm/lib/namespacereplication/proto/v1/tasks.proto:25

  • Details
small — The backoff task fields are undocumented.

These fields identify which peer retry the timer re-enqueues, but their semantics are absent from the persisted task contract. The corresponding ApplyPeerTask fields already document this relationship.

Suggestion: Document the target peer and retry attempt.

  string target_cell = 1;
  int32 attempt = 2;

chasm/lib/namespacereplication/proto/v1/message.proto:100

  • Details
small — The local and peer status fields are undocumented.

The persisted status contract does not define the outcome, attempt count, or timestamp semantics. Consumers therefore cannot tell when applied_at is meaningful or what the peer timestamps represent.

Suggestion: Add field-level descriptions for both status messages.

  LocalApplyOutcome outcome = 1;
  google.protobuf.Timestamp applied_at = 2;
  // Failure detail when outcome is FAILED (e.g. CAS conflict, store unavailable).
  temporal.api.failure.v1.Failure failure = 3;
}

message PeerApplyStatus {
  PeerApplyOutcome outcome = 1;
  int32 attempt_count = 2;
  google.protobuf.Timestamp first_attempt_at = 3;
  google.protobuf.Timestamp last_attempt_at = 4;

proto/internal/temporal/server/api/adminservice/v1/request_response.proto:230

  • Details
small — The response outcome field is undocumented.

The enum values describe individual cases, but the response field itself does not state that it reports the receiver's application result.

Suggestion: Add a field-level description.

  Outcome outcome = 1;

chasm/lib/namespacereplication/proto/v1/service.proto:16

  • Details
small — The service comment describes the component as per-namespace instead of per-mutation.

The request uses a UUID-suffixed business_id so concurrent mutations create distinct components. Calling the component “per-namespace” therefore misstates its identity and lifecycle.

Suggestion: Describe the handler as starting one component for each mutation.

// NamespaceReplicationService is the internal (frontend → history) RPC that
// frontend uses to trigger namespace mutations through the CHASM-based
// replication transport. The history-side handler starts the per-namespace
// NamespaceMutationComponent and waits for the local apply (ApplyLocalTask) to
// complete. Peer fan-out (ApplyPeerTask) continues asynchronously after the
// RPC returns.
  • Files reviewed: 6/23 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread chasm/lib/namespacereplication/proto/v1/message.proto Outdated
Comment thread chasm/lib/namespacereplication/proto/v1/message.proto Outdated

Copilot AI left a comment

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.

🟢 Approval recommended

Only a non-blocking outcome-description clarification remains.

Review details

Files not reviewed (16)

  • api/adminservice/v1/request_response.go-helpers.pb.go: Generated file
  • api/adminservice/v1/service.pb.go: Generated file
  • api/adminservice/v1/service_grpc.pb.go: Generated file
  • api/adminservicemock/v1/service_grpc.pb.mock.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/message.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_client.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/service_grpc.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.go-helpers.pb.go: Generated file
  • chasm/lib/namespacereplication/gen/namespacereplicationpb/v1/tasks.pb.go: Generated file
  • client/admin/client_gen.go: Generated file
  • client/admin/metric_client_gen.go: Generated file
  • client/admin/retryable_client_gen.go: Generated file
  • common/rpc/interceptor/logtags/admin_service_server_gen.go: Generated file
  • Files reviewed: 6/23 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +214 to +219
// An existing namespace was updated (incoming ConfigVersion or
// FailoverVersion was strictly higher than current).
OUTCOME_APPLIED = 1;
// The receiver's current state is >= incoming state on both versions.
// No write was performed. Success outcome.
OUTCOME_NO_OP_STALE = 2;
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