<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.
 */

package com.google.android.libraries.pcc.policies.federatedcompute

/** Safecomms FederatedCompute policy. */
val SafecommsPolicy_FederatedCompute =
  flavoredPolicies(
    name = "SafecommsPolicy_FederatedCompute",
    policyType = MonitorOrImproveUserExperienceWithFederatedCompute,
  ) {
    description =
      """
      To improve phishing detection for messaging apps.

      ALLOWED EGRESSES: FederatedCompute.
      ALLOWED USAGES: Federated analytics, federated learning.
    """.trimIndent()

    flavors(Flavor.ASI_PROD) { minRoundSize(minRoundSize = 1000, minSecAggRoundSize = 0) }
    consentRequiredForCollectionOrStorage(Consent.UsageAndDiagnosticsCheckbox)
    presubmitReviewRequired(OwnersApprovalOnly)
    checkpointMaxTtlDays(720)

    target(SAFECOMMS_ENTITY_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "isContact" { rawUsage(UsageType.ANY) }
      "isFirstMessageFromSender" { rawUsage(UsageType.ANY) }
      "hasUrl" { rawUsage(UsageType.ANY) }
      "hasEmail" { rawUsage(UsageType.ANY) }
      "hasPhoneNumber" { rawUsage(UsageType.ANY) }
      "hasCurrencySymbol" { rawUsage(UsageType.ANY) }
      "packageName" {
        conditionalUsage("top2000PackageNamesWith2000Wau", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "messageLength" { rawUsage(UsageType.ANY) }
      "featureInteraction" { rawUsage(UsageType.ANY) }
      "userInteraction" { rawUsage(UsageType.ANY) }
      "modelVersion" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_CONVERSATION_ENTITY_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "id" { rawUsage(UsageType.JOIN) }
      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "packageName" {
        conditionalUsage("top2000PackageNamesWith2000Wau", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "riskType" { rawUsage(UsageType.ANY) }
      "verdict" { rawUsage(UsageType.ANY) }
      "lastMessageSource" { rawUsage(UsageType.ANY) }
      "predictedValue" { rawUsage(UsageType.ANY) }
      "modelVersion" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_UI_EVENT_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "timestampInMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "conversationEntityId" { rawUsage(UsageType.ANY) }
      "uiScreen" { rawUsage(UsageType.ANY) }
      "uiEvent" { rawUsage(UsageType.ANY) }
    }
  }<commit_msg>#safecomms: Simple storage Sql policy update, adding SafecommsAnalyzerEntities table.<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.
 */

package com.google.android.libraries.pcc.policies.federatedcompute

/** Safecomms FederatedCompute policy. */
val SafecommsPolicy_FederatedCompute =
  flavoredPolicies(
    name = "SafecommsPolicy_FederatedCompute",
    policyType = MonitorOrImproveUserExperienceWithFederatedCompute,
  ) {
    description =
      """
      To improve phishing detection for messaging apps.

      ALLOWED EGRESSES: FederatedCompute.
      ALLOWED USAGES: Federated analytics, federated learning.
    """.trimIndent()

    flavors(Flavor.ASI_PROD) { minRoundSize(minRoundSize = 1000, minSecAggRoundSize = 0) }
    consentRequiredForCollectionOrStorage(Consent.UsageAndDiagnosticsCheckbox)
    presubmitReviewRequired(OwnersApprovalOnly)
    checkpointMaxTtlDays(720)

    target(SAFECOMMS_ENTITY_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "isContact" { rawUsage(UsageType.ANY) }
      "isFirstMessageFromSender" { rawUsage(UsageType.ANY) }
      "hasUrl" { rawUsage(UsageType.ANY) }
      "hasEmail" { rawUsage(UsageType.ANY) }
      "hasPhoneNumber" { rawUsage(UsageType.ANY) }
      "hasCurrencySymbol" { rawUsage(UsageType.ANY) }
      "packageName" {
        conditionalUsage("top2000PackageNamesWith2000Wau", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "messageLength" { rawUsage(UsageType.ANY) }
      "featureInteraction" { rawUsage(UsageType.ANY) }
      "userInteraction" { rawUsage(UsageType.ANY) }
      "modelVersion" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_CONVERSATION_ENTITY_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "id" { rawUsage(UsageType.JOIN) }
      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "packageName" {
        conditionalUsage("top2000PackageNamesWith2000Wau", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "riskType" { rawUsage(UsageType.ANY) }
      "verdict" { rawUsage(UsageType.ANY) }
      "lastMessageSource" { rawUsage(UsageType.ANY) }
      "predictedValue" { rawUsage(UsageType.ANY) }
      "modelVersion" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_UI_EVENT_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "timestampInMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "conversationEntityId" { rawUsage(UsageType.ANY) }
      "uiScreen" { rawUsage(UsageType.ANY) }
      "uiEvent" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_FEATURE_STATUS_CHANGE_EVENT_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "featureEnabled" { rawUsage(UsageType.ANY) }
      "featureDisableReason" { rawUsage(UsageType.ANY) }
    }

    target(SAFECOMMS_ANALYZER_ENTITY_GENERATED_DTD, maxAge = Duration.ofDays(14)) {
      retention(StorageMedium.RAM)
      retention(StorageMedium.DISK)

      "conversationEntityId" { rawUsage(UsageType.ANY) }
      "packageName" {
        conditionalUsage("top2000PackageNamesWith2000Wau", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "timestampMillis" {
        conditionalUsage("truncatedToDays", UsageType.ANY)
        rawUsage(UsageType.JOIN)
      }
      "verdict" { rawUsage(UsageType.ANY) }
      "predictedValue" { rawUsage(UsageType.ANY) }
      "modelVersion" { rawUsage(UsageType.ANY) }
    }
  }
{'fraction_non_alphanumeric': 0.10020015011258444, 'fraction_numerical': 0.011008256192144109, 'mean_word_length': 3.5685714285714285, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6276922', 'n_tokens_mistral': 2620, 'n_tokens_neox': 2456, 'n_words': 430}