Expose import defaults and selection evidence

This commit is contained in:
2026-10-19 21:06:31 +00:00
parent 05b67cbfcf
commit 24131617c7
12 changed files with 568 additions and 18 deletions

View File

@@ -210,6 +210,39 @@ type SourceInfo struct {
// and failed loads, text is conservatively withheld; successful final source
// records reflect completed sensitivity classification.
VersionCheck *SourceVersionCheck
// ImportSelections records completed optional declarations that selected no
// sources, in declaration order. Paths are local to this declaring source.
ImportSelections []ImportSelection
}
// ImportSelector identifies the selector used by an import declaration.
type ImportSelector string
const (
// ImportSelectorPath identifies a named-file selector.
ImportSelectorPath ImportSelector = "path"
// ImportSelectorDirectory identifies a literal directory search.
ImportSelectorDirectory ImportSelector = "dir"
// ImportSelectorGlob identifies a path-glob selector.
ImportSelectorGlob ImportSelector = "glob"
)
// ImportSelectionOutcome identifies the established result of import selection.
type ImportSelectionOutcome string
const (
// ImportSelectionNone means the optional declaration selected no sources.
ImportSelectionNone ImportSelectionOutcome = "none"
)
// ImportSelection records an optional import declaration that selected no
// sources. Path is local to the declaring source; Location identifies its
// declaration mapping and source ID.
type ImportSelection struct {
Path Path
Location Location
Selector ImportSelector
Outcome ImportSelectionOutcome
}
// SourceVersionCheck describes a source-local version declaration observed
@@ -295,9 +328,22 @@ func cloneSourceInfo(source SourceInfo) SourceInfo {
source.Destination = source.Destination.clone()
source.ImportedFrom = cloneLocation(source.ImportedFrom)
source.VersionCheck = cloneSourceVersionCheck(source.VersionCheck)
source.ImportSelections = cloneImportSelections(source.ImportSelections)
return source
}
func cloneImportSelections(selections []ImportSelection) []ImportSelection {
if selections == nil {
return nil
}
cloned := make([]ImportSelection, len(selections))
for index, selection := range selections {
selection.Path = selection.Path.clone()
cloned[index] = selection
}
return cloned
}
func cloneSourceVersionCheck(value *SourceVersionCheck) *SourceVersionCheck {
if value == nil {
return nil