Files
configkit/docs/adr/0026-optional-host-import-containment.md

4.1 KiB

ADR 0026: Separate Import Containment from Resource Anchors

Status

Accepted. Partially supersedes the inherited import-containment provision of ADR 0022.

Date

2026-12-05

Context

Applications need to import shared configuration outside the main file's directory. The relative lookup base, import boundary, and passive resource root serve different purposes. Treating the main directory as all three prevents ordinary shared-file layouts and couples import access to resource coordinates.

ADR 0019 keeps main selection explicit. ADR 0016 separates import selection controls, and ADR 0015 owns dependency ordering. Broader path selection can use these existing loading responsibilities.

Decision

Host imports have no implicit containment boundary. Absolute YAML selectors name host paths, and relative selectors use the declaring source's canonical directory. An explicit FilesystemContext.Root retains canonical containment for every transitive import. Synthetic host sources require an explicit BaseDir and may omit Root. An absent input with BaseDir alone uses that base without inferring the process working directory.

Within a supplied filesystem, leading-slash YAML selectors start at its namespace root. Relative selectors use the declaring source's namespace directory. The selected namespace and any explicit root continue to bound access; native Go path arguments and filesystem symlink targets retain their existing syntax.

Apply this interpretation to path, directory, and glob selectors. Establish a glob's literal starting location before wildcard discovery, then inspect each segment in order, including parent segments following wildcards. Preserve source identity, admission, dependency ordering, budgets, composition, and inspection.

Represent the optional import boundary separately from the existing resource, overlay, and bootstrap anchor and the lookup base. Derived main-relative inputs inherit those independent facts. Contained sources retain their existing passive resource coordinates; an external unbounded host source uses its own canonical directory as its passive resource root. This root does not constrain imports.

Captured main sources retain their import policy separately. Omitting a later root preserves that policy; a compatible explicit root may narrow an unbounded capture at its resource anchor. Existing incompatible-context errors remain.

Overlay lookup retains its established anchor and containment. Configured secrets bootstrap retains its separate relative-only, anchored access under ADR 0023. Loading remains synchronous and complete on return as described by ADR 0008, releasing loading handles before return and exposing passive resource contexts.

Alternatives Considered

  • Retain implicit main-directory containment and require callers to widen Root. This leaves shared layouts dependent on redundant context setup.
  • Widen every context root to the host root. This changes existing resource, overlay, and bootstrap coordinates along with import access.
  • Add a public permission switch. The existing explicit Root already expresses intentional containment.
  • Add a separate acquisition pipeline for absolute imports. This duplicates admission, accounting, link handling, and lifecycle responsibilities.

Consequences

This is an additive minor-release feature: existing valid configurations, public signatures, explicit roots, and resource coordinates remain compatible. Default host import scope deliberately becomes broader. Applications requiring the previous containment boundary specify Root explicitly.

The access owner supports bounded host, unbounded host, and native namespace operations. These use ordinary filesystem facilities and the existing stable-input assumptions; the change establishes no sandbox or concurrent-mutation guarantee. The roadmap owns implementation progress until canonical contracts are updated.