Class HierarchyIndex
The identity snapshot is computed once, on first use, and cached. Callers
that select a hierarchical strategy must force the full structural check with
validate() before retrieval enters its failure-policy
boundary: a malformed hierarchy is a configuration fault, not a transport
failure, so it must not be routed through @Search.onFailure.
- Since:
- 0.13.0
-
Constructor Summary
ConstructorsConstructorDescriptionHierarchyIndex(List<RetrievedDocument> documents) Creates an index over hierarchy documents. -
Method Summary
Modifier and TypeMethodDescriptionReturns the source documents in declaration order.Resolves a document by hierarchy ID.identifier(RetrievedDocument document) Resolves the canonical hierarchy ID for a document.Returns the immediate parent ID for an indexed document.intsize()Returns the validated index size.sourceGroup(RetrievedDocument document) Resolves the canonical source group used for source fencing.voidvalidate()Checks every structural invariant this index can decide from its own documents: canonical identity, duplicate hierarchy and entry IDs, blank parents, unresolvable parent references, and parent cycles.
-
Constructor Details
-
HierarchyIndex
Creates an index over hierarchy documents.- Parameters:
documents- documents with canonical hierarchy metadata
-
-
Method Details
-
documents
Returns the source documents in declaration order.- Returns:
- immutable document list
-
size
public int size()Returns the validated index size.- Returns:
- number of unique hierarchy documents
-
validate
public void validate()Checks every structural invariant this index can decide from its own documents: canonical identity, duplicate hierarchy and entry IDs, blank parents, unresolvable parent references, and parent cycles.Whether a hierarchy is well-formed is fixed by the Role's knowledge sources and the installed
SourceLoaders, never by request data, so this runs at strategy-selection time — above the@Search.onFailureguard, the same rulererankerModel,queryExpansionModelandGraphStoreProviderresolution follow. Routing a malformed hierarchy through the guard would letCONTINUEemit a silently ungrounded action that reports success andUSE_CACHEanswer it from a stale entry, for what is a deployment fault. Failures raised while traversing a valid hierarchy stay runtime concerns and still reach the guard.- Throws:
HierarchyException- when any structural invariant is violated
-
find
Resolves a document by hierarchy ID.- Parameters:
id- hierarchy identifier- Returns:
- matching document, if present
-
identifier
Resolves the canonical hierarchy ID for a document.- Parameters:
document- indexed document or child hit- Returns:
- canonical hierarchy ID
- Throws:
HierarchyException- when neither hierarchyId nor entryId is valid
-
parentId
Returns the immediate parent ID for an indexed document.- Parameters:
id- hierarchy document ID- Returns:
- parent ID, or empty for a root/flat document
-
sourceGroup
Resolves the canonical source group used for source fencing.- Parameters:
document- hierarchy document- Returns:
- hierarchySource metadata, or the document source as fallback
-