Record absolute import review findings

This commit is contained in:
2026-12-05 21:27:40 +00:00
parent 9d86e3377a
commit 22a022a9e8

121
docs/roadmap/remediation.md Normal file
View File

@@ -0,0 +1,121 @@
# Absolute-import implementation review
Reviewed commit: `9d86e3377a5f462bc7b9eb572aff881abd1b70b3`.
Scope: all 15 stages of the [implementation plan](implementation.md), compared
with the [agreed roadmap](absolute-imports.md), ADR 0026, and the current contracts.
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.
Relevant code: `globStartingCandidates` in
[glob.go](../../internal/engine/glob.go), particularly lines 349–354;
`explicitGlobCandidate` in the same file; and `filesystemAccess.canonical` in
[filesystem_access.go](../../internal/engine/filesystem_access.go).
The literal-prefix loop keeps a native candidate's namespace spelling as its
access path. Although `explicitGlobCandidate` inspects the link and obtains its
resolved target, native canonicalization returns the original namespace path.
The next literal `..` therefore uses the parent of the alias spelling. In
contrast, the traversal loop after the first wildcard explicitly obtains the
matched directory's resolved identity before advancing to its parent.
This is observable with a supplied `os.DirFS` exposing `fs.ReadLinkFS` and this
layout:
```text
main.yml
services/
alias -> ../targets/unit
shared/part.yml # value: other
targets/
unit/marker
shared/part.yml # value: intended
```
With required imports and following enabled:
- `glob: services/alias/../shared/*.yml` loads `services/shared/part.yml` and
returns `value: other`.
- `glob: services/[a]lias/../shared/*.yml` loads `targets/shared/part.yml` and
returns `value: intended`.
- Host loading resolves both spellings to `targets/shared/part.yml`.
These results were reproduced through the public loading API in a disposable
program outside the checkout. If the lexical counterpart is absent, the native
literal-prefix form instead reports a required import missing, or silently
selects nothing for an optional declaration.
This carries an older native literal-prefix limitation into the new prefix
owner. It leaves the stage 7–8 separation of lexical and physical traversal
coordinates incomplete: moving the same directory match across the prefix/
wildcard boundary changes which parent is selected. The new wildcard-parent
tests cover the second form but do not cover the literal-prefix form.
Suggested remediation: when advancing a literal prefix through `..`, obtain the
preceding directory's resolved native identity for the access coordinate, as the
post-wildcard traversal already does. Keep the lexical candidate separate and
reuse a small shared parent-advance helper if useful. Preserve component error
handling, explicit boundaries, native source identity outside this traversal,
and existing link-follow behavior; this needs no host fallback or new alias
identity contract. Add a focused native link regression demonstrating agreement
between the two forms, with the host behavior retained.
## 2. Limit the native absolute-link rejection statement to inspected links
Priority: P2. Status: open.
Relevant documentation: the native-link paragraph at lines 2026–2029 of
[the import contract](../config.md#explicit-imports).
Relevant code: `validateNamedImportTarget` in
[import_selection.go](../../internal/engine/import_selection.go), native
`filesystemAccess.canonical` and `open` in
[filesystem_access.go](../../internal/engine/filesystem_access.go), and
`resolveNativeImportPath` in
[filesystem_links.go](../../internal/engine/filesystem_links.go).
The newly written contract says that native absolute link targets retain their
existing rejection, without limiting that statement to the operations that
inspect link targets. Named-file imports continue to delegate native `Stat` and
`Open` to the supplied filesystem. They do not call the native link resolver.
For example, give `NewFilesystem` an `os.DirFS` containing `alias.yml`, an
absolute symlink to a regular YAML file outside that directory. A native main
declaring `path: /alias.yml` successfully loads the file. The corresponding
`glob: /alias.yml` rejects the absolute link target through ConfigKit's explicit
link inspection. This was also reproduced using disposable local files and the
public API; it requires neither concurrent mutation nor a custom filesystem.
The named-file delegation is unchanged behavior. The prior contract described
`fs.ReadLinkFS` inspection of discovered links and expressly avoided a general
native sandbox guarantee. The requested feature preserves those existing
capability and operation boundaries; it does not authorize stronger native
symlink enforcement. The new blanket rejection wording consequently promises
more than the implementation and the selected scope provide.
Suggested remediation: scope the rejection statement to ConfigKit's link-target
inspection and explain that named-file access retains the supplied filesystem's
ordinary behavior. Keep the distinction between YAML namespace-root syntax and
symlink target syntax. Correct the documentation rather than introducing new
named-file rejection or a stronger filesystem guarantee.
## Review coverage and validation
- Stage 1: ADR 0026 records the selected separation, and ADR 0022 changes only
its status to identify the partial supersession.
- Stages 2–6: reviewed context resolution and validation, bounded/unbounded/native
access, link handling, shared selector resolution, transitive bases, admission,
identity and cleanup. No additional actionable findings.
- Stages 7–8: reviewed literal roots, wildcard/parent ordering, union and physical
candidate retention. Finding 1 remains in the literal-prefix path.
- Stages 9–13: reviewed passive source contexts, derived/fallback contexts,
overlay anchors, captured-policy compatibility, bootstrap isolation, public
lifecycle coverage and the maintained consumer example. No additional
actionable findings.
- Stage 14: reviewed the changed canonical documentation and Go comments.
Finding 2 is an unintended strengthening of the documented contract.
- Stage 15: `./scripts/check.sh` and `go test -race ./...` pass with Go 1.27.4.
Existing tests do not expose the two findings above. The public reproductions
remained outside the repository; no permanent tests, dependencies, release
gates or runtime changes were added for this audit.