diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index ec03094..298dfc9 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -7,7 +7,12 @@ This review changes no production code or tests. ## 1. Resolve native link targets before parent steps in a literal glob prefix -Priority: P2. Status: open. +Priority: P2. Status: complete. + +Completed: literal prefix parent steps now use the resolved directory identity. +The existing host/native glob regression covers both literal and wildcard link +spellings, fails before the fix, and passes afterward. Focused glob/native-link +tests and `./scripts/check.sh` pass. Relevant code: `globStartingCandidates` in [glob.go](../../internal/engine/glob.go), particularly lines 349–354; diff --git a/internal/engine/glob.go b/internal/engine/glob.go index 0c6e1e5..4f85add 100644 --- a/internal/engine/glob.go +++ b/internal/engine/glob.go @@ -347,7 +347,17 @@ func globStartingCandidates(access *filesystemAccess, base, pattern string, segm break } lexical, lexicalErr := resolveLiteralImportSelector(&prefixAccess, candidate.path, literal) - physical, physicalErr := resolveLiteralImportSelector(&prefixAccess, candidate.accessPath, literal) + parentAccess := candidate.accessPath + if literal == ".." { + target, err := prefixAccess.importEntryTarget(parentAccess, nil, true) + if err != nil { + return nil, 0, []Diagnostic{globCandidateDiagnostic(err, site.location, "glob parent directory could not be inspected")} + } + if target.identity != "" { + parentAccess = target.identity + } + } + physical, physicalErr := resolveLiteralImportSelector(&prefixAccess, parentAccess, literal) if lexicalErr != nil || physicalErr != nil { return nil, 0, []Diagnostic{*importSelectionDiagnostic(site, CodeImportOutsideRoot, "glob prefix is outside the selected namespace")} } diff --git a/internal/engine/glob_selection_test.go b/internal/engine/glob_selection_test.go index a4fd568..aa301f6 100644 --- a/internal/engine/glob_selection_test.go +++ b/internal/engine/glob_selection_test.go @@ -254,11 +254,13 @@ func TestSelectGlobParentUsesMatchedLinkTarget(t *testing.T) { {"host", host, root, file}, {"native", native, ".", "targets/shared/one.yml"}, } { t.Run(mode.name, func(t *testing.T) { - selection, diagnostics := selectGlobForTestWithDiagnostics(t, mode.access, mode.base, " - glob: services/*/../shared/*.yml\n required: true\n") - if len(diagnostics) != 0 || len(selection.candidates) != 1 || selection.candidates[0].accessPath != mode.want { - t.Fatalf("selection=%#v, diagnostics=%#v", selection, diagnostics) + for _, pattern := range []string{"services/*/../shared/*.yml", "services/alias/../shared/*.yml"} { + selection, diagnostics := selectGlobForTestWithDiagnostics(t, mode.access, mode.base, " - glob: "+pattern+"\n required: true\n") + if len(diagnostics) != 0 || len(selection.candidates) != 1 || selection.candidates[0].accessPath != mode.want { + t.Fatalf("pattern %q: selection=%#v, diagnostics=%#v", pattern, selection, diagnostics) + } } - selection = selectGlobForTest(t, mode.access, mode.base, " - glob: services/*/../shared/*.yml\n follow: false\n") + selection := selectGlobForTest(t, mode.access, mode.base, " - glob: services/*/../shared/*.yml\n follow: false\n") if len(selection.candidates) != 0 { t.Fatalf("unfollowed link selected=%#v", selection) }