kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/proto/analysis.proto (about)

     1  /*
     2   * Copyright 2014 The Kythe Authors. All rights reserved.
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *   http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16  
    17  syntax = "proto3";
    18  
    19  package kythe.proto;
    20  
    21  import "google/protobuf/any.proto";
    22  import "google/protobuf/timestamp.proto";
    23  import "kythe/proto/storage.proto";
    24  
    25  option go_package = "kythe.io/kythe/proto/analysis_go_proto";
    26  option java_package = "com.google.devtools.kythe.proto";
    27  option cc_enable_arenas = true;
    28  
    29  // An AnalysisRequest instructs an analyzer to perform an analysis on a single
    30  // CompilationUnit.
    31  message AnalysisRequest {
    32    // The compilation to analyze.
    33    CompilationUnit compilation = 1;
    34  
    35    // The address of a file data service to use.  If this is provided, it should
    36    // be used in preference to any other file data service the analyzer may know
    37    // about for this compilation.
    38    string file_data_service = 2;
    39  
    40    // The revision marker that should be attributed to this compilation.
    41    string revision = 3;
    42  
    43    // An identifier for the current analysis.
    44    string build_id = 4;
    45  
    46    // A digest of the CompilationUnit used for identification.
    47    string compilation_digest = 5;
    48  }
    49  
    50  // AnalysisOutput contains an output artifact for the current analysis taking
    51  // place.  A given analysis may not produce any outputs.  It is okay for an
    52  // indexer to send an empty AnalysisOutput message if needed to keep the RPC
    53  // channel alive; the driver must correctly handle this.
    54  message AnalysisOutput {
    55    // The format of `value` is determined by the analyzer. Kythe language
    56    // indexers emit wire-format kythe.proto.Entry messages.
    57    bytes value = 1;
    58  
    59    // An analyzer may optionally report the final result of analysis by
    60    // populating this field in the last output it emits.
    61    //
    62    // Constraints: If final_result is set, value must be unset, and once a
    63    // final_result has been sent no further outputs may be sent. The driver must
    64    // enforce these constraints by aborting and discarding the request if the
    65    // analyzer sends additional data after the final_result. It is legal for the
    66    // analyzer to omit any final_result, in which case the driver will assume
    67    // that the analysis was completed successfully.
    68    AnalysisResult final_result = 10;
    69  
    70    // TODO(fromberger): Convert these fields to a single oneof, to enforce the
    71    // mutual exclusion explicitly. For now I'm leaving them separate to make it
    72    // easier to migrate existing uses.
    73  }
    74  
    75  // AnalysisResult documents the analyzer's opinion of an analysis request.
    76  message AnalysisResult {
    77    enum Status {
    78      COMPLETE = 0;         // analysis completed successfully without error
    79      INCOMPLETE = 1;       // analysis ended after partial results
    80      INVALID_REQUEST = 2;  // the analysis request was invalid for this analyzer
    81    }
    82  
    83    Status status = 1;   // the status code describing the result
    84    string summary = 2;  // a human-readable error message for use in diagnostics
    85  
    86    // Freeform details from the analyzer
    87    repeated google.protobuf.Any details = 3;
    88  }
    89  
    90  // Describes a single unit of compilation.
    91  message CompilationUnit {
    92    // The base VName for the compilation and any VNames generated from its
    93    // analysis. The `v_name` field does not identify a compilation unit, but
    94    // provides the information the analyzer needs to correctly label the
    95    // entities described by its source. At minimum, this should include the
    96    // `corpus` and `language` the unit belongs to, and if appropriate the
    97    // `root`. The `v_name` of an object in the code is formed by merging its
    98    // specifics into this basis.
    99    //
   100    // This VName also serves as the default basis for any required inputs that
   101    // do not provide their own `v_name` field.  As such, the general logic for
   102    // constructing VNames for entities arising a given source path should be:
   103    // {
   104    //   vname := unit.required_input[path].v_name
   105    //   if vname.corpus is empty
   106    //      vname.corpus := unit.v_name.corpus
   107    //      vname.root := unit.v_name.root
   108    //   if vname.path is empty
   109    //      vname.path := path
   110    // }
   111    // The above applies generally, but specific node kinds may have rules which
   112    // override this logic.
   113    VName v_name = 1;
   114  
   115    reserved 2;
   116  
   117    // All files that might be touched in the course of this compilation.
   118    // Consumers of the CompilationUnit may not assume anything about the order
   119    // of the elements of this field.
   120    repeated FileInput required_input = 3;
   121  
   122    // Set by the extractor to indicate that the original input had compile
   123    // errors. This is used to check validity of the sharded analysis.
   124    bool has_compile_errors = 4;
   125  
   126    // The arguments to pass to a compiler tool for this compilation unit,
   127    // including the compiler executable, flags, and input files.
   128    repeated string argument = 5;
   129  
   130    // Of those files in `required_input`, the ones that this CompilationUnit
   131    // is intended to analyze. This is necessary to support languages like Go,
   132    // where a single translation unit may contain many source files that must all
   133    // be processed at once (while excluding source files that belong to other
   134    // CUs/packages, if any).
   135    repeated string source_file = 6;
   136  
   137    // The output key of the CompilationUnit; for example, the object file that
   138    // it writes.  The output key for a compilation should match the path in the
   139    // FileInfo message of a dependent compilation that consumes its output.
   140    string output_key = 7;
   141  
   142    message FileInput {
   143      // If set, overrides the `v_name` in the `CompilationUnit` for deriving
   144      // VNames during analysis. Values for fields which are not explicitly set
   145      // should be taken from the CompilationUnit's VName or (for path) FileInfo.
   146      VName v_name = 1;
   147  
   148      // The file's metadata. It is invalid to provide a FileInput without both
   149      // the file's path and digest.
   150      FileInfo info = 2;
   151  
   152      reserved 3;
   153  
   154      // Per-language or per-tool details.
   155      repeated google.protobuf.Any details = 4;
   156    }
   157  
   158    // The absolute path of the current working directory where the build tool
   159    // was invoked.  During analysis, a file whose path has working_directory
   160    // plus a path separator as an exact prefix is considered accessible from
   161    // that same path without said prefix.  It is only necessary to set this
   162    // field if the build tool requires it.
   163    string working_directory = 8;
   164  
   165    // For languages that make use of resource contexts (like C++), the context
   166    // that should be initially entered.
   167    // TODO(zarko): What is a "resource context"? Needs a clear definition and/or
   168    // a link to one.
   169    string entry_context = 9;
   170  
   171    // An Env message represents the name and value of a single environment
   172    // variable in the build environment.
   173    message Env {
   174      string name = 1;
   175      string value = 2;
   176    }
   177  
   178    // A collection of environment variables that the build environment expects
   179    // to be set.  As a rule, we only record variables here that must be set to
   180    // specific values for the build to work.  Users of this field may not assume
   181    // anything about the order of values; in particular the pipeline is free to
   182    // sort by name in order to canonicalize the message.
   183    repeated Env environment = 10;
   184  
   185    // Per-language or per-tool details.
   186    repeated google.protobuf.Any details = 11;
   187  }
   188  
   189  // KzipInfo contains a summary of the contents of a kzip. It provides a
   190  // breakdown of files and units by corpus and lanugage.
   191  message KzipInfo {
   192    reserved 2, 3;
   193  
   194    message CorpusInfo {
   195      reserved 1, 2, 3;
   196  
   197      message Inputs {
   198        // TODO(salguarnieri) Add count of unique inputs for this corpus?
   199        int32 count = 1;
   200      }
   201  
   202      message CUInfo {
   203        int32 count = 1;
   204        // Map from java version to number of CUs that make use of that java
   205        // version. Note that if no -source flag is specified for a CU, it will
   206        // not impact this count.
   207        map<int32, int32> java_version_count = 2;
   208      }
   209  
   210      // Map from language to count of required inputs that have this corpus in
   211      // their VName.
   212      map<string, Inputs> language_required_inputs = 4;
   213      // Map from language to count of sources that have this corpus in their
   214      // required_input VName.
   215      map<string, Inputs> language_sources = 5;
   216      // Map from language to count of compilation units that have this corpus in
   217      // their VName.
   218      map<string, CUInfo> language_cu_info = 6;
   219    }
   220  
   221    // Map from corpus name to corpus info.
   222    map<string, CorpusInfo> corpora = 1;
   223    // Size in bytes of all the kzips that contributed to this KzipInfo.
   224    int64 size = 4;
   225  
   226    // The vname paths of required inputs should be relative to the root of the
   227    // repo. This field contains paths that erroneously contain a leading '/'.
   228    repeated string absolute_paths = 6;
   229  
   230    // Error messages detected when computing KzipInfo. For example, source files
   231    // with no corresponding required_input. If there are any items in this field,
   232    // it indicates that this kzip has serious problems and should not be used.
   233    repeated string critical_kzip_errors = 5;
   234  }
   235  
   236  // RepoMetadata provides storage for additional information about a specific
   237  // build from a repository. This message is stored in the
   238  // CompilationUnit.details field.
   239  message BuildMetadata {
   240    // The commit_timestamp is generally the timestamp at which the source for
   241    // this build was checked into version control, but can be any timestamp
   242    // associated with the origin of this build. In the case that a project is
   243    // made up of multiple repositories, this timestamp should be the one
   244    // associated with the primary/super repository.
   245    google.protobuf.Timestamp commit_timestamp = 1;
   246  }
   247  
   248  // A FilesRequest specifies a collection of files to be fetched from a
   249  // FileDataService.
   250  message FilesRequest {
   251    repeated FileInfo files = 1;
   252  }
   253  
   254  // A FileInfo identifies a file used for analysis.
   255  // At least one of the path and digest fields must be non-empty.
   256  message FileInfo {
   257    // The path of the file relative to the working directory of the compilation
   258    // command, which is typically the root of the build.
   259    // For example:
   260    //  file/base/file.cc
   261    //  ../../base/atomic_ref_count.h
   262    string path = 1;
   263  
   264    // The lowercase ascii hex SHA-256 digest of the file contents.
   265    string digest = 2;
   266  }
   267  
   268  // A FileData carries the content of a single file, as returned from the Get
   269  // method of a FileDataService.
   270  message FileData {
   271    // The content of the file, if known.  If missing == true, this field must be
   272    // empty.
   273    bytes content = 1;
   274  
   275    // A (possibly normalized) copy of the non-empty fields of the FileInfo
   276    // message from the Get request.  If either field from the original request
   277    // was empty, the server may optionally fill in that field in the reply if it
   278    // is known.  For example, if the client requested a file by path only and
   279    // the server found it, the reply MAY fill in the digest.
   280    FileInfo info = 2;
   281  
   282    // If true, no data are available for the requested file, and the content
   283    // field must be empty.  If false, the content field contains the complete
   284    // file content (which may be empty).
   285    bool missing = 3;
   286  }
   287  
   288  // A CompilationBundle carries a CompilationUnit and its required FileData.
   289  message CompilationBundle {
   290    // The CompilationUnit to be analyzed.
   291    CompilationUnit unit = 1;
   292  
   293    // File data for the CompilationUnit's required_input.
   294    repeated FileData files = 2;
   295  }
   296  
   297  // A compilation unit combined with index terms.
   298  message IndexedCompilation {
   299    CompilationUnit unit = 1;
   300    Index index = 2;
   301  
   302    message Index {
   303      // Revision markers at which this compilation record is indexed.
   304      repeated string revisions = 1;
   305    }
   306  }