Plan main-relative companion inputs

This commit is contained in:
2026-11-09 18:39:25 +00:00
parent c51bea9b4f
commit ae0c94d3c6
3 changed files with 322 additions and 70 deletions

View File

@@ -1,7 +1,7 @@
# Main-relative companion imports and overlays
Status: all four design decisions settled; not implemented. Final API spelling
and implementation planning remain. Baseline: `191015e`.
Status: design settled; not implemented. The [implementation plan](implementation.md)
owns the concrete API spelling, execution order, and verification. Baseline: `191015e`.
## Purpose
@@ -205,74 +205,6 @@ architectural exclusions. The design follows
follow-up for deferred context ownership without rewriting accepted decisions.
No release version or additional release gate is selected here.
## Work from the baseline
1. **Finalize API spelling and examples.** Translate the settled decisions below
into concrete declarations and prepare Go examples for Audita's mapping/bytes
workflow, explicit overrides, non-file main contexts, and independently located
embedded inputs.
2. **Carry binding intent through the public facade and load request.** Update
the relevant input/options declarations and conversions in `layered.go` and
`lifecycle.go`, retaining root-owned public types and normal ownership rules.
Distinguish a deferred relationship from a concrete filesystem context.
3. **Bind underlay import contexts after main context resolution.** Extend
preparation and acquisition in `internal/engine/load_request.go`, `load_input.go`, and
`acquisition.go` as needed. Reuse the main's resolved base, root, and namespace,
apply the settled missing-base policy, and delegate selection to existing import
machinery. Preserve independently supplied contexts.
4. **Derive overlay context and separate lookup from containment.** Remove the
unconditional explicit-context requirement for the new layered default.
Preserve explicit and ordinary lookup while using the main context's resolved
base inside a potentially wider root. Reuse selected-overlay loading and its
failure and resource-ownership behavior.
5. **Verify the complete workflow and document it.** Add maintained consumer
examples, public integration coverage, and focused engine tests. Update the
discovery, layered-loading, import-context, and selected-overlay contracts,
declaration comments, and internal ownership documentation when implemented.
This is dependency order for a later implementation plan, not a required commit
layout or a requirement to expose intermediate stages to consumers.
## Validation and completion
Validate behavior through the public loading boundary, including:
- Explicit and discovered main files, early and later search candidates, and an
unrelated invocation directory. Companions follow the same selected main.
- Native file mains, bytes/readers/mappings with explicit host or native contexts,
and absent mains with explicit contexts. Cover absent host root-only contexts,
missing and invalid contexts, and context reuse without enabling main imports.
- Mapping, bytes, and reader underlays containing optional named-file and recursive
directory imports with `*.yml`/`*.yaml` filtering and mounted destinations.
- Receiving-input scope: active bindings on main inputs and file-backed underlays
fail with option errors; concrete context overrides retain their precedence.
- File only, directory only, both, neither, empty directories, and invalid or
unreadable selected fragments. Both forms compose as peers when present.
- Operator prompt overrides above embedded catalogs using registered identity;
same-tier duplicate IDs remain conflicts. Main and overlay precedence survive.
- Mixed embedded and companion inputs, multiple underlay tiers, transitive
imports, placement, source-version checks, and load-wide import defaults.
- Automatic derived overlays and explicit overrides, active and inactive names,
broader containment roots, and missing selected overlays.
- Optional discovery exhaustion, required discovery, fallback and skip policies,
mixed payload/required-import cases from OD-2, and terminal selected-main errors.
- Unused fallback paths need not exist or be accessible; selected fallback paths
receive normal validation. Inactive overlays ignore fallback settings.
- Empty `path: []` with either requiredness value when no base exists, including
the independent effect of `RequireBase`, and skipped imports without fabricated
completed-search evidence.
- Symlinks, eligible namespaces, parent-relative paths within the selected scope,
context validity, and namespace identity under OD-3 and OD-4.
- Normal source evidence, diagnostics, passive resource contexts, cleanup, and
budget accounting; no duplicate lifecycle callbacks or preliminary full load.
- Existing ordinary and explicit layered workflows and description reuse.
Run focused checks during implementation and applicable normal repository checks
before completion. No benchmark campaign is required. Completion means the
application can discover its main, bind companion imports and the selected
overlay, and receive normal resolved configuration and inspection in one load,
without an application directory walker, parser, or extra discovery pass.
## Settled Decisions
### OD-1: Public representation of deferred context binding — settled