diff --git a/docs/config.md b/docs/config.md index 2ec578f..7f47cc3 100644 --- a/docs/config.md +++ b/docs/config.md @@ -145,7 +145,8 @@ from attempted search directories. The same root-only context can accompany a search that selects a file: the selected file determines its base and must be inside `Root`. A selected host file rejects an explicit `BaseDir` or native filesystem context. Invalid context fails without resuming selection. Layered -overlays keep their independent `OverlayFilesystem` requirement. +overlays select an explicit context, the resolved main context, or their fallback +in the order described under [layered loading](#layered-loading). When a search selects a file, inspection reports that actual file with ordinary source IDs, paths, placement, metadata origins, and resource context. Missing @@ -212,9 +213,11 @@ CLI coordinates remain rooted at the application root. Ordinary `Load` recognize source-root collection declarations whether or not imports are enabled; an `imports` declaration still requires imports to be enabled. `NoSource` may enable imports, but it has no main declarations to traverse. It accepts an explicit -filesystem context: a host context requires an absolute existing `Root` and may -omit `BaseDir` to use that root as its internal import base; a native context -requires its namespace, `BaseDir`, and `Root`. Supplied context is validated even +filesystem context: a host context supplies an absolute existing `BaseDir`, +`Root`, or both. BaseDir alone also supplies the resource/overlay anchor and +leaves imports unbounded; Root alone supplies both base and explicit boundary. +An explicitly empty context is invalid and never selects the working directory. +A native context requires its namespace, `BaseDir`, and `Root`. Supplied context is validated even when imports are disabled. An active ordinary overlay requires this explicit context. `NoSource` accepts overrides and remains absent rather than contributing an empty document. @@ -375,12 +378,13 @@ selections fail without a base, while an empty `path: []` remains a no-op. Invalid declarations still fail, and skipped imports create no search evidence. Selected main failures never trigger fallback or a second discovery attempt. -Derived contexts preserve the main namespace and containment root, while lookup -starts at its resolved base. A host file's base is its canonical target directory, -including when the selected filename is a symlink. A wider root permits contained -parent-relative imports without moving the lookup base. Explicit non-file and -absent-main contexts can provide a base; an absent host input may use its root as -base. An unused fallback is not opened or checked for existence. See the +Derived contexts preserve the main namespace, optional import boundary and +resource/overlay anchor, while lookup starts at its resolved base. A host file's +base is its canonical target directory, including when the selected filename is +a symlink. Explicit Root bounds parent-relative and absolute imports without +moving that base. Explicit non-file, absent-main and fallback host contexts may +use BaseDir alone; a root-only absent context uses Root as its base. An unused +fallback is not opened or checked for existence. See the [consumer example](../examples/consumers/main_relative.go). Source IDs follow acquisition order—main and its depth-first imports, then each @@ -624,8 +628,13 @@ resolution query follows the callback's lifetime guard. Queries perform no filesystem access. Obtain IDs from exact origin locations rather than guessing one context for a composite origin or an application-derived value. -`ResourceContext.FS` is rooted at the source's configured root, and `BaseDir` -is its slash-relative directory inside that root. This includes imported +`ResourceContext.FS` uses the load context's resource anchor for contained sources, +and `BaseDir` is the source directory relative to that anchor using slash paths. +An unbounded external host import instead uses its own canonical directory as +its passive resource root, with BaseDir `.`. That resource root does not bound +the source's transitive imports. BaseDir-only synthetic host contexts use that +base as their resource anchor. Explicit-root and native coordinates retain their +configured roots. This includes imported sources, selected overlays, host files even without enabled imports, native files, and byte, reader, or mapping inputs with an explicit or main-derived context. CLI and contextless synthetic inputs have no resource context. To open a relative @@ -1192,16 +1201,18 @@ bootstrap again. The prepared source is a reusable snapshot of the selected main document, including its unconsumed controls, byte count, canonical file identity, base, -and containment root. A later load neither rediscovers nor rereads the main -and does not repeat bootstrap; it reads imports and resources when accessed and +resource/overlay/bootstrap anchor, and independent import boundary. A later load +neither rediscovers nor rereads the main and does not repeat bootstrap; it reads imports and resources when accessed and looks up secrets anew. The main's source record retains `SourceKindFile`. Each load clones the document, creates its own source IDs and records, and applies normal input accounting. No file handle or secret-file contents remain in the prepared source. With no later context, loading uses the -captured context. A supplied later host context must resolve to the same root, -base, and main path; equivalent path spellings and root symlink aliases are -accepted. Native contexts, a file `BaseDir`, and different roots fail with -`options.invalid`. A caller needing another root prepares the original source +captured context. A later host context with Root omitted preserves the captured +import policy, including explicit containment captured during preparation. An +explicit Root canonically equal to the captured anchor retains containment or +narrows an unbounded capture. Equivalent path spellings and root symlink aliases +are accepted without reselecting the main. Native contexts, a file `BaseDir`, and +different roots fail with `options.invalid`. A caller needing another root prepares the original source again. These rules apply to ordinary options and layered main inputs. The helper returns a non-nil report on every attempt and a zero, unusable source @@ -1838,8 +1849,16 @@ The [mounted-root example](../examples/consumers/config_controls_test.go) shows an imported payload becoming application-root `config`. Inspection YAML can contain that data and retains its existing lack of a reloadability guarantee. -Path declarations use slash-separated relative paths. Absolute paths and network -URLs are invalid. Each path resolves from its declaring file's canonical directory. +Path, directory and glob selectors accept absolute and parent-relative paths. +Absolute host selectors name host paths directly; relative selectors use the +declaring file's canonical directory, including for transitive external imports. +Synthetic and absent contexts use their selected base. Within a supplied `fs.FS`, +a leading `/` selects from that namespace's root; relative paths use the declaring +source's namespace directory. Targets must remain addressable within that +namespace and any explicit Root. This YAML syntax does not change the +slash-relative `fs.ValidPath` syntax of native Go source/context arguments. +Network URLs and schemes remain invalid; supported host volume roots are paths. +There is no shell expansion, environment substitution or remote fetching. An empty `path: []` selects nothing; it succeeds even when `required: true` because there are no named targets to be missing. A nonempty required path list verifies every named target, including targets later excluded from selection. @@ -1864,7 +1883,16 @@ walks only directories selected by preceding segments, and reads wildcard directories in bounded batches. Every examined entry consumes the separate visit budget, including nonmatches. Literal components are explicit path components; `follow` and `hidden` filter only wildcard-discovered entries. `exclude` filters -final candidate basenames. +final candidate basenames. Absolute roots and the longest literal prefix select +the starting location before wildcard discovery. For Root `/allowed/config`, +`/allowed/config/fragments/*.yml` starts in its contained fragments directory; +ancestors used only to resolve that prefix are not discovery directories. Every +actual discovery/traversal target remains subject to containment. Literal +components are inspected in order, so a missing directory before `..` cannot be +cleaned away. After a wildcard, `..` advances from each inspected matched +directory, preserving link targets and access failures. For example, +`services/*/../shared/*.yml` expands `*` before traversing its parent. A fully +literal glob follows named-file requiredness and regular-file checks. `Options.ImportDefaults` and `LayeredOptions.ImportDefaults` provide one application-owned load-wide policy for enabled imports in the main source, @@ -1965,31 +1993,48 @@ Physical paths continue to resolve from the file that declares each import. An actual empty mapping contributes an empty item, while an unmatched declaration with default or explicit `required: false` contributes nothing. -For host files, the configuration root defaults to the selected file's -canonical directory. A host file may supply `FilesystemContext.Root` to widen -that root but may not supply `BaseDir` or a native `FS`. Byte, reader, and -mapping inputs with host context must provide both `BaseDir` and `Root` as -absolute existing directories. For `Filesystem.File`, the default root is `.` -in its namespace and the base is the selected file's directory. An explicit -context must use the same `Filesystem` namespace and may set `Root` to contain -the file and its base; it may not supply `BaseDir`. Byte, reader, and mapping -inputs with native context provide both `BaseDir` and `Root` as slash-relative -`fs.ValidPath` directories in `FS` (`.` means its root), with the base inside -the root. Context paths are checked even when imports and overlays are -inactive. Diagnostic labels, including URI-looking labels, never imply -filesystem paths. Nonregular targets are rejected before opening to avoid -blocking on FIFOs; post-open regular-file checks remain in place under the -stable-input assumption. ConfigKit canonicalizes symlinks, checks containment -with relative paths, and opens the canonical root-relative target through a -library-owned root handle. Contained relative or absolute symlink targets are -accepted; escapes are rejected. Canonical paths define identity, so hard links -at distinct paths remain distinct sources. Native filesystems use slash-path -operations. Where the supplied `fs.FS` implements `fs.ReadLinkFS`, ConfigKit -uses that capability to inspect and resolve discovered links; otherwise it -follows the filesystem's ordinary `fs.FS` behavior. ConfigKit does not require -every native filesystem to expose link inspection, and native filesystem -behavior is not a general sandbox guarantee. Imports stay in their selected -namespace and root. +For host files, imports are unbounded by default, subject to ordinary filesystem +access and the existing admission and resource budgets. `FilesystemContext.Root` +explicitly bounds canonical targets, including links and transitive imports. +The selected file and base must be inside that root. A selected file determines +its own base and rejects BaseDir or native FS. Its canonical directory remains +the default resource/overlay/bootstrap anchor even when imports can reach beyond +it. Existing valid configurations and resource coordinates remain compatible; +applications preserving the earlier containment scope explicitly set Root. + +Byte, reader and mapping host inputs require an absolute existing BaseDir even +for absolute-only selectors. Root is optional; omission uses BaseDir as the +resource/overlay/bootstrap anchor with unbounded imports. Explicit Root must be +an existing directory containing the base. Context paths are checked even when +imports and overlays are inactive. Diagnostic labels, including URI-looking +labels, never imply filesystem paths or a working-directory base. + +For `Filesystem.File`, the default root is `.` in its namespace and the base is +the selected file's directory. An explicit context must use the same Filesystem +namespace and may set Root to contain the file and base; it may not supply +BaseDir. Synthetic native inputs still supply both BaseDir and Root as +slash-relative fs.ValidPath directories in FS, with the base inside the root. +There is no host fallback from a native namespace. + +Nonregular targets are rejected before opening to avoid blocking on FIFOs; +post-open regular-file checks remain in place under the stable-input assumption. +Host canonical paths define identity, so hard links at distinct paths remain +distinct sources. Unbounded host access uses ordinary OS operations; explicit +containment uses a library-owned root handle. Host links may reach external +locations under unbounded access; explicit Root still bounds their canonical +targets. Discovered-link follow controls remain independent of containment. +Native filesystems use slash-path operations and fs.ReadLinkFS when supplied; +otherwise they follow their ordinary fs.FS capabilities. YAML leading-slash +selector rewriting does not apply to native symlink targets: native absolute +link targets retain their existing rejection. These facilities provide no +additional sandbox or concurrent-filesystem mutation guarantee. + +Import widening does not widen selected-overlay lookup or configured secrets +bootstrap. Those continue using the legacy anchor and their own contracts. +[ADR 0026](adr/0026-optional-host-import-containment.md) records the separation; +the maintained [external-import example](../examples/consumers/external_imports_test.go) +and [YAML illustration](../examples/consumers/testdata/external-imports/main.yml) +show a one-load consumer workflow. An active-stack repeat is `import.cycle` and reports the complete cycle's import sites. A previously visited canonical path is `import.repeated` and reports both diff --git a/docs/consumers/README.md b/docs/consumers/README.md index 6325384..8476742 100644 --- a/docs/consumers/README.md +++ b/docs/consumers/README.md @@ -33,6 +33,17 @@ Start with one file, then choose the tasks your application needs: | Hand one result to library consumers | [Component handoff](#component-handoff) | | Upgrade an existing consumer | [Migration guidance](#intentional-migration-changes) | +## Shared external configuration + +The [external-import example](../../examples/consumers/external_imports_test.go) +loads the [illustrated main](../../examples/consumers/testdata/external-imports/main.yml) +and a shared file, including its own relative import, in one ordinary load. +It follows the resource field's origin to select its SourceContext. The test also +shows deliberate containment with FilesystemContext.Root. See the +[import contract](../config.md#explicit-imports) for host and namespace-root +selectors and the [resource contract](../config.md#source-resource-contexts) +for coordinates and lifetime. + ## Component handoff Register application and library rules in one definition, then load once and diff --git a/docs/development.md b/docs/development.md index 2319197..94bef75 100644 --- a/docs/development.md +++ b/docs/development.md @@ -60,6 +60,7 @@ Accepted decisions: - [Compare frozen effective configuration snapshots](adr/0010-effective-configuration-diff.md) - [Compare inspection views across application types](adr/0024-compare-inspection-views-across-application-types.md) - [Inspect failed configuration loads](adr/0025-inspect-failed-configuration-loads.md) +- [Separate import containment from resource anchors](adr/0026-optional-host-import-containment.md) - [Place inputs at literal application mapping paths](adr/0011-input-destinations.md) - [Share dependency-ready ordering](adr/0015-shared-dependency-ready-ordering.md) - [Separate import selection controls](adr/0016-independent-import-controls.md) @@ -131,6 +132,7 @@ code changes. Use the component overview to find the corresponding implementatio | --- | --- | --- | | YAML syntax, diagnostics, parser limits | [Adapter tests](../internal/yaml/parse_test.go), [source translation](../internal/engine/parse_test.go) | `go test ./internal/yaml` and `go test ./internal/engine -run '^TestParseSource'` | | File/reader access, imports, globs, containment | [Import internals](internal/imports.md), [source acquisition](../internal/engine/source_test.go), [FIFO](../internal/engine/source_fifo_test.go), [import traversal](../internal/engine/imports_test.go), [import evidence](../internal/engine/import_evidence_test.go), [relative destinations](../internal/engine/destination_import_test.go), [globs](../internal/engine/glob_test.go) | `go test ./internal/engine -run 'Source\|Import\|Glob\|Filesystem\|Nonregular\|RegularFile'` | +| Absolute/parent-relative imports and external resource contexts | [Public lifecycle](../facade_absolute_import_test.go), [acquisition](../internal/engine/absolute_import_test.go), [glob roots](../internal/engine/glob_root_test.go), and [consumer example](../examples/consumers/external_imports_test.go) | `go test . -run AbsoluteImport`, `go test ./internal/engine -run 'Absolute\|External\|SelectGlob'`, and `go test ./examples/consumers` | | Explicit main-file discovery and absent-input loading | [Candidate selection](../internal/engine/discovery_test.go), [load integration](../internal/engine/discovery_load_test.go), [public facade](../facade_discovery_test.go), and maintained [catalog](../examples/consumers/sequence_catalog_test.go) and [preset](../examples/consumers/discovery_test.go) examples | `go test ./internal/engine -run 'Discovery\|Search'`, `go test . -run 'Search'`, and `go test ./examples/consumers -run 'WorkingDirectoryPreset\|SequenceCatalog'` | | Import defaults, empty-selection evidence, and dependency-ready ordering | [Defaults and facade evidence](../facade_import_defaults_test.go), [engine import evidence](../internal/engine/import_evidence_test.go), [scheduler](../internal/engine/dependency_order_test.go), [scheduling integrations](../internal/engine/imports_test.go) | `go test ./internal/engine -run 'Import\|ScheduleDependencies\|Inheritance'`, `go test . -run 'ImportDefaults\|FacadeImport'`, and `go test ./examples/consumers` | | Native filesystem and mapping sources | [Native acquisition](../internal/engine/native_filesystem_test.go), [filesystem facade](../facade_filesystem_test.go), [mapping facade](../facade_mapping_test.go) | `go test ./internal/engine -run 'NativeFilesystem'` and `go test . -run 'TestFacade'` | diff --git a/docs/internal/imports.md b/docs/internal/imports.md index 91d8e1d..74f2ec8 100644 --- a/docs/internal/imports.md +++ b/docs/internal/imports.md @@ -21,7 +21,8 @@ overlapping roots. Exclusions are applied as set difference after discovery and candidate normalization. They do not suppress discovery or resource errors. Layered assembly passes the resolved main context to underlay acquisition. -Derived inputs retain the main's filesystem location and namespace. The +Derived inputs retain the main namespace, lookup base, resource anchor and +independent optional import boundary. The receiving tier supplies its own host token and tracks repeated sources. Contextless bindings prepare declaration policies and assemble the declaring payload without opening filesystem access or recording selection evidence. @@ -31,7 +32,7 @@ A captured host main enters the same parsed-source and import traversal handoff as an ordinarily selected file. Its original bytes and nodes are charged once per load, including placement wrappers, and its canonical path participates in cycle and repeated-source checks. Imports are still acquired live; layered -main-relative consumers receive the captured base and root, while each tier +main-relative consumers receive the captured base, anchor and import policy, while each tier continues to use its own namespace token and repetition state. The capture and context checks are owned by [`prepared_source.go`](../../internal/engine/prepared_source.go) and @@ -41,14 +42,17 @@ Directory traversal tracks canonical directories on the active traversal path. It adds an identity when descending and removes it when the frame is popped, so only a back-edge to an active directory is a traversal cycle; a later alias is not mistaken for one. This is separate from import dependency-cycle detection. -For host sources, discovery uses rooted `Lstat` and canonical containment. +Host discovery dispatches to ordinary OS Lstat/Readlink for unbounded imports, +or rooted operations with canonical containment for an explicit boundary. `filesystem_context.go` owns resolved access facts and live access setup; the acquisition operation closes its live handles before composition. Native sources use `fs.ReadLinkFS` inspection when supplied; otherwise traversal follows the capabilities and behavior of the provided `fs.FS`, without claiming a general sandbox guarantee. `source_context.go` derives passive resource contexts from -resolved sources for later caller-owned reads; those records do not retain live -acquisition handles. +resolved sources for later caller-owned reads. Contained sources keep the legacy +anchor and coordinates; external unbounded host sources use their own canonical +directory as a passive root. Those roots never constrain transitive acquisition +and retain no live handles. Host and native link bindings share one iterative link-frame evaluator. It tracks active links for cycle detection and reuses successfully completed link @@ -59,6 +63,22 @@ directory can be treated as optional, while enumeration and close failures remain selection errors, including errors from the standard `fs.ReadDir` fallback. +`filesystem_context.go` separates rootPath (resource/overlay/bootstrap anchor), +basePath (relative lookup), and importRoot (optional host containment, or native +namespace boundary). An empty host importRoot is no path to canonicalize or open. +`filesystem_access.go` owns bounded host, unbounded host and borrowed native +operation dispatch; host accesses preserve their tier token across directories. +Overlay setup explicitly selects the legacy anchor as its access root. Configured +bootstrap also uses the captured legacy anchor, independently of importRoot. + +Literal selector resolution in `import_selection.go` distinguishes host absolute +paths, native namespace-root selectors, and relative bases before candidate +normalization. Glob roots are separated from pattern segments without whole-pattern +cleaning. The longest literal prefix is inspected component by component before +discovery, permitting resolution ancestors of explicit roots without enumerating +them. Parent segments after wildcards advance from inspected matched directories, +retaining lexical candidates separately from physical access paths. + Glob selection keeps traversal coordination in `selectGlobImportCandidates`: it advances literal and patterned segments, reads directories, unions and sorts candidates, validates final targets, then applies exclusions and requiredness. diff --git a/docs/internal/overview.md b/docs/internal/overview.md index ef88660..d1e40df 100644 --- a/docs/internal/overview.md +++ b/docs/internal/overview.md @@ -125,8 +125,12 @@ share one assembly handoff that applies collection declarations and projects only that tier's source/version evidence; the caller keeps main-version protection and its projection explicit. Live filesystem access handles are confined to acquisition and closed there. Resolved -filesystem facts used to authorize access are separate from passively retained -resource contexts. Non-import validation retains those facts on `assembledInput` +filesystem facts separate an optional import boundary from the lookup base and +legacy resource/overlay/bootstrap anchor. `filesystem_access.go` dispatches bounded +host operations through os.Root, unbounded host operations through ordinary OS +calls, and native operations through the borrowed namespace. Passive source +contexts keep contained coordinates and use each external unbounded host source's +canonical directory as its resource root; they do not limit transitive imports. Non-import validation retains those facts on `assembledInput` for passive-context construction and ordinary-overlay handling: see [`filesystem_context.go`](../../internal/engine/filesystem_context.go) and [`source_context.go`](../../internal/engine/source_context.go). @@ -134,12 +138,16 @@ for passive-context construction and ordinary-overlay handling: see Explicit configured bootstrap uses [`prepared_source.go`](../../internal/engine/prepared_source.go) to share host discovery and bounded parsing with acquisition. It stores a read-only main tree, -byte count, and canonical path facts; each load clones the tree and assigns its +byte count, canonical path facts and independent import policy; each load clones +the tree and assigns its own source ID. [`secrets_from_config.go`](../../internal/engine/secrets_from_config.go) validates just the bootstrap controls and calls the shared directory worker. Acquisition checks any later explicit context against the captured facts before imports or overlays, then applies normal source and aggregate accounting. -Captured state contains no access handles or secret-file values. +Captured state contains no access handles or secret-file values. Omitted later +roots preserve captured import policy; compatible explicit roots can narrow an +unbounded capture. Bootstrap and overlays continue using the legacy anchor. +[ADR 0026](../adr/0026-optional-host-import-containment.md) records that separation. Import responsibilities are split across candidate selection and path normalization in [`import_selection.go`](../../internal/engine/import_selection.go), diff --git a/docs/policy/architecture.md b/docs/policy/architecture.md index 09bd11b..4b6e7e4 100644 --- a/docs/policy/architecture.md +++ b/docs/policy/architecture.md @@ -178,6 +178,11 @@ dependency-ready scheduling within their existing scopes; acquisition order and precedence-tier boundaries remain distinct. The [configuration contract](../config.md#explicit-imports) owns observable behavior; [ADR 0015](../adr/0015-shared-dependency-ready-ordering.md) and [ADR 0016](../adr/0016-independent-import-controls.md) record the decisions. +Host imports use an optional explicit containment boundary, separate from the +relative lookup base and resource/overlay/bootstrap anchor. Native imports stay +in their selected namespace. Broader import access must not widen overlays or +secrets bootstrap or change existing contained resource coordinates. +[ADR 0026](../adr/0026-optional-host-import-containment.md) records this decision. The explicit secrets-directory bootstrap is a narrow, opt-in exception: applications invoke it during startup, and it reports writes, skips and partial failures. It must never run implicitly as part of configuration loading. diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 0a6a13d..89905f7 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -476,6 +476,11 @@ 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 diff --git a/internal/engine/load.go b/internal/engine/load.go index 7eb2feb..192e798 100644 --- a/internal/engine/load.go +++ b/internal/engine/load.go @@ -37,9 +37,9 @@ type Options[T any] struct { PlacementMode PlacementMode } -// FilesystemContext supplies filesystem roots for imports and overlays. For an -// absent host input, Root is required and BaseDir may be omitted to use Root as -// the import base. Native contexts still require both BaseDir and Root. +// FilesystemContext transports the public filesystem selection. Host Root is +// optional import containment; BaseDir alone supplies a synthetic/absent base +// and resource anchor. Synthetic native contexts still require both directories. type FilesystemContext struct { BaseDir string Root string diff --git a/lifecycle.go b/lifecycle.go index 8aea164..df403f5 100644 --- a/lifecycle.go +++ b/lifecycle.go @@ -90,7 +90,8 @@ type ImportDefaults struct { // Options contains the application definition and per-load input selections. // Imports enables traversal of source-root declarations; an absent source has -// no main declarations to traverse. Controls are interpreted before placement, +// no main declarations to traverse. Host imports are unbounded unless Root is +// explicit; native imports stay in the selected namespace. Controls precede placement, // while nested and assembled application config values remain data. Overlay selects one fixed // overlay and requires filesystem context for NoSource. Overrides contain only // values explicitly supplied by an application CLI. @@ -117,12 +118,18 @@ type Options[T any] struct { SourceVersionMode SourceVersionMode } -// FilesystemContext supplies roots for imports and overlays. With FS nil, -// BaseDir and Root use absolute host paths. For NoSource, Root is required and -// BaseDir may be omitted to use Root as the import base. With FS set, BaseDir -// and Root use slash-relative paths in that namespace ("." denotes its root). -// File sources derive BaseDir from the selected file; a native file's explicit -// Root limits its scope. +// FilesystemContext supplies filesystem lookup, import containment and resource +// anchors. With FS nil, synthetic sources require an absolute existing BaseDir; +// Root is optional and explicitly bounds host imports when supplied. Without +// Root, host imports may reach other host paths. A selected file derives its +// own BaseDir and rejects a supplied one. Its directory is the default resource, +// overlay and secrets-bootstrap anchor, independently of import containment. +// NoSource may supply BaseDir alone, Root alone (also used as its base), or both; +// an empty supplied context does not establish a working-directory default. +// With FS set, BaseDir and Root remain slash-relative fs.ValidPath directories +// in that namespace ("." denotes its root). Synthetic native inputs require both; +// native files derive their base and default Root to ".". YAML leading-slash +// selectors start at the namespace root; Go context paths remain slash-relative. type FilesystemContext struct { BaseDir string Root string diff --git a/secrets.go b/secrets.go index 3c78b2a..a7a9f40 100644 --- a/secrets.go +++ b/secrets.go @@ -113,7 +113,8 @@ func LoadSecretsIntoEnvironmentWithOptions(directory string, options SecretsOpti // SecretsFromConfigOptions configures preparation of a host main source. type SecretsFromConfigOptions struct { - // Filesystem selects the main file's host containment root when supplied. + // Filesystem selects the main host context. Its Root bounds bootstrap; + // omitted Root keeps bootstrap at the selected main directory. Filesystem *FilesystemContext // Overwrite, when non-nil, overrides the main document's Boolean setting. // A nil value uses that setting, or false when it is absent. @@ -128,7 +129,9 @@ type SecretsFromConfigOptions struct { // NoSource and an optional search with no match return NoSource and an empty // report. The returned source owns a reusable main-document snapshot and its // host context; imports and environment lookup remain part of each later load. -// A later explicit host context must match the captured root and base. +// A later omitted Root preserves captured import policy. A supplied compatible +// Root at the captured anchor retains or narrows import containment; a different +// root, supplied BaseDir or native filesystem is incompatible. // At most one options value is accepted. A non-nil report accompanies every // result. Preparation failures return *LoadError; directory or environment // failures return *SecretsError. Any error returns a zero Source and does not