Class TypeDescriptorIndex

java.lang.Object
ai.pipestream.registration.descriptors.TypeDescriptorIndex

@ApplicationScoped public class TypeDescriptorIndex extends Object
In-memory index over the full-workspace protobuf descriptor snapshot baked into this service at build time (descriptors/pipestream-workspace.desc, a serialized DescriptorProtos.FileDescriptorSet produced by buf build over the entire pipestream-protos workspace).

Backs the descriptor door (GetTypeDescriptor / ListTypeDescriptors): given a message full name, produces a SELF-CONTAINED descriptor set — the defining file plus all transitive imports, topologically ordered (dependencies before dependents) — that a browser-side registry can consume without any further fetch.

Everything here works at the DescriptorProtos.FileDescriptorProto level; no FileDescriptor linking is performed, so the index is independent of which message types are compiled into this service.

Versioning is content-addressed: the version of a type's descriptor set is the SHA-256 of its serialized bytes. Identical content always hashes to the same version, so clients can cache for as long as the version matches.

  • Constructor Details

    • TypeDescriptorIndex

      public TypeDescriptorIndex()
  • Method Details

    • load

      @PostConstruct public void load()
      Loads and indexes the baked descriptor snapshot. The resource is produced by this service's own build; a missing or unparsable snapshot is a broken build and fails startup.
    • messageNameFromTypeUrl

      public static Optional<String> messageNameFromTypeUrl(String typeUrl)
      Extracts the message full name from an Any type_url (type.googleapis.com/pkg.Msg — everything after the last slash) or returns a bare name unchanged. Returns empty when the result is not a syntactically valid fully-qualified message name.
      Parameters:
      typeUrl - the type_url or bare message name
      Returns:
      the message full name, or empty if malformed
    • lookup

      public Optional<TypeDescriptorIndex.TypeDescriptorPayload> lookup(String messageFullName)
      Resolves one message type to its self-contained descriptor set.
      Parameters:
      messageFullName - fully-qualified message name (pkg.Msg)
      Returns:
      the payload, or empty when the type is not in the snapshot
    • list

      Lists every message type in the snapshot, sorted by full name.
      Parameters:
      filter - case-insensitive substring filter on the full name; null or blank = no filter
      Returns:
      catalog rows including each type's current content-hash version
    • isValidFieldPath

      public boolean isValidFieldPath(String messageFullName, String fieldPath)
      Whether a dot-separated field path resolves against a type's schema. Each segment must name a field of the current message; intermediate segments must be message-typed (repeated message fields may be traversed — the path describes schema, not data); synthetic map-entry messages are not traversable (annotate the map field itself).
      Parameters:
      messageFullName - the root type
      fieldPath - dot-separated field names ("content.text", "doc_id")
      Returns:
      true when every segment resolves
    • bakedFieldDescriptions

      public Map<String,String> bakedFieldDescriptions(String messageFullName)
      The BAKED metadata layer: each direct field's leading proto doc-comment (trailing as fallback), keyed by field name. Nested paths are served by fetching the nested type's own metadata — annotations are type-scoped and compose.
      Parameters:
      messageFullName - the type
      Returns:
      field name → trimmed comment; empty map for unknown types or comment-less fields