Files
scriptorium/docs/roadmap/library-upgrades.md

411 lines
25 KiB
Markdown

# ConfigKit, PromptKit, And CommandKit Upgrades
## Status And Recommendation
Proposed. Revised 2026-11-22 to incorporate the selected native-workflow
direction, including ConfigKit's configured secrets bootstrap. The code review
baseline is Scriptorium commit `857c0bae201bb5f9b5ffdcb20c4f5a0bddb00114`.
This is an upgrade recommendation, not an implementation plan or a record of
implemented behavior.
Adopt the latest released versions together, using ConfigKit's completed result
as the handoff to PromptKit and CommandKit's native integrations for operator
interfaces. Adopt native upstream workflows by default; retain an
application-specific workflow where a concrete Scriptorium requirement warrants
it. Use a clean configuration migration, including configured secrets bootstrap,
in place of the separate framework-loading architecture. Expose native CLI
token/cost reporting and preserve new definition features without building
parallel application machinery.
The shared-load configuration cutover and native secrets bootstrap are the
selected direction. They change the application format, startup behavior, and
inspection boundary, not just dependencies. Additional HTTP reporting is deferred;
this upgrade retains the current HTTP response and execution-report shapes.
Documentation adopts upstream ownership too: acknowledge the libraries and link
their canonical documentation; retain local reference material for Scriptorium's
own interfaces and integration choices.
## Reviewed Releases And Sources
Published tags were checked directly against each repository's `origin` using
`git ls-remote --tags`. The adjacent clean checkouts supplied release notes,
consumer contracts, public APIs, and change history. The newly published
ckprompt v0.12.0 tag was fetched and its released module metadata checked;
recommendations do not rely on the older checkout's draft dependency selection.
The web reader could not access the forge; Git supplied the release evidence.
| Module | Current | Recommended | Full released source commit |
| --- | --- | --- | --- |
| `go.maximumdirect.net/configkit` | v1.2.1 | v1.4.0 | `4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3` |
| `go.maximumdirect.net/promptkit` | v0.23.3 | v0.25.0 | `207677e9948dc5699073a4d6620d21139033c72d` |
| `go.maximumdirect.net/commandkit` | v0.7.0 | v0.8.0 | `0b53a63648c536afe50c46f948159116f776adae` |
| `go.maximumdirect.net/ckconfig` | v0.9.0 | v0.11.0 | `cd5cf483a46caeff7ca0a91fb4747d57188a3888` |
| `go.maximumdirect.net/ckprompt` | v0.10.0 | v0.12.0 | `2422ccf02d6b55756b07f21e66a581202a09fc3f` |
Review covers both intervening ConfigKit releases (v1.3.0 and v1.4.0), both
PromptKit releases (v0.24.0 and v0.25.0), CommandKit v0.8.0, and the corresponding
integration changes. Released ckprompt v0.12.0 already requires the four other
recommended versions. No unpublished API or local replacement is needed.
All retain Go 1.27.0 as their consumer minimum; Scriptorium's selected release
toolchain need not change solely for these upgrades.
Primary release records:
- ConfigKit [v1.3.0][ck130] and [v1.4.0][ck140].
- PromptKit [v0.24.0][pk240] and [v0.25.0][pk250].
- CommandKit [v0.8.0][cmd080], ckconfig [v0.10.0][cc100] and
[v0.11.0][cc110], and ckprompt [v0.11.0][cp110] and [v0.12.0][cp120].
## Current Baseline
`internal/config` loads a strict application document through ConfigKit. Its
`promptkit` section currently selects an external `configuration` file and a
cwd-relative `schema_dir`; it does not contain PromptKit definitions. Runtime
conversion produces application settings, and the CLI adapter constructs an
engine through a second, PromptKit-owned load. Bundled OpenRouter definitions
are enabled by that constructor.
Native `config` commands expose the application result and the separate engine
inspection. The CLI maintains application-acquisition evidence and decorators
to distinguish those two loads. Application-only inspection currently avoids
framework acquisition. Each comparison side loads independently.
CLI execution submits one native `RunResult` to CommandKit; text writes exact
artifact bytes, structured output exposes upstream results, and an optional
separate report uses independent native formatting. HTTP uses application DTOs
and an opt-in terminal-event projection in `internal/report`. Those projections
currently omit the new reasoning and cost fields. The server constructs one
engine and shares its backend capacity accounting across requests.
The accepted [definition-support boundary](../adr/0004-definition-boundary.md),
[ConfigKit boundary](../adr/0005-configkit-boundary.md), and
[native operator-interface decision](../adr/0006-adopt-commandkit-native-operator-interfaces.md)
support this upgrade direction. They do not require adopting workflow APIs or
every public library capability.
## Upstream Changes And Adoption Assessment
### ConfigKit
v1.3.0 adds explicit secrets-directory startup helpers, main-file
`config.secrets_dir` / `config.secrets_overwrite`, and overwrite options.
Configured bootstrap returns a captured main source for the subsequent load,
preserving its filesystem context. It writes process environment variables;
partial writes survive a later failure. Ordinary loading consumes the controls
but never performs bootstrap itself. Scriptorium must explicitly invoke the
helper to make the native configured-startup workflow available; operators opt
into file provisioning by declaring the main-file controls.
v1.4.0 supplies the key integration enablers:
- `Result.Value(path)` returns current typed values without root-type knowledge,
conversion, or revalidation. Maps, slices, and pointers can alias the result.
- `Result.InspectSubtree(path)` exposes non-generic, frozen inspection with
redaction, historical paths, explanations, source catalogs, and resource
contexts. It can represent an absent scope.
- `Inspection.Diff` compares matching scopes, including across different root
types, using native snapshot comparison and paired redaction. Ancestor
differences remain possible; sequences remain atomic.
These are additive APIs. Use them through PromptKit and ckconfig rather than
creating a Scriptorium configuration projection or provenance merger. Keep
resolved settings consistent with frozen evidence until engine handoff; this
requires ordinary ownership discipline, not a new generic deep-copy layer.
Recommendation: adopt v1.4.0 and integrate
`LoadSecretsIntoEnvironmentFromConfig` into the common configuration-loading
path. Preserve its native source capture, overwrite policy, reports, and failure
semantics. This populates the environment before configuration loading;
PromptKit still resolves `api_key_env` at its native preparation/execution
lifecycle. Converting those names to ConfigKit `Secret` fields would change
that lifecycle and is not needed for this upgrade.
### PromptKit
v0.24.0 changes the configuration and schema boundary:
- Public `Settings` can be embedded at application YAML key `promptkit`.
`Configure` composes native rules with application callbacks, defaults,
sensitivity, version policy, and sequence registrations. `NewFromConfig`
captures resources from the whole completed ConfigKit result without loading
again. Bundled defaults must be selected before that application load.
- Complete documents move resources and `schema_root` under `promptkit`.
`SettingsInput` and `CollectionInput` mount wrapperless fragments at their
native destinations. Discovery helpers themselves remain root-mounted.
- Output contracts support inline `schema`, source-relative `schema_file`, and
explicit-root `schema_path`; collections can own schema roots. Global
`Config.SchemaDir`, `WithSchemaFS`, and `WithSchemaFile` are removed. Schemas
are read during preparation and retained by prepared execution.
- `RunRequest.Validation` uses `*OutputContractInput`, whose pointer repair
budget distinguishes omission from zero. Enabled validation defaults to one
repair; `none` defaults to zero. Inspection returns a resolved integer budget.
- Prepared reports add opaque `message_content_hash` for ordered message roles
and exact text, independent of session/cache metadata. The existing
rendered-prompt hash is unchanged.
- Native configuration inspection focuses on `/promptkit` and exposes
`HistoricalPaths`, while retaining whole-load evidence and explicit queries.
- PromptKit no longer imposes resource-version policy. It retains extension
fields at settings, collection, backend, profile, and prompt boundaries;
nested PromptKit-owned objects remain strict. Input requirements inherited
from application defaults are now retained correctly. Capture and schema
handling also avoid unnecessary copying and provenance expansion.
v0.25.0 adds execution and provider capabilities:
- `WithExecutionObserver` carries invocation-scoped observation in context,
composing with explicit request observers. Prepared execution selects
contextual observers when executed, not when prepared.
- Backend `provider` explicitly selects `openai-compatible`, `openrouter`, or
`vllm`; blank/omitted uses the generic provider. IDs and endpoints do not
select conventions. Declared `zero_cost: true` is an optional fallback,
never an inferred property of local endpoints.
- Usage includes reasoning tokens and provider-specific cache fields, with
native presence-aware cache-hit ratios. Reasoning is included in completion
tokens; cache activity does not add to total tokens.
- `RunResult.CostUSD` and observations retain available USD subtotals,
completeness, and provider/configured-zero/mixed source information. Costs
include dispatched retries and repairs; result usage still sums successful
generation responses. Failure observations can retain cost without a result.
- Authentication diagnostics can use provider defaults, including `vllm_models`.
An endpoint-only authentication object is now valid; `kind: none` disables
authentication testing. Probes remain explicitly requested operations.
Recommendation: adopt both releases' definition semantics and shared-load API.
Use native results/inspection for the new fields; do not write a local schema
resolver, cost estimator, repair controller, or provider-name heuristic.
### CommandKit And Integrations
Core v0.8.0 adds captured invocation features: application-wide flags, context
decoration, and final diagnostic reports. Features start after successful input
checks and finish after deferred messages, including on returned failure or
cancellation. Help, version, completion, and input failures skip startup.
`ErrHelpRequested` also supports help-only input checks. Registry validation
accounts for feature flag/alias collisions; invocation flag processing avoids
repeated owner partitioning and duplicated lookup maps.
ckconfig v0.10.0 adds `FromConfigKitSubtree` and native path discovery through
`View.Paths`. v0.11.0 adopts core's help-only exemption for bare `config explain`.
Loading and validation cover the whole result even when rendering is focused.
ckprompt v0.11.0 adopts shared loading, focused inspection, schema selections,
repair inputs, and message hashes. v0.12.0 installs native `--show-tokens` through
ordinary nonempty `Command` / `Declarations` assembly. It observes the invocation
context and produces a text token/cost summary on diagnostics, independently of
main `--format`; quiet suppresses it. It also forwards provider declarations,
reasoning/cache evidence, and changes automatic smoke output to a native text
template. Explicit JSON/YAML remain structured; smoke usage is separate from
ordinary run observation and its report does not acquire a cost field.
Recommendation: retain existing native assembly and expose this capability
without wrapping `App.Execute`, installing a second accounting observer, or
adding a duplicate application flag. Preserve invocation context in PromptKit
calls. No selected-main-format accessor is needed for current output delivery.
## Target State
The [implementation plan](implementation.md) owns staged tasks, concrete file
changes, and verification steps. The following describes the selected end state
and application choices, not an implementation sequence.
### Shared Configuration And Engine Handoff
Scriptorium embeds public `promptkit.Settings` at `Document.PromptKit`, with
`promptkit.Configure` supplying native rules alongside application defaults,
normalization, validation, and sensitivity declarations. The application retains
its retry setting and server settings; it no longer has a separate framework
acquisition/settings model.
Each acquisition prepares its selected host file/search source with ConfigKit's
configured secrets helper and performs one typed layered load. The main uses
the captured source, native imports/overlay/override selections, and the bundled
OpenRouter underlay. PromptKit receives the whole successful result through
`NewFromConfig`, without reloading, projecting/redecoding, or redefining
effective configuration.
The acquired result is authoritative. Genuine application choices remain local:
discovery preset selection/order, server settings and validation, request
mapping, process behavior, and HTTP artifact policy. Source-relative message
and schema resources keep native contexts. A server constructs one shared
engine before accepting requests; namespace views share its operational state.
The cutover removes `promptkit.configuration`, `promptkit.schema_dir`, the
schema-directory default, and the former two-load conversions, selectors,
evidence state/decorators, sentinels, and obsolete-only tests. Narrow validation
diagnoses the two retired fields instead of silently using them or building a
general legacy/migration subsystem. There is no legacy loader or format alias.
Valid native settings and root/collection definition extension points remain
usable. Existing raw-key restrictions are enforced through public application
validation and safe native diagnostic rendering, including backend/profile
`api_key` extension fields. Native sensitivity remains intact; ordinary
`extra_params` data is not redacted as a whole. No new resource-version policy
or general extension-field ban is selected.
### Native Configured Secrets Startup
Configured secrets bootstrap is part of the common acquisition path used by
execution, server startup, configuration inspection/comparison, and PromptKit
commands. ConfigKit owns its main-file controls, directory processing,
filesystem rules, overwrite behavior, reports, and failure semantics under the
[upstream startup contract][secrets-contract] and [public helper][secrets-api].
No additional application bootstrap opt-in, secret-file parser, or raw-key
configuration field is selected.
Native bootstrap reports are available on success and failure and forwarded
safely to CommandKit diagnostics, separately from the configuration result and
main output. Thin presentation integration remains justified; it does not
recreate configuration evidence reconciliation or invent sources for
environment writes. Failed acquisition remains a failure.
The process environment retains native effects, including partial writes and
effects across sequential comparison sides. Source/option independence does
not imply environment isolation, rollback, or secret-file-content comparison.
Bootstrap precedes server concurrency and is not performed per HTTP request.
Help, version, static completion, and scope discovery remain acquisition-free.
PromptKit's own credential lookup lifecycle is unchanged.
### Native Configuration Views And Overrides
The native `app` scope reports the complete application result through
`FromConfigKit`; `promptkit` focuses the same kind of result at `/promptkit`
through `FromConfigKitSubtree`. Neither config scope needs an engine.
Both enable native override capabilities, including independent comparison
overrides. Paths and conflict semantics remain native, not scope-rebased.
Application inspection now includes PromptKit settings and whole-document
validation. Focused inspection retains native whole-load evidence and explicit
queries outside the focus; it is not an isolation boundary. Each reached
comparison side uses its own selections. Multiple native acquisitions within
an invocation do not create an application cache or a cross-acquisition snapshot
guarantee.
Native prompt/resource/requirements/preparation/smoke commands remain installed.
Their engine acquisitions use the same common load and result handoff, with
original typed errors and native diagnostic evidence rather than masked errors
and reconstructed explanation trees.
### Definitions, Resources, And Native CLI Reporting
Complete definitions use PromptKit's `/promptkit` format; wrapperless fragments
and collection resources use native mounts and imports. Existing IDs/references
keep their upstream meaning. All valid native schema forms and collection roots
work through Scriptorium, without an implicit cwd schema root or local fallback.
Maintained examples retain the application quickstart and representative
collection discovery: an application file, both glob-discovered entry spellings,
self-declared namespaces, relative imports, and source-relative message/schema
resources. They demonstrate the application integration rather than duplicate
standalone library tutorials.
Repair defaults, optional budget presence, provider conventions, explicit
zero-cost declarations, prepared message hashes, and native inspection/report
fields follow the selected PromptKit release. Existing explicit zero budgets
remain explicit; no application override silently restores an older default.
Native `--show-tokens` is supplied by ckprompt's ordinary declaration
installation, with invocation context propagated to PromptKit. Scriptorium has
no separate accounting group, usage serializer, pricing estimator, or duplicate
usage flag. Native behavior is documented upstream.
Application delivery choices remain: artifact-only text stdout, native
structured results, independently formatted optional report files, and the
whole-run timeout passed to PromptKit. Library rendering/execution/finalization
remains native. Existing application domain and operational outcomes stay
distinct; the selected-format accessor is not a prerequisite.
### HTTP Boundary And Other Local Responsibilities
The current HTTP wire contract, including its opt-in terminal report, remains
unchanged. Native reasoning/cost/cache facts are available through CLI reports;
additional HTTP reporting is [deferred](#deferred-work). Internal HTTP/report
simplification is allowed without committing to the present collector or
projection implementation permanently.
HTTP DTOs, transport limits, status mapping, restricted artifact reading,
request-scoped report projection, and shared engine/capacity behavior implement
Scriptorium's service boundary; CommandKit is not an HTTP transport. Application
discovery selection, domain callbacks, process lifecycle, file effects, and
safe bootstrap-report forwarding are integration responsibilities, not parallel
implementations of native library workflows. Shared configuration/bootstrap has
no identified application-specific requirement that warrants a legacy path.
### Documentation Ownership And Migration
The [adopted documentation policy](../policy/documentation.md#upstream-dependencies)
already contains upstream v1.13's ownership rule. Maintained documentation
identifies the adopted libraries and links canonical documentation applicable to
the imported versions: [ConfigKit][configkit-contract], [PromptKit formats][promptkit-formats],
[consumer][promptkit-consumer] and [migration][promptkit-migration] guidance,
and [CommandKit CLI][commandkit-cli] and [integration][commandkit-consumer]
guidance. It does not maintain another library manual.
Local references cover Scriptorium's installed interfaces, selected configuration
and source integration, application settings/bindings, file/process effects,
HTTP wire contract, deployment choices, and migration from its former interfaces.
Upstream rules, feature tables, and tutorials are linked rather than reproduced.
| Documentation group | Target ownership |
| --- | --- |
| `README.md`, `docs/development.md` | Application orientation, minimal quickstart, selective reading, and native upstream navigation. |
| `docs/cli.md`, `docs/config.md` | Application entrypoints/bindings/settings/effects and selected integration, with native contracts delegated upstream. |
| `docs/operations.md`, `docs/api.md` | Local deployment/process/retention and unchanged complete HTTP contract, without a duplicate framework manual. |
| `docs/consumers/`, `docs/integrations/subprocess.md` | Executable selection, stream/file responsibilities, application-specific migration, and the historical package-split boundary. |
| `docs/internal/`, `docs/policy/architecture.md` | Landed local structure/constraints and public upstream handoff, without obsolete two-load mechanics or copied library algorithms. |
Application migration is a hard cutover with upstream format/default migration
guidance linked at its owner. Superseded local intermediary tutorials do not
remain a competing current reference. Accepted ADR decisions and published
release records remain historical. Documentation policy v1.13 is already adopted;
no additional local policy rewrite or general policy-suite refresh is needed.
### Attribution And Completion Evidence
The selected dependencies' exact versions and source/notice links are maintained
in the existing attribution document under the adopted OSS policy, using the
reviewed unchanged grants/texts. Actual runtime dependencies are distinguished
from graph-only maintainer tools.
Completion evidence covers shared-load/bootstrap handoff and failures, native
views/overrides/provenance/redaction, resource contexts and definition support,
native CLI usage and retained delivery/outcomes, and the existing HTTP
wire/reader/concurrency boundaries. Tests remain proportionate, offline, and
credential-free, without duplicating upstream grammar/accounting matrices.
Current documentation describes the delivered integration and delegates native
semantics upstream. The embedded-configuration future direction is considered
delivered only when implementation lands; other deferred work remains tracked.
No new release gates, live provider checks, publication workflow, or stronger
application guarantees are introduced. A later breaking pre-v1 release requires
a minor version under existing policy, selected during release preparation.
## Deferred Work
### HTTP Accounting Additions
The user selected deferral of additional HTTP reporting. A future roadmap may
add reasoning tokens to result and terminal usage, native cost availability,
completeness and source information to success/terminal reports (including
failures with terminal evidence), and a nullable terminal cache-hit ratio using
`ObservedTokenUsage.CacheHitRatio()`. Keep result usage distinct from
presence-aware observations; do not infer ratios from unavailable counts or
treat unknown cost as zero. This is future work, not an upgrade acceptance
requirement or a blocker for native CLI reporting.
[ck130]: https://forge.maximumdirect.net/base-layer/configkit/src/commit/652ddb649c60208dbba964f0ef919e36725c12c0/docs/releases/v1.3.0.md
[ck140]: https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/releases/v1.4.0.md
[pk240]: https://forge.maximumdirect.net/base-layer/promptkit/src/commit/5ea60e9b96651fd7dfcbc7d05b6f43d131df358f/docs/releases/v0.24.0.md
[pk250]: https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/docs/releases/v0.25.0.md
[cmd080]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/0b53a63648c536afe50c46f948159116f776adae/docs/releases/v0.8.0.md
[cc100]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/eedbd83e7ea7be6a626755a63595f512ccd6fd15/integrations/ckconfig/docs/releases/v0.10.0.md
[cc110]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/cd5cf483a46caeff7ca0a91fb4747d57188a3888/integrations/ckconfig/docs/releases/v0.11.0.md
[cp110]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/54e951e38a404b4338c7967ac39c6c01159bf76d/integrations/ckprompt/docs/releases/v0.11.0.md
[cp120]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/2422ccf02d6b55756b07f21e66a581202a09fc3f/integrations/ckprompt/docs/releases/v0.12.0.md
[secrets-contract]: https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/config.md#explicit-secrets-directory-bootstrap
[secrets-api]: https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/secrets.go
[configkit-contract]: https://forge.maximumdirect.net/base-layer/configkit/src/commit/4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3/docs/config.md
[promptkit-formats]: https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/docs/formats.md
[promptkit-consumer]: https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/docs/consumers/pkg-promptkit.md
[promptkit-migration]: https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/docs/consumers/configuration-migration.md
[commandkit-cli]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/0b53a63648c536afe50c46f948159116f776adae/docs/cli.md
[commandkit-consumer]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/2422ccf02d6b55756b07f21e66a581202a09fc3f/docs/consumers/guide.md