Support optional Narratio reference catalogs

This commit is contained in:
2026-12-03 19:24:58 +00:00
parent 76aec69434
commit 12cdc04b73
7 changed files with 124 additions and 17 deletions

View File

@@ -48,8 +48,19 @@ The runtime account owns managed configuration and the shared workspace;
workspace and Notarius cache access use group permissions and default ACLs.
Campaign, party and glossary documents use the shared v4 formats. Source paths
resolve relative to the file that declares them; the optional character family
uses flat artifact paths. No sample reference catalog is installed by this core
role; optional catalog deployment is a separate planned addition.
uses flat artifact paths. No sample reference catalog is selected for the default campaigns.
A caller can opt in to a managed catalog by setting
`dnd_pipeline_reference_catalog_repository_url` and a nonempty
`dnd_pipeline_reference_catalog_revision`. The default checkout is
`/usr/local/etc/narratio/reference-catalog`; a custom root must remain inside
`/usr/local/etc/narratio` for the required source-relative `catalog.yml` import.
Alternatively or additionally, supply disjoint caller-owned vocabulary paths
through `dnd_pipeline_narratio_reference_catalog_settings` and
`dnd_pipeline_narratio_reference_catalog_systems`. Native composition resolves
these maps and reports conflicts. Campaigns select a setting or system by ID;
the supplied campaigns select neither. Catalog content is authored and updated
independently, with no runtime fetch service.
## Migration and operation

View File

@@ -354,3 +354,8 @@ dnd_pipeline_scriptorium_promptkit_backends: null
dnd_pipeline_scriptorium_promptkit_profiles: null
dnd_pipeline_scriptorium_promptkit_collections: null
dnd_pipeline_narratio_notarius_cache: null
dnd_pipeline_reference_catalog_repository_url: null
dnd_pipeline_reference_catalog_revision: null
dnd_pipeline_reference_catalog_root: /usr/local/etc/narratio/reference-catalog
dnd_pipeline_narratio_reference_catalog_settings: null
dnd_pipeline_narratio_reference_catalog_systems: null

View File

@@ -368,3 +368,23 @@ argument_specs:
type: str
required: false
description: Native suite configuration input.
dnd_pipeline_reference_catalog_repository_url:
type: str
required: false
description: Optional reference catalog Git origin.
dnd_pipeline_reference_catalog_revision:
type: str
required: false
description: Revision selected for a managed reference catalog.
dnd_pipeline_reference_catalog_root:
type: path
required: true
description: Catalog checkout inside the Narratio configuration directory.
dnd_pipeline_narratio_reference_catalog_settings:
type: dict
required: false
description: Optional caller-managed setting vocabulary map.
dnd_pipeline_narratio_reference_catalog_systems:
type: dict
required: false
description: Optional caller-managed system vocabulary map.

View File

@@ -32,19 +32,21 @@ dependencies:
narratio_config_file_mode: "{{ dnd_pipeline_config_file_mode }}"
narratio_whisperx_transcribe_url: "{{ dnd_pipeline_whisperx_transcribe_url }}"
narratio_campaigns_root: "{{ dnd_pipeline_campaigns_root }}"
narratio_config_imports:
- path: conf.d/processing.yml
required: true
- path: artifacts/session-recap.yml
required: true
- path: artifacts/hostile-rumors.yml
required: true
- path: artifacts/deranged-rumors.yml
required: true
- path: artifacts/scene-map.yml
required: true
- path: artifact-families/character-meta-analysis.yml
required: true
narratio_config_imports: >-
{{
[
{'path': 'conf.d/processing.yml', 'required': true},
{'path': 'artifacts/session-recap.yml', 'required': true},
{'path': 'artifacts/hostile-rumors.yml', 'required': true},
{'path': 'artifacts/deranged-rumors.yml', 'required': true},
{'path': 'artifacts/scene-map.yml', 'required': true},
{'path': 'artifact-families/character-meta-analysis.yml', 'required': true}
] +
([{'path': (dnd_pipeline_reference_catalog_root ~ '/catalog.yml') | relpath('/usr/local/etc/narratio'), 'required': true}]
if dnd_pipeline_reference_catalog_repository_url is not none else [])
}}
narratio_reference_catalog_settings: "{{ dnd_pipeline_narratio_reference_catalog_settings }}"
narratio_reference_catalog_systems: "{{ dnd_pipeline_narratio_reference_catalog_systems }}"
narratio_config_secrets_dir: secrets
narratio_workspace_cleanup_after_publish: "{{ dnd_pipeline_narratio_workspace_cleanup_after_publish }}"
narratio_storage_backend: "{{ dnd_pipeline_narratio_storage_backend }}"

View File

@@ -132,6 +132,34 @@
update: true
force: true
- name: Require a revision for a selected reference catalog
ansible.builtin.assert:
that:
- dnd_pipeline_reference_catalog_revision is string
- dnd_pipeline_reference_catalog_revision | length > 0
fail_msg: A reference catalog repository requires a nonempty revision.
when: dnd_pipeline_reference_catalog_repository_url is not none
- name: Create the reference catalog root
become: true
ansible.builtin.file:
path: "{{ dnd_pipeline_reference_catalog_root }}"
state: directory
owner: root
group: "{{ dnd_pipeline_runtime_group }}"
mode: "0755"
when: dnd_pipeline_reference_catalog_repository_url is not none
- name: Deploy the selected reference catalog
become: true
ansible.builtin.git:
repo: "{{ dnd_pipeline_reference_catalog_repository_url }}"
dest: "{{ dnd_pipeline_reference_catalog_root }}"
version: "{{ dnd_pipeline_reference_catalog_revision }}"
update: true
force: true
when: dnd_pipeline_reference_catalog_repository_url is not none
- name: Create Narratio configuration directories
become: true
ansible.builtin.file:

