Remove completed import planning documents

This commit is contained in:
2026-12-05 22:35:47 +00:00
parent 8d6622722b
commit 89340cee1e
3 changed files with 0 additions and 1187 deletions

View File

@@ -1,311 +0,0 @@
# Absolute and parent-relative imports
Status: complete; see the [completed implementation record](implementation.md).
Baseline: `9037fdb74e1cd4f35ac78032f1bf70854b0e8754`.
The current [import contract](../config.md#explicit-imports),
[resource-context contract](../config.md#source-resource-contexts), and
[import internals](../internal/imports.md) own implemented behavior.
[ADR 0026](../adr/0026-optional-host-import-containment.md) records the decision;
the [consumer example](../../examples/consumers/external_imports_test.go) shows use.
## Purpose and agreed direction
Applications should be able to import shared configuration from locations such
as `/etc/shared/logging.yml`, even when their discovered main file lives in
another directory. The declaring file's canonical directory supplies the base
for relative imports. Absolute host paths select their named targets directly.
For ordinary host-file loading, enabling imports is sufficient to enable these
paths. Omission of an explicit containment root permits imports elsewhere on the
host, subject to filesystem access and the existing import rules. Parent-relative
paths such as `../shared/logging.yml` follow the same access policy. Absolute and
relative spellings of the same target should not acquire different permissions
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.
This feature changes filesystem selection and access. Existing composition,
precedence, configuration destinations, schema/version handling and inspection
semantics continue to apply.
## Planning baseline (historical)
At the planning baseline, the configuration contract accepted
slash-separated relative selectors and rejects absolute paths. Host access uses
a canonical root which defaults to the selected main file's directory. Relative
targets and symlink targets must remain within that root. A caller can supply a
wider root, but absolute selector syntax remains invalid.
At that baseline, host byte, reader and mapping sources required explicit absolute
`BaseDir` and `Root` directories for filesystem imports. A `Filesystem.File`
source uses its selected namespace, with `.` as its default root. Synthetic
sources with native context provide namespace-relative base and root directories.
Diagnostic labels do not establish filesystem locations.
Internally, the resolved context carries a root and base, and live host access
opens an `os.Root` for that root. Selection, link resolution and resource-context
construction rely on those facts. In particular,
`contextsForResolvedSources` rejects source directories outside the selected
root. Updating only selector validation would therefore leave external imports
unusable.
The same context machinery supports main-relative inputs, captured main sources,
selected overlays, passive resource contexts and configured secrets bootstrap.
Their uses of a root need explicit consideration when import access changes.
## Target behavior
### Host selectors and resolution
The following is valid when imports are enabled:
```yaml
config:
imports:
- path: /etc/shared/logging.yml
- path: ../shared/application.yml
- dir: /etc/shared/fragments
pattern: "*.yml"
- glob: "/etc/shared/services/*.yml"
```
Apply the same absolute/relative resolution policy to `path`, `dir` and `glob`,
including each element of a path or directory list. Existing selector-specific
options, wildcard grammar, filtering, ordering and requiredness remain in place.
An absolute glob establishes its absolute starting location; it does not scan
the declaring file's directory first. Handle path roots separately from pattern
segments so normalization preserves wildcard and escape semantics.
Absolute globs also work within an explicit containment root. With
`Root: /etc/myapp`, `/etc/myapp/fragments/*.yml` starts wildcard discovery in
`/etc/myapp/fragments`; resolving its literal prefix must not fail merely because
`/` and `/etc` are ancestors of the allowed root. Establish the literal starting
directory before wildcard discovery, then apply the existing containment and
traversal rules. The same rule applies within a supplied filesystem namespace.
Preserve traversal order when parent segments follow wildcards. For example,
`services/*/../shared/*.yml` must expand the wildcard directory segment before
processing its following `..`, using the existing link-handling rules. Cleaning
the complete pattern as though `*` were a literal directory name would change
which directories are visited and could suppress relevant access errors.
Relative imports in an acquired file resolve from that file's own canonical
directory, including when it lies outside the main file's directory. YAML
`destination` and `placement` continue to describe configuration-tree placement;
they do not affect physical path resolution.
Resolve host paths using the supported host platform's path rules while
preserving existing slash-based selector and glob conventions. Absolute volume
roots must not be accidentally interpreted as relative components where the
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.
The namespace-root interpretation of a leading `/` applies to YAML selectors.
Symlink target strings returned by a supplied filesystem retain their existing
interpretation and validation, including existing `fs.ReadLinkFS` capability
handling. Do not apply YAML selector rewriting to those target strings; a host
absolute target returned by a filesystem wrapper must not be reinterpreted as
an absolute YAML path within that 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 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.
An explicit absolute existing `BaseDir` without `Root` is also a usable host
context for `NoSource()`, optional discovery exhaustion, and main-relative
fallbacks where a host context is applicable. It supplies the relative lookup
base and default resource root, with no import containment boundary. Existing
root-only absent-main contexts continue to use that root as their base and
explicit boundary. Omitting both does not infer the working directory. These
rules do not change context selection or the rule that a selected host file
determines its own base and rejects an explicit `BaseDir`.
Apply explicit containment to canonical targets, including symlink targets and
every transitive import. Without an explicit boundary, a host symlink target
outside the main file's directory is eligible under the normal import rules.
Existing discovered-link `follow` behavior remains independent of whether the
resolved target is inside the former default root.
Use ordinary filesystem facilities and existing stable-input assumptions. No
additional sandbox, isolation, adversarial mutation guarantee, allowlist,
confirmation step or numeric limit is part of this feature.
### Identity, loading and reporting
Retain canonical access identity separately from selector spelling. Absolute,
parent-relative and symlink spellings of the same file must participate in the
existing cycle/repeated-source detection within its established scopes.
Cross-directory imports remain in the same host namespace for those checks.
Preserve established canonical-path identity, including the existing treatment
of hard links, rather than adding inode identity or new deduplication rules.
Maintain deterministic selection and dependency-ready composition ordering under
the existing [import scheduling model](../internal/imports.md). Source records,
import sites, source-local coordinates, version evidence and configuration
destinations continue to identify actual acquisitions. Absolute paths must not
create a second composition or precedence model.
External imports must work through ordinary and layered loading, mapping and
sequence-item placement, discovered mains and main-relative underlay contexts.
Prepared main sources must retain whether containment was expressly selected;
materializing a default context during preparation must not turn an omitted
import boundary into an explicit one on a subsequent load.
With no later context, a prepared main retains its captured policy. A later
compatible host context may explicitly select containment at the captured
resource root: preparing without `Root` and then loading with `Root` equal to
the main directory remains valid and applies that explicit boundary. Omitting
`Root` in a later context does not remove a boundary explicitly selected during
preparation. Continue rejecting incompatible root changes under the existing
prepared-source contract. Context compatibility must account for the selected
containment policy as well as resolved paths.
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.
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.
For a synthetic or absent host source with `BaseDir` and no explicit `Root`, use
that `BaseDir` as its default passive resource root, with resource `BaseDir` equal
to `.`. Imports inside that resource root share it; external imports receive the
source-directory-rooted context described above. A main-relative input preserves
its inherited resource context, including its resource root and base coordinates,
instead of manufacturing a new resource root from its relative lookup base.
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.
### Related contexts retain their own contracts
Selected-overlay lookup conventions and main-relative context selection retain
their existing meanings. Imports within inputs that support them use the policy
above once their context has been selected. A broader import scope must not
accidentally change overlay search locations.
Configured secrets bootstrap retains its separately documented relative-path
and containment rules in [ADR 0023](../adr/0023-explicit-configured-secrets-bootstrap.md)
and the [configuration contract](../config.md#explicit-secrets-directory-bootstrap).
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
recognition, parent-relative normalization, directory selection and glob
starting locations. Preserve existing import defaults and error distinctions;
newly valid paths must still honor missing/required and inaccessible-target
behavior. Filesystem-dependent interpretation belongs with the selected
namespace rather than assuming every selector is a host path.
- **Access and contexts:** distinguish an authored containment boundary from
a relative base and from any root used for passive resource access. Revise
host/native context resolution, rooted access and link handling accordingly.
Unrestricted host access may require different internal access setup from
explicitly rooted access; opening the main directory alone cannot implement
it. Preserve caller-owned filesystem and reader ownership.
- **Pipeline integration:** carry those distinctions through discovery,
main-relative bindings, ordinary/grouped acquisition, prepared mains and
source-context construction. Reuse existing acquisition accounting and graph
admission. Avoid a separate absolute-import pipeline, repeated source reads,
or a retained root handle per imported file.
- **Contracts and decisions:** update `docs/config.md`, public filesystem-context
comments, relevant consumer examples and `docs/internal/imports.md` when the
implementation lands. Record the revised default and context distinctions in
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. 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. 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. Include a glob with parent traversal after a wildcard,
absolute globs whose literal prefixes lead into an explicit host or namespace
root, and synthetic and absent-main host contexts with an omitted root.
Exercise BaseDir-only main-relative fallbacks and retained root-only absent-main
behavior. Cover prepared-source loads that inherit the captured boundary,
explicitly narrow an unbounded capture at its resource root, or supply an
incompatible root; an omitted later root must preserve captured containment.
Include inherited main-relative resource contexts and the distinction between
native YAML selectors and native symlink targets. Reuse existing semantic,
budget and cleanup coverage rather than adding a Cartesian test matrix or
performance thresholds.
The [implementation plan](implementation.md) owns 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.

View File

@@ -1,552 +0,0 @@
# Implementation plan: absolute and parent-relative imports
Status: complete.
Planning baseline: `8c04dfd`; runtime baseline: `a441347`.
Implemented behavior is owned by the [import contract](../config.md#explicit-imports),
[resource-context contract](../config.md#source-resource-contexts), and
[import internals](../internal/imports.md). The decision is recorded in
[ADR 0026](../adr/0026-optional-host-import-containment.md); the maintained
[consumer example](../../examples/consumers/external_imports_test.go) demonstrates
the public workflow.
## Scope and execution
Implement the agreed end state in [absolute-imports.md](absolute-imports.md).
Read [development guidance](../development.md), [agents](../policy/agents.md),
[architecture](../policy/architecture.md), [testing](../policy/testing.md),
[documentation](../policy/documentation.md), and the release policy's
[compatibility definition](../policy/release.md#versioning-and-compatibility).
Use [the import contract](../config.md#explicit-imports) and
[import internals](../internal/imports.md) for behavior retained from the baseline.
Execute stages in order in one end-to-end sprint. Each stage is sized as one
focused Luna prompt. Intermediate stages need not compile; defer a focused
command until its dependencies are integrated rather than adding transitional
adapters or preserving two implementations. Private helper names are flexible;
the behavior and ownership choices below are settled.
This is an additive minor-release feature. Existing valid configurations,
explicit roots, resource coordinates and public signatures continue to work.
The relaxed implicit import boundary is intentional and must be documented.
Keep composition, precedence, version checks, source admission, budgets and
safe inspection on their existing owners. No new dependency, public switch,
automatic search, network provider, numeric budget, performance threshold or
release gate is required. Do not publish, push or tag a release during the
implementation sprint unless separately instructed.
## Concrete design and acceptance rules
### Separate import scope from the context's other roots
Extend the private resolved context with an optional import-containment root.
Keep the current `rootPath` meaning as the legacy resource/overlay/bootstrap
anchor, and `basePath` as the lookup base. An empty host import root denotes
unrestricted host imports; it is not a path to canonicalize or open. Native
imports retain the selected namespace root, including `.` for the full namespace.
Do not infer explicit containment merely because a resource root was resolved.
Persist the import policy with a captured main and copy it through derived
contexts. No additional public context fields are needed.
The following table defines host context resolution. Directory values are
canonical existing directories, with the baseline absolute-path validation
retained where applicable. A selected host file still rejects a supplied BaseDir.
| Input/context | Lookup base | Resource/legacy anchor | Import boundary |
| --- | --- | --- | --- |
| Selected host file, Root omitted | Canonical file directory | Same directory | None |
| Selected host file, explicit Root R | Canonical file directory | R | R |
| Bytes/reader/mapping, BaseDir B only | B | B | None |
| Bytes/reader/mapping, BaseDir B and Root R | B | R | R |
| NoSource or optional search exhaustion, BaseDir B only | B | B | None |
| Absent main, Root R only | R | R | R |
| Absent main, BaseDir B and Root R | B | R | R |
Synthetic host inputs still require BaseDir even for absolute-only declarations.
A supplied empty absent-main context establishes no working-directory default;
contextless NoSource remains valid under its existing lifecycle. An explicit
root must contain the selected file and base as today. A search that selects a
file follows the selected-file row; an invalid selected context is terminal.
Keep native Go context arguments and their validation unchanged, including the
existing synthetic-native base/root requirements.
For unrestricted host acquisition, use an unbounded mode in the existing
filesystem-access owner, dispatching to ordinary host filesystem operations.
Explicitly bounded host access continues to use its contained root handle;
native access continues borrowing its fs.FS. Do not open `/` as a new default
resource root, manufacture a boundary at the selected file's directory, or
retain a root handle per imported file. Overlay access must explicitly use the
legacy anchor, independently of the import mode.
### Selector resolution
- Host absolute selectors start at their host path; relative selectors start at
the declaring source's canonical directory. Synthetic and absent host contexts
use their selected base. Test absoluteness before joining; ordinary Join does
not provide the required selector dispatch.
- In YAML native selectors, leading `/` means the selected fs.FS namespace root.
Translate it to namespace-relative coordinates before filesystem calls.
Relative parent traversal uses the declaring source's namespace directory.
Paths must be addressable in that namespace and satisfy its selected root;
there is no host fallback. Existing Go constructor/context path syntax stays
slash-relative and follows fs.ValidPath.
- Share this distinction across path, directory and glob selection. Keep the
existing scheme/URL rejection and pattern grammar except for recognizing path
roots. Parse supported host volume roots before treating a colon as a scheme.
Preserve literal backslashes and wildcard escapes according to the existing
host/native conventions; do not turn every selector into a host filepath.
- Absolute glob roots and their longest literal prefix establish the starting
location before wildcard discovery. For Root `/etc/myapp`, the pattern
`/etc/myapp/fragments/*.yml` starts in the contained fragments directory;
`/` and `/etc` are resolution prefixes, not wildcard discovery targets.
The same distinction applies to native roots. Explicit-root containment still
governs the actual discovery directory and every subsequent traversal target.
- Keep segments after the first wildcard in traversal order. Expand `*` before
processing a following `..`; retain separate namespace spelling and physical
access coordinates under the current candidate model. Do not clean the whole
glob, skip matched-directory inspection, or suppress access errors through
premature normalization. A glob without wildcards follows named-target
requiredness/type behavior already used by glob selection.
- Preserve existing canonical host identity, normalized native namespace
identity, alias handling, candidate unions, admission and dependency scheduling.
Newly accepted absolute and relative spellings normalize into those existing
identities. Native link-target identities retain their current traversal role;
do not introduce inode identity or a new native alias contract.
- The new leading-slash interpretation is for YAML selectors. Preserve supplied
filesystem symlink-target interpretation, fs.ReadLinkFS capability handling,
discovered-link follow rules and native absolute-link rejection as currently
implemented. Host links can reach outside the old default directory when
imports are unbounded; explicit containment still applies to their targets.
### Resources and captured-policy compatibility
For a host source inside its context's legacy resource anchor, keep the same
rooted FS and relative BaseDir. For an unbounded external host import, use its
own canonical directory as its passive resource root and `.` as BaseDir. Imports
are still resolved using the load's import policy: the new per-source resource
root must not become a boundary on that source's transitive imports.
Synthetic/absent BaseDir-only sources use that base as their resource anchor.
Main-relative inputs inherit the main resource anchor and base coordinates.
Explicitly bounded host and native resource views retain baseline behavior.
Returned contexts remain passive and require no new close operation.
For an actual captured host main, retain canonical main path, base, resource
anchor and import boundary separately. Compatibility is:
| Capture | Later context | Result |
| --- | --- | --- |
| Unbounded, resource anchor D | None, or host context with Root omitted | Keep unbounded imports and D |
| Unbounded, resource anchor D | Root canonically equal to D | Apply explicit containment at D |
| Bounded at R | None, or host context with Root omitted | Keep containment at R |
| Bounded at R | Root canonically equal to R | Keep containment at R |
| Either capture | Different resource root, native FS, or supplied BaseDir | Existing incompatible-context option error |
Canonical aliases for an otherwise compatible root remain compatible. Do not
reopen or reselect the main to decide compatibility. Preserve existing behavior
after deletion or retargeting of its original filename. Absence does not create
a captured document or a new context-retention API.
Configured secrets bootstrap continues using the legacy anchor and its existing
relative-only directory declaration. Ordinary/layered overlay selection and
containment likewise continue using their established context anchors and lookup
locations. Import widening does not widen either facility.
## Stage 1 — Record the selected architectural change
Completed: recorded in [ADR 0026](../adr/0026-optional-host-import-containment.md)
and linked from ADR 0022's status.
Write ADR 0026 (or the next available number) as Accepted, recording optional
host import containment, namespace-root YAML selectors, and the separation of
import policy from resource/overlay/bootstrap anchors. Include the additive
compatibility intent and preserve the complete-on-return lifecycle.
Reference ADRs 0008, 0015, 0016, 0019, 0022 and 0023 as relevant. Describe selected
behavior directly; put rejected alternatives only in Alternatives Considered.
The inherited containment provision in ADR 0022 is revised by this decision:
update its status with a link explaining the partial supersession, preserving
the accepted decision text and its continuing context-selection rules. Leave
the configured-bootstrap decision intact.
Acceptance: the record states the agreed policy without adding a public
permission switch, sandbox promise, execution sequence or new approval gate.
## Stage 2 — Represent and validate independent context facts
Completed: resolved contexts now retain a separate import boundary; host
BaseDir-only contexts are accepted without changing native requirements or
selected-file base ownership. Focused context, filesystem and discovery tests pass.
Read `filesystem_context.go`, `filesystem.go`, `options.go`, `load_input.go` and
the context tables above. Add the private import-boundary state while retaining
the legacy anchor/base meanings. Update host selected, synthetic, absent and
search-exhaustion context resolution plus option validation to implement the
table. Separate host and native synthetic checks before allowing Root omission.
Audit directory validation and nil-context branches so an absent import bound
never reaches canonicalExistingPath or os.OpenRoot as an empty string. Continue
validating supplied contexts even when imports are disabled where baseline
contracts require it. Keep selected-file BaseDir rejection and native namespace
validation. Do not resolve a working directory for an empty context.
Add focused context cases in the existing filesystem/discovery owners for
BaseDir-only host synthetic and absent inputs, root-only absence, a base outside
an explicit root, and a search selecting a file versus exhausting with BaseDir.
Acceptance: the table is expressible without changing public signatures or
native Go context syntax. Runtime wiring can remain incomplete until later stages.
## Stage 3 — Add unbounded host filesystem access
Completed: the existing access owner dispatches unbounded host operations to the
OS, preserves namespace tokens and bounded/native access, and validates actual
anchor/base directories. The focused access, directory-read and cleanup test passes.
In `filesystem_access.go` and the access-opening path in
`filesystem_context.go`, add unbounded host operation dispatch to the existing
access object. Keep absolute host access names and namespace tokens; bounded
access translates contained names relative to its live root, native access
uses namespace-relative names, and unbounded access uses ordinary OS calls.
Update contains/stat/open/close and any root-relative assumptions needed for
regular file and directory reads. An unbounded context owns no root handle;
opened files and directories retain their normal cleanup. Retain the distinction
between missing initial directory opens and enumeration/close failures.
Keep nonregular preflight and post-open file checks in their existing owner.
Add narrow access/cleanup coverage using existing seams. Check the access
initialization in `acquireImportedWithAccess`: it must validate real base/anchor
directories, not stat an absent import-boundary path. Preserve tier host tokens.
Acceptance: host operations outside the legacy anchor are representable without
weakening explicit-root access or retaining handles in published metadata.
## Stage 4 — Integrate host link inspection with both access modes
Completed: the shared iterative link resolver supports absolute host coordinates
and ordinary unbounded Lstat/Readlink operations. Focused link/access/regular-file
checks pass. Overlay integration was deferred to stage 10, which resolved the
intermediate FIFO overlay failure caused by using import mode for overlay access.
Read `filesystem_links.go`, `filesystem_links_test.go`, `directory_walk.go` and
the regular-file tests. Update host import-entry inspection and link operations
to use the selected bounded/unbounded mode. Retain the shared iterative link
frame algorithm, active-cycle tracking and completed-target reuse. Extend its
coordinate handling only as needed to express host absolute roots; unbounded
resolution must not accidentally start from the process working directory.
Use ordinary host Lstat/Readlink operations for unbounded access. Resolve
absolute host link targets as host paths, including intermediate directory
links, while preserving follow behavior for the final discovered entry. Bounded
links retain canonical containment. Keep the native binding's existing link
target policy and capability-dependent behavior.
Cover contained and external host links, intermediate absolute links, final-link
follow=false, explicit-root rejection and active link cycles. Reuse FIFO and
cleanup coverage; no concurrent-filesystem attacker guarantees are added.
Acceptance: link and regular-file checks work in both host modes without a
second link-resolution framework or host fallback from a native namespace.
## Stage 5 — Parse selector roots and share literal path resolution
Completed: selector validation accepts absolute spellings while retaining scheme
and glob grammar checks; glob declarations retain root information separately.
A shared literal resolver passes host/native coordinate and boundary tests.
Read `directives.go`, `import_spec.go`, `import_selection.go` and `glob.go`.
Separate path spelling validation from selected-filesystem interpretation.
Accept new absolute spellings while preserving existing nonempty/string-set,
scheme rejection, declaration-site and selector-option validation. Keep root
information alongside glob segments instead of treating its leading slash as
an invalid empty segment.
Provide a shared private literal-selector resolution helper taking the selected
access/base. Absolute host paths bypass base joining; native leading-slash
selectors anchor at the namespace root; relative paths use the declared base.
Normalize native results into fs.ValidPath coordinates and retain outside-root
diagnostics for unaddressable or out-of-bound results. Recognize platform path
roots without introducing unrelated host spelling restrictions or changing Go
Source constructors. Leave wildcard segments uncleaned for stages 7–8.
Cover host absolute/parent-relative and native root/parent-relative spellings,
including explicit bounds, escaped literal names and the existing invalid input
classes. Acceptance: path and directory selectors can share one resolution rule;
native Go argument validation and native symlink target parsing remain separate.
## Stage 6 — Route named and directory imports through the shared resolver
Completed: named/list/directory selectors resolve before candidate normalization
and use existing target validation and acquisition. Host external/transitive,
absence, union, repeat, cycle, explicit-bound and native-root tests pass, as do
the existing directory selection policy/link tests.
Update `selectNamedImportCandidates` and `selectDirectoryImportCandidates` to
resolve each authored selector before candidate normalization. Preserve source
sites for list elements, candidate union/exclusion order, lexical selection
ordering, and canonical access identity separate from display spelling. Reuse
`validateNamedImportTarget`, directory traversal and shared admission rather
than constructing a parallel absolute-import acquisition path.
Trace `import_acquisition.go` and `acquisition.go` through transitive imports:
each acquired file uses its own directory as base while retaining its load's
import boundary and namespace. Avoid charging a source twice or creating a
fresh host token when paths cross directories.
Add behavioral path/list/directory cases outside the main directory and inside
an explicit root. Include optional missing versus required missing, unchanged
selection exclusions, transitive relative imports and absolute/relative repeats
and cycles. Native tests use a supplied filesystem; host path/link tests use real
temporary files. Acceptance: path and directory imports follow the target policy
end to end with existing diagnostics, version processing and accounting.
## Stage 7 — Establish glob roots and literal starting locations
Completed: globs inspect their literal prefix before wildcard discovery, admitting
resolution ancestors of an explicit root while checking the actual starting
location. Absolute host/native, fully literal, missing-prefix and outside-root
cases pass alongside existing glob selection tests.
Implement rooted glob initialization in `glob.go` using stage 5's root parsing
and literal resolution. Establish the longest literal starting directory before
the first wildcard, decoding literal escapes through the existing glob helpers.
If there is no wildcard, resolve and validate the complete named target through
the existing glob path. Preserve current grammar, including recursive-star
rules, and do not implicitly add recursive traversal.
Apply containment to the actual starting directory after resolving the literal
prefix. Absolute path ancestors preceding a contained explicit root are not
selected discovery directories. This does not authorize wildcard enumeration
outside an explicit root merely because a later match might reenter it.
Keep missing/required and inaccessible-prefix behavior consistent with existing
selection rules; no unrelated directories should be enumerated to reach a
literal prefix. Preserve component inspection within that prefix, including a
literal directory before `..`: a previously missing or inaccessible component
must not disappear through whole-prefix cleaning. Resolution prefixes may be
ancestors of the explicit root; that permission does not turn them into selected
discovery directories or suppress filesystem errors.
Cover host and native absolute globs whose literal prefix enters a multi-part
explicit root, an outside-root discovery directory, optional/required missing
prefixes, a missing literal component before `..`, and fully literal glob targets.
Acceptance: an explicitly bounded `/allowed/fragments/*.yml` reaches its contained
starting directory successfully.
## Stage 8 — Preserve wildcard traversal before parent normalization
Completed: parent segments advance from inspected matched directories, including
physical link targets, while lexical candidates remain separate. Wildcard/parent,
permission failure before exclusion, missing branches and host/native link cases
pass with the existing glob policy and grammar checks.
Continue segment-by-segment traversal from stage 7's starting candidates.
Update literal-segment handling and `explicitGlobCandidate` so a `..` after
a wildcard advances from each inspected matched directory. Keep namespace
candidate spelling and physical access paths distinct, particularly for links.
Preserve `prepareGlobEntry` ownership of wildcard matching, hidden/follow policy,
link inspection and intermediate-directory eligibility.
Do not clean away wildcard/parent segments before inspection. Retain the
existing union, filtering and source-admission rules and directory-entry budget.
Reuse their sorting and traversal instead of duplicating them for absolute forms.
Containment remains enforced at the actual discovery/traversal targets, and
exclusions continue to leave discovery/access errors visible.
Add a focused wildcard-then-parent fixture with irrelevant/missing branches,
a matched directory inspection failure using an existing deterministic seam,
and representative link/boundary cases. Reuse existing glob grammar and policy
tests. Acceptance: `services/*/../shared/*.yml` preserves traversal and error
behavior rather than behaving like a prematurely cleaned literal path.
## Stage 9 — Produce passive contexts for external imported sources
Completed: external unbounded host sources receive their own passive directory
root; contained/native/bounded coordinates remain intact. Resource tests cover
origins, resolution, failed validation inspection, synthetic contexts and imports
beyond an external source's resource directory.
Update `contextsForResolvedSources` in `source_context.go` to select a passive
root per source under the rules above. Keep the context anchor unchanged for
existing contained sources. External unbounded host imports use their own
canonical directory; synthetic/absent BaseDir-only contexts use their base;
native and explicit-root contexts retain their baseline roots.
Use existing rootedHostFS/rootedNativeFS wrappers. Returning a context performs
no resource read and retains no loading handle. Keep slash-relative BaseDir
coordinates and apply this behavior to contexts available during resolution,
successful results and supported failure inspection. The per-source passive
root must not constrain transitive import acquisition.
Cover a main and contained fragment retaining their old coordinates, an external
fragment reading its neighboring resource, a synthetic source's own context,
and an external fragment importing beyond its resource directory. Follow actual
origins to select contexts; do not infer ownership from the final YAML location.
Acceptance: admitted external imports no longer fail context construction.
## Stage 10 — Preserve main-relative binding and overlay behavior
Completed: derived context copies retain independent import policy; overlay
access explicitly uses the legacy anchor. Engine and public main-relative,
overlay, native overlay and nonregular-source checks pass, including the earlier
overlay FIFO regression and new BaseDir-only fallback cases.
Audit `acquireUnderlayGroupScopes`, `nativeTokenForLoadInput`,
`completeAcquisitionContexts`, `resolveOrdinaryOverlayFilesystem` and
`openSelectedOverlayAccess`. Derived inputs copy the selected namespace, import
boundary, resource anchor and base; only tier identity/main-source bookkeeping
changes as before. Explicit input contexts still override binding. BaseDir-only
fallbacks are usable after absence; optional contextless imports and RequireBase
retain their established behavior.
Overlay access must use a bounded view at the legacy context anchor. Ordinary
and explicit overlay lookup remain root-relative; derived/fallback layered
lookup retains its existing base-relative choice. Never substitute an unbounded
import root for an overlay lookup or access root. Preserve terminal selected-main
failures and inactive-overlay behavior.
Extend existing main-relative and overlay tests for unbounded main imports,
BaseDir-only fallback/optional exhaustion, root-only absent contexts, explicit
override and inherited resource coordinates. Reuse native and selected-overlay
repetition tests. Acceptance: broader imports work with discovered mains while
overlay paths and containment remain unchanged for existing valid loads.
## Stage 11 — Retain captured import policy without widening secrets bootstrap
Completed: captured mains retain the independent import boundary, preserve it
for omitted later roots and accept compatible explicit narrowing. Capture,
preparation, canonical alias/removal/retargeting and configured-secrets tests
pass; public bootstrap tests prove separate default and explicit anchors.
Extend `capturedHostSource` and `captureHostMain` in `prepared_source.go` to
retain the separated policy. Implement the captured compatibility table in
`resolveCapturedFilesystemContext`. Preserve canonical main identity, captured
bytes/nodes and live later imports; preparation must not pre-acquire imports or
reselect the main. A later omitted Root keeps captured explicit containment,
while compatible explicit narrowing of an unbounded capture is applied.
Trace `loadSecretsFromConfig` and `secrets_from_config.go`: configured directory
bootstrap continues using the captured legacy anchor, not the optional import
boundary. Keep its relative-only YAML paths, overwrite precedence, separate
report, failure handling and explicit environment mutation. Absent preparation
retains existing NoSource behavior rather than inventing a captured document.
Test the capture table, including canonical root aliases, nil and empty later
host contexts, narrowing, incompatible roots, and original-main removal or link
retargeting. Add one public bootstrap-then-load case where imports can reach an
external file while bootstrap still obeys its original default/explicit root.
Restore environment changes and keep process-mutating tests nonparallel.
Acceptance: preparation preserves authored import intent, compatible old calls,
and the existing secrets contract.
## Stage 12 — Verify public lifecycle integration and minor compatibility
Completed: public tests cover an external mounted fragment, inherited resource
origins/history, safe equivalent failure inspection and source-version evidence.
Legacy implicit-containment tests now request explicit roots with deterministic
temporary paths. The focused engine/public suites and ./scripts/check.sh pass.
Use public facade tests for a representative externally imported fragment that
is mounted into a mapping or identified sequence, contributes an inherited
value, and supplies a relative resource reference. Reuse current lifecycle
fixtures instead of combining every optional feature in every case.
Check final values, source-local provenance, placement and history; obtain the
resource context through origins. Repeat one configuration with semantic
validation rejection and verify its frozen inspection reports the same retained
source values safely. Include a source-version case to establish that absolute
imports still go through normal version processing and source catalogs.
Keep existing valid configurations working across ordinary/layered loading,
discovery, native filesystems, explicit roots, synthetic contexts, overlays and
prepared sources. Move old tests that enforce implicit containment to explicit
roots where they still protect that contract; add positive default-scope cases
rather than deleting meaningful failure coverage. Preserve tests for unchanged
budgets, regular-file checks, namespaces, link capabilities and cleanup.
Acceptance: existing public signatures and boundary tests pass, old valid
fixtures remain accepted, and new path spellings use the normal lifecycle.
## Stage 13 — Demonstrate the feature with a maintained consumer example
Completed: the external-import fixture and consumer test demonstrate absolute
and transitive relative imports, origin-selected resource access and deliberate
Root containment. Consumer guidance links the YAML and test; consumer tests pass.
Add a small example under `examples/consumers` showing a main file importing a
shared external file using an absolute path, plus a relative import declared by
that external file. Build the host paths from temporary fixture directories in
its test; do not depend on `/etc` contents, credentials or network access.
Demonstrate explicitly retaining containment with Root and using SourceContext
for a resource supplied by the external source. Use the existing consumer
example conventions and one representative behavioral test. Link a short YAML
illustration from consumer guidance rather than copying a whole application.
Acceptance: the example uses existing public APIs, loads once and proves both
the unrestricted default and intentional boundary without a new wrapper API.
## Stage 14 — Update canonical documentation and release handoff
Completed: Go declaration comments, configuration contract, import internals,
component overview and architecture guidance describe the implemented separation.
Development/consumer guides link ADR 0026 and the example. Changed local Markdown
links and whitespace pass review; release handoff is included in the final report.
Update Go declaration comments for FilesystemContext and affected import-facing
APIs without redefining the unchanged Go native-path format. Update
`docs/config.md` for selector roots, optional host import containment, synthetic
and absent contexts, prepared compatibility, passive resources and symlink
scope. Update `docs/internal/imports.md` and the component overview for actual
access/context responsibilities. Link the ADR and example from development and
consumer guidance. Adjust architecture policy only where its existing wording
needs the new distinction; preserve adopted upstream provenance.
Review stale blanket statements about imports staying beneath the main root,
absolute selectors being invalid, and synthetic host Root being mandatory.
Retain the separate current secrets and overlay contracts. Keep historical
release notes and accepted ADR decision text intact, apart from status links.
Include a release handoff in the final sprint report describing: an additive
minor release; new absolute and parent-relative selector support; the deliberately broader default import
scope; Root as the way to preserve containment; and compatibility of existing
valid configurations/resource coordinates. Version selection and writing the
version-matched note occur during the documented release preparation, not by
inventing a version or publication step here. Do not add release machinery.
Acceptance: current documents describe implemented behavior accurately and the
roadmap points to canonical owners after completion.
## Stage 15 — Validate and finish the sprint
Completed: the context/capture tables and feature diff were reviewed against
behavioral evidence. Final audit found and corrected glob union of distinct
physical parent directories after wildcard links; host/native regression tests
pass. Go 1.27.4 focused engine/public/consumer checks, ./scripts/check.sh and
go test -race ./... pass. Changed local Markdown links resolve. Public/dependency
boundaries, terminal failures, cleanup and retained resource coordinates pass
their existing suites. No release publication or downstream changes were made.
Use installed compatible Go and explicitly acquired dependencies as described
in development guidance. Run focused commands as relevant after dependent
stages compile:
```sh
go test ./internal/engine -run 'Import|Glob|Filesystem|Captured|MainRelative|Resource|SecretsFromConfig'
go test . -run 'Import|Glob|Filesystem|Search|MainRelative|SourceContext|Secrets|Failure'
go test ./examples/consumers
```
Finish with `./scripts/check.sh` and `go test -race ./...` for the completed
ownership/context changes. Reuse successful checks on unchanged code; rerun
affected validation after later edits. No benchmarks, allocation thresholds,
additional platform gates, CI waiting or real-service checks are required.
Review the diff against the context/capture tables and every roadmap target.
Check changed local Markdown links, examples, terminal failure paths, handle
cleanup and public/dependency boundaries. Ensure only intended feature changes
are staged. Mark the plan and roadmap complete only after the integrated result
is validated; commit completed nonempty units with plain-English messages.
Report tests, remaining limitations and workspace status. Do not publish a
release or update downstream consumers as part of this sprint.
## Open Questions
None required for this scope. The adopted roadmap decisions and the mechanical
context/access/capture choices above settle the implementation direction.
Helper names, small private file splits and test organization remain normal
implementation choices, subject to the existing ownership and testing policies.

View File

@@ -1,324 +0,0 @@
# 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.
Remediation status: complete. All four findings have been addressed. The review
descriptions and audit evidence below are historical; completion notes record
the subsequent fixes.
## 1. Resolve native link targets before parent steps in a literal glob prefix
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;
`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: complete.
Completed: the import contract distinguishes delegated named-file access from
explicit link inspection in directory/glob traversal. Absolute-target rejection
is scoped to that inspection; no runtime restrictions were added. The edited
paragraph and its existing section links were reviewed, and whitespace passes.
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.
## 3. Preserve symlink-target components before resolving host directory identity
Priority: P2. Status: complete.
Completed: host link targets retain unresolved components for the shared frame
evaluator. Bounded absolute target resolution keeps canonical containment and
uses rooted access for contained names. A regression compares all three import
selectors for relative/absolute targets and bounded/unbounded access; it fails
before the fix and passes afterward. Focused link/directory/glob tests,
`./scripts/check.sh`, and `go test -race ./internal/engine` pass.
Relevant code: `hostImportLinkOperations.normalizeTarget` at lines 237–249 of
[filesystem_links.go](../../internal/engine/filesystem_links.go), and the
`rootTarget.identity` handoff at lines 104–111 of `selectDirectoryImportCandidates`
in [import_selection.go](../../internal/engine/import_selection.go).
Host link-target normalization cleans the complete target before the shared
link-frame evaluator visits its components. If the target contains another
symlink followed by `..`, cleaning removes that inner link before resolving it.
The returned directory identity can therefore differ from the actual filesystem
target. The new unbounded absolute-target branch repeats this normalization;
the relative-target and bounded branches already had the same limitation.
An external host layout reproduces the integration failure:
```text
app/main.yml
external/
alias -> a/link/../shared
a/
link -> ../b/unit
shared/part.yml # value: wrong
b/
unit/marker
shared/part.yml # value: intended
```
The filesystem resolves `external/alias` to `external/b/shared`, as verified
with `filepath.EvalSymlinks`. A main declaring an absolute `dir` selector for
`external/alias`, with `pattern: '*.yml'` and `required: true`, instead loads
`external/a/shared/part.yml` and returns `value: wrong`. Equivalent absolute
`path` and `glob` selectors through the alias both load `external/b/shared/part.yml`
and return `value: intended`. The same disagreement occurs when the outer alias
contains the absolute target `<fixture>/external/a/link/../shared`. Both target
forms were reproduced through ordinary public `Load` with imports enabled and
no Root, using disposable files outside the checkout.
The directory selector initially validates the correct canonical directory, then
replaces its access path with the link resolver's incorrectly cleaned identity
before enumeration. This exposes an inherited resolver defect through the new
external-directory access mode, causing successful loading of unintended
configuration. It is distinct from finding 1: here the symlink target itself is
normalized incorrectly, including for host access, before any glob parent step.
Suggested remediation: preserve unresolved symlink-target components until the
shared link evaluator processes them in filesystem order. In particular, resolve
an intervening link before applying a following parent segment. Audit both
absolute and relative host-target coordinate conversion and keep directory
enumeration and cycle identity consistent with the validated canonical target.
Retain the existing iterative evaluator, active/completed link tracking, explicit
containment and native target policy; no stronger sandbox or mutation guarantee
is needed. Add a real-filesystem regression for both target forms that compares
directory selection with the corresponding named/glob targets. Check bounded
access as well, since it shares the normalization defect.
## 4. Avoid repeatedly resolving the ancestors of every literal glob prefix
Priority: P3. Status: complete.
Completed: literal prefixes now advance through one shared link evaluator from
an already resolved base. A component visitor retains directory/access errors,
containment checks and native source spelling. Completed-link metadata supports
continued traversal without re-inspection, and native target components retain
filesystem order. The semantic regression also covers a literal native glob
through a compound link target.
A disposable Go test overlay (outside the checkout, with no permanent count
assertions) compared link-free native prefixes at depths 8/16/32. Component
operations changed from 63/187/627 to 29/53/101. These are inspection counts,
not timing claims. Focused filesystem tests, `./scripts/check.sh`, and
`go test -race ./...` pass; changed local links and whitespace checks pass.
Relevant code: the loop in `globStartingCandidates`, lines 344–365 of
[glob.go](../../internal/engine/glob.go); `explicitGlobCandidate` in that file;
and `importEntryTarget` / `resolveImportLinkPath` in
[filesystem_links.go](../../internal/engine/filesystem_links.go).
The new prefix owner inspects each literal component in order, as required by
stage 7. However, each iteration calls `explicitGlobCandidate` with the entire
accumulated access path. That calls `importEntryTarget`, which starts a fresh
link-resolution walk from the namespace root. Its active/completed maps are
local to that call and do not reuse the preceding prefix inspection.
Consider a link-free native filesystem exposing `fs.ReadLinkFS`, with all
directories present and an absolute selector `/a1/a2/.../aD/*.yml`. At prefix
depth i, `importEntryTarget` calls `resolveNativeImportPath`, whose frame
evaluator issues an Lstat for each of the i components from the namespace root.
The prefix loop therefore performs at least
`1 + 2 + ... + D = D(D+1)/2` component Lstat calls, before counting its other
inspection calls. This is Theta(D squared) explicit component inspections for
a single chain, even with no links, aliases or wildcard branching. Host access
also repeatedly resolves the accumulated parent/full path, and then separately
canonicalizes it. Relative prefixes additionally revisit their base ancestors.
This bound counts ConfigKit-issued component inspections, not wall-clock time.
Path-string processing and the filesystem implementation's own path-resolution
costs are additional. The finding does not assert a particular measured cost or
an end-to-end linear-time guarantee.
Potential refactoring: retain traversal-local resolved-prefix state, or extend
the existing iterative evaluator to consume the literal prefix once while
reporting each completed component for the existing directory, error and
containment checks. On the link-free chain this can reduce explicit component
inspections to O(D), plus any initial base resolution, rather than restarting
for every prefix. Preserve separate lexical/physical coordinates and inspect a
directory before consuming a following `..`; cleaning the complete prefix is
not a substitute. Link expansions retain their own required work. Evaluate this
alongside findings 1 and 3, reusing the selected evaluator rather than introducing
a second resolver or persistent cache.
The plan expressly selects ordered component inspection and the iterative link
algorithm, but does not require restarting that algorithm at every component.
This opportunity concerns their call-site composition, not reconsideration of
those decisions. It is an optimization candidate, not a new release gate or
public performance promise.
## Initial implementation 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 findings 1 and 2. The public reproductions
remained outside the repository; no permanent tests, dependencies, release
gates or runtime changes were added for this audit.
## Integration audit coverage and validation
Integration follow-up reviewed at `22a022a9e85a37ccf7a77f6823412c34359f9d3e`;
production code remains at the implementation revision identified above.
At that review, findings 1 and 2 remained open; the follow-up added finding 3.
| Stage | Interaction reviewed | Result |
| --- | --- | --- |
| 1 | ADR 0026 versus discovery, companion-binding and bootstrap decisions | The selected import change preserves the other responsibilities. |
| 2 | Context validation versus discovery selection, synthetic inputs and absence | Base-only contexts and terminal selected-file validation follow the context table. |
| 3 | Unbounded access versus shared regular-file reads, directory reads and ownership | The existing read/accounting/cleanup owners remain in use. |
| 4 | Host link resolution versus directory access identity | Finding 3: normalization can select the wrong physical directory. |
| 5 | Rooted YAML selectors versus Go filesystem arguments and parser validation | Root interpretation stays in selection; Go namespace arguments remain unchanged. |
| 6 | External directory selection versus canonical validation, union and admission | Finding 3: enumeration can disagree with the target just validated. |
| 7 | Glob prefixes versus native link inspection and explicit roots | Finding 1 remains in literal-prefix parent handling. |
| 8 | Wildcard parents versus physical targets, filtering and candidate unions | Distinct physical parents are retained; findings 1 and 3 identify the remaining link-coordinate inconsistencies. |
| 9 | External source contexts versus origins, resolution and failure inspection | Passive contexts follow source IDs and preserve contained coordinates. |
| 10 | Derived/fallback contexts versus tier repetition and selected overlays | Import policy is copied while overlay access uses its legacy bound and lookup location. |
| 11 | Captured main policy versus later context selection and secrets bootstrap | Omitted roots preserve capture policy; bootstrap uses its separate captured anchor. |
| 12 | External inputs versus composition, mounting, versions, inheritance and inspection | The existing processing owners remain in use; focused lifecycle coverage passes. |
| 13 | Consumer example versus public source/resource APIs | The maintained external-import consumer example passes. |
| 14 | Updated documentation versus existing native filesystem behavior | Finding 2 remains the contract wording correction. |
| 15 | Combined integration verification | Focused suites pass; the additional public reproducer exposes finding 3. |
Commands run for this follow-up:
```sh
go test ./internal/engine -run 'Import|Glob|Filesystem|Captured|MainRelative|Resource|SecretsFromConfig'
go test . -run 'Import|Glob|Filesystem|Search|MainRelative|SourceContext|Secrets|Failure'
go test ./examples/consumers
```
All passed. The earlier everyday-check and full-race results above remain
applicable to unchanged production code. No production code or permanent tests
were changed, and no publication or downstream dependency updates were made.
## Algorithmic audit coverage
Reviewed at `cda0fa5`, with production code still at `9d86e33`. All stages were
considered in order. That follow-up added finding 4; findings 1–3 were still open.
| Stage | Algorithmic assessment |
| --- | --- |
| 1 | Decision documentation introduces no runtime algorithm. |
| 2 | The added context facts use fixed-size state and path validation; no growing input scan was introduced. |
| 3 | Bounded/unbounded dispatch adds constant branching per operation and retains the existing read/accounting owners. |
| 4 | The expressly selected iterative link frames and active/completed tracking are retained; ancestor restarts at their glob caller are covered by finding 4. |
| 5 | Root parsing, segment decoding and literal normalization scan selector/path text; no new pairwise selector processing was found. |
| 6 | Named/root unions use maps and deterministic sorting. Existing directory traversal, filtering and admission choices were preserved rather than reconsidered. Finding 3 remains the directory-identity correctness issue. |
| 7 | Finding 4 identifies quadratic repeated prefix inspections; finding 1 remains the native parent-coordinate correctness gap. |
| 8 | Candidate unions use composite-key maps and deterministic sorting. Distinct lexical/physical routes, wildcard ordering and visit budgets are deliberate choices; no additional defect was found in the new union code. |
| 9 | Context construction makes one pass over sources, with path work per source and O(S) context records for S sources. Per-source passive roots do not trigger source reacquisition. |
| 10 | Derived policy is a fixed-size context copy reused within the group; existing tier assembly and overlay algorithms remain unchanged. |
| 11 | Capturing import policy adds a string field; compatibility checks perform path work without reacquiring the main document or its imports. Existing snapshot ownership remains intact. |
| 12 | Lifecycle integration reuses existing composition, provenance and inspection algorithms; no alternate absolute-import pipeline was added. |
| 13 | The consumer example adds no production algorithm. |
| 14 | Documentation adds no runtime algorithm; finding 2 remains its contract correction. |
| 15 | Validation adds no production algorithm or new performance gate. |
Evidence for finding 4 is the static call chain and loop bound above. No timing,
allocation benchmarks, empirical performance measurements or new tests were
needed. Existing successful semantic checks apply to unchanged runtime code;
this pass changes only the audit record and validates its links and whitespace.
No additional correctness findings were identified beyond those already recorded.