From 752ec676a60dd7dc0943cee789c84c313ed78eab Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 23 Nov 2026 04:47:06 +0000 Subject: [PATCH] Document the library migration and update examples --- docs/cli.md | 16 +++++- docs/config.md | 31 ++++++++--- docs/integrations/openai-compatible-llm.md | 48 ++++++---------- docs/integrations/output-files.md | 4 +- docs/integrations/subprocess.md | 8 ++- docs/internal/cli-config.md | 3 +- docs/internal/diagnostics-reporting.md | 8 ++- docs/internal/llm-runtime.md | 31 +++++------ docs/internal/modules.md | 4 +- docs/internal/overview.md | 3 +- docs/internal/prompts.md | 6 +- docs/internal/validators.md | 8 +-- docs/migrations/v4.1.md | 64 ++++++++++++++++++++++ docs/operations.md | 7 +++ docs/roadmap/implementation.md | 7 +++ examples/README.md | 6 +- examples/prompt-edit/prompts.yml | 1 + internal/cli/examples_integration_test.go | 37 +++++++++++++ 18 files changed, 217 insertions(+), 75 deletions(-) create mode 100644 docs/migrations/v4.1.md diff --git a/docs/cli.md b/docs/cli.md index 896bd47..cf6b93b 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -3,7 +3,7 @@ Audita uses CommandKit for routing and the ConfigKit and PromptKit integrations for their standard inspection and request commands. Run `audita --help` or command-specific `--help` for the installed command inventory. The adopted -[CommandKit consumer guide](https://forge.maximumdirect.net/base-layer/commandkit/src/commit/f369d6a78253b6e6fcb1e023fb2e9c3af1d20ff0/docs/consumers/guide.md) +[CommandKit consumer guide](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/v0.8.0/docs/consumers/guide.md) describes the standard command grammar, inspection, comparison, preview, validation, smoke tests, and their provider-specific caveats. Help and version do not load application or model configuration. @@ -20,6 +20,12 @@ audita process [flags] transcript.json messages. Quiet processing requires an output file or `/dev/null`. See [operations](operations.md) for output and report lifecycle. +Use `audita process --show-tokens --config config.yml transcript.json` to +request the native execution-usage summary on diagnostics. It works without +debug capture or ordinary reports and follows quiet mode. See the +[ckprompt guide](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/integrations/ckprompt/v0.12.0/docs/consumers/guide.md) +for usage and native command details. + Progress for processing goes to stderr. Use `--progress` to show stage and chunk activity, model proposal, validation and repair operations, and observed counts as work completes. Debug mode enables progress by default. @@ -43,11 +49,15 @@ own configuration and resource scopes and request preparation, validation, and explicit smoke diagnostics. Inspection does not require a processing-ready pipeline or contact a provider. Processing preflight separately checks the selected profiles and glossary entries. Smoke tests can contact providers and are run -only on explicit request. +only on explicit request. Request `--format yaml` or `--format json` for +machine-readable smoke results; their default is text. Shared loading can run +configured secrets bootstrap for inspection as well as processing. Process stdout contains transcript JSON when no output file is selected. Ordinary reports may record recoverable model failures even when processing completes. Exit status `0` means success, `1` runtime or output failure, `2` invalid usage -or input, and native comparison may return `3` for differences. A missing +or input, and native comparison may return `3` for differences. ConfigKit +classifies native configuration diagnostics; bootstrap failures and +cancellation are operational. A missing processing profile or required glossary selection is an input failure. See the [output contract](integrations/output-files.md) and [subprocess contract](integrations/subprocess.md). diff --git a/docs/config.md b/docs/config.md index d3b0825..c6e7b18 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,7 +1,8 @@ # Audita Configuration Audita uses version 3 application configuration. See the [migration guide](migrations/v3.md) -and [examples](../examples/) for complete projects. Command syntax is owned by +and [v4.1 migration guide](migrations/v4.1.md), and [examples](../examples/) +for complete projects. Command syntax is owned by [the CLI reference](cli.md). ## Loading and composition @@ -18,16 +19,33 @@ base for an optional `overlays/.yml`, optional `glossary.yml`, and recursi `glossary/` YAML files. Without a main source, automatic companion files are not loaded from the working directory. ConfigKit composes sources, resolves native inheritance, applies explicit overrides, records derived defaults, and validates -the result. Its [configuration reference](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.2.0/docs/config.md) +the result. Its [configuration reference](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md) owns native composition and provenance semantics. +Before shared configuration loading, Audita runs configured ConfigKit secrets +bootstrap against the selected main source. This can populate the process +environment for processing and native inspection; help and version do not load +configuration. A bootstrap failure stops the acquisition before transcript and +output preparation. See the [ConfigKit secrets documentation](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md) +for directory and overwrite controls. + ### PromptKit profiles and operator prompts -PromptKit loads its default catalog and Audita's embedded prompts, followed by -optional `prompts.yml` and recursive `prompts/` YAML files beside the application -main. Native imports, resource collections, inheritance, and replacement apply. +The combined result contains native PromptKit settings under `/promptkit`. +Audita combines the bundled OpenRouter catalog and its embedded prompts and +schemas with optional wrapperless `prompts.yml` and recursive `prompts/` YAML +files beside the application main. These companions are mounted at `/promptkit`; +a main or overlay may instead contain a `promptkit` section. Native imports, +resource collections, inheritance, and replacement apply. Profiles, backends, models, credentials, admission, and provider parameters belong -to PromptKit configuration; see its [format reference](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.23.0/docs/formats.md). +to PromptKit configuration; see its [format reference](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md). +The selected prompt owns its output contract and structural-repair budget; +operators replacing a prompt must supply a contract compatible with Audita's +expected response. See the [migration guide](migrations/v4.1.md). +Declare `provider: openrouter` for custom OpenRouter backends or `provider: vllm` +for vLLM; an omitted provider remains generic. Neither an endpoint nor a backend +ID implies provider conventions or zero cost. PromptKit owns those settings and +their [usage and cost semantics](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/integrations/openai-compatible-chat.md). The engine captures its sources for an invocation. Edit files and run a new invocation to pick up changes. Inspection does not require model credentials. @@ -74,7 +92,6 @@ specified by the [editorial acceptance boundary](policy/architecture.md#correcti | `llm.correction_repair_profile` | effective proposal profile | Profile for correction repair; null clears an inherited selection before fallback. | | `llm.correction_repair_attempts` | `1` | Nonnegative repair attempts per correction; zero disables correction repair. | | `llm.transient_retries` | `2` | Additional transient attempts per generation. | -| `llm.repair_attempts` | `2` | Structural repairs, from zero through three. | | `llm.operation_timeout` | `15m` | Positive duration per logical operation. | | `validation.max_prompt_tokens` | `2048` | Positive validation batching budget. | | `context.description` | empty | Prompt context; at most 500 bytes after trimming. | diff --git a/docs/integrations/openai-compatible-llm.md b/docs/integrations/openai-compatible-llm.md index 6b4ba99..3cd6e6c 100644 --- a/docs/integrations/openai-compatible-llm.md +++ b/docs/integrations/openai-compatible-llm.md @@ -1,34 +1,22 @@ # OpenAI-Compatible LLM Integration -Audita uses the pinned [PromptKit](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/171fb11f4e967a1da3af57843c6467954b14ba09) -built-in OpenAI-compatible transport. PromptKit owns chat-completions wire framing, -provider envelope parsing, transient retries, per-generation timeouts, and JSON -Schema repair. A backend's configured base endpoint must support the selected -profile's model and structured JSON-schema responses; local configuration -inspection does not contact the provider. +Audita uses [PromptKit v0.25.0](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/integrations/openai-compatible-chat.md) +for its OpenAI-compatible transport, provider conventions, credentials, retries, +admission, and observed token and cost information. Inspection prepares requests +without contacting a provider or requiring model credentials. -Audita selects role profiles independently for each pipeline entry and supplies -its domain response schema and per-operation budget. PromptKit owns backend and -credential selection, request preparation, transport, retries, repairs, and -admission. Audita executes the same prepared handle and retains its own domain -validation. Profiles may use native endpoint and credential settings; local -inspection does not resolve a credential value or call the provider. +Audita selects a profile for each proposal, validation, and correction-repair +role. The selected prompt supplies the output contract and structural-repair +budget, while Audita retains its operation timeout, transient retry selection, +semantic correction-repair budget, and domain checks. Operator prompt contracts +must produce the response shapes expected by Audita. See [configuration](../config.md) +and the [migration guide](../migrations/v4.1.md). -`llm.transient_retries` counts additional attempts for eligible transient -failures; explicit zero makes one attempt. `llm.repair_attempts` counts -additional generations for schema-invalid model output. The operation timeout -covers preparation, capacity waiting, retries, generation, and repair. Caller -cancellation or an earlier deadline also applies. See [configuration](../config.md#settings) -for defaults and the [PromptKit consumer contract](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.23.0/docs/consumers/pkg-promptkit.md) -for protocol and retry details. - -A model operation that exhausts structural repair, a live-parent local operation -timeout, capacity rejection, transport failure, malformed provider response, -or provider HTTP failure is recoverable for that operation. Proposal generation -then contributes no candidates from that response; a failed validation batch -marks its candidates unavailable while other batches and later modules can -continue. Caller cancellation, broken assets or configuration, and unknown -internal failures remain fatal and cancel peers. Audita decodes into domain -types only after PromptKit validates the JSON. Ordinary reports use safe reason -codes and counts rather than provider messages. Full request/response content -is written only with `--debug`; see [operations](../operations.md#debug-evidence). +Exhausted structural validation, an incompatible response JSON, a live-parent +operation timeout, capacity rejection, transport failure, malformed provider +response, or provider HTTP failure is recoverable for the affected operation. +Proposal generation contributes no candidates from a failed response; a failed +validation batch makes its candidates unavailable while independent work can +continue. Caller cancellation, broken assets or configuration, and internal +programming failures remain fatal. Ordinary reports use safe reason codes and +counts. Full interaction content is optional [debug evidence](../operations.md#debug-evidence). diff --git a/docs/integrations/output-files.md b/docs/integrations/output-files.md index b350da5..e04af45 100644 --- a/docs/integrations/output-files.md +++ b/docs/integrations/output-files.md @@ -105,7 +105,9 @@ transcript excerpts or correction lists. With `--debug`, `correction-ledger.json` contains proposed candidates and their application, rejection, or interruption details. `llm-execution.json` -holds logical calls and PromptKit execution events. Interaction request/response +holds `summary`, `calls`, and `events` with Audita attribution and nested native +PromptKit evidence. Interaction request payloads include the prepared native +contract and message hash when preparation succeeded. Interaction request/response artifacts and input snapshots are also debug-only. Records carry zero-based `stage_index` and optional `stage_id` where an entry is identified. These files are diagnostic evidence, not an alternate ordinary report schema. diff --git a/docs/integrations/subprocess.md b/docs/integrations/subprocess.md index 09795f2..200ca79 100644 --- a/docs/integrations/subprocess.md +++ b/docs/integrations/subprocess.md @@ -15,8 +15,9 @@ directory. For stdout output, reports use the effective `reporting.stdout_dir` override. A config-file or overlay value for `reporting.stdout_dir` alone does not redirect file-output reports. `--work-dir` selects a debug root, while `--debug` enables capture; the path flag alone does not. -Supplying a configuration path also makes file selection predictable; only -explicitly referenced credential variables are read from the environment. +Supplying a configuration path also makes file selection predictable. Configured +secrets bootstrap can populate the child environment before the shared load; +see [configuration](../config.md#loading-and-composition). Choose a trusted configuration bundle. An explicit main path still allows its configured imports and automatic overlay, glossary, and prompt companions. @@ -41,7 +42,8 @@ Interpret the exit result according to the Consume transcript/report data through the [output-file contract](output-files.md), and treat stderr as human-readable detail. Audita loads configuration and parses the input transcript before report -initialization. Early destination failures can also leave no reports. After +initialization. Bootstrap failure also occurs before transcript and output +preparation and may leave no reports. Early destination failures can also leave no reports. After initialization, failed reports can describe partial processing or output failures and use the same report directory as successful runs. Exit `0` can include recoverable model errors and applied diff --git a/docs/internal/cli-config.md b/docs/internal/cli-config.md index 8119172..84fedf0 100644 --- a/docs/internal/cli-config.md +++ b/docs/internal/cli-config.md @@ -6,7 +6,8 @@ CLI wiring, and maintained examples. Definitions of behavior belong to the ## Changing Configuration -1. Update fields, defaults, loading, and validation in `internal/core/config`. +1. Update domain fields, defaults, and validation in `internal/core/config`; + update shared source composition in `internal/appconfig` when needed. 2. Update file, selected overlay, credential reference, and CLI mapping as applicable. Preserve the precedence defined in the [configuration contract](../config.md#loading-and-composition), including the diff --git a/docs/internal/diagnostics-reporting.md b/docs/internal/diagnostics-reporting.md index 98eb1fa..6236443 100644 --- a/docs/internal/diagnostics-reporting.md +++ b/docs/internal/diagnostics-reporting.md @@ -60,9 +60,11 @@ prompt content. Execution position and optional operator ID are carried separately from generated safe artifact path coordinates. -Execution diagnostics include a native-group invocation summary and per-call -summaries. Terminal coverage is separate from usage completeness; unknown usage -is distinct from known zero. Overlapping summaries must not be added together. +Execution diagnostics put native group evidence under `promptkit` in the +invocation summary and each logical call, and native events under `promptkit` +with Audita's call and context attribution. Prepared interaction payloads retain +the actual native request under the same key. See [PromptKit's execution guide](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/consumers/pkg-promptkit.md) +for coverage and usage semantics. Overlapping summaries must not be added together. The collector snapshots after work joins and retains domain labels and stable presentation order. Prepared evidence comes from `OnPrepared`, so preparation or admission failures may have no request snapshot. Coordinator execution failures diff --git a/docs/internal/llm-runtime.md b/docs/internal/llm-runtime.md index 13a8333..4c81717 100644 --- a/docs/internal/llm-runtime.md +++ b/docs/internal/llm-runtime.md @@ -1,23 +1,23 @@ # Audita LLM Runtime -`llm.NewRuntime` assembles one captured PromptKit engine using its default -catalog, Audita's embedded prompts and schemas, and optional operator sources -anchored to the recorded application main context. Captured host sources and -message files are passed to output collision checks. An embedded-only diagnostic -construction distinguishes shipped asset failures from operator-source failures; -it never replaces the requested engine. +`internal/appconfig` assembles one shared result and bootstraps configured +secrets before loading. `llm.NewRuntime` captures a PromptKit engine from that +result. Effective host sources and message files are passed to output collision +checks. Native errors and source evidence are retained for classification. Each resolved pipeline entry receives role-bound clients with its selected profiles and effective budgets. Clients share engine-local backend admission. The adapter uses ordinary `Run` with `OperationTimeout` and `OnPrepared`, passes -Audita's per-call schema and repair budget, and decodes only validated results. +no per-call output override, and decodes the response after the selected prompt's +contract has been applied. The operation budget includes preparation, admission, retries, and structural repair. An expired parent context stops processing and retains any native cause. With an active parent, PromptKit's operation deadline remains recoverable even when a preparation error wraps it. A native transport timeout affects the HTTP attempt and is recorded as a transport failure. The prepared notification supplies prompt metadata to observers. With debug capture enabled, it also -supplies the actual request messages when preparation reaches that point. +supplies the native prepared request, including the contract and message hash, +when preparation reaches that point. PromptKit owns backend and credential selection. When a required credential is absent, the CLI identifies the role, profile, and environment variable using the native diagnostic. See the [integration contract](../integrations/openai-compatible-llm.md) @@ -28,8 +28,8 @@ and coordinator before submitting proposal work. The proposal call captures a native immutable PromptKit exchange. Each actionable correction starts an independent `Engine.Coordinate` branch from that exchange. PromptKit assembles continuation history, owns the additional-turn budget, and delivers the last permitted response -for assessment. Follow-ups select the repair prompt, profile, and output schema -directly; Audita does not rerender the original proposal or assemble replay messages. +for assessment. Follow-ups select the repair prompt and profile; the prompt owns +its contract. Audita does not rerender the original proposal or assemble replay messages. An opaque exchange in the structured-output contract keeps provider state outside modules and validators. The adapter shares request construction, notifications, observers, and once-only completion between ordinary and coordinated calls. @@ -51,12 +51,11 @@ The bundled prompts separate durable system principles from the initial user assignment so later repair instructions can allow acceptable minor cleanup; see [prompt instruction ownership](prompts.md). -The observation collector tracks logical calls and execution events, and enrolls -selected runs in a native `ExecutionGroup`. Proposal, repair, and nested validator -clients explicitly share the invocation observer; history reuse adds no extra run. -Native summaries deduplicate terminal totals by run ID and retain terminal coverage -separately from usage presence and completeness. Logical calls and run membership -can differ, especially on failures before execution. +The optional debug collector tracks logical calls and native execution events, +and replays selected events into a native `ExecutionGroup`. The invocation +context also carries ckprompt's optional usage observer through proposal, repair, +and nested validation. See the [PromptKit execution guide](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/consumers/pkg-promptkit.md) +for native observation and aggregation semantics. Processing operations retain the failure class, reason, and underlying error. When a client omits the reason, the operation uses `internal_failure` and keeps diff --git a/docs/internal/modules.md b/docs/internal/modules.md index b591f96..b84b27a 100644 --- a/docs/internal/modules.md +++ b/docs/internal/modules.md @@ -45,8 +45,8 @@ Module packages own: Each stage prepares the encoded glossary context and protected spellings once. Proposal generation adds the selected transcript section and trimmed description -for each request. PromptKit renders the selected definition and validates the -correction-set schema before Audita maps proposals. Domain validators still +for each request. PromptKit renders the selected definition and applies its +output contract before Audita decodes and maps proposals. Domain validators still check applicability, protected glossary terms, and replacement policy. Model-facing segment IDs are one-based positions within the proposal request. Generation and repair map those references back to the current chunk's actual diff --git a/docs/internal/overview.md b/docs/internal/overview.md index c22fa6e..890c1a7 100644 --- a/docs/internal/overview.md +++ b/docs/internal/overview.md @@ -11,6 +11,7 @@ baseline commands, see the [contributor guide](../development.md). Executable and command orchestration: - `cmd/audita`: executable entry point. - `internal/cli`: argument parsing, config commands, streams, filesystem wiring, and process orchestration. +- `internal/appconfig`: shared application and PromptKit source composition and secrets bootstrap. Core deterministic components: - `internal/core/config` @@ -67,7 +68,7 @@ artifact lifecycle. ## Component Responsibilities -Core components implement configuration defaults, loading, and validation, +Core components implement reusable configuration defaults and validation, transcript schemas and derived glossary views, normalization and chunking, output encoding, diagnostics artifact helpers, and public report structures. diff --git a/docs/internal/prompts.md b/docs/internal/prompts.md index f61cad9..d6aeac6 100644 --- a/docs/internal/prompts.md +++ b/docs/internal/prompts.md @@ -13,8 +13,8 @@ PromptKit composes embedded defaults with operator prompt sources. Shared instructions come from the embedded fragments in `assets/shared`; the request shared-variable helper fills absent `HardeningPolicy`, `ProposalContract`, `RepairContract`, and `ValidationContract` variables. The processing adapter -supplies the embedded instruction fragments for those names. Processing supplies -Audita's response-schema contract separately. +supplies the embedded instruction fragments for those names. Each prompt owns +its output contract and references the shared embedded schema assets. The operator's prompt definition controls which variables its template uses. Proposal focus and validator acceptance intentionally differ: minor editorial @@ -46,7 +46,7 @@ includes `original_segment_text`; when the correction is applicable, it includes not an applied change. An inapplicable correction omits the resulting text and retains its findings and available source text. An operator replacement may use different variables. -See the [upstream CLI reference](https://forge.maximumdirect.net/base-layer/commandkit/src/commit/f369d6a78253b6e6fcb1e023fb2e9c3af1d20ff0/docs/cli.md) +See the [upstream CLI reference](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/v0.8.0/docs/cli.md) for the standard preview, validation, and smoke commands. The correction-set schema requires a string replacement and accepts an empty diff --git a/docs/internal/validators.md b/docs/internal/validators.md index 4dc18d4..efae3d1 100644 --- a/docs/internal/validators.md +++ b/docs/internal/validators.md @@ -71,14 +71,14 @@ LLM validators: - build canonical validation request payloads; - batch using `validation.max_prompt_tokens` and the existing domain token estimator; - select an embedded prompt ID and pass payload/description variables to the - role-bound structured client with the validator-decision schema. + role-bound structured client; the selected prompt supplies its output contract. Oversized single inputs are rejected with a consolidated `validation_input_too_large` operation, without a provider call. Recoverable model failures make only their batch candidates unavailable while other -batches continue. PromptKit validates each complete response against the -validator-decision JSON Schema and performs configured structural repair before -Audita receives decoded decisions. Each actual batch presents candidates +batches continue. PromptKit applies the selected prompt's output contract before +Audita decodes decisions. Shipped validator prompts select the validator-decision +JSON Schema. Each actual batch presents candidates numbered from 1, independent of their internal proposal indices. Audita then reconciles those local references: one usable entry keeps its approval or editorial rejection; a missing or duplicate requested entry makes diff --git a/docs/migrations/v4.1.md b/docs/migrations/v4.1.md new file mode 100644 index 0000000..fa13aeb --- /dev/null +++ b/docs/migrations/v4.1.md @@ -0,0 +1,64 @@ +# Migrating to Audita v4.1 + +Audita v4.1 keeps application configuration version `3` and accepts existing +wrapperless `prompts.yml` and `prompts/` companions. It changes how structural +output contracts, configuration loading, inspection, and debug evidence work. +Review the following changes before upgrading scripts or operator prompts. + +## Move structural-repair budgets to prompts + +Remove `llm.repair_attempts` from the root and every pipeline entry. Audita no +longer accepts that setting or supplies an output contract at each call. The +selected PromptKit prompt now owns its `output` format, validation mode, schema, +and structural-repair budget. Shipped definitions omit `output.repair_attempts`; +the PromptKit v0.25.0 default for enabled validation is one additional generation, +where Audita previously defaulted to two. Set an explicit budget in a complete +replacement prompt when needed; zero disables structural repair for that prompt. +This is separate from Audita's `llm.correction_repair_attempts`, which controls +semantic correction repair, and from transient retries. + +For a working replacement with `output.repair_attempts: 2`, see +[`examples/prompt-edit/prompts.yml`](../../examples/prompt-edit/prompts.yml). +The example retains the complete grammar proposal definition, including its +messages, format, validation mode, and schema path. A same-ID replacement is a +whole record, not a field patch. Former per-entry budgets have no automatic +one-to-one conversion: select or define prompts with budgets appropriate to each +use. See the [PromptKit format reference](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md) +for prompt contracts and the [Audita prompt guide](../internal/prompts.md) for +required request variables and response shapes. + +Audita no longer replaces an operator prompt's output contract with its own +schema. Make operator proposal, validator, and repair prompts produce the +appropriate Audita response shapes. Responses that pass a weaker contract but +cannot be decoded into the expected JSON types become recoverable invalid-output +failures for that operation; domain validation still applies. + +## Update inspection and diagnostics consumers + +The shared application configuration includes native settings under `/promptkit`. +Use these paths when inspecting the application scope; the separate PromptKit +scope remains available. Existing wrapperless companions are mounted at that +path, while main files and overlays can use a `promptkit` section. Configuration +inspection now validates the shared result and may run configured secrets +bootstrap. See [configuration](../config.md#loading-and-composition). + +Debug `llm-execution.json` retains `summary`, `calls`, and `events`, with native +PromptKit evidence nested under `promptkit`. Prepared interaction request payloads +also include native contract, schema, and message-hash evidence under that key. +Update scripts that read the former projected metric fields; native field names +and duration representations differ. Ordinary reports retain their schemas. +Native smoke reports now default to text; scripts consuming structured output +should request `--format yaml` or `--format json`. See the +[CLI reference](../cli.md#inspection-and-outcomes) and +[debug output contract](../integrations/output-files.md#debug-only-files). + +## Review startup failures + +Application and PromptKit resources now share configuration loading and +validation. Invalid native configuration can be reported during application +inspection as well as processing; native configuration usage errors are +classified as status `2`, while bootstrap failures are status `1`. A failed +bootstrap occurs before transcript and output preparation. Help, version, and +other help-only paths do not perform the load. See [subprocess integration](../integrations/subprocess.md) +for handling results and [ConfigKit bootstrap documentation](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md) +for the native controls. diff --git a/docs/operations.md b/docs/operations.md index 3a908ce..a6315d4 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -27,6 +27,11 @@ these sources before running with sensitive transcript data. Native inspection describes the loaded configuration and resources. Processing readiness also depends on the profiles and glossaries selected by the pipeline. See [configuration loading](config.md#loading-and-composition) for discovery rules. +Configured secrets bootstrap runs before the shared load for processing and +native inspection. If it fails, processing stops before transcript and output +preparation; its safe diagnostic details are reported on stderr. Follow the +[ConfigKit documentation](https://forge.maximumdirect.net/base-layer/configkit/src/tag/v1.4.0/docs/config.md) +for bootstrap configuration and environment effects. ## Outputs and lifecycle @@ -68,6 +73,8 @@ Use `--progress` to follow stage, chunk, proposal, validation, and repair activity on stderr. Report and transcript files provide the retained outcome. Debug mode enables live progress by default. Use `--progress=false` to keep debug evidence with progress disabled. +The optional native `--show-tokens` report is independent of debug and ordinary +reports; see the [CLI reference](cli.md#processing). ## Debug evidence diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 306196f..1c75111 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -467,6 +467,13 @@ 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 diff --git a/examples/README.md b/examples/README.md index 3fe7413..19ad0bc 100644 --- a/examples/README.md +++ b/examples/README.md @@ -59,7 +59,11 @@ audita promptkit show prompt audita/modules.grammar.proposal --config config.yml Edit its message in `prompts.yml`, repeat the inspection, and run `audita process --config config.yml --output corrected.json transcript.json` against a configured -local service. Each invocation captures the files anew. +local service. Its complete replacement also selects a structural-repair budget; +see the [v4.1 migration guide](../docs/migrations/v4.1.md). Each invocation captures +the files anew. For native resource formats and commands, see the +[PromptKit documentation](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md) +and [ckprompt guide](https://forge.maximumdirect.net/base-layer/commandkit/src/tag/integrations/ckprompt/v0.12.0/docs/consumers/guide.md). ## Shared glossary library diff --git a/examples/prompt-edit/prompts.yml b/examples/prompt-edit/prompts.yml index 986f753..b3a500d 100644 --- a/examples/prompt-edit/prompts.yml +++ b/examples/prompt-edit/prompts.yml @@ -21,3 +21,4 @@ collections: format: json validation_mode: json_schema schema_path: correction_set.v1.json + repair_attempts: 2 diff --git a/internal/cli/examples_integration_test.go b/internal/cli/examples_integration_test.go index a504fde..25737da 100644 --- a/internal/cli/examples_integration_test.go +++ b/internal/cli/examples_integration_test.go @@ -17,7 +17,9 @@ import ( "gitea.maximumdirect.net/eric/audita/v4/internal/appconfig" "gitea.maximumdirect.net/eric/audita/v4/internal/core/schema" "gitea.maximumdirect.net/eric/audita/v4/internal/framework/llm" + auditaprompts "gitea.maximumdirect.net/eric/audita/v4/internal/prompts" ck "go.maximumdirect.net/configkit" + pk "go.maximumdirect.net/promptkit" ) func TestMaintainedProjectsWithControlledProvider(t *testing.T) { @@ -33,6 +35,32 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) { } { t.Run(tc.dir+"/"+tc.main, func(t *testing.T) { main := filepath.Join(root, tc.dir, tc.main) + if tc.dir == "service" { + dir := t.TempDir() + if err := os.Mkdir(filepath.Join(dir, "overlays"), 0700); err != nil { + t.Fatal(err) + } + if err := os.Mkdir(filepath.Join(dir, "secrets"), 0700); err != nil { + t.Fatal(err) + } + for _, name := range []string{"config.yml", "prompts.yml", "overlays/testing.yml"} { + data, err := os.ReadFile(filepath.Join(root, tc.dir, name)) + if err != nil { + t.Fatal(err) + } + if name == "config.yml" { + data = append(data, []byte("\nconfig:\n secrets_dir: secrets\n secrets_overwrite: true\n")...) + } + if err := os.WriteFile(filepath.Join(dir, name), data, 0600); err != nil { + t.Fatal(err) + } + } + if err := os.WriteFile(filepath.Join(dir, "secrets", "AUDITA_EXAMPLE_KEY"), []byte("synthetic-bootstrap-key"), 0600); err != nil { + t.Fatal(err) + } + t.Setenv("AUDITA_EXAMPLE_KEY", "") + main = filepath.Join(dir, "config.yml") + } loaded, _, err := appconfig.Load(context.Background(), ck.Input{Source: ck.File(main)}, tc.overlay) if err != nil { t.Fatal(err) @@ -42,6 +70,9 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) { var mu sync.Mutex var models, prompts []string transport := controlledTransport(func(r *http.Request) (*http.Response, error) { + if tc.dir == "service" && r.Header.Get("Authorization") != "Bearer synthetic-bootstrap-key" { + t.Errorf("bootstrap credential was not supplied") + } calls.Add(1) var request struct { Model string `json:"model"` @@ -89,6 +120,12 @@ func TestMaintainedProjectsWithControlledProvider(t *testing.T) { if tc.dir == "service" && (len(models) != 1 || models[0] != "example-testing-model") { t.Fatalf("overlay models=%v", models) } + if tc.dir == "prompt-edit" { + prepared, err := engine.Engine.Prepare(context.Background(), pk.RunRequest{PromptID: auditaprompts.PromptIDModuleGrammarProposal, ProfileID: "local", Vars: auditaprompts.WithSharedVariables(map[string]string{"TranscriptDescriptionBlock": "", "GlossaryJSON": "[]", "SectionJSON": "[]"})}) + if err != nil || prepared.OutputContract.RepairAttempts != 2 || prepared.StructuredOutput == nil || len(prepared.Messages) != 2 { + t.Fatalf("replacement contract: %+v, error=%v", prepared, err) + } + } if tc.dir == "campaigns" && tc.main == "first.yml" { if len(prompts) != 3 || !strings.Contains(prompts[0], `"name": "Lyra"`) || strings.Contains(prompts[0], `"name": "Shield"`) || !strings.Contains(prompts[1], `"name": "Shield"`) || strings.Contains(prompts[1], `"name": "Lyra"`) { t.Fatalf("campaign glossary selections: %v", prompts)