From 2ec43305da6c47709909d5cee167c7be0358b311 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Mon, 30 Nov 2026 02:40:17 +0000 Subject: [PATCH] Document the shared pipeline and verify the cutover --- docs/cli.md | 4 +- docs/config.md | 208 +++++------- docs/development.md | 3 +- docs/integrations/README.md | 4 +- docs/integrations/audita.md | 14 +- docs/integrations/notarius.md | 228 +++---------- docs/internal/adapters.md | 13 +- docs/internal/artifacts.md | 16 +- docs/internal/command-restore.md | 9 +- docs/internal/fileops.md | 7 +- docs/internal/manifest.md | 2 +- docs/internal/preflight.md | 7 +- docs/internal/stage-analyze.md | 2 +- docs/internal/stage-cleanup.md | 53 +-- docs/internal/stage-extract.md | 157 ++------- docs/internal/stage-prepare.md | 6 +- docs/internal/stage-publish.md | 2 +- docs/internal/workspace.md | 16 +- docs/operations.md | 305 ++++++------------ docs/oss/attribution.md | 12 + docs/policy/architecture.md | 21 +- docs/roadmap/implementation.md | 23 ++ docs/troubleshooting.md | 94 ++---- examples/README.md | 27 +- examples/autocorrect.yml | 2 - .../campaigns/sample-campaign/autocorrect.yml | 1 - .../sample-campaign/spell_catalog.json | 18 -- examples/pipeline.extraction-subset.yml | 1 - examples/pipeline.full.annotated.yml | 2 +- .../reference-catalog/fragments/places.yml | 3 - 30 files changed, 394 insertions(+), 866 deletions(-) delete mode 100644 examples/autocorrect.yml delete mode 100644 examples/campaigns/sample-campaign/autocorrect.yml delete mode 100644 examples/campaigns/sample-campaign/spell_catalog.json delete mode 100644 examples/reference-catalog/fragments/places.yml diff --git a/docs/cli.md b/docs/cli.md index 4ce8549..18ede97 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -220,11 +220,11 @@ execution report. See [restore operations](operations.md#restore-workflow). ```sh narratio session clean SESSION --dry-run -narratio session clean --all --dry-run --clear-cache +narratio session clean --all --dry-run ``` Choose positional `SESSION` or `--all`. Removes the selected local workspace -and spool state; cache deletion requires `--clear-cache`. Dry runs return planned +state. Dry runs return planned actions without deletion. Partial failures retain completed actions. This manual operation is separate from the pipeline cleanup stage. Exact scope and recovery implications belong in [cleanup operations](operations.md#cleanup). diff --git a/docs/config.md b/docs/config.md index e8f7c7a..238dda1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -146,7 +146,7 @@ shows a complete Narratio configuration. Only the pipeline selects an overlay; Narratio validates the resulting effective domain entries. Relative host-resource paths, including integration configuration files, -workspace/campaign/spool/cache roots, campaign template and stable inputs, and +workspace/campaign roots, campaign template and stable inputs, and session stable inputs and local audio references, resolve from the effective value's defining source. Inherited values follow their origin. When no distinct usable source context exists, the main source is the fallback; if it too is @@ -157,8 +157,8 @@ IDs, and binary names retain their domain meanings. The effective digest excludes source layout, overlay identity, and secret values; credential reference names and resolved resource paths participate. Prepared campaign, session, and party documents contain effective standalone values rather -than authored import directives. Session fields omitted by the author remain -eligible to inherit the receiving campaign's values. +than authored import directives. A prepared session snapshot carries the resolved +values used for that session; retain authored files for future edits. ### Upgrade from earlier configuration @@ -194,12 +194,12 @@ whisperx: `campaign.yml` ```yaml -campaign_id: sample-campaign -inputs: - speakers_file: ./speakers.yml - autocorrect_file: ./autocorrect.yml - glossary_file: ./glossary.yml - party_file: ./party.yml +schema_version: maximumdirect.rpg.campaign.v1 +id: sample-campaign +references: {party: ./party.yml} +narratio: + inputs: + speakers_file: ./speakers.yml ``` `session.yml` (local audio) @@ -266,7 +266,7 @@ Rules: - `outputs[].source` is required. - `outputs[].dest` may be omitted when derivable from source. - extraction sources require an explicit `outputs[].dest` and publish only when - a rule names that source; the Notarius index and complete bundle are not + a rule names that source; the Notarius bundle is not publish sources. - `outputs[].required` defaults to `true`. - publish locks are independent remote session objects managed with @@ -285,6 +285,7 @@ Rules: | `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.default_campaign_id` | string | No | empty | +| `pipeline.campaigns.session_template_file` | string | No | installation session template; built-in default when absent | | `pipeline.storage.backend` | string | No | `local`; supported values are `local` and `s3` (case-insensitive) | | `pipeline.storage.s3.bucket` | string | Conditional | required when backend is `s3` and S3 session-audio or publish upload is enabled | | `pipeline.storage.s3.root_prefix` | string | No | `dnd` | @@ -293,10 +294,6 @@ Rules: | `pipeline.storage.s3.force_path_style` | bool | No | `false` | | `pipeline.storage.s3.access_key_id` | secret reference | Conditional | unset; must be paired with `secret_access_key` | | `pipeline.storage.s3.secret_access_key` | secret reference | Conditional | unset; must be paired with `access_key_id` | -| `pipeline.spool.root` | string | No | `/var/spool/narratio` | -| `pipeline.spool.delete_audio_after_publish` | bool | No | `false`; selects the published run's spool-audio target for final cleanup and requires effective `pipeline.publish.enabled=true` and `pipeline.publish.upload_run=true` | -| `pipeline.cache.root` | string | No | `/var/cache/narratio` | -| `pipeline.cache.s3_audio` | bool | No | `true` | | `pipeline.publish.enabled` | bool | No | `true` | | `pipeline.publish.upload_run` | bool | No | `true` | | `pipeline.publish.outputs[]` | list | No | defaults to final trimmed JSON plus final and final-trimmed Markdown outputs | @@ -349,8 +346,8 @@ Rules: | `pipeline.notarius.pipeline_id` | string | Conditional | required when enabled | | `pipeline.notarius.timeout` | duration | No | `3h`; must be positive | | `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.chunk_cache` | string | No | empty; when set, exactly `auto`, `bypass`, or `refresh` | +| `pipeline.notarius.cache` | string | No | unset; when set, `auto`, `bypass`, or `refresh` | +| `pipeline.notarius.debug` | bool | No | `false`; true requests debug capture | | `pipeline.notarius.references` | map[string]string | No | empty; maps normalized Notarius selectors to supported prepared Narratio source IDs; maximum 256 entries | | `pipeline.notarius.outputs` | map | Conditional | at least one entry when enabled | | `pipeline.render.enabled` | bool | No | `true` | @@ -370,13 +367,13 @@ Rules: ### Audita Selection and Credentials -`pipeline.audita.config_path` optionally selects an Audita v4.2 configuration; +`pipeline.audita.config_path` optionally selects an Audita v4.3.0 configuration; otherwise Audita uses native discovery. `overlay`, `proposal_profile`, and `validation_profile` independently select downstream settings. Empty values add no override. Narratio does not create Audita configuration or infer its selectors from a Narratio overlay. Configure the ordered Audita pipeline in Audita itself; the retired `pipeline.audita.modules` field is rejected. See -[Audita's configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md) +[Audita's configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md) and the [integration contract](integrations/audita.md). `debug: true` requests Audita debug capture; false or omission adds no debug override. Debug alone does not invalidate a completed polish result. @@ -392,9 +389,8 @@ replaces the list. Captured diagnostics redact those values. ### Notarius Configuration Overlay Migration: rename `pipeline.notarius.config_profile` to `config_overlay`. -The old field is rejected; there is no compatibility alias. For Notarius v0.8+ -move selected downstream files from `profiles/` to `overlays/` beside its root -configuration. This does not rename PromptKit LLM profiles. +The old field is rejected; there is no compatibility alias. For current Notarius versions, move selected downstream files from `profiles/` +to `overlays/` beside its root configuration. This does not rename PromptKit LLM profiles. The renamed selector also changes extraction resume evidence for named selections: their existing extraction is regenerated on the next applicable run, with normal dependent invalidation. Omitted/base selections do not acquire @@ -454,78 +450,38 @@ delivery and redaction boundary. ### Notarius Cache Controls -`pipeline.notarius.resume` defaults to `false`. When true, an executed ordinary -extraction passes `--resume`; the deployed Notarius configuration must already -enable checkpoint recording and should select an explicit persistent checkpoint -root. Narratio does not inspect or generate that configuration. - -`pipeline.notarius.chunk_cache` is empty by default, leaving Notarius's -configured mode in control. A nonempty value must be `auto`, `bypass`, or -`refresh` and is passed as `--chunk_cache`. Forced extraction takes precedence -over both fields: it omits `--resume` and passes `--chunk_cache refresh`. -Neither field changes Narratio's semantic extraction fingerprint, so changing -them alone does not rerun an otherwise complete durable extraction. +`pipeline.notarius.cache` is optional; omission leaves the Notarius configuration +in control. Supply `auto`, `bypass`, or `refresh` to select native cache behavior. +Forced extraction uses `refresh`. Narratio's own completed-stage reuse is separate; +changing cache or debug selection alone does not invalidate completed products. +Notarius owns its configuration, pipeline, and cache storage. ### Notarius Reference Bindings -`pipeline.notarius.references` maps a Notarius CLI selector to a prepared -Narratio source, not to a filesystem path: +Map selectors to prepared source IDs, for example: ```yaml notarius: references: - glossary: narratio.input.glossary.campaign party: narratio.input.party - players: narratio.input.players - spell_catalog: narratio.input.spell_catalog + glossary: narratio.input.glossary.combined + spell_catalog: narratio.input.glossary.combined ``` -Supported sources are `narratio.input.party`, `narratio.input.players`, -`narratio.input.glossary.party`, `narratio.input.glossary.campaign`, -`narratio.input.glossary.setting`, `narratio.input.glossary.spells`, and -`narratio.input.spell_catalog`. The retired `narratio.input.glossary` is not an -alias; update each binding explicitly. Each map entry is -required by its presence: omit a binding when the selected Notarius pipeline -does not need it. A spell-catalog binding additionally requires an effective -campaign or session `spell_catalog_file`. - -Selectors accept Notarius's `slot`, `chunk.slot`, `lane.slot`, -`lane.extract.slot`, `lane.merge.slot`, and `lane.normalize.slot` forms. -Narratio trims whitespace around -selectors and their dot-separated components, rejects empty components and -`=`, rejects duplicate normalized selectors, and limits the map to 256 entries. -It validates only selector structure and the prepared source vocabulary; -Notarius owns target-slot declarations and media compatibility. - -Before extraction, Narratio resolves every binding from the current prepared -session manifest and streams it into a verified, content-addressed session -snapshot whose absolute path is passed to Notarius. Missing, unsafe, empty, -changed-during-copy, or checksum-inconsistent prepared evidence fails with -guidance to force `prepare`. Bindings are sorted by normalized selector and are -part of extraction fingerprint and resume identity. See the -[Notarius integration contract](./integrations/notarius.md) for the subprocess -boundary and the [complete example](../examples/pipeline.full.annotated.yml) -for a copyable configuration. +Supported IDs are `narratio.input.party`, `narratio.input.players`, and +`narratio.input.glossary.{party,campaign,setting,spells,combined}`. Every +configured binding is required; omit unused bindings. Selectors use Notarius's +native slot forms. Narratio verifies and snapshots the prepared files before +passing them to the subprocess. See the [Notarius contract](integrations/notarius.md) +and [complete example](../examples/pipeline.full.annotated.yml). ### Notarius Output Entries -For each `pipeline.notarius.outputs.`: - -| Field | Type | Required | Rule | -| --- | --- | --- | --- | -| `lane_id` | string | Yes | unique Notarius lane ID | -| `media_type` | string | Yes | exact accepted descriptor media type | -| `schema_id` | string | Yes | exact accepted descriptor schema ID | -| `schema_version` | string | Yes | exact accepted descriptor schema version | -| `module_key` | string | No | exact accepted module key when set | - -Output names must match `^[a-z][a-z0-9_]*$` and become selectable sources named -`narratio.extraction.`. Lane IDs must be unique. Every declared output is -required from a successful Notarius result; a missing, rejected, duplicate, or -contract-incompatible lane fails extraction. See the -[complete maintained example](../examples/pipeline.full.annotated.yml) for the -current ten-lane D&D mapping and the [Notarius contract](./integrations/notarius.md) -for compatibility ownership. +Each `pipeline.notarius.outputs.` requires a unique `lane_id` and may set +`filename` to a flat JSON filename. The default is `.json`. Names create +`narratio.extraction.` source IDs. Each configured lane is required, and +its completed JSON is promoted into the session's flat artifacts directory. +See the [Notarius contract](integrations/notarius.md). ### Scriptorium Credentials @@ -619,7 +575,7 @@ For each `pipeline.scriptorium.artifact_families.`: | --- | --- | --- | --- | | `enabled`, `prompt_id`, `profile_id`, `timeout`, `render_debug`, `depends_on`, `inputs`, `vars` | ordinary artifact fields | No | copied to each generated artifact under the corresponding ordinary rules | | `for_each` | string | Yes | exactly `party.characters` | -| `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 | flat filename directly 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_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`) validated against effective `pipeline.publish` settings and expanded into concrete publish outputs when enabled | @@ -628,6 +584,11 @@ 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. +Explicit and generated analysis artifacts and session bounds must use flat +filenames directly beneath `artifacts/`; combined transcripts use flat filenames +directly beneath `transcripts/`. Remote publish destinations remain independent. +Collisions among effective producers are rejected. + Generated keys are `_` and generated output paths must not collide with explicit artifacts or another generated artifact. Families expand even when disabled; normal analyze selection still omits disabled @@ -657,47 +618,45 @@ integration. ### Campaign -| Field | Type | Required | Notes | -| --- | --- | --- | --- | -| `campaign_id` | string | Yes | canonical opaque campaign identity | -| `session_template_file` | string | No | used by `session init` when set | -| `inputs.speakers_file` | string | Yes | stable input default | -| `inputs.autocorrect_file` | string | Yes | stable input default | -| `inputs.setting` | string | No | selected setting ID in `reference_catalog.settings` | -| `inputs.system` | string | No | selected system ID in `reference_catalog.systems` | -| `inputs.glossary_file` | string | No | campaign vocabulary file | -| `inputs.glossary` | mapping | No | inline campaign collection contribution | -| `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` | +The campaign is a shared [RPG campaign document](https://schemas.maximumdirect.net/rpg/campaign/v0.2.0/schema.json). +Shared extensions are allowed; Narratio's `narratio` settings are strict. + +| Field | Required | Meaning | +| --- | --- | --- | +| `schema_version` | Yes | `maximumdirect.rpg.campaign.v1` | +| `id` | Yes | campaign identity | +| `name`, `description` | No | shared context | +| `references.party` | Yes | shared roster path; `--party-file` can select another roster | +| `setting`, `system` | No | selected installed catalog IDs | +| `references.glossaries` | No | shared relationships, not an ordered Narratio composition list | +| `narratio.inputs.speakers_file` | Yes | speaker mapping path | +| `narratio.inputs.glossary_file` | No | shared campaign glossary path | +| `narratio.inputs.glossary` | No | inline campaign collection | +| `narratio.inputs.autocorrect` | No | replacement rules, default empty | +| `narratio.session_template_file` | No | campaign template; otherwise installation or built-in template | + +Resource paths resolve relative to their defining source. See the +[three-file example](../examples/campaigns/lantern-coast/campaign.yml) and +[party contract](integrations/party.md). ### Glossary Inputs -Install an independently selected catalog locally and import its `catalog.yml` -into the pipeline; [the example](../examples/pipeline.catalog.yml) uses a small -synthetic bundle. Catalog IDs map to file paths relative to their defining -configuration sources. Only selected files are read; an unknown selected ID is -an error. Catalog files and their native imports are resolved with ConfigKit. +Install a reference catalog and import its root into the pipeline. Selected +setting and system IDs resolve to source-relative shared glossary files; only +selected files are read. Campaign file and inline contributions compose using +ConfigKit identity and list controls. Session omissions inherit each selection +independently; explicit null or empty optional selectors clear them. A supplied +inline glossary or autocorrection list replaces the campaign contribution as a +whole, and null clears it. Clearing inline vocabulary leaves a selected file +unchanged; `autocorrect: []` disables inherited campaign rules. -Campaigns can select `setting`, `system`, `glossary_file`, and inline `glossary` -independently. Session omissions inherit each campaign value independently; -null or empty optional selectors clear that selection. Session inline data -replaces the campaign inline contribution as a whole, and explicit null removes -it. The selected campaign file is composed below the effective inline -contribution using native ConfigKit entry identity and list controls. - -Files contain named collections: campaign files provide `campaign`, selected -setting files provide `setting`, and system files provide `spells`. Preparation -derives `party` from the canonical roster and writes all four collections, even -when empty. The [catalog format](https://forge.maximumdirect.net/eric/narratio-reference-catalog/src/branch/main/FORMAT.md) -owns the shared schema; [examples](../examples/README.md#campaign-and-session-configuration) -show file-only, inline-only, and combined authoring. The former standalone -glossary format is not converted automatically. - -All four prepared entry lists are supplied to Audita and replace the matching -Audita-configured lists, including when empty. Other collections and omitted -instruction fields follow Audita's native composition. The canonical roster, -players projection, and optional Notarius spell-catalog overlay remain separate -inputs. Configuration inspection preserves authored selections and inline data. +Preparation writes shared envelopes for party, campaign, setting, spells, and +combined collections, including empty collections. Audita receives the four +individual envelopes and Notarius may bind the combined envelope to both glossary +roles. Collection extensions such as `instruction` are data, not prompt guidance. +[Shared glossary schema](https://schemas.maximumdirect.net/glossary/v0.2.0/schema.json) +and [semantics](https://schemas.maximumdirect.net/glossary/v0.2.0/semantics.md) +own the contract; see the [maintained examples](../examples/README.md). ### Session @@ -709,12 +668,11 @@ inputs. Configuration inspection preserves authored selections and inline data. | `date` | string | No | metadata | | `title` | string | No | metadata | | `inputs.speakers_file` | string | No | overrides campaign stable input | -| `inputs.autocorrect_file` | string | No | overrides campaign stable input | +| `inputs.autocorrect` | list | No | replaces inherited rules; null or empty clears them | | `inputs.setting` | string | No | independently overrides the campaign setting selection | | `inputs.system` | string | No | independently overrides the campaign system selection | | `inputs.glossary_file` | string | No | independently overrides the campaign vocabulary file | | `inputs.glossary` | mapping | No | replaces the campaign's inline contribution | -| `inputs.spell_catalog_file` | string | No | omission inherits the campaign spell catalog; an explicit empty string clears this optional input | | `inputs.audio_dir` | string | Conditional | local audio mode | | `inputs.audio_files[]` | list[string] | Conditional | local audio mode | | `inputs.audio_s3.prefix` | string | Conditional | S3 audio mode | @@ -737,6 +695,16 @@ select a backend on its own. Unknown backend names and an S3 block paired with `--previous-session-id`, however, the session file must contain the same value; an omitted or different value is rejected before the command performs work. +## Shared contract provenance + +Narratio validates the shared glossary, RPG party, and RPG campaign `0.2.0` +schemas and their dependency closure offline from schemas distribution +`2026.11.1`, commit `f7e3cedeca11ed903311cdf29ca4d81fb1f216b7`. +The supplied synthetic catalog data is based on commit +`02dd53c6ea026347452d497350c40249c949f8ce`. Installed catalogs are selected +independently. See [attribution](oss/attribution.md) and the +[integration contracts](integrations/README.md) for tested consumers. + ## Maintained Examples See the [maintained examples index](../examples/README.md) for complete pipeline, diff --git a/docs/development.md b/docs/development.md index 5cdcfe5..10b5d86 100644 --- a/docs/development.md +++ b/docs/development.md @@ -35,8 +35,7 @@ builds use the selected patch version and setup instructions in the | [OSS](policy/oss.md) | Adding or updating dependencies or incorporated third-party material, or changing licensing or attribution. | | [Release](policy/release.md) | Preparing or publishing a release, changing release procedures, or making versioning and compatibility decisions. | -The pending [pipeline roadmap](roadmap/pipeline.md) consolidates shared-input, -consumer, catalog, and workspace work; it describes future behavior. +The [pipeline roadmap](roadmap/pipeline.md) records the design and implementation history. - Read applicable policies before making decisions they govern; multiple policies may apply. diff --git a/docs/integrations/README.md b/docs/integrations/README.md index ba2f99a..6433777 100644 --- a/docs/integrations/README.md +++ b/docs/integrations/README.md @@ -19,8 +19,8 @@ focused stage documents. ## Integration Contracts - [Audita](./audita.md): transcript polishing (`audita process`). -- [Notarius](./notarius.md): complete pipeline execution and safe JSON bundle - discovery (`notarius run`). +- [Notarius](./notarius.md): complete pipeline execution and safe JSON product + promotion (`notarius run`). - [Party](./party.md): canonical campaign roster input. - [Seriatim](./seriatim.md): merge, normalize, trim, and render operations. - [Scriptorium](./scriptorium.md): artifact generation, prepared previews, and diff --git a/docs/integrations/audita.md b/docs/integrations/audita.md index f1a5f74..bb0deba 100644 --- a/docs/integrations/audita.md +++ b/docs/integrations/audita.md @@ -1,18 +1,18 @@ # Integration: Audita -Narratio invokes Audita v4.2 for polishing. Its adapter supplies the prepared +Narratio invokes Audita v4.3.0 for polishing. Its adapter supplies the prepared party, campaign, setting, and spells documents as repeated `--glossary-file` arguments, the merged transcript and requested output, and run-local report and work destinations. Optional config, overlay, profile, transcript-description, and output-schema selectors are forwarded only when set. `audita.debug: true` forwards `--debug`; false adds no debug override. Audita owns its configuration, ordered pipeline, profiles, and native discovery. Narratio does -not generate a downstream configuration. See [Audita configuration](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md) -and its [runtime glossary input contract](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/transcript-glossary-files.md). +not generate a downstream configuration. See [Audita configuration](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md) +and its [runtime glossary input contract](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/integrations/transcript-glossary-files.md). All four entry lists are supplied, including empty ones, and replace same-named -Audita-configured lists. Other collections and omitted instruction fields retain -native downstream composition. The [configuration reference](../config.md#glossary-inputs) +Audita-configured lists. Other collections and configured instructions retain native downstream +composition; shared collection extensions are data, not prompt guidance. The [configuration reference](../config.md#glossary-inputs) explains selection and migration of the prepared inputs. After preparation, Narratio runs native Audita preflight when projected polish @@ -22,7 +22,7 @@ they can contact providers and destination probes can create directories. `session validate` uses existing prepared records and a validation probe namespace. A successful check is not a guarantee about later real-transcript processing or editorial quality. See [operations](../operations.md#prompt-requirements-preflight) -and [Audita preflight](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/cli.md#preflight). +and [Audita preflight](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/cli.md#preflight). Each `pipeline.audita.credentials` value is an exact ConfigKit secret reference. Narratio forwards selected names and captured values in the child environment @@ -36,7 +36,7 @@ is accepted even when ordinary reports describe recoverable errors or no corrections. Narratio records available `errors.yml`, `recoveries.yml`, and `report.md` from the requested report directory as diagnostics, each subject to a 16 MiB bound. Reports may be absent when disabled. See Audita's -[output contract](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/output-files.md). +[output contract](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/integrations/output-files.md). On nonzero exit, Narratio preserves the subprocess error and available run-local evidence and does not promote an incidental transcript. The generated invocation diff --git a/docs/integrations/notarius.md b/docs/integrations/notarius.md index 18f2f7f..4c44368 100644 --- a/docs/integrations/notarius.md +++ b/docs/integrations/notarius.md @@ -1,205 +1,49 @@ # Notarius Integration Contract -## Boundary - -Narratio uses Notarius as a subprocess to extract configured structured JSON -lanes from the final trimmed Seriatim transcript. Narratio owns invocation, -safe bundle discovery, lane selection, and its own artifact metadata. Notarius -owns pipeline definitions, lane schemas, the receipt, and bundle formats. - -Canonical Notarius v0.8.1 references: - -- [CLI reference](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/cli.md) -- [Subprocess consumer contract](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/consumers/subprocess.md) -- [D&D pipeline and lane contracts](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/consumers/dnd-pipeline.md) -- [Run-result receipt](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/integrations/run-result.md) -- [JSON output bundle](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/integrations/json-output.md) -- [D&D spell-catalog overlay](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/integrations/dnd-spell-catalog-overlays.md) - -The [complete Narratio example](../../examples/pipeline.full.annotated.yml) -records the exact current constraints for all ten D&D lanes. Treat the linked -Notarius documents as canonical when changing those values; Narratio does not -duplicate the complete schemas. +Narratio invokes a separately installed Notarius v0.10.0 executable and the +operator's existing Notarius configuration and pipeline. Narratio does not build +that configuration. The [Notarius consumer guide](https://forge.maximumdirect.net/eric/notarius/src/tag/v0.10.0/docs/consumers/dnd-pipeline.md) +owns the maintained pipeline and [CLI](https://forge.maximumdirect.net/eric/notarius/src/tag/v0.10.0/docs/cli.md) +owns its invocation and native output contracts. Controlled local-provider +compatibility was exercised against commit `752c9b44d2c0bb3bfb1e02a5d4379f7cc5b6261e`. ## Invocation -When `pipeline.notarius.enabled` is true, Narratio resolves the executable, -configuration path, input path, output directory, and working directory to -absolute paths. Configured references require support for the `--reference` -contract introduced in Notarius v0.6.0. Cache controls require support for the -selected `--resume` and `--chunk_cache` flags. Notarius v0.8.1 is the tested -cache integration baseline, not an unconditional minimum version; Narratio -does not impose a runtime version gate. Each reference binding is a separate -argument before `--json`. When `pipeline.notarius.config_overlay` is present, -its exact value is another argument pair before `--json`: +Narratio supplies `run `, `--config`, `--input-file`, `--output-dir`, +`--debug-dir`, and `--format json`. It forwards an explicitly selected overlay, +cache mode, and reference bindings; debug true requests capture. The configured +child credentials are forwarded by exact name and captured streams are redacted. +The same selected configuration, credentials, references and cache mode are used +for native pipeline inspection and preflight. Preflight may contact providers and +probe destinations; a synthetic transcript establishes readiness for that input +only. See [operations](../operations.md#prompt-requirements-preflight). -```text -notarius run --config --input --output-dir [--resume] [--chunk_cache ] [--reference =]... [--config-overlay ] --json -``` - -Notarius v0.8.1 is a known supporting version for `--config-overlay`; using the -option requires a compatible Notarius executable, but deployments that omit the -field acquire no additional version requirement. Omitted or null configuration -adds no flag. Supplied empty, `default`, and named selectors are forwarded -without normalization so Notarius can apply its own ConfigKit semantics. This -option selects a Notarius configuration overlay, not a PromptKit profile through -`--llm-profile`, and Narratio never substitutes its own selected overlay name. -A missing or invalid downstream overlay is an ordinary Notarius subprocess -failure: Narratio does not retry without the selector or fall back to another -overlay. - -Reference paths are absolute stable snapshots streamed from manifest-verified -canonical files prepared inside the current Narratio session workspace. They -live at `cache/notarius/references//` and retain the -full lowercase content digest. Narratio verifies snapshot checksum and size -before and after the subprocess, reconstructs missing or corrupt regular files -from a still-valid prepared source, and passes only configured bindings, -ordered lexically by normalized selector, as direct argument-vector entries -without shell interpretation. Symlinks, directories, other non-regular -conflicts, and prepared-source mismatches fail rather than being deleted. A CLI -binding takes precedence over a matching external path in Notarius -configuration. Narratio never emits `--without-reference`. - -For canonical party configuration, the `party` binding is the unchanged, -validated authored roster and the `players` binding is its generated -projection. Both retain their established `narratio.input.party` and -`narratio.input.players` source IDs, and both are resolved from the prepared -manifest rather than from campaign configuration at extraction time. - -The `glossary` slot may bind `narratio.input.glossary.campaign`; the four -prepared glossary sources are explicit and the retired monolithic source is -not an alias. The separate Notarius spell-catalog overlay remains unchanged. - -The maintained D&D boundary binds only the four campaign-owned external slots: - -```text -notarius run dnd-session \ - --config \ - --input \ - --output-dir \ - --reference glossary= \ - --reference party= \ - --reference players= \ - --reference spell_catalog= \ - --json -``` - -The spell-catalog binding is omitted when the campaign does not maintain that -optional overlay. Registry, scene-description, combat-turn, and occurrence -handoffs generated during the same Notarius run remain in Notarius pipeline -composition and must not be emitted as CLI references. The linked CLI and D&D -consumer documents own selector targeting, declared slots, media compatibility, -and generated-handoff collision rules. - -Standard output is reserved for the JSON receipt. Standard error is captured -separately as diagnostic output. Narratio applies the configured timeout and -does not interpret stdout as a receipt unless the subprocess exits successfully. -It does not pass a Narratio session ID or run `notarius config validate` -automatically; the configured working directory and Narratio's minimal child -environment apply to the subprocess. - -Ordinary extraction maps `pipeline.notarius.resume: true` to `--resume` and a -nonempty `pipeline.notarius.chunk_cache` to `--chunk_cache `. Forced -extraction always omits `--resume` and supplies `--chunk_cache refresh`. -Notarius owns checkpoint enablement, recording, identity, and both cache roots; -Narratio neither reads nor synthesizes its configuration. Use explicit -persistent roots in Notarius when reuse must span subprocess invocations. -Changing a reference path/digest or other upstream identity input correctly -causes a cold miss. Chunk refresh bypasses lookup and publishes the accepted -replacement for the active source; it does not delete unrelated plans or -checkpoint state. - -When `pipeline.notarius.credentials` is absent, null, or empty, Narratio adds no -credentials to that environment. When configured, each list entry names an -environment variable whose already-loaded nonempty value is forwarded under -that exact name. Operators must use the names referenced by the selected -Notarius/PromptKit providers. Narratio does not inspect the Notarius configuration -to infer providers or destination names, and it does not forward unrelated -credentials from its parent environment or secrets directory. A Narratio -overlay replaces the whole credential list; `[]` clears it. - -Every selected name is registered with Narratio's shared streaming redactor. -Credential bytes written by the child to captured stdout, captured stderr, or -stderr-derived failure diagnostics are replaced with ``, including -custom names not known to the built-in sensitive-name list. Narratio does not -serialize the credential into arguments, stage metadata, manifests, or -generated configuration. - -This captured-stream protection is not a filesystem sandbox. Notarius remains -responsible for keeping credentials out of files it writes directly, including -bundle artifacts and its own diagnostics. Narratio does not scan or rewrite -arbitrary downstream files and cannot promise redaction of transformed or -encoded credentials. +The prepared shared roster can bind to `party`; the combined shared glossary can +bind to both `glossary` and `spell_catalog`. Notarius owns collection selection, +D&D recognition, its configuration and caches. See [configuration](../config.md#notarius-reference-bindings). +Narratio stage reuse and Notarius cache reuse are separate. Forced extraction +requests native cache refresh. ## Accepted Result -Narratio's tested invocation baseline is Notarius v0.8.1. The accepted -receipt remains `notarius.run-result.v2`; reference flags do not change the -receipt or ten-lane output contract. The receipt -must identify the configured pipeline, and its `index_file` must be exactly -`index.json` beneath the reported bundle root. The production index must name -the management files exactly as `manifest.json`, `rejected.json`, -`warnings.json`, and `diagnostics.json`. All receipt, index, and lane paths must -stay inside that bundle; symlinks and non-regular lane payloads are rejected. +After a successful exit, Narratio reads the native JSON completion report, checks +its pipeline and confined output directory, and validates each configured +`lanes/.json` as a safe regular JSON file. It promotes those required +lanes to flat session artifacts and records content evidence. The reported +`artifact_count` can include reused or auxiliary results; it is not an inventory. +Optional `chunk-map.json` and `evidence-context.json` stay with the retained +original bundle. A positive native `fallback_count` remains visible in fresh and +reused reports. -Supported receipt and index shapes tolerate unknown fields for forward -compatibility, while required identity, validation, count, manifest, -rejection, warning, diagnostic, and lane-list fields remain mandatory. -Narratio applies bounded reads to the receipt, index, rejection, warning, and -diagnostic documents. Warning and diagnostic envelopes, group counts, -occurrence counts, truncation state, framework-owned origins, and -receipt-to-bundle counts must be internally consistent. Optional chunk-map and -evidence-context descriptors must carry their complete generic contract -metadata when present. - -For every entry in `pipeline.notarius.outputs`, Narratio requires exactly one -index descriptor with the configured lane ID, media type, schema ID, schema -version, and, when configured, module key. Missing, duplicate, rejected, or -incompatible required lanes fail extraction even if Notarius exited zero. A -configured lane whose v2 validation summary is `rejected` or `incomplete` also -fails extraction. -An accepted reused producer may report `producer_attempt_count: 0`; Narratio -preserves that valid summary rather than treating it as a missing field. -Unconfigured lanes may remain in the preserved bundle but do not become -selectable Narratio sources. - -Each accepted configured lane is registered as -`narratio.extraction.`. The bundle index is retained for audit and -resume validation but is not selectable. Scriptorium and publish rules consume -only explicitly named lane sources; `--artifacts` never selects Notarius lanes. - -## Failure And Compatibility Behavior - -- Startup and nonzero-exit errors fail extraction and retain captured diagnostics. -- Invalid receipt JSON or an unsupported receipt schema fails before bundle use. -- Unsafe or incompatible index data and required-lane rejection fail before the - staged bundle is promoted to durable storage. -- Contract and external provenance metadata are preserved on lane artifact - records and through explicit publication. -- Undeclared selectors, incompatible reference files, and external/generated - reference collisions are Notarius errors and fail extraction normally. - -Rejection, validation, warning, and diagnostic summaries retain bounded stable -identity, category, origin, reason-code, status, and occurrence fields without -copying free-form external messages into Narratio manifest metadata or reading -lane payload bodies. - -Configuration fields and defaults are in [Configuration](../config.md). -Operator paths, rerun procedures, and bundle retention are in -[Operations](../operations.md). See [Troubleshooting](../troubleshooting.md) -for failure recovery. +Nonzero exit, malformed completion, unsafe output, or a missing required lane +fails extraction. Diagnostics and available files remain for investigation; an +incidental file or partial report does not establish success. See +[extraction operations](../operations.md#extraction-workflow). ## Opt-in Integration Test -The production-boundary cache test requires an absolute path to a locally -built Notarius v0.8.1-compatible executable. It uses only a local -OpenAI-compatible `httptest` provider and temporary cache/config/output roots: - -```sh -NARRATIO_TEST_NOTARIUS_BINARY=/absolute/path/to/notarius \ - GOWORK=off go test ./internal/stage \ - -run '^TestNotariusCacheReuseIntegration$' -count=1 -v -``` - -When the variable is unset, the normal test suite skips this test and never -searches `PATH`, a sibling checkout, the network, or a real provider. +The [catalog compatibility script](https://forge.maximumdirect.net/eric/narratio-reference-catalog/src/commit/016473fd16b15847f3e913670c423faa7c35720b/scripts/check-compatibility.sh) +accepts explicit Narratio and Notarius checkouts and Audita and Notarius binary +paths. It uses a controlled local provider and verifies readiness, the ten-lane +pipeline, flat promotion, cache reuse, and forced refresh. Ordinary tests skip +external binaries. diff --git a/docs/internal/adapters.md b/docs/internal/adapters.md index d44876f..859cedc 100644 --- a/docs/internal/adapters.md +++ b/docs/internal/adapters.md @@ -62,18 +62,15 @@ command configuration loader may still use object storage to retrieve a missing remote session file before planning begins. After preparation, the application projects remaining selected work and uses -invocation-owned Audita and Scriptorium runners for applicable readiness checks. +invocation-owned Audita, Notarius, and Scriptorium runners for applicable readiness checks. The same runners are available to processing. Explicit session validation uses existing prepared inputs and invocation-owned factories. See [preflight internals](preflight.md). -Notarius is composed only when extraction is enabled; the extract stage owns -prepared reference resolution, receipt, bundle, and configured-lane policy. -The adapter validates the ordered selector/absolute-path pairs and is the sole -owner of serializing them as repeated `--reference` arguments before `--json`. -It also serializes an effective resume request as `--resume` and a nonempty -validated chunk mode as `--chunk_cache `. The extract stage, not the -adapter, resolves force precedence before constructing the request. +Notarius is composed only when extraction is enabled. The stage resolves +prepared references and promotes configured products; the adapter builds native +inspection, preflight, and run commands and validates the completion report. +Force selects native cache refresh before request construction. Its request may also carry already-resolved ConfigKit secret references. Audita and Scriptorium requests carry the same kind of list. All three adapters use the shared subprocess helper to convert their selected references into exact-name child diff --git a/docs/internal/artifacts.md b/docs/internal/artifacts.md index 5cfe2c8..5f63c56 100644 --- a/docs/internal/artifacts.md +++ b/docs/internal/artifacts.md @@ -33,15 +33,15 @@ validator. The focused stage documents own their input/output flow; All formats are validated by strict source-policy rules. Configured artifact and extraction keys use `^[a-z][a-z0-9_]*$`; source parsers never normalize an unrecognized token into a valid source. Extraction sources are registered only -from `pipeline.notarius.outputs`; the Notarius index has no selectable source -ID. +from `pipeline.notarius.outputs`; the retained bundle is not a selectable +source. Prepared stable source IDs are `narratio.input.players`, `narratio.input.party`, `narratio.input.glossary.party`, `narratio.input.glossary.campaign`, `narratio.input.glossary.setting`, -`narratio.input.glossary.spells`, and `narratio.input.spell_catalog`. Artifact policy owns their canonical manifest +`narratio.input.glossary.spells`, and `narratio.input.glossary.combined`. Artifact policy owns their canonical manifest kind and prepared filename vocabulary. Canonical party mode preserves the -party source bytes in the party record and supplies the players record from the +effective standalone party document in the party record and supplies the players record from the deterministic `derived_from_party` projection; both remain ordinary prepared source IDs for consumers. @@ -132,10 +132,10 @@ Prepared stable sources (`narratio.input.*`): Extraction sources (`narratio.extraction.*`): -- use the shared typed bundle evidence inspection in `extraction_evidence.go`; +- use the shared product evidence inspection in `extraction_evidence.go`; - require a current successful extract record with the exact configured source, - compatible contract and Notarius provenance, a confined regular durable - payload, matching checksum, and the current resolved trimmed-transcript + Notarius provenance, a confined regular flat product with matching size and + checksum, and the current resolved trimmed-transcript identity; - remain unavailable unless catalog hydration receives valid evidence. Resume treats absent or obsolete evidence as a rerun decision and unsafe evidence as @@ -249,7 +249,7 @@ generation, and removal is idempotent. - session/work/run paths; - previous-cache paths; -- spool/cache paths; +- managed session, run, and diagnostic paths; - S3 session/run/current-state key layout. New publication creates run-scoped immutable objects, including diff --git a/docs/internal/command-restore.md b/docs/internal/command-restore.md index 8c8cede..26e6b95 100644 --- a/docs/internal/command-restore.md +++ b/docs/internal/command-restore.md @@ -85,17 +85,16 @@ Execution order and safety: - restored manifest local references are rebased beneath the selected local session root. Unsafe relative references and producer-machine absolute paths outside the manifest's producer session root are rejected; producer-local - spool paths and run-local diagnostic references are not restored as + run-local diagnostic references are not restored as authority. Cleanup remains ordinary restored stage state and is not reset or synthesized by restore. Audio restore path: - uses `audio.MaterializeS3Audio`; -- integrates spool and S3 audio cache paths; -- reuses cached audio only when its opened regular file, content digest, and - identity sidecar all match the selected remote object version; otherwise it - refreshes through the validated download path. +- restores selected audio directly into the prepared session audio directory; +- reuses a prepared copy only when manifest identity and its content checksum + match; otherwise downloads to a verified temporary sibling before installation. ## Reporting Contract diff --git a/docs/internal/fileops.md b/docs/internal/fileops.md index 320fe8e..ada9a50 100644 --- a/docs/internal/fileops.md +++ b/docs/internal/fileops.md @@ -15,8 +15,11 @@ sibling temporary file, validates the complete result, and passes that file to remote object selection, validation, conflict handling, and temporary-file cleanup. -Directory bundles are not promoted by `internal/fileops`; extraction owns its -validated Notarius bundle rename. +Directory bundles are not promoted by `internal/fileops`; extraction retains +the original bundle in its run and promotes individual validated products. + +Managed latest-attempt links are updated and inspected by fileops. Cleanup uses +those validated targets when retaining current diagnostics. ## Cleanup Contract diff --git a/docs/internal/manifest.md b/docs/internal/manifest.md index 3b18a31..be5a398 100644 --- a/docs/internal/manifest.md +++ b/docs/internal/manifest.md @@ -12,7 +12,7 @@ manifest placement belongs in - required `schema_version: narratio.session-manifest.v2` - identity (`session_id`, `campaign`, `run_id`) -- local path metadata (`local_workdir`, `local_spool_dir`) +- local path metadata (`local_workdir`) - remote identity metadata (`s3_bucket`, `s3_session_prefix`, `s3_run_prefix`) - `inputs` records - durable `artifacts` records diff --git a/docs/internal/preflight.md b/docs/internal/preflight.md index 758d97a..9b60e0a 100644 --- a/docs/internal/preflight.md +++ b/docs/internal/preflight.md @@ -4,7 +4,8 @@ The application performs downstream checks after selected preparation completes or is reused and before remaining selected processing. It projects remaining work against a clone of the locked manifest using the same stage decisions and analysis planner as `session plan`. Projected polish selects Audita; projected -enabled trim and analysis select Scriptorium requirements. A projection is not +enabled extraction selects Notarius inspection and preflight; enabled trim and +analysis select Scriptorium requirements. A projection is not an execution commitment. Empty target sets invoke no checker. Audita receives the verified four prepared glossary files and the same @@ -14,6 +15,10 @@ transient diagnostics, and preserves exit classification. No preflight result is cached as a stage. A failure stops later processing without presenting it as complete. +Notarius uses the same execution controls and verified reference snapshots. It +checks an available verified transcript or reports that a synthetic one was used. +Readiness warnings and native failures remain visible; checks do not publish work. + For `session validate`, the application selects enabled downstream definitions independently of reuse and checks the existing prepared manifest. It does not resolve live files into candidate glossary projections or run prepare. The diff --git a/docs/internal/stage-analyze.md b/docs/internal/stage-analyze.md index 1c9f0b0..c682b0d 100644 --- a/docs/internal/stage-analyze.md +++ b/docs/internal/stage-analyze.md @@ -20,7 +20,7 @@ dependency order, and safely materialize validated outputs. Supported source families: - built-ins: `narratio.transcript.*`, `narratio.bounds.session` - prepared stable inputs: `narratio.input.players`, `narratio.input.party`, - `narratio.input.glossary.{party,campaign,setting,spells}`, `narratio.input.spell_catalog` + `narratio.input.glossary.{party,campaign,setting,spells,combined}` - configured artifacts: `narratio.artifact.` - extraction lanes: `narratio.extraction.` - previous-session cache: `narratio.previous_session.artifact.` diff --git a/docs/internal/stage-cleanup.md b/docs/internal/stage-cleanup.md index 768e47f..1483e4d 100644 --- a/docs/internal/stage-cleanup.md +++ b/docs/internal/stage-cleanup.md @@ -2,53 +2,24 @@ ## Purpose -Remove explicitly configured local data for the run selected by a successful -publish commit. Cleanup is the twelfth and final canonical stage, after -`notify`. +Remove eligible run data only after a successful publish, according to the +workspace cleanup policy. Explicit session cleanup is a separate operator action. ## Authorization And Targets -Cleanup is disabled unless at least one of these policies is true: - -- `pipeline.spool.delete_audio_after_publish` -- `pipeline.workspace.cleanup_after_publish` - -An enabled cleanup requires the manifest's publish stage to be succeeded with -`uploaded=true`, a canonical `published_run_id`, and the exact remote commit and -current commit-pointer keys for the manifest campaign/session prefix. The -configured campaign and session must match the manifest. Cleanup derives its -only possible targets through the canonical artifact path helpers: - -- the published run's session spool-audio directory; and -- the published run's workspace run directory. - -It does not scan parent directories, infer the newest run, or read object -storage. Every deletion uses the root-confined file operation, which rejects a -root itself, traversal, symlink escape, and out-of-root targets. +`workspace.cleanup_after_publish` enables automatic cleanup. It requires a +succeeded upload and matching published run, commit, and pointer evidence. +Cleanup confines deletion to that run and protects managed latest log/debug +view targets and the original session-durable Notarius bundle. Subprocess state +and caches are outside its scope. ## Execution And Resume -Disabled cleanup records an explicit skipped result. Enabled cleanup removes -targets in deterministic policy order and treats an already-missing target as -success. A successful record contains the published run ID and completed policy -names. - -A previous cleanup success is reusable only while its semantic configuration -matches and every selected target remains absent. A recreated target makes the -stage non-resumable. A failure is recorded against cleanup; publish remains -succeeded and remote current state is unchanged. On a later normal full run, -valid upstream stages are skipped and cleanup is retried without republishing. - -`narratio run SESSION --stage publish` selects publish only and never invokes cleanup. A bounded run -through `notify` or any earlier endpoint also excludes it. Operators may run -`narratio run --stage cleanup` directly; missing, failed, malformed, -or identity-mismatched publication evidence fails before deletion. +Cleanup is idempotent and retries failed deletion without republishing. Retained +protected files are intentional and do not trigger endless cleanup. Bounded +runs ending before cleanup do not execute it. See [operations](../operations.md#cleanup). ## Implementation And Tests -- Planning and evidence validation: `internal/stage/cleanup_plan.go` -- Execution and resume: `internal/stage/cleanup.go` -- Root-confined deletion: `internal/fileops/cleanup.go` -- Focused tests: `internal/stage/cleanup_plan_test.go`, - `internal/stage/cleanup_test.go`, and - `internal/app/cleanup_orchestration_test.go` +`internal/stage/cleanup_plan.go`, `cleanup.go`, `internal/fileops/cleanup.go` +and their tests own authorization, protected targets, and confined deletion. diff --git a/docs/internal/stage-extract.md b/docs/internal/stage-extract.md index 17d5bc8..e76b220 100644 --- a/docs/internal/stage-extract.md +++ b/docs/internal/stage-extract.md @@ -2,147 +2,40 @@ ## Responsibility -`extract` runs after `render` and before `analyze`. It converts the canonical -`narratio.transcript.final_trimmed` JSON into configured Notarius lane artifacts. -An omitted or disabled Notarius section makes the stage explicitly self-skip -with reason `notarius_disabled`, no outputs, and no Notarius runner. - -The external protocol is documented in the -[Notarius integration contract](../integrations/notarius.md). Configuration -fields belong in [Configuration](../config.md), and physical paths and force -procedures belong in [Operations](../operations.md). +The extract stage invokes the configured Notarius pipeline on the verified +final trimmed transcript and prepared references, promotes configured lane +products, and records Narratio-owned content evidence. Notarius owns its +pipeline, cache, validation and completion protocol; see the +[integration contract](../integrations/notarius.md). ## Lifecycle -`internal/stage/extract.go`: - -1. resolves the final trimmed transcript from the shared artifact catalog; -2. resolves every configured prepared reference through the shared - manifest-authoritative identity resolver before creating run-local output; -3. resolves each reference to a stable content-addressed session snapshot, - reusing verified bytes or reconstructing a missing/corrupt regular entry, - and rejects any source change observed while copying; -4. fingerprints the byte- and provenance-bearing Notarius invocation evidence, - including sorted reference identities and the explicit downstream - configuration-overlay selection; -5. creates a run-local staging directory and invokes the injected - `notarius.Runner`, carrying the optional already-resolved credential - reference without exposing its value, the optional exact configuration - overlay, plus effective resume and chunk-cache controls after force - precedence; -6. revalidates the reference snapshots, then validates the v2 successful - receipt, confined index, management documents, configured required lane - descriptors, validation summaries, and regular payload files; -7. atomically promotes the complete bundle to its immutable durable location; -8. records one non-selectable `notarius_index` output and one selectable - `notarius_lane` output per configured lane; and -9. registers each lane as `narratio.extraction.` for downstream - Scriptorium and publish resolution. - -Lane records retain checksum, contract, producer run ID, and Notarius system, -run, pipeline, and lane provenance. Stage metadata retains the durable bundle -root, receipt, diagnostic paths, rejection/warning summaries, producing -Narratio run ID, the resolved trimmed-input identity, and invocation -fingerprint. The input identity binds the exact transcript bytes, canonical -source ID, producer stage/output/run identity, and resolution provenance. -Reference metadata contains only selector, source ID, canonical session-relative -path, checksum, and size; adapter requests receive selector and absolute stable -snapshot path, never payload contents. Snapshot bytes must -match the prepared identity both before and after Notarius runs, so a concurrent -prepared-file replacement cannot make recorded provenance describe different -bytes from those supplied to Notarius. -Validation completes before the single durable rename, so a rejected result -cannot expose a partial durable bundle. - -Snapshot destinations are owned by `internal/artifacts` under -`cache/notarius/references//`. They contain no run ID -or timestamp and can be reused across invocations. Identical bytes and basename -share a verified file; changed bytes select a different digest directory. -Unsafe path components and non-regular conflicts fail without recursive -deletion. Snapshot paths are delivery details and never become manifest output -evidence or prerequisites for reuse of an already complete extract bundle. - -Any executed extraction outcome that replaces a different effective outcome -marks succeeded analysis and delivery dependents stale. Render is an independent -sibling and remains current. Repeating the same disabled self-skip with no -outputs is stable and does not repeatedly invalidate dependent stages. +Disabled extraction records a skip. An execution resolves manifest-backed input +identities, creates immutable content-addressed reference snapshots, and invokes +Notarius with run-local output, log and debug destinations. The adapter accepts a +successful native completion report for the expected pipeline and confined output +directory. The stage reads each configured lane JSON, validates its safe path and +content, then promotes all required products to flat artifact paths before +recording success. The original bundle and optional domain auxiliaries stay in +the producing run. Positive native fallback counts are recorded and reported. ## Resume Validation -Before the focused validator runs, the application compares extract's versioned -semantic fingerprint. It covers enablement, Notarius pipeline identity, sorted -reference selector/source mappings, sorted declared output contracts, and each -canonical `narratio.extraction.` output identity. It also covers the -explicit Notarius configuration-overlay selection; omitted, empty, and exact -`default` selectors share the base-selection identity. It excludes executable, -timeout, working directory, config path, and private Notarius config contents. -Credential presence, reference name, and resolved value are likewise -operational-only and excluded. Ordinary command loading still resolves a -selected reference before resume evaluation, but a credential-only change does -not rerun a valid completed extraction or stale its dependents. - -`internal/stage/extract_resume.go` then permits a skip only when the existing -stage record still matches the current byte- and provenance-bearing invocation -evidence. That evidence covers the current direct trimmed-transcript identity, -sorted prepared-reference identities, pipeline identity, and configured output -contracts, plus the same downstream overlay-selection identity. The same -reference helper and transcript identity are resolved again for artifact -evidence, so changing current transcript bytes, reference bytes, producer -identity, or a named downstream selection makes the prior extraction obsolete. -Operational runner settings do not invalidate otherwise current durable -evidence. This includes `resume` and `chunk_cache`; changing them alone cannot -make a complete extraction non-resumable. If extraction executes, ordinary -runs forward the configured values, while force disables resume and selects -`refresh`. - -A valid prepared-reference change makes extraction non-resumable. Missing, -unsafe, or checksum-inconsistent prepared evidence is a hard validation error -with prepare-force guidance because an immediate extract rerun cannot succeed. - -The validator then checks the producing run identity, canonical immutable -bundle root, path confinement and absence of symlink components, receipt -identity, exactly one canonical index, the exact configured source set, -contracts and provenance, regular-file status, and stored checksums. Missing or -obsolete results are non-resumable and run again; unsafe filesystem conditions -return an error rather than silently accepting or replacing data. - -This sensitivity is limited to the explicit downstream selector. Narratio's -own overlay label and whole effective-configuration digest are not blanket -extraction invalidators. Neither contract can observe files imported by -Notarius configuration, profile contents, prompt/module definitions, or other -transitive inputs. Operators must force extraction after changing any such -private input behind a stable identifier. +Resume checks the direct transcript identity, configured pipeline and lane +selection, reference identities, and manifest-backed output checksums and sizes. +Cache and debug selection, executable version and private downstream config are +not blanket invalidators. Force invokes extraction with cache refresh. A failed +replacement is not represented as a current successful extraction. ## Failure Behavior -Adapter startup, timeout, nonzero exit, receipt decoding, path confinement, -index compatibility, inconsistent warning or diagnostic envelopes, -required-lane rejection or incomplete validation, payload inspection, -checksum, or installation errors fail the stage through ordinary manifest -transition handling. -Stdout receipt and stderr diagnostics remain separate. Downstream stages are -not given selectable extraction sources unless the complete configured result -has passed validation and installation. - -When a replacement attempt begins, the current session-stage record no longer -advertises payload from the previous success. A failed replacement therefore -has no current outputs, logs, generated configuration references, or metadata, -while the earlier immutable promoted bundle remains available for audit and -recovery. +Native errors, malformed completion, missing required lanes, unsafe paths, or +invalid JSON fail the attempt while preserving available diagnostics. A partial +report or incidental output is not success. See [operations](../operations.md#extraction-workflow). ## Implementation And Focused Tests -- Stage execution, selection, and resume validation: `internal/stage/extract.go`, - `internal/stage/extract_resume.go`, - `internal/stage/extract_test.go`, - `internal/stage/semantic_contracts_delivery.go` -- Stable snapshot materialization and verification: - `internal/stage/extract_references.go` -- Subprocess boundary: `internal/adapters/notarius/subprocess.go`, - `internal/adapters/notarius/subprocess_test.go` -- Catalog hydration: `internal/artifacts/extraction_catalog.go`, - `internal/artifacts/extraction_catalog_test.go` -- Composition and downstream behavior: `internal/app/runner_test.go`, - `internal/stage/analyze_test.go`, `internal/stage/publish_test.go` -- Opt-in Notarius v0.8.1 production-boundary coverage: - `internal/stage/notarius_cache_integration_test.go` +`internal/stage/extract.go`, `extract_preflight.go`, `extract_native_test.go`, +`internal/artifacts/extraction_evidence.go`, and `internal/adapters/notarius/` +own the stage, readiness, evidence and subprocess boundaries. The opt-in +`notarius_cache_integration_test.go` exercises a real executable. diff --git a/docs/internal/stage-prepare.md b/docs/internal/stage-prepare.md index a3a1776..50e96cb 100644 --- a/docs/internal/stage-prepare.md +++ b/docs/internal/stage-prepare.md @@ -37,7 +37,7 @@ Materialize canonical current-session inputs before processing stages. - rejects duplicate explicit local audio sources after resolution. - gives distinct local source paths with the same basename deterministic unique prepared filenames so neither source is overwritten. -- materializes S3 audio through spool/cache-aware logic. +- downloads S3 audio into a temporary sibling before verifying and installing the prepared copy. - writes effective autocorrection rules as a Seriatim envelope, with checksum, size, and source provenance, including an empty list when no rules apply. - renders standalone effective campaign, session, and canonical party documents, @@ -72,7 +72,7 @@ previous-artifact requirement set. A change reruns prepare and stales its fixed descendants. Existing successful records without this evidence rerun once when selected. -Workspace, spool, and cache placement are not semantic when logical selection, +Workspace placement are not semantic when logical selection, canonical names, and effective bytes are equivalent. The fingerprint deliberately does not read or rehash large audio. Prepared input checksums remain the content provenance. Before reusing success, prepare @@ -86,7 +86,7 @@ reusable; changed or unavailable evidence causes a normal prepare rerun. - [Configuration](../config.md) owns audio selection, stable input fields, and previous-session settings. -- [Operations](../operations.md) owns physical input, audio, spool, cache, and +- [Operations](../operations.md) owns physical input, audio, and previous-state layout. - [Storage Internals](storage.md) and [Artifact Internals](artifacts.md) explain the internal collaborators. diff --git a/docs/internal/stage-publish.md b/docs/internal/stage-publish.md index 341369d..0d0b485 100644 --- a/docs/internal/stage-publish.md +++ b/docs/internal/stage-publish.md @@ -108,7 +108,7 @@ Includes counts/lists for: - run and previous uploads contain only manifest-declared regular files opened from verified descriptors; symlinks, special files, replacement races, and undeclared entries are rejected or ignored before uploads begin. -- run-local diagnostics, including Notarius receipt and stderr files, are +- run-local diagnostics, including Notarius completion report and stderr files, are archived only when recorded by the session manifest. A run with no declared current-run diagnostics legitimately uploads none. - independent publish locks are not overridden by `--force`; every initially diff --git a/docs/internal/workspace.md b/docs/internal/workspace.md index 8fa8393..763a6ae 100644 --- a/docs/internal/workspace.md +++ b/docs/internal/workspace.md @@ -8,7 +8,7 @@ retention workflow belong in [Operations](../operations.md#local-state-layout). ## Path Ownership -`internal/artifacts` owns canonical session, run, spool, cache, and +`internal/artifacts` owns canonical session, run, and previous-cache path construction. `SessionPathsFor` provides the session-scoped path model, and layout creation goes through `EnsureLayoutFor`. Callers should consume those helpers instead of rebuilding relative paths. @@ -32,13 +32,11 @@ materialized into canonical session paths before stage success. Managed previous-session cache paths remain session-durable and are never redirected into run-local output space. -Polish uses run-local transcript, report/log, and debug destinations; validation -probes use `runs/.validation`. These are not latest-attempt views. - -Extraction uses run-local receipt, stderr, and output-root helpers, then -validates and renames the external bundle to the unique immutable Notarius -bundle path supplied by `internal/artifacts`. Exact physical paths belong in -[Operations](../operations.md#extraction-workflow). +Polish and extraction write to actual run-local output, log, and debug paths. +Each attempt advances managed relative `logs/` and `debug/` links; +skips do not rotate them. Restore has its own diagnostic attempt. Extraction +promotes validated lanes to flat artifacts and retains the original bundle in +the producing run. See [Operations](../operations.md#local-state-layout). Prepared references delivered to Notarius use session-durable paths owned by `internal/artifacts` beneath @@ -93,7 +91,7 @@ syntax and exact deletion scope belong in [CLI](../cli.md#session-clean) and - Path model and local store: `internal/artifacts/paths.go`, `internal/artifacts/local.go` - Run-local materialization: `internal/stage/run_local.go` -- Immutable bundle installation: `internal/stage/extract.go` +- Bundle validation and product promotion: `internal/stage/extract.go` - Workspace modes: `internal/fileops/modes.go` - Cleanup confinement: `internal/fileops/cleanup.go`, `internal/stage/cleanup.go`, `internal/stage/cleanup_plan.go`, and diff --git a/docs/operations.md b/docs/operations.md index 7972456..2a4a6fd 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -30,13 +30,44 @@ Remote session object: narratio session init 2026-04-04 --remote --force ``` -If `campaign.yml` sets `session_template_file`, `session init` renders it. Template variables must resolve to concrete values. +Installation config supplies services, credentials, and an optional reference +catalog. Onboard a campaign with [campaign.yml](../examples/campaigns/lantern-coast/campaign.yml), +[party.yml](../examples/campaigns/lantern-coast/party.yml), and +[speakers.yml](../examples/campaigns/lantern-coast/speakers.yml). The campaign +selects its roster, speakers, optional catalog sources, inline vocabulary and +replacement rules. The roster describes characters and players; speaker mapping +separately describes recordings. The example uses synthetic catalog data. -Campaigns provide speakers, autocorrect, and a canonical party; players are -derived from that roster. Glossary selections and the separate spell-catalog -overlay are optional. Preparation writes the shared glossary documents and -other stable inputs under `inputs/`; consumers use verified prepared files. -See [glossary inputs](config.md#glossary-inputs) for selections and sources. +`session init` uses a campaign template if configured, otherwise the installation +template or built-in default. Supply session audio and metadata, for example: + +```bash +narratio session init 2026-04-04 --output ./session.yml --audio-dir ./audio +``` + +Preparation resolves the roster, rules, and vocabularies into standalone inputs. +See [Configuration](config.md#campaign) for fields, inheritance and clearing. + +## Migrating to the shared pipeline + +Before upgrading an existing deployment, retain its authored sources and any +committed snapshots. Convert campaign identity and inputs to the shared campaign +fields and Narratio extension in [Configuration](config.md#campaign); replace +file-based autocorrection with inline rules and the private spell source with a +shared glossary. Reauthor wrapperless vocabularies as shared envelopes. Remove +retired spool/audio-cache settings, Notarius descriptor fields, `resume`, and +`chunk_cache`; select native `cache` and optional debug controls as needed. +Keep external tool configuration under each tool's ownership: Audita uses its +version 3 configuration and Notarius its version 6 configuration. Consult the +[Audita](integrations/audita.md) and [Notarius](integrations/notarius.md) +contracts for their upstream guides. + +Move unsupported local state aside before regenerating it; restore only a +supported committed session manifest, or regenerate and republish. Do not edit +state markers manually. Products now use flat session paths and diagnostics use +latest-attempt views; explicit remote destinations remain independent. Review +cleanup and separately configured subprocess caches before removing old state. +This guidance does not create a release or publish any changes. ## Standard Session Workflow @@ -85,7 +116,9 @@ comparison details. After selected preparation completes or is reused, Narratio checks downstream work projected to run before processing continues. Audita preflight uses the prepared glossary files, a synthetic transcript, and the selected Audita -configuration; its native provider smoke checks are enabled. Scriptorium +configuration; its native provider smoke checks are enabled. Notarius inspection +and preflight use its configured pipeline and the verified transcript when available, +or a synthetic transcript otherwise. Both may contact providers. Scriptorium requirements discovery checks projected trim and analysis bindings. A missing required binding or failed check stops the invocation; incomplete or conditional prompt discovery can produce warnings. Already completed work remains recorded. @@ -143,7 +176,7 @@ extract through the fixed dependency relation, while a render-only change preserves the extract sibling. Operational timeouts, retry/concurrency tuning, executable paths, -workspace/cache/spool placement, reports, diagnostics, and secret values are +workspace placement, reports, diagnostics, and secret values are excluded. Configuration, models, prompts, modules, or resources loaded privately inside external tools remain unobservable to Narratio. If their contents change behind the same configured identifier, explicitly force the @@ -318,10 +351,10 @@ Audita and `extract` for Notarius. Production can omit both selectors. Set `audita.debug: true` in Narratio to request Audita debug capture. Omission or false adds no debug override. Narratio supplies the run-local `polish/debug` work destination and -the separate `polish/logs` report destination. Notarius's debug directory does -not enable capture; its `--debug` flag is not currently forwarded by Narratio. -See the upstream [Audita configuration](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md) -and [Notarius CLI](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.8.1/docs/cli.md). +the separate `polish/logs` report destination. Set `notarius.debug: true` to request Notarius capture; its debug directory alone +does not enable capture. +See the upstream [Audita configuration](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md) +and [Notarius CLI](https://gitea.maximumdirect.net/eric/notarius/src/tag/v0.10.0/docs/cli.md). Edits inside downstream configuration behind an unchanged selector are not automatically detected by Narratio. To inspect a fresh Audita debug run, explicitly @@ -335,12 +368,8 @@ This replaces polish output and invalidates dependent results; it is not a diagnostics-only operation. Selecting testing does not create an isolated workspace or retain a separate current result. -Notarius v0.8+ defaults to two additional eligible transient provider attempts -per generation. Review downstream retry settings and Narratio's extraction -timeout together; retries can increase elapsed time and provider charges. -Notarius v0.8.1 refreshes its built-in profile checkpoint identity, so older -checkpoints may not be reused. Source-keyed chunk plans and already published -outputs are unaffected; no manual cache deletion is required. +Review downstream retry settings and Narratio's extraction timeout together; +retries can increase elapsed time and provider charges. Selecting Narratio's `testing` overlay then supplies `downstream-economy` only when extraction executes. Switching that explicit selector makes a recorded @@ -382,86 +411,24 @@ Selection behavior: ## Extraction Workflow -When Notarius is omitted or disabled, `extract` records an explicit skipped -outcome with reason `notarius_disabled` and no outputs. A later invocation -reconsiders the skipped stage, so enabling Notarius does not require force. +Disabled extraction records a skipped outcome. When enabled, Narratio uses the +configured Notarius pipeline and verified prepared inputs. Bind the shared party +and combined glossary as described in [Configuration](config.md#notarius-reference-bindings). +The final trimmed transcript and content-identified snapshots under +`inputs/references/` are passed to the subprocess. -When Notarius extraction is enabled, the stage consumes the final trimmed JSON -and preserves the complete validated Notarius bundle at: +Successful configured lanes become flat `artifacts/.json` products and +`narratio.extraction.` sources. The original bundle remains under the +producing run for evidence; it is not implicitly published. A failed replacement +does not make the earlier extraction record current. Native fallback counts and +readiness warnings remain visible in command reports. -- `artifacts/notarius/{narratio_run_id}/` - -The directory is immutable once promoted. Configured lanes become -`narratio.extraction.` sources for Scriptorium and explicit publish rules; -the bundle and `index.json` are retained for audit and resume validation but -are not selectable or published implicitly. - -Configured Notarius references resolve only from the current manifest-backed -prepared inputs. Their canonical locations are `inputs/party.yml`, -`inputs/players.yml`, the four `inputs/glossaries/{party,campaign,setting,spells}.yml` -files, and, when configured, `inputs/spell_catalog.json`. Extraction supplies Notarius with verified, -content-addressed copies under -`cache/notarius/references//`. The full lowercase -SHA-256 digest identifies the reference bytes, so retries and later invocations -reuse the same path while changed bytes select a new path. Older snapshots are -retained and are not current artifact evidence. A concurrent refresh of -canonical prepared files therefore cannot change the bytes consumed by an -in-flight invocation. -For a canonical party, preparation retains the validated authored party bytes -at `inputs/party.yml` and generates `inputs/players.yml` from that roster. -The manifest records their checksums separately, with the players input marked -as derived from the party; refresh preparation after changing the roster rather -than editing either prepared file. -Inspect the effective stable-input inventory and -prepared-file readiness with: - -```bash -narratio session status 2026-04-04 -narratio session validate 2026-04-04 -``` - -Reference metadata records selector, source ID, session-relative path, -checksum, and byte size, but never payload contents. Changing a prepared -reference changes extraction identity: ordinary continuation rejects the old -result, reruns Notarius, and marks successful downstream stages stale. If the -prepared file is missing or inconsistent with its manifest checksum, repair -the source configuration and refresh prepared state first: - -```bash -narratio run 2026-04-04 --stage prepare --force -``` - -Starting a replacement clears the previous extraction payload from the current -session-stage record. If that replacement fails or self-skips, the current -record does not fall back to the earlier outputs. The earlier immutable bundle -remains available for inspection, but downstream resolution requires a new -current successful extraction record. - -Notarius extraction validates its run-local bundle and moves it once to the -unique durable bundle path. A pre-existing durable destination is a collision; -no duplicate promotion tree is created. - -`pipeline.notarius.resume` and `pipeline.notarius.chunk_cache` control work -inside an executed Notarius invocation. Ordinary extraction forwards their -configured values. Forced extraction always disables checkpoint loading and -requests chunk-plan `refresh`, even when the configured mode is `bypass`. -Refresh regenerates and replaces only the active input's accepted chunk plan; -it is not cache deletion. - -Notarius checkpoint recording must be enabled in the deployed Notarius -configuration. Narratio neither creates a Notarius pipeline/configuration nor -reads it to infer checkpoint availability. Configure explicit persistent -Notarius chunk-plan and checkpoint roots when reuse must survive separate -Narratio subprocesses. A changed reference, transcript, selected profile, -profile content, endpoint, or other Notarius checkpoint identity input can -produce a legitimate cold miss. - -There are two independent resume boundaries: Narratio may skip a completed -`extract` stage without invoking Notarius, while `--resume` allows Notarius to -reuse compatible accepted work only after Narratio has decided extraction must -execute. Deleting Narratio's local reference snapshots does not invalidate a -complete durable extraction; missing snapshots are reconstructed only when a -later extraction actually runs. +Narratio can reuse completed extraction without starting Notarius. When extraction +runs, Notarius owns its own cache and configuration. Select native `cache` if +needed; force extraction requests `refresh`. Configure downstream cache locations +in Notarius, outside Narratio cleanup. A changed private downstream model or config +is not automatically detected; force extraction when fresh work is needed. +See [Notarius integration](integrations/notarius.md). ## Migrating Manifest Overlay Provenance @@ -472,7 +439,7 @@ snapshots. ## Migrating Audita and Provider Credentials -Install Audita v4.2 and its own configuration and selected pipeline before +Install Audita v4.3.0 and its own configuration and selected pipeline before running polish. Move ordered processing configuration into Audita; remove the retired Narratio `pipeline.audita.modules` field. Update every old `narratio.input.glossary` binding to the intended explicit glossary source and @@ -484,7 +451,7 @@ List each downstream provider's exact environment-variable name in `audita.credentials`; Narratio passes resolved values to Audita and does not infer names or generate the downstream configuration. `audita.config_path` and `audita.overlay` select Audita's configuration independently of Narratio's -overlay. Consult [Audita's configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md). +overlay. Consult [Audita's configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md). Operators can install the independently maintained [D&D recipes](https://forge.maximumdirect.net/eric/audita-pipelines-dnd/src/commit/6d5e66dcfca4bb5971a8423332a19ce884b846c0/README.md) and select their production or testing overlays explicitly; Narratio does not bundle those recipes or infer a downstream selection. @@ -517,9 +484,9 @@ Run-local diagnostics are: - `runs/{run_id}/polish/logs/{errors.yml,recoveries.yml,report.md}` when Audita reporting is enabled, alongside captured streams and invocation records -- `runs/{run_id}/extract/notarius.receipt.json` -- `runs/{run_id}/extract/notarius.stderr.log` -- `runs/{run_id}/extract/notarius-output/` before durable promotion +- `runs/{run_id}/extract/logs/notarius.report.json` +- `runs/{run_id}/extract/logs/notarius.stderr.log` +- `runs/{run_id}/extract/notarius-output/` for retained original bundles The run upload is an allowlist derived from the session manifest's declared current-run outputs, logs, and generated configurations, not a workspace scan. @@ -667,9 +634,9 @@ plan, so it is not a network-free operation. Default restore scope: -- the committed session manifest, prepared campaign/session/party documents, - and transcript/artifact objects declared by the selected remote commit -- `previous/**` when needed by configured previous-session artifact inputs; +- the committed session manifest, prepared inputs, and transcript/artifact + objects declared by the selected remote commit +- `inputs/previous/**` when needed by configured previous-session artifact inputs; each is selected from its exact committed `published_output` declaration Optional: @@ -686,7 +653,8 @@ Before each install, restore validates the destination again beneath the selected session root. A target changed into a symlink, directory, or other non-regular entry is not overwritten. -Restore writes an execution report at `reports/restore-latest.json`. +Restore writes an execution report under `runs//restore/logs/restore.json`; +`logs/restore` points to the latest actual restore attempt. If restore fails after beginning installation, it leaves a durable `.restore-incomplete.json` marker in the session root. Pipeline runs will stop @@ -696,70 +664,30 @@ snapshot is the recovery procedure. ## Local State Layout -Session root: +A session lives at `{workspace.root}/work/{campaign}/{session_id}`. It contains +`manifest.json`, prepared `inputs/` and `audio/`, `transcripts/` (including +`raw/` speaker files), flat `artifacts/`, and `runs/` for actual attempts. +Previous-session inputs live under `inputs/previous/`; verified subprocess +reference snapshots live under `inputs/references/`. -- `{workspace.root}/work/{campaign}/{session_id}` +Each attempted stage writes actual logs and debug capture beneath its run. +`logs/` and `debug/` are relative links to the latest attempt, +including failed attempts; skipped work does not rotate them. Restore writes its +own diagnostic attempt. Original Notarius bundles remain in the producing run. +Automatic cleanup retains current view targets and session-durable bundle evidence. -Durable session paths: +Remote audio is downloaded to a temporary sibling and verified before replacing +its single prepared `audio/` copy. Restore follows the same layout. Subprocess +cache and state locations are configured separately in those applications. -- `manifest.json` -- `inputs/**` -- `audio/**` -- `transcripts/**` -- `artifacts/**` -- `inputs/previous/**` -- `reports/**` -- `logs/**` -- `config/**` -- `runs/**` -- `inputs/references//` - -`manifest.json` is the versioned session-progress document. Narratio accepts -only `narratio.session-manifest.v2`. Do not edit unsupported session state to -add missing markers. Move unsupported local state aside before regenerating it -or restoring a supported committed snapshot. Republish regenerated state when -the remote snapshot is unsupported. - -Validated Notarius bundles live below `artifacts/notarius/{run_id}/`; receipt, -stderr, and pre-promotion output remain in the producing run's `extract` -directory as described in [Extraction Workflow](#extraction-workflow). -Stable reference snapshots live in the session cache path above. Ordinary -published-run cleanup removes its selected run-local target but retains this -cache, and publish/restore never enumerate it as an artifact. Remove a snapshot -or digest directory manually only while no command is active for the session; -regular missing or corrupt content is reconstructed on the next executed -extraction, while symlinks, directories, and other unsafe conflicts must be -investigated and removed deliberately. - -Run-local layout: - -- `runs/{run_id}/{stage}/outputs` -- `runs/{run_id}/{stage}/logs` -- `runs/{run_id}/{stage}/reports` -- `runs/{run_id}/{stage}/config` -- `runs/{run_id}/{stage}/scratch` -- `runs/{run_id}/polish/debug` for Audita's selected work destination -- `runs/.validation/polish` for validation probes - -Spool layout (runtime/transient): - -- `{spool.root}/{campaign}/{session_id}/{run_id}/...` -- restore audio spool under `{spool.root}/{campaign}/{session_id}/restore/audio` - -Cache layout (durable S3 audio cache): - -- `{cache.root}/s3/{bucket}/...` - -Each cached audio file has an adjacent managed identity record. It binds the -file to its remote object version and verified digest; deleting or altering the -record simply causes Narratio to download and verify the object again. -Remote audio and restored files are fully transferred into sibling temporary -files and validated before they replace their canonical workspace paths. +Only `narratio.session-manifest.v2` is supported. Move older local state aside +and regenerate it, or restore a supported committed snapshot; republish after +regeneration when remote state is incompatible. Do not edit old markers by hand. ### Workspace Permissions Ordinary Narratio workspace content is intentionally shareable with the -workspace group. On POSIX systems, Narratio-created workspace, spool, and cache +workspace group. On POSIX systems, Narratio-created workspace directories converge on setgid `02775`; ordinary files, including manifests, transcripts, generated configuration, logs, reports, and Notarius artifacts, converge on `0664`. Narratio explicitly applies these modes so a restrictive @@ -795,53 +723,14 @@ the session workload. ## Cleanup -Session-scoped cleanup: +Use `narratio session clean SESSION` to remove an entire local session, or +`narratio session clean --all` for all local sessions. Add `--dry-run` to inspect +planned targets. These commands do not delete subprocess caches or remote data. -```bash -narratio session clean 2026-04-04 -``` - -Global cleanup: - -```bash -narratio session clean --all -``` - -Dry-run and cache variants: - -```bash -narratio session clean 2026-04-04 --dry-run --clear-cache -narratio session clean --all --dry-run --clear-cache -``` - -Rules: - -- `clean` deletes work/spool session state; -- cache is preserved unless `--clear-cache` is set; -- each deletion is confined beneath its configured workspace, spool, or cache - root; root, traversal, and out-of-root targets are refused; -- the final cleanup stage is gated by successful publish evidence plus: - - `pipeline.spool.delete_audio_after_publish=true` - - `pipeline.workspace.cleanup_after_publish=true` - - the manifest publish record has `uploaded=true`, the published run ID, the - exact remote commit key, and the current commit-pointer key. - -Cleanup derives only the configured run-scoped spool and workspace targets, -uses root-confined deletion, and does not read or mutate object storage. A -failure leaves publish succeeded and the remote committed snapshot current. -Retry with a normal full run: valid upstream work, including publish and notify, -is skipped while the failed cleanup stage runs again. `run SESSION --stage cleanup` is -also available when the manifest has valid publish evidence. A range ending at -`notify` or earlier and `run SESSION --stage publish` never delete local -state. - -Older local manifests that contain the retired cleanup-obligation field are -intentionally incompatible with strict manifest decoding. If such an -obligation is still outstanding, complete it with the pre-upgrade binary. -Otherwise verify that the remote publication is committed, move aside or -regenerate the incompatible local manifest (or restore the verified remote -snapshot), and then use the cleanup stage. Manual JSON editing is not the -normal migration path. +Automatic run cleanup requires `workspace.cleanup_after_publish` and successful +publication evidence. It preserves current log/debug targets and retained Notarius +bundle evidence. A failed cleanup can be retried without republishing; bounded +runs ending before cleanup do not execute it. See [cleanup internals](internal/stage-cleanup.md). ## Operational Caveats diff --git a/docs/oss/attribution.md b/docs/oss/attribution.md index 5106ef7..a3a4004 100644 --- a/docs/oss/attribution.md +++ b/docs/oss/attribution.md @@ -328,3 +328,15 @@ License and notices: [CC0 1.0](licenses/CC0-1.0.txt) | [LICENSE](https://forge.maximumdirect.net/eric/schemas/src/commit/f7e3cedeca11ed903311cdf29ca4d81fb1f216b7/LICENSE). [Source](https://forge.maximumdirect.net/eric/schemas/src/commit/f7e3cedeca11ed903311cdf29ca4d81fb1f216b7). + +## Narratio reference catalog + +Material: synthetic files under `examples/reference-catalog/`, adapted from +revision `02dd53c6ea026347452d497350c40249c949f8ce`. + +SPDX-License-Identifier: CC0-1.0 + +License and notices: [CC0 1.0](licenses/CC0-1.0.txt) | +[LICENSE](https://forge.maximumdirect.net/eric/narratio-reference-catalog/src/commit/02dd53c6ea026347452d497350c40249c949f8ce/LICENSE). + +[Source](https://forge.maximumdirect.net/eric/narratio-reference-catalog/src/commit/02dd53c6ea026347452d497350c40249c949f8ce). diff --git a/docs/policy/architecture.md b/docs/policy/architecture.md index d30d46a..8650d9b 100644 --- a/docs/policy/architecture.md +++ b/docs/policy/architecture.md @@ -197,7 +197,9 @@ Missing configuration or inspection capabilities are addressed upstream. values remain present and are evaluated by Narratio's domain rules. - Validation rejects invalid configuration before stage execution where practical. -- ConfigKit resolves local imports and the selected pipeline overlay. +- ConfigKit resolves local imports and the selected pipeline overlay. Shared + campaign, party, and glossary documents permit schema extensions; Narratio + operational settings remain strict, as selected in [ADR 0003](../adr/0003-assign-configuration-ownership.md). - Canonical party rosters are campaign-owned inputs. Narratio derives players projections and concrete character-family artifacts as separate domain objects before execution, without modifying configuration. @@ -218,27 +220,26 @@ field-level contract and credential-supply mechanisms belong in ## Artifacts, Paths, And Storage Artifact identities and local and remote paths are application contracts. -Canonical helpers own workspace, spool, cache, session, run, input, transcript, +Canonical helpers own workspace, session, run, input, transcript, artifact, log, report, configuration, and publish-current paths. Callers must not reconstruct canonical paths through scattered string concatenation. -Reusable audio cache entries require a typed record that binds a confined, -no-follow regular file and its digest to the selected remote object identity. -Size alone and unqualified multipart ETags are not content-integrity evidence. +Prepared audio reuse requires manifest-backed identity and checksum evidence. +Subprocess applications own their own state and caches, separately configured +and outside Narratio cleanup. See [ADR 0001](../adr/0001-classify-session-content.md) +and [ADR 0002](../adr/0002-assign-subprocess-content-ownership.md). Artifact resolution is deterministic and manifest-aware. Producers materialize canonical outputs before reporting success, and consumers resolve declared artifact identities rather than infer files from unrelated directory contents. -External artifact bundles become current only through validated immutable -promotion and manifest records; directory presence alone never establishes -availability. +Configured products become current through validated promotion and manifest +records; directory presence alone never establishes availability. Writes, moves, replacements, and deletions must use narrow, explicit, root-confined destinations. Symlinks, traversal, broad roots, and ambiguous relative destinations must not expand the scope of an operation. Cleanup is permitted only through explicit operator action or the configured final cleanup -stage, and it must preserve durable cache unless cache removal is explicitly -requested. +stage, and must preserve subprocess-owned state and caches. Physical layout, retention, and operational lifecycle belong in [Operations](../operations.md). Logical external formats and durable integration diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index ff4cbc7..7fbf732 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -852,6 +852,29 @@ tested consumer baselines. No source release is needed to exercise local binarie ## Stage 23 — Finish canonical documentation and end-to-end verification +**Complete.** Commit: `Document the shared pipeline and verify the cutover`. +The canonical configuration, operations, CLI, integration, troubleshooting, +architecture, internal, example, and attribution documents now describe the +implemented contracts and cutover. Obsolete authored private-input fixtures were +removed. Schema distribution `2026.11.1` is pinned at +`f7e3cedeca11ed903311cdf29ca4d81fb1f216b7`; catalog and tested consumer revisions +and controlled results are recorded above. + +Final verification used Go 1.27.4 after `go mod download`: `go test ./...`, +`go test -race ./...`, `go vet ./...`, and `go build ./...` passed. CGO-disabled +CLI cross-builds passed for Linux amd64, Linux arm64, and darwin arm64; the last +is compile evidence, not a native macOS run. Catalog `go mod download`, +`go test ./...`, and `go run ./cmd/validate` passed independently. Local +documentation links, maintained examples, formatting and scoped diffs were +checked. The Stage 22 script passed the pinned controlled Audita and Notarius +boundaries; default tests remain offline. + +The verification table in [pipeline.md](pipeline.md#delivery-documentation-and-verification) +was checked against the stage evidence above: campaign/acquisition, prepared +and catalog inputs, consumer/readiness, paths/diagnostics, reuse, durable +lifecycle and audio each have focused tests, and assembled/real-consumer +checks cover their boundaries. No required outcome remains open. + **Read:** roadmap “Delivery, documentation, and verification”; documentation, architecture, testing, and OSS policies; Development validation commands. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index f6eb80e..76322e5 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -22,7 +22,7 @@ narratio session plan 2026-04-04 Safe fix: -- pass explicit `--config`, `--campaign` or `--campaign-file`, and `--session`. +- pass explicit `--config`, `--campaign` or `--campaign-file`, and `--session-file`, with the positional session ID. Relevant reference: [Configuration discovery](./config.md#discovery-and-selection). @@ -377,7 +377,7 @@ Likely causes: Safe fix: - follow the [migration guidance](./operations.md#migrating-audita-and-provider-credentials) - and use an Audita v4.2 executable and configuration; + and use an Audita v4.3.0 executable and configuration; - provide each needed provider-named variable through the environment or secrets directory, and list that same name in `pipeline.audita.credentials`; - validate the external file offline with @@ -414,12 +414,12 @@ and [Notarius integration](./integrations/notarius.md). Symptom: -- extraction reports a Notarius exit error instead of a receipt. +- extraction reports a Notarius exit error instead of a completion report. Diagnostics: -- inspect `runs/{run_id}/extract/notarius.stderr.log`; stdout is reserved for - the receipt and is not merged with diagnostics. +- inspect `runs/{run_id}/extract/logs/notarius.stderr.log`; stdout is reserved for + the completion report and is not merged with diagnostics. Safe fix: @@ -445,7 +445,7 @@ Likely causes: - `prepare` has not run since the campaign/session stable input changed; - the configured source file is missing; - a prepared `inputs/` file or its manifest record was modified independently; -- a spell-catalog binding exists without an effective `spell_catalog_file`. +- a configured glossary binding does not identify a prepared shared glossary. Diagnostics: @@ -472,7 +472,7 @@ and [Operations: Extraction Workflow](./operations.md#extraction-workflow). Symptom: - extraction reports that a path beneath - `cache/notarius/references//` is a symlink, directory, or another + `inputs/references//` is a symlink, directory, or another non-regular or unsafe entry. Safe fix: @@ -491,34 +491,11 @@ Relevant reference: [Operations: Extraction Workflow](./operations.md#extraction ## Notarius resume executes work instead of reusing it -Symptom: - -- Narratio executes `extract`, and Notarius makes provider calls despite - `pipeline.notarius.resume: true`. - -Likely causes: - -- checkpoint recording is disabled in the Notarius configuration; -- Notarius is using a nonpersistent or different checkpoint root; -- transcript/reference bytes, reference paths, pipeline/profile content, - local-backend endpoint, selected lanes, or another checkpoint identity input - changed; or -- Narratio extraction was forced, which deliberately omits `--resume`. - -Safe fix: - -- validate the deployed Notarius configuration and configure explicit - persistent chunk-plan and checkpoint roots; -- inspect Notarius checkpoint decision reason codes for a legitimate cold miss; - and -- retry without force only when reuse is intended. - -Remember that Narratio skipping a completed `extract` stage is separate from -Notarius reusing work inside an extraction that does execute. Narratio does not -read the Notarius configuration to infer checkpoint enablement. - -Relevant references: [Notarius cache controls](./config.md#notarius-cache-controls) -and [Notarius integration](./integrations/notarius.md). +Narratio may reuse a completed extraction without invoking Notarius. When it +executes, Notarius independently selects cached results based on its own +configuration and inputs. Verify its configured cache location and native +cache mode; force requests `refresh`. Changed inputs or downstream settings can +cause a cold miss. See [cache controls](config.md#notarius-cache-controls). ## Notarius reference selector or generated-handoff collision @@ -545,44 +522,13 @@ Narratio validates selector structure and prepared evidence, while Notarius owns slot declarations, media compatibility, and generated-handoff conflicts. Relevant reference: [Notarius integration](./integrations/notarius.md). -## Notarius receipt or index incompatible +## Notarius completion or required lane invalid -Symptom: - -- extraction rejects the receipt schema, pipeline identity, bundle/index path, - lane descriptor, or payload path even though Notarius exited successfully. - -Likely causes: - -- Narratio and Notarius versions disagree on their consumer contract; -- the configured pipeline or lane constraints are stale; -- output paths escape the bundle or traverse symlinks. - -Safe fix: - -- compare installed Notarius output with the canonical Notarius contracts, - including receipt `index_file: index.json` and index management names - `manifest.json`, `rejected.json`, `warnings.json`, and `diagnostics.json`; align - `pipeline.notarius` constraints and rerun. Do not bypass confinement or schema - checks. - -Relevant reference: [Notarius integration](./integrations/notarius.md). - -## Required Notarius lane rejected or missing - -Symptom: - -- extraction fails because a configured lane is rejected, missing, duplicated, - or incompatible, including after a zero exit. - -Safe fix: - -- inspect the Notarius diagnostic log and bundle rejection/warning information; -- correct the Notarius module or the exact declared lane contract; -- remove an output declaration only if downstream consumers genuinely no longer - require that source, then rerun extraction. - -Every configured output is required. Narratio does not promote a partial result. +If successful subprocess output is rejected, inspect the native completion +report and stderr under the extraction attempt's logs. Confirm the configured +pipeline identity, safe output directory, and required lane IDs against the +[Notarius contract](integrations/notarius.md). Correct the configuration and +rerun; do not treat partial output as a success or bypass confinement checks. ## Extraction resume invalidated @@ -592,11 +538,11 @@ Symptom: Likely causes: -- the pipeline ID or configured output contracts changed; +- the pipeline ID or configured output selection changed; - a configured prepared reference selector, source, path, checksum, or byte size changed; - the direct trimmed transcript identity or bytes changed; or -- the durable bundle, index, lane set, provenance, regular-file status, or +- a promoted product, its manifest provenance, regular-file status, size, or checksum no longer validates. Safe fix: diff --git a/examples/README.md b/examples/README.md index 91226ed..efe86f6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -54,6 +54,12 @@ with the sample campaign and a compatible local- or S3-audio session. ## Campaign And Session Configuration +- [Lantern Coast](campaigns/lantern-coast/campaign.yml) is a complete three-file + campaign with adjacent [party](campaigns/lantern-coast/party.yml) and + [speakers](campaigns/lantern-coast/speakers.yml). Its optional vocabulary and + autocorrection rules may be omitted. Select the synthetic catalog through the + [catalog pipeline](pipeline.catalog.yml). + - [Sample campaign](campaigns/sample-campaign/campaign.yml), its [session template](campaigns/sample-campaign/session.template.yml), and its adjacent stable inputs provide a complete campaign directory shape. Its @@ -73,16 +79,15 @@ those IDs only when the pipeline imports a matching catalog. ## Input Fixtures -- [Speakers](speakers.yml), [autocorrect](autocorrect.yml), and - [glossary](glossary.yml) show the standalone input shapes. -- The sample campaign references its local - [speakers](campaigns/sample-campaign/speakers.yml), - [autocorrect](campaigns/sample-campaign/autocorrect.yml), - [glossary](campaigns/sample-campaign/glossary.yml), and canonical - [party](campaigns/sample-campaign/party.yml) fixture, plus an optional - [spell-catalog overlay](campaigns/sample-campaign/spell_catalog.json) that - follows the Notarius v0.7 contract. Narratio derives the players projection - from this party source. +- [Speakers](speakers.yml) and [glossary](glossary.yml) show standalone + formats. Autocorrection is authored inline in campaign or session configuration. +- The sample campaign uses its local [speakers](campaigns/sample-campaign/speakers.yml), + [glossary](campaigns/sample-campaign/glossary.yml), and + [party](campaigns/sample-campaign/party.yml). Narratio derives players from + the roster and writes the Seriatim autocorrection input during preparation. +- The synthetic [reference catalog](reference-catalog/catalog.yml) is adapted + from catalog commit `02dd53c6ea026347452d497350c40249c949f8ce`, under CC0-1.0; + see [attribution](../docs/oss/attribution.md). - [Sample speaker audio](audio/sample-speaker.flac) is a text placeholder that reserves the expected filename and directory shape. Replace it with a real FLAC file before running transcription. @@ -94,7 +99,7 @@ examples that reference them. They use fictional campaign content and reserved example domains. The Audita and Notarius names are example references, not implicit aliases: external backend/profile configurations must use those exact names, or the Narratio credential lists must be changed to match. See the -[Audita v4.2 configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md) +[Audita v4.3.0 configuration guide](https://forge.maximumdirect.net/eric/audita/src/tag/v4.3.0/docs/config.md) for maintained downstream configuration examples. For a deployed bundle, keep credential files out of source control. Select a diff --git a/examples/autocorrect.yml b/examples/autocorrect.yml deleted file mode 100644 index 7dd4387..0000000 --- a/examples/autocorrect.yml +++ /dev/null @@ -1,2 +0,0 @@ -[] - diff --git a/examples/campaigns/sample-campaign/autocorrect.yml b/examples/campaigns/sample-campaign/autocorrect.yml deleted file mode 100644 index fe51488..0000000 --- a/examples/campaigns/sample-campaign/autocorrect.yml +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/examples/campaigns/sample-campaign/spell_catalog.json b/examples/campaigns/sample-campaign/spell_catalog.json deleted file mode 100644 index fe8effb..0000000 --- a/examples/campaigns/sample-campaign/spell_catalog.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "schema_version": "notarius.dnd.spell-catalog-overlay.v1", - "catalogs": [ - { - "id": "narratio.sample-campaign", - "ruleset": "dnd-5e-2014", - "source": { - "title": "Narratio sample campaign spell names" - }, - "spells": [ - { - "name": "Aegis of Emberfall", - "aliases": ["Emberfall Aegis"] - } - ] - } - ] -} diff --git a/examples/pipeline.extraction-subset.yml b/examples/pipeline.extraction-subset.yml index 790e86c..b92b777 100644 --- a/examples/pipeline.extraction-subset.yml +++ b/examples/pipeline.extraction-subset.yml @@ -17,7 +17,6 @@ notarius: references: glossary: narratio.input.glossary.combined party: narratio.input.party - players: narratio.input.players spell_catalog: narratio.input.glossary.combined outputs: npc_registry: diff --git a/examples/pipeline.full.annotated.yml b/examples/pipeline.full.annotated.yml index a8e81a1..76cdf2c 100644 --- a/examples/pipeline.full.annotated.yml +++ b/examples/pipeline.full.annotated.yml @@ -136,12 +136,12 @@ notarius: working_directory: /usr/local/etc/notarius # Forced extraction requests refresh from Notarius. cache: auto + debug: false # true requests run-local Notarius debug capture # External campaign references use prepared Narratio source IDs. Omit an # optional binding when the selected Notarius pipeline does not need it. references: glossary: narratio.input.glossary.combined party: narratio.input.party - players: narratio.input.players spell_catalog: narratio.input.glossary.combined # Each key creates source narratio.extraction. for its selected lane. outputs: diff --git a/examples/reference-catalog/fragments/places.yml b/examples/reference-catalog/fragments/places.yml deleted file mode 100644 index b65c643..0000000 --- a/examples/reference-catalog/fragments/places.yml +++ /dev/null @@ -1,3 +0,0 @@ -setting: - entries: - - {id: harbor, name: North Harbor, category: place}