44 Commits

Author SHA1 Message Date
fa9ed78a6d Remove completed ConfigKit planning documents
All checks were successful
ci/woodpecker/push/verify Pipeline was successful
2026-11-18 14:33:12 +00:00
4dae8e0d36 Stream verified prepared inputs into publication archives 2026-11-18 04:17:37 +00:00
35eaefd05d Read selected remote sessions directly without listing run history 2026-11-18 04:12:56 +00:00
f85f93bdfb Reuse party provenance within each inspection 2026-11-18 04:10:29 +00:00
0e34ea1d48 Reuse native source records and catalog source indexes 2026-11-18 04:09:24 +00:00
97a93d3393 Honor remote session authoring updates after publication 2026-11-18 04:08:43 +00:00
435ec79185 Initialize standalone sessions from native local authoring context 2026-11-18 04:06:29 +00:00
33d2ebf44c Pin Go attribution to the released source commit 2026-11-18 04:03:40 +00:00
e93fb8d5ab Record publish defaults and destinations at field level 2026-11-18 04:03:33 +00:00
69dc5cc8ec Make restore lock contention coverage independent of startup timing 2026-11-18 04:02:30 +00:00
5d62f9a88b Report effective resource contributors without superseded definitions 2026-11-18 03:59:09 +00:00
ba9079ee74 Record algorithmic refactoring opportunities 2026-11-18 01:10:44 +00:00
583c5bdf1b Record configuration integration audit findings 2026-11-18 00:30:09 +00:00
bccf03a99f Record ConfigKit migration review findings 2026-11-17 23:57:45 +00:00
39a958675d Verify native configuration workflows end to end 2026-11-17 22:49:22 +00:00
413b0d7134 Align configuration documentation with native loading 2026-11-17 22:42:53 +00:00
ff4bdaa483 Demonstrate native configuration authoring 2026-11-17 22:38:51 +00:00
ebcc5b32a0 Use native configuration diff and source evidence 2026-11-17 22:35:56 +00:00
ce661252d0 Render final configuration through native snapshots 2026-11-17 22:31:03 +00:00
ed7e722077 Publish and restore prepared session documents 2026-11-17 22:27:24 +00:00
bcfca7a044 Materialize effective campaign and session inputs 2026-11-17 22:21:55 +00:00
05f5607968 Render imported party rosters as canonical inputs 2026-11-17 22:18:57 +00:00
1657c9f65d Load campaign and session imports from their sources 2026-11-17 22:15:05 +00:00
c3023cb609 Resolve pipeline resources from their source locations 2026-11-17 22:09:58 +00:00
6593ccbeaf Use native pipeline discovery and independent secrets bootstrap 2026-11-17 22:06:29 +00:00
341fe93e3b Adopt ConfigKit and Go toolchain baseline 2026-11-17 21:59:19 +00:00
65d0e518e5 Plan the native ConfigKit migration 2026-11-17 20:41:34 +00:00
4a0e3c83db Record the agreed ConfigKit adoption decisions 2026-11-17 20:27:47 +00:00
f5451a0cf5 Outline native ConfigKit adoption and configuration ergonomics 2026-11-17 20:23:22 +00:00
381668568f Adopt the updated standard repository policies 2026-11-17 19:56:32 +00:00
8afb49c018 Record the ConfigKit configuration ownership boundary 2026-10-05 14:03:51 +00:00
535f47ef20 Cover inherited Notarius path resolution 2026-10-04 15:35:45 +00:00
dcb9bae215 Verify inherited configuration inspection commands 2026-10-04 15:33:16 +00:00
f1f71d8cdf Document native configuration inheritance 2026-10-04 15:25:48 +00:00
39af6ef941 Verify inherited credential safety 2026-10-04 14:41:34 +00:00
e1c934a492 Assert credential-safe projections survive rotation 2026-10-04 14:02:43 +00:00
dd760d84e0 Compare inherited effective pipeline values 2026-10-04 14:00:55 +00:00
6db49b3949 Verify inherited configuration semantics 2026-10-04 13:49:42 +00:00
f1672f6f95 Preserve composite ConfigKit provenance 2026-10-04 13:34:27 +00:00
428f435734 Accept composed ConfigKit artifact definitions 2026-10-04 13:10:53 +00:00
c4abdc19df Upgrade ConfigKit to v0.5.0 2026-10-04 12:53:29 +00:00
08327c2e63 Add documentation style guidance to the plan 2026-10-04 12:49:08 +00:00
2850498043 Simplify the ConfigKit adoption plan 2026-10-04 12:42:58 +00:00
fe9817f354 Plan the ConfigKit upgrade and workspace development 2026-10-04 12:28:09 +00:00
129 changed files with 4349 additions and 1531 deletions

View File

@@ -3,12 +3,12 @@ when:
steps: steps:
validate-release: validate-release:
image: golang:1.26.7 image: golang:1.27.4
commands: commands:
- ./scripts/check-release-candidate.sh "$CI_COMMIT_TAG" - ./scripts/check-release-candidate.sh "$CI_COMMIT_TAG"
build-release-assets: build-release-assets:
image: golang:1.26.7 image: golang:1.27.4
depends_on: depends_on:
- validate-release - validate-release
commands: commands:

View File

@@ -3,6 +3,6 @@ when:
steps: steps:
shuffled-race-tests: shuffled-race-tests:
image: golang:1.26 image: golang:1.27.4
commands: commands:
- go test -race -shuffle=on -count=3 ./... - go test -race -shuffle=on -count=3 ./...

View File

@@ -3,30 +3,30 @@ when:
steps: steps:
tests: tests:
image: golang:1.26 image: golang:1.27.4
commands: commands:
- go test ./... - go test ./...
race-tests: race-tests:
image: golang:1.26 image: golang:1.27.4
depends_on: tests depends_on: tests
commands: commands:
- go test -race ./... - go test -race ./...
static-analysis: static-analysis:
image: golang:1.26 image: golang:1.27.4
depends_on: tests depends_on: tests
commands: commands:
- go vet ./... - go vet ./...
build: build:
image: golang:1.26 image: golang:1.27.4
depends_on: tests depends_on: tests
commands: commands:
- go build ./... - go build ./...
cross-build: cross-build:
image: golang:1.26 image: golang:1.27.4
depends_on: [race-tests, static-analysis, build] depends_on: [race-tests, static-analysis, build]
commands: commands:
- | - |

View File

@@ -0,0 +1,84 @@
# 0001. Classify session content by purpose and lifecycle
## Status
Proposed
## Date
2026-10-01
## Context
Narratio coordinates applications that produce transcripts, artifacts,
diagnostics, and working files. The current session layout mixes some of these
roles, including complete Notarius bundles under `artifacts/`. Operators use
transcripts and artifacts to evaluate results during development and need
predictable locations for diagnostics.
A shared classification model will guide the workspace design and subsequent
adapter changes. The [operator guide](../operations.md#local-state-layout)
describes the implemented layout.
## Decision
Classify content by its primary purpose and lifecycle:
| Category | Purpose |
| --- | --- |
| Inputs | Material consumed by an application, including audio, configuration, and reference documents. |
| Outputs | Completed substantive products, including intermediate artifacts exposed for further use. |
| Logs | Records of execution, including process logs, execution reports, warnings, and diagnostic summaries. |
| Cache | Reusable information whose absence permits ordinary recomputation or retrieval. |
| State | Application condition, progress, recovery records, and unfinished work. |
Classification is relative to the consuming application. An output of one stage
can serve as an input to another while retaining its output location. Completed
outputs reused to skip work remain Outputs. Narratio's manifest is State and
records whether those outputs are reusable.
Classify checkpoints according to their recovery behavior. A checkpoint needed
to continue a particular interrupted operation is State. A saved work result
that can be reused or recomputed is Cache. Recomputation cost informs retention
policy. File-specific classification remains necessary for stores serving both
purposes.
Treat Debug as a capture and retention mode that can include detailed Logs,
snapshots of State, and other diagnostic evidence. Retained debug snapshots have
a diagnostic role; live recovery records retain their State role.
Apply these directory principles to Narratio:
- Store completed artifacts, including intermediate artifacts like
`session_bounds.json`, directly in a flat `artifacts/` directory.
- Store combined transcripts directly in `transcripts/`, with a subdirectory
for the initial per-speaker transcripts.
- Store prepared external audio in `audio/` and other prepared external inputs
in `inputs/`.
- Organize Logs under `logs/` by stage. Execution reports belong to this category.
- Organize Cache under a cache root by the application that owns its format and
reuse behavior.
- Treat scratch files and unfinished outputs as State until completion permits
promotion to Outputs.
## Alternatives Considered
- Group outputs by producer. This exposes subprocess packaging to operators;
flat artifact and transcript locations better support comparison and review.
- Group Logs by application. Stage names match the operator's workflow and
collect diagnostics from stages that invoke multiple applications.
- Classify all checkpoints as State. Recovery behavior provides a more useful
distinction for eviction and reuse decisions.
- Treat all Debug material as Logs. A separate debug location can accommodate
retained state snapshots and larger diagnostic bundles when needed.
## Consequences
Each managed file family needs an identified role, owner, scope, and retention
rule. Subprocess bundles require classification before their contents are
placed in Narratio's output and diagnostic directories.
Physical roots, retention rules, the mechanism for presenting latest logs,
debug placement, and ambiguous checkpoint classifications remain open. The file
inventory and subsequent roadmap will resolve these choices and define the
migration. Current versus historical views are separate from content categories.

View File

@@ -0,0 +1,76 @@
# 0002. Assign subprocess content ownership
## Status
Proposed
## Date
2026-10-03
## Context
[ADR 0001](0001-classify-session-content.md) defines content categories and
operator-facing directory principles. Narratio also needs an ownership boundary
for the applications it invokes. That boundary determines who selects locations,
manages retained files, and controls cleanup.
The current subprocess workflows can execute with fresh working state. Notarius
can reuse persistent chunk-plan and checkpoint caches. Narratio maintains its own
session progress and recovery records.
## Decision
Assign responsibility by content category:
| Category | Responsibility |
| --- | --- |
| Inputs | Narratio supplies paths to prepared inputs, transcripts, and artifacts. |
| Outputs | Narratio selects destinations and promotes completed products into the output locations defined by ADR 0001. |
| Logs | Narratio selects stage-based destinations and captures subprocess output streams. |
| Debug | Narratio selects the destination when capture is enabled; the subprocess defines the diagnostic contents. |
| Subprocess State | Each application manages its working directory, temporary files, and execution lifecycle through its own configuration and defaults. |
| Subprocess Cache | Each application manages its configured persistent cache, including its format, identity, and reuse behavior. |
Narratio retains ownership of its own State, including the session manifest,
recovery bookkeeping, and staging files it manages.
Recommend a dedicated cache root for each cache-aware application, configurable
through that application's supported controls. For system-wide deployments,
`/var/cache/<application>` is a suggested location; `/var/cache/notarius` is an
example for Notarius. Each application defines its cache configuration, defaults,
and internal layout. Operators select locations and retention settings through
those controls. Narratio's session cleanup leaves subprocess caches under their
separate lifecycle policies.
Subprocesses retain ownership of their file formats and bundle structures.
Narratio can receive a complete result bundle at a selected staging destination
and promote the selected products into its canonical output directories.
Diagnostic snapshots of subprocess State follow the Debug destination selected
by Narratio.
Narratio's `runs/` directory can hold staging outputs and retained execution
evidence. Subprocess working directories follow the application's configuration
and may reside elsewhere. Narratio cleanup manages Narratio-owned material;
subprocess State and Cache follow their separate lifecycle policies.
## Alternatives Considered
- Place all subprocess working files and caches inside each Narratio session.
This makes sessions easier to collect as a unit, but couples application
internals and cache retention to Narratio's session lifecycle.
- Allow subprocesses to choose output, log, and debug destinations independently.
This simplifies invocation but scatters the material operators inspect.
- Give Narratio control of downstream bundle formats. This simplifies some
destination mappings but increases integration coupling. Selecting and
promoting products preserves application ownership of those formats.
## Consequences
Adapters need supported controls for Narratio-selected output, log, and debug
locations. Upstream changes may be needed where those destinations are coupled
to application working directories or to one another.
Workspace layout and file classification can proceed independently of subprocess
working-directory conventions. Exact debug placement, retained diagnostic views,
and migration steps remain for the workspace design and roadmap.

View File

@@ -0,0 +1,66 @@
# 0003. Assign configuration ownership
## Status
Accepted
## Date
2026-10-05
## Context
Narratio uses ConfigKit to assemble typed configuration. Earlier integration
code added source-authoring acceptance checks and cached field ownership.
ConfigKit's native composition, inheritance, presence, and provenance APIs now
provide the information needed for loading and operator inspection.
The ConfigKit adoption establishes a responsibility boundary around the
effective configuration. This record captures the rationale for that boundary.
The [architecture policy](../policy/architecture.md#configuration) owns the
normative requirements, and the [configuration reference](../config.md) owns
the operator-facing contract.
## Decision
Narratio receives a final configuration from ConfigKit. ConfigKit owns the
process of resolving the configuration prior to that handoff. Narratio owns
domain validation and application use of the configuration after that handoff.
ConfigKit owns input loading, source composition, sibling inheritance, presence
tracking, typed secret resolution, and native provenance.
Narratio owns configuration-domain meaning, application-specific defaults and
derivation, path resolution, and fail-fast validation of effective domain values.
Narratio expresses these operations through ConfigKit's supported callbacks and
the application resolution steps appropriate to its schema.
Narratio uses ConfigKit's public presence and metadata APIs as intended.
Operator inspection exposes native sources, effective origins, and historical
definition evidence. Narratio adds the derivation context for generated
artifacts and campaign-owned party data.
Structural acceptance follows ConfigKit's loading rules. Domain acceptance
follows Narratio's validation of the effective configuration. Contributor count
and source history serve operator inspection.
## Alternatives Considered
- Retain Narratio-owned source-authoring checks and cached provenance. This
preserves the earlier implementation but creates overlapping responsibilities
and additional maintenance when ConfigKit's composition features evolve.
- Consume typed configuration alone. This produces a smaller integration but
discards useful presence information and native provenance needed for
defaults and operator inspection.
## Consequences
ConfigKit upgrades carry responsibility for structural configuration semantics.
Narratio integration tests cover effective domain outcomes, presence-sensitive
defaults, safe credential projections, and useful operator inspection.
Composite definitions can have several contributors. Inspection presents that
evidence alongside Narratio's generated-artifact context.
Configuration assembly and provenance have one library owner. Narratio's
integration remains focused on application meaning and runtime preparation.

View File

@@ -59,8 +59,8 @@ Rules:
base configuration, while an unknown named overlay fails. The same selection base configuration, while an unknown named overlay fails. The same selection
applies to all common-flag commands, including `regenerate-artifacts`. applies to all common-flag commands, including `regenerate-artifacts`.
- `--secrets-dir` selects ConfigKit credential-file bootstrap explicitly. A - `--secrets-dir` selects ConfigKit credential-file bootstrap explicitly. A
relative value uses caller CWD. Without the flag, a present `secrets/` relative value uses caller CWD. Without the flag, Narratio uses the optional
directory beside the resolved root pipeline is used; an absent one is skipped. `/usr/local/etc/narratio/secrets` directory.
- `clean --all` cannot be combined with campaign/session selectors. - `clean --all` cannot be combined with campaign/session selectors.
- notification delivery is currently limited to the configured `noop` mode; see - notification delivery is currently limited to the configured `noop` mode; see
the [configuration reference](./config.md#notifications). the [configuration reference](./config.md#notifications).
@@ -117,8 +117,13 @@ family declarations, and runtime provenance.
effective values. Its header identifies the root, ordered imports, selected effective values. Its header identifies the root, ordered imports, selected
overlay and its file, selected campaign, party source, and digest. The overlay and its file, selected campaign, party source, and digest. The
remaining tab-separated records are sorted as `path`, `role`, and `source`. remaining tab-separated records are sorted as `path`, `role`, and `source`.
Roles distinguish root, import, overlay, centralized default, campaign, party, Roles distinguish root, import, overlay, normalization, centralized default,
and generated family ownership. A generated party member has campaign, party, and generated family ownership. Records labeled
`resolution` retain their effective pre-normalization source contributors;
superseded definitions remain historical evidence in the artifact catalog.
Records labeled
`empty_import` identify the source-local declaration path, selector, and
location of an optional import that selected no sources. A generated party member has
one family record and one party record at the same logical path. The output one family record and one party record at the same logical path. The output
never reads or prints secret values. never reads or prints secret values.
@@ -127,9 +132,11 @@ artifact key. Its tab-separated header is `key`, `source`, `definitions`,
`enabled`, `output`, `dependencies`, `family`, `character`, `family_source`, and `enabled`, `output`, `dependencies`, `family`, `character`, `family_source`, and
`party_source`. Definitions and effective dependencies are sorted comma-separated `party_source`. Definitions and effective dependencies are sorted comma-separated
lists, and control characters in fields are escaped. Family-member rows identify lists, and control characters in fields are escaped. Family-member rows identify
their family, character, defining family file, and party file. An empty catalog their family, character, contributing family source files, and party file.
prints only the header. Ordinary artifacts can be inspected without a campaign; Family source paths are comma-separated when ConfigKit reports a composite
party-driven families retain the campaign requirement. See origin. An empty catalog prints only the header. Ordinary artifacts can be
inspected without a campaign; party-driven families retain the campaign
requirement. See
[Scriptorium Artifact Entries](./config.md#scriptorium-artifact-entries) for the [Scriptorium Artifact Entries](./config.md#scriptorium-artifact-entries) for the
configuration layout. configuration layout.
@@ -149,8 +156,10 @@ removed <path> <left-value>
changed <path> <left-value> <right-value> changed <path> <left-value> <right-value>
``` ```
Mappings are flattened to their logical field paths; lists remain one atomic Paths use JSON Pointer notation, with `~0` for `~` and `~1` for `/`. Native
value. The command compares defaulted concrete artifacts and publish rules, not comparison reports a changed mapping region as one value when a whole mapping
is added or removed; lists are compared as whole values. A `hidden_changed=true`
field indicates a change hidden by redaction. The command compares defaulted concrete artifacts and publish rules, not
overlay names, source-file layout, or formatting. It succeeds when differences overlay names, source-file layout, or formatting. It succeeds when differences
are found, making it suitable for review and migration checks. are found, making it suitable for review and migration checks.
@@ -364,6 +373,9 @@ Rules:
- `--audio-dir` and `--audio-s3-prefix` are mutually exclusive. - `--audio-dir` and `--audio-s3-prefix` are mutually exclusive.
- if campaign `session_template_file` is configured, `session init` renders it. - if campaign `session_template_file` is configured, `session init` renders it.
- generated session YAML must be concrete (no unresolved `{{ ... }}` placeholders). - generated session YAML must be concrete (no unresolved `{{ ... }}` placeholders).
- template imports and relative resources resolve in the template's local
authoring context. Generated output contains standalone effective values.
- relative `--audio-dir` paths resolve from the invocation directory.
### `session restore` ### `session restore`

View File

@@ -12,10 +12,20 @@ Narratio resolves three YAML documents:
### `pipeline.yml` ### `pipeline.yml`
When `--config` is omitted, search order is: An explicit `--config` selects exactly that file, including a custom filename.
Otherwise ConfigKit searches these locations in order:
1. `/usr/local/etc/narratio/pipeline.yml` 1. The working directory, for `narratio.yml` then `narratio.yaml`.
2. `/etc/narratio/pipeline.yml` 2. The Go user-config directory's `narratio/` subdirectory, for those named
files followed by `config.yml`, `config.yaml`, `main.yml`, and `main.yaml`.
3. The Go user-config directory itself, for the named files.
4. `/usr/local/etc/narratio/` and then `/etc/narratio/`, each for named files
followed by the generic filenames above.
5. `/etc/`, for the named files.
On Linux, the user-config directory normally follows `XDG_CONFIG_HOME`, or
`~/.config` when it is unset. A selected invalid file fails loading; discovery
does not continue to another candidate.
### `campaign.yml` ### `campaign.yml`
@@ -32,15 +42,15 @@ When `--session` is omitted, local search order is:
1. `/usr/local/etc/narratio/session.yml` 1. `/usr/local/etc/narratio/session.yml`
2. `/etc/narratio/session.yml` 2. `/etc/narratio/session.yml`
If local session discovery fails and a `session_id` is known, Narratio attempts remote session loading from: If no local session exists and a `session_id` is known, Narratio loads the
session from configured object storage. Downloaded session bytes are contextless
snapshots, with remote object
provenance retained independently of locally materialized checksums.
- `{root_prefix}/campaigns/{campaign}/sessions/{session_id}/session.yml` Remote loading prefers an authored session-root `session.yml`, including updates
from `session init --remote --force`. When that object is absent, loading falls
using configured object storage. back to the current commit's standalone prepared session. Published snapshots
remain immutable; restore validates the pointer-selected committed state.
The downloaded remote session file is command-scoped: Narratio removes it after
the command finishes and records only the remote object provenance alongside
the durable copied session input.
### Read-only effective pipeline inspection ### Read-only effective pipeline inspection
@@ -67,13 +77,15 @@ not promised to be a reloadable authoring document. `config sources` prints a st
source projection instead of effective values: root/import/overlay/default source projection instead of effective values: root/import/overlay/default
ownership plus campaign/party and generated-family records. Canonical derived ownership plus campaign/party and generated-family records. Canonical derived
players trace to the party. `config artifacts` lists the concrete artifact map, players trace to the party. `config artifacts` lists the concrete artifact map,
effective dependencies, and defining sources. The [CLI reference](cli.md#config-validate-config-show-config-sources-config-artifacts-and-config-diff) effective dependencies, and definition contributor paths, which may identify
several files for one family member. The [CLI reference](cli.md#config-validate-config-show-config-sources-config-artifacts-and-config-diff)
owns command syntax and output conventions. owns command syntax and output conventions.
`config diff` compares normalized field values rather than YAML text or source `config diff` compares normalized field values rather than YAML text or source
ownership. It emits sorted `added`, `removed`, and `changed` records, uses ownership. It emits native ordered `added`, `removed`, and `changed` records with
compact deterministic JSON values, treats lists atomically, and reports `no JSON Pointer paths and compact JSON values. Lists are compared atomically, and
differences` when the complete effective configurations are equal. Concrete changed regions may contain whole values. It reports `no differences` when the
complete effective configurations are equal. Concrete
family members and generated publish rules participate after expansion; moving family members and generated publish rules participate after expansion; moving
an equal value between eligible root/import sources does not create a an equal value between eligible root/import sources does not create a
difference. difference.
@@ -104,23 +116,14 @@ remote state with an unsafe legacy identity must be migrated before use.
- ConfigKit performs strict typed YAML decoding and accepts exactly one document; - ConfigKit performs strict typed YAML decoding and accepts exactly one document;
unknown fields, duplicate keys, and trailing documents fail load. unknown fields, duplicate keys, and trailing documents fail load.
- A pipeline file may explicitly import additive YAML fragments through the - Local pipeline, campaign, session, and party documents may declare native
root-only `configkit.imports` list. Imported files contribute fields to one imports and sibling inheritance. Only the pipeline selects an overlay.
logical pipeline document; they do not override fields supplied by the root - An omitted overlay, empty overlay option, and exact `default` select the base;
or another import. another name selects `overlays/<name>.yml` relative to the pipeline root.
- An omitted overlay, an empty overlay option, and the exact name `default`
select the base configuration. Any other name selects
`overlays/<name>.yml` relative to the pipeline root. Move previously selected
`profiles/<name>.yml` files there; the old directory is not searched, and
`--profile` is no longer accepted for Narratio pipeline selection. Explicit
imports from a directory named `profiles` remain valid.
- Campaign, session, and canonical-party documents are strict single-source
ConfigKit schemas. They do not enable imports, overlays, or `configkit`
directives.
- Configured timeout and retry-delay durations must be positive. An omitted - Configured timeout and retry-delay durations must be positive. An omitted
artifact timeout continues to inherit its configured Scriptorium timeout. artifact timeout continues to inherit its configured Scriptorium timeout.
- Session files must be concrete; unresolved `{{ ... }}` placeholders fail load. - Session files must be concrete; unresolved `{{ ... }}` placeholders fail load.
- Session and party inputs inspected before typed loading are limited to 8 MiB. - ConfigKit applies its acquisition limits to configuration sources and imports.
- Pipeline defaults are applied before validation. - Pipeline defaults are applied before validation.
- Defaults apply only to absent fields. Explicit empty strings, zero values, - Defaults apply only to absent fields. Explicit empty strings, zero values,
`false`, and `null` retain ConfigKit's typed meaning and are then checked by `false`, and `null` retain ConfigKit's typed meaning and are then checked by
@@ -142,57 +145,74 @@ remote state with an unsafe legacy identity must be migrated before use.
### Pipeline imports and overlays ### Pipeline imports and overlays
Large pipeline configurations may be split into explicitly named fragments and Local pipeline, campaign, session, and party files can use source-root
may use fixed-path selected overlays: `config.imports` and `config.sequences`. Every acquired document has its own
source-root controls, including imported fragments. Nested `config` keys are
ordinary data. `extends` is reserved for native sibling inheritance; parents
remain ordinary entries subject to Narratio's effective-domain validation.
```yaml ```yaml
configkit: config:
imports: imports:
- path: config/storage.yml - path: artifacts/session-recap.yml
- path: config/integrations.yaml destination: [scriptorium, artifacts, session_recap]
required: true
campaigns: - dir: artifacts/families
root: /usr/local/share/narratio/campaigns pattern: "*.yml"
``` ```
The maintained [production/testing bundle](../examples/production-testing/pipeline.yml) Imports support `path`, `dir`, and `glob` selectors, applicable filters and
is a complete copyable example of this structure, including canonical-party relative destinations. Paths are relative to the declaring source. Missing or
artifact families. empty selections are optional by default; use `required: true` when a selection
is essential. Selected invalid input fails. Destinations place content under
literal mapping keys, independent of filenames; nested imports can declare
relative destinations. Strict peer contributions must satisfy ConfigKit's
composition rules, and Narratio validates the resulting effective entries.
Imports are resolved relative to the directory containing the root pipeline A selected pipeline overlay is applied after base composition. It may declare
file and are loaded in declaration order. Narratio does not scan directories or root `config.sequences` but cannot import other files. Ordinary overlay lists
infer fragments. Each import must be a confined regular `.yml` or `.yaml` file: replace the lower list; declared collections can use native `replace`, `append`,
absolute paths, traversal, symlinks, directories, duplicate files, and an or `upsert`. Upsert replaces a whole matching record; an empty append or upsert
import of the root pipeline itself are rejected. Imported files cannot declare does not clear the lower list. Mapping and identified-list inheritance follow
another `configkit` control section. native sibling rules. See the pinned [ConfigKit configuration contract](https://forge.maximumdirect.net/base-layer/configkit/src/commit/51ef3144158db1a09fabdbd1c7ae59908c84923b/docs/config.md)
and [consumer guide](https://forge.maximumdirect.net/base-layer/configkit/src/commit/51ef3144158db1a09fabdbd1c7ae59908c84923b/docs/consumers/README.md)
for full selection, composition, collection, and reserved-key semantics.
The [maintained bundle](../examples/production-testing/pipeline.yml) illustrates
these controls, family expansion, and a split roster.
Base merging is additive. A map may be extended by multiple files when every Relative host-resource paths, including integration configuration files,
leaf is distinct, but a scalar, list, or map/list/scalar kind cannot be claimed workspace/campaign/spool/cache roots, campaign template and stable inputs, and
more than once, even when the repeated values are identical. Conflict errors session stable inputs and local audio references, resolve from the effective
name the full field path and every source that claimed it. Narratio additionally value's defining source. Inherited values follow their origin. When no distinct
rejects an artifact or artifact-family key declared by more than one base file, usable source context exists, the main source is the fallback; if it too is
even when those files contribute disjoint children. contextless, the invocation directory is used. Explicit CLI-relative file paths
use the invocation directory. Artifact outputs, publish destinations, logical
IDs, and binary names retain their domain meanings.
Overlay names are case-sensitive and use ConfigKit's safe fixed-path naming The effective digest excludes source layout, overlay identity, and secret values;
rules. Only the selected overlay is opened; a malformed unselected overlay does credential reference names and resolved resource paths participate. Prepared
not affect a base or different-overlay load. Maps merge recursively, overlay campaign, session, and party documents contain effective standalone values rather
scalars replace base scalars, and overlay lists replace base lists completely. than authored import directives. Session fields omitted by the author remain
Explicit `false`, zero, empty strings, empty containers, and null values remain eligible to inherit the receiving campaign's values.
explicit inputs and are not refilled by defaults. Overlays cannot inherit,
stack, import files, or declare another ConfigKit control section.
During ConfigKit loading, Narratio applies fresh typed defaults, recorded ### Upgrade from earlier configuration
entry-level defaults and normalization, read-only file-local validation, and
ordinary path resolution before computing a deterministic effective
configuration digest. The digest represents the normalized, secret-free
runtime pipeline mapping; it excludes ConfigKit directives, source
provenance, overlay identity, and raw environment secret values. Equivalent
effective mappings therefore have the same digest regardless of how fields are
split among the root and imports.
An imported field has the same meaning it would have in a monolithic root - Rename source-root `configkit:` controls to `config:`. Nested `config` data
pipeline. In particular, ordinary relative pipeline paths continue to resolve and the Go `configkit` package and secret tags have different meanings.
from the root pipeline directory, not from the importing fragment's directory. - Rename or move pipeline files to the discovery names above, or retain a custom
filename such as `pipeline.yml` and pass it with `--config`.
- Move conventional secrets to `/usr/local/etc/narratio/secrets`, supply them
through the environment, or pass the previous directory with `--secrets-dir`.
- Review relative resource references moved into fragments: their defining
source now supplies the base. Mark necessary imports `required: true`.
- Review lists and use `config.sequences` where append or whole-record upsert is
intended. Verify the effective result with the inspection commands.
- Prepared documents contain effective values; retain authored roots and their
companions separately for editing. Separately installed downstream tools own
their own configuration migrations.
These control-key changes require a major version for the eventual Narratio
release. This migration does not itself publish a release.
## Minimal Working Configuration ## Minimal Working Configuration
@@ -237,8 +257,8 @@ inputs:
stage range, or eligible for resume. Omit the field or set it to `null` when stage range, or eligible for resume. Omit the field or set it to `null` when
that deployment should not require the credential. that deployment should not require the credential.
- Every command that loads a pipeline accepts `--secrets-dir <path>`. When the - Every command that loads a pipeline accepts `--secrets-dir <path>`. When the
flag is omitted, Narratio uses a present `secrets/` directory beside the flag is omitted, Narratio uses `/usr/local/etc/narratio/secrets` when present;
resolved root `pipeline.yml`; an absent conventional directory is ignored. an absent conventional directory is ignored.
Explicit relative paths are resolved from the caller's working directory, Explicit relative paths are resolved from the caller's working directory,
and a missing or empty explicit selection is an error. and a missing or empty explicit selection is an error.
- Each immediate regular file whose name is a valid environment-variable name - Each immediate regular file whose name is a valid environment-variable name
@@ -294,7 +314,7 @@ Rules:
| Field | Type | Required | Default / Rule | | Field | Type | Required | Default / Rule |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| `configkit.imports[].path` | string | No | explicit additive pipeline fragment relative to the root pipeline directory; `.yml` or `.yaml` regular files only | | `config.imports` | list | No | native source-root import selections; see [imports and overlays](#pipeline-imports-and-overlays) |
| `pipeline.workspace.root` | string | No | `/var/lib/narratio` | | `pipeline.workspace.root` | string | No | `/var/lib/narratio` |
| `pipeline.workspace.cleanup_after_publish` | bool | No | `false`; selects the published run's workspace target for final cleanup and requires effective `pipeline.publish.enabled=true` and `pipeline.publish.upload_run=true` | | `pipeline.workspace.cleanup_after_publish` | bool | No | `false`; selects the published run's workspace target for final cleanup and requires effective `pipeline.publish.enabled=true` and `pipeline.publish.upload_run=true` |
| `pipeline.campaigns.root` | string | No | `/usr/local/share/narratio/campaigns` | | `pipeline.campaigns.root` | string | No | `/usr/local/share/narratio/campaigns` |
@@ -359,10 +379,10 @@ Rules:
| `pipeline.notarius.binary` | string | No | `notarius` | | `pipeline.notarius.binary` | string | No | `notarius` |
| `pipeline.notarius.credentials[]` | list[secret reference] | No | empty; exact environment-variable names forwarded to Notarius | | `pipeline.notarius.credentials[]` | list[secret reference] | No | empty; exact environment-variable names forwarded to Notarius |
| `pipeline.notarius.config_overlay` | string | No | unset; exact Notarius ConfigKit overlay selector | | `pipeline.notarius.config_overlay` | string | No | unset; exact Notarius ConfigKit overlay selector |
| `pipeline.notarius.config_path` | string | Conditional | required when enabled; relative paths resolve from the pipeline file directory | | `pipeline.notarius.config_path` | string | Conditional | required when enabled; relative paths resolve from their defining source |
| `pipeline.notarius.pipeline_id` | string | Conditional | required when enabled | | `pipeline.notarius.pipeline_id` | string | Conditional | required when enabled |
| `pipeline.notarius.timeout` | duration | No | `3h`; must be positive | | `pipeline.notarius.timeout` | duration | No | `3h`; must be positive |
| `pipeline.notarius.working_directory` | string | No | directory containing resolved `config_path`; relative paths resolve from the pipeline file directory | | `pipeline.notarius.working_directory` | string | No | directory containing resolved `config_path`; relative paths resolve from their defining source |
| `pipeline.notarius.resume` | bool | No | `false`; request compatible Notarius checkpoint reuse during ordinary executed extraction | | `pipeline.notarius.resume` | bool | No | `false`; request compatible Notarius checkpoint reuse during ordinary executed extraction |
| `pipeline.notarius.chunk_cache` | string | No | empty; when set, exactly `auto`, `bypass`, or `refresh` | | `pipeline.notarius.chunk_cache` | string | No | empty; when set, exactly `auto`, `bypass`, or `refresh` |
| `pipeline.notarius.references` | map[string]string | No | empty; maps normalized Notarius selectors to supported prepared Narratio source IDs; maximum 256 entries | | `pipeline.notarius.references` | map[string]string | No | empty; maps normalized Notarius selectors to supported prepared Narratio source IDs; maximum 256 entries |
@@ -629,7 +649,11 @@ For each `pipeline.scriptorium.artifact_families.<name>`:
| `output_path_pattern` | string | Yes | safe path beneath `artifacts/` with exactly one `{character_id}` token and no other brace syntax | | `output_path_pattern` | string | Yes | safe path beneath `artifacts/` with exactly one `{character_id}` token and no other brace syntax |
| `member_vars` | map | No | maps an ordinary Scriptorium variable name to a supported canonical character selector | | `member_vars` | map | No | maps an ordinary Scriptorium variable name to a supported canonical character selector |
| `member_dependencies` | list | No | unique family keys; each generated member depends on the corresponding generated member of each listed family | | `member_dependencies` | list | No | unique family keys; each generated member depends on the corresponding generated member of each listed family |
| `publish` | map | No | typed family publish policy (`enabled`, `required`, `dest_pattern`) expanded into concrete publish outputs when enabled | | `publish` | map | No | typed family publish policy (`enabled`, `required`, `dest_pattern`) validated against effective `pipeline.publish` settings and expanded into concrete publish outputs when enabled |
An enabled family publish declaration is validated against the effective
`pipeline.publish` configuration, including its defaults; it does not require
an explicit `publish.enabled` declaration in the same source file.
Generated keys are `<family>_<character_id>` and generated output paths must Generated keys are `<family>_<character_id>` and generated output paths must
not collide with explicit artifacts or another generated artifact. Families not collide with explicit artifacts or another generated artifact. Families
@@ -667,7 +691,7 @@ integration.
| `inputs.speakers_file` | string | Yes | stable input default | | `inputs.speakers_file` | string | Yes | stable input default |
| `inputs.autocorrect_file` | string | Yes | stable input default | | `inputs.autocorrect_file` | string | Yes | stable input default |
| `inputs.glossary_file` | string | Yes | stable input default | | `inputs.glossary_file` | string | Yes | stable input default |
| `inputs.party_file` | string | Yes | stable campaign party source; relative paths resolve from `campaign.yml` | | `inputs.party_file` | string | Yes | stable campaign party source; relative paths resolve from their defining source |
| `inputs.spell_catalog_file` | string | No | optional spell-catalog overlay default; required when a Notarius reference selects `narratio.input.spell_catalog` | | `inputs.spell_catalog_file` | string | No | optional spell-catalog overlay default; required when a Notarius reference selects `narratio.input.spell_catalog` |
### Session ### Session

View File

@@ -16,8 +16,10 @@ commit-after-completed-work rule; it does not authorize pushing or releasing.
## Go Prerequisite ## Go Prerequisite
Maintained development and verification require Go 1.26. Use the official Go The Go consumer minimum is 1.27.0, declared in `go.mod`. Maintained development
1.26 toolchain before running repository commands. and verification use the official Go 1.27.4 toolchain. Release validation and
builds use the selected patch version and setup instructions in the
[release procedure](release.md#release-toolchain).
## Policy Reading Guide ## Policy Reading Guide

View File

@@ -1,8 +1,8 @@
# Canonical Party Input # Canonical Party Input
`party.yml` is a campaign-owned roster input. It must be a single, versioned `party.yml` is a campaign-owned roster input. Its main document must declare
`narratio.party.v1` document when Narratio resolves a pipeline, campaign, and `narratio.party.v1` when Narratio resolves the roster. Local party files may
session together. import fragments; fragments need no version header.
```yaml ```yaml
schema_version: narratio.party.v1 schema_version: narratio.party.v1
@@ -48,8 +48,8 @@ The configuration rules and source-relative path behavior are defined in the
## Derived players document ## Derived players document
During `prepare`, Narratio copies the canonical party source bytes unchanged During `prepare`, Narratio renders the effective roster as standalone canonical
to `inputs/party.yml` and writes this deterministic players-only projection to `inputs/party.yml` and writes this deterministic players-only projection to
`inputs/players.yml`: `inputs/players.yml`:
```yaml ```yaml

View File

@@ -37,6 +37,8 @@ Restore planner action kinds:
Planner behavior: Planner behavior:
- prepared campaign, session, and party inputs are restored from their declared
immutable run objects to their canonical local input paths;
- a new-protocol restore uses only the selected commit's declared artifact set; - a new-protocol restore uses only the selected commit's declared artifact set;
each action carries that artifact's immutable key, checksum, size, and each action carries that artifact's immutable key, checksum, size, and
generation; generation;

View File

@@ -1,196 +1,81 @@
# Configuration Internals # Configuration Internals
User-visible fields, defaults, and selection behavior belong in the User-visible fields, defaults, discovery, and selection belong in the
[Configuration Reference](../config.md). This document describes the internal [Configuration Reference](../config.md). This document describes the
pipeline-loading boundary implemented by `internal/config`. `internal/config` loading and resolution boundary.
## Pipeline Loading ## Pipeline Loading
`LoadPipeline` assembles and validates a pipeline in this order: Commands bootstrap secrets once before loading, then select an explicit file or
native required discovery. ConfigKit loads typed defaults, source-root imports,
and the selected overlay, resolves inheritance, and strictly decodes the
result. Narratio applies recorded defaults, normalization, resource resolution,
and effective-domain validation. The selected root, source contexts, metadata,
and authoring result are retained for provenance. Family expansion and checks
requiring the campaign occur after campaign and party resolution.
1. Give ConfigKit a fresh typed `PipelineConfig` default value, the root file, Resource resolution consults native entry origins and source contexts before
enabled imports, and the caller's overlay selection. Omitted, empty, and normalization. An effective source supplies the base when usable; otherwise the
exact `default` selections use the base; named overlays use the fixed main source, then the captured invocation directory, is the fallback. Explicit
`overlays/<name>.yml` convention. CLI file references use the invocation directory. Derived values record their
2. ConfigKit parses the root and declared imports, additively merges base dependencies. See the [configuration reference](../config.md#pipeline-imports-and-overlays)
sources, applies only the selected overlay, and strictly decodes the result. for the resource classifications and native authoring contract.
3. The definition resolver applies recorded entry-level and inherited defaults,
runs deterministic domain normalization, records derived publish destinations,
and resolves ordinary paths relative to the root pipeline file.
4. The definition validator performs read-only checks that require only the
pipeline file. Checks requiring canonical-party family expansion remain at
the existing explicit pipeline/campaign resolution boundary.
5. Narratio inspects public ConfigKit metadata to reject artifact and family keys
declared by multiple base files, adapts source ownership records, attaches
runtime-only state, and computes the normalized effective digest.
This ordering preserves monolithic configuration behavior. Moving a field to
an imported fragment changes its source ownership, not its path base, default,
or schema semantics.
## Loaded Context Resolution ## Loaded Context Resolution
`LoadedPipelineCampaign` carries one already composed pipeline and its selected `LoadedPipelineCampaign` carries the selected pipeline and campaign into local
campaign into session resolution. `LoadSessionWithPipelineCampaignOptions` or remote session resolution. Local campaign, session, and party loads enable
loads a local session against that context, while imports through their own ConfigKit definitions; only the pipeline selects an
`ResolveLoadedPipelineCampaign` also accepts an already loaded remote session overlay. Native optional search distinguishes an absent local session from an
or no session while a caller retrieves one. Compatibility loaders route through invalid selected file. Remote session bytes have no incidental download-directory
these functions after their initial pipeline and campaign reads. context, and retain object provenance. Effective session strings are checked for
unresolved template tokens, and campaign/session identity and stable-input rules
remain Narratio-owned.
Application commands own pipeline and campaign discovery, campaign-file versus Campaign and session loaders retain detached document values after their own
registry selection, and the corresponding mutual-exclusion rules. Once they resolution. The session document is captured before campaign defaults are copied
have a `LoadedPipelineCampaign`, local session discovery and remote-session into runtime session state. Configuration-owned renderers produce standalone
download retain that exact pipeline object and its private provenance. Removing campaign and session YAML, preserving omitted session overrides. Prepare uses
a temporary downloaded session file therefore cannot invalidate the resolved those renderers and canonical party rendering for materialization and resume
pipeline or campaign context. comparison.
Campaign and session files use independent ConfigKit definitions with imports ## Inspection And Provenance
and overlays disabled. Campaign files normally load directly from their source;
session files are first read through the 8 MiB bounded-read boundary because the
application must reject unresolved template placeholders before passing an exact
byte snapshot to ConfigKit. Local and remotely downloaded session bytes then use
the same typed loader and retain the existing post-load identity expectations,
stable-input precedence, and source-relative path semantics.
The application also has a separate read-only inspection resolver for `config Read-only inspection shares production pipeline and campaign selection without
validate`, `config show`, `config sources`, and `config artifacts`. It uses the session discovery, workspace initialization, adapters, or manifest access. After
same production root, overlay, and campaign selection functions, but never routes applicable campaign and family resolution, a safe typed final-domain DTO contains
through session discovery, concrete artifacts and generated publish rules. It stores credential reference
remote-session download, adapter composition, workspace names rather than typed secrets. A defaults-backed native result freezes this
initialization, manifest access, or cleanup. A pipeline with retained artifact DTO without resolving credentials again; `WriteEffective` supplies show and
family declarations must resolve its selected campaign before ordinary pipeline prepared pipeline YAML, and deterministic JSON of the same DTO supplies the
validation, which expands its canonical-party members and generated publish versioned semantic digest. Resolved resources participate in that digest, while
rules. A pipeline without those declarations may be validated by itself. source layout and secret values do not.
Secret-directory bootstrap remains invocation-scoped and happens before the
ordinary ConfigKit load because explicit typed references must resolve even for
inspection.
`MarshalEffectivePipeline` is the configuration-owned projection for `config Authoring results separately supply native origins, source histories, and empty
show`. It serializes one explicit typed safe projection with the existing YAML optional-import evidence to source and artifact inspection. Family and party
encoder. The projection has no slots for resolution-only artifact family context identifies generated entries without reparsing sources. Diff fully
declarations or private provenance. The result has one trailing newline; resolves each side against the same selected campaign and party, then uses
commands do not marshal runtime objects directly. ConfigKit `Diff` on the safe snapshots. The command presents native JSON Pointer
paths and safe compact values.
`EffectivePipelineSources` and `EffectiveCampaignSources` provide the separate
safe provenance projection for `config sources`. Pipeline ownership begins with
the complete logical field paths projected from the schema and classifies
each contributor as root, import, overlay, or centralized default. The
projection replaces generated concrete member paths with paired family and
canonical-party records, and does the same for generated publish rules.
Campaign records identify campaign-owned fields and party inputs; canonical
derived players point to the party source. The application command only joins these sorted
records with selection metadata and never reparses configuration files.
`EffectiveArtifactCatalog` projects the same finalized concrete artifact map for
`config artifacts`. It derives source identity from each map key, carries sorted
effective dependencies, aggregates ConfigKit definition contributors, and adds
family/character/party provenance for generated members. It does not inspect
files named after artifacts or infer another runtime graph.
`config diff` uses a thin paired loader that performs two independent ConfigKit
loads. When campaign
resolution is needed, the command loads one selected campaign and party and
expands both effective pipelines from that same party value. The configuration
owner projects each normalized effective mapping directly from that same typed
projection into sorted logical paths using JSON number preservation;
mapping leaves are compared individually while sequence values remain atomic.
Values are compact deterministic JSON representations for command output, not
raw YAML fragments, ownership records, or secret material. A differing digest
with no projected difference is treated as an internal consistency error.
Campaign context construction reads the campaign-owned party source through
`ParseParty`. The required canonical party retains its raw bytes and normalized
roster in runtime-only `ResolvedParty` provenance. Canonical resolution creates
a deterministic `derived_from_party` players projection. The party is the only
configured roster authority; player and session-party fields are unsupported.
## Canonical Party Domain ## Canonical Party Domain
`ParseParty` is the package-owned boundary for parsing a party source. Its File-backed party loading enables imports; `ParseParty` accepts contextless bytes.
single-source ConfigKit definition disables imports and overlays, requires The shared definition checks the main document's version and Narratio validates
`schema_version` through `VersionRule`, and strictly decodes the the effective character roster. Native acquisition order and source coordinates
character-keyed typed schema before applying Narratio's party-domain checks. establish roster order, favoring each child's own declaration. A deterministic
Successful metadata coordinates recover authored character-map order without a renderer writes standalone canonical party YAML from that roster; the players
second YAML parse; class and alias slice order comes directly from typed decode. projection and family expansion use the same resolved roster. The external format
The canonical value retains a separate exact byte copy of its source so is defined in the [party contract](../integrations/party.md).
consumers can materialize the authored party document without reserializing it.
Its `PlayersYAML` method deterministically derives the ID-sorted, versioned
players-only projection.
An unversioned source is rejected before resolution, family expansion, or
prepare-stage materialization.
## Validation Ownership ## Validation Ownership
Configuration validation remains within `internal/config`, with the public ConfigKit owns composition, inheritance, presence, typed-secret resolution, and
entry points and pipeline-domain sequencing separated from the private owners provenance. Narratio owns validation and normalization of effective domain
for core pipeline/session rules, external adapters, publish/storage, Notarius, values. Source histories are inspection evidence, not an additional acceptance
Scriptorium, and shared scalar/path checks. These are package-local ownership gate. Focused configuration and application tests exercise imports, resource
boundaries rather than extension points or a general validation framework. contexts, snapshots, secret-safe inspection, party resolution, and materialized
inputs through the production boundaries.
Validation is read-only, fails fast, and does not define which of several
independent invalid fields is reported first. Map-backed declarations are
nevertheless traversed deterministically. Reusable domain normalization is an
explicit preceding operation for both loaded and programmatically constructed
pipelines. Notarius normalization commits canonical scalar, reference, and output
values only after the complete normalization succeeds; its validator then checks
that candidate without changing it. Scriptorium validates artifact declarations
and outputs, dependencies and inputs, variables, referenced outputs, and the final
dependency graph in deterministic artifact order.
Diagnostics identify the relevant semantic field. Merge conflicts also
retain every claiming source needed to correct an additive ownership conflict.
Complete prose, punctuation, formatting, and private validation choreography are
not compatibility contracts.
## Diagnostics And Runtime Metadata
Syntax, duplicate-key, merge, overlay, and schema failures include the
relevant source name and full field path. Additive conflicts report every
claiming source so operators can repair the split without repeatedly
rediscovering additional conflicts.
The loaded pipeline retains private runtime metadata for the absolute root
path, ordered imports, selected overlay name, source, and path, original
ConfigKit metadata and source snapshots, effective digest,
and leaf ownership. Base
leaves retain their root/import owners, replaced leaves belong to the selected
overlay, and centrally supplied values use the synthetic `default` owner. This
metadata does not participate in YAML decoding or alter the public
configuration model.
The effective digest is SHA-256 over a versioned deterministic JSON encoding of
the same typed safe projection used by show and diff. Runtime Notarius paths remain absolute for
execution, but the digest substitutes their normalized logical values captured
before root-relative resolution, so relocating an equivalent configuration
bundle does not change provenance. Because ConfigKit and resolution metadata
are private, the digest excludes source layout, overlay name, and ownership.
Configuration stores credentials as ConfigKit typed references. A successful
load resolves their values inside the opaque typed boundary, while this safe
projection serializes only `EnvName()` identities. Credential-value changes are
therefore never hashed; reference-name changes remain ordinary provenance.
The optional Notarius credential follows the same path even for disabled or
resumable extraction; normalization copies the opaque reference without reading
or resolving it again. Direct YAML serialization has a configuration-owned safe
projection so only the reference name can leave this boundary.
`recomputePipelineEffectiveDigest` is the single package-owned refresh point
for later runtime expansion.
## Test Surfaces
`pipeline_configkit_test.go` exercises real imports and fixed-path overlays,
base selection, unselected-overlay isolation, source attribution, and Narratio's
unique artifact/family base-declaration rule. Existing focused configuration
tests protect defaults, explicit-value semantics, strict decoding, validation,
metadata, and root-relative path behavior. Application configuration-loader tests protect the
single-read boundary by changing the pipeline file after its initial load and
confirming local session resolution retains the original pipeline. Other
configuration tests continue to protect defaults and validation after assembly.
`party_test.go` protects the versioned typed party schema, domain invariants,
authored character order, retained bytes, and deterministic players projection
without involving campaign or runtime wiring.
`party_resolution_test.go` protects campaign-owned party loading, canonical
input restrictions, source provenance, and virtual players input selection.
## Artifact Family Resolution ## Artifact Family Resolution

View File

@@ -107,7 +107,7 @@ so any earlier replacement can stale a prior cleanup result.
## Focused Documentation ## Focused Documentation
- [Configuration Internals](configuration.md): pipeline imports and overlays, - [Configuration Internals](configuration.md): pipeline imports and overlays,
field ownership, decoding, and root-relative path semantics. field ownership, decoding, and source-relative resource semantics.
- [Adapter Internals](adapters.md): external adapter boundaries, composition, - [Adapter Internals](adapters.md): external adapter boundaries, composition,
failure behavior, and test surfaces. failure behavior, and test surfaces.
- [Artifact Internals](artifacts.md): source identities, runtime catalog, - [Artifact Internals](artifacts.md): source identities, runtime catalog,

View File

@@ -39,8 +39,8 @@ Materialize canonical current-session inputs before processing stages.
- materializes a configured spell catalog with checksum and provenance, or - materializes a configured spell catalog with checksum and provenance, or
safely removes an obsolete canonical spell catalog and its manifest record safely removes an obsolete canonical spell catalog and its manifest record
when the effective input is omitted. when the effective input is omitted.
- copies the validated canonical party bytes unchanged and deterministically - renders standalone effective campaign, session, and canonical party documents,
generates the prepared players projection. and deterministically generates the prepared players projection.
- scans enabled configured artifact inputs for `narratio.previous_session.artifact.*` requirements. - scans enabled configured artifact inputs for `narratio.previous_session.artifact.*` requirements.
- clears managed `previous/` state on every invocation, then, when requirements exist: - clears managed `previous/` state on every invocation, then, when requirements exist:
- resolves the pointer-selected previous source through the shared resolver; - resolves the pointer-selected previous source through the shared resolver;
@@ -71,15 +71,15 @@ previous-artifact requirement set. A change reruns prepare and
stales its fixed descendants. Existing successful records without this stales its fixed descendants. Existing successful records without this
evidence rerun once when selected. evidence rerun once when selected.
Workspace, spool, and cache placement and absolute source relocation are not Workspace, spool, and cache placement are not semantic when logical selection,
semantic when logical selection, canonical names, and bytes are equivalent. canonical names, and effective bytes are equivalent.
The fingerprint deliberately does not read or rehash large audio. Prepared The fingerprint deliberately does not read or rehash large audio. Prepared
input checksums remain the content provenance. Before reusing success, prepare input checksums remain the content provenance. Before reusing success, prepare
validates every durable prepared copy and compares current stable-input bytes, validates every durable prepared copy and compares current stable-input bytes,
canonical party and derived-player bytes, local audio membership/checksums, or effective campaign/session, canonical party and derived-player bytes, local audio
S3 key/size/entity-tag identity with that provenance. Source relocation with membership/checksums, or S3 key/size/entity-tag identity with that provenance.
equivalent names and bytes remains reusable; changed or unavailable evidence Source relocation with equivalent effective documents, names, and bytes remains
causes a normal prepare rerun. reusable; changed or unavailable evidence causes a normal prepare rerun.
## Related Contracts And Tests ## Related Contracts And Tests

View File

@@ -15,8 +15,8 @@ Upload run/session outputs to object storage and atomically advance remote curre
## Outputs ## Outputs
- uploaded session manifest, declared run-local diagnostics, and selected - uploaded session manifest, prepared campaign/session/party inputs, declared
publish outputs; run-local diagnostics, and selected publish outputs;
- uploaded durable previous-session cache files when present; - uploaded durable previous-session cache files when present;
- immutable run-scoped commit manifest; and - immutable run-scoped commit manifest; and
- current commit pointer, written last. - current commit pointer, written last.
@@ -34,7 +34,10 @@ and optional rules, destination resolution, and collision inputs live in
remote verification live in `publish_transfer.go`; committed-manifest, remote verification live in `publish_transfer.go`; committed-manifest,
immutable-commit, and current-pointer encoding and writes live in immutable-commit, and current-pointer encoding and writes live in
`publish_commit.go`. `publish_output_plan.go` owns the deterministic, I/O-free `publish_commit.go`. `publish_output_plan.go` owns the deterministic, I/O-free
five-outcome model and its secret-free metadata projection. five-outcome model and its secret-free metadata projection. Prepared input
objects are committed under the immutable run; the committed standalone session
supports remote loading when no authored session override is available. The
[configuration reference](../config.md#sessionyml) owns input selection.
- when publishing or run upload is disabled, completes successfully with no - when publishing or run upload is disabled, completes successfully with no
outputs and records explanatory metadata. This is not an explicit self-skip: outputs and records explanatory metadata. This is not an explicit self-skip:

View File

@@ -626,6 +626,8 @@ Publish commit model:
- uploads eligible run files under `{session_prefix}/runs/{run_id}/`, excluding - uploads eligible run files under `{session_prefix}/runs/{run_id}/`, excluding
audio and the run-local Notarius staging bundle; audio and the run-local Notarius staging bundle;
- uploads prepared campaign, session, and party documents under the run's
`prepare/inputs/` prefix, when recorded by the manifest;
- uploads configured published outputs and `previous/**` cache files into the - uploads configured published outputs and `previous/**` cache files into the
same immutable run scope, including only explicitly configured extraction same immutable run scope, including only explicitly configured extraction
lanes; lanes;
@@ -714,8 +716,8 @@ plan, so it is not a network-free operation.
Default restore scope: Default restore scope:
- the committed session manifest and the committed transcript/artifact objects - the committed session manifest, prepared campaign/session/party documents,
declared by the selected remote commit and transcript/artifact objects declared by the selected remote commit
- `previous/**` when needed by configured previous-session artifact inputs; - `previous/**` when needed by configured previous-session artifact inputs;
each is selected from its exact committed `published_output` declaration each is selected from its exact committed `published_output` declaration
@@ -821,7 +823,7 @@ ConfigKit.
Every pipeline-loading command bootstraps credentials once, before the first Every pipeline-loading command bootstraps credentials once, before the first
configuration load and before any adapter is constructed. `--secrets-dir` configuration load and before any adapter is constructed. `--secrets-dir`
selects an explicit directory (relative paths use caller CWD). Otherwise a selects an explicit directory (relative paths use caller CWD). Otherwise a
present `secrets/` beside the resolved root pipeline is used, while an absent present `/usr/local/etc/narratio/secrets` directory is used, while an absent
conventional directory is skipped. Explicit missing/empty selections and conventional directory is skipped. Explicit missing/empty selections and
invalid existing directories fail the command. ConfigKit follows a symlink used invalid existing directories fail the command. ConfigKit follows a symlink used
as the selected directory, but immediate entries must be regular non-symlink as the selected directory, but immediate entries must be regular non-symlink

View File

@@ -11,14 +11,14 @@ Copyright (C) 2026 Eric Rakestraw
SPDX-License-Identifier: CC-BY-SA-4.0 SPDX-License-Identifier: CC-BY-SA-4.0
License and notices: [CC BY-SA 4.0](licenses/CC-BY-SA-4.0.txt) | License and notices: [CC BY-SA 4.0](licenses/CC-BY-SA-4.0.txt) |
[COPYRIGHT](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/COPYRIGHT) | [COPYRIGHT](https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/COPYRIGHT) |
[LICENSE](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/LICENSE). [LICENSE](https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/LICENSE).
[Source](https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843). [Source](https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4).
## ConfigKit ## ConfigKit
Selected module: `gitea.maximumdirect.net/eric/ConfigKit` at `v0.4.2`. Selected module: `go.maximumdirect.net/configkit` at `v1.2.1`.
Copyright (C) 2026 Eric Rakestraw Copyright (C) 2026 Eric Rakestraw
@@ -26,10 +26,10 @@ SPDX-License-Identifier: LGPL-3.0-or-later
License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) | License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) |
[GPL 3.0](licenses/GPL-3.0.txt) | [GPL 3.0](licenses/GPL-3.0.txt) |
[COPYRIGHT](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/67c03690181c5af8dde6be325abac241dae6732f/COPYRIGHT) | [COPYRIGHT](https://forge.maximumdirect.net/base-layer/configkit/src/commit/51ef3144158db1a09fabdbd1c7ae59908c84923b/COPYRIGHT) |
[LICENSE](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/67c03690181c5af8dde6be325abac241dae6732f/LICENSE). [LICENSE](https://forge.maximumdirect.net/base-layer/configkit/src/commit/51ef3144158db1a09fabdbd1c7ae59908c84923b/LICENSE).
[Source](https://gitea.maximumdirect.net/eric/ConfigKit/src/commit/67c03690181c5af8dde6be325abac241dae6732f). [Source](https://forge.maximumdirect.net/base-layer/configkit/src/commit/51ef3144158db1a09fabdbd1c7ae59908c84923b).
## YAML v3 ## YAML v3
@@ -54,7 +54,7 @@ License and notices: [MIT](licenses/MIT.txt) |
## YAML v4 ## YAML v4
Selected module: `go.yaml.in/yaml/v4` at `v4.0.0-rc.6`. Selected module: `go.yaml.in/yaml/v4` at `v4.0.0`.
Copyright 2006-2010 Kirill Simonov Copyright 2006-2010 Kirill Simonov
@@ -66,10 +66,10 @@ SPDX-License-Identifier: MIT AND Apache-2.0
License and notices: [MIT](licenses/MIT.txt) | License and notices: [MIT](licenses/MIT.txt) |
[Apache 2.0](licenses/Apache-2.0.txt) | [Apache 2.0](licenses/Apache-2.0.txt) |
[LICENSE](https://github.com/yaml/go-yaml/blob/1c17b9cee72bf81ae73a8be50fbd7dd3a9985125/LICENSE) | [LICENSE](https://github.com/yaml/go-yaml/blob/f2f9563503f11b7a60da0c532175dcc693ce8d5a/LICENSE) |
[NOTICE](https://github.com/yaml/go-yaml/blob/1c17b9cee72bf81ae73a8be50fbd7dd3a9985125/NOTICE). [NOTICE](https://github.com/yaml/go-yaml/blob/f2f9563503f11b7a60da0c532175dcc693ce8d5a/NOTICE).
[Source](https://github.com/yaml/go-yaml/commit/1c17b9cee72bf81ae73a8be50fbd7dd3a9985125). [Source](https://github.com/yaml/go-yaml/commit/f2f9563503f11b7a60da0c532175dcc693ce8d5a).
## go-cmp ## go-cmp
@@ -114,18 +114,18 @@ License and notices: [BSD 3-Clause](licenses/BSD-3-Clause.txt) |
## Go runtime and standard library ## Go runtime and standard library
Material: Go `1.26.7` runtime and standard library material incorporated in Material: Go `1.27.4` runtime and standard library material incorporated in
release binaries built with the declared `golang:1.26.7` CI toolchain. release binaries built with the declared `golang:1.27.4` CI toolchain.
Copyright 2009 The Go Authors. Copyright 2009 The Go Authors.
SPDX-License-Identifier: BSD-3-Clause SPDX-License-Identifier: BSD-3-Clause
License and notices: [BSD 3-Clause](licenses/BSD-3-Clause.txt) | License and notices: [BSD 3-Clause](licenses/BSD-3-Clause.txt) |
[LICENSE](https://github.com/golang/go/blob/e3336a22ad3f0a90bd252c95d8b5544e02674205/LICENSE) | [LICENSE](https://github.com/golang/go/blob/7b2881024c95a11ddb86663a616340aa3a88b67f/LICENSE) |
[PATENTS](https://github.com/golang/go/blob/e3336a22ad3f0a90bd252c95d8b5544e02674205/PATENTS). [PATENTS](https://github.com/golang/go/blob/7b2881024c95a11ddb86663a616340aa3a88b67f/PATENTS).
[Source](https://github.com/golang/go/commit/e3336a22ad3f0a90bd252c95d8b5544e02674205). [Source](https://github.com/golang/go/commit/7b2881024c95a11ddb86663a616340aa3a88b67f).
## AWS SDK for Go v2 ## AWS SDK for Go v2

View File

@@ -2,9 +2,9 @@
**Base Policy Version:** 1.3 **Base Policy Version:** 1.3
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/agents.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/agents.md
## Purpose ## Purpose

View File

@@ -2,9 +2,9 @@
**Base Policy Version:** 1.3 **Base Policy Version:** 1.3
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/architecture.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/architecture.md
## Purpose And Ownership ## Purpose And Ownership
@@ -172,15 +172,22 @@ or other non-regular conflict into a successful restore.
## Configuration ## Configuration
Configuration is strict, explicit, centralized, and operator-oriented. Configuration is strict, explicit, centralized, and operator-oriented. ConfigKit
owns input loading, assembly, sibling inheritance, presence tracking, typed
secrets, and provenance. Narratio owns configuration-domain meaning and
fail-fast validation of the effective configuration.
- YAML decoding rejects unknown fields. - YAML decoding rejects unknown fields.
- Defaults are centralized and testable. - Defaults are centralized and testable.
- Empty configured values do not silently replace meaningful defaults. - Defaults apply only to absent fields. Explicit false, zero, empty, and null
values remain present and are evaluated by Narratio's domain rules.
- Validation rejects invalid configuration before stage execution where - Validation rejects invalid configuration before stage execution where
practical. practical.
- Root-owned imports and one selected overlay resolve deterministically through - Local document imports and one selected pipeline overlay resolve through
the configuration owner; commands do not implement their own merge rules. the configuration owner; commands do not implement their own merge rules.
- Native ConfigKit metadata and supported resolution callbacks provide presence,
inheritance, and provenance information without a parallel loading or
ownership system.
- Canonical party rosters are campaign-owned. Their derived players projection - Canonical party rosters are campaign-owned. Their derived players projection
and concrete character-family artifacts are resolved before runtime stages and concrete character-family artifacts are resolved before runtime stages
or adapters receive configuration. or adapters receive configuration.

View File

@@ -1,15 +1,15 @@
# Documentation Policy # Documentation Policy
**Base Policy Version:** 1.11 **Base Policy Version:** 1.12
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/documentation.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/documentation.md
## Purpose ## Purpose
This policy assigns each documentation topic to one canonical owner. Its goal is This policy assigns each documentation topic to one canonical owner. Its goal is
to keep Narratio's documentation accurate, concise, discoverable, and resistant to keep this application's documentation accurate, concise, discoverable, and resistant
to drift for users, operators, developers, integrators, and LLM coding agents. to drift for users, operators, developers, integrators, and LLM coding agents.
## Core Rules ## Core Rules
@@ -75,19 +75,19 @@ secret values.
| Release policy | `docs/policy/release.md` | Versioning, compatibility, release integrity and immutability, release documentation, proportionate gates, publication controls, completion, and required versus optional checks. | Repository-specific commands, product installation guidance, CLI version semantics, historical release summaries, and CI implementation detail. | | Release policy | `docs/policy/release.md` | Versioning, compatibility, release integrity and immutability, release documentation, proportionate gates, publication controls, completion, and required versus optional checks. | Repository-specific commands, product installation guidance, CLI version semantics, historical release summaries, and CI implementation detail. |
| Open source licensing and attribution policy | `docs/policy/oss.md` | License defaults and author choices, COPYRIGHT and attribution formats, license/notice links, discoverability, maintenance, and concrete exceptions. | Component entries, license texts, release commands, and dependency security review. | | Open source licensing and attribution policy | `docs/policy/oss.md` | License defaults and author choices, COPYRIGHT and attribution formats, license/notice links, discoverability, maintenance, and concrete exceptions. | Component entries, license texts, release commands, and dependency security review. |
| Project copyright and license grant | `COPYRIGHT` | Project identity, copyright holders and years, SPDX expression, grant, warranty disclaimer, and third-party statement. | Complete license texts and upstream component attribution. | | Project copyright and license grant | `COPYRIGHT` | Project identity, copyright holders and years, SPDX expression, grant, warranty disclaimer, and third-party statement. | Complete license texts and upstream component attribution. |
| Project license text | `LICENSE` | Complete GPLv3 project license text. | Companion dependency license texts and upstream component attribution. | | Project license texts | `LICENSE` | Complete project and incorporated companion license texts, with required project-specific fields. | General licensing policy and upstream component attribution. |
| Upstream component attribution | `docs/oss/attribution.md` | House Format component entries: identity, material scope and modifications where applicable, copyright, license, required notices, and license, notice, and source links. | General attribution policy, exception reasoning, research narratives, compliance commentary, and complete standard license texts. | | Upstream component attribution | `docs/oss/attribution.md` | House Format component entries: identity, material scope and modifications where applicable, copyright, license, required notices, and license, notice, and source links. | General attribution policy, exception reasoning, research narratives, compliance commentary, and complete standard license texts. |
| Standard dependency license texts | `docs/oss/licenses/` | Complete, verbatim standard license texts shared by applicable entries. | Project-specific upstream notices, attribution prose, and policy interpretation. | | Standard dependency license texts | `docs/oss/licenses/` | Complete, verbatim standard license texts shared by applicable entries. | Project-specific upstream notices, attribution prose, and policy interpretation. |
| Repository-specific release procedure | `docs/release.md` | Maintainer prerequisites, candidate preparation, validation and publication commands and automated guards, asynchronous deliverables, delivery status, optional consumer verification, and recovery. | General release requirements, product installation guidance, historical release summaries, and current compatibility contracts. | | Repository-specific release procedure | `docs/release.md` | Maintainer prerequisites, candidate preparation, validation and publication commands and automated guards, asynchronous deliverables, delivery status, optional consumer verification, and recovery. | General release requirements, product installation guidance, historical release summaries, and current compatibility contracts. |
| CLI contract (if applicable) | `docs/cli.md` | Commands, arguments, flags, invocation semantics, and exit codes. | End-to-end operating procedures, configuration field definitions, runtime filesystem layout, module implementation details. | | CLI contract (if applicable) | `docs/cli.md` | Commands, arguments, flags, invocation semantics, and exit codes. | End-to-end operating procedures, configuration field definitions, runtime filesystem layout, module implementation details. |
| Configuration contract (if applicable) | `docs/config.md` | Discovery, precedence, schema, fields, defaults, environment overrides, validation, and selectable module and validator keys. | Complete example files, CLI syntax, runtime state lifecycle, module implementation details. | | Configuration contract (if applicable) | `docs/config.md` | Discovery, precedence, schema, fields, defaults, environment overrides, validation, and selectable module and validator keys. | Complete example files, CLI syntax, runtime state lifecycle, module implementation details. |
| Operations | `docs/operations.md` | Runtime workflows, physical filesystem and state layout, output, cache and debug handling, resume, cleanup, permissions, recovery, and limits. | CLI flag syntax, configuration field definitions, logical output schemas, implementation mechanics. | | Operations (if applicable) | `docs/operations.md` | Runtime workflows, physical filesystem and state layout, output, cache and debug handling, resume, cleanup, permissions, recovery, and limits. | CLI flag syntax, configuration field definitions, logical output schemas, implementation mechanics. |
| Troubleshooting | `docs/troubleshooting.md` | Symptom-driven diagnosis, likely causes, safe inspection, and remedies. | Canonical commands, configuration definitions, operational procedures, and integration contracts. | | Troubleshooting | `docs/troubleshooting.md` | Symptom-driven diagnosis, likely causes, safe inspection, and remedies. | Canonical commands, configuration definitions, operational procedures, and integration contracts. |
| Integration contracts for external components (if applicable) | `docs/integrations/` | External formats and protocols, upstream and downstream contracts, logical output paths and schemas, media types, and compatibility. | Physical runtime placement and lifecycle, internal transformations, CLI syntax, configuration defaults. | | Integration contracts for external components (if applicable) | `docs/integrations/` | External formats and protocols, upstream and downstream contracts, logical output paths and schemas, media types, and compatibility. | Physical runtime placement and lifecycle, internal transformations, CLI syntax, configuration defaults. |
| Inventory of implemented internal packages | `docs/internal/overview.md` | Implemented packages and components, responsibilities, and links to focused internal docs. | Normative architecture, contributor reading policy, external contracts. | | Inventory of implemented internal packages | `docs/internal/overview.md` | Implemented packages and components, responsibilities, and links to focused internal docs. | Normative architecture, contributor reading policy, external contracts. |
| Behavior and architecture of internal packages | Other files under `docs/internal/` | Implementation flow, collaborators, state transitions, package-local guarantees and failures, and relevant tests. | Global architecture invariants, configuration definitions and defaults, external schemas, operator procedures. | | Behavior and architecture of internal packages | Other files under `docs/internal/` | Implementation flow, collaborators, state transitions, package-local guarantees and failures, and relevant tests. | Global architecture invariants, configuration definitions and defaults, external schemas, operator procedures. |
| Architectural decision records | `docs/adr/` | Significant decisions, context, alternatives, rationale, consequences, and supersession history. | Current behavior reference, implementation status, task sequencing. | | Architectural decision records | `docs/adr/` | Records of significant architectural decisions and supporting rationale. | Ordinary design choices, current behavior reference, implementation status, task sequencing. |
| Future work and implementation status | `docs/roadmap/` | Proposed, accepted, deferred, or rejected work; implementation status, sequencing, and task breakdowns. | Implemented behavior reference and architectural decision rationale. | | Future work and implementation status | `docs/roadmap/` | Proposed, accepted, or future work; implementation status, sequencing, and task breakdowns. | Implemented behavior reference and architectural decision rationale. |
| Release-note history | `docs/releases/` | One checked-in summary per source release under the procedure; the note at its immutable tag is the release record. | Current commands, behavior, contracts, and compatibility definitions. | | Release-note history | `docs/releases/` | One checked-in summary per source release under the procedure; the note at its immutable tag is the release record. | Current commands, behavior, contracts, and compatibility definitions. |
| Complete copyable artifacts | `examples/` | Maintained configuration, inputs, and other copyable or runnable files. | Field-by-field reference, command reference, prose explanation. | | Complete copyable artifacts | `examples/` | Maintained configuration, inputs, and other copyable or runnable files. | Field-by-field reference, command reference, prose explanation. |
@@ -153,8 +153,15 @@ Use sequentially numbered ADR filenames such as
Treat the decision content of an accepted ADR as immutable. When a decision Treat the decision content of an accepted ADR as immutable. When a decision
changes, create a new ADR and update the earlier ADR's status to superseded. changes, create a new ADR and update the earlier ADR's status to superseded.
Rejected architectural alternatives belong in the ADR; rejected product ideas
belong in the roadmap. ADRs should be reserved for major architectural decisions, such as ownership
boundaries, large-scale architectural features, or invariants that rise to
the level of architectural significance. Routine choices, implementation
decisions, and rejected suggestions do not warrant an ADR unless they
otherwise represent a significant architectural decision.
Roadmaps should preserve plausible future work, not rejected product
ideas.
## Maintenance ## Maintenance

View File

@@ -2,9 +2,9 @@
**Base Policy Version:** 1.0 **Base Policy Version:** 1.0
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/meta.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/meta.md
## Origin And Local Authority ## Origin And Local Authority

View File

@@ -1,10 +1,10 @@
# Open Source Licensing And Attribution Policy # Open Source Licensing And Attribution Policy
**Base Policy Version:** 1.8 **Base Policy Version:** 1.9
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/oss.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/oss.md
## Purpose And Scope ## Purpose And Scope
@@ -74,6 +74,9 @@ individual packages.
Use the upstream [application COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/a469273adda336625f96b9d769ea27b33999f146/examples/licensing/application/COPYRIGHT) Use the upstream [application COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/a469273adda336625f96b9d769ea27b33999f146/examples/licensing/application/COPYRIGHT)
or [library COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/a469273adda336625f96b9d769ea27b33999f146/examples/licensing/library/COPYRIGHT) or [library COPYRIGHT example](https://gitea.maximumdirect.net/eric/policy/src/commit/a469273adda336625f96b9d769ea27b33999f146/examples/licensing/library/COPYRIGHT)
to create the project’s root `COPYRIGHT` file. to create the project’s root `COPYRIGHT` file.
Use the COPYRIGHT examples exactly as provided, except for placeholder
substitutions and changes expressly required or authorized by this policy or
the author.
Use verified project names, contribution years, and copyright holders. Use verified project names, contribution years, and copyright holders.
For another selected license, adapt the grant, SPDX expression, disclaimer, and For another selected license, adapt the grant, SPDX expression, disclaimer, and
text references together to reflect the author's selected grant. text references together to reflect the author's selected grant.
@@ -169,10 +172,15 @@ source files; the central attribution entry does not authorize stripping them.
## Discoverability ## Discoverability
End Narratio's README with two friendly statements linking to its actual grant End the project's README with two friendly statements linking to its actual
in root `COPYRIGHT` and to `docs/oss/attribution.md`, using paths relative to grant in `COPYRIGHT` and the attribution document. For example, for a project
the README. The statements identify Narratio's GPL v3.0-or-later grant and make with the stated license:
the open source attribution notices discoverable.
```markdown
PROJECT_NAME is licensed under the [LGPL v3.0 or later](COPYRIGHT).
[Open Source attribution notices](docs/oss/attribution.md) are available.
```
Each new checked-in release document and its hosted download page must end Each new checked-in release document and its hosted download page must end
with links whose visible text is `COPYRIGHT | LICENSE | ATTRIBUTION`. Use absolute with links whose visible text is `COPYRIGHT | LICENSE | ATTRIBUTION`. Use absolute

View File

@@ -1,10 +1,10 @@
# Release Policy # Release Policy
**Base Policy Version:** 1.4 **Base Policy Version:** 1.7
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/release.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/release.md
## Purpose ## Purpose
@@ -12,6 +12,9 @@ This policy defines a proportionate workflow for validating and publishing an
intended source revision under a fresh version. Releases should require little intended source revision under a fresh version. Releases should require little
routine intervention, avoid repeated work, and preserve published contents. routine intervention, avoid repeated work, and preserve published contents.
Adopt stronger verification or reproducibility requirements through an explicit
project-specific decision justified by the intended audience and support needs.
The repository-specific commands belong in `docs/release.md`. Historical release The repository-specific commands belong in `docs/release.md`. Historical release
summaries belong in `docs/releases/`. The procedure must agree with the adopted summaries belong in `docs/releases/`. The procedure must agree with the adopted
policy and link to it rather than introduce additional release requirements. policy and link to it rather than introduce additional release requirements.
@@ -59,9 +62,14 @@ requires a deliberate update to the policy and procedure where needed.
For releases at or after `v1.0.0`: For releases at or after `v1.0.0`:
- a major release may make intentional incompatible changes; - a major release may make intentional incompatible changes;
- a minor release may add backward-compatible behavior; and - a minor release may add backward-compatible behavior or raise the Go consumer
minimum as described below; and
- a patch release may make backward-compatible fixes. - a patch release may make backward-compatible fixes.
In this context, "backward-compatible" means only that pre-existing, valid
configurations will continue to work following the release. Behavior need not
remain strictly identical.
Before `v1.0.0`, a minor release may change a documented public, operational, Before `v1.0.0`, a minor release may change a documented public, operational,
configuration, data, integration, or compatibility contract when the release configuration, data, integration, or compatibility contract when the release
note explains the impact and required consumer action. A patch release must note explains the impact and required consumer action. A patch release must
@@ -71,6 +79,36 @@ Additional compatibility promises and deliberate exceptions belong in the
adopted policy or canonical contract documentation. Release notes explain adopted policy or canonical contract documentation. Release notes explain
changes; they do not redefine current compatibility contracts. changes; they do not redefine current compatibility contracts.
## Consumer Minimum And Release Toolchain
Distinguish the minimum toolchain supported for consumers from the toolchain
maintainers use to build and validate a release. Record the consumer minimum in
the language's standard metadata and explain its support meaning in canonical
documentation. Define the selected release toolchain and its setup commands in
`docs/release.md`. Toolchain selection and upgrade cadence are repository-specific
choices.
For Go repositories, normally declare the initial stable release of the selected
series as the consumer minimum, such as `go 1.26.0`. Use a higher patch minimum
when a dependency or an identified correctness fix requires it, and document
the reason.
For release-policy purposes, successful build and release validation on the
selected Go patch release are sufficient to presume support across that Go
series, subject to the declared consumer minimum and concrete evidence of
incompatibility. Investigate specific compatibility concerns as they arise.
Use the selected release toolchain for candidate validation and release builds,
including CI jobs performing those tasks. A newer validation patch version alone
leaves the consumer minimum unchanged.
A minor release may raise the Go consumer minimum, including from one Go series
to the next, both before and after `v1.0.0`. This is an explicit exception to the
backward-compatibility requirement for minor releases. Patch releases preserve
the consumer minimum. Explain an increase's impact and required consumer action
in the release note. Other incompatible changes remain subject to the versioning
rules above.
## Release Documentation And Preparation ## Release Documentation And Preparation
Every new release must include `docs/releases/<version>.md` in the tagged Every new release must include `docs/releases/<version>.md` in the tagged
@@ -206,7 +244,8 @@ release without replacing its contents or reusing its version.
Maintain `docs/release.md` as a short, executable maintainer runbook. It must Maintain `docs/release.md` as a short, executable maintainer runbook. It must
identify: identify:
1. prerequisites, primary branch, and authoritative remote; 1. prerequisites, selected release toolchain, primary branch, and authoritative
remote;
2. version and release-note preparation; 2. version and release-note preparation;
3. one publication command with its selected local checks and automated guards; 3. one publication command with its selected local checks and automated guards;
4. declared deliverables, required build targets, and automation responsibilities; 4. declared deliverables, required build targets, and automation responsibilities;

View File

@@ -2,9 +2,9 @@
**Base Policy Version:** 1.3 **Base Policy Version:** 1.3
**Last Updated**: 2026-09-28 **Last Updated**: 2026-11-17
**Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/d84a38ebab26f048cafbe59a2246700c35d29843/docs/policy/testing.md **Upstream Source**: https://gitea.maximumdirect.net/eric/policy/src/commit/593c9b52273c5c879785ae9e995d21026df467b4/docs/policy/testing.md
## Purpose ## Purpose

View File

@@ -7,16 +7,18 @@ The source release completes when the intended tag is successfully pushed to
## Prepare the candidate ## Prepare the candidate
Use `main` and the authoritative Git remote `origin`. Install Git, a POSIX Use `main` and the authoritative Git remote `origin`. Install Git, a POSIX
shell, standard Unix build tools, and Go 1.26. Have the selected Go modules shell, standard Unix build tools, and the [release toolchain](#release-toolchain).
available before offline validation. Git access must permit fetch and tag push. Have the selected Go modules available before offline validation. Git access
must permit fetch and tag push.
Application-provider credentials are not required; Gitea delivery credentials Application-provider credentials are not required; Gitea delivery credentials
belong to CI. belong to CI.
Choose an unused stable `vMAJOR.MINOR.PATCH` under the Choose an unused stable `vMAJOR.MINOR.PATCH` under the
[compatibility rules](policy/release.md#versioning-and-compatibility). Narratio [compatibility rules](policy/release.md#versioning-and-compatibility). Narratio
is past v1.0.0, so intentional CLI or configuration breaks require a major is past v1.0.0; apply the policy's effective-configuration compatibility
release. Update affected canonical documentation with the change. Write the definition and Go consumer-minimum exception. Update affected canonical
matching `docs/releases/vMAJOR.MINOR.PATCH.md` with a short summary and any documentation with the change. Write the matching
`docs/releases/vMAJOR.MINOR.PATCH.md` with a short summary and any
relevant compatibility impact or upgrade action; choose sections to suit the relevant compatibility impact or upgrade action; choose sections to suit the
release. release.
@@ -39,6 +41,27 @@ before tagging; record its exact commit if needed:
git rev-parse HEAD git rev-parse HEAD
``` ```
## Release toolchain
The selected release toolchain is Go 1.27.4, matching the validation and build
jobs in `.woodpecker/release.yml`. With an official Go installation available,
select it before candidate validation and publication:
```sh
export GOTOOLCHAIN=go1.27.4
go version
```
Go downloads the selected toolchain if needed. Complete that setup and module
preparation before offline candidate validation. Keep this selection and the
release CI images aligned when deliberately updating the release toolchain.
The consumer minimum is Go 1.27.0 as declared in `go.mod`.
Successful release validation on the selected patch establishes presumed
support across that series, subject to the declared minimum and concrete
evidence of incompatibility, under the
[release policy](policy/release.md#consumer-minimum-and-release-toolchain).
## Publish ## Publish
From a clean `main` checkout at the pushed candidate, run one command: From a clean `main` checkout at the pushed candidate, run one command:

175
docs/roadmap/audita.md Normal file
View File

@@ -0,0 +1,175 @@
# Adopt Audita v3 and independent diagnostic destinations
## Purpose
Adopt Audita v3.0.0 for transcript polishing and use its independent output
destinations to implement the Audita portion of the
[session workspace roadmap](workspace.md). Operators should find the completed
transcript, ordinary reports, and optional debug evidence in their respective
Narratio locations.
This document defines the Audita adoption scope and target. The workspace
roadmap owns shared layout, latest-attempt views, and retention behavior. Its
referenced ADRs remain Proposed. Implementation sequencing belongs in a
subsequent implementation plan.
## Reviewed Upstream Release
The reviewed Audita v3.0.0 tag identifies commit
`3b4933256eff84327b812e7ae12babf743bc04a6`. Its
[release notes](https://gitea.maximumdirect.net/eric/audita/src/tag/v3.0.0/docs/releases/v3.0.0.md),
[CLI reference](https://gitea.maximumdirect.net/eric/audita/src/tag/v3.0.0/docs/cli.md),
[configuration reference](https://gitea.maximumdirect.net/eric/audita/src/tag/v3.0.0/docs/config.md),
and [operations guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v3.0.0/docs/operations.md)
own the downstream contracts.
Audita now honors an explicit `--report-dir` alongside file transcript output.
Its existing `--work-dir` selects the parent of retained debug captures, with
capture enabled separately through configuration or `--debug`. These controls
satisfy Narratio's requested destination separation. Further upstream changes
are unnecessary for this scope.
## Current Baseline
Narratio's [Audita integration](../integrations/audita.md) and
[polish stage](../internal/stage-polish.md) describe the implemented behavior:
- The adapter invokes `process` with a transcript, glossary, and staged transcript
destination. It supports independent downstream configuration, overlay,
profile, module, description, and output-schema selectors.
- The adapter supplies no reporting, debug, or work-directory flags. Audita
controls debug capture and placement through its own configuration.
- Ordinary reports are discovered beside the staged transcript. The polish
stage validates returned report paths against those adjacent filenames.
- Only the validated polished transcript becomes a canonical stage output.
Reports, captured streams, and the generated invocation record are diagnostics.
- Selected credential references use Narratio's shared exact-name forwarding and
captured-stream redaction boundary.
The existing invocation remains usable with Audita v3 after deployment-side
profile migration. Narratio changes are needed to request and consume the
new destination separation.
## Targeted End State
### Products and diagnostics
Narratio supplies separate destinations for each actual polish attempt:
| Content | Destination and control |
| --- | --- |
| Corrected transcript | Run-local staging via `--output`; validated and promoted to `transcripts/polished.json` on success. |
| Ordinary reports | `runs/<run_id>/polish/logs/` via `--report-dir`. |
| Captured stdout, stderr, and Narratio invocation record | The same run-local polish log directory. |
| Optional debug evidence | `runs/<run_id>/polish/debug/` via `--work-dir`; Audita may create its own `run-*` subdirectory beneath it. |
The workspace roadmap's `logs/polish` and `debug/polish` links expose the latest
attempt. Narratio supplies actual run destinations to Audita and records those
paths in manifest diagnostics. Shared link updates and cleanup protection are
implemented by the workspace work rather than separately inside the adapter.
### Capture selection
Add an optional `pipeline.audita.debug` boolean, defaulting to false. A true
value passes `--debug`. False or omission supplies no capture override and
preserves Audita configuration and overlay behavior; it does not disable debug
enabled downstream.
Supply `--work-dir` for each executing attempt so downstream-enabled capture
also lands in the Narratio-selected debug directory. Selecting that destination
alone does not enable capture. Ordinary production operation retains Audita's
default reporting and debug settings. Narratio adds no reporting enable/disable
flag or debug-disable flag.
Debug selection affects diagnostics for an executing stage. Changing it alone
does not invalidate a completed transcript. Operators use the existing force
workflow when fresh polish or debug evidence is needed.
### Ownership and compatibility
Use a clean adoption of Audita v3's CLI contract, without version-dependent
adapter branches or legacy profile conversion. Audita continues to own its
configuration, profiles, prompts, runtime State, and diagnostic contents.
Narratio owns supplied destinations and transcript promotion.
Keep existing selectors and shared credentials such as `OPENROUTER_API_KEY` and
`RAKESTRAWHOME_API_KEY` under their configured exact names. Audita's examples
do not require Narratio to adopt application-specific credential aliases.
Operators continue to list the credential references required by all configured
Audita backends.
Audita is a separately installed executable. Its adoption of ConfigKit v0.5.0
and PromptKit v0.12.0 does not require changing Narratio's own library
dependencies as part of this feature.
## Required Changes
### Deployment configuration migration
Document the manual migration of Audita-owned PromptKit files:
- Wrap profile definitions under keyed `profiles:` mappings, remove inner `id`
fields, and replace `base_profile` with `extends`. Preserve selected profile
IDs when appropriate.
- Review explicit zeros, omitted values, and nulls against the new generation
control semantics. Validate the final configuration root, including unused
definitions and backend references.
- Rename any backend literally named `extends` and update its references.
- Validate production configuration and each used testing overlay with Audita's
offline `config validate` command. Audita application configuration continues
to use `version: 2`.
Keep the detailed downstream format owned by the pinned Audita documentation.
Narratio does not inspect, rewrite, or automatically migrate these files.
Deployment can migrate Audita before the workspace changes land.
### Adapter and polish stage
Carry explicit report and debug destinations through the Audita request and
construct the supported flags inside the adapter. Wire the debug selector
through configuration and runner composition.
Discover the existing three report filenames in the requested report directory.
Update polish's expected-path validation to the same location. Update invocation
records and safe result metadata to describe the selected destinations and
capture request. Preserve available failure evidence and the original subprocess
error.
Keep existing transcript validation, report read bounds, timeouts, credential
forwarding, and captured-stream redaction. Reports remain optional diagnostics;
early failures or downstream-disabled reporting may produce none. Exit-zero
runs with recoverable model errors remain successful. A nonzero exit, including
a late report-write failure, never authorizes transcript promotion. Narratio
does not add report-schema parsing or report-status success gates.
### Workspace integration and lifecycle
Use the shared workspace path owner for run-local log/debug destinations and
the agreed latest-attempt behavior. Preserve previous views on skipped stages;
actual attempts refresh both views, including on failure. An attempt without
debug capture exposes an empty current debug directory.
Keep full Audita debug bundles local in this feature. Preserve existing declared
diagnostic publication and apply the workspace roadmap's retention protection
to latest link targets. This feature inherits that roadmap's clean session
cutover and unchanged treatment of older completed outputs after invalidation
or failed replacement.
### Documentation and verification
When implemented, update the configuration reference and examples, Audita
integration contract, polish internals, and operator guide. Reference Audita v3's
profile migration and explain the shared Audita/Notarius overlay development
workflow. Downstream configuration edits behind unchanged selectors still
require explicitly forcing the affected stage to replace reused outputs.
Revise the workspace roadmap's upstream-request description when this adoption
is incorporated; Audita v3.0.0 supplies the previously missing capability.
Use focused offline tests for separate transcript/report/debug destinations,
enable-only debug selection, capture enabled by downstream configuration,
available failure reports, and preservation of nonzero-exit behavior. Verify
that reports remain diagnostics and only a successful validated transcript is
promoted. Shared latest-view and cleanup tests belong to the workspace change.
Default Narratio tests use subprocess doubles and temporary filesystems and
remain independent of sibling checkouts, real credentials, and paid providers.

280
docs/roadmap/workspace.md Normal file
View File

@@ -0,0 +1,280 @@
# Session workspace organization
## Purpose
Give operators predictable locations for session inputs, completed outputs,
logs, and debug evidence. Apply the taxonomy in
[ADR 0001](../adr/0001-classify-session-content.md) and the ownership boundary in
[ADR 0002](../adr/0002-assign-subprocess-content-ownership.md).
This roadmap defines the target behavior and required changes. Implementation
sequencing belongs in a subsequent implementation plan. The ADRs remain
Proposed pending their acceptance.
## Confirmed Requirements
- Completed artifacts occupy a flat `artifacts/` directory. Intermediate
products such as `session_bounds.json` belong here.
- Combined transcripts occupy `transcripts/` directly. Initial per-speaker
transcripts occupy a subdirectory beneath it.
- Prepared external audio occupies `audio/`; other prepared external inputs
occupy `inputs/`. Outputs consumed by later stages retain their output paths.
- Logs and Debug use matching latest-attempt views: `logs/<stage>` and
`debug/<stage>` are symlinks to the producing run's directories. Both views
advance when a stage starts an actual attempt, including attempts that fail.
A skipped stage leaves its previous views intact.
- Execution reports and invocation records are Logs. Historical Logs and Debug
remain under their producing runs, subject to cleanup.
- Narratio can selectively request supported subprocess debug capture through
configuration. Omission preserves application configuration and defaults;
Narratio needs no explicit downstream debug-disable override.
- Prepared session audio is the single retained Narratio-managed audio copy.
Remove Narratio's separate persistent audio cache and spool duplicates.
- Configurations that produce colliding artifact names or destinations fail
validation before execution. Validation covers the effective pipeline,
including expanded character families and built-in artifact destinations.
- Narratio selects input, output, log, and debug paths. Subprocess applications
own their working State and Cache through their supported configuration.
- A dedicated cache root such as `/var/cache/notarius` is a deployment
recommendation. The application owns its cache defaults, internal layout,
identity, and reuse semantics. Narratio session cleanup respects that boundary.
- Narratio retains its own manifest, recovery records, and managed staging State.
- This is a clean cutover for newly prepared sessions. Existing-session migration
and backward compatibility shims are outside the feature.
- Treatment of older completed files after invalidation or failed replacement
remains unchanged, including their availability through manifest-backed
resolution. Directory reorganization does not authorize new stale-file
deletion, automatic fallback, or rollback behavior.
## Current Baseline
The [operator guide](../operations.md#local-state-layout) owns the current
physical layout. Relevant differences from the target are:
- Extraction moves the complete Notarius bundle to
`artifacts/notarius/<run_id>/`. Resume evidence and artifact resolution depend
on that bundle and its index.
- Merge and normalize promote Seriatim execution reports into `artifacts/`.
- Analysis output paths and character-family patterns can introduce nested
artifact directories. Output-path configuration also permits locations that
need reconciliation with the selected directory categories.
- Standard combined transcript paths already match the target. Layout creation
also creates an unused `transcripts/trimmed/` directory.
- Most subprocess diagnostics live under individual run directories. Root-level
log paths lack a consistent latest-attempt view. Audita reports sit beside
its staged transcript, and restore writes a separate top-level report.
- Prepared previous-session inputs occupy `previous/`. Narratio-owned reference
snapshots supplied to Notarius occupy session `cache/notarius/references/`.
These snapshots are distinct from Notarius's own execution caches.
- Audita debug placement follows downstream configuration. Narratio does not
expose Notarius debug capture, and Scriptorium render-debug placement varies.
- Narratio maintains separate S3 audio cache and spool paths in addition to the
prepared session audio copy.
## Target Layout And Ownership
Retain the configurable workspace root and its current system-wide default,
`/var/lib/narratio`. Sessions remain under
`/var/lib/narratio/work/<campaign>/<session>` by default. The following paths
express the selected categories:
| Path | Contents and role |
| --- | --- |
| `manifest.json` | Narratio's durable progress and output references. |
| `artifacts/<filename>` | Completed artifact payloads, including session bounds. |
| `transcripts/<filename>` | Completed combined transcripts and rendered transcripts. |
| `transcripts/raw/<speaker>.json` | Completed initial per-speaker transcripts. |
| `audio/` | Prepared external audio. |
| `inputs/` | Prepared configuration, references, and previous-session inputs. |
| `logs/<stage>` | Symlink to the latest attempt's run-local logs and execution reports. |
| `debug/<stage>` | Symlink to the latest attempt's run-local debug directory, empty when no capture is produced. |
| `runs/<run_id>/<stage>/logs/` | Actual logs and execution reports for that attempt. |
| `runs/<run_id>/<stage>/debug/` | Actual debug captures for that attempt, including retained state snapshots. |
| `runs/<run_id>/` | Narratio staging, original tool bundles, and retained execution evidence. |
For example, the latest views use relative links within the session:
```text
logs/polish -> ../runs/<run_id>/polish/logs/
debug/polish -> ../runs/<run_id>/polish/debug/
```
Each stage's latest attempt can belong to a different run. Producers write to
the actual run paths; the symlinks provide operator navigation without duplicate
diagnostic storage.
Narratio's lock and restore marker remain its own State. Their current placement
can remain; introducing another root-level State directory is unnecessary for
this feature. Generated records that describe an invocation belong with Logs;
configuration actually supplied as an input follows its input or staging role.
Subprocesses may create internal working directories wherever their configuration
directs. Narratio-selected staging destinations for result bundles remain valid
under ADR 0002. Cache locations are documented as operator recommendations using
each application's existing configuration surface.
## Required Changes
### Output paths and configuration
Centralize the revised paths in the existing path owner. Apply the flat artifact
rule to explicit artifacts, expanded families, extraction outputs, and session
bounds. Preserve logical source identities used by dependencies and publication.
Keep explicit analysis filenames and require flat destinations. Derive extraction
filenames from configured extraction keys with a `.json` extension, with an
explicit extraction filename override for naming preferences or collisions.
Retain `session_bounds.json` as the default bounds filename. Do not silently
rename conflicting files. Report conflicting producers and the shared destination
in configuration errors. Validate the effective configuration after composition
and family expansion.
Keep combined transcript destinations directly beneath `transcripts/`. Remove
obsolete directory scaffolding and reconcile configurable output paths with
their category. Local path changes do not require flattening explicitly
configured remote publish destinations.
### Notarius result handling and reuse
Receive and validate the complete Notarius bundle in Narratio staging. Promote
selected accepted payloads to their flat artifact destinations. Classify the
receipt, warnings, rejection summaries, and diagnostics as Logs. Keep bundle
indexes and other management metadata with the bundle or Narratio State according
to their use.
Revise extraction evidence, catalog hydration, and resume checks to resolve
promoted products independently of the old `artifacts/notarius/` layout. Retain
the identity, provenance, contract, and checksum evidence needed for current
reuse behavior. Historical bundles may remain available for inspection under
their existing retention semantics; relocating them beneath `runs/` must not
silently shorten their lifetime through run cleanup.
Preserve ordinary resume and forced-extraction behavior. Subprocess caches remain
under Notarius's control.
### Inputs
Place prepared previous-session material beneath `inputs/previous/`. Place the
stable reference snapshots Narratio supplies to Notarius beneath
`inputs/references/`, retaining their content identities where needed for reuse.
Update preparation, input resolution, manifest references, and restore mappings.
Keep source configuration ownership and prepared-file validation unchanged.
### Audio acquisition
Simplify acquisition to one prepared session copy under `audio/`. Remove the
separate Narratio S3 audio cache and routine retained spool copies, together with
their obsolete configuration, manifest bookkeeping, and cleanup controls.
Preparation may use temporary download files before installing validated audio.
Preserve reuse of valid prepared audio and update restore to use the same layout.
Recreating a session after its prepared audio is removed requires fetching the
source again. Original recordings remain outside this cleanup change. Removing
spool/cache handling does not authorize new deletion of prepared session audio.
Subprocess caches remain independently configured and managed.
### Logs and execution reports
Provide one consistent latest-attempt view per stage. Include failed attempts;
a skipped stage leaves its previous view intact. Distinguish multiple applications
or artifact invocations within a stage through their filenames. Route Seriatim
reports, Audita reports, Notarius diagnostic records, and Narratio invocation
records through this model. Treat restore execution as its own diagnostic group
under `logs/restore/`, using run-local evidence and a latest-attempt view.
Prevent a new attempt from presenting old diagnostic files as newly generated
ones. At the start of each actual stage attempt, create its run-local log and
debug directories and refresh both latest symlinks. An attempt without debug
output exposes an empty debug directory rather than an older capture. Preserve
subprocess errors and available evidence on failure. Retain existing
captured-stream redaction and limits.
Keep historical files at their run paths; rotating the links does not move files.
Run cleanup must preserve directories targeted by current latest links. Do not
introduce an automatic history age or count limit. Publication and manifest
diagnostic references use actual run paths. Adjust path handling for these
Narratio-managed navigation links without relying on arbitrary symlink traversal.
### Debug controls and placement
Add selective Narratio configuration for Audita and Notarius debug capture using
their supported enabling CLI flags. An enabled Narratio selector requests
capture; an omitted or false selector passes no debug override and preserves the
application's configured/default behavior. Do not add a downstream disable flag.
Supply the actual run-local debug directories, exposed through `debug/polish`
and `debug/extract`. Control the destination when capture can be enabled through
downstream configuration as well, including Audita overlays, using supported
destination controls without changing capture enablement. Audita's debug
work-directory option selects diagnostic storage and belongs to this placement
responsibility.
Route Scriptorium's existing analysis and bounds render-debug products to the
run-local directories exposed through `debug/analyze` and `debug/trim`. Preserve
its existing per-artifact selection capability. Seriatim requires no invented
debug mode; its ordinary reports are
Logs. Subprocess-defined bundle contents and nested run directories are allowed
beneath the selected run-local debug root. Logs and Debug share the same
latest-attempt semantics and cleanup protection.
Keep new full Audita and Notarius debug bundles local in this feature. Preserve
publication of currently declared diagnostics, including existing render-debug
products. Enabling capture does not implicitly add full debug bundles to remote
archives.
Debug controls govern capture when a stage executes. They do not independently
require regeneration of valid substantive outputs. Document the existing force
workflow for obtaining fresh diagnostic evidence when a stage would be reused.
Preserve downstream failure semantics for diagnostic writes and the existing
boundary of Narratio's captured-stream redaction.
### Audita destination support
Request upstream support for independently selecting the transcript output,
ordinary report/log directory, and debug/retained working directory, then adopt
a supporting release. Audita currently ignores `--report-dir` when transcript
output is a file; honoring that destination is the principal missing capability.
Narratio continues to capture subprocess stdout and stderr itself.
Direct ordinary reports, including failure reports, to the actual polish log
directory, the transcript to its staged product destination, and retained debug
material to the actual polish debug directory. This feature uses the supported
upstream controls in a clean cutover without version-based compatibility branches.
### Manifest, publication, restore, and cleanup
Update all consumers of changed paths and file categories together. Preserve
per-speaker and per-artifact completed-work reuse. Keep publication driven by
declared products and diagnostics, with new full debug bundles remaining local.
Restore new-format products and inputs to their new locations.
Define an explicit way to identify supported session state for the clean
cutover. Document regeneration with the new version and manual configuration
updates. Avoid accepting old state through path fallbacks or silently rewriting
old local sessions or remote snapshots.
Preserve existing invalidation and failed-replacement behavior. Review retention
by content role before changing cleanup targets, especially when durable products
or historical bundles move. Run cleanup preserves the current log and debug
link targets; explicit removal of an entire session removes its local views
with it. Subprocess working State and Cache remain outside Narratio's cleanup
responsibility.
### Documentation and verification
Update configuration examples, the operator guide, adapter contracts, workspace
internals, and the architecture policy when implementation lands. Replace the
current architectural assumption that extraction requires a complete immutable
bundle beneath `artifacts/` with the selected product-promotion model. Retire
policy and documentation for Narratio's removed audio cache/spool lifecycle and
document the managed latest-attempt symlinks. Keep per-application cache locations
as deployment recommendations owned by each application's configuration.
Use focused behavioral coverage for flat output placement, collision rejection,
latest-attempt diagnostics on success and failure, debug selection and routing,
unchanged completed-work reuse, failed replacement, and new-format publish/restore.
Cover empty debug views after attempts without capture, preserved views for
skipped stages, cleanup protection of latest targets, and audio acquisition,
reuse, and restore without persistent spool/cache duplicates. Exercise cleanup
against products and separately owned caches. Use temporary filesystems and
subprocess doubles; default tests remain offline and independent
of sibling checkouts or paid providers.

View File

@@ -90,12 +90,12 @@ Symptom:
Likely cause: Likely cause:
- the campaign `party.yml` is an unversioned legacy document, or names a - the campaign party main document is unversioned, or names a
schema other than `narratio.party.v1`. schema other than `narratio.party.v1`.
Safe fix: Safe fix:
- replace the file with one exact, single-document - replace the main file with a versioned
[`narratio.party.v1` party](./integrations/party.md); do not add a version [`narratio.party.v1` party](./integrations/party.md); do not add a version
marker to an otherwise incompatible legacy structure. The versioned party is marker to an otherwise incompatible legacy structure. The versioned party is
the only configured roster authority. the only configured roster authority.
@@ -118,7 +118,8 @@ narratio config sources --config /path/pipeline.yml --overlay testing
Add `--campaign` or `--campaign-file` when the pipeline has party-driven Add `--campaign` or `--campaign-file` when the pipeline has party-driven
artifact families. The output identifies each effective logical field's root, artifact families. The output identifies each effective logical field's root,
import, overlay, default, campaign, party, or family source without printing import, overlay, default, campaign, party, or family source without printing
the field value or credential contents. the field value or credential contents. Empty optional import selections are
reported separately; selected invalid files still fail.
Safe fix: Safe fix:
@@ -958,7 +959,7 @@ Symptom:
Likely causes: Likely causes:
- missing, unreadable, or invalid explicit `--secrets-dir`; - missing, unreadable, or invalid explicit `--secrets-dir`;
- invalid entries in the conventional `secrets/` directory beside the root pipeline; - invalid entries in `/usr/local/etc/narratio/secrets`;
- missing credential environment variables; - missing credential environment variables;
- invalid S3 endpoint/bucket settings. - invalid S3 endpoint/bucket settings.

View File

@@ -12,12 +12,18 @@ in the [configuration reference](../docs/config.md).
- [Production-shaped pipeline](pipeline.production.yml): S3 storage, publish, - [Production-shaped pipeline](pipeline.production.yml): S3 storage, publish,
external tools, and configured Scriptorium artifacts. external tools, and configured Scriptorium artifacts.
- [Production-base/testing-overlay bundle](production-testing/pipeline.yml): - [Production-base/testing-overlay bundle](production-testing/pipeline.yml):
explicit `conf.d` imports, one ordinary artifact per `artifacts/<key>.yml`, explicit required `conf.d` imports, an optional local import, destination-mounted
one family per `artifact-families/<key>.yml`, and the fixed artifact files, a YAML-filtered directory of keyed families, and the fixed
`overlays/testing.yml` overlay. Production values live in the base. The `overlays/testing.yml` overlay. Production values live in the base. The
bundle demonstrates an input-only artifact dependency, two character families bundle demonstrates an input-only artifact dependency, two character families
sharing the campaign party, and a testing-only disabled artifact. Inspect it sharing the campaign party, and a testing-only disabled artifact. The testing
offline with: overlay's `testing_notes` artifact inherits the recap prompt, inputs, and
testing profile while retaining its disabled status and separate output path.
The testing overlay upserts the transcript publish rule by `source`. A
destination key defines each artifact ID; filenames do not. Full-root and
disjoint definitions are also valid. Upsert replaces a matching list record
as a whole; empty append or upsert contributions leave existing entries intact.
Inspect it offline with:
```sh ```sh
narratio config validate --config examples/production-testing/pipeline.yml --campaign-file examples/campaigns/sample-campaign/campaign.yml narratio config validate --config examples/production-testing/pipeline.yml --campaign-file examples/campaigns/sample-campaign/campaign.yml
@@ -43,7 +49,9 @@ with the sample campaign and a compatible local- or S3-audio session.
- [Sample campaign](campaigns/sample-campaign/campaign.yml), its - [Sample campaign](campaigns/sample-campaign/campaign.yml), its
[session template](campaigns/sample-campaign/session.template.yml), and its [session template](campaigns/sample-campaign/session.template.yml), and its
adjacent stable inputs provide a complete campaign directory shape. adjacent stable inputs provide a complete campaign directory shape. Its
imported settings and split party demonstrate local secondary imports;
relative resources follow the file that supplies each value.
- [Local-audio session](session.local-audio.yml) and - [Local-audio session](session.local-audio.yml) and
[S3-audio session](session.s3-audio.yml) are concrete session files. [S3-audio session](session.s3-audio.yml) are concrete session files.
- [Session template](session.template.yml) and the campaign-local equivalent - [Session template](session.template.yml) and the campaign-local equivalent
@@ -76,8 +84,8 @@ names, or the Narratio credential lists must be changed to match. See the
[Audita v2 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.0/docs/migrations/v2.md) [Audita v2 migration guide](https://gitea.maximumdirect.net/eric/audita/src/tag/v2.0.0/docs/migrations/v2.md)
for maintained downstream configuration examples. for maintained downstream configuration examples.
For a deployed bundle, keep credential files out of source control in a For a deployed bundle, keep credential files out of source control in the
`secrets/` directory beside the root `pipeline.yml`, one file per referenced conventional `/usr/local/etc/narratio/secrets` directory, one file per referenced
environment-variable name, or select another directory with `--secrets-dir`. environment-variable name, or select another directory with `--secrets-dir`.
Static S3 credentials are optional: omit both S3 credential references to use Static S3 credentials are optional: omit both S3 credential references to use
the AWS SDK discovery chain. the AWS SDK discovery chain.

View File

@@ -1,8 +1,5 @@
config:
imports:
- path: fragments/inputs.yml
required: true
campaign_id: sample-campaign campaign_id: sample-campaign
session_template_file: ./session.template.yml
inputs:
speakers_file: ./speakers.yml
autocorrect_file: ./autocorrect.yml
glossary_file: ./glossary.yml
party_file: ./party.yml
spell_catalog_file: ./spell_catalog.json

View File

@@ -0,0 +1,12 @@
brenna:
player:
name: Rowan Hale
character:
name: Brenna
alias:
- Shield of Dawn
classes:
- name: paladin
level: 6
- name: warlock
level: 2

View File

@@ -0,0 +1,7 @@
session_template_file: ../session.template.yml
inputs:
speakers_file: ../speakers.yml
autocorrect_file: ../autocorrect.yml
glossary_file: ../glossary.yml
party_file: ../party.yml
spell_catalog_file: ../spell_catalog.json

View File

@@ -1,4 +1,9 @@
schema_version: narratio.party.v1 schema_version: narratio.party.v1
config:
imports:
- path: fragments/brenna.yml
destination: [characters]
required: true
characters: characters:
arannis: arannis:
@@ -12,15 +17,3 @@ characters:
classes: classes:
- name: wizard - name: wizard
level: 8 level: 8
brenna:
player:
name: Rowan Hale
character:
name: Brenna
alias:
- Shield of Dawn
classes:
- name: paladin
level: 6
- name: warlock
level: 2

View File

@@ -1,20 +1,18 @@
scriptorium: character_items:
artifact_families: enabled: true
character_items: for_each: party.characters
enabled: true prompt_id: dnd.character_items
for_each: party.characters profile_id: production-placeholder
prompt_id: dnd.character_items output_path_pattern: artifacts/characters/{character_id}/items.md
profile_id: production-placeholder inputs:
output_path_pattern: artifacts/characters/{character_id}/items.md character_meta:
inputs: source: narratio.member_artifact.character_meta
character_meta: required: true
source: narratio.member_artifact.character_meta member_vars:
required: true character_id: character_id
member_vars: character_name: character.name
character_id: character_id aliases: character.alias_summary
character_name: character.name publish:
aliases: character.alias_summary enabled: true
publish: required: false
enabled: true dest_pattern: artifacts/characters/{character_id}/items.md
required: false
dest_pattern: artifacts/characters/{character_id}/items.md

View File

@@ -1,13 +1,11 @@
scriptorium: character_meta:
artifact_families: enabled: true
character_meta: for_each: party.characters
enabled: true prompt_id: dnd.character_meta
for_each: party.characters profile_id: production-placeholder
prompt_id: dnd.character_meta output_path_pattern: artifacts/characters/{character_id}/meta.md
profile_id: production-placeholder member_vars:
output_path_pattern: artifacts/characters/{character_id}/meta.md character_id: character_id
member_vars: character_name: character.name
character_id: character_id player_name: player.name
character_name: character.name class_summary: character.class_summary
player_name: player.name
class_summary: character.class_summary

View File

@@ -1,11 +1,8 @@
scriptorium: enabled: true
artifacts: prompt_id: dnd.player_handout
player_handout: profile_id: production-placeholder
enabled: true output_path: artifacts/player-handout.md
prompt_id: dnd.player_handout inputs:
profile_id: production-placeholder recap:
output_path: artifacts/player-handout.md source: narratio.artifact.session_recap
inputs: required: true
recap:
source: narratio.artifact.session_recap
required: true

View File

@@ -1,11 +1,8 @@
scriptorium: enabled: true
artifacts: prompt_id: dnd.session_recap
session_recap: profile_id: production-placeholder
enabled: true output_path: artifacts/session-recap.md
prompt_id: dnd.session_recap inputs:
profile_id: production-placeholder transcript:
output_path: artifacts/session-recap.md source: narratio.transcript.final_trimmed
inputs: required: true
transcript:
source: narratio.transcript.final_trimmed
required: true

View File

@@ -1,3 +1,15 @@
config:
sequences:
- destination: [publish, outputs]
key: source
mode: upsert
publish:
outputs:
- source: narratio.transcript.final_markdown
dest: transcripts/final.md
required: false
audita: audita:
proposal_profile: narratio-testing-model-placeholder proposal_profile: narratio-testing-model-placeholder
validation_profile: narratio-testing-validator-placeholder validation_profile: narratio-testing-validator-placeholder
@@ -9,6 +21,7 @@ scriptorium:
player_handout: player_handout:
profile_id: testing-placeholder profile_id: testing-placeholder
testing_notes: testing_notes:
extends: session_recap
enabled: false enabled: false
output_path: artifacts/testing-notes.md output_path: artifacts/testing-notes.md
artifact_families: artifact_families:

View File

@@ -1,13 +1,25 @@
# Copyable production-base/testing-overlay entry point. ConfigKit expands only # ConfigKit assembles these declared sources; destinations define artifact IDs.
# these explicit path and glob imports; Narratio never scans directories itself. config:
configkit:
imports: imports:
- path: conf.d/platform.yml - path: conf.d/platform.yml
required: true
- path: conf.d/storage.yml - path: conf.d/storage.yml
required: true
- path: conf.d/transcript.yml - path: conf.d/transcript.yml
required: true
- path: conf.d/publish.yml - path: conf.d/publish.yml
- glob: artifacts/*.yml required: true
- glob: artifact-families/*.yml - path: conf.d/local.yml
- path: artifacts/session_recap.yml
destination: [scriptorium, artifacts, session_recap]
required: true
- path: artifacts/player_handout.yml
destination: [scriptorium, artifacts, player_handout]
required: true
- dir: artifact-families
pattern: "*.yml"
destination: [scriptorium, artifact_families]
required: true
scriptorium: scriptorium:
binary: scriptorium binary: scriptorium

View File

@@ -0,0 +1,2 @@
inputs:
audio_dir: ../audio

View File

@@ -1,5 +1,7 @@
config:
imports:
- path: session-inputs/local-audio.yml
required: true
session_id: 2026-05-03 session_id: 2026-05-03
date: 2026-05-03 date: 2026-05-03
title: Sample Session title: Sample Session
inputs:
audio_dir: ./audio

6
go.mod
View File

@@ -1,14 +1,14 @@
module gitea.maximumdirect.net/eric/narratio module gitea.maximumdirect.net/eric/narratio
go 1.26.0 go 1.27.0
require ( require (
gitea.maximumdirect.net/eric/ConfigKit v0.4.2
github.com/aws/aws-sdk-go-v2/config v1.32.17 github.com/aws/aws-sdk-go-v2/config v1.32.17
github.com/aws/aws-sdk-go-v2/credentials v1.19.16 github.com/aws/aws-sdk-go-v2/credentials v1.19.16
github.com/aws/aws-sdk-go-v2/service/s3 v1.101.0 github.com/aws/aws-sdk-go-v2/service/s3 v1.101.0
github.com/aws/smithy-go v1.25.1 github.com/aws/smithy-go v1.25.1
github.com/google/go-cmp v0.7.0 github.com/google/go-cmp v0.7.0
go.maximumdirect.net/configkit v1.2.1
golang.org/x/sync v0.22.0 golang.org/x/sync v0.22.0
golang.org/x/sys v0.47.0 golang.org/x/sys v0.47.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
@@ -29,5 +29,5 @@ require (
github.com/aws/aws-sdk-go-v2/service/sso v1.30.17 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.30.17 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.21 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.21 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.42.1 // indirect github.com/aws/aws-sdk-go-v2/service/sts v1.42.1 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect go.yaml.in/yaml/v4 v4.0.0 // indirect
) )

8
go.sum
View File

@@ -1,5 +1,3 @@
gitea.maximumdirect.net/eric/ConfigKit v0.4.2 h1:ZMxmv8pOnLtAx2hFTf8Z+pHKUbR89xErkBhwjr4yK24=
gitea.maximumdirect.net/eric/ConfigKit v0.4.2/go.mod h1:tYWpsrbLyu05r8+1MapWp5fN6ZrX9I8hU2xEPedYmYk=
github.com/aws/aws-sdk-go-v2 v1.41.7 h1:DWpAJt66FmnnaRIOT/8ASTucrvuDPZASqhhLey6tLY8= github.com/aws/aws-sdk-go-v2 v1.41.7 h1:DWpAJt66FmnnaRIOT/8ASTucrvuDPZASqhhLey6tLY8=
github.com/aws/aws-sdk-go-v2 v1.41.7/go.mod h1:4LAfZOPHNVNQEckOACQx60Y8pSRjIkNZQz1w92xpMJc= github.com/aws/aws-sdk-go-v2 v1.41.7/go.mod h1:4LAfZOPHNVNQEckOACQx60Y8pSRjIkNZQz1w92xpMJc=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.10 h1:gx1AwW1Iyk9Z9dD9F4akX5gnN3QZwUB20GGKH/I+Rho= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.10 h1:gx1AwW1Iyk9Z9dD9F4akX5gnN3QZwUB20GGKH/I+Rho=
@@ -38,8 +36,10 @@ github.com/aws/smithy-go v1.25.1 h1:J8ERsGSU7d+aCmdQur5Txg6bVoYelvQJgtZehD12GkI=
github.com/aws/smithy-go v1.25.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc= github.com/aws/smithy-go v1.25.1/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4= go.maximumdirect.net/configkit v1.2.1 h1:f+/6WjNl6CULbMr6ZSVwi4aty9rmuDfJlvpeU7I+HZM=
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= go.maximumdirect.net/configkit v1.2.1/go.mod h1:ewu6blSokUDCMovy8JBXAdXRikGmlHXAQpFghnPWRfs=
go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=

View File

@@ -10,7 +10,7 @@ import (
"strings" "strings"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess" "gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess"
"gitea.maximumdirect.net/eric/narratio/internal/fileops" "gitea.maximumdirect.net/eric/narratio/internal/fileops"
) )

View File

@@ -10,7 +10,7 @@ import (
"testing" "testing"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess" "gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess"
) )

View File

@@ -3,7 +3,7 @@ package notarius
import ( import (
"context" "context"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
// FakeRunner is a configurable in-memory runner for stage tests. // FakeRunner is a configurable in-memory runner for stage tests.

View File

@@ -5,7 +5,7 @@ import (
"context" "context"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
const ReceiptSchemaVersion = "notarius.run-result.v2" const ReceiptSchemaVersion = "notarius.run-result.v2"

View File

@@ -11,7 +11,7 @@ import (
"testing" "testing"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
sharedsubprocess "gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess" sharedsubprocess "gitea.maximumdirect.net/eric/narratio/internal/adapters/subprocess"
) )

View File

@@ -5,7 +5,7 @@ import (
"context" "context"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
const ( const (

View File

@@ -10,7 +10,7 @@ import (
"testing" "testing"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
func TestSubprocessRunnerRunSuccessBuildsDeterministicArgsAndCapturesLogs(t *testing.T) { func TestSubprocessRunnerRunSuccessBuildsDeterministicArgsAndCapturesLogs(t *testing.T) {

View File

@@ -14,7 +14,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/aws/smithy-go" "github.com/aws/smithy-go"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
) )

View File

@@ -3,7 +3,7 @@ package subprocess
import ( import (
"fmt" "fmt"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
// CredentialEnvironment returns captured secret values and names for a child // CredentialEnvironment returns captured secret values and names for a child

View File

@@ -4,7 +4,7 @@ import (
"reflect" "reflect"
"testing" "testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
func TestCredentialEnvironmentUsesCapturedReferences(t *testing.T) { func TestCredentialEnvironmentUsesCapturedReferences(t *testing.T) {

View File

@@ -272,7 +272,7 @@ func TestExecuteAnalyzeRejectsPositionalArgsAndForceFlag(t *testing.T) {
} }
func TestExecuteAnalyzeMissingConfigUsesRunStageLoadingPath(t *testing.T) { func TestExecuteAnalyzeMissingConfigUsesRunStageLoadingPath(t *testing.T) {
deps, missingPath, executor := guardedMissingPipelineDiscovery(t) deps, _, executor := guardedMissingPipelineDiscovery(t)
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := executeWithDependencies([]string{"analyze", "2026-05-03"}, &stdout, &stderr, deps, executor) code := executeWithDependencies([]string{"analyze", "2026-05-03"}, &stdout, &stderr, deps, executor)
@@ -282,8 +282,7 @@ func TestExecuteAnalyzeMissingConfigUsesRunStageLoadingPath(t *testing.T) {
if stdout.Len() != 0 { if stdout.Len() != 0 {
t.Fatalf("stdout = %q, want empty", stdout.String()) t.Fatalf("stdout = %q, want empty", stdout.String())
} }
if got := stderr.String(); !strings.Contains(got, "analyze: no pipeline config path provided") || if got := stderr.String(); !strings.Contains(got, "source.missing") {
!strings.Contains(got, "no default pipeline config found") || !strings.Contains(got, missingPath) {
t.Fatalf("stderr = %q, want pipeline discovery error", stderr.String()) t.Fatalf("stderr = %q, want pipeline discovery error", stderr.String())
} }
} }
@@ -376,7 +375,7 @@ func TestExecutePublishUnknownArtifactFailsValidation(t *testing.T) {
} }
func TestExecutePublishMissingConfigUsesRunStageLoadingPath(t *testing.T) { func TestExecutePublishMissingConfigUsesRunStageLoadingPath(t *testing.T) {
deps, missingPath, executor := guardedMissingPipelineDiscovery(t) deps, _, executor := guardedMissingPipelineDiscovery(t)
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := executeWithDependencies([]string{"publish", "2026-05-03"}, &stdout, &stderr, deps, executor) code := executeWithDependencies([]string{"publish", "2026-05-03"}, &stdout, &stderr, deps, executor)
@@ -386,8 +385,7 @@ func TestExecutePublishMissingConfigUsesRunStageLoadingPath(t *testing.T) {
if stdout.Len() != 0 { if stdout.Len() != 0 {
t.Fatalf("stdout = %q, want empty", stdout.String()) t.Fatalf("stdout = %q, want empty", stdout.String())
} }
if got := stderr.String(); !strings.Contains(got, "publish: no pipeline config path provided") || if got := stderr.String(); !strings.Contains(got, "source.missing") {
!strings.Contains(got, "no default pipeline config found") || !strings.Contains(got, missingPath) {
t.Fatalf("stderr = %q, want pipeline discovery error", stderr.String()) t.Fatalf("stderr = %q, want pipeline discovery error", stderr.String())
} }
} }

View File

@@ -272,7 +272,7 @@ func TestAssembledSplitBundleCommandsUseOneEffectiveFamilyConfiguration(t *testi
}, &diff); err != nil { }, &diff); err != nil {
t.Fatalf("compare profiles: %v", err) t.Fatalf("compare profiles: %v", err)
} }
if !strings.Contains(diff.String(), "audita.proposal_profile") || !strings.Contains(diff.String(), "character_items_arannis.profile_id") { if !strings.Contains(diff.String(), "/audita/proposal_profile") || !strings.Contains(diff.String(), "/character_items_arannis/profile_id") {
t.Fatalf("profile diff = %q, want proposal profile and expanded family changes", diff.String()) t.Fatalf("profile diff = %q, want proposal profile and expanded family changes", diff.String())
} }

View File

@@ -4,16 +4,15 @@ import (
"context" "context"
"io" "io"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
) )
type commandDependencies struct { type commandDependencies struct {
diagnostics io.Writer diagnostics io.Writer
resolvePipelineConfigPath func(string) (string, error) pipelineSearch *configkit.Search
loadPipelineConfig func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error) loadPipelineConfig func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error)
downloadObjectToTemp func(context.Context, storage.ObjectStore, string, string) (string, error)
loadSecretsDir func(string) (*configkit.SecretsReport, error) loadSecretsDir func(string) (*configkit.SecretsReport, error)
secretsBootstrap *secretsBootstrap secretsBootstrap *secretsBootstrap
newObjectStore func(context.Context, *config.Config) (storage.ObjectStore, error) newObjectStore func(context.Context, *config.Config) (storage.ObjectStore, error)
@@ -26,17 +25,11 @@ func normalizeCommandDependencies(deps commandDependencies) commandDependencies
if deps.diagnostics == nil { if deps.diagnostics == nil {
deps.diagnostics = io.Discard deps.diagnostics = io.Discard
} }
if deps.resolvePipelineConfigPath == nil {
deps.resolvePipelineConfigPath = resolvePipelineConfigPath
}
if deps.loadPipelineConfig == nil { if deps.loadPipelineConfig == nil {
deps.loadPipelineConfig = config.LoadPipelineWithOptions deps.loadPipelineConfig = config.LoadPipelineWithOptions
} }
if deps.downloadObjectToTemp == nil {
deps.downloadObjectToTemp = storage.DownloadObjectToTemp
}
if deps.loadSecretsDir == nil { if deps.loadSecretsDir == nil {
deps.loadSecretsDir = configkit.LoadSecretsDir deps.loadSecretsDir = configkit.LoadSecretsIntoEnvironment
} }
if deps.secretsBootstrap == nil { if deps.secretsBootstrap == nil {
deps.secretsBootstrap = &secretsBootstrap{} deps.secretsBootstrap = &secretsBootstrap{}

View File

@@ -13,7 +13,6 @@ import (
"time" "time"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
) )
@@ -70,7 +69,7 @@ func TestExecuteMissingRequiredFlags(t *testing.T) {
{name: "resume removed", args: []string{"resume"}, want: `unknown command: "resume"`}, {name: "resume removed", args: []string{"resume"}, want: `unknown command: "resume"`},
{name: "run-stage missing name", args: []string{"run-stage", "--config", "a", "--session", "b"}, want: "run-stage: expected stage name and session_id"}, {name: "run-stage missing name", args: []string{"run-stage", "--config", "a", "--session", "b"}, want: "run-stage: expected stage name and session_id"},
{name: "run-stage missing session", args: []string{"run-stage", "polish"}, want: "run-stage: expected stage name and session_id"}, {name: "run-stage missing session", args: []string{"run-stage", "polish"}, want: "run-stage: expected stage name and session_id"},
{name: "run missing config uses defaults", args: []string{"run", "2026-05-03", "--session", "session.yml"}, want: "run: no pipeline config path provided", controlledDiscovery: true}, {name: "run missing config uses defaults", args: []string{"run", "2026-05-03", "--session", "session.yml"}, want: "source.missing", controlledDiscovery: true},
} }
for _, tc := range cases { for _, tc := range cases {
@@ -80,9 +79,8 @@ func TestExecuteMissingRequiredFlags(t *testing.T) {
deps := commandDependencies{} deps := commandDependencies{}
executor := pipelineExecutor(executePlan) executor := pipelineExecutor(executePlan)
missingPath := ""
if tc.controlledDiscovery { if tc.controlledDiscovery {
deps, missingPath, executor = guardedMissingPipelineDiscovery(t) deps, _, executor = guardedMissingPipelineDiscovery(t)
} }
code := executeWithDependencies(tc.args, &stdout, &stderr, deps, executor) code := executeWithDependencies(tc.args, &stdout, &stderr, deps, executor)
if code == 0 { if code == 0 {
@@ -94,11 +92,7 @@ func TestExecuteMissingRequiredFlags(t *testing.T) {
if !strings.Contains(stderr.String(), tc.want) { if !strings.Contains(stderr.String(), tc.want) {
t.Fatalf("stderr = %q, want to contain %q", stderr.String(), tc.want) t.Fatalf("stderr = %q, want to contain %q", stderr.String(), tc.want)
} }
if tc.controlledDiscovery {
if got := stderr.String(); !strings.Contains(got, "no default pipeline config found") || !strings.Contains(got, missingPath) {
t.Fatalf("stderr = %q, want controlled searched path %q", got, missingPath)
}
}
}) })
} }
} }
@@ -267,7 +261,7 @@ inputs:
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := Execute([]string{"run-stage", "polish", sessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath, "--force"}, &stdout, &stderr) code := Execute([]string{"run-stage", "polish", sessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath, "--force", "--secrets-dir", secretsDir}, &stdout, &stderr)
if code != 0 { if code != 0 {
t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String()) t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String())
} }
@@ -375,11 +369,7 @@ func TestExecuteUsesDefaultPipelineConfigPathWhenConfigFlagOmitted(t *testing.T)
defer srv.Close() defer srv.Close()
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot, srv.URL) pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot, srv.URL)
originalDefaults := append([]string(nil), config.DefaultPipelineConfigSearchPaths...) withDefaultPipelineCampaignConfigs(t, pipelinePath, campaignPath)
config.DefaultPipelineConfigSearchPaths = []string{pipelinePath}
defer func() {
config.DefaultPipelineConfigSearchPaths = originalDefaults
}()
_ = campaignPath _ = campaignPath
var stdout bytes.Buffer var stdout bytes.Buffer

View File

@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"errors" "errors"
"io"
"path/filepath" "path/filepath"
"reflect" "reflect"
"strings" "strings"
@@ -109,6 +110,148 @@ func TestConfigArtifactsReportsOverlayFamilyContributors(t *testing.T) {
} }
} }
func TestConfigInspectionReportsInheritedCompositeSources(t *testing.T) {
t.Setenv("NARRATIO_CONFIG_INSPECTION_KEY", "synthetic-inspection-secret")
pipelinePath, campaignPath := writeInspectionFamilyConfig(t)
dir := filepath.Dir(pipelinePath)
parentPath := filepath.Join(dir, "families", "parent.yml")
childPath := filepath.Join(dir, "families", "child.yml")
overlayPath := filepath.Join(dir, "overlays", "testing.yml")
mustWriteTestFile(t, pipelinePath, `config:
imports:
- path: families/parent.yml
- path: families/child.yml
workspace:
root: `+filepath.Join(dir, "workspace")+`
campaigns:
root: `+filepath.Join(dir, "campaigns")+`
whisperx:
transcribe_url: https://transcription.example.com/transcribe
audita:
credentials: [NARRATIO_CONFIG_INSPECTION_KEY]
scriptorium:
extends: audita
`)
mustWriteTestFile(t, parentPath, `scriptorium:
artifact_families:
character_meta:
enabled: false
for_each: party.characters
prompt_id: dnd.character_meta
profile_id: production
output_path_pattern: artifacts/characters/{character_id}/meta.md
artifacts:
notes:
enabled: false
prompt_id: dnd.notes
`)
mustWriteTestFile(t, childPath, `scriptorium:
artifact_families:
character_note:
extends: character_meta
profile_id: testing
output_path_pattern: artifacts/characters/{character_id}/note.md
artifacts:
notes:
output_path: artifacts/notes.md
`)
mustWriteTestFile(t, overlayPath, `scriptorium:
artifact_families:
character_note:
prompt_id: dnd.character_note.testing
artifacts:
notes:
output_path: artifacts/notes-testing.md
`)
expandedOverlayPath := filepath.Join(dir, "overlays", "expanded.yml")
mustWriteTestFile(t, expandedOverlayPath, `scriptorium:
extends: null
credentials: [NARRATIO_CONFIG_INSPECTION_KEY]
artifact_families:
character_note:
enabled: false
for_each: party.characters
prompt_id: dnd.character_note.testing
profile_id: testing
output_path_pattern: artifacts/characters/{character_id}/note.md
artifacts:
notes:
output_path: artifacts/notes-testing.md
`)
args := []string{"--config", pipelinePath, "--campaign-file", campaignPath, "--overlay", "testing"}
if err := ConfigValidate(context.Background(), args, io.Discard); err != nil {
t.Fatalf("ConfigValidate() error = %v", err)
}
var effective bytes.Buffer
if err := ConfigShow(context.Background(), args, &effective); err != nil {
t.Fatalf("ConfigShow() error = %v", err)
}
for _, want := range []string{"NARRATIO_CONFIG_INSPECTION_KEY", "character_note_arannis:", "dnd.character_note.testing", "artifacts/characters/arannis/note.md"} {
if !strings.Contains(effective.String(), want) {
t.Errorf("effective show omitted %q:\n%s", want, effective.String())
}
}
if strings.Contains(effective.String(), "synthetic-inspection-secret") {
t.Fatal("effective show exposed a credential value")
}
var catalog bytes.Buffer
if err := ConfigArtifacts(context.Background(), args, &catalog); err != nil {
t.Fatal(err)
}
records := catalogRecordsByKey(t, catalog.String())
notes := records["notes"]
if strings.Contains(catalog.String(), "synthetic-inspection-secret") {
t.Fatal("artifact catalog exposed a credential value")
}
if notes[4] != "artifacts/notes-testing.md" {
t.Fatalf("composed artifact output = %#v", notes)
}
for _, contributor := range []string{parentPath, childPath, overlayPath} {
if !strings.Contains(notes[2], contributor) {
t.Errorf("composed artifact definitions %q omit %q", notes[2], contributor)
}
}
note := records["character_note_arannis"]
if note[4] != "artifacts/characters/arannis/note.md" || note[6] != "character_note" || note[7] != "arannis" {
t.Fatalf("inherited family catalog identity and output = %#v", note)
}
for _, contributor := range []string{parentPath, childPath, overlayPath} {
if !strings.Contains(note[2], contributor) || !strings.Contains(note[8], contributor) {
t.Errorf("family provenance = definitions %q, family sources %q; want %q", note[2], note[8], contributor)
}
}
var sources bytes.Buffer
if err := ConfigSources(context.Background(), args, &sources); err != nil {
t.Fatal(err)
}
for _, want := range []string{
"scriptorium.artifacts.notes.output_path\toverlay\t" + overlayPath,
"scriptorium.artifacts.character_note_arannis.output_path\tfamily\t" + childPath,
"scriptorium.artifacts.character_note_arannis.prompt_id\tfamily\t" + overlayPath,
"scriptorium.credentials\troot\t" + pipelinePath,
} {
if !strings.Contains(sources.String(), want) {
t.Errorf("effective source output missing %q:\n%s", want, sources.String())
}
}
if strings.Contains(sources.String(), "synthetic-inspection-secret") {
t.Fatal("source inspection exposed a credential value")
}
var diff bytes.Buffer
if err := ConfigDiff(context.Background(), []string{"testing", "expanded", "--config", pipelinePath, "--campaign-file", campaignPath}, &diff); err != nil {
t.Fatalf("ConfigDiff() error = %v", err)
}
if diff.String() != "no differences\n" {
t.Fatalf("equivalent inherited/expanded overlays diff = %q", diff.String())
}
if strings.Contains(diff.String(), "synthetic-inspection-secret") {
t.Fatal("configuration diff exposed a credential value")
}
}
func TestConfigArtifactsReportsBaseAndOverlayContributors(t *testing.T) { func TestConfigArtifactsReportsBaseAndOverlayContributors(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
pipelinePath := filepath.Join(dir, "pipeline.yml") pipelinePath := filepath.Join(dir, "pipeline.yml")
@@ -198,7 +341,7 @@ func catalogRecordsByKey(t *testing.T, output string) map[string][]string {
func artifactIdentityPipeline(importPath, inlineKey string) string { func artifactIdentityPipeline(importPath, inlineKey string) string {
document := "workspace:\n root: /srv/narratio\nwhisperx:\n transcribe_url: https://transcription.example.com/transcribe\nscriptorium:\n binary: scriptorium\n" document := "workspace:\n root: /srv/narratio\nwhisperx:\n transcribe_url: https://transcription.example.com/transcribe\nscriptorium:\n binary: scriptorium\n"
if importPath != "" { if importPath != "" {
document = "configkit:\n imports:\n - path: " + importPath + "\n" + document document = "config:\n imports:\n - path: " + importPath + "\n" + document
} }
if inlineKey != "" { if inlineKey != "" {
document += " artifacts:\n " + inlineKey + ":\n enabled: false\n output_path: artifacts/recap.md\n" document += " artifacts:\n " + inlineKey + ":\n enabled: false\n output_path: artifacts/recap.md\n"

View File

@@ -140,6 +140,11 @@ func configSourcesWithDependencies(_ context.Context, args []string, out io.Writ
return err return err
} }
} }
for _, selection := range config.EffectiveEmptyImports(resolved.Pipeline, resolved.Campaign) {
if _, err := fmt.Fprintf(out, "empty_import\t%s\t%s\t%s:%d:%d\n", selection.Path, selection.Selector, selection.Source, selection.Line, selection.Column); err != nil {
return err
}
}
return nil return nil
} }
@@ -178,7 +183,7 @@ func configArtifactsWithDependencies(_ context.Context, args []string, out io.Wr
strings.Join(record.Dependencies, ","), strings.Join(record.Dependencies, ","),
record.FamilyKey, record.FamilyKey,
record.CharacterID, record.CharacterID,
config.NormalizedConfigurationPath(record.FamilySource), strings.Join(normalizedCatalogPaths(record.FamilySources), ","),
config.NormalizedConfigurationPath(record.PartySource), config.NormalizedConfigurationPath(record.PartySource),
} }
for index := range fields { for index := range fields {
@@ -217,7 +222,7 @@ func parseInspectionFlags(command string, args []string, out io.Writer) (inspect
flags.overlay.name = "overlay" flags.overlay.name = "overlay"
fs.Var(&flags.overlay, "overlay", "named pipeline overlay") fs.Var(&flags.overlay, "overlay", "named pipeline overlay")
flags.secretsDir.name = "secrets-dir" flags.secretsDir.name = "secrets-dir"
fs.Var(&flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults beside pipeline.yml)") fs.Var(&flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults to /usr/local/etc/narratio/secrets)")
fs.Usage = func() { fs.Usage = func() {
fmt.Fprintf(out, "Usage: narratio %s [--config <pipeline.yml>] [--campaign <id> | --campaign-file <campaign.yml>] [--overlay <name>] [--secrets-dir <path>]\n\n", command) fmt.Fprintf(out, "Usage: narratio %s [--config <pipeline.yml>] [--campaign <id> | --campaign-file <campaign.yml>] [--overlay <name>] [--secrets-dir <path>]\n\n", command)
fmt.Fprintln(out, "Resolves configuration without a session, workspace, manifest, adapters, or external services.") fmt.Fprintln(out, "Resolves configuration without a session, workspace, manifest, adapters, or external services.")

View File

@@ -11,8 +11,8 @@ import (
"strings" "strings"
"testing" "testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
) )
func TestConfigCommandHelpAndDispatch(t *testing.T) { func TestConfigCommandHelpAndDispatch(t *testing.T) {
@@ -186,24 +186,24 @@ scriptorium:
} }
output := first.String() output := first.String()
for _, want := range []string{ for _, want := range []string{
"changed\taudita.modules\t[\"glossary\",\"grammar\"]\t[]\n", "changed\t/audita/modules\t[\"glossary\",\"grammar\"]\t[]\n",
"changed\tworkspace.cleanup_after_publish\ttrue\tfalse\n", "changed\t/workspace/cleanup_after_publish\ttrue\tfalse\n",
"changed\twhisperx.language\t\"en\"\t\"fr\"\n", "changed\t/whisperx/language\t\"en\"\t\"fr\"\n",
"removed\tscriptorium.artifacts.production_only.enabled\tfalse\n", "removed\t/scriptorium/artifacts/production_only\t{",
"added\tscriptorium.artifacts.testing_only.enabled\tfalse\n", "added\t/scriptorium/artifacts/testing_only\t{",
} { } {
if !strings.Contains(output, want) { if !strings.Contains(output, want) {
t.Fatalf("diff output missing %q:\n%s", want, output) t.Fatalf("diff output missing %q:\n%s", want, output)
} }
} }
if strings.Index(output, "audita.modules") > strings.Index(output, "workspace.cleanup_after_publish") { if strings.Index(output, "/audita/modules") > strings.Index(output, "/workspace/cleanup_after_publish") {
t.Fatalf("diff records are not sorted by path:\n%s", output) t.Fatalf("diff records are not sorted by path:\n%s", output)
} }
var reversed bytes.Buffer var reversed bytes.Buffer
if err := ConfigDiff(context.Background(), []string{"testing", "production", "--config", pipelinePath}, &reversed); err != nil { if err := ConfigDiff(context.Background(), []string{"testing", "production", "--config", pipelinePath}, &reversed); err != nil {
t.Fatalf("reversed ConfigDiff() error = %v", err) t.Fatalf("reversed ConfigDiff() error = %v", err)
} }
if !strings.Contains(reversed.String(), "changed\twhisperx.language\t\"fr\"\t\"en\"\n") { if !strings.Contains(reversed.String(), "changed\t/whisperx/language\t\"fr\"\t\"en\"\n") {
t.Fatalf("reversed diff did not independently resolve overlays:\n%s", reversed.String()) t.Fatalf("reversed diff did not independently resolve overlays:\n%s", reversed.String())
} }
} }
@@ -249,8 +249,8 @@ scriptorium:
t.Fatal(err) t.Fatal(err)
} }
for _, want := range []string{ for _, want := range []string{
"changed\taudita.modules\tnull\t[]\n", "changed\t/audita/modules\tnull\t[]\n",
"changed\tscriptorium.artifacts\tnull\t{}\n", "changed\t/scriptorium/artifacts\tnull\t{}\n",
} { } {
if !strings.Contains(diff.String(), want) { if !strings.Contains(diff.String(), want) {
t.Fatalf("diff output missing %q:\n%s", want, diff.String()) t.Fatalf("diff output missing %q:\n%s", want, diff.String())
@@ -289,9 +289,9 @@ func TestConfigDiffComparesExpandedFamiliesAndPublishRules(t *testing.T) {
} }
output := out.String() output := out.String()
for _, want := range []string{ for _, want := range []string{
"changed\tscriptorium.artifacts.character_note_arannis.enabled\tfalse\ttrue\n", "changed\t/scriptorium/artifacts/character_note_arannis/enabled\tfalse\ttrue\n",
"changed\tscriptorium.artifacts.character_note_arannis.vars.character_name\t\"Arannis\"\t\"wizard\"\n", "changed\t/scriptorium/artifacts/character_note_arannis/vars/character_name\t\"Arannis\"\t\"wizard\"\n",
"changed\tpublish.outputs\t", "changed\t/publish/outputs\t",
} { } {
if !strings.Contains(output, want) { if !strings.Contains(output, want) {
t.Fatalf("family diff output missing %q:\n%s", want, output) t.Fatalf("family diff output missing %q:\n%s", want, output)
@@ -339,23 +339,33 @@ func TestConfigDiffBootstrapsSecretsOnceForBothOverlays(t *testing.T) {
} }
mustWriteSecretFile(t, filepath.Join(secretsDir, secretName), "diff-secret-must-not-appear\n") mustWriteSecretFile(t, filepath.Join(secretsDir, secretName), "diff-secret-must-not-appear\n")
bootstrapCalls := 0 bootstrapCalls := 0
var loadedPaths []string
var diagnostics bytes.Buffer var diagnostics bytes.Buffer
deps := commandDependencies{loadSecretsDir: func(got string) (*configkit.SecretsReport, error) { deps := commandDependencies{loadSecretsDir: func(got string) (*configkit.SecretsReport, error) {
bootstrapCalls++ bootstrapCalls++
if got != secretsDir { if got != secretsDir {
t.Fatalf("secrets directory = %q, want %q", got, secretsDir) t.Fatalf("secrets directory = %q, want %q", got, secretsDir)
} }
return configkit.LoadSecretsDir(got) return configkit.LoadSecretsIntoEnvironment(got)
}, diagnostics: &diagnostics} }, diagnostics: &diagnostics}
search := configkit.SearchPaths(pipelinePath)
deps.pipelineSearch = &search
deps.loadPipelineConfig = func(path string, opts config.PipelineLoadOptions) (*config.PipelineConfig, error) {
loadedPaths = append(loadedPaths, path)
return config.LoadPipelineWithOptions(path, opts)
}
if err := configDiffWithDependencies(context.Background(), []string{ if err := configDiffWithDependencies(context.Background(), []string{
"production", "testing", "--config", pipelinePath, "--secrets-dir", secretsDir, "production", "testing", "--secrets-dir", secretsDir,
}, io.Discard, deps); err != nil { }, io.Discard, deps); err != nil {
t.Fatalf("config diff: %v", err) t.Fatalf("config diff: %v", err)
} }
if bootstrapCalls != 1 { if bootstrapCalls != 1 {
t.Fatalf("bootstrap calls = %d, want 1", bootstrapCalls) t.Fatalf("bootstrap calls = %d, want 1", bootstrapCalls)
} }
if len(loadedPaths) != 2 || loadedPaths[0] != "" || loadedPaths[1] != pipelinePath {
t.Fatalf("pipeline load paths = %q, want discovery then selected root %q", loadedPaths, pipelinePath)
}
if got := diagnostics.String(); strings.Count(got, `name="`+secretName+`"`) != 1 { if got := diagnostics.String(); strings.Count(got, `name="`+secretName+`"`) != 1 {
t.Fatalf("bootstrap report count = %d, want 1; diagnostics = %q", strings.Count(got, `name="`+secretName+`"`), got) t.Fatalf("bootstrap report count = %d, want 1; diagnostics = %q", strings.Count(got, `name="`+secretName+`"`), got)
} }
@@ -476,7 +486,7 @@ func TestConfigCommandsInspectMaintainedSplitBundleWithoutRuntimeState(t *testin
if err := ConfigDiff(context.Background(), []string{"default", "testing", "--config", pipelinePath, "--campaign-file", campaignPath}, &diff); err != nil { if err := ConfigDiff(context.Background(), []string{"default", "testing", "--config", pipelinePath, "--campaign-file", campaignPath}, &diff); err != nil {
t.Fatalf("ConfigDiff() error = %v", err) t.Fatalf("ConfigDiff() error = %v", err)
} }
if !strings.Contains(diff.String(), "audita.proposal_profile") { if !strings.Contains(diff.String(), "/audita/proposal_profile") {
t.Fatalf("split bundle overlay diff = %q, want proposal profile change", diff.String()) t.Fatalf("split bundle overlay diff = %q, want proposal profile change", diff.String())
} }
if _, err := os.Stat(workspacePath); !os.IsNotExist(err) { if _, err := os.Stat(workspacePath); !os.IsNotExist(err) {
@@ -572,7 +582,7 @@ func TestConfigValidateReportsCanonicalPartyAndImportErrors(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
rootPath := filepath.Join(dir, "pipeline.yml") rootPath := filepath.Join(dir, "pipeline.yml")
mustWriteTestFile(t, rootPath, `configkit: mustWriteTestFile(t, rootPath, `config:
imports: imports:
- path: conf.yml - path: conf.yml
workspace: workspace:
@@ -673,7 +683,7 @@ func TestConfigSourcesAttributesInferredArtifactDependencies(t *testing.T) {
pipelinePath := filepath.Join(dir, "pipeline.yml") pipelinePath := filepath.Join(dir, "pipeline.yml")
inputPath := filepath.Join(dir, "input-only.yml") inputPath := filepath.Join(dir, "input-only.yml")
overlayPath := filepath.Join(dir, "overlays", "testing.yml") overlayPath := filepath.Join(dir, "overlays", "testing.yml")
mustWriteTestFile(t, pipelinePath, `configkit: mustWriteTestFile(t, pipelinePath, `config:
imports: imports:
- path: input-only.yml - path: input-only.yml
workspace: workspace:
@@ -733,7 +743,7 @@ func TestConfigSourcesReportsRootImportOverlayAndDefaultOwnership(t *testing.T)
rootPath := filepath.Join(dir, "pipeline.yml") rootPath := filepath.Join(dir, "pipeline.yml")
importPath := filepath.Join(dir, "base.yml") importPath := filepath.Join(dir, "base.yml")
overlayPath := filepath.Join(dir, "overlays", "testing.yml") overlayPath := filepath.Join(dir, "overlays", "testing.yml")
mustWriteTestFile(t, rootPath, `configkit: mustWriteTestFile(t, rootPath, `config:
imports: imports:
- path: base.yml - path: base.yml
workspace: workspace:
@@ -813,3 +823,104 @@ characters:
`) `)
return pipelinePath, campaignPath return pipelinePath, campaignPath
} }
func TestNativeBundleInspectionAndExecutionAgree(t *testing.T) {
examples, err := filepath.Abs(filepath.Join("..", "..", "examples"))
if err != nil {
t.Fatal(err)
}
bundle := t.TempDir()
if err := os.CopyFS(bundle, os.DirFS(examples)); err != nil {
t.Fatal(err)
}
root := filepath.Join(bundle, "production-testing")
pipeline := filepath.Join(root, "narratio.yml")
if err := os.Rename(filepath.Join(root, "pipeline.yml"), pipeline); err != nil {
t.Fatal(err)
}
f, err := os.OpenFile(pipeline, os.O_APPEND|os.O_WRONLY, 0)
if err != nil {
t.Fatal(err)
}
if _, err := f.WriteString("\naudita:\n credentials: [NARRATIO_BUNDLE_TEST_KEY]\n"); err != nil {
t.Fatal(err)
}
if err := f.Close(); err != nil {
t.Fatal(err)
}
const secretName = "NARRATIO_BUNDLE_TEST_KEY"
const secretValue = "synthetic-bundle-secret"
restoreEnvAfterTest(t, secretName)
if err := os.Unsetenv(secretName); err != nil {
t.Fatal(err)
}
secrets := filepath.Join(bundle, "secrets")
mustWriteSecretFile(t, filepath.Join(secrets, secretName), secretValue)
t.Chdir(root)
campaign := filepath.Join(bundle, "campaigns", "sample-campaign", "campaign.yml")
common := []string{"--campaign-file", campaign, "--secrets-dir", secrets}
for _, tc := range []struct {
name string
run func(context.Context, []string, io.Writer) error
want []string
}{
{"validate", ConfigValidate, []string{pipeline}},
{"show", ConfigShow, []string{"NARRATIO_BUNDLE_TEST_KEY", "character_meta_arannis"}},
{"sources", ConfigSources, []string{"empty_import", "brenna.yml"}},
{"artifacts", ConfigArtifacts, []string{"session_recap", "character_meta_arannis"}},
} {
var out bytes.Buffer
if err := tc.run(context.Background(), common, &out); err != nil {
t.Fatalf("%s: %v", tc.name, err)
}
for _, want := range tc.want {
if !strings.Contains(out.String(), want) {
t.Errorf("%s output missing %q: %s", tc.name, want, out.String())
}
}
if strings.Contains(out.String(), secretValue) {
t.Errorf("%s exposed credential value", tc.name)
}
}
var diff bytes.Buffer
args := append([]string{"default", "testing"}, common...)
if err := ConfigDiff(context.Background(), args, &diff); err != nil {
t.Fatal(err)
}
if !strings.Contains(diff.String(), "/audita/proposal_profile") || strings.Contains(diff.String(), secretValue) {
t.Fatalf("unexpected diff: %s", diff.String())
}
workspace := filepath.Join(root, "conf.d", "workspace")
if _, err := os.Stat(workspace); !os.IsNotExist(err) {
t.Fatalf("inspection created workspace: %v", err)
}
var execution *config.Config
executor := func(_ context.Context, cfg *config.Config, _ BoundedPlan, _ RunOptions) (*RunSummary, error) {
execution = cfg
return &RunSummary{SessionID: "2026-05-03"}, nil
}
runArgs := append([]string{"2026-05-03", "--session", filepath.Join(bundle, "session.local-audio.yml"), "--overlay", "testing"}, common...)
var plan bytes.Buffer
planArgs := append(append([]string{}, runArgs...), "--from", "prepare", "--through", "prepare")
if err := Plan(context.Background(), planArgs, &plan); err != nil {
t.Fatal(err)
}
if !strings.Contains(plan.String(), "prepare: run") {
t.Fatalf("unexpected plan: %s", plan.String())
}
if _, err := os.Stat(workspace); !os.IsNotExist(err) {
t.Fatalf("plan created workspace: %v", err)
}
if err := runWithPipelineExecutor(context.Background(), runArgs, io.Discard, executor); err != nil {
t.Fatal(err)
}
if execution == nil || execution.Session.Inputs.AudioDir != filepath.Join(bundle, "audio") || execution.Campaign.Inputs.PartyFile != filepath.Join(bundle, "campaigns", "sample-campaign", "party.yml") {
t.Fatalf("execution did not resolve imported session and campaign resources: %+v", execution)
}
if execution.Pipeline.Audita.ProposalProfile != "narratio-testing-model-placeholder" {
t.Fatalf("execution did not use the inspected overlay: %q", execution.Pipeline.Audita.ProposalProfile)
}
if _, ok := execution.Pipeline.Scriptorium.Artifacts["character_meta_arannis"]; !ok {
t.Fatal("execution did not expand the inspected party family")
}
}

View File

@@ -2,14 +2,16 @@ package app
import ( import (
"context" "context"
"encoding/json"
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"io" "io"
"sort"
"strings" "strings"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
"gopkg.in/yaml.v3"
) )
type configDiffFlags struct { type configDiffFlags struct {
@@ -30,13 +32,6 @@ type configDiffResolved struct {
right *inspectionConfig right *inspectionConfig
} }
type configDiffRecord struct {
Kind string
Path string
Left string
Right string
}
// ConfigDiff compares two explicitly selected overlays through the same // ConfigDiff compares two explicitly selected overlays through the same
// read-only configuration resolution boundary used by config validate, show, // read-only configuration resolution boundary used by config validate, show,
// and sources. Differences describe normalized effective values rather than // and sources. Differences describe normalized effective values rather than
@@ -57,43 +52,42 @@ func configDiffWithDependencies(_ context.Context, args []string, out io.Writer,
if err != nil { if err != nil {
return fmt.Errorf("config diff: %w", err) return fmt.Errorf("config diff: %w", err)
} }
leftValues, err := config.EffectivePipelineValues(resolved.left.Pipeline) differences, err := config.DiffEffectivePipelines(resolved.left.Pipeline, resolved.right.Pipeline)
if err != nil {
return fmt.Errorf("config diff: project left effective configuration: %w", err)
}
rightValues, err := config.EffectivePipelineValues(resolved.right.Pipeline)
if err != nil {
return fmt.Errorf("config diff: project right effective configuration: %w", err)
}
records, err := diffEffectivePipelineValues(leftValues, rightValues)
if err != nil { if err != nil {
return fmt.Errorf("config diff: %w", err) return fmt.Errorf("config diff: %w", err)
} }
leftDigest := config.EffectivePipelineDigest(resolved.left.Pipeline) if len(differences) == 0 {
rightDigest := config.EffectivePipelineDigest(resolved.right.Pipeline)
if len(records) == 0 {
if leftDigest != rightDigest {
return fmt.Errorf("internal error: effective pipeline digests differ without a semantic difference")
}
_, err := fmt.Fprintln(out, "no differences") _, err := fmt.Fprintln(out, "no differences")
return err return err
} }
for _, record := range records { for _, difference := range differences {
switch record.Kind { kind := "changed"
case "added": if !difference.Left.Present {
if _, err := fmt.Fprintf(out, "added\t%s\t%s\n", record.Path, record.Right); err != nil { kind = "added"
}
if !difference.Right.Present {
kind = "removed"
}
fields := []string{kind, difference.Path.String()}
if difference.Left.Present {
value, err := compactSnapshot(difference.Left)
if err != nil {
return err return err
} }
case "removed": fields = append(fields, value)
if _, err := fmt.Fprintf(out, "removed\t%s\t%s\n", record.Path, record.Left); err != nil { }
if difference.Right.Present {
value, err := compactSnapshot(difference.Right)
if err != nil {
return err return err
} }
case "changed": fields = append(fields, value)
if _, err := fmt.Fprintf(out, "changed\t%s\t%s\t%s\n", record.Path, record.Left, record.Right); err != nil { }
return err if difference.HiddenChanged {
} fields = append(fields, "hidden_changed=true")
default: }
return fmt.Errorf("internal error: unsupported difference kind %q", record.Kind) if _, err := fmt.Fprintln(out, strings.Join(fields, "\t")); err != nil {
return err
} }
} }
return nil return nil
@@ -111,7 +105,7 @@ func parseConfigDiffRequest(args []string, out io.Writer) (configDiffRequest, er
fs.Var(&request.flags.pipelinePath, "config", "path to pipeline.yml (optional; defaults searched)") fs.Var(&request.flags.pipelinePath, "config", "path to pipeline.yml (optional; defaults searched)")
fs.Var(&request.flags.campaignPath, "campaign", "campaign ID") fs.Var(&request.flags.campaignPath, "campaign", "campaign ID")
fs.Var(&request.flags.campaignFilePath, "campaign-file", "path to campaign.yml") fs.Var(&request.flags.campaignFilePath, "campaign-file", "path to campaign.yml")
fs.Var(&request.flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults beside pipeline.yml)") fs.Var(&request.flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults to /usr/local/etc/narratio/secrets)")
fs.Usage = func() { fs.Usage = func() {
fmt.Fprintln(out, "Usage: narratio config diff <left-overlay> <right-overlay> [--config <pipeline.yml>] [--campaign <id> | --campaign-file <campaign.yml>] [--secrets-dir <path>]") fmt.Fprintln(out, "Usage: narratio config diff <left-overlay> <right-overlay> [--config <pipeline.yml>] [--campaign <id> | --campaign-file <campaign.yml>] [--secrets-dir <path>]")
fmt.Fprintln(out) fmt.Fprintln(out)
@@ -179,7 +173,7 @@ func resolveConfigDiff(request configDiffRequest, deps commandDependencies) (*co
if err != nil { if err != nil {
return nil, fmt.Errorf("load left pipeline overlay: %w", err) return nil, fmt.Errorf("load left pipeline overlay: %w", err)
} }
_, rightPipeline, err := loadPipelineConfigWithDependencies(request.flags.pipelinePath.value, config.PipelineLoadOptions{Overlay: &request.rightOverlay}, request.flags.secretsDir.pointer(), deps) _, rightPipeline, err := loadPipelineConfigWithDependencies(pipelinePath, config.PipelineLoadOptions{Overlay: &request.rightOverlay}, request.flags.secretsDir.pointer(), deps)
if err != nil { if err != nil {
return nil, fmt.Errorf("load right pipeline overlay: %w", err) return nil, fmt.Errorf("load right pipeline overlay: %w", err)
} }
@@ -264,50 +258,14 @@ func resolveSharedDiffCampaignPath(left, right *config.PipelineConfig, flags con
return leftPath, nil return leftPath, nil
} }
func diffEffectivePipelineValues(left, right []config.EffectivePipelineValueRecord) ([]configDiffRecord, error) { func compactSnapshot(snapshot configkit.ValueSnapshot) (string, error) {
leftByPath, err := effectivePipelineValueMap("left", left) var value any
if err := yaml.Unmarshal([]byte(snapshot.YAML), &value); err != nil {
return "", fmt.Errorf("decode safe diff value: %w", err)
}
encoded, err := json.Marshal(value)
if err != nil { if err != nil {
return nil, err return "", fmt.Errorf("encode safe diff value: %w", err)
} }
rightByPath, err := effectivePipelineValueMap("right", right) return string(encoded), nil
if err != nil {
return nil, err
}
paths := make([]string, 0, len(leftByPath)+len(rightByPath))
seen := make(map[string]struct{}, len(leftByPath)+len(rightByPath))
for path := range leftByPath {
seen[path] = struct{}{}
paths = append(paths, path)
}
for path := range rightByPath {
if _, exists := seen[path]; !exists {
paths = append(paths, path)
}
}
sort.Strings(paths)
records := make([]configDiffRecord, 0)
for _, path := range paths {
leftValue, leftExists := leftByPath[path]
rightValue, rightExists := rightByPath[path]
switch {
case !leftExists:
records = append(records, configDiffRecord{Kind: "added", Path: path, Right: rightValue})
case !rightExists:
records = append(records, configDiffRecord{Kind: "removed", Path: path, Left: leftValue})
case leftValue != rightValue:
records = append(records, configDiffRecord{Kind: "changed", Path: path, Left: leftValue, Right: rightValue})
}
}
return records, nil
}
func effectivePipelineValueMap(side string, records []config.EffectivePipelineValueRecord) (map[string]string, error) {
values := make(map[string]string, len(records))
for _, record := range records {
if _, exists := values[record.Path]; exists {
return nil, fmt.Errorf("internal error: %s effective configuration has duplicate path %q", side, record.Path)
}
values[record.Path] = record.Value
}
return values, nil
} }

View File

@@ -2,8 +2,11 @@ package app
import ( import (
"context" "context"
"crypto/sha256"
"encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -59,12 +62,12 @@ func loadCommandConfigWithDependencies(ctx context.Context, pipelineFlag, campai
return retainedCommandConfig(cfg), nil return retainedCommandConfig(cfg), nil
} }
discoveredSession, err := discoverSessionConfigPathWithCandidates(config.DefaultSessionConfigSearchPaths) discoveredSession, discoveredPath, err := config.DiscoverSession(config.DefaultSessionConfigSearchPaths, sessionOpts)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if discoveredSession.Path != "" { if discoveredSession != nil {
cfg, err := config.LoadSessionWithPipelineCampaignOptions(*base, discoveredSession.Path, sessionOpts) cfg, err := config.ResolveLoadedPipelineCampaign(*base, discoveredPath, discoveredSession, config.SessionSource{Source: "session_config", LocalPath: discoveredPath})
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -73,7 +76,7 @@ func loadCommandConfigWithDependencies(ctx context.Context, pipelineFlag, campai
sessionID := strings.TrimSpace(sessionOpts.SessionID) sessionID := strings.TrimSpace(sessionOpts.SessionID)
if sessionID == "" { if sessionID == "" {
return nil, missingSessionConfigError(discoveredSession.Searched, "remote session loading requires a session_id") return nil, missingSessionConfigError(config.DefaultSessionConfigSearchPaths, "remote session loading requires a session_id")
} }
rootPrefix := "" rootPrefix := ""
@@ -88,27 +91,41 @@ func loadCommandConfigWithDependencies(ctx context.Context, pipelineFlag, campai
} }
store, err := newCommandObjectStoreWithDependencies(ctx, partialCfg, nil, deps) store, err := newCommandObjectStoreWithDependencies(ctx, partialCfg, nil, deps)
if err != nil { if err != nil {
return nil, missingSessionConfigError(discoveredSession.Searched, fmt.Sprintf("remote session %q unavailable: %v", remoteKey, err)) return nil, missingSessionConfigError(config.DefaultSessionConfigSearchPaths, fmt.Sprintf("remote session %q unavailable: %v", remoteKey, err))
} }
sessionInfo, err := findRemoteSessionConfig(ctx, store, sessionPrefix, remoteKey) sessionInfo, checksum, body, err := findRemoteSessionConfig(ctx, store, sessionPrefix, remoteKey, config.CampaignID(base.Campaign), sessionID)
if err != nil { if err != nil {
return nil, missingSessionConfigError(discoveredSession.Searched, err.Error()) return nil, missingSessionConfigError(config.DefaultSessionConfigSearchPaths, err.Error())
} }
sessionTempPath, err := deps.downloadObjectToTemp(ctx, store, remoteKey, "narratio-session-*.yml") defer body.Close()
remoteKey = sessionInfo.Key
temporary, err := os.CreateTemp("", "narratio-session-*.yml")
if err != nil { if err != nil {
return nil, missingSessionConfigError(discoveredSession.Searched, fmt.Sprintf("remote session %q download failed: %v", remoteKey, err)) return nil, missingSessionConfigError(config.DefaultSessionConfigSearchPaths, fmt.Sprintf("remote session %q download failed: %v", remoteKey, err))
} }
sessionTempPath := temporary.Name()
cleanup = func() error { cleanup = func() error {
if err := fileops.RemoveAllUnderRoot(filepath.Dir(sessionTempPath), sessionTempPath); err != nil { if err := fileops.RemoveAllUnderRoot(filepath.Dir(sessionTempPath), sessionTempPath); err != nil {
return fmt.Errorf("remove downloaded remote session config: %w", err) return fmt.Errorf("remove downloaded remote session config: %w", err)
} }
return nil return nil
} }
_, copyErr := io.Copy(temporary, body)
closeErr := temporary.Close()
if err := errors.Join(copyErr, closeErr); err != nil {
return nil, fmt.Errorf("download remote session %q: %w", remoteKey, err)
}
sessionBytes, err := os.ReadFile(sessionTempPath) sessionBytes, err := os.ReadFile(sessionTempPath)
if err != nil { if err != nil {
return nil, fmt.Errorf("read downloaded remote session config: %w", err) return nil, fmt.Errorf("read downloaded remote session config: %w", err)
} }
if checksum != "" {
digest := sha256.Sum256(sessionBytes)
if !strings.EqualFold(hex.EncodeToString(digest[:]), checksum) || int64(len(sessionBytes)) != sessionInfo.Size {
return nil, fmt.Errorf("remote session %q does not match its committed checksum or size", remoteKey)
}
}
sessionCfg, err := config.LoadSessionBytesWithOptions("s3://"+s3BucketName(base.Pipeline)+"/"+remoteKey, sessionBytes, sessionOpts) sessionCfg, err := config.LoadSessionBytesWithOptions("s3://"+s3BucketName(base.Pipeline)+"/"+remoteKey, sessionBytes, sessionOpts)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -163,35 +180,65 @@ func loadPipelineCampaignConfigWithDependencies(pipelineFlag, campaignFlag, camp
func loadPipelineConfigWithDependencies(pipelineFlag string, opts config.PipelineLoadOptions, secretsDir *string, deps commandDependencies) (string, *config.PipelineConfig, error) { func loadPipelineConfigWithDependencies(pipelineFlag string, opts config.PipelineLoadOptions, secretsDir *string, deps commandDependencies) (string, *config.PipelineConfig, error) {
deps = normalizeCommandDependencies(deps) deps = normalizeCommandDependencies(deps)
resolvedPipelinePath, err := deps.resolvePipelineConfigPath(pipelineFlag)
if err != nil {
return "", nil, err
}
if !deps.secretsBootstrap.selectionSet { if !deps.secretsBootstrap.selectionSet {
deps.secretsBootstrap.selection = secretsDir deps.secretsBootstrap.selection = secretsDir
deps.secretsBootstrap.selectionSet = true deps.secretsBootstrap.selectionSet = true
} }
if err := deps.secretsBootstrap.load(resolvedPipelinePath, deps.loadSecretsDir, deps.diagnostics); err != nil { if err := deps.secretsBootstrap.load(deps.loadSecretsDir, deps.diagnostics); err != nil {
return "", nil, err return "", nil, err
} }
pipelineCfg, err := deps.loadPipelineConfig(resolvedPipelinePath, opts) opts.Search = deps.pipelineSearch
pipelineCfg, err := deps.loadPipelineConfig(strings.TrimSpace(pipelineFlag), opts)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
resolvedPipelinePath := config.EffectivePipelineRootPath(pipelineCfg)
if resolvedPipelinePath == "" {
resolvedPipelinePath = strings.TrimSpace(pipelineFlag)
}
return resolvedPipelinePath, pipelineCfg, nil return resolvedPipelinePath, pipelineCfg, nil
} }
func findRemoteSessionConfig(ctx context.Context, store storage.ObjectStore, sessionPrefix, remoteKey string) (storage.ObjectInfo, error) { func findRemoteSessionConfig(ctx context.Context, store storage.ObjectStore, sessionPrefix, remoteKey, campaign, sessionID string) (storage.ObjectInfo, string, io.ReadCloser, error) {
objects, err := store.List(ctx, sessionPrefix) authored, err := store.Exists(ctx, remoteKey)
if err != nil { if err != nil {
return storage.ObjectInfo{}, fmt.Errorf("remote session %q list failed: %w", remoteKey, err) return storage.ObjectInfo{}, "", nil, fmt.Errorf("check authored session %q: %w", remoteKey, err)
} }
for _, obj := range objects { var selected *artifacts.RemoteArtifact
if obj.Key == remoteKey { if !authored {
return obj, nil current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{ExpectedCampaign: campaign, ExpectedSessionID: sessionID, ValidateRunID: true})
if err == nil {
for _, item := range current.Commit.Artifacts {
if item.Type == artifacts.RemoteArtifactTypeRunFile && item.Source == "run:prepare/inputs/session.yml" {
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, item.DestinationKey)
if err != nil || "run:"+identity.RelativePath != item.Source {
return storage.ObjectInfo{}, "", nil, fmt.Errorf("committed session source does not match its object key")
}
copy := item
selected = &copy
remoteKey = item.DestinationKey
break
}
}
} else if !errors.Is(err, artifacts.ErrCurrentCommitPointerMissing) {
return storage.ObjectInfo{}, "", nil, fmt.Errorf("load remote session selection: %w", err)
} }
} }
return storage.ObjectInfo{}, fmt.Errorf("remote session %q not found", remoteKey) info, body, err := store.Read(ctx, remoteKey)
if err != nil {
if errors.Is(err, os.ErrNotExist) {
return storage.ObjectInfo{}, "", nil, fmt.Errorf("remote session %q not found: %w", remoteKey, err)
}
return storage.ObjectInfo{}, "", nil, fmt.Errorf("read remote session %q: %w", remoteKey, err)
}
if selected != nil {
if info.Size != selected.Size || strings.TrimSpace(info.ETag) != selected.Generation {
_ = body.Close()
return storage.ObjectInfo{}, "", nil, fmt.Errorf("remote session %q differs from committed object identity", remoteKey)
}
return info, selected.SHA256, body, nil
}
return info, "", body, nil
} }
func s3BucketName(cfg *config.PipelineConfig) string { func s3BucketName(cfg *config.PipelineConfig) string {

View File

@@ -0,0 +1,40 @@
package app
import (
"bytes"
"context"
"path/filepath"
"strings"
"testing"
)
func TestConfigDiffUsesEscapedPointersAndAtomicLists(t *testing.T) {
dir := t.TempDir()
root := filepath.Join(dir, "pipeline.yml")
mustWriteTestFile(t, root, "whisperx: {transcribe_url: 'https://example.test/transcribe'}\nscriptorium:\n artifacts:\n recap:\n enabled: false\n output_path: artifacts/recap.md\n vars: {'a/b~c': before}\naudita: {modules: [glossary, grammar]}\n")
mustWriteTestFile(t, filepath.Join(dir, "overlays", "changed.yml"), "scriptorium:\n artifacts:\n recap:\n vars: {'a/b~c': after}\naudita: {modules: [glossary, homophones]}\n")
var output bytes.Buffer
if err := ConfigDiff(context.Background(), []string{"default", "changed", "--config", root}, &output); err != nil {
t.Fatal(err)
}
for _, want := range []string{"changed\t/audita/modules\t[\"glossary\",\"grammar\"]\t[\"glossary\",\"homophones\"]", "changed\t/scriptorium/artifacts/recap/vars/a~1b~0c\t\"before\"\t\"after\""} {
if !strings.Contains(output.String(), want) {
t.Fatalf("diff lacks %q: %s", want, output.String())
}
}
}
func TestConfigSourcesReportsEmptyOptionalImportAndNormalization(t *testing.T) {
dir := t.TempDir()
root := filepath.Join(dir, "pipeline.yml")
mustWriteTestFile(t, root, "config:\n imports:\n - path: absent.yml\nworkspace: {root: ./work}\nwhisperx: {transcribe_url: 'https://example.test/transcribe'}\n")
var output bytes.Buffer
if err := ConfigSources(context.Background(), []string{"--config", root}, &output); err != nil {
t.Fatal(err)
}
for _, want := range []string{"empty_import\t/config/imports/0\tpath\t" + root, "workspace.root\tresolution\tresolution", "workspace.root\troot\t" + root} {
if !strings.Contains(output.String(), want) {
t.Fatalf("sources lack %q: %s", want, output.String())
}
}
}

View File

@@ -13,7 +13,6 @@ import (
"testing" "testing"
"time" "time"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius" "gitea.maximumdirect.net/eric/narratio/internal/adapters/notarius"
"gitea.maximumdirect.net/eric/narratio/internal/artifactmodel" "gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy" "gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
@@ -21,6 +20,7 @@ import (
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest" "gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage" "gitea.maximumdirect.net/eric/narratio/internal/stage"
configkit "go.maximumdirect.net/configkit"
) )
type materializingNotariusRunner struct { type materializingNotariusRunner struct {
@@ -314,7 +314,11 @@ characters:
if err != nil { if err != nil {
t.Fatalf("ReadFile(prepared party) error = %v", err) t.Fatalf("ReadFile(prepared party) error = %v", err)
} }
if string(contents) != string(partyBytes) || partyPath == cfg.Party.Source.Path { wantParty, err := partyDocument.YAML()
if err != nil {
t.Fatal(err)
}
if string(contents) != string(wantParty) || partyPath == cfg.Party.Source.Path {
t.Fatalf("prepared party path=%q contents=%q source=%q", partyPath, contents, cfg.Party.Source.Path) t.Fatalf("prepared party path=%q contents=%q source=%q", partyPath, contents, cfg.Party.Source.Path)
} }
} }

View File

@@ -37,7 +37,7 @@ func addCommonConfigFlags(fs *flag.FlagSet, flags *commonConfigFlags) {
flags.overlay.name = "overlay" flags.overlay.name = "overlay"
fs.Var(&flags.overlay, "overlay", "named pipeline overlay") fs.Var(&flags.overlay, "overlay", "named pipeline overlay")
flags.secretsDir.name = "secrets-dir" flags.secretsDir.name = "secrets-dir"
fs.Var(&flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults beside pipeline.yml)") fs.Var(&flags.secretsDir, "secrets-dir", "secrets directory (optional; defaults to /usr/local/etc/narratio/secrets)")
} }
func (f commonConfigFlags) sessionOptions() config.SessionLoadOptions { func (f commonConfigFlags) sessionOptions() config.SessionLoadOptions {

View File

@@ -164,7 +164,7 @@ func TestExecuteSessionInitRequiresSessionID(t *testing.T) {
} }
func TestExecuteSessionInitMissingDefaultConfigReportsSearchedPaths(t *testing.T) { func TestExecuteSessionInitMissingDefaultConfigReportsSearchedPaths(t *testing.T) {
deps, missingPath, executor := guardedMissingPipelineDiscovery(t) deps, _, executor := guardedMissingPipelineDiscovery(t)
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
@@ -175,8 +175,7 @@ func TestExecuteSessionInitMissingDefaultConfigReportsSearchedPaths(t *testing.T
if stdout.Len() != 0 { if stdout.Len() != 0 {
t.Fatalf("stdout = %q, want empty", stdout.String()) t.Fatalf("stdout = %q, want empty", stdout.String())
} }
if got := stderr.String(); !strings.Contains(got, "session init: no pipeline config path provided") || if got := stderr.String(); !strings.Contains(got, "source.missing") {
!strings.Contains(got, "no default pipeline config found") || !strings.Contains(got, missingPath) {
t.Fatalf("stderr = %q, want default pipeline searched-path error", stderr.String()) t.Fatalf("stderr = %q, want default pipeline searched-path error", stderr.String())
} }
} }
@@ -203,7 +202,7 @@ func TestExecuteSessionInitRemoteLoadsSecretsBeforeObjectStoreInit(t *testing.T)
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := executeWithDependencies([]string{"session", "init", "2026-06-07", "--remote"}, &stdout, &stderr, deps, executePlan) code := executeWithDependencies([]string{"session", "init", "2026-06-07", "--remote", "--secrets-dir", secretsDir}, &stdout, &stderr, deps, executePlan)
if code != 0 { if code != 0 {
t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String()) t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String())
} }
@@ -242,22 +241,41 @@ inputs:
t.Fatalf("read generated session: %v", err) t.Fatalf("read generated session: %v", err)
} }
got := string(data) got := string(data)
for _, want := range []string{ generated, err := config.LoadSession(outputPath)
`session_id: "2026-06-07"`, if err != nil {
`previous_session_id: "2026-05-31"`, t.Fatal(err)
`date: "2026-06-07"`, }
`title: "The Black Cabin"`, if generated.SessionID != "2026-06-07" || generated.PreviousSessionID != "2026-05-31" || generated.Date != "2026-06-07" || generated.Title != "The Black Cabin" || generated.Inputs.AudioS3 == nil || generated.Inputs.AudioS3.Prefix != "audio/" {
`prefix: "audio/"`, t.Fatalf("generated session = %#v", generated)
} {
if !strings.Contains(got, want) {
t.Fatalf("generated session = %q, want %q", got, want)
}
} }
if strings.Contains(got, "{{") { if strings.Contains(got, "{{") {
t.Fatalf("generated session still contains template placeholder: %q", got) t.Fatalf("generated session still contains template placeholder: %q", got)
} }
} }
func TestExecuteSessionInitUsesImportedTemplateLocation(t *testing.T) {
pipeline, campaign, _ := writeValidConfigFiles(t, t.TempDir())
dir := filepath.Dir(campaign)
original, err := os.ReadFile(campaign)
if err != nil {
t.Fatal(err)
}
mustWriteTestFile(t, filepath.Join(dir, "fragments", "template-settings.yml"), "session_template_file: templates/session.yml\n")
mustWriteTestFile(t, filepath.Join(dir, "fragments", "templates", "session.yml"), "session_id: '{{ session_id }}'\ninputs:\n audio_s3: {prefix: audio/}\n")
if err := os.WriteFile(campaign, append([]byte("config:\n imports:\n - path: fragments/template-settings.yml\n"), original...), 0o644); err != nil {
t.Fatal(err)
}
output := filepath.Join(t.TempDir(), "session.yml")
var stdout, stderr bytes.Buffer
if code := Execute([]string{"session", "init", "2026-06-07", "--config", pipeline, "--campaign-file", campaign, "--output", output}, &stdout, &stderr); code != 0 {
t.Fatalf("exit = %d; stderr = %q", code, stderr.String())
}
data, err := os.ReadFile(output)
if err != nil || !strings.Contains(string(data), "2026-06-07") {
t.Fatalf("generated session = %q, %v", data, err)
}
}
func TestExecuteSessionInitRemoteRendersCampaignTemplate(t *testing.T) { func TestExecuteSessionInitRemoteRendersCampaignTemplate(t *testing.T) {
workspaceRoot := t.TempDir() workspaceRoot := t.TempDir()
pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot) pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot)
@@ -436,7 +454,7 @@ inputs:
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := executeWithDependencies([]string{"session", "validate", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &stdout, &stderr, deps, executePlan) code := executeWithDependencies([]string{"session", "validate", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath, "--secrets-dir", secretsDir}, &stdout, &stderr, deps, executePlan)
if code != 0 { if code != 0 {
t.Fatalf("exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String()) t.Fatalf("exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String())
} }
@@ -800,11 +818,18 @@ func TestExecuteTopLevelLockAndUnlockAreRemoved(t *testing.T) {
func withDefaultPipelineCampaignConfigs(t *testing.T, pipelinePath, campaignPath string) { func withDefaultPipelineCampaignConfigs(t *testing.T, pipelinePath, campaignPath string) {
t.Helper() t.Helper()
origPipelineDefaults := append([]string(nil), config.DefaultPipelineConfigSearchPaths...) dir := t.TempDir()
config.DefaultPipelineConfigSearchPaths = []string{pipelinePath} if err := os.Link(pipelinePath, filepath.Join(dir, "narratio.yml")); err != nil {
t.Cleanup(func() { t.Fatal(err)
config.DefaultPipelineConfigSearchPaths = origPipelineDefaults }
}) original, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = os.Chdir(original) })
_ = campaignPath _ = campaignPath
} }

View File

@@ -43,7 +43,7 @@ func sessionInitWithDependencies(ctx context.Context, args []string, out io.Writ
overlay.name = "overlay" overlay.name = "overlay"
fs.Var(&overlay, "overlay", "named pipeline overlay") fs.Var(&overlay, "overlay", "named pipeline overlay")
secretsDir.name = "secrets-dir" secretsDir.name = "secrets-dir"
fs.Var(&secretsDir, "secrets-dir", "secrets directory (optional; defaults beside pipeline.yml)") fs.Var(&secretsDir, "secrets-dir", "secrets directory (optional; defaults to /usr/local/etc/narratio/secrets)")
fs.BoolVar(&remote, "remote", false, "write session.yml to S3 session prefix") fs.BoolVar(&remote, "remote", false, "write session.yml to S3 session prefix")
fs.BoolVar(&force, "force", false, "overwrite existing target") fs.BoolVar(&force, "force", false, "overwrite existing target")
if err := parseSessionAwareFlags("session init", fs, args, &sessionID); err != nil { if err := parseSessionAwareFlags("session init", fs, args, &sessionID); err != nil {
@@ -58,6 +58,13 @@ func sessionInitWithDependencies(ctx context.Context, args []string, out io.Writ
if strings.TrimSpace(audioDir) != "" && strings.TrimSpace(audioS3Prefix) != "" { if strings.TrimSpace(audioDir) != "" && strings.TrimSpace(audioS3Prefix) != "" {
return fmt.Errorf("session init: --audio-dir and --audio-s3-prefix are mutually exclusive") return fmt.Errorf("session init: --audio-dir and --audio-s3-prefix are mutually exclusive")
} }
if strings.TrimSpace(audioDir) != "" {
var err error
audioDir, err = filepath.Abs(audioDir)
if err != nil {
return fmt.Errorf("session init: resolve --audio-dir: %w", err)
}
}
base, err := loadPipelineCampaignConfigWithDependencies(pipelinePath, campaignPath, campaignFilePath, config.PipelineLoadOptions{Overlay: overlay.pointer()}, secretsDir.pointer(), deps) base, err := loadPipelineCampaignConfigWithDependencies(pipelinePath, campaignPath, campaignFilePath, config.PipelineLoadOptions{Overlay: overlay.pointer()}, secretsDir.pointer(), deps)
if err != nil { if err != nil {
@@ -83,7 +90,13 @@ func sessionInitWithDependencies(ctx context.Context, args []string, out io.Writ
if label == "" { if label == "" {
label = "remote session.yml" label = "remote session.yml"
} }
sessionCfg, err := config.LoadSessionBytesWithOptions(label, data, config.SessionLoadOptions{ // Generated defaults and CLI resources originate at the invocation. A
// configured template supplies its own existing local authoring context.
authoringPath := "session.yml"
if input.TemplateFile != "" {
authoringPath = resolveSessionInitTemplatePath(input.CampaignPath, input.TemplateFile)
}
sessionCfg, err := config.LoadSessionAuthoringBytes(authoringPath, data, config.SessionLoadOptions{
SessionID: sessionID, SessionID: sessionID,
PreviousSessionID: previousSessionID, PreviousSessionID: previousSessionID,
}) })
@@ -97,6 +110,10 @@ func sessionInitWithDependencies(ctx context.Context, args []string, out io.Writ
if err := config.Validate(cfg); err != nil { if err := config.Validate(cfg); err != nil {
return fmt.Errorf("session init: %w", err) return fmt.Errorf("session init: %w", err)
} }
data, err = config.RenderSessionDocument(cfg, sessionID)
if err != nil {
return fmt.Errorf("session init: render effective session: %w", err)
}
if !remote { if !remote {
if err := writeLocalFile(output, data, force); err != nil { if err := writeLocalFile(output, data, force); err != nil {

View File

@@ -1,49 +0,0 @@
package app
import (
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"gitea.maximumdirect.net/eric/narratio/internal/config"
)
func resolvePipelineConfigPath(flagValue string) (string, error) {
return resolvePipelineConfigPathWithCandidates(flagValue, config.DefaultPipelineConfigSearchPaths)
}
func resolvePipelineConfigPathWithCandidates(flagValue string, candidates []string) (string, error) {
if explicit := strings.TrimSpace(flagValue); explicit != "" {
return explicit, nil
}
ordered := make([]string, 0, len(candidates))
for _, raw := range candidates {
path := strings.TrimSpace(raw)
if path == "" {
continue
}
ordered = append(ordered, path)
info, err := os.Stat(path)
if err == nil {
if info.IsDir() {
continue
}
return filepath.Clean(path), nil
}
if errors.Is(err, os.ErrNotExist) {
continue
}
return "", fmt.Errorf("check default pipeline config %q: %w", path, err)
}
if len(ordered) == 0 {
return "", fmt.Errorf("no pipeline config path provided and no default locations configured")
}
return "", fmt.Errorf(
"no pipeline config path provided and no default pipeline config found; searched: %s",
strings.Join(ordered, ", "),
)
}

View File

@@ -1,117 +0,0 @@
package app
import (
"bytes"
"context"
"errors"
"os"
"path/filepath"
"strings"
"testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/config"
)
func TestResolvePipelineConfigPathWithCandidatesExplicitWins(t *testing.T) {
got, err := resolvePipelineConfigPathWithCandidates(" ./custom/pipeline.yml ", []string{"/a", "/b"})
if err != nil {
t.Fatalf("resolvePipelineConfigPathWithCandidates() error = %v", err)
}
if got != "./custom/pipeline.yml" {
t.Fatalf("resolved path = %q, want explicit path", got)
}
}
func TestResolvePipelineConfigPathWithCandidatesUsesFirstExisting(t *testing.T) {
dir := t.TempDir()
first := filepath.Join(dir, "first.yml")
second := filepath.Join(dir, "second.yml")
if err := os.WriteFile(second, []byte("workspace:\n root: ./tmp\n"), 0o644); err != nil {
t.Fatalf("write second default: %v", err)
}
got, err := resolvePipelineConfigPathWithCandidates("", []string{first, second})
if err != nil {
t.Fatalf("resolvePipelineConfigPathWithCandidates() error = %v", err)
}
if got != filepath.Clean(second) {
t.Fatalf("resolved path = %q, want %q", got, filepath.Clean(second))
}
}
func TestResolvePipelineConfigPathWithCandidatesPrecedence(t *testing.T) {
dir := t.TempDir()
first := filepath.Join(dir, "first.yml")
second := filepath.Join(dir, "second.yml")
if err := os.WriteFile(first, []byte("workspace:\n root: ./tmp\n"), 0o644); err != nil {
t.Fatalf("write first default: %v", err)
}
if err := os.WriteFile(second, []byte("workspace:\n root: ./tmp\n"), 0o644); err != nil {
t.Fatalf("write second default: %v", err)
}
got, err := resolvePipelineConfigPathWithCandidates("", []string{first, second})
if err != nil {
t.Fatalf("resolvePipelineConfigPathWithCandidates() error = %v", err)
}
if got != filepath.Clean(first) {
t.Fatalf("resolved path = %q, want first candidate %q", got, filepath.Clean(first))
}
}
func TestResolvePipelineConfigPathWithCandidatesMissing(t *testing.T) {
directory := t.TempDir()
first := filepath.Join(directory, "one.yml")
second := filepath.Join(directory, "two.yml")
_, err := resolvePipelineConfigPathWithCandidates("", []string{first, second})
if err == nil {
t.Fatal("expected error, got nil")
}
if !strings.Contains(err.Error(), "no default pipeline config found") {
t.Fatalf("error = %q, want missing-defaults context", err.Error())
}
if !strings.Contains(err.Error(), first) || !strings.Contains(err.Error(), second) {
t.Fatalf("error = %q, want controlled searched paths", err.Error())
}
}
func TestExecuteMissingExplicitConfigDiscoversExistingDefaultBeforeLoading(t *testing.T) {
directory := t.TempDir()
missing := filepath.Join(directory, "missing.yml")
existing := filepath.Join(directory, "pipeline.yml")
if err := os.WriteFile(existing, []byte("workspace:\n root: ./tmp\n"), 0o644); err != nil {
t.Fatalf("write default pipeline: %v", err)
}
controlledErr := errors.New("controlled pipeline loader boundary")
loadedPath := ""
deps := commandDependenciesForPipelineCandidates(missing, existing)
deps.loadPipelineConfig = func(path string, _ config.PipelineLoadOptions) (*config.PipelineConfig, error) {
loadedPath = path
return nil, controlledErr
}
deps.loadSecretsDir = func(string) (*configkit.SecretsReport, error) {
t.Fatal("absent conventional secrets directory unexpectedly invoked bootstrap loader")
return nil, nil
}
var stdout bytes.Buffer
var stderr bytes.Buffer
code := executeWithDependencies([]string{"config", "validate"}, &stdout, &stderr, deps, func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error) {
t.Fatal("config validation unexpectedly invoked pipeline executor")
return nil, nil
})
if code == 0 {
t.Fatal("exit code = 0, want controlled loader failure")
}
if loadedPath != existing {
t.Fatalf("loader path = %q, want discovered default %q", loadedPath, existing)
}
if stdout.Len() != 0 {
t.Fatalf("stdout = %q, want empty", stdout.String())
}
if !strings.Contains(stderr.String(), controlledErr.Error()) {
t.Fatalf("stderr = %q, want controlled loader error", stderr.String())
}
}

View File

@@ -0,0 +1,153 @@
package app
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config"
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
"gitea.maximumdirect.net/eric/narratio/internal/stage"
)
func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
ctx := context.Background()
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, t.TempDir())
fragment := filepath.Join(filepath.Dir(sessionPath), "fragment.yml")
mustWriteTestFile(t, sessionPath, "config:\n imports:\n - path: fragment.yml\nsession_id: 2026-05-03\n")
mustWriteTestFile(t, fragment, "title: Published title\ninputs: {audio_dir: audio}\n")
cfg, err := config.LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, config.SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
enabled := true
cfg.Pipeline.Publish.Enabled = &enabled
cfg.Pipeline.Publish.UploadRun = &enabled
cfg.Pipeline.Publish.Outputs = nil
fake := &storage.FakeBackend{}
store := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root)
env := &stage.Env{Config: cfg, ArtifactStore: store, ObjectStore: fake}
m := manifest.New("2026-05-03", time.Now().UTC())
m.Campaign = "sample-campaign"
m.RunID = "20260519T010203Z-a1b2c3d4"
runRoot := artifacts.SessionRunRootForCampaign(cfg.Pipeline.Workspace.Root, m.Campaign, m.SessionID, m.RunID)
m.LocalWorkDir = runRoot
if err := os.MkdirAll(runRoot, 0o755); err != nil {
t.Fatal(err)
}
prepare, err := stage.Select("prepare")
if err != nil {
t.Fatal(err)
}
if _, err := prepare.Run(ctx, env, m); err != nil {
t.Fatal(err)
}
for _, name := range []string{"prepare", "transcribe", "merge", "polish", "normalize", "trim", "render", "analyze"} {
m.MarkStageSucceeded(name, time.Now().UTC(), nil)
}
if err := os.Remove(sessionPath); err != nil {
t.Fatal(err)
}
if err := os.Remove(fragment); err != nil {
t.Fatal(err)
}
publish, err := stage.Select("publish")
if err != nil {
t.Fatal(err)
}
if _, err := publish.Run(ctx, env, m); err != nil {
t.Fatal(err)
}
prefix := artifacts.S3SessionPrefix("dnd", m.Campaign, m.SessionID)
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(prefix, m.RunID), "prepare/inputs/session.yml")
if got := string(fake.Objects[key].Data); !strings.Contains(got, "Published title") || strings.Contains(got, "imports:") || strings.Contains(got, "speakers_file:") {
t.Fatalf("published session = %q", got)
}
for _, name := range []string{"campaign.yml", "party.yml"} {
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(prefix, m.RunID), "prepare/inputs/"+name)
if data := fake.Objects[key].Data; len(data) == 0 || strings.Contains(string(data), "imports:") {
t.Fatalf("published %s = %q", name, data)
}
}
setSessionConfigSearchPaths(t, []string{sessionPath})
deps, _ := remoteSessionLoaderDependencies(fake)
loaded, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
if err != nil {
t.Fatal(err)
}
defer func() { _ = loaded.Close() }()
if loaded.Config.Session.Title != "Published title" || loaded.Config.SessionSource.S3Key != key {
t.Fatalf("remote session = %#v, source=%#v", loaded.Config.Session, loaded.Config.SessionSource)
}
if got := loaded.Config.StableInputs.SpeakersFile; got.Source != "campaign_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
t.Fatalf("receiving campaign speakers = %#v", got)
}
current, err := discoverRemoteCurrentState(ctx, loaded.Config, fake)
if err != nil {
t.Fatal(err)
}
plan, err := buildRestorePlan(ctx, loaded.Config, current, fake, RestorePlanOptions{Force: true})
if err != nil {
t.Fatal(err)
}
want := map[string]bool{"inputs/session.yml": false, "inputs/campaign.yml": false, "inputs/party.yml": false}
for _, action := range plan.Actions {
if _, ok := want[action.LocalRelativePath]; ok {
want[action.LocalRelativePath] = true
}
}
for path, found := range want {
if !found {
t.Fatalf("restore omitted %q", path)
}
}
paths := store.SessionPathsFor(m.Campaign, m.SessionID)
for _, name := range []string{"session.yml", "campaign.yml", "party.yml"} {
if err := os.Remove(filepath.Join(paths.InputsDir, name)); err != nil {
t.Fatal(err)
}
}
var output strings.Builder
if err := restoreWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--force"}, &output, deps); err != nil {
t.Fatalf("restore: %v", err)
}
restored, err := os.ReadFile(filepath.Join(paths.InputsDir, "session.yml"))
if err != nil || string(restored) != string(fake.Objects[key].Data) {
t.Fatalf("restored session = %q, %v", restored, err)
}
committedBytes := string(fake.Objects[key].Data)
if err := sessionInitWithDependencies(ctx, []string{m.SessionID, "--config", pipelinePath, "--campaign-file", campaignPath, "--remote", "--force", "--title", "Updated title", "--audio-s3-prefix", "replacement/"}, &output, deps); err != nil {
t.Fatal(err)
}
updated, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps)
if err != nil {
t.Fatal(err)
}
defer func() { _ = updated.Close() }()
if updated.Config.Session.Title != "Updated title" || updated.Config.Session.Inputs.AudioS3 == nil || updated.Config.Session.Inputs.AudioS3.Prefix != "replacement/" {
t.Fatalf("remote edit ignored: %#v", updated.Config.Session)
}
if string(fake.Objects[key].Data) != committedBytes {
t.Fatal("authoring update changed committed input")
}
if _, err := discoverRemoteCurrentState(ctx, updated.Config, fake); err != nil {
t.Fatalf("committed state after authoring update: %v", err)
}
// Remove the authored override to exercise committed-snapshot integrity below.
rootKey := artifacts.S3SessionConfigKey(prefix)
if err := fake.Delete(ctx, rootKey); err != nil {
t.Fatal(err)
}
object := fake.Objects[key]
modified := append([]byte(nil), object.Data...)
modified[0] ^= 1
fake.SeedObject(storage.FakeObject{Key: key, Data: modified, ETag: object.ETag})
if _, err := loadCommandConfigWithDependencies(ctx, pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: m.SessionID}, nil, deps); err == nil || !strings.Contains(err.Error(), "committed checksum") {
t.Fatalf("changed remote session error = %v", err)
}
}

View File

@@ -90,7 +90,7 @@ inputs:
`) `)
var stdout, stderr bytes.Buffer var stdout, stderr bytes.Buffer
if code := Execute([]string{"config", "show", "--config", configPath}, &stdout, &stderr); code != 0 { if code := Execute([]string{"config", "show", "--config", configPath, "--secrets-dir", secretsDir}, &stdout, &stderr); code != 0 {
t.Fatalf("config show exit = %d; stderr=%q", code, stderr.String()) t.Fatalf("config show exit = %d; stderr=%q", code, stderr.String())
} }
if !strings.Contains(stdout.String(), sharedProviderName) || !strings.Contains(stdout.String(), auditaOnlyName) { if !strings.Contains(stdout.String(), sharedProviderName) || !strings.Contains(stdout.String(), auditaOnlyName) {
@@ -104,7 +104,7 @@ inputs:
mustWriteTestFile(t, basePath, `{"schema":"seriatim-intermediate","segments":[]}`) mustWriteTestFile(t, basePath, `{"schema":"seriatim-intermediate","segments":[]}`)
seedCurrentBuiltInEvidence(t, manifestPath, "2026-05-03", "sample-campaign", "merge", artifacts.TranscriptOutputKindBase, artifacts.ArtifactTranscriptBase, basePath) seedCurrentBuiltInEvidence(t, manifestPath, "2026-05-03", "sample-campaign", "merge", artifacts.TranscriptOutputKindBase, artifacts.ArtifactTranscriptBase, basePath)
mustWriteTestFile(t, filepath.Join(workRoot, "inputs", "glossary.yml"), "[]\n") mustWriteTestFile(t, filepath.Join(workRoot, "inputs", "glossary.yml"), "[]\n")
args := []string{"--config", configPath, "--campaign-file", campaignPath, "--session", sessionPath} args := []string{"--secrets-dir", secretsDir, "--config", configPath, "--campaign-file", campaignPath, "--session", sessionPath}
stdout.Reset() stdout.Reset()
stderr.Reset() stderr.Reset()
if code := Execute(append([]string{"run-stage", "polish", "2026-05-03", "--force"}, args...), &stdout, &stderr); code != 0 { if code := Execute(append([]string{"run-stage", "polish", "2026-05-03", "--force"}, args...), &stdout, &stderr); code != 0 {

View File

@@ -10,10 +10,10 @@ import (
"strings" "strings"
"testing" "testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage" "gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts" "gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
) )
func TestExecuteRemoteSessionFallbackLoadsFromObjectStore(t *testing.T) { func TestExecuteRemoteSessionFallbackLoadsFromObjectStore(t *testing.T) {
@@ -46,6 +46,24 @@ inputs:
} }
} }
func TestInvalidDiscoveredSessionDoesNotTriggerRemoteFallback(t *testing.T) {
pipeline, campaign, _ := writeValidConfigFiles(t, t.TempDir())
selected := filepath.Join(t.TempDir(), "session.yml")
if err := os.WriteFile(selected, []byte("unexpected: value\n"), 0o644); err != nil {
t.Fatal(err)
}
setSessionConfigSearchPaths(t, []string{selected})
storeCalls := 0
deps := fakeCommandDependencies(&storage.FakeBackend{}, &storeCalls)
var stdout, stderr bytes.Buffer
if code := executeWithDependencies([]string{"session", "plan", "2026-05-03", "--config", pipeline, "--campaign-file", campaign}, &stdout, &stderr, deps, executePlan); code == 0 {
t.Fatal("invalid session was accepted")
}
if storeCalls != 0 || !strings.Contains(stderr.String(), "decode.unknown_field") {
t.Fatalf("store calls=%d, stderr=%q", storeCalls, stderr.String())
}
}
func TestRemoteSessionLoadingRetainsCampaignCanonicalParty(t *testing.T) { func TestRemoteSessionLoadingRetainsCampaignCanonicalParty(t *testing.T) {
workspaceRoot := t.TempDir() workspaceRoot := t.TempDir()
pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot) pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot)
@@ -191,6 +209,7 @@ func TestRemoteSessionConfigCloseIsIdempotent(t *testing.T) {
workspaceRoot := t.TempDir() workspaceRoot := t.TempDir()
pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot) pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot)
fake := &storage.FakeBackend{} fake := &storage.FakeBackend{}
fake.ListErr = errors.New("remote session loading must not enumerate historical objects")
seedRemoteSessionConfig(t, fake, "2026-05-03", `session_id: 2026-05-03 seedRemoteSessionConfig(t, fake, "2026-05-03", `session_id: 2026-05-03
inputs: inputs:
audio_s3: audio_s3:
@@ -199,12 +218,11 @@ inputs:
setSessionConfigSearchPaths(t, []string{filepath.Join(t.TempDir(), "session.yml")}) setSessionConfigSearchPaths(t, []string{filepath.Join(t.TempDir(), "session.yml")})
deps, _ := remoteSessionLoaderDependencies(fake) deps, _ := remoteSessionLoaderDependencies(fake)
var downloadedPath string
deps.downloadObjectToTemp = captureRemoteSessionTempPath(&downloadedPath)
loaded, err := loadCommandConfigWithDependencies(context.Background(), pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: "2026-05-03"}, nil, deps) loaded, err := loadCommandConfigWithDependencies(context.Background(), pipelinePath, "", campaignPath, "", config.SessionLoadOptions{SessionID: "2026-05-03"}, nil, deps)
if err != nil { if err != nil {
t.Fatalf("loadCommandConfig() error = %v", err) t.Fatalf("loadCommandConfig() error = %v", err)
} }
downloadedPath := loaded.Config.SessionSource.LocalPath
if err := loaded.Close(); err != nil { if err := loaded.Close(); err != nil {
t.Fatalf("first Close() error = %v", err) t.Fatalf("first Close() error = %v", err)
} }
@@ -219,16 +237,6 @@ inputs:
} }
} }
func captureRemoteSessionTempPath(destination *string) func(context.Context, storage.ObjectStore, string, string) (string, error) {
return func(ctx context.Context, store storage.ObjectStore, key, pattern string) (string, error) {
path, err := storage.DownloadObjectToTemp(ctx, store, key, pattern)
if err == nil {
*destination = path
}
return path, err
}
}
func TestExecuteRemoteSessionFallbackLoadsSecretsBeforeObjectStoreInit(t *testing.T) { func TestExecuteRemoteSessionFallbackLoadsSecretsBeforeObjectStoreInit(t *testing.T) {
workspaceRoot := t.TempDir() workspaceRoot := t.TempDir()
pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot) pipelinePath, campaignPath, _ := writeValidConfigFiles(t, workspaceRoot)
@@ -251,7 +259,7 @@ inputs:
deps := commandDependencies{ deps := commandDependencies{
loadSecretsDir: func(directory string) (*configkit.SecretsReport, error) { loadSecretsDir: func(directory string) (*configkit.SecretsReport, error) {
bootstrapCalls++ bootstrapCalls++
return configkit.LoadSecretsDir(directory) return configkit.LoadSecretsIntoEnvironment(directory)
}, },
newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) { newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
if os.Getenv(accessKeyEnv) != "remote-session-key-id" || os.Getenv(secretKeyEnv) != "remote-session-secret" { if os.Getenv(accessKeyEnv) != "remote-session-key-id" || os.Getenv(secretKeyEnv) != "remote-session-secret" {
@@ -262,7 +270,7 @@ inputs:
var stdout bytes.Buffer var stdout bytes.Buffer
var stderr bytes.Buffer var stderr bytes.Buffer
code := executeWithDependencies([]string{"session", "plan", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath}, &stdout, &stderr, deps, executePlan) code := executeWithDependencies([]string{"session", "plan", "2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--secrets-dir", secretsDir}, &stdout, &stderr, deps, executePlan)
if code != 0 { if code != 0 {
t.Fatalf("exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String()) t.Fatalf("exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String())
} }

View File

@@ -380,8 +380,19 @@ func TestExecuteRestoreLockConflictFailsAndWritesNothing(t *testing.T) {
deps := restoreCommandDependencies(fake) deps := restoreCommandDependencies(fake)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
discover := deps.discoverRemoteCurrentState
if discover == nil {
discover = discoverRemoteCurrentState
}
deps.discoverRemoteCurrentState = func(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) {
current, err := discover(ctx, cfg, store)
// Cancel after discovery so configuration and storage startup have no
// incidental deadline. The held lock must prevent installation.
cancel()
return current, err
}
err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps) err = restoreWithDependencies(ctx, []string{"2026-05-03", "--config", pipelinePath, "--campaign-file", campaignPath, "--session", sessionPath}, &bytes.Buffer{}, deps)
if err == nil || !strings.Contains(err.Error(), "acquire session lock") { if err == nil || !strings.Contains(err.Error(), "acquire session lock") {
t.Fatalf("Restore() error = %v, want lock failure", err) t.Fatalf("Restore() error = %v, want lock failure", err)

View File

@@ -179,6 +179,16 @@ func restoreLocalRelativePathForCommittedArtifact(sessionPrefix string, artifact
if artifact.Type == artifacts.RemoteArtifactTypeSessionManifest { if artifact.Type == artifacts.RemoteArtifactTypeSessionManifest {
return config.PathManifestFile, true, nil return config.PathManifestFile, true, nil
} }
if artifact.Type == artifacts.RemoteArtifactTypeRunFile {
switch artifact.Source {
case "run:prepare/inputs/session.yml", "run:prepare/inputs/campaign.yml", "run:prepare/inputs/party.yml":
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, artifact.DestinationKey)
if err != nil || "run:"+identity.RelativePath != artifact.Source {
return "", false, fmt.Errorf("prepared input does not match its run object key")
}
return strings.TrimPrefix(identity.RelativePath, "prepare/"), true, nil
}
}
if artifact.Type != artifacts.RemoteArtifactTypePublishedOutput { if artifact.Type != artifacts.RemoteArtifactTypePublishedOutput {
return "", false, nil return "", false, nil
} }

View File

@@ -179,9 +179,6 @@ func TestExecuteRestoreLoadsSecretsBeforeObjectStoreInit(t *testing.T) {
secretsDir := filepath.Join(t.TempDir(), "secrets") secretsDir := filepath.Join(t.TempDir(), "secrets")
mustWriteSecretFile(t, filepath.Join(secretsDir, accessKeyEnv), "test-access-key-id\n") mustWriteSecretFile(t, filepath.Join(secretsDir, accessKeyEnv), "test-access-key-id\n")
mustWriteSecretFile(t, filepath.Join(secretsDir, secretKeyEnv), "test-secret-key\n") mustWriteSecretFile(t, filepath.Join(secretsDir, secretKeyEnv), "test-secret-key\n")
if err := os.Symlink(secretsDir, filepath.Join(filepath.Dir(pipelinePath), "secrets")); err != nil {
t.Fatalf("link conventional secrets directory: %v", err)
}
storeInitCalled := false storeInitCalled := false
deps := commandDependencies{newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) { deps := commandDependencies{newObjectStore: func(context.Context, *config.Config) (storage.ObjectStore, error) {
@@ -226,6 +223,7 @@ func TestExecuteRestoreLoadsSecretsBeforeObjectStoreInit(t *testing.T) {
"--campaign-file", campaignPath, "--campaign-file", campaignPath,
"--session", sessionPath, "--session", sessionPath,
"--dry-run", "--dry-run",
"--secrets-dir", secretsDir,
}, },
&stdout, &stdout,
&stderr, &stderr,

View File

@@ -9,7 +9,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
type secretsBootstrap struct { type secretsBootstrap struct {
@@ -18,12 +18,14 @@ type secretsBootstrap struct {
called bool called bool
} }
func (b *secretsBootstrap) load(pipelinePath string, loader func(string) (*configkit.SecretsReport, error), diagnostics io.Writer) error { var conventionalSecretsDirectory = "/usr/local/etc/narratio/secrets"
func (b *secretsBootstrap) load(loader func(string) (*configkit.SecretsReport, error), diagnostics io.Writer) error {
if b == nil || b.called { if b == nil || b.called {
return nil return nil
} }
b.called = true b.called = true
directory, required, err := selectedSecretsDirectory(pipelinePath, b.selection) directory, required, err := selectedSecretsDirectory(b.selection)
if err != nil { if err != nil {
return err return err
} }
@@ -53,7 +55,7 @@ func (b *secretsBootstrap) load(pipelinePath string, loader func(string) (*confi
return fmt.Errorf("bootstrap secrets directory: %w", loadErr) return fmt.Errorf("bootstrap secrets directory: %w", loadErr)
} }
func selectedSecretsDirectory(pipelinePath string, selection *string) (string, bool, error) { func selectedSecretsDirectory(selection *string) (string, bool, error) {
if selection != nil { if selection != nil {
if strings.TrimSpace(*selection) == "" { if strings.TrimSpace(*selection) == "" {
return "", true, fmt.Errorf("--secrets-dir requires a non-empty path") return "", true, fmt.Errorf("--secrets-dir requires a non-empty path")
@@ -64,9 +66,5 @@ func selectedSecretsDirectory(pipelinePath string, selection *string) (string, b
} }
return filepath.Clean(path), true, nil return filepath.Clean(path), true, nil
} }
root, err := filepath.Abs(pipelinePath) return conventionalSecretsDirectory, false, nil
if err != nil {
return "", false, fmt.Errorf("resolve pipeline path for secrets discovery: %w", err)
}
return filepath.Join(filepath.Dir(root), "secrets"), false, nil
} }

View File

@@ -9,8 +9,8 @@ import (
"strings" "strings"
"testing" "testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
) )
func TestPipelineLoadSkipsAbsentConventionalSecretsDirectory(t *testing.T) { func TestPipelineLoadSkipsAbsentConventionalSecretsDirectory(t *testing.T) {
@@ -39,6 +39,27 @@ func TestPipelineLoadSkipsAbsentConventionalSecretsDirectory(t *testing.T) {
} }
} }
func TestPipelineLoadUsesIndependentConventionalSecretsDirectory(t *testing.T) {
dir := t.TempDir()
previous := conventionalSecretsDirectory
conventionalSecretsDirectory = dir
t.Cleanup(func() { conventionalSecretsDirectory = previous })
const name = "NARRATIO_TEST_CONVENTIONAL_SECRET"
restoreEnvAfterTest(t, name)
mustWriteSecretFile(t, filepath.Join(dir, name), "synthetic-value\n")
pipelinePath := filepath.Join(t.TempDir(), "pipeline.yml")
if err := os.WriteFile(pipelinePath, []byte("notarius:\n enabled: false\n credentials: ["+name+"]\n"), 0o644); err != nil {
t.Fatal(err)
}
_, pipeline, err := loadPipelineConfigWithDependencies(pipelinePath, config.PipelineLoadOptions{}, nil, commandDependencies{})
if err != nil {
t.Fatal(err)
}
if got := pipeline.Notarius.Credentials[0].Value(); got != "synthetic-value" {
t.Fatal("conventional directory credential was not resolved")
}
}
func TestExplicitSecretsDirectoryIsResolvedFromCallerWorkingDirectory(t *testing.T) { func TestExplicitSecretsDirectoryIsResolvedFromCallerWorkingDirectory(t *testing.T) {
callerDir := t.TempDir() callerDir := t.TempDir()
selected := filepath.Join(callerDir, "credentials") selected := filepath.Join(callerDir, "credentials")
@@ -54,7 +75,7 @@ func TestExplicitSecretsDirectoryIsResolvedFromCallerWorkingDirectory(t *testing
} }
t.Cleanup(func() { _ = os.Chdir(original) }) t.Cleanup(func() { _ = os.Chdir(original) })
got, required, err := selectedSecretsDirectory(filepath.Join(t.TempDir(), "pipeline.yml"), stringPointer("credentials")) got, required, err := selectedSecretsDirectory(stringPointer("credentials"))
if err != nil { if err != nil {
t.Fatalf("select secrets: %v", err) t.Fatalf("select secrets: %v", err)
} }
@@ -103,7 +124,7 @@ func TestSecretsBootstrapPreservesExistingEnvironmentValues(t *testing.T) {
bootstrap := &secretsBootstrap{selection: &directory, selectionSet: true} bootstrap := &secretsBootstrap{selection: &directory, selectionSet: true}
var diagnostics bytes.Buffer var diagnostics bytes.Buffer
if err := bootstrap.load(filepath.Join(t.TempDir(), "pipeline.yml"), configkit.LoadSecretsDir, &diagnostics); err != nil { if err := bootstrap.load(configkit.LoadSecretsIntoEnvironment, &diagnostics); err != nil {
t.Fatalf("bootstrap: %v", err) t.Fatalf("bootstrap: %v", err)
} }
if got := diagnostics.String(); !strings.Contains(got, `status="skipped_existing"`) || !strings.Contains(got, `existing_empty=true`) { if got := diagnostics.String(); !strings.Contains(got, `status="skipped_existing"`) || !strings.Contains(got, `existing_empty=true`) {
@@ -128,7 +149,6 @@ func TestNotariusCredentialLoadsFromCommandSecretBootstrap(t *testing.T) {
fileValue string fileValue string
wantValue string wantValue string
}{ }{
{name: "conventional", fileValue: "conventional-value", wantValue: "conventional-value"},
{name: "explicit", explicit: true, fileValue: "explicit-value", wantValue: "explicit-value"}, {name: "explicit", explicit: true, fileValue: "explicit-value", wantValue: "explicit-value"},
{name: "environment precedence", explicit: true, environment: "environment-value", fileValue: "file-value", wantValue: "environment-value"}, {name: "environment precedence", explicit: true, environment: "environment-value", fileValue: "file-value", wantValue: "environment-value"},
} }
@@ -170,7 +190,7 @@ func TestSecretsBootstrapPreservesSafePartialReportOnFailure(t *testing.T) {
directory := t.TempDir() directory := t.TempDir()
mustWriteSecretFile(t, filepath.Join(directory, "INVALID-NAME"), "must-not-appear\n") mustWriteSecretFile(t, filepath.Join(directory, "INVALID-NAME"), "must-not-appear\n")
bootstrap := &secretsBootstrap{selection: &directory, selectionSet: true} bootstrap := &secretsBootstrap{selection: &directory, selectionSet: true}
err := bootstrap.load(filepath.Join(t.TempDir(), "pipeline.yml"), configkit.LoadSecretsDir, io.Discard) err := bootstrap.load(configkit.LoadSecretsIntoEnvironment, io.Discard)
if err == nil { if err == nil {
t.Fatal("bootstrap succeeded, want error") t.Fatal("bootstrap succeeded, want error")
} }

View File

@@ -131,7 +131,7 @@ func TestRunStageAcceptsPositionalSessionIDAndParsesStageName(t *testing.T) {
} }
func TestResolveSessionConfigPathErrorIncludesSearchedPaths(t *testing.T) { func TestResolveSessionConfigPathErrorIncludesSearchedPaths(t *testing.T) {
_, err := resolveSessionConfigPathWithCandidates("", []string{"/usr/local/etc/narratio/session.yml", "/etc/narratio/session.yml"}) err := missingSessionConfigError([]string{"/usr/local/etc/narratio/session.yml", "/etc/narratio/session.yml"}, "")
if err == nil { if err == nil {
t.Fatal("expected error, got nil") t.Fatal("expected error, got nil")
} }

View File

@@ -1,57 +1,10 @@
package app package app
import ( import (
"errors"
"fmt" "fmt"
"os"
"path/filepath"
"strings" "strings"
) )
func resolveSessionConfigPathWithCandidates(flagValue string, candidates []string) (string, error) {
if explicit := strings.TrimSpace(flagValue); explicit != "" {
return explicit, nil
}
resolved, err := discoverSessionConfigPathWithCandidates(candidates)
if err != nil {
return "", err
}
if resolved.Path != "" {
return resolved.Path, nil
}
return "", missingSessionConfigError(resolved.Searched, "")
}
type sessionConfigDiscovery struct {
Path string
Searched []string
}
func discoverSessionConfigPathWithCandidates(candidates []string) (sessionConfigDiscovery, error) {
ordered := make([]string, 0, len(candidates))
for _, raw := range candidates {
path := strings.TrimSpace(raw)
if path == "" {
continue
}
ordered = append(ordered, path)
info, err := os.Stat(path)
if err == nil {
if info.IsDir() {
continue
}
return sessionConfigDiscovery{Path: filepath.Clean(path), Searched: ordered}, nil
}
if errors.Is(err, os.ErrNotExist) {
continue
}
return sessionConfigDiscovery{}, fmt.Errorf("check default session config %q: %w", path, err)
}
return sessionConfigDiscovery{Searched: ordered}, nil
}
func missingSessionConfigError(searched []string, remoteDetail string) error { func missingSessionConfigError(searched []string, remoteDetail string) error {
ordered := append([]string(nil), searched...) ordered := append([]string(nil), searched...)
if len(ordered) == 0 { if len(ordered) == 0 {

View File

@@ -1,68 +0,0 @@
package app
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestResolveSessionConfigPathWithCandidatesExplicitWins(t *testing.T) {
got, err := resolveSessionConfigPathWithCandidates(" ./custom/session.yml ", []string{"./session.yml", "/a", "/b"})
if err != nil {
t.Fatalf("resolveSessionConfigPathWithCandidates() error = %v", err)
}
if got != "./custom/session.yml" {
t.Fatalf("resolved path = %q, want explicit path", got)
}
}
func TestResolveSessionConfigPathWithCandidatesUsesFirstExisting(t *testing.T) {
dir := t.TempDir()
first := filepath.Join(dir, "first.yml")
second := filepath.Join(dir, "second.yml")
if err := os.WriteFile(second, []byte("session_id: 2026-05-03\n"), 0o644); err != nil {
t.Fatalf("write second default: %v", err)
}
got, err := resolveSessionConfigPathWithCandidates("", []string{first, second})
if err != nil {
t.Fatalf("resolveSessionConfigPathWithCandidates() error = %v", err)
}
if got != filepath.Clean(second) {
t.Fatalf("resolved path = %q, want %q", got, filepath.Clean(second))
}
}
func TestResolveSessionConfigPathWithCandidatesPrecedence(t *testing.T) {
dir := t.TempDir()
first := filepath.Join(dir, "first.yml")
second := filepath.Join(dir, "second.yml")
if err := os.WriteFile(first, []byte("session_id: 2026-05-03\n"), 0o644); err != nil {
t.Fatalf("write first default: %v", err)
}
if err := os.WriteFile(second, []byte("session_id: 2026-05-03\n"), 0o644); err != nil {
t.Fatalf("write second default: %v", err)
}
got, err := resolveSessionConfigPathWithCandidates("", []string{first, second})
if err != nil {
t.Fatalf("resolveSessionConfigPathWithCandidates() error = %v", err)
}
if got != filepath.Clean(first) {
t.Fatalf("resolved path = %q, want first candidate %q", got, filepath.Clean(first))
}
}
func TestResolveSessionConfigPathWithCandidatesMissing(t *testing.T) {
_, err := resolveSessionConfigPathWithCandidates("", []string{"/does/not/exist/one.yml", "/does/not/exist/two.yml"})
if err == nil {
t.Fatal("expected error, got nil")
}
if !strings.Contains(err.Error(), "no default session config found") {
t.Fatalf("error = %q, want missing-defaults context", err.Error())
}
if !strings.Contains(err.Error(), "pass --session") {
t.Fatalf("error = %q, want explicit-path guidance", err.Error())
}
}

View File

@@ -0,0 +1,75 @@
package app
import (
"bytes"
"context"
"os"
"path/filepath"
"testing"
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
"gitea.maximumdirect.net/eric/narratio/internal/config"
)
func TestSessionInitMaterializesLocalTemplateImports(t *testing.T) {
pipeline, campaign, _ := writeValidConfigFiles(t, t.TempDir())
writeSessionInitTemplate(t, campaign, "config:\n imports:\n - path: shared.yml\n required: true\nsession_id: '{{ session_id }}'\ninputs:\n audio_s3: {prefix: audio/}\n")
fragment := filepath.Join(filepath.Dir(campaign), "shared.yml")
mustWriteTestFile(t, fragment, "title: Shared metadata\n")
output := filepath.Join(t.TempDir(), "nested", "session.yml")
if err := sessionInitWithDependencies(context.Background(), []string{"2026-06-07", "--config", pipeline, "--campaign-file", campaign, "--output", output}, &bytes.Buffer{}, commandDependencies{}); err != nil {
t.Fatal(err)
}
if err := os.Remove(fragment); err != nil {
t.Fatal(err)
}
loaded, err := config.LoadSession(output)
if err != nil {
t.Fatal(err)
}
if loaded.Title != "Shared metadata" || loaded.Inputs.SpeakersFile != "" {
t.Fatalf("unexpected standalone session: %#v", loaded)
}
}
func TestSessionInitPublishesStandaloneImportedTemplate(t *testing.T) {
pipeline, campaign, _ := writeValidConfigFiles(t, t.TempDir())
writeSessionInitTemplate(t, campaign, "config:\n imports:\n - path: shared.yml\n required: true\nsession_id: '{{ session_id }}'\ninputs: {audio_s3: {prefix: audio/}}\n")
fragment := filepath.Join(filepath.Dir(campaign), "shared.yml")
mustWriteTestFile(t, fragment, "title: Shared metadata\n")
fake := &storage.FakeBackend{}
if err := sessionInitWithDependencies(context.Background(), []string{"2026-06-07", "--config", pipeline, "--campaign-file", campaign, "--remote"}, &bytes.Buffer{}, restoreCommandDependencies(fake)); err != nil {
t.Fatal(err)
}
key := artifacts.S3SessionConfigKey(artifacts.S3SessionPrefix("dnd", "sample-campaign", "2026-06-07"))
if err := os.Remove(fragment); err != nil {
t.Fatal(err)
}
loaded, err := config.LoadSessionBytesWithOptions("remote session", fake.Objects[key].Data, config.SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
if loaded.Title != "Shared metadata" {
t.Fatalf("title = %q", loaded.Title)
}
}
func TestSessionInitPersistsInvocationRelativeAudio(t *testing.T) {
pipeline, campaign, _ := writeValidConfigFiles(t, t.TempDir())
output := filepath.Join(t.TempDir(), "nested", "session.yml")
if err := sessionInitWithDependencies(context.Background(), []string{"2026-06-07", "--config", pipeline, "--campaign-file", campaign, "--output", output, "--audio-dir", "./audio"}, &bytes.Buffer{}, commandDependencies{}); err != nil {
t.Fatal(err)
}
loaded, err := config.LoadSession(output)
if err != nil {
t.Fatal(err)
}
want, err := filepath.Abs("./audio")
if err != nil {
t.Fatal(err)
}
if loaded.Inputs.AudioDir != want {
t.Fatalf("audio = %q; want %q", loaded.Inputs.AudioDir, want)
}
}

View File

@@ -133,14 +133,14 @@ inputs:
t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String()) t.Fatalf("exit code = %d, want 0; stderr=%q", code, stderr.String())
} }
downloaded := false downloaded := false
for _, call := range fake.Downloads { for _, call := range fake.Reads {
if call.Key == remoteKey { if call.Key == remoteKey {
downloaded = true downloaded = true
break break
} }
} }
if !downloaded { if !downloaded {
t.Fatalf("remote session %q was not downloaded; downloads=%v", remoteKey, fake.Downloads) t.Fatalf("remote session %q was not read; reads=%v", remoteKey, fake.Reads)
} }
if storeInitCalls == 0 { if storeInitCalls == 0 {
t.Fatal("object store was not initialized") t.Fatal("object store was not initialized")

View File

@@ -6,10 +6,21 @@ import (
"path/filepath" "path/filepath"
"testing" "testing"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/config" "gitea.maximumdirect.net/eric/narratio/internal/config"
configkit "go.maximumdirect.net/configkit"
) )
func TestMain(m *testing.M) {
dir, err := os.MkdirTemp("", "narratio-app-test-*")
if err != nil {
panic(err)
}
conventionalSecretsDirectory = filepath.Join(dir, "secrets")
code := m.Run()
_ = os.RemoveAll(dir)
os.Exit(code)
}
// restoreEnvAfterTest clears names for a test and restores both their prior // restoreEnvAfterTest clears names for a test and restores both their prior
// values and their set/unset state during cleanup. // values and their set/unset state during cleanup.
func restoreEnvAfterTest(t *testing.T, names ...string) { func restoreEnvAfterTest(t *testing.T, names ...string) {
@@ -51,24 +62,14 @@ func mustWriteSecretFile(t *testing.T, path, value string) {
} }
func commandDependenciesForPipelineCandidates(candidates ...string) commandDependencies { func commandDependenciesForPipelineCandidates(candidates ...string) commandDependencies {
ownedCandidates := append([]string(nil), candidates...) search := configkit.SearchPaths(candidates...)
return commandDependencies{resolvePipelineConfigPath: func(flagValue string) (string, error) { return commandDependencies{pipelineSearch: &search}
return resolvePipelineConfigPathWithCandidates(flagValue, ownedCandidates)
}}
} }
func guardedMissingPipelineDiscovery(t *testing.T) (commandDependencies, string, pipelineExecutor) { func guardedMissingPipelineDiscovery(t *testing.T) (commandDependencies, string, pipelineExecutor) {
t.Helper() t.Helper()
candidate := filepath.Join(t.TempDir(), "missing-pipeline.yml") candidate := filepath.Join(t.TempDir(), "missing-pipeline.yml")
deps := commandDependenciesForPipelineCandidates(candidate) deps := commandDependenciesForPipelineCandidates(candidate)
deps.loadSecretsDir = func(string) (*configkit.SecretsReport, error) {
t.Fatal("secret bootstrap continued after pipeline discovery failed")
return nil, nil
}
deps.loadPipelineConfig = func(string, config.PipelineLoadOptions) (*config.PipelineConfig, error) {
t.Fatal("typed pipeline loading continued after pipeline discovery failed")
return nil, nil
}
executor := func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error) { executor := func(context.Context, *config.Config, BoundedPlan, RunOptions) (*RunSummary, error) {
t.Fatal("pipeline execution continued after pipeline discovery failed") t.Fatal("pipeline execution continued after pipeline discovery failed")
return nil, nil return nil, nil

View File

@@ -5,8 +5,8 @@ import (
"sort" "sort"
"strings" "strings"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy" "gitea.maximumdirect.net/eric/narratio/internal/artifactpolicy"
configkit "go.maximumdirect.net/configkit"
) )
// EffectiveArtifactRecord describes one concrete artifact after configuration // EffectiveArtifactRecord describes one concrete artifact after configuration
@@ -20,7 +20,7 @@ type EffectiveArtifactRecord struct {
Dependencies []string Dependencies []string
FamilyKey string FamilyKey string
CharacterID string CharacterID string
FamilySource string FamilySources []string
PartySource string PartySource string
} }
@@ -40,6 +40,8 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
} }
sort.Strings(keys) sort.Strings(keys)
records := make([]EffectiveArtifactRecord, 0, len(keys)) records := make([]EffectiveArtifactRecord, 0, len(keys))
pathsByID := pipelineSourcePaths(cfg)
partySources := partyCharacterSourceLookup(party)
for _, key := range keys { for _, key := range keys {
artifact := cfg.Scriptorium.Artifacts[key] artifact := cfg.Scriptorium.Artifacts[key]
record := EffectiveArtifactRecord{ record := EffectiveArtifactRecord{
@@ -50,13 +52,13 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
Dependencies: append([]string(nil), artifact.DependsOn...), Dependencies: append([]string(nil), artifact.DependsOn...),
} }
if member, ok := cfg.familyCatalog.Members[key]; ok { if member, ok := cfg.familyCatalog.Members[key]; ok {
record.DefinitionSources = artifactFamilyDefinitionSources(cfg, member.Family) record.DefinitionSources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
record.FamilyKey = member.Family record.FamilyKey = member.Family
record.CharacterID = member.CharacterID record.CharacterID = member.CharacterID
record.FamilySource = member.Source record.FamilySources = append([]string(nil), cfg.familyCatalog.Families[member.Family].Sources...)
record.PartySource = party.Source.Path record.PartySource = strings.Join(partySources(member.CharacterID), ",")
} else { } else {
record.DefinitionSources = artifactDefinitionSources(cfg, key) record.DefinitionSources = declarationDefinitionSourcesWithIndex(cfg, configkit.Keys("scriptorium", "artifacts", key), pathsByID)
} }
record.Dependencies = nonEmptySortedStrings(record.Dependencies) record.Dependencies = nonEmptySortedStrings(record.Dependencies)
records = append(records, record) records = append(records, record)
@@ -64,63 +66,106 @@ func EffectiveArtifactCatalog(cfg *PipelineConfig, party ResolvedParty) ([]Effec
return records, nil return records, nil
} }
func artifactDefinitionSources(cfg *PipelineConfig, key string) []string { // partyCharacterSourceLookup owns a single inspection's detached native evidence.
return declarationDefinitionSources(cfg, func partyCharacterSourceLookup(party ResolvedParty) func(string) []string {
configkit.Keys("scriptorium", "artifacts", key), var metadata configkit.Metadata
"scriptorium.artifacts."+key, sources := map[string]string{}
) if party.Canonical != nil && party.Canonical.authoring != nil {
result := party.Canonical.authoring
metadata = result.Metadata()
for _, source := range result.Sources() {
name := source.Path
if name == "" {
name = source.Label
}
sources[source.ID] = name
}
}
cache := map[string][]string{}
return func(id string) []string {
if value, ok := cache[id]; ok {
return value
}
path := configkit.Keys("characters", id)
var ids []string
add := func(origin configkit.Origin) {
for _, location := range origin.Locations {
ids = append(ids, location.SourceID)
}
for _, step := range origin.Inheritance {
for _, location := range step.Locations {
ids = append(ids, location.SourceID)
}
}
}
if info, ok := metadata.Lookup(path); ok {
add(info.Origin)
}
for _, change := range metadata.History(path) {
if change.Origin.Layer == configkit.LayerMain || change.Origin.Layer == configkit.LayerOverlay {
add(change.Origin)
}
}
var paths []string
for _, id := range nonEmptySortedStrings(ids) {
if name := sources[id]; name != "" {
paths = append(paths, name)
}
}
if len(paths) == 0 {
paths = append(paths, party.Source.Path)
}
cache[id] = nonEmptySortedStrings(paths)
return cache[id]
}
} }
func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string { func artifactFamilyDefinitionSources(cfg *PipelineConfig, key string) []string {
return declarationDefinitionSources(cfg, return declarationDefinitionSources(cfg,
configkit.Keys("scriptorium", "artifact_families", key), configkit.Keys("scriptorium", "artifact_families", key),
"scriptorium.artifact_families."+key,
) )
} }
func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path, prefix string) []string { func declarationDefinitionSources(cfg *PipelineConfig, declaration configkit.Path) []string {
return declarationDefinitionSourcesWithIndex(cfg, declaration, pipelineSourcePaths(cfg))
}
func declarationDefinitionSourcesWithIndex(cfg *PipelineConfig, declaration configkit.Path, pathsByID map[string]string) []string {
if cfg == nil || cfg.resolution == nil { if cfg == nil || cfg.resolution == nil {
return nil return nil
} }
pathsByID := make(map[string]string, len(cfg.resolution.configkitSources))
for _, source := range cfg.resolution.configkitSources {
path := source.Path
if path == "" {
path = source.Label
}
pathsByID[source.ID] = path
}
seen := map[string]struct{}{} seen := map[string]struct{}{}
for _, change := range cfg.resolution.configkitMetadata.History(declaration) { for _, change := range cfg.resolution.configkitMetadata.History(declaration) {
if change.Origin.Layer != configkit.LayerBase && change.Origin.Layer != configkit.LayerOverlay { if change.Origin.Layer != configkit.LayerMain && change.Origin.Layer != configkit.LayerOverlay {
continue continue
} }
for _, location := range change.Origin.Locations { for _, location := range change.Origin.Locations {
source := pathsByID[location.SourceID] seen[location.SourceID] = struct{}{}
if source == "" { }
source = location.SourceID for _, inheritance := range change.Origin.Inheritance {
for _, location := range inheritance.Locations {
seen[location.SourceID] = struct{}{}
} }
seen[source] = struct{}{}
} }
} }
if len(seen) == 0 { if len(seen) == 0 {
for _, ownership := range cfg.resolution.ownership { if info, ok := cfg.resolution.configkitMetadata.Lookup(declaration); ok {
if ownership.path != prefix && !strings.HasPrefix(ownership.path, prefix+".") { for _, location := range info.Origin.Locations {
continue seen[location.SourceID] = struct{}{}
} }
for _, source := range ownership.sources { for _, inheritance := range info.Origin.Inheritance {
if source != pipelineDefaultOwnershipSource && source != "resolution" { for _, location := range inheritance.Locations {
seen[source] = struct{}{} seen[location.SourceID] = struct{}{}
} }
} }
} }
} }
if len(seen) == 0 && cfg.resolution.rootPath != "" {
seen[cfg.resolution.rootPath] = struct{}{}
}
result := make([]string, 0, len(seen)) result := make([]string, 0, len(seen))
for source := range seen { for sourceID := range seen {
source := pathsByID[sourceID]
if source == "" {
source = sourceID
}
result = append(result, source) result = append(result, source)
} }
sort.Strings(result) sort.Strings(result)

View File

@@ -83,7 +83,7 @@ func expandPipelineArtifactFamilies(cfg *PipelineConfig, party ResolvedParty) er
Members: make([]string, 0, len(characters)), Members: make([]string, 0, len(characters)),
MemberDependencies: append([]string(nil), family.MemberDependencies...), MemberDependencies: append([]string(nil), family.MemberDependencies...),
Publish: cloneArtifactFamilyPublish(family.Publish), Publish: cloneArtifactFamilyPublish(family.Publish),
Source: artifactFamilySource(cfg, familyKey), Sources: artifactFamilyDefinitionSources(cfg, familyKey),
} }
for _, character := range characters { for _, character := range characters {
key := familyKey + "_" + character.ID key := familyKey + "_" + character.ID
@@ -116,7 +116,7 @@ func expandPipelineArtifactFamilies(cfg *PipelineConfig, party ResolvedParty) er
} }
outputOwners[outputPath] = key outputOwners[outputPath] = key
familyOrigin.Members = append(familyOrigin.Members, key) familyOrigin.Members = append(familyOrigin.Members, key)
catalog.Members[key] = ArtifactFamilyMemberOrigin{Family: familyKey, CharacterID: character.ID, Source: familyOrigin.Source, Dependencies: append([]string(nil), dependencies...), Inputs: inputSourceMap(inputs)} catalog.Members[key] = ArtifactFamilyMemberOrigin{Family: familyKey, CharacterID: character.ID, Dependencies: append([]string(nil), dependencies...), Inputs: inputSourceMap(inputs)}
} }
catalog.Families[familyKey] = familyOrigin catalog.Families[familyKey] = familyOrigin
} }
@@ -169,9 +169,6 @@ func expandFamilyPublishRules(cfg *PipelineConfig, catalog ArtifactFamilyCatalog
if family.Publish == nil || !family.Publish.Enabled { if family.Publish == nil || !family.Publish.Enabled {
continue continue
} }
if cfg.resolution == nil || !cfg.resolution.publishDeclared {
return fmt.Errorf("pipeline.scriptorium.artifact_families.%s.publish requires pipeline.publish", familyKey)
}
pattern := strings.TrimSpace(family.Publish.DestPattern) pattern := strings.TrimSpace(family.Publish.DestPattern)
if pattern != "" { if pattern != "" {
if err := validateFamilyOutputPattern("pipeline.scriptorium.artifact_families."+familyKey+".publish.dest_pattern", pattern); err != nil { if err := validateFamilyOutputPattern("pipeline.scriptorium.artifact_families."+familyKey+".publish.dest_pattern", pattern); err != nil {
@@ -354,31 +351,6 @@ func sortedFamilyKeys(families map[string]ScriptoriumArtifactFamilyConfig) []str
return keys return keys
} }
func artifactFamilySource(cfg *PipelineConfig, family string) string {
if cfg == nil || cfg.resolution == nil {
return ""
}
prefix := "scriptorium.artifact_families." + family + "."
var fallback string
for _, ownership := range cfg.resolution.ownership {
if !strings.HasPrefix(ownership.path, prefix) || len(ownership.sources) == 0 {
continue
}
for _, source := range ownership.sources {
if source != pipelineDefaultOwnershipSource {
return source
}
if fallback == "" {
fallback = source
}
}
}
if fallback != "" {
return fallback
}
return pipelineDefaultOwnershipSource
}
func cloneArtifactDefinitions(in map[string]ScriptoriumArtifactConfig) map[string]ScriptoriumArtifactConfig { func cloneArtifactDefinitions(in map[string]ScriptoriumArtifactConfig) map[string]ScriptoriumArtifactConfig {
if len(in) == 0 { if len(in) == 0 {
return map[string]ScriptoriumArtifactConfig{} return map[string]ScriptoriumArtifactConfig{}
@@ -450,6 +422,7 @@ func cloneArtifactFamilyPublish(in *ScriptoriumArtifactFamilyPublishConfig) *Scr
func cloneArtifactFamilyCatalog(in ArtifactFamilyCatalog) ArtifactFamilyCatalog { func cloneArtifactFamilyCatalog(in ArtifactFamilyCatalog) ArtifactFamilyCatalog {
out := ArtifactFamilyCatalog{Families: make(map[string]ArtifactFamilyOrigin, len(in.Families)), Members: make(map[string]ArtifactFamilyMemberOrigin, len(in.Members))} out := ArtifactFamilyCatalog{Families: make(map[string]ArtifactFamilyOrigin, len(in.Families)), Members: make(map[string]ArtifactFamilyMemberOrigin, len(in.Members))}
for key, family := range in.Families { for key, family := range in.Families {
family.Sources = append([]string(nil), family.Sources...)
family.Members = append([]string(nil), family.Members...) family.Members = append([]string(nil), family.Members...)
family.MemberDependencies = append([]string(nil), family.MemberDependencies...) family.MemberDependencies = append([]string(nil), family.MemberDependencies...)
family.Publish = cloneArtifactFamilyPublish(family.Publish) family.Publish = cloneArtifactFamilyPublish(family.Publish)

View File

@@ -90,13 +90,13 @@ characters:
t.Fatalf("zeta class summary = %#v", got) t.Fatalf("zeta class summary = %#v", got)
} }
catalog := ArtifactFamilies(cfg.Pipeline) catalog := ArtifactFamilies(cfg.Pipeline)
if got, want := catalog.Families["character_meta"].Source, absolutePath(t, pipelinePath); got != want { if got, want := catalog.Families["character_meta"].Sources, []string{absolutePath(t, pipelinePath)}; !reflect.DeepEqual(got, want) {
t.Fatalf("family source = %q, want %q", got, want) t.Fatalf("family sources = %#v, want %#v", got, want)
} }
if got := catalog.Families["character_meta"].Members; !reflect.DeepEqual(got, []string{"character_meta_alpha", "character_meta_zeta"}) { if got := catalog.Families["character_meta"].Members; !reflect.DeepEqual(got, []string{"character_meta_alpha", "character_meta_zeta"}) {
t.Fatalf("meta members = %#v", got) t.Fatalf("meta members = %#v", got)
} }
if got := catalog.Members["character_items_zeta"]; got.Family != "character_items" || got.CharacterID != "zeta" || got.Source == "" { if got := catalog.Members["character_items_zeta"]; got.Family != "character_items" || got.CharacterID != "zeta" {
t.Fatalf("zeta origin = %#v", got) t.Fatalf("zeta origin = %#v", got)
} }
@@ -312,8 +312,7 @@ func TestFamilyPublishRulesExpandToConcreteArtifacts(t *testing.T) {
"character_meta_alpha": {OutputPath: "artifacts/characters/alpha/meta.md"}, "character_meta_alpha": {OutputPath: "artifacts/characters/alpha/meta.md"},
"character_meta_zeta": {OutputPath: "artifacts/characters/zeta/meta.md"}, "character_meta_zeta": {OutputPath: "artifacts/characters/zeta/meta.md"},
}}, }},
Publish: &PublishConfig{}, Publish: &PublishConfig{},
resolution: &pipelineResolutionMetadata{publishDeclared: true},
} }
catalog := ArtifactFamilyCatalog{Families: map[string]ArtifactFamilyOrigin{ catalog := ArtifactFamilyCatalog{Families: map[string]ArtifactFamilyOrigin{
"character_meta": {Members: []string{"character_meta_alpha", "character_meta_zeta"}, Publish: &ScriptoriumArtifactFamilyPublishConfig{Enabled: true, Required: required, DestPattern: "published/{character_id}.md"}}, "character_meta": {Members: []string{"character_meta_alpha", "character_meta_zeta"}, Publish: &ScriptoriumArtifactFamilyPublishConfig{Enabled: true, Required: required, DestPattern: "published/{character_id}.md"}},
@@ -328,12 +327,192 @@ func TestFamilyPublishRulesExpandToConcreteArtifacts(t *testing.T) {
} }
cfg.Publish.Outputs = nil cfg.Publish.Outputs = nil
catalog.Families["character_meta"] = ArtifactFamilyOrigin{Members: []string{"character_meta_alpha"}, Publish: &ScriptoriumArtifactFamilyPublishConfig{Enabled: true}} catalog.Families["character_meta"] = ArtifactFamilyOrigin{Members: []string{"character_meta_alpha"}, Publish: &ScriptoriumArtifactFamilyPublishConfig{Enabled: true}}
cfg.resolution.publishDeclared = false cfg.Publish = nil
if err := expandFamilyPublishRules(cfg, catalog); err == nil || !strings.Contains(err.Error(), "requires pipeline.publish") { if err := expandFamilyPublishRules(cfg, catalog); err == nil || !strings.Contains(err.Error(), "requires pipeline.publish") {
t.Fatalf("missing publish error = %v", err) t.Fatalf("missing publish error = %v", err)
} }
} }
func TestArtifactFamilyInheritanceAcrossImports(t *testing.T) {
dir := t.TempDir()
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1
characters:
alice:
player: {name: Alice Player}
character:
name: Alice
classes: [{name: wizard}]
`)
pipeline := `config:
imports:
- path: families/summary.yml
- path: families/notes.yml
whisperx:
transcribe_url: https://transcription.example.test/transcribe
`
writePipelineFixture(t, dir, "families/summary.yml", `scriptorium:
artifact_families:
character_summary:
enabled: true
for_each: party.characters
prompt_id: dnd.character_summary
profile_id: production
output_path_pattern: artifacts/characters/{character_id}/summary.md
publish:
enabled: true
required: true
dest_pattern: published/characters/{character_id}/summary.md
`)
writePipelineFixture(t, dir, "families/notes.yml", `scriptorium:
artifact_families:
character_notes:
extends: character_summary
output_path_pattern: artifacts/characters/{character_id}/notes.md
publish:
dest_pattern: published/characters/{character_id}/notes.md
`)
pipelinePath, campaignPath, sessionPath := writeArtifactFamilyConfig(t, dir, pipeline)
cfg, err := LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
for key, wantPath := range map[string]string{
"character_summary_alice": "artifacts/characters/alice/summary.md",
"character_notes_alice": "artifacts/characters/alice/notes.md",
} {
artifact, ok := cfg.Pipeline.Scriptorium.Artifacts[key]
if !ok {
t.Fatalf("inherited family member %q is missing", key)
}
if !artifact.Enabled || artifact.PromptID != "dnd.character_summary" || artifact.ProfileID != "production" || artifact.OutputPath != wantPath {
t.Fatalf("expanded family member %q = %#v", key, artifact)
}
}
wantPublish := map[string]string{
"narratio.artifact.character_summary_alice": "published/characters/alice/summary.md",
"narratio.artifact.character_notes_alice": "published/characters/alice/notes.md",
}
for _, rule := range cfg.Pipeline.Publish.Outputs {
if want, ok := wantPublish[rule.Source]; ok {
if rule.Dest != want {
t.Errorf("family publish destination for %q = %q, want %q", rule.Source, rule.Dest, want)
}
delete(wantPublish, rule.Source)
}
}
if len(wantPublish) != 0 {
t.Fatalf("inherited family publish rules missing: %#v", wantPublish)
}
}
func TestInheritedAndExpandedConfigurationsHaveEqualEffectiveSemantics(t *testing.T) {
load := func(t *testing.T, expanded bool) *Config {
t.Helper()
dir := t.TempDir()
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1
characters:
alice:
player: {name: Alice Player}
character:
name: Alice
classes: [{name: wizard}]
`)
pipeline := `config:
imports:
- path: definitions/parent.yml
- path: definitions/child.yml
whisperx:
transcribe_url: https://transcription.example.test/transcribe
`
if expanded {
pipeline = `whisperx:
transcribe_url: https://transcription.example.test/transcribe
scriptorium:
artifacts:
base:
enabled: false
prompt_id: dnd.summary
profile_id: production
output_path: artifacts/base.md
render_debug: false
summary:
enabled: true
prompt_id: dnd.summary
profile_id: production
output_path: artifacts/summary.md
render_debug: false
artifact_families:
character_summary:
enabled: true
for_each: party.characters
prompt_id: dnd.character_summary
profile_id: production
output_path_pattern: artifacts/characters/{character_id}/summary.md
character_notes:
enabled: true
for_each: party.characters
prompt_id: dnd.character_summary
profile_id: production
output_path_pattern: artifacts/characters/{character_id}/notes.md
`
} else {
writePipelineFixture(t, dir, "definitions/parent.yml", `scriptorium:
artifacts:
base:
enabled: false
prompt_id: dnd.summary
profile_id: production
output_path: artifacts/base.md
render_debug: false
artifact_families:
character_summary:
enabled: true
for_each: party.characters
prompt_id: dnd.character_summary
profile_id: production
output_path_pattern: artifacts/characters/{character_id}/summary.md
`)
writePipelineFixture(t, dir, "definitions/child.yml", `scriptorium:
artifacts:
summary:
extends: base
enabled: true
output_path: artifacts/summary.md
artifact_families:
character_notes:
extends: character_summary
output_path_pattern: artifacts/characters/{character_id}/notes.md
`)
}
pipelinePath, campaignPath, sessionPath := writeArtifactFamilyConfig(t, dir, pipeline)
cfg, err := LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath, SessionLoadOptions{})
if err != nil {
t.Fatalf("LoadWithSessionOptions(expanded=%t): %v", expanded, err)
}
return cfg
}
inherited := load(t, false)
expanded := load(t, true)
inheritedValues, err := EffectivePipelineValues(inherited.Pipeline)
if err != nil {
t.Fatal(err)
}
expandedValues, err := EffectivePipelineValues(expanded.Pipeline)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(inheritedValues, expandedValues) {
t.Fatalf("inherited and expanded effective values differ:\ninherited=%#v\nexpanded=%#v", inheritedValues, expandedValues)
}
if inheritedDigest, expandedDigest := EffectivePipelineDigest(inherited.Pipeline), EffectivePipelineDigest(expanded.Pipeline); inheritedDigest != expandedDigest {
t.Fatalf("inherited and expanded digests differ: %q != %q", inheritedDigest, expandedDigest)
}
}
func TestExplicitFamilyMemberPublishDestinationResolution(t *testing.T) { func TestExplicitFamilyMemberPublishDestinationResolution(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1 writePartyResolutionFile(t, filepath.Join(dir, "party.yml"), `schema_version: narratio.party.v1

View File

@@ -90,7 +90,7 @@ func TestCampaignStrictDecodeAcceptsSessionTemplateFile(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("LoadWithSessionOptions() error = %v", err) t.Fatalf("LoadWithSessionOptions() error = %v", err)
} }
if cfg.Campaign.SessionTemplateFile != "./session.template.yml" { if cfg.Campaign.SessionTemplateFile != filepath.Join(filepath.Dir(campaignPath), "session.template.yml") {
t.Fatalf("SessionTemplateFile = %q, want ./session.template.yml", cfg.Campaign.SessionTemplateFile) t.Fatalf("SessionTemplateFile = %q, want ./session.template.yml", cfg.Campaign.SessionTemplateFile)
} }
} }
@@ -173,8 +173,8 @@ func TestCampaignSessionMergeSpellCatalog(t *testing.T) {
wantConfigPath = sessionPath wantConfigPath = sessionPath
} }
assertResolvedStableInput(t, cfg.StableInputs.SpellCatalogFile, tt.wantPath, wantConfigPath, tt.wantSource) assertResolvedStableInput(t, cfg.StableInputs.SpellCatalogFile, tt.wantPath, wantConfigPath, tt.wantSource)
if cfg.Session.Inputs.SpellCatalogFile != tt.wantPath { if cfg.Session.Inputs.SpellCatalogFile != cfg.StableInputs.SpellCatalogFile.Path {
t.Fatalf("session spell_catalog_file = %q, want %q", cfg.Session.Inputs.SpellCatalogFile, tt.wantPath) t.Fatalf("session spell_catalog_file = %q, want %q", cfg.Session.Inputs.SpellCatalogFile, cfg.StableInputs.SpellCatalogFile.Path)
} }
}) })
} }
@@ -275,6 +275,9 @@ func writeCampaignConfigTestFiles(t *testing.T, campaignYAML, sessionYAML string
func assertResolvedStableInput(t *testing.T, got ResolvedInputFile, wantPath, wantConfigPath, wantSource string) { func assertResolvedStableInput(t *testing.T, got ResolvedInputFile, wantPath, wantConfigPath, wantSource string) {
t.Helper() t.Helper()
if wantPath != "" && !filepath.IsAbs(wantPath) {
wantPath = filepath.Join(filepath.Dir(wantConfigPath), wantPath)
}
if got.Path != wantPath || got.ConfigPath != wantConfigPath || got.Source != wantSource { if got.Path != wantPath || got.ConfigPath != wantConfigPath || got.Source != wantSource {
t.Fatalf("resolved input = %#v, want path=%q config_path=%q source=%q", got, wantPath, wantConfigPath, wantSource) t.Fatalf("resolved input = %#v, want path=%q config_path=%q source=%q", got, wantPath, wantConfigPath, wantSource)
} }

View File

@@ -0,0 +1,50 @@
package config
import (
"reflect"
"strings"
"testing"
)
func TestAuthoredPublishOutputCollectionOperations(t *testing.T) {
dir := t.TempDir()
root := writePipelineFixture(t, dir, "pipeline.yml", `config:
sequences:
- destination: [publish, outputs]
key: source
publish:
outputs:
- {source: narratio.transcript.final_markdown, dest: transcripts/base.md, required: true}
`)
for _, tc := range []struct {
name string
mode string
body string
want []string
}{
{"append", "append", "[{source: narratio.transcript.final_trimmed, dest: transcripts/extra.json, required: false}]", []string{"transcripts/base.md", "transcripts/extra.json"}},
{"upsert", "upsert", "[{source: narratio.transcript.final_markdown, dest: transcripts/replaced.md, required: false}]", []string{"transcripts/replaced.md"}},
{"replace", "replace", "[]", []string{}},
{"empty append", "append", "[]", []string{"transcripts/base.md"}},
{"empty upsert", "upsert", "[]", []string{"transcripts/base.md"}},
} {
t.Run(tc.name, func(t *testing.T) {
selection := strings.ReplaceAll(tc.name, " ", "_")
writePipelineFixture(t, dir, "overlays/"+selection+".yml", "config:\n sequences:\n - destination: [publish, outputs]\n key: source\n mode: "+tc.mode+"\npublish:\n outputs: "+tc.body+"\n")
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Overlay: &selection})
if err != nil {
t.Fatal(err)
}
got := make([]string, 0, len(cfg.Publish.Outputs))
for _, output := range cfg.Publish.Outputs {
got = append(got, output.Dest)
}
if !reflect.DeepEqual(got, tc.want) {
t.Fatalf("output destinations = %v, want %v", got, tc.want)
}
if tc.name == "upsert" && (cfg.Publish.Outputs[0].Required == nil || *cfg.Publish.Outputs[0].Required) {
t.Fatal("upsert did not replace the whole matching output")
}
})
}
}

View File

@@ -1,16 +1,18 @@
package config package config
import configkit "gitea.maximumdirect.net/eric/ConfigKit" import configkit "go.maximumdirect.net/configkit"
// Config is the resolved combined configuration from pipeline.yml, // Config is the resolved combined configuration from pipeline.yml,
// campaign.yml, and session.yml. // campaign.yml, and session.yml.
type Config struct { type Config struct {
Pipeline *PipelineConfig Pipeline *PipelineConfig
Campaign *CampaignConfig Campaign *CampaignConfig
Session *SessionConfig Session *SessionConfig
PipelinePath string PipelinePath string
CampaignPath string CampaignPath string
SessionPath string SessionPath string
CampaignDocument *CampaignConfig
SessionDocument *SessionConfig
StableInputs ResolvedStableInputs StableInputs ResolvedStableInputs
SessionSource SessionSource SessionSource SessionSource
@@ -58,6 +60,7 @@ type CampaignConfig struct {
CampaignID string `yaml:"campaign_id" json:"campaign_id"` CampaignID string `yaml:"campaign_id" json:"campaign_id"`
SessionTemplateFile string `yaml:"session_template_file" json:"session_template_file"` SessionTemplateFile string `yaml:"session_template_file" json:"session_template_file"`
Inputs CampaignInputsConfig `yaml:"inputs" json:"inputs"` Inputs CampaignInputsConfig `yaml:"inputs" json:"inputs"`
resolution *documentResolution
} }
// CampaignInputsConfig contains stable campaign-level input file references. // CampaignInputsConfig contains stable campaign-level input file references.
@@ -77,6 +80,7 @@ type SessionConfig struct {
Date string `yaml:"date" json:"date"` Date string `yaml:"date" json:"date"`
Title string `yaml:"title" json:"title"` Title string `yaml:"title" json:"title"`
Inputs SessionInputsConfig `yaml:"inputs" json:"inputs"` Inputs SessionInputsConfig `yaml:"inputs" json:"inputs"`
resolution *documentResolution
} }
// WorkspaceConfig configures local workspace behavior. // WorkspaceConfig configures local workspace behavior.
@@ -277,12 +281,12 @@ type ArtifactFamilyCatalog struct {
Members map[string]ArtifactFamilyMemberOrigin Members map[string]ArtifactFamilyMemberOrigin
} }
// ArtifactFamilyOrigin records one declared family and its source ownership. // ArtifactFamilyOrigin records one declared family and its contributing sources.
type ArtifactFamilyOrigin struct { type ArtifactFamilyOrigin struct {
Members []string Members []string
MemberDependencies []string MemberDependencies []string
Publish *ScriptoriumArtifactFamilyPublishConfig Publish *ScriptoriumArtifactFamilyPublishConfig
Source string Sources []string
} }
// ArtifactFamilyMemberOrigin identifies the canonical party member that // ArtifactFamilyMemberOrigin identifies the canonical party member that
@@ -290,7 +294,6 @@ type ArtifactFamilyOrigin struct {
type ArtifactFamilyMemberOrigin struct { type ArtifactFamilyMemberOrigin struct {
Family string Family string
CharacterID string CharacterID string
Source string
Dependencies []string Dependencies []string
Inputs map[string]string Inputs map[string]string
} }

View File

@@ -1,6 +1,6 @@
package config package config
import configkit "gitea.maximumdirect.net/eric/ConfigKit" import configkit "go.maximumdirect.net/configkit"
// MarshalYAML exposes only public credential reference names. Resolved values // MarshalYAML exposes only public credential reference names. Resolved values
// remain available solely through ConfigKit's explicit trusted accessor. // remain available solely through ConfigKit's explicit trusted accessor.

View File

@@ -5,16 +5,14 @@ import "gitea.maximumdirect.net/eric/narratio/internal/artifactmodel"
// Default filesystem locations for config lookup when config path flags are // Default filesystem locations for config lookup when config path flags are
// omitted. Order is highest to lowest precedence. // omitted. Order is highest to lowest precedence.
const ( const (
DefaultPipelineConfigPathUsrLocal = "/usr/local/etc/narratio/pipeline.yml" DefaultSessionConfigPathUsrLocal = "/usr/local/etc/narratio/session.yml"
DefaultPipelineConfigPathEtc = "/etc/narratio/pipeline.yml" DefaultSessionConfigPathEtc = "/etc/narratio/session.yml"
DefaultSessionConfigPathUsrLocal = "/usr/local/etc/narratio/session.yml" DefaultStorageS3RootPrefix = "dnd"
DefaultSessionConfigPathEtc = "/etc/narratio/session.yml" DefaultWorkspaceRoot = "/var/lib/narratio"
DefaultStorageS3RootPrefix = "dnd" DefaultCampaignsRoot = "/usr/local/share/narratio/campaigns"
DefaultWorkspaceRoot = "/var/lib/narratio" DefaultSpoolRoot = "/var/spool/narratio"
DefaultCampaignsRoot = "/usr/local/share/narratio/campaigns" DefaultCacheRoot = "/var/cache/narratio"
DefaultSpoolRoot = "/var/spool/narratio" DefaultCacheS3Audio = true
DefaultCacheRoot = "/var/cache/narratio"
DefaultCacheS3Audio = true
DefaultWhisperXLanguage = "en" DefaultWhisperXLanguage = "en"
DefaultWhisperXTimeout = "30m" DefaultWhisperXTimeout = "30m"
@@ -104,16 +102,6 @@ var DefaultPublishOutputs = []PublishOutputRule{
{Source: artifactmodel.SourceTranscriptFinalTrimmedMarkdown, Dest: artifactmodel.TranscriptPathFinalTrimmedMarkdown}, {Source: artifactmodel.SourceTranscriptFinalTrimmedMarkdown, Dest: artifactmodel.TranscriptPathFinalTrimmedMarkdown},
} }
// DefaultPipelineConfigSearchPaths defines the default search order for
// pipeline.yml when callers do not provide an explicit path.
//
// Keep this in a variable so future defaults can be extended without changing
// call sites.
var DefaultPipelineConfigSearchPaths = []string{
DefaultPipelineConfigPathUsrLocal,
DefaultPipelineConfigPathEtc,
}
// DefaultSessionConfigSearchPaths defines the default search order for // DefaultSessionConfigSearchPaths defines the default search order for
// session.yml when callers do not provide an explicit path. // session.yml when callers do not provide an explicit path.
// //

View File

@@ -1,32 +1,142 @@
package config package config
import ( import (
"encoding/json"
"fmt" "fmt"
"os"
"path/filepath"
configkit "gitea.maximumdirect.net/eric/ConfigKit" configkit "go.maximumdirect.net/configkit"
) )
const maxConfigDocumentBytes int64 = 8 << 20 const maxConfigDocumentBytes int64 = 8 << 20
type documentResolution struct {
campaign *configkit.Result[CampaignConfig]
session *configkit.Result[SessionConfig]
sources map[string]string
}
func documentResource(resolution *configkit.Resolution, path configkit.Path, value *string, invocationDir string, sources map[string]string) {
if info, ok := resolution.EntryInfo(path); ok && len(info.Origin.Locations) == 1 {
if source, ok := resolution.Source(info.Origin.Locations[0].SourceID); ok {
name := source.Path
if name == "" {
name = source.Label
}
sources[path.String()] = name
}
}
resolveHostResource(resolution, path, value, invocationDir)
}
func campaignDefinition(invocationDir string, sources map[string]string) configkit.Definition[CampaignConfig] {
return configkit.Definition[CampaignConfig]{Resolve: func(cfg *CampaignConfig, resolution *configkit.Resolution) error {
documentResource(resolution, configkit.Keys("session_template_file"), &cfg.SessionTemplateFile, invocationDir, sources)
inputs := configkit.Keys("inputs")
for _, field := range []struct {
name string
value *string
}{
{"speakers_file", &cfg.Inputs.SpeakersFile}, {"autocorrect_file", &cfg.Inputs.AutocorrectFile},
{"glossary_file", &cfg.Inputs.GlossaryFile}, {"party_file", &cfg.Inputs.PartyFile},
{"spell_catalog_file", &cfg.Inputs.SpellCatalogFile},
} {
documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources)
}
return nil
}}
}
func sessionDefinition(invocationDir string, sources map[string]string) configkit.Definition[SessionConfig] {
return configkit.Definition[SessionConfig]{Resolve: func(cfg *SessionConfig, resolution *configkit.Resolution) error {
inputs := configkit.Keys("inputs")
for _, field := range []struct {
name string
value *string
}{
{"audio_dir", &cfg.Inputs.AudioDir}, {"speakers_file", &cfg.Inputs.SpeakersFile},
{"autocorrect_file", &cfg.Inputs.AutocorrectFile}, {"glossary_file", &cfg.Inputs.GlossaryFile},
{"spell_catalog_file", &cfg.Inputs.SpellCatalogFile},
} {
documentResource(resolution, inputs.Key(field.name), field.value, invocationDir, sources)
}
for index := range cfg.Inputs.AudioFiles {
documentResource(resolution, inputs.Key("audio_files").Index(index), &cfg.Inputs.AudioFiles[index], invocationDir, sources)
}
return nil
}}
}
func loadCampaignWithConfigKit(path string) (*CampaignConfig, error) { func loadCampaignWithConfigKit(path string) (*CampaignConfig, error) {
result, err := configkit.Load(configkit.File(path), configkit.Options[CampaignConfig]{ invocationDir, err := os.Getwd()
Definition: configkit.Definition[CampaignConfig]{}, if err != nil {
}) return nil, err
}
sources := make(map[string]string)
result, err := configkit.Load(configkit.File(path), configkit.Options[CampaignConfig]{Imports: true, Definition: campaignDefinition(invocationDir, sources)})
if err != nil { if err != nil {
return nil, describeConfigKitLoadError("campaign", err) return nil, describeConfigKitLoadError("campaign", err)
} }
return &result.Config, nil cfg := result.Config
cfg.resolution = &documentResolution{campaign: result, sources: sources}
return &cfg, nil
} }
func loadSessionWithConfigKit(label string, data []byte) (*SessionConfig, error) { func loadSessionSource(source configkit.Source, label string, opts SessionLoadOptions, imports bool) (*SessionConfig, string, error) {
if int64(len(data)) > maxConfigDocumentBytes { return loadSessionSourceWithFilesystem(source, label, opts, imports, nil)
return nil, fmt.Errorf("load session config: session file %q exceeds %d-byte limit", label, maxConfigDocumentBytes) }
}
result, err := configkit.Load(configkit.Bytes(label, data), configkit.Options[SessionConfig]{ // LoadSessionAuthoringBytes resolves a rendered local document before moving or
Definition: configkit.Definition[SessionConfig]{}, // publishing it. The path supplies its authoring base without writing that file.
}) func LoadSessionAuthoringBytes(path string, data []byte, opts SessionLoadOptions) (*SessionConfig, error) {
if err != nil { absolute, err := filepath.Abs(path)
return nil, describeConfigKitLoadError("session", err) if err != nil {
} return nil, err
return &result.Config, nil }
filesystem := &configkit.FilesystemContext{BaseDir: filepath.Dir(absolute), Root: string(filepath.Separator)}
cfg, _, err := loadSessionSourceWithFilesystem(configkit.Bytes(absolute, data), absolute, opts, true, filesystem)
return cfg, err
}
func loadSessionSourceWithFilesystem(source configkit.Source, label string, opts SessionLoadOptions, imports bool, filesystem *configkit.FilesystemContext) (*SessionConfig, string, error) {
invocationDir, err := os.Getwd()
if err != nil {
return nil, "", err
}
if filesystem != nil {
invocationDir = filesystem.BaseDir
}
sources := make(map[string]string)
result, err := configkit.Load(source, configkit.Options[SessionConfig]{Imports: imports, Filesystem: filesystem, Definition: sessionDefinition(invocationDir, sources)})
if err != nil {
return nil, "", describeConfigKitLoadError("session", err)
}
acquired := result.Sources()
if len(acquired) == 0 {
return nil, "", nil
}
selected := acquired[0].Path
if selected == "" {
selected = label
}
cfg := result.Config
data, err := json.Marshal(cfg)
if err != nil {
return nil, "", fmt.Errorf("inspect session config: %w", err)
}
if err := rejectSessionTemplatePlaceholders(selected, string(data)); err != nil {
return nil, "", fmt.Errorf("load session config: %w", err)
}
if err := validateSessionIdentity(selected, &cfg, opts); err != nil {
return nil, "", err
}
cfg.resolution = &documentResolution{session: result, sources: sources}
return &cfg, filepath.Clean(selected), nil
}
// DiscoverSession loads the first selected local candidate, or returns nil when
// none exists. A selected but invalid source is an error.
func DiscoverSession(candidates []string, opts SessionLoadOptions) (*SessionConfig, string, error) {
return loadSessionSource(configkit.SearchConfig("narratio", configkit.SearchPaths(candidates...)), "", opts, true)
} }

View File

@@ -8,32 +8,20 @@ import (
"testing" "testing"
) )
func TestSingleSourceDocumentsRejectConfigKitDirectives(t *testing.T) { func TestContextlessDocumentsRejectImports(t *testing.T) {
dir := t.TempDir() for _, load := range []func() error{
campaignPath := filepath.Join(dir, "campaign.yml") func() error {
if err := os.WriteFile(campaignPath, []byte("configkit:\n imports: []\ncampaign_id: sample\n"), 0o644); err != nil { _, err := LoadSessionBytesWithOptions("remote", []byte("config:\n imports: []\nsession_id: sample\n"), SessionLoadOptions{})
t.Fatal(err)
}
tests := []struct {
name string
load func() error
}{
{name: "campaign", load: func() error { _, err := LoadCampaign(campaignPath); return err }},
{name: "session", load: func() error {
_, err := LoadSessionBytesWithOptions("session.yml", []byte("configkit:\n imports: []\nsession_id: sample\n"), SessionLoadOptions{})
return err return err
}}, },
{name: "party", load: func() error { func() error {
_, err := ParseParty([]byte("configkit:\n imports: []\nschema_version: narratio.party.v1\ncharacters: {}\n")) _, err := ParseParty([]byte("config:\n imports: []\nschema_version: narratio.party.v1\ncharacters: {}\n"))
return err return err
}}, },
} } {
for _, test := range tests { if err := load(); err == nil || !strings.Contains(err.Error(), "import.disabled") {
t.Run(test.name, func(t *testing.T) { t.Fatalf("load error = %v, want disabled-import diagnostic", err)
if err := test.load(); err == nil || !strings.Contains(err.Error(), "import.disabled") { }
t.Fatalf("load error = %v, want disabled-import diagnostic", err)
}
})
} }
} }

View File

@@ -0,0 +1,130 @@
package config
import (
"os"
"path/filepath"
"strings"
"testing"
)
func TestImportedCampaignAndSessionResourcesRetainTheirSources(t *testing.T) {
dir := t.TempDir()
pipeline := writePipelineFixture(t, dir, "pipeline.yml", "workspace: {root: /tmp/narratio}\n")
campaign := writePipelineFixture(t, dir, "campaign.yml", "config:\n imports:\n - path: campaign/shared.yml\ncampaign_id: sample\n")
fragment := writePipelineFixture(t, dir, "campaign/shared.yml", `session_template_file: templates/session.yml
inputs:
speakers_file: speakers.yml
autocorrect_file: autocorrect.yml
glossary_file: glossary.yml
party_file: party.yml
`)
writePipelineFixture(t, dir, "campaign/party.yml", canonicalPartyFixture)
session := writePipelineFixture(t, dir, "session.yml", "config:\n imports:\n - path: session/inputs.yml\nsession_id: sample-session\n")
sessionFragment := writePipelineFixture(t, dir, "session/inputs.yml", "inputs:\n speakers_file: override.yml\n audio_files: [a.flac, b.flac]\n")
cfg, err := LoadWithSessionOptions(pipeline, campaign, session, SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
if cfg.Campaign.SessionTemplateFile != filepath.Join(dir, "campaign/templates/session.yml") {
t.Fatalf("template = %q", cfg.Campaign.SessionTemplateFile)
}
if got := cfg.StableInputs.SpeakersFile; got.Path != filepath.Join(dir, "session/override.yml") || got.ConfigPath != sessionFragment {
t.Fatalf("session override = %#v", got)
}
if got := cfg.StableInputs.GlossaryFile; got.Path != filepath.Join(dir, "campaign/glossary.yml") || got.ConfigPath != fragment {
t.Fatalf("campaign input = %#v", got)
}
if cfg.Party.Source.ConfigPath != fragment || cfg.Party.Source.Path != filepath.Join(dir, "campaign/party.yml") {
t.Fatalf("party source = %#v", cfg.Party.Source)
}
for i, name := range []string{"a.flac", "b.flac"} {
if got := cfg.Session.Inputs.AudioFiles[i]; got != filepath.Join(dir, "session", name) {
t.Fatalf("audio[%d] = %q", i, got)
}
}
if cfg.SessionDocument.Inputs.GlossaryFile != "" || cfg.SessionDocument.Inputs.SpeakersFile != filepath.Join(dir, "session/override.yml") {
t.Fatalf("detached session = %#v", cfg.SessionDocument)
}
if cfg.CampaignDocument.Inputs.GlossaryFile != filepath.Join(dir, "campaign/glossary.yml") {
t.Fatalf("detached campaign = %#v", cfg.CampaignDocument)
}
}
func TestSessionDiscoveryDistinguishesAbsenceFromInvalidSelection(t *testing.T) {
dir := t.TempDir()
first := filepath.Join(dir, "first.yml")
second := writePipelineFixture(t, dir, "second.yml", "session_id: valid\n")
if cfg, path, err := DiscoverSession([]string{first, second}, SessionLoadOptions{}); err != nil || cfg == nil || path != second {
t.Fatalf("selected = %#v %q %v", cfg, path, err)
}
if _, _, err := DiscoverSession([]string{first, second}, SessionLoadOptions{SessionID: "different"}); err == nil || !strings.Contains(err.Error(), "mismatch") {
t.Fatalf("identity error = %v", err)
}
if err := os.WriteFile(first, []byte("inputs: [invalid\n"), 0o644); err != nil {
t.Fatal(err)
}
if _, _, err := DiscoverSession([]string{first, second}, SessionLoadOptions{}); err == nil {
t.Fatal("invalid first candidate fell through")
}
if cfg, path, err := DiscoverSession([]string{filepath.Join(dir, "absent.yml")}, SessionLoadOptions{}); err != nil || cfg != nil || path != "" {
t.Fatalf("absent result = %#v %q %v", cfg, path, err)
}
}
func TestImportedSessionPlaceholderIsRejected(t *testing.T) {
dir := t.TempDir()
root := writePipelineFixture(t, dir, "session.yml", "config:\n imports:\n - path: fragment.yml\nsession_id: test\n")
writePipelineFixture(t, dir, "fragment.yml", "title: '{{ title }}'\n")
if _, err := LoadSession(root); err == nil || !strings.Contains(err.Error(), "title") || !strings.Contains(err.Error(), "session init") {
t.Fatalf("placeholder error = %v", err)
}
}
func TestRemoteSessionResourceBaseIgnoresDiagnosticLabel(t *testing.T) {
invocation, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
for _, label := range []string{"s3://bucket/session.yml", filepath.Join(t.TempDir(), "download.yml")} {
cfg, err := LoadSessionBytesWithOptions(label, []byte("session_id: test\ninputs: {audio_dir: ./audio}\n"), SessionLoadOptions{})
if err != nil {
t.Fatal(err)
}
if got := cfg.Inputs.AudioDir; got != filepath.Join(invocation, "audio") {
t.Fatalf("resource from %q = %q", label, got)
}
}
}
func TestEquivalentDocumentLayoutsRenderIdentically(t *testing.T) {
dir := t.TempDir()
firstCampaign := writePipelineFixture(t, dir, "first-campaign.yml", "campaign_id: sample\ninputs: {speakers_file: shared/speakers.yml}\n")
secondCampaign := writePipelineFixture(t, dir, "second-campaign.yml", "config:\n imports:\n - path: shared/campaign.yml\ncampaign_id: sample\n")
writePipelineFixture(t, dir, "shared/campaign.yml", "inputs: {speakers_file: speakers.yml}\n")
firstSession := writePipelineFixture(t, dir, "first-session.yml", "session_id: sample\ninputs: {audio_dir: shared/audio}\n")
secondSession := writePipelineFixture(t, dir, "second-session.yml", "config:\n imports:\n - path: shared/session.yml\nsession_id: sample\n")
writePipelineFixture(t, dir, "shared/session.yml", "inputs: {audio_dir: audio}\n")
var campaigns, sessions [2][]byte
for i, files := range [][2]string{{firstCampaign, firstSession}, {secondCampaign, secondSession}} {
campaign, err := LoadCampaign(files[0])
if err != nil {
t.Fatal(err)
}
session, err := LoadSession(files[1])
if err != nil {
t.Fatal(err)
}
cfg := &Config{Campaign: campaign, Session: session, CampaignDocument: campaign, SessionDocument: session}
campaigns[i], err = RenderCampaignDocument(cfg)
if err != nil {
t.Fatal(err)
}
sessions[i], err = RenderSessionDocument(cfg, "sample")
if err != nil {
t.Fatal(err)
}
}
if string(campaigns[0]) != string(campaigns[1]) || string(sessions[0]) != string(sessions[1]) {
t.Fatalf("equivalent documents differ: %q / %q; %q / %q", campaigns[0], campaigns[1], sessions[0], sessions[1])
}
}

View File

@@ -0,0 +1,70 @@
package config
import (
"fmt"
"gopkg.in/yaml.v3"
)
type renderedCampaignInputs struct {
SpeakersFile string `yaml:"speakers_file,omitempty"`
AutocorrectFile string `yaml:"autocorrect_file,omitempty"`
GlossaryFile string `yaml:"glossary_file,omitempty"`
PartyFile string `yaml:"party_file,omitempty"`
SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"`
}
// RenderCampaignDocument serializes the loaded effective campaign document.
func RenderCampaignDocument(cfg *Config) ([]byte, error) {
if cfg == nil {
return nil, fmt.Errorf("campaign document is required")
}
doc := cfg.CampaignDocument
if doc == nil {
doc = cfg.Campaign
}
if doc == nil {
return nil, fmt.Errorf("campaign document is required")
}
value := struct {
CampaignID string `yaml:"campaign_id"`
SessionTemplateFile string `yaml:"session_template_file,omitempty"`
Inputs renderedCampaignInputs `yaml:"inputs"`
}{doc.CampaignID, doc.SessionTemplateFile, renderedCampaignInputs{
doc.Inputs.SpeakersFile, doc.Inputs.AutocorrectFile, doc.Inputs.GlossaryFile, doc.Inputs.PartyFile, doc.Inputs.SpellCatalogFile,
}}
return yaml.Marshal(value)
}
// RenderSessionDocument serializes the session's own fields and actual identity.
func RenderSessionDocument(cfg *Config, sessionID string) ([]byte, error) {
if cfg == nil || cfg.Session == nil {
return nil, fmt.Errorf("session document is required")
}
doc := cfg.SessionDocument
if doc == nil {
doc = cfg.Session
}
id := cfg.Session.SessionID
if id == "" {
id = sessionID
}
inputs := struct {
AudioDir string `yaml:"audio_dir,omitempty"`
AudioFiles []string `yaml:"audio_files,omitempty"`
AudioS3 *SessionAudioS3Input `yaml:"audio_s3,omitempty"`
SpeakersFile string `yaml:"speakers_file,omitempty"`
AutocorrectFile string `yaml:"autocorrect_file,omitempty"`
GlossaryFile string `yaml:"glossary_file,omitempty"`
SpellCatalogFile string `yaml:"spell_catalog_file,omitempty"`
}{doc.Inputs.AudioDir, doc.Inputs.AudioFiles, doc.Inputs.AudioS3, doc.Inputs.SpeakersFile, doc.Inputs.AutocorrectFile, doc.Inputs.GlossaryFile, doc.Inputs.SpellCatalogFile}
value := struct {
SessionID string `yaml:"session_id"`
PreviousSessionID string `yaml:"previous_session_id,omitempty"`
Campaign string `yaml:"campaign,omitempty"`
Date string `yaml:"date,omitempty"`
Title string `yaml:"title,omitempty"`
Inputs any `yaml:"inputs"`
}{id, cfg.Session.PreviousSessionID, cfg.Session.Campaign, doc.Date, doc.Title, inputs}
return yaml.Marshal(value)
}

View File

@@ -4,14 +4,13 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"path/filepath"
"sort" configkit "go.maximumdirect.net/configkit"
"strings"
) )
const ( const (
pipelineDefaultOwnershipSource = "default" pipelineDefaultOwnershipSource = "default"
effectivePipelineDigestVersion = "narratio-effective-pipeline-v3\n" effectivePipelineDigestVersion = "narratio-effective-pipeline-v4\n"
) )
// PipelineOverlayProvenance identifies the overlay selected while resolving a // PipelineOverlayProvenance identifies the overlay selected while resolving a
@@ -44,31 +43,6 @@ func finalizePipelineResolution(cfg *PipelineConfig) error {
if cfg == nil || cfg.resolution == nil { if cfg == nil || cfg.resolution == nil {
return fmt.Errorf("pipeline resolution metadata is required") return fmt.Errorf("pipeline resolution metadata is required")
} }
declared := make(map[string][]string, len(cfg.resolution.ownership))
for _, ownership := range cfg.resolution.ownership {
declared[ownership.path] = append([]string(nil), ownership.sources...)
}
records, err := projectionValueRecords(projectEffectivePipeline(cfg, true))
if err != nil {
return err
}
ownership := make([]pipelineFieldOwnership, 0, len(records))
for _, record := range records {
sources := declared[record.Path]
if len(sources) == 0 {
sources = []string{pipelineDefaultOwnershipSource}
}
ownership = append(ownership, pipelineFieldOwnership{
path: record.Path, sources: append([]string(nil), sources...),
})
}
for path, sources := range declared {
if strings.HasPrefix(path, "scriptorium.artifact_families.") {
ownership = append(ownership, pipelineFieldOwnership{path: path, sources: append([]string(nil), sources...)})
}
}
sort.Slice(ownership, func(i, j int) bool { return ownership[i].path < ownership[j].path })
cfg.resolution.ownership = ownership
return recomputePipelineEffectiveDigest(cfg) return recomputePipelineEffectiveDigest(cfg)
} }
@@ -79,34 +53,30 @@ func recomputePipelineEffectiveDigest(cfg *PipelineConfig) error {
if cfg == nil || cfg.resolution == nil { if cfg == nil || cfg.resolution == nil {
return fmt.Errorf("pipeline resolution metadata is required") return fmt.Errorf("pipeline resolution metadata is required")
} }
canonical, err := projectionJSON(projectEffectivePipeline(cfg, true)) snapshot, err := newPipelineInspection(cfg)
if err != nil {
return err
}
canonical, err := projectionJSON(snapshot.Config)
if err != nil { if err != nil {
return err return err
} }
digestInput := append([]byte(effectivePipelineDigestVersion), canonical...) digestInput := append([]byte(effectivePipelineDigestVersion), canonical...)
digest := sha256.Sum256(digestInput) digest := sha256.Sum256(digestInput)
cfg.resolution.effectiveDigest = hex.EncodeToString(digest[:]) cfg.resolution.effectiveDigest = hex.EncodeToString(digest[:])
cfg.resolution.inspection = snapshot
return nil return nil
} }
// captureLogicalNotariusPaths retains normalized user-facing path semantics func newPipelineInspection(cfg *PipelineConfig) (*configkit.Result[effectivePipelineProjection], error) {
// before runtime resolution makes relative paths depend on the checkout or projection := projectEffectivePipeline(cfg)
// installation directory. Runtime paths remain absolute; provenance does not. return configkit.Load(configkit.NoSource(), configkit.Options[effectivePipelineProjection]{Definition: configkit.Definition[effectivePipelineProjection]{Defaults: func() effectivePipelineProjection { return projection }}})
func captureLogicalNotariusPaths(cfg *PipelineConfig) {
if cfg == nil || cfg.resolution == nil || cfg.Notarius == nil {
return
}
configPath := normalizeLogicalFilesystemPath(cfg.Notarius.ConfigPath)
workingDirectory := normalizeLogicalFilesystemPath(cfg.Notarius.WorkingDirectory)
cfg.resolution.logicalNotariusConfig = configPath
cfg.resolution.logicalNotariusWorking = workingDirectory
cfg.resolution.logicalNotariusCaptured = true
} }
func normalizeLogicalFilesystemPath(value string) string { // DiffEffectivePipelines compares frozen final-domain snapshots.
value = strings.TrimSpace(value) func DiffEffectivePipelines(left, right *PipelineConfig) ([]configkit.Difference, error) {
if value == "" { if left == nil || right == nil || left.resolution == nil || right.resolution == nil {
return "" return nil, fmt.Errorf("resolved pipelines are required")
} }
return filepath.ToSlash(filepath.Clean(value)) return configkit.Diff(left.resolution.inspection, right.resolution.inspection)
} }

View File

@@ -1,14 +1,13 @@
package config package config
import ( import (
"encoding/json" "bytes"
"fmt" "fmt"
"path/filepath" "path/filepath"
"sort" "sort"
"strconv"
"strings" "strings"
"gopkg.in/yaml.v3" configkit "go.maximumdirect.net/configkit"
) )
// EffectivePipelineRootPath reports the absolute root pipeline path retained // EffectivePipelineRootPath reports the absolute root pipeline path retained
@@ -46,6 +45,44 @@ type EffectivePipelineSourceRecord struct {
Source string Source string
} }
// EmptyImportSelection describes a native optional selection that acquired no source.
type EmptyImportSelection struct {
Source string
Path string
Selector string
Line int
Column int
}
func emptyImportSelections[T any](result *configkit.Result[T]) []EmptyImportSelection {
if result == nil {
return nil
}
var selections []EmptyImportSelection
for _, source := range result.Sources() {
name := source.Path
if name == "" {
name = source.Label
}
for _, item := range source.EmptyImportSelections {
selections = append(selections, EmptyImportSelection{Source: name, Path: item.Path.String(), Selector: string(item.Selector), Line: item.Location.Line, Column: item.Location.Column})
}
}
return selections
}
// EffectiveEmptyImports reports only optional selections that acquired nothing.
func EffectiveEmptyImports(pipeline *PipelineConfig, campaign *CampaignConfig) []EmptyImportSelection {
var result []EmptyImportSelection
if pipeline != nil && pipeline.resolution != nil {
result = append(result, emptyImportSelections(pipeline.resolution.authoring)...)
}
if campaign != nil && campaign.resolution != nil {
result = append(result, emptyImportSelections(campaign.resolution.campaign)...)
}
return result
}
// EffectivePipelineValueRecord identifies one normalized, secret-free // EffectivePipelineValueRecord identifies one normalized, secret-free
// effective configuration value. Values use deterministic compact JSON // effective configuration value. Values use deterministic compact JSON
// representations so command output can be compared without raw YAML layout. // representations so command output can be compared without raw YAML layout.
@@ -62,7 +99,7 @@ func EffectivePipelineValues(cfg *PipelineConfig) ([]EffectivePipelineValueRecor
if cfg == nil { if cfg == nil {
return nil, fmt.Errorf("pipeline config is required") return nil, fmt.Errorf("pipeline config is required")
} }
return projectionValueRecords(projectEffectivePipeline(cfg, true)) return projectionValueRecords(projectEffectivePipeline(cfg))
} }
// EffectivePipelineSources projects pipeline ownership after defaults and // EffectivePipelineSources projects pipeline ownership after defaults and
@@ -80,8 +117,12 @@ func EffectivePipelineSources(cfg *PipelineConfig, party ResolvedParty) ([]Effec
for _, value := range values { for _, value := range values {
paths = append(paths, value.Path) paths = append(paths, value.Path)
} }
owners := effectivePipelineOwners(cfg) owners, err := effectivePipelineOwners(cfg)
if err != nil {
return nil, err
}
families := ArtifactFamilies(cfg) families := ArtifactFamilies(cfg)
partySources := partyCharacterSourceLookup(party)
publishCount := 0 publishCount := 0
if cfg.Publish != nil { if cfg.Publish != nil {
publishCount = len(cfg.Publish.Outputs) publishCount = len(cfg.Publish.Outputs)
@@ -92,7 +133,7 @@ func EffectivePipelineSources(cfg *PipelineConfig, party ResolvedParty) ([]Effec
continue continue
} }
if familyKey, ok := generatedArtifactFamilyForPath(path, families); ok { if familyKey, ok := generatedArtifactFamilyForPath(path, families); ok {
records = appendGeneratedArtifactSources(records, path, familyKey, families, owners, party) records = appendGeneratedArtifactSources(records, path, familyKey, families, owners, partySources)
continue continue
} }
records = appendPipelineOwners(records, path, owners[path], cfg) records = appendPipelineOwners(records, path, owners[path], cfg)
@@ -117,15 +158,19 @@ func EffectiveCampaignSources(campaignPath string, campaign *CampaignConfig, par
if campaign == nil { if campaign == nil {
return nil return nil
} }
campaignSource := normalizedProvenancePath(campaignPath) fields := []string{"campaign_id", "inputs.autocorrect_file", "inputs.glossary_file", "inputs.speakers_file", "inputs.party_file"}
records := []EffectivePipelineSourceRecord{
{Path: "campaign.campaign_id", Role: "campaign", Source: campaignSource},
{Path: "campaign.inputs.autocorrect_file", Role: "campaign", Source: campaignSource},
{Path: "campaign.inputs.glossary_file", Role: "campaign", Source: campaignSource},
{Path: "campaign.inputs.speakers_file", Role: "campaign", Source: campaignSource},
}
if strings.TrimSpace(campaign.Inputs.SpellCatalogFile) != "" { if strings.TrimSpace(campaign.Inputs.SpellCatalogFile) != "" {
records = append(records, EffectivePipelineSourceRecord{Path: "campaign.inputs.spell_catalog_file", Role: "campaign", Source: campaignSource}) fields = append(fields, "inputs.spell_catalog_file")
}
var records []EffectivePipelineSourceRecord
for _, field := range fields {
sources := campaignDefinitionSources(campaign, configkit.Keys(strings.Split(field, ".")...))
if len(sources) == 0 {
sources = []string{campaignPath}
}
for _, source := range sources {
records = append(records, EffectivePipelineSourceRecord{Path: "campaign." + field, Role: "campaign", Source: normalizedProvenancePath(source)})
}
} }
partySource := normalizedProvenancePath(party.Source.Path) partySource := normalizedProvenancePath(party.Source.Path)
records = append(records, records = append(records,
@@ -144,6 +189,43 @@ func EffectiveCampaignSources(campaignPath string, campaign *CampaignConfig, par
return records return records
} }
func campaignDefinitionSources(campaign *CampaignConfig, path configkit.Path) []string {
if campaign.resolution == nil || campaign.resolution.campaign == nil {
return nil
}
result := campaign.resolution.campaign
var ids []string
add := func(origin configkit.Origin) {
for _, location := range origin.Locations {
ids = append(ids, location.SourceID)
}
for _, step := range origin.Inheritance {
for _, location := range step.Locations {
ids = append(ids, location.SourceID)
}
}
}
if info, ok := result.Metadata().Lookup(path); ok {
add(info.Origin)
}
for _, change := range result.Metadata().History(path) {
if change.Origin.Layer == configkit.LayerMain || change.Origin.Layer == configkit.LayerOverlay {
add(change.Origin)
}
}
var sources []string
for _, id := range nonEmptySortedStrings(ids) {
if source, ok := result.Source(id); ok {
name := source.Path
if name == "" {
name = source.Label
}
sources = append(sources, name)
}
}
return nonEmptySortedStrings(sources)
}
// MarshalEffectivePipeline renders the validated, normalized pipeline as one // MarshalEffectivePipeline renders the validated, normalized pipeline as one
// deterministic YAML document. Composition declarations and runtime-only // deterministic YAML document. Composition declarations and runtime-only
// resolution data are excluded. Artifact family declarations are also omitted // resolution data are excluded. Artifact family declarations are also omitted
@@ -153,79 +235,57 @@ func MarshalEffectivePipeline(cfg *PipelineConfig) ([]byte, error) {
return nil, fmt.Errorf("pipeline config is required") return nil, fmt.Errorf("pipeline config is required")
} }
value, err := projectionValueTree(projectEffectivePipeline(cfg, true)) var snapshot *configkit.Result[effectivePipelineProjection]
if cfg.resolution != nil {
snapshot = cfg.resolution.inspection
}
if snapshot == nil {
var err error
snapshot, err = newPipelineInspection(cfg)
if err != nil {
return nil, err
}
}
var output bytes.Buffer
if err := snapshot.WriteEffective(&output); err != nil {
return nil, fmt.Errorf("serialize effective pipeline: %w", err)
}
return output.Bytes(), nil
}
func effectivePipelineOwners(cfg *PipelineConfig) (map[string][]string, error) {
owners := make(map[string][]string)
if cfg == nil || cfg.resolution == nil {
return owners, nil
}
paths, err := pipelineMetadataPaths(cfg)
if err != nil { if err != nil {
return nil, err return nil, err
} }
node, err := effectiveYAMLNode(value) pathsByID := pipelineSourcePaths(cfg)
if err != nil { for _, value := range paths {
return nil, fmt.Errorf("serialize effective pipeline: %w", err) info, ok := cfg.resolution.configkitMetadata.Lookup(configkit.Keys(value.segments...))
} sources := []string{pipelineDefaultOwnershipSource}
data, err := yaml.Marshal(node) if ok {
if err != nil { sources = ownershipSources(info.Origin, pathsByID)
return nil, fmt.Errorf("serialize effective pipeline: %w", err) if info.Origin.Layer == configkit.LayerResolution {
} for _, change := range cfg.resolution.configkitMetadata.History(configkit.Keys(value.segments...)) {
return data, nil if change.Origin.Layer != configkit.LayerResolution {
} continue
}
func effectiveYAMLNode(value any) (*yaml.Node, error) { // Native Previous evidence identifies the input immediately before
switch value := value.(type) { // resolution, including composite and inherited origins.
case nil: for _, previous := range change.Previous {
return &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!null", Value: "null"}, nil if previous.Layer == configkit.LayerMain || previous.Layer == configkit.LayerOverlay {
case bool: sources = append(sources, ownershipSources(previous, pathsByID)...)
return &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!bool", Value: strconv.FormatBool(value)}, nil }
case string: }
return &yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: value}, nil break
case json.Number: }
tag := "!!int" sources = nonEmptySortedStrings(sources)
if strings.ContainsAny(value.String(), ".eE") {
tag = "!!float"
}
return &yaml.Node{Kind: yaml.ScalarNode, Tag: tag, Value: value.String()}, nil
case []any:
node := &yaml.Node{Kind: yaml.SequenceNode, Tag: "!!seq"}
if len(value) == 0 {
node.Style = yaml.FlowStyle
}
for _, item := range value {
child, err := effectiveYAMLNode(item)
if err != nil {
return nil, err
} }
node.Content = append(node.Content, child)
} }
return node, nil owners[value.record.Path] = sources
case map[string]any:
node := &yaml.Node{Kind: yaml.MappingNode, Tag: "!!map"}
if len(value) == 0 {
node.Style = yaml.FlowStyle
}
keys := make([]string, 0, len(value))
for key := range value {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
child, err := effectiveYAMLNode(value[key])
if err != nil {
return nil, err
}
node.Content = append(node.Content,
&yaml.Node{Kind: yaml.ScalarNode, Tag: "!!str", Value: key}, child)
}
return node, nil
default:
return nil, fmt.Errorf("unsupported projected value type %T", value)
}
}
func effectivePipelineOwners(cfg *PipelineConfig) map[string][]string {
owners := make(map[string][]string)
if cfg == nil || cfg.resolution == nil {
return owners
}
for _, ownership := range cfg.resolution.ownership {
owners[ownership.path] = append([]string(nil), ownership.sources...)
} }
if cfg.Scriptorium != nil { if cfg.Scriptorium != nil {
for key, artifact := range cfg.Scriptorium.Artifacts { for key, artifact := range cfg.Scriptorium.Artifacts {
@@ -236,7 +296,7 @@ func effectivePipelineOwners(cfg *PipelineConfig) map[string][]string {
} }
} }
} }
return owners return owners, nil
} }
func artifactDependencyOwnershipPaths(artifactKey string, artifact ScriptoriumArtifactConfig) []string { func artifactDependencyOwnershipPaths(artifactKey string, artifact ScriptoriumArtifactConfig) []string {
@@ -275,7 +335,7 @@ func generatedArtifactFamilyForPath(path string, families ArtifactFamilyCatalog)
return member.Family, exists return member.Family, exists
} }
func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, path, familyKey string, families ArtifactFamilyCatalog, owners map[string][]string, party ResolvedParty) []EffectivePipelineSourceRecord { func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, path, familyKey string, families ArtifactFamilyCatalog, owners map[string][]string, partySources func(string) []string) []EffectivePipelineSourceRecord {
for _, source := range generatedArtifactSources(path, familyKey, families, owners) { for _, source := range generatedArtifactSources(path, familyKey, families, owners) {
role := "family" role := "family"
if source == pipelineDefaultOwnershipSource { if source == pipelineDefaultOwnershipSource {
@@ -283,8 +343,10 @@ func appendGeneratedArtifactSources(records []EffectivePipelineSourceRecord, pat
} }
records = append(records, EffectivePipelineSourceRecord{Path: path, Role: role, Source: normalizedProvenanceSource(source)}) records = append(records, EffectivePipelineSourceRecord{Path: path, Role: role, Source: normalizedProvenanceSource(source)})
} }
if source := normalizedProvenancePath(party.Source.Path); source != "" { memberPath := strings.TrimPrefix(path, "scriptorium.artifacts.")
records = append(records, EffectivePipelineSourceRecord{Path: path, Role: "party", Source: source}) memberKey, _, _ := strings.Cut(memberPath, ".")
for _, source := range partySources(families.Members[memberKey].CharacterID) {
records = append(records, EffectivePipelineSourceRecord{Path: path, Role: "party", Source: normalizedProvenancePath(source)})
} }
return records return records
} }
@@ -308,8 +370,8 @@ func generatedArtifactSources(path, familyKey string, families ArtifactFamilyCat
if len(sources) != 0 { if len(sources) != 0 {
return sources return sources
} }
if family, ok := families.Families[familyKey]; ok && family.Source != "" { if family, ok := families.Families[familyKey]; ok && len(family.Sources) != 0 {
return []string{family.Source} return append([]string(nil), family.Sources...)
} }
return []string{pipelineDefaultOwnershipSource} return []string{pipelineDefaultOwnershipSource}
} }
@@ -369,8 +431,8 @@ func appendGeneratedPublishSources(records []EffectivePipelineSourceRecord, path
familyPrefix := "scriptorium.artifact_families." + familyKey + ".publish." familyPrefix := "scriptorium.artifact_families." + familyKey + ".publish."
sources := sourcesForPipelinePaths(owners, []string{familyPrefix + "enabled", familyPrefix + "required", familyPrefix + "dest_pattern"}) sources := sourcesForPipelinePaths(owners, []string{familyPrefix + "enabled", familyPrefix + "required", familyPrefix + "dest_pattern"})
if len(sources) == 0 { if len(sources) == 0 {
if family, ok := families.Families[familyKey]; ok && family.Source != "" { if family, ok := families.Families[familyKey]; ok && len(family.Sources) != 0 {
sources = []string{family.Source} sources = append([]string(nil), family.Sources...)
} else { } else {
sources = []string{pipelineDefaultOwnershipSource} sources = []string{pipelineDefaultOwnershipSource}
} }

View File

@@ -14,23 +14,63 @@ import (
type effectivePipelineProjection struct { type effectivePipelineProjection struct {
Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"` Workspace WorkspaceConfig `yaml:"workspace" json:"workspace"`
Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"` Campaigns CampaignsConfig `yaml:"campaigns" json:"campaigns"`
Storage StorageConfig `yaml:"storage" json:"storage"` Storage effectiveStorageConfig `yaml:"storage" json:"storage"`
Spool SpoolConfig `yaml:"spool" json:"spool"` Spool SpoolConfig `yaml:"spool" json:"spool"`
Cache CacheConfig `yaml:"cache" json:"cache"` Cache CacheConfig `yaml:"cache" json:"cache"`
Publish *PublishConfig `yaml:"publish" json:"publish"` Publish *PublishConfig `yaml:"publish" json:"publish"`
WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"` WhisperX WhisperXConfig `yaml:"whisperx" json:"whisperx"`
Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"` Seriatim SeriatimConfig `yaml:"seriatim" json:"seriatim"`
Audita AuditaConfig `yaml:"audita" json:"audita"` Audita effectiveAuditaConfig `yaml:"audita" json:"audita"`
Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"` Normalize *NormalizeConfig `yaml:"normalize" json:"normalize"`
Trim *TrimConfig `yaml:"trim" json:"trim"` Trim *TrimConfig `yaml:"trim" json:"trim"`
Render *RenderConfig `yaml:"render" json:"render"` Render *RenderConfig `yaml:"render" json:"render"`
Scriptorium *effectiveScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"` Scriptorium *effectiveScriptoriumConfig `yaml:"scriptorium" json:"scriptorium"`
Notarius *NotariusConfig `yaml:"notarius" json:"notarius"` Notarius *effectiveNotariusConfig `yaml:"notarius" json:"notarius"`
Notification NotificationConfig `yaml:"notification" json:"notification"` Notification NotificationConfig `yaml:"notification" json:"notification"`
} }
type effectiveStorageConfig struct {
Backend string `yaml:"backend" json:"backend"`
S3 *effectiveStorageS3Config `yaml:"s3" json:"s3"`
}
type effectiveStorageS3Config struct {
Bucket string `yaml:"bucket" json:"bucket"`
RootPrefix string `yaml:"root_prefix" json:"root_prefix"`
Region string `yaml:"region" json:"region"`
Endpoint string `yaml:"endpoint" json:"endpoint"`
ForcePathStyle bool `yaml:"force_path_style" json:"force_path_style"`
AccessKeyID *string `yaml:"access_key_id,omitempty" json:"access_key_id,omitempty"`
SecretAccessKey *string `yaml:"secret_access_key,omitempty" json:"secret_access_key,omitempty"`
}
type effectiveAuditaConfig struct {
Binary string `yaml:"binary" json:"binary"`
Timeout string `yaml:"timeout" json:"timeout"`
Credentials []string `yaml:"credentials" json:"credentials"`
Modules []string `yaml:"modules" json:"modules"`
Overlay string `yaml:"overlay" json:"overlay"`
ProposalProfile string `yaml:"proposal_profile" json:"proposal_profile"`
ValidationProfile string `yaml:"validation_profile" json:"validation_profile"`
TranscriptDescription string `yaml:"transcript_description" json:"transcript_description"`
ConfigPath string `yaml:"config_path" json:"config_path"`
OutputSchema string `yaml:"output_schema" json:"output_schema"`
}
type effectiveNotariusConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Binary string `yaml:"binary" json:"binary"`
Credentials []string `yaml:"credentials" json:"credentials"`
ConfigOverlay *string `yaml:"config_overlay,omitempty" json:"config_overlay,omitempty"`
Resume bool `yaml:"resume,omitempty" json:"resume,omitempty"`
ChunkCache string `yaml:"chunk_cache,omitempty" json:"chunk_cache,omitempty"`
ConfigPath string `yaml:"config_path" json:"config_path"`
PipelineID string `yaml:"pipeline_id" json:"pipeline_id"`
Timeout string `yaml:"timeout" json:"timeout"`
WorkingDirectory string `yaml:"working_directory" json:"working_directory"`
References map[string]string `yaml:"references" json:"references"`
Outputs map[string]NotariusOutputConfig `yaml:"outputs" json:"outputs"`
}
type effectiveScriptoriumConfig struct { type effectiveScriptoriumConfig struct {
Credentials []string `yaml:"credentials,omitempty" json:"credentials,omitempty"` Credentials []string `yaml:"credentials" json:"credentials"`
Binary string `yaml:"binary" json:"binary"` Binary string `yaml:"binary" json:"binary"`
ConfigPath string `yaml:"config_path" json:"config_path"` ConfigPath string `yaml:"config_path" json:"config_path"`
Timeout string `yaml:"timeout" json:"timeout"` Timeout string `yaml:"timeout" json:"timeout"`
@@ -43,13 +83,21 @@ type projectedPipelineValue struct {
segments []string segments []string
} }
func projectEffectivePipeline(cfg *PipelineConfig, logicalNotarius bool) effectivePipelineProjection { func projectEffectivePipeline(cfg *PipelineConfig) effectivePipelineProjection {
projection := effectivePipelineProjection{ projection := effectivePipelineProjection{
Workspace: cfg.Workspace, Campaigns: cfg.Campaigns, Storage: cfg.Storage, Workspace: cfg.Workspace, Campaigns: cfg.Campaigns, Storage: effectiveStorageConfig{Backend: cfg.Storage.Backend},
Spool: cfg.Spool, Cache: cfg.Cache, Publish: cfg.Publish, Spool: cfg.Spool, Cache: cfg.Cache, Publish: cfg.Publish,
WhisperX: cfg.WhisperX, Seriatim: cfg.Seriatim, Audita: cfg.Audita, WhisperX: cfg.WhisperX, Seriatim: cfg.Seriatim,
Normalize: cfg.Normalize, Trim: cfg.Trim, Render: cfg.Render, Normalize: cfg.Normalize, Trim: cfg.Trim, Render: cfg.Render,
Notarius: cfg.Notarius, Notification: cfg.Notification, Notification: cfg.Notification,
}
if s3 := cfg.Storage.S3; s3 != nil {
projection.Storage.S3 = &effectiveStorageS3Config{Bucket: s3.Bucket, RootPrefix: s3.RootPrefix, Region: s3.Region, Endpoint: s3.Endpoint, ForcePathStyle: s3.ForcePathStyle, AccessKeyID: secretReferenceName(s3.AccessKeyID), SecretAccessKey: secretReferenceName(s3.SecretAccessKey)}
}
audita := cfg.Audita
projection.Audita = effectiveAuditaConfig{Binary: audita.Binary, Timeout: audita.Timeout, Credentials: secretReferenceNames(audita.Credentials), Modules: audita.Modules, Overlay: audita.Overlay, ProposalProfile: audita.ProposalProfile, ValidationProfile: audita.ValidationProfile, TranscriptDescription: audita.TranscriptDescription, ConfigPath: audita.ConfigPath, OutputSchema: audita.OutputSchema}
if n := cfg.Notarius; n != nil {
projection.Notarius = &effectiveNotariusConfig{Enabled: n.Enabled, Binary: n.Binary, Credentials: secretReferenceNames(n.Credentials), ConfigOverlay: n.ConfigOverlay, Resume: n.Resume, ChunkCache: n.ChunkCache, ConfigPath: n.ConfigPath, PipelineID: n.PipelineID, Timeout: n.Timeout, WorkingDirectory: n.WorkingDirectory, References: n.References, Outputs: n.Outputs}
} }
if cfg.Scriptorium != nil { if cfg.Scriptorium != nil {
projection.Scriptorium = &effectiveScriptoriumConfig{ projection.Scriptorium = &effectiveScriptoriumConfig{
@@ -59,12 +107,6 @@ func projectEffectivePipeline(cfg *PipelineConfig, logicalNotarius bool) effecti
Artifacts: cfg.Scriptorium.Artifacts, Artifacts: cfg.Scriptorium.Artifacts,
} }
} }
if logicalNotarius && cfg.Notarius != nil && cfg.resolution != nil && cfg.resolution.logicalNotariusCaptured {
notarius := *cfg.Notarius
notarius.ConfigPath = cfg.resolution.logicalNotariusConfig
notarius.WorkingDirectory = cfg.resolution.logicalNotariusWorking
projection.Notarius = &notarius
}
return projection return projection
} }

View File

@@ -0,0 +1,42 @@
package config
import (
"path/filepath"
"testing"
)
func TestEffectiveResourceSourcesExcludeSupersededDefinitions(t *testing.T) {
dir := t.TempDir()
root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: shared.yml\nnotarius:\n extends: audita\n")
writePipelineFixture(t, dir, "shared.yml", "audita: {config_path: old.yml}\n")
overlayPath := writePipelineFixture(t, dir, "overlays/testing.yml", "audita: {config_path: replacement.yml}\n")
overlay := "testing"
cfg, err := LoadPipelineWithOptions(root, PipelineLoadOptions{Overlay: &overlay})
if err != nil {
t.Fatal(err)
}
records, err := EffectivePipelineSources(cfg, ResolvedParty{})
if err != nil {
t.Fatal(err)
}
for _, path := range []string{"audita.config_path", "notarius.config_path"} {
foundOverlay, foundResolution := false, false
for _, record := range records {
if record.Path != path {
continue
}
if record.Role == "overlay" && record.Source == overlayPath {
foundOverlay = true
}
if record.Role == "resolution" {
foundResolution = true
}
if record.Source == filepath.Join(dir, "shared.yml") {
t.Fatalf("superseded source for %s: %#v", path, record)
}
}
if !foundOverlay || !foundResolution {
t.Fatalf("missing effective evidence for %s: %#v", path, records)
}
}
}

View File

@@ -0,0 +1,27 @@
package config
import "testing"
func TestEmptyImportSourcesIncludeNestedDeclarations(t *testing.T) {
dir := t.TempDir()
root := writePipelineFixture(t, dir, "pipeline.yml", "config:\n imports:\n - path: fragment.yml\n - path: absent-root.yml\n")
fragment := writePipelineFixture(t, dir, "fragment.yml", "config:\n imports:\n - path: absent-child.yml\n")
cfg, err := LoadPipeline(root)
if err != nil {
t.Fatal(err)
}
selections := EffectiveEmptyImports(cfg, nil)
if len(selections) != 2 {
t.Fatalf("empty selections: %#v", selections)
}
seen := map[string]bool{}
for _, selection := range selections {
if selection.Selector != "path" || selection.Path == "" || selection.Line == 0 {
t.Fatalf("incomplete evidence: %#v", selection)
}
seen[selection.Source] = true
}
if !seen[root] || !seen[fragment] {
t.Fatalf("source evidence: %#v", selections)
}
}

Some files were not shown because too many files have changed in this diff Show More