syntax = "proto3";
package website.court.v1;
option java_package = "demo";
option java_outer_classname = "CourtTypes";

import "ai/protomolt/proto/projection/v1/projection.proto";
import "ai/protomolt/proto/validate/v1/validate.proto";
import "ai/protomolt/proto/index/hints/v1/indexing_hints.proto";

// Source service: a filing system uses its own field names.
service CaseSource {
  // Read one sample filing by its source identifier.
  rpc Read(CaseKey) returns (Case);
}
message CaseKey { string case_id = 1; }
message Case {
  string case_id = 1;
  string style_of_cause = 2;
}

// Destination service: accept the projected, validated search document.
// This demo acknowledges a document; it does not persist a search index.
service DocumentSink {
  rpc Accept(SearchDoc) returns (Receipt);
}
message Receipt { string doc_id = 1; }

// Common search shape, adapted from ProtoMolt's court projection fixture.
message SearchDoc {
  option (ai.protomolt.proto.projection.v1.sources) = {
    source: "website.court.v1.Case"
  };
  // Preserve the filing identity as an exact-match search key.
  string doc_id = 1 [
    (ai.protomolt.proto.projection.v1.from) = { paths: { path: "case_id" } },
    (ai.protomolt.proto.validate.v1.field) = { required: true string: { min_len: 1 } },
    (ai.protomolt.proto.index.hints.v1.index) = { type: INDEX_FIELD_TYPE_KEYWORD }
  ];
  // Project the case name into searchable text and derive a title vector.
  string title = 2 [
    (ai.protomolt.proto.projection.v1.from) = { paths: { path: "style_of_cause" } },
    (ai.protomolt.proto.validate.v1.field) = { required: true string: { min_len: 2 } },
    (ai.protomolt.proto.index.hints.v1.index) = {
      type: INDEX_FIELD_TYPE_TEXT
      chunking_policy: {
        chunking: {
          strategy: "sentence-packed" strategy_version: 1
          target_tokens: 128 overlap_tokens: 0 min_tokens: 0 max_tokens: 128
          boundary: "rules-v1"
        }
        embedding: {
          model: "sentence-transformers/all-MiniLM-L6-v2"
          dims: 384 similarity: VECTOR_SIMILARITY_COSINE normalize: true
        }
        vector_field: "title_vector"
        store_chunk_text: true
      }
    }
  ];
}
