package artifacts import ( "path/filepath" "strings" "gitea.maximumdirect.net/eric/narratio/internal/manifest" ) type inputSourceKey struct{ kind, source string } // InputLookup holds candidate records for one manifest input snapshot. Construct // a new lookup whenever the manifest's inputs are replaced. type InputLookup struct { byKind map[string][]manifest.InputRecord bySource map[inputSourceKey][]manifest.InputRecord byPath map[string][]manifest.InputRecord } // NewInputLookup indexes candidates without validating their content or paths. func NewInputLookup(paths SessionPaths, m *manifest.Manifest) *InputLookup { lookup := &InputLookup{byKind: make(map[string][]manifest.InputRecord), bySource: make(map[inputSourceKey][]manifest.InputRecord), byPath: make(map[string][]manifest.InputRecord)} if m == nil { return lookup } root, rootErr := filepath.Abs(strings.TrimSpace(paths.Root)) for _, record := range m.Inputs { kind := strings.TrimSpace(record.Kind) lookup.byKind[kind] = append(lookup.byKind[kind], record) key := inputSourceKey{record.Kind, record.Source} lookup.bySource[key] = append(lookup.bySource[key], record) if rootErr == nil && strings.TrimSpace(paths.Root) != "" { if resolved, err := resolvePreparedManifestPath(paths, record.Path, filepath.Clean(root)); err == nil { lookup.byPath[resolved] = append(lookup.byPath[resolved], record) } } } return lookup }