Update Audita to its native version 4 configuration

This commit is contained in:
2026-12-03 13:19:02 +00:00
parent c3dd59f5ac
commit b818f60677
7 changed files with 368 additions and 327 deletions

200
README.md
View File

@@ -1,35 +1,41 @@
# Ansible Role: Audita
Installs and configures [Audita](https://gitea.maximumdirect.net/eric/audita)
from source on Ubuntu 26.04 (`x86_64` or `aarch64`). The role requires gathered
facts and uses privilege escalation on tasks that install dependencies or
manage root-owned application state.
Installs [Audita](https://gitea.maximumdirect.net/eric/audita) from source on
Ubuntu 26.04 (`x86_64` or `aarch64`). The role requires gathered facts and
uses privilege escalation for installation and managed application state.
## Variables
Every invocation requires caller-supplied `audita_backends` and
`audita_llm_proposal_profile`. Neither has a role default.
```yaml
audita_version: v2.0.1
audita_version: v4.3.0
audita_repository_url: https://gitea.maximumdirect.net/eric/audita.git
audita_source_dir: /usr/local/src/audita
audita_binary_path: /usr/local/bin/audita
audita_manage_build_dependencies: true
audita_go_snap_channel: 1.26/stable
audita_go_snap_channel: 1.27/stable
audita_go_binary: /snap/bin/go
audita_config_path: /usr/local/etc/audita/config.yml
audita_config_owner: root
audita_config_group: root
audita_config_directory_mode: "0755"
audita_config_file_mode: "0644"
audita_config_version: 2
audita_profiles_dir: null
audita_pipeline_modules: null
audita_config_version: 3
audita_config_imports: null
audita_promptkit_backends: null
audita_promptkit_profiles: null
audita_promptkit_prompts: null
audita_promptkit_collections: null
audita_promptkit_schema_root: null
audita_pipeline_stages: null
audita_glossary_collections: null
audita_glossaries: null
audita_protected_terms: null
audita_llm_proposal_profile: null
audita_llm_correction_repair_profile: null
audita_llm_correction_repair_attempts: null
audita_output_schema: null
audita_llm_validation_profile: null
audita_llm_transient_retries: null
audita_llm_repair_attempts: null
audita_llm_operation_timeout: null
audita_validation_max_prompt_tokens: null
audita_chunking_target_sections: null
@@ -39,99 +45,94 @@ audita_normalization_max_segment_gap: null
audita_normalization_ellipsis_gap: null
audita_normalization_max_segment_duration: null
audita_normalization_max_segment_tokens: null
audita_thresholds_glossary: null
audita_thresholds_homophones: null
audita_thresholds_spoken_word: null
audita_thresholds_grammar: null
audita_context_description: null
audita_reporting_enabled: null
audita_reporting_stdout_dir: null
audita_diagnostics_debug: null
audita_diagnostics_work_dir: null
```
When `audita_manage_build_dependencies` is `false`, Git and the executable
selected by `audita_go_binary` must already be available. Otherwise, the role
installs Git with APT and the classic Go Snap from `audita_go_snap_channel`.
The role builds the selected revision with `audita_go_binary` and rebuilds when
the checkout changes or the binary is missing. When dependency management is
disabled, callers provide Git and a compatible Go executable (Go 1.27 or newer
for v4.3.0). Configuration owner, group, and modes are configurable.
The checkout is authoritative: local source changes are discarded while
selecting `audita_version`. The role builds Audita directly to
`audita_binary_path` using `audita_go_binary`, `CGO_ENABLED=0`, `GOWORK=off`,
`GOTOOLCHAIN=local`, `-trimpath`, and release linker metadata. It rebuilds when
the checkout changes or the binary is absent. The source tree is recursively
owned by `root:root`; the binary is `root:root` mode `0755`.
The schema marker is always rendered. Optional settings are omitted when null;
non-null falsey values and nested nulls are preserved. A minimal document with
only `version: 3` validates offline but processing requires suitable profiles
and, for glossary correction, selected entries. The earlier v2 requirement for
a backend and proposal profile on every invocation no longer applies.
The configuration variables map directly to Audita's version-2 YAML fields.
`audita_backends` and `audita_llm_proposal_profile` are required caller inputs;
the role has no defaults for them. Callers own the selected PromptKit profile
files. Every optional variable defaults to `null`; null values and their empty
parent sections are omitted, allowing Audita to retain ownership of its built-in
defaults. `audita_config_version` always renders as `version` and defaults to
`2`. The role manages `audita_config_path | dirname` and the resulting file
with the `audita_config_owner`, `audita_config_group`,
`audita_config_directory_mode`, and `audita_config_file_mode` inputs. The
standalone defaults are `root:root`, directory mode `0755`, and file mode
`0644`. Composing roles may override these generic configuration inputs for
their own deployment policy.
For example, inventory can supply native resources, ordered stages, and vocabulary:
Backend `credential` values are explicit environment-variable reference names,
not secret values. Every surviving reference must resolve to a nonempty value
when Audita loads configuration, including references on unselected backends.
An omitted or null credential permits unauthenticated local use. The role does
not supply secret values, start a service, or probe profiles during convergence.
```yaml
local_backends:
- id: local
endpoint: http://127.0.0.1:11434/v1
local_profiles:
- id: local-proposal
backend: local
model: example-model
first_stages:
- id: punctuation
module: grammar
llm: {proposal_profile: local-proposal}
extra_stages: []
local_glossaries:
people:
entries:
- {id: mira, name: Mira, category: person}
extra_glossaries: {}
audita_promptkit_backends: "{{ local_backends }}"
audita_promptkit_profiles: "{{ local_profiles }}"
audita_pipeline_stages: "{{ first_stages + extra_stages }}"
audita_glossary_collections: "{{ local_glossaries | combine(extra_glossaries) }}"
audita_glossaries: [people]
```
## Migrating from the version-1 role
Root selections can be overridden per stage; explicit empty stage or vocabulary
lists are retained. An empty stage list selects normalization without model work.
Native collection resource IDs use `namespace/id`. Imports are also supported:
This revision renders version-2 configuration only. Existing version-1 users
can retain the previous role revision while planning a coordinated migration.
The old fields have no compatibility aliases:
```yaml
audita_config_imports:
- path: fragments/audita.yml
required: true
```
| Previous role inputs | Version-2 destination |
| --- | --- |
| `audita_llm_{proposal,validation}_base_url` | `audita_backends.<id>.endpoint`; both selections may share one backend. |
| `audita_llm_{proposal,validation}_api_key_env` | `audita_backends.<id>.credential`, an explicit environment-variable name. |
| `audita_concurrency_{total_llm,proposal_llm,validation_llm}` | `audita_backends.<id>.concurrency` and optional `queue_capacity`; capacity is shared by roles using that backend. |
| `audita_llm_{proposal,validation}_model` | Model in caller-owned PromptKit profile files, selected by `audita_llm_proposal_profile` and optional `audita_llm_validation_profile`. |
| `audita_llm_{proposal,validation}_timeout` | Per-attempt `timeout_seconds` in profile files; `audita_llm_operation_timeout` separately bounds a logical call. |
| `audita_llm_{proposal,validation}_max_retries` | `audita_llm_transient_retries` and `audita_llm_repair_attempts` are separate native budgets; old values do not map directly. |
| Three `audita_normalization_*` gap/duration values | Same role variables, now numeric seconds rather than duration strings. |
| `audita_diagnostics_retention` | Removed; use `audita_diagnostics_debug` and `audita_diagnostics_work_dir` for v2 debug behavior. Reporting uses `audita_reporting_enabled` and `audita_reporting_stdout_dir`. |
Callers deploy referenced fragments and resources, whose paths are relative to
their declaring source. A ConfigKit overlay selected at invocation is distinct
from a PromptKit LLM profile. The role does not manage arbitrary assets, secrets,
services, or runtime invocations. Credentials are environment variable names,
not values; see [configuration and secrets bootstrap](https://gitea.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md).
Omitting `audita_llm_validation_profile` lets Audita inherit the proposal
selection. `audita_llm_operation_timeout` is a Go duration string, while
normalization times are numbers. See the tagged
[v2 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.1/docs/migrations/v2.md)
and [configuration reference](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.1/docs/config.md)
for exact validation and precedence rules.
Inline `glossary_collections` use Audita's application vocabulary, including
optional instructions. Shared runtime glossary files use a different envelope
and must be passed explicitly using `--glossary-file`; they are not discovered
automatically. See the [v4.3 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/migrations/v4.3.md).
## Migrating to v4
Replace `audita_backends` with ID-bearing `audita_promptkit_backends` records,
and `audita_profiles_dir` with native profiles or caller-owned imports. Replace
`audita_pipeline_modules` with ordered `audita_pipeline_stages` records. Remove
`audita_thresholds_glossary`, `audita_thresholds_homophones`,
`audita_thresholds_spoken_word`, and `audita_thresholds_grammar`; confidence
scores and thresholds have no replacement. Replace `audita_diagnostics_debug`
with the runtime `--debug` flag. See the [schema 3 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/migrations/v3.md).
Remove `audita_llm_repair_attempts`: structural output repair budgets now belong
to prompts. Semantic correction repair uses the separate
`audita_llm_correction_repair_profile` and `audita_llm_correction_repair_attempts`
settings; transient retries are a third, distinct budget. Prompt replacements
must retain Audita's complete compatible output contract. See the
[v4.1 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/migrations/v4.1.md).
Use native `audita config validate`, `audita config show`, and
`audita promptkit show` for offline inspection. Provider-contacting preflight and
model processing are caller workflows, not role installation checks.
## Example
Inventory can supply the required choices for a local backend:
```yaml
# host_vars/audita_host.yml (caller-owned)
audita_backends:
local:
endpoint: http://127.0.0.1:11434/v1
credential: null
audita_llm_proposal_profile: local-proposal
```
The caller also supplies `profiles/local-proposal.yaml` beside the managed
configuration, or selects another directory with `audita_profiles_dir`:
```yaml
# profiles/local-proposal.yaml (caller-owned)
id: local-proposal
backend: local
model: replace-with-an-available-local-model
timeout_seconds: 30
```
Choose a model available at the selected endpoint. These profile files must
exist before invoking Audita, but need not exist before applying the role.
The role neither deploys them nor selects a ConfigKit overlay.
```yaml
- hosts: audita_hosts
roles:
@@ -140,18 +141,7 @@ The role neither deploys them nor selects a ConfigKit overlay.
## Validation
The integration driver installs pinned collection dependencies, runs syntax
checking and ansible-lint, and applies the role with local fixture backends and
caller-owned profiles. It checks the temporary configuration with native
`config validate` and the effective settings and profiles views, then requires
clean repeated convergence. It also tests a caller-supplied Go executable with
dependency management disabled after removing the managed binary. The fixture
configuration and sibling `profiles/` directory live under the script's private
temporary root, which cleanup removes. The role still mutates the local managed
source checkout and binary; an existing system configuration is not replaced.
These offline checks do not establish provider connectivity, runtime report
behavior, or compatibility with the unchanged D&D suite:
```sh
tests/integration
```
`tests/integration` installs the pinned collection, runs syntax and production
lint checks, validates and inspects synthetic configuration offline, verifies
version selection and custom-Go recovery, and requires clean repeated convergence.
It does not validate provider access, model output, or suite compatibility.

View File

@@ -1,23 +1,33 @@
---
audita_version: v2.0.1
audita_version: v4.3.0
audita_repository_url: https://gitea.maximumdirect.net/eric/audita.git
audita_source_dir: /usr/local/src/audita
audita_binary_path: /usr/local/bin/audita
audita_manage_build_dependencies: true
audita_go_snap_channel: 1.26/stable
audita_go_snap_channel: 1.27/stable
audita_go_binary: /snap/bin/go
audita_config_path: /usr/local/etc/audita/config.yml
audita_config_owner: root
audita_config_group: root
audita_config_directory_mode: "0755"
audita_config_file_mode: "0644"
audita_config_version: 2
audita_profiles_dir: null
audita_pipeline_modules: null
audita_config_version: 3
audita_config_imports: null
audita_promptkit_backends: null
audita_promptkit_profiles: null
audita_promptkit_prompts: null
audita_promptkit_collections: null
audita_promptkit_schema_root: null
audita_pipeline_stages: null
audita_glossary_collections: null
audita_glossaries: null
audita_protected_terms: null
audita_llm_proposal_profile: null
audita_llm_correction_repair_profile: null
audita_llm_correction_repair_attempts: null
audita_output_schema: null
audita_llm_validation_profile: null
audita_llm_transient_retries: null
audita_llm_repair_attempts: null
audita_llm_operation_timeout: null
audita_validation_max_prompt_tokens: null
audita_chunking_target_sections: null
@@ -27,12 +37,7 @@ audita_normalization_max_segment_gap: null
audita_normalization_ellipsis_gap: null
audita_normalization_max_segment_duration: null
audita_normalization_max_segment_tokens: null
audita_thresholds_glossary: null
audita_thresholds_homophones: null
audita_thresholds_spoken_word: null
audita_thresholds_grammar: null
audita_context_description: null
audita_reporting_enabled: null
audita_reporting_stdout_dir: null
audita_diagnostics_debug: null
audita_diagnostics_work_dir: null

View File

@@ -55,26 +55,68 @@ argument_specs:
type: int
required: true
description: Version of the Audita configuration schema.
audita_profiles_dir:
audita_config_imports:
type: list
elements: dict
required: false
description: Optional native config imports setting.
audita_promptkit_backends:
type: list
elements: dict
required: false
description: Optional native promptkit backends setting.
audita_promptkit_profiles:
type: list
elements: dict
required: false
description: Optional native promptkit profiles setting.
audita_promptkit_prompts:
type: list
elements: dict
required: false
description: Optional native promptkit prompts setting.
audita_promptkit_collections:
type: dict
required: false
description: Optional native promptkit collections setting.
audita_promptkit_schema_root:
type: path
required: false
description: Optional caller-managed PromptKit profile directory.
audita_backends:
description: Optional native promptkit schema root setting.
audita_pipeline_stages:
type: list
elements: dict
required: false
description: Optional native pipeline stages setting.
audita_glossary_collections:
type: dict
required: true
description: Native backend mapping supplied by the caller.
audita_pipeline_modules:
required: false
description: Optional native glossary collections setting.
audita_glossaries:
type: list
elements: str
required: false
description: Optional pipeline module list.
description: Optional native glossaries setting.
audita_protected_terms:
type: list
elements: str
required: false
description: Optional native protected terms setting.
audita_llm_correction_repair_profile:
type: str
required: false
description: Optional native llm correction repair profile setting.
audita_llm_correction_repair_attempts:
type: int
required: false
description: Optional native llm correction repair attempts setting.
audita_output_schema:
type: str
required: false
description: Optional output schema.
audita_llm_proposal_profile:
type: str
required: true
required: false
description: Caller-selected proposal PromptKit profile ID.
audita_llm_validation_profile:
type: str
@@ -84,10 +126,6 @@ argument_specs:
type: int
required: false
description: Optional additional transient attempts per generation.
audita_llm_repair_attempts:
type: int
required: false
description: Optional additional structural repair generations.
audita_llm_operation_timeout:
type: str
required: false
@@ -124,22 +162,6 @@ argument_specs:
type: int
required: false
description: Optional maximum segment token count.
audita_thresholds_glossary:
type: float
required: false
description: Optional glossary confidence threshold.
audita_thresholds_homophones:
type: float
required: false
description: Optional homophones confidence threshold.
audita_thresholds_spoken_word:
type: float
required: false
description: Optional spoken-word confidence threshold.
audita_thresholds_grammar:
type: float
required: false
description: Optional grammar confidence threshold.
audita_context_description:
type: str
required: false
@@ -152,10 +174,6 @@ argument_specs:
type: str
required: false
description: Optional report directory for stdout output.
audita_diagnostics_debug:
type: bool
required: false
description: Optional detailed debug-artifact policy.
audita_diagnostics_work_dir:
type: str
required: false

View File

@@ -68,10 +68,10 @@
- build
- -trimpath
- -ldflags
- "-s -w -X gitea.maximumdirect.net/eric/audita/internal/buildinfo.Version={{ audita_version }}"
- "-s -w -X go.maximumdirect.net/releasekit/internal/runtimeinfo.injectedVersion={{ audita_version }}"
- -o
- "{{ audita_binary_path }}"
- gitea.maximumdirect.net/eric/audita/cmd/audita
- ./cmd/audita
chdir: "{{ audita_source_dir }}"
environment:
CGO_ENABLED: "0"

View File

@@ -1,25 +1,59 @@
version: {{ audita_config_version | to_json }}
{% if audita_profiles_dir is not none %}
profiles_dir: {{ audita_profiles_dir | to_json }}
{% if audita_config_imports is not none %}
config:
imports: {{ audita_config_imports | to_json }}
{% endif %}
backends: {{ audita_backends | to_json }}
{% if audita_promptkit_backends is not none or audita_promptkit_profiles is not none or audita_promptkit_prompts is not none or audita_promptkit_collections is not none or audita_promptkit_schema_root is not none %}
promptkit:
{% if audita_promptkit_backends is not none %}
backends: {{ audita_promptkit_backends | to_json }}
{% endif %}
{% if audita_promptkit_profiles is not none %}
profiles: {{ audita_promptkit_profiles | to_json }}
{% endif %}
{% if audita_promptkit_prompts is not none %}
prompts: {{ audita_promptkit_prompts | to_json }}
{% endif %}
{% if audita_promptkit_collections is not none %}
collections: {{ audita_promptkit_collections | to_json }}
{% endif %}
{% if audita_promptkit_schema_root is not none %}
schema_root: {{ audita_promptkit_schema_root | to_json }}
{% endif %}
{% endif %}
{% if audita_pipeline_stages is not none %}
pipeline:
stages: {{ audita_pipeline_stages | to_json }}
{% endif %}
{% if audita_glossary_collections is not none %}
glossary_collections: {{ audita_glossary_collections | to_json }}
{% endif %}
{% if audita_glossaries is not none %}
glossaries: {{ audita_glossaries | to_json }}
{% endif %}
{% if audita_protected_terms is not none %}
protected_terms: {{ audita_protected_terms | to_json }}
{% endif %}
{% if audita_llm_proposal_profile is not none or audita_llm_validation_profile is not none or audita_llm_correction_repair_profile is not none or audita_llm_correction_repair_attempts is not none or audita_llm_transient_retries is not none or audita_llm_operation_timeout is not none %}
llm:
{% if audita_llm_proposal_profile is not none %}
proposal_profile: {{ audita_llm_proposal_profile | to_json }}
{% endif %}
{% if audita_llm_validation_profile is not none %}
validation_profile: {{ audita_llm_validation_profile | to_json }}
{% endif %}
{% if audita_llm_correction_repair_profile is not none %}
correction_repair_profile: {{ audita_llm_correction_repair_profile | to_json }}
{% endif %}
{% if audita_llm_correction_repair_attempts is not none %}
correction_repair_attempts: {{ audita_llm_correction_repair_attempts | to_json }}
{% endif %}
{% if audita_llm_transient_retries is not none %}
transient_retries: {{ audita_llm_transient_retries | to_json }}
{% endif %}
{% if audita_llm_repair_attempts is not none %}
repair_attempts: {{ audita_llm_repair_attempts | to_json }}
{% endif %}
{% if audita_llm_operation_timeout is not none %}
operation_timeout: {{ audita_llm_operation_timeout | to_json }}
{% endif %}
{% if audita_pipeline_modules is not none %}
pipeline:
modules: {{ audita_pipeline_modules | to_json }}
{% endif %}
{% if audita_output_schema is not none %}
output:
@@ -56,21 +90,6 @@ normalization:
max_segment_tokens: {{ audita_normalization_max_segment_tokens | to_json }}
{% endif %}
{% endif %}
{% if audita_thresholds_glossary is not none or audita_thresholds_homophones is not none or audita_thresholds_spoken_word is not none or audita_thresholds_grammar is not none %}
thresholds:
{% if audita_thresholds_glossary is not none %}
glossary: {{ audita_thresholds_glossary | to_json }}
{% endif %}
{% if audita_thresholds_homophones is not none %}
homophones: {{ audita_thresholds_homophones | to_json }}
{% endif %}
{% if audita_thresholds_spoken_word is not none %}
spoken_word: {{ audita_thresholds_spoken_word | to_json }}
{% endif %}
{% if audita_thresholds_grammar is not none %}
grammar: {{ audita_thresholds_grammar | to_json }}
{% endif %}
{% endif %}
{% if audita_context_description is not none %}
context:
description: {{ audita_context_description | to_json }}
@@ -84,12 +103,7 @@ reporting:
stdout_dir: {{ audita_reporting_stdout_dir | to_json }}
{% endif %}
{% endif %}
{% if audita_diagnostics_debug is not none or audita_diagnostics_work_dir is not none %}
diagnostics:
{% if audita_diagnostics_debug is not none %}
debug: {{ audita_diagnostics_debug | to_json }}
{% endif %}
{% if audita_diagnostics_work_dir is not none %}
diagnostics:
work_dir: {{ audita_diagnostics_work_dir | to_json }}
{% endif %}
{% endif %}

View File

@@ -5,10 +5,8 @@ repository_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
workspace_venv="$repository_root/../.venv"
test_tmp=$(mktemp -d)
chmod 0700 "$test_tmp"
export ANSIBLE_COLLECTIONS_PATH="$test_tmp/collections"
export ANSIBLE_ROLES_PATH="$(dirname "$repository_root")"
inventory="$repository_root/tests/inventory"
converge="$repository_root/tests/converge.yml"
verify_config="$repository_root/tests/verify-config.yml"
@@ -16,8 +14,6 @@ ansible_playbook="$workspace_venv/bin/ansible-playbook"
binary_path=/usr/local/bin/audita
config_root="$test_tmp/config"
config_path="$config_root/config.yml"
profile_dir="$config_root/profiles"
cleanup() {
exit_status=$?
trap - EXIT
@@ -25,140 +21,164 @@ cleanup() {
exit "$exit_status"
}
trap cleanup EXIT
require_clean_recap() {
grep -Eq 'changed=0 .*failed=0' "$1"
}
require_clean_recap() { grep -Eq 'changed=0 .*failed=0' "$1"; }
run_converge() {
output_file=$1
shift
"$ansible_playbook" -i "$inventory" "${baseline_args[@]}" "$@" "$converge" | tee "$output_file"
"$ansible_playbook" -i "$inventory" "${common_args[@]}" "$@" "$converge" | tee "$output_file"
}
validate_config() {
"$binary_path" config validate --config "$config_path"
}
verify_profiles() {
expected_validation_id=$1
expected_validation_model=$2
expected_validation_timeout=$3
"$binary_path" config print-effective --config "$config_path" --view profiles | \
"$workspace_venv/bin/python" -c '
import sys
import yaml
profiles = yaml.safe_load(sys.stdin)
assert profiles["proposal"]["id"] == "fixture-proposal"
assert profiles["proposal"]["backend"] == "fixture"
assert profiles["proposal"]["model"] == "offline-fixture"
assert profiles["proposal"]["timeout_seconds"] == 30
assert profiles["validation"]["id"] == sys.argv[1]
assert profiles["validation"]["backend"] == "fixture"
assert profiles["validation"]["model"] == sys.argv[2]
assert profiles["validation"]["timeout_seconds"] == int(sys.argv[3])
' "$expected_validation_id" "$expected_validation_model" "$expected_validation_timeout"
}
mkdir -p "$profile_dir"
printf '%s\n' \
'id: fixture-proposal' \
'backend: fixture' \
'model: offline-fixture' \
'timeout_seconds: 30' > "$profile_dir/fixture-proposal.yaml"
printf '%s\n' \
'id: fixture-validation' \
'backend: fixture' \
'model: offline-validation' \
'timeout_seconds: 45' > "$profile_dir/fixture-validation.yaml"
baseline_args=(
validate_config() { "$binary_path" config validate --config "$config_path"; }
common_args=(
-e "audita_config_path=$config_path"
-e "audita_config_owner=$(id -un)"
-e "audita_config_group=$(id -gn)"
-e '{"audita_backends": {"fixture": {"endpoint": "http://127.0.0.1:11434/v1", "credential": null}}, "audita_llm_proposal_profile": "fixture-proposal"}'
-e '{"audita_config_version": 3}'
)
mkdir -p "$config_root/schemas" "$config_root/fragments"
cd "$repository_root"
"$workspace_venv/bin/ansible-galaxy" collection install \
-r collections/requirements.yml \
-p "$ANSIBLE_COLLECTIONS_PATH"
"$ansible_playbook" -i "$inventory" "${baseline_args[@]}" --syntax-check "$converge"
"$workspace_venv/bin/ansible-lint" "$converge" "$verify_config"
"$workspace_venv/bin/ansible-galaxy" collection install -r collections/requirements.yml -p "$ANSIBLE_COLLECTIONS_PATH"
"$ansible_playbook" -i "$inventory" "${common_args[@]}" --syntax-check "$converge"
"$workspace_venv/bin/ansible-lint" --offline "$converge" "$verify_config"
baseline_log="$test_tmp/baseline.log"
run_converge "$baseline_log"
cat > "$test_tmp/minimal.yml" <<'EOFVARS'
audita_config_imports: null
audita_promptkit_backends: null
audita_promptkit_profiles: null
audita_promptkit_prompts: null
audita_promptkit_collections: null
audita_promptkit_schema_root: null
audita_pipeline_stages: null
audita_glossary_collections: null
audita_glossaries: null
audita_protected_terms: null
audita_output_schema: null
audita_llm_proposal_profile: null
audita_llm_validation_profile: null
audita_llm_correction_repair_profile: null
audita_llm_correction_repair_attempts: null
audita_llm_transient_retries: null
audita_llm_operation_timeout: null
audita_validation_max_prompt_tokens: null
audita_chunking_target_sections: null
audita_chunking_max_section_tokens: null
audita_chunking_min_section_tokens: null
audita_normalization_max_segment_gap: null
audita_normalization_ellipsis_gap: null
audita_normalization_max_segment_duration: null
audita_normalization_max_segment_tokens: null
audita_context_description: null
audita_reporting_enabled: null
audita_reporting_stdout_dir: null
audita_diagnostics_work_dir: null
EOFVARS
minimal_args=(-e "@$test_tmp/minimal.yml")
run_converge "$test_tmp/minimal.log" "${minimal_args[@]}"
validate_config
verify_profiles fixture-proposal offline-fixture 30
"$ansible_playbook" -i "$inventory" \
-e "audita_test_config_path=$config_path" \
-e 'audita_test_case=baseline' "$verify_config"
baseline_repeat_log="$test_tmp/baseline-repeat.log"
run_converge "$baseline_repeat_log"
require_clean_recap "$baseline_repeat_log"
"$workspace_venv/bin/python" -c 'import sys, yaml; assert yaml.safe_load(open(sys.argv[1], encoding="utf-8")) == {"version": 3}' "$config_path"
run_converge "$test_tmp/minimal-repeat.log" "${minimal_args[@]}"
require_clean_recap "$test_tmp/minimal-repeat.log"
representative_config='{
"audita_backend_base": {"fixture": {"endpoint": "http://127.0.0.1:11434/v1", "credential": null}},
"audita_backend_capacity": {"fixture": {"concurrency": 2, "queue_capacity": 0}},
"audita_backends": "{{ audita_backend_base | combine(audita_backend_capacity, recursive=true) }}",
"audita_profiles_dir": "profiles",
"audita_llm_validation_profile": "fixture-validation",
"audita_llm_transient_retries": 0,
"audita_llm_repair_attempts": 0,
"audita_llm_operation_timeout": "45s",
"audita_validation_max_prompt_tokens": 128,
"audita_pipeline_modules": [],
"audita_normalization_max_segment_gap": 1.25,
"audita_normalization_ellipsis_gap": 2.5,
"audita_normalization_max_segment_duration": 30.75,
"audita_context_description": "",
"audita_reporting_enabled": false,
"audita_reporting_stdout_dir": "",
"audita_diagnostics_debug": false
}'
representative_log="$test_tmp/representative-config.log"
run_converge "$representative_log" -e "$representative_config"
cat > "$test_tmp/representative.yml" <<'EOFVARS'
fixture_backends:
- id: fixture-backend
endpoint: http://127.0.0.1:11434/v1
concurrency_limit: 1
queue_capacity: 0
extra_params: {stream: false}
fixture_profiles:
- {id: fixture-proposal, backend: fixture-backend, model: offline-proposal}
- {id: fixture-validation, backend: fixture-backend, model: offline-validation}
- {id: fixture-repair, backend: fixture-backend, model: offline-repair}
fixture_first:
- module: grammar
id: first
glossaries: []
llm: {proposal_profile: fixture-proposal, validation_profile: null}
fixture_second:
- module: grammar
id: second
llm: {proposal_profile: fixture-validation}
context: {description: 'Second pass'}
fixture_glossaries:
people:
instruction: 'Names'
entries:
- {id: mira, name: Mira, category: person}
fixture_extra_glossaries:
places:
entries:
- {id: town, name: Haven, category: place}
audita_promptkit_backends: "{{ fixture_backends }}"
audita_promptkit_profiles: "{{ fixture_profiles }}"
audita_promptkit_prompts:
- id: fixture-note
messages: [{role: user, content: 'Fixture note'}]
output: {format: text, validation_mode: none}
audita_promptkit_collections:
fixture:
profiles:
- {id: offline, endpoint: 'http://127.0.0.1:11434/v1', model: offline}
audita_promptkit_schema_root: schemas
audita_pipeline_stages: "{{ fixture_first + fixture_second }}"
audita_glossary_collections: "{{ fixture_glossaries | combine(fixture_extra_glossaries) }}"
audita_glossaries: [people]
audita_protected_terms: [places]
audita_llm_proposal_profile: fixture-proposal
audita_llm_validation_profile: fixture-validation
audita_llm_correction_repair_profile: fixture-repair
audita_llm_correction_repair_attempts: 0
audita_llm_transient_retries: 0
audita_llm_operation_timeout: 45s
audita_validation_max_prompt_tokens: 128
audita_normalization_max_segment_gap: 1.25
audita_normalization_ellipsis_gap: 2.5
audita_normalization_max_segment_duration: 30.75
audita_context_description: ''
audita_reporting_enabled: false
audita_output_schema: null
audita_diagnostics_work_dir: null
EOFVARS
representative_args=(-e "@$test_tmp/representative.yml")
run_converge "$test_tmp/representative.log" "${representative_args[@]}"
validate_config
verify_profiles fixture-validation offline-validation 45
"$binary_path" config print-effective --config "$config_path" --view settings | \
"$workspace_venv/bin/python" -c '
import sys
import yaml
settings = yaml.safe_load(sys.stdin)
assert settings["backends"]["fixture"]["concurrency"] == 2
assert settings["backends"]["fixture"]["queue_capacity"] == 0
assert settings["llm"]["validation_profile"] == "fixture-validation"
assert settings["llm"]["transient_retries"] == 0
assert settings["llm"]["repair_attempts"] == 0
assert settings["llm"]["operation_timeout"] == "45s"
assert settings["normalization"]["max_segment_gap"] == 1.25
assert settings["reporting"]["enabled"] is False
assert settings["diagnostics"]["debug"] is False
'
"$ansible_playbook" -i "$inventory" \
-e "audita_test_config_path=$config_path" \
-e 'audita_test_case=representative' "$verify_config"
representative_repeat_log="$test_tmp/representative-config-repeat.log"
run_converge "$representative_repeat_log" -e "$representative_config"
require_clean_recap "$representative_repeat_log"
"$binary_path" promptkit show profile fixture-proposal --config "$config_path" --format json
"$binary_path" promptkit show profile fixture/offline --config "$config_path" --format json
"$binary_path" promptkit show prompt fixture-note --config "$config_path" --format json
"$binary_path" config show --config "$config_path" --path /llm/correction_repair_attempts --format json | "$workspace_venv/bin/python" -c 'import json, sys; assert json.load(sys.stdin) == 0'
"$binary_path" config show --config "$config_path" --path /pipeline/stages --format json | "$workspace_venv/bin/python" -c 'import json, sys; stages = json.load(sys.stdin); assert [s["id"] for s in stages] == ["first", "second"]; assert stages[0]["glossaries"] == []'
"$binary_path" config show --config "$config_path" --path /glossary_collections/people/entries --format json | "$workspace_venv/bin/python" -c 'import json, sys; assert json.load(sys.stdin)[0]["name"] == "Mira"'
"$binary_path" config show --config "$config_path" --path /glossaries --format json | "$workspace_venv/bin/python" -c 'import json, sys; assert json.load(sys.stdin) == ["people"]'
"$ansible_playbook" -i "$inventory" -e "audita_test_config_path=$config_path" "$verify_config"
run_converge "$test_tmp/representative-repeat.log" "${representative_args[@]}"
require_clean_recap "$test_tmp/representative-repeat.log"
printf '%s\n' 'context:' ' description: Imported fixture' > "$config_root/fragments/context.yml"
import_args=(-e '{"audita_config_imports": [{"path": "fragments/context.yml", "required": true}], "audita_pipeline_stages": [], "audita_glossaries": [], "audita_protected_terms": [], "audita_glossary_collections": {}}')
run_converge "$test_tmp/import.log" "${import_args[@]}"
validate_config
"$workspace_venv/bin/python" -c '
import sys, yaml
with open(sys.argv[1], encoding="utf-8") as f: config = yaml.safe_load(f)
assert config["config"]["imports"] == [{"path": "fragments/context.yml", "required": True}]
assert config["pipeline"]["stages"] == []
assert config["glossaries"] == [] and config["protected_terms"] == []
assert config["glossary_collections"] == {} and "llm" not in config
' "$config_path"
"$binary_path" config show --config "$config_path" --path /context/description --format json | "$workspace_venv/bin/python" -c 'import json, sys; assert json.load(sys.stdin) == "Imported fixture"'
"$binary_path" config show --config "$config_path" --path /pipeline/stages --format json | "$workspace_venv/bin/python" -c 'import json, sys; assert json.load(sys.stdin) == []'
run_converge "$test_tmp/import-repeat.log" "${import_args[@]}"
require_clean_recap "$test_tmp/import-repeat.log"
custom_go_binary="$test_tmp/go"
custom_go_invocations="$test_tmp/go-invocations.log"
printf '%s\n' \
'#!/usr/bin/env bash' \
'set -euo pipefail' \
printf '%s\n' '#!/usr/bin/env bash' 'set -euo pipefail' \
"printf '%s\\n' \"\$*\" >> '$custom_go_invocations'" \
'exec /snap/bin/go "$@"' > "$custom_go_binary"
chmod 0755 "$custom_go_binary"
sudo rm -f -- "$binary_path"
recovery_log="$test_tmp/recovery.log"
run_converge "$recovery_log" \
-e '{"audita_manage_build_dependencies": false}' \
-e "audita_go_binary=$custom_go_binary"
recovery_args=(-e '{"audita_manage_build_dependencies": false, "audita_version": "v4.3.0"}' -e "audita_go_binary=$custom_go_binary")
run_converge "$test_tmp/recovery.log" "${recovery_args[@]}"
grep -q . "$custom_go_invocations"
validate_config
recovery_repeat_log="$test_tmp/recovery-repeat.log"
run_converge "$recovery_repeat_log" \
-e '{"audita_manage_build_dependencies": false}' \
-e "audita_go_binary=$custom_go_binary"
require_clean_recap "$recovery_repeat_log"
test "$("$binary_path" version)" = 'audita v4.3.0'
run_converge "$test_tmp/recovery-repeat.log" "${recovery_args[@]}"
require_clean_recap "$test_tmp/recovery-repeat.log"

View File

@@ -10,44 +10,38 @@
src: "{{ audita_test_config_path }}"
register: audita_rendered_config_file
- name: Check omitted baseline settings
ansible.builtin.assert:
that:
- audita_rendered_config.profiles_dir is not defined
- audita_rendered_config.llm.validation_profile is not defined
- audita_rendered_config.llm.transient_retries is not defined
- audita_rendered_config.llm.repair_attempts is not defined
- audita_rendered_config.llm.operation_timeout is not defined
- audita_rendered_config.reporting is not defined
- audita_rendered_config.diagnostics is not defined
when: audita_test_case == "baseline"
- name: Check representative rendered configuration
ansible.builtin.assert:
that:
- audita_rendered_config.version == 2
- audita_rendered_config.profiles_dir == "profiles"
- audita_rendered_config.backends.fixture.endpoint == "http://127.0.0.1:11434/v1"
- audita_rendered_config.backends.fixture.credential is none
- audita_rendered_config.backends.fixture.concurrency == 2
- audita_rendered_config.backends.fixture.queue_capacity == 0
- audita_rendered_config.version == 3
- audita_rendered_config.promptkit.backends[0].id == "fixture-backend"
- audita_rendered_config.promptkit.backends[0].endpoint == "http://127.0.0.1:11434/v1"
- audita_rendered_config.promptkit.backends[0].concurrency_limit == 1
- audita_rendered_config.promptkit.backends[0].queue_capacity == 0
- audita_rendered_config.promptkit.backends[0].extra_params.stream == false
- audita_rendered_config.promptkit.profiles[0].model == "offline-proposal"
- audita_rendered_config.promptkit.prompts[0].id == "fixture-note"
- audita_rendered_config.promptkit.collections.fixture.profiles[0].id == "offline"
- audita_rendered_config.promptkit.schema_root == "schemas"
- audita_rendered_config.pipeline.stages | map(attribute='id') | list == ['first', 'second']
- audita_rendered_config.pipeline.stages[0].glossaries == []
- audita_rendered_config.pipeline.stages[0].llm.validation_profile is none
- audita_rendered_config.pipeline.stages[1].context.description == "Second pass"
- audita_rendered_config.glossary_collections.people.entries[0].name == "Mira"
- audita_rendered_config.glossary_collections.places.entries[0].name == "Haven"
- audita_rendered_config.glossaries == ['people']
- audita_rendered_config.protected_terms == ['places']
- audita_rendered_config.llm.proposal_profile == "fixture-proposal"
- audita_rendered_config.llm.validation_profile == "fixture-validation"
- audita_rendered_config.llm.correction_repair_profile == "fixture-repair"
- audita_rendered_config.llm.correction_repair_attempts == 0
- audita_rendered_config.llm.transient_retries == 0
- audita_rendered_config.llm.repair_attempts == 0
- audita_rendered_config.llm.operation_timeout == "45s"
- audita_rendered_config.validation.max_prompt_tokens == 128
- audita_rendered_config.pipeline.modules == []
- audita_rendered_config.normalization.max_segment_gap == 1.25
- audita_rendered_config.normalization.max_segment_gap is number
- audita_rendered_config.normalization.ellipsis_gap == 2.5
- audita_rendered_config.normalization.ellipsis_gap is number
- audita_rendered_config.normalization.max_segment_duration == 30.75
- audita_rendered_config.normalization.max_segment_duration is number
- audita_rendered_config.context.description == ""
- audita_rendered_config.reporting.enabled == false
- audita_rendered_config.reporting.stdout_dir == ""
- audita_rendered_config.diagnostics.debug == false
- audita_rendered_config.output is not defined
- audita_rendered_config.diagnostics.work_dir is not defined
when: audita_test_case == "representative"
- audita_rendered_config.diagnostics is not defined