Class TypeDescriptorIndex
java.lang.Object
ai.pipestream.registration.descriptors.TypeDescriptorIndex
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne type's served descriptor set: the bytes, their content-hash version, and catalog metadata.static final recordCatalog row forListTypeDescriptors. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbakedFieldDescriptions(String messageFullName) The BAKED metadata layer: each direct field's leading proto doc-comment (trailing as fallback), keyed by field name.booleanisValidFieldPath(String messageFullName, String fieldPath) Whether a dot-separated field path resolves against a type's schema.Lists every message type in the snapshot, sorted by full name.voidload()Loads and indexes the baked descriptor snapshot.Resolves one message type to its self-contained descriptor set.messageNameFromTypeUrl(String typeUrl) Extracts the message full name from anAnytype_url (type.googleapis.com/pkg.Msg— everything after the last slash) or returns a bare name unchanged.
-
Constructor Details
-
TypeDescriptorIndex
public TypeDescriptorIndex()Creates the index bean. The descriptor snapshot is parsed and indexed later byload(), which CDI invokes after construction.
-
-
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
Extracts the message full name from anAnytype_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
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
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 typefieldPath- dot-separated field names ("content.text", "doc_id")- Returns:
- true when every segment resolves
-
bakedFieldDescriptions
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
-