Plan native configuration acquisition migration

This commit is contained in:
2026-11-23 02:35:17 +00:00
parent b63bef2d43
commit 9fb0c6a994
2 changed files with 377 additions and 3 deletions

View File

@@ -10,9 +10,10 @@ ConfigKit owns configuration resolution through the final handoff; Narratio owns
startup ordering, domain interpretation, and execution, as defined by
[ADR 0003](../adr/0003-assign-configuration-ownership.md).
This roadmap defines the target and required changes. A subsequent implementation
plan will define staged work. Audita adoption and session layout remain in the
separate [Audita](audita.md) and [workspace](workspace.md) roadmaps.
This roadmap defines the target and required changes. The
[implementation plan](implementation.md) defines the staged work. Audita adoption
and session layout remain in the separate [Audita](audita.md) and
[workspace](workspace.md) roadmaps.
## Reviewed Upstream Releases

View File

@@ -0,0 +1,373 @@
# ConfigKit and CommandKit adoption implementation plan
## Scope and execution
Implement the target in [config.md](config.md). This plan is for a Luna coding
agent working through one end-to-end sprint. Execute the numbered stages in
order. Intermediate stages may leave callers or tests temporarily incompatible;
do not add compatibility routes merely to keep each intermediate commit green.
The completed sprint must compile, pass validation, and implement the full target.
Report intermediate verification limitations accurately.
Start each prompt with `docs/development.md` and `docs/policy/agents.md`. Read
the architecture and testing policies for code work, the documentation policy for
documentation work, and the OSS policy for dependency/attribution work. Follow
the repository's graph-first code-discovery guidance. File names below identify
the current owners, not a requirement to preserve their internal structure.
Read the feature roadmap once for scope and intent, then the focused files named
by each stage. Use its pinned upstream references for native semantics. This plan
specifies Narratio changes; it is not a replacement library reference.
### Decisions carried into implementation
- Select ConfigKit v1.4.0, CommandKit v0.8.0, and `ckconfig` v0.11.0 together.
Preserve the Go minimum and maintained toolchain.
- Pipeline selection produces a native source. Command-owned acquisition calls
`LoadSecretsIntoEnvironmentFromConfig` and passes the returned source to the
same pure pipeline loader used by library callers. Leave bootstrap options at
their native defaults, including filesystem context and overwrite selection.
- Retire `--secrets-dir` and the conventional-directory fallback completely.
Ordinary library loading remains free of environment writes.
- Reuse an acquired result within its acquisition object. Each distinct pipeline
acquisition performs ordinary native preparation and loading. Comparison
sides use that same path, shared process environment, and native `ckconfig`
comparison behavior. No primary-side bootstrap or environment restoration.
- Use a small CommandKit invocation feature for bootstrap evidence reporting,
as described in Stage 5. Acquisition retains fallible startup work. This
replaces the current byte-buffer capture and scope report-forwarding wrappers.
- Preserve the existing app, campaign, session, and party scopes, configuration
rules, domain catalogs, persistence, resume evidence, subprocess credential
forwarding, and cleanup behavior apart from the agreed startup changes.
Audita/workspace implementation, new scopes, and `ckprompt` are separate work.
- Keep upstream feature documentation upstream. Local documentation describes
Narratio's selections, wiring, domain rules, and operator workflows.
## Stage 1 — Update the coordinated dependencies and notices
Read `go.mod`, `go.sum`, the three component entries in
`docs/oss/attribution.md`, and the release references in the feature roadmap.
1. Update ConfigKit to v1.4.0, CommandKit to v0.8.0, and `ckconfig` to v0.11.0.
Resolve/tidy the module graph without adding local replacements, sibling
checkout dependencies, or unrelated upgrades.
2. Update the three attribution entries to the exact imported commits recorded
in the roadmap, retaining the current license expressions and notice format.
Check the upstream notices; reuse unchanged local standard texts.
3. Keep the existing Go/platform declarations and CommandKit/ckconfig public
assembly unless a real compilation adjustment is required. Convert any
affected positional upstream struct literal to a keyed literal.
Validation: inspect the selected module versions and dependency diff. Run
`go test ./internal/config ./internal/app ./internal/doccheck` and
`go build ./...` as an initial compatibility check. Subsequent stages intentionally
change startup behavior; this compatibility check is not sprint completion.
## Stage 2 — Share native source selection and pure pipeline loading
Read `internal/config/load.go`, `pipeline_configkit.go`,
`pipeline_discovery_test.go`, `pipeline_configkit_test.go`, and
`native_results_test.go`. Consult ConfigKit's prepared-source contract.
1. Extract the existing file/search source construction into one helper, proposed
name `PipelineSource(path, opts)`. Keep current explicit-file selection,
discovery order, injected `Search`, and required-search behavior.
2. Add a source-taking entry point, proposed name
`LoadPipelineSourceWithOptions(source, opts)`. It must perform the current
`loadPipelineConfigKitResult`, metadata attachment, and
`finalizeLoadedPipeline` path with the supplied native source.
3. Make `LoadPipelineWithOptions(path, opts)` select its source and delegate to
that entry point. Existing library callers continue to load configuration
without bootstrapping the process environment.
4. Preserve overlay normalization, inspection overrides, defaults, resolution,
validation, native result retention, selected-source provenance, and effective
digest behavior. Do not reconstruct or serialize a prepared source to a new
file/bytes source. Keep ConfigKit types inside the existing config/application
boundary rather than adding a general source abstraction.
5. Add a focused test that a native prepared source is consumed successfully
after its original main file changes, while its original source identity and
context remain useful. Also verify that the pure loader alone does not apply
a declared secrets directory. These tests protect Narratio's handoff, not
ConfigKit's entire snapshot implementation.
Validation: `go test ./internal/config`. Reuse existing import, discovery,
overlay, provenance, and materialization tests rather than duplicating them.
## Stage 3 — Replace startup guards with ordinary pipeline acquisition
Read `internal/app/configuration_acquisition.go`, `config_loader.go`,
`command_dependencies.go`, `secrets_bootstrap.go`, and the Stage 2 entry points.
Use graph search to find startup resets and dependency seams in command helpers.
1. Change `configurationAcquisition.Pipeline` to check cancellation/selection,
return its cached pipeline when available, then select, prepare/bootstrap,
and load the native source. Keep the bootstrap report separately from the
completed configuration, including on preparation/bootstrap failure.
2. Replace the old path-based loader/direct-directory test seams with narrow
seams for native source preparation and source loading where needed by
existing tests. Their production defaults call ConfigKit's helper and the
Stage 2 loader. Source selection has one owner; the application uses the
shared selection helper and passes `pipelineSearch` through existing options.
3. Consolidate or remove `loadPipelineConfigWithDependencies` so it no longer
constitutes another startup route. Preserve useful error context and native
causes. Obtain the resolved pipeline path from the completed native result.
4. Delete `secretsBootstrap`, `selectedSecretsDirectory`, the conventional path
variable/probe, `loadSecretsDir`, and the per-command bootstrap resets.
Remove `bootstrap()` calls from campaign/party/session/domain acquisition;
retain their cancellation and selection checks where still needed.
5. Keep explicit local campaign/session/party inspection independent of pipeline
acquisition. Retain remote session acquisition and resource release through
the existing domain path. Every command that needs a pipeline, including
planning, initialization, restore, and clean-all, reaches the same ordinary
pipeline acquisition.
6. Cache completed results normally. Distinct acquisitions, including native
comparison loads, prepare their own sources. Do not replace the retired
invocation guard with a source-keyed bootstrap registry, cached environment,
failure-replay mechanism, or primary/secondary role flag.
The small reporting connection needed here is completed in Stage 5. Update
direct acquisition tests as the new seams become available. Other caller/test
breakage can remain visible until Stage 4; do not retain old startup machinery
as a temporary compatibility API.
Validation: focused acquisition and pure-loader tests that are runnable at this
point. Confirm by code review that environment mutation occurs only in explicit
command-side native preparation, and reuse returns before another preparation.
## Stage 4 — Remove the CLI surface and migrate affected fixtures
Read `internal/app/command_selection.go`, command declarations reached by its
flags, `configuration_commands.go`, and tests identified by graph search for
`SecretsDir`, `secretsBootstrap`, and `loadSecretsDir`.
1. Remove the secrets selector field, flag binding, empty-value check, scope
selector registration, and flag installation from every command declaration.
Retain other selectors and domain input checks.
2. Migrate existing command fixtures using `--secrets-dir` to a root pipeline
declaration and a temporary adjacent secrets directory, or to disposable
environment values when the fixture is not testing bootstrap. Keep unrelated
test intent intact; no real credentials or installed directories.
3. Delete obsolete tests of the removed flag/fallback helpers and invocation
guard. Update loader stubs to the Stage 3 seam. Remove `TestMain`'s temporary
conventional-directory redirection in `test_environment_test.go` when it has
no remaining purpose; retain useful environment-restoration helpers.
4. Add representative CLI coverage that the removed flag is absent from help
and rejected as an unknown flag. The shared binding removal supplies the
rest of the command tree; do not add a separate exhaustive parser suite.
Validation: compile/test `internal/app` and `cmd/narratio` as far as remaining
Stage 5 reporting changes allow. Search active code for retired selectors and
bootstrap types; remaining references should be intentional retirement tests,
not production compatibility handling.
## Stage 5 — Report native bootstrap evidence through CommandKit
Read `internal/app/commands.go`, `command_reporting.go`, `command_outcome.go`,
`configuration_commands.go`, and the upstream invocation-feature, `Report`,
`SecretsReport`, and diagnostic-rendering APIs at the adopted versions.
1. Install one flag-free CommandKit invocation feature through normal application
assembly. Its `Start` creates a small invocation-local evidence collector and
places it in the context. Startup does no file access or bootstrap. Keep the
caller's cancellation context intact.
2. Ordinary pipeline acquisition records its returned native `SecretsReport`
reference in that collector, including when preparation fails or a later
configuration load fails. On `SecretsError`, retain native diagnostic records
for presentation as well. Acquisition still returns the native error through
the normal command outcome path; the collector does not choose success.
3. Return a final report producer from the feature. Use native final diagnostic
timing, text rendering independent of the main `--format`, and quiet-mode
handling. This intentionally replaces the old successful-bootstrap Info-only
delivery path with native final diagnostic reporting. No evidence means no
rendered bytes; help and direct non-pipeline inspection acquire no evidence.
4. Bridge native evidence to `commandkit.Report` with a small text template and
a value whose rendering method delegates to `SecretsReport.WriteTo` and
`configkit.WriteDiagnostics` for bootstrap-directory failures. `Report` exposes
`Value`/`TextTemplate`, not an arbitrary writer callback: a local
`strings.Builder` in that final formatter is sufficient. Preserve renderer
errors for CommandKit; do not duplicate native line formatting or retain an
eagerly rendered error/report string. Only safe native bootstrap evidence
belongs in this report, never configuration credential values.
5. Leave `LoadError` presentation to existing native ckconfig adaptation and
domain outcome handling, avoiding a second copy in the bootstrap report.
Keep joined operational/cancellation causes and current native classification;
do not invent custom status codes or translate `SecretsError` into `LoadError`.
6. Remove `pendingDiagnostics`, `bootstrapDiagnostics`, the diagnostic-only
`Scope.Acquire`/`Scope.Compare` wrappers, and the old bootstrap writer adapter
where now unused. Remove the `independent` flag and selection-to-acquisition
map: each native scope loader callback creates its own acquisition object
with that callback's selections and overrides. Reuse within that object's
dependency chain remains sufficient. This lets native comparison loaders
receive separate results without any local comparison wrapper, and permits
distinct aggregate-scope loads to perform ordinary startup as well.
7. Keep substantive command reports, logging adapters, final persistence, and
session resource cleanup on their existing boundaries. Diagnostic delivery
failures remain CommandKit's finalization concern and do not interrupt durable
work. A background-context unit test can inspect acquisition-retained evidence;
it does not need a fallback global reporter.
Validation: focused native invocation/reporting tests for successful bootstrap,
bootstrap failure, later load failure, cancellation, quiet, JSON main output,
empty evidence, and diagnostic writer failure. Assert useful evidence, preserved
causes, separation of stdout/stderr, and absence of synthetic credential values;
do not snapshot incidental wording or require old buffers/wrapper choreography.
## Stage 6 — Verify configured startup behavior at stable boundaries
Read the migrated `secrets_bootstrap_test.go`,
`configuration_acquisition_test.go`, `configuration_commands_test.go`, and
existing environment helpers. Consolidate into focused behavioral fixtures.
1. Use real ConfigKit and temporary files for explicit-file and search-discovered
pipeline startup. Verify configured credentials resolve into the completed
typed pipeline and that ordinary repeated access to that acquired result
reuses it. Include source-relative directory selection from a different
invocation directory and preserved native source/provenance evidence.
2. Exercise environment-only loading and native preservation/explicit-overwrite
behavior, including an existing empty variable where relevant. Omit the
directory declaration to show there is no Narratio auto-selection of an
adjacent `secrets/` directory. Removal of the fixed probe plus this test is
sufficient; do not touch the real system-wide directory to test its absence.
3. Verify declared missing/invalid startup input fails before pipeline execution
or adapter construction, retaining native report/error evidence. A successful
bootstrap followed by invalid pipeline data leaves the applied environment
value and report available. For partial application failures that cannot be
induced portably, use the narrow preparation seam to propagate a native
partial report/error instead of reproducing ConfigKit's filesystem internals.
4. Preserve credential forwarding/redaction coverage for Audita, Notarius,
Scriptorium, and storage. Existing tests of native configuration, catalog
derivation, prepared snapshots, and semantic resume should remain meaningful;
change obsolete startup fixtures rather than weakening their actual checks.
Validation: `go test ./internal/config ./internal/app ./cmd/narratio` and focused
race tests for changed application paths. Environment-mutating tests restore
variables and do not run concurrently with other process-environment mutations.
Avoid redundant tests of upstream limits, symlink policy, or exact error wording.
## Stage 7 — Verify native comparisons and lazy acquisition
Read `configuration_comparison_test.go`, `configuration_acquisition_test.go`,
`commands_boundary_test.go`, and the native ckconfig comparison contract.
1. Keep existing independent selector/default and override-isolation coverage.
Add a real two-pipeline comparison with distinct configured secrets directories
and a shared disposable variable. Native preservation and overwrite determine
each completed result in library acquisition order; no test-time environment
isolation is inserted into production code.
2. Cover a comparison where only one side needs pipeline acquisition, such as
exact party-file selection on one side and campaign discovery on the other.
Assert that the reached pipeline's configured bootstrap works, whichever side
needs it. Let ckconfig handle early failure, result comparison, and output.
3. Verify explicit local campaign/session/party inspection remains usable without
acquiring pipeline configuration just for bootstrap. Reuse the existing
acquisition-free help/version/completion/scope-listing and bare-explain tests.
4. Remove obsolete shared-bootstrap expectations and comparison wrappers/tests
whose only purpose was preserving implementation bookkeeping. Tests protect
ordinary acquisition reuse and native pass-through, not a new comparison
transaction, primary-source rule, retry protocol, or isolation contract.
Validation: focused comparison/boundary tests, then `go test ./internal/app`.
Comparison is best effort; keep the cases small and avoid a bespoke comparator,
per-side environment snapshots, or a matrix duplicating native library tests.
## Stage 8 — Simplify public configuration and CLI documentation
Read `docs/config.md`, `docs/cli.md`, and the adopted documentation policy's
Upstream Dependencies rule. Use the roadmap's pinned upstream contracts.
1. Replace generic ConfigKit feature explanations with a short identification
and canonical version-appropriate links. Keep Narratio's schema, discovery
choices, resource interpretation, scope selection, domain validation, and
environment bootstrap integration discoverable locally.
2. Replace generic CommandKit/ckconfig parsing, visibility tables, inspection
field descriptions, pointer syntax, and library comparison rules with links.
Keep Narratio's command inventory, installed selectors/scopes, domain reports,
and short practical invocation examples.
3. Document removal of the flag/fallback and the new pipeline-owned selection.
Explain only the local acquisition choice and shared-process comparison
integration; link upstream for control definitions and environment semantics.
Distinguish final bootstrap diagnostics from substantive command output.
4. Refresh imported-version links, consolidate redundant sections, and repair
inbound anchors as sections move. Do not remove application-specific facts
merely because they are adjacent to duplicate library prose.
Validation: review this diff against runtime changes and the ownership policy;
run `go test ./internal/doccheck`. No new upstream tutorial or report contract
belongs in Narratio as part of this cleanup.
## Stage 9 — Align policy, operator guidance, internals, and examples
Read `docs/policy/architecture.md`, `docs/operations.md`,
`docs/troubleshooting.md`, `docs/internal/configuration.md`,
`docs/internal/overview.md`, `docs/development.md`, `examples/README.md`, and
affected maintained YAML/integration documents found by non-code text search.
1. Revise the architecture startup paragraph affirmatively: explicit command-side
preparation uses ConfigKit's configured bootstrap before that pipeline's typed
credentials and adapters; completed acquisitions are reused normally; native
environment policy applies. Remove once-per-invocation, fixed-directory, and
always-environment-wins requirements. Preserve credential protection and the
existing ownership boundary. Leave accepted ADR 0003's decision unchanged.
Retain policy provenance and update the local modification date.
2. Keep internal docs about Narratio's wiring, acquisition state, safe persistence,
and domain derivation; link to library APIs for upstream behavior. The adopted
documentation policy already supplies the needed rule; no policy-suite rewrite
or extra ADR is required.
3. Update operations/troubleshooting and examples to remove the flag and fallback
recommendations. Explain migration: remove the flag from invocations, declare
a directory through native main-file controls, or provision environment values.
An adjacent system-wide pipeline can retain `secrets_dir: secrets`. Use native
default filesystem context; other layouts follow upstream path rules rather
than gaining a new Narratio path override or automatic migration shim.
4. Keep copyable maintained examples free of real credentials. Existing examples
need no secrets directory by default. A small commented startup declaration
in the full annotated pipeline can demonstrate where the selection belongs;
link upstream for its definition. Preserve usable example commands and test
them through the existing example owner.
5. Replace duplicate library guidance in operator/integration/example documents
with upstream links, retaining actual subprocess argument mappings, resume
implications, and Narratio development workflows. Identify PromptKit only in
its actual downstream role; no direct dependency is added. Historical release
notes and accepted decision records remain historical records.
Validation: `go test ./internal/doccheck` and
`go test ./internal/config -run '^TestExamplesLoadAndValidate$'`. Search current
documentation for stale flag/fallback instructions and upstream feature reference
copies. Preserve a reference only when it describes intentional migration/history
or an actual Narratio-specific responsibility.
## Stage 10 — Complete the integration and simplification review
Read the final diff and the feature roadmap's Targeted End State and Verification
sections. Finish remaining mechanical fixture/caller cleanup from earlier stages.
1. Confirm the selected dependency graph and attribution match Stage 1. Verify
no sibling checkout or `replace` is needed to build or run default tests.
2. Confirm there is one ordinary command-side pipeline preparation/load route,
pure library loading, normal acquisition reuse, and no retired selector,
directory probe, blanket bootstrap guard, diagnostic capture/reset buffer,
role-based comparison startup, or environment-restore machinery left active.
3. Review code for proportionate simplification. Remove dead dependencies,
helpers, state, and obsolete tests made unnecessary by this work. Keep useful
domain boundaries; no LOC quota or unrelated refactoring is required.
4. Run the maintained Go toolchain's full verification:
```sh
go test ./...
go test -race ./...
go vet ./...
go build ./...
git diff --check
```
The full suite includes maintained examples and documentation checks. Use
local/fake subprocesses and services; no paid or live-provider smoke tests.
5. Verify the documentation follows ownership policy and the roadmap's runtime
changes are all accounted for. Update implementation status honestly, review
staged changes, and commit completed work under the repository's plain-English
commit policy. Report test results and any outstanding work. This sprint does
not authorize a release, tag, push, or CI wait.
Completion means all ten stages' end-state work is present and repository-wide
verification succeeds; earlier compatibility tests or a dependency-only upgrade
do not establish completion.