<commit_before>// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.internal.federatedcompute.v1;

import "google/api/annotations.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/duration.proto";
import "google/rpc/code.proto";
import "fcp/protos/federated_api.proto";
import "fcp/protos/federatedcompute/common.proto";

option java_package = "com.google.internal.federatedcompute.v1";
option java_multiple_files = true;

service TaskAssignments {
  // A request sent by the device to check if it should participate in the
  // current phase.
  //
  // Clients should use the same `ForwardingInfo` (incl. the headers) as used in
  // this request to construct the URI to poll the operation service to check
  // for task assignment completion.
  //
  // When the task assignment is complete, the result of the operation will
  // either contain an error or the resulting `StartTaskAssignmentResponse` in
  // the response.
  //
  // If the client no longer needs a task assignment because it is interrupted
  // or drops out or an error occurs during polling the long running operation,
  // the client should make a best effort to call CancelOperation.
  //
  // If the returned operation is not complete, clients should poll for status
  // at the rate specified in the StartTaskAssignmentMetadata.
  rpc StartTaskAssignment(StartTaskAssignmentRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/populations/{population_name}/taskassignments/{session_id}:start"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "StartTaskAssignmentResponse"
      metadata_type: "StartTaskAssignmentMetadata"
    };
  }

  // A request sent by the device to report the result of running the task
  // provided by `StartTaskAssignmentResponse`.
  //
  // Clients should use the same `ForwardingInfo` as used in the
  // `StartTaskAssignment` request to construct the URI for this request.
  //
  // A result with a status code other than Code.OK indicates client session
  // termination. The client may not send any future requests with the given
  // session_id.
  rpc ReportTaskResult(ReportTaskResultRequest)
      returns (ReportTaskResultResponse) {
    option (google.api.http) = {
      post: "/v1/populations/{population_name}/taskassignments/{session_id}:reportresult"
      body: "*"
    };
  }
}

message StartTaskAssignmentRequest {
  // The name of the population this client belongs to.
  //
  // Note that http clients set this value in the request URL instead of the
  // request body.
  string population_name = 1
      ;

  // The session id returned by the server.
  //
  // Note that http clients set this value in the request URL instead of the
  // request body.
  string session_id = 2
      ;

  reserved 3;

  ClientVersion client_version = 4;

  // The client computes this message using the task returned by a previous
  // `RequestEligibilityEvalTask` call.
  //
  // If this field is set, it describes to the server which tasks the client is
  // (in)eligible. The server must take this information into account when
  // deciding task to serve in response to this request.
  //
  // If this field is unset, it may indicate that the client previously received
  // an `EligibilityEvalTask` without an `EligibilityEvalPayload` message (i.e.
  // the population did not have an eligibility-computing task configured at the
  // time of the request). It may also indicate a client for which the
  // eligibility-computing task feature has been disabled, or an old client that
  // does not support this feature yet.
  //
  // If this field is unset but the population has an eligibility-computing task
  // configured, then the server must reject this client, since the server has
  // no way to determine which tasks the client is (in)eligible for.
  //
  // If this field is unset and the population does not have an
  // eligibility-computing task configured, then the server may serve this
  // client any task.
  //
  google.internal.federatedml.v2.TaskEligibilityInfo task_eligibility_info = 5;

  // The client's capabilities when downloading and processing resources.
  ResourceCapabilities resource_capabilities = 6;
}

message StartTaskAssignmentMetadata {
  // The suggested duration between instances of polling the StartTaskAssignment
  // LRO.
  google.protobuf.Duration polling_interval = 1;
}

message StartTaskAssignmentResponse {
  // One of two outcomes, depending on server's decision on participation of the
  // client.
  oneof result {
    // If the client joined the phase with this call, information how
    // to proceed.
    TaskAssignment task_assignment = 1;

    // If the client was not accepted, information how to proceed.
    RejectionInfo rejection_info = 2;
  }
}

// When client (device) is accepted for the current phase, this
// data structure carries information necessary to begin task execution.
message TaskAssignment {
  // Information to construct the URI to use for providing resulting aggregation
  // data after task execution.
  ForwardingInfo aggregation_data_forwarding_info = 1;

  // Unique identifier for the client's protocol session.
  string session_id = 5;

  // The opaque id of the aggregation session the client has joined. This is a
  // string generated by the server and MUST NOT contain any information that
  // could be used to identify a specific device.<commit_msg>Populate minimum_clients_in_server_visible_aggregate in TaskAssignment.<commit_after>// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.internal.federatedcompute.v1;

import "google/api/annotations.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/duration.proto";
import "google/rpc/code.proto";
import "fcp/protos/federated_api.proto";
import "fcp/protos/federatedcompute/common.proto";

option java_package = "com.google.internal.federatedcompute.v1";
option java_multiple_files = true;

service TaskAssignments {
  // A request sent by the device to check if it should participate in the
  // current phase.
  //
  // Clients should use the same `ForwardingInfo` (incl. the headers) as used in
  // this request to construct the URI to poll the operation service to check
  // for task assignment completion.
  //
  // When the task assignment is complete, the result of the operation will
  // either contain an error or the resulting `StartTaskAssignmentResponse` in
  // the response.
  //
  // If the client no longer needs a task assignment because it is interrupted
  // or drops out or an error occurs during polling the long running operation,
  // the client should make a best effort to call CancelOperation.
  //
  // If the returned operation is not complete, clients should poll for status
  // at the rate specified in the StartTaskAssignmentMetadata.
  rpc StartTaskAssignment(StartTaskAssignmentRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/populations/{population_name}/taskassignments/{session_id}:start"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "StartTaskAssignmentResponse"
      metadata_type: "StartTaskAssignmentMetadata"
    };
  }

  // A request sent by the device to report the result of running the task
  // provided by `StartTaskAssignmentResponse`.
  //
  // Clients should use the same `ForwardingInfo` as used in the
  // `StartTaskAssignment` request to construct the URI for this request.
  //
  // A result with a status code other than Code.OK indicates client session
  // termination. The client may not send any future requests with the given
  // session_id.
  rpc ReportTaskResult(ReportTaskResultRequest)
      returns (ReportTaskResultResponse) {
    option (google.api.http) = {
      post: "/v1/populations/{population_name}/taskassignments/{session_id}:reportresult"
      body: "*"
    };
  }
}

message StartTaskAssignmentRequest {
  // The name of the population this client belongs to.
  //
  // Note that http clients set this value in the request URL instead of the
  // request body.
  string population_name = 1
      ;

  // The session id returned by the server.
  //
  // Note that http clients set this value in the request URL instead of the
  // request body.
  string session_id = 2
      ;

  reserved 3;

  ClientVersion client_version = 4;

  // The client computes this message using the task returned by a previous
  // `RequestEligibilityEvalTask` call.
  //
  // If this field is set, it describes to the server which tasks the client is
  // (in)eligible. The server must take this information into account when
  // deciding task to serve in response to this request.
  //
  // If this field is unset, it may indicate that the client previously received
  // an `EligibilityEvalTask` without an `EligibilityEvalPayload` message (i.e.
  // the population did not have an eligibility-computing task configured at the
  // time of the request). It may also indicate a client for which the
  // eligibility-computing task feature has been disabled, or an old client that
  // does not support this feature yet.
  //
  // If this field is unset but the population has an eligibility-computing task
  // configured, then the server must reject this client, since the server has
  // no way to determine which tasks the client is (in)eligible for.
  //
  // If this field is unset and the population does not have an
  // eligibility-computing task configured, then the server may serve this
  // client any task.
  //
  google.internal.federatedml.v2.TaskEligibilityInfo task_eligibility_info = 5;

  // The client's capabilities when downloading and processing resources.
  ResourceCapabilities resource_capabilities = 6;
}

message StartTaskAssignmentMetadata {
  // The suggested duration between instances of polling the StartTaskAssignment
  // LRO.
  google.protobuf.Duration polling_interval = 1;
}

message StartTaskAssignmentResponse {
  // One of two outcomes, depending on server's decision on participation of the
  // client.
  oneof result {
    // If the client joined the phase with this call, information how
    // to proceed.
    TaskAssignment task_assignment = 1;

    // If the client was not accepted, information how to proceed.
    RejectionInfo rejection_info = 2;
  }
}

// When client (device) is accepted for the current phase, this
// data structure carries information necessary to begin task execution.
message TaskAssignment {
  // Information to construct the URI to use for providing resulting aggregation
  // data after task execution.
  ForwardingInfo aggregation_data_forwarding_info = 1;

  message AggregationInfo {}

  message SecureAggregationInfo {
    // The minimum number of clients' values that must be aggregated together
    // before the server can gain access to the aggregate,
    // even transiently (e.g. in RAM).
    // This isn't needed by Secure Aggregation protocol on the client side but
    // shared by the server with clients for transparency or policy reasons.
    int32 minimum_clients_in_server_visible_aggregate = 1;
  }

  oneof aggregation_type {
    // If set, indicates that the Aggregations service (see
    // `aggregations.proto`) should be used to perform aggregation.
    AggregationInfo aggregation_info = 9;

    // If set, indicates that the SecureAggregations service (see
    // `secure_aggregations.proto`) should be used to perform aggregation.
    SecureAggregationInfo secure_aggregation_info = 10;
  }

  // Unique identifier for the client's protocol session.
  string session_id = 5;

  // The opaque id of the aggregation session the client has joined. This is a
  // string generated by the server and MUST NOT contain any information that
  // could be used to identify a specific device.
{'fraction_non_alphanumeric': 0.0730319803198032, 'fraction_numerical': 0.004305043050430504, 'mean_word_length': 3.3698354047699026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1882386', 'n_tokens_mistral': 3430, 'n_tokens_neox': 3310, 'n_words': 1499}