// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

edition = "2023";

package optimization_guide.proto;

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.features.proto";

option java_outer_classname = "AtMemoryProto";

// DO NOT EDIT THIS FILE DIRECTLY!
//
// This file is generated in g3 and then synced to Chrome. Instead, please refer to
// http://go/chrome-mqls-onboarding (Google-internal link), and then changes will
// be synced with Chrome automatically.

message AtMemoryLoggingData {
  AtMemoryQuality quality = 1 [features = { field_presence: EXPLICIT }];
}

message AtMemoryQuality {
  // The query that was entered by the user.
  string query = 1 [features = { field_presence: EXPLICIT }];

  // The session id of the user query. Use this to join with AtMemoryQuality
  // protos from the same session.
  string session_id = 2 [features = { field_presence: EXPLICIT }];

  // The title of the page the user was on when they entered the query.
  string title = 3 [features = { field_presence: EXPLICIT }];

  // The URL of the page the user was on when they entered the query.
  string url = 4 [features = { field_presence: EXPLICIT }];

  // The signature of the form the user invoked AtMemory from. See
  // components/autofill/core/common/signatures.cc for more details.
  uint64 form_signature = 5 [features = { field_presence: IMPLICIT }];

  // The signature of the field. This is the hash identifier used to denote this
  // field for query and voting purposes. See
  // components/autofill/core/common/signatures.cc for more details.
  uint64 field_signature = 6 [features = { field_presence: IMPLICIT }];

  // The suggestions that were shown to the user for this query. If none were
  // shown to the user, this will be empty. If there are multiple suggestions,
  // these will be provided in the order that were shown to the user.
  repeated AtMemorySuggestion suggestions = 7;

  // The duration between the query being submitted and the suggestions being
  // shown to the user, even if empty.
  int64 query_submitted_to_suggestions_shown_ms = 8 [features = { field_presence: EXPLICIT }];
}

message AtMemorySuggestion {
  // The action the user took on the suggestion.
  AtMemorySuggestionAction action = 1 [features = { field_presence: EXPLICIT }];

  // The index of the corresponding entry in the AtMemoryQueryResponse results
  // list returned by the Context/Memory service. If the suggestion was not
  // generated by the Context/Memory service, this will be -1.
  int32 response_results_index = 2 [features = { field_presence: EXPLICIT }];

  // The source of the suggestion.
  AtMemorySuggestionSource source = 3 [features = { field_presence: EXPLICIT }];
}

enum AtMemorySuggestionAction {
  AT_MEMORY_SUGGESTION_ACTION_UNSPECIFIED = 0;

  // The user accepted the suggestion, filling with the identified primary
  // attribute.
  AT_MEMORY_SUGGESTION_ACTION_ACCEPTED = 1;

  // The user opened the flyout menu for the suggestion but did not
  // click on any secondary attributes.
  AT_MEMORY_SUGGESTION_ACTION_FLYOUT_MENU_OPENED = 2;

  // The user accepted a suggestion from the flyout menu and filled
  // using one of the identified secondary attributes.
  AT_MEMORY_SUGGESTION_ACTION_FLYOUT_MENU_ATTRIBUTE_ACCEPTED = 3;
}

enum AtMemorySuggestionSource {
  AT_MEMORY_SUGGESTION_SOURCE_UNSPECIFIED = 0;

  // The suggestion was generated by the Context/Memory service.
  AT_MEMORY_SUGGESTION_SOURCE_CONTEXT_MEMORY_SERVICE = 1;

  // The suggestion was generated from local Autofill data.
  AT_MEMORY_SUGGESTION_SOURCE_AUTOFILL = 2;
}
