# Native Kit Observability Upgrade ## Purpose Upgrade Notarius's native kit dependencies together and adopt their new execution-observation, provider-accounting, and operator-reporting capabilities. Retain the existing configuration ownership, typed pipeline, accepted-result cache, domain artifacts, and application assessment boundaries. This document records the selected target and a short implementation sequence. Implementation remains pending; recording these decisions changes no application behavior or dependencies. Keep implementation planning here rather than requiring a separate planning document. ## Reviewed Baseline And Published Targets The Notarius baseline is commit `7faa4a05066179eb61ab6f129b6c915343d094e2`. Its [go.mod](../../go.mod) declares the versions below. Release status was checked against the upstream repositories' remote tags on 2026-11-23; annotated tags were resolved to source commits. The source commits, rather than tag-object hashes, are recorded here. | Module | Notarius baseline | Selected target | Target source commit | | --- | --- | --- | --- | | `go.maximumdirect.net/configkit` | v1.4.0 | Retain v1.4.0 | `4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3` | | `go.maximumdirect.net/promptkit` | v0.24.0 | v0.25.0 | `207677e9948dc5699073a4d6620d21139033c72d` | | `go.maximumdirect.net/commandkit` | v0.7.0 | v0.8.0 | `0b53a63648c536afe50c46f948159116f776adae` | | `go.maximumdirect.net/ckconfig` | v0.10.0 | v0.11.0 | `cd5cf483a46caeff7ca0a91fb4747d57188a3888` | | `go.maximumdirect.net/ckprompt` | v0.11.0 | v0.12.0 | `2422ccf02d6b55756b07f21e66a581202a09fc3f` | ConfigKit has no newer published version at this review: v1.4.0 is already selected, and upstream main points to that release's source commit. There is no additional ConfigKit migration to invent. ckprompt v0.12.0 became published during this review; the complete target set is now available as released Go modules. Recheck published tags when implementation starts if upstream has advanced; changes beyond these reviewed versions need their own assessment. All five selected modules retain Go 1.27.0 as their consumer minimum. The published integrations align with this dependency set; no compatibility patch, local replacement, pseudo-version, or toolchain change is needed for it. Primary release evidence: - [ConfigKit v1.4.0](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/releases/v1.4.0.md). - [PromptKit v0.25.0](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/releases/v0.25.0.md). - [CommandKit v0.8.0](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/v0.8.0/docs/releases/v0.8.0.md). - [ckconfig v0.11.0](https://forge.maximumdirect.net/base-layer/commandkit/src/commit/cd5cf483a46caeff7ca0a91fb4747d57188a3888/integrations/ckconfig/docs/releases/v0.11.0.md). - [ckprompt v0.12.0](https://forge.maximumdirect.net/base-layer/commandkit/src/commit/2422ccf02d6b55756b07f21e66a581202a09fc3f/integrations/ckprompt/docs/releases/v0.12.0.md). ## Release Assessment ### ConfigKit: Already Adopted v1.4.0 adds current typed `Result.Value`, frozen `InspectSubtree` views, and focused comparisons across application root types. Notarius already composes PromptKit settings into one application-owned load, hands its original result to `promptkit.NewFromConfig`, and uses ckconfig's whole-application/subtree adapters. These are the relevant native capabilities; retain this integration. The existing distinction between current typed values and frozen inspection must remain. Do not add a second configuration load, settings serialization round-trip, or application-owned implementation of native composition or diff. See [ConfigKit integration](../integrations/pkg-configkit.md) and [ADR-0020](../adr/0020-delegate-configuration-mechanics-to-configkit.md). ### PromptKit: Execution Observation And Provider Accounting v0.25.0 adds: - `WithExecutionObserver(ctx, observer)`, covering calls using that context across ordinary execution, coordinated corrections, prepared execution, nested validators, concurrent work, and multiple engines. Prepared handles select contextual observers when executed, not when prepared. Explicit request observers still run first and can coexist with contextual observers. - Native reasoning-token counts, presence-aware observations, and `ObservedTokenUsage.CacheHitRatio()`. Reasoning is a subset of completion tokens; cache reads/writes are input details, not additional total tokens. - Native `RunResult.CostUSD` and observed/group cost, retaining availability, completeness, and provider/configured-zero/mixed source information. Cost covers dispatched attempts, including repairs and transient retries; observed failures can retain cost without a returned result. Existing `RunResult.Usage` still sums successful generation responses and is not a substitute for presence-aware execution observations. - Explicit backend `provider` selection: `openai-compatible`, `openrouter`, or `vllm`. Names and endpoint hostnames do not select conventions. Missing, null, or blank selects generic OpenAI-compatible conventions. - OpenRouter-specific reasoning, cache-write, and optional `usage.cost` decoding; vLLM-specific reasoning/cache activity decoding; explicit optional backend `zero_cost` fallback. Provider-reported cost, including zero, takes precedence over that fallback. - Provider-default authentication diagnostics and the `vllm_models` adapter. A supplied authentication object can omit its kind. Clearing the object restores the provider default; explicit `kind: none` disables that diagnostic. OpenRouter cache writes now come from `usage.prompt_tokens_details.cache_write_tokens`; vLLM uses `usage.prompt_tokens_details.created_cache_tokens`. Missing or unusable new details remain unknown without invalidating otherwise usable model content. vLLM detail availability depends on server token-detail/reasoning configuration. Generic-provider behavior remains available for other compatible endpoints. The native result JSON gains `cost_usd`, and token JSON gains `reasoning_tokens`. Review strict decoders and unkeyed literals if present. Notarius's debug writer already serializes native events, results, and group snapshots directly, so it can retain the expanded evidence without a new application accounting schema. See the [native observation guide](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/consumers/pkg-promptkit.md#observe-an-ordinary-run) and [provider response contract](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/integrations/openai-compatible-chat.md#response-handling). ### CommandKit And Integrations: Native Invocation Reporting CommandKit v0.8.0 adds captured invocation features with invocation-wide flags, context decoration, and final diagnostic reports. Features start after input construction and successful `CheckInput`; reports run after deferred messages and before terminal failure explanations, including returned failure and cancellation. Help, version, completion, and input failures skip startup. `ErrHelpRequested` supports help-only preflight without starting features. ckconfig v0.11.0 uses that mechanism for bare `config explain`; its normal help fallback remains free of configuration loading and usage reporting. ckprompt v0.12.0 automatically installs `--show-tokens` through the ordinary nonempty `Command` or `Declarations` integration. It observes application-owned commands as well as the PromptKit family, using the invocation context. The flag defaults to false, accepts explicit false, and uses the last repeated value. Reporting is text on diagnostics, independent of the primary result format, and is suppressed by quiet mode. The native summary includes prompt executions, nonzero repair details, reasoning/cache token categories, available cache-hit ratio, and observed cost. Smoke reports separately gain reasoning and nullable cache-hit ratio. Their default representation changes to text with YAML evidence and percentage comments; callers needing structured smoke output should select JSON or YAML. Smoke usage remains in the smoke report, separate from ordinary execution observation, without a new smoke cost field. ## Selected Target State And Work ### Adopt The Coordinated Published Set Update `go.mod` and `go.sum` for the four changed modules together, retaining ConfigKit v1.4.0. Confirm the selected graph with `GOWORK=off`; local workspace replacements must not mask a published dependency mismatch. Review tidy's actual dependency changes rather than importing upstream maintainer tooling into Notarius. Keep configuration version 6, the built-in D&D profile/model, prompt content, schemas, producer budgets, assessment policy, worker limits, and backend admission choices unchanged unless a specific compatibility fix requires it. These releases do not require new domain extraction behavior. Preserve application outcomes and useful diagnostic evidence; freely remove or relocate internal plumbing that upstream capabilities make unnecessary. Existing group parameters, observer hooks, and snapshot-writing locations are not compatibility requirements. Keep the public artifact, cache, assessment, and execution-policy contracts distinct from those implementation choices. ### Use Native Operator Usage Reporting Retain the existing `ckprompt.Declarations` assembly in [application.go](../../internal/cli/application.go). Let the updated integration provide `--show-tokens`; do not register a competing flag, wrap `App.Execute`, copy its template, or add manual token/cost summation to handlers. Audit the invocation context path through [pipeline_run.go](../../internal/cli/pipeline_run.go), runner workers, producers, native coordination, and LLM validators. Preserve that context and join all application-owned work before returning so the final summary sees completed execution. Existing cancellation/draining behavior is the foundation, not a reason to add another scheduler. Keep the small completion report and durable domain outputs unchanged. Usage is opt-in diagnostic information, not a warning, success qualification, mandatory sidecar, public debug contract, or promised invoice. Missing token or cost details are ordinary unknowns, not new warnings or run failures. Cached accepted artifacts represent no current model execution and must not replay historical usage or cost; deterministic-only operations likewise create no synthetic executions. An empty native group can legitimately report zeros. ### Move Invocation Accounting Out Of Runner Inputs The runner currently enrolls its `RunInput.Executions` group by composing its observer into `input.Execution.Observer` and propagating that observer through requests. Replace this with native contextual observation owned by the consumer of the evidence: - ckprompt owns ordinary invocation usage reporting through its installed feature. - Debug capture creates and attaches a native group when it needs a snapshot, retaining that group for capture at the appropriate application boundary. - Other callers attach their own observers or groups through `WithExecutionObserver` and inspect them after their work finishes. - The runner propagates the supplied context without an accounting-group input or unconditional allocation of its own group. Remove `RunInput.Executions` and general observer forwarding through `ExecutionOptions.Observer`. Audit remaining callers and migrate them to native contextual enrollment; internal caller compatibility does not justify retaining the old path. Remove the old request/coordination/validator enrollment in the same change so a group is registered once, without relying on terminal de-duplication to conceal duplicate event delivery. When neither capture nor an explicit caller needs a group, Notarius creates none of its own. A debug group and ckprompt's CLI invocation group may independently observe the same execution. Never add their overlapping totals. Exactly one group is not an architectural goal: do not introduce shared-group discovery, an accounting service, or new upstream integration machinery merely to avoid this small duplication. Verify both `Run` and `RunPrepared` use the decorated execution context, as do corrections and nested validators. Preparation/cache hits must remain event-free. ### Retain Operation Evidence And Application Lifecycle Ownership Invocation accounting and operation evidence serve different purposes. `NativeCapture` still associates prepared messages, raw responses, exchanges, cache-hit evidence, and domain scope with individual operations. Preserve that useful evidence and native request-specific callbacks, including `OnPrepared` and direct request observers where needed. Contextual accounting does not require turning per-operation writers into one centralized event router that reconstructs lane/chunk/validator ownership. Keep callback composition, synchronization, native run identity, and capture-error handling where their consumers still need them. Remove forwarding that only served invocation accounting; do not remove capture hooks simply because they also use native observer APIs. Notarius continues to own debug allocation and finalization, domain assessment, and publication-aware failure handling. CommandKit's final diagnostic reports do not replace these application boundaries. Preserve requested capture failures, available artifacts and locations, and completion-report ordering without moving domain lifecycle work into a generic invocation feature solely because one exists. ### Adopt Explicit Provider Conventions Without Adding Defaults The bundled OpenRouter backend now declares `provider: openrouter` upstream. Notarius already loads that underlay, and the complete example's `limited-openrouter` inherits it. Retain that inheritance; an extra local copy of the upstream backend is unnecessary. Link operators to PromptKit's canonical backend documentation for independently declared or replaced backends, including OpenRouter and vLLM provider selection. Brief Notarius-specific orientation or examples may explain an integration choice; link upstream for field semantics rather than maintaining a parallel reference. An endpoint override of an inherited backend retains its provider selection, so switching from an OpenRouter parent to a local vLLM endpoint also needs a deliberate provider override. Do not infer conventions from an ID, hostname, model name, or the fact that an endpoint is locally hosted. Keep `zero_cost` omitted by default; link upstream for its meaning and use. Do not assume that local inference is free or introduce token-rate tables, estimated charges, billing guarantees, application-side provider parsing, or extra public accounting types. Expose new inspection and authentication behavior through the installed native suite. Probes remain explicit operator actions; an accessible vLLM `/models` response establishes neither authentication enforcement nor permission to run inference. No new startup probe, credential requirement, or provider restriction is part of this upgrade. ### Maintain Canonical Documentation And Notices Notarius documentation should state which native libraries and integrations it imports and link to their canonical upstream documentation. Upstream owns the explanation of its features, APIs, configuration fields, defaults, flags, reporting, and authentication semantics. Do not reproduce those references or write parallel library tutorials in Notarius. Brief orientation and concrete Notarius workflows are appropriate, with links to the selected upstream contracts for details. For example, explaining that an accepted-artifact cache hit makes no model call and adds no current token usage connects application behavior to native reporting; that explanation belongs locally. The release assessment above supplies upgrade-review context, not material to copy wholesale into product docs. Local documentation retains Notarius-specific integration choices, application behavior, and workflows. Update only the affected content when changes land: - [CLI reference](../cli.md): identify the imported CommandKit/ckconfig/ckprompt interfaces and link to the selected upstream CLI reference, including native [usage reporting](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/v0.8.0/docs/cli.md#promptkit-usage-reporting). Keep application-owned commands, aliases, inputs, and completion reports local; brief usage examples may orient callers without duplicating a usage-flag or smoke-report reference. - [Configuration](../config.md): retain Notarius's source assembly and embedded collection choices; link to PromptKit's [backend definitions](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md#backend-definitions) for provider, zero-cost, and authentication semantics. Explain Notarius-specific source/inheritance choices locally where useful. - [Operations](../operations.md): retain application-owned accepted-result reuse and debug handling, including how application cache reuse affects current execution. Link upstream for token/cache/cost interpretation without adding a reporting contract or duplicating accounting documentation. - [LLM internals](../internal/llm.md), [pipeline internals](../internal/pipeline.md), and [CLI internals](../internal/cli.md): update Notarius's contextual enrollment and integration wiring where implementation changes; link upstream for API contracts rather than reproducing library behavior. - [Kit integration documents](../integrations/pkg-commandkit.md): keep concise adoption/boundary notes and update affected versions and canonical upstream links, including the separate PromptKit/ConfigKit integration documents where relevant. Replace affected duplicated library explanations with links. - [Subprocess](../consumers/subprocess.md) and [D&D consumer](../consumers/dnd-pipeline.md) guidance: briefly link opt-in diagnostics while retaining primary stdout parsing and domain artifact retrieval as the consumer contract. - [Maintained examples](../../examples/): retain native inherited OpenRouter configuration and valid complete/minimal pipelines; only change declarations if review finds they actually need migration. - [Attribution](../oss/attribution.md): update changed modules' versions and source/notice links to their distinct release commits. Selected COPYRIGHT and LICENSE texts were compared with the current releases and are unchanged; recheck the final selected graph and preserve existing license texts. Retain the unchanged ConfigKit entry. Maintainer-only tools are not new runtime attribution entries merely because an upstream `go.mod` lists them. A new ADR is not needed for this additive use of the already adopted native-kit ownership boundaries. Existing architecture wording may need a small factual update from runner-owned request enrollment to consumer-owned contextual observation; accepted ADR bodies remain unchanged. Documentation acceptance: readers can discover each adopted interface and reach its selected upstream documentation directly. Local material describes what Notarius contributes or selects, allowing brief orientation without a parallel library reference. This upgrade is not a repository-wide documentation rewrite. ## Implementation Sequence All work remains pending. Use a few focused, reviewable changes, with relevant tests and documentation accompanying each change: 1. Adopt the coordinated dependencies and native reporting through the existing command assembly. Verify installation and invocation-context propagation without introducing temporary application accounting or reporting wrappers. 2. Move caller/debug observation to native contexts, remove the runner group parameter and general observer forwarding, and retain operation-specific capture and application lifecycle handling. Update callers and focused tests with the removal rather than preserving a compatibility path. 3. Complete the integration checks below and remaining documentation/notices. Confirm that ordinary accounting needs no application-maintained totals, unconditional group, or handler reporting callbacks. These are implementation units within this roadmap, not separate releases or new approval gates. Refine file-level tasks as the code changes without creating another substantial planning artifact. ## Verification And Acceptance Use the real updated kits with fake clients or local HTTP fixtures. Protect integration behavior, not an exact copy of upstream report wording. The list below defines coverage, not one required new test per item or flag combination. Reuse existing tests and combine representative workflows where they protect the same integration boundary: 1. Both maintained example configurations pass offline pipeline validation; original-result handoff, focused inspection, overlays, and secret-aware evidence remain intact. 2. `run` and `pipeline run` accept the native usage flag, with no application flag/alias collision. An assembled model-backed run covers initial calls, a correction or structural repair, concurrent work, and a nested validator without duplicate totals. Reuse existing recovery fixtures where practical. 3. `--show-tokens --format json` leaves stdout as the ordinary completion report and writes usage only to diagnostics. Omission/explicit false, repeated selection, quiet, help, bare `config explain`, returned failure, cancellation, and diagnostic-delivery failure retain native semantics. Cover representative application reporting and failure boundaries using existing tests where sufficient; do not reproduce upstream's parser and presentation matrix. 4. A subsequent accepted-result hit performs no new model call and contributes no historical usage. Preparation alone emits no execution; a prepared miss observes its execution context. Debug events/group snapshots continue to retain native identity, coverage, reasoning, and cost without a second ledger. Caller/debug observers work through context without `RunInput.Executions` or general `ExecutionOptions.Observer` forwarding. Preserve operation-specific evidence and capture/publication failure handling while retiring tests coupled only to the old plumbing. 5. One representative HTTP fixture verifies an application-selected OpenRouter or vLLM configuration through the built-in HTTP client and new accounting fields. Preserve known zero versus unavailable/incomplete state; do not add reasoning/cache counts again to total tokens. Avoid duplicating the full upstream provider decoder test suite. 6. Smoke JSON/YAML retain native structured reasoning/cache-ratio fields; scripts/documentation no longer assume the old default serialization. Existing domain JSON, completion fields, cache identity/eligibility, and producer failure/fallback behavior remain unchanged. Relevant existing test owners include [application assembly](../../internal/cli/application_test.go), [recovery](../../internal/cli/recovery_contract_test.go), [native processes](../../internal/cli/native_process_test.go), [completion/delivery](../../internal/cli/run_result_command_test.go), [producer execution](../../internal/framework/pipeline/producer_test.go), [cache reuse](../../internal/framework/pipeline/producer_cache_test.go), [capture](../../internal/framework/pipeline/native_capture_test.go), and [native validator execution](../../internal/modules/dnd/validate/scenedescriptions/combat_semantics/native_execution_test.go). Run focused tests during changes, then `GOWORK=off go test ./...`, `GOWORK=off go vet ./...`, and a build of `./cmd/notarius`. Run focused race checks for touched pipeline/CLI observation paths. Validate maintained examples and exercise native help/inspection/reporting using the resulting executable. Tests remain offline and credential-independent; production billing accuracy and model quality are not release gates for this dependency upgrade. ### Review-Time Compatibility Evidence The published target set was selected in a temporary module file outside the repository. The existing full test suite, vet, build, and module verification passed. Executable tests were also rerun with the temporary module selection inherited by their child builds. The resulting executable passed both maintained examples' offline preflight with `--show-tokens --format json`, showed the inherited `openrouter` provider on `limited-openrouter`, and displayed bare `config explain` help without a usage summary. Local roadmap links and whitespace checks passed. Repository dependency files and application code remain unchanged. These checks establish baseline compatibility, not completion of the proposed contextual-enrollment refactor or new accounting integration coverage. No live provider, production-model, or billing tests were run. ## Scope Boundaries This is a coordinated dependency and native-observability upgrade. It does not add a dashboard, cost enforcement, budget caps, usage database, durable execution ledger, new validator policy, prompt/model change, configuration compatibility layer, or changed artifact schema. Future reporting demands can build on the native evidence when a concrete consumer requires them.