Settle import path decisions and minor release scope

This commit is contained in:
2026-12-05 19:12:16 +00:00
parent e2ec298cbc
commit 19512adfab

View File

@@ -1,6 +1,6 @@
# Absolute and parent-relative imports
Status: proposed; no runtime changes have been implemented.
Status: agreed target behavior; implementation pending.
Baseline: `9037fdb74e1cd4f35ac78032f1bf70854b0e8754`.
## Purpose and agreed direction
@@ -20,8 +20,7 @@ merely because of their spelling.
An explicitly supplied `FilesystemContext.Root` remains an intentional boundary.
Applications can continue choosing containment when they need it. Supplied
`fs.FS` values remain their own namespaces; an import from such a namespace does
not silently switch to host filesystem access. The significant unresolved
details are collected under Open Decisions.
not silently switch to host filesystem access.
This feature changes filesystem selection and access. Existing composition,
precedence, configuration destinations, schema/version handling and inspection
@@ -87,13 +86,32 @@ platform supports them. This feature does not expand the project's platform
support commitments. It adds no URL fetching, shell expansion, environment
substitution or implicit directory search.
### Supplied filesystem namespaces
A leading `/` in a YAML import selector starts at the selected `fs.FS` namespace's
root. For example, `/shared/common.yml` selects that namespace's
`shared/common.yml`; a relative selector starts at the declaring file's directory.
Apply this interpretation consistently to `path`, `dir` and `glob`. An explicit
`Root` continues to bound canonical targets within the namespace.
Translate selector paths to valid namespace-relative paths for Go filesystem
operations. The existing `fs.ValidPath` conventions for `Filesystem.File` and
`FilesystemContext` Go arguments remain unchanged. YAML selector syntax expresses
one conceptual absolute/relative rule across host and supplied filesystems while
respecting the selected namespace.
### Explicit roots and links
Keep relative-path base selection independent of optional import containment.
For host files, an omitted `Root` means unrestricted host import scope; a
supplied root retains existing validation and containment semantics. Host
synthetic contexts should likewise be able to omit `Root` without manufacturing
a main-directory boundary; their base requirements are discussed below.
supplied root retains existing validation and containment semantics.
Host byte, reader and mapping sources retain their existing requirement for an
explicit absolute `BaseDir`, including when all selectors are absolute. Their
host context may omit `Root`. This preserves a predictable relative base without
inferring filesystem locations from display labels or the working directory.
The redundant base for an absolute-only synthetic document is an accepted
tradeoff for keeping the existing context model straightforward.
Apply explicit containment to canonical targets, including symlink targets and
every transitive import. Without an explicit boundary, a host symlink target
@@ -129,9 +147,19 @@ import boundary into an explicit one on a subsequent load.
Keep passive `SourceContext` reporting usable for externally imported files,
including through resolution and available failed-load inspection. Its filesystem
and slash-relative `BaseDir` must address the contributing source's directory.
The default resource root for newly reachable sources is an open decision;
loading must not fail simply because that directory lies outside the former
implicit import root.
For host sources inside the previous default root, preserve their existing
resource contexts and `FS`/`BaseDir` coordinates. A newly eligible external source
without an explicit containment root receives a passive context rooted at that
source's canonical directory, with `BaseDir` equal to `.`. With an explicit root,
continue using it for the passive context as today.
This gives an external file the default resource scope it would have when loaded
directly, while retaining established consumers' contexts. A caller needing
resource access beyond that directory can select a broader explicit context.
Broader import access does not automatically make the host filesystem root the
passive resource root. Loading must not fail simply because a source directory
lies outside the former implicit import root. These choices do not establish a
general filesystem sandbox guarantee.
Release library-owned acquisition handles before returning, as today. No
additional close obligation or background activity is introduced.
@@ -150,6 +178,33 @@ Changing imports does not implicitly enable absolute secrets directories, widen
their default root, or make `Load` modify the environment. Separate the internal
facts where a shared root currently conflates these responsibilities.
## Additive compatibility and release intent
Implement this as an additive feature suitable for a minor release under the
[release policy](../policy/release.md#versioning-and-compatibility): pre-existing
valid configurations must continue to work. Strictly identical behavior is not
required by that policy. Existing public Go signatures and fields need no removal
or incompatible change to support the selected design.
Preserve established relative imports, explicit-root validation and containment,
composition and precedence, source identity/reporting, and existing passive
resource contexts. Synthetic host sources supplying both `BaseDir` and `Root`
continue to work. Making `Root` optional and accepting additional YAML selector
spellings expands the supported input set.
Relaxing implicit main-directory import containment is a deliberate revision of
the documented default. The release note must explain that broader default and
show how callers can retain containment by explicitly setting
`FilesystemContext.Root`. Do not describe the release as preserving all former
rejection behavior. Previously invalid absolute or outside-default-root imports
can become valid; explicit boundaries continue to apply.
Keep secrets bootstrap and overlay lookup behavior intact. Compatibility coverage
should exercise representative previously valid configurations and their
source/resource contexts alongside the newly accepted forms. The intent adds no
release gate or requirement for downstream consumers to rewrite working
configuration to adopt the release.
## Changes needed from the baseline
- **Declarations and selection:** revise selector validation, absolute-root
@@ -175,73 +230,21 @@ facts where a shared root currently conflates these responsibilities.
a new ADR, including the extension of inherited containment described by
[ADR 0022](../adr/0022-main-relative-context.md). Preserve accepted ADR decision
text and the configured-bootstrap contract. Update architecture policy only
where its statements are affected.
where its statements are affected. Document the additive compatibility intent
and default-containment change in the minor release note.
- **Behavioral verification:** replace tests of the former implicit restriction
with coverage of the new default and retained explicit-root choice. Cover all
selectors, transitive relative bases, parent-relative paths, explicit-root
failures, symlink aliases, repeated sources and cycles. Include representative
discovery/preparation, mounted input, provenance/resource-context and failed
inspection interactions. Exercise native namespace behavior once selected.
Reuse existing semantic, budget and cleanup coverage rather than adding a
Cartesian test matrix or performance thresholds.
inspection interactions. Verify namespace-root YAML selectors separately from
unchanged Go filesystem argument conventions. Include compatibility cases for
existing valid relative imports, explicit roots, synthetic contexts and passive
resource coordinates. Reuse existing semantic, budget and cleanup coverage
rather than adding a Cartesian test matrix or performance thresholds.
The implementation plan will own sequencing and concrete verification commands.
This roadmap proposes no new release gates, dependencies or public performance
guarantees. Completion means eligible absolute and parent-relative imports work
end to end, with intentional caller-selected boundaries and consistent source
evidence, without unrelated changes to configuration composition or startup.
## Open Decisions
### 1. Absolute selector syntax in supplied filesystem namespaces
**Recommendation:** interpret a leading `/` as the root of the selected `fs.FS`
namespace, and translate it to a valid namespace-relative path for Go filesystem
operations. Thus `/shared/common.yml` starts at that namespace's root, while
`../shared/common.yml` starts from the declaring file's directory. An explicit
`Root` still bounds canonical targets. This offers one conceptual resolution
rule across host and supplied filesystems while retaining namespace ownership.
It requires documenting YAML selector syntax separately from `Filesystem.File`
and `FilesystemContext` Go arguments, whose existing `fs.ValidPath` conventions
need not change.
**Alternative:** add absolute syntax only for host imports and retain relative
selectors in supplied filesystems. This follows Go's native `fs.FS` path format
directly and reduces implementation scope, but the same absolute YAML spelling
would have different acceptance depending on its selected namespace. Both
approaches keep native imports within the supplied filesystem.
### 2. Base requirements for synthetic host sources
**Recommendation:** retain an explicitly supplied absolute `BaseDir` for byte,
reader and mapping sources, while allowing their host context's `Root` to be
omitted. This preserves their existing explicit context model, supplies a
predictable base for relative declarations, and avoids deriving paths from
display labels or the working directory. It leaves some redundant setup for a
synthetic source whose declarations are all absolute.
**Alternative:** permit an explicitly selected host context without `BaseDir`
when a synthetic document uses only absolute selectors. Report a missing-base
error only if that document actually selects a relative path; imported files
still have their own directories. This reduces consumer setup for absolute-only
documents but requires representing a base-less context through acquisition and
passive reporting. It must not silently substitute the process working directory.
### 3. Default passive resource roots for external host imports
**Recommendation:** preserve existing passive contexts for sources inside their
previous default root. For a newly eligible external source with no explicit
containment root, expose a passive context rooted at that source's canonical
directory. With an explicit root, continue using it. This supports source-local
resource reads using the existing public API, preserves existing consumers'
contexts, and avoids making the entire host filesystem the default resource
view merely to broaden imports. It gives an external source the same default
resource scope as loading that file directly, while resource reads beyond its
directory may need a broader context selected by the caller.
**Alternative:** expose a host-filesystem-root resource view for unrestricted
imports, with each source directory represented relative to it. This is uniform
and accommodates cross-directory resource references with fewer per-source
choices, but changes existing `FS`/`BaseDir` coordinates and broadens passive
resource access for established consumers. Neither choice changes configured
secrets bootstrap or implies a general filesystem sandbox guarantee.