Share the source index with validators

This commit is contained in:
2026-11-26 05:12:19 +00:00
parent 60e732bbe8
commit d66cfe3986
43 changed files with 191 additions and 68 deletions

View File

@@ -21,10 +21,16 @@ func NewSourceRefOrder(doc *source.SourceDocument) SourceRefOrder {
// NewSourceRefOrderForSource uses a borrowed whole-source index when provided.
// The caller must supply an index for doc; otherwise one is built locally.
func NewSourceRefOrderForSource(doc *source.SourceDocument, index *source.DocumentIndex) SourceRefOrder {
return NewSourceRefOrderFromIndex(DocumentIndexForSource(doc, index))
}
// DocumentIndexForSource borrows the supplied whole-source snapshot, or builds
// one locally when omitted. A supplied index must match doc's unchanged ID/order.
func DocumentIndexForSource(doc *source.SourceDocument, index *source.DocumentIndex) source.DocumentIndex {
if index != nil {
return NewSourceRefOrderFromIndex(*index)
return *index
}
return NewSourceRefOrder(doc)
return source.NewDocumentIndex(doc)
}
// NewSourceRefOrderFromIndex captures source identity and unit positions from