View File

@@ -15,10 +15,19 @@ campaigns_repository=$(cd "$repository_root/../assets/campaigns" && pwd)
prompt_repository=$(cd "$repository_root/../assets/narratio-prompts" && pwd)
operator_user="dnd_test_${$}"
shared_fixture_root="/var/cache/notarius/$operator_user"
catalog_root="/usr/local/etc/narratio/catalog-$operator_user"
catalog_selected=false
cleanup() {
exit_status=$?
trap - EXIT
sudo rm -rf -- "$shared_fixture_root" || true
if "$catalog_selected"; then
if ! "$ansible_playbook" -i "$inventory" -e "@$test_tmp/base.json" "$converge" > /dev/null 2>&1; then
printf '%s\n' "Could not restore the no-catalog configuration; retaining $catalog_root" >&2
exit_status=1
catalog_root="$test_tmp/no-catalog-cleanup"
fi
fi
sudo rm -rf -- "$shared_fixture_root" "$catalog_root" || true
sudo userdel --remove "$operator_user" 2>/dev/null || true
rm -rf -- "$test_tmp"
exit "$exit_status"
@@ -123,3 +132,29 @@ repeat_case overrides -e "@$test_tmp/overrides.json"
sudo -u narratio /usr/local/bin/narratio config validate --config /usr/local/etc/narratio/narratio.yml --scope app
"$workspace_venv/bin/python" tests/verify.py overrides "$test_tmp"
! grep -Eq 'synthetic-fixture-(audita|notarius)' "$test_tmp/overrides.log"
catalog_repository="$test_tmp/catalog-source"
mkdir -p "$catalog_repository"
"$workspace_venv/bin/python" - "$catalog_repository" "$repository_root/../../narratio" <<'PYTHON'
import json, subprocess, sys
from pathlib import Path
import yaml
from jsonschema import Draft202012Validator
root = Path(sys.argv[1])
schema = json.loads(subprocess.check_output(['git', '-C', sys.argv[2], 'show', 'v4.0.0:internal/domaininput/resources/glossary/v0.2.0/schema.json'], text=True))
for collection, filename in [('setting', 'setting.yml'), ('spells', 'spells.yml')]:
document = {'schema_version': 'maximumdirect.glossary.v1', 'collections': {collection: {'entries': [{'id': 'fixture', 'name': 'Fixture', 'category': 'test'}]}}}
Draft202012Validator(schema).validate(document)
(root / filename).write_text(yaml.safe_dump(document, sort_keys=False), encoding='utf-8')
(root / 'catalog.yml').write_text('reference_catalog:\n settings:\n fixture_setting: setting.yml\n systems:\n fixture_system: spells.yml\n', encoding='utf-8')
PYTHON
git -C "$catalog_repository" init -q
git -C "$catalog_repository" add .
git -C "$catalog_repository" -c user.name='Fixture' -c user.email='fixture@example.invalid' commit -qm 'Add synthetic catalog'
catalog_revision=$(git -C "$catalog_repository" rev-parse HEAD)
catalog_args=(-e "dnd_pipeline_reference_catalog_repository_url=file://$catalog_repository" -e "dnd_pipeline_reference_catalog_revision=$catalog_revision" -e "dnd_pipeline_reference_catalog_root=$catalog_root" -e '{"dnd_pipeline_narratio_reference_catalog_settings":{"caller_setting":"/usr/local/etc/narratio/caller-setting.yml"}}')
catalog_selected=true
repeat_case catalog "${catalog_args[@]}"
sudo -u narratio /usr/local/bin/narratio config validate --config /usr/local/etc/narratio/narratio.yml --scope app
sudo -u narratio /usr/local/bin/narratio config show --config /usr/local/etc/narratio/narratio.yml --scope app --format json > "$test_tmp/catalog.json"
"$workspace_venv/bin/python" tests/verify.py catalog "$test_tmp" "$catalog_root"

View File

@@ -6,7 +6,7 @@ from pathlib import Path
import yaml
case, directory = sys.argv[1:]
case, directory = sys.argv[1:3]
tmp = Path(directory)
def read_json(name):
@@ -53,5 +53,11 @@ elif case == "overrides":
assert narratio["audita"]["credentials"] == ["FIXTURE_AUDITA_KEY"]
assert narratio["notarius"]["credentials"] == ["FIXTURE_NOTARIUS_KEY"]
assert narratio["scriptorium"]["credentials"] == ["FIXTURE_AUDITA_KEY", "FIXTURE_NOTARIUS_KEY"]
elif case == "catalog":
catalog = read_json("catalog.json")["reference_catalog"]
root = Path(sys.argv[3])
assert catalog["settings"]["fixture_setting"] == str(root / "setting.yml")
assert catalog["settings"]["caller_setting"] == "/usr/local/etc/narratio/caller-setting.yml"
assert catalog["systems"]["fixture_system"] == str(root / "spells.yml")
else:
raise ValueError(case)