From bdeac85e8efa0273e63e9b098d5e13cdd6df3576 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 23 Nov 2026 17:18:18 +0000 Subject: [PATCH] Remove completed library upgrade planning documents --- docs/roadmap/implementation.md | 573 ------------------------------- docs/roadmap/library-upgrades.md | 479 -------------------------- docs/roadmap/remediation.md | 341 ------------------ 3 files changed, 1393 deletions(-) delete mode 100644 docs/roadmap/implementation.md delete mode 100644 docs/roadmap/library-upgrades.md delete mode 100644 docs/roadmap/remediation.md diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md deleted file mode 100644 index 6a20a39..0000000 --- a/docs/roadmap/implementation.md +++ /dev/null @@ -1,573 +0,0 @@ -# Library Adoption Implementation Plan - -**Status:** Implementation complete; [review remediation](remediation.md) is complete. -Planning baseline: -`12fd2fba6b88e30eb482227ac786201caa84616b`. - -**Audience:** Luna coding agent implementing one stage per prompt, in the -numbered order below, during one end-to-end sprint. - -The [feature roadmap](library-upgrades.md) owns the target state, adoption -decisions, upstream revisions, and release authorization. This document owns -the implementation sequence. Read `docs/development.md` and the applicable -policies before each stage; follow the agent, architecture, testing, -documentation, OSS, and release policies for the work they govern. - -## Execution Instructions - -- Implement the final design directly. Intermediate stages may fail to compile - while callers and tests are being migrated. Stage acceptance describes the - completed portion of the final design, not a requirement for an independently - buildable intermediate release. Do not add temporary adapters, legacy loaders, - compatibility serializers, or placeholder implementations to keep stages green. -- Update affected tests with their owning implementation. Run focused checks - once their dependencies compile; otherwise record the specific deferred check - and complete it in the final stage. Do not repeatedly run the full suite while - the coordinated changes are incomplete. -- Preserve domain behavior: proposal identity, applicability, protection, - editorial acceptance, validator reconciliation, semantic correction repair, - deterministic collection, recoverable failures, cancellation/joining, and - transcript/ordinary-report publication. The deliberate changes are those - selected in the feature roadmap, including prompt-owned structural contracts, - startup classification, and debug representation. -- Test Audita's integration decisions and transformations. Use native libraries - with controlled clients, files, and environment values; do not reproduce their - complete test matrices or freeze prompt wording and upstream report layouts. -- Commit completed units with plain-English messages under the agent policy. - State honestly when a commit's validation depends on a later stage. This plan - is for separately requested implementation and release-document preparation; - publication remains a later release task. - -## Stage 1: Select the Dependencies and Compose One Application Configuration - -**Outcome:** One typed application configuration contains Audita settings and -native PromptKit settings, with one source-composition path. - -1. Update `go.mod`/`go.sum` to the feature roadmap's matched set: ConfigKit - v1.4.0, PromptKit v0.25.0, CommandKit v0.8.0, ckconfig v0.11.0, and ckprompt - v0.12.0. Keep the `/v4` module path, Go 1.27.0 minimum, selected release - toolchain, and ReleaseKit selection. Use normal module resolution, without - local replacements or workspace dependencies. Compile failures from removed - APIs are expected until the later stages. -2. Keep `internal/core/config.Config` as the reusable domain settings type. - Extract its existing defaults, version rule, sequence identities, recorded - resolution, and validation into an exported `Definition()` returning - `configkit.Definition[config.Config]`. Preserve application schema version 3. - Source discovery and embedded PromptKit assembly do not belong in this core - definition. -3. Add a small application assembly package, `internal/appconfig`, with a root - type containing `Application config.Config` tagged `yaml:",inline"` and - `PromptKit promptkit.Settings` tagged `yaml:"promptkit"`. The inline field - keeps Audita's YAML paths unchanged. Lift the domain definition's callbacks - onto `Application`, passing through the same native resolution/validation - objects and root paths; preserve its version rule, identities, and any - sensitivity rule. Compose the result with `promptkit.Configure`. -4. Assemble native underlays in increasing precedence: - `promptkit.BundledOpenRouterUnderlay()`; embedded Audita prompts and the - embedded schema-root input; - optional main-relative glossary and prompt companions. Main, selected - overlay, and explicit overrides follow those underlays through the normal - layered load. Retain the existing distinction between strict composition - within an underlay group and replacement by a later group. -5. Discover embedded definitions with `promptkit.FilesystemInputs` and set each - fragment's destination to `/promptkit`. Install `SchemaRootSource` at the - same destination with the existing embedded schema filesystem and asset - root as its explicit filesystem context. Keep the schema JSON assets shared. -6. Move the glossary-import assembly and `operatorImports` declarations into - this source-composition boundary. Keep their existing names, optionality, - recursive patterns, and selected-main anchoring. Use `MainRelative` for - companion directive inputs; enable native imports and mount wrapperless - prompt companions at `/promptkit`. Do not add a working-directory fallback - when there is no main source. Check relative import destinations in their - fragment context. -7. Replace the application-only production `config.Load` path with this - assembly. Move source-composition tests to `internal/appconfig`; core tests - can load their domain definition through a small test-local native loader. - Do not retain another production loading route solely for old test helpers. - -**Acceptance and focused verification:** Defaults, explicit version validation, -domain resolution, and glossary identities retain their existing paths and -behavior. A combined native result exposes `/promptkit` as `promptkit.Settings`. -Representative composition tests cover a wrapperless companion, a source-local -message, a main setting, and an overlay override. Main/companion behavior with -no selected main is covered. Neither assembly nor these tests contacts a -provider. The former `WithSchemaFS` users will be removed in Stages 3 and 4. - -**Complete.** The matched modules and combined application definition are in -place. Focused core and assembly tests pass, including main-relative glossary -imports, replacement and peer conflicts, prompt content files, overlay -selection, and absent-main discovery. The CLI and remaining runtime test -callers cannot yet compile against the new result and removed PromptKit APIs. -Their migration and integration checks are deferred to the following stages. -The superseded runtime companion assembly remains until its removal in Stage 3. - -## Stage 2: Bootstrap Secrets and Wire Shared CLI Acquisitions - -**Outcome:** Processing and native configuration commands use the same -bootstrap-before-load path and retain its safe evidence. - -1. In `internal/appconfig`, make the load entry point return the completed - native result, `*configkit.SecretsReport`, and error. Pass the selected host - `File`/`SearchConfig` source to `LoadSecretsIntoEnvironmentFromConfig` before - `LoadLayered`. Pass through any explicitly selected host filesystem context - during preparation and reuse its returned prepared main as the later input. - Do not rediscover the file or run bootstrap during engine construction. -2. Preserve native behavior for absent optional discovery, missing directory - declarations, overwrite controls, and partial effects. On bootstrap failure, - return its report and original cause without loading configuration or - starting transcript/output preparation. Check the caller context before and - after the synchronous preparation/load boundaries; retain cancellation - identity alongside any native failure already returned. -3. Update `internal/cli/app_wiring.go` and `process_inputs.go` to use the combined - result. Pass only its `Application` settings to normalization, preflight, - modules, validators, and the runner. Keep native inspection of the whole - result for the `app` scope and native PromptKit inspection for `promptkit`. - Debug effective configuration uses the completed result's native rendering. -4. Keep the invocation-local engine capture used by request inspection. Reuse - a completed acquisition where one command needs both its result and engine; - do not bootstrap twice for that handoff. Comparison loaders still acquire - each side independently, even for equal selections. Their environment is - ordinary shared process state, as selected in the roadmap. Do not introduce - process-global caches or credential-environment isolation. -5. Present successful bootstrap entry details through ordinary verbose/debug - diagnostic reporting and retain the report on error. For uniform access - from native loader callbacks, use one small, flagless CommandKit invocation - feature to put a CLI-owned report sink in the invocation context. Attach it - once through a declaration; its sole job is forwarding safe bootstrap - details to the existing reporter. It adds no final usage report or new - reporting framework. Pass contexts through rather than replacing them with - background contexts. -6. On failure, keep native load diagnostics/source evidence in the established - CommandKit acquisition path. For `SecretsError`, include its safe native - diagnostics and report in terminal error context so ordinary/quiet mode - still explains the failure. A narrow error wrapper may retain this context - while unwrapping to the original error; do not invent a second classifier. - Use `ckconfig.ClassifyConfigurationError`: native usage errors remain usage - errors and unclassified bootstrap/runtime failures remain operational. - Preserve reporter write-error handling. -7. The flagless feature and loaders must remain uninvoked for generated help, - version, completion, input preflight failures, and bare `config explain`'s - help fallback. Configuration inspection still requires no processing-ready - pipeline or model credentials, although configured bootstrap may populate - the process environment. - -**Acceptance and focused verification:** A temporary secrets directory supplies -a synthetic credential that the shared load/engine can consume. Test one -overwrite selection through Audita wiring and a failed bootstrap with safe -terminal evidence, retained native cause, no output preparation, and no provider -request. Use nonparallel environment-changing tests and restore test variables. -Exercise prepared-main reuse at this boundary without cloning upstream's full -file/overwrite test matrix. Check help-only paths and representative native -inspection; use existing `app_wiring_test.go` and process input tests as owners. - -**Complete.** Shared loading prepares the selected main once, bootstraps secrets, -retains the native report and error, and forwards safe details through the -invocation reporter. Focused assembly and isolated native-adapter tests pass -for overwrite, failure, cancellation, help, independent comparisons, and -diagnostic write errors. Full CLI and engine handoff tests are deferred until -the runtime accepts the combined result in the next stage and the removed -PromptKit APIs are migrated. The prepared-source snapshot test confirms reuse -when an already prepared source is supplied. - -## Stage 3: Construct the Engine from the Result and Track Native Source Origins - -**Outcome:** The LLM runtime captures resources from the shared result without -loading a second configuration or reconstructing a filesystem context. - -1. Update `internal/framework/llm/runtime.go` to use `promptkit.NewFromConfig` - with the captured result and `RuntimeConfig{HTTPClient: client}`. Accept the - public `promptkit.Configuration` handoff interface where only native result - access is needed. Keep domain settings as separate inputs at their actual - consumers; remove the runtime's unused stored configuration copy. -2. Remove `newEngineWithPromptFS`'s source reconstruction, duplicate discovery, - `pk.NewEngine` production construction, `WithSchemaFS`, and - `embeddedAssetOrInputError`. Tests that inject alternate assets should do - so at the source-assembly boundary, not through an embedded-only diagnostic - engine. Keep checking required shipped prompt identities where needed for - existing runtime readiness. -3. Preserve original `LoadError`/engine errors, source records, and error chains - through CLI classification. For directly identified application asset-access - failures, use a small assembly-owned asset error rather than reconstructing - another engine. Replace the former `llm.AssetError` plumbing accordingly. - A defect that only manifests as a native configuration error may retain - that native classification, as authorized by the roadmap. -4. Rewrite `source_paths.go` around the captured typed settings and effective - native origins. Traverse root prompts and namespaced collection prompts; - use native paths under `/promptkit` for `content_file` metadata. Associate - host message paths with their actual contributing acquired source/context, - including inherited/replaced definitions. Keep acquired host configuration - sources in the protected set. Embedded/native filesystems do not acquire - invented host paths. -5. Remove effective-YAML rendering and partial YAML decoding from path discovery. - Feed the resulting source/message set into the existing output-collision - checks. Preserve their existing semantics, including intentional in-place - transcript replacement and protection of consumed configuration/messages. - Do not add an independent filename scan or another source resolver. -6. Adapt `loadProcessInputs`, `prepareProcess`, and their tests to the combined - result and domain subvalue. Keep the existing order of configuration/runtime - preparation, transcript acquisition, processing preflight, and output setup. - -**Acceptance and focused verification:** Tests in `engine_sources_test.go`, -`source_paths_test.go`, `runtime_inspection_test.go`, and CLI output tests cover -shared handoff, main-relative companions in a wider selected host root, -source-local/inherited message paths, native inspection without provider access, -and retained collision protection. Replace reconstruction-specific asset tests -with focused shipped-asset preparation checks and original-error preservation. -Cancellation remains operational and retains its identity. - -**Complete.** Engine construction now consumes the shared native result, and -source protection uses typed settings and origin metadata. Focused runtime -tests pass for inherited and replaced prompts, source-local messages, symlinks, -wider filesystem roots, offline inspection, and cancellation. The remaining -adapter, CLI, and output integration tests require the PromptKit request -contract migration in the next stage and will be run after it compiles. - -## Stage 4: Use Prompt-Owned Contracts and Recover Invalid Response Decoding - -**Outcome:** Processing and native previews honor the same prompt definitions; -Audita's structural contract override and setting are retired. - -1. In `adapter.go`, leave `RunRequest.Validation` unset for ordinary and - coordinated calls. Remove `OutputContract` and all request-time schema/budget - replacement code. Keep explicit role profiles, transient retry controls, - operation deadlines, exchange capture, prepared notifications, and operation - execution counts. -2. Remove `structuredoutput.Request.Schema` and its plumbing in proposal - generation, LLM validators, semantic-repair requests, test doubles, and - diagnostic metadata. A selected prompt now supplies its contract. Preserve - Audita's existing expected domain DTOs and domain validation. -3. Remove `config.LLM.RepairAttempts`, its root default, stage inheritance, - validation, resolved-setting copies, request plumbing, and any remaining - associated CLI exposure. The current process flag table has no dedicated - structural-repair flag; do not introduce one. Keep `CorrectionRepairAttempts` - and its profile selection, and keep transient retries and operation timeouts. - The old YAML key has no translation or compatibility handling. -4. Keep the embedded JSON schema files and a minimal filesystem/asset-root - accessor in `internal/framework/responseschema`. Remove key enums, schema - lookup maps, hashes, diagnostics maps, eager registry decoding, and tests - that solely maintain that retired registry. Retain only loading support - actually needed by native schema-root assembly or shipped-asset tests. -5. Keep the shipped proposal, validation, and repair schema references in their - prompt definitions. Omit `output.repair_attempts` in shipped definitions so - PromptKit resolves its default. Operator replacements supply their own - compatible contracts, including any explicit budget. Do not inject defaults - into their definitions or require them to use a particular schema identity - or validation mode beyond existing native configuration rules. -6. In `finishResponse`, treat `json.SyntaxError` and `json.UnmarshalTypeError` - from the model response as recoverable `invalid_output` failures. Retain the - fatal invalid-target check before execution and fatal handling of actual - application programming errors. Apply this classification to coordinated - repair delivery through the same finish path. Preserve parent cancellation - precedence and current timeout classification. -7. Keep local proposal shape/applicability/protection checks, decision-set - reconciliation, repair response identity checks, and apply-time safety. - A weak operator contract is not a reason to restore per-call schema - enforcement. Do not add another repair loop after failed JSON decoding. - -**Acceptance and focused verification:** Prepare all eleven shipped prompts -through the new assembly and their configured schemas. Use controlled responses -to prove that ordinary proposal/validation and coordinated repair honor native -prompt contracts, including an operator replacement and explicit zero/nonzero -budgets. For the omitted budget, derive expectations from native inspection -rather than duplicating upstream's default-resolution implementation. Under a -permissive operator contract, malformed JSON/type-incompatible responses become -recoverable errors; an invalid application decode target remains fatal. Include -an assembled partial-success case showing usable sibling work continues. Update -adapter, conversation, proposal, validator, runner, and config fixtures at their -existing ownership boundaries. - -**Complete.** Prompt definitions now select structural contracts and repair -budgets. The Audita schema registry and configuration override are removed. -Focused tests passed for all eleven shipped prompts, explicit repair budgets, -operator replacements, recoverable decode failures including coordinated repair, -partial pipeline progress, and the affected CLI, runner, validator, module, and -configuration packages. - -## Stage 5: Retain Native Execution Evidence in the Collector - -**Outcome:** Execution collection carries Audita attribution around native facts, -with native aggregation and no redundant metric representations. - -1. Change `llm.ExecutionObservation` to carry `call_id`, domain `context`, and - a `promptkit` field containing the public `promptkit.ExecutionEvent` value. - Preserve the existing `LogicalCall` attribution, start/finish facts, and - logical call IDs; those are Audita-owned rather than native run IDs. -2. Remove `llm.TokenCount`, `Usage`, and the copied fields in execution events. - Keep one native invocation `ExecutionGroup` and native per-call aggregation - where the debug view needs it. Feed or replay native events into native - groups rather than converting them back from local token DTOs. -3. Replace `ExecutionSummary`'s metric projection with Audita's logical-call - count plus the native `ExecutionGroupSummary`. Preserve the distinction - between pre-execution logical calls and actual native runs; a pre-dispatch - failure need not manufacture a run or prepared request. -4. Keep callback synchronization, copied domain coordinates, deterministic - presentation ordering, and snapshots after work joins. Preserve terminal - evidence for failures and canceled/undelivered coordinated responses. - Do not register the same collector through both a request observer and - context observation. The independent native CLI usage group in Stage 7 - may observe the same runs for its own view. -5. Keep `outcomes.ExecutionCounts` and the small adapter projection from a - terminal event into provider attempts, retries, structural repairs, HTTP - status, and exhaustion. Those are used by domain outcomes and ordinary - reports and remain independent of debug-native DTOs. - -**Acceptance and focused verification:** Collector tests check call/run -attribution, concurrent collection, snapshot ownership, and native evidence -retention. Read reasoning, cache, cost, usage availability/completeness, and -terminal coverage directly from the native structures. Reuse existing native -group behavior rather than retesting its aggregation algebra or provider -decoders. Ordinary-report counts and role progress still function without -debug capture. - -**Complete.** The collector retains native PromptKit events and group summaries -alongside Audita's logical-call attribution. Focused LLM tests pass for -concurrent attribution, snapshot ownership, coverage, reasoning and cache -usage, cost, and replayed group evidence. The debug serializer and its tests -still consume the former projection and are migrated in the next stage. - -## Stage 6: Serialize the Native Diagnostic Envelope - -**Outcome:** One debug format exposes native evidence with Audita's stage, -section, role, and proposal/batch attribution. - -1. Update `internal/framework/processreport/llm.go` so `llm-execution.json` - retains top-level `summary`, `calls`, and `events`. The summary contains - `logical_calls` and nested `promptkit` native group evidence; calls retain - their Audita identity/context and native per-call evidence under `promptkit`; - events contain `call_id`, `context`, and nested `promptkit` native events. - Use public PromptKit types for those nested values. Their native JSON field - names and duration representation need not match the old local projections. -2. Keep `IndexLLMObservations`'s deterministic proposal-index adjustment on - Audita coordinates. It must not rewrite native run identity or provider - evidence. Remove `mapLLMSummary` and corresponding copied metric structures - in `internal/core/reporting/llm.go` when their consumers are gone. -3. Capture the actual `PreparedRun` at the adapter's prepared notification when - debug evidence is requested, including its contract, structured schema - evidence, and `MessageContentHash`. Forward it as optional opaque diagnostic - data through the application boundary and serialize it under `promptkit` in - the interaction request payload. Keep the small domain prompt metadata used - by logical calls; remove independent registry-schema metadata from request - construction and artifact builders. -4. Adapt `structuredoutput.PreparedSnapshot`, proposal/validator interaction - builders, semantic-repair artifact capture, and the diagnostic writer only - as needed for that native payload. Keep necessary domain-neutral message - snapshots where indexed repair history sharing uses them. Preserve the - existing sharing of unchanged message prefixes and final index/path binding; - do not reintroduce full transcript/history copies to normalize native JSON. - Native execution types remain inside adapters/diagnostics, not module or - validator decision logic. -5. Retain the correction ledger's Audita domain fields, optional debug-write - warning handling, and preparation/undelivered-response evidence. Use one - serializer for the new representation; no old-format output switch is - required. Ordinary errors/recoveries/report files keep their current schemas. - -**Acceptance and focused verification:** Existing processreport and debug -integration tests verify the new envelope, correct section/proposal offsets, -semantic-repair attribution, actual prepared contract/hash, and native -reasoning/cost evidence. Test selected meaningful fields and preserved unknown -versus zero states; do not snapshot the complete upstream event structure. -Confirm debug remains optional and capture-disabled processing avoids prepared -message snapshots. Keep partial artifact-write failure coverage. - -**Complete.** Debug reports now retain native execution and prepared-run -evidence alongside Audita attribution. Repair request histories share unchanged -message prefixes, including native evidence. Focused adapter, runner, report, -and CLI tests pass for prepared contracts and hashes, optional capture, -attribution, native usage and cost, and partial artifact-write failures. - -## Stage 7: Exercise Native CLI Usage Reporting and the Assembled Pipeline - -**Outcome:** The installed ckprompt family supplies invocation usage reporting -for Audita processing, and all command paths use the new assembly. - -1. Keep the existing `ckprompt.Declarations` installation, which brings native - `--show-tokens`. Resolve any actual assembly collisions without creating an - Audita-owned duplicate flag or usage formatter. Keep the Stage 2 bootstrap - report sink separate from this upstream final-report feature. -2. Trace `Invocation.Context` through processing, derived worker contexts, - ordinary model calls, coordinated repairs, and nested validators. Preserve - its values and join owned work before returning. Do not install an extra - accounting observer into each handler for the native CLI summary. -3. Adapt application-native inspection tests for `/promptkit` paths, prepared - contracts/hashes, provider declarations, and native smoke output. Structured - smoke consumers and tests request `--format yaml` or `--format json`; default - text output follows upstream. Keep explicit smoke probes opt-in. -4. Update native adapter and assembled HTTP fixtures to use the appropriate - explicit provider when testing OpenRouter/vLLM evidence. Preserve generic - OpenAI-compatible examples and do not infer `zero_cost` or a provider from - endpoint/ID. Let upstream validate and interpret those settings. -5. Add or adapt representative assembled tests combining proposal, validation, - and semantic repair. Verify observed usage with debug off, with debug on, - and on a returned failure/cancellation. Check transcript stdout isolation, - quiet suppression, help-only paths, and coexistence with ordinary reports. - A normalization-only pipeline can exercise native zero-execution reporting. - -**Acceptance and focused verification:** Existing CLI and subprocess tests pass -with controlled responses and no real credentials or paid calls. The native -summary includes executions reached through the pipeline's contexts and is -independent of optional debug retention. Compare meaningful observed counts to -the controlled workload, without copying CommandKit's report template or -PromptKit's full retry/cost accounting suite. Keep Audita's ordinary completion -message, partial-success behavior, capacity sharing, and output lifecycle. - -**Complete.** Assembled command tests exercise native usage reporting through -proposal, validation, correction repair, failure, cancellation, debug and -quiet modes, as well as normalization-only processing. They cover an explicit -OpenRouter provider, prepared contract inspection, transcript stdout isolation, -and ordinary reports. The CLI, subprocess, and LLM package tests pass with -controlled providers and prompt-owned fixture budgets. - -## Stage 8: Update Maintained Examples, Migration Guidance, and Canonical Docs - -**Outcome:** Documentation explains Audita's changed integration and links to -upstream for library behavior; maintained projects exercise the target model. - -1. Follow the feature roadmap's documentation-consolidation table and the - adopted documentation policy. Keep Audita's paths, mounts, role choices, - domain response requirements, output lifecycle, and error mapping local. - Replace repeated upstream feature descriptions with links applicable to the - imported versions. Keep brief Audita workflow examples discoverable. -2. Update `docs/config.md`, `docs/cli.md`, `docs/operations.md`, and affected - integration docs. Remove the retired Audita structural-repair setting. - Identify shared loading, configured bootstrap availability and when Audita - invokes it, and native usage reporting. Explain the changed startup error - mapping. Link upstream for controls, native commands, providers, credentials, - schemas, and token/cost semantics. -3. Add `docs/migrations/v4.1.md` for this conversion. Cover removal of root/stage - `llm.repair_attempts`, prompt-level budget selection and the changed omitted - default, operator output contracts, native inspection paths, debug-format - changes, and native smoke format selection where scripts are affected. - Keep application configuration version 3 and wrapperless companions. - Explain that former stage-specific structural budgets now become choices - for the selected prompt; do not promise an automatic one-to-one conversion. -4. Give the budget migration a concrete, valid example using the existing - complete grammar prompt replacement in `examples/prompt-edit/prompts.yml`. - Add an explicit `output.repair_attempts` there while retaining its messages, - format, validation mode, and schema reference. Validate the example through - the real loader; do not present a partial same-ID record as a field patch - when native replacement discards its lower record. -5. Update `examples/local`, `service`, `prompt-edit`, and `campaigns` and their - integration fixtures as needed. Keep generic/local service identities and - synthetic credentials. Add a small synthetic bootstrap fixture to the - existing maintained-example tests rather than checking in real secret files. - Validate a prompt-owned budget example with the native engine; keep complete - copyable inputs in `examples/`, with migration prose linking to them. -6. Update internal overview, CLI/configuration recipes, runtime, prompts, - diagnostics, modules, and validator docs where ownership or call signatures - changed. Remove references to retired registries, schema overrides, metric - DTOs, and the diagnostic reconstruction. Document the Audita envelope and - its native nested evidence without maintaining a duplicate upstream schema. - Keep existing accepted ADR decisions and historical release notes intact. -7. The upstream documentation policy v1.13 is already adopted. Apply it; no - further policy edit is needed merely to restate its upstream-dependency rule. - -**Acceptance and focused verification:** Maintained projects load, native -previews resolve the schemas they use, and controlled processing examples pass. -The migration example actually selects the intended budget without losing the -prompt's messages or schema. Check affected local links and examples. Readers -can find the imported libraries' canonical docs, while Audita's behavior remains -understandable without duplicated library manuals. - -**Complete.** Current configuration, CLI, integration, operations, and internal -guidance describe shared loading, prompt-owned contracts, and native evidence, -with versioned upstream links. The v4.1 migration guide and complete prompt-edit -example explain structural-budget conversion. Maintained projects pass their -controlled-provider test, including synthetic secrets bootstrap and native -preparation of the replacement contract; affected local links were checked. - -## Stage 9: Refresh Attribution and Prepare v4.1.0 Release Documentation - -**Outcome:** The changed dependency selections and application migration have -accurate notices and a checked-in release record ready for later publication. - -1. Update the five dependency entries in `docs/oss/attribution.md` to the - roadmap's exact versions and full source commits. For ckconfig/ckprompt, - use their independently tagged integration commits and correct nested - notice paths. Inspect the selected `COPYRIGHT`/`LICENSE` material, preserving - `LGPL-3.0-or-later` and applicable companion-text links under the OSS policy. -2. Reuse applicable local standard license texts. Review any transitive changes - actually selected by normal module resolution, updating only affected - entries. The toolchain, YAML v4 selection, and ReleaseKit remain unchanged; - this work does not require rewriting unrelated notices or published records. -3. Create `docs/releases/v4.1.0.md`, beginning `# Audita v4.1.0`, and index it in - `docs/releases/README.md`. Describe the shipped upgrade, bootstrap capability, - native usage reporting, and the configuration/debug/inspection/error-mapping - changes with links to canonical Audita guidance and the migration guide. - Explain actual breaking changes and required action plainly. The feature - roadmap owns the release authorization; do not repeat its versioning-override - discussion in the release note or change the release policy. -4. End the release note with the runbook's absolute, immutable v4.1.0 links - labeled `COPYRIGHT | LICENSE | ATTRIBUTION`. Check those paths against the - source tree; the unpublished tag need not resolve. Keep Audita's `/v4` import - path. Prepare documentation only: do not tag, push, run `publish`, or wait - for CI as part of this sprint plan. - -**Acceptance and focused verification:** Attribution versions/commits agree -with module metadata, license links reach the proper texts, and the release -note accurately describes the implemented migration. Required footer paths and -the release index resolve locally. No historical release content is rewritten. - -**Complete.** Attribution records the five selected module versions and their -independent source commits. Their selected copyright and license files were -checked against the prior selections and retained local license texts. The -v4.1.0 note and index are prepared with the required immutable-tag footer; the -referenced source paths exist. No tag or publication was created. - -## Stage 10: Finish Cleanup and Validate the Complete Target State - -**Outcome:** The complete adoption compiles, passes the offline suite, builds -both production targets, and contains no retired implementation path. - -1. Review every stage's deferred checks and complete them. Remove superseded - tests, imports, files, helper DTOs, and comments that only served the old - loader, schema registry, per-call structural contracts, embedded-only probe, - or debug metric projections. Retain domain and integration coverage serving - the current contracts. Keep the tests for unavailable decisions, empty - replacement spans, semantic repair, and output failures. -2. Search active application/test code and maintained current docs for retired - references: `WithSchemaFS`, `embeddedAssetOrInputError`, per-call - `Request.Schema`, the removed schema registry/builder, and Audita's root/stage - structural budget. Distinguish legitimate native `repair_attempts`, semantic - correction-repair settings, migration explanations, and historical records - from stale production support. Do not make a blanket zero-occurrence rule. -3. Review the final dependency direction: core domain code does not acquire - CLI/provider responsibilities; `internal/appconfig` composes configuration; - runtime constructs from the result; modules/validators retain their domain - contracts; debug-native types stay at the adapter/diagnostic boundary. -4. Use the selected Go 1.27.4 toolchain and prepare module dependencies before - offline validation. Run `go mod tidy` and review its diff, format changed Go - files, run `go vet ./...`, and run `go test -race ./...` once on the completed - source. The race-enabled command covers the complete default suite; do not - require a second full non-race run for this same state. Fix failures according - to their actual contract; repeat affected checks when fixes warrant it. -5. Build `./cmd/audita` for Linux amd64 and arm64 using `GOOS=linux`, the selected - `GOARCH`, and `CGO_ENABLED=0`, writing binaries to a temporary directory. - Native macOS testing is best effort and is not a prerequisite. Check affected - documentation links, examples, and `git diff --check` without introducing - new recurring release gates or running the publication command as a test. -6. Review the final diff against the feature roadmap: all selected capabilities - are present, intentional migrations are documented, ordinary output and - resilience behavior remain covered, and cleanup is complete. Commit the - final changes under the agent policy and report validation results and any - actual limitations. A later release task follows the existing runbook. - -**Acceptance:** All ten stage outcomes are satisfied, required checks pass on -the final source, no outstanding implementation work is hidden behind a -compatibility path or temporary scaffold, and the workspace is clean. Report -the completed source commit and prepared release documentation without claiming -that v4.1.0 has been published. - -**Complete.** Deferred integration checks and the final cleanup are finished. -Offline `go mod tidy`, `go vet ./...`, and `go test -race ./...` passed with -Go 1.27.4. Linux amd64 and arm64 production builds succeeded, changed Go files -are formatted, affected local documentation links were checked, and retired -implementation references were reviewed. Runtime preparation errors retain -operational classification; native configuration usage errors remain usage -errors. Release documentation is prepared for a later publication task. - -## Open Questions - -None. Product choices are resolved by the feature roadmap. The private assembly -package, shared-load handoff, diagnostic envelope, startup reporting integration, -and failure classifications above provide the implementation decisions needed -for this sprint. diff --git a/docs/roadmap/library-upgrades.md b/docs/roadmap/library-upgrades.md deleted file mode 100644 index d0f8395..0000000 --- a/docs/roadmap/library-upgrades.md +++ /dev/null @@ -1,479 +0,0 @@ -# ConfigKit, PromptKit, and CommandKit Upgrade - -**Status:** Implementation complete; [review remediation](remediation.md) is complete. -The [implementation plan](implementation.md) records the completed stages. - -**Reviewed:** 2026-11-23, against Audita commit -`da5b8913d1206a8e8f0a784b2322760385548a60` (v4.0.0). - -## Recommendation - -Upgrade the three libraries and both CommandKit integrations together. Adopt -PromptKit's application-owned configuration handoff and CommandKit's native -invocation usage reporting. Include ConfigKit's configured secrets bootstrap -to keep startup consistent with other ConfigKit consumers. This reduces -Audita's configuration assembly and reporting responsibilities while retaining -its domain correction and validation behavior, semantic repair, and ordinary -output handling. Prompt definitions own output contracts and structural-repair -budgets; Audita's separate overrides are removed. Debug representation and -startup failure classification also change as specified below. - -Use the shared-load approach because it removes filesystem-context -reconstruction and gives application settings, PromptKit settings, and overlays -one provenance model. -The tradeoff is broader configuration validation and inspection, described below. - -This document records agreed adoption choices and the desired outcome. -The [implementation plan](implementation.md) owns the ordered work and validation. - -## Reviewed Releases - -The following are the latest published versions verified against each upstream -repository's remote tags. Full commits identify the source behind each tag; -CommandKit's integrations are independently versioned modules in its repository. - -| Module | Audita currently selects | Recommended version | Reviewed release commit | -| --- | --- | --- | --- | -| `go.maximumdirect.net/configkit` | v1.2.1 | [v1.4.0](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/releases/v1.4.0.md) | `4a7ae664a6287d71cba20f59c7c5b37b6f05b0a3` | -| `go.maximumdirect.net/promptkit` | v0.23.2 | [v0.25.0](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/releases/v0.25.0.md) | `207677e9948dc5699073a4d6620d21139033c72d` | -| `go.maximumdirect.net/commandkit` | v0.7.0 | [v0.8.0](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/v0.8.0/docs/releases/v0.8.0.md) | `0b53a63648c536afe50c46f948159116f776adae` | -| `go.maximumdirect.net/ckconfig` | v0.9.0 | [v0.11.0](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/integrations/ckconfig/v0.11.0/integrations/ckconfig/docs/releases/v0.11.0.md) | `cd5cf483a46caeff7ca0a91fb4747d57188a3888` | -| `go.maximumdirect.net/ckprompt` | v0.10.0 | [v0.12.0](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/integrations/ckprompt/v0.12.0/integrations/ckprompt/docs/releases/v0.12.0.md) | `2422ccf02d6b55756b07f21e66a581202a09fc3f` | - -The matched integrations select these ConfigKit, PromptKit, and core versions. -Their Go minimum remains 1.27.0, matching Audita. The reviewed module manifests -require no additional upgrade to Audita's existing YAML, JSON Schema, Cobra, -pflag, or ReleaseKit selections. - -The review covered intervening ConfigKit v1.3.0, PromptKit v0.23.3 and v0.24.0, -ckconfig v0.10.0, and ckprompt v0.11.0 as well as the target releases. Upstream -release notes, migration guidance, public APIs, and Audita's consumers were -compared directly. - -## Current Baseline - -- `internal/core/config.Load` produces an application-only ConfigKit result, - with application defaults, glossary companions, imports, overlays, recorded - resolution, and explicit CLI overrides. -- `internal/framework/llm/runtime.go` separately constructs a PromptKit engine. - It reconstructs the application's main filesystem context to discover prompt - companions, selects the bundled catalog and embedded prompts, and installs - embedded response schemas through `WithSchemaFS`. -- Prompt companions are wrapperless PromptKit fragments. Embedded definitions - contain `collections.audita`; operator fragments can contain profiles, - backends, and collections. Resource identities do not include a configuration - path prefix. -- Processing replaces each prompt's output contract with an Audita-owned schema - and explicit structural-repair budget. Semantic correction repair uses native - exchanges and `Engine.Coordinate`, separately from structural repair. -- The LLM adapter records native execution facts for operation outcomes and - optional detailed debug evidence. Its debug collector projects token fields - into Audita DTOs and uses a native execution group. There is no ordinary - invocation-wide token/cost flag. -- Command assembly already uses `ckconfig` and `ckprompt`. Source collision - checks recover message-file paths by rendering effective PromptKit YAML and - decoding a partial projection with root-relative metadata paths. - -A compile-only compatibility probe used a temporary alternate module file with -all five target versions. Audita's module files were unchanged. The unchanged -application does not compile: `WithSchemaFS` is unavailable and -`RunRequest.Validation` now requires `*OutputContractInput` instead of -`*OutputContract`. Prompt registry tests also use the removed schema option. -These are confirmed initial migration points, not an exhaustive runtime check. - -## ConfigKit: Share the Completed Load - -ConfigKit v1.3.0 adds explicit configured secrets-directory bootstrap and -overwrite selection. v1.4.0 adds `Result.Value` and `Result.InspectSubtree`, which -let a library capture its typed settings and focused inspection from an -application-owned result. The latter is directly useful to Audita's PromptKit -adoption. See the [component handoff guide](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/consumers/README.md#component-handoff). - -### Target end state - -The application configuration includes native `promptkit.Settings` under -`yaml:"promptkit"`. Compose Audita's ConfigKit definition with -`promptkit.Configure`, preserving Audita's application version rule, recorded -domain resolution, glossary identities, and validation. Retain application -defaults except for the structural-repair setting removed below. Pass the whole -successful result to `promptkit.NewFromConfig` with the runtime HTTP client. - -Compose the bundled OpenRouter catalog, embedded prompts, schema-root input, -glossary companions, and operator prompt companions as native inputs before the -load. Select `BundledOpenRouterUnderlay` explicitly: `NewFromConfig` does not -add the standalone constructor's default bundle. Main configuration, selected -overlay, and explicit overrides should then operate on the combined document -using ConfigKit's normal precedence. - -Use `MainRelative` for companion imports instead of reconstructing host roots -and base directories in the LLM adapter. Keep optional companion discovery -anchored to the selected main source; the absence of a main source should retain -the existing embedded/default behavior. Keep source-local message resolution -and effective origins intact. - -One completed result should serve a processing acquisition and its engine. -Comparison still acquires each side independently, including equal selections; -this proposal does not establish a process-global cache or a universal -one-load-per-invocation rule. Native loading and validation remain distinct from -processing readiness and provider execution. - -### Inspection and source ownership - -Keep the existing `app` and `promptkit` command scopes. The app scope describes -the combined application result; the PromptKit scope uses native focused -inspection at `/promptkit`. Explicit metadata queries retain application-root -paths, and focused comparisons can include ancestor changes. A focused view is -not an isolation or confidentiality boundary. - -Use the captured typed settings and recorded source contexts when identifying -consumed message files. Remove the YAML encode/decode projection where the -shared result makes it unnecessary, and update metadata lookups to their native -`/promptkit/...` paths. Preserve the existing output-collision protections. -`FromConfigKitSubtree` is available if another concrete configuration scope is -needed later; this upgrade does not need additional inspection commands. - -### Runtime failure classification - -**Agreed decision:** Remove the embedded-only diagnostic engine construction in -`embeddedAssetOrInputError`. Report the original shared-load or engine failure, -preserving upstream diagnostics, source information, and error causes. Use native -configuration-error classification where available. Retain directly identifiable -application failures, such as inability to access a required embedded asset, -without reconstructing an engine to establish responsibility. - -Validate bundled assets through focused offline tests that load shipped -definitions and check prompt and schema references. These tests protect -structural correctness without freezing prompt wording. Runtime processing -still stops on preparation failure, but Audita need not always distinguish a -bundled defect from an operator-input problem. An unexpected shipped -configuration defect may receive the ordinary configuration-failure -classification; retain the original diagnostic evidence in that case. - -Remove tests dedicated to the retired diagnostic reconstruction, retaining -coverage of original error evidence, native classification, directly identifiable -application failures, and cancellation. Update CLI and subprocess documentation -for any resulting changes to error mapping, and assess release compatibility -under the release policy. - -### Secrets bootstrap - -Adopt `LoadSecretsIntoEnvironmentFromConfig` in the common configuration -acquisition path, before the shared `LoadLayered` call and before concurrent -model work. This is an agreed adoption choice for consistency with other -ConfigKit consumers. Use its native main-document controls as defined in the -[upstream bootstrap contract](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md#explicit-secrets-directory-bootstrap). - -Pass the selected host `File` or `SearchConfig` source to the helper, then use -its returned prepared source as the layered load's main input. Reuse that -captured main and its filesystem context rather than rediscovering or rereading -the file. Engine construction consumes the completed result without repeating -bootstrap. Missing optional discovery and configurations without `secrets_dir` -retain the native no-op behavior. - -Use upstream path resolution, eligible-file handling, overwrite semantics, and -partial-effect behavior. No additional Audita bootstrap flags or environment -precedence rules are needed. Link to the upstream contract for those controls -and their limits. - -Retain the returned `SecretsReport` even on failure. Use native safe diagnostics -and the report's names, paths, and statuses for startup reporting, with routine -entry details following existing verbose/debug controls. Bootstrap failure -stops configuration preparation before outputs or provider work. Completed -environment writes remain if a subsequent write or configuration load fails; -follow upstream partial-effect semantics without adding rollback machinery. - -Apply this startup path to configuration-consuming processing and inspection -commands; help, version, and completion retain their configuration-free behavior. -Inspection may therefore populate the process environment, while remaining -independent of provider calls and processing readiness. Independent comparison -acquisitions each prepare their selected main, and share the normal process -environment; they do not receive isolated credential environments. Document -Audita's startup integration and link upstream for bootstrap behavior and -credential selection. - -## PromptKit: Adapt Configuration and Schema Boundaries - -v0.23.3 fixes operation-timeout attribution and cancellation/error identities. -v0.24.0 introduces shared configuration loading, prompt-owned schema selection, -`MessageContentHash`, and a default of one structural repair for enabled -validation modes. It is a breaking upstream release. v0.25.0 adds contextual -execution observers, explicit provider conventions, reasoning/cache usage, and -presence-aware USD costs. Follow the [migration guide](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/consumers/configuration-migration.md) -and [format contract](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md). - -### Configuration shape and compatibility - -Complete PromptKit documents now require a `promptkit` wrapper. Preserve -Audita's existing wrapperless `prompts.yml` and `prompts/` fragments by mounting -them at `/promptkit`, using `SettingsInput` or equivalent explicit destinations. -Mount embedded fragments consistently. Discovery helpers return root-mounted -inputs; they do not perform this adaptation automatically. Imports and nested -destinations must be checked in the context of their containing fragment. -This is a native fragment-mounting capability, so retaining these inputs does -not require a compatibility parser or a parallel loading path. - -Keep existing resource IDs, references, and application configuration version 3. -An optional `promptkit` section in the application main and its overlay can -provide native settings without requiring existing companion files to be -rewritten. Full external PromptKit documents use the new upstream wrapper; -document that distinction rather than silently accepting a file at the wrong -mount. PromptKit no longer enforces resource-version fields; retain Audita's -application version rule without inventing resource-version requirements. - -Shared loading deliberately makes PromptKit settings part of application -configuration validation and inspection. Invalid PromptKit definitions may now -surface in application inspection as well as engine construction. Explain that -change, and keep help/version and processing-readiness checks at their existing -boundaries. No provider calls or required credentials belong in configuration -inspection. - -### Prompt-owned output contracts and structural-repair budgets - -**Agreed decision:** Each proposal, validation, and repair prompt definition owns -its output format, validation mode, schema selection, and structural-repair -budget. Ordinary and coordinated processing select the prompt and leave -`RunRequest.Validation` unset, allowing PromptKit to use that definition's output -contract. Processing and native request previews use the same configured -contract; Audita does not substitute a schema or budget at the call site. - -Replace `WithSchemaFS` with a native `SchemaRootSource` input, mounted under -`/promptkit` and anchored to the embedded schema filesystem at its asset root -(currently exposed through `responseschema.Filesystem()`). -This preserves the existing shipped `schema_path` references and standalone -request previews without duplicating schema JSON into prompt YAML. PromptKit -also supports inline and source-relative `schema_file` definitions; adopt those -where an operator actually needs them. - -Keep shared schema assets referenced by prompt definitions rather than copying -schema JSON into every prompt. Remove the adapter's output-contract builder, -per-call schema-selection fields, and schema-key lookup/registry machinery that -no longer serves a purpose. Retain the embedded assets and any necessary loading -support. Execution diagnostics should describe the actual prepared contract, -using native evidence instead of an independently selected registry contract. - -Shipped prompt definitions omit `output.repair_attempts` to adopt PromptKit's -native default, currently one additional generation for enabled validation. -Operators customize this field through native prompt configuration, including -explicit zero to disable structural repair. ConfigKit owns composition and -clearing; PromptKit owns contract resolution and structural repair. - -Remove Audita's root and stage `llm.repair_attempts` setting, its default, -inheritance and validation logic, request plumbing, and any associated CLI -bindings. Do not translate the retired setting into per-call replacements or -retain a compatibility path that copies and modifies prompt contracts. Migration -guidance should move explicit structural budgets into the applicable prompt -definitions and explain that structural budgets are selected by prompt rather -than by Audita stage. - -Operator replacement prompts must supply output contracts compatible with -Audita's expected response shapes. Audita continues decoding responses and -performing domain checks, including proposal identity, applicability, decision -reconciliation, and protection. It does not enforce a second schema selection -over the operator's configured contract. Keep transient retries and Audita's -semantic correction-repair budget (`llm.correction_repair_attempts`) separate, -with their existing operation deadlines and partial-success behavior. Failed -structural validation continues through the existing model-operation failure -handling. Update ordinary and coordinated requests together. - -**Decoder clarification:** Successful PromptKit validation no longer guarantees -that a response is valid JSON compatible with Audita's decode target, because -the selected prompt owns the validation contract. Treat response JSON syntax -and type errors as recoverable invalid-output failures for the affected -operation. Retain fatal classification for application programming errors, such -as an invalid decode target. Apply this distinction to ordinary and coordinated -responses, preserving existing cancellation and partial-success handling. -Do not add a second schema-enforcement layer or an additional retry loop. - -Link to the upstream schema reference for external prompt definitions and file -resolution. Audita's documentation should identify its shipped schema selection -and domain requirements. Do not add another schema resolver or introduce -broader schema prohibitions in Audita. - -### Providers and execution evidence - -Custom OpenRouter backends should explicitly set `provider: openrouter` to -receive its usage, cost, and default authentication conventions. Use -`provider: vllm` for actual vLLM services. An omitted provider retains generic -OpenAI-compatible behavior; an endpoint hostname or backend ID does not select -provider conventions. Keep generic services generic, including the existing -local example unless its server actually uses another supported convention. - -Allow native `zero_cost` declarations, but do not infer that a local backend is -free or set zero-cost defaults for operators. Unknown cost remains distinct -from known zero and an incomplete subtotal. PromptKit owns attempt aggregation, -reasoning-token interpretation, cache-hit ratios, cost sources, and terminal -coverage. Costs are observations, not a billing guarantee or budget control. - -### Debug execution data and format compatibility - -**Agreed decision:** Use an Audita-owned diagnostic envelope containing native -PromptKit execution facts. Audita supplies stage, module, role, logical-call, -and relevant correction or validation-batch attribution. Place native evidence -in a clearly named nested field, using PromptKit's public types wherever -practical. Remove redundant local metric structures and mappings; concentrate -any necessary serialization adaptation at the diagnostic-output boundary. -Native execution types belong in the integration and diagnostic machinery; -modules and validators continue using their application contracts. - -Carry `MessageContentHash` into prepared debug metadata where useful, and retain -reasoning tokens, native cost facts, and cache-hit information with their native -availability/completeness semantics. Audita may select execution membership for -a stage or logical call; PromptKit owns aggregation. Avoid recomputing metrics -or summing overlapping attempt, terminal, and group totals. These facts belong -in optional diagnostics; ordinary errors/recoveries documents continue to -describe processing outcomes. - -Accept a deliberate change to the debug artifact format. Native evidence may -evolve with the imported PromptKit version; keep one serializer for the selected -format rather than maintaining an old-format compatibility path. Assess existing -published compatibility commitments and affected consumers, document this -transition and any required script updates, and choose the release version -accordingly. Retaining the current debug field layout is not a requirement. - -Tests should protect correct attribution, inclusion of native evidence, and any -necessary serialization conversion. Avoid snapshots that freeze the complete -upstream execution structure or repeat PromptKit's accounting checks. - -## CommandKit: Adopt Native Invocation Reporting - -Core v0.8.0 provides invocation features for shared flags, context decoration, -and final diagnostic reports. ckconfig v0.11.0 includes native subtree support -and a help-only preflight exemption. ckprompt v0.12.0 installs `--show-tokens` -through the existing nonempty PromptKit family, including application-owned -commands. See the [consumer guide](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/integrations/ckprompt/v0.12.0/docs/consumers/guide.md). - -Adopt that built-in flag and presentation. Propagate `Invocation.Context` through -proposal, validator, and coordinated repair work, including derived cancellation -contexts, and continue joining owned work before returning. The integration's -contextual observer then sees executions across nested clients and engines, -including failures. Audita should retain explicit request observers for domain -operation counts and debug attribution without installing the same collector -twice or implementing another CLI total/report callback. - -The native summary is opt-in, goes to diagnostics, follows deferred completion -messages, respects quiet, and precedes terminal failure explanations. It does -not require debug artifacts or ordinary reporting. Help, version, completion, -and input errors skip feature startup; bare `config explain` has the same help -exemption. Preserve the current transcript stream and completion behavior. - -Adopt native inspection additions and smoke-report changes: backend provider and -explicit zero-cost fields, resolved repair budgets, prepared message hashes, -reasoning usage, and cache-hit ratios. Smoke reports now default to text with -annotated YAML evidence; machine consumers should request `--format yaml` or -`--format json`. Smoke usage is reported separately from ordinary execution -usage, and smoke reports do not gain a cost field. Update affected examples and -tests without promising historical incidental formatting. - -## Documentation Ownership and Consolidation - -**Agreed documentation direction:** Audita identifies the ConfigKit, PromptKit, -and CommandKit libraries it imports and links to their canonical upstream -documentation. Upstream owns descriptions of its features, configuration -fields, defaults, algorithms, CLI grammar, output formats, and API behavior. -Replace local explanations of adopted library features with those links. - -Keep Audita's selected integration and application-owned behavior local: -configuration discovery and companion locations chosen by Audita, input mounts, -role/profile mappings, remaining application-owned processing budgets, required -domain response shapes and shipped schema assets, failure classification, -transcript/report handling, and application migration -steps. A concise integration statement should explain where the adopted library -fits and link upstream for its behavior. Planning documents may identify APIs -and migration constraints needed to explain the proposed work; those details -should not grow into a parallel library reference in the published documentation. - -Keep ordinary Audita workflows discoverable. Brief application examples may -demonstrate standard flags such as `--show-tokens` or an inspection command, -with a link to upstream for the detailed contract. These examples explain how -to operate Audita; they need not reproduce a library command or field reference. - -Align the documentation during this upgrade, including existing duplication: - -| Affected material | Required alignment | -| --- | --- | -| [Documentation policy](../policy/documentation.md#upstream-dependencies) | Completed: adopted upstream v1.13's dependency-documentation rule from revision `5b9088601290564647a9e20c13f95c0da9f4cb15`. Apply it to the remaining documentation work below. | -| [Configuration](../config.md) | Retain Audita's schema, source selection, companion mounts, role settings, and remaining overrides. Remove the retired structural-repair setting and link to its migration guidance. Link to ConfigKit for composition and secrets controls, and to PromptKit for output contracts, structural budgets, and resource formats; avoid reproducing their field/default references. | -| [CLI](../cli.md) | Identify the installed CommandKit integrations and link to the upstream command reference. Describe Audita's `process` command and application-specific stream/exit mapping locally. Introduce native usage reporting with a brief workflow example and an upstream link; leave the detailed flag, report layout, and formatting reference upstream. | -| [LLM integration](../integrations/openai-compatible-llm.md) | Reduce the document to Audita's adapter boundary, role/schema/budget choices, and mapping of model failures into processing outcomes. Link upstream for transport, provider conventions, credentials, retry/repair mechanics, admission, and token/cost semantics. | -| [Operations](../operations.md) and [subprocess integration](../integrations/subprocess.md) | Describe when Audita invokes secrets bootstrap and how startup failure affects processing/output preparation. Link to ConfigKit for bootstrap behavior and to CommandKit for native diagnostic reporting; retain Audita-owned output lifecycle and subprocess handling. | -| [LLM runtime](../internal/llm-runtime.md), [prompt registry](../internal/prompts.md), [diagnostics internals](../internal/diagnostics-reporting.md), and [CLI/configuration recipes](../internal/cli-config.md) | Retain Audita's component wiring, call sites, domain attribution, and change recipes. Replace standalone explanations of upstream loading, coordination, observation, schema resolution, and metrics with focused upstream links. | -| [Maintained examples](../../examples/README.md) and [migration guides](../migrations/) | Keep minimal runnable Audita projects, application-specific prompt inputs, and actual Audita conversion steps. Link upstream for general library tutorials and native command syntax rather than expanding local walkthroughs into library manuals. | - -Use links to canonical documentation for the selected upstream releases, using -the release identities recorded above. Refresh outdated upstream references as -part of current guidance; migration guides should link to the source or target -release appropriate to the conversion they describe. Link to the owning topic -or section, rather than copying the upstream reference into another local page. -Preserve immutable release records and accepted ADR decisions; this work -concerns maintained documentation. Keep attribution notices in their existing -canonical location. - -Completion requires the adopted libraries to be discoverable through brief -adoption statements and canonical upstream links. Apply that approach to the -new secrets, schema, provider, and token/cost capabilities rather than adding -local feature references. Review the affected documents for duplicated library -explanations while checking that Audita-specific choices and workflows remain -understandable. No new library reference pages or recurring documentation gates -are needed. - -## Acceptance Criteria - -- The selected dependency versions match the reviewed releases, with consistent - module metadata and commit-pinned attribution. The reviewed target - `COPYRIGHT` and `LICENSE` files are unchanged from the currently selected - releases; all five remain `LGPL-3.0-or-later`. -- One combined native result serves application settings and engine capture, - preceded by configured secrets bootstrap with prepared-source reuse and safe - startup evidence. Native inspection and processing use the same assembly. -- Prompt definitions own actual output contracts and structural budgets. - Audita's retired setting, per-call overrides, and redundant registry are gone. - Domain checks and recoverable JSON decoding retain the selected behavior. -- Native execution facts and aggregation supply CLI usage reporting and the - new diagnostic envelope. Domain attribution, cancellation/joining, ordinary - reports, partial success, and output publication retain their contracts. -- Superseded source assembly, filesystem reconstruction, YAML round trips, - diagnostic engine reconstruction, metric projections, and tests dedicated to - those retired mechanisms are removed. No temporary compatibility path remains. -- Current documentation and maintained examples follow the upstream ownership - rule. Migration guidance and v4.1.0 release documentation explain actual - configuration, inspection, debug, and failure-classification changes. -- Representative offline integration coverage protects Audita's wiring and - selected behavior without repeating upstream test inventories. The complete - offline suite and required Linux builds pass for the completed source. - -The [implementation plan](implementation.md) identifies the owning components, -ordered changes, and focused checks. The earlier compile probe establishes -incompatibility, not successful adoption; implementation has not been validated. - -## Scope and Release Impact - -This is a coordinated integration change, rather than a version-only update. -It does not require a toolchain increase, a new concurrency scheduler, new -semantic repair policy, pricing estimates, spending limits, or a redesign of -ordinary processing reports. ConfigKit secrets bootstrap is included in the -adoption; additional custom inspection scopes remain an optional future choice. - -Compatibility is a consideration, not an absolute constraint on the target -design. Retain wrapperless companion inputs through native mounting, but avoid -compatibility branches whose only purpose is preserving incidental inspection -formatting, debug representations, or old loading mechanisms. The agreed debug -format and failure-classification changes follow the compatibility assessments -described above. -Choose the desired application contract first, then assess migration and release -impact; a smaller release number is not a reason to retain avoidable complexity. - -Native fragment mounting preserves the wrapperless companion shape, but removal -of Audita's structural-repair setting is an intentional configuration migration. -Operator prompts that previously relied on per-call contract replacement must -also provide a compatible output contract. Document the conversion, including -root/stage budget removal and the changed default. Review representative projects -and existing integration contracts for additional migration needs when -implementing the agreed debug and failure classification changes. - -**Maintainer-authorized release target: v4.1.0.** Because Audita has just tagged -a major release, the maintainer has authorized a one-time override of the normal -[release versioning policy](../policy/release.md#versioning-and-compatibility) -to deliver this roadmap's breaking changes in a minor release. This authorization -applies to this adoption only; the release policy remains unchanged. Record the -override here only, not in the release notes. The v4.1.0 release notes should -describe the actual changes and migration requirements. diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md deleted file mode 100644 index bccdc4a..0000000 --- a/docs/roadmap/remediation.md +++ /dev/null @@ -1,341 +0,0 @@ -# Library Adoption Remediation - -**Status:** Findings from the implementation, integration, and algorithm -reviews; all five issues are complete. - -**Reviewed source:** `338e93a7ebda9a86593069d63f9d5a7fe23ccaf5` -(`Complete library adoption validation and cleanup`). -The follow-up review used `ca06f7c4e34d5702d2234a56c84250c31435fcf2`, which -adds the initial findings without changing application code or dependencies. -The algorithm review used `a020d155f4f2b4270745a2e4ccf9c3565ea129e2`, which -adds the integration finding and also leaves application code unchanged. - -The review covered Stages 1–10 of the [implementation plan](implementation.md) -against the [feature roadmap](library-upgrades.md), including implementation, -tests, maintained documentation, migration guidance, and release preparation. -The intended architecture is substantially in place. The initial review found -test-maintenance and documentation gaps; the follow-up integration review also -confirmed an output-safety gap involving operator-owned schema files. -The algorithm review adds a debug-assembly memory opportunity and a diagnostic -ordering defect. Completion markers below record the fixes. - -## R1: Remove the Test Fixtures' Implicit YAML Layout Requirement - -**Complete.** Shared structural YAML fixture editing replaces all three text -injections; focused layout/contract regressions and affected package tests pass. - -**Priority:** P2 — test maintainability and unintended constraint. - -**Affected code:** - -- [Adapter fixture](../../internal/framework/llm/adapter_test.go): - `adapterFixtureWithPrompt`, budget insertion near line 102. -- [Native adapter fixture](../../internal/framework/llm/native_adapter_test.go): - budget insertion near line 98. -- [Subprocess fixture](../../cmd/audita/main_integration_test.go): - budget insertion near line 280. - -**Finding:** These new fixture paths copy complete shipped prompt documents and -append `repair_attempts` as raw text with ten leading spaces. This assumes the -prompt's `output` mapping is last and has the current indentation. Equivalent -YAML formatting or mapping-order changes can therefore break adapter and -subprocess tests while the production native loader continues to accept the -prompt. The same fragile operation is duplicated in three places. - -This strengthens an incidental source-layout choice into a test requirement. -The selected contract is that fixtures choose explicit prompt-owned repair -budgets; it does not require shipped YAML to retain a particular indentation -or key order. - -**Evidence:** A temporary, external probe loaded the shipped glossary prompt -through native PromptKit successfully, then decoded and reserialized it with -the selected YAML library. The equivalent document also loaded successfully. -Appending the fixture's budget line to that equivalent document made native -configuration loading fail. No repository prompt was modified for this probe. - -**Recommended change:** Set the selected prompt record's -`output.repair_attempts` structurally using a YAML node or mapping, then render -the complete replacement document. Reuse a small fixture helper where practical -so adapter, native-adapter, and subprocess tests do not maintain independent -text-injection rules. Keep this adaptation in test support; production request -contracts should continue to come directly from prompt definitions. - -**Acceptance:** Fixture budgets remain test-controlled and native loading -continues to see the complete intended prompt contract. Equivalent YAML -formatting or key-order changes do not invalidate budget insertion. Retain a -focused regression at the helper boundary without duplicating upstream YAML -or budget-resolution test matrices. - -## R2: Align Remaining Documentation with the Removed Schema Registry - -**Complete.** Prompt guidance describes prompt-owned contracts and domain -validation; roadmap statuses reflect the completed implementation. Local links -and whitespace checks passed. - -**Priority:** P3 — incomplete documentation cleanup. - -**Affected documents:** - -- [Prompt registry guide](../internal/prompts.md), especially lines 58–68. -- [Feature roadmap](library-upgrades.md), implementation status near its opening. -- [Implementation plan](implementation.md), opening status. - -**Finding:** The prompt guide still says `responseschema` retains Audita's -schema-key lookup and that structured calls carry a response-schema key. The -implementation intentionally removed both: `responseschema` now exposes only -the embedded filesystem/asset root, and `structuredoutput.Request` selects a -prompt without a schema field. These statements contradict the central -prompt-owned-contract decision and could lead a future contributor to restore -the retired override path. - -The feature roadmap also says implementation has not begun, and the plan's -opening still says ready for implementation despite completion records for -all ten stages. These status statements no longer describe the reviewed source. - -**Recommended change:** Remove the obsolete schema-key/lookup descriptions. -Describe the remaining shared schema assets, the selected prompt's output -contract, and Audita's domain decoding and validation. Link to upstream for -native schema behavior. Update the roadmap and plan statuses to reflect that -implementation is complete and review remediation remains outstanding; preserve -their baseline and decision history. - -**Acceptance:** Maintained guidance does not claim that production structured -requests carry schema keys or that a schema registry still chooses their -contracts. Roadmap status agrees with the implementation and this review. -No application code, historical release record, or accepted ADR needs to change -to address this finding. - -## R3: Include Operator Schema Files in Existing Output-Collision Checks - -**Complete.** Effective schema files now share origin-based consumed-input -tracking with message files. Source-local/inherited paths, transcript/report -collisions before writes, and successful noncolliding processing pass focused -LLM and assembled CLI tests. Operational guidance lists schema protection. - -**Priority:** P2 — consumed-input preservation and runtime integration. - -**Affected code:** - -- [Runtime source tracking](../../internal/framework/llm/source_paths.go): - `capturedSourcePaths`, especially lines 23–44. -- [Processing input assembly](../../internal/cli/process_inputs.go): - protected-path handoff near lines 71–77. -- [Output selection](../../internal/core/diagnostics/output_session.go): - `SelectOutput` consumes that protected set before preparing outputs. - -**Finding:** Prompt-owned contracts now make an operator's native -`output.schema_file` an actual processing input. Source tracking still collects -only configuration sources and effective `messages[].content_file` paths. The -schema file is absent from ConfigKit's configuration-source inventory and from -Audita's protected paths, so existing output-collision checks never see it. - -A transcript destination can consequently overwrite a schema used by its own -run. An ordinary report can also overwrite the schema during initialization, -before PromptKit prepares the first request. That both damages an input and -turns a valid configuration into a fatal validation-contract failure. The -configured contract is valid; the conflict arises between the newly honored -schema input and the previously existing output lifecycle. This concerns the -integration work in Stages 3 and 4, rather than a defect in native schema -validation. - -**Evidence:** Two isolated subprocess probes used a grammar-only pipeline, a -complete operator prompt replacement with a source-relative `schema_file`, and -a local HTTP stub returning `{"corrections":[]}`: - -- Selecting that schema file as the transcript output completed successfully - after one provider request and replaced the schema with transcript JSON. -- Naming the schema `errors.yml` beside the transcript output let report - initialization replace it. Processing then failed with `structured validation - contract failed`, made no provider request, and left report YAML in the - former schema file. - -The probe binary's build metadata identifies the reviewed implementation -commit. Application code and dependencies are unchanged at the follow-up -review revision. All probe files were temporary and synthetic. - -**Recommended change:** Extend the existing consumed-input path collection to -include effective host-backed `output.schema_file` inputs for root and -collection prompts. Use the native recorded origin/filesystem context to -identify the same file PromptKit resolves, including inherited or replaced -definitions, and pass those paths through the existing collision mechanism -before any output preparation. Keep schema parsing and validation upstream; -this requires no alternate resolver or restriction on operator contracts. -Keep inline and embedded schemas valid and preserve intentional in-place -transcript replacement. Update the operational description of protected inputs -when the fix lands. - -**Acceptance:** Colliding transcript and ordinary-report destinations are -rejected before writes or provider calls, leaving the schema unchanged. A -noncolliding operator schema still supports processing and native preparation. -Cover source-local origin selection at the source-tracking boundary and both -output-collision outcomes at an assembled boundary, reusing existing collision -semantics rather than duplicating their complete filesystem test matrix. - -## R4: Build Per-Call Summaries Without a Second Event Inventory - -**Complete.** One-pass native groups replace per-call event inventories. -Reporting tests pass for unsorted inputs, retained order, duplicate terminals, -incomplete coverage, and calls with no events. - -**Priority:** P3 — optional debug-memory improvement. - -**Affected code:** - -- [Debug execution assembly](../../internal/framework/processreport/llm.go): - `BuildLLMExecution`, especially the `eventsByCall` construction and replay. -- [Native aggregation handoff](../../internal/framework/llm/observations.go): - `Summarize` replays each selected event sequence into an `ExecutionGroup`. - -**Finding:** The builder copies the event slice for the returned artifact, then -copies every complete observation again into per-call slices in `eventsByCall`. -Those extra slices exist solely to replay their contents into native groups. -The grouping pattern predates this upgrade, but the revised builder carries it -forward with the richer native event values. The plan requires native per-call -aggregation and retained events; it does not require a second event inventory. - -**Complexity:** Let `E` be observations, `C` logical calls, and `R` distinct -call/run memberships. Current assembly takes expected `O(E + C + R)` time, with -`Theta(E + C)` additional storage for event grouping. A map of call IDs to native -`*ExecutionGroup` instances can observe events directly in one pass, retaining -`O(C + R)` grouping state instead. This helps when attempts and repair activity -produce many events for each run. Required snapshot/artifact storage remains -linear in the retained evidence, and processing time remains linear; this is -an auxiliary-memory improvement, not a quadratic-time defect or a claim of -measured performance impact. - -**Evidence:** Inspection of the selected native group shows that it retains -run membership and aggregate facts, rather than event history. A temporary -synthetic probe matched the existing per-call summaries using direct native -group accumulation for 40 events, four logical calls, and three observed runs, -including duplicate terminal events, incomplete coverage, and a call without -events. No benchmark or real-provider workload was used. - -**Recommended change:** If undertaking this cleanup, accumulate native groups -by call ID while traversing the retained events, then snapshot those groups -when constructing calls. Preserve the returned event sequence and call order, -including for unsorted supplied snapshots. Continue delegating terminal -deduplication, coverage, usage, and cost to PromptKit. Retain the existing -invocation summary handoff; do not introduce copied metric DTOs or a second -accounting algorithm. - -**Acceptance:** Per-call summaries retain their current meaning, including -pre-execution calls and incomplete runs, without allocating a second full -event inventory for grouping. Reuse existing reporting tests with a focused -multi-event case where needed. This opportunity does not require a new runtime -limit, benchmark gate, or change to the debug artifact schema. - -## R5: Order Native Group Members at the Debug Presentation Boundary - -**Complete.** The diagnostic serializer sorts detached native membership lists -for invocation and per-call summaries. Deterministic permutation tests pass -and verify original snapshot ownership, native facts, and event order. - -**Priority:** P3 — deterministic diagnostic presentation. - -**Affected code:** - -- [Collector snapshots and summaries](../../internal/framework/llm/observations.go): - `Snapshot` and `Summarize`. -- [Debug execution assembly](../../internal/framework/processreport/llm.go): - top-level and per-call `promptkit` group summaries. - -**Finding:** The selected PromptKit group enumerates its membership map when -creating `ExecutionGroupSummary.Members`. Audita now includes that slice in -debug output without ordering it. Sorting the surrounding calls and events -does not order the summary's members. An unchanged completed collector can -therefore produce different serialized membership orders across snapshots. -The previous metric projection did not expose this new slice. - -Stage 5 explicitly retains deterministic presentation ordering. This is an -incomplete adaptation of native evidence to that selected presentation -requirement. Counts, correction decisions, and ordinary reports are unaffected; -the defect is confined to optional diagnostic presentation. - -**Complexity:** Enumerating `R` members is linear. Canonical presentation adds -`O(R log R)` string comparisons for the invocation summary, plus -`sum O(R_i log R_i)` for per-call member lists. A detached copy costs `O(R)` -storage where an existing owned copy cannot be reused. This is a correctness -tradeoff for the already selected ordering requirement, not a speed optimization. - -**Evidence:** A temporary overlay-only test populated one collector with 32 -completed calls and fixed timestamps, then serialized 32 snapshots without -changing any records. It observed multiple distinct membership orders in the -top-level summary. The test file remained outside the repository. - -**Recommended change:** At one Audita diagnostic-presentation boundary, order -detached native `Members` slices by run ID for the top-level and per-call -summaries. Preserve native values, attribution, and the existing call/event -sequence. Keep aggregation upstream and avoid changing shared snapshot slices -as a side effect of rendering. No upstream ordering guarantee or new ordering -of model execution is required. - -**Acceptance:** A fixed captured membership set has a consistent displayed -order, regardless of native map enumeration. Use a small deterministic -serialization regression with deliberately permuted member inputs; do not -retain the audit probe's probabilistic map-order check. Native totals, -availability, coverage, and run identities remain intact. - -## Follow-Up Integration Coverage - -The review revisited the numbered implementation stages in order: - -| Stages | Interaction reviewed | Result | -| --- | --- | --- | -| 1–2 | Shared settings, domain defaults and overrides, companion origins, secrets bootstrap, native inspection, and startup diagnostics. | No additional gap identified. | -| 3–4 | Runtime handoff, source protection, prompt-owned contracts, recoverable decoding, and semantic correction repair. | R3 confirms a missing input in existing output protection. | -| 5–6 | Native execution evidence alongside domain operation counts, proposal attribution, repair histories, and optional debug output. | No additional gap identified. | -| 7 | Invocation context propagation, shared admission, nested validation, usage reporting, quiet mode, and transcript streams. | No additional gap identified. | -| 8–9 | Maintained examples, migration guidance, canonical contracts, attribution, and prepared release documentation. | Existing R2 remains; no additional gap identified. | -| 10 | Cleanup and assembled workflows, including failure, cancellation, partial success, and output publication. | Existing tests pass; the schema-collision probes expose R3 beyond their coverage. | - -## Algorithm Review Coverage - -The algorithm review examined the implementation stages in their numbered -order. It did not reconsider the explicitly retained repair-history sharing, -native retry/repair/admission and aggregation algorithms, or presentation -ordering. No additional avoidable quadratic-time algorithm was identified in -the reviewed changes. - -| Stage | Algorithm review result | -| --- | --- | -| 1 | Source composition and domain callback lifting delegate loading to the selected libraries; no additional local superlinear algorithm identified. | -| 2 | Bootstrap forwarding and diagnostic buffering are linear in their supplied evidence; the retained invocation-local capture is not a growing processing cache. | -| 3 | Source tracking uses maps for source identity, path deduplication, and native metadata lookup, followed by sorting unique paths. No repeated full metadata scan occurs per message. | -| 4 | Removal of contract overrides and registry copying simplifies the call path; response decoding is linear in response size. Existing domain algorithms are preserved. | -| 5 | Collection uses map updates and append operations; snapshot sorting follows the selected presentation design. Native membership ordering needs R5. | -| 6 | Report assembly is linear in calls/events but has the avoidable grouping storage in R4. R5 also applies to its native summary presentation. Planned message-prefix sharing is retained. | -| 7 | Context propagation and native invocation reporting add no separate local accounting algorithm. | -| 8 | Documentation and maintained-example updates introduce no additional production algorithm. | -| 9 | Attribution and release preparation introduce no additional production algorithm. | -| 10 | Cleanup and final wiring introduce no additional algorithm beyond those reviewed above. | - -## Review Validation - -With Go 1.27.4, the complete `go test -race ./...` suite, `go vet ./...`, -`go mod tidy -diff`, and Linux amd64/arm64 builds passed. All 58 changed Go files -were gofmt clean, and 145 local links in the changed Markdown documents -resolved. The fixture-format probe above confirmed R1 separately from the -passing current suite. This review did not change application code or publish -a release. - -For the follow-up, uncached race-enabled tests passed for `internal/appconfig`, -`internal/cli`, `internal/framework/llm`, `internal/framework/runner`, -`internal/framework/processreport`, and `cmd/audita`. The two controlled schema -collision probes confirmed R3. The follow-up changes only this remediation -document; it does not implement the fixes or publish a release. - -The algorithm review used source-level complexity analysis and two temporary -synthetic tests through a Go overlay. The membership-order probe confirmed R5; -the single-pass native-group comparison supports R4. It gathered no real-world -performance data and made no application-code changes. Existing tests for -`internal/framework/llm`, `internal/framework/processreport`, and -`internal/framework/runner` passed; remediation links and whitespace checks -also passed. - -## Remediation Validation - -All five issues are complete. With Go 1.27.4, `go test -race ./...`, -`go vet ./...`, and `go mod tidy -diff` passed on the completed code. -Linux amd64 and arm64 builds succeeded. Changed Go files are formatted; -affected local documentation links and whitespace checks passed. Each issue -was addressed in its own commit with the completion marker recorded above.