diff --git a/buf.yaml b/buf.yaml index 06779db..d15a15d 100644 --- a/buf.yaml +++ b/buf.yaml @@ -7,6 +7,10 @@ modules: lint: use: - STANDARD + # Internal D↔A protocol has one current package; release versions stay in + # protocol_version fields, not in the Go/Proto package name. + except: + - PACKAGE_VERSION_SUFFIX breaking: use: diff --git a/cmd/sip-go-agent/agent_mock_originator.go b/cmd/sip-go-agent/agent_mock_originator.go index a76b7c2..25a7489 100644 --- a/cmd/sip-go-agent/agent_mock_originator.go +++ b/cmd/sip-go-agent/agent_mock_originator.go @@ -5,16 +5,16 @@ import ( "errors" "log/slog" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) // mockAuthorizedOriginator is deliberately isolated from SIP and Asterisk. // Mixed/real modes have no adapter until separately authorized and verified. -func mockAuthorizedOriginator(mode string) func(context.Context, *agentv1.ExecuteAuthorizedRequest) error { +func mockAuthorizedOriginator(mode string) func(context.Context, *agentpb.ExecuteAuthorizedRequest) error { if mode != "mock" { return nil } - return func(ctx context.Context, request *agentv1.ExecuteAuthorizedRequest) error { + return func(ctx context.Context, request *agentpb.ExecuteAuthorizedRequest) error { if err := ctx.Err(); err != nil { return err } diff --git a/cmd/sip-go-agent/agent_mock_originator_test.go b/cmd/sip-go-agent/agent_mock_originator_test.go index 59f2650..bc572ce 100644 --- a/cmd/sip-go-agent/agent_mock_originator_test.go +++ b/cmd/sip-go-agent/agent_mock_originator_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func TestAuthorizedOriginatorIsExplicitlyMockOnly(t *testing.T) { @@ -15,7 +15,7 @@ func TestAuthorizedOriginatorIsExplicitlyMockOnly(t *testing.T) { if originator == nil { t.Fatal("mock mode has no isolated originator") } - request := &agentv1.ExecuteAuthorizedRequest{Binding: &agentv1.ExecutionBinding{ExecutionId: "execution-1"}, SelectedTrunkId: "trunk-1"} + request := &agentpb.ExecuteAuthorizedRequest{Binding: &agentpb.ExecutionBinding{ExecutionId: "execution-1"}, SelectedTrunkId: "trunk-1"} ctx, cancel := context.WithCancel(context.Background()) cancel() if err := originator(ctx, request); err == nil { diff --git a/cmd/sip-go-agent/main.go b/cmd/sip-go-agent/main.go index 91ee6f5..e5d9c12 100644 --- a/cmd/sip-go-agent/main.go +++ b/cmd/sip-go-agent/main.go @@ -15,7 +15,7 @@ import ( "syscall" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/ai" "git.ipao.vip/rogee/go-sip/internal/callflow" @@ -363,18 +363,18 @@ func serveAgentRPC(cfg config.Config, spool *agent.Spool, report agent.RecoveryR grpcServer := grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsConfig))) handler := rpc.NewServer(rpc.ServerOptions{ Mode: cfg.Mode, - Status: &agentv1.AgentStatus{ + Status: &agentpb.AgentStatus{ AgentId: cfg.AgentID, CellId: cfg.CellID, BootId: bootID, SoftwareVersion: cfg.Version, ProtocolVersion: "agent.v1", - AdmissionState: agentv1.AdmissionState_ADMISSION_STATE_CLOSED, + AdmissionState: agentpb.AdmissionState_ADMISSION_STATE_CLOSED, StatusReason: fmt.Sprintf("recovered_unknown=%d quarantined=%d spool=%s", len(report.Unknown), len(report.Quarantined), spool.Root()), - Capabilities: []*agentv1.Capability{{Name: "mode", Value: cfg.Mode}, {Name: "grpc_transport", Value: "unary-mtls"}, {Name: "resource_sample", Value: "partial-unknown"}}, + Capabilities: []*agentpb.Capability{{Name: "mode", Value: cfg.Mode}, {Name: "grpc_transport", Value: "unary-mtls"}, {Name: "resource_sample", Value: "partial-unknown"}}, Resources: health.Sampler{}.Sample(context.Background(), spool.Root()), }, - UploadPolicy: &agentv1.UploadPolicy{Enabled: cfg.Mode == "mock", MaxAssetBytes: 16 << 20}, + UploadPolicy: &agentpb.UploadPolicy{Enabled: cfg.Mode == "mock", MaxAssetBytes: 16 << 20}, StaticArtifactRaw: staticArtifactRaw, StaticArtifactExpected: contract.StaticArtifactExpectation{CellID: cfg.CellID, Mode: cfg.Mode}, RequirePeerCertificate: true, @@ -383,7 +383,7 @@ func serveAgentRPC(cfg config.Config, spool *agent.Spool, report agent.RecoveryR CallLogger: callLogger, MockAuthorizedOriginate: mockAuthorizedOriginator(cfg.Mode), }) - agentv1.RegisterAgentControlServiceServer(grpcServer, handler) + agentpb.RegisterAgentControlServiceServer(grpcServer, handler) serveCtx, cancel := signalContext() defer cancel() stopUploadRecovery, err := startUploadNotificationRecovery(serveCtx, cfg, spool, handler.ActiveSessionMeta) @@ -557,7 +557,7 @@ func newDispatcherCommand() *cobra.Command { return errors.New("MTLS_PEER_CERT_FINGERPRINTS is required when Dispatcher gRPC is enabled") } allowedAgentIDs := parseCSVSet(cfg.DispatcherGRPCAllowedAgentIDs) - authorizeAgentSession := func(meta *agentv1.RequestMeta) error { + authorizeAgentSession := func(meta *agentpb.RequestMeta) error { if connectedAgents == nil || connectedAgents.coordinator == nil { return fmt.Errorf("no activated Agent coordinator: %w", store.ErrCommandConflict) } @@ -565,13 +565,13 @@ func newDispatcherCommand() *cobra.Command { } uploadHandler, handlerErr := rpc.NewDispatcherUploadServerWithOptions(st, uploadClient, time.Now, rpc.DispatcherUploadOptions{ RequirePeer: true, PeerCertificateFingerprints: peerFingerprints, AllowedAgentIDs: allowedAgentIDs, - LocalV3Authorize: func(ctx context.Context, req *agentv1.RequestUploadRequest) error { + LocalV3Authorize: func(ctx context.Context, req *agentpb.RequestUploadRequest) error { if err := authorizeAgentSession(req.Meta); err != nil { return err } return d.AuthorizeLocalMockUpload(ctx, req) }, - LocalV3Complete: func(ctx context.Context, req *agentv1.CompleteUploadRequest, record store.UploadRecord) (bool, error) { + LocalV3Complete: func(ctx context.Context, req *agentpb.CompleteUploadRequest, record store.UploadRecord) (bool, error) { if err := authorizeAgentSession(req.Meta); err != nil { return false, err } @@ -605,7 +605,7 @@ func newDispatcherCommand() *cobra.Command { } return handler(ctx, req) })) - agentv1.RegisterAgentControlServiceServer(dispatcherGRPC, dispatcherHandler) + agentpb.RegisterAgentControlServiceServer(dispatcherGRPC, dispatcherHandler) go func() { if serveErr := dispatcherGRPC.Serve(dispatcherListener); serveErr != nil && !errors.Is(serveErr, grpc.ErrServerStopped) { slog.Error("Dispatcher gRPC stopped", "error", serveErr) diff --git a/cmd/sip-go-agent/upload.go b/cmd/sip-go-agent/upload.go index f454cb7..4b6503c 100644 --- a/cmd/sip-go-agent/upload.go +++ b/cmd/sip-go-agent/upload.go @@ -10,7 +10,7 @@ import ( "strings" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/callruntime" "git.ipao.vip/rogee/go-sip/internal/config" @@ -38,7 +38,7 @@ func uploadCallRecordings(ctx context.Context, cfg config.Config, result callrun if executionID == "" { executionID = result.ChannelID } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: cfg.CallTenantID, TenantKey: cfg.CallTenantKey, ExecutionId: executionID, @@ -69,8 +69,8 @@ func uploadCallRecordings(ctx context.Context, cfg config.Config, result callrun return nil, fmt.Errorf("recording %d is missing path, size or checksum", index+1) } assetID := recordingAssetID(recording.Segment, recording.Path, index+1) - asset := &agentv1.AssetDescriptor{ - Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, + asset := &agentpb.AssetDescriptor{ + Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: assetID, CallId: result.ChannelID, ExecutionId: executionID, @@ -119,15 +119,15 @@ func recordingAssetID(segment, path string, index int) string { return assetID } -func stableUploadID(binding *agentv1.ExecutionBinding, asset *agentv1.AssetDescriptor) string { +func stableUploadID(binding *agentpb.ExecutionBinding, asset *agentpb.AssetDescriptor) string { value := binding.ExecutionId + "\x00" + asset.AssetId + "\x00" + asset.ChecksumSha256 digest := sha256.Sum256([]byte(value)) return "upload-" + hex.EncodeToString(digest[:16]) } -func uploadMeta(cfg config.Config, phase, uploadID string) *agentv1.RequestMeta { +func uploadMeta(cfg config.Config, phase, uploadID string) *agentpb.RequestMeta { operationID := "recording-" + phase + "-" + uploadID - return &agentv1.RequestMeta{ + return &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", RequestId: operationID, TraceId: operationID, diff --git a/cmd/sip-go-agent/upload_attempt.go b/cmd/sip-go-agent/upload_attempt.go index 1f2fe9a..e2e63b0 100644 --- a/cmd/sip-go-agent/upload_attempt.go +++ b/cmd/sip-go-agent/upload_attempt.go @@ -10,18 +10,18 @@ import ( "os" "strings" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" "google.golang.org/protobuf/proto" ) type recordingUploadRPC interface { - RequestUpload(context.Context, *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) - CompleteUpload(context.Context, *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) + RequestUpload(context.Context, *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) + CompleteUpload(context.Context, *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) } -func uploadRecording(ctx context.Context, cfg config.Config, client recordingUploadRPC, uploader agent.UploadClient, spool *agent.Spool, binding *agentv1.ExecutionBinding, asset *agentv1.AssetDescriptor, path string) (returned agent.UploadAttempt, returnErr error) { +func uploadRecording(ctx context.Context, cfg config.Config, client recordingUploadRPC, uploader agent.UploadClient, spool *agent.Spool, binding *agentpb.ExecutionBinding, asset *agentpb.AssetDescriptor, path string) (returned agent.UploadAttempt, returnErr error) { if binding == nil || asset == nil { return returned, errors.New("upload binding and asset are required") } @@ -31,7 +31,7 @@ func uploadRecording(ctx context.Context, cfg config.Config, client recordingUpl return returned, err } defer func() { returnErr = errors.Join(returnErr, lock.Close()) }() - identityBytes, err := (proto.MarshalOptions{Deterministic: true}).Marshal(&agentv1.RequestUploadRequest{Binding: binding, Asset: asset, UploadId: id}) + identityBytes, err := (proto.MarshalOptions{Deterministic: true}).Marshal(&agentpb.RequestUploadRequest{Binding: binding, Asset: asset, UploadId: id}) if err != nil { return agent.UploadAttempt{}, err } @@ -39,11 +39,11 @@ func uploadRecording(ctx context.Context, cfg config.Config, client recordingUpl identity := hex.EncodeToString(digest[:]) record, err := spool.LoadUploadAttempt(id) if errors.Is(err, os.ErrNotExist) { - response, err := client.RequestUpload(ctx, &agentv1.RequestUploadRequest{Meta: uploadMeta(cfg, "request", id), Binding: binding, Asset: asset, UploadId: id}) + response, err := client.RequestUpload(ctx, &agentpb.RequestUploadRequest{Meta: uploadMeta(cfg, "request", id), Binding: binding, Asset: asset, UploadId: id}) if err != nil { return record, fmt.Errorf("request upload %s: %w", id, err) } - if response.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || response.GetGrant() == nil { + if response.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || response.GetGrant() == nil { return record, fmt.Errorf("request upload %s has no accepted grant", id) } grant := response.Grant @@ -106,11 +106,11 @@ func notifyUploadedRecordingLocked(ctx context.Context, cfg config.Config, clien return record, errors.New("successful upload and original notification metadata are required") } id := record.UploadID - response, err := client.CompleteUpload(ctx, &agentv1.CompleteUploadRequest{Meta: uploadMeta(cfg, "complete", id), Binding: record.Binding, Asset: record.Asset, UploadId: id, UploadedSizeBytes: record.Result.SizeBytes, UploadedChecksumSha256: record.Result.SHA256}) + response, err := client.CompleteUpload(ctx, &agentpb.CompleteUploadRequest{Meta: uploadMeta(cfg, "complete", id), Binding: record.Binding, Asset: record.Asset, UploadId: id, UploadedSizeBytes: record.Result.SizeBytes, UploadedChecksumSha256: record.Result.SHA256}) if err != nil { return record, fmt.Errorf("notify upload %s: %w", id, err) } - if response.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || response.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED { + if response.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || response.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED { return record, errors.New("upload notification has not completed MQ delivery") } if err := spool.CompleteUploadNotification(id); err != nil { diff --git a/cmd/sip-go-agent/upload_attempt_test.go b/cmd/sip-go-agent/upload_attempt_test.go index 38350a2..ae06de1 100644 --- a/cmd/sip-go-agent/upload_attempt_test.go +++ b/cmd/sip-go-agent/upload_attempt_test.go @@ -12,28 +12,28 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" ) type uploadRPCStub struct { - grant *agentv1.UploadGrant + grant *agentpb.UploadGrant requests, notifications int pending bool } -func (s *uploadRPCStub) RequestUpload(_ context.Context, r *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) { +func (s *uploadRPCStub) RequestUpload(_ context.Context, r *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) { s.requests++ s.grant.UploadId = r.UploadId - return &agentv1.RequestUploadResponse{Grant: s.grant, Receipt: &agentv1.OperationReceipt{Result: agentv1.ResultCode_RESULT_CODE_ACCEPTED}}, nil + return &agentpb.RequestUploadResponse{Grant: s.grant, Receipt: &agentpb.OperationReceipt{Result: agentpb.ResultCode_RESULT_CODE_ACCEPTED}}, nil } -func (s *uploadRPCStub) CompleteUpload(_ context.Context, _ *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) { +func (s *uploadRPCStub) CompleteUpload(_ context.Context, _ *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) { s.notifications++ if s.pending { return nil, errors.New("notification pending") } - return &agentv1.CompleteUploadResponse{State: agentv1.UploadState_UPLOAD_STATE_COMPLETED, Receipt: &agentv1.OperationReceipt{Result: agentv1.ResultCode_RESULT_CODE_ACCEPTED}}, nil + return &agentpb.CompleteUploadResponse{State: agentpb.UploadState_UPLOAD_STATE_COMPLETED, Receipt: &agentpb.OperationReceipt{Result: agentpb.ResultCode_RESULT_CODE_ACCEPTED}}, nil } func TestRecordingNotificationRecoveryDoesNotPUTAgain(t *testing.T) { @@ -46,9 +46,9 @@ func TestRecordingNotificationRecoveryDoesNotPUTAgain(t *testing.T) { t.Fatal(err) } sum := sha256.Sum256([]byte("audio")) - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{AssetId: "recording-a", SizeBytes: 5, ChecksumSha256: hex.EncodeToString(sum[:])} - remote := &uploadRPCStub{pending: true, grant: &agentv1.UploadGrant{ObjectKey: "recording-a", TargetUrl: server.URL, MaxBytes: 5, RequiredChecksumSha256: asset.ChecksumSha256, ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()}} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{AssetId: "recording-a", SizeBytes: 5, ChecksumSha256: hex.EncodeToString(sum[:])} + remote := &uploadRPCStub{pending: true, grant: &agentpb.UploadGrant{ObjectKey: "recording-a", TargetUrl: server.URL, MaxBytes: 5, RequiredChecksumSha256: asset.ChecksumSha256, ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()}} spool, err := agent.NewSpool(root, nil) if err != nil { t.Fatal(err) diff --git a/cmd/sip-go-agent/upload_failure_recovery_test.go b/cmd/sip-go-agent/upload_failure_recovery_test.go index 55c1049..de27434 100644 --- a/cmd/sip-go-agent/upload_failure_recovery_test.go +++ b/cmd/sip-go-agent/upload_failure_recovery_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" "github.com/google/uuid" @@ -17,13 +17,13 @@ type mockFailureRecoveryClient struct { fail bool } -func (c *mockFailureRecoveryClient) ReportExecutionEvent(_ context.Context, req *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (c *mockFailureRecoveryClient) ReportExecutionEvent(_ context.Context, req *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { c.reports++ if c.fail { return nil, errors.New("Dispatcher unavailable") } - return &agentv1.ReportExecutionEventResponse{Receipt: &agentv1.OperationReceipt{ - Result: agentv1.ResultCode_RESULT_CODE_ACCEPTED, FactId: req.Fact.FactId, ContentSha256: req.Fact.ContentSha256, + return &agentpb.ReportExecutionEventResponse{Receipt: &agentpb.OperationReceipt{ + Result: agentpb.ResultCode_RESULT_CODE_ACCEPTED, FactId: req.Fact.FactId, ContentSha256: req.Fact.ContentSha256, }}, nil } @@ -32,7 +32,7 @@ func TestMockFailureRecoveryWaitsForActivationAndRejectsRealMode(t *testing.T) { if err != nil { t.Fatal(err) } - active := &agentv1.RequestMeta{ + active := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1, } @@ -41,8 +41,8 @@ func TestMockFailureRecoveryWaitsForActivationAndRejectsRealMode(t *testing.T) { t.Helper() if err := spool.ClaimUpload(agent.UploadAttempt{ UploadID: id, Identity: "identity-" + id, State: "attempted", RequestID: uuid.NewString(), - Binding: &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-" + id}, - Asset: &agentv1.AssetDescriptor{AssetId: "recording-" + id}, + Binding: &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-" + id}, + Asset: &agentpb.AssetDescriptor{AssetId: "recording-" + id}, }); err != nil { t.Fatal(err) } @@ -53,12 +53,12 @@ func TestMockFailureRecoveryWaitsForActivationAndRejectsRealMode(t *testing.T) { } claimAndFail("upload-a") cfg := config.Config{Mode: "mock"} - missingSession := func() (*agentv1.RequestMeta, error) { return nil, errors.New("not activated") } + missingSession := func() (*agentpb.RequestMeta, error) { return nil, errors.New("not activated") } if err := recoverMockFailureNotifications(context.Background(), cfg, remote, spool, missingSession); err == nil || remote.reports != 1 { t.Fatalf("unactivated Agent reported a durable fact: reports=%d err=%v", remote.reports, err) } remote.fail = false - currentSession := func() (*agentv1.RequestMeta, error) { return active, nil } + currentSession := func() (*agentpb.RequestMeta, error) { return active, nil } if err := recoverMockFailureNotifications(context.Background(), cfg, remote, spool, currentSession); err != nil || remote.reports != 2 { t.Fatalf("Mock failure was not recovered through the active session: reports=%d err=%v", remote.reports, err) } diff --git a/cmd/sip-go-agent/upload_recovery.go b/cmd/sip-go-agent/upload_recovery.go index 64614b2..2bdb710 100644 --- a/cmd/sip-go-agent/upload_recovery.go +++ b/cmd/sip-go-agent/upload_recovery.go @@ -7,7 +7,7 @@ import ( "log/slog" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" "git.ipao.vip/rogee/go-sip/internal/rpc" @@ -30,7 +30,7 @@ func recoverUploadNotifications(ctx context.Context, cfg config.Config, client r // recoverMockFailureNotifications never treats a prior boot's persisted fact // as a current session. The report uses metadata from the newly activated // session, while preserving the original immutable fact identity. -func recoverMockFailureNotifications(ctx context.Context, cfg config.Config, client agent.MockFailureFactClient, spool *agent.Spool, activeMeta func() (*agentv1.RequestMeta, error)) error { +func recoverMockFailureNotifications(ctx context.Context, cfg config.Config, client agent.MockFailureFactClient, spool *agent.Spool, activeMeta func() (*agentpb.RequestMeta, error)) error { pending, err := spool.PendingUploadFailures() if err != nil || len(pending) == 0 { return err @@ -50,7 +50,7 @@ func recoverMockFailureNotifications(ctx context.Context, cfg config.Config, cli // startUploadNotificationRecovery never requests a token or opens a source file. // The worker owns only durable metadata-to-Dispatcher notifications. -func startUploadNotificationRecovery(ctx context.Context, cfg config.Config, spool *agent.Spool, activeMeta func() (*agentv1.RequestMeta, error)) (func(), error) { +func startUploadNotificationRecovery(ctx context.Context, cfg config.Config, spool *agent.Spool, activeMeta func() (*agentpb.RequestMeta, error)) (func(), error) { pending, err := spool.PendingUploadNotifications() if err != nil { return nil, fmt.Errorf("read upload recovery journal: %w", err) diff --git a/cmd/sip-go-agent/upload_retry.go b/cmd/sip-go-agent/upload_retry.go index ad50fcb..f110fd6 100644 --- a/cmd/sip-go-agent/upload_retry.go +++ b/cmd/sip-go-agent/upload_retry.go @@ -8,7 +8,7 @@ import ( "net/url" "strings" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" "github.com/google/uuid" @@ -34,7 +34,7 @@ func retryUploadRecording(ctx context.Context, cfg config.Config, client recordi if record.State != "attempted" || record.Binding == nil || record.Asset == nil || record.RequestID == "" || record.RequestID == requestID { return record, errors.New("only an unsuccessful upload may explicitly request a new grant") } - raw, err := (proto.MarshalOptions{Deterministic: true}).Marshal(&agentv1.RequestUploadRequest{Binding: record.Binding, Asset: record.Asset, UploadId: uploadID}) + raw, err := (proto.MarshalOptions{Deterministic: true}).Marshal(&agentpb.RequestUploadRequest{Binding: record.Binding, Asset: record.Asset, UploadId: uploadID}) if err != nil { return record, err } @@ -47,11 +47,11 @@ func retryUploadRecording(ctx context.Context, cfg config.Config, client recordi meta.OperationId = requestID meta.IdempotencyKey = requestID meta.TraceId = requestID - response, err := client.RequestUpload(ctx, &agentv1.RequestUploadRequest{Meta: meta, Binding: record.Binding, Asset: record.Asset, UploadId: uploadID}) + response, err := client.RequestUpload(ctx, &agentpb.RequestUploadRequest{Meta: meta, Binding: record.Binding, Asset: record.Asset, UploadId: uploadID}) if err != nil { return record, err } - if response.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || response.GetGrant() == nil { + if response.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || response.GetGrant() == nil { return record, errors.New("explicit upload request was not granted") } grant := response.Grant diff --git a/cmd/sip-go-agent/upload_retry_test.go b/cmd/sip-go-agent/upload_retry_test.go index d70497b..752cd18 100644 --- a/cmd/sip-go-agent/upload_retry_test.go +++ b/cmd/sip-go-agent/upload_retry_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/config" ) @@ -33,9 +33,9 @@ func TestExplicitUploadRetryIsOneNewRequestAndOnePUT(t *testing.T) { t.Fatal(err) } sum := sha256.Sum256([]byte("audio")) - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{AssetId: "recording-a", SizeBytes: 5, ChecksumSha256: hex.EncodeToString(sum[:])} - remote := &uploadRPCStub{grant: &agentv1.UploadGrant{ObjectKey: "recording-a", TargetUrl: server.URL, MaxBytes: 5, RequiredChecksumSha256: asset.ChecksumSha256, ExpiresAtUnixMs: time.Now().Add(-time.Minute).UnixMilli()}} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{AssetId: "recording-a", SizeBytes: 5, ChecksumSha256: hex.EncodeToString(sum[:])} + remote := &uploadRPCStub{grant: &agentpb.UploadGrant{ObjectKey: "recording-a", TargetUrl: server.URL, MaxBytes: 5, RequiredChecksumSha256: asset.ChecksumSha256, ExpiresAtUnixMs: time.Now().Add(-time.Minute).UnixMilli()}} spool, err := agent.NewSpool(root, nil) if err != nil { t.Fatal(err) diff --git a/gen/agent/v1/agent.pb.go b/gen/agent/agent.pb.go similarity index 78% rename from gen/agent/v1/agent.pb.go rename to gen/agent/agent.pb.go index 56b7893..bb8fd93 100644 --- a/gen/agent/v1/agent.pb.go +++ b/gen/agent/agent.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 +// protoc-gen-go v1.36.12 // protoc (unknown) -// source: agent/v1/agent.proto +// source: agent/agent.proto -package agentv1 +package agentpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -63,11 +63,11 @@ func (x ResultCode) String() string { } func (ResultCode) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[0].Descriptor() + return file_agent_agent_proto_enumTypes[0].Descriptor() } func (ResultCode) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[0] + return &file_agent_agent_proto_enumTypes[0] } func (x ResultCode) Number() protoreflect.EnumNumber { @@ -76,7 +76,7 @@ func (x ResultCode) Number() protoreflect.EnumNumber { // Deprecated: Use ResultCode.Descriptor instead. func (ResultCode) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{0} + return file_agent_agent_proto_rawDescGZIP(), []int{0} } type FailureCode int32 @@ -136,11 +136,11 @@ func (x FailureCode) String() string { } func (FailureCode) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[1].Descriptor() + return file_agent_agent_proto_enumTypes[1].Descriptor() } func (FailureCode) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[1] + return &file_agent_agent_proto_enumTypes[1] } func (x FailureCode) Number() protoreflect.EnumNumber { @@ -149,7 +149,7 @@ func (x FailureCode) Number() protoreflect.EnumNumber { // Deprecated: Use FailureCode.Descriptor instead. func (FailureCode) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{1} + return file_agent_agent_proto_rawDescGZIP(), []int{1} } type ActivationState int32 @@ -191,11 +191,11 @@ func (x ActivationState) String() string { } func (ActivationState) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[2].Descriptor() + return file_agent_agent_proto_enumTypes[2].Descriptor() } func (ActivationState) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[2] + return &file_agent_agent_proto_enumTypes[2] } func (x ActivationState) Number() protoreflect.EnumNumber { @@ -204,7 +204,7 @@ func (x ActivationState) Number() protoreflect.EnumNumber { // Deprecated: Use ActivationState.Descriptor instead. func (ActivationState) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{2} + return file_agent_agent_proto_rawDescGZIP(), []int{2} } type AdmissionState int32 @@ -246,11 +246,11 @@ func (x AdmissionState) String() string { } func (AdmissionState) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[3].Descriptor() + return file_agent_agent_proto_enumTypes[3].Descriptor() } func (AdmissionState) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[3] + return &file_agent_agent_proto_enumTypes[3] } func (x AdmissionState) Number() protoreflect.EnumNumber { @@ -259,7 +259,7 @@ func (x AdmissionState) Number() protoreflect.EnumNumber { // Deprecated: Use AdmissionState.Descriptor instead. func (AdmissionState) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{3} + return file_agent_agent_proto_rawDescGZIP(), []int{3} } type ControlAction int32 @@ -298,11 +298,11 @@ func (x ControlAction) String() string { } func (ControlAction) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[4].Descriptor() + return file_agent_agent_proto_enumTypes[4].Descriptor() } func (ControlAction) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[4] + return &file_agent_agent_proto_enumTypes[4] } func (x ControlAction) Number() protoreflect.EnumNumber { @@ -311,7 +311,7 @@ func (x ControlAction) Number() protoreflect.EnumNumber { // Deprecated: Use ControlAction.Descriptor instead. func (ControlAction) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{4} + return file_agent_agent_proto_rawDescGZIP(), []int{4} } type ActiveCallPolicy int32 @@ -347,11 +347,11 @@ func (x ActiveCallPolicy) String() string { } func (ActiveCallPolicy) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[5].Descriptor() + return file_agent_agent_proto_enumTypes[5].Descriptor() } func (ActiveCallPolicy) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[5] + return &file_agent_agent_proto_enumTypes[5] } func (x ActiveCallPolicy) Number() protoreflect.EnumNumber { @@ -360,7 +360,7 @@ func (x ActiveCallPolicy) Number() protoreflect.EnumNumber { // Deprecated: Use ActiveCallPolicy.Descriptor instead. func (ActiveCallPolicy) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{5} + return file_agent_agent_proto_rawDescGZIP(), []int{5} } type ExecutionState int32 @@ -408,11 +408,11 @@ func (x ExecutionState) String() string { } func (ExecutionState) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[6].Descriptor() + return file_agent_agent_proto_enumTypes[6].Descriptor() } func (ExecutionState) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[6] + return &file_agent_agent_proto_enumTypes[6] } func (x ExecutionState) Number() protoreflect.EnumNumber { @@ -421,7 +421,7 @@ func (x ExecutionState) Number() protoreflect.EnumNumber { // Deprecated: Use ExecutionState.Descriptor instead. func (ExecutionState) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{6} + return file_agent_agent_proto_rawDescGZIP(), []int{6} } type AssetKind int32 @@ -457,11 +457,11 @@ func (x AssetKind) String() string { } func (AssetKind) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[7].Descriptor() + return file_agent_agent_proto_enumTypes[7].Descriptor() } func (AssetKind) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[7] + return &file_agent_agent_proto_enumTypes[7] } func (x AssetKind) Number() protoreflect.EnumNumber { @@ -470,7 +470,7 @@ func (x AssetKind) Number() protoreflect.EnumNumber { // Deprecated: Use AssetKind.Descriptor instead. func (AssetKind) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{7} + return file_agent_agent_proto_rawDescGZIP(), []int{7} } type UploadState int32 @@ -509,11 +509,11 @@ func (x UploadState) String() string { } func (UploadState) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[8].Descriptor() + return file_agent_agent_proto_enumTypes[8].Descriptor() } func (UploadState) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[8] + return &file_agent_agent_proto_enumTypes[8] } func (x UploadState) Number() protoreflect.EnumNumber { @@ -522,7 +522,7 @@ func (x UploadState) Number() protoreflect.EnumNumber { // Deprecated: Use UploadState.Descriptor instead. func (UploadState) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{8} + return file_agent_agent_proto_rawDescGZIP(), []int{8} } type FactKind int32 @@ -573,11 +573,11 @@ func (x FactKind) String() string { } func (FactKind) Descriptor() protoreflect.EnumDescriptor { - return file_agent_v1_agent_proto_enumTypes[9].Descriptor() + return file_agent_agent_proto_enumTypes[9].Descriptor() } func (FactKind) Type() protoreflect.EnumType { - return &file_agent_v1_agent_proto_enumTypes[9] + return &file_agent_agent_proto_enumTypes[9] } func (x FactKind) Number() protoreflect.EnumNumber { @@ -586,7 +586,7 @@ func (x FactKind) Number() protoreflect.EnumNumber { // Deprecated: Use FactKind.Descriptor instead. func (FactKind) EnumDescriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{9} + return file_agent_agent_proto_rawDescGZIP(), []int{9} } type RequestMeta struct { @@ -608,7 +608,7 @@ type RequestMeta struct { func (x *RequestMeta) Reset() { *x = RequestMeta{} - mi := &file_agent_v1_agent_proto_msgTypes[0] + mi := &file_agent_agent_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -620,7 +620,7 @@ func (x *RequestMeta) String() string { func (*RequestMeta) ProtoMessage() {} func (x *RequestMeta) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[0] + mi := &file_agent_agent_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -633,7 +633,7 @@ func (x *RequestMeta) ProtoReflect() protoreflect.Message { // Deprecated: Use RequestMeta.ProtoReflect.Descriptor instead. func (*RequestMeta) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{0} + return file_agent_agent_proto_rawDescGZIP(), []int{0} } func (x *RequestMeta) GetProtocolVersion() string { @@ -731,7 +731,7 @@ type ResponseMeta struct { func (x *ResponseMeta) Reset() { *x = ResponseMeta{} - mi := &file_agent_v1_agent_proto_msgTypes[1] + mi := &file_agent_agent_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -743,7 +743,7 @@ func (x *ResponseMeta) String() string { func (*ResponseMeta) ProtoMessage() {} func (x *ResponseMeta) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[1] + mi := &file_agent_agent_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -756,7 +756,7 @@ func (x *ResponseMeta) ProtoReflect() protoreflect.Message { // Deprecated: Use ResponseMeta.ProtoReflect.Descriptor instead. func (*ResponseMeta) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{1} + return file_agent_agent_proto_rawDescGZIP(), []int{1} } func (x *ResponseMeta) GetProtocolVersion() string { @@ -831,7 +831,7 @@ func (x *ResponseMeta) GetSessionGeneration() uint64 { type Failure struct { state protoimpl.MessageState `protogen:"open.v1"` - Code FailureCode `protobuf:"varint,1,opt,name=code,proto3,enum=agent.v1.FailureCode" json:"code,omitempty"` + Code FailureCode `protobuf:"varint,1,opt,name=code,proto3,enum=agent.FailureCode" json:"code,omitempty"` Retryable bool `protobuf:"varint,2,opt,name=retryable,proto3" json:"retryable,omitempty"` Detail string `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"` Field string `protobuf:"bytes,4,opt,name=field,proto3" json:"field,omitempty"` @@ -841,7 +841,7 @@ type Failure struct { func (x *Failure) Reset() { *x = Failure{} - mi := &file_agent_v1_agent_proto_msgTypes[2] + mi := &file_agent_agent_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -853,7 +853,7 @@ func (x *Failure) String() string { func (*Failure) ProtoMessage() {} func (x *Failure) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[2] + mi := &file_agent_agent_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -866,7 +866,7 @@ func (x *Failure) ProtoReflect() protoreflect.Message { // Deprecated: Use Failure.ProtoReflect.Descriptor instead. func (*Failure) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{2} + return file_agent_agent_proto_rawDescGZIP(), []int{2} } func (x *Failure) GetCode() FailureCode { @@ -900,7 +900,7 @@ func (x *Failure) GetField() string { type OperationReceipt struct { state protoimpl.MessageState `protogen:"open.v1"` Meta *ResponseMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` - Result ResultCode `protobuf:"varint,2,opt,name=result,proto3,enum=agent.v1.ResultCode" json:"result,omitempty"` + Result ResultCode `protobuf:"varint,2,opt,name=result,proto3,enum=agent.ResultCode" json:"result,omitempty"` Failure *Failure `protobuf:"bytes,3,opt,name=failure,proto3" json:"failure,omitempty"` FactId string `protobuf:"bytes,4,opt,name=fact_id,json=factId,proto3" json:"fact_id,omitempty"` ContentSha256 string `protobuf:"bytes,5,opt,name=content_sha256,json=contentSha256,proto3" json:"content_sha256,omitempty"` @@ -911,7 +911,7 @@ type OperationReceipt struct { func (x *OperationReceipt) Reset() { *x = OperationReceipt{} - mi := &file_agent_v1_agent_proto_msgTypes[3] + mi := &file_agent_agent_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -923,7 +923,7 @@ func (x *OperationReceipt) String() string { func (*OperationReceipt) ProtoMessage() {} func (x *OperationReceipt) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[3] + mi := &file_agent_agent_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -936,7 +936,7 @@ func (x *OperationReceipt) ProtoReflect() protoreflect.Message { // Deprecated: Use OperationReceipt.ProtoReflect.Descriptor instead. func (*OperationReceipt) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{3} + return file_agent_agent_proto_rawDescGZIP(), []int{3} } func (x *OperationReceipt) GetMeta() *ResponseMeta { @@ -995,7 +995,7 @@ type AgentBinding struct { func (x *AgentBinding) Reset() { *x = AgentBinding{} - mi := &file_agent_v1_agent_proto_msgTypes[4] + mi := &file_agent_agent_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1007,7 +1007,7 @@ func (x *AgentBinding) String() string { func (*AgentBinding) ProtoMessage() {} func (x *AgentBinding) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[4] + mi := &file_agent_agent_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1020,7 +1020,7 @@ func (x *AgentBinding) ProtoReflect() protoreflect.Message { // Deprecated: Use AgentBinding.ProtoReflect.Descriptor instead. func (*AgentBinding) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{4} + return file_agent_agent_proto_rawDescGZIP(), []int{4} } func (x *AgentBinding) GetAgentId() string { @@ -1076,7 +1076,7 @@ type Capability struct { func (x *Capability) Reset() { *x = Capability{} - mi := &file_agent_v1_agent_proto_msgTypes[5] + mi := &file_agent_agent_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1088,7 +1088,7 @@ func (x *Capability) String() string { func (*Capability) ProtoMessage() {} func (x *Capability) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[5] + mi := &file_agent_agent_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1101,7 +1101,7 @@ func (x *Capability) ProtoReflect() protoreflect.Message { // Deprecated: Use Capability.ProtoReflect.Descriptor instead. func (*Capability) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{5} + return file_agent_agent_proto_rawDescGZIP(), []int{5} } func (x *Capability) GetName() string { @@ -1144,7 +1144,7 @@ type ResourceSample struct { func (x *ResourceSample) Reset() { *x = ResourceSample{} - mi := &file_agent_v1_agent_proto_msgTypes[6] + mi := &file_agent_agent_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1156,7 +1156,7 @@ func (x *ResourceSample) String() string { func (*ResourceSample) ProtoMessage() {} func (x *ResourceSample) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[6] + mi := &file_agent_agent_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1169,7 +1169,7 @@ func (x *ResourceSample) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceSample.ProtoReflect.Descriptor instead. func (*ResourceSample) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{6} + return file_agent_agent_proto_rawDescGZIP(), []int{6} } func (x *ResourceSample) GetObservedAtUnixMs() int64 { @@ -1266,7 +1266,7 @@ type AppliedConfig struct { func (x *AppliedConfig) Reset() { *x = AppliedConfig{} - mi := &file_agent_v1_agent_proto_msgTypes[7] + mi := &file_agent_agent_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1278,7 +1278,7 @@ func (x *AppliedConfig) String() string { func (*AppliedConfig) ProtoMessage() {} func (x *AppliedConfig) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[7] + mi := &file_agent_agent_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1291,7 +1291,7 @@ func (x *AppliedConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use AppliedConfig.ProtoReflect.Descriptor instead. func (*AppliedConfig) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{7} + return file_agent_agent_proto_rawDescGZIP(), []int{7} } func (x *AppliedConfig) GetKind() string { @@ -1337,7 +1337,7 @@ type AgentStatus struct { SoftwareVersion string `protobuf:"bytes,4,opt,name=software_version,json=softwareVersion,proto3" json:"software_version,omitempty"` ProtocolVersion string `protobuf:"bytes,5,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` AsteriskVersion string `protobuf:"bytes,6,opt,name=asterisk_version,json=asteriskVersion,proto3" json:"asterisk_version,omitempty"` - AdmissionState AdmissionState `protobuf:"varint,7,opt,name=admission_state,json=admissionState,proto3,enum=agent.v1.AdmissionState" json:"admission_state,omitempty"` + AdmissionState AdmissionState `protobuf:"varint,7,opt,name=admission_state,json=admissionState,proto3,enum=agent.AdmissionState" json:"admission_state,omitempty"` Capabilities []*Capability `protobuf:"bytes,8,rep,name=capabilities,proto3" json:"capabilities,omitempty"` Resources *ResourceSample `protobuf:"bytes,9,opt,name=resources,proto3" json:"resources,omitempty"` AppliedConfigs []*AppliedConfig `protobuf:"bytes,10,rep,name=applied_configs,json=appliedConfigs,proto3" json:"applied_configs,omitempty"` @@ -1350,7 +1350,7 @@ type AgentStatus struct { func (x *AgentStatus) Reset() { *x = AgentStatus{} - mi := &file_agent_v1_agent_proto_msgTypes[8] + mi := &file_agent_agent_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1362,7 +1362,7 @@ func (x *AgentStatus) String() string { func (*AgentStatus) ProtoMessage() {} func (x *AgentStatus) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[8] + mi := &file_agent_agent_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1375,7 +1375,7 @@ func (x *AgentStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use AgentStatus.ProtoReflect.Descriptor instead. func (*AgentStatus) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{8} + return file_agent_agent_proto_rawDescGZIP(), []int{8} } func (x *AgentStatus) GetAgentId() string { @@ -1481,7 +1481,7 @@ type Session struct { func (x *Session) Reset() { *x = Session{} - mi := &file_agent_v1_agent_proto_msgTypes[9] + mi := &file_agent_agent_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1493,7 +1493,7 @@ func (x *Session) String() string { func (*Session) ProtoMessage() {} func (x *Session) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[9] + mi := &file_agent_agent_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1506,7 +1506,7 @@ func (x *Session) ProtoReflect() protoreflect.Message { // Deprecated: Use Session.ProtoReflect.Descriptor instead. func (*Session) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{9} + return file_agent_agent_proto_rawDescGZIP(), []int{9} } func (x *Session) GetDispatcherEpoch() string { @@ -1549,7 +1549,7 @@ type ConfigReference struct { func (x *ConfigReference) Reset() { *x = ConfigReference{} - mi := &file_agent_v1_agent_proto_msgTypes[10] + mi := &file_agent_agent_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1561,7 +1561,7 @@ func (x *ConfigReference) String() string { func (*ConfigReference) ProtoMessage() {} func (x *ConfigReference) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[10] + mi := &file_agent_agent_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1574,7 +1574,7 @@ func (x *ConfigReference) ProtoReflect() protoreflect.Message { // Deprecated: Use ConfigReference.ProtoReflect.Descriptor instead. func (*ConfigReference) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{10} + return file_agent_agent_proto_rawDescGZIP(), []int{10} } func (x *ConfigReference) GetKind() string { @@ -1616,7 +1616,7 @@ type UploadPolicy struct { func (x *UploadPolicy) Reset() { *x = UploadPolicy{} - mi := &file_agent_v1_agent_proto_msgTypes[11] + mi := &file_agent_agent_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1628,7 +1628,7 @@ func (x *UploadPolicy) String() string { func (*UploadPolicy) ProtoMessage() {} func (x *UploadPolicy) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[11] + mi := &file_agent_agent_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1641,7 +1641,7 @@ func (x *UploadPolicy) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadPolicy.ProtoReflect.Descriptor instead. func (*UploadPolicy) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{11} + return file_agent_agent_proto_rawDescGZIP(), []int{11} } func (x *UploadPolicy) GetEnabled() bool { @@ -1684,7 +1684,7 @@ type ExecutionBinding struct { func (x *ExecutionBinding) Reset() { *x = ExecutionBinding{} - mi := &file_agent_v1_agent_proto_msgTypes[12] + mi := &file_agent_agent_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1696,7 +1696,7 @@ func (x *ExecutionBinding) String() string { func (*ExecutionBinding) ProtoMessage() {} func (x *ExecutionBinding) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[12] + mi := &file_agent_agent_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1709,7 +1709,7 @@ func (x *ExecutionBinding) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecutionBinding.ProtoReflect.Descriptor instead. func (*ExecutionBinding) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{12} + return file_agent_agent_proto_rawDescGZIP(), []int{12} } func (x *ExecutionBinding) GetTenantId() string { @@ -1791,7 +1791,7 @@ func (x *ExecutionBinding) GetCallerProfileId() string { type AssetDescriptor struct { state protoimpl.MessageState `protogen:"open.v1"` - Kind AssetKind `protobuf:"varint,1,opt,name=kind,proto3,enum=agent.v1.AssetKind" json:"kind,omitempty"` + Kind AssetKind `protobuf:"varint,1,opt,name=kind,proto3,enum=agent.AssetKind" json:"kind,omitempty"` AssetId string `protobuf:"bytes,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` CallId string `protobuf:"bytes,3,opt,name=call_id,json=callId,proto3" json:"call_id,omitempty"` ExecutionId string `protobuf:"bytes,4,opt,name=execution_id,json=executionId,proto3" json:"execution_id,omitempty"` @@ -1807,7 +1807,7 @@ type AssetDescriptor struct { func (x *AssetDescriptor) Reset() { *x = AssetDescriptor{} - mi := &file_agent_v1_agent_proto_msgTypes[13] + mi := &file_agent_agent_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1819,7 +1819,7 @@ func (x *AssetDescriptor) String() string { func (*AssetDescriptor) ProtoMessage() {} func (x *AssetDescriptor) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[13] + mi := &file_agent_agent_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1832,7 +1832,7 @@ func (x *AssetDescriptor) ProtoReflect() protoreflect.Message { // Deprecated: Use AssetDescriptor.ProtoReflect.Descriptor instead. func (*AssetDescriptor) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{13} + return file_agent_agent_proto_rawDescGZIP(), []int{13} } func (x *AssetDescriptor) GetKind() AssetKind { @@ -1915,7 +1915,7 @@ type Header struct { func (x *Header) Reset() { *x = Header{} - mi := &file_agent_v1_agent_proto_msgTypes[14] + mi := &file_agent_agent_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1927,7 +1927,7 @@ func (x *Header) String() string { func (*Header) ProtoMessage() {} func (x *Header) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[14] + mi := &file_agent_agent_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1940,7 +1940,7 @@ func (x *Header) ProtoReflect() protoreflect.Message { // Deprecated: Use Header.ProtoReflect.Descriptor instead. func (*Header) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{14} + return file_agent_agent_proto_rawDescGZIP(), []int{14} } func (x *Header) GetName() string { @@ -1967,7 +1967,7 @@ type GetAgentStatusRequest struct { func (x *GetAgentStatusRequest) Reset() { *x = GetAgentStatusRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[15] + mi := &file_agent_agent_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1979,7 +1979,7 @@ func (x *GetAgentStatusRequest) String() string { func (*GetAgentStatusRequest) ProtoMessage() {} func (x *GetAgentStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[15] + mi := &file_agent_agent_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1992,7 +1992,7 @@ func (x *GetAgentStatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetAgentStatusRequest.ProtoReflect.Descriptor instead. func (*GetAgentStatusRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{15} + return file_agent_agent_proto_rawDescGZIP(), []int{15} } func (x *GetAgentStatusRequest) GetMeta() *RequestMeta { @@ -2020,7 +2020,7 @@ type GetAgentStatusResponse struct { func (x *GetAgentStatusResponse) Reset() { *x = GetAgentStatusResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[16] + mi := &file_agent_agent_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2032,7 +2032,7 @@ func (x *GetAgentStatusResponse) String() string { func (*GetAgentStatusResponse) ProtoMessage() {} func (x *GetAgentStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[16] + mi := &file_agent_agent_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2045,7 +2045,7 @@ func (x *GetAgentStatusResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetAgentStatusResponse.ProtoReflect.Descriptor instead. func (*GetAgentStatusResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{16} + return file_agent_agent_proto_rawDescGZIP(), []int{16} } func (x *GetAgentStatusResponse) GetMeta() *ResponseMeta { @@ -2082,7 +2082,7 @@ type ActivateAgentRequest struct { func (x *ActivateAgentRequest) Reset() { *x = ActivateAgentRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[17] + mi := &file_agent_agent_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2094,7 +2094,7 @@ func (x *ActivateAgentRequest) String() string { func (*ActivateAgentRequest) ProtoMessage() {} func (x *ActivateAgentRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[17] + mi := &file_agent_agent_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2107,7 +2107,7 @@ func (x *ActivateAgentRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ActivateAgentRequest.ProtoReflect.Descriptor instead. func (*ActivateAgentRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{17} + return file_agent_agent_proto_rawDescGZIP(), []int{17} } func (x *ActivateAgentRequest) GetMeta() *RequestMeta { @@ -2148,7 +2148,7 @@ func (x *ActivateAgentRequest) GetSessionExpiresAtUnixMs() int64 { type ActivateAgentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Meta *ResponseMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` - State ActivationState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.ActivationState" json:"state,omitempty"` + State ActivationState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.ActivationState" json:"state,omitempty"` Session *Session `protobuf:"bytes,3,opt,name=session,proto3" json:"session,omitempty"` Failure *Failure `protobuf:"bytes,4,opt,name=failure,proto3" json:"failure,omitempty"` unknownFields protoimpl.UnknownFields @@ -2157,7 +2157,7 @@ type ActivateAgentResponse struct { func (x *ActivateAgentResponse) Reset() { *x = ActivateAgentResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[18] + mi := &file_agent_agent_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2169,7 +2169,7 @@ func (x *ActivateAgentResponse) String() string { func (*ActivateAgentResponse) ProtoMessage() {} func (x *ActivateAgentResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[18] + mi := &file_agent_agent_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2182,7 +2182,7 @@ func (x *ActivateAgentResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ActivateAgentResponse.ProtoReflect.Descriptor instead. func (*ActivateAgentResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{18} + return file_agent_agent_proto_rawDescGZIP(), []int{18} } func (x *ActivateAgentResponse) GetMeta() *ResponseMeta { @@ -2226,7 +2226,7 @@ type GetBootstrapRequest struct { func (x *GetBootstrapRequest) Reset() { *x = GetBootstrapRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[19] + mi := &file_agent_agent_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2238,7 +2238,7 @@ func (x *GetBootstrapRequest) String() string { func (*GetBootstrapRequest) ProtoMessage() {} func (x *GetBootstrapRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[19] + mi := &file_agent_agent_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2251,7 +2251,7 @@ func (x *GetBootstrapRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBootstrapRequest.ProtoReflect.Descriptor instead. func (*GetBootstrapRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{19} + return file_agent_agent_proto_rawDescGZIP(), []int{19} } func (x *GetBootstrapRequest) GetMeta() *RequestMeta { @@ -2292,7 +2292,7 @@ func (x *GetBootstrapRequest) GetSessionGeneration() uint64 { type GetBootstrapResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Meta *ResponseMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` - State ActivationState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.ActivationState" json:"state,omitempty"` + State ActivationState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.ActivationState" json:"state,omitempty"` RuntimeConfigs []*ConfigReference `protobuf:"bytes,3,rep,name=runtime_configs,json=runtimeConfigs,proto3" json:"runtime_configs,omitempty"` UploadPolicy *UploadPolicy `protobuf:"bytes,4,opt,name=upload_policy,json=uploadPolicy,proto3" json:"upload_policy,omitempty"` Failure *Failure `protobuf:"bytes,5,opt,name=failure,proto3" json:"failure,omitempty"` @@ -2302,7 +2302,7 @@ type GetBootstrapResponse struct { func (x *GetBootstrapResponse) Reset() { *x = GetBootstrapResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[20] + mi := &file_agent_agent_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2314,7 +2314,7 @@ func (x *GetBootstrapResponse) String() string { func (*GetBootstrapResponse) ProtoMessage() {} func (x *GetBootstrapResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[20] + mi := &file_agent_agent_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2327,7 +2327,7 @@ func (x *GetBootstrapResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBootstrapResponse.ProtoReflect.Descriptor instead. func (*GetBootstrapResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{20} + return file_agent_agent_proto_rawDescGZIP(), []int{20} } func (x *GetBootstrapResponse) GetMeta() *ResponseMeta { @@ -2369,7 +2369,7 @@ type SetAdmissionStateRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Meta *RequestMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` Target *AgentBinding `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` - State AdmissionState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.v1.AdmissionState" json:"state,omitempty"` + State AdmissionState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.AdmissionState" json:"state,omitempty"` BarrierId string `protobuf:"bytes,4,opt,name=barrier_id,json=barrierId,proto3" json:"barrier_id,omitempty"` ExpectedAdmissionGeneration uint64 `protobuf:"varint,5,opt,name=expected_admission_generation,json=expectedAdmissionGeneration,proto3" json:"expected_admission_generation,omitempty"` Reason string `protobuf:"bytes,6,opt,name=reason,proto3" json:"reason,omitempty"` @@ -2379,7 +2379,7 @@ type SetAdmissionStateRequest struct { func (x *SetAdmissionStateRequest) Reset() { *x = SetAdmissionStateRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[21] + mi := &file_agent_agent_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2391,7 +2391,7 @@ func (x *SetAdmissionStateRequest) String() string { func (*SetAdmissionStateRequest) ProtoMessage() {} func (x *SetAdmissionStateRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[21] + mi := &file_agent_agent_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2404,7 +2404,7 @@ func (x *SetAdmissionStateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SetAdmissionStateRequest.ProtoReflect.Descriptor instead. func (*SetAdmissionStateRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{21} + return file_agent_agent_proto_rawDescGZIP(), []int{21} } func (x *SetAdmissionStateRequest) GetMeta() *RequestMeta { @@ -2459,7 +2459,7 @@ type SetAdmissionStateResponse struct { func (x *SetAdmissionStateResponse) Reset() { *x = SetAdmissionStateResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[22] + mi := &file_agent_agent_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2471,7 +2471,7 @@ func (x *SetAdmissionStateResponse) String() string { func (*SetAdmissionStateResponse) ProtoMessage() {} func (x *SetAdmissionStateResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[22] + mi := &file_agent_agent_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2484,7 +2484,7 @@ func (x *SetAdmissionStateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SetAdmissionStateResponse.ProtoReflect.Descriptor instead. func (*SetAdmissionStateResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{22} + return file_agent_agent_proto_rawDescGZIP(), []int{22} } func (x *SetAdmissionStateResponse) GetReceipt() *OperationReceipt { @@ -2516,7 +2516,7 @@ type ExecuteRequest struct { func (x *ExecuteRequest) Reset() { *x = ExecuteRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[23] + mi := &file_agent_agent_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2528,7 +2528,7 @@ func (x *ExecuteRequest) String() string { func (*ExecuteRequest) ProtoMessage() {} func (x *ExecuteRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[23] + mi := &file_agent_agent_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2541,7 +2541,7 @@ func (x *ExecuteRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecuteRequest.ProtoReflect.Descriptor instead. func (*ExecuteRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{23} + return file_agent_agent_proto_rawDescGZIP(), []int{23} } func (x *ExecuteRequest) GetMeta() *RequestMeta { @@ -2596,14 +2596,14 @@ func (x *ExecuteRequest) GetPermitId() string { type ExecuteResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Receipt *OperationReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` - State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.ExecutionState" json:"state,omitempty"` + State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.ExecutionState" json:"state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ExecuteResponse) Reset() { *x = ExecuteResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[24] + mi := &file_agent_agent_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2615,7 +2615,7 @@ func (x *ExecuteResponse) String() string { func (*ExecuteResponse) ProtoMessage() {} func (x *ExecuteResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[24] + mi := &file_agent_agent_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2628,7 +2628,7 @@ func (x *ExecuteResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecuteResponse.ProtoReflect.Descriptor instead. func (*ExecuteResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{24} + return file_agent_agent_proto_rawDescGZIP(), []int{24} } func (x *ExecuteResponse) GetReceipt() *OperationReceipt { @@ -2667,7 +2667,7 @@ type ExecuteAuthorizedRequest struct { func (x *ExecuteAuthorizedRequest) Reset() { *x = ExecuteAuthorizedRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[25] + mi := &file_agent_agent_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2679,7 +2679,7 @@ func (x *ExecuteAuthorizedRequest) String() string { func (*ExecuteAuthorizedRequest) ProtoMessage() {} func (x *ExecuteAuthorizedRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[25] + mi := &file_agent_agent_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2692,7 +2692,7 @@ func (x *ExecuteAuthorizedRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecuteAuthorizedRequest.ProtoReflect.Descriptor instead. func (*ExecuteAuthorizedRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{25} + return file_agent_agent_proto_rawDescGZIP(), []int{25} } func (x *ExecuteAuthorizedRequest) GetSchemaVersion() string { @@ -2768,14 +2768,14 @@ func (x *ExecuteAuthorizedRequest) GetBoundSnapshotSha256() string { type ExecuteAuthorizedResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Receipt *OperationReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` - State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.ExecutionState" json:"state,omitempty"` + State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.ExecutionState" json:"state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ExecuteAuthorizedResponse) Reset() { *x = ExecuteAuthorizedResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[26] + mi := &file_agent_agent_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2787,7 +2787,7 @@ func (x *ExecuteAuthorizedResponse) String() string { func (*ExecuteAuthorizedResponse) ProtoMessage() {} func (x *ExecuteAuthorizedResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[26] + mi := &file_agent_agent_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2800,7 +2800,7 @@ func (x *ExecuteAuthorizedResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecuteAuthorizedResponse.ProtoReflect.Descriptor instead. func (*ExecuteAuthorizedResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{26} + return file_agent_agent_proto_rawDescGZIP(), []int{26} } func (x *ExecuteAuthorizedResponse) GetReceipt() *OperationReceipt { @@ -2831,7 +2831,7 @@ type GetExecutionPermitRequest struct { func (x *GetExecutionPermitRequest) Reset() { *x = GetExecutionPermitRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[27] + mi := &file_agent_agent_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2843,7 +2843,7 @@ func (x *GetExecutionPermitRequest) String() string { func (*GetExecutionPermitRequest) ProtoMessage() {} func (x *GetExecutionPermitRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[27] + mi := &file_agent_agent_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2856,7 +2856,7 @@ func (x *GetExecutionPermitRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetExecutionPermitRequest.ProtoReflect.Descriptor instead. func (*GetExecutionPermitRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{27} + return file_agent_agent_proto_rawDescGZIP(), []int{27} } func (x *GetExecutionPermitRequest) GetMeta() *RequestMeta { @@ -2917,7 +2917,7 @@ type ExecutionPermit struct { func (x *ExecutionPermit) Reset() { *x = ExecutionPermit{} - mi := &file_agent_v1_agent_proto_msgTypes[28] + mi := &file_agent_agent_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2929,7 +2929,7 @@ func (x *ExecutionPermit) String() string { func (*ExecutionPermit) ProtoMessage() {} func (x *ExecutionPermit) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[28] + mi := &file_agent_agent_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2942,7 +2942,7 @@ func (x *ExecutionPermit) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecutionPermit.ProtoReflect.Descriptor instead. func (*ExecutionPermit) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{28} + return file_agent_agent_proto_rawDescGZIP(), []int{28} } func (x *ExecutionPermit) GetPermitId() string { @@ -3011,7 +3011,7 @@ type GetExecutionPermitResponse struct { func (x *GetExecutionPermitResponse) Reset() { *x = GetExecutionPermitResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[29] + mi := &file_agent_agent_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3023,7 +3023,7 @@ func (x *GetExecutionPermitResponse) String() string { func (*GetExecutionPermitResponse) ProtoMessage() {} func (x *GetExecutionPermitResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[29] + mi := &file_agent_agent_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3036,7 +3036,7 @@ func (x *GetExecutionPermitResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetExecutionPermitResponse.ProtoReflect.Descriptor instead. func (*GetExecutionPermitResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{29} + return file_agent_agent_proto_rawDescGZIP(), []int{29} } func (x *GetExecutionPermitResponse) GetReceipt() *OperationReceipt { @@ -3057,8 +3057,8 @@ type ApplyTaskControlRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Meta *RequestMeta `protobuf:"bytes,1,opt,name=meta,proto3" json:"meta,omitempty"` Binding *ExecutionBinding `protobuf:"bytes,2,opt,name=binding,proto3" json:"binding,omitempty"` - Action ControlAction `protobuf:"varint,3,opt,name=action,proto3,enum=agent.v1.ControlAction" json:"action,omitempty"` - ActiveCallPolicy ActiveCallPolicy `protobuf:"varint,4,opt,name=active_call_policy,json=activeCallPolicy,proto3,enum=agent.v1.ActiveCallPolicy" json:"active_call_policy,omitempty"` + Action ControlAction `protobuf:"varint,3,opt,name=action,proto3,enum=agent.ControlAction" json:"action,omitempty"` + ActiveCallPolicy ActiveCallPolicy `protobuf:"varint,4,opt,name=active_call_policy,json=activeCallPolicy,proto3,enum=agent.ActiveCallPolicy" json:"active_call_policy,omitempty"` ExpectedTaskRevision int64 `protobuf:"varint,5,opt,name=expected_task_revision,json=expectedTaskRevision,proto3" json:"expected_task_revision,omitempty"` Reason string `protobuf:"bytes,6,opt,name=reason,proto3" json:"reason,omitempty"` unknownFields protoimpl.UnknownFields @@ -3067,7 +3067,7 @@ type ApplyTaskControlRequest struct { func (x *ApplyTaskControlRequest) Reset() { *x = ApplyTaskControlRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[30] + mi := &file_agent_agent_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3079,7 +3079,7 @@ func (x *ApplyTaskControlRequest) String() string { func (*ApplyTaskControlRequest) ProtoMessage() {} func (x *ApplyTaskControlRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[30] + mi := &file_agent_agent_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3092,7 +3092,7 @@ func (x *ApplyTaskControlRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ApplyTaskControlRequest.ProtoReflect.Descriptor instead. func (*ApplyTaskControlRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{30} + return file_agent_agent_proto_rawDescGZIP(), []int{30} } func (x *ApplyTaskControlRequest) GetMeta() *RequestMeta { @@ -3141,14 +3141,14 @@ type ApplyTaskControlResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Receipt *OperationReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` AppliedTaskRevision int64 `protobuf:"varint,2,opt,name=applied_task_revision,json=appliedTaskRevision,proto3" json:"applied_task_revision,omitempty"` - State ExecutionState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.v1.ExecutionState" json:"state,omitempty"` + State ExecutionState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.ExecutionState" json:"state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ApplyTaskControlResponse) Reset() { *x = ApplyTaskControlResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[31] + mi := &file_agent_agent_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3160,7 +3160,7 @@ func (x *ApplyTaskControlResponse) String() string { func (*ApplyTaskControlResponse) ProtoMessage() {} func (x *ApplyTaskControlResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[31] + mi := &file_agent_agent_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3173,7 +3173,7 @@ func (x *ApplyTaskControlResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ApplyTaskControlResponse.ProtoReflect.Descriptor instead. func (*ApplyTaskControlResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{31} + return file_agent_agent_proto_rawDescGZIP(), []int{31} } func (x *ApplyTaskControlResponse) GetReceipt() *OperationReceipt { @@ -3207,7 +3207,7 @@ type QueryExecutionRequest struct { func (x *QueryExecutionRequest) Reset() { *x = QueryExecutionRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[32] + mi := &file_agent_agent_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3219,7 +3219,7 @@ func (x *QueryExecutionRequest) String() string { func (*QueryExecutionRequest) ProtoMessage() {} func (x *QueryExecutionRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[32] + mi := &file_agent_agent_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3232,7 +3232,7 @@ func (x *QueryExecutionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryExecutionRequest.ProtoReflect.Descriptor instead. func (*QueryExecutionRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{32} + return file_agent_agent_proto_rawDescGZIP(), []int{32} } func (x *QueryExecutionRequest) GetMeta() *RequestMeta { @@ -3252,7 +3252,7 @@ func (x *QueryExecutionRequest) GetBinding() *ExecutionBinding { type ExecutionSnapshot struct { state protoimpl.MessageState `protogen:"open.v1"` Binding *ExecutionBinding `protobuf:"bytes,1,opt,name=binding,proto3" json:"binding,omitempty"` - State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.ExecutionState" json:"state,omitempty"` + State ExecutionState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.ExecutionState" json:"state,omitempty"` CallState string `protobuf:"bytes,3,opt,name=call_state,json=callState,proto3" json:"call_state,omitempty"` AttemptId string `protobuf:"bytes,4,opt,name=attempt_id,json=attemptId,proto3" json:"attempt_id,omitempty"` ReasonCode string `protobuf:"bytes,5,opt,name=reason_code,json=reasonCode,proto3" json:"reason_code,omitempty"` @@ -3265,7 +3265,7 @@ type ExecutionSnapshot struct { func (x *ExecutionSnapshot) Reset() { *x = ExecutionSnapshot{} - mi := &file_agent_v1_agent_proto_msgTypes[33] + mi := &file_agent_agent_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3277,7 +3277,7 @@ func (x *ExecutionSnapshot) String() string { func (*ExecutionSnapshot) ProtoMessage() {} func (x *ExecutionSnapshot) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[33] + mi := &file_agent_agent_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3290,7 +3290,7 @@ func (x *ExecutionSnapshot) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecutionSnapshot.ProtoReflect.Descriptor instead. func (*ExecutionSnapshot) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{33} + return file_agent_agent_proto_rawDescGZIP(), []int{33} } func (x *ExecutionSnapshot) GetBinding() *ExecutionBinding { @@ -3360,7 +3360,7 @@ type QueryExecutionResponse struct { func (x *QueryExecutionResponse) Reset() { *x = QueryExecutionResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[34] + mi := &file_agent_agent_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3372,7 +3372,7 @@ func (x *QueryExecutionResponse) String() string { func (*QueryExecutionResponse) ProtoMessage() {} func (x *QueryExecutionResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[34] + mi := &file_agent_agent_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3385,7 +3385,7 @@ func (x *QueryExecutionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryExecutionResponse.ProtoReflect.Descriptor instead. func (*QueryExecutionResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{34} + return file_agent_agent_proto_rawDescGZIP(), []int{34} } func (x *QueryExecutionResponse) GetMeta() *ResponseMeta { @@ -3414,7 +3414,7 @@ type ExecutionFact struct { FactId string `protobuf:"bytes,1,opt,name=fact_id,json=factId,proto3" json:"fact_id,omitempty"` ContentSha256 string `protobuf:"bytes,2,opt,name=content_sha256,json=contentSha256,proto3" json:"content_sha256,omitempty"` Binding *ExecutionBinding `protobuf:"bytes,3,opt,name=binding,proto3" json:"binding,omitempty"` - Kind FactKind `protobuf:"varint,4,opt,name=kind,proto3,enum=agent.v1.FactKind" json:"kind,omitempty"` + Kind FactKind `protobuf:"varint,4,opt,name=kind,proto3,enum=agent.FactKind" json:"kind,omitempty"` ObservedAtUnixMs int64 `protobuf:"varint,5,opt,name=observed_at_unix_ms,json=observedAtUnixMs,proto3" json:"observed_at_unix_ms,omitempty"` SourceBootId string `protobuf:"bytes,6,opt,name=source_boot_id,json=sourceBootId,proto3" json:"source_boot_id,omitempty"` SourceSequence uint64 `protobuf:"varint,7,opt,name=source_sequence,json=sourceSequence,proto3" json:"source_sequence,omitempty"` @@ -3425,7 +3425,7 @@ type ExecutionFact struct { func (x *ExecutionFact) Reset() { *x = ExecutionFact{} - mi := &file_agent_v1_agent_proto_msgTypes[35] + mi := &file_agent_agent_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3437,7 +3437,7 @@ func (x *ExecutionFact) String() string { func (*ExecutionFact) ProtoMessage() {} func (x *ExecutionFact) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[35] + mi := &file_agent_agent_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3450,7 +3450,7 @@ func (x *ExecutionFact) ProtoReflect() protoreflect.Message { // Deprecated: Use ExecutionFact.ProtoReflect.Descriptor instead. func (*ExecutionFact) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{35} + return file_agent_agent_proto_rawDescGZIP(), []int{35} } func (x *ExecutionFact) GetFactId() string { @@ -3519,7 +3519,7 @@ type ReportExecutionEventRequest struct { func (x *ReportExecutionEventRequest) Reset() { *x = ReportExecutionEventRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[36] + mi := &file_agent_agent_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3531,7 +3531,7 @@ func (x *ReportExecutionEventRequest) String() string { func (*ReportExecutionEventRequest) ProtoMessage() {} func (x *ReportExecutionEventRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[36] + mi := &file_agent_agent_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3544,7 +3544,7 @@ func (x *ReportExecutionEventRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ReportExecutionEventRequest.ProtoReflect.Descriptor instead. func (*ReportExecutionEventRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{36} + return file_agent_agent_proto_rawDescGZIP(), []int{36} } func (x *ReportExecutionEventRequest) GetMeta() *RequestMeta { @@ -3570,7 +3570,7 @@ type ReportExecutionEventResponse struct { func (x *ReportExecutionEventResponse) Reset() { *x = ReportExecutionEventResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[37] + mi := &file_agent_agent_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3582,7 +3582,7 @@ func (x *ReportExecutionEventResponse) String() string { func (*ReportExecutionEventResponse) ProtoMessage() {} func (x *ReportExecutionEventResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[37] + mi := &file_agent_agent_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3595,7 +3595,7 @@ func (x *ReportExecutionEventResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ReportExecutionEventResponse.ProtoReflect.Descriptor instead. func (*ReportExecutionEventResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{37} + return file_agent_agent_proto_rawDescGZIP(), []int{37} } func (x *ReportExecutionEventResponse) GetReceipt() *OperationReceipt { @@ -3617,7 +3617,7 @@ type RequestUploadRequest struct { func (x *RequestUploadRequest) Reset() { *x = RequestUploadRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[38] + mi := &file_agent_agent_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3629,7 +3629,7 @@ func (x *RequestUploadRequest) String() string { func (*RequestUploadRequest) ProtoMessage() {} func (x *RequestUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[38] + mi := &file_agent_agent_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3642,7 +3642,7 @@ func (x *RequestUploadRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RequestUploadRequest.ProtoReflect.Descriptor instead. func (*RequestUploadRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{38} + return file_agent_agent_proto_rawDescGZIP(), []int{38} } func (x *RequestUploadRequest) GetMeta() *RequestMeta { @@ -3688,7 +3688,7 @@ type UploadGrant struct { func (x *UploadGrant) Reset() { *x = UploadGrant{} - mi := &file_agent_v1_agent_proto_msgTypes[39] + mi := &file_agent_agent_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3700,7 +3700,7 @@ func (x *UploadGrant) String() string { func (*UploadGrant) ProtoMessage() {} func (x *UploadGrant) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[39] + mi := &file_agent_agent_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3713,7 +3713,7 @@ func (x *UploadGrant) ProtoReflect() protoreflect.Message { // Deprecated: Use UploadGrant.ProtoReflect.Descriptor instead. func (*UploadGrant) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{39} + return file_agent_agent_proto_rawDescGZIP(), []int{39} } func (x *UploadGrant) GetUploadId() string { @@ -3769,14 +3769,14 @@ type RequestUploadResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Receipt *OperationReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` Grant *UploadGrant `protobuf:"bytes,2,opt,name=grant,proto3" json:"grant,omitempty"` - State UploadState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.v1.UploadState" json:"state,omitempty"` + State UploadState `protobuf:"varint,3,opt,name=state,proto3,enum=agent.UploadState" json:"state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *RequestUploadResponse) Reset() { *x = RequestUploadResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[40] + mi := &file_agent_agent_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3788,7 +3788,7 @@ func (x *RequestUploadResponse) String() string { func (*RequestUploadResponse) ProtoMessage() {} func (x *RequestUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[40] + mi := &file_agent_agent_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3801,7 +3801,7 @@ func (x *RequestUploadResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RequestUploadResponse.ProtoReflect.Descriptor instead. func (*RequestUploadResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{40} + return file_agent_agent_proto_rawDescGZIP(), []int{40} } func (x *RequestUploadResponse) GetReceipt() *OperationReceipt { @@ -3839,7 +3839,7 @@ type CompleteUploadRequest struct { func (x *CompleteUploadRequest) Reset() { *x = CompleteUploadRequest{} - mi := &file_agent_v1_agent_proto_msgTypes[41] + mi := &file_agent_agent_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3851,7 +3851,7 @@ func (x *CompleteUploadRequest) String() string { func (*CompleteUploadRequest) ProtoMessage() {} func (x *CompleteUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[41] + mi := &file_agent_agent_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3864,7 +3864,7 @@ func (x *CompleteUploadRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CompleteUploadRequest.ProtoReflect.Descriptor instead. func (*CompleteUploadRequest) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{41} + return file_agent_agent_proto_rawDescGZIP(), []int{41} } func (x *CompleteUploadRequest) GetMeta() *RequestMeta { @@ -3912,14 +3912,14 @@ func (x *CompleteUploadRequest) GetUploadedChecksumSha256() string { type CompleteUploadResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Receipt *OperationReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` - State UploadState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.v1.UploadState" json:"state,omitempty"` + State UploadState `protobuf:"varint,2,opt,name=state,proto3,enum=agent.UploadState" json:"state,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *CompleteUploadResponse) Reset() { *x = CompleteUploadResponse{} - mi := &file_agent_v1_agent_proto_msgTypes[42] + mi := &file_agent_agent_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3931,7 +3931,7 @@ func (x *CompleteUploadResponse) String() string { func (*CompleteUploadResponse) ProtoMessage() {} func (x *CompleteUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_agent_v1_agent_proto_msgTypes[42] + mi := &file_agent_agent_proto_msgTypes[42] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3944,7 +3944,7 @@ func (x *CompleteUploadResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CompleteUploadResponse.ProtoReflect.Descriptor instead. func (*CompleteUploadResponse) Descriptor() ([]byte, []int) { - return file_agent_v1_agent_proto_rawDescGZIP(), []int{42} + return file_agent_agent_proto_rawDescGZIP(), []int{42} } func (x *CompleteUploadResponse) GetReceipt() *OperationReceipt { @@ -3961,11 +3961,11 @@ func (x *CompleteUploadResponse) GetState() UploadState { return UploadState_UPLOAD_STATE_UNSPECIFIED } -var File_agent_v1_agent_proto protoreflect.FileDescriptor +var File_agent_agent_proto protoreflect.FileDescriptor -const file_agent_v1_agent_proto_rawDesc = "" + +const file_agent_agent_proto_rawDesc = "" + "\n" + - "\x14agent/v1/agent.proto\x12\bagent.v1\"\x8f\x03\n" + + "\x11agent/agent.proto\x12\x05agent\"\x8f\x03\n" + "\vRequestMeta\x12)\n" + "\x10protocol_version\x18\x01 \x01(\tR\x0fprotocolVersion\x12\x1d\n" + "\n" + @@ -3992,16 +3992,16 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\acell_id\x18\b \x01(\tR\x06cellId\x12\x17\n" + "\aboot_id\x18\t \x01(\tR\x06bootId\x12-\n" + "\x12session_generation\x18\n" + - " \x01(\x04R\x11sessionGeneration\"\x80\x01\n" + - "\aFailure\x12)\n" + - "\x04code\x18\x01 \x01(\x0e2\x15.agent.v1.FailureCodeR\x04code\x12\x1c\n" + + " \x01(\x04R\x11sessionGeneration\"}\n" + + "\aFailure\x12&\n" + + "\x04code\x18\x01 \x01(\x0e2\x12.agent.FailureCodeR\x04code\x12\x1c\n" + "\tretryable\x18\x02 \x01(\bR\tretryable\x12\x16\n" + "\x06detail\x18\x03 \x01(\tR\x06detail\x12\x14\n" + - "\x05field\x18\x04 \x01(\tR\x05field\"\x88\x02\n" + - "\x10OperationReceipt\x12*\n" + - "\x04meta\x18\x01 \x01(\v2\x16.agent.v1.ResponseMetaR\x04meta\x12,\n" + - "\x06result\x18\x02 \x01(\x0e2\x14.agent.v1.ResultCodeR\x06result\x12+\n" + - "\afailure\x18\x03 \x01(\v2\x11.agent.v1.FailureR\afailure\x12\x17\n" + + "\x05field\x18\x04 \x01(\tR\x05field\"\xff\x01\n" + + "\x10OperationReceipt\x12'\n" + + "\x04meta\x18\x01 \x01(\v2\x13.agent.ResponseMetaR\x04meta\x12)\n" + + "\x06result\x18\x02 \x01(\x0e2\x11.agent.ResultCodeR\x06result\x12(\n" + + "\afailure\x18\x03 \x01(\v2\x0e.agent.FailureR\afailure\x12\x17\n" + "\afact_id\x18\x04 \x01(\tR\x06factId\x12%\n" + "\x0econtent_sha256\x18\x05 \x01(\tR\rcontentSha256\x12-\n" + "\x13accepted_at_unix_ms\x18\x06 \x01(\x03R\x10acceptedAtUnixMs\"\xe7\x01\n" + @@ -4036,19 +4036,19 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\brevision\x18\x02 \x01(\tR\brevision\x12#\n" + "\rconfig_sha256\x18\x03 \x01(\tR\fconfigSha256\x12\x14\n" + "\x05state\x18\x04 \x01(\tR\x05state\x12-\n" + - "\x13observed_at_unix_ms\x18\x05 \x01(\x03R\x10observedAtUnixMs\"\xcd\x04\n" + + "\x13observed_at_unix_ms\x18\x05 \x01(\x03R\x10observedAtUnixMs\"\xc1\x04\n" + "\vAgentStatus\x12\x19\n" + "\bagent_id\x18\x01 \x01(\tR\aagentId\x12\x17\n" + "\acell_id\x18\x02 \x01(\tR\x06cellId\x12\x17\n" + "\aboot_id\x18\x03 \x01(\tR\x06bootId\x12)\n" + "\x10software_version\x18\x04 \x01(\tR\x0fsoftwareVersion\x12)\n" + "\x10protocol_version\x18\x05 \x01(\tR\x0fprotocolVersion\x12)\n" + - "\x10asterisk_version\x18\x06 \x01(\tR\x0fasteriskVersion\x12A\n" + - "\x0fadmission_state\x18\a \x01(\x0e2\x18.agent.v1.AdmissionStateR\x0eadmissionState\x128\n" + - "\fcapabilities\x18\b \x03(\v2\x14.agent.v1.CapabilityR\fcapabilities\x126\n" + - "\tresources\x18\t \x01(\v2\x18.agent.v1.ResourceSampleR\tresources\x12@\n" + + "\x10asterisk_version\x18\x06 \x01(\tR\x0fasteriskVersion\x12>\n" + + "\x0fadmission_state\x18\a \x01(\x0e2\x15.agent.AdmissionStateR\x0eadmissionState\x125\n" + + "\fcapabilities\x18\b \x03(\v2\x11.agent.CapabilityR\fcapabilities\x123\n" + + "\tresources\x18\t \x01(\v2\x15.agent.ResourceSampleR\tresources\x12=\n" + "\x0fapplied_configs\x18\n" + - " \x03(\v2\x17.agent.v1.AppliedConfigR\x0eappliedConfigs\x12-\n" + + " \x03(\v2\x14.agent.AppliedConfigR\x0eappliedConfigs\x12-\n" + "\x12mtls_authenticated\x18\v \x01(\bR\x11mtlsAuthenticated\x12%\n" + "\x0esession_active\x18\f \x01(\bR\rsessionActive\x12#\n" + "\rstatus_reason\x18\r \x01(\tR\fstatusReason\"\xbf\x01\n" + @@ -4081,9 +4081,9 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\x10agent_version_id\x18\t \x01(\tR\x0eagentVersionId\x12&\n" + "\x0froute_policy_id\x18\n" + " \x01(\tR\rroutePolicyId\x12*\n" + - "\x11caller_profile_id\x18\v \x01(\tR\x0fcallerProfileId\"\xd4\x02\n" + - "\x0fAssetDescriptor\x12'\n" + - "\x04kind\x18\x01 \x01(\x0e2\x13.agent.v1.AssetKindR\x04kind\x12\x19\n" + + "\x11caller_profile_id\x18\v \x01(\tR\x0fcallerProfileId\"\xd1\x02\n" + + "\x0fAssetDescriptor\x12$\n" + + "\x04kind\x18\x01 \x01(\x0e2\x10.agent.AssetKindR\x04kind\x12\x19\n" + "\basset_id\x18\x02 \x01(\tR\aassetId\x12\x17\n" + "\acall_id\x18\x03 \x01(\tR\x06callId\x12!\n" + "\fexecution_id\x18\x04 \x01(\tR\vexecutionId\x12\x16\n" + @@ -4098,63 +4098,63 @@ const file_agent_v1_agent_proto_rawDesc = "" + "durationMs\"2\n" + "\x06Header\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value\"r\n" + - "\x15GetAgentStatusRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x12.\n" + - "\x06target\x18\x02 \x01(\v2\x16.agent.v1.AgentBindingR\x06target\"\xa0\x01\n" + - "\x16GetAgentStatusResponse\x12*\n" + - "\x04meta\x18\x01 \x01(\v2\x16.agent.v1.ResponseMetaR\x04meta\x12-\n" + - "\x06status\x18\x02 \x01(\v2\x15.agent.v1.AgentStatusR\x06status\x12+\n" + - "\afailure\x18\x03 \x01(\v2\x11.agent.v1.FailureR\afailure\"\x8c\x02\n" + - "\x14ActivateAgentRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x120\n" + - "\abinding\x18\x02 \x01(\v2\x16.agent.v1.AgentBindingR\abinding\x126\n" + + "\x05value\x18\x02 \x01(\tR\x05value\"l\n" + + "\x15GetAgentStatusRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x12+\n" + + "\x06target\x18\x02 \x01(\v2\x13.agent.AgentBindingR\x06target\"\x97\x01\n" + + "\x16GetAgentStatusResponse\x12'\n" + + "\x04meta\x18\x01 \x01(\v2\x13.agent.ResponseMetaR\x04meta\x12*\n" + + "\x06status\x18\x02 \x01(\v2\x12.agent.AgentStatusR\x06status\x12(\n" + + "\afailure\x18\x03 \x01(\v2\x0e.agent.FailureR\afailure\"\x86\x02\n" + + "\x14ActivateAgentRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x12-\n" + + "\abinding\x18\x02 \x01(\v2\x13.agent.AgentBindingR\abinding\x126\n" + "\x17activation_operation_id\x18\x03 \x01(\tR\x15activationOperationId\x12#\n" + "\rsession_nonce\x18\x04 \x01(\fR\fsessionNonce\x12:\n" + - "\x1asession_expires_at_unix_ms\x18\x05 \x01(\x03R\x16sessionExpiresAtUnixMs\"\xce\x01\n" + - "\x15ActivateAgentResponse\x12*\n" + - "\x04meta\x18\x01 \x01(\v2\x16.agent.v1.ResponseMetaR\x04meta\x12/\n" + - "\x05state\x18\x02 \x01(\x0e2\x19.agent.v1.ActivationStateR\x05state\x12+\n" + - "\asession\x18\x03 \x01(\v2\x11.agent.v1.SessionR\asession\x12+\n" + - "\afailure\x18\x04 \x01(\v2\x11.agent.v1.FailureR\afailure\"\xbc\x01\n" + - "\x13GetBootstrapRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x12\x19\n" + + "\x1asession_expires_at_unix_ms\x18\x05 \x01(\x03R\x16sessionExpiresAtUnixMs\"\xc2\x01\n" + + "\x15ActivateAgentResponse\x12'\n" + + "\x04meta\x18\x01 \x01(\v2\x13.agent.ResponseMetaR\x04meta\x12,\n" + + "\x05state\x18\x02 \x01(\x0e2\x16.agent.ActivationStateR\x05state\x12(\n" + + "\asession\x18\x03 \x01(\v2\x0e.agent.SessionR\asession\x12(\n" + + "\afailure\x18\x04 \x01(\v2\x0e.agent.FailureR\afailure\"\xb9\x01\n" + + "\x13GetBootstrapRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x12\x19\n" + "\bagent_id\x18\x02 \x01(\tR\aagentId\x12\x17\n" + "\acell_id\x18\x03 \x01(\tR\x06cellId\x12\x17\n" + "\aboot_id\x18\x04 \x01(\tR\x06bootId\x12-\n" + - "\x12session_generation\x18\x05 \x01(\x04R\x11sessionGeneration\"\xa1\x02\n" + - "\x14GetBootstrapResponse\x12*\n" + - "\x04meta\x18\x01 \x01(\v2\x16.agent.v1.ResponseMetaR\x04meta\x12/\n" + - "\x05state\x18\x02 \x01(\x0e2\x19.agent.v1.ActivationStateR\x05state\x12B\n" + - "\x0fruntime_configs\x18\x03 \x03(\v2\x19.agent.v1.ConfigReferenceR\x0eruntimeConfigs\x12;\n" + - "\rupload_policy\x18\x04 \x01(\v2\x16.agent.v1.UploadPolicyR\fuploadPolicy\x12+\n" + - "\afailure\x18\x05 \x01(\v2\x11.agent.v1.FailureR\afailure\"\xa0\x02\n" + - "\x18SetAdmissionStateRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x12.\n" + - "\x06target\x18\x02 \x01(\v2\x16.agent.v1.AgentBindingR\x06target\x12.\n" + - "\x05state\x18\x03 \x01(\x0e2\x18.agent.v1.AdmissionStateR\x05state\x12\x1d\n" + + "\x12session_generation\x18\x05 \x01(\x04R\x11sessionGeneration\"\x92\x02\n" + + "\x14GetBootstrapResponse\x12'\n" + + "\x04meta\x18\x01 \x01(\v2\x13.agent.ResponseMetaR\x04meta\x12,\n" + + "\x05state\x18\x02 \x01(\x0e2\x16.agent.ActivationStateR\x05state\x12?\n" + + "\x0fruntime_configs\x18\x03 \x03(\v2\x16.agent.ConfigReferenceR\x0eruntimeConfigs\x128\n" + + "\rupload_policy\x18\x04 \x01(\v2\x13.agent.UploadPolicyR\fuploadPolicy\x12(\n" + + "\afailure\x18\x05 \x01(\v2\x0e.agent.FailureR\afailure\"\x97\x02\n" + + "\x18SetAdmissionStateRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x12+\n" + + "\x06target\x18\x02 \x01(\v2\x13.agent.AgentBindingR\x06target\x12+\n" + + "\x05state\x18\x03 \x01(\x0e2\x15.agent.AdmissionStateR\x05state\x12\x1d\n" + "\n" + "barrier_id\x18\x04 \x01(\tR\tbarrierId\x12B\n" + "\x1dexpected_admission_generation\x18\x05 \x01(\x04R\x1bexpectedAdmissionGeneration\x12\x16\n" + - "\x06reason\x18\x06 \x01(\tR\x06reason\"\x93\x01\n" + - "\x19SetAdmissionStateResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x12@\n" + - "\x1capplied_admission_generation\x18\x02 \x01(\x04R\x1aappliedAdmissionGeneration\"\xca\x02\n" + - "\x0eExecuteRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12*\n" + + "\x06reason\x18\x06 \x01(\tR\x06reason\"\x90\x01\n" + + "\x19SetAdmissionStateResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12@\n" + + "\x1capplied_admission_generation\x18\x02 \x01(\x04R\x1aappliedAdmissionGeneration\"\xc4\x02\n" + + "\x0eExecuteRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12*\n" + "\x11call_execute_json\x18\x03 \x01(\fR\x0fcallExecuteJson\x12#\n" + "\rconfig_sha256\x18\x04 \x01(\tR\fconfigSha256\x121\n" + "\x14admission_generation\x18\x05 \x01(\x04R\x13admissionGeneration\x126\n" + "\x17resource_reservation_id\x18\x06 \x01(\tR\x15resourceReservationId\x12\x1b\n" + - "\tpermit_id\x18\a \x01(\tR\bpermitId\"w\n" + - "\x0fExecuteResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x12.\n" + - "\x05state\x18\x02 \x01(\x0e2\x18.agent.v1.ExecutionStateR\x05state\"\xbf\x03\n" + + "\tpermit_id\x18\a \x01(\tR\bpermitId\"q\n" + + "\x0fExecuteResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12+\n" + + "\x05state\x18\x02 \x01(\x0e2\x15.agent.ExecutionStateR\x05state\"\xb9\x03\n" + "\x18ExecuteAuthorizedRequest\x12%\n" + - "\x0eschema_version\x18\x01 \x01(\tR\rschemaVersion\x12)\n" + - "\x04meta\x18\x02 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x03 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12*\n" + + "\x0eschema_version\x18\x01 \x01(\tR\rschemaVersion\x12&\n" + + "\x04meta\x18\x02 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x03 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12*\n" + "\x11selected_trunk_id\x18\x04 \x01(\tR\x0fselectedTrunkId\x12\x1b\n" + "\tcaller_id\x18\x05 \x01(\tR\bcallerId\x12\x16\n" + "\x06callee\x18\x06 \x01(\tR\x06callee\x12&\n" + @@ -4162,13 +4162,13 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\x14max_call_duration_ms\x18\b \x01(\x03R\x11maxCallDurationMs\x12-\n" + "\x13dial_before_unix_ms\x18\t \x01(\x03R\x10dialBeforeUnixMs\x122\n" + "\x15bound_snapshot_sha256\x18\n" + - " \x01(\tR\x13boundSnapshotSha256\"\x81\x01\n" + - "\x19ExecuteAuthorizedResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x12.\n" + - "\x05state\x18\x02 \x01(\x0e2\x18.agent.v1.ExecutionStateR\x05state\"\xc2\x02\n" + - "\x19GetExecutionPermitRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x126\n" + + " \x01(\tR\x13boundSnapshotSha256\"{\n" + + "\x19ExecuteAuthorizedResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12+\n" + + "\x05state\x18\x02 \x01(\x0e2\x15.agent.ExecutionStateR\x05state\"\xbc\x02\n" + + "\x19GetExecutionPermitRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x126\n" + "\x17resource_reservation_id\x18\x03 \x01(\tR\x15resourceReservationId\x124\n" + "\x16expected_task_revision\x18\x04 \x01(\x03R\x14expectedTaskRevision\x121\n" + "\x14admission_generation\x18\x05 \x01(\x04R\x13admissionGeneration\x12#\n" + @@ -4181,27 +4181,27 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\x10dispatcher_epoch\x18\x05 \x01(\tR\x0fdispatcherEpoch\x12-\n" + "\x12session_generation\x18\x06 \x01(\x04R\x11sessionGeneration\x12#\n" + "\rfencing_token\x18\a \x01(\tR\ffencingToken\x12#\n" + - "\rconfig_sha256\x18\b \x01(\tR\fconfigSha256\"\x85\x01\n" + - "\x1aGetExecutionPermitResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x121\n" + - "\x06permit\x18\x02 \x01(\v2\x19.agent.v1.ExecutionPermitR\x06permit\"\xc3\x02\n" + - "\x17ApplyTaskControlRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12/\n" + - "\x06action\x18\x03 \x01(\x0e2\x17.agent.v1.ControlActionR\x06action\x12H\n" + - "\x12active_call_policy\x18\x04 \x01(\x0e2\x1a.agent.v1.ActiveCallPolicyR\x10activeCallPolicy\x124\n" + + "\rconfig_sha256\x18\b \x01(\tR\fconfigSha256\"\x7f\n" + + "\x1aGetExecutionPermitResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12.\n" + + "\x06permit\x18\x02 \x01(\v2\x16.agent.ExecutionPermitR\x06permit\"\xb7\x02\n" + + "\x17ApplyTaskControlRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12,\n" + + "\x06action\x18\x03 \x01(\x0e2\x14.agent.ControlActionR\x06action\x12E\n" + + "\x12active_call_policy\x18\x04 \x01(\x0e2\x17.agent.ActiveCallPolicyR\x10activeCallPolicy\x124\n" + "\x16expected_task_revision\x18\x05 \x01(\x03R\x14expectedTaskRevision\x12\x16\n" + - "\x06reason\x18\x06 \x01(\tR\x06reason\"\xb4\x01\n" + - "\x18ApplyTaskControlResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x122\n" + - "\x15applied_task_revision\x18\x02 \x01(\x03R\x13appliedTaskRevision\x12.\n" + - "\x05state\x18\x03 \x01(\x0e2\x18.agent.v1.ExecutionStateR\x05state\"x\n" + - "\x15QueryExecutionRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\"\xd4\x02\n" + - "\x11ExecutionSnapshot\x124\n" + - "\abinding\x18\x01 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12.\n" + - "\x05state\x18\x02 \x01(\x0e2\x18.agent.v1.ExecutionStateR\x05state\x12\x1d\n" + + "\x06reason\x18\x06 \x01(\tR\x06reason\"\xae\x01\n" + + "\x18ApplyTaskControlResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x122\n" + + "\x15applied_task_revision\x18\x02 \x01(\x03R\x13appliedTaskRevision\x12+\n" + + "\x05state\x18\x03 \x01(\x0e2\x15.agent.ExecutionStateR\x05state\"r\n" + + "\x15QueryExecutionRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\"\xcb\x02\n" + + "\x11ExecutionSnapshot\x121\n" + + "\abinding\x18\x01 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12+\n" + + "\x05state\x18\x02 \x01(\x0e2\x15.agent.ExecutionStateR\x05state\x12\x1d\n" + "\n" + "call_state\x18\x03 \x01(\tR\tcallState\x12\x1d\n" + "\n" + @@ -4209,55 +4209,55 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\vreason_code\x18\x05 \x01(\tR\n" + "reasonCode\x12-\n" + "\x13observed_at_unix_ms\x18\x06 \x01(\x03R\x10observedAtUnixMs\x12\x18\n" + - "\aunknown\x18\a \x01(\bR\aunknown\x121\n" + - "\x06assets\x18\b \x03(\v2\x19.agent.v1.AssetDescriptorR\x06assets\"\xaa\x01\n" + - "\x16QueryExecutionResponse\x12*\n" + - "\x04meta\x18\x01 \x01(\v2\x16.agent.v1.ResponseMetaR\x04meta\x127\n" + - "\bsnapshot\x18\x02 \x01(\v2\x1b.agent.v1.ExecutionSnapshotR\bsnapshot\x12+\n" + - "\afailure\x18\x03 \x01(\v2\x11.agent.v1.FailureR\afailure\"\xce\x02\n" + + "\aunknown\x18\a \x01(\bR\aunknown\x12.\n" + + "\x06assets\x18\b \x03(\v2\x16.agent.AssetDescriptorR\x06assets\"\xa1\x01\n" + + "\x16QueryExecutionResponse\x12'\n" + + "\x04meta\x18\x01 \x01(\v2\x13.agent.ResponseMetaR\x04meta\x124\n" + + "\bsnapshot\x18\x02 \x01(\v2\x18.agent.ExecutionSnapshotR\bsnapshot\x12(\n" + + "\afailure\x18\x03 \x01(\v2\x0e.agent.FailureR\afailure\"\xc8\x02\n" + "\rExecutionFact\x12\x17\n" + "\afact_id\x18\x01 \x01(\tR\x06factId\x12%\n" + - "\x0econtent_sha256\x18\x02 \x01(\tR\rcontentSha256\x124\n" + - "\abinding\x18\x03 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12&\n" + - "\x04kind\x18\x04 \x01(\x0e2\x12.agent.v1.FactKindR\x04kind\x12-\n" + + "\x0econtent_sha256\x18\x02 \x01(\tR\rcontentSha256\x121\n" + + "\abinding\x18\x03 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12#\n" + + "\x04kind\x18\x04 \x01(\x0e2\x0f.agent.FactKindR\x04kind\x12-\n" + "\x13observed_at_unix_ms\x18\x05 \x01(\x03R\x10observedAtUnixMs\x12$\n" + "\x0esource_boot_id\x18\x06 \x01(\tR\fsourceBootId\x12'\n" + "\x0fsource_sequence\x18\a \x01(\x04R\x0esourceSequence\x12!\n" + - "\fpayload_json\x18\b \x01(\fR\vpayloadJson\"u\n" + - "\x1bReportExecutionEventRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x12+\n" + - "\x04fact\x18\x02 \x01(\v2\x17.agent.v1.ExecutionFactR\x04fact\"T\n" + - "\x1cReportExecutionEventResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\"\xc5\x01\n" + - "\x14RequestUploadRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12/\n" + - "\x05asset\x18\x03 \x01(\v2\x19.agent.v1.AssetDescriptorR\x05asset\x12\x1b\n" + - "\tupload_id\x18\x04 \x01(\tR\buploadId\"\x98\x02\n" + + "\fpayload_json\x18\b \x01(\fR\vpayloadJson\"o\n" + + "\x1bReportExecutionEventRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x12(\n" + + "\x04fact\x18\x02 \x01(\v2\x14.agent.ExecutionFactR\x04fact\"Q\n" + + "\x1cReportExecutionEventResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\"\xbc\x01\n" + + "\x14RequestUploadRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12,\n" + + "\x05asset\x18\x03 \x01(\v2\x16.agent.AssetDescriptorR\x05asset\x12\x1b\n" + + "\tupload_id\x18\x04 \x01(\tR\buploadId\"\x95\x02\n" + "\vUploadGrant\x12\x1b\n" + "\tupload_id\x18\x01 \x01(\tR\buploadId\x12\x1d\n" + "\n" + - "target_url\x18\x02 \x01(\tR\ttargetUrl\x12*\n" + - "\aheaders\x18\x03 \x03(\v2\x10.agent.v1.HeaderR\aheaders\x12+\n" + + "target_url\x18\x02 \x01(\tR\ttargetUrl\x12'\n" + + "\aheaders\x18\x03 \x03(\v2\r.agent.HeaderR\aheaders\x12+\n" + "\x12expires_at_unix_ms\x18\x04 \x01(\x03R\x0fexpiresAtUnixMs\x12\x1d\n" + "\n" + "object_key\x18\x05 \x01(\tR\tobjectKey\x128\n" + "\x18required_checksum_sha256\x18\x06 \x01(\tR\x16requiredChecksumSha256\x12\x1b\n" + - "\tmax_bytes\x18\a \x01(\x03R\bmaxBytes\"\xa7\x01\n" + - "\x15RequestUploadResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x12+\n" + - "\x05grant\x18\x02 \x01(\v2\x15.agent.v1.UploadGrantR\x05grant\x12+\n" + - "\x05state\x18\x03 \x01(\x0e2\x15.agent.v1.UploadStateR\x05state\"\xb0\x02\n" + - "\x15CompleteUploadRequest\x12)\n" + - "\x04meta\x18\x01 \x01(\v2\x15.agent.v1.RequestMetaR\x04meta\x124\n" + - "\abinding\x18\x02 \x01(\v2\x1a.agent.v1.ExecutionBindingR\abinding\x12/\n" + - "\x05asset\x18\x03 \x01(\v2\x19.agent.v1.AssetDescriptorR\x05asset\x12\x1b\n" + + "\tmax_bytes\x18\a \x01(\x03R\bmaxBytes\"\x9e\x01\n" + + "\x15RequestUploadResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12(\n" + + "\x05grant\x18\x02 \x01(\v2\x12.agent.UploadGrantR\x05grant\x12(\n" + + "\x05state\x18\x03 \x01(\x0e2\x12.agent.UploadStateR\x05state\"\xa7\x02\n" + + "\x15CompleteUploadRequest\x12&\n" + + "\x04meta\x18\x01 \x01(\v2\x12.agent.RequestMetaR\x04meta\x121\n" + + "\abinding\x18\x02 \x01(\v2\x17.agent.ExecutionBindingR\abinding\x12,\n" + + "\x05asset\x18\x03 \x01(\v2\x16.agent.AssetDescriptorR\x05asset\x12\x1b\n" + "\tupload_id\x18\x04 \x01(\tR\buploadId\x12.\n" + "\x13uploaded_size_bytes\x18\x05 \x01(\x03R\x11uploadedSizeBytes\x128\n" + - "\x18uploaded_checksum_sha256\x18\x06 \x01(\tR\x16uploadedChecksumSha256\"\x89\x01\n" + - "\x16CompleteUploadResponse\x124\n" + - "\areceipt\x18\x01 \x01(\v2\x1a.agent.v1.OperationReceiptR\areceipt\x12+\n" + - "\x05state\x18\x02 \x01(\x0e2\x15.agent.v1.UploadStateR\x05stateJ\x04\b\x03\x10\x04R\x06oss_id*\xa9\x01\n" + + "\x18uploaded_checksum_sha256\x18\x06 \x01(\tR\x16uploadedChecksumSha256\"\x83\x01\n" + + "\x16CompleteUploadResponse\x121\n" + + "\areceipt\x18\x01 \x01(\v2\x17.agent.OperationReceiptR\areceipt\x12(\n" + + "\x05state\x18\x02 \x01(\x0e2\x12.agent.UploadStateR\x05stateJ\x04\b\x03\x10\x04R\x06oss_id*\xa9\x01\n" + "\n" + "ResultCode\x12\x1b\n" + "\x17RESULT_CODE_UNSPECIFIED\x10\x00\x12\x18\n" + @@ -4325,188 +4325,188 @@ const file_agent_v1_agent_proto_rawDesc = "" + "\x1cFACT_KIND_TRANSCRIPT_UPDATED\x10\x04\x12\x1f\n" + "\x1bFACT_KIND_TRANSCRIPT_FAILED\x10\x05\x12\x1d\n" + "\x19FACT_KIND_CONTACT_OPT_OUT\x10\x06\x12 \n" + - "\x1cFACT_KIND_RECORDING_PROGRESS\x10\a2\xa6\b\n" + - "\x13AgentControlService\x12S\n" + - "\x0eGetAgentStatus\x12\x1f.agent.v1.GetAgentStatusRequest\x1a .agent.v1.GetAgentStatusResponse\x12P\n" + - "\rActivateAgent\x12\x1e.agent.v1.ActivateAgentRequest\x1a\x1f.agent.v1.ActivateAgentResponse\x12M\n" + - "\fGetBootstrap\x12\x1d.agent.v1.GetBootstrapRequest\x1a\x1e.agent.v1.GetBootstrapResponse\x12\\\n" + - "\x11SetAdmissionState\x12\".agent.v1.SetAdmissionStateRequest\x1a#.agent.v1.SetAdmissionStateResponse\x12>\n" + - "\aExecute\x12\x18.agent.v1.ExecuteRequest\x1a\x19.agent.v1.ExecuteResponse\x12\\\n" + - "\x11ExecuteAuthorized\x12\".agent.v1.ExecuteAuthorizedRequest\x1a#.agent.v1.ExecuteAuthorizedResponse\x12_\n" + - "\x12GetExecutionPermit\x12#.agent.v1.GetExecutionPermitRequest\x1a$.agent.v1.GetExecutionPermitResponse\x12Y\n" + - "\x10ApplyTaskControl\x12!.agent.v1.ApplyTaskControlRequest\x1a\".agent.v1.ApplyTaskControlResponse\x12S\n" + - "\x0eQueryExecution\x12\x1f.agent.v1.QueryExecutionRequest\x1a .agent.v1.QueryExecutionResponse\x12e\n" + - "\x14ReportExecutionEvent\x12%.agent.v1.ReportExecutionEventRequest\x1a&.agent.v1.ReportExecutionEventResponse\x12P\n" + - "\rRequestUpload\x12\x1e.agent.v1.RequestUploadRequest\x1a\x1f.agent.v1.RequestUploadResponse\x12S\n" + - "\x0eCompleteUpload\x12\x1f.agent.v1.CompleteUploadRequest\x1a .agent.v1.CompleteUploadResponseB0Z.git.ipao.vip/rogee/go-sip/gen/agent/v1;agentv1b\x06proto3" + "\x1cFACT_KIND_RECORDING_PROGRESS\x10\a2\xde\a\n" + + "\x13AgentControlService\x12M\n" + + "\x0eGetAgentStatus\x12\x1c.agent.GetAgentStatusRequest\x1a\x1d.agent.GetAgentStatusResponse\x12J\n" + + "\rActivateAgent\x12\x1b.agent.ActivateAgentRequest\x1a\x1c.agent.ActivateAgentResponse\x12G\n" + + "\fGetBootstrap\x12\x1a.agent.GetBootstrapRequest\x1a\x1b.agent.GetBootstrapResponse\x12V\n" + + "\x11SetAdmissionState\x12\x1f.agent.SetAdmissionStateRequest\x1a .agent.SetAdmissionStateResponse\x128\n" + + "\aExecute\x12\x15.agent.ExecuteRequest\x1a\x16.agent.ExecuteResponse\x12V\n" + + "\x11ExecuteAuthorized\x12\x1f.agent.ExecuteAuthorizedRequest\x1a .agent.ExecuteAuthorizedResponse\x12Y\n" + + "\x12GetExecutionPermit\x12 .agent.GetExecutionPermitRequest\x1a!.agent.GetExecutionPermitResponse\x12S\n" + + "\x10ApplyTaskControl\x12\x1e.agent.ApplyTaskControlRequest\x1a\x1f.agent.ApplyTaskControlResponse\x12M\n" + + "\x0eQueryExecution\x12\x1c.agent.QueryExecutionRequest\x1a\x1d.agent.QueryExecutionResponse\x12_\n" + + "\x14ReportExecutionEvent\x12\".agent.ReportExecutionEventRequest\x1a#.agent.ReportExecutionEventResponse\x12J\n" + + "\rRequestUpload\x12\x1b.agent.RequestUploadRequest\x1a\x1c.agent.RequestUploadResponse\x12M\n" + + "\x0eCompleteUpload\x12\x1c.agent.CompleteUploadRequest\x1a\x1d.agent.CompleteUploadResponseB-Z+git.ipao.vip/rogee/go-sip/gen/agent;agentpbb\x06proto3" var ( - file_agent_v1_agent_proto_rawDescOnce sync.Once - file_agent_v1_agent_proto_rawDescData []byte + file_agent_agent_proto_rawDescOnce sync.Once + file_agent_agent_proto_rawDescData []byte ) -func file_agent_v1_agent_proto_rawDescGZIP() []byte { - file_agent_v1_agent_proto_rawDescOnce.Do(func() { - file_agent_v1_agent_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_agent_v1_agent_proto_rawDesc), len(file_agent_v1_agent_proto_rawDesc))) +func file_agent_agent_proto_rawDescGZIP() []byte { + file_agent_agent_proto_rawDescOnce.Do(func() { + file_agent_agent_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_agent_agent_proto_rawDesc), len(file_agent_agent_proto_rawDesc))) }) - return file_agent_v1_agent_proto_rawDescData + return file_agent_agent_proto_rawDescData } -var file_agent_v1_agent_proto_enumTypes = make([]protoimpl.EnumInfo, 10) -var file_agent_v1_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 43) -var file_agent_v1_agent_proto_goTypes = []any{ - (ResultCode)(0), // 0: agent.v1.ResultCode - (FailureCode)(0), // 1: agent.v1.FailureCode - (ActivationState)(0), // 2: agent.v1.ActivationState - (AdmissionState)(0), // 3: agent.v1.AdmissionState - (ControlAction)(0), // 4: agent.v1.ControlAction - (ActiveCallPolicy)(0), // 5: agent.v1.ActiveCallPolicy - (ExecutionState)(0), // 6: agent.v1.ExecutionState - (AssetKind)(0), // 7: agent.v1.AssetKind - (UploadState)(0), // 8: agent.v1.UploadState - (FactKind)(0), // 9: agent.v1.FactKind - (*RequestMeta)(nil), // 10: agent.v1.RequestMeta - (*ResponseMeta)(nil), // 11: agent.v1.ResponseMeta - (*Failure)(nil), // 12: agent.v1.Failure - (*OperationReceipt)(nil), // 13: agent.v1.OperationReceipt - (*AgentBinding)(nil), // 14: agent.v1.AgentBinding - (*Capability)(nil), // 15: agent.v1.Capability - (*ResourceSample)(nil), // 16: agent.v1.ResourceSample - (*AppliedConfig)(nil), // 17: agent.v1.AppliedConfig - (*AgentStatus)(nil), // 18: agent.v1.AgentStatus - (*Session)(nil), // 19: agent.v1.Session - (*ConfigReference)(nil), // 20: agent.v1.ConfigReference - (*UploadPolicy)(nil), // 21: agent.v1.UploadPolicy - (*ExecutionBinding)(nil), // 22: agent.v1.ExecutionBinding - (*AssetDescriptor)(nil), // 23: agent.v1.AssetDescriptor - (*Header)(nil), // 24: agent.v1.Header - (*GetAgentStatusRequest)(nil), // 25: agent.v1.GetAgentStatusRequest - (*GetAgentStatusResponse)(nil), // 26: agent.v1.GetAgentStatusResponse - (*ActivateAgentRequest)(nil), // 27: agent.v1.ActivateAgentRequest - (*ActivateAgentResponse)(nil), // 28: agent.v1.ActivateAgentResponse - (*GetBootstrapRequest)(nil), // 29: agent.v1.GetBootstrapRequest - (*GetBootstrapResponse)(nil), // 30: agent.v1.GetBootstrapResponse - (*SetAdmissionStateRequest)(nil), // 31: agent.v1.SetAdmissionStateRequest - (*SetAdmissionStateResponse)(nil), // 32: agent.v1.SetAdmissionStateResponse - (*ExecuteRequest)(nil), // 33: agent.v1.ExecuteRequest - (*ExecuteResponse)(nil), // 34: agent.v1.ExecuteResponse - (*ExecuteAuthorizedRequest)(nil), // 35: agent.v1.ExecuteAuthorizedRequest - (*ExecuteAuthorizedResponse)(nil), // 36: agent.v1.ExecuteAuthorizedResponse - (*GetExecutionPermitRequest)(nil), // 37: agent.v1.GetExecutionPermitRequest - (*ExecutionPermit)(nil), // 38: agent.v1.ExecutionPermit - (*GetExecutionPermitResponse)(nil), // 39: agent.v1.GetExecutionPermitResponse - (*ApplyTaskControlRequest)(nil), // 40: agent.v1.ApplyTaskControlRequest - (*ApplyTaskControlResponse)(nil), // 41: agent.v1.ApplyTaskControlResponse - (*QueryExecutionRequest)(nil), // 42: agent.v1.QueryExecutionRequest - (*ExecutionSnapshot)(nil), // 43: agent.v1.ExecutionSnapshot - (*QueryExecutionResponse)(nil), // 44: agent.v1.QueryExecutionResponse - (*ExecutionFact)(nil), // 45: agent.v1.ExecutionFact - (*ReportExecutionEventRequest)(nil), // 46: agent.v1.ReportExecutionEventRequest - (*ReportExecutionEventResponse)(nil), // 47: agent.v1.ReportExecutionEventResponse - (*RequestUploadRequest)(nil), // 48: agent.v1.RequestUploadRequest - (*UploadGrant)(nil), // 49: agent.v1.UploadGrant - (*RequestUploadResponse)(nil), // 50: agent.v1.RequestUploadResponse - (*CompleteUploadRequest)(nil), // 51: agent.v1.CompleteUploadRequest - (*CompleteUploadResponse)(nil), // 52: agent.v1.CompleteUploadResponse +var file_agent_agent_proto_enumTypes = make([]protoimpl.EnumInfo, 10) +var file_agent_agent_proto_msgTypes = make([]protoimpl.MessageInfo, 43) +var file_agent_agent_proto_goTypes = []any{ + (ResultCode)(0), // 0: agent.ResultCode + (FailureCode)(0), // 1: agent.FailureCode + (ActivationState)(0), // 2: agent.ActivationState + (AdmissionState)(0), // 3: agent.AdmissionState + (ControlAction)(0), // 4: agent.ControlAction + (ActiveCallPolicy)(0), // 5: agent.ActiveCallPolicy + (ExecutionState)(0), // 6: agent.ExecutionState + (AssetKind)(0), // 7: agent.AssetKind + (UploadState)(0), // 8: agent.UploadState + (FactKind)(0), // 9: agent.FactKind + (*RequestMeta)(nil), // 10: agent.RequestMeta + (*ResponseMeta)(nil), // 11: agent.ResponseMeta + (*Failure)(nil), // 12: agent.Failure + (*OperationReceipt)(nil), // 13: agent.OperationReceipt + (*AgentBinding)(nil), // 14: agent.AgentBinding + (*Capability)(nil), // 15: agent.Capability + (*ResourceSample)(nil), // 16: agent.ResourceSample + (*AppliedConfig)(nil), // 17: agent.AppliedConfig + (*AgentStatus)(nil), // 18: agent.AgentStatus + (*Session)(nil), // 19: agent.Session + (*ConfigReference)(nil), // 20: agent.ConfigReference + (*UploadPolicy)(nil), // 21: agent.UploadPolicy + (*ExecutionBinding)(nil), // 22: agent.ExecutionBinding + (*AssetDescriptor)(nil), // 23: agent.AssetDescriptor + (*Header)(nil), // 24: agent.Header + (*GetAgentStatusRequest)(nil), // 25: agent.GetAgentStatusRequest + (*GetAgentStatusResponse)(nil), // 26: agent.GetAgentStatusResponse + (*ActivateAgentRequest)(nil), // 27: agent.ActivateAgentRequest + (*ActivateAgentResponse)(nil), // 28: agent.ActivateAgentResponse + (*GetBootstrapRequest)(nil), // 29: agent.GetBootstrapRequest + (*GetBootstrapResponse)(nil), // 30: agent.GetBootstrapResponse + (*SetAdmissionStateRequest)(nil), // 31: agent.SetAdmissionStateRequest + (*SetAdmissionStateResponse)(nil), // 32: agent.SetAdmissionStateResponse + (*ExecuteRequest)(nil), // 33: agent.ExecuteRequest + (*ExecuteResponse)(nil), // 34: agent.ExecuteResponse + (*ExecuteAuthorizedRequest)(nil), // 35: agent.ExecuteAuthorizedRequest + (*ExecuteAuthorizedResponse)(nil), // 36: agent.ExecuteAuthorizedResponse + (*GetExecutionPermitRequest)(nil), // 37: agent.GetExecutionPermitRequest + (*ExecutionPermit)(nil), // 38: agent.ExecutionPermit + (*GetExecutionPermitResponse)(nil), // 39: agent.GetExecutionPermitResponse + (*ApplyTaskControlRequest)(nil), // 40: agent.ApplyTaskControlRequest + (*ApplyTaskControlResponse)(nil), // 41: agent.ApplyTaskControlResponse + (*QueryExecutionRequest)(nil), // 42: agent.QueryExecutionRequest + (*ExecutionSnapshot)(nil), // 43: agent.ExecutionSnapshot + (*QueryExecutionResponse)(nil), // 44: agent.QueryExecutionResponse + (*ExecutionFact)(nil), // 45: agent.ExecutionFact + (*ReportExecutionEventRequest)(nil), // 46: agent.ReportExecutionEventRequest + (*ReportExecutionEventResponse)(nil), // 47: agent.ReportExecutionEventResponse + (*RequestUploadRequest)(nil), // 48: agent.RequestUploadRequest + (*UploadGrant)(nil), // 49: agent.UploadGrant + (*RequestUploadResponse)(nil), // 50: agent.RequestUploadResponse + (*CompleteUploadRequest)(nil), // 51: agent.CompleteUploadRequest + (*CompleteUploadResponse)(nil), // 52: agent.CompleteUploadResponse } -var file_agent_v1_agent_proto_depIdxs = []int32{ - 1, // 0: agent.v1.Failure.code:type_name -> agent.v1.FailureCode - 11, // 1: agent.v1.OperationReceipt.meta:type_name -> agent.v1.ResponseMeta - 0, // 2: agent.v1.OperationReceipt.result:type_name -> agent.v1.ResultCode - 12, // 3: agent.v1.OperationReceipt.failure:type_name -> agent.v1.Failure - 3, // 4: agent.v1.AgentStatus.admission_state:type_name -> agent.v1.AdmissionState - 15, // 5: agent.v1.AgentStatus.capabilities:type_name -> agent.v1.Capability - 16, // 6: agent.v1.AgentStatus.resources:type_name -> agent.v1.ResourceSample - 17, // 7: agent.v1.AgentStatus.applied_configs:type_name -> agent.v1.AppliedConfig - 7, // 8: agent.v1.AssetDescriptor.kind:type_name -> agent.v1.AssetKind - 10, // 9: agent.v1.GetAgentStatusRequest.meta:type_name -> agent.v1.RequestMeta - 14, // 10: agent.v1.GetAgentStatusRequest.target:type_name -> agent.v1.AgentBinding - 11, // 11: agent.v1.GetAgentStatusResponse.meta:type_name -> agent.v1.ResponseMeta - 18, // 12: agent.v1.GetAgentStatusResponse.status:type_name -> agent.v1.AgentStatus - 12, // 13: agent.v1.GetAgentStatusResponse.failure:type_name -> agent.v1.Failure - 10, // 14: agent.v1.ActivateAgentRequest.meta:type_name -> agent.v1.RequestMeta - 14, // 15: agent.v1.ActivateAgentRequest.binding:type_name -> agent.v1.AgentBinding - 11, // 16: agent.v1.ActivateAgentResponse.meta:type_name -> agent.v1.ResponseMeta - 2, // 17: agent.v1.ActivateAgentResponse.state:type_name -> agent.v1.ActivationState - 19, // 18: agent.v1.ActivateAgentResponse.session:type_name -> agent.v1.Session - 12, // 19: agent.v1.ActivateAgentResponse.failure:type_name -> agent.v1.Failure - 10, // 20: agent.v1.GetBootstrapRequest.meta:type_name -> agent.v1.RequestMeta - 11, // 21: agent.v1.GetBootstrapResponse.meta:type_name -> agent.v1.ResponseMeta - 2, // 22: agent.v1.GetBootstrapResponse.state:type_name -> agent.v1.ActivationState - 20, // 23: agent.v1.GetBootstrapResponse.runtime_configs:type_name -> agent.v1.ConfigReference - 21, // 24: agent.v1.GetBootstrapResponse.upload_policy:type_name -> agent.v1.UploadPolicy - 12, // 25: agent.v1.GetBootstrapResponse.failure:type_name -> agent.v1.Failure - 10, // 26: agent.v1.SetAdmissionStateRequest.meta:type_name -> agent.v1.RequestMeta - 14, // 27: agent.v1.SetAdmissionStateRequest.target:type_name -> agent.v1.AgentBinding - 3, // 28: agent.v1.SetAdmissionStateRequest.state:type_name -> agent.v1.AdmissionState - 13, // 29: agent.v1.SetAdmissionStateResponse.receipt:type_name -> agent.v1.OperationReceipt - 10, // 30: agent.v1.ExecuteRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 31: agent.v1.ExecuteRequest.binding:type_name -> agent.v1.ExecutionBinding - 13, // 32: agent.v1.ExecuteResponse.receipt:type_name -> agent.v1.OperationReceipt - 6, // 33: agent.v1.ExecuteResponse.state:type_name -> agent.v1.ExecutionState - 10, // 34: agent.v1.ExecuteAuthorizedRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 35: agent.v1.ExecuteAuthorizedRequest.binding:type_name -> agent.v1.ExecutionBinding - 13, // 36: agent.v1.ExecuteAuthorizedResponse.receipt:type_name -> agent.v1.OperationReceipt - 6, // 37: agent.v1.ExecuteAuthorizedResponse.state:type_name -> agent.v1.ExecutionState - 10, // 38: agent.v1.GetExecutionPermitRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 39: agent.v1.GetExecutionPermitRequest.binding:type_name -> agent.v1.ExecutionBinding - 13, // 40: agent.v1.GetExecutionPermitResponse.receipt:type_name -> agent.v1.OperationReceipt - 38, // 41: agent.v1.GetExecutionPermitResponse.permit:type_name -> agent.v1.ExecutionPermit - 10, // 42: agent.v1.ApplyTaskControlRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 43: agent.v1.ApplyTaskControlRequest.binding:type_name -> agent.v1.ExecutionBinding - 4, // 44: agent.v1.ApplyTaskControlRequest.action:type_name -> agent.v1.ControlAction - 5, // 45: agent.v1.ApplyTaskControlRequest.active_call_policy:type_name -> agent.v1.ActiveCallPolicy - 13, // 46: agent.v1.ApplyTaskControlResponse.receipt:type_name -> agent.v1.OperationReceipt - 6, // 47: agent.v1.ApplyTaskControlResponse.state:type_name -> agent.v1.ExecutionState - 10, // 48: agent.v1.QueryExecutionRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 49: agent.v1.QueryExecutionRequest.binding:type_name -> agent.v1.ExecutionBinding - 22, // 50: agent.v1.ExecutionSnapshot.binding:type_name -> agent.v1.ExecutionBinding - 6, // 51: agent.v1.ExecutionSnapshot.state:type_name -> agent.v1.ExecutionState - 23, // 52: agent.v1.ExecutionSnapshot.assets:type_name -> agent.v1.AssetDescriptor - 11, // 53: agent.v1.QueryExecutionResponse.meta:type_name -> agent.v1.ResponseMeta - 43, // 54: agent.v1.QueryExecutionResponse.snapshot:type_name -> agent.v1.ExecutionSnapshot - 12, // 55: agent.v1.QueryExecutionResponse.failure:type_name -> agent.v1.Failure - 22, // 56: agent.v1.ExecutionFact.binding:type_name -> agent.v1.ExecutionBinding - 9, // 57: agent.v1.ExecutionFact.kind:type_name -> agent.v1.FactKind - 10, // 58: agent.v1.ReportExecutionEventRequest.meta:type_name -> agent.v1.RequestMeta - 45, // 59: agent.v1.ReportExecutionEventRequest.fact:type_name -> agent.v1.ExecutionFact - 13, // 60: agent.v1.ReportExecutionEventResponse.receipt:type_name -> agent.v1.OperationReceipt - 10, // 61: agent.v1.RequestUploadRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 62: agent.v1.RequestUploadRequest.binding:type_name -> agent.v1.ExecutionBinding - 23, // 63: agent.v1.RequestUploadRequest.asset:type_name -> agent.v1.AssetDescriptor - 24, // 64: agent.v1.UploadGrant.headers:type_name -> agent.v1.Header - 13, // 65: agent.v1.RequestUploadResponse.receipt:type_name -> agent.v1.OperationReceipt - 49, // 66: agent.v1.RequestUploadResponse.grant:type_name -> agent.v1.UploadGrant - 8, // 67: agent.v1.RequestUploadResponse.state:type_name -> agent.v1.UploadState - 10, // 68: agent.v1.CompleteUploadRequest.meta:type_name -> agent.v1.RequestMeta - 22, // 69: agent.v1.CompleteUploadRequest.binding:type_name -> agent.v1.ExecutionBinding - 23, // 70: agent.v1.CompleteUploadRequest.asset:type_name -> agent.v1.AssetDescriptor - 13, // 71: agent.v1.CompleteUploadResponse.receipt:type_name -> agent.v1.OperationReceipt - 8, // 72: agent.v1.CompleteUploadResponse.state:type_name -> agent.v1.UploadState - 25, // 73: agent.v1.AgentControlService.GetAgentStatus:input_type -> agent.v1.GetAgentStatusRequest - 27, // 74: agent.v1.AgentControlService.ActivateAgent:input_type -> agent.v1.ActivateAgentRequest - 29, // 75: agent.v1.AgentControlService.GetBootstrap:input_type -> agent.v1.GetBootstrapRequest - 31, // 76: agent.v1.AgentControlService.SetAdmissionState:input_type -> agent.v1.SetAdmissionStateRequest - 33, // 77: agent.v1.AgentControlService.Execute:input_type -> agent.v1.ExecuteRequest - 35, // 78: agent.v1.AgentControlService.ExecuteAuthorized:input_type -> agent.v1.ExecuteAuthorizedRequest - 37, // 79: agent.v1.AgentControlService.GetExecutionPermit:input_type -> agent.v1.GetExecutionPermitRequest - 40, // 80: agent.v1.AgentControlService.ApplyTaskControl:input_type -> agent.v1.ApplyTaskControlRequest - 42, // 81: agent.v1.AgentControlService.QueryExecution:input_type -> agent.v1.QueryExecutionRequest - 46, // 82: agent.v1.AgentControlService.ReportExecutionEvent:input_type -> agent.v1.ReportExecutionEventRequest - 48, // 83: agent.v1.AgentControlService.RequestUpload:input_type -> agent.v1.RequestUploadRequest - 51, // 84: agent.v1.AgentControlService.CompleteUpload:input_type -> agent.v1.CompleteUploadRequest - 26, // 85: agent.v1.AgentControlService.GetAgentStatus:output_type -> agent.v1.GetAgentStatusResponse - 28, // 86: agent.v1.AgentControlService.ActivateAgent:output_type -> agent.v1.ActivateAgentResponse - 30, // 87: agent.v1.AgentControlService.GetBootstrap:output_type -> agent.v1.GetBootstrapResponse - 32, // 88: agent.v1.AgentControlService.SetAdmissionState:output_type -> agent.v1.SetAdmissionStateResponse - 34, // 89: agent.v1.AgentControlService.Execute:output_type -> agent.v1.ExecuteResponse - 36, // 90: agent.v1.AgentControlService.ExecuteAuthorized:output_type -> agent.v1.ExecuteAuthorizedResponse - 39, // 91: agent.v1.AgentControlService.GetExecutionPermit:output_type -> agent.v1.GetExecutionPermitResponse - 41, // 92: agent.v1.AgentControlService.ApplyTaskControl:output_type -> agent.v1.ApplyTaskControlResponse - 44, // 93: agent.v1.AgentControlService.QueryExecution:output_type -> agent.v1.QueryExecutionResponse - 47, // 94: agent.v1.AgentControlService.ReportExecutionEvent:output_type -> agent.v1.ReportExecutionEventResponse - 50, // 95: agent.v1.AgentControlService.RequestUpload:output_type -> agent.v1.RequestUploadResponse - 52, // 96: agent.v1.AgentControlService.CompleteUpload:output_type -> agent.v1.CompleteUploadResponse +var file_agent_agent_proto_depIdxs = []int32{ + 1, // 0: agent.Failure.code:type_name -> agent.FailureCode + 11, // 1: agent.OperationReceipt.meta:type_name -> agent.ResponseMeta + 0, // 2: agent.OperationReceipt.result:type_name -> agent.ResultCode + 12, // 3: agent.OperationReceipt.failure:type_name -> agent.Failure + 3, // 4: agent.AgentStatus.admission_state:type_name -> agent.AdmissionState + 15, // 5: agent.AgentStatus.capabilities:type_name -> agent.Capability + 16, // 6: agent.AgentStatus.resources:type_name -> agent.ResourceSample + 17, // 7: agent.AgentStatus.applied_configs:type_name -> agent.AppliedConfig + 7, // 8: agent.AssetDescriptor.kind:type_name -> agent.AssetKind + 10, // 9: agent.GetAgentStatusRequest.meta:type_name -> agent.RequestMeta + 14, // 10: agent.GetAgentStatusRequest.target:type_name -> agent.AgentBinding + 11, // 11: agent.GetAgentStatusResponse.meta:type_name -> agent.ResponseMeta + 18, // 12: agent.GetAgentStatusResponse.status:type_name -> agent.AgentStatus + 12, // 13: agent.GetAgentStatusResponse.failure:type_name -> agent.Failure + 10, // 14: agent.ActivateAgentRequest.meta:type_name -> agent.RequestMeta + 14, // 15: agent.ActivateAgentRequest.binding:type_name -> agent.AgentBinding + 11, // 16: agent.ActivateAgentResponse.meta:type_name -> agent.ResponseMeta + 2, // 17: agent.ActivateAgentResponse.state:type_name -> agent.ActivationState + 19, // 18: agent.ActivateAgentResponse.session:type_name -> agent.Session + 12, // 19: agent.ActivateAgentResponse.failure:type_name -> agent.Failure + 10, // 20: agent.GetBootstrapRequest.meta:type_name -> agent.RequestMeta + 11, // 21: agent.GetBootstrapResponse.meta:type_name -> agent.ResponseMeta + 2, // 22: agent.GetBootstrapResponse.state:type_name -> agent.ActivationState + 20, // 23: agent.GetBootstrapResponse.runtime_configs:type_name -> agent.ConfigReference + 21, // 24: agent.GetBootstrapResponse.upload_policy:type_name -> agent.UploadPolicy + 12, // 25: agent.GetBootstrapResponse.failure:type_name -> agent.Failure + 10, // 26: agent.SetAdmissionStateRequest.meta:type_name -> agent.RequestMeta + 14, // 27: agent.SetAdmissionStateRequest.target:type_name -> agent.AgentBinding + 3, // 28: agent.SetAdmissionStateRequest.state:type_name -> agent.AdmissionState + 13, // 29: agent.SetAdmissionStateResponse.receipt:type_name -> agent.OperationReceipt + 10, // 30: agent.ExecuteRequest.meta:type_name -> agent.RequestMeta + 22, // 31: agent.ExecuteRequest.binding:type_name -> agent.ExecutionBinding + 13, // 32: agent.ExecuteResponse.receipt:type_name -> agent.OperationReceipt + 6, // 33: agent.ExecuteResponse.state:type_name -> agent.ExecutionState + 10, // 34: agent.ExecuteAuthorizedRequest.meta:type_name -> agent.RequestMeta + 22, // 35: agent.ExecuteAuthorizedRequest.binding:type_name -> agent.ExecutionBinding + 13, // 36: agent.ExecuteAuthorizedResponse.receipt:type_name -> agent.OperationReceipt + 6, // 37: agent.ExecuteAuthorizedResponse.state:type_name -> agent.ExecutionState + 10, // 38: agent.GetExecutionPermitRequest.meta:type_name -> agent.RequestMeta + 22, // 39: agent.GetExecutionPermitRequest.binding:type_name -> agent.ExecutionBinding + 13, // 40: agent.GetExecutionPermitResponse.receipt:type_name -> agent.OperationReceipt + 38, // 41: agent.GetExecutionPermitResponse.permit:type_name -> agent.ExecutionPermit + 10, // 42: agent.ApplyTaskControlRequest.meta:type_name -> agent.RequestMeta + 22, // 43: agent.ApplyTaskControlRequest.binding:type_name -> agent.ExecutionBinding + 4, // 44: agent.ApplyTaskControlRequest.action:type_name -> agent.ControlAction + 5, // 45: agent.ApplyTaskControlRequest.active_call_policy:type_name -> agent.ActiveCallPolicy + 13, // 46: agent.ApplyTaskControlResponse.receipt:type_name -> agent.OperationReceipt + 6, // 47: agent.ApplyTaskControlResponse.state:type_name -> agent.ExecutionState + 10, // 48: agent.QueryExecutionRequest.meta:type_name -> agent.RequestMeta + 22, // 49: agent.QueryExecutionRequest.binding:type_name -> agent.ExecutionBinding + 22, // 50: agent.ExecutionSnapshot.binding:type_name -> agent.ExecutionBinding + 6, // 51: agent.ExecutionSnapshot.state:type_name -> agent.ExecutionState + 23, // 52: agent.ExecutionSnapshot.assets:type_name -> agent.AssetDescriptor + 11, // 53: agent.QueryExecutionResponse.meta:type_name -> agent.ResponseMeta + 43, // 54: agent.QueryExecutionResponse.snapshot:type_name -> agent.ExecutionSnapshot + 12, // 55: agent.QueryExecutionResponse.failure:type_name -> agent.Failure + 22, // 56: agent.ExecutionFact.binding:type_name -> agent.ExecutionBinding + 9, // 57: agent.ExecutionFact.kind:type_name -> agent.FactKind + 10, // 58: agent.ReportExecutionEventRequest.meta:type_name -> agent.RequestMeta + 45, // 59: agent.ReportExecutionEventRequest.fact:type_name -> agent.ExecutionFact + 13, // 60: agent.ReportExecutionEventResponse.receipt:type_name -> agent.OperationReceipt + 10, // 61: agent.RequestUploadRequest.meta:type_name -> agent.RequestMeta + 22, // 62: agent.RequestUploadRequest.binding:type_name -> agent.ExecutionBinding + 23, // 63: agent.RequestUploadRequest.asset:type_name -> agent.AssetDescriptor + 24, // 64: agent.UploadGrant.headers:type_name -> agent.Header + 13, // 65: agent.RequestUploadResponse.receipt:type_name -> agent.OperationReceipt + 49, // 66: agent.RequestUploadResponse.grant:type_name -> agent.UploadGrant + 8, // 67: agent.RequestUploadResponse.state:type_name -> agent.UploadState + 10, // 68: agent.CompleteUploadRequest.meta:type_name -> agent.RequestMeta + 22, // 69: agent.CompleteUploadRequest.binding:type_name -> agent.ExecutionBinding + 23, // 70: agent.CompleteUploadRequest.asset:type_name -> agent.AssetDescriptor + 13, // 71: agent.CompleteUploadResponse.receipt:type_name -> agent.OperationReceipt + 8, // 72: agent.CompleteUploadResponse.state:type_name -> agent.UploadState + 25, // 73: agent.AgentControlService.GetAgentStatus:input_type -> agent.GetAgentStatusRequest + 27, // 74: agent.AgentControlService.ActivateAgent:input_type -> agent.ActivateAgentRequest + 29, // 75: agent.AgentControlService.GetBootstrap:input_type -> agent.GetBootstrapRequest + 31, // 76: agent.AgentControlService.SetAdmissionState:input_type -> agent.SetAdmissionStateRequest + 33, // 77: agent.AgentControlService.Execute:input_type -> agent.ExecuteRequest + 35, // 78: agent.AgentControlService.ExecuteAuthorized:input_type -> agent.ExecuteAuthorizedRequest + 37, // 79: agent.AgentControlService.GetExecutionPermit:input_type -> agent.GetExecutionPermitRequest + 40, // 80: agent.AgentControlService.ApplyTaskControl:input_type -> agent.ApplyTaskControlRequest + 42, // 81: agent.AgentControlService.QueryExecution:input_type -> agent.QueryExecutionRequest + 46, // 82: agent.AgentControlService.ReportExecutionEvent:input_type -> agent.ReportExecutionEventRequest + 48, // 83: agent.AgentControlService.RequestUpload:input_type -> agent.RequestUploadRequest + 51, // 84: agent.AgentControlService.CompleteUpload:input_type -> agent.CompleteUploadRequest + 26, // 85: agent.AgentControlService.GetAgentStatus:output_type -> agent.GetAgentStatusResponse + 28, // 86: agent.AgentControlService.ActivateAgent:output_type -> agent.ActivateAgentResponse + 30, // 87: agent.AgentControlService.GetBootstrap:output_type -> agent.GetBootstrapResponse + 32, // 88: agent.AgentControlService.SetAdmissionState:output_type -> agent.SetAdmissionStateResponse + 34, // 89: agent.AgentControlService.Execute:output_type -> agent.ExecuteResponse + 36, // 90: agent.AgentControlService.ExecuteAuthorized:output_type -> agent.ExecuteAuthorizedResponse + 39, // 91: agent.AgentControlService.GetExecutionPermit:output_type -> agent.GetExecutionPermitResponse + 41, // 92: agent.AgentControlService.ApplyTaskControl:output_type -> agent.ApplyTaskControlResponse + 44, // 93: agent.AgentControlService.QueryExecution:output_type -> agent.QueryExecutionResponse + 47, // 94: agent.AgentControlService.ReportExecutionEvent:output_type -> agent.ReportExecutionEventResponse + 50, // 95: agent.AgentControlService.RequestUpload:output_type -> agent.RequestUploadResponse + 52, // 96: agent.AgentControlService.CompleteUpload:output_type -> agent.CompleteUploadResponse 85, // [85:97] is the sub-list for method output_type 73, // [73:85] is the sub-list for method input_type 73, // [73:73] is the sub-list for extension type_name @@ -4514,27 +4514,27 @@ var file_agent_v1_agent_proto_depIdxs = []int32{ 0, // [0:73] is the sub-list for field type_name } -func init() { file_agent_v1_agent_proto_init() } -func file_agent_v1_agent_proto_init() { - if File_agent_v1_agent_proto != nil { +func init() { file_agent_agent_proto_init() } +func file_agent_agent_proto_init() { + if File_agent_agent_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_agent_v1_agent_proto_rawDesc), len(file_agent_v1_agent_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_agent_agent_proto_rawDesc), len(file_agent_agent_proto_rawDesc)), NumEnums: 10, NumMessages: 43, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_agent_v1_agent_proto_goTypes, - DependencyIndexes: file_agent_v1_agent_proto_depIdxs, - EnumInfos: file_agent_v1_agent_proto_enumTypes, - MessageInfos: file_agent_v1_agent_proto_msgTypes, + GoTypes: file_agent_agent_proto_goTypes, + DependencyIndexes: file_agent_agent_proto_depIdxs, + EnumInfos: file_agent_agent_proto_enumTypes, + MessageInfos: file_agent_agent_proto_msgTypes, }.Build() - File_agent_v1_agent_proto = out.File - file_agent_v1_agent_proto_goTypes = nil - file_agent_v1_agent_proto_depIdxs = nil + File_agent_agent_proto = out.File + file_agent_agent_proto_goTypes = nil + file_agent_agent_proto_depIdxs = nil } diff --git a/gen/agent/v1/agent_grpc.pb.go b/gen/agent/agent_grpc.pb.go similarity index 92% rename from gen/agent/v1/agent_grpc.pb.go rename to gen/agent/agent_grpc.pb.go index 2b2771c..003a8c4 100644 --- a/gen/agent/v1/agent_grpc.pb.go +++ b/gen/agent/agent_grpc.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.6.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) -// source: agent/v1/agent.proto +// source: agent/agent.proto -package agentv1 +package agentpb import ( context "context" @@ -19,18 +19,18 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - AgentControlService_GetAgentStatus_FullMethodName = "/agent.v1.AgentControlService/GetAgentStatus" - AgentControlService_ActivateAgent_FullMethodName = "/agent.v1.AgentControlService/ActivateAgent" - AgentControlService_GetBootstrap_FullMethodName = "/agent.v1.AgentControlService/GetBootstrap" - AgentControlService_SetAdmissionState_FullMethodName = "/agent.v1.AgentControlService/SetAdmissionState" - AgentControlService_Execute_FullMethodName = "/agent.v1.AgentControlService/Execute" - AgentControlService_ExecuteAuthorized_FullMethodName = "/agent.v1.AgentControlService/ExecuteAuthorized" - AgentControlService_GetExecutionPermit_FullMethodName = "/agent.v1.AgentControlService/GetExecutionPermit" - AgentControlService_ApplyTaskControl_FullMethodName = "/agent.v1.AgentControlService/ApplyTaskControl" - AgentControlService_QueryExecution_FullMethodName = "/agent.v1.AgentControlService/QueryExecution" - AgentControlService_ReportExecutionEvent_FullMethodName = "/agent.v1.AgentControlService/ReportExecutionEvent" - AgentControlService_RequestUpload_FullMethodName = "/agent.v1.AgentControlService/RequestUpload" - AgentControlService_CompleteUpload_FullMethodName = "/agent.v1.AgentControlService/CompleteUpload" + AgentControlService_GetAgentStatus_FullMethodName = "/agent.AgentControlService/GetAgentStatus" + AgentControlService_ActivateAgent_FullMethodName = "/agent.AgentControlService/ActivateAgent" + AgentControlService_GetBootstrap_FullMethodName = "/agent.AgentControlService/GetBootstrap" + AgentControlService_SetAdmissionState_FullMethodName = "/agent.AgentControlService/SetAdmissionState" + AgentControlService_Execute_FullMethodName = "/agent.AgentControlService/Execute" + AgentControlService_ExecuteAuthorized_FullMethodName = "/agent.AgentControlService/ExecuteAuthorized" + AgentControlService_GetExecutionPermit_FullMethodName = "/agent.AgentControlService/GetExecutionPermit" + AgentControlService_ApplyTaskControl_FullMethodName = "/agent.AgentControlService/ApplyTaskControl" + AgentControlService_QueryExecution_FullMethodName = "/agent.AgentControlService/QueryExecution" + AgentControlService_ReportExecutionEvent_FullMethodName = "/agent.AgentControlService/ReportExecutionEvent" + AgentControlService_RequestUpload_FullMethodName = "/agent.AgentControlService/RequestUpload" + AgentControlService_CompleteUpload_FullMethodName = "/agent.AgentControlService/CompleteUpload" ) // AgentControlServiceClient is the client API for AgentControlService service. @@ -216,40 +216,40 @@ type AgentControlServiceServer interface { type UnimplementedAgentControlServiceServer struct{} func (UnimplementedAgentControlServiceServer) GetAgentStatus(context.Context, *GetAgentStatusRequest) (*GetAgentStatusResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetAgentStatus not implemented") + return nil, status.Errorf(codes.Unimplemented, "method GetAgentStatus not implemented") } func (UnimplementedAgentControlServiceServer) ActivateAgent(context.Context, *ActivateAgentRequest) (*ActivateAgentResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ActivateAgent not implemented") + return nil, status.Errorf(codes.Unimplemented, "method ActivateAgent not implemented") } func (UnimplementedAgentControlServiceServer) GetBootstrap(context.Context, *GetBootstrapRequest) (*GetBootstrapResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetBootstrap not implemented") + return nil, status.Errorf(codes.Unimplemented, "method GetBootstrap not implemented") } func (UnimplementedAgentControlServiceServer) SetAdmissionState(context.Context, *SetAdmissionStateRequest) (*SetAdmissionStateResponse, error) { - return nil, status.Error(codes.Unimplemented, "method SetAdmissionState not implemented") + return nil, status.Errorf(codes.Unimplemented, "method SetAdmissionState not implemented") } func (UnimplementedAgentControlServiceServer) Execute(context.Context, *ExecuteRequest) (*ExecuteResponse, error) { - return nil, status.Error(codes.Unimplemented, "method Execute not implemented") + return nil, status.Errorf(codes.Unimplemented, "method Execute not implemented") } func (UnimplementedAgentControlServiceServer) ExecuteAuthorized(context.Context, *ExecuteAuthorizedRequest) (*ExecuteAuthorizedResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ExecuteAuthorized not implemented") + return nil, status.Errorf(codes.Unimplemented, "method ExecuteAuthorized not implemented") } func (UnimplementedAgentControlServiceServer) GetExecutionPermit(context.Context, *GetExecutionPermitRequest) (*GetExecutionPermitResponse, error) { - return nil, status.Error(codes.Unimplemented, "method GetExecutionPermit not implemented") + return nil, status.Errorf(codes.Unimplemented, "method GetExecutionPermit not implemented") } func (UnimplementedAgentControlServiceServer) ApplyTaskControl(context.Context, *ApplyTaskControlRequest) (*ApplyTaskControlResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ApplyTaskControl not implemented") + return nil, status.Errorf(codes.Unimplemented, "method ApplyTaskControl not implemented") } func (UnimplementedAgentControlServiceServer) QueryExecution(context.Context, *QueryExecutionRequest) (*QueryExecutionResponse, error) { - return nil, status.Error(codes.Unimplemented, "method QueryExecution not implemented") + return nil, status.Errorf(codes.Unimplemented, "method QueryExecution not implemented") } func (UnimplementedAgentControlServiceServer) ReportExecutionEvent(context.Context, *ReportExecutionEventRequest) (*ReportExecutionEventResponse, error) { - return nil, status.Error(codes.Unimplemented, "method ReportExecutionEvent not implemented") + return nil, status.Errorf(codes.Unimplemented, "method ReportExecutionEvent not implemented") } func (UnimplementedAgentControlServiceServer) RequestUpload(context.Context, *RequestUploadRequest) (*RequestUploadResponse, error) { - return nil, status.Error(codes.Unimplemented, "method RequestUpload not implemented") + return nil, status.Errorf(codes.Unimplemented, "method RequestUpload not implemented") } func (UnimplementedAgentControlServiceServer) CompleteUpload(context.Context, *CompleteUploadRequest) (*CompleteUploadResponse, error) { - return nil, status.Error(codes.Unimplemented, "method CompleteUpload not implemented") + return nil, status.Errorf(codes.Unimplemented, "method CompleteUpload not implemented") } func (UnimplementedAgentControlServiceServer) mustEmbedUnimplementedAgentControlServiceServer() {} func (UnimplementedAgentControlServiceServer) testEmbeddedByValue() {} @@ -262,7 +262,7 @@ type UnsafeAgentControlServiceServer interface { } func RegisterAgentControlServiceServer(s grpc.ServiceRegistrar, srv AgentControlServiceServer) { - // If the following call panics, it indicates UnimplementedAgentControlServiceServer was + // If the following call pancis, it indicates UnimplementedAgentControlServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. @@ -492,7 +492,7 @@ func _AgentControlService_CompleteUpload_Handler(srv interface{}, ctx context.Co // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var AgentControlService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "agent.v1.AgentControlService", + ServiceName: "agent.AgentControlService", HandlerType: (*AgentControlServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -545,5 +545,5 @@ var AgentControlService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "agent/v1/agent.proto", + Metadata: "agent/agent.proto", } diff --git a/internal/agent/mock_failure_report.go b/internal/agent/mock_failure_report.go index 1cf654a..6e0d240 100644 --- a/internal/agent/mock_failure_report.go +++ b/internal/agent/mock_failure_report.go @@ -10,14 +10,14 @@ import ( "net/http" "os" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "github.com/google/uuid" "google.golang.org/protobuf/proto" ) type MockFailureFactClient interface { - ReportExecutionEvent(context.Context, *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) + ReportExecutionEvent(context.Context, *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) } // MockUploadFailureCode returns empty for uncertain PUT outcomes. In particular @@ -45,7 +45,7 @@ func MockUploadFailureCode(cause error) string { return "" } -func validateMockFailureActiveMeta(meta *agentv1.RequestMeta) error { +func validateMockFailureActiveMeta(meta *agentpb.RequestMeta) error { if meta == nil || meta.ProtocolVersion != "agent.v1" || meta.AgentId == "" || meta.CellId == "" || meta.BootId == "" || meta.DispatcherEpoch == "" || meta.SessionGeneration == 0 { return errors.New("Mock failure requires the current activated Agent session") @@ -58,7 +58,7 @@ func validateMockFailureActiveMeta(meta *agentv1.RequestMeta) error { // The caller supplies metadata from its activated Agent session, not a newly // invented boot identity. A pending fact is retried with the same ID after // restart, while the request metadata uses the new active session. -func (s *Spool) ReportMockUploadFailure(ctx context.Context, client MockFailureFactClient, active *agentv1.RequestMeta, uploadID string, cause error) (bool, error) { +func (s *Spool) ReportMockUploadFailure(ctx context.Context, client MockFailureFactClient, active *agentpb.RequestMeta, uploadID string, cause error) (bool, error) { code := MockUploadFailureCode(cause) if code == "" { return false, nil @@ -82,9 +82,9 @@ func (s *Spool) ReportMockUploadFailure(ctx context.Context, client MockFailureF return true, err } sum := sha256.Sum256(payload) - fact := &agentv1.ExecutionFact{ - FactId: uuid.NewString(), Binding: proto.Clone(record.Binding).(*agentv1.ExecutionBinding), - Kind: agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS, PayloadJson: payload, + fact := &agentpb.ExecutionFact{ + FactId: uuid.NewString(), Binding: proto.Clone(record.Binding).(*agentpb.ExecutionBinding), + Kind: agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS, PayloadJson: payload, ContentSha256: hex.EncodeToString(sum[:]), ObservedAtUnixMs: s.now().UTC().UnixMilli(), SourceBootId: active.BootId, SourceSequence: 1, } @@ -99,7 +99,7 @@ func (s *Spool) ReportMockUploadFailure(ctx context.Context, client MockFailureF return true, s.deliverMockFailure(ctx, client, active, record) } -func (s *Spool) RecoverMockUploadFailures(ctx context.Context, client MockFailureFactClient, active *agentv1.RequestMeta) error { +func (s *Spool) RecoverMockUploadFailures(ctx context.Context, client MockFailureFactClient, active *agentpb.RequestMeta) error { pending, err := s.PendingUploadFailures() if err != nil || len(pending) == 0 { return err @@ -115,25 +115,25 @@ func (s *Spool) RecoverMockUploadFailures(ctx context.Context, client MockFailur return nil } -func (s *Spool) deliverMockFailure(ctx context.Context, client MockFailureFactClient, active *agentv1.RequestMeta, record UploadAttempt) error { +func (s *Spool) deliverMockFailure(ctx context.Context, client MockFailureFactClient, active *agentpb.RequestMeta, record UploadAttempt) error { if client == nil || record.FailureFact == nil { return errors.New("Mock failure reporter or durable fact is missing") } if err := validateMockFailureActiveMeta(active); err != nil { return err } - meta := proto.Clone(active).(*agentv1.RequestMeta) + meta := proto.Clone(active).(*agentpb.RequestMeta) meta.RequestId = record.FailureFact.FactId meta.OperationId = record.FailureFact.FactId meta.IdempotencyKey = "mock-upload-failure:" + record.FailureFact.FactId - response, err := client.ReportExecutionEvent(ctx, &agentv1.ReportExecutionEventRequest{ - Meta: meta, Fact: proto.Clone(record.FailureFact).(*agentv1.ExecutionFact), + response, err := client.ReportExecutionEvent(ctx, &agentpb.ReportExecutionEventRequest{ + Meta: meta, Fact: proto.Clone(record.FailureFact).(*agentpb.ExecutionFact), }) if err != nil { return err } receipt := response.GetReceipt() - if receipt.GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || + if receipt.GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || receipt.GetFactId() != record.FailureFact.FactId || receipt.GetContentSha256() != record.FailureFact.ContentSha256 { return errors.New("Dispatcher did not acknowledge the original Mock failure fact") } diff --git a/internal/agent/upload.go b/internal/agent/upload.go index 1825ad5..591ec33 100644 --- a/internal/agent/upload.go +++ b/internal/agent/upload.go @@ -15,7 +15,7 @@ import ( "sync" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) // UploadClient performs the Agent-direct data-plane upload using a restricted @@ -46,7 +46,7 @@ type UploadResult struct { ETag string } -func (c UploadClient) UploadFile(ctx context.Context, grant *agentv1.UploadGrant, path string) (result UploadResult, err error) { +func (c UploadClient) UploadFile(ctx context.Context, grant *agentpb.UploadGrant, path string) (result UploadResult, err error) { if grant == nil { return UploadResult{}, fmt.Errorf("%w: grant is required", ErrUploadGrantInvalid) } diff --git a/internal/agent/upload_failure.go b/internal/agent/upload_failure.go index a1e53e9..53dfbb3 100644 --- a/internal/agent/upload_failure.go +++ b/internal/agent/upload_failure.go @@ -8,15 +8,15 @@ import ( "os" "path/filepath" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "github.com/google/uuid" "google.golang.org/protobuf/proto" ) -func validateUploadFailureFact(record UploadAttempt, fact *agentv1.ExecutionFact) error { +func validateUploadFailureFact(record UploadAttempt, fact *agentpb.ExecutionFact) error { if record.State != "attempted" || record.Binding == nil || record.Asset == nil || record.Result.SizeBytes != 0 || - fact == nil || fact.Binding == nil || fact.Kind != agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS || + fact == nil || fact.Binding == nil || fact.Kind != agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS || !proto.Equal(record.Binding, fact.Binding) || fact.SourceBootId == "" || fact.SourceSequence == 0 || fact.ObservedAtUnixMs <= 0 { return errors.New("Mock failure requires a matching uncompleted upload attempt") } @@ -41,7 +41,7 @@ func validateUploadFailureFact(record UploadAttempt, fact *agentv1.ExecutionFact // RecordUploadFailureFact persists a single terminal failure identity before // any network report. Unknown PUT results never enter this path and cannot be // replayed as a second upload after restart. -func (s *Spool) RecordUploadFailureFact(id string, fact *agentv1.ExecutionFact) error { +func (s *Spool) RecordUploadFailureFact(id string, fact *agentpb.ExecutionFact) error { s.mu.Lock() defer s.mu.Unlock() record, err := s.LoadUploadAttempt(id) @@ -57,7 +57,7 @@ func (s *Spool) RecordUploadFailureFact(id string, fact *agentv1.ExecutionFact) } return nil } - record.FailureFact = proto.Clone(fact).(*agentv1.ExecutionFact) + record.FailureFact = proto.Clone(fact).(*agentpb.ExecutionFact) return writeJSONAtomic(filepath.Join(s.uploadAttemptDir(id), "state.json"), record) } diff --git a/internal/agent/upload_failure_report_test.go b/internal/agent/upload_failure_report_test.go index b3adeb6..aedd2aa 100644 --- a/internal/agent/upload_failure_report_test.go +++ b/internal/agent/upload_failure_report_test.go @@ -9,19 +9,19 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "github.com/google/uuid" "google.golang.org/protobuf/proto" ) type mockFailureRPC struct { - requests []*agentv1.ReportExecutionEventRequest + requests []*agentpb.ReportExecutionEventRequest unavailable bool wrongReceipt bool } -func (m *mockFailureRPC) ReportExecutionEvent(_ context.Context, request *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { - m.requests = append(m.requests, proto.Clone(request).(*agentv1.ReportExecutionEventRequest)) +func (m *mockFailureRPC) ReportExecutionEvent(_ context.Context, request *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { + m.requests = append(m.requests, proto.Clone(request).(*agentpb.ReportExecutionEventRequest)) if m.unavailable { return nil, errors.New("Dispatcher unavailable before receipt") } @@ -29,8 +29,8 @@ func (m *mockFailureRPC) ReportExecutionEvent(_ context.Context, request *agentv if m.wrongReceipt { factID = uuid.NewString() } - return &agentv1.ReportExecutionEventResponse{Receipt: &agentv1.OperationReceipt{ - Result: agentv1.ResultCode_RESULT_CODE_ACCEPTED, FactId: factID, ContentSha256: request.Fact.ContentSha256, + return &agentpb.ReportExecutionEventResponse{Receipt: &agentpb.OperationReceipt{ + Result: agentpb.ResultCode_RESULT_CODE_ACCEPTED, FactId: factID, ContentSha256: request.Fact.ContentSha256, }}, nil } @@ -41,14 +41,14 @@ func TestMockUploadFailureReportReusesDurableFactAcrossActiveBoots(t *testing.T) if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"} if err := spool.ClaimUpload(UploadAttempt{ UploadID: "upload-a", Identity: "identity-a", State: "attempted", RequestID: uuid.NewString(), - Binding: binding, Asset: &agentv1.AssetDescriptor{AssetId: "recording-a"}, + Binding: binding, Asset: &agentpb.AssetDescriptor{AssetId: "recording-a"}, }); err != nil { t.Fatal(err) } - active := &agentv1.RequestMeta{ + active := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-old", DispatcherEpoch: "epoch-a", SessionGeneration: 1, } @@ -69,7 +69,7 @@ func TestMockUploadFailureReportReusesDurableFactAcrossActiveBoots(t *testing.T) if err != nil { t.Fatal(err) } - activeNew := proto.Clone(active).(*agentv1.RequestMeta) + activeNew := proto.Clone(active).(*agentpb.RequestMeta) activeNew.BootId = "boot-new" activeNew.SessionGeneration = 2 remote.unavailable, remote.wrongReceipt = false, true @@ -133,12 +133,12 @@ func TestMockUploadFailureClassificationKeepsUncertainOutcomesUnknown(t *testing } if err := spool.ClaimUpload(UploadAttempt{ UploadID: "unknown-a", Identity: "identity-a", State: "attempted", RequestID: uuid.NewString(), - Binding: &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"}, - Asset: &agentv1.AssetDescriptor{AssetId: "recording-a"}, + Binding: &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"}, + Asset: &agentpb.AssetDescriptor{AssetId: "recording-a"}, }); err != nil { t.Fatal(err) } - active := &agentv1.RequestMeta{ProtocolVersion: "agent.v1", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1} + active := &agentpb.RequestMeta{ProtocolVersion: "agent.v1", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1} remote := &mockFailureRPC{} known, err := spool.ReportMockUploadFailure(context.Background(), remote, active, "unknown-a", &UploadHTTPError{StatusCode: 500}) if err != nil || known || len(remote.requests) != 0 { diff --git a/internal/agent/upload_failure_state_test.go b/internal/agent/upload_failure_state_test.go index 7f30ea2..2285d12 100644 --- a/internal/agent/upload_failure_state_test.go +++ b/internal/agent/upload_failure_state_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "github.com/google/uuid" "google.golang.org/protobuf/proto" ) @@ -20,8 +20,8 @@ func TestMockRecordingFailureFactSurvivesRestartWithoutAnotherPUT(t *testing.T) if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"} - asset := &agentv1.AssetDescriptor{AssetId: "recording-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"} + asset := &agentpb.AssetDescriptor{AssetId: "recording-a"} requestID := uuid.NewString() if err := spool.ClaimUpload(UploadAttempt{ RequestID: requestID, UploadID: "upload-a", Identity: "identity-a", State: "attempted", @@ -31,8 +31,8 @@ func TestMockRecordingFailureFactSurvivesRestartWithoutAnotherPUT(t *testing.T) } payload := []byte(`{"schema_version":"local-mock-recording-failure.v0.1","upload_id":"upload-a","recording_id":"recording-a","error_code":"upload_failed"}`) sum := sha256.Sum256(payload) - fact := &agentv1.ExecutionFact{ - FactId: uuid.NewString(), Binding: binding, Kind: agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS, + fact := &agentpb.ExecutionFact{ + FactId: uuid.NewString(), Binding: binding, Kind: agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS, PayloadJson: payload, ContentSha256: hex.EncodeToString(sum[:]), ObservedAtUnixMs: time.Now().UnixMilli(), SourceBootId: uuid.NewString(), SourceSequence: 1, } @@ -50,7 +50,7 @@ func TestMockRecordingFailureFactSurvivesRestartWithoutAnotherPUT(t *testing.T) if err := restarted.RecordUploadFailureFact("upload-a", fact); err != nil { t.Fatalf("same fact must be idempotent: %v", err) } - conflict := proto.Clone(fact).(*agentv1.ExecutionFact) + conflict := proto.Clone(fact).(*agentpb.ExecutionFact) conflict.FactId = uuid.NewString() if err := restarted.RecordUploadFailureFact("upload-a", conflict); err == nil { t.Fatal("a second failure identity replaced the original") diff --git a/internal/agent/upload_integrity_test.go b/internal/agent/upload_integrity_test.go index 174053b..c80d062 100644 --- a/internal/agent/upload_integrity_test.go +++ b/internal/agent/upload_integrity_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) type uploadTransportFunc func(*http.Request) (*http.Response, error) @@ -36,7 +36,7 @@ func TestUploadDoesNotReportPreReadDigestForChangedBytes(t *testing.T) { } return &http.Response{StatusCode: 200, Header: make(http.Header), Body: io.NopCloser(strings.NewReader(""))}, nil })} - grant := &agentv1.UploadGrant{UploadId: "upload-a", ObjectKey: "recording", TargetUrl: "https://oss.invalid/object", MaxBytes: 8, RequiredChecksumSha256: hex.EncodeToString(sum[:]), ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()} + grant := &agentpb.UploadGrant{UploadId: "upload-a", ObjectKey: "recording", TargetUrl: "https://oss.invalid/object", MaxBytes: 8, RequiredChecksumSha256: hex.EncodeToString(sum[:]), ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()} if _, err := (UploadClient{HTTPClient: client}).UploadFile(context.Background(), grant, path); err == nil { t.Fatal("reported original checksum after sending changed bytes") } diff --git a/internal/agent/upload_state.go b/internal/agent/upload_state.go index dc645d3..b776f92 100644 --- a/internal/agent/upload_state.go +++ b/internal/agent/upload_state.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) // UploadAttempt records no signed URLs or credentials. An attempted PUT whose @@ -19,9 +19,9 @@ type UploadAttempt struct { State string `json:"state"` ObjectKey string `json:"object_key"` Result UploadResult `json:"result"` - Binding *agentv1.ExecutionBinding `json:"binding"` - Asset *agentv1.AssetDescriptor `json:"asset"` - FailureFact *agentv1.ExecutionFact `json:"failure_fact,omitempty"` + Binding *agentpb.ExecutionBinding `json:"binding"` + Asset *agentpb.AssetDescriptor `json:"asset"` + FailureFact *agentpb.ExecutionFact `json:"failure_fact,omitempty"` FailureDelivered bool `json:"failure_delivered,omitempty"` } diff --git a/internal/agent/upload_test.go b/internal/agent/upload_test.go index 3b9dbf4..bab7d06 100644 --- a/internal/agent/upload_test.go +++ b/internal/agent/upload_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func TestUploadTransportFailureIsSingleAttemptAndRedactsSignedURL(t *testing.T) { @@ -24,7 +24,7 @@ func TestUploadTransportFailureIsSingleAttemptAndRedactsSignedURL(t *testing.T) } var attempts int client := &http.Client{Transport: uploadFailureTransport{calls: &attempts}} - grant := &agentv1.UploadGrant{UploadId: "upload-error", ObjectKey: "recording", TargetUrl: "https://oss.example.invalid/object?signature=DO_NOT_LOG", MaxBytes: 5, ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()} + grant := &agentpb.UploadGrant{UploadId: "upload-error", ObjectKey: "recording", TargetUrl: "https://oss.example.invalid/object?signature=DO_NOT_LOG", MaxBytes: 5, ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli()} _, err := (UploadClient{HTTPClient: client}).UploadFile(context.Background(), grant, path) if err == nil { t.Fatal("transport failure hidden") @@ -63,7 +63,7 @@ func TestUploadClientUsesGrantAndVerifiesChecksum(t *testing.T) { if err := os.WriteFile(assetPath, body, 0o600); err != nil { t.Fatal(err) } - grant := &agentv1.UploadGrant{UploadId: "upload-1", TargetUrl: server.URL, ObjectKey: "recording-1", ExpiresAtUnixMs: time.Unix(101, 0).UnixMilli(), Headers: []*agentv1.Header{{Name: "x-upload-token", Value: "mock-token"}}, RequiredChecksumSha256: hex.EncodeToString(digest[:]), MaxBytes: int64(len(body))} + grant := &agentpb.UploadGrant{UploadId: "upload-1", TargetUrl: server.URL, ObjectKey: "recording-1", ExpiresAtUnixMs: time.Unix(101, 0).UnixMilli(), Headers: []*agentpb.Header{{Name: "x-upload-token", Value: "mock-token"}}, RequiredChecksumSha256: hex.EncodeToString(digest[:]), MaxBytes: int64(len(body))} result, err := (UploadClient{AllowInsecureHTTP: true, Now: func() time.Time { return time.Unix(100, 0) }, AllowedHosts: map[string]struct{}{strings.TrimPrefix(server.URL, "http://"): {}}}).UploadFile(context.Background(), grant, assetPath) if err != nil { t.Fatal(err) @@ -81,7 +81,7 @@ func TestUploadClientFailsClosedForGrantMismatchAndHTTP(t *testing.T) { if err := os.WriteFile(assetPath, []byte("bytes"), 0o600); err != nil { t.Fatal(err) } - grant := &agentv1.UploadGrant{UploadId: "upload-2", TargetUrl: "http://127.0.0.1:1/upload", ObjectKey: "recording-2", ExpiresAtUnixMs: time.Now().Add(time.Hour).UnixMilli(), RequiredChecksumSha256: strings.Repeat("a", 64), MaxBytes: 1024} + grant := &agentpb.UploadGrant{UploadId: "upload-2", TargetUrl: "http://127.0.0.1:1/upload", ObjectKey: "recording-2", ExpiresAtUnixMs: time.Now().Add(time.Hour).UnixMilli(), RequiredChecksumSha256: strings.Repeat("a", 64), MaxBytes: 1024} if _, err := (UploadClient{AllowInsecureHTTP: true}).UploadFile(context.Background(), grant, assetPath); !errors.Is(err, ErrUploadChecksumMismatch) { t.Fatalf("expected typed checksum mismatch, got %v", err) } @@ -103,7 +103,7 @@ func TestUploadClientHTTPFailureHasStatusWithoutResponseBody(t *testing.T) { })) defer server.Close() sum := sha256.Sum256(body) - grant := &agentv1.UploadGrant{UploadId: "upload-forbidden", TargetUrl: server.URL, ObjectKey: "recording-forbidden", ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli(), RequiredChecksumSha256: hex.EncodeToString(sum[:]), MaxBytes: 1024} + grant := &agentpb.UploadGrant{UploadId: "upload-forbidden", TargetUrl: server.URL, ObjectKey: "recording-forbidden", ExpiresAtUnixMs: time.Now().Add(time.Minute).UnixMilli(), RequiredChecksumSha256: hex.EncodeToString(sum[:]), MaxBytes: 1024} _, err := (UploadClient{AllowInsecureHTTP: true}).UploadFile(context.Background(), grant, assetPath) var response *UploadHTTPError if !errors.As(err, &response) || response.StatusCode != http.StatusForbidden || strings.Contains(err.Error(), "DO_NOT_LOG_SECRET") { @@ -116,7 +116,7 @@ func TestUploadClientEnforcesSizeAndHost(t *testing.T) { if err := os.WriteFile(assetPath, []byte("bytes"), 0o600); err != nil { t.Fatal(err) } - grant := &agentv1.UploadGrant{UploadId: "upload-3", TargetUrl: "https://oss.example.invalid/upload", ObjectKey: "recording-3", ExpiresAtUnixMs: time.Now().Add(time.Hour).UnixMilli(), MaxBytes: 1} + grant := &agentpb.UploadGrant{UploadId: "upload-3", TargetUrl: "https://oss.example.invalid/upload", ObjectKey: "recording-3", ExpiresAtUnixMs: time.Now().Add(time.Hour).UnixMilli(), MaxBytes: 1} if _, err := (UploadClient{}).UploadFile(context.Background(), grant, assetPath); err == nil { t.Fatal("expected size rejection") } @@ -131,7 +131,7 @@ func TestUploadClientRejectsExpiredGrant(t *testing.T) { if err := os.WriteFile(assetPath, []byte("bytes"), 0o600); err != nil { t.Fatal(err) } - grant := &agentv1.UploadGrant{UploadId: "upload-expired", TargetUrl: "https://oss.example.invalid/upload", ObjectKey: "recording-expired", ExpiresAtUnixMs: time.Unix(100, 0).UnixMilli(), MaxBytes: 1024} + grant := &agentpb.UploadGrant{UploadId: "upload-expired", TargetUrl: "https://oss.example.invalid/upload", ObjectKey: "recording-expired", ExpiresAtUnixMs: time.Unix(100, 0).UnixMilli(), MaxBytes: 1024} if _, err := (UploadClient{Now: func() time.Time { return time.Unix(100, 0) }}).UploadFile(context.Background(), grant, assetPath); !errors.Is(err, ErrUploadGrantExpired) { t.Fatalf("expected typed expired grant rejection, got %v", err) } diff --git a/internal/dispatcher/agent.go b/internal/dispatcher/agent.go index cd7a79a..49ca390 100644 --- a/internal/dispatcher/agent.go +++ b/internal/dispatcher/agent.go @@ -8,7 +8,7 @@ import ( "sync" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/configread" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" @@ -22,7 +22,7 @@ const ( ) type AgentStatusProbe interface { - Probe(ctx context.Context, agentID, cellID string) (*agentv1.AgentStatus, error) + Probe(ctx context.Context, agentID, cellID string) (*agentpb.AgentStatus, error) } type AgentSIPConfigVerifier struct { @@ -42,14 +42,14 @@ func (v *AgentSIPConfigVerifier) VerifyAppliedSIPConfig(ctx context.Context, sna return verifyAppliedSIPConfigStatus(status, v.AgentID, v.CellID, snapshot) } -func verifyAppliedSIPConfigStatus(status *agentv1.AgentStatus, agentID, cellID string, snapshot configread.Snapshot) error { +func verifyAppliedSIPConfigStatus(status *agentpb.AgentStatus, agentID, cellID string, snapshot configread.Snapshot) error { if snapshot.SIPRevision <= 0 { return errors.New("SIP config revision is missing") } if status == nil || status.AgentId != agentID || status.CellId != cellID || status.BootId == "" { return errors.New("Agent status identity or boot ID is invalid") } - var appliedSIP *agentv1.AppliedConfig + var appliedSIP *agentpb.AppliedConfig for _, applied := range status.AppliedConfigs { if applied == nil || applied.Kind != AppliedConfigKindSIP { continue @@ -79,11 +79,11 @@ type AgentSession struct { } type DispatchResult struct { - Permit *agentv1.ExecutionPermit - Receipt *agentv1.OperationReceipt - State agentv1.ExecutionState + Permit *agentpb.ExecutionPermit + Receipt *agentpb.OperationReceipt + State agentpb.ExecutionState Unknown bool - Snapshot *agentv1.ExecutionSnapshot + Snapshot *agentpb.ExecutionSnapshot } // AgentCoordinator owns session binding and the no-retry-after-unknown rule. @@ -92,7 +92,7 @@ type DispatchResult struct { type AgentCoordinator struct { mu sync.Mutex now func() time.Time - clients map[string]agentv1.AgentControlServiceClient + clients map[string]agentpb.AgentControlServiceClient sessions map[string]AgentSession } @@ -100,10 +100,10 @@ func NewAgentCoordinator(now func() time.Time) *AgentCoordinator { if now == nil { now = time.Now } - return &AgentCoordinator{now: now, clients: make(map[string]agentv1.AgentControlServiceClient), sessions: make(map[string]AgentSession)} + return &AgentCoordinator{now: now, clients: make(map[string]agentpb.AgentControlServiceClient), sessions: make(map[string]AgentSession)} } -func (c *AgentCoordinator) Register(agentID string, client agentv1.AgentControlServiceClient) error { +func (c *AgentCoordinator) Register(agentID string, client agentpb.AgentControlServiceClient) error { if agentID == "" || client == nil { return errors.New("agent ID and client are required") } @@ -116,7 +116,7 @@ func (c *AgentCoordinator) Register(agentID string, client agentv1.AgentControlS // Probe performs the pre-activation R01 status read. The response is limited // to deployment status; Activate must still bind the returned boot ID before // any session-authorized operation is attempted. -func (c *AgentCoordinator) Probe(ctx context.Context, agentID, cellID string) (*agentv1.AgentStatus, error) { +func (c *AgentCoordinator) Probe(ctx context.Context, agentID, cellID string) (*agentpb.AgentStatus, error) { if agentID == "" || cellID == "" { return nil, errors.New("agent ID and cell ID are required") } @@ -125,8 +125,8 @@ func (c *AgentCoordinator) Probe(ctx context.Context, agentID, cellID string) (* return nil, err } operationID := "status:" + agentID - response, err := client.GetAgentStatus(ctx, &agentv1.GetAgentStatusRequest{ - Meta: &agentv1.RequestMeta{ + response, err := client.GetAgentStatus(ctx, &agentpb.GetAgentStatusRequest{ + Meta: &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", RequestId: operationID + ":request", TraceId: operationID, @@ -134,7 +134,7 @@ func (c *AgentCoordinator) Probe(ctx context.Context, agentID, cellID string) (* AgentId: agentID, CellId: cellID, }, - Target: &agentv1.AgentBinding{AgentId: agentID, CellId: cellID}, + Target: &agentpb.AgentBinding{AgentId: agentID, CellId: cellID}, }) if err != nil { return nil, err @@ -157,12 +157,12 @@ func (c *AgentCoordinator) Activate(ctx context.Context, agentID, cellID, bootID return AgentSession{}, errors.New("cell, boot and dispatcher epoch are required") } operationID := fmt.Sprintf("activate:%s:%s", agentID, bootID) - meta := &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + ":request", TraceId: operationID, OperationId: operationID, DispatcherEpoch: epoch, AgentId: agentID, CellId: cellID, BootId: bootID} - response, err := client.ActivateAgent(ctx, &agentv1.ActivateAgentRequest{Meta: meta, Binding: &agentv1.AgentBinding{AgentId: agentID, CellId: cellID, ExpectedBootId: bootID, DispatcherEpoch: epoch, SessionGeneration: generation}, ActivationOperationId: operationID}) + meta := &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + ":request", TraceId: operationID, OperationId: operationID, DispatcherEpoch: epoch, AgentId: agentID, CellId: cellID, BootId: bootID} + response, err := client.ActivateAgent(ctx, &agentpb.ActivateAgentRequest{Meta: meta, Binding: &agentpb.AgentBinding{AgentId: agentID, CellId: cellID, ExpectedBootId: bootID, DispatcherEpoch: epoch, SessionGeneration: generation}, ActivationOperationId: operationID}) if err != nil { return AgentSession{}, err } - if response.Session == nil || response.State != agentv1.ActivationState_ACTIVATION_STATE_ACTIVE { + if response.Session == nil || response.State != agentpb.ActivationState_ACTIVATION_STATE_ACTIVE { return AgentSession{}, errors.New("Agent activation was not active") } session := AgentSession{AgentID: agentID, CellID: cellID, BootID: bootID, DispatcherEpoch: epoch, SessionGeneration: response.Session.SessionGeneration, ExpiresAtUnixMs: response.Session.ExpiresAtUnixMs} @@ -172,7 +172,7 @@ func (c *AgentCoordinator) Activate(ctx context.Context, agentID, cellID, bootID return session, nil } -func (c *AgentCoordinator) ExecuteRaw(ctx context.Context, agentID string, binding *agentv1.ExecutionBinding, raw []byte, reservationID, configSHA256 string) (DispatchResult, error) { +func (c *AgentCoordinator) ExecuteRaw(ctx context.Context, agentID string, binding *agentpb.ExecutionBinding, raw []byte, reservationID, configSHA256 string) (DispatchResult, error) { if binding == nil || binding.ExecutionId == "" || reservationID == "" { return DispatchResult{}, errors.New("execution binding and reservation are required") } @@ -180,12 +180,12 @@ func (c *AgentCoordinator) ExecuteRaw(ctx context.Context, agentID string, bindi if err != nil { return DispatchResult{}, err } - permitRequest := &agentv1.GetExecutionPermitRequest{Meta: c.meta(session, "permit:"+binding.ExecutionId, "permit:"+binding.ExecutionId), Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), ResourceReservationId: reservationID, ExpectedTaskRevision: binding.TaskRevision, ConfigSha256: configSHA256} + permitRequest := &agentpb.GetExecutionPermitRequest{Meta: c.meta(session, "permit:"+binding.ExecutionId, "permit:"+binding.ExecutionId), Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), ResourceReservationId: reservationID, ExpectedTaskRevision: binding.TaskRevision, ConfigSha256: configSHA256} permitResponse, err := client.GetExecutionPermit(ctx, permitRequest) if err != nil { return c.reconcileUnknown(ctx, client, session, binding, err) } - if permitResponse != nil && permitResponse.Permit == nil && permitResponse.Receipt != nil && permitResponse.Receipt.Result == agentv1.ResultCode_RESULT_CODE_APPLIED { + if permitResponse != nil && permitResponse.Permit == nil && permitResponse.Receipt != nil && permitResponse.Receipt.Result == agentpb.ResultCode_RESULT_CODE_APPLIED { // A durable receipt without the permit body is an incomplete read, not a // reason to originate. Re-read the same reservation under a new read key. permitRequest.Meta = c.meta(session, "permit-reconcile:"+binding.ExecutionId, "permit-reconcile:"+binding.ExecutionId) @@ -194,14 +194,14 @@ func (c *AgentCoordinator) ExecuteRaw(ctx context.Context, agentID string, bindi return c.reconcileUnknown(ctx, client, session, binding, err) } } - if permitResponse == nil || permitResponse.Permit == nil || permitResponse.Receipt == nil || permitResponse.Receipt.Result == agentv1.ResultCode_RESULT_CODE_REJECTED || permitResponse.Receipt.Result == agentv1.ResultCode_RESULT_CODE_CONFLICT { + if permitResponse == nil || permitResponse.Permit == nil || permitResponse.Receipt == nil || permitResponse.Receipt.Result == agentpb.ResultCode_RESULT_CODE_REJECTED || permitResponse.Receipt.Result == agentpb.ResultCode_RESULT_CODE_CONFLICT { if permitResponse == nil { return DispatchResult{}, fmt.Errorf("Agent did not grant execution permit: empty response") } return DispatchResult{}, fmt.Errorf("Agent did not grant execution permit: result=%s failure=%v permit=%v", permitResponse.Receipt.GetResult().String(), permitResponse.Receipt.GetFailure(), permitResponse.Permit) } executeMeta := c.meta(session, "execute:"+binding.ExecutionId, "execute:"+binding.ExecutionId) - executeResponse, err := client.Execute(ctx, &agentv1.ExecuteRequest{Meta: executeMeta, Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), CallExecuteJson: append([]byte(nil), raw...), ConfigSha256: configSHA256, PermitId: permitResponse.Permit.PermitId}) + executeResponse, err := client.Execute(ctx, &agentpb.ExecuteRequest{Meta: executeMeta, Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), CallExecuteJson: append([]byte(nil), raw...), ConfigSha256: configSHA256, PermitId: permitResponse.Permit.PermitId}) if err != nil { return c.reconcileUnknown(ctx, client, session, binding, err) } @@ -211,16 +211,16 @@ func (c *AgentCoordinator) ExecuteRaw(ctx context.Context, agentID string, bindi return DispatchResult{Permit: permitResponse.Permit, Receipt: executeResponse.Receipt, State: executeResponse.State}, nil } -func (c *AgentCoordinator) Control(ctx context.Context, agentID string, binding *agentv1.ExecutionBinding, action agentv1.ControlAction, policy agentv1.ActiveCallPolicy) (*agentv1.ApplyTaskControlResponse, error) { +func (c *AgentCoordinator) Control(ctx context.Context, agentID string, binding *agentpb.ExecutionBinding, action agentpb.ControlAction, policy agentpb.ActiveCallPolicy) (*agentpb.ApplyTaskControlResponse, error) { client, session, err := c.clientAndSession(agentID) if err != nil { return nil, err } meta := c.meta(session, fmt.Sprintf("control:%s:%d", binding.ExecutionId, binding.TaskRevision), fmt.Sprintf("control:%s:%d", binding.ExecutionId, binding.TaskRevision)) - return client.ApplyTaskControl(ctx, &agentv1.ApplyTaskControlRequest{Meta: meta, Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), Action: action, ActiveCallPolicy: policy, ExpectedTaskRevision: binding.TaskRevision}) + return client.ApplyTaskControl(ctx, &agentpb.ApplyTaskControlRequest{Meta: meta, Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), Action: action, ActiveCallPolicy: policy, ExpectedTaskRevision: binding.TaskRevision}) } -func (c *AgentCoordinator) client(agentID string) (agentv1.AgentControlServiceClient, error) { +func (c *AgentCoordinator) client(agentID string) (agentpb.AgentControlServiceClient, error) { c.mu.Lock() defer c.mu.Unlock() client := c.clients[agentID] @@ -230,7 +230,7 @@ func (c *AgentCoordinator) client(agentID string) (agentv1.AgentControlServiceCl return client, nil } -func (c *AgentCoordinator) clientAndSession(agentID string) (agentv1.AgentControlServiceClient, AgentSession, error) { +func (c *AgentCoordinator) clientAndSession(agentID string) (agentpb.AgentControlServiceClient, AgentSession, error) { client, err := c.client(agentID) if err != nil { return nil, AgentSession{}, err @@ -247,7 +247,7 @@ func (c *AgentCoordinator) clientAndSession(agentID string) (agentv1.AgentContro // AuthorizeInboundMeta accepts an Agent→Dispatcher fact only from the current // activated Endpoint session. An old boot's durable fact can be replayed, but // its request metadata must use the newly activated boot and generation. -func (c *AgentCoordinator) AuthorizeInboundMeta(meta *agentv1.RequestMeta) error { +func (c *AgentCoordinator) AuthorizeInboundMeta(meta *agentpb.RequestMeta) error { if c == nil || meta == nil || meta.ProtocolVersion != "agent.v1" || meta.AgentId == "" { return fmt.Errorf("active Agent session is required: %w", store.ErrCommandConflict) } @@ -263,13 +263,13 @@ func (c *AgentCoordinator) AuthorizeInboundMeta(meta *agentv1.RequestMeta) error return nil } -func (c *AgentCoordinator) meta(session AgentSession, operationID, idempotencyKey string) *agentv1.RequestMeta { - return &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + ":request", TraceId: operationID, OperationId: operationID, IdempotencyKey: idempotencyKey, DispatcherEpoch: session.DispatcherEpoch, AgentId: session.AgentID, CellId: session.CellID, BootId: session.BootID, SessionGeneration: session.SessionGeneration} +func (c *AgentCoordinator) meta(session AgentSession, operationID, idempotencyKey string) *agentpb.RequestMeta { + return &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + ":request", TraceId: operationID, OperationId: operationID, IdempotencyKey: idempotencyKey, DispatcherEpoch: session.DispatcherEpoch, AgentId: session.AgentID, CellId: session.CellID, BootId: session.BootID, SessionGeneration: session.SessionGeneration} } -func (c *AgentCoordinator) reconcileUnknown(ctx context.Context, client agentv1.AgentControlServiceClient, session AgentSession, binding *agentv1.ExecutionBinding, cause error) (DispatchResult, error) { +func (c *AgentCoordinator) reconcileUnknown(ctx context.Context, client agentpb.AgentControlServiceClient, session AgentSession, binding *agentpb.ExecutionBinding, cause error) (DispatchResult, error) { queryMeta := c.meta(session, "query:"+binding.ExecutionId, "query:"+binding.ExecutionId) - response, err := client.QueryExecution(ctx, &agentv1.QueryExecutionRequest{Meta: queryMeta, Binding: proto.Clone(binding).(*agentv1.ExecutionBinding)}) + response, err := client.QueryExecution(ctx, &agentpb.QueryExecutionRequest{Meta: queryMeta, Binding: proto.Clone(binding).(*agentpb.ExecutionBinding)}) if err == nil && response != nil && response.Snapshot != nil { return DispatchResult{Unknown: true, Snapshot: response.Snapshot}, fmt.Errorf("%w: %v", ErrRemoteResultUnknown, cause) } diff --git a/internal/dispatcher/agent_inbound_session_test.go b/internal/dispatcher/agent_inbound_session_test.go index 7810ecc..6f0f9a3 100644 --- a/internal/dispatcher/agent_inbound_session_test.go +++ b/internal/dispatcher/agent_inbound_session_test.go @@ -5,13 +5,13 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" ) type inboundSessionTestClient struct { - agentv1.AgentControlServiceClient + agentpb.AgentControlServiceClient } func TestInboundAgentFactRequiresCurrentUnexpiredActivatedSession(t *testing.T) { @@ -24,7 +24,7 @@ func TestInboundAgentFactRequiresCurrentUnexpiredActivatedSession(t *testing.T) AgentID: "agent-a", CellID: "cell-a", BootID: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 3, ExpiresAtUnixMs: now.Add(time.Minute).UnixMilli(), } - meta := &agentv1.RequestMeta{ + meta := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 3, } @@ -33,16 +33,16 @@ func TestInboundAgentFactRequiresCurrentUnexpiredActivatedSession(t *testing.T) } for _, tc := range []struct { name string - change func(*agentv1.RequestMeta) + change func(*agentpb.RequestMeta) }{ - {"old boot", func(m *agentv1.RequestMeta) { m.BootId = "boot-old" }}, - {"old generation", func(m *agentv1.RequestMeta) { m.SessionGeneration = 2 }}, - {"other cell", func(m *agentv1.RequestMeta) { m.CellId = "cell-other" }}, - {"other epoch", func(m *agentv1.RequestMeta) { m.DispatcherEpoch = "epoch-other" }}, - {"unregistered Agent", func(m *agentv1.RequestMeta) { m.AgentId = "agent-other" }}, + {"old boot", func(m *agentpb.RequestMeta) { m.BootId = "boot-old" }}, + {"old generation", func(m *agentpb.RequestMeta) { m.SessionGeneration = 2 }}, + {"other cell", func(m *agentpb.RequestMeta) { m.CellId = "cell-other" }}, + {"other epoch", func(m *agentpb.RequestMeta) { m.DispatcherEpoch = "epoch-other" }}, + {"unregistered Agent", func(m *agentpb.RequestMeta) { m.AgentId = "agent-other" }}, } { t.Run(tc.name, func(t *testing.T) { - changed := proto.Clone(meta).(*agentv1.RequestMeta) + changed := proto.Clone(meta).(*agentpb.RequestMeta) tc.change(changed) if err := coordinator.AuthorizeInboundMeta(changed); !errors.Is(err, store.ErrCommandConflict) { t.Fatalf("unbound Agent report passed: %v", err) diff --git a/internal/dispatcher/agent_test.go b/internal/dispatcher/agent_test.go index e13c5ce..e1eff83 100644 --- a/internal/dispatcher/agent_test.go +++ b/internal/dispatcher/agent_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" rpcserver "git.ipao.vip/rogee/go-sip/internal/rpc" "git.ipao.vip/rogee/go-sip/internal/testfixture" @@ -19,7 +19,7 @@ func TestAgentCoordinatorProbesBeforeActivation(t *testing.T) { listener := bufconn.Listen(1024 * 1024) server := rpcserver.NewServer(rpcserver.ServerOptions{ Now: func() time.Time { return time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC) }, - Status: &agentv1.AgentStatus{ + Status: &agentpb.AgentStatus{ AgentId: "agent-1", CellId: "cell-1", BootId: "boot-probed", @@ -27,7 +27,7 @@ func TestAgentCoordinatorProbesBeforeActivation(t *testing.T) { }, }) grpcServer := grpc.NewServer() - agentv1.RegisterAgentControlServiceServer(grpcServer, server) + agentpb.RegisterAgentControlServiceServer(grpcServer, server) go func() { _ = grpcServer.Serve(listener) }() defer grpcServer.Stop() conn, err := grpc.NewClient("passthrough:///bufnet", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }), grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -37,7 +37,7 @@ func TestAgentCoordinatorProbesBeforeActivation(t *testing.T) { defer conn.Close() coordinator := NewAgentCoordinator(func() time.Time { return time.Unix(100, 0) }) - if err := coordinator.Register("agent-1", agentv1.NewAgentControlServiceClient(conn)); err != nil { + if err := coordinator.Register("agent-1", agentpb.NewAgentControlServiceClient(conn)); err != nil { t.Fatal(err) } status, err := coordinator.Probe(context.Background(), "agent-1", "cell-1") @@ -64,7 +64,7 @@ func TestAgentCoordinatorActivatesExecutesAndControlsWithoutRetryingOriginate(t listener := bufconn.Listen(1024 * 1024) server := rpcserver.NewServer(rpcserver.ServerOptions{Now: func() time.Time { return time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC) }}) grpcServer := grpc.NewServer() - agentv1.RegisterAgentControlServiceServer(grpcServer, server) + agentpb.RegisterAgentControlServiceServer(grpcServer, server) go func() { _ = grpcServer.Serve(listener) }() defer grpcServer.Stop() conn, err := grpc.NewClient("passthrough:///bufnet", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }), grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -74,7 +74,7 @@ func TestAgentCoordinatorActivatesExecutesAndControlsWithoutRetryingOriginate(t defer conn.Close() coordinator := NewAgentCoordinator(func() time.Time { return time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC) }) - if err := coordinator.Register("agent-1", agentv1.NewAgentControlServiceClient(conn)); err != nil { + if err := coordinator.Register("agent-1", agentpb.NewAgentControlServiceClient(conn)); err != nil { t.Fatal(err) } if _, err := coordinator.Activate(context.Background(), "agent-1", "cell-1", "boot-1", "epoch-1", 1); err != nil { @@ -89,7 +89,7 @@ func TestAgentCoordinatorActivatesExecutesAndControlsWithoutRetryingOriginate(t if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} first, err := coordinator.ExecuteRaw(context.Background(), "agent-1", binding, raw, "reservation-1", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") if err != nil { t.Fatal(err) @@ -104,11 +104,11 @@ func TestAgentCoordinatorActivatesExecutesAndControlsWithoutRetryingOriginate(t if second.Permit == nil || second.Receipt == nil || second.Unknown { t.Fatalf("unexpected replay result: %+v", second) } - control, err := coordinator.Control(context.Background(), "agent-1", binding, agentv1.ControlAction_CONTROL_ACTION_PAUSE, agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN) + control, err := coordinator.Control(context.Background(), "agent-1", binding, agentpb.ControlAction_CONTROL_ACTION_PAUSE, agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN) if err != nil { t.Fatal(err) } - if control.Receipt == nil || control.State != agentv1.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED { + if control.Receipt == nil || control.State != agentpb.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED { t.Fatalf("unexpected control result: %+v", control) } } diff --git a/internal/dispatcher/authorized_agent.go b/internal/dispatcher/authorized_agent.go index fe82c65..cda0005 100644 --- a/internal/dispatcher/authorized_agent.go +++ b/internal/dispatcher/authorized_agent.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/protobuf/proto" ) @@ -47,9 +47,9 @@ func (c *AgentCoordinator) ExecuteAuthorized(ctx context.Context, agentID string return DispatchResult{}, err } meta := c.meta(session, "authorized:"+authorized.Binding.ExecutionId, "authorized:"+authorized.Binding.ExecutionId) - request := &agentv1.ExecuteAuthorizedRequest{ + request := &agentpb.ExecuteAuthorizedRequest{ SchemaVersion: localAuthorizedOriginationVersion, - Meta: meta, Binding: proto.Clone(authorized.Binding).(*agentv1.ExecutionBinding), + Meta: meta, Binding: proto.Clone(authorized.Binding).(*agentpb.ExecutionBinding), SelectedTrunkId: authorized.TrunkID, CallerId: authorized.CallerID, Callee: authorized.Callee, RingTimeoutMs: authorized.RingTimeoutMS, MaxCallDurationMs: authorized.MaxCallDurationMS, DialBeforeUnixMs: authorized.AllowedUntil.UnixMilli(), BoundSnapshotSha256: authorized.SnapshotSHA256, @@ -63,11 +63,11 @@ func (c *AgentCoordinator) ExecuteAuthorized(ctx context.Context, agentID string } result := DispatchResult{Receipt: response.Receipt, State: response.State} switch response.Receipt.Result { - case agentv1.ResultCode_RESULT_CODE_APPLIED: - if response.State == agentv1.ExecutionState_EXECUTION_STATE_TERMINAL { + case agentpb.ResultCode_RESULT_CODE_APPLIED: + if response.State == agentpb.ExecutionState_EXECUTION_STATE_TERMINAL { return result, nil } - case agentv1.ResultCode_RESULT_CODE_UNKNOWN: + case agentpb.ResultCode_RESULT_CODE_UNKNOWN: result.Unknown = true return result, fmt.Errorf("%w: Agent authorized execution is unknown", ErrRemoteResultUnknown) } diff --git a/internal/dispatcher/dispatcher.go b/internal/dispatcher/dispatcher.go index 20c3dbd..0f59d18 100644 --- a/internal/dispatcher/dispatcher.go +++ b/internal/dispatcher/dispatcher.go @@ -10,7 +10,7 @@ import ( "sync" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/configread" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/mq" @@ -123,7 +123,7 @@ func (d *Dispatcher) ExecuteReserved(ctx context.Context, coordinator *AgentCoor } return DispatchResult{}, errors.New("reserved task does not match call.execute binding") } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, diff --git a/internal/dispatcher/dispatcher_test.go b/internal/dispatcher/dispatcher_test.go index 9b81235..d9e43db 100644 --- a/internal/dispatcher/dispatcher_test.go +++ b/internal/dispatcher/dispatcher_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "git.ipao.vip/rogee/go-sip/internal/testfixture" _ "modernc.org/sqlite" @@ -262,7 +262,7 @@ func TestExecuteReservedBindsQuotaAndAgentExecution(t *testing.T) { t.Fatal(err) } coordinator := NewAgentCoordinator(func() time.Time { return now }) - client := startMockAgent(t, &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1"}) + client := startMockAgent(t, &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1"}) if err := coordinator.Register("agent-1", client); err != nil { t.Fatal(err) } diff --git a/internal/dispatcher/local_flow_test.go b/internal/dispatcher/local_flow_test.go index f8e1bb3..0fccb36 100644 --- a/internal/dispatcher/local_flow_test.go +++ b/internal/dispatcher/local_flow_test.go @@ -6,7 +6,7 @@ import ( "time" "git.ipao.vip/rogee/go-sip/contracts" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/ai" "git.ipao.vip/rogee/go-sip/internal/contract" @@ -105,6 +105,6 @@ func TestLocalContractBackedFlowEvidence(t *testing.T) { } } -func agentStatusForLocalFlow() agentv1.AgentStatus { - return agentv1.AgentStatus{AgentId: "agent-a", CellId: "cell-a"} +func agentStatusForLocalFlow() agentpb.AgentStatus { + return agentpb.AgentStatus{AgentId: "agent-a", CellId: "cell-a"} } diff --git a/internal/dispatcher/local_mock_failure.go b/internal/dispatcher/local_mock_failure.go index 1a7dc28..1f8a5d8 100644 --- a/internal/dispatcher/local_mock_failure.go +++ b/internal/dispatcher/local_mock_failure.go @@ -7,7 +7,7 @@ import ( "log" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/store" "github.com/google/uuid" @@ -19,12 +19,12 @@ import ( // for a confirmed Mock recording. The fact and unavailable outcome are one // SQLite transaction; the normal recovery path finishes an outbox write if // interrupted before the final result is enqueued. -func (d *Dispatcher) RecordLocalMockRecordingFailure(ctx context.Context, fact *agentv1.ExecutionFact) error { +func (d *Dispatcher) RecordLocalMockRecordingFailure(ctx context.Context, fact *agentpb.ExecutionFact) error { if err := ctx.Err(); err != nil { return err } if d.store == nil || d.dispatcherID == "" || fact == nil || fact.Binding == nil || - fact.Kind != agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS || fact.SourceBootId == "" || fact.SourceSequence == 0 { + fact.Kind != agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS || fact.SourceBootId == "" || fact.SourceSequence == 0 { return fmt.Errorf("Mock recording failure requires a bound execution fact: %w", store.ErrCommandConflict) } factID, err := uuid.Parse(fact.FactId) diff --git a/internal/dispatcher/local_mock_pending_result_test.go b/internal/dispatcher/local_mock_pending_result_test.go index e64dfa0..6aa82c7 100644 --- a/internal/dispatcher/local_mock_pending_result_test.go +++ b/internal/dispatcher/local_mock_pending_result_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" "git.ipao.vip/rogee/go-sip/internal/rpc" "git.ipao.vip/rogee/go-sip/internal/store" @@ -22,7 +22,7 @@ type mockFailureEventForwarder struct { attempts int } -func (f *mockFailureEventForwarder) ReportExecutionEvent(ctx context.Context, request *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (f *mockFailureEventForwarder) ReportExecutionEvent(ctx context.Context, request *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { response, err := f.handler.ReportExecutionEvent(ctx, request) f.attempts++ if err == nil && f.loseReceipt { @@ -85,7 +85,7 @@ func TestRecoverPendingMockRecordingResultWithoutAgentOrSecondUpload(t *testing. if err := st.DB().QueryRow(`SELECT state FROM reservations WHERE execution_id=?`, executionID).Scan(&reservation); err != nil || reservation != "released" { t.Fatalf("call end did not release quota before upload: state=%q err=%v", reservation, err) } - var uploadRequest *agentv1.CompleteUploadRequest + var uploadRequest *agentpb.CompleteUploadRequest var uploadRecord store.UploadRecord if tc.withUpload { current = endedAt.Add(time.Second) @@ -93,17 +93,17 @@ func TestRecoverPendingMockRecordingResultWithoutAgentOrSecondUpload(t *testing. if err != nil { t.Fatal(err) } - asset := &agentv1.AssetDescriptor{ - Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: terminal.Recording.RecordingID, + asset := &agentpb.AssetDescriptor{ + Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: terminal.Recording.RecordingID, CallId: terminal.CallID, Format: terminal.Recording.Format, Channels: int32(terminal.Recording.Channels), SampleRateHz: int32(terminal.Recording.SampleRateHz), DurationMs: terminal.Recording.DurationMs, SizeBytes: 128000, ChecksumSha256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", } - grantRequest := &agentv1.RequestUploadRequest{Binding: authorized.Binding, Asset: asset, UploadId: terminal.Recording.UploadID} + grantRequest := &agentpb.RequestUploadRequest{Binding: authorized.Binding, Asset: asset, UploadId: terminal.Recording.UploadID} if err := d.AuthorizeLocalMockUpload(context.Background(), grantRequest); err != nil { t.Fatalf("confirmed Mock recording cannot request its first grant: %v", err) } - unbound := proto.Clone(grantRequest).(*agentv1.RequestUploadRequest) + unbound := proto.Clone(grantRequest).(*agentpb.RequestUploadRequest) unbound.UploadId = "unbound-recording" if err := d.AuthorizeLocalMockUpload(context.Background(), unbound); !errors.Is(err, store.ErrCommandConflict) { t.Fatalf("unbound Mock recording received grant authorization: %v", err) @@ -116,7 +116,7 @@ func TestRecoverPendingMockRecordingResultWithoutAgentOrSecondUpload(t *testing. if _, err := st.IssueUploadGrant(uploadRecord, "op-recording", "request-recording"); err != nil { t.Fatal(err) } - uploadRequest = &agentv1.CompleteUploadRequest{ + uploadRequest = &agentpb.CompleteUploadRequest{ Binding: authorized.Binding, Asset: asset, UploadId: uploadRecord.UploadID, UploadedSizeBytes: asset.SizeBytes, UploadedChecksumSha256: asset.ChecksumSha256, } @@ -161,18 +161,18 @@ func TestRecoverPendingMockRecordingResultWithoutAgentOrSecondUpload(t *testing. if err := agentSpool.ClaimUpload(agent.UploadAttempt{ UploadID: terminal.Recording.UploadID, Identity: "Mock-" + executionID, RequestID: uuid.NewString(), State: "attempted", Binding: authorized.Binding, - Asset: &agentv1.AssetDescriptor{AssetId: terminal.Recording.RecordingID}, + Asset: &agentpb.AssetDescriptor{AssetId: terminal.Recording.RecordingID}, }); err != nil { t.Fatal(err) } activeBoot, activeGeneration := "boot-original", uint64(1) - activeMeta := &agentv1.RequestMeta{ + activeMeta := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", AgentId: agentID, CellId: "cell-a", BootId: activeBoot, DispatcherEpoch: "epoch-a", SessionGeneration: activeGeneration, } eventServer, err := rpc.NewDispatcherEventServer(st, rpc.DispatcherEventServerOptions{ Now: func() time.Time { return current }, LocalV3RecordingFailure: d.RecordLocalMockRecordingFailure, - LocalV3SessionCheck: func(meta *agentv1.RequestMeta) error { + LocalV3SessionCheck: func(meta *agentpb.RequestMeta) error { if meta == nil || meta.AgentId != agentID || meta.CellId != "cell-a" || meta.BootId != activeBoot || meta.DispatcherEpoch != "epoch-a" || meta.SessionGeneration != activeGeneration { return store.ErrCommandConflict diff --git a/internal/dispatcher/local_mock_recovery.go b/internal/dispatcher/local_mock_recovery.go index 828b619..439f97d 100644 --- a/internal/dispatcher/local_mock_recovery.go +++ b/internal/dispatcher/local_mock_recovery.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" ) @@ -43,8 +43,8 @@ func (d *Dispatcher) RecoverAuthorizedMockResults(ctx context.Context, agentID s } authorized, err := d.issuedMockAuthorization(executionID) if err == nil { - var snapshot *agentv1.ExecutionSnapshot - snapshot, err = coordinator.observeAuthorizedMock(ctx, agentID, &agentv1.ExecutionBinding{ExecutionId: executionID}) + var snapshot *agentpb.ExecutionSnapshot + snapshot, err = coordinator.observeAuthorizedMock(ctx, agentID, &agentpb.ExecutionBinding{ExecutionId: executionID}) if err == nil { err = validateMockTerminal(authorized, snapshot) } @@ -204,7 +204,7 @@ func (d *Dispatcher) mockAuthorizationFromCandidate(candidate store.LocalOrigina } return LocalDialAuthorization{ dialDecision: dialDecision{TrunkID: candidate.Snapshot.SelectedTrunkID}, - Binding: &agentv1.ExecutionBinding{ + Binding: &agentpb.ExecutionBinding{ ExecutionId: candidate.ExecutionID, TaskItemId: candidate.CommandID, TenantId: candidate.TenantID, TenantKey: candidate.TenantKey, TaskId: candidate.TaskID, TaskRevision: candidate.Snapshot.TaskRevision, AgentVersionId: task.Agent.AgentVersionID, RoutePolicyId: task.RoutePolicyID, @@ -215,10 +215,10 @@ func (d *Dispatcher) mockAuthorizationFromCandidate(candidate store.LocalOrigina }, nil } -func validateMockTerminal(authorized LocalDialAuthorization, snapshot *agentv1.ExecutionSnapshot) error { +func validateMockTerminal(authorized LocalDialAuthorization, snapshot *agentpb.ExecutionSnapshot) error { if authorized.Binding == nil || snapshot == nil || !proto.Equal(snapshot.Binding, authorized.Binding) || snapshot.AttemptId != authorized.Binding.AttemptId || - snapshot.State != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL || snapshot.Unknown || + snapshot.State != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL || snapshot.Unknown || (snapshot.CallState != "mock_no_answer" && snapshot.CallState != "mock_deadline_closed_without_dial") { return fmt.Errorf("%w: authorized Mock execution %s has no confirmed terminal fact (state=%s call_state=%q unknown=%t)", ErrRemoteResultUnknown, authorized.Binding.GetExecutionId(), snapshot.GetState(), snapshot.GetCallState(), snapshot.GetUnknown()) diff --git a/internal/dispatcher/local_mock_recovery_test.go b/internal/dispatcher/local_mock_recovery_test.go index 17e02df..ca48259 100644 --- a/internal/dispatcher/local_mock_recovery_test.go +++ b/internal/dispatcher/local_mock_recovery_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func TestRecoverIssuedMockTerminalWithoutReorigination(t *testing.T) { @@ -30,7 +30,7 @@ func TestRecoverIssuedMockTerminalWithoutReorigination(t *testing.T) { if err := st.DB().QueryRow(`SELECT execution_id FROM tasks WHERE task_item_id='command-recovery'`).Scan(&executionID); err != nil { t.Fatal(err) } - if result, err := d.DispatchAuthorizedLocal(context.Background(), executionID, agentID, coordinator); err != nil || result.State != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL || client.attempts != 1 { + if result, err := d.DispatchAuthorizedLocal(context.Background(), executionID, agentID, coordinator); err != nil || result.State != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL || client.attempts != 1 { t.Fatalf("initial issued instruction: result=%+v attempts=%d err=%v", result, client.attempts, err) } if _, _, err := st.LoadLocalCallTerminal(executionID); err != sql.ErrNoRows { diff --git a/internal/dispatcher/local_mock_result.go b/internal/dispatcher/local_mock_result.go index 261ed72..95f9bee 100644 --- a/internal/dispatcher/local_mock_result.go +++ b/internal/dispatcher/local_mock_result.go @@ -7,7 +7,7 @@ import ( "log/slog" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" ) @@ -35,18 +35,18 @@ func (d *Dispatcher) DispatchAndFinalizeAuthorizedMock(ctx context.Context, exec slog.Info("reconciled uncertain Mock Agent reply from confirmed terminal observation", "execution_id", executionID) } result.Unknown = false - result.State = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL + result.State = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL return result, nil } -func (c *AgentCoordinator) observeAuthorizedMock(ctx context.Context, agentID string, binding *agentv1.ExecutionBinding) (*agentv1.ExecutionSnapshot, error) { +func (c *AgentCoordinator) observeAuthorizedMock(ctx context.Context, agentID string, binding *agentpb.ExecutionBinding) (*agentpb.ExecutionSnapshot, error) { client, session, err := c.clientAndSession(agentID) if err != nil { return nil, err } - request := &agentv1.QueryExecutionRequest{ + request := &agentpb.QueryExecutionRequest{ Meta: c.meta(session, "observe:"+binding.ExecutionId, "observe:"+binding.ExecutionId), - Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), + Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), } response, err := client.QueryExecution(ctx, request) if err != nil { @@ -58,7 +58,7 @@ func (c *AgentCoordinator) observeAuthorizedMock(ctx context.Context, agentID st return response.Snapshot, nil } -func (d *Dispatcher) completeAuthorizedMockTerminal(authorized LocalDialAuthorization, snapshot *agentv1.ExecutionSnapshot) error { +func (d *Dispatcher) completeAuthorizedMockTerminal(authorized LocalDialAuthorization, snapshot *agentpb.ExecutionSnapshot) error { if snapshot.ObservedAtUnixMs <= 0 || authorized.AuthorizedAt.IsZero() || authorized.TraceID == "" || authorized.Binding == nil || authorized.Binding.AttemptId == "" || authorized.Callee == "" || authorized.TrunkID == "" { return errors.New("incomplete bound Mock terminal observation") diff --git a/internal/dispatcher/local_mock_upload.go b/internal/dispatcher/local_mock_upload.go index b5dac45..dcb1b58 100644 --- a/internal/dispatcher/local_mock_upload.go +++ b/internal/dispatcher/local_mock_upload.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" ) @@ -13,7 +13,7 @@ import ( // AuthorizeLocalMockUpload rejects grants not bound to a confirmed Mock // recording. This check runs before creating an OSS PUT grant, not just after // a PUT has already happened. -func (d *Dispatcher) AuthorizeLocalMockUpload(ctx context.Context, request *agentv1.RequestUploadRequest) error { +func (d *Dispatcher) AuthorizeLocalMockUpload(ctx context.Context, request *agentpb.RequestUploadRequest) error { if request == nil { return errors.New("local Mock upload request is required") } @@ -34,7 +34,7 @@ func (d *Dispatcher) AuthorizeLocalMockUpload(ctx context.Context, request *agen return nil } -func (d *Dispatcher) localMockUploadOwner(ctx context.Context, binding *agentv1.ExecutionBinding, asset *agentv1.AssetDescriptor, uploadID string) (LocalDialAuthorization, store.LocalCallTerminal, string, error) { +func (d *Dispatcher) localMockUploadOwner(ctx context.Context, binding *agentpb.ExecutionBinding, asset *agentpb.AssetDescriptor, uploadID string) (LocalDialAuthorization, store.LocalCallTerminal, string, error) { if err := ctx.Err(); err != nil { return LocalDialAuthorization{}, store.LocalCallTerminal{}, "", err } @@ -54,7 +54,7 @@ func (d *Dispatcher) localMockUploadOwner(ctx context.Context, binding *agentv1. } manifest := fact.Recording if fact.Source != "mock_agent" || !fact.RecordingExpected || manifest == nil || - asset.Kind != agentv1.AssetKind_ASSET_KIND_RECORDING || asset.AssetId != manifest.RecordingID || + asset.Kind != agentpb.AssetKind_ASSET_KIND_RECORDING || asset.AssetId != manifest.RecordingID || asset.CallId != fact.CallID || asset.Format != manifest.Format || int(asset.Channels) != manifest.Channels || int(asset.SampleRateHz) != manifest.SampleRateHz || asset.DurationMs != manifest.DurationMs || uploadID == "" || uploadID != manifest.UploadID { @@ -66,7 +66,7 @@ func (d *Dispatcher) localMockUploadOwner(ctx context.Context, binding *agentv1. // CompleteLocalMockRecording binds an Agent's finished PUT to the already // confirmed Mock call. The sole outward notification is the immutable V3 // call.result; a locally stored result never counts as MQ delivery. -func (d *Dispatcher) CompleteLocalMockRecording(ctx context.Context, request *agentv1.CompleteUploadRequest, grant store.UploadRecord) (bool, error) { +func (d *Dispatcher) CompleteLocalMockRecording(ctx context.Context, request *agentpb.CompleteUploadRequest, grant store.UploadRecord) (bool, error) { if request == nil { return false, errors.New("local Mock upload completion is required") } diff --git a/internal/dispatcher/local_origination.go b/internal/dispatcher/local_origination.go index 413b5a9..7a8fa92 100644 --- a/internal/dispatcher/local_origination.go +++ b/internal/dispatcher/local_origination.go @@ -8,7 +8,7 @@ import ( "log/slog" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/callwindow" "git.ipao.vip/rogee/go-sip/internal/configread" "git.ipao.vip/rogee/go-sip/internal/store" @@ -19,7 +19,7 @@ import ( // a line or recalculating outbound business policy. type LocalDialAuthorization struct { dialDecision - Binding *agentv1.ExecutionBinding + Binding *agentpb.ExecutionBinding TraceID string AuthorizedAt time.Time Callee string @@ -121,7 +121,7 @@ func (d *Dispatcher) AuthorizeLocalOrigination(executionID, agentID string) (aut if !validLocalID(command.TraceID) { return LocalDialAuthorization{}, fmt.Errorf("accepted call trace is missing: %w", store.ErrCommandConflict) } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: candidate.TenantID, TenantKey: candidate.TenantKey, ExecutionId: executionID, TaskId: candidate.TaskID, TaskItemId: candidate.CommandID, TaskRevision: candidate.Snapshot.TaskRevision, AgentVersionId: identity.Agent.AgentVersionID, diff --git a/internal/dispatcher/local_origination_rpc_test.go b/internal/dispatcher/local_origination_rpc_test.go index 035af4b..3740b1f 100644 --- a/internal/dispatcher/local_origination_rpc_test.go +++ b/internal/dispatcher/local_origination_rpc_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" rpcserver "git.ipao.vip/rogee/go-sip/internal/rpc" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" @@ -20,7 +20,7 @@ func TestLocalAuthorizedOriginationReachesOnlyMockAgentAfterFinalGate(t *testing defer st.Close() attempts := 0 current := at.Add(time.Minute) - agent := rpcserver.NewServer(rpcserver.ServerOptions{Mode: "mock", Now: func() time.Time { return current }, MockAuthorizedOriginate: func(_ context.Context, req *agentv1.ExecuteAuthorizedRequest) error { + agent := rpcserver.NewServer(rpcserver.ServerOptions{Mode: "mock", Now: func() time.Time { return current }, MockAuthorizedOriginate: func(_ context.Context, req *agentpb.ExecuteAuthorizedRequest) error { attempts++ if req.SelectedTrunkId != "trunk-mock" || req.CallerId != "BD00000000" || req.Callee != "15003164745" || req.MaxCallDurationMs != 120000 || req.BoundSnapshotSha256 == "" { t.Errorf("Agent received an unbound/changed decision: %+v", req) @@ -29,7 +29,7 @@ func TestLocalAuthorizedOriginationReachesOnlyMockAgentAfterFinalGate(t *testing }}) listener := bufconn.Listen(1024 * 1024) grpcServer := grpc.NewServer() - agentv1.RegisterAgentControlServiceServer(grpcServer, agent) + agentpb.RegisterAgentControlServiceServer(grpcServer, agent) go func() { _ = grpcServer.Serve(listener) }() defer grpcServer.Stop() connection, err := grpc.NewClient("passthrough:///authorized-mock", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }), grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -38,7 +38,7 @@ func TestLocalAuthorizedOriginationReachesOnlyMockAgentAfterFinalGate(t *testing } defer connection.Close() coordinator := NewAgentCoordinator(func() time.Time { return current }) - if err := coordinator.Register("agent-1", agentv1.NewAgentControlServiceClient(connection)); err != nil { + if err := coordinator.Register("agent-1", agentpb.NewAgentControlServiceClient(connection)); err != nil { t.Fatal(err) } if _, err := coordinator.Activate(context.Background(), "agent-1", "cell-1", "boot-1", "epoch-1", 1); err != nil { @@ -47,7 +47,7 @@ func TestLocalAuthorizedOriginationReachesOnlyMockAgentAfterFinalGate(t *testing executionID := acceptedLocalExecutionID(t, d, st, at, "command-agent-bridge") d.now = func() time.Time { return current } result, err := d.DispatchAuthorizedLocal(context.Background(), executionID, "agent-1", coordinator) - if err != nil || result.Unknown || result.Receipt.GetResult() != agentv1.ResultCode_RESULT_CODE_APPLIED || attempts != 1 { + if err != nil || result.Unknown || result.Receipt.GetResult() != agentpb.ResultCode_RESULT_CODE_APPLIED || attempts != 1 { t.Fatalf("authorized mock call: %+v attempts=%d err=%v", result, attempts, err) } if _, err := d.DispatchAuthorizedLocal(context.Background(), executionID, "agent-1", coordinator); err == nil || attempts != 1 { diff --git a/internal/dispatcher/local_v01_test.go b/internal/dispatcher/local_v01_test.go index 860fcb0..f54c7b7 100644 --- a/internal/dispatcher/local_v01_test.go +++ b/internal/dispatcher/local_v01_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/configread" "git.ipao.vip/rogee/go-sip/internal/store" ) @@ -24,9 +24,9 @@ const ( localTestTaskID = "task-mock" ) -func localTestExecutionBinding(t *testing.T, st *store.Store, executionID string) *agentv1.ExecutionBinding { +func localTestExecutionBinding(t *testing.T, st *store.Store, executionID string) *agentpb.ExecutionBinding { t.Helper() - binding := &agentv1.ExecutionBinding{ExecutionId: executionID, AttemptId: executionID} + binding := &agentpb.ExecutionBinding{ExecutionId: executionID, AttemptId: executionID} if err := st.DB().QueryRow(`SELECT tenant_id,tenant_key,task_id,task_item_id,task_revision,agent_version_id,route_policy_id,caller_profile_id FROM tasks WHERE execution_id=?`, executionID).Scan( &binding.TenantId, &binding.TenantKey, &binding.TaskId, &binding.TaskItemId, &binding.TaskRevision, &binding.AgentVersionId, &binding.RoutePolicyId, &binding.CallerProfileId, @@ -656,9 +656,9 @@ func newLocalV01MultiTaskConfigServer(t *testing.T, taskIDs []string, quotaRevis func localTestSIPConfigVerifier() SIPConfigVerifier { return SIPConfigVerifierFunc(func(_ context.Context, snapshot configread.Snapshot) error { - status := &agentv1.AgentStatus{ + status := &agentpb.AgentStatus{ AgentId: "agent-mock", CellId: "cell-mock", BootId: "boot-mock", - AppliedConfigs: []*agentv1.AppliedConfig{{ + AppliedConfigs: []*agentpb.AppliedConfig{{ Kind: AppliedConfigKindSIP, Revision: fmt.Sprint(snapshot.SIPRevision), State: AppliedConfigStateApplied, ObservedAtUnixMs: 1, }}, diff --git a/internal/dispatcher/sip_applied_config_test.go b/internal/dispatcher/sip_applied_config_test.go index 0f1d9ca..aa51fba 100644 --- a/internal/dispatcher/sip_applied_config_test.go +++ b/internal/dispatcher/sip_applied_config_test.go @@ -6,28 +6,28 @@ import ( "fmt" "testing" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/configread" ) type staticAgentStatusProbe struct { - status *agentv1.AgentStatus + status *agentpb.AgentStatus err error gotAgentID string gotCellID string } -func (p *staticAgentStatusProbe) Probe(_ context.Context, agentID, cellID string) (*agentv1.AgentStatus, error) { +func (p *staticAgentStatusProbe) Probe(_ context.Context, agentID, cellID string) (*agentpb.AgentStatus, error) { p.gotAgentID, p.gotCellID = agentID, cellID return p.status, p.err } func TestAgentSIPConfigVerifierRequiresExactAppliedRevision(t *testing.T) { snapshot := configread.Snapshot{SIPRevision: 7} - newStatus := func() *agentv1.AgentStatus { - return &agentv1.AgentStatus{ + newStatus := func() *agentpb.AgentStatus { + return &agentpb.AgentStatus{ AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", - AppliedConfigs: []*agentv1.AppliedConfig{{ + AppliedConfigs: []*agentpb.AppliedConfig{{ Kind: AppliedConfigKindSIP, Revision: fmt.Sprint(snapshot.SIPRevision), State: AppliedConfigStateApplied, ObservedAtUnixMs: 1000, @@ -54,14 +54,14 @@ func TestAgentSIPConfigVerifierRequiresExactAppliedRevision(t *testing.T) { cases := []struct { name string - status *agentv1.AgentStatus + status *agentpb.AgentStatus err error }{ {name: "missing status"}, {name: "wrong agent", status: newStatus()}, {name: "wrong cell", status: newStatus()}, {name: "missing boot ID", status: newStatus()}, - {name: "missing applied config", status: &agentv1.AgentStatus{AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a"}}, + {name: "missing applied config", status: &agentpb.AgentStatus{AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a"}}, {name: "multiple SIP applied configs", status: newStatus()}, {name: "wrong kind", status: newStatus()}, {name: "not applied", status: newStatus()}, @@ -79,7 +79,7 @@ func TestAgentSIPConfigVerifierRequiresExactAppliedRevision(t *testing.T) { case "missing boot ID": c.status.BootId = "" case "multiple SIP applied configs": - c.status.AppliedConfigs = append(c.status.AppliedConfigs, &agentv1.AppliedConfig{Kind: AppliedConfigKindSIP, Revision: "7", State: AppliedConfigStateApplied, ObservedAtUnixMs: 2000}) + c.status.AppliedConfigs = append(c.status.AppliedConfigs, &agentpb.AppliedConfig{Kind: AppliedConfigKindSIP, Revision: "7", State: AppliedConfigStateApplied, ObservedAtUnixMs: 2000}) case "wrong kind": c.status.AppliedConfigs[0].Kind = "media" case "not applied": diff --git a/internal/dispatcher/task_controller.go b/internal/dispatcher/task_controller.go index e9dd99a..9d7fb8f 100644 --- a/internal/dispatcher/task_controller.go +++ b/internal/dispatcher/task_controller.go @@ -3,9 +3,9 @@ package dispatcher import ( "context" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) type TaskController interface { - Control(context.Context, string, *agentv1.ExecutionBinding, agentv1.ControlAction, agentv1.ActiveCallPolicy) (*agentv1.ApplyTaskControlResponse, error) + Control(context.Context, string, *agentpb.ExecutionBinding, agentpb.ControlAction, agentpb.ActiveCallPolicy) (*agentpb.ApplyTaskControlResponse, error) } diff --git a/internal/dispatcher/task_queue_v3.go b/internal/dispatcher/task_queue_v3.go index 70d09eb..7831114 100644 --- a/internal/dispatcher/task_queue_v3.go +++ b/internal/dispatcher/task_queue_v3.go @@ -8,7 +8,7 @@ import ( "log/slog" "sync" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/mq" "git.ipao.vip/rogee/go-sip/internal/store" ) @@ -226,12 +226,12 @@ func (q *v3TaskQueueController) ApplyActiveCallPolicy(ctx context.Context, assig if policy != "hangup" { return fmt.Errorf("unsupported active-call policy %q", policy) } - var controlAction agentv1.ControlAction + var controlAction agentpb.ControlAction switch action { case "pause": - controlAction = agentv1.ControlAction_CONTROL_ACTION_PAUSE + controlAction = agentpb.ControlAction_CONTROL_ACTION_PAUSE case "stop": - controlAction = agentv1.ControlAction_CONTROL_ACTION_STOP + controlAction = agentpb.ControlAction_CONTROL_ACTION_STOP default: return fmt.Errorf("active-call hangup is not valid for %q", action) } @@ -252,13 +252,13 @@ func (q *v3TaskQueueController) ApplyActiveCallPolicy(ctx context.Context, assig if target.Binding == nil || target.AgentID == "" { return fmt.Errorf("execution %s has no durable Agent control binding", target.ExecutionID) } - response, err := q.taskController.Control(ctx, target.AgentID, target.Binding, controlAction, agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP) + response, err := q.taskController.Control(ctx, target.AgentID, target.Binding, controlAction, agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP) if err != nil { return fmt.Errorf("hang up active execution %s: %w", target.ExecutionID, err) } - if response == nil || response.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_APPLIED || + if response == nil || response.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_APPLIED || response.GetAppliedTaskRevision() != target.Binding.TaskRevision+1 || - response.GetState() != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL { + response.GetState() != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL { return fmt.Errorf("Agent did not confirm hangup for execution %s", target.ExecutionID) } } diff --git a/internal/dispatcher/task_queue_v3_origination_test.go b/internal/dispatcher/task_queue_v3_origination_test.go index 3b1079b..a4975f0 100644 --- a/internal/dispatcher/task_queue_v3_origination_test.go +++ b/internal/dispatcher/task_queue_v3_origination_test.go @@ -6,35 +6,35 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc" ) type fakeAuthorizedAgentClient struct { - agentv1.AgentControlServiceClient + agentpb.AgentControlServiceClient attempts int mockOrigins int deadlineClosed bool - last *agentv1.ExecuteAuthorizedRequest + last *agentpb.ExecuteAuthorizedRequest } -func (f *fakeAuthorizedAgentClient) ExecuteAuthorized(_ context.Context, request *agentv1.ExecuteAuthorizedRequest, _ ...grpc.CallOption) (*agentv1.ExecuteAuthorizedResponse, error) { +func (f *fakeAuthorizedAgentClient) ExecuteAuthorized(_ context.Context, request *agentpb.ExecuteAuthorizedRequest, _ ...grpc.CallOption) (*agentpb.ExecuteAuthorizedResponse, error) { f.attempts++ f.last = request if f.deadlineClosed { - return &agentv1.ExecuteAuthorizedResponse{ - Receipt: &agentv1.OperationReceipt{Result: agentv1.ResultCode_RESULT_CODE_REJECTED}, - State: agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, + return &agentpb.ExecuteAuthorizedResponse{ + Receipt: &agentpb.OperationReceipt{Result: agentpb.ResultCode_RESULT_CODE_REJECTED}, + State: agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, }, nil } f.mockOrigins++ - return &agentv1.ExecuteAuthorizedResponse{ - Receipt: &agentv1.OperationReceipt{Result: agentv1.ResultCode_RESULT_CODE_APPLIED}, - State: agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, + return &agentpb.ExecuteAuthorizedResponse{ + Receipt: &agentpb.OperationReceipt{Result: agentpb.ResultCode_RESULT_CODE_APPLIED}, + State: agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, }, nil } -func (f *fakeAuthorizedAgentClient) QueryExecution(_ context.Context, request *agentv1.QueryExecutionRequest, _ ...grpc.CallOption) (*agentv1.QueryExecutionResponse, error) { +func (f *fakeAuthorizedAgentClient) QueryExecution(_ context.Context, request *agentpb.QueryExecutionRequest, _ ...grpc.CallOption) (*agentpb.QueryExecutionResponse, error) { binding := request.Binding if f.last != nil && f.last.Binding.GetExecutionId() == request.Binding.GetExecutionId() { binding = f.last.Binding @@ -43,8 +43,8 @@ func (f *fakeAuthorizedAgentClient) QueryExecution(_ context.Context, request *a if f.deadlineClosed { callState = "mock_deadline_closed_without_dial" } - return &agentv1.QueryExecutionResponse{Snapshot: &agentv1.ExecutionSnapshot{ - Binding: binding, State: agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, + return &agentpb.QueryExecutionResponse{Snapshot: &agentpb.ExecutionSnapshot{ + Binding: binding, State: agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, CallState: callState, AttemptId: binding.AttemptId, ObservedAtUnixMs: time.Date(2026, 9, 21, 1, 30, 1, 0, time.UTC).UnixMilli(), }}, nil diff --git a/internal/dispatcher/task_queue_v3_stop_active_test.go b/internal/dispatcher/task_queue_v3_stop_active_test.go index b8cffe6..1908ea6 100644 --- a/internal/dispatcher/task_queue_v3_stop_active_test.go +++ b/internal/dispatcher/task_queue_v3_stop_active_test.go @@ -5,32 +5,32 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) type mockActiveStopRecorder struct { - state agentv1.ExecutionState + state agentpb.ExecutionState calls []struct { agentID string executionID string - action agentv1.ControlAction - policy agentv1.ActiveCallPolicy + action agentpb.ControlAction + policy agentpb.ActiveCallPolicy } } -func (r *mockActiveStopRecorder) Control(_ context.Context, agentID string, binding *agentv1.ExecutionBinding, action agentv1.ControlAction, policy agentv1.ActiveCallPolicy) (*agentv1.ApplyTaskControlResponse, error) { +func (r *mockActiveStopRecorder) Control(_ context.Context, agentID string, binding *agentpb.ExecutionBinding, action agentpb.ControlAction, policy agentpb.ActiveCallPolicy) (*agentpb.ApplyTaskControlResponse, error) { r.calls = append(r.calls, struct { agentID string executionID string - action agentv1.ControlAction - policy agentv1.ActiveCallPolicy + action agentpb.ControlAction + policy agentpb.ActiveCallPolicy }{agentID, binding.ExecutionId, action, policy}) state := r.state - if state == agentv1.ExecutionState_EXECUTION_STATE_UNSPECIFIED { - state = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL + if state == agentpb.ExecutionState_EXECUTION_STATE_UNSPECIFIED { + state = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL } - return &agentv1.ApplyTaskControlResponse{ - Receipt: &agentv1.OperationReceipt{Result: agentv1.ResultCode_RESULT_CODE_APPLIED}, + return &agentpb.ApplyTaskControlResponse{ + Receipt: &agentpb.OperationReceipt{Result: agentpb.ResultCode_RESULT_CODE_APPLIED}, AppliedTaskRevision: binding.TaskRevision + 1, State: state, }, nil @@ -78,7 +78,7 @@ func TestAuthorizedMockInFlightExecutionsRemainAddressableForStop(t *testing.T) t.Fatalf("stop selected an unrelated or unbound call: %+v", target) } } - control := &mockActiveStopRecorder{state: agentv1.ExecutionState_EXECUTION_STATE_OBSERVED} + control := &mockActiveStopRecorder{state: agentpb.ExecutionState_EXECUTION_STATE_OBSERVED} broker := &fakeQueueBroker{} queues := newTaskQueueController(d, broker, control) assignment, err := st.LocalTaskAssignment(localTestDispatcherID, localTestTaskID) @@ -89,7 +89,7 @@ func TestAuthorizedMockInFlightExecutionsRemainAddressableForStop(t *testing.T) t.Fatal("Agent applied receipt without terminal call state was accepted as hangup") } control.calls = nil - control.state = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL + control.state = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL reader := &fakeTaskControlStatusReader{status: localControlStatus("stopped", 3)} processor := newLocalTaskControlProcessor(d, reader, queues) if err := processor.Handle(ctx, localControlRoutingKey(), localTaskControlBody(t, at, "stop")); err != nil { @@ -100,7 +100,7 @@ func TestAuthorizedMockInFlightExecutionsRemainAddressableForStop(t *testing.T) } for _, call := range control.calls { if call.agentID != "agent-1" || !issued[call.executionID] || - call.action != agentv1.ControlAction_CONTROL_ACTION_STOP || call.policy != agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { + call.action != agentpb.ControlAction_CONTROL_ACTION_STOP || call.policy != agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { t.Fatalf("stop sent an unbound control: %+v", call) } } @@ -111,8 +111,8 @@ func TestAuthorizedMockInFlightExecutionsRemainAddressableForStop(t *testing.T) if err != nil { t.Fatal(err) } - terminal := &agentv1.ExecutionSnapshot{ - Binding: authorized.Binding, State: agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, + terminal := &agentpb.ExecutionSnapshot{ + Binding: authorized.Binding, State: agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, CallState: "mock_no_answer", AttemptId: authorized.Binding.AttemptId, ObservedAtUnixMs: at.Add(time.Second).UnixMilli(), } diff --git a/internal/dispatcher/two_cell_test.go b/internal/dispatcher/two_cell_test.go index 6115df5..cc2b452 100644 --- a/internal/dispatcher/two_cell_test.go +++ b/internal/dispatcher/two_cell_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" rpcserver "git.ipao.vip/rogee/go-sip/internal/rpc" "git.ipao.vip/rogee/go-sip/internal/testfixture" @@ -18,8 +18,8 @@ import ( func TestTwoMockCellsKeepAgentSessionsAndPermitsSeparate(t *testing.T) { coordinator := NewAgentCoordinator(func() time.Time { return time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC) }) - clientA := startMockAgent(t, &agentv1.AgentStatus{AgentId: "agent-a", CellId: "cell-a"}) - clientB := startMockAgent(t, &agentv1.AgentStatus{AgentId: "agent-b", CellId: "cell-b"}) + clientA := startMockAgent(t, &agentpb.AgentStatus{AgentId: "agent-a", CellId: "cell-a"}) + clientB := startMockAgent(t, &agentpb.AgentStatus{AgentId: "agent-b", CellId: "cell-b"}) if err := coordinator.Register("agent-a", clientA); err != nil { t.Fatal(err) } @@ -54,12 +54,12 @@ func TestTwoMockCellsKeepAgentSessionsAndPermitsSeparate(t *testing.T) { } } -func startMockAgent(t *testing.T, status *agentv1.AgentStatus) agentv1.AgentControlServiceClient { +func startMockAgent(t *testing.T, status *agentpb.AgentStatus) agentpb.AgentControlServiceClient { t.Helper() listener := bufconn.Listen(1024 * 1024) server := rpcserver.NewServer(rpcserver.ServerOptions{Now: func() time.Time { return time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC) }, Status: status}) grpcServer := grpc.NewServer() - agentv1.RegisterAgentControlServiceServer(grpcServer, server) + agentpb.RegisterAgentControlServiceServer(grpcServer, server) go func() { _ = grpcServer.Serve(listener) }() t.Cleanup(func() { grpcServer.Stop() }) conn, err := grpc.NewClient("passthrough:///mock-agent", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }), grpc.WithTransportCredentials(insecure.NewCredentials())) @@ -67,7 +67,7 @@ func startMockAgent(t *testing.T, status *agentv1.AgentStatus) agentv1.AgentCont t.Fatal(err) } t.Cleanup(func() { _ = conn.Close() }) - return agentv1.NewAgentControlServiceClient(conn) + return agentpb.NewAgentControlServiceClient(conn) } func mutateExecution(t *testing.T, raw []byte, executionID, taskID, itemID string) []byte { @@ -87,11 +87,11 @@ func mutateExecution(t *testing.T, raw []byte, executionID, taskID, itemID strin return encoded } -func executionBinding(t *testing.T, raw []byte) *agentv1.ExecutionBinding { +func executionBinding(t *testing.T, raw []byte) *agentpb.ExecutionBinding { t.Helper() envelope, payload, err := contract.DecodeExecute(raw) if err != nil { t.Fatal(err) } - return &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} + return &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} } diff --git a/internal/health/sample.go b/internal/health/sample.go index 85e3547..c923d93 100644 --- a/internal/health/sample.go +++ b/internal/health/sample.go @@ -6,7 +6,7 @@ import ( "strings" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "github.com/shirou/gopsutil/v4/cpu" "github.com/shirou/gopsutil/v4/disk" "github.com/shirou/gopsutil/v4/mem" @@ -20,12 +20,12 @@ type Sampler struct { Now func() time.Time } -func (s Sampler) Sample(ctx context.Context, spoolRoot string) *agentv1.ResourceSample { +func (s Sampler) Sample(ctx context.Context, spoolRoot string) *agentpb.ResourceSample { now := time.Now if s.Now != nil { now = s.Now } - sample := &agentv1.ResourceSample{ + sample := &agentpb.ResourceSample{ ObservedAtUnixMs: now().UnixMilli(), SampleFresh: true, } diff --git a/internal/oss/aliyun.go b/internal/oss/aliyun.go index 70618a7..ca9320e 100644 --- a/internal/oss/aliyun.go +++ b/internal/oss/aliyun.go @@ -8,7 +8,7 @@ import ( "strings" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" aliyunoss "github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss" "github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials" ) @@ -80,7 +80,7 @@ func NewClient(config Config) (*Client, error) { func (c *Client) Config() Config { return c.config } -func (c *Client) Grant(ctx context.Context, uploadID, objectKey, checksum string, maxBytes int64, now time.Time) (*agentv1.UploadGrant, error) { +func (c *Client) Grant(ctx context.Context, uploadID, objectKey, checksum string, maxBytes int64, now time.Time) (*agentpb.UploadGrant, error) { if c == nil || c.client == nil { return nil, errors.New("OSS client is not configured") } @@ -105,11 +105,11 @@ func (c *Client) Grant(ctx context.Context, uploadID, objectKey, checksum string if err != nil { return nil, fmt.Errorf("presign OSS PUT: %w", err) } - headers := make([]*agentv1.Header, 0, len(presigned.SignedHeaders)) + headers := make([]*agentpb.Header, 0, len(presigned.SignedHeaders)) for name, value := range presigned.SignedHeaders { - headers = append(headers, &agentv1.Header{Name: name, Value: value}) + headers = append(headers, &agentpb.Header{Name: name, Value: value}) } - return &agentv1.UploadGrant{ + return &agentpb.UploadGrant{ UploadId: uploadID, TargetUrl: presigned.URL, Headers: headers, diff --git a/internal/rpc/ai_authorization_test.go b/internal/rpc/ai_authorization_test.go index 1cb51d1..b880b5f 100644 --- a/internal/rpc/ai_authorization_test.go +++ b/internal/rpc/ai_authorization_test.go @@ -6,7 +6,7 @@ import ( "time" "git.ipao.vip/rogee/go-sip/contracts" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/ai" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" @@ -42,7 +42,7 @@ func TestExecutionPermitEnforcesAIAuthorization(t *testing.T) { if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: payload.ExecutionID, @@ -53,7 +53,7 @@ func TestExecutionPermitEnforcesAIAuthorization(t *testing.T) { RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID, } - response, err := server.GetExecutionPermit(context.Background(), &agentv1.GetExecutionPermitRequest{ + response, err := server.GetExecutionPermit(context.Background(), &agentpb.GetExecutionPermitRequest{ Meta: testMeta("permit-ai", "permit-ai-key", 1), Binding: binding, ResourceReservationId: "reservation-ai", @@ -63,11 +63,11 @@ func TestExecutionPermitEnforcesAIAuthorization(t *testing.T) { if err != nil { t.Fatal(err) } - if response.Permit == nil || response.Receipt == nil || response.Receipt.Result != agentv1.ResultCode_RESULT_CODE_APPLIED { + if response.Permit == nil || response.Receipt == nil || response.Receipt.Result != agentpb.ResultCode_RESULT_CODE_APPLIED { t.Fatalf("unexpected authorized permit response: %+v", response) } - badDigest := &agentv1.GetExecutionPermitRequest{ + badDigest := &agentpb.GetExecutionPermitRequest{ Meta: testMeta("permit-ai-bad-digest", "permit-ai-bad-digest-key", 1), Binding: binding, ResourceReservationId: "reservation-ai-2", @@ -98,9 +98,9 @@ func TestExecutionPermitRejectsRevokedAIAuthorization(t *testing.T) { AIAuthorizationRaw: authorizationRaw, }) activateTestServer(t, server) - response, err := server.GetExecutionPermit(context.Background(), &agentv1.GetExecutionPermitRequest{ + response, err := server.GetExecutionPermit(context.Background(), &agentpb.GetExecutionPermitRequest{ Meta: testMeta("permit-revoked", "permit-revoked-key", 1), - Binding: &agentv1.ExecutionBinding{TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: "execution-revoked", AgentVersionId: snapshot.AgentVersionID}, + Binding: &agentpb.ExecutionBinding{TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: "execution-revoked", AgentVersionId: snapshot.AgentVersionID}, ResourceReservationId: "reservation-revoked", ConfigSha256: snapshot.Digest, }) @@ -111,9 +111,9 @@ func TestExecutionPermitRejectsRevokedAIAuthorization(t *testing.T) { func activateTestServer(t *testing.T, server *Server) { t.Helper() - _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: testMeta("activate-ai", "", 0), - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-ai", }) if err != nil { diff --git a/internal/rpc/authorized_execution.go b/internal/rpc/authorized_execution.go index 1f7decd..e349fd3 100644 --- a/internal/rpc/authorized_execution.go +++ b/internal/rpc/authorized_execution.go @@ -5,7 +5,7 @@ import ( "encoding/hex" "log/slog" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" @@ -16,7 +16,7 @@ const authorizedOriginationVersion = "agent-authorized-origination.v0.1" // ExecuteAuthorized only runs an explicit mock adapter. D has already made and // durably claimed the final dial decision. A enforces the D-issued exclusive // deadline and session identity, but never recalculates business policy. -func (s *Server) ExecuteAuthorized(ctx context.Context, req *agentv1.ExecuteAuthorizedRequest) (*agentv1.ExecuteAuthorizedResponse, error) { +func (s *Server) ExecuteAuthorized(ctx context.Context, req *agentpb.ExecuteAuthorizedRequest) (*agentpb.ExecuteAuthorizedResponse, error) { if req == nil || req.Meta == nil || req.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and execution binding are required") } @@ -45,20 +45,20 @@ func (s *Server) ExecuteAuthorized(ctx context.Context, req *agentv1.ExecuteAuth if previous, exists := s.operations[key]; exists { if previous.digest != digest { s.mu.Unlock() - return &agentv1.ExecuteAuthorizedResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil + return &agentpb.ExecuteAuthorizedResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil } entry := s.executions[binding.ExecutionId] if entry == nil { s.mu.Unlock() return nil, status.Error(codes.Internal, "persisted operation lacks execution state") } - response := &agentv1.ExecuteAuthorizedResponse{Receipt: proto.Clone(previous.receipt).(*agentv1.OperationReceipt), State: entry.state} + response := &agentpb.ExecuteAuthorizedResponse{Receipt: proto.Clone(previous.receipt).(*agentpb.OperationReceipt), State: entry.state} s.mu.Unlock() return response, nil } if _, exists := s.executions[binding.ExecutionId]; exists { s.mu.Unlock() - return &agentv1.ExecuteAuthorizedResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "execution already exists", false)}, nil + return &agentpb.ExecuteAuthorizedResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "execution already exists", false)}, nil } if s.now().UnixMilli() >= req.DialBeforeUnixMs { s.mu.Unlock() @@ -67,11 +67,11 @@ func (s *Server) ExecuteAuthorized(ctx context.Context, req *agentv1.ExecuteAuth // Persist an unknown one-shot attempt BEFORE contacting the mock adapter. // After a crash or lost response, replay/query cannot cause a second dial. s.executions[binding.ExecutionId] = &executionRecord{ - executeDigest: digest, binding: proto.Clone(binding).(*agentv1.ExecutionBinding), - state: agentv1.ExecutionState_EXECUTION_STATE_UNKNOWN, taskRevision: binding.TaskRevision, + executeDigest: digest, binding: proto.Clone(binding).(*agentpb.ExecutionBinding), + state: agentpb.ExecutionState_EXECUTION_STATE_UNKNOWN, taskRevision: binding.TaskRevision, unknown: true, callState: "mock_originating_unknown", } - pending := s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_UNKNOWN, agentv1.FailureCode_FAILURE_CODE_UNAVAILABLE, "mock originate pending; do not retry", false) + pending := s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_UNKNOWN, agentpb.FailureCode_FAILURE_CODE_UNAVAILABLE, "mock originate pending; do not retry", false) s.operations[key] = operationRecord{digest: digest, receipt: pending} if err := s.persistExecutionJournalLocked(); err != nil { s.mu.Unlock() @@ -84,34 +84,34 @@ func (s *Server) ExecuteAuthorized(ctx context.Context, req *agentv1.ExecuteAuth expired := s.now().UnixMilli() >= req.DialBeforeUnixMs var dialErr error if !expired { - dialErr = s.mockAuthorizedOriginate(ctx, proto.Clone(req).(*agentv1.ExecuteAuthorizedRequest)) + dialErr = s.mockAuthorizedOriginate(ctx, proto.Clone(req).(*agentpb.ExecuteAuthorizedRequest)) } s.mu.Lock() defer s.mu.Unlock() record := s.executions[binding.ExecutionId] - var result agentv1.ResultCode - var failure agentv1.FailureCode + var result agentpb.ResultCode + var failure agentpb.FailureCode var detail string switch { case expired: - record.state, record.unknown, record.callState = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, false, "mock_deadline_closed_without_dial" + record.state, record.unknown, record.callState = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, false, "mock_deadline_closed_without_dial" record.terminalObservedAtUnixMs = s.now().UnixMilli() - result, failure, detail = agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "dial deadline expired before mock adapter" + result, failure, detail = agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "dial deadline expired before mock adapter" case dialErr != nil: slog.Error("mock originate failed; execution remains unknown and cannot be retried", "execution_id", binding.ExecutionId, "error", dialErr) - record.state, record.unknown, record.callState = agentv1.ExecutionState_EXECUTION_STATE_UNKNOWN, true, "mock_originating_unknown" - result, failure, detail = agentv1.ResultCode_RESULT_CODE_UNKNOWN, agentv1.FailureCode_FAILURE_CODE_UNAVAILABLE, "mock originate outcome unknown; reconcile instead of retry" + record.state, record.unknown, record.callState = agentpb.ExecutionState_EXECUTION_STATE_UNKNOWN, true, "mock_originating_unknown" + result, failure, detail = agentpb.ResultCode_RESULT_CODE_UNKNOWN, agentpb.FailureCode_FAILURE_CODE_UNAVAILABLE, "mock originate outcome unknown; reconcile instead of retry" default: - record.state, record.unknown, record.callState = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, false, "mock_no_answer" + record.state, record.unknown, record.callState = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, false, "mock_no_answer" record.terminalObservedAtUnixMs = s.now().UnixMilli() - result, failure, detail = agentv1.ResultCode_RESULT_CODE_APPLIED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "" + result, failure, detail = agentpb.ResultCode_RESULT_CODE_APPLIED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "" } receipt := s.receipt(req.Meta, result, failure, detail, false) s.operations[key] = operationRecord{digest: digest, receipt: receipt} if err := s.persistExecutionJournalLocked(); err != nil { return nil, err } - return &agentv1.ExecuteAuthorizedResponse{Receipt: receipt, State: record.state}, nil + return &agentpb.ExecuteAuthorizedResponse{Receipt: receipt, State: record.state}, nil } func validLowerSHA256(value string) bool { diff --git a/internal/rpc/authorized_execution_test.go b/internal/rpc/authorized_execution_test.go index b8419bf..ba2f32b 100644 --- a/internal/rpc/authorized_execution_test.go +++ b/internal/rpc/authorized_execution_test.go @@ -8,17 +8,17 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" ) -func authorizedMockRequest(now time.Time) *agentv1.ExecuteAuthorizedRequest { - return &agentv1.ExecuteAuthorizedRequest{ +func authorizedMockRequest(now time.Time) *agentpb.ExecuteAuthorizedRequest { + return &agentpb.ExecuteAuthorizedRequest{ SchemaVersion: "agent-authorized-origination.v0.1", Meta: testMeta("authorized-1", "authorized-key-1", 1), - Binding: &agentv1.ExecutionBinding{ + Binding: &agentpb.ExecutionBinding{ TenantId: "tenant-1", TenantKey: "tenant-original", ExecutionId: "execution-authorized-1", TaskId: "task-1", TaskItemId: "command-1", TaskRevision: 2, AgentVersionId: "agent-version-1", RoutePolicyId: "route-1", CallerProfileId: "caller-1", @@ -36,7 +36,7 @@ func authorizedMockRequest(now time.Time) *agentv1.ExecuteAuthorizedRequest { func TestExecuteAuthorizedMockOneShotAndIdentity(t *testing.T) { now := time.Date(2026, 9, 21, 1, 30, 0, 0, time.UTC) attempts := 0 - server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(_ context.Context, req *agentv1.ExecuteAuthorizedRequest) error { + server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(_ context.Context, req *agentpb.ExecuteAuthorizedRequest) error { attempts++ if req.SelectedTrunkId != "trunk-1" || req.CallerId != "BD93205882" || req.MaxCallDurationMs != 30000 { t.Fatalf("Agent received modified Dispatcher decision: %+v", req) @@ -46,23 +46,23 @@ func TestExecuteAuthorizedMockOneShotAndIdentity(t *testing.T) { activateTestServer(t, server) req := authorizedMockRequest(now) first, err := server.ExecuteAuthorized(context.Background(), req) - if err != nil || first.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_APPLIED || first.GetState() != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL || attempts != 1 { + if err != nil || first.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_APPLIED || first.GetState() != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL || attempts != 1 { t.Fatalf("first mock execution=%+v attempts=%d err=%v", first, attempts, err) } replay, err := server.ExecuteAuthorized(context.Background(), req) if err != nil || replay.GetReceipt().GetMeta().GetOperationId() != first.GetReceipt().GetMeta().GetOperationId() || attempts != 1 { t.Fatalf("replay caused duplicate mock dial: %+v attempts=%d err=%v", replay, attempts, err) } - changed := proto.Clone(req).(*agentv1.ExecuteAuthorizedRequest) + changed := proto.Clone(req).(*agentpb.ExecuteAuthorizedRequest) changed.Callee = "15830461047" conflict, err := server.ExecuteAuthorized(context.Background(), changed) - if err != nil || conflict.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_CONFLICT || attempts != 1 { + if err != nil || conflict.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_CONFLICT || attempts != 1 { t.Fatalf("same key/different body: %+v attempts=%d err=%v", conflict, attempts, err) } - newKey := proto.Clone(req).(*agentv1.ExecuteAuthorizedRequest) + newKey := proto.Clone(req).(*agentpb.ExecuteAuthorizedRequest) newKey.Meta = testMeta("authorized-2", "authorized-key-2", 1) conflict, err = server.ExecuteAuthorized(context.Background(), newKey) - if err != nil || conflict.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_CONFLICT || attempts != 1 { + if err != nil || conflict.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_CONFLICT || attempts != 1 { t.Fatalf("same execution/new operation: %+v attempts=%d err=%v", conflict, attempts, err) } } @@ -70,19 +70,19 @@ func TestExecuteAuthorizedMockOneShotAndIdentity(t *testing.T) { func TestExecuteAuthorizedRejectsExpiredAndInvalidMock(t *testing.T) { now := time.Date(2026, 9, 21, 1, 30, 0, 0, time.UTC) attempts := 0 - server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(context.Context, *agentv1.ExecuteAuthorizedRequest) error { + server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(context.Context, *agentpb.ExecuteAuthorizedRequest) error { attempts++ return nil }}) activateTestServer(t, server) for _, tc := range []struct { name string - change func(*agentv1.ExecuteAuthorizedRequest) + change func(*agentpb.ExecuteAuthorizedRequest) }{ - {"expired at Agent", func(r *agentv1.ExecuteAuthorizedRequest) { r.DialBeforeUnixMs = now.UnixMilli() }}, - {"missing selected trunk", func(r *agentv1.ExecuteAuthorizedRequest) { r.SelectedTrunkId = "" }}, - {"invalid snapshot digest", func(r *agentv1.ExecuteAuthorizedRequest) { r.BoundSnapshotSha256 = "bad" }}, - {"unknown contract version", func(r *agentv1.ExecuteAuthorizedRequest) { r.SchemaVersion = "other" }}, + {"expired at Agent", func(r *agentpb.ExecuteAuthorizedRequest) { r.DialBeforeUnixMs = now.UnixMilli() }}, + {"missing selected trunk", func(r *agentpb.ExecuteAuthorizedRequest) { r.SelectedTrunkId = "" }}, + {"invalid snapshot digest", func(r *agentpb.ExecuteAuthorizedRequest) { r.BoundSnapshotSha256 = "bad" }}, + {"unknown contract version", func(r *agentpb.ExecuteAuthorizedRequest) { r.SchemaVersion = "other" }}, } { t.Run(tc.name, func(t *testing.T) { req := authorizedMockRequest(now) @@ -101,18 +101,18 @@ func TestExecuteAuthorizedRejectsExpiredAndInvalidMock(t *testing.T) { func TestExecuteAuthorizedMockFailureIsUnknownAndNeverRetried(t *testing.T) { now := time.Date(2026, 9, 21, 1, 30, 0, 0, time.UTC) attempts := 0 - server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(context.Context, *agentv1.ExecuteAuthorizedRequest) error { + server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, MockAuthorizedOriginate: func(context.Context, *agentpb.ExecuteAuthorizedRequest) error { attempts++ return errors.New("mock transport failed") }}) activateTestServer(t, server) req := authorizedMockRequest(now) first, err := server.ExecuteAuthorized(context.Background(), req) - if err != nil || first.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_UNKNOWN || attempts != 1 { + if err != nil || first.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_UNKNOWN || attempts != 1 { t.Fatalf("uncertain mock execution=%+v attempts=%d err=%v", first, attempts, err) } replay, err := server.ExecuteAuthorized(context.Background(), req) - if err != nil || replay.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_UNKNOWN || attempts != 1 { + if err != nil || replay.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_UNKNOWN || attempts != 1 { t.Fatalf("uncertain execution redialed: %+v attempts=%d err=%v", replay, attempts, err) } } @@ -131,8 +131,8 @@ func TestExecuteAuthorizedJournalPreventsRedialAfterAgentRestart(t *testing.T) { attempts := 0 start := func(generation uint64, bootID string) *Server { server := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, StatePath: path, - Status: &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: bootID}, - MockAuthorizedOriginate: func(context.Context, *agentv1.ExecuteAuthorizedRequest) error { + Status: &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: bootID}, + MockAuthorizedOriginate: func(context.Context, *agentpb.ExecuteAuthorizedRequest) error { attempts++ if tc.fail { return errors.New("mock adapter failed") @@ -142,8 +142,8 @@ func TestExecuteAuthorizedJournalPreventsRedialAfterAgentRestart(t *testing.T) { }) meta := testMeta("activate", "", 0) meta.BootId = bootID - if _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ - Meta: meta, Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: bootID, + if _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ + Meta: meta, Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: bootID, DispatcherEpoch: "epoch-1", SessionGeneration: generation}, ActivationOperationId: "activate", }); err != nil { t.Fatal(err) @@ -159,16 +159,16 @@ func TestExecuteAuthorizedJournalPreventsRedialAfterAgentRestart(t *testing.T) { terminalObservedAt := now.UnixMilli() now = now.Add(time.Hour) recovered := start(2, "boot-2") - replay := proto.Clone(req).(*agentv1.ExecuteAuthorizedRequest) + replay := proto.Clone(req).(*agentpb.ExecuteAuthorizedRequest) replay.Meta = testMeta("authorized-new-boot", "authorized-key-new-boot", 2) replay.Meta.BootId = "boot-2" retry, err := recovered.ExecuteAuthorized(context.Background(), replay) - if err != nil || retry.GetReceipt().GetResult() == agentv1.ResultCode_RESULT_CODE_APPLIED || attempts != 1 { + if err != nil || retry.GetReceipt().GetResult() == agentpb.ResultCode_RESULT_CODE_APPLIED || attempts != 1 { t.Fatalf("restart redialed execution: response=%+v attempts=%d err=%v", retry, attempts, err) } queryMeta := testMeta("query-recovered", "query-recovered-key", 2) queryMeta.BootId = "boot-2" - query, err := recovered.QueryExecution(context.Background(), &agentv1.QueryExecutionRequest{Meta: queryMeta, Binding: req.Binding}) + query, err := recovered.QueryExecution(context.Background(), &agentpb.QueryExecutionRequest{Meta: queryMeta, Binding: req.Binding}) if err != nil || query.Snapshot == nil || query.Snapshot.Unknown != tc.fail { t.Fatalf("recovered state failed to retain uncertainty: %+v err=%v", query, err) } diff --git a/internal/rpc/calllog_test.go b/internal/rpc/calllog_test.go index e1ccd92..d438b17 100644 --- a/internal/rpc/calllog_test.go +++ b/internal/rpc/calllog_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/calllog" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" @@ -23,9 +23,9 @@ func TestServerWritesPhoneCorrelatedCallBusinessLog(t *testing.T) { } server := NewServer(ServerOptions{Now: func() time.Time { return now }, CallLogger: logger}) meta := testMeta("activate-log", "", 0) - if _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + if _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: meta, - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-log", }); err != nil { t.Fatal(err) @@ -38,31 +38,31 @@ func TestServerWritesPhoneCorrelatedCallBusinessLog(t *testing.T) { if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID, } - if _, err := server.Execute(context.Background(), &agentv1.ExecuteRequest{ + if _, err := server.Execute(context.Background(), &agentpb.ExecuteRequest{ Meta: testMeta("execute-log", "execute-log-key", 1), Binding: binding, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", }); err != nil { t.Fatal(err) } statusPayload := []byte(`{"call_id":"call-1","execution_id":"execution-1","call_state":"answered","attempt_id":"attempt-1","attempt_state":"active","route_policy_id":"route-sip-first","caller_profile_id":"caller-sip-first","trunk_id":"provider-primary","cell_id":"cell-1","sip_stage":"invite","sip_status_code":183}`) - if _, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{ - Meta: testMeta("fact-status", "fact-status-key", 1), Fact: &agentv1.ExecutionFact{ + if _, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{ + Meta: testMeta("fact-status", "fact-status-key", 1), Fact: &agentpb.ExecutionFact{ FactId: "fact-status", ContentSha256: "digest-status", Binding: binding, - Kind: agentv1.FactKind_FACT_KIND_CALL_STATUS, PayloadJson: statusPayload, + Kind: agentpb.FactKind_FACT_KIND_CALL_STATUS, PayloadJson: statusPayload, }, }); err != nil { t.Fatal(err) } finishedPayload := []byte(`{"call_id":"call-1","execution_id":"execution-1","outcome":"no_answer","duration_ms":3000,"reason_code":"provider_480","asset_state":"failed","attempt_summary":[{"attempt_id":"attempt-1","state":"ended","trunk_id":"provider-primary","cell_id":"cell-1","reason_code":"provider_480"}],"recording_id":"recording-1","recording_state":"failed"}`) - if _, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{ - Meta: testMeta("fact-finished", "fact-finished-key", 1), Fact: &agentv1.ExecutionFact{ + if _, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{ + Meta: testMeta("fact-finished", "fact-finished-key", 1), Fact: &agentpb.ExecutionFact{ FactId: "fact-finished", ContentSha256: "digest-finished", Binding: binding, - Kind: agentv1.FactKind_FACT_KIND_CALL_FINISHED, PayloadJson: finishedPayload, + Kind: agentpb.FactKind_FACT_KIND_CALL_FINISHED, PayloadJson: finishedPayload, }, }); err != nil { t.Fatal(err) diff --git a/internal/rpc/client.go b/internal/rpc/client.go index 2f429bf..e217921 100644 --- a/internal/rpc/client.go +++ b/internal/rpc/client.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) @@ -15,7 +15,7 @@ import ( // remain at the caller; this type never retries an originate automatically. type Client struct { Conn *grpc.ClientConn - Agent agentv1.AgentControlServiceClient + Agent agentpb.AgentControlServiceClient } func Dial(endpoint string, tlsConfig *tls.Config) (*Client, error) { @@ -29,7 +29,7 @@ func Dial(endpoint string, tlsConfig *tls.Config) (*Client, error) { if err != nil { return nil, fmt.Errorf("dial gRPC endpoint: %w", err) } - return &Client{Conn: conn, Agent: agentv1.NewAgentControlServiceClient(conn)}, nil + return &Client{Conn: conn, Agent: agentpb.NewAgentControlServiceClient(conn)}, nil } func DialFromFiles(endpoint, caFile, certFile, keyFile, serverName string) (*Client, error) { @@ -63,21 +63,21 @@ func readFile(path, label string) ([]byte, error) { return data, nil } -func (c *Client) ReportExecutionEvent(ctx context.Context, request *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (c *Client) ReportExecutionEvent(ctx context.Context, request *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { if c == nil || c.Agent == nil { return nil, fmt.Errorf("AgentControl client is not initialized") } return c.Agent.ReportExecutionEvent(ctx, request) } -func (c *Client) RequestUpload(ctx context.Context, request *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) { +func (c *Client) RequestUpload(ctx context.Context, request *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) { if c == nil || c.Agent == nil { return nil, fmt.Errorf("AgentControl client is not initialized") } return c.Agent.RequestUpload(ctx, request) } -func (c *Client) CompleteUpload(ctx context.Context, request *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) { +func (c *Client) CompleteUpload(ctx context.Context, request *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) { if c == nil || c.Agent == nil { return nil, fmt.Errorf("AgentControl client is not initialized") } diff --git a/internal/rpc/control_policy_test.go b/internal/rpc/control_policy_test.go index bba1222..82bd12f 100644 --- a/internal/rpc/control_policy_test.go +++ b/internal/rpc/control_policy_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" ) @@ -16,17 +16,17 @@ func TestStopDrainPreservesCallAndCannotResume(t *testing.T) { require.NoError(t, err) envelope, payload, err := contract.DecodeExecute(raw) require.NoError(t, err) - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} - _, err = s.Execute(context.Background(), &agentv1.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: binding, CallExecuteJson: raw}) + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} + _, err = s.Execute(context.Background(), &agentpb.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: binding, CallExecuteJson: raw}) require.NoError(t, err) - s.executions[binding.ExecutionId].state = agentv1.ExecutionState_EXECUTION_STATE_OBSERVED - stopped, err := s.ApplyTaskControl(context.Background(), &agentv1.ApplyTaskControlRequest{Meta: testMeta("stop", "stop-key", 1), Binding: binding, ExpectedTaskRevision: binding.TaskRevision, Action: agentv1.ControlAction_CONTROL_ACTION_STOP, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}) + s.executions[binding.ExecutionId].state = agentpb.ExecutionState_EXECUTION_STATE_OBSERVED + stopped, err := s.ApplyTaskControl(context.Background(), &agentpb.ApplyTaskControlRequest{Meta: testMeta("stop", "stop-key", 1), Binding: binding, ExpectedTaskRevision: binding.TaskRevision, Action: agentpb.ControlAction_CONTROL_ACTION_STOP, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_APPLIED, stopped.Receipt.Result) - require.Equal(t, agentv1.ExecutionState_EXECUTION_STATE_OBSERVED, stopped.State) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_APPLIED, stopped.Receipt.Result) + require.Equal(t, agentpb.ExecutionState_EXECUTION_STATE_OBSERVED, stopped.State) binding.TaskRevision = stopped.AppliedTaskRevision - resumed, err := s.ApplyTaskControl(context.Background(), &agentv1.ApplyTaskControlRequest{Meta: testMeta("resume", "resume-key", 1), Binding: binding, ExpectedTaskRevision: binding.TaskRevision, Action: agentv1.ControlAction_CONTROL_ACTION_RESUME, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}) + resumed, err := s.ApplyTaskControl(context.Background(), &agentpb.ApplyTaskControlRequest{Meta: testMeta("resume", "resume-key", 1), Binding: binding, ExpectedTaskRevision: binding.TaskRevision, Action: agentpb.ControlAction_CONTROL_ACTION_RESUME, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_REJECTED, resumed.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_REJECTED, resumed.Receipt.Result) require.Equal(t, stopped.AppliedTaskRevision, resumed.AppliedTaskRevision) } diff --git a/internal/rpc/control_policy_validation_test.go b/internal/rpc/control_policy_validation_test.go index ec370e3..65ab331 100644 --- a/internal/rpc/control_policy_validation_test.go +++ b/internal/rpc/control_policy_validation_test.go @@ -5,42 +5,42 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func TestControlPolicyDoesNotInventMediaCompletion(t *testing.T) { for _, tc := range []struct { name, mode string - action agentv1.ControlAction - policy agentv1.ActiveCallPolicy + action agentpb.ControlAction + policy agentpb.ActiveCallPolicy wantError, terminal bool }{ - {name: "missing policy", mode: "mock", action: agentv1.ControlAction_CONTROL_ACTION_STOP, wantError: true}, - {name: "invalid policy", mode: "mock", action: agentv1.ControlAction_CONTROL_ACTION_STOP, policy: agentv1.ActiveCallPolicy(99), wantError: true}, - {name: "mixed hangup requires media adapter", mode: "mixed", action: agentv1.ControlAction_CONTROL_ACTION_STOP, policy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, wantError: true}, - {name: "real pause hangup requires media adapter", mode: "real", action: agentv1.ControlAction_CONTROL_ACTION_PAUSE, policy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, wantError: true}, - {name: "mock pause hangup", mode: "mock", action: agentv1.ControlAction_CONTROL_ACTION_PAUSE, policy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, terminal: true}, - {name: "mock pause drain", mode: "mock", action: agentv1.ControlAction_CONTROL_ACTION_PAUSE, policy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}, + {name: "missing policy", mode: "mock", action: agentpb.ControlAction_CONTROL_ACTION_STOP, wantError: true}, + {name: "invalid policy", mode: "mock", action: agentpb.ControlAction_CONTROL_ACTION_STOP, policy: agentpb.ActiveCallPolicy(99), wantError: true}, + {name: "mixed hangup requires media adapter", mode: "mixed", action: agentpb.ControlAction_CONTROL_ACTION_STOP, policy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, wantError: true}, + {name: "real pause hangup requires media adapter", mode: "real", action: agentpb.ControlAction_CONTROL_ACTION_PAUSE, policy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, wantError: true}, + {name: "mock pause hangup", mode: "mock", action: agentpb.ControlAction_CONTROL_ACTION_PAUSE, policy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, terminal: true}, + {name: "mock pause drain", mode: "mock", action: agentpb.ControlAction_CONTROL_ACTION_PAUSE, policy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN}, } { t.Run(tc.name, func(t *testing.T) { s := activatedServer(time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC), t) // Unit-only adapter mode selection: no provider or network call is made. s.mode = tc.mode - binding := &agentv1.ExecutionBinding{ExecutionId: "execution-policy", TenantId: "tenant-1", TenantKey: "tenant-key", TaskId: "task-1", TaskItemId: "item-1", TaskRevision: 1} - s.executions[binding.ExecutionId] = &executionRecord{binding: binding, taskRevision: 1, state: agentv1.ExecutionState_EXECUTION_STATE_OBSERVED} - response, err := s.ApplyTaskControl(context.Background(), &agentv1.ApplyTaskControlRequest{Meta: testMeta("control", "control-key", 1), Binding: binding, ExpectedTaskRevision: 1, Action: tc.action, ActiveCallPolicy: tc.policy}) + binding := &agentpb.ExecutionBinding{ExecutionId: "execution-policy", TenantId: "tenant-1", TenantKey: "tenant-key", TaskId: "task-1", TaskItemId: "item-1", TaskRevision: 1} + s.executions[binding.ExecutionId] = &executionRecord{binding: binding, taskRevision: 1, state: agentpb.ExecutionState_EXECUTION_STATE_OBSERVED} + response, err := s.ApplyTaskControl(context.Background(), &agentpb.ApplyTaskControlRequest{Meta: testMeta("control", "control-key", 1), Binding: binding, ExpectedTaskRevision: 1, Action: tc.action, ActiveCallPolicy: tc.policy}) if tc.wantError { if err == nil || response != nil { t.Fatal("unsupported policy reported applied") } - if s.executions[binding.ExecutionId].taskRevision != 1 || s.executions[binding.ExecutionId].state != agentv1.ExecutionState_EXECUTION_STATE_OBSERVED { + if s.executions[binding.ExecutionId].taskRevision != 1 || s.executions[binding.ExecutionId].state != agentpb.ExecutionState_EXECUTION_STATE_OBSERVED { t.Fatal("failed policy changed execution") } return } require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_APPLIED, response.Receipt.Result) - if (response.State == agentv1.ExecutionState_EXECUTION_STATE_TERMINAL) != tc.terminal { + require.Equal(t, agentpb.ResultCode_RESULT_CODE_APPLIED, response.Receipt.Result) + if (response.State == agentpb.ExecutionState_EXECUTION_STATE_TERMINAL) != tc.terminal { t.Fatal("incorrect call termination") } }) diff --git a/internal/rpc/dispatcher_events.go b/internal/rpc/dispatcher_events.go index 6af40ce..8a07b21 100644 --- a/internal/rpc/dispatcher_events.go +++ b/internal/rpc/dispatcher_events.go @@ -7,7 +7,7 @@ import ( "fmt" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/mq" "git.ipao.vip/rogee/go-sip/internal/store" @@ -24,8 +24,8 @@ type DispatcherEventServerOptions struct { Now func() time.Time // LocalV3RecordingFailure accepts only a versioned Mock failure fact; // when configured, the older split execution events are rejected. - LocalV3RecordingFailure func(context.Context, *agentv1.ExecutionFact) error - LocalV3SessionCheck func(*agentv1.RequestMeta) error + LocalV3RecordingFailure func(context.Context, *agentpb.ExecutionFact) error + LocalV3SessionCheck func(*agentpb.RequestMeta) error } // DispatcherEventServer owns the Dispatcher side of R11. It persists the @@ -36,8 +36,8 @@ type DispatcherEventServerOptions struct { type DispatcherEventServer struct { store *store.Store now func() time.Time - localV3RecordingFailure func(context.Context, *agentv1.ExecutionFact) error - localV3SessionCheck func(*agentv1.RequestMeta) error + localV3RecordingFailure func(context.Context, *agentpb.ExecutionFact) error + localV3SessionCheck func(*agentpb.RequestMeta) error requirePeer bool peerCertificateFingerprints map[string]struct{} allowedAgentIDs map[string]struct{} @@ -63,7 +63,7 @@ func NewDispatcherEventServer(st *store.Store, options DispatcherEventServerOpti }, nil } -func (s *DispatcherEventServer) ReportExecutionEvent(ctx context.Context, req *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (s *DispatcherEventServer) ReportExecutionEvent(ctx context.Context, req *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { if req == nil || req.Meta == nil || req.Fact == nil || req.Fact.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata, fact and binding are required") } @@ -94,23 +94,23 @@ func (s *DispatcherEventServer) ReportExecutionEvent(ctx context.Context, req *a if s.localV3RecordingFailure != nil { if err := s.localV3SessionCheck(req.Meta); err != nil { if errors.Is(err, store.ErrCommandConflict) { - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil } return nil, status.Errorf(codes.Internal, "check active Agent session: %v", err) } - if fact.Kind != agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS || fact.SourceSequence == 0 { - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_ABORTED, "Mock V3 accepts only a recording failure with a valid source sequence", fact.FactId, fact.ContentSha256)}, nil + if fact.Kind != agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS || fact.SourceSequence == 0 { + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_ABORTED, "Mock V3 accepts only a recording failure with a valid source sequence", fact.FactId, fact.ContentSha256)}, nil } if err := s.localV3RecordingFailure(ctx, fact); err != nil { if errors.Is(err, store.ErrFactConflict) { - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil } if errors.Is(err, store.ErrCommandConflict) { - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil } return nil, status.Errorf(codes.Internal, "persist Mock recording failure and final result: %v", err) } - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "Mock recording failure and final result persisted", fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "Mock recording failure and final result persisted", fact.FactId, fact.ContentSha256)}, nil } eventType, aggregateType, aggregateID, eventPayload, err := deriveFactEvent(fact.Kind, binding, payload) @@ -156,7 +156,7 @@ func (s *DispatcherEventServer) ReportExecutionEvent(ctx context.Context, req *a result, err := s.store.RecordExecutionFact(record, mq.EventExchange, routingKey, eventBuilder) if err != nil { if errors.Is(err, store.ErrFactConflict) { - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, err.Error(), fact.FactId, fact.ContentSha256)}, nil } return nil, status.Errorf(codes.Internal, "persist execution fact: %v", err) } @@ -164,25 +164,25 @@ func (s *DispatcherEventServer) ReportExecutionEvent(ctx context.Context, req *a if result.Duplicate { message = "duplicate fact" } - return &agentv1.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, message, fact.FactId, fact.ContentSha256)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: dispatcherReceipt(req.Meta, s.now(), agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, message, fact.FactId, fact.ContentSha256)}, nil } -func deriveFactEvent(kind agentv1.FactKind, binding *agentv1.ExecutionBinding, payload map[string]any) (string, string, string, map[string]any, error) { +func deriveFactEvent(kind agentpb.FactKind, binding *agentpb.ExecutionBinding, payload map[string]any) (string, string, string, map[string]any, error) { var eventType, aggregateType string switch kind { - case agentv1.FactKind_FACT_KIND_EXECUTION_ACCEPTED: + case agentpb.FactKind_FACT_KIND_EXECUTION_ACCEPTED: eventType, aggregateType = "command.result", "command" - case agentv1.FactKind_FACT_KIND_CALL_STATUS: + case agentpb.FactKind_FACT_KIND_CALL_STATUS: eventType, aggregateType = "call.status", "call" - case agentv1.FactKind_FACT_KIND_CALL_FINISHED: + case agentpb.FactKind_FACT_KIND_CALL_FINISHED: eventType, aggregateType = "call.finished", "call" - case agentv1.FactKind_FACT_KIND_TRANSCRIPT_UPDATED: + case agentpb.FactKind_FACT_KIND_TRANSCRIPT_UPDATED: eventType, aggregateType = "transcript.updated", "transcript_segment" - case agentv1.FactKind_FACT_KIND_TRANSCRIPT_FAILED: + case agentpb.FactKind_FACT_KIND_TRANSCRIPT_FAILED: eventType, aggregateType = "transcript.failed", "transcript" - case agentv1.FactKind_FACT_KIND_CONTACT_OPT_OUT: + case agentpb.FactKind_FACT_KIND_CONTACT_OPT_OUT: eventType, aggregateType = "contact.opt_out", "call" - case agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS: + case agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS: return "", "execution_fact", binding.ExecutionId, payload, nil default: return "", "", "", nil, fmt.Errorf("unsupported fact kind %s", kind.String()) @@ -210,9 +210,9 @@ func firstPayloadString(payload map[string]any, keys ...string) string { return "" } -func dispatcherReceipt(meta *agentv1.RequestMeta, now time.Time, result agentv1.ResultCode, failure agentv1.FailureCode, detail, factID, digest string) *agentv1.OperationReceipt { - receipt := &agentv1.OperationReceipt{ - Meta: &agentv1.ResponseMeta{ +func dispatcherReceipt(meta *agentpb.RequestMeta, now time.Time, result agentpb.ResultCode, failure agentpb.FailureCode, detail, factID, digest string) *agentpb.OperationReceipt { + receipt := &agentpb.OperationReceipt{ + Meta: &agentpb.ResponseMeta{ ProtocolVersion: meta.ProtocolVersion, RequestId: meta.RequestId, TraceId: meta.TraceId, OperationId: meta.OperationId, ObservedAtUnixMs: now.UnixMilli(), DispatcherEpoch: meta.DispatcherEpoch, AgentId: meta.AgentId, CellId: meta.CellId, @@ -220,8 +220,8 @@ func dispatcherReceipt(meta *agentv1.RequestMeta, now time.Time, result agentv1. }, Result: result, FactId: factID, ContentSha256: digest, AcceptedAtUnixMs: now.UnixMilli(), } - if failure != agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED { - receipt.Failure = &agentv1.Failure{Code: failure, Detail: detail} + if failure != agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED { + receipt.Failure = &agentpb.Failure{Code: failure, Detail: detail} } return receipt } diff --git a/internal/rpc/dispatcher_events_local_v3_test.go b/internal/rpc/dispatcher_events_local_v3_test.go index f5b77b3..f7573d5 100644 --- a/internal/rpc/dispatcher_events_local_v3_test.go +++ b/internal/rpc/dispatcher_events_local_v3_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/store" "github.com/google/uuid" "google.golang.org/grpc/codes" @@ -32,15 +32,15 @@ func TestLocalV3EventServerAcceptsOnlyVersionedMockRecordingFailure(t *testing.T var callbackErr error server, err := NewDispatcherEventServer(st, DispatcherEventServerOptions{ Now: func() time.Time { return now }, - LocalV3SessionCheck: func(meta *agentv1.RequestMeta) error { + LocalV3SessionCheck: func(meta *agentpb.RequestMeta) error { if meta.BootId != activeBoot || meta.SessionGeneration != activeGeneration || meta.DispatcherEpoch != "epoch-a" { return store.ErrCommandConflict } return nil }, - LocalV3RecordingFailure: func(_ context.Context, fact *agentv1.ExecutionFact) error { + LocalV3RecordingFailure: func(_ context.Context, fact *agentpb.ExecutionFact) error { called++ - if fact.Kind != agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS { + if fact.Kind != agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS { t.Fatalf("legacy event passed Mock failure handler: %v", fact.Kind) } return callbackErr @@ -49,42 +49,42 @@ func TestLocalV3EventServerAcceptsOnlyVersionedMockRecordingFailure(t *testing.T if err != nil { t.Fatal(err) } - meta := &agentv1.RequestMeta{ + meta := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", RequestId: "request-a", OperationId: "operation-a", IdempotencyKey: "idempotency-a", AgentId: "agent-a", CellId: "cell-a", BootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1, TraceId: "trace-a", } payload := []byte(`{"schema_version":"local-mock-recording-failure.v0.1","upload_id":"upload-a","recording_id":"recording-a","error_code":"upload_failed"}`) sum := sha256.Sum256(payload) - fact := &agentv1.ExecutionFact{ - FactId: uuid.NewString(), ContentSha256: hex.EncodeToString(sum[:]), Kind: agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS, - Binding: &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"}, + fact := &agentpb.ExecutionFact{ + FactId: uuid.NewString(), ContentSha256: hex.EncodeToString(sum[:]), Kind: agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS, + Binding: &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", ExecutionId: "execution-a"}, PayloadJson: payload, ObservedAtUnixMs: now.UnixMilli(), SourceBootId: meta.BootId, SourceSequence: 1, } - request := &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: fact} + request := &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: fact} receipt, err := server.ReportExecutionEvent(context.Background(), request) - if err != nil || receipt.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || called != 1 { + if err != nil || receipt.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || called != 1 { t.Fatalf("Mock failure was not routed: receipt=%+v calls=%d err=%v", receipt, called, err) } - legacy := proto.Clone(fact).(*agentv1.ExecutionFact) - legacy.Kind = agentv1.FactKind_FACT_KIND_CALL_STATUS + legacy := proto.Clone(fact).(*agentpb.ExecutionFact) + legacy.Kind = agentpb.FactKind_FACT_KIND_CALL_STATUS legacy.FactId = uuid.NewString() legacy.PayloadJson = []byte(`{"call_id":"call-a","state":"finished"}`) - if got, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: legacy}); err != nil || got.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_REJECTED || called != 1 { + if got, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: legacy}); err != nil || got.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_REJECTED || called != 1 { t.Fatalf("legacy split call event leaked into V3: receipt=%+v calls=%d err=%v", got, called, err) } - restartedMeta := proto.Clone(meta).(*agentv1.RequestMeta) + restartedMeta := proto.Clone(meta).(*agentpb.RequestMeta) restartedMeta.BootId = "new-active-boot" restartedMeta.SessionGeneration = 2 activeBoot, activeGeneration = restartedMeta.BootId, restartedMeta.SessionGeneration - if got, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: restartedMeta, Fact: fact}); err != nil || got.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_ACCEPTED || called != 2 { + if got, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: restartedMeta, Fact: fact}); err != nil || got.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_ACCEPTED || called != 2 { t.Fatalf("durable fact from the previous boot was rejected after restart: receipt=%+v calls=%d err=%v", got, called, err) } - if got, err := server.ReportExecutionEvent(context.Background(), request); err != nil || got.GetReceipt().GetResult() != agentv1.ResultCode_RESULT_CODE_REJECTED || called != 2 { + if got, err := server.ReportExecutionEvent(context.Background(), request); err != nil || got.GetReceipt().GetResult() != agentpb.ResultCode_RESULT_CODE_REJECTED || called != 2 { t.Fatalf("fenced old Agent session reached Mock handler: receipt=%+v calls=%d err=%v", got, called, err) } - missingSource := proto.Clone(fact).(*agentv1.ExecutionFact) + missingSource := proto.Clone(fact).(*agentpb.ExecutionFact) missingSource.SourceBootId = "" - if _, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: missingSource}); status.Code(err) != codes.InvalidArgument || called != 2 { + if _, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: missingSource}); status.Code(err) != codes.InvalidArgument || called != 2 { t.Fatalf("missing source boot reached handler: calls=%d err=%v", called, err) } var outbox int @@ -95,10 +95,10 @@ func TestLocalV3EventServerAcceptsOnlyVersionedMockRecordingFailure(t *testing.T for _, tc := range []struct { name string cause error - result agentv1.ResultCode + result agentpb.ResultCode }{ - {"fact conflict", store.ErrFactConflict, agentv1.ResultCode_RESULT_CODE_CONFLICT}, - {"recording conflict", store.ErrCommandConflict, agentv1.ResultCode_RESULT_CODE_REJECTED}, + {"fact conflict", store.ErrFactConflict, agentpb.ResultCode_RESULT_CODE_CONFLICT}, + {"recording conflict", store.ErrCommandConflict, agentpb.ResultCode_RESULT_CODE_REJECTED}, } { t.Run(tc.name, func(t *testing.T) { callbackErr = tc.cause diff --git a/internal/rpc/dispatcher_events_test.go b/internal/rpc/dispatcher_events_test.go index 2289e24..634da93 100644 --- a/internal/rpc/dispatcher_events_test.go +++ b/internal/rpc/dispatcher_events_test.go @@ -8,7 +8,7 @@ import ( "time" "git.ipao.vip/rogee/go-sip/contracts" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/mq" "git.ipao.vip/rogee/go-sip/internal/store" @@ -46,25 +46,25 @@ func TestDispatcherServerReportsFactAndEmitsOneAuthoritativeEvent(t *testing.T) if err != nil { t.Fatal(err) } - meta := &agentv1.RequestMeta{ + meta := &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", RequestId: "request-fact-1", TraceId: "trace-fact-1", OperationId: "operation-fact-1", IdempotencyKey: "idempotency-fact-1", AgentId: "agent-cell-a", CellId: "cell-a", BootId: "boot-a", } - binding := &agentv1.ExecutionBinding{ + binding := &agentpb.ExecutionBinding{ TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: "execution-1", TaskId: "task-1", TaskItemId: "item-1", TaskRevision: 1, CallId: "call-1", AttemptId: "attempt-1", } - fact := &agentv1.ExecutionFact{ - FactId: "fact-1", ContentSha256: "sha256-fact-1", Kind: agentv1.FactKind_FACT_KIND_CALL_STATUS, + fact := &agentpb.ExecutionFact{ + FactId: "fact-1", ContentSha256: "sha256-fact-1", Kind: agentpb.FactKind_FACT_KIND_CALL_STATUS, Binding: binding, PayloadJson: payload, ObservedAtUnixMs: clock.UnixMilli(), SourceBootId: "boot-a", SourceSequence: 1, } - request := &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: fact} + request := &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: fact} response, err := server.ReportExecutionEvent(context.Background(), request) if err != nil { t.Fatal(err) } - if response.Receipt == nil || response.Receipt.Result != agentv1.ResultCode_RESULT_CODE_ACCEPTED { + if response.Receipt == nil || response.Receipt.Result != agentpb.ResultCode_RESULT_CODE_ACCEPTED { t.Fatalf("unexpected receipt: %+v", response) } var body []byte @@ -107,7 +107,7 @@ func TestDispatcherServerReportsFactAndEmitsOneAuthoritativeEvent(t *testing.T) if err != nil { t.Fatal(err) } - if duplicate.Receipt == nil || duplicate.Receipt.Result != agentv1.ResultCode_RESULT_CODE_ACCEPTED { + if duplicate.Receipt == nil || duplicate.Receipt.Result != agentpb.ResultCode_RESULT_CODE_ACCEPTED { t.Fatalf("duplicate was not accepted: %+v", duplicate) } if err := st.DB().QueryRow(`SELECT COUNT(*) FROM outbox WHERE event_id = ?`, "execution-fact-fact-1").Scan(&outbox); err != nil { @@ -117,15 +117,15 @@ func TestDispatcherServerReportsFactAndEmitsOneAuthoritativeEvent(t *testing.T) t.Fatalf("duplicate created %d outbox rows", outbox) } - secondFact := proto.Clone(fact).(*agentv1.ExecutionFact) + secondFact := proto.Clone(fact).(*agentpb.ExecutionFact) secondFact.FactId = "fact-2" secondFact.ContentSha256 = "sha256-fact-2" secondFact.SourceSequence = 2 - second, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: secondFact}) + second, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: secondFact}) if err != nil { t.Fatal(err) } - if second.Receipt == nil || second.Receipt.Result != agentv1.ResultCode_RESULT_CODE_ACCEPTED { + if second.Receipt == nil || second.Receipt.Result != agentpb.ResultCode_RESULT_CODE_ACCEPTED { t.Fatalf("second fact was not accepted: %+v", second) } if err := st.DB().QueryRow(`SELECT body FROM outbox WHERE event_id = ?`, "execution-fact-fact-2").Scan(&body); err != nil { @@ -138,13 +138,13 @@ func TestDispatcherServerReportsFactAndEmitsOneAuthoritativeEvent(t *testing.T) t.Fatalf("Dispatcher did not allocate aggregate version 2: %#v", eventEnvelope["aggregate_version"]) } - conflictFact := proto.Clone(fact).(*agentv1.ExecutionFact) + conflictFact := proto.Clone(fact).(*agentpb.ExecutionFact) conflictFact.ContentSha256 = "sha256-fact-conflict" - conflict, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: meta, Fact: conflictFact}) + conflict, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: meta, Fact: conflictFact}) if err != nil { t.Fatal(err) } - if conflict.Receipt == nil || conflict.Receipt.Result != agentv1.ResultCode_RESULT_CODE_CONFLICT { + if conflict.Receipt == nil || conflict.Receipt.Result != agentpb.ResultCode_RESULT_CODE_CONFLICT { t.Fatalf("digest conflict was not rejected: %+v", conflict) } } diff --git a/internal/rpc/dispatcher_server.go b/internal/rpc/dispatcher_server.go index e17c4d1..ce6e71b 100644 --- a/internal/rpc/dispatcher_server.go +++ b/internal/rpc/dispatcher_server.go @@ -3,7 +3,7 @@ package rpc import ( "context" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/peer" @@ -14,11 +14,11 @@ import ( // Upload RPCs and Agent-reported facts share this listener; the service is not // an upload-only endpoint. type dispatcherEventReporter interface { - ReportExecutionEvent(context.Context, *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) + ReportExecutionEvent(context.Context, *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) } type DispatcherServer struct { - agentv1.UnimplementedAgentControlServiceServer + agentpb.UnimplementedAgentControlServiceServer uploads *DispatcherUploadServer events dispatcherEventReporter } @@ -31,28 +31,28 @@ func NewDispatcherServer(uploads *DispatcherUploadServer, eventHandlers ...dispa return &DispatcherServer{uploads: uploads, events: events} } -func (s *DispatcherServer) RequestUpload(ctx context.Context, req *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) { +func (s *DispatcherServer) RequestUpload(ctx context.Context, req *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) { if s.uploads == nil { return nil, status.Error(codes.Unimplemented, "Dispatcher upload handler is not configured") } return s.uploads.RequestUpload(ctx, req) } -func (s *DispatcherServer) CompleteUpload(ctx context.Context, req *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) { +func (s *DispatcherServer) CompleteUpload(ctx context.Context, req *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) { if s.uploads == nil { return nil, status.Error(codes.Unimplemented, "Dispatcher upload handler is not configured") } return s.uploads.CompleteUpload(ctx, req) } -func (s *DispatcherServer) ReportExecutionEvent(ctx context.Context, req *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (s *DispatcherServer) ReportExecutionEvent(ctx context.Context, req *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { if s.events == nil { return nil, status.Error(codes.Unimplemented, "Dispatcher execution-event receiver is not configured") } return s.events.ReportExecutionEvent(ctx, req) } -func validateDispatcherPeer(ctx context.Context, meta *agentv1.RequestMeta, requirePeer bool, fingerprints, allowedAgentIDs map[string]struct{}) error { +func validateDispatcherPeer(ctx context.Context, meta *agentpb.RequestMeta, requirePeer bool, fingerprints, allowedAgentIDs map[string]struct{}) error { if meta == nil { return status.Error(codes.InvalidArgument, "request metadata is required") } diff --git a/internal/rpc/dispatcher_upload.go b/internal/rpc/dispatcher_upload.go index d72d4ac..28d88d8 100644 --- a/internal/rpc/dispatcher_upload.go +++ b/internal/rpc/dispatcher_upload.go @@ -11,7 +11,7 @@ import ( "strings" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" @@ -25,13 +25,13 @@ import ( // credentials and durable upload state on the Dispatcher and gives Agents only // short-lived presigned PUT grants. type DispatcherUploadServer struct { - agentv1.UnimplementedAgentControlServiceServer + agentpb.UnimplementedAgentControlServiceServer store *store.Store oss *ossclient.Client now func() time.Time - localV3Authorize func(context.Context, *agentv1.RequestUploadRequest) error - localV3Complete func(context.Context, *agentv1.CompleteUploadRequest, store.UploadRecord) (bool, error) + localV3Authorize func(context.Context, *agentpb.RequestUploadRequest) error + localV3Complete func(context.Context, *agentpb.CompleteUploadRequest, store.UploadRecord) (bool, error) requirePeer bool maxAssetBytes int64 peerCertificateFingerprints map[string]struct{} @@ -43,11 +43,11 @@ type DispatcherUploadOptions struct { PeerCertificateFingerprints map[string]struct{} AllowedAgentIDs map[string]struct{} // LocalV3Authorize binds an OSS grant to a confirmed Mock recording. - LocalV3Authorize func(context.Context, *agentv1.RequestUploadRequest) error + LocalV3Authorize func(context.Context, *agentpb.RequestUploadRequest) error // LocalV3Complete is the sole Mock-mode upload outcome path. A successful // local write is not delivery: true requires the final call.result to // have reached the durable MQ queue with publisher confirmation. - LocalV3Complete func(context.Context, *agentv1.CompleteUploadRequest, store.UploadRecord) (bool, error) + LocalV3Complete func(context.Context, *agentpb.CompleteUploadRequest, store.UploadRecord) (bool, error) } func NewDispatcherUploadServer(st *store.Store, client *ossclient.Client, now func() time.Time, requirePeer bool) (*DispatcherUploadServer, error) { @@ -77,15 +77,15 @@ func NewDispatcherUploadServerWithOptions(st *store.Store, client *ossclient.Cli }, nil } -func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) { +func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) { if err := s.validateRequest(ctx, req.GetMeta(), req.GetBinding(), req.GetAsset(), req.GetUploadId()); err != nil { return nil, err } if req.Asset.SizeBytes <= 0 || req.Asset.ChecksumSha256 == "" { - return s.requestUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "asset size and SHA-256 are required", false), nil + return s.requestUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "asset size and SHA-256 are required", false), nil } if s.maxAssetBytes > 0 && req.Asset.SizeBytes > s.maxAssetBytes { - return s.requestUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_RESOURCE_EXHAUSTED, "asset exceeds Dispatcher OSS limit", false), nil + return s.requestUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_RESOURCE_EXHAUSTED, "asset exceeds Dispatcher OSS limit", false), nil } if s.localV3Authorize != nil { if err := s.localV3Authorize(ctx, req); err != nil { @@ -100,7 +100,7 @@ func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentv1 return nil, status.Errorf(codes.Internal, "decode durable upload %q: %v", req.UploadId, decodeErr) } if !proto.Equal(binding, req.Binding) || !proto.Equal(asset, req.Asset) { - return s.requestUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_ABORTED, "upload ID is bound to a different execution or asset", false), nil + return s.requestUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_ABORTED, "upload ID is bound to a different execution or asset", false), nil } if record.State == "uploaded" { detail := "upload already reported; retry completion notification, not PUT" @@ -114,7 +114,7 @@ func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentv1 if s.localV3Complete != nil { detail = "final call.result delivered to MQ" } - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, detail, false), State: agentv1.UploadState_UPLOAD_STATE_COMPLETED}, nil + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, detail, false), State: agentpb.UploadState_UPLOAD_STATE_COMPLETED}, nil } } else if !errors.Is(err, sql.ErrNoRows) { return nil, status.Errorf(codes.Internal, "load upload: %v", err) @@ -130,11 +130,11 @@ func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentv1 requestHash := hex.EncodeToString(requestSum[:]) previous, err := s.store.LoadUploadGrantRequest(req.UploadId, req.Meta.OperationId, requestHash) if err == nil { - var original agentv1.UploadGrant + var original agentpb.UploadGrant if err := proto.Unmarshal(previous, &original); err != nil { return nil, status.Errorf(codes.Internal, "decode original grant: %v", err) } - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, "original upload grant", false), Grant: &original, State: agentv1.UploadState_UPLOAD_STATE_REQUESTED}, nil + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, "original upload grant", false), Grant: &original, State: agentpb.UploadState_UPLOAD_STATE_REQUESTED}, nil } if errors.Is(err, store.ErrIdempotencyConflict) { return nil, status.Error(codes.AlreadyExists, "upload request identity conflicts") @@ -175,23 +175,23 @@ func (s *DispatcherUploadServer) RequestUpload(ctx context.Context, req *agentv1 if err := proto.Unmarshal(persisted, grant); err != nil { return nil, status.Errorf(codes.Internal, "decode persisted grant: %v", err) } - return &agentv1.RequestUploadResponse{ - Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, "upload grant issued", false), + return &agentpb.RequestUploadResponse{ + Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, "upload grant issued", false), Grant: grant, - State: agentv1.UploadState_UPLOAD_STATE_REQUESTED, + State: agentpb.UploadState_UPLOAD_STATE_REQUESTED, }, nil } -func (s *DispatcherUploadServer) CompleteUpload(ctx context.Context, req *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) { +func (s *DispatcherUploadServer) CompleteUpload(ctx context.Context, req *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) { if err := s.validateRequest(ctx, req.GetMeta(), req.GetBinding(), req.GetAsset(), req.GetUploadId()); err != nil { return nil, err } if req.UploadedSizeBytes <= 0 || req.UploadedChecksumSha256 == "" { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded size and SHA-256 are required", false), nil + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded size and SHA-256 are required", false), nil } record, err := s.store.LoadUpload(req.UploadId) if errors.Is(err, sql.ErrNoRows) { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_NOT_FOUND, "upload not found", false), nil + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_NOT_FOUND, "upload not found", false), nil } if err != nil { return nil, status.Errorf(codes.Internal, "load upload: %v", err) @@ -201,23 +201,23 @@ func (s *DispatcherUploadServer) CompleteUpload(ctx context.Context, req *agentv return nil, status.Errorf(codes.Internal, "decode durable upload %q: %v", req.UploadId, err) } if !proto.Equal(binding, req.Binding) || !proto.Equal(asset, req.Asset) { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_ABORTED, "upload completion binding does not match request", false), nil + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_ABORTED, "upload completion binding does not match request", false), nil } if asset.SizeBytes != req.UploadedSizeBytes || !strings.EqualFold(asset.ChecksumSha256, req.UploadedChecksumSha256) || req.UploadedSizeBytes > grant.MaxBytes { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded asset does not match grant", false), nil + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded asset does not match grant", false), nil } if record.State == "completed" && s.localV3Complete == nil { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, "upload notification delivered to MQ", false), State: agentv1.UploadState_UPLOAD_STATE_COMPLETED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, "upload notification delivered to MQ", false), State: agentpb.UploadState_UPLOAD_STATE_COMPLETED}, nil } if record.State == "uploaded" && s.localV3Complete == nil { return nil, status.Error(codes.Unavailable, "upload fact retained; original notification awaits MQ delivery") } - if asset.Kind != agentv1.AssetKind_ASSET_KIND_RECORDING { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "only recording upload facts are supported", false), nil + if asset.Kind != agentpb.AssetKind_ASSET_KIND_RECORDING { + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "only recording upload facts are supported", false), nil } if s.localV3Complete != nil { if record.State != "granted" && record.State != "uploaded" && record.State != "completed" { - return s.completeUploadFailure(req.Meta, agentv1.FailureCode_FAILURE_CODE_ABORTED, "upload already closed without a completed asset", false), nil + return s.completeUploadFailure(req.Meta, agentpb.FailureCode_FAILURE_CODE_ABORTED, "upload already closed without a completed asset", false), nil } delivered, err := s.localV3Complete(ctx, req, record) if err != nil { @@ -226,7 +226,7 @@ func (s *DispatcherUploadServer) CompleteUpload(ctx context.Context, req *agentv if !delivered { return nil, status.Error(codes.Unavailable, "upload fact retained; final call.result awaits MQ delivery") } - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, "final call.result delivered to MQ", false), State: agentv1.UploadState_UPLOAD_STATE_COMPLETED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, "final call.result delivered to MQ", false), State: agentpb.UploadState_UPLOAD_STATE_COMPLETED}, nil } dispatcherID, err := s.store.DispatcherID() if err != nil { @@ -254,7 +254,7 @@ func (s *DispatcherUploadServer) CompleteUpload(ctx context.Context, req *agentv return nil, status.Error(codes.Unavailable, "upload fact retained; original notification awaits MQ delivery") } -func (s *DispatcherUploadServer) validateRequest(ctx context.Context, meta *agentv1.RequestMeta, binding *agentv1.ExecutionBinding, asset *agentv1.AssetDescriptor, uploadID string) error { +func (s *DispatcherUploadServer) validateRequest(ctx context.Context, meta *agentpb.RequestMeta, binding *agentpb.ExecutionBinding, asset *agentpb.AssetDescriptor, uploadID string) error { if meta == nil || binding == nil || asset == nil { return status.Error(codes.InvalidArgument, "request metadata, binding and asset are required") } @@ -284,7 +284,7 @@ func cloneStringSet(source map[string]struct{}) map[string]struct{} { return result } -func (s *DispatcherUploadServer) objectKey(binding *agentv1.ExecutionBinding, asset *agentv1.AssetDescriptor) string { +func (s *DispatcherUploadServer) objectKey(binding *agentpb.ExecutionBinding, asset *agentpb.AssetDescriptor) string { prefix := strings.Trim(s.oss.Config().KeyPrefix, "/") input := binding.TenantKey + "\x00" + binding.ExecutionId + "\x00" + asset.AssetId digest := sha256.Sum256([]byte(input)) @@ -295,10 +295,10 @@ func (s *DispatcherUploadServer) objectKey(binding *agentv1.ExecutionBinding, as return prefix + "/" + name } -func decodeUploadRecord(record store.UploadRecord) (*agentv1.ExecutionBinding, *agentv1.AssetDescriptor, *agentv1.UploadGrant, error) { - binding := &agentv1.ExecutionBinding{} - asset := &agentv1.AssetDescriptor{} - grant := &agentv1.UploadGrant{} +func decodeUploadRecord(record store.UploadRecord) (*agentpb.ExecutionBinding, *agentpb.AssetDescriptor, *agentpb.UploadGrant, error) { + binding := &agentpb.ExecutionBinding{} + asset := &agentpb.AssetDescriptor{} + grant := &agentpb.UploadGrant{} if err := proto.Unmarshal(record.Binding, binding); err != nil { return nil, nil, nil, fmt.Errorf("binding: %w", err) } @@ -311,22 +311,22 @@ func decodeUploadRecord(record store.UploadRecord) (*agentv1.ExecutionBinding, * return binding, asset, grant, nil } -func (s *DispatcherUploadServer) responseMeta(meta *agentv1.RequestMeta) *agentv1.ResponseMeta { - return &agentv1.ResponseMeta{ProtocolVersion: meta.ProtocolVersion, RequestId: meta.RequestId, TraceId: meta.TraceId, OperationId: meta.OperationId, ObservedAtUnixMs: s.now().UnixMilli(), DispatcherEpoch: meta.DispatcherEpoch, AgentId: meta.AgentId, CellId: meta.CellId, BootId: meta.BootId, SessionGeneration: meta.SessionGeneration} +func (s *DispatcherUploadServer) responseMeta(meta *agentpb.RequestMeta) *agentpb.ResponseMeta { + return &agentpb.ResponseMeta{ProtocolVersion: meta.ProtocolVersion, RequestId: meta.RequestId, TraceId: meta.TraceId, OperationId: meta.OperationId, ObservedAtUnixMs: s.now().UnixMilli(), DispatcherEpoch: meta.DispatcherEpoch, AgentId: meta.AgentId, CellId: meta.CellId, BootId: meta.BootId, SessionGeneration: meta.SessionGeneration} } -func (s *DispatcherUploadServer) receipt(meta *agentv1.RequestMeta, result agentv1.ResultCode, detail string, retryable bool) *agentv1.OperationReceipt { - receipt := &agentv1.OperationReceipt{Meta: s.responseMeta(meta), Result: result, AcceptedAtUnixMs: s.now().UnixMilli()} +func (s *DispatcherUploadServer) receipt(meta *agentpb.RequestMeta, result agentpb.ResultCode, detail string, retryable bool) *agentpb.OperationReceipt { + receipt := &agentpb.OperationReceipt{Meta: s.responseMeta(meta), Result: result, AcceptedAtUnixMs: s.now().UnixMilli()} if detail != "" { - receipt.Failure = &agentv1.Failure{Code: agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, Detail: detail, Retryable: retryable} + receipt.Failure = &agentpb.Failure{Code: agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, Detail: detail, Retryable: retryable} } return receipt } -func (s *DispatcherUploadServer) requestUploadFailure(meta *agentv1.RequestMeta, code agentv1.FailureCode, detail string, retryable bool) *agentv1.RequestUploadResponse { - return &agentv1.RequestUploadResponse{Receipt: &agentv1.OperationReceipt{Meta: s.responseMeta(meta), Result: agentv1.ResultCode_RESULT_CODE_REJECTED, Failure: &agentv1.Failure{Code: code, Detail: detail, Retryable: retryable}, AcceptedAtUnixMs: s.now().UnixMilli()}, State: agentv1.UploadState_UPLOAD_STATE_FAILED} +func (s *DispatcherUploadServer) requestUploadFailure(meta *agentpb.RequestMeta, code agentpb.FailureCode, detail string, retryable bool) *agentpb.RequestUploadResponse { + return &agentpb.RequestUploadResponse{Receipt: &agentpb.OperationReceipt{Meta: s.responseMeta(meta), Result: agentpb.ResultCode_RESULT_CODE_REJECTED, Failure: &agentpb.Failure{Code: code, Detail: detail, Retryable: retryable}, AcceptedAtUnixMs: s.now().UnixMilli()}, State: agentpb.UploadState_UPLOAD_STATE_FAILED} } -func (s *DispatcherUploadServer) completeUploadFailure(meta *agentv1.RequestMeta, code agentv1.FailureCode, detail string, retryable bool) *agentv1.CompleteUploadResponse { - return &agentv1.CompleteUploadResponse{Receipt: &agentv1.OperationReceipt{Meta: s.responseMeta(meta), Result: agentv1.ResultCode_RESULT_CODE_REJECTED, Failure: &agentv1.Failure{Code: code, Detail: detail, Retryable: retryable}, AcceptedAtUnixMs: s.now().UnixMilli()}, State: agentv1.UploadState_UPLOAD_STATE_FAILED} +func (s *DispatcherUploadServer) completeUploadFailure(meta *agentpb.RequestMeta, code agentpb.FailureCode, detail string, retryable bool) *agentpb.CompleteUploadResponse { + return &agentpb.CompleteUploadResponse{Receipt: &agentpb.OperationReceipt{Meta: s.responseMeta(meta), Result: agentpb.ResultCode_RESULT_CODE_REJECTED, Failure: &agentpb.Failure{Code: code, Detail: detail, Retryable: retryable}, AcceptedAtUnixMs: s.now().UnixMilli()}, State: agentpb.UploadState_UPLOAD_STATE_FAILED} } diff --git a/internal/rpc/dispatcher_upload_integration_test.go b/internal/rpc/dispatcher_upload_integration_test.go index a4c0e5d..e2ab6eb 100644 --- a/internal/rpc/dispatcher_upload_integration_test.go +++ b/internal/rpc/dispatcher_upload_integration_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/agent" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" @@ -54,9 +54,9 @@ func TestAlibabaOSSDispatcherUploadDurableIntegration(t *testing.T) { } digest := sha256.Sum256(payload) checksum := hex.EncodeToString(digest[:]) - binding := &agentv1.ExecutionBinding{TenantId: "tenant-integration", TenantKey: "tenant-integration", ExecutionId: "exec-oss-integration", TaskId: "task-oss-integration", TaskItemId: "item-oss-integration", TaskRevision: 1, CallId: "call-oss-integration", AttemptId: "attempt-oss-integration"} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-integration", CallId: binding.CallId, ExecutionId: binding.ExecutionId, Format: "wav", SizeBytes: int64(len(payload)), ChecksumSha256: checksum, Channels: 1, SampleRateHz: 16000, DurationMs: 1000} - requestMeta := &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "request-oss-integration", TraceId: "trace-oss-integration", OperationId: "operation-oss-integration", IdempotencyKey: "idempotency-oss-integration", AgentId: "agent-integration", CellId: "cell-integration"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-integration", TenantKey: "tenant-integration", ExecutionId: "exec-oss-integration", TaskId: "task-oss-integration", TaskItemId: "item-oss-integration", TaskRevision: 1, CallId: "call-oss-integration", AttemptId: "attempt-oss-integration"} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-integration", CallId: binding.CallId, ExecutionId: binding.ExecutionId, Format: "wav", SizeBytes: int64(len(payload)), ChecksumSha256: checksum, Channels: 1, SampleRateHz: 16000, DurationMs: 1000} + requestMeta := &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "request-oss-integration", TraceId: "trace-oss-integration", OperationId: "operation-oss-integration", IdempotencyKey: "idempotency-oss-integration", AgentId: "agent-integration", CellId: "cell-integration"} st, err := store.Open(filepath.Join(t.TempDir(), "dispatcher.db")) if err != nil { t.Fatal(err) @@ -71,23 +71,23 @@ func TestAlibabaOSSDispatcherUploadDurableIntegration(t *testing.T) { t.Fatal(err) } uploadID := "upload-oss-integration" - grantResponse, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID}) + grantResponse, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID}) if err != nil { t.Fatal(err) } - if grantResponse.Receipt.Result != agentv1.ResultCode_RESULT_CODE_ACCEPTED || grantResponse.Grant == nil { + if grantResponse.Receipt.Result != agentpb.ResultCode_RESULT_CODE_ACCEPTED || grantResponse.Grant == nil { t.Fatalf("grant rejected: %+v", grantResponse.Receipt) } clock = clock.Add(16 * time.Minute) - requestMeta = proto.Clone(requestMeta).(*agentv1.RequestMeta) + requestMeta = proto.Clone(requestMeta).(*agentpb.RequestMeta) requestMeta.OperationId = "renew-upload-" + uploadID requestMeta.IdempotencyKey = "renew-upload-key-" + uploadID - retryMeta := proto.Clone(requestMeta).(*agentv1.RequestMeta) + retryMeta := proto.Clone(requestMeta).(*agentpb.RequestMeta) retryMeta.RequestId = "request-oss-integration-retry" retryMeta.TraceId = "trace-oss-integration-retry" retryMeta.OperationId = "operation-oss-integration-retry" retryMeta.IdempotencyKey = "idempotency-oss-integration-retry" - reissuedResponse, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: retryMeta, Binding: binding, Asset: asset, UploadId: uploadID}) + reissuedResponse, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: retryMeta, Binding: binding, Asset: asset, UploadId: uploadID}) if err != nil { t.Fatal(err) } @@ -104,7 +104,7 @@ func TestAlibabaOSSDispatcherUploadDurableIntegration(t *testing.T) { if err != nil { t.Fatal(err) } - completion := &agentv1.CompleteUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID, UploadedSizeBytes: result.SizeBytes, UploadedChecksumSha256: result.SHA256} + completion := &agentpb.CompleteUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID, UploadedSizeBytes: result.SizeBytes, UploadedChecksumSha256: result.SHA256} for i := 0; i < 2; i++ { if _, err := server.CompleteUpload(context.Background(), completion); status.Code(err) != codes.Unavailable { t.Fatalf("notification without MQ publication must remain pending: %v", err) @@ -117,7 +117,7 @@ func TestAlibabaOSSDispatcherUploadDurableIntegration(t *testing.T) { if outboxCount != 1 { t.Fatalf("upload notification rows = %d, want 1", outboxCount) } - if _, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID}); status.Code(err) != codes.Unavailable { + if _, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: requestMeta, Binding: binding, Asset: asset, UploadId: uploadID}); status.Code(err) != codes.Unavailable { t.Fatal("uploaded object was reauthorized") } // This opt-in test establishes the upload fact only. Queue-delivery evidence diff --git a/internal/rpc/dispatcher_upload_local_v3_test.go b/internal/rpc/dispatcher_upload_local_v3_test.go index 38ca1a2..e98d1d5 100644 --- a/internal/rpc/dispatcher_upload_local_v3_test.go +++ b/internal/rpc/dispatcher_upload_local_v3_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/grpc/codes" @@ -34,7 +34,7 @@ func TestLocalV3UploadCompletionDoesNotWriteSplitNotification(t *testing.T) { now := time.Date(2026, 9, 21, 2, 0, 0, 0, time.UTC) calls, delivered, inactive := 0, false, false server, err := NewDispatcherUploadServerWithOptions(st, client, func() time.Time { return now }, DispatcherUploadOptions{ - LocalV3Authorize: func(_ context.Context, request *agentv1.RequestUploadRequest) error { + LocalV3Authorize: func(_ context.Context, request *agentpb.RequestUploadRequest) error { if inactive { return errors.New("inactive Mock Agent session") } @@ -43,7 +43,7 @@ func TestLocalV3UploadCompletionDoesNotWriteSplitNotification(t *testing.T) { } return nil }, - LocalV3Complete: func(_ context.Context, request *agentv1.CompleteUploadRequest, record store.UploadRecord) (bool, error) { + LocalV3Complete: func(_ context.Context, request *agentpb.CompleteUploadRequest, record store.UploadRecord) (bool, error) { calls++ if request.UploadId != record.UploadID { t.Fatalf("upload identity changed: %q != %q", request.UploadId, record.UploadID) @@ -59,20 +59,20 @@ func TestLocalV3UploadCompletionDoesNotWriteSplitNotification(t *testing.T) { if err != nil { t.Fatal(err) } - meta := &agentv1.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} - if _, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "forged"}); status.Code(err) != codes.FailedPrecondition { + meta := &agentpb.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} + if _, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "forged"}); status.Code(err) != codes.FailedPrecondition { t.Fatalf("unbound Mock recording received a PUT grant: %v", err) } var issued int if err := st.DB().QueryRow(`SELECT COUNT(*) FROM uploads`).Scan(&issued); err != nil || issued != 0 { t.Fatalf("refused recording persisted a grant: count=%d err=%v", issued, err) } - if grant, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}); err != nil || grant.GetGrant() == nil { + if grant, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}); err != nil || grant.GetGrant() == nil { t.Fatalf("first grant: %+v err=%v", grant, err) } - request := &agentv1.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} + request := &agentpb.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} if _, err := server.CompleteUpload(context.Background(), request); status.Code(err) != codes.Unavailable { t.Fatalf("unpublished final call.result cannot complete upload: %v", err) } @@ -88,15 +88,15 @@ func TestLocalV3UploadCompletionDoesNotWriteSplitNotification(t *testing.T) { } delivered = true completed, err := server.CompleteUpload(context.Background(), request) - if err != nil || completed.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED || calls != 2 { + if err != nil || completed.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED || calls != 2 { t.Fatalf("confirmed final-result delivery: response=%+v calls=%d err=%v", completed, calls, err) } - grant, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) - if err != nil || grant.GetGrant() != nil || grant.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED { + grant, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) + if err != nil || grant.GetGrant() != nil || grant.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED { t.Fatalf("completed upload reauthorized a PUT: grant=%+v err=%v", grant, err) } inactive = true - if _, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}); status.Code(err) != codes.FailedPrecondition { + if _, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}); status.Code(err) != codes.FailedPrecondition { t.Fatalf("inactive session read a completed Mock upload without authorization: %v", err) } } diff --git a/internal/rpc/dispatcher_upload_notification_test.go b/internal/rpc/dispatcher_upload_notification_test.go index 23f4e7c..3c401e7 100644 --- a/internal/rpc/dispatcher_upload_notification_test.go +++ b/internal/rpc/dispatcher_upload_notification_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/grpc/codes" @@ -32,16 +32,16 @@ func TestUploadFactWaitsOnlyForMQPublication(t *testing.T) { if err != nil { t.Fatal(err) } - meta := &agentv1.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} - grant, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) + meta := &agentpb.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} + grant, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) if err != nil || grant.GetGrant() == nil { t.Fatalf("grant: %v", err) } // A delayed notification is not a request for a fresh PUT token. now = now.Add(20 * time.Minute) - request := &agentv1.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} + request := &agentpb.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} for i := 0; i < 2; i++ { _, err := server.CompleteUpload(context.Background(), request) if status.Code(err) != codes.Unavailable { @@ -60,11 +60,11 @@ func TestUploadFactWaitsOnlyForMQPublication(t *testing.T) { t.Fatal(err) } completed, err := server.CompleteUpload(context.Background(), request) - if err != nil || completed.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED { + if err != nil || completed.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED { t.Fatalf("completion: %v %v", completed, err) } - again, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) - if err != nil || again.GetGrant() != nil || again.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED { + again, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) + if err != nil || again.GetGrant() != nil || again.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED { t.Fatal("completed upload was reauthorized") } } diff --git a/internal/rpc/execution_journal.go b/internal/rpc/execution_journal.go index 5f0c3fc..fe554ac 100644 --- a/internal/rpc/execution_journal.go +++ b/internal/rpc/execution_journal.go @@ -9,7 +9,7 @@ import ( "os" "path/filepath" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" @@ -17,17 +17,17 @@ import ( type savedOperation struct { Digest string `json:"digest"` - Receipt *agentv1.OperationReceipt `json:"receipt"` - Control *agentv1.ApplyTaskControlResponse `json:"control,omitempty"` + Receipt *agentpb.OperationReceipt `json:"receipt"` + Control *agentpb.ApplyTaskControlResponse `json:"control,omitempty"` } type savedExecution struct { - Binding *agentv1.ExecutionBinding `json:"binding"` + Binding *agentpb.ExecutionBinding `json:"binding"` Digest string `json:"digest"` - State agentv1.ExecutionState `json:"state"` + State agentpb.ExecutionState `json:"state"` Revision int64 `json:"revision"` CallState string `json:"call_state"` TerminalObservedAtUnixMs int64 `json:"terminal_observed_at_unix_ms,omitempty"` - ControlAction agentv1.ControlAction `json:"control_action"` + ControlAction agentpb.ControlAction `json:"control_action"` } type executionJournal struct { Version int `json:"version"` @@ -81,14 +81,14 @@ func (s *Server) loadExecutionJournal() error { if record.Binding == nil || record.Binding.ExecutionId != id || record.Revision != record.Binding.TaskRevision { return errors.New("invalid persisted execution binding") } - if _, ok := agentv1.ExecutionState_name[int32(record.State)]; !ok { + if _, ok := agentpb.ExecutionState_name[int32(record.State)]; !ok { return errors.New("invalid persisted execution state") } - if _, ok := agentv1.ControlAction_name[int32(record.ControlAction)]; !ok { + if _, ok := agentpb.ControlAction_name[int32(record.ControlAction)]; !ok { return errors.New("invalid persisted control action") } mockTerminal := record.CallState == "mock_no_answer" || record.CallState == "mock_deadline_closed_without_dial" - if mockTerminal && (record.TerminalObservedAtUnixMs <= 0 || record.State != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL) || + if mockTerminal && (record.TerminalObservedAtUnixMs <= 0 || record.State != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL) || !mockTerminal && record.TerminalObservedAtUnixMs != 0 { return errors.New("invalid durable Mock terminal observation") } @@ -96,8 +96,8 @@ func (s *Server) loadExecutionJournal() error { terminalObservedAtUnixMs: record.TerminalObservedAtUnixMs, controlAction: record.ControlAction, state: record.State} // A new process cannot infer Asterisk's state from an old local snapshot. // Never restore permits or clear unknown occupancy because a process restarted. - if execution.state != agentv1.ExecutionState_EXECUTION_STATE_TERMINAL { - execution.state = agentv1.ExecutionState_EXECUTION_STATE_UNKNOWN + if execution.state != agentpb.ExecutionState_EXECUTION_STATE_TERMINAL { + execution.state = agentpb.ExecutionState_EXECUTION_STATE_UNKNOWN execution.unknown = true } s.executions[id] = execution diff --git a/internal/rpc/execution_journal_failure_test.go b/internal/rpc/execution_journal_failure_test.go index 43f3027..7546ffc 100644 --- a/internal/rpc/execution_journal_failure_test.go +++ b/internal/rpc/execution_journal_failure_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" ) @@ -21,7 +21,7 @@ func TestExecutionJournalFailureCannotReplayMemoryAsSuccess(t *testing.T) { require.NoError(t, err) envelope, payload, err := contract.DecodeExecute(raw) require.NoError(t, err) - req := &agentv1.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw} + req := &agentpb.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw} response, err := s.Execute(context.Background(), req) if err == nil || response != nil { t.Fatal("failed write acknowledged") @@ -35,7 +35,7 @@ func TestExecutionJournalFailureCannotReplayMemoryAsSuccess(t *testing.T) { func TestMissingExecutionJournalWithExistingSessionFailsClosed(t *testing.T) { path := filepath.Join(t.TempDir(), "session.json") require.NoError(t, os.WriteFile(path, []byte(`{"generations":{"agent-1":1}}`), 0600)) - s := NewServer(ServerOptions{StatePath: path, Status: &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"}}) + s := NewServer(ServerOptions{StatePath: path, Status: &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"}}) if s.executionJournalReady() == nil { t.Fatal("missing execution history silently reset") } diff --git a/internal/rpc/execution_journal_mode_test.go b/internal/rpc/execution_journal_mode_test.go index 2013b65..13cd5d9 100644 --- a/internal/rpc/execution_journal_mode_test.go +++ b/internal/rpc/execution_journal_mode_test.go @@ -4,14 +4,14 @@ import ( "path/filepath" "testing" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func TestExecutionJournalCannotCrossAdapterModes(t *testing.T) { for _, mode := range []string{"mixed", "real"} { t.Run(mode, func(t *testing.T) { path := filepath.Join(t.TempDir(), "session.json") - status := &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"} + status := &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"} original := NewServer(ServerOptions{Mode: "mock", StatePath: path, Status: status}) require.NoError(t, original.executionJournalReady()) recovered := NewServer(ServerOptions{Mode: mode, StatePath: path, Status: status}) diff --git a/internal/rpc/execution_journal_test.go b/internal/rpc/execution_journal_test.go index 6e8f3ca..8467968 100644 --- a/internal/rpc/execution_journal_test.go +++ b/internal/rpc/execution_journal_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" "google.golang.org/protobuf/proto" @@ -21,10 +21,10 @@ func TestControlReceiptSurvivesRestartAndNewSession(t *testing.T) { if generation > 1 { bootID = "boot-2" } - s := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, StatePath: path, Status: &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: bootID}}) + s := NewServer(ServerOptions{Mode: "mock", Now: func() time.Time { return now }, StatePath: path, Status: &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: bootID}}) activationMeta := testMeta("activate", "", 0) activationMeta.BootId = bootID - _, err := s.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{Meta: activationMeta, Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: bootID, DispatcherEpoch: "epoch-1", SessionGeneration: generation}, ActivationOperationId: "activate"}) + _, err := s.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{Meta: activationMeta, Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: bootID, DispatcherEpoch: "epoch-1", SessionGeneration: generation}, ActivationOperationId: "activate"}) require.NoError(t, err) return s } @@ -33,17 +33,17 @@ func TestControlReceiptSurvivesRestartAndNewSession(t *testing.T) { require.NoError(t, err) envelope, payload, err := contract.DecodeExecute(raw) require.NoError(t, err) - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} - _, err = s.Execute(context.Background(), &agentv1.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: binding, CallExecuteJson: raw}) + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} + _, err = s.Execute(context.Background(), &agentpb.ExecuteRequest{Meta: testMeta("execute", "execute-key", 1), Binding: binding, CallExecuteJson: raw}) require.NoError(t, err) - request := &agentv1.ApplyTaskControlRequest{Meta: testMeta("pause", "pause-key", 1), Binding: binding, Action: agentv1.ControlAction_CONTROL_ACTION_PAUSE, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: binding.TaskRevision} + request := &agentpb.ApplyTaskControlRequest{Meta: testMeta("pause", "pause-key", 1), Binding: binding, Action: agentpb.ControlAction_CONTROL_ACTION_PAUSE, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: binding.TaskRevision} applied, err := s.ApplyTaskControl(context.Background(), request) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_APPLIED, applied.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_APPLIED, applied.Receipt.Result) recovered := start(2) request.Meta.SessionGeneration = 2 request.Meta.BootId = "boot-2" - freshMeta := func(operation, key string) *agentv1.RequestMeta { + freshMeta := func(operation, key string) *agentpb.RequestMeta { meta := testMeta(operation, key, 2) meta.BootId = "boot-2" return meta @@ -53,14 +53,14 @@ func TestControlReceiptSurvivesRestartAndNewSession(t *testing.T) { if !proto.Equal(applied, replayed) { t.Fatal("lost original control receipt after restart") } - snapshot, err := recovered.QueryExecution(context.Background(), &agentv1.QueryExecutionRequest{Meta: freshMeta("query", "query-key"), Binding: binding}) + snapshot, err := recovered.QueryExecution(context.Background(), &agentpb.QueryExecutionRequest{Meta: freshMeta("query", "query-key"), Binding: binding}) require.NoError(t, err) if snapshot.Snapshot == nil || !snapshot.Snapshot.Unknown || snapshot.Snapshot.Binding.TaskRevision != applied.AppliedTaskRevision { t.Fatal("recovered active work must remain unknown with applied control revision") } - retry, err := recovered.Execute(context.Background(), &agentv1.ExecuteRequest{Meta: freshMeta("new-execute", "new-key"), Binding: binding, CallExecuteJson: raw}) + retry, err := recovered.Execute(context.Background(), &agentpb.ExecuteRequest{Meta: freshMeta("new-execute", "new-key"), Binding: binding, CallExecuteJson: raw}) require.NoError(t, err) - if retry.Receipt.Result == agentv1.ResultCode_RESULT_CODE_ACCEPTED { + if retry.Receipt.Result == agentpb.ResultCode_RESULT_CODE_ACCEPTED { t.Fatal("restarted execution was prepared again") } } @@ -68,7 +68,7 @@ func TestControlReceiptSurvivesRestartAndNewSession(t *testing.T) { func TestCorruptExecutionJournalPreventsActivation(t *testing.T) { path := filepath.Join(t.TempDir(), "session.json") require.NoError(t, os.WriteFile(path+".executions", []byte(`{"version":999}`), 0600)) - s := NewServer(ServerOptions{Mode: "mock", StatePath: path, Status: &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"}}) - _, err := s.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{Meta: testMeta("activate", "", 0), Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate"}) + s := NewServer(ServerOptions{Mode: "mock", StatePath: path, Status: &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1"}}) + _, err := s.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{Meta: testMeta("activate", "", 0), Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate"}) require.Error(t, err) } diff --git a/internal/rpc/server.go b/internal/rpc/server.go index 3de1309..6317ce9 100644 --- a/internal/rpc/server.go +++ b/internal/rpc/server.go @@ -12,7 +12,7 @@ import ( "sync" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/ai" "git.ipao.vip/rogee/go-sip/internal/calllog" "git.ipao.vip/rogee/go-sip/internal/callwindow" @@ -30,9 +30,9 @@ import ( // grpc.Server via TLS credentials; no certificate or secret is stored here. type ServerOptions struct { Mode string - Status *agentv1.AgentStatus - UploadPolicy *agentv1.UploadPolicy - ConfigReferences []*agentv1.ConfigReference + Status *agentpb.AgentStatus + UploadPolicy *agentpb.UploadPolicy + ConfigReferences []*agentpb.ConfigReference StaticArtifactRaw []byte StaticArtifactExpected contract.StaticArtifactExpectation AISnapshotRaw []byte @@ -45,20 +45,20 @@ type ServerOptions struct { CallLogger *calllog.Logger // MockAuthorizedOriginate is explicitly supplied only in isolated mock mode. // Real/mixed dialing is not authorized through the new local contract. - MockAuthorizedOriginate func(context.Context, *agentv1.ExecuteAuthorizedRequest) error + MockAuthorizedOriginate func(context.Context, *agentpb.ExecuteAuthorizedRequest) error } // Server is the local Unary gRPC state boundary. It owns session/fencing and // durable-operation semantics for the RPC layer; Dispatcher SQLite remains the // business source of truth for quotas and task state. type Server struct { - agentv1.UnimplementedAgentControlServiceServer + agentpb.UnimplementedAgentControlServiceServer mode string now func() time.Time - status *agentv1.AgentStatus - uploadPolicy *agentv1.UploadPolicy - configReferences []*agentv1.ConfigReference + status *agentpb.AgentStatus + uploadPolicy *agentpb.UploadPolicy + configReferences []*agentpb.ConfigReference staticArtifact contract.StaticCellArtifact staticArtifactEnabled bool staticArtifactError error @@ -69,7 +69,7 @@ type Server struct { peerAgentIDs map[string]string peerCertificateFingerprints map[string]struct{} callLogger *calllog.Logger - mockAuthorizedOriginate func(context.Context, *agentv1.ExecuteAuthorizedRequest) error + mockAuthorizedOriginate func(context.Context, *agentpb.ExecuteAuthorizedRequest) error sessions *SessionRegistry executionPath string @@ -84,33 +84,33 @@ type Server struct { type operationRecord struct { digest string - receipt *agentv1.OperationReceipt - control *agentv1.ApplyTaskControlResponse + receipt *agentpb.OperationReceipt + control *agentpb.ApplyTaskControlResponse } type admissionRecord struct { - state agentv1.AdmissionState + state agentpb.AdmissionState generation uint64 } type executionRecord struct { executeDigest string - binding *agentv1.ExecutionBinding - state agentv1.ExecutionState + binding *agentpb.ExecutionBinding + state agentpb.ExecutionState taskRevision int64 callState string terminalObservedAtUnixMs int64 - controlAction agentv1.ControlAction - permit *agentv1.ExecutionPermit + controlAction agentpb.ControlAction + permit *agentpb.ExecutionPermit unknown bool phone calllog.Identity } type uploadRecord struct { - binding *agentv1.ExecutionBinding - asset *agentv1.AssetDescriptor - state agentv1.UploadState - grant *agentv1.UploadGrant + binding *agentpb.ExecutionBinding + asset *agentpb.AssetDescriptor + state agentpb.UploadState + grant *agentpb.UploadGrant completed bool } @@ -124,16 +124,16 @@ func NewServer(options ServerOptions) *Server { if now == nil { now = time.Now } - statusValue := &agentv1.AgentStatus{} + statusValue := &agentpb.AgentStatus{} if options.Status != nil { - statusValue = proto.Clone(options.Status).(*agentv1.AgentStatus) + statusValue = proto.Clone(options.Status).(*agentpb.AgentStatus) } - if statusValue.AdmissionState == agentv1.AdmissionState_ADMISSION_STATE_UNSPECIFIED { - statusValue.AdmissionState = agentv1.AdmissionState_ADMISSION_STATE_CLOSED + if statusValue.AdmissionState == agentpb.AdmissionState_ADMISSION_STATE_UNSPECIFIED { + statusValue.AdmissionState = agentpb.AdmissionState_ADMISSION_STATE_CLOSED } - uploadPolicy := &agentv1.UploadPolicy{} + uploadPolicy := &agentpb.UploadPolicy{} if options.UploadPolicy != nil { - uploadPolicy = proto.Clone(options.UploadPolicy).(*agentv1.UploadPolicy) + uploadPolicy = proto.Clone(options.UploadPolicy).(*agentpb.UploadPolicy) } var staticArtifact contract.StaticCellArtifact var staticArtifactError error @@ -182,7 +182,7 @@ func NewServer(options ServerOptions) *Server { return server } -func (s *Server) validateAIExecution(binding *agentv1.ExecutionBinding, configSHA256 string) error { +func (s *Server) validateAIExecution(binding *agentpb.ExecutionBinding, configSHA256 string) error { if s.aiConfigError == nil && len(s.aiAuthorizationRaw) == 0 { return nil } @@ -216,10 +216,10 @@ type SessionRegistry struct { } type sessionRecord struct { - binding *agentv1.AgentBinding + binding *agentpb.AgentBinding activationOperationID string digest string - session *agentv1.Session + session *agentpb.Session } func NewSessionRegistry(statePath string) *SessionRegistry { @@ -261,7 +261,7 @@ func (r *SessionRegistry) persistLocked() error { return writeRPCJournal(r.statePath, sessionJournal{Generations: r.generations}) } -func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOperationID, digest string, now time.Time) (*agentv1.Session, bool, error) { +func (r *SessionRegistry) Activate(binding *agentpb.AgentBinding, activationOperationID, digest string, now time.Time) (*agentpb.Session, bool, error) { if binding == nil || binding.AgentId == "" || binding.CellId == "" || binding.DispatcherEpoch == "" || activationOperationID == "" { return nil, false, status.Error(codes.InvalidArgument, "agent, cell, epoch and activation operation are required") } @@ -275,7 +275,7 @@ func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOper return cloneSession(existing.session), true, nil } if binding.SessionGeneration == 0 { - binding = proto.Clone(binding).(*agentv1.AgentBinding) + binding = proto.Clone(binding).(*agentpb.AgentBinding) binding.SessionGeneration = existing.binding.SessionGeneration + 1 } if binding.SessionGeneration <= existing.binding.SessionGeneration { @@ -283,7 +283,7 @@ func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOper } } if binding.SessionGeneration == 0 { - binding = proto.Clone(binding).(*agentv1.AgentBinding) + binding = proto.Clone(binding).(*agentpb.AgentBinding) binding.SessionGeneration = 1 } if previous, ok := r.generations[binding.AgentId]; ok && binding.SessionGeneration <= previous { @@ -293,7 +293,7 @@ func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOper if _, err := cryptorand.Read(credential); err != nil { return nil, false, status.Errorf(codes.Internal, "create session credential: %v", err) } - session := &agentv1.Session{ + session := &agentpb.Session{ DispatcherEpoch: binding.DispatcherEpoch, SessionGeneration: binding.SessionGeneration, ExpiresAtUnixMs: now.Add(10 * time.Minute).UnixMilli(), @@ -301,7 +301,7 @@ func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOper } previous, hadPrevious := r.sessions[binding.AgentId] r.sessions[binding.AgentId] = sessionRecord{ - binding: proto.Clone(binding).(*agentv1.AgentBinding), + binding: proto.Clone(binding).(*agentpb.AgentBinding), activationOperationID: activationOperationID, digest: digest, session: cloneSession(session), @@ -318,7 +318,7 @@ func (r *SessionRegistry) Activate(binding *agentv1.AgentBinding, activationOper return session, false, nil } -func (r *SessionRegistry) Authorize(meta *agentv1.RequestMeta, now time.Time) error { +func (r *SessionRegistry) Authorize(meta *agentpb.RequestMeta, now time.Time) error { if meta == nil || meta.AgentId == "" || meta.CellId == "" || meta.BootId == "" || meta.DispatcherEpoch == "" || meta.SessionGeneration == 0 { return status.Error(codes.InvalidArgument, "complete session metadata is required") } @@ -340,7 +340,7 @@ func (r *SessionRegistry) Authorize(meta *agentv1.RequestMeta, now time.Time) er // CurrentMeta returns only the active, unexpired session identity. It does // not expose the session credential; callers use it for Agent→Dispatcher // reports and never invent a new boot identity after restart. -func (r *SessionRegistry) CurrentMeta(agentID string, now time.Time) (*agentv1.RequestMeta, error) { +func (r *SessionRegistry) CurrentMeta(agentID string, now time.Time) (*agentpb.RequestMeta, error) { if agentID == "" { return nil, status.Error(codes.InvalidArgument, "Agent ID is required") } @@ -353,21 +353,21 @@ func (r *SessionRegistry) CurrentMeta(agentID string, now time.Time) (*agentv1.R if !ok || existing.session.ExpiresAtUnixMs <= now.UnixMilli() { return nil, status.Error(codes.Unauthenticated, "Agent session is not active") } - return &agentv1.RequestMeta{ + return &agentpb.RequestMeta{ ProtocolVersion: "agent.v1", AgentId: agentID, CellId: existing.binding.CellId, BootId: existing.binding.ExpectedBootId, DispatcherEpoch: existing.binding.DispatcherEpoch, SessionGeneration: existing.binding.SessionGeneration, }, nil } -func (s *Server) ActiveSessionMeta() (*agentv1.RequestMeta, error) { +func (s *Server) ActiveSessionMeta() (*agentpb.RequestMeta, error) { if s.status == nil { return nil, status.Error(codes.FailedPrecondition, "Agent status is unavailable") } return s.sessions.CurrentMeta(s.status.AgentId, s.now()) } -func (s *Server) GetAgentStatus(ctx context.Context, req *agentv1.GetAgentStatusRequest) (*agentv1.GetAgentStatusResponse, error) { +func (s *Server) GetAgentStatus(ctx context.Context, req *agentpb.GetAgentStatusRequest) (*agentpb.GetAgentStatusResponse, error) { if req == nil || req.Meta == nil || req.Meta.AgentId == "" || req.Meta.CellId == "" { return nil, status.Error(codes.InvalidArgument, "status metadata with agent and cell is required") } @@ -393,13 +393,13 @@ func (s *Server) GetAgentStatus(ctx context.Context, req *agentv1.GetAgentStatus } else if err := s.sessions.Authorize(req.Meta, s.now()); err != nil { return nil, err } - result := proto.Clone(s.status).(*agentv1.AgentStatus) + result := proto.Clone(s.status).(*agentpb.AgentStatus) result.SessionActive = !preActivation result.MtlsAuthenticated = s.peerIsAuthenticated(ctx) - return &agentv1.GetAgentStatusResponse{Meta: s.responseMeta(req.Meta), Status: result}, nil + return &agentpb.GetAgentStatusResponse{Meta: s.responseMeta(req.Meta), Status: result}, nil } -func (s *Server) ActivateAgent(ctx context.Context, req *agentv1.ActivateAgentRequest) (*agentv1.ActivateAgentResponse, error) { +func (s *Server) ActivateAgent(ctx context.Context, req *agentpb.ActivateAgentRequest) (*agentpb.ActivateAgentResponse, error) { if err := s.executionJournalReady(); err != nil { return nil, err } @@ -423,7 +423,7 @@ func (s *Server) ActivateAgent(ctx context.Context, req *agentv1.ActivateAgentRe return nil, status.Error(codes.FailedPrecondition, "activation Cell does not match static artifact") } } - binding := proto.Clone(req.Binding).(*agentv1.AgentBinding) + binding := proto.Clone(req.Binding).(*agentpb.AgentBinding) if binding.ExpectedBootId == "" { binding.ExpectedBootId = req.Meta.BootId } @@ -438,14 +438,14 @@ func (s *Server) ActivateAgent(ctx context.Context, req *agentv1.ActivateAgentRe if err != nil { return nil, err } - state := agentv1.ActivationState_ACTIVATION_STATE_ACTIVE + state := agentpb.ActivationState_ACTIVATION_STATE_ACTIVE if replay { - state = agentv1.ActivationState_ACTIVATION_STATE_ACTIVE + state = agentpb.ActivationState_ACTIVATION_STATE_ACTIVE } - return &agentv1.ActivateAgentResponse{Meta: s.responseMeta(req.Meta), State: state, Session: session}, nil + return &agentpb.ActivateAgentResponse{Meta: s.responseMeta(req.Meta), State: state, Session: session}, nil } -func (s *Server) GetBootstrap(ctx context.Context, req *agentv1.GetBootstrapRequest) (*agentv1.GetBootstrapResponse, error) { +func (s *Server) GetBootstrap(ctx context.Context, req *agentpb.GetBootstrapRequest) (*agentpb.GetBootstrapResponse, error) { if req == nil || req.Meta == nil { return nil, status.Error(codes.InvalidArgument, "request metadata is required") } @@ -455,15 +455,15 @@ func (s *Server) GetBootstrap(ctx context.Context, req *agentv1.GetBootstrapRequ if err := s.sessions.Authorize(req.Meta, s.now()); err != nil { return nil, err } - return &agentv1.GetBootstrapResponse{ + return &agentpb.GetBootstrapResponse{ Meta: s.responseMeta(req.Meta), - State: agentv1.ActivationState_ACTIVATION_STATE_ACTIVE, + State: agentpb.ActivationState_ACTIVATION_STATE_ACTIVE, RuntimeConfigs: cloneConfigReferences(s.configReferences), - UploadPolicy: proto.Clone(s.uploadPolicy).(*agentv1.UploadPolicy), + UploadPolicy: proto.Clone(s.uploadPolicy).(*agentpb.UploadPolicy), }, nil } -func (s *Server) SetAdmissionState(ctx context.Context, req *agentv1.SetAdmissionStateRequest) (*agentv1.SetAdmissionStateResponse, error) { +func (s *Server) SetAdmissionState(ctx context.Context, req *agentpb.SetAdmissionStateRequest) (*agentpb.SetAdmissionStateResponse, error) { if req == nil || req.Meta == nil || req.Target == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and target are required") } @@ -473,7 +473,7 @@ func (s *Server) SetAdmissionState(ctx context.Context, req *agentv1.SetAdmissio if err := requireIdempotency(req.Meta); err != nil { return nil, err } - if req.State == agentv1.AdmissionState_ADMISSION_STATE_UNSPECIFIED { + if req.State == agentpb.AdmissionState_ADMISSION_STATE_UNSPECIFIED { return nil, status.Error(codes.InvalidArgument, "admission state is required") } key := req.Target.AgentId @@ -481,15 +481,15 @@ func (s *Server) SetAdmissionState(ctx context.Context, req *agentv1.SetAdmissio defer s.mu.Unlock() current := s.admissions[key] if current.generation != req.ExpectedAdmissionGeneration { - return &agentv1.SetAdmissionStateResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "admission generation conflict", false)}, nil + return &agentpb.SetAdmissionStateResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "admission generation conflict", false)}, nil } current.generation++ current.state = req.State s.admissions[key] = current - return &agentv1.SetAdmissionStateResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_APPLIED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), AppliedAdmissionGeneration: current.generation}, nil + return &agentpb.SetAdmissionStateResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_APPLIED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), AppliedAdmissionGeneration: current.generation}, nil } -func (s *Server) Execute(ctx context.Context, req *agentv1.ExecuteRequest) (*agentv1.ExecuteResponse, error) { +func (s *Server) Execute(ctx context.Context, req *agentpb.ExecuteRequest) (*agentpb.ExecuteResponse, error) { if req == nil || req.Meta == nil || req.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and execution binding are required") } @@ -522,9 +522,9 @@ func (s *Server) Execute(ctx context.Context, req *agentv1.ExecuteRequest) (*age digest := messageDigest(req) if receipt, conflict := s.replayOperation(req.Meta, digest); receipt != nil || conflict != nil { if conflict != nil { - return &agentv1.ExecuteResponse{Receipt: conflict}, nil + return &agentpb.ExecuteResponse{Receipt: conflict}, nil } - return &agentv1.ExecuteResponse{Receipt: receipt, State: agentv1.ExecutionState_EXECUTION_STATE_PREPARED}, nil + return &agentpb.ExecuteResponse{Receipt: receipt, State: agentpb.ExecutionState_EXECUTION_STATE_PREPARED}, nil } if s.mode != "mock" { if err := callwindow.Check(s.now()); err != nil { @@ -540,20 +540,20 @@ func (s *Server) Execute(ctx context.Context, req *agentv1.ExecuteRequest) (*age // have passed the earlier read-only replay check together. if previous, ok := s.operations[s.operationKey(req.Meta)]; ok { if previous.digest != digest { - return &agentv1.ExecuteResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil + return &agentpb.ExecuteResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil } - return &agentv1.ExecuteResponse{Receipt: proto.Clone(previous.receipt).(*agentv1.OperationReceipt), State: agentv1.ExecutionState_EXECUTION_STATE_PREPARED}, nil + return &agentpb.ExecuteResponse{Receipt: proto.Clone(previous.receipt).(*agentpb.OperationReceipt), State: agentpb.ExecutionState_EXECUTION_STATE_PREPARED}, nil } - var priorPermit *agentv1.ExecutionPermit + var priorPermit *agentpb.ExecutionPermit if previous := s.executions[req.Binding.ExecutionId]; previous != nil { if previous.unknown { - return &agentv1.ExecuteResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_UNKNOWN, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution requires reconciliation", false), State: agentv1.ExecutionState_EXECUTION_STATE_UNKNOWN}, nil + return &agentpb.ExecuteResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_UNKNOWN, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution requires reconciliation", false), State: agentpb.ExecutionState_EXECUTION_STATE_UNKNOWN}, nil } - if previous.controlAction == agentv1.ControlAction_CONTROL_ACTION_PAUSE || previous.controlAction == agentv1.ControlAction_CONTROL_ACTION_STOP || previous.state == agentv1.ExecutionState_EXECUTION_STATE_TERMINAL { - return &agentv1.ExecuteResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution control blocks preparation", false)}, nil + if previous.controlAction == agentpb.ControlAction_CONTROL_ACTION_PAUSE || previous.controlAction == agentpb.ControlAction_CONTROL_ACTION_STOP || previous.state == agentpb.ExecutionState_EXECUTION_STATE_TERMINAL { + return &agentpb.ExecuteResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution control blocks preparation", false)}, nil } if previous.executeDigest != "" { - return &agentv1.ExecuteResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "execution already prepared under another operation", false)}, nil + return &agentpb.ExecuteResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "execution already prepared under another operation", false)}, nil } priorPermit = previous.permit } @@ -568,20 +568,20 @@ func (s *Server) Execute(ctx context.Context, req *agentv1.ExecuteRequest) (*age return nil, status.Errorf(codes.Internal, "write call business log: %v", err) } } - state := agentv1.ExecutionState_EXECUTION_STATE_PREPARED + state := agentpb.ExecutionState_EXECUTION_STATE_PREPARED if req.PermitId != "" { - state = agentv1.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED + state = agentpb.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED } - s.executions[req.Binding.ExecutionId] = &executionRecord{executeDigest: digest, binding: proto.Clone(req.Binding).(*agentv1.ExecutionBinding), state: state, taskRevision: req.Binding.TaskRevision, callState: "prepared", phone: phoneIdentity, permit: priorPermit} - receipt := s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false) - s.operations[s.operationKey(req.Meta)] = operationRecord{digest: digest, receipt: proto.Clone(receipt).(*agentv1.OperationReceipt)} + s.executions[req.Binding.ExecutionId] = &executionRecord{executeDigest: digest, binding: proto.Clone(req.Binding).(*agentpb.ExecutionBinding), state: state, taskRevision: req.Binding.TaskRevision, callState: "prepared", phone: phoneIdentity, permit: priorPermit} + receipt := s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false) + s.operations[s.operationKey(req.Meta)] = operationRecord{digest: digest, receipt: proto.Clone(receipt).(*agentpb.OperationReceipt)} if err := s.persistExecutionJournalLocked(); err != nil { return nil, err } - return &agentv1.ExecuteResponse{Receipt: receipt, State: state}, nil + return &agentpb.ExecuteResponse{Receipt: receipt, State: state}, nil } -func (s *Server) GetExecutionPermit(ctx context.Context, req *agentv1.GetExecutionPermitRequest) (*agentv1.GetExecutionPermitResponse, error) { +func (s *Server) GetExecutionPermit(ctx context.Context, req *agentpb.GetExecutionPermitRequest) (*agentpb.GetExecutionPermitResponse, error) { if req == nil || req.Meta == nil || req.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and execution binding are required") } @@ -611,40 +611,40 @@ func (s *Server) GetExecutionPermit(ctx context.Context, req *agentv1.GetExecuti execution := s.executions[req.Binding.ExecutionId] // Control and permission decisions share one lock: neither a fresh grant // nor a replayed grant may cross an already-applied pause/stop barrier. - if execution != nil && (execution.unknown || execution.controlAction == agentv1.ControlAction_CONTROL_ACTION_PAUSE || execution.controlAction == agentv1.ControlAction_CONTROL_ACTION_STOP || execution.state == agentv1.ExecutionState_EXECUTION_STATE_TERMINAL) { - return &agentv1.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution control blocks permission", false)}, nil + if execution != nil && (execution.unknown || execution.controlAction == agentpb.ControlAction_CONTROL_ACTION_PAUSE || execution.controlAction == agentpb.ControlAction_CONTROL_ACTION_STOP || execution.state == agentpb.ExecutionState_EXECUTION_STATE_TERMINAL) { + return &agentpb.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "execution control blocks permission", false)}, nil } if previous, ok := s.operations[s.operationKey(req.Meta)]; ok { if previous.digest != digest { - return &agentv1.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil + return &agentpb.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil } - var permit *agentv1.ExecutionPermit + var permit *agentpb.ExecutionPermit if execution != nil && execution.permit != nil { - permit = proto.Clone(execution.permit).(*agentv1.ExecutionPermit) + permit = proto.Clone(execution.permit).(*agentpb.ExecutionPermit) } - return &agentv1.GetExecutionPermitResponse{Receipt: proto.Clone(previous.receipt).(*agentv1.OperationReceipt), Permit: permit}, nil + return &agentpb.GetExecutionPermitResponse{Receipt: proto.Clone(previous.receipt).(*agentpb.OperationReceipt), Permit: permit}, nil } permitID := fmt.Sprintf("permit-%s", req.Binding.ExecutionId) fencingToken := randomToken() - permit := &agentv1.ExecutionPermit{PermitId: permitID, ResourceReservationId: req.ResourceReservationId, IssuedAtUnixMs: s.now().UnixMilli(), ExpiresAtUnixMs: s.now().Add(time.Second).UnixMilli(), DispatcherEpoch: req.Meta.DispatcherEpoch, SessionGeneration: req.Meta.SessionGeneration, FencingToken: fencingToken, ConfigSha256: req.ConfigSha256} + permit := &agentpb.ExecutionPermit{PermitId: permitID, ResourceReservationId: req.ResourceReservationId, IssuedAtUnixMs: s.now().UnixMilli(), ExpiresAtUnixMs: s.now().Add(time.Second).UnixMilli(), DispatcherEpoch: req.Meta.DispatcherEpoch, SessionGeneration: req.Meta.SessionGeneration, FencingToken: fencingToken, ConfigSha256: req.ConfigSha256} if execution == nil { - execution = &executionRecord{binding: proto.Clone(req.Binding).(*agentv1.ExecutionBinding), taskRevision: req.Binding.TaskRevision, callState: "prepared"} + execution = &executionRecord{binding: proto.Clone(req.Binding).(*agentpb.ExecutionBinding), taskRevision: req.Binding.TaskRevision, callState: "prepared"} s.executions[req.Binding.ExecutionId] = execution } if execution.permit != nil && execution.permit.ResourceReservationId != req.ResourceReservationId { - return &agentv1.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "execution already has a different permit", false)}, nil + return &agentpb.GetExecutionPermitResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "execution already has a different permit", false)}, nil } - execution.permit = proto.Clone(permit).(*agentv1.ExecutionPermit) - execution.state = agentv1.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED - receipt := s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_APPLIED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false) - s.operations[s.operationKey(req.Meta)] = operationRecord{digest: digest, receipt: proto.Clone(receipt).(*agentv1.OperationReceipt)} + execution.permit = proto.Clone(permit).(*agentpb.ExecutionPermit) + execution.state = agentpb.ExecutionState_EXECUTION_STATE_PERMIT_GRANTED + receipt := s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_APPLIED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false) + s.operations[s.operationKey(req.Meta)] = operationRecord{digest: digest, receipt: proto.Clone(receipt).(*agentpb.OperationReceipt)} if err := s.persistExecutionJournalLocked(); err != nil { return nil, err } - return &agentv1.GetExecutionPermitResponse{Receipt: receipt, Permit: permit}, nil + return &agentpb.GetExecutionPermitResponse{Receipt: receipt, Permit: permit}, nil } -func (s *Server) ApplyTaskControl(ctx context.Context, req *agentv1.ApplyTaskControlRequest) (*agentv1.ApplyTaskControlResponse, error) { +func (s *Server) ApplyTaskControl(ctx context.Context, req *agentpb.ApplyTaskControlRequest) (*agentpb.ApplyTaskControlResponse, error) { if req == nil || req.Meta == nil || req.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and execution binding are required") } @@ -654,16 +654,16 @@ func (s *Server) ApplyTaskControl(ctx context.Context, req *agentv1.ApplyTaskCon if err := requireIdempotency(req.Meta); err != nil { return nil, err } - if req.Action != agentv1.ControlAction_CONTROL_ACTION_PAUSE && req.Action != agentv1.ControlAction_CONTROL_ACTION_RESUME && req.Action != agentv1.ControlAction_CONTROL_ACTION_STOP { + if req.Action != agentpb.ControlAction_CONTROL_ACTION_PAUSE && req.Action != agentpb.ControlAction_CONTROL_ACTION_RESUME && req.Action != agentpb.ControlAction_CONTROL_ACTION_STOP { return nil, status.Error(codes.InvalidArgument, "a supported control action is required") } - if req.ActiveCallPolicy != agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN && req.ActiveCallPolicy != agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { + if req.ActiveCallPolicy != agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN && req.ActiveCallPolicy != agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { return nil, status.Error(codes.InvalidArgument, "an explicit drain or hangup policy is required") } // Authorization above checks the live session. Recovery may use a new // session or trace, but must retain the original operation and business body. - identity := proto.Clone(req).(*agentv1.ApplyTaskControlRequest) - identity.Meta = &agentv1.RequestMeta{ + identity := proto.Clone(req).(*agentpb.ApplyTaskControlRequest) + identity.Meta = &agentpb.RequestMeta{ ProtocolVersion: req.Meta.ProtocolVersion, AgentId: req.Meta.AgentId, CellId: req.Meta.CellId, OperationId: req.Meta.OperationId, IdempotencyKey: req.Meta.IdempotencyKey, @@ -682,12 +682,12 @@ func (s *Server) ApplyTaskControl(ctx context.Context, req *agentv1.ApplyTaskCon } if previous, ok := s.operations[key]; ok { if previous.digest != digest || previous.control == nil { - return &agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil + return &agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false)}, nil } - return proto.Clone(previous.control).(*agentv1.ApplyTaskControlResponse), nil + return proto.Clone(previous.control).(*agentpb.ApplyTaskControlResponse), nil } - save := func(response *agentv1.ApplyTaskControlResponse) (*agentv1.ApplyTaskControlResponse, error) { - s.operations[key] = operationRecord{digest: digest, receipt: proto.Clone(response.Receipt).(*agentv1.OperationReceipt), control: proto.Clone(response).(*agentv1.ApplyTaskControlResponse)} + save := func(response *agentpb.ApplyTaskControlResponse) (*agentpb.ApplyTaskControlResponse, error) { + s.operations[key] = operationRecord{digest: digest, receipt: proto.Clone(response.Receipt).(*agentpb.OperationReceipt), control: proto.Clone(response).(*agentpb.ApplyTaskControlResponse)} if err := s.persistExecutionJournalLocked(); err != nil { return nil, err } @@ -695,43 +695,43 @@ func (s *Server) ApplyTaskControl(ctx context.Context, req *agentv1.ApplyTaskCon } execution := s.executions[req.Binding.ExecutionId] if execution == nil { - return save(&agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_NOT_FOUND, "execution not found", false)}) + return save(&agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_NOT_FOUND, "execution not found", false)}) } if !proto.Equal(execution.binding, req.Binding) { - return save(&agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "execution control binding mismatch", false)}) + return save(&agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "execution control binding mismatch", false)}) } if execution.taskRevision != req.ExpectedTaskRevision { - return save(&agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "task revision conflict", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) + return save(&agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "task revision conflict", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) } - if (execution.state == agentv1.ExecutionState_EXECUTION_STATE_TERMINAL || execution.controlAction == agentv1.ControlAction_CONTROL_ACTION_STOP) && req.Action != agentv1.ControlAction_CONTROL_ACTION_STOP { - return save(&agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "stopped execution cannot resume", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) + if (execution.state == agentpb.ExecutionState_EXECUTION_STATE_TERMINAL || execution.controlAction == agentpb.ControlAction_CONTROL_ACTION_STOP) && req.Action != agentpb.ControlAction_CONTROL_ACTION_STOP { + return save(&agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "stopped execution cannot resume", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) } - if req.Action != agentv1.ControlAction_CONTROL_ACTION_RESUME && req.ActiveCallPolicy == agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP && s.mode != "mock" { + if req.Action != agentpb.ControlAction_CONTROL_ACTION_RESUME && req.ActiveCallPolicy == agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP && s.mode != "mock" { return nil, status.Error(codes.FailedPrecondition, "media hangup adapter is not configured; control was not applied") } execution.taskRevision++ execution.binding.TaskRevision = execution.taskRevision execution.controlAction = req.Action execution.permit = nil - if req.Action == agentv1.ControlAction_CONTROL_ACTION_STOP { - if req.ActiveCallPolicy == agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN { + if req.Action == agentpb.ControlAction_CONTROL_ACTION_STOP { + if req.ActiveCallPolicy == agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN { execution.callState = "draining" } else { - execution.state = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL + execution.state = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL execution.callState = "stopped" } - } else if req.Action == agentv1.ControlAction_CONTROL_ACTION_PAUSE { + } else if req.Action == agentpb.ControlAction_CONTROL_ACTION_PAUSE { execution.callState = "paused" - if req.ActiveCallPolicy == agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { - execution.state = agentv1.ExecutionState_EXECUTION_STATE_TERMINAL + if req.ActiveCallPolicy == agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP { + execution.state = agentpb.ExecutionState_EXECUTION_STATE_TERMINAL } } else { execution.callState = "resumed" } - return save(&agentv1.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_APPLIED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) + return save(&agentpb.ApplyTaskControlResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_APPLIED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), AppliedTaskRevision: execution.taskRevision, State: execution.state}) } -func (s *Server) QueryExecution(ctx context.Context, req *agentv1.QueryExecutionRequest) (*agentv1.QueryExecutionResponse, error) { +func (s *Server) QueryExecution(ctx context.Context, req *agentpb.QueryExecutionRequest) (*agentpb.QueryExecutionResponse, error) { if req == nil || req.Meta == nil || req.Binding == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and execution binding are required") } @@ -742,7 +742,7 @@ func (s *Server) QueryExecution(ctx context.Context, req *agentv1.QueryExecution execution := s.executions[req.Binding.ExecutionId] if execution == nil { s.mu.Unlock() - return &agentv1.QueryExecutionResponse{Meta: s.responseMeta(req.Meta), Failure: s.failure(agentv1.FailureCode_FAILURE_CODE_NOT_FOUND, "execution not found", false)}, nil + return &agentpb.QueryExecutionResponse{Meta: s.responseMeta(req.Meta), Failure: s.failure(agentpb.FailureCode_FAILURE_CODE_NOT_FOUND, "execution not found", false)}, nil } observedAt := s.now().UnixMilli() if execution.callState == "mock_no_answer" || execution.callState == "mock_deadline_closed_without_dial" { @@ -752,12 +752,12 @@ func (s *Server) QueryExecution(ctx context.Context, req *agentv1.QueryExecution } observedAt = execution.terminalObservedAtUnixMs } - snapshot := &agentv1.ExecutionSnapshot{Binding: proto.Clone(execution.binding).(*agentv1.ExecutionBinding), State: execution.state, CallState: execution.callState, AttemptId: execution.binding.AttemptId, ObservedAtUnixMs: observedAt, Unknown: execution.unknown} + snapshot := &agentpb.ExecutionSnapshot{Binding: proto.Clone(execution.binding).(*agentpb.ExecutionBinding), State: execution.state, CallState: execution.callState, AttemptId: execution.binding.AttemptId, ObservedAtUnixMs: observedAt, Unknown: execution.unknown} s.mu.Unlock() - return &agentv1.QueryExecutionResponse{Meta: s.responseMeta(req.Meta), Snapshot: snapshot}, nil + return &agentpb.QueryExecutionResponse{Meta: s.responseMeta(req.Meta), Snapshot: snapshot}, nil } -func (s *Server) ReportExecutionEvent(ctx context.Context, req *agentv1.ReportExecutionEventRequest) (*agentv1.ReportExecutionEventResponse, error) { +func (s *Server) ReportExecutionEvent(ctx context.Context, req *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) { if req == nil || req.Meta == nil || req.Fact == nil { return nil, status.Error(codes.InvalidArgument, "request metadata and fact are required") } @@ -774,9 +774,9 @@ func (s *Server) ReportExecutionEvent(ctx context.Context, req *agentv1.ReportEx if previous, ok := s.facts[req.Fact.FactId]; ok { s.mu.Unlock() if previous != req.Fact.ContentSha256 { - return &agentv1.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "fact digest conflict", false)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "fact digest conflict", false)}, nil } - return &agentv1.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate fact", false)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate fact", false)}, nil } execution := executionForFact(s.executions, req.Fact) if s.callLogger != nil && execution != nil && execution.phone.Ref != "" { @@ -789,7 +789,7 @@ func (s *Server) ReportExecutionEvent(ctx context.Context, req *agentv1.ReportEx } s.facts[req.Fact.FactId] = req.Fact.ContentSha256 s.mu.Unlock() - return &agentv1.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false)}, nil + return &agentpb.ReportExecutionEventResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false)}, nil } type callFactPayload struct { @@ -829,14 +829,14 @@ type callFactPayload struct { } `json:"attempt_summary"` } -func executionForFact(executions map[string]*executionRecord, fact *agentv1.ExecutionFact) *executionRecord { +func executionForFact(executions map[string]*executionRecord, fact *agentpb.ExecutionFact) *executionRecord { if fact == nil || fact.Binding == nil || fact.Binding.ExecutionId == "" { return nil } return executions[fact.Binding.ExecutionId] } -func callLogEvents(fact *agentv1.ExecutionFact, execution *executionRecord, meta *agentv1.RequestMeta, now time.Time) []calllog.Event { +func callLogEvents(fact *agentpb.ExecutionFact, execution *executionRecord, meta *agentpb.RequestMeta, now time.Time) []calllog.Event { if fact == nil || execution == nil { return nil } @@ -923,21 +923,21 @@ func callLogEvents(fact *agentv1.ExecutionFact, execution *executionRecord, meta return result } -func factKindEventType(kind agentv1.FactKind) string { +func factKindEventType(kind agentpb.FactKind) string { switch kind { - case agentv1.FactKind_FACT_KIND_EXECUTION_ACCEPTED: + case agentpb.FactKind_FACT_KIND_EXECUTION_ACCEPTED: return "execution.accepted" - case agentv1.FactKind_FACT_KIND_CALL_STATUS: + case agentpb.FactKind_FACT_KIND_CALL_STATUS: return "call.status" - case agentv1.FactKind_FACT_KIND_CALL_FINISHED: + case agentpb.FactKind_FACT_KIND_CALL_FINISHED: return "call.finished" - case agentv1.FactKind_FACT_KIND_TRANSCRIPT_UPDATED: + case agentpb.FactKind_FACT_KIND_TRANSCRIPT_UPDATED: return "transcript.updated" - case agentv1.FactKind_FACT_KIND_TRANSCRIPT_FAILED: + case agentpb.FactKind_FACT_KIND_TRANSCRIPT_FAILED: return "transcript.failed" - case agentv1.FactKind_FACT_KIND_CONTACT_OPT_OUT: + case agentpb.FactKind_FACT_KIND_CONTACT_OPT_OUT: return "contact.opt_out" - case agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS: + case agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS: return "recording.progress" default: return "execution.fact" @@ -953,7 +953,7 @@ func firstNonEmpty(values ...string) string { return "" } -func (s *Server) RequestUpload(ctx context.Context, req *agentv1.RequestUploadRequest) (*agentv1.RequestUploadResponse, error) { +func (s *Server) RequestUpload(ctx context.Context, req *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) { if s.mode != "mock" { return nil, status.Error(codes.Unimplemented, "mock upload path is disabled outside mock mode") } @@ -970,25 +970,25 @@ func (s *Server) RequestUpload(ctx context.Context, req *agentv1.RequestUploadRe return nil, status.Error(codes.InvalidArgument, "upload ID is required") } if !s.uploadPolicy.Enabled { - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "uploads are disabled", false), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "uploads are disabled", false), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } s.mu.Lock() defer s.mu.Unlock() if existing, ok := s.uploads[req.UploadId]; ok { if !proto.Equal(existing.binding, req.Binding) || !proto.Equal(existing.asset, req.Asset) { - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "upload ID is bound to a different execution or asset", false), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "upload ID is bound to a different execution or asset", false), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate upload request", false), Grant: proto.Clone(existing.grant).(*agentv1.UploadGrant), State: existing.state}, nil + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate upload request", false), Grant: proto.Clone(existing.grant).(*agentpb.UploadGrant), State: existing.state}, nil } - grant := &agentv1.UploadGrant{UploadId: req.UploadId, TargetUrl: "https://oss.mock.invalid/upload/" + req.UploadId, ExpiresAtUnixMs: s.now().Add(5 * time.Minute).UnixMilli(), ObjectKey: req.Asset.AssetId, RequiredChecksumSha256: req.Asset.ChecksumSha256, MaxBytes: s.uploadPolicy.MaxAssetBytes} + grant := &agentpb.UploadGrant{UploadId: req.UploadId, TargetUrl: "https://oss.mock.invalid/upload/" + req.UploadId, ExpiresAtUnixMs: s.now().Add(5 * time.Minute).UnixMilli(), ObjectKey: req.Asset.AssetId, RequiredChecksumSha256: req.Asset.ChecksumSha256, MaxBytes: s.uploadPolicy.MaxAssetBytes} if grant.MaxBytes == 0 { grant.MaxBytes = req.Asset.SizeBytes } - s.uploads[req.UploadId] = uploadRecord{binding: proto.Clone(req.Binding).(*agentv1.ExecutionBinding), asset: proto.Clone(req.Asset).(*agentv1.AssetDescriptor), state: agentv1.UploadState_UPLOAD_STATE_REQUESTED, grant: grant} - return &agentv1.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), Grant: proto.Clone(grant).(*agentv1.UploadGrant), State: agentv1.UploadState_UPLOAD_STATE_REQUESTED}, nil + s.uploads[req.UploadId] = uploadRecord{binding: proto.Clone(req.Binding).(*agentpb.ExecutionBinding), asset: proto.Clone(req.Asset).(*agentpb.AssetDescriptor), state: agentpb.UploadState_UPLOAD_STATE_REQUESTED, grant: grant} + return &agentpb.RequestUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "", false), Grant: proto.Clone(grant).(*agentpb.UploadGrant), State: agentpb.UploadState_UPLOAD_STATE_REQUESTED}, nil } -func (s *Server) CompleteUpload(ctx context.Context, req *agentv1.CompleteUploadRequest) (*agentv1.CompleteUploadResponse, error) { +func (s *Server) CompleteUpload(ctx context.Context, req *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) { if s.mode != "mock" { return nil, status.Error(codes.Unimplemented, "mock upload path is disabled outside mock mode") } @@ -1005,34 +1005,34 @@ func (s *Server) CompleteUpload(ctx context.Context, req *agentv1.CompleteUpload defer s.mu.Unlock() upload, ok := s.uploads[req.UploadId] if !ok { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_NOT_FOUND, "upload not found", false), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_NOT_FOUND, "upload not found", false), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } if !proto.Equal(upload.binding, req.Binding) || !proto.Equal(upload.asset, req.Asset) { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "upload completion binding does not match request", false), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "upload completion binding does not match request", false), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } if upload.asset.ChecksumSha256 != req.UploadedChecksumSha256 || upload.asset.SizeBytes != req.UploadedSizeBytes || req.UploadedSizeBytes > upload.grant.MaxBytes { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded asset does not match grant", false), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_INVALID_ARGUMENT, "uploaded asset does not match grant", false), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } if upload.completed { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate mock upload completion", false), State: agentv1.UploadState_UPLOAD_STATE_COMPLETED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "duplicate mock upload completion", false), State: agentpb.UploadState_UPLOAD_STATE_COMPLETED}, nil } if upload.grant.ExpiresAtUnixMs <= s.now().UnixMilli() { - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_REJECTED, agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "upload grant has expired", true), State: agentv1.UploadState_UPLOAD_STATE_FAILED}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_REJECTED, agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION, "upload grant has expired", true), State: agentpb.UploadState_UPLOAD_STATE_FAILED}, nil } upload.completed = true - upload.state = agentv1.UploadState_UPLOAD_STATE_COMPLETED + upload.state = agentpb.UploadState_UPLOAD_STATE_COMPLETED s.uploads[req.UploadId] = upload - return &agentv1.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentv1.ResultCode_RESULT_CODE_ACCEPTED, agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED, "mock upload notification completion accepted", false), State: upload.state}, nil + return &agentpb.CompleteUploadResponse{Receipt: s.receipt(req.Meta, agentpb.ResultCode_RESULT_CODE_ACCEPTED, agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED, "mock upload notification completion accepted", false), State: upload.state}, nil } -func requireIdempotency(meta *agentv1.RequestMeta) error { +func requireIdempotency(meta *agentpb.RequestMeta) error { if meta == nil || meta.OperationId == "" || meta.IdempotencyKey == "" { return status.Error(codes.InvalidArgument, "operation and idempotency key are required") } return nil } -func (s *Server) authorize(ctx context.Context, meta *agentv1.RequestMeta) error { +func (s *Server) authorize(ctx context.Context, meta *agentpb.RequestMeta) error { if err := s.executionJournalReady(); err != nil { return err } @@ -1096,33 +1096,33 @@ func (s *Server) peerIsAuthenticated(ctx context.Context) bool { return ok } -func (s *Server) responseMeta(meta *agentv1.RequestMeta) *agentv1.ResponseMeta { +func (s *Server) responseMeta(meta *agentpb.RequestMeta) *agentpb.ResponseMeta { if meta == nil { return nil } - return &agentv1.ResponseMeta{ProtocolVersion: meta.ProtocolVersion, RequestId: meta.RequestId, TraceId: meta.TraceId, OperationId: meta.OperationId, ObservedAtUnixMs: s.now().UnixMilli(), DispatcherEpoch: meta.DispatcherEpoch, AgentId: meta.AgentId, CellId: meta.CellId, BootId: meta.BootId, SessionGeneration: meta.SessionGeneration} + return &agentpb.ResponseMeta{ProtocolVersion: meta.ProtocolVersion, RequestId: meta.RequestId, TraceId: meta.TraceId, OperationId: meta.OperationId, ObservedAtUnixMs: s.now().UnixMilli(), DispatcherEpoch: meta.DispatcherEpoch, AgentId: meta.AgentId, CellId: meta.CellId, BootId: meta.BootId, SessionGeneration: meta.SessionGeneration} } -func (s *Server) receipt(meta *agentv1.RequestMeta, result agentv1.ResultCode, code agentv1.FailureCode, detail string, retryable bool) *agentv1.OperationReceipt { - receipt := &agentv1.OperationReceipt{Meta: s.responseMeta(meta), Result: result, AcceptedAtUnixMs: s.now().UnixMilli()} - if code != agentv1.FailureCode_FAILURE_CODE_UNSPECIFIED { +func (s *Server) receipt(meta *agentpb.RequestMeta, result agentpb.ResultCode, code agentpb.FailureCode, detail string, retryable bool) *agentpb.OperationReceipt { + receipt := &agentpb.OperationReceipt{Meta: s.responseMeta(meta), Result: result, AcceptedAtUnixMs: s.now().UnixMilli()} + if code != agentpb.FailureCode_FAILURE_CODE_UNSPECIFIED { receipt.Failure = s.failure(code, detail, retryable) } return receipt } -func (s *Server) failure(code agentv1.FailureCode, detail string, retryable bool) *agentv1.Failure { - return &agentv1.Failure{Code: code, Detail: detail, Retryable: retryable} +func (s *Server) failure(code agentpb.FailureCode, detail string, retryable bool) *agentpb.Failure { + return &agentpb.Failure{Code: code, Detail: detail, Retryable: retryable} } -func (s *Server) operationKey(meta *agentv1.RequestMeta) string { +func (s *Server) operationKey(meta *agentpb.RequestMeta) string { if meta == nil || meta.IdempotencyKey == "" { return "" } return meta.AgentId + "\x00" + meta.OperationId + "\x00" + meta.IdempotencyKey } -func (s *Server) replayOperation(meta *agentv1.RequestMeta, digest string) (*agentv1.OperationReceipt, *agentv1.OperationReceipt) { +func (s *Server) replayOperation(meta *agentpb.RequestMeta, digest string) (*agentpb.OperationReceipt, *agentpb.OperationReceipt) { key := s.operationKey(meta) if key == "" { return nil, nil @@ -1130,16 +1130,16 @@ func (s *Server) replayOperation(meta *agentv1.RequestMeta, digest string) (*age s.mu.Lock() defer s.mu.Unlock() if s.executionErr != nil { - return nil, s.receipt(meta, agentv1.ResultCode_RESULT_CODE_UNKNOWN, agentv1.FailureCode_FAILURE_CODE_UNAVAILABLE, "execution journal unavailable", false) + return nil, s.receipt(meta, agentpb.ResultCode_RESULT_CODE_UNKNOWN, agentpb.FailureCode_FAILURE_CODE_UNAVAILABLE, "execution journal unavailable", false) } record, ok := s.operations[key] if !ok { return nil, nil } if record.digest != digest { - return nil, s.receipt(meta, agentv1.ResultCode_RESULT_CODE_CONFLICT, agentv1.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false) + return nil, s.receipt(meta, agentpb.ResultCode_RESULT_CODE_CONFLICT, agentpb.FailureCode_FAILURE_CODE_ABORTED, "idempotency key content conflict", false) } - return proto.Clone(record.receipt).(*agentv1.OperationReceipt), nil + return proto.Clone(record.receipt).(*agentpb.OperationReceipt), nil } func messageDigest(message proto.Message) string { @@ -1159,18 +1159,18 @@ func randomToken() string { return hex.EncodeToString(value) } -func cloneSession(value *agentv1.Session) *agentv1.Session { +func cloneSession(value *agentpb.Session) *agentpb.Session { if value == nil { return nil } - return proto.Clone(value).(*agentv1.Session) + return proto.Clone(value).(*agentpb.Session) } -func cloneConfigReferences(values []*agentv1.ConfigReference) []*agentv1.ConfigReference { - result := make([]*agentv1.ConfigReference, 0, len(values)) +func cloneConfigReferences(values []*agentpb.ConfigReference) []*agentpb.ConfigReference { + result := make([]*agentpb.ConfigReference, 0, len(values)) for _, value := range values { if value != nil { - result = append(result, proto.Clone(value).(*agentv1.ConfigReference)) + result = append(result, proto.Clone(value).(*agentpb.ConfigReference)) } } return result @@ -1198,5 +1198,5 @@ func cloneSet(values map[string]struct{}) map[string]struct{} { return result } -var _ agentv1.AgentControlServiceServer = (*Server)(nil) +var _ agentpb.AgentControlServiceServer = (*Server)(nil) var _ = grpc.SupportPackageIsVersion9 diff --git a/internal/rpc/server_test.go b/internal/rpc/server_test.go index aec2f6a..2caa8fa 100644 --- a/internal/rpc/server_test.go +++ b/internal/rpc/server_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" "google.golang.org/grpc" @@ -41,18 +41,18 @@ func TestGetAgentStatusSupportsPreActivationProbe(t *testing.T) { now := time.Unix(100, 0) server := NewServer(ServerOptions{ Now: func() time.Time { return now }, - Status: &agentv1.AgentStatus{ + Status: &agentpb.AgentStatus{ AgentId: "agent-1", CellId: "cell-1", BootId: "boot-current", SoftwareVersion: "test", ProtocolVersion: "agent.v1", - AdmissionState: agentv1.AdmissionState_ADMISSION_STATE_CLOSED, + AdmissionState: agentpb.AdmissionState_ADMISSION_STATE_CLOSED, }, }) - response, err := server.GetAgentStatus(context.Background(), &agentv1.GetAgentStatusRequest{ - Meta: &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "probe-request", TraceId: "probe-trace", OperationId: "probe-operation", AgentId: "agent-1", CellId: "cell-1"}, - Target: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, + response, err := server.GetAgentStatus(context.Background(), &agentpb.GetAgentStatusRequest{ + Meta: &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "probe-request", TraceId: "probe-trace", OperationId: "probe-operation", AgentId: "agent-1", CellId: "cell-1"}, + Target: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, }) require.NoError(t, err) require.Equal(t, "boot-current", response.Status.BootId) @@ -60,22 +60,22 @@ func TestGetAgentStatusSupportsPreActivationProbe(t *testing.T) { require.Equal(t, false, response.Status.MtlsAuthenticated) active := activatedServer(now, t) - activeResponse, err := active.GetAgentStatus(context.Background(), &agentv1.GetAgentStatusRequest{Meta: testMeta("status-active", "status-active-key", 1), Target: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}}) + activeResponse, err := active.GetAgentStatus(context.Background(), &agentpb.GetAgentStatusRequest{Meta: testMeta("status-active", "status-active-key", 1), Target: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}}) require.NoError(t, err) require.Equal(t, true, activeResponse.Status.SessionActive) } func TestAgentIdentityIsBoundToConfiguredEndpoint(t *testing.T) { - server := NewServer(ServerOptions{Status: &agentv1.AgentStatus{AgentId: "agent-1", CellId: "cell-1"}}) - _, err := server.GetAgentStatus(context.Background(), &agentv1.GetAgentStatusRequest{ - Meta: &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "wrong-probe", TraceId: "wrong-probe", OperationId: "wrong-probe", AgentId: "agent-2", CellId: "cell-2"}, - Target: &agentv1.AgentBinding{AgentId: "agent-2", CellId: "cell-2"}, + server := NewServer(ServerOptions{Status: &agentpb.AgentStatus{AgentId: "agent-1", CellId: "cell-1"}}) + _, err := server.GetAgentStatus(context.Background(), &agentpb.GetAgentStatusRequest{ + Meta: &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "wrong-probe", TraceId: "wrong-probe", OperationId: "wrong-probe", AgentId: "agent-2", CellId: "cell-2"}, + Target: &agentpb.AgentBinding{AgentId: "agent-2", CellId: "cell-2"}, }) require.Equal(t, codes.PermissionDenied, status.Code(err)) - _, err = server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ - Meta: &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "wrong-activate", TraceId: "wrong-activate", OperationId: "wrong-activate", AgentId: "agent-2", CellId: "cell-2", BootId: "boot-2", DispatcherEpoch: "epoch-2"}, - Binding: &agentv1.AgentBinding{AgentId: "agent-2", CellId: "cell-2", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 1}, + _, err = server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ + Meta: &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: "wrong-activate", TraceId: "wrong-activate", OperationId: "wrong-activate", AgentId: "agent-2", CellId: "cell-2", BootId: "boot-2", DispatcherEpoch: "epoch-2"}, + Binding: &agentpb.AgentBinding{AgentId: "agent-2", CellId: "cell-2", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 1}, ActivationOperationId: "wrong-activate", }) require.Equal(t, codes.PermissionDenied, status.Code(err)) @@ -86,29 +86,29 @@ func TestSessionGenerationFencesOlderRequests(t *testing.T) { server := NewServer(ServerOptions{Now: func() time.Time { return now }}) firstMeta := testMeta("activate-1", "", 0) firstMeta.OperationId = "activate-1" - _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: firstMeta, - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-1", }) require.NoError(t, err) secondMeta := testMeta("activate-2", "", 0) secondMeta.BootId = "boot-2" secondMeta.OperationId = "activate-2" - _, err = server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + _, err = server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: secondMeta, - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 2}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 2}, ActivationOperationId: "activate-2", }) require.NoError(t, err) - _, err = server.GetBootstrap(context.Background(), &agentv1.GetBootstrapRequest{Meta: testMeta("old", "read-old", 1)}) + _, err = server.GetBootstrap(context.Background(), &agentpb.GetBootstrapRequest{Meta: testMeta("old", "read-old", 1)}) require.Error(t, err) require.Equal(t, codes.Aborted, status.Code(err)) fresh := testMeta("fresh", "read-fresh", 2) fresh.BootId = "boot-2" fresh.DispatcherEpoch = "epoch-2" - _, err = server.GetBootstrap(context.Background(), &agentv1.GetBootstrapRequest{Meta: fresh}) + _, err = server.GetBootstrap(context.Background(), &agentpb.GetBootstrapRequest{Meta: fresh}) require.NoError(t, err) } @@ -120,18 +120,18 @@ func TestExecuteIdempotencyAndBinding(t *testing.T) { envelope, payload, err := contract.DecodeExecute(raw) require.NoError(t, err) meta := testMeta("execute-1", "execute-key", 1) - req := &agentv1.ExecuteRequest{Meta: meta, Binding: &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} + req := &agentpb.ExecuteRequest{Meta: meta, Binding: &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} first, err := server.Execute(context.Background(), req) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_ACCEPTED, first.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_ACCEPTED, first.Receipt.Result) replay, err := server.Execute(context.Background(), req) require.NoError(t, err) require.Equal(t, first.Receipt.Meta.OperationId, replay.Receipt.Meta.OperationId) - conflictReq := proto.Clone(req).(*agentv1.ExecuteRequest) + conflictReq := proto.Clone(req).(*agentpb.ExecuteRequest) conflictReq.ConfigSha256 = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" conflict, err := server.Execute(context.Background(), conflictReq) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) } func TestRealModeRejectsExecutionOutsideCallWindow(t *testing.T) { @@ -140,9 +140,9 @@ func TestRealModeRejectsExecutionOutsideCallWindow(t *testing.T) { Now: func() time.Time { return time.Date(2026, 9, 18, 12, 0, 0, 0, time.UTC) }, }) activateTestServer(t, server) - response, err := server.GetExecutionPermit(context.Background(), &agentv1.GetExecutionPermitRequest{ + response, err := server.GetExecutionPermit(context.Background(), &agentpb.GetExecutionPermitRequest{ Meta: testMeta("permit-window", "permit-window-key", 1), - Binding: &agentv1.ExecutionBinding{ExecutionId: "execution-window"}, + Binding: &agentpb.ExecutionBinding{ExecutionId: "execution-window"}, ResourceReservationId: "reservation-window", }) if response != nil || status.Code(err) != codes.FailedPrecondition { @@ -152,7 +152,7 @@ func TestRealModeRejectsExecutionOutsideCallWindow(t *testing.T) { func TestRealModeRejectsMockUploadDataPlane(t *testing.T) { server := NewServer(ServerOptions{Mode: "real"}) - response, err := server.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{}) + response, err := server.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{}) if response != nil || status.Code(err) != codes.Unimplemented { t.Fatalf("response=%+v err=%v code=%s", response, err, status.Code(err)) } @@ -161,46 +161,46 @@ func TestRealModeRejectsMockUploadDataPlane(t *testing.T) { func TestAdmissionAndControlCAS(t *testing.T) { server := activatedServer(time.Date(2026, 9, 18, 1, 0, 0, 0, time.UTC), t) meta := testMeta("admission-1", "admission-key", 1) - admission, err := server.SetAdmissionState(context.Background(), &agentv1.SetAdmissionStateRequest{Meta: meta, Target: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, State: agentv1.AdmissionState_ADMISSION_STATE_OPEN}) + admission, err := server.SetAdmissionState(context.Background(), &agentpb.SetAdmissionStateRequest{Meta: meta, Target: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, State: agentpb.AdmissionState_ADMISSION_STATE_OPEN}) require.NoError(t, err) require.Equal(t, uint64(1), admission.AppliedAdmissionGeneration) - conflict, err := server.SetAdmissionState(context.Background(), &agentv1.SetAdmissionStateRequest{Meta: testMeta("admission-2", "admission-key-2", 1), Target: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, State: agentv1.AdmissionState_ADMISSION_STATE_CLOSED}) + conflict, err := server.SetAdmissionState(context.Background(), &agentpb.SetAdmissionStateRequest{Meta: testMeta("admission-2", "admission-key-2", 1), Target: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1"}, State: agentpb.AdmissionState_ADMISSION_STATE_CLOSED}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) raw, err := testfixture.Execute() require.NoError(t, err) envelope, payload, err := contract.DecodeExecute(raw) require.NoError(t, err) executeMeta := testMeta("execute-control", "execute-control-key", 1) - _, err = server.Execute(context.Background(), &agentv1.ExecuteRequest{Meta: executeMeta, Binding: &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}) + _, err = server.Execute(context.Background(), &agentpb.ExecuteRequest{Meta: executeMeta, Binding: &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}) require.NoError(t, err) controlMeta := testMeta("control-1", "control-key", 1) - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} - pauseRequest := &agentv1.ApplyTaskControlRequest{Meta: controlMeta, Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), Action: agentv1.ControlAction_CONTROL_ACTION_PAUSE, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: payload.TaskRevision} - foreign := proto.Clone(pauseRequest).(*agentv1.ApplyTaskControlRequest) + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID} + pauseRequest := &agentpb.ApplyTaskControlRequest{Meta: controlMeta, Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), Action: agentpb.ControlAction_CONTROL_ACTION_PAUSE, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: payload.TaskRevision} + foreign := proto.Clone(pauseRequest).(*agentpb.ApplyTaskControlRequest) foreign.Meta = testMeta("foreign-control", "foreign-control-key", 1) foreign.Binding.TenantKey = "different-tenant" foreignResponse, err := server.ApplyTaskControl(context.Background(), foreign) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_CONFLICT, foreignResponse.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_CONFLICT, foreignResponse.Receipt.Result) paused, err := server.ApplyTaskControl(context.Background(), pauseRequest) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_APPLIED, paused.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_APPLIED, paused.Receipt.Result) duplicate, err := server.ApplyTaskControl(context.Background(), pauseRequest) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_APPLIED, duplicate.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_APPLIED, duplicate.Receipt.Result) require.Equal(t, paused.AppliedTaskRevision, duplicate.AppliedTaskRevision) - blockedPermit, err := server.GetExecutionPermit(context.Background(), &agentv1.GetExecutionPermitRequest{Meta: testMeta("permit-paused", "permit-paused-key", 1), Binding: &agentv1.ExecutionBinding{ExecutionId: payload.ExecutionID, TaskRevision: paused.AppliedTaskRevision}, ResourceReservationId: "paused-reservation"}) + blockedPermit, err := server.GetExecutionPermit(context.Background(), &agentpb.GetExecutionPermitRequest{Meta: testMeta("permit-paused", "permit-paused-key", 1), Binding: &agentpb.ExecutionBinding{ExecutionId: payload.ExecutionID, TaskRevision: paused.AppliedTaskRevision}, ResourceReservationId: "paused-reservation"}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_REJECTED, blockedPermit.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_REJECTED, blockedPermit.Receipt.Result) if blockedPermit.Permit != nil { t.Fatal("paused execution received a permit") } - resetAttempt, err := server.Execute(context.Background(), &agentv1.ExecuteRequest{Meta: testMeta("execute-after-pause", "execute-after-pause-key", 1), Binding: &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}) + resetAttempt, err := server.Execute(context.Background(), &agentpb.ExecuteRequest{Meta: testMeta("execute-after-pause", "execute-after-pause-key", 1), Binding: &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, ExecutionId: payload.ExecutionID, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, AgentVersionId: payload.AgentVersionID}, CallExecuteJson: raw, ConfigSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_REJECTED, resetAttempt.Receipt.Result) - retraced := proto.Clone(pauseRequest).(*agentv1.ApplyTaskControlRequest) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_REJECTED, resetAttempt.Receipt.Result) + retraced := proto.Clone(pauseRequest).(*agentpb.ApplyTaskControlRequest) retraced.Meta.RequestId = "recovered-control-request" retraced.Meta.TraceId = "recovered-control-trace" replayed, err := server.ApplyTaskControl(context.Background(), retraced) @@ -208,64 +208,64 @@ func TestAdmissionAndControlCAS(t *testing.T) { if !proto.Equal(paused, replayed) { t.Fatal("transport metadata changed a control's business identity") } - changed := proto.Clone(pauseRequest).(*agentv1.ApplyTaskControlRequest) + changed := proto.Clone(pauseRequest).(*agentpb.ApplyTaskControlRequest) changed.Reason = "different control content" conflicted, err := server.ApplyTaskControl(context.Background(), changed) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_CONFLICT, conflicted.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_CONFLICT, conflicted.Receipt.Result) binding.TaskRevision = paused.AppliedTaskRevision - stopped, err := server.ApplyTaskControl(context.Background(), &agentv1.ApplyTaskControlRequest{Meta: testMeta("control-2", "control-key-2", 1), Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), Action: agentv1.ControlAction_CONTROL_ACTION_STOP, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, ExpectedTaskRevision: paused.AppliedTaskRevision}) + stopped, err := server.ApplyTaskControl(context.Background(), &agentpb.ApplyTaskControlRequest{Meta: testMeta("control-2", "control-key-2", 1), Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), Action: agentpb.ControlAction_CONTROL_ACTION_STOP, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_HANGUP, ExpectedTaskRevision: paused.AppliedTaskRevision}) require.NoError(t, err) - require.Equal(t, agentv1.ExecutionState_EXECUTION_STATE_TERMINAL, stopped.State) + require.Equal(t, agentpb.ExecutionState_EXECUTION_STATE_TERMINAL, stopped.State) original, err := server.ApplyTaskControl(context.Background(), pauseRequest) require.NoError(t, err) require.Equal(t, paused.AppliedTaskRevision, original.AppliedTaskRevision) - snapshot, err := server.QueryExecution(context.Background(), &agentv1.QueryExecutionRequest{Meta: testMeta("query-after-stop", "", 1), Binding: pauseRequest.Binding}) + snapshot, err := server.QueryExecution(context.Background(), &agentpb.QueryExecutionRequest{Meta: testMeta("query-after-stop", "", 1), Binding: pauseRequest.Binding}) require.NoError(t, err) require.Equal(t, stopped.AppliedTaskRevision, snapshot.Snapshot.Binding.TaskRevision) binding.TaskRevision = stopped.AppliedTaskRevision - resumed, err := server.ApplyTaskControl(context.Background(), &agentv1.ApplyTaskControlRequest{Meta: testMeta("control-3", "control-key-3", 1), Binding: proto.Clone(binding).(*agentv1.ExecutionBinding), Action: agentv1.ControlAction_CONTROL_ACTION_RESUME, ActiveCallPolicy: agentv1.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: stopped.AppliedTaskRevision}) + resumed, err := server.ApplyTaskControl(context.Background(), &agentpb.ApplyTaskControlRequest{Meta: testMeta("control-3", "control-key-3", 1), Binding: proto.Clone(binding).(*agentpb.ExecutionBinding), Action: agentpb.ControlAction_CONTROL_ACTION_RESUME, ActiveCallPolicy: agentpb.ActiveCallPolicy_ACTIVE_CALL_POLICY_DRAIN, ExpectedTaskRevision: stopped.AppliedTaskRevision}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_REJECTED, resumed.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_REJECTED, resumed.Receipt.Result) } func TestFactDeduplication(t *testing.T) { server := activatedServer(time.Unix(100, 0), t) - fact := &agentv1.ExecutionFact{FactId: "fact-1", ContentSha256: "digest-a", Binding: &agentv1.ExecutionBinding{ExecutionId: "execution-1"}, Kind: agentv1.FactKind_FACT_KIND_CALL_STATUS} - first, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: testMeta("fact-1", "fact-key-1", 1), Fact: fact}) + fact := &agentpb.ExecutionFact{FactId: "fact-1", ContentSha256: "digest-a", Binding: &agentpb.ExecutionBinding{ExecutionId: "execution-1"}, Kind: agentpb.FactKind_FACT_KIND_CALL_STATUS} + first, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: testMeta("fact-1", "fact-key-1", 1), Fact: fact}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_ACCEPTED, first.Receipt.Result) - replay, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: testMeta("fact-2", "fact-key-2", 1), Fact: fact}) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_ACCEPTED, first.Receipt.Result) + replay, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: testMeta("fact-2", "fact-key-2", 1), Fact: fact}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_ACCEPTED, replay.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_ACCEPTED, replay.Receipt.Result) fact.ContentSha256 = "digest-b" - conflict, err := server.ReportExecutionEvent(context.Background(), &agentv1.ReportExecutionEventRequest{Meta: testMeta("fact-3", "fact-key-3", 1), Fact: fact}) + conflict, err := server.ReportExecutionEvent(context.Background(), &agentpb.ReportExecutionEventRequest{Meta: testMeta("fact-3", "fact-key-3", 1), Fact: fact}) require.NoError(t, err) - require.Equal(t, agentv1.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) + require.Equal(t, agentpb.ResultCode_RESULT_CODE_CONFLICT, conflict.Receipt.Result) } func TestGeneratedUnaryServiceWiring(t *testing.T) { server := NewServer(ServerOptions{Now: func() time.Time { return time.Unix(100, 0) }}) listener := bufconn.Listen(1024 * 1024) grpcServer := grpc.NewServer() - agentv1.RegisterAgentControlServiceServer(grpcServer, server) + agentpb.RegisterAgentControlServiceServer(grpcServer, server) go func() { _ = grpcServer.Serve(listener) }() defer grpcServer.Stop() conn, err := grpc.NewClient("passthrough:///bufnet", grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { return listener.Dial() }), grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) defer conn.Close() - client := agentv1.NewAgentControlServiceClient(conn) + client := agentpb.NewAgentControlServiceClient(conn) meta := testMeta("activate-rpc", "", 0) - response, err := client.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{Meta: meta, Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-rpc"}) + response, err := client.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{Meta: meta, Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-rpc"}) require.NoError(t, err) - require.Equal(t, agentv1.ActivationState_ACTIVATION_STATE_ACTIVE, response.State) + require.Equal(t, agentpb.ActivationState_ACTIVATION_STATE_ACTIVE, response.State) } func activatedServer(now time.Time, t *testing.T) *Server { t.Helper() - server := NewServer(ServerOptions{Now: func() time.Time { return now }, UploadPolicy: &agentv1.UploadPolicy{Enabled: true, MaxAssetBytes: 16 << 20}}) + server := NewServer(ServerOptions{Now: func() time.Time { return now }, UploadPolicy: &agentpb.UploadPolicy{Enabled: true, MaxAssetBytes: 16 << 20}}) meta := testMeta("activate", "", 0) - _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{Meta: meta, Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate"}) + _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{Meta: meta, Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate"}) require.NoError(t, err) return server } @@ -295,6 +295,6 @@ func (testAssertions) Equal(t *testing.T, expected, actual any, _ ...any) { } } -func testMeta(operationID, idempotencyKey string, generation uint64) *agentv1.RequestMeta { - return &agentv1.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + "-request", TraceId: "trace-1", OperationId: operationID, IdempotencyKey: idempotencyKey, DispatcherEpoch: "epoch-1", AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1", SessionGeneration: generation} +func testMeta(operationID, idempotencyKey string, generation uint64) *agentpb.RequestMeta { + return &agentpb.RequestMeta{ProtocolVersion: "agent.v1", RequestId: operationID + "-request", TraceId: "trace-1", OperationId: operationID, IdempotencyKey: idempotencyKey, DispatcherEpoch: "epoch-1", AgentId: "agent-1", CellId: "cell-1", BootId: "boot-1", SessionGeneration: generation} } diff --git a/internal/rpc/session_meta_test.go b/internal/rpc/session_meta_test.go index 856545b..76b0e03 100644 --- a/internal/rpc/session_meta_test.go +++ b/internal/rpc/session_meta_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -15,7 +15,7 @@ func TestCurrentSessionMetaUsesOnlyActivatedUnexpiredAgentBinding(t *testing.T) if _, err := registry.CurrentMeta("agent-a", now); status.Code(err) != codes.Unauthenticated { t.Fatalf("unactivated Agent fabricated a session: %v", err) } - binding := &agentv1.AgentBinding{AgentId: "agent-a", CellId: "cell-a", ExpectedBootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1} + binding := &agentpb.AgentBinding{AgentId: "agent-a", CellId: "cell-a", ExpectedBootId: "boot-a", DispatcherEpoch: "epoch-a", SessionGeneration: 1} session, _, err := registry.Activate(binding, "activate-a", "digest-a", now) if err != nil { t.Fatal(err) diff --git a/internal/rpc/session_test.go b/internal/rpc/session_test.go index 105a59b..5ca3227 100644 --- a/internal/rpc/session_test.go +++ b/internal/rpc/session_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -12,16 +12,16 @@ import ( func TestSessionRegistryPersistsGenerationAcrossRestart(t *testing.T) { path := t.TempDir() + "/rpc-session.json" first := NewSessionRegistry(path) - _, _, err := first.Activate(&agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 3}, "activate-1", "digest-1", time.Unix(100, 0)) + _, _, err := first.Activate(&agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 3}, "activate-1", "digest-1", time.Unix(100, 0)) if err != nil { t.Fatal(err) } second := NewSessionRegistry(path) - _, _, err = second.Activate(&agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 2}, "activate-2", "digest-2", time.Unix(100, 0)) + _, _, err = second.Activate(&agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 2}, "activate-2", "digest-2", time.Unix(100, 0)) if status.Code(err) != codes.Aborted { t.Fatalf("error = %v, want persisted generation fence", err) } - if _, _, err := second.Activate(&agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 4}, "activate-3", "digest-3", time.Unix(100, 0)); err != nil { + if _, _, err := second.Activate(&agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-2", DispatcherEpoch: "epoch-2", SessionGeneration: 4}, "activate-3", "digest-3", time.Unix(100, 0)); err != nil { t.Fatal(err) } } diff --git a/internal/rpc/static_artifact_test.go b/internal/rpc/static_artifact_test.go index 33379fa..c906d31 100644 --- a/internal/rpc/static_artifact_test.go +++ b/internal/rpc/static_artifact_test.go @@ -6,7 +6,7 @@ import ( "time" "git.ipao.vip/rogee/go-sip/contracts" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -31,15 +31,15 @@ func TestActivationValidatesStaticCellArtifact(t *testing.T) { }) meta := testMeta("activate-static", "", 0) meta.CellId = "cell-a" - response, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + response, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: meta, - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-a", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-a", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-static", }) if err != nil { t.Fatal(err) } - if response.State != agentv1.ActivationState_ACTIVATION_STATE_ACTIVE { + if response.State != agentpb.ActivationState_ACTIVATION_STATE_ACTIVE { t.Fatalf("activation state=%s", response.State) } } @@ -56,9 +56,9 @@ func TestActivationRejectsInvalidStaticCellArtifact(t *testing.T) { }) meta := testMeta("activate-invalid-static", "", 0) meta.CellId = "cell-a" - _, err = server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + _, err = server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: meta, - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-a", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-a", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-invalid-static", }) if err == nil || status.Code(err) != codes.FailedPrecondition { diff --git a/internal/rpc/upload_destination_test.go b/internal/rpc/upload_destination_test.go index c505c74..3513097 100644 --- a/internal/rpc/upload_destination_test.go +++ b/internal/rpc/upload_destination_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/grpc/codes" @@ -34,16 +34,16 @@ func TestUploadFactKeepsOriginallyGrantedBucketAfterConfigurationChange(t *testi } return server } - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} - meta := &agentv1.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} + meta := &agentpb.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} first := makeServer("original-bucket") - response, err := first.RequestUpload(context.Background(), &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) + response, err := first.RequestUpload(context.Background(), &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) if err != nil || response.GetGrant() == nil { t.Fatalf("grant: %v", err) } restarted := makeServer("new-bucket") - _, err = restarted.CompleteUpload(context.Background(), &agentv1.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256}) + _, err = restarted.CompleteUpload(context.Background(), &agentpb.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256}) if status.Code(err) != codes.Unavailable { t.Fatalf("pending notification: %v", err) } diff --git a/internal/rpc/upload_grant_idempotency_test.go b/internal/rpc/upload_grant_idempotency_test.go index 229657c..ab6fa93 100644 --- a/internal/rpc/upload_grant_idempotency_test.go +++ b/internal/rpc/upload_grant_idempotency_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" "git.ipao.vip/rogee/go-sip/internal/store" "google.golang.org/protobuf/proto" @@ -27,10 +27,10 @@ func TestUploadGrantRedeliveryDoesNotRenewExpiredToken(t *testing.T) { if err != nil { t.Fatal(err) } - request := &agentv1.RequestUploadRequest{ - Meta: &agentv1.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "original-request", IdempotencyKey: "original-request"}, - Binding: &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"}, - Asset: &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)}, UploadId: "upload-a", + request := &agentpb.RequestUploadRequest{ + Meta: &agentpb.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "original-request", IdempotencyKey: "original-request"}, + Binding: &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: "tenant-a", TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"}, + Asset: &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)}, UploadId: "upload-a", } first, err := server.RequestUpload(context.Background(), request) if err != nil { @@ -44,7 +44,7 @@ func TestUploadGrantRedeliveryDoesNotRenewExpiredToken(t *testing.T) { if !proto.Equal(first.Grant, duplicate.Grant) { t.Fatal("redelivery silently renewed the original token") } - explicit := proto.Clone(request).(*agentv1.RequestUploadRequest) + explicit := proto.Clone(request).(*agentpb.RequestUploadRequest) explicit.Meta.OperationId = "explicit-new-request" explicit.Meta.IdempotencyKey = "explicit-new-request" renewed, err := server.RequestUpload(context.Background(), explicit) diff --git a/internal/rpc/upload_mq_integration_test.go b/internal/rpc/upload_mq_integration_test.go index c0b6659..5a45249 100644 --- a/internal/rpc/upload_mq_integration_test.go +++ b/internal/rpc/upload_mq_integration_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/dispatcher" "git.ipao.vip/rogee/go-sip/internal/mq" ossclient "git.ipao.vip/rogee/go-sip/internal/oss" @@ -88,16 +88,16 @@ func TestLocalUploadNoticeSurvivesUnroutableAndRestart(t *testing.T) { if err != nil { t.Fatal(err) } - meta := &agentv1.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} - binding := &agentv1.ExecutionBinding{TenantId: "tenant-a", TenantKey: key, TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} + meta := &agentpb.RequestMeta{AgentId: "agent-a", CellId: "cell-a", OperationId: "op-a", IdempotencyKey: "key-a", TraceId: "trace-a"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-a", TenantKey: key, TaskId: "task-a", ExecutionId: "execution-a", CallId: "call-a"} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-a", CallId: "call-a", Format: "wav", Channels: 1, SampleRateHz: 8000, DurationMs: 10, SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64)} ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() - grant, err := server.RequestUpload(ctx, &agentv1.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) + grant, err := server.RequestUpload(ctx, &agentpb.RequestUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a"}) if err != nil || grant.GetGrant() == nil { t.Fatalf("grant: %v", err) } - request := &agentv1.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} + request := &agentpb.CompleteUploadRequest{Meta: meta, Binding: binding, Asset: asset, UploadId: "upload-a", UploadedSizeBytes: 4, UploadedChecksumSha256: asset.ChecksumSha256} if _, err := server.CompleteUpload(ctx, request); status.Code(err) != codes.Unavailable { t.Fatalf("premature completion: %v", err) } @@ -158,7 +158,7 @@ func TestLocalUploadNoticeSurvivesUnroutableAndRestart(t *testing.T) { t.Fatal(err) } response, err := server.CompleteUpload(ctx, request) - if err != nil || response.GetState() != agentv1.UploadState_UPLOAD_STATE_COMPLETED { + if err != nil || response.GetState() != agentpb.UploadState_UPLOAD_STATE_COMPLETED { t.Fatalf("completion: %v", err) } for delivery := 0; delivery < 2; delivery++ { diff --git a/internal/rpc/upload_test.go b/internal/rpc/upload_test.go index a4d7c47..fba59a8 100644 --- a/internal/rpc/upload_test.go +++ b/internal/rpc/upload_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" @@ -16,20 +16,20 @@ func TestUploadBindingAndExpiryGuards(t *testing.T) { now := time.Unix(100, 0) server := NewServer(ServerOptions{ Now: func() time.Time { return now }, - UploadPolicy: &agentv1.UploadPolicy{Enabled: true, MaxAssetBytes: 1024}, + UploadPolicy: &agentpb.UploadPolicy{Enabled: true, MaxAssetBytes: 1024}, }) - _, err := server.ActivateAgent(context.Background(), &agentv1.ActivateAgentRequest{ + _, err := server.ActivateAgent(context.Background(), &agentpb.ActivateAgentRequest{ Meta: testMeta("activate-upload", "", 0), - Binding: &agentv1.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, + Binding: &agentpb.AgentBinding{AgentId: "agent-1", CellId: "cell-1", ExpectedBootId: "boot-1", DispatcherEpoch: "epoch-1", SessionGeneration: 1}, ActivationOperationId: "activate-upload", SessionExpiresAtUnixMs: now.Add(time.Hour).UnixMilli(), }) if err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: "execution-upload", TaskId: "task-upload", TaskItemId: "item-upload", TaskRevision: 1} - asset := &agentv1.AssetDescriptor{Kind: agentv1.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-upload", ExecutionId: binding.ExecutionId, Format: "wav", SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64), Channels: 1, SampleRateHz: 16000, DurationMs: 1} - request := &agentv1.RequestUploadRequest{Meta: testMeta("upload-request", "upload-request-key", 1), Binding: binding, Asset: asset, UploadId: "upload-binding"} + binding := &agentpb.ExecutionBinding{TenantId: "tenant-1", TenantKey: "tenant-demo-key", ExecutionId: "execution-upload", TaskId: "task-upload", TaskItemId: "item-upload", TaskRevision: 1} + asset := &agentpb.AssetDescriptor{Kind: agentpb.AssetKind_ASSET_KIND_RECORDING, AssetId: "recording-upload", ExecutionId: binding.ExecutionId, Format: "wav", SizeBytes: 4, ChecksumSha256: strings.Repeat("a", 64), Channels: 1, SampleRateHz: 16000, DurationMs: 1} + request := &agentpb.RequestUploadRequest{Meta: testMeta("upload-request", "upload-request-key", 1), Binding: binding, Asset: asset, UploadId: "upload-binding"} created, err := server.RequestUpload(context.Background(), request) if err != nil { t.Fatal(err) @@ -38,20 +38,20 @@ func TestUploadBindingAndExpiryGuards(t *testing.T) { t.Fatalf("invalid grant: %+v", created.Grant) } - mismatched := proto.Clone(request).(*agentv1.RequestUploadRequest) + mismatched := proto.Clone(request).(*agentpb.RequestUploadRequest) mismatched.Meta = testMeta("upload-conflict", "upload-conflict-key", 1) - mismatched.Binding = proto.Clone(binding).(*agentv1.ExecutionBinding) + mismatched.Binding = proto.Clone(binding).(*agentpb.ExecutionBinding) mismatched.Binding.ExecutionId = "other-execution" conflict, err := server.RequestUpload(context.Background(), mismatched) if err != nil { t.Fatal(err) } - if conflict.Receipt == nil || conflict.Receipt.Result != agentv1.ResultCode_RESULT_CODE_CONFLICT { + if conflict.Receipt == nil || conflict.Receipt.Result != agentpb.ResultCode_RESULT_CODE_CONFLICT { t.Fatalf("unexpected upload conflict: %+v", conflict) } now = now.Add(6 * time.Minute) - completed, err := server.CompleteUpload(context.Background(), &agentv1.CompleteUploadRequest{ + completed, err := server.CompleteUpload(context.Background(), &agentpb.CompleteUploadRequest{ Meta: testMeta("upload-complete-expired", "upload-complete-expired-key", 1), Binding: binding, Asset: asset, @@ -62,7 +62,7 @@ func TestUploadBindingAndExpiryGuards(t *testing.T) { if err != nil { t.Fatal(err) } - if completed.Receipt == nil || completed.Receipt.Result != agentv1.ResultCode_RESULT_CODE_REJECTED || completed.Receipt.Failure == nil || completed.Receipt.Failure.Code != agentv1.FailureCode_FAILURE_CODE_FAILED_PRECONDITION { + if completed.Receipt == nil || completed.Receipt.Result != agentpb.ResultCode_RESULT_CODE_REJECTED || completed.Receipt.Failure == nil || completed.Receipt.Failure.Code != agentpb.FailureCode_FAILURE_CODE_FAILED_PRECONDITION { t.Fatalf("unexpected expired completion: %+v", completed) } if status.Code(err) != codes.OK { diff --git a/internal/store/active_task_controls.go b/internal/store/active_task_controls.go index b69346f..ea829fe 100644 --- a/internal/store/active_task_controls.go +++ b/internal/store/active_task_controls.go @@ -3,7 +3,7 @@ package store import ( "errors" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/protobuf/proto" ) @@ -11,7 +11,7 @@ type ActiveTaskExecutionControl struct { ExecutionID string Status string AgentID string - Binding *agentv1.ExecutionBinding + Binding *agentpb.ExecutionBinding } // ActiveTaskExecutionControls returns only reserved or in-flight executions @@ -38,7 +38,7 @@ func (s *Store) ActiveTaskExecutionControls(tenantID, tenantKey, taskID string) if err := rows.Scan(&target.ExecutionID, &target.Status, &target.AgentID, &encoded); err != nil { return nil, err } - binding := &agentv1.ExecutionBinding{} + binding := &agentpb.ExecutionBinding{} if err := proto.Unmarshal(encoded, binding); err != nil { return nil, err } diff --git a/internal/store/control_ack_test.go b/internal/store/control_ack_test.go index a327430..866e8bc 100644 --- a/internal/store/control_ack_test.go +++ b/internal/store/control_ack_test.go @@ -5,7 +5,7 @@ import ( "time" "git.ipao.vip/rogee/go-sip/contracts" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/tenant" ) @@ -39,7 +39,7 @@ func TestControlAcknowledgementCommitsFinalReceiptOnce(t *testing.T) { if err := s.Reserve("reservation-a", payload.ExecutionID, envelope.TenantKey, []string{"global"}); err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} if err := s.BindExecutionAgent("agent-a", binding); err != nil { t.Fatal(err) } diff --git a/internal/store/control_pending.go b/internal/store/control_pending.go index cc6c134..3c63364 100644 --- a/internal/store/control_pending.go +++ b/internal/store/control_pending.go @@ -4,14 +4,14 @@ import ( "database/sql" "errors" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/protobuf/proto" ) type PendingTaskControl struct { TenantID, CommandID, ExecutionID, AgentID, Action, Policy string ExpectedRevision int64 - Binding *agentv1.ExecutionBinding + Binding *agentpb.ExecutionBinding } // PendingTaskControls includes unroutable targets rather than silently dropping @@ -38,7 +38,7 @@ func (s *Store) PendingTaskControls(limit int) ([]PendingTaskControl, error) { } if agentID.Valid { item.AgentID = agentID.String - item.Binding = &agentv1.ExecutionBinding{} + item.Binding = &agentpb.ExecutionBinding{} if err := proto.Unmarshal(raw, item.Binding); err != nil { return nil, err } diff --git a/internal/store/control_routes.go b/internal/store/control_routes.go index 7693c20..4607afa 100644 --- a/internal/store/control_routes.go +++ b/internal/store/control_routes.go @@ -5,13 +5,13 @@ import ( "database/sql" "errors" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "google.golang.org/protobuf/proto" ) // BindExecutionAgent records the controlled endpoint identity before any remote // execution. An execution may not be reassigned after a lost response. -func (s *Store) BindExecutionAgent(agentID string, binding *agentv1.ExecutionBinding) error { +func (s *Store) BindExecutionAgent(agentID string, binding *agentpb.ExecutionBinding) error { if err := validateExecutionAgentBinding(agentID, binding); err != nil { return err } @@ -28,7 +28,7 @@ func (s *Store) BindExecutionAgent(agentID string, binding *agentv1.ExecutionBin return tx.Commit() } -func validateExecutionAgentBinding(agentID string, binding *agentv1.ExecutionBinding) error { +func validateExecutionAgentBinding(agentID string, binding *agentpb.ExecutionBinding) error { if agentID == "" || binding == nil { return errors.New("agent and execution binding are required") } @@ -37,7 +37,7 @@ func validateExecutionAgentBinding(agentID string, binding *agentv1.ExecutionBin // bindExecutionAgentTx is shared by the legacy control route and the local // Mock origination claim, which must commit its Agent assignment atomically. -func bindExecutionAgentTx(tx *sql.Tx, agentID string, binding *agentv1.ExecutionBinding) error { +func bindExecutionAgentTx(tx *sql.Tx, agentID string, binding *agentpb.ExecutionBinding) error { encoded, err := (proto.MarshalOptions{Deterministic: true}).Marshal(binding) if err != nil { return err diff --git a/internal/store/control_routes_test.go b/internal/store/control_routes_test.go index f7b3de5..6a4ff16 100644 --- a/internal/store/control_routes_test.go +++ b/internal/store/control_routes_test.go @@ -3,7 +3,7 @@ package store import ( "testing" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/testfixture" ) @@ -21,7 +21,7 @@ func TestActiveTaskExecutionControlsReturnsOnlyBoundNonterminalExecutions(t *tes if _, err := s.IngestCommand(raw, testfixture.InboundKey(envelope.TenantKey)); err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} if err := s.SetQuota("global", 1); err != nil { t.Fatal(err) } @@ -57,7 +57,7 @@ func TestExecutionRouteRequiresReservedMatchingTask(t *testing.T) { if _, err := s.IngestCommand(raw, testfixture.InboundKey(envelope.TenantKey)); err != nil { t.Fatal(err) } - binding := &agentv1.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} + binding := &agentpb.ExecutionBinding{TenantId: envelope.TenantID, TenantKey: envelope.TenantKey, TaskId: payload.TaskID, TaskItemId: payload.TaskItemID, TaskRevision: payload.TaskRevision, ExecutionId: payload.ExecutionID, AgentVersionId: payload.AgentVersionID, RoutePolicyId: payload.RoutePolicyID, CallerProfileId: payload.CallerProfileID} if err := s.BindExecutionAgent("agent-a", binding); err == nil { t.Fatal("unreserved task dispatched") } diff --git a/internal/store/local_origination.go b/internal/store/local_origination.go index afb0200..9301278 100644 --- a/internal/store/local_origination.go +++ b/internal/store/local_origination.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) var ErrLocalOriginationNotAuthorized = errors.New("local execution is not authorized for origination") @@ -86,7 +86,7 @@ func validateLocalOriginationCandidate(candidate *LocalOriginationCandidate, sna // ClaimLocalOrigination commits the one-shot dial decision and its Agent // control route together. A crash between them must not leave an unaddressable // in-flight call. The admission reservation is not debited a second time. -func (s *Store) ClaimLocalOrigination(dispatcherID, executionID, agentID string, binding *agentv1.ExecutionBinding, decidedAt time.Time) error { +func (s *Store) ClaimLocalOrigination(dispatcherID, executionID, agentID string, binding *agentpb.ExecutionBinding, decidedAt time.Time) error { if decidedAt.IsZero() || binding == nil || binding.ExecutionId != executionID || binding.AttemptId != executionID || agentID == "" { return ErrLocalOriginationNotAuthorized } diff --git a/internal/store/local_origination_test.go b/internal/store/local_origination_test.go index e58bb2d..d33802c 100644 --- a/internal/store/local_origination_test.go +++ b/internal/store/local_origination_test.go @@ -10,12 +10,12 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) -func localTestOriginationBinding(t *testing.T, st *Store, executionID string) *agentv1.ExecutionBinding { +func localTestOriginationBinding(t *testing.T, st *Store, executionID string) *agentpb.ExecutionBinding { t.Helper() - binding := &agentv1.ExecutionBinding{ExecutionId: executionID, AttemptId: executionID} + binding := &agentpb.ExecutionBinding{ExecutionId: executionID, AttemptId: executionID} if err := st.DB().QueryRow(`SELECT tenant_id,tenant_key,task_id,task_item_id,task_revision,agent_version_id,route_policy_id,caller_profile_id FROM tasks WHERE execution_id=?`, executionID).Scan( &binding.TenantId, &binding.TenantKey, &binding.TaskId, &binding.TaskItemId, &binding.TaskRevision, &binding.AgentVersionId, &binding.RoutePolicyId, &binding.CallerProfileId, diff --git a/internal/store/local_recording_failure_fact.go b/internal/store/local_recording_failure_fact.go index 2417c2f..6ac0fdc 100644 --- a/internal/store/local_recording_failure_fact.go +++ b/internal/store/local_recording_failure_fact.go @@ -9,7 +9,7 @@ import ( "fmt" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) // RecordLocalRecordingFailureFact binds one authenticated Mock failure fact to @@ -19,7 +19,7 @@ import ( func (s *Store) RecordLocalRecordingFailureFact(record ExecutionFactRecord, outcome LocalRecordingOutcome) (bool, error) { if record.FactID == "" || record.TenantID == "" || record.TenantKey == "" || record.ExecutionID == "" || record.SourceBootID == "" || record.SourceSequence == 0 || len(record.BindingJSON) == 0 || len(record.PayloadJSON) == 0 || - record.Kind != int32(agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS) { + record.Kind != int32(agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS) { return false, errors.New("Mock recording failure requires a bound execution fact") } if outcome.Status != "unavailable" || diff --git a/internal/store/local_recording_failure_fact_test.go b/internal/store/local_recording_failure_fact_test.go index 0a46769..8d2f99a 100644 --- a/internal/store/local_recording_failure_fact_test.go +++ b/internal/store/local_recording_failure_fact_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - agentv1 "git.ipao.vip/rogee/go-sip/gen/agent/v1" + agentpb "git.ipao.vip/rogee/go-sip/gen/agent" ) func localFailureFactFixture(terminal LocalCallTerminal) (ExecutionFactRecord, LocalRecordingOutcome) { @@ -16,7 +16,7 @@ func localFailureFactFixture(terminal LocalCallTerminal) (ExecutionFactRecord, L observed := terminal.EndedAt.Add(time.Second) return ExecutionFactRecord{ FactID: "failure-fact-a", TenantID: "tenant-a", TenantKey: "tenant-a", ExecutionID: terminal.ExecutionID, - ContentSHA256: hex.EncodeToString(sum[:]), Kind: int32(agentv1.FactKind_FACT_KIND_RECORDING_PROGRESS), + ContentSHA256: hex.EncodeToString(sum[:]), Kind: int32(agentpb.FactKind_FACT_KIND_RECORDING_PROGRESS), BindingJSON: []byte(`{"tenantId":"tenant-a","tenantKey":"tenant-a","executionId":"` + terminal.ExecutionID + `"}`), PayloadJSON: payload, ObservedAt: observed, SourceBootID: "boot-a", SourceSequence: 1, }, LocalRecordingOutcome{Status: "unavailable", ErrorCode: "upload_failed", ObservedAt: observed} diff --git a/proto/ERRORS.md b/proto/ERRORS.md index 5ed7be6..325efea 100644 --- a/proto/ERRORS.md +++ b/proto/ERRORS.md @@ -1,7 +1,8 @@ # W02 error, idempotency, and fencing contract -This document is part of the `agent.v1` project-owned baseline. It does not -change the SaaS/MQ contract. +This document belongs to the current Agent gRPC contract. The package name is +not a protocol version; `RequestMeta.protocol_version` remains meaningful. It +does not change the SaaS/MQ contract. ## Transport and domain errors diff --git a/proto/README.md b/proto/README.md index 36d77df..18fe5bd 100644 --- a/proto/README.md +++ b/proto/README.md @@ -1,4 +1,4 @@ -# W02 Unary gRPC contract +# Agent Unary gRPC contract This directory is the project-owned W02 protocol baseline, created from the confirmed R01–R03/R05/R07–R13 responsibilities in `docs/contracts/通信与事件数据交互_v0.1.md` @@ -32,8 +32,9 @@ buf breaking --against '.git#branch=HEAD' buf generate ``` -The protocol is versioned by the `agent.v1` package and the `protocol_version` -metadata. Field numbers are never reused. Production mTLS credentials and +The Proto/Go package has no implementation-generation suffix. The existing +`protocol_version` metadata (`agent.v1`) remains the meaningful wire-protocol +version; field numbers are never reused. Production mTLS credentials and endpoints are deployment inputs, not repository contents. `ERRORS.md` and the Proto are released together; a field or semantic change requires a new compatibility review. diff --git a/proto/agent/v1/agent.proto b/proto/agent/agent.proto similarity index 99% rename from proto/agent/v1/agent.proto rename to proto/agent/agent.proto index 323947f..08473bb 100644 --- a/proto/agent/v1/agent.proto +++ b/proto/agent/agent.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package agent.v1; +package agent; -option go_package = "git.ipao.vip/rogee/go-sip/gen/agent/v1;agentv1"; +option go_package = "git.ipao.vip/rogee/go-sip/gen/agent;agentpb"; // AgentControl is the project-owned Unary gRPC boundary between the single // active Dispatcher and a Cell Agent. It carries metadata and facts, never diff --git a/proto/manifest.json b/proto/manifest.json index 6e94316..10553ca 100644 --- a/proto/manifest.json +++ b/proto/manifest.json @@ -1,5 +1,5 @@ { - "package": "agent.v1", + "package": "agent", "service": "AgentControlService", "status": "project-owned-development-baseline", "external_authority": false, @@ -19,33 +19,33 @@ }, { "path": "buf.yaml", - "bytes": 100, - "sha256": "62e59b0299c930c1eb5324c8a139232dd59109c4f8dbac577bc7ca0f8627d96b" + "bytes": 280, + "sha256": "6fc8b891946fa35012a1350d8c2080e5e41989b701c30bd65635c92d9f42205c" }, { "path": "proto/ERRORS.md", - "bytes": 5664, - "sha256": "98db6c9d568a06ce6506fbd880758ecdf22323c57fd7c76e77a39c571ffe1be5" + "bytes": 5753, + "sha256": "6edd6342ef91c5b04b766e4d82ab003ecb9dc35daab6cf2b6f5b477d7a3ae80d" }, { "path": "proto/README.md", - "bytes": 2102, - "sha256": "730e2940a887f541527767f9fe68e3f437285d7c91447a1ef74498438a2ec68d" + "bytes": 2177, + "sha256": "e6bc250385672025366c14be356deaa26b630ada2f0642370636d8c0afd0b39d" }, { - "path": "proto/agent/v1/agent.proto", - "bytes": 12029, - "sha256": "f126aa941b06b31c45f31bceb8d5355ddf24d571856b09ef6a7a193aedca88c9" + "path": "proto/agent/agent.proto", + "bytes": 12023, + "sha256": "05ec234377e63d8dab90567fd2ef3373b7ac5eb3d492c302869aea0000a1d5c3" }, { - "path": "gen/agent/v1/agent.pb.go", - "bytes": 151876, - "sha256": "d68179699408f850eb54c115239276389f3bb7d42cfa4b936b43c6ca6e9cb452" + "path": "gen/agent/agent.pb.go", + "bytes": 150228, + "sha256": "d61403f7e88de4bb17dc2ac71c49e71787e4ea8765a74c4f1f2edbaeed50176e" }, { - "path": "gen/agent/v1/agent_grpc.pb.go", - "bytes": 25021, - "sha256": "dade4714efcbbf13ed761db9c4480639300780eae74abfe7a4ea16a8847135e6" + "path": "gen/agent/agent_grpc.pb.go", + "bytes": 24988, + "sha256": "90f16296e10ad1b4114bb602608c3f24b66e1b5dc5046bbbe0a3822ef41faec4" } ] } diff --git a/scripts/check-proto.sh b/scripts/check-proto.sh index 42f7c15..a64fd8e 100755 --- a/scripts/check-proto.sh +++ b/scripts/check-proto.sh @@ -7,7 +7,7 @@ cd "$root" buf lint buf build --error-format=json >/dev/null buf generate -go test ./gen/agent/v1 +go test ./gen/agent python3 - <<'PY' from hashlib import sha256