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

@@ -207,6 +207,90 @@ type importSelectionEvidence struct {
outcome importSelectionOutcome
}
// ImportSelectionForFacade is a root-converted source-selection transport
// record. Its paths and enum spellings are converted by the facade.
type ImportSelectionForFacade struct {
Path Path // source-local import declaration path
Location Location // authored location and declaring source ID
Selector string // path, dir, or glob
Outcome string // none for a completed empty optional selection
}
// SourceInfoImportSelectionsForFacade returns detached selection records for
// explicit root-owned conversion.
func SourceInfoImportSelectionsForFacade(source SourceInfo) []ImportSelectionForFacade {
if source.importSelections == nil {
return nil
}
result := make([]ImportSelectionForFacade, len(source.importSelections))
for index, selection := range source.importSelections {
result[index] = ImportSelectionForFacade{
Path: selection.path.clone(), Location: selection.location,
Selector: importSelectorString(selection.selector),
Outcome: importSelectionOutcomeString(selection.outcome),
}
}
return result
}
// SourceInfoWithImportSelections copies converted root-owned records into
// private engine source evidence.
func SourceInfoWithImportSelections(source SourceInfo, selections []ImportSelectionForFacade) SourceInfo {
if selections == nil {
source.importSelections = nil
return source
}
source.importSelections = make([]importSelectionEvidence, len(selections))
for index, selection := range selections {
source.importSelections[index] = importSelectionEvidence{
path: selection.Path.clone(), location: selection.Location,
selector: importSelectorFromString(selection.Selector),
outcome: importSelectionOutcomeFromString(selection.Outcome),
}
}
return source
}
func importSelectorString(value importSelector) string {
switch value {
case importSelectorPath:
return "path"
case importSelectorDirectory:
return "dir"
case importSelectorGlob:
return "glob"
default:
return ""
}
}
func importSelectorFromString(value string) importSelector {
switch value {
case "path":
return importSelectorPath
case "dir":
return importSelectorDirectory
case "glob":
return importSelectorGlob
default:
return 0
}
}
func importSelectionOutcomeString(value importSelectionOutcome) string {
if value == importSelectionNone {
return "none"
}
return ""
}
func importSelectionOutcomeFromString(value string) importSelectionOutcome {
if value == "none" {
return importSelectionNone
}
return 0
}
// SourceInfoPlacementModeForFacade converts private placement evidence to its
// root-owned numeric representation.
func SourceInfoPlacementModeForFacade(source SourceInfo) uint8 {