Files
notarius/docs/roadmap/upgrade-kit.md

20 KiB

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 recommendations and the target state, not an implementation sequence. No application or dependency changes are part of this review. A separate staged implementation plan can follow approval.

Reviewed Baseline And Published Targets

The Notarius baseline is commit 7faa4a05066179eb61ab6f129b6c915343d094e2. Its 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 Recommended 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:

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 and ADR-0020.

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 and provider response contract.

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.

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.

Use Native Operator Usage Reporting

Retain the existing ckprompt.Declarations assembly in 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, 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.

Simplify Invocation Observation Where It Removes Existing Plumbing

The runner currently enrolls its RunInput.Executions group by composing its observer into input.Execution.Observer and propagating that observer through requests. Prefer attaching this group once with WithExecutionObserver to the runner context, retaining the group for existing debug snapshots and caller inspection. Remove the old enrollment of that same group from request-level fan-out in the same change; do not rely on terminal de-duplication to hide duplicate registration.

Keep request-specific capture and caller callbacks where they serve their existing purpose. This recommendation does not require deleting the general ExecutionOptions.Observer hook or turning per-operation debug writers into one shared writer. A pipeline debug group and ckprompt's CLI invocation group may independently observe the same execution; never add their overlapping totals. Preserve callback composition, concurrency synchronization, captured run identity, and error/capture handling.

Verify both Run and RunPrepared use the decorated execution context, as do corrections and nested validators. Preparation/cache hits must remain event-free.

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. Do not write a Notarius-owned explanation or field reference for these settings. 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 tutorials in Notarius. The release assessment above supplies upgrade-review context, not material to copy into permanent product docs.

Local documentation retains Notarius-specific integration choices, application behavior, and workflows. Update only the affected content when changes land:

  • CLI reference: identify the imported CommandKit/ckconfig/ckprompt interfaces and link to the selected upstream CLI reference, including native usage reporting. Keep application-owned commands, aliases, inputs, and completion reports local; do not add a local usage-flag or smoke-report reference.
  • Configuration: retain Notarius's source assembly and embedded collection choices; link to PromptKit's backend definitions for provider, zero-cost, and authentication settings instead of explaining them.
  • Operations: retain application-owned accepted-result reuse and debug handling; link upstream for token/cache/cost interpretation without adding a reporting contract or duplicating accounting documentation.
  • LLM internals, pipeline internals, and CLI internals: update Notarius's contextual enrollment and integration wiring where implementation changes; link upstream for API contracts rather than reproducing library behavior.
  • Kit integration documents: 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 and D&D consumer guidance: briefly link opt-in diagnostics while retaining primary stdout parsing and domain artifact retrieval as the consumer contract.
  • Maintained examples: retain native inherited OpenRouter configuration and valid complete/minimal pipelines; only change declarations if review finds they actually need migration.
  • Attribution: 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 request enrollment to contextual enrollment; 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, with no parallel library feature documentation. This upgrade is not a repository-wide documentation rewrite.

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:

  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. Choose a focused set of application integration tests; upstream already tests its own 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.
  5. Provider fixtures verify a representative 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, recovery, native processes, completion/delivery, producer execution, cache reuse, capture, and native validator execution.

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.