212 lines
11 KiB
Markdown
212 lines
11 KiB
Markdown
# Adopt ConfigKit v1.4 and native secrets startup
|
|
|
|
## Purpose
|
|
|
|
Adopt ConfigKit v1.4.0 and use its native configured-secrets bootstrap to reduce
|
|
Narratio-owned configuration machinery. 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.
|
|
|
|
## Reviewed Upstream Release
|
|
|
|
ConfigKit v1.4.0 identifies commit
|
|
`4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3`. Its
|
|
[configuration contract](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/config.md)
|
|
and [consumer guide](https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/consumers/README.md)
|
|
own upstream semantics. The
|
|
[v1.3.0 notes](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.3.0/docs/releases/v1.3.0.md)
|
|
describe configured bootstrap; the
|
|
[v1.4.0 notes](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/releases/v1.4.0.md)
|
|
describe typed value access and focused inspection.
|
|
|
|
The Go consumer minimum remains 1.27.0. The existing CommandKit v0.7.0 and
|
|
`ckconfig` v0.9.0 APIs remain compatible. ConfigKit's license remains
|
|
LGPL-3.0-or-later, with unchanged license texts relative to v1.2.1.
|
|
|
|
## Current Baseline
|
|
|
|
- Narratio pins ConfigKit v1.2.1. Pipeline discovery, YAML composition, typed
|
|
credential resolution, validation, and provenance already use ConfigKit.
|
|
- `internal/app/secrets_bootstrap.go` selects `--secrets-dir` or automatically
|
|
probes `/usr/local/etc/narratio/secrets`. It delegates file loading to
|
|
`LoadSecretsIntoEnvironment`, retains invocation-level completion, and renders
|
|
reports. Existing environment values win, including empty values.
|
|
- Pipeline source selection occurs separately from bootstrap. Narratio has no
|
|
configured-bootstrap handoff using a prepared ConfigKit source.
|
|
- Lazy configuration acquisition supports independent app, campaign, session,
|
|
and party scopes. Comparisons acquire their own results while sharing startup
|
|
bootstrap. Native inspection is exposed through `ckconfig`.
|
|
- Narratio derives separate domain catalogs, persisted configuration projections,
|
|
and semantic resume evidence. These serve application responsibilities rather
|
|
than replacing ConfigKit inspection.
|
|
|
|
The [configuration reference](../config.md#secrets-handling),
|
|
[configuration internals](../internal/configuration.md), and
|
|
[architecture policy](../policy/architecture.md#configuration) own current behavior.
|
|
|
|
## Targeted End State
|
|
|
|
### Configured startup
|
|
|
|
When acquiring the primary pipeline without an explicit `--secrets-dir`, Narratio
|
|
passes its existing native `File` or `SearchConfig` source to
|
|
`LoadSecretsIntoEnvironmentFromConfig`. Operators can declare:
|
|
|
|
```yaml
|
|
config:
|
|
secrets_dir: secrets
|
|
secrets_overwrite: false
|
|
```
|
|
|
|
ConfigKit selects and captures the main document, interprets these controls,
|
|
resolves the directory, performs bootstrap, and returns a safe report and prepared
|
|
source. Narratio passes that source to ordinary `Load` with its existing schema,
|
|
defaults, resolution callbacks, validation, imports, overlay, and explicit
|
|
configuration overrides. Bootstrap and loading use the same captured main
|
|
document. Imports and credential lookup retain their native load-time behavior.
|
|
|
|
Use upstream path and filesystem-context semantics. The configured directory is
|
|
relative to the canonical main file and contained by its ConfigKit filesystem
|
|
root. Keep existing discovery choices; introduce no parallel YAML parsing,
|
|
control extraction, or application-specific source reconstruction.
|
|
|
|
The automatic fixed-directory fallback is removed. With neither a configured
|
|
directory nor an explicit flag, credential references use the existing process
|
|
environment. A deployment retaining the former system-wide directory can place
|
|
`secrets_dir: secrets` in its adjacent pipeline configuration or supply the flag.
|
|
|
|
### Explicit directory selection and precedence
|
|
|
|
Retain `--secrets-dir` as an explicit alternative to configured-directory
|
|
bootstrap. Its existing caller-relative path behavior remains. This route uses
|
|
ConfigKit's direct-directory helper and preserves existing environment values.
|
|
It performs the selected direct bootstrap instead of configured bootstrap.
|
|
|
|
The configured helper has no directory-override option. A small application-owned
|
|
selection branch is appropriate; Narratio does not first bootstrap the YAML
|
|
directory and then load the flag-selected directory. Normal configuration loading
|
|
still validates and consumes main-document controls according to ConfigKit.
|
|
`config.secrets_overwrite` applies to the configured-bootstrap route; it does not
|
|
change the explicit flag's environment-preserving behavior.
|
|
|
|
For configured bootstrap, leave ConfigKit's overwrite option unspecified so the
|
|
main document controls it. Omission or false preserves existing values, including
|
|
empty values; true permits files to replace them. Credentials remain typed
|
|
environment-name references, and ConfigKit resolves every surviving reference
|
|
under its existing rules. Native eligibility, bounds, symlink handling, and
|
|
failure semantics remain upstream-owned.
|
|
|
|
### Invocation lifecycle and inspection
|
|
|
|
Narratio calls bootstrap during command-owned startup, before typed credential
|
|
resolution and adapter construction. ConfigKit's preparation may read and parse
|
|
the main document before this point. Loading a prepared source does not repeat
|
|
bootstrap. Preserve invocation-level reuse without introducing a global cache.
|
|
|
|
Help, version, completion, and scope listing retain their current acquisition-free
|
|
behavior. Direct inspection of campaign, session, or party documents retains lazy
|
|
acquisition: configured pipeline bootstrap runs when that invocation actually
|
|
needs the pipeline. An explicit secrets-directory flag remains usable without
|
|
requiring an otherwise unnecessary pipeline load.
|
|
|
|
Configuration comparisons use one startup environment. The primary pipeline
|
|
selection owns configured bootstrap; comparison-only pipeline sources undergo
|
|
ordinary loading without additional bootstrap. A different comparison overlay
|
|
does not initiate another bootstrap. Preserve separate ConfigKit results for
|
|
each side. This feature adds no independent per-side environment snapshots or
|
|
credential-isolation promise.
|
|
|
|
### Reports, errors, and ownership
|
|
|
|
Keep the native `SecretsReport` separate from later configuration results and
|
|
retain the report on bootstrap failure. Present safe report contents and
|
|
`SecretsError` diagnostics through Narratio's CommandKit reporting boundary.
|
|
Preparation failures retain native `LoadError` evidence. Preserve typed causes
|
|
and relevant operation context rather than embedding a rendered report into an
|
|
otherwise opaque error string.
|
|
|
|
ConfigKit owns file validation, limits, environment writes, and safe evidence.
|
|
Narratio owns scheduling, selection of the explicit flag route, and presentation.
|
|
Use native partial-write semantics: completed environment writes survive a later
|
|
bootstrap or configuration failure. This work adds no rollback, transaction,
|
|
concurrent-environment protection, or custom filesystem-hardening layer.
|
|
|
|
### Other native APIs
|
|
|
|
Keep configuration inspection delegated to `ckconfig`. ConfigKit's new
|
|
`InspectSubtree` and scoped `Diff` are available for future focused inspection;
|
|
they do not replace Narratio's separately loaded configuration scopes. Additional
|
|
CLI exposure belongs in the native adapter when needed.
|
|
|
|
`Result.Value(path)` supports root-type-independent library consumers. Existing
|
|
typed field access remains appropriate for Narratio's current consumers. This
|
|
feature requires no generic accessor framework or conversion of subprocess
|
|
adapters into in-process libraries. Continue using native metadata and resource
|
|
contexts where they serve domain interpretation.
|
|
|
|
Domain catalogs, credential forwarding, persisted configuration projections, and
|
|
stage-owned resume fingerprints retain their current responsibilities. Diagnostic
|
|
inspection output is not substituted for reloadable configuration or semantic
|
|
reuse evidence.
|
|
|
|
## Required Changes
|
|
|
|
### Dependency and startup wiring
|
|
|
|
Update `go.mod` and `go.sum` to ConfigKit v1.4.0. Keep other dependency versions
|
|
unless dependency resolution requires a related adjustment. Update ConfigKit's
|
|
attribution entry and pinned contract links to the adopted revision.
|
|
|
|
Connect native pipeline source selection, configured bootstrap, and prepared-source
|
|
loading through the application/configuration boundary. Preserve pure library
|
|
loaders: command-owned startup invokes the environment-mutating helper explicitly.
|
|
Share that startup service across execution, planning, and configuration inspection
|
|
where applicable. Remove the conventional-directory probe and obsolete fallback
|
|
logic. Keep the remaining explicit-selection and invocation-lifecycle wiring small.
|
|
|
|
Adapt reporting to retain native reports and typed failures separately. Keep
|
|
existing CommandKit outcome handling and useful native diagnostic details.
|
|
|
|
### Policy, documentation, and operator migration
|
|
|
|
When implementation lands, update the architecture policy's startup wording to
|
|
affirm the native preparation, bootstrap, and final-load boundary. Describe
|
|
environment precedence as the selected ConfigKit bootstrap policy. ADR 0003's
|
|
configuration ownership decision remains applicable.
|
|
|
|
Update the configuration reference, CLI reference, operations and troubleshooting
|
|
guidance, configuration internals, and affected maintained examples. Explain
|
|
configured-directory selection, explicit-flag precedence, overwrite behavior,
|
|
primary-source comparison startup, and the removal of automatic conventional
|
|
directory loading. Replace stale fixed-fallback and before-any-configuration-read
|
|
language in affected documents. Link detailed bootstrap behavior to the pinned
|
|
upstream contract rather than maintaining a second implementation specification.
|
|
|
|
Provide a concise manual migration for operators relying on the former fallback.
|
|
Retain environment-only deployments. Preserve existing credential-protection
|
|
guidance and ConfigKit's safe reporting; this adoption adds no permission-mode
|
|
enforcement or new credential naming convention.
|
|
|
|
### Verification
|
|
|
|
Use focused offline behavioral tests covering native configured startup and
|
|
discovery, prepared-main handoff, configured path resolution, preservation and
|
|
explicit overwrite, direct-flag precedence, and environment-only operation.
|
|
Cover useful reports and typed errors on failure, including retained partial
|
|
effects, without duplicating ConfigKit's complete file-validation test suite.
|
|
|
|
Exercise invocation reuse, lazy non-pipeline inspection, acquisition-free CLI
|
|
paths, and primary-source comparison bootstrap. Retain existing tests for native
|
|
inspection, credential forwarding/redaction, separate domain derivation, and
|
|
semantic reuse. Update tests that deliberately encode the retired directory
|
|
fallback or environment precedence that is now operator-selectable.
|
|
|
|
Run the repository's normal tests, race tests, vet, build, maintained-example,
|
|
and documentation checks in proportion to the implemented change. Default tests
|
|
use temporary files and disposable environment values and remain independent of
|
|
sibling checkouts, real credentials, and live services.
|