diff --git a/docs/roadmap/audita.md b/docs/roadmap/audita.md deleted file mode 100644 index 09f02f0..0000000 --- a/docs/roadmap/audita.md +++ /dev/null @@ -1,715 +0,0 @@ -# Adopt Audita v4.2, runtime glossaries, and diagnostic destinations - -## Purpose - -Adopt Audita v4.2.0 directly for transcript polishing. Preserve Narratio's -orchestration and output validation while using Audita's native configuration, -processing, and reporting contracts. Place the corrected transcript, ordinary -reports, and optional debug evidence in their Narratio-selected destinations. - -This roadmap supersedes the v4.1 adoption proposal and records the agreed -runtime-glossary ownership boundary. It defines the target and required changes; -the [implementation plan](implementation.md) owns staged execution. -The [workspace roadmap](workspace.md) owns shared layout, latest-attempt views, -and retention behavior. Its referenced ADRs remain Proposed. - -## Reviewed Baseline and Upstream - -Narratio baseline: `3b1718c44fcd893dc8c91a9bfe3950653ed7f19e`. -The reviewed Audita v4.2.0 tag identifies commit -`973b24e46618dc785751fa7c803e7c16c900353f`. - -Canonical upstream references: - -- [v4.0 release notes][v4], [v4.1 release notes][v41], and - [v4.2 release notes][v42]. -- [CLI][cli], [configuration][config], and [operations][operations]. -- [Application schema v3 migration][schema-migration] and - [v4.1 migration][migration]. -- [Subprocess integration][subprocess], [input contract][inputs], and - [output/report contract][outputs]. - -Audita remains a separately installed executable. Its current library versions -require no Narratio dependency upgrade for this adoption. Narratio's maintained -Go toolchain already meets Audita's source-build minimum. - -The separate [D&D recipe repository][recipes] was also reviewed at commit -`6d5e66dcfca4bb5971a8423332a19ce884b846c0`. Its overlays passed offline checks -against v4.2.0. Its README still describes the runtime interface as unreleased; -updating that upstream statement is a documentation follow-up, not an adapter -dependency. There is no remaining upstream feature blocker for the glossary -handoff or synthetic-transcript preflight. The implementation plan records the -steps needed to reach this target. - -## Current Narratio Behavior - -The [Audita integration](../integrations/audita.md), -[polish internals](../internal/stage-polish.md), and -[configuration reference](../config.md#audita-selection-and-credentials) -describe implemented behavior: - -- The adapter invokes `process` with the base transcript, `--glossary` pointing - to prepared `inputs/glossary.yml`, and a run-local transcript destination. -- Optional module selection uses `--modules`; omission, an empty list, order, - and repeated modules have distinct existing meanings. -- Config, overlay, proposal/validation profile, description, and transcript - output-schema selectors are forwarded when selected. -- The adapter supplies no debug, work-directory, or reporting flags. Ordinary - reports are discovered beside the staged transcript. -- Only a successful validated transcript becomes canonical. Available reports, - captured streams, and the invocation record are diagnostics. -- Configured credential references use shared exact-name forwarding and - captured-stream redaction. - -Audita v4.2 rejects the current glossary and module flags. The old adapter and -new executable therefore require a coordinated cutover. The prior roadmap's -v3-only profile migration is insufficient. - -## Targeted End State - -### Native processing and configuration ownership - -Narratio invokes Audita v4.2's `process` command with explicit transcript input -and output paths, its existing supervisor timeout, and selected supported -resource/configuration overrides. Audita owns its application schema v3, -`pipeline.stages`, glossary collections, PromptKit resources, and processing -preflight. Narratio owns stage selection, input handoff, result validation, -manifest evidence, and promotion. - -Retain independent downstream config and overlay selection. Narratio's pipeline -overlay does not imply an Audita overlay. Retain supported profile, description, -and transcript output-schema overrides with their upstream meanings: process -flags affect root settings, while explicit Audita per-entry settings retain -their native precedence. - -Replace the removed `--glossary` interface with native runtime inputs. Retire -`pipeline.audita.modules` and its request/runner plumbing. Operator-maintained -Audita configuration owns `pipeline.stages`, including ordering, repetitions, -and normalization-only processing; Narratio prepares inputs and selects the -configuration. Do not translate the retired module list into generated config. - -Audita checks selected profiles and glossary-correction entries before preparing -processing outputs or making model calls. Consume its ordinary outcomes and -diagnostics through Narratio's preflight orchestration rather than implementing -a second Audita processing-readiness engine. - -### Runtime glossary handoff and ownership - -Narratio owns domain-specific glossary selection, projection, and preparation. -ConfigKit owns generic resolution, imports, inheritance, and composition through -its native workflow. Audita owns final composition with its configuration, -interpretation of the supplied collections, and processing. - -Narratio prepares four shared domain collections and supplies all four to Audita: - -| Collection | Source and preparation | -| --- | --- | -| `party` | Project character IDs, names, and aliases from the required canonical party roster into Audita entries. | -| `campaign` | Prepare the operator's campaign glossary terms using Audita's native entry structure. | -| `setting` | Select and prepare reference vocabulary from a catalog using a setting ID, such as `forgotten_realms`. | -| `spells` | Select and prepare spell vocabulary from a catalog using a system ID, such as `5e`. | - -These collections cover the anticipated vocabulary needs. Other subprocesses -may consume subsets or consumer-specific projections and combinations. Save all -prepared collections and projections as shared domain inputs with content -evidence, rather than private Audita-adapter files. Preserve named collections -where the consumer supports them; add a projection only for a demonstrated -consumer need, without a generic projection framework. - -Catalog definitions belong in application/pipeline configuration, supplied by -the installed catalog's importable fragment. Campaign configuration selects the -setting, system, and campaign vocabulary. Session configuration may override -those choices through the existing campaign/session input model; omission -inherits the campaign choice. - -Campaign vocabulary may be supplied by an external `glossary_file`, an inline -`glossary` collection with native `entries` and optional `instruction`, or both. -Use native ConfigKit import and composition semantics when both are supplied. -Both forms resolve to one campaign collection and share preparation, preflight, -and execution paths. The authoring contract below defines their selection and -native precedence; do not introduce a separate merge mechanism. - -Setting and system catalogs are configuration data mapping identifiers to -reference sources, extensible without Go changes or a custom loader. Each -identifier selects one entry file; that file may use native ConfigKit imports -to compose reusable fragments. The campaign selects its setting and system. -Unknown identifiers and unreadable selected sources fail early with contextual -diagnostics. - -Narratio supplies prepared collection files with repeatable `--glossary-file` -arguments. Files use Audita's wrapperless native collection shape. A file may -contain multiple collections; input order is significant under the upstream -composition rules. Resolve selected vocabulary and imports with ConfigKit and -capture fully resolved, standalone glossary projections as prepared inputs. -Preserve collection boundaries, instructions, extensions, and native presence -semantics. Do not add Narratio-specific collision or merge rules. - -Record prepared content evidence and supply the same prepared vocabulary to -preflight and processing. Preparation and resume use shared production paths; -polish consumes the prepared data rather than reopening live vocabulary sources. -Audita's private configuration and references remain downstream-owned. These -snapshots do not promise identical future model results. - -Audita's runtime files preserve the selected main's companion discovery, overlay -context, and bootstrap. Supplying definitions does not select them; native root -and per-entry selections remain in Audita configuration. Narratio need not expose -new glossary/protection selection flags for this adoption. - -Follow the [upstream configuration contract][config] at both composition -boundaries. Runtime files compose first; their supplied entry lists then replace -configured lists at CLI precedence while unrelated collections remain. Runtime -inheritance resolves within supplied files and imports, separately from application -inheritance. Final inspection records the CLI assignment; detailed file/import -provenance remains with the preliminary load. Use these native capabilities -without reconstructing effective Audita configuration or provenance in Narratio. - -Audita's optional collection `instruction` field carries proposal guidance and -remains in the repair conversation. Preserve operator-supplied instructions; -domain guidance can live in the selected recipe. Narratio supplies the native -data format rather than maintaining Audita prompt templates or validator rules. - -Notarius v0.9.0 adoption and upstream Notarius enhancements or feature requests -belong to a separate, subsequent roadmap. This scope establishes shared Narratio -inputs without prescribing that every consumer accept all four collections. -Apply the explicit input cutover below without silently reinterpreting downstream -bindings or adding legacy format detection or conversion. - -### Glossary authoring and precedence - -Use these fields in the new configuration contract: - -| Scope | Field | Meaning | -| --- | --- | --- | -| Application/pipeline | `reference_catalog.settings` | Map of setting IDs to entry-file paths. | -| Application/pipeline | `reference_catalog.systems` | Map of system IDs to entry-file paths. | -| Campaign/session | `inputs.setting` | Optional selected setting ID. | -| Campaign/session | `inputs.system` | Optional selected system ID. | -| Campaign/session | `inputs.glossary_file` | Optional external named-collection file supplying `campaign`. | -| Campaign/session | `inputs.glossary` | Optional inline collection supplying `campaign`. | - -After campaign/session selection, omitted setting or system selections produce -empty `setting` or `spells` collections. If neither campaign vocabulary form is -supplied, prepare an empty `campaign` collection. All four prepared identities -remain present; the canonical party roster is still required. Explicitly selected -catalog IDs and files must resolve successfully and supply the expected named -collection. Do not turn a missing or invalid selected source into an empty result. -Empty collections are valid; Audita owns processing sufficiency checks. - -All four entry lists are authoritative runtime inputs, including empty lists. -An omitted Narratio setting or system selection therefore replaces any -same-named Audita-configured entry list with an empty list. Other Audita -collections remain available under native composition. - -Resolve catalog paths and `glossary_file` relative to their defining sources, -including imported fragments. External files use the canonical named-collection -document shape, not a bare collection or a legacy glossary. Their native imports -remain relative to each declaring file. Resolve the complete file before selecting -its named collection so native inheritance can reference sibling definitions. - -Session omission inherits each campaign field independently. An explicitly -supplied session field replaces that field's campaign selection: a session file -selection does not implicitly clear inherited inline vocabulary, and a session -inline collection replaces the campaign inline collection rather than silently -combining both. Explicit empty/null values retain native typed meaning and undergo -domain validation; they must not trigger fallback to the campaign value. - -For the selected campaign vocabulary, use a separate native ConfigKit layered -load: the selected external file is the lower tier, with imports enabled; the -selected inline collection is the higher input mounted at `campaign`. Omit an -absent contribution. Register entry identity by `id` using ConfigKit's supported -sequence-identity API, matching Audita. Native default upsert replaces a matching -entry in full, retains unmatched file entries, and appends new inline identities. -Native explicit collection modes continue to govern composition; no Narratio -entry-merging or collision algorithm is added. Preserve ConfigKit errors. - -This load produces a separate domain input, not a rewritten effective campaign -or session configuration. File selection and inline data remain visible through -their ordinary configuration views. Prepared inputs contain the resolved result. - -The following abbreviated future configuration illustrates the contract; other -required Narratio settings are omitted. The installed catalog fragment contains: - -```yaml -reference_catalog: - settings: - forgotten_realms: ./settings/forgotten_realms.yml - systems: - 5e: ./systems/5e.yml -``` - -Pipeline configuration imports that fragment through native `config.imports`: - -```yaml -config: - imports: - - path: ./reference-catalog/catalog.yml - required: true -``` - -Campaign configuration selects its entries and supplies local vocabulary: - -```yaml -campaign_id: sample-campaign -inputs: - setting: forgotten_realms - system: 5e - glossary_file: ./vocabulary.yml - glossary: - entries: - - {id: watch, name: Silver Watch, category: organization} -``` - -`vocabulary.yml` may import relative fragments using `config.imports`; its -resolved collection could be: - -```yaml -campaign: - instruction: Use established campaign names. - entries: - - {id: watch, name: Old Watch, category: organization, aliases: [Old]} - - {id: harbor, name: North Harbor, category: place} -``` - -The prepared campaign retains the instruction and harbor entry, and replaces -the complete watch entry with the inline Silver Watch record, including removal -of the old alias. A session setting `inputs.glossary` to -`{instruction: "Session context."}` replaces the campaign inline contribution: -the file's Old Watch and North Harbor remain, with the session instruction. -A session overriding only -`inputs.glossary_file` instead uses that file beneath the inherited Silver Watch -inline contribution. These are explicit field selections followed by native -layered composition, not an additional campaign/session merge policy. - -An inline `entries: []` contributes no records under native default upsert; it -does not clear the file's entries. To use replacement instead, place this native -control at the root of the selected `vocabulary.yml`, alongside `campaign`: - -```yaml -config: - sequences: - - destination: [campaign, entries] - mode: replace -``` - -That explicit lower-tier mode persists into the inline tier under ConfigKit's -rules. A session can then clear the file's entries with: - -```yaml -inputs: - glossary: - entries: [] -``` - -The result retains the collection's instruction with an empty entries list. -This control belongs to the glossary load, not the outer campaign/session -configuration load. Do not add a Narratio-specific clearing flag or treat empty -lists as replacements when native collection policy says otherwise. - -### Shared input identities and cutover - -Prepare each collection as a standalone named-collection document: - -| Collection | Source ID | Prepared path | -| --- | --- | --- | -| `party` | `narratio.input.glossary.party` | `inputs/glossaries/party.yml` | -| `campaign` | `narratio.input.glossary.campaign` | `inputs/glossaries/campaign.yml` | -| `setting` | `narratio.input.glossary.setting` | `inputs/glossaries/setting.yml` | -| `spells` | `narratio.input.glossary.spells` | `inputs/glossaries/spells.yml` | - -Register these identities with shared input resolution, manifest evidence, -preparation/reuse, publication, and restore handling. Keep paths under the shared -workspace owner. Only requested consumer projections add further input identities; -do not create a speculative combined-glossary artifact. - -Retire `narratio.input.glossary` and its `inputs/glossary.yml` preparation contract. -Reprepare affected inputs and reconsider dependent semantic evidence under normal -rules; an old file or manifest record does not satisfy a new source identity. -Do not provide a source alias or automatically rewrite operator configuration. -Migration guidance must replace old source references explicitly and move authored -campaign vocabulary to the native inline or named-file contract. - -For the currently supported Notarius integration, the existing text `glossary` -slot can explicitly bind `narratio.input.glossary.campaign`; Narratio supplies its -prepared YAML as text through the existing reference mechanism. Update maintained -bindings accordingly. This does not introduce new Notarius slots or adopt v0.9.0. -Scriptorium bindings likewise select the new collection IDs explicitly; prompt -authors must update any expectations of the old content shape. Consumer-local -binding names such as `glossary` need not change when their source ID changes. - -`narratio.input.party` and `narratio.input.players` retain their richer roster and -player contracts. `inputs.spell_catalog_file` and `narratio.input.spell_catalog` -retain the current structured Notarius spell-overlay contract until that separate -adoption addresses it. The new `spells` glossary is not a replacement for that -different input, and this roadmap adds no conversion between them. - -### Canonical glossary format - -The reference-catalog repository owns the canonical interchange format document, -a versioned JSON Schema (for example, `schemas/glossary-v1.schema.json`), and -small valid and invalid examples. Narratio owns source selection, preparation, -and projection behavior and links to that format contract. A common format is -the intended basis for reuse across consumers; each consumer still owns its -interpretation and processing rules. - -Start with Audita's existing wrapperless mapping of collection names to -collections. Define a reusable collection schema with `entries` and optional -`instruction`; entries retain native `id`, `name`, `category`, optional fields, -and supported extensions. Reuse field definitions for partial authoring inputs, -and the complete collection schema for resolved individual collections and -documents containing multiple collections. The four -Narratio roles do not restrict the names allowed by the general format schema. - -Validate decoded YAML data against JSON Schema after ConfigKit resolves imports, -inheritance, and final file/inline composition. Partial contributions, including -an inline collection containing only `instruction`, are allowed; do not validate -them as complete collections before combining them. Complete prepared collections -have an `entries` list, which may be empty; do not impose a nonempty-list rule. -Integrate validation with shared acquisition and -preparation paths using existing library capabilities. Retain semantic checks -where needed, such as entry-ID uniqueness within a collection; schema validity -alone does not establish processing readiness. - -Version the format separately from vocabulary releases. Identify the format -through its schema identity and documented contract, without inserting a -top-level version field into Audita's collection mapping. Consumers use a pinned, -locally available schema rather than fetching it during execution. - -### D&D recipes and operator readiness - -The external D&D recipe repository owns recipe role meanings, processing stages, -profiles, and domain guidance. Document selecting its production/testing overlays -as an operator workflow, with a selected recipe revision. Operators may maintain -their own Audita configurations and overlays. Preserve Narratio's independent -downstream selectors; choosing a Narratio overlay does not automatically select -a D&D recipe. Narratio does not bundle or regenerate the upstream pipeline. - -### Preflight after preparation - -Execution follows configuration acquisition and validation, `prepare`, preflight, -then processing beginning with `transcribe`. Run full native `audita preflight` -through `internal/preflight` when polish is projected to execute. Move existing -Scriptorium execution preflight checks to the same boundary, retaining their -target selection and finding policies. Preparation may complete or be reused; -preflight runs before the first selected processing stage that follows it. - -Preflight is an invocation check, not a durable stage with reusable success. -Check relevant work on each invocation because credentials and provider readiness -can change. Bounded runs that omit `prepare` use the verified prepared inputs -they will consume, without implicitly preparing again. Missing prerequisites -produce actionable errors. Invocations with no relevant work invoke no downstream -preflight. `session plan` remains subprocess-free. - -Preparation, including audio downloads, occurs before these checks. This accepts -preparation costs in exchange for checking actual prepared inputs before expensive -processing. Retain native Audita provider smoke checks; they may contact services -and consume usage. - -`session validate` uses the same downstream checking paths against existing -prepared inputs, with Audita checked when polish is enabled. If required prepared -inputs are unavailable, report that preparation is needed. Do not implicitly run -`prepare`, download audio, or create candidate glossaries. Basic configuration -checks can still report their findings. Full validation performs native destination -probes and provider calls and is not described as read-only or offline. - -Maintain one representative synthetic transcript as a Narratio-owned integration -asset, embedded in the executable with `go:embed`. Materialize it in invocation- -scoped temporary storage for Audita and clean it up afterward. It is not a shared -domain input or canonical session transcript. Supply it with the actual prepared -glossaries, selected configuration, overlay, profiles, credentials, processing -settings, and intended destinations. -Use ordinary prepared-input resolution and share adapter invocation construction -with production execution. Create destination parents required for Audita's -native probes. Preflight itself must not promote outputs, mark processing -complete, invalidate results, or advance latest-attempt views. - -Any unsuccessful preflight stops processing with Audita's diagnostic explanation. -Completed preparation remains available for reuse, and any normal invalidation -caused by preparation remains in effect. Preflight failure does not roll back -those transitions. Consume native outcomes and captured diagnostics without parsing -human-readable reports into a second readiness model. No upstream extension or -relaxation of Audita's required processing inputs is needed. - -Report the scope accurately: configuration and provider readiness were exercised -using synthetic transcript content. Audita still checks the actual transcript -when processing begins, and provider readiness can change afterward. A known-good -fixture is not compatible with every possible configuration; for example, a -requested section count may be infeasible for it. Such failures remain errors. -Address concrete fixture conflicts when encountered rather than adding -speculative fixture-generation or configuration-rewriting machinery. - -### Products and diagnostics - -Narratio supplies destinations for each actual polish attempt: - -| Content | Target destination and control | -| --- | --- | -| Corrected transcript | Run-local staging via `--output`, followed by existing validation and promotion to `transcripts/polished.json`. | -| Ordinary reports | `runs//polish/logs/` via `--report-dir`. | -| Captured stdout/stderr and Narratio invocation record | The same run-local polish log directory. | -| Optional debug evidence | `runs//polish/debug/` via `--work-dir`; Audita may create its own nested run directory. | - -Use the shared workspace path owner and create required destination parents -before invocation, as required by Audita's output contract. The workspace work -adds `logs/polish` and `debug/polish` latest-attempt views and retention protection. -The adapter uses actual run paths rather than maintaining its own link scheme. -Native adoption and explicit destinations can land before those shared views. - -Discover `errors.yml`, `recoveries.yml`, and `report.md` in the requested report -directory, including available failure reports. Keep the existing transcript and -report bounds, path validation, and declared diagnostic publication behavior. -Reports remain optional diagnostics. A successful invocation can contain -recoverable model errors; a nonzero outcome, including a late report failure, -does not authorize transcript promotion merely because output bytes exist. - -### Debug selection and ordinary production behavior - -Add optional `pipeline.audita.debug`, defaulting to false. True requests -`--debug`; false or omission supplies no debug override. Supply `--work-dir` -to select the diagnostic destination without implicitly enabling capture. -Audita v4.2 enables retained capture through its debug CLI/reporting mode; this -roadmap adds no downstream YAML debug-enable setting. - -Ordinary production operation supplies neither `--debug` nor `--reporting=false`. -Keep Audita's default reporting behavior and explicit downstream configuration -choices. No new Narratio reporting toggle or debug-disable override is needed. -Audita's new token-summary and live-progress flags need no Narratio controls for -this adoption. - -Debug selection and destination changes alone do not invalidate a completed -transcript. Operators use the existing force workflow to obtain fresh evidence. -Keep full debug bundles local under the workspace roadmap's agreed behavior; -Narratio supplies the root and does not parse, repackage, or implicitly publish -their contents. Existing declared diagnostics retain their publication behavior. - -### Credentials, failure handling, and compatibility - -Retain Narratio's configured secret-reference resolution and exact-name -forwarding, including shared keys such as `OPENROUTER_API_KEY` and -`RAKESTRAWHOME_API_KEY`. Audita/PromptKit own backend credential selection; -Narratio does not enumerate private backend definitions or invent key aliases. -Audita's native ConfigKit bootstrap may supply child credentials according to -its own configuration. Preserve Narratio's captured-stream redaction; Audita -v4 does not provide application-wide credential substitution in arbitrary -diagnostic artifacts. - -Use a clean v4.2 cutover with manual deployment configuration migration. -Do not add legacy parsers, automatic conversions, compatibility shims, or -version-dependent adapter branches anywhere in this adoption. Migration guidance -describes operator changes to the new contracts. Narratio continues to accept -success with recoverable model errors and preserves the original causes and -available evidence on failure. -Current treatment of older completed files after invalidation or failed -replacement remains unchanged. - -## Required Changes - -### Deployment migration - -Replace Audita application schema v2 with schema v3 and native resource -definitions using the upstream guides. Move module order to `pipeline.stages` -and glossary definitions/selections to native collections and runtime inputs. -Preserve intended campaign terminology, including migration of -legacy `summary` context to `description` where applicable. - -Remove obsolete confidence settings and prompt fields. Remove root and per-entry -`llm.repair_attempts`; selected prompts now own structural output contracts and -repair budgets. Audita's semantic correction-repair budget remains separate. -Its new semantic repair behavior and changed structural-repair default can -change model-call counts. Document budget review without imposing new Narratio -limits or silently overriding Audita's settings. - -Operators maintain native prompts/profiles, production settings, and testing -overlays. Link upstream for formats, whole-record prompt replacement, bootstrap, -and validation commands. Narratio does not parse and rewrite private Audita -configuration. Explicit downstream paths remain useful for predictable selection. - -The v4.1-to-v4.2 release itself requires no configuration schema migration; -Narratio still needs the full transition from its v2 integration. Select and -install external D&D overlays independently when desired, following their own -contract and installation instructions. - -### Narratio configuration, adapter, and polish integration - -Replace obsolete glossary argument construction with the native prepared-file -handoff and remove the module-selection surface. -Update request types, composition, configuration validation/defaults, examples, -and the polish stage's required inputs together. Preserve supported selectors -and their omission semantics. - -Prepare and record all four glossary collections under the shared input/path -owners. Bind polish's required inputs and semantic -evidence to the prepared content it actually consumes. Keep generated glossary -data separate from immutable resolved Narratio configuration. Use the authoring -fields, source identities, and prepared paths above. Package mechanics and any -additional consumer projections belong in the implementation plan. Use shared resolution/projection -helpers and reuse prepared content between preflight and execution rather than -independently rebuilding it for each path. - -Extend `internal/preflight` and the Audita adapter for native preflight with the -maintained synthetic transcript. Reuse execution selection and validation target -selection, subprocess supervision, credential forwarding, and diagnostics. -Keep glossary materialization in normal preparation and move execution preflight -to the shared boundary after preparation. Reuse verified prepared files rather -than introducing temporary candidate glossary handoffs. Integrate destination- -parent creation with the shared workspace owner and preserve preparation's -normal stage and manifest transitions. - -Carry report/debug destinations and the enable-only debug choice through the -adapter boundary. Align report discovery and polish's expected-path checks with -the selected report directory. Update generated invocation records and safe -result metadata to reflect actual arguments, destinations, and credential names. - -Update polish semantic evidence for result-affecting selector changes and any -changed input handoff. Obsolete evidence is reconsidered when polish executes -or is resume-checked under existing rules. Operational diagnostics and credential -rotation remain outside substantive result identity. Stable downstream selectors -do not expose private prompt/configuration edits to Narratio; forcing polish -remains the operator workflow for those edits. - -Audita v4.2 completes normalization and chunk planning before report initialization. -An early failure may leave no reports; preserve the existing optional-diagnostic -behavior and original subprocess cause. Ordinary transcript/report schemas are -unchanged from v4.1. The new `run` alias requires no Narratio adapter change; -continue invoking `process`. - -### Workspace integration and documentation - -Keep link rotation, cleanup protection, physical layout cutover, and restore -changes in the workspace scope. Skipped stages preserve previous views; actual -attempts advance them even on failure. An attempt without capture exposes its -own empty debug directory under that scope's design. - -When implemented, update the Audita integration contract, polish internals, -configuration/examples, preflight internals, and operator guidance. Describe the -Audita and reference-catalog development workflow with upstream links rather -than duplicating library manuals. Update the workspace roadmap's outdated -upstream-request description when the coordinated work lands: v4.1 already -supports independent report and debug destinations. - -Link to the external recipe contract for its roles and model choices and to -Audita's native inspection/preflight documentation for diagnostics. Document -Narratio-specific projection, catalog selection, prepared-input, and force behavior -locally. Explain preflight timing, preparation reuse after failure, automatic -provider checks, synthetic-transcript scope, and validation's prepared-input -requirements and side effects in validation and execution guidance. Update the -existing Scriptorium preflight timing documentation with this coordinated change. - -### Verification - -Use focused offline tests for native invocation, the selected glossary handoff, -module-surface removal, independent destinations, enable-only -debug selection, and shared credential forwarding. Cover empty selections, -ordered/repeated processing where applicable, and native root/per-entry selector -precedence without inventing a Narratio precedence rule. - -Exercise the authoring example's relative imports, whole-record entry upsert, -native replacement clearing, and independent session field replacements through -ConfigKit. Cover empty collections from omitted selections, failures for invalid -selected sources, and complete validation after partial contributions compose. -Verify the retired -monolithic source is not aliased, the four new source bindings resolve prepared -manifest evidence, and retained roster/player/spell-overlay contracts stay intact. - -Cover party IDs/names/aliases in the native projection, separate collection -preservation, inline/file campaign vocabulary, setting/system selection, -preparation failures, and standalone -snapshots from native imports and composition. Verify that preflight and polish -consume the same prepared vocabulary and consumer bindings are changed only -through explicit input-contract changes. Verify the resolved schema contract -and saved projections at the shared input boundary. Upstream owns the full native merge, instruction, and -inspection behavior; a representative controlled compatibility check is enough -at Narratio's boundary. - -Verify full preflight after completed or reused preparation, provider checks -remaining enabled, shared execution/validation paths, and failure before -processing. Cover bounded runs using existing inputs, missing prepared inputs, -and preservation of preparation results and normal invalidation after failure. -Validation must not implicitly prepare inputs. Exercise the maintained embedded -synthetic transcript against a controlled Audita invocation and cover a fixture-dependent -configuration failure without suppressing it. Default tests simulate provider -outcomes; they do not make paid smoke calls. - -Verify optional and failed reports, failed output delivery, and transcript -validation/promotion. Preserve existing resume/force behavior and demonstrate -the semantic-evidence cutover for affected polish selections. Shared latest-view -and cleanup tests belong to workspace work. - -Default Narratio tests use subprocess doubles and temporary filesystems, with -no dependency on sibling checkouts, real credentials, or paid providers. An -optional controlled Audita v4.2 compatibility check can supplement them. The -reviewed release passed focused offline glossary/inspection/preflight tests, -and both external D&D recipes passed their offline configuration and -normalization checks. Those checks establish integration behavior, not editorial -quality or live-provider readiness. - -[v4]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/releases/v4.0.0.md -[v41]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/releases/v4.1.0.md -[v42]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/releases/v4.2.0.md -[cli]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/cli.md -[config]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/config.md -[operations]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/operations.md -[schema-migration]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/migrations/v3.md -[migration]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/migrations/v4.1.md -[subprocess]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/subprocess.md -[inputs]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/transcript-glossary-files.md -[outputs]: https://forge.maximumdirect.net/eric/audita/src/tag/v4.2.0/docs/integrations/output-files.md -[recipes]: https://forge.maximumdirect.net/eric/audita-pipelines-dnd/src/commit/6d5e66dcfca4bb5971a8423332a19ce884b846c0/README.md - -## Reference Catalog Distribution and Development - -The separate [narratio-reference-catalog repository][catalog] owns vocabulary, -catalog entries, the glossary format/schema, source organization, attribution, -and bundle release history. -Narratio owns the catalog configuration contract, domain selection, projections, -prepared inputs, and preflight. Audita owns native glossary interpretation. - -The catalog's original vocabulary, schema, examples, and documentation use -CC0-1.0. Incorporated third-party material retains its applicable terms and -attribution. Narratio's application license remains unchanged. - -Install a selected catalog tag or commit locally and import its configuration -fragment through Narratio's native ConfigKit workflow. Catalog identifiers map -to entry files using source-relative paths. A setting entry supplies `setting`; -a system entry supplies `spells`. Entry files may import reusable fragments; -Narratio does not introduce another ordered-source composition interface. -Operators extend catalogs through their own native configuration. Narratio does -not download references, manage updates, or resolve versions at runtime. - -Vocabulary releases are independent of Narratio releases. Record tested -Narratio/Audita versions in catalog release documentation without synchronized -version numbers. Ordinary vocabulary corrections can retain an identifier; -materially different rulesets can coexist under distinct identifiers. Prepared -session vocabulary changes through normal input-change and preparation behavior, -not merely because an installed catalog was updated during processing. - -Use sibling checkouts of Narratio, the reference catalog, and Audita for local -development. Local development configuration can import the sibling catalog; -maintained production examples must not depend on developer checkout paths. -No submodule or Go workspace is required for the data repository. - -The initial bundle contains its catalog fragment, one setting entry, one system -entry, representative vocabulary demonstrating native imports, and the format -schema with validation examples. Its compatibility checks cover the complete -production handoff: selection, party/campaign preparation, all four prepared -collections, and full Audita preflight. Larger vocabulary coverage can evolve -independently of this initial integration. - -Narratio's default tests use checked-in synthetic fixtures without sibling -checkout dependencies. The catalog should have an offline compatibility check -that loads its actual bundle through the supported configuration path and -checks the resulting collections against the pinned shared schema and Audita's -native contract. Controlled -integration checks can exercise working checkouts before release; provider smoke -calls remain explicit integration runs, not ordinary catalog tests. - -[catalog]: https://forge.maximumdirect.net/eric/narratio-reference-catalog - -## Implementation Coordination - -The catalog model, authoring fields, native file/inline composition, session -selection behavior, and shared input cutover are settled. The -[implementation plan](implementation.md) owns stage ordering, schema packaging, -the minimal catalog bundle, validation probe placement, and verification through -Narratio's complete acquisition path. Validation probes use the relevant -workspace location without creating a processing attempt or advancing -latest-attempt views. The canonical schema and bundle are pending implementation. diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md deleted file mode 100644 index 6835225..0000000 --- a/docs/roadmap/implementation.md +++ /dev/null @@ -1,729 +0,0 @@ -# Audita v4.2 and shared glossary implementation plan - -## Scope and execution - -Implement [the feature roadmap](audita.md) in the numbered order below. The -audience is a Luna coding agent handling one stage per implementation prompt. -Every stage starts pending. Record completed work and its verification when a -stage is finished; distinguish implemented work from checks awaiting a later -stage. Follow `AGENTS.md`, [development guidance](../development.md), and its -applicable policy-reading guide for every stage. - -This is one end-to-end sprint. Intermediate changes may temporarily fail to -compile or leave dependent tests awaiting the cutover. Make the direct changes -needed for the final design; temporary compatibility readers, dual source IDs, -module translators, and provisional configuration formats are unnecessary. -Commit focused completed units under the agent policy. Report deferred checks -truthfully, and make the final repository-wide checks pass before completion. - -Planning baseline: Narratio `4f68fb2`. Audita v4.2.0 is -`973b24e46618dc785751fa7c803e7c16c900353f`; the reviewed D&D recipes are -`6d5e66dcfca4bb5971a8423332a19ce884b846c0`. Canonical upstream links and the -full intent belong in the feature roadmap. Inspect current sources before -editing: the file names below identify owners, not immutable private APIs. -Prefer the codebase graph for code discovery. - -The sprint covers Narratio and the new local `../narratio-reference-catalog` -data repository. That sibling directory was absent at planning time. Stage 1 -establishes its schema and minimal bundle. Commit each repository independently; -record the catalog commit used by Narratio. Creating a remote repository, -pushing, tagging, releasing, updating Audita code, and adopting Notarius v0.9.0 -are separate actions requiring authorization. Default tests must work without -any sibling checkout, installed downstream executable, real credentials, or -external provider. - -The catalog's original vocabulary, schema, examples, and documentation use -CC0-1.0, as selected by the author. Preserve applicable third-party terms and -attribution for incorporated material. Narratio's application license remains -unchanged. The roadmap's design and licensing decisions are settled. - -## Implementation boundaries - -- ConfigKit owns source composition, imports, inheritance, presence, and native - inspection. Use its supported definitions, resolution, and layered inputs. - Narratio consumes completed results and derives separate glossary objects; - it does not replace effective configuration with those objects. -- Use a small `internal/glossary` owner for the shared glossary model, native - vocabulary acquisition, schema validation, deterministic projections, and - serialization. Keep selection/defaulting and source-context adaptation in - `internal/config`; keep subprocess flags in the Audita adapter. No general - projection framework or second composition implementation is needed. -- Preserve native entry extensions and collection instructions. Party projection - uses stable character IDs, character names, aliases, and category `person`; - order entries by stable character ID. Player/class enrichment is not required. - Preserve supported field-presence distinctions during projection/serialization; - do not erase an explicitly empty instruction through an `omitempty` shortcut. -- Prepare the four named documents and identities in the roadmap. Use distinct - manifest input kinds `glossary_party`, `glossary_campaign`, `glossary_setting`, - and `glossary_spells`, through the existing prepared-input descriptor mechanism. - Their content digests and existing input records establish authority. -- All four collections are supplied to Audita, even when empty. Thus Narratio - owns those four runtime entry lists: an empty list replaces a same-named - Audita-configured list. Other collections and omitted instruction fields - retain native downstream composition. Do not silently omit an empty role to - preserve privately configured entries. -- Preserve richer party/player inputs and the existing Notarius spell-overlay - input. Retire only the monolithic glossary source and its old prepared path. - Update authored bindings explicitly; never redirect an old source ID. -- Preflight follows completed/reused preparation and precedes selected - processing. It remains an invocation check. Retain Audita's provider checks, - use a synthetic transcript, and report that scope accurately. Scriptorium - keeps its current target-selection and error/warning policy at the new boundary. -- Preserve canonical stage order, output validation/promotion, ordinary force - and invalidation, credential forwarding/redaction, publication commitment, - workspace modes, and restore guards. Apply the pending workspace roadmap only - to its stated coordination points; this sprint does not implement that entire - independent feature. - -## Stage 1. Establish the catalog format and minimal data bundle - -Status: Complete - -Catalog revision: `ecad94a5a53f87847b1fd81fd042eee9c8d3ea08`. Validated -the schema and valid/invalid examples with JSON Schema Draft 2020-12; checked -catalog and fragment paths and reviewed the resolved shapes against Audita -v4.2.0. Executable consumer compatibility remains for Stage 17. - -Read roadmap sections “Canonical glossary format” and “Reference Catalog -Distribution and Development,” and the OSS/documentation policies. - -In the local catalog repository, create the format contract, `catalog.yml`, -`schemas/glossary-v1.schema.json`, small valid/invalid examples, and one setting -and system entry demonstrating native relative imports. Use a deliberately small -representative vocabulary, not an encyclopedia or an unreviewed third-party dump. -Describe content sources and attribution. Add the catalog's CC0-1.0 license -documentation with its original-material scope clearly identified. - -Define a JSON Schema with reusable entry, partial-authoring collection, complete -collection, and named-document definitions. Base the fields on Audita v4.2's -native glossary model. Keep extension fields on entries; allow general collection -names. Complete collections require an `entries` list, including `[]`. -Partial authoring definitions allow instruction-only contributions. Do not add -nonempty-collection, global entry-ID uniqueness, or Narratio-role restrictions. -Keep format identity in the schema and contract, outside the glossary root. - -The catalog fragment maps IDs to source-relative entry files under -`reference_catalog.settings` and `.systems`. Document local installation and -native imports, independently selected vocabulary revisions, and compatibility -targets. Give minimal entries truthful names/IDs; do not label synthetic content -as a complete Forgotten Realms or 5e reference. - -Check examples against the schema and Audita's documented shape. Commit this -unit locally and record its full revision for Stage 2. Executable consumer -compatibility checking is completed in Stage 17. - -## Stage 2. Add the shared glossary model and pinned schema validation - -Status: Complete - -Embedded the verbatim schema from catalog revision -`ecad94a5a53f87847b1fd81fd042eee9c8d3ea08`, added offline JSON Schema -validation and collection-scoped ID checks, and recorded dependency notices. -Verified with `go test ./internal/glossary ./internal/doccheck` and a bytewise -schema comparison. Integration with acquisition and preparation follows in -later stages. - -Read roadmap “Canonical glossary format” and Audita's native input contract. -Create `internal/glossary` with native collection/entry representations retaining -extensions, and an embedded, verbatim copy of the catalog's versioned schema. -Record the catalog revision and maintain schema ownership upstream. Use -`github.com/santhosh-tekuri/jsonschema/v6` v6.0.3, the engine already used by -Audita, for JSON Schema evaluation; ConfigKit remains the YAML/configuration -loader. Add the dependency and OSS notices using the selected module's actual -license and commit. Review notices for the incorporated schema as well. - -Compile the pinned schema locally; runtime validation must not fetch a schema. -Validate resolved decoded data and complete prepared documents, preserving the -native types supported by the loader. Keep partial and complete validation -entry points distinct. Preserve useful collection/field context in errors. -Apply semantic validation for within-collection ID uniqueness where -schema evaluation alone cannot express it. Avoid unrelated spelling restrictions. - -Test empty complete collections, missing required structure, instruction-only -partial input, ordinary optional fields, retained entry extensions, and duplicate -IDs within one collection. Identical IDs in different collections remain valid. -Add synthetic local fixtures so tests do not read the catalog checkout. - -## Stage 3. Add catalog selections to native pipeline acquisition - -Status: Complete - -Pipeline acquisition preserves reference-catalog mappings, resolves imported -paths from their field origins, and provides selection with unknown-ID errors. -Verified with `go test ./internal/config ./internal/doccheck`, including an -imported catalog and an operator extension. Campaign/session selection fields -and their use of these lookups are introduced in Stage 4. - -Read `docs/internal/configuration.md` and the roadmap's authoring field table. -Update `internal/config/config.go`, pipeline definitions/defaults/validation, -resource-base adaptation, and projections/rendering as applicable. - -Add `reference_catalog.settings` and `.systems` mappings to the pipeline model. -Resolve each selected catalog path from its effective field's native origin and -source context, including paths contributed by an imported catalog fragment. -Reuse `resource_base.go` and ConfigKit metadata. Keep catalog data and selections -visible in actual native inspection rather than substituting a derived view. - -Catalog absence is valid. Validate selected IDs against the effective catalog; -an explicitly selected unknown ID is an error. Do not require unused catalog -entries to be installed/readable or inspect unselected vocabulary files. - -Use a real ConfigKit imported-fragment fixture to test source-relative paths, -operator catalog extensions through ordinary native configuration, missing IDs, -and native inspection/digest behavior. Equivalent layouts should not gain an -extra all-configuration cache invalidation key. - -## Stage 4. Implement campaign/session glossary authoring and field selection - -Status: Complete - -Campaign and session acquisition now retain independent glossary selections, -inline contributions, nullable/empty overrides, source-relative file paths, -and authored snapshot values. Unknown selected catalog IDs fail during combined -acquisition. Verified focused configuration, stage, application and documentation -tests, including imported defaults, replacement, nulls, and rendering. Vocabulary -composition and the preparation cutover remain in subsequent stages. - -Start with `document_configkit.go`, `config.go`, `document_render.go`, -`resource_base.go`, and their session-default/presence tests. Implement the -roadmap's `inputs.setting`, `.system`, `.glossary_file`, and inline `.glossary`. -The file becomes optional and uses the new named-collection format. Keep the -canonical party roster required; retain existing spell-overlay fields. - -Use ConfigKit presence/default callbacks to inherit each omitted campaign field -independently. A supplied session inline collection replaces the campaign's -inline selection as a whole; its file selection changes only that field. -Perform later file-plus-inline composition separately in Stage 5. Record truthful -default provenance. Resolve selected file paths from their defining sources. - -For optional setting/system/file selectors, null or empty effective selections -mean no selected source, without falling back to campaign values. For inline -data, explicit null removes that contribution; an empty collection mapping is -an explicit contribution. Validate incompatible value types normally. Preserve -native list/control behavior inside the glossary load rather than interpreting -`entries: []` as a custom clear operation. - -Render authored/effective campaign and session snapshots with their selections -and inline values intact. Do not replace inline authoring data with composed -vocabulary in native results. Test the roadmap's two independent session override -examples, omitted versus supplied selections, partial inline data, and imported -source bases. Update current tests that require a monolithic glossary file. - -## Stage 5. Resolve native vocabulary and derive the four domain collections - -Status: Complete - -Added a shared native ConfigKit resolution path and deterministic, validated -party, campaign, setting and spells documents. Focused glossary and configuration -tests cover imports, inheritance, whole-record upsert, native replacement, -independent session overrides, missing sources, and unchanged native values. -`go test ./internal/glossary ./internal/config ./internal/doccheck` passed. -Preparation and resume integration are performed in Stages 7 and 8. - -Read roadmap “Glossary authoring and precedence” in full. Implement one production -resolution path shared by preparation and prepare-resume comparison. Configuration -acquisition supplies finalized selections/contexts; vocabulary resolution returns -separate domain values and serialized standalone named-collection documents. - -Use native ConfigKit layered loading for the selected campaign file below the -selected inline contribution mounted at `campaign`. Enable imports and register -entry identity by `id` using the supported sequence API, matching Audita. Resolve -complete external files before selecting the requested collection, so sibling -inheritance works. The setting/system files supply `setting`/`spells` respectively. -Do not reduce the file to a hand-parsed YAML subtree before native resolution. - -Preserve whole-record upsert, native lower-tier explicit replacement policy, -instructions, extensions, and errors. Validate the completed selected collection -after the file/inline contributions compose; incomplete individual contributions -are valid inputs to that composition. Do not normalize a native composition -error into an empty collection. Missing selected files or required named roles -fail with selection/source context. Omitted sources produce complete empty roles. - -Derive `party` from the resolved canonical roster and serialize all four documents -deterministically. Reuse these functions rather than independently composing -vocabulary for preflight, validation, and stage execution. Basic acquisition -selects resources; validation against prepared inputs must not resolve live -files into candidate glossary projections. - -Test the roadmap's Silver Watch/Old Watch and native `replace` clearing examples -through the actual pipeline/campaign/session acquisition path, including imported -catalog paths. Also cover retained instructions/extensions, sibling inheritance, -omitted roles, invalid selected sources, and nonmutation of native configuration. - -## Stage 6. Register shared glossary identities and canonical paths - -Status: Complete - -Registered the four nested prepared-input descriptors and retired the old -source, with migration guidance for both consumer bindings. Focused artifact -policy, prepared-input, and configuration tests cover all four identities, -checksums, sizes, tampering and missing files. Existing preparation still uses -the retired source until Stage 7, and maintained consumer fixtures are updated -in Stage 16; related end-to-end tests are deferred until those cutovers. - -Read roadmap “Shared input identities and cutover,” `artifactpolicy/policy.go`, -`artifacts/prepared_input.go`, and the existing prepared-input tests. - -Add the four exact source IDs and paths from the roadmap to the shared prepared -descriptor and path owners. Extend descriptor handling to support nested -`inputs/glossaries/` destinations without assuming every filename is a basename. -Use those same descriptors for resolution, artifact classification, supported -source validation, and configured Scriptorium/Notarius bindings. - -Remove the old `narratio.input.glossary` registration and resolution paths. Do not -alias it to `campaign`, infer new roles from old bytes, or change `party`, -`players`, and `spell_catalog` identities. A stale old file can remain incidental -under existing lifecycle behavior; its presence is never new input authority. - -Test all four descriptors and resolution against manifest checksums/sizes, -missing/tampered files, and nested path handling under existing guards. Verify -old configured source references fail with actionable migration guidance. - -## Stage 7. Materialize shared collections in prepare - -Status: Complete - -Preparation resolves vocabulary before audio work and writes all four named -collections with manifest checksums, sizes, and provenance. Focused prepare, -artifact, and manifest tests verify nested workspace modes, empty roles, sorted -records, failure without manifest replacement, and existing audio/party inputs. -Resume comparison and downstream consumer cutover remain in later stages. - -Start with `stage/prepare.go`, `prepare_party.go`, and configuration rendering. -Call Stage 5's resolver as part of ordinary preparation and fail on invalid -selected vocabulary before downstream processing. Materialize four standalone -documents using shared paths and ordinary workspace file operations/modes. -Write all four, including empty collections, and record their distinct manifest -inputs with digest, size, and non-secret provenance. Use the existing manifest -input model; this feature does not need another progress manifest. - -Remove the monolithic glossary copy/manifest input from the current preparation -set. Preserve party/player generation, speakers/autocorrect, optional structured -spell overlay, previous-session inputs, and audio behavior. Resolve vocabulary -before expensive preparation work where practical without moving native -downstream preflight ahead of completed preparation. - -Verify deterministic prepared bytes and manifest ordering, nested workspace -modes, empty roles, failure without false preparation success, and retention of -unrelated stable input contracts. Leave stage transitions with the existing -runner, not the glossary helper. - -## Stage 8. Make preparation reuse and invalidation glossary-aware - -Status: Complete - -Versioned prepare semantic evidence and compare the same resolved glossary -bytes used by preparation, requiring verified canonical records for all four -roles. Focused resume tests pass for imported changes, equivalent relocation, -selection changes, empty roles, tampering, missing files, and old evidence. -Existing bounded consumer resolution already reports prepare guidance. Tests -using retired synthetic glossary fixtures await the Stage 16 fixture cutover. - -Read `prepare_resume.go`, `semantic_contracts_initial.go`, and their focused -tests. Extend the prepare semantic contract and durable-input checks for the -new selection/projection contract. Compare current resolved vocabulary using -the same resolver and serializer as Stage 7; include imported effective content, -inline overrides, catalog selections, and the party projection. - -Changes to effective prepared vocabulary invalidate through existing prepare -rules. Equivalent source relocation/formatting with equivalent effective bytes -does not gain a new path-only invalidation requirement. Unchanged prepared -inputs remain reusable. An installed catalog update during processing never -reopens or replaces the invocation's prepared vocabulary. - -Require new input records when prepare is selected or reuse-checked. Prior -monolithic records cannot satisfy them; use normal reprepare behavior and a -versioned semantic contract rather than an old-session converter. A bounded -run excluding prepare verifies the prepared sources it needs and reports -prepare guidance when they are unavailable. - -Test an imported vocabulary change, equivalent layout relocation, selected ID -change, empty-role preparation, missing/corrupt prepared files, and old evidence. -Retain existing per-speaker and per-artifact resume behavior. - -## Stage 9. Carry the new prepared inputs through publish and restore - -Status: Complete - -Publish archives verified prepared glossary bytes using shared descriptors; -restore maps committed objects back to their nested canonical paths. Focused -publish and restore tests pass, including all four documents, empty roles, -changed local bytes, restored manifest evidence, and existing restore guards. - -Read `stage/publish_sources.go`, prepared publication tests, artifact current -state mapping, and app restore planning/execution tests. Register the four input -kinds and nested paths wherever publication, remote descriptors, status, and -restore enumerate prepared inputs. Prefer the shared descriptors over four -new independent path switches. - -Publish the actual verified prepared documents; do not reopen campaign/catalog -sources during upload. Restore the committed documents and manifest evidence -at their canonical nested paths, retaining manifest-last installation and all -current path/conflict/lock checks. New vocabulary inputs are neither run-local -debug evidence nor subprocess cache. Retire the old glossary mapping in current -output generation without introducing a compatibility reader for it. - -Test a prepared-input publish/restore round trip containing all four documents, -empty roles, changed local bytes, and unchanged party/player/spell-overlay -behavior. Preserve the existing immutable commit/pointer ordering and force -conflict policy; no new remote protocol is needed. - -## Stage 10. Cut the Audita processing adapter over to v4.2 - -Status: Complete - -The adapter now passes ordered native glossary files, independent destinations, -and enable-only debug, with a shared argument builder and updated safe invocation -records. Removed module configuration and plumbing. Focused adapter, configuration, -and semantic tests pass; all packages compile. Polish still supplies its former -input path until Stage 11; examples and wider fixture updates remain scheduled. - -Read Audita v4.2 CLI/subprocess/output contracts, then `adapters/audita` and -its current subprocess tests. Replace the single legacy glossary request with -an ordered native glossary-file request. Pass one argument pair per file. -Continue using `process` and explicit output. Keep main/overlay/profile, -description, output-schema, timeout, credential, and cancellation behavior. - -Remove `--modules` and its configuration, validation, projection, request, and -composition plumbing. Add optional `pipeline.audita.debug`: true requests debug; -false/omission adds no debug override. Add independent report/work-directory -request destinations. Normal production omits `--debug` and `--reporting=false`. -Selecting the work directory alone must not enable capture. - -Use a shared processing-settings argument builder suitable for preflight in -Stage 12. Keep native CLI semantics; no version probe, generated Audita entry -configuration, legacy flag fallback, or module-list translator is needed. -Update the safe generated invocation record to the actual new request contract. - -Test exact argument boundaries/order for runtime files, supported selectors, -independent destinations, debug omission/enablement, and removed fields. Retain -shared sensitive credential forwarding/redaction and failure evidence coverage. - -## Stage 11. Integrate prepared glossaries and diagnostics into polish - -Status: Complete - -Polish now resolves the four verified prepared inputs in role order and uses -run-local log and debug destinations via a shared request builder. Versioned -semantic and glossary evidence prevents reuse after input changes. Focused -polish and adapter tests cover missing and changed inputs, diagnostic paths, -nonzero outcomes, output promotion, and resume. Preflight uses the shared -builder in subsequent stages. - -Read `stage/polish.go`, `run_local.go`, and -`semantic_contracts_refinement.go`. Resolve all four glossary inputs through -the shared prepared-input resolver. Use a stable role order: party, campaign, -setting, spells. Resolve the base transcript through its existing output evidence. -Stage logic receives domain paths and settings; the adapter owns CLI construction. - -Use a shared polish invocation/context builder for both execution and preflight: -execution supplies the real transcript, preflight later substitutes its fixture. -Supply `runs//polish/logs/` for reports, captured streams, and invocation -records, and `runs//polish/debug/` as the debug root. Create required -parents through the shared workspace owner. Do not add latest-attempt links here; -that work remains in the workspace roadmap. - -Discover only the existing fixed optional report names in the selected report -directory. Validate reported paths there rather than beside the staged transcript. -Keep bounds and original failure causes. Nonzero exit never promotes transcript -bytes; recoverable model errors on exit zero remain accepted. Early failures may -have no reports. Keep the existing `segments` output validation contract and -explicit output-schema choice where needed. - -Version affected polish semantic evidence; remove modules and include actual -prepared input identity through the existing input-evidence mechanism. Debug, -credential rotation, and destination-only changes remain operational. Test -missing/changed vocabulary, nonzero-with-output, optional reports, independent -paths, successful promotion, and force/reuse semantics. - -## Stage 12. Add native Audita preflight and the embedded transcript asset - -Status: Complete - -Added native preflight with the shared processing arguments, provider smoke -checks enabled, an embedded synthetic multi-speaker transcript, and isolated -temporary diagnostics. Focused adapter/subprocess tests cover settings, -credentials, redaction, failure, cancellation, and cleanup; all packages -compile. Checker and runner integration follows in subsequent stages. - -Extend the Audita adapter with a narrow preflight operation using the same -processing settings/argument builder as Stage 10. Use `preflight` and retain -native default smoke checks; do not pass `--smoke=false` in production orchestration. -Return native exit outcome and safe diagnostic context without parsing its -human-readable progress or inventing a readiness schema. Reuse supervision, -timeouts, cancellation, and credential redaction. Preflight does not discover -or promote processing outputs or expect ordinary report files. - -Keep preflight's own captured streams and invocation diagnostics in its temporary -invocation context, separate from the intended processing/report/debug paths -being probed. Preserve useful bounded diagnostic details in its returned error -before temporary cleanup. Do not clear or overwrite earlier stage diagnostics. - -Embed a small representative synthetic transcript in the Narratio-owned -integration boundary, using `go:embed`. Give it multiple valid timed utterances -and speakers, and materialize it in invocation-scoped temporary storage. Remove -temporary material on every outcome. It is not a prepared session input or a -transcript artifact. It need not satisfy every possible chunk/section setting; -native fixture-dependent failures remain errors. - -Test shared flags/destinations/vocabulary/credentials between preflight and -processing, absence of any smoke-disabling override, exit/error propagation, -temporary cleanup, and cancellation. Use the subprocess seam, not paid providers. - -## Stage 13. Extend the shared preflight checker and target model - -Status: Complete - -Added a narrow Audita preflight contract, sequential downstream checking, -and polish target selection based on projected execution or validation. -Focused checker and selection tests cover reuse, empty targets, warnings, -Audita failures, and cancellation. Runner and validation wiring follows in -Stages 14 and 15. - -Read `internal/preflight`, `app/preflight_targets.go`, and current Scriptorium -finding-policy tests. Add a narrow Audita check contract and a selected polish -target alongside the existing Scriptorium targets. Keep tool-specific invocation -in adapters and tool-specific findings interpretable through their own contracts. -A sequential composition of the existing checks is sufficient; no plugin registry -or generic workflow engine is required. - -Use verified prepared vocabulary and Stage 11's invocation/context construction. -Execution selects Audita only when polish is projected to run. Validation selects -it when polish is enabled, independently of completed output reuse. Existing -Scriptorium target closure, required/optional binding treatment, and warning/error -policy remain intact. Empty target sets invoke no tool. Native Audita failure is -an error with its original diagnostic explanation; cancellation stops checks. - -Test selected/unselected polish, reusable work, Scriptorium warnings versus errors, -Audita failure, and cancellation at the shared checker/selection boundaries. -Do not duplicate adapter command tests or parse Audita's stderr into findings. - -## Stage 14. Move execution preflight after preparation - -Status: Complete - -Runner preflight now reprojects remaining work after preparation and checks -only selected downstream targets before stage attempts or forced invalidation. -Adapter composition is lazy and reuses invocation-owned runners. Focused -runner tests pass for preparation success/failure/reuse, preparation-induced -invalidation, preflight failure and retry, forced authority preservation, -prepare-only and fully reused invocations; cleanup and bounded checks also pass. - -Start with `app/runner.go`, `runner_preflight.go`, `runner_composition.go`, -`runner_stage_execution.go`, `plan.go`, and the current runner/preflight tests. -Remove the old unconditional pre-stage hook. Run ordinary selected `prepare` -through its existing lifecycle, including reuse, durable saves, and invalidation. -Then run downstream preflight once before the first selected post-prepare stage. -For a bounded range omitting prepare, check at that same logical boundary using -existing prepared inputs, without inserting prepare into the range. - -Reproject remaining selected work against the post-preparation manifest. Do not -reuse a projection made before preparation could invalidate polish or analysis. -Include force/range/artifact selection exactly as the normal work planner does. -Only relevant downstream targets initialize their adapters, and invocation-owned -instances can be reused by execution. A prepare-only invocation has no remaining -processing target and makes no downstream calls. Fully reused and cleanup-only -invocations also avoid irrelevant preflight and empty run directories. - -A failed check stops before subsequent stage attempts or their force invalidation. -Retain completed preparation and any invalidation it already caused. Finalize -the invocation/summary with prepare completed or reused and processing not -attempted; do not mark polish failed or succeeded when it never ran. Reuse the -existing session lock and finalization machinery. - -Test preparation success/reuse/failure, preparation-induced invalidation exposing -new targets, bounded runs, prepare-only/full reuse/cleanup-only, force after -failure, and retry reusing completed preparation. `session plan` remains -subprocess-free; neither preflight nor fixture storage advances latest views. - -## Stage 15. Use the shared downstream checks in session validation - -Status: Complete - -Validation checks existing prepared glossary evidence using the shared -request builder and downstream checker, with a dedicated `.validation` probe -namespace and explicit synthetic/provider-side-effect findings. Focused tests -cover missing evidence, valid reuse, unchanged manifest and source independence, -provider and destination failures, cancellation, and Scriptorium findings. - -Read `app/session_inspection_command.go`, `operator_inspection.go`, invocation -acquisition, and their validation tests. Retain basic configuration findings. -Resolve the existing local manifest and prepared vocabulary required by enabled -polish through the same resolver/checker used for execution. Missing or invalid -evidence produces actionable prepare guidance. Do not run prepare, fetch audio, -resolve candidate live vocabulary, or manufacture manifest authority. - -Use the shared embedded transcript and actual selected Audita settings. Validation -has no execution run: probe intended polish destinations beneath the session's -workspace root in `runs/.validation/polish/`, with the normal transcript filename -under `outputs/`, and separate `logs/` and `debug/` roots. This is a validation -probe namespace, never a run identity, processing attempt, report, or latest view. -Use the workspace path owner and existing directory modes. Remove temporary -probe files through native preflight; empty parent directories may remain. Keep -these probe paths out of publication/restore and stage authority. Real execution -still checks its actual run destinations. - -Native preflight performs provider calls and temporary destination probes; -report these side effects and synthetic-transcript scope. Preserve current -validation result/exit presentation and safe errors. No new durable validation -manifest or session lock policy is required merely for this check. - -Test missing prepared inputs, valid prepared reuse, unchanged source bytes and -manifest, native destination failure, provider failure, cancellation, and existing -Scriptorium findings. Verify no audio transfer, processing artifact, run ID, -stage transition, or latest-view rotation occurs. - -## Stage 16. Cut maintained consumer bindings and examples over explicitly - -Status: Complete - -Updated maintained bindings, native glossary examples, and offline test -fixtures, including a synthetic catalog with relative imports and campaign -authoring variants. Verified example acquisition and glossary resolution, -extract/analyze/preflight coverage, documentation links, and `go test ./...`. -Real catalog and Audita compatibility checks remain for Stage 17. - -Update maintained pipelines, campaign/session examples, and synthetic fixtures -to the new fields and source IDs. Replace the old Notarius text `glossary` -binding with `narratio.input.glossary.campaign`. Keep its binding name and current -Notarius v0.8.1 reference mechanism; preserve party/player/spell-overlay bindings. -Change Scriptorium source IDs explicitly while preserving prompt binding names. -Update prompt input-shape examples where the old glossary format was assumed. - -Remove `pipeline.audita.modules`; show pipeline ordering in Audita-owned -configuration or link to the independently selected external recipes. Include -one minimal checked-in synthetic reference catalog, an import-relative example, -inline-only/file-only/combined campaign authoring, and omitted optional roles. -Production installation examples point to an operator-installed catalog location, -not a developer sibling directory. Do not bundle a full production vocabulary. - -Retarget tests that protected retired glossary behavior to the deliberate new -contract. Remove obsolete expectations rather than keeping old code for fixtures. -Run example loading/validation and targeted extract/analyze/preflight tests. - -## Stage 17. Check the real catalog and Audita boundaries offline - -Status: Complete - -Added opt-in checks using explicit catalog and Audita paths, and corrected -native source contexts for sibling vocabulary imports. The real catalog -bundle and pinned schema at `ecad94a5a53f87847b1fd81fd042eee9c8d3ea08` -passed alongside Audita `973b24e46618dc785751fa7c803e7c16c900353f` -using controlled loopback provider responses, including a negative result. -The catalog's offline check script is committed at -`ff26b24172ff5efddbcf666c5179268ea1372b01`; the checks also pass there. -Focused glossary and configuration tests passed with the external variables -unset. No paid provider calls were used. - -Add opt-in Narratio compatibility tests accepting absolute paths through -`NARRATIO_TEST_REFERENCE_CATALOG_DIR` and `NARRATIO_TEST_AUDITA_BINARY`. Unset -variables skip those external checks; do not search PATH or sibling directories. -The ordinary suite continues to use local synthetic fixtures and doubles. - -The catalog test loads its actual fragment through Narratio's normal pipeline, -campaign, and session acquisition, then the production glossary resolver and -preparation path. Validate the four prepared documents against the pinned schema. -Check the imported paths and combined file/inline fixture, not just isolated -ConfigKit layering primitives. Compare the schema copy with its recorded catalog -revision when the checkout is that revision; format-compatible newer vocabulary -need not share the same vocabulary release number. - -With a supplied Audita v4.2 executable, exercise native inspection and a full -preflight using controlled local provider responses, synthetic inputs, and -temporary destinations. Keep smoke enabled to test production behavior while -avoiding real credentials/services. Include one fixture-dependent failure. -Check that the prepared named collections and instructions reach the native -configuration, and preserve exit classifications. - -Add a short catalog-owned offline check script accepting explicit Narratio -checkout and Audita binary paths, invoking these compatibility tests with its -own bundle. No Go workspace/submodule, remote downloads, or new public Narratio -debug command is needed. Document exact local commands and tested revisions in -the catalog README. Do not make real paid smoke calls a routine test gate. - -## Stage 18. Update canonical documentation and migration guidance - -Status: Complete - -Updated public, integration, internal, and architecture guidance for the -glossary cutover, downstream checks, diagnostics, migration, and restore. -Updated the independent workspace roadmap's Audita capability baseline; the -D&D README follow-up remains recorded in the feature roadmap. Documentation -and maintained-example checks pass with `go test ./internal/doccheck -./internal/config`. - -Update `docs/config.md`, `cli.md`, `operations.md`, `troubleshooting.md`, -`integrations/audita.md`, `integrations/notarius.md`, applicable Scriptorium/input -contracts, and focused internal documents for configuration, prepare, polish, -preflight, adapters, manifests, publish, restore, and workspace paths. Update the -overview inventory for the new glossary owner. Update architecture statements -about preflight timing/validation side effects where affected; preserve ADR 0003. - -Explain the explicit source/format cutover, four prepared identities, independent -session fields, shared roster/spell-overlay retention, preparation/reuse and force -workflow, catalog installation, downstream configuration/overlay selection, and -diagnostic destinations. State that empty prepared roles replace same-named -Audita entry lists. Document automatic provider checks and validation's probe -namespace and side effects; distinguish synthetic readiness from real-transcript -feasibility and editorial quality. Native library/Audita behavior stays linked -upstream rather than becoming another local manual. - -The catalog owns schema/format details, vocabulary organization, attribution, -and release history. Update it and its notices when incorporated content changes. -Record an upstream D&D README compatibility follow-up if it still calls the -feature unreleased; changing that separate repository is not this sprint's gate. -Keep the independent workspace roadmap pending, updating its upstream-capability -references as needed without implementing its latest-view/retention work. - -Run documentation and example checks. Review prose for accidental extra invariants, -legacy conversion promises, duplicated upstream reference material, or an implied -guarantee that successful preflight ensures later processing succeeds. - -## Stage 19. Verify the complete sprint and remove retired machinery - -Status: Complete - -With Go 1.27.4, `go test ./...`, `go test -race ./...`, `go vet ./...`, -and `go build ./...` passed. The controlled catalog/Audita compatibility -checks passed against catalog `ff26b24172ff5efddbcf666c5179268ea1372b01` -and Audita `973b24e46618dc785751fa7c803e7c16c900353f`; the original -pinned schema was compared at catalog revision -`ecad94a5a53f87847b1fd81fd042eee9c8d3ea08`. Reviewed the cutover and -extended the prepared-input round trip through preflight failure and retry, -polish, publication, and restore. Confirmed native empty-list replacement and -instruction retention with the real Audita binary. No live-provider calls, -push, tag, or release were performed. - -Run focused checks during earlier stages as they become buildable. At this final -stage use the maintained Go 1.27.4 toolchain and run: - -```sh -go test ./... -go test -race ./... -go vet ./... -go build ./... -``` - -Run Stage 17's controlled external compatibility checks against the actual -catalog and Audita v4.2. Keep live-provider experiments separately authorized -and reported; offline controlled-provider coverage satisfies this sprint's -verification requirement. Review a representative full workflow using subprocess -doubles: preparation, full native-style preflight, polishing, and downstream -binding resolution; then failure/retry and publish/restore of the same inputs. - -Audit the cutover: no live legacy glossary/module request fields, aliases, -automatic format detection/conversion, generated Audita pipeline, custom native -merge engine, runtime schema/catalog download, or paid-call default test remains. -Retired source/flag names can remain in migration documentation, rejection tests, -planning records, and Git history; they must not retain live compatibility behavior. -Confirm snapshots, extensions, native presence semantics, publication guards, -diagnostic-only debug behavior, and latest-view separation against the roadmap. - -Keep successful per-speaker and per-artifact work reusable under existing rules. -Ensure no preflight success is cached as a stage, and no check failure advertises -unattempted processing as complete. Resolve genuine regressions; remove redundant -or retired-behavior tests rather than preserving obsolete implementation. - -Commit final focused units in each affected repository, report tested revisions -and any outstanding checks, and leave a clean workspace. Do not push, tag, release, -or delete planning documents as part of this implementation plan. diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md deleted file mode 100644 index 2a4f8f1..0000000 --- a/docs/roadmap/remediation.md +++ /dev/null @@ -1,304 +0,0 @@ -# Shared glossary and Audita adoption review - -Reviewed Narratio commit `4f27331636b44bd75e402c12fc6ab4c16fcb3899` -against all 19 stages of [implementation.md](implementation.md) and the -[feature roadmap](audita.md). The catalog checkout was -`ff26b24172ff5efddbcf666c5179268ea1372b01`; its embedded schema source is -`ecad94a5a53f87847b1fd81fd042eee9c8d3ea08`. Native compatibility was checked -with Audita v4.2.0 at `973b24e46618dc785751fa7c803e7c16c900353f`. - -This document records required remediations and separately identified algorithmic -improvements for consideration. Implementation code and upstream repositories -were left unchanged during review. - -## 1. Reject empty paths for explicitly selected catalog entries - -Priority: P2 - -Status: Complete - -Selected blank catalog paths now fail with kind/ID context. Acquisition and -prepare-only regression tests cover empty/null values in both catalog groups -and successful empty roles with unused empty or uninstalled entries. Focused -configuration and application tests passed with Go 1.27.4. - -Affected stages: 3 and 5; prepare and downstream vocabulary coverage are affected. - -### Finding - -`internal/config/reference_catalog.go:19-23` distinguishes unknown IDs from -known IDs, but returns a known entry's value without checking whether it names -a source. For example: - -```yaml -reference_catalog: - settings: - broken: "" -``` - -A campaign selecting `inputs.setting: broken` passes combined acquisition. -The empty path then reaches `internal/glossary/resolve.go:73-74`, which treats -it like an omitted setting and prepares an empty collection. An explicit null -catalog path, by contrast, already fails native decoding with `decode.null`; -retain that correct behavior. - -The CLI reproduction used ordinary valid campaign/session inputs and a -prepare-only invocation. It exited zero with `complete: true` and wrote: - -```yaml -setting: - entries: [] -``` - -This contradicts the selected-source contract: omitted selections may be empty, -while explicitly selected invalid sources must fail. It can silently remove -expected correction vocabulary, particularly because all four runtime lists -replace their same-named Audita lists. - -### Required remediation - -Reject a selected catalog entry whose value does not identify a usable source, -with context naming the catalog kind and selected ID. Preserve ordinary source -loading errors for nonempty nonexistent or unreadable paths. Keep an omitted -setting/system selection valid, and do not impose eager file-existence checks -on unselected catalog entries. - -Add behavioral coverage through full configuration acquisition and preparation -for selected empty and null paths in both catalog groups. Verify that invalid -selection cannot become successful empty vocabulary, while omitted selections -still prepare empty roles. Cover native decoding rejection as an acceptable -outcome where the selected value is invalid before domain selection. - -## 2. Preserve native acceptance of a null aliases list - -Priority: P2 - -Status: Complete - -Catalog commit `a1a87edafd59a1de545a1c0b4efe5feeb80348e0` corrects -the canonical schema and format description. Narratio pins its verbatim copy -and updated notices. File/inline preparation tests preserve omitted, null, empty, -and populated aliases; schema tests retain invalid-type/null-scalar rejection. -Focused tests and controlled real-Audita/catalog compatibility checks passed -with Go 1.27.4, including native inspection/preflight with null aliases. - -Affected stages: 1, 2, and 5. This is an inadvertently strengthened input -restriction in the shared schema and its embedded copy. - -### Finding - -The catalog schema and `internal/glossary/glossary-v1.schema.json:30-36` -require `aliases` to be an array whenever supplied. Audita v4.2 accepts an -explicit null aliases list through its native typed configuration, so valid -native glossary input is rejected by Narratio's new shared format validator. - -This minimal glossary was used for the comparison: - -```yaml -campaign: - entries: - - id: watch - name: Silver Watch - category: organization - aliases: null -``` - -With a valid Audita main configuration: - -```sh -audita config validate --scope app --config MAIN --glossary-file VOCABULARY -``` - -returned `app: valid` and exit zero. Selecting the same file as Narratio's -campaign glossary made `prepare` fail with: - -```text -at '/campaign/entries/0/aliases': got null, want array -``` - -The requested format follows native Audita fields and preserves supported -presence semantics. A blanket non-null restriction on optional aliases was -not selected. This finding is specific to aliases: the same probe confirmed -that Audita rejects null `instruction` and `description` strings, so those -fields must not be broadened merely by analogy. - -### Required remediation - -Correct the catalog-owned schema to accept the supported null aliases value -alongside its existing array shape. Update the embedded schema verbatim, its -recorded catalog revision, applicable notices, and the canonical format -description as needed. Keep the schema locally pinned and preserve the normal -native handoff; no compatibility parser or custom alias-merging rule is needed. - -Test omitted, null, empty, and populated aliases through resolved file and -inline vocabulary and preparation. Include the null case in the controlled -native Audita compatibility check. Retain rejection of genuinely invalid alias -types and upstream-invalid null scalar fields. Default tests remain offline. - -## 3. Index prepared-input records for resume comparison - -Priority: P3 - -Status: Complete - -Resume comparison now indexes managed records by kind and audio destination, -retaining multiplicity and consuming each matched entry once. Matching is -expected O(E+M), excluding content processing. Stage/application tests cover -reordering, duplicate/missing/extra records, checksum normalization, semantic -snapshots, and each remote identity field; they passed with Go 1.27.4. - -Affected stage: 8. This is an inherited algorithm extended by the glossary -cutover, rather than a newly introduced regression. - -### Finding and complexity - -`internal/stage/prepare_resume.go:254-269` scans every manifest input for each -expected input. The `matched` map prevents a record from being consumed twice, -but the inner loop still visits every record, including after finding a match. -For E expected inputs and M manifest inputs, successful matching performs -Theta(E*M) record visits. With N audio files, both lists grow with N, giving -Theta(N^2) matching work, separately from file hashing and vocabulary resolution. -The existing count checks do not eliminate this successful-case cost. - -The sprint added four glossary kinds and normalized configuration-snapshot -comparison to this path. Neither the roadmap nor Stage 8 selects the nested -matching algorithm as a requirement. Ordinary D&D sessions may have few audio -files; this is a scalability and simplification opportunity, not evidence of a -measured production bottleneck or incorrect resume decisions. - -### Potential refactoring - -Build a single index using the existing matching identity: kind, with the -destination basename for audio records. Retain record multiplicity explicitly -and compare checksums, normalized snapshots, or remote object identity within -the appropriate entry. Managed-kind cardinality and ambiguity checks can remain -linear. The intended result is expected O(E+M) matching time with O(E+M) -auxiliary space; the current matcher already allocates O(E) consumed-record state. -String normalization and file-content processing remain additional costs. - -Preserve rejection of missing, extra managed, ambiguous, and reused records; -a map assignment that silently overwrites duplicates would change behavior. -Preserve case-insensitive checksum comparison and the existing remote-audio -identity fields. Retain representative local/remote and snapshot cases, and add -synthetic reordered/duplicate-record coverage when making this refactor. A -benchmark or a real audio workload is unnecessary to establish the complexity. - -## 4. Validate report bounds without buffering discarded contents - -Priority: P3 - -Status: Complete - -Both Audita report boundaries now use a shared streaming bounded-file check -with constant auxiliary memory. Existing regular-file/path guards and the -central report limit remain intact. Focused file-operation, adapter, and stage -tests passed, including below/at/above limits, invalid paths, optional reports, -and preservation of the original subprocess failure. - -Affected stages: 10 and 11, principally the new polish-stage report check. - -### Finding and complexity - -`internal/adapters/audita/subprocess.go` reads each discovered report with -`fileops.ReadFileBounded` and discards the returned bytes. The new check at -`internal/stage/polish.go:115-117` repeats that operation. The helper uses -`io.ReadAll(io.LimitReader(...))` in `internal/fileops/read_bounded.go`. -Neither caller parses or retains report content; they retain only its path. - -For a report of B bytes within the existing limit L, each validation performs -O(B) I/O and O(B) temporary allocation. An oversized report can allocate O(L) -before rejection. The normal subprocess path performs two such reads. These -are fixed linear passes, not quadratic work, and the existing 16 MiB per-report -cap already bounds their memory exposure. - -### Potential refactoring - -Use a small shared bounded-file validation helper that retains the existing -regular/readable-file and path checks while streaming at most L+1 bytes to -`io.Discard`. This preserves read-error detection and limit enforcement with -O(B) time and O(1) auxiliary memory relative to report length. It can replace -the discarded-content reads at both boundaries without weakening stage-side -validation of another runner implementation. A broader file-operations -abstraction or cross-boundary validation cache is unnecessary. - -Keep the limit in its existing central constant, preserve optional-report and -nonzero-exit behavior, and retain errors identifying the responsible Audita -boundary and limit. Test below/at/above-limit files and existing invalid-file -cases when implementing the helper. Content-consuming bounded reads elsewhere -are outside this finding. - -## Stage-by-stage review coverage - -| Stage | Evidence examined and result | -| --- | --- | -| 1 | Catalog format/schema, minimal relative-import bundle, examples, CC0 grant, and check script. Finding 2 affects the native format match. | -| 2 | Local schema compilation, offline loader, partial/complete validation, extension retention, and collection-scoped identity checks. Finding 2 affects accepted aliases. | -| 3 | Native pipeline catalog acquisition, source-origin path adaptation, lookup behavior, and imported catalog tests. Finding 1 affects selected values. | -| 4 | Independent campaign/session defaults, pointer/null handling, inline replacement, native-result preservation, and snapshot rendering tests. No additional actionable finding. | -| 5 | Native layered resolution, imports/sibling inheritance, whole-record upsert/replacement, party projection, deterministic output, and selection errors. Findings 1 and 2 surface here. | -| 6 | Four descriptors/paths, manifest-backed resolution, retired-source rejection, and unchanged roster/player/spell-overlay identities. No additional actionable finding. | -| 7 | Preparation writes, input sizes/digests/provenance, workspace modes, empty roles, and failure handling. Finding 1 can incorrectly yield empty selected vocabulary. | -| 8 | Versioned prepare evidence, effective-content comparison, source relocation, imported changes, and missing/tampered prepared records. No additional actionable finding. | -| 9 | Verified prepared-input archival, nested remote/local mapping, manifest-last restore, and round-trip tests. No additional actionable finding. | -| 10 | Native arguments, removed module surface, independent report/debug paths, credential handling, and omission semantics. No additional actionable finding. | -| 11 | Shared polish request construction, four-input evidence, resume metadata, report bounds/paths, and transcript promotion failures. No additional actionable finding. | -| 12 | Embedded synthetic transcript, native preflight arguments, isolated temporary captures, cleanup, redaction, and cancellation. No additional actionable finding. | -| 13 | Selected Audita/Scriptorium checks, native error propagation, existing prompt findings, and empty/cancelled checks. No additional actionable finding. | -| 14 | Post-prepare reprojection, lazy adapter composition, bounded runs, force/failure authority, preparation reuse, and fully reused invocations. No additional actionable finding. | -| 15 | Validation against existing prepared evidence, probe namespace, provider side effects, source independence, and unchanged manifest tests. No additional actionable finding. | -| 16 | Explicit consumer source changes, maintained native authoring/catalog examples, and retired-field tests. No additional actionable finding. | -| 17 | Real catalog acquisition/preparation and controlled native Audita inspection/preflight checks. Checks pass, but did not cover Findings 1 and 2. | -| 18 | Public/internal integration, configuration, migration, lifecycle, and attribution updates. Schema documentation needs coordination for Finding 2. | -| 19 | Full tests/race tests, vet/build, native compatibility, recovery round trip, and cutover review. Checks pass; the two reproduced edge cases still require remediation. | - -## Verification performed - -- `go test ./...` and `go test -race ./...` passed with Go 1.27.4. -- `go vet ./...` and `go build ./...` passed. -- Opt-in `TestReferenceCatalogCompatibility` and `TestAuditaBinaryCompatibility` - passed against the actual catalog and a fresh Audita v4.2 build. Provider - requests used a controlled loopback server, not paid services. -- The embedded schema matches the catalog schema byte for byte. -- CLI probes independently reproduced both findings using temporary synthetic - data. Native Audita acceptance of null aliases was checked directly. - -Automatic provider checks, synthetic-transcript feasibility errors, all-four-role -runtime authority, and the clean source/format cutover are explicit user-selected -scope. They are not findings or reasons to restore the earlier behavior. - -## Algorithmic review coverage - -The follow-up review used Narratio `54ba768a28eee317985b0be4bb284d5f77ff00f1` -and the same implementation and catalog revisions described above. At review -time, Findings 1 and 2 were pending and Findings 3 and 4 were lower-priority -refactoring opportunities. Completion notes above record their resolution. -No additional ordinary correctness bug was found in this pass. - -| Stage | Algorithmic assessment | -| --- | --- | -| 1 | Reviewed the catalog schema and offline check script. Neither adds a pairwise entry comparison or runtime catalog traversal. | -| 2 | Schema compilation uses `sync.Once`; collection ID uniqueness uses a hash set. JSON conversion and validation traverse the data. | -| 3 | Catalog path adaptation traverses sorted IDs; selection is a map lookup. No eager vocabulary-file loading was added. | -| 4 | Campaign/session selection visits a fixed set of fields. Native composition remains ConfigKit-owned. | -| 5 | Party sorting is explicitly prescribed. Vocabulary uses native composition, hash-based duplicate checks, and deterministic serialization; those selected algorithms were retained. | -| 6 | Four descriptors are fixed-size. Each prepared-input lookup scans manifest inputs and streams its file digest; four lookups remain linear in manifest size and total bytes. | -| 7 | Preparation materializes four documents using existing change detection and deterministic record ordering. No growing cross-product of glossary entries is added. | -| 8 | Finding 3 identifies quadratic record matching in the extended resume path. Effective vocabulary comparison and content hashing are explicit design choices. | -| 9 | Publication adds a fixed four verified input kinds; archival streams file contents. Restore uses a fixed-size descriptor lookup per object. | -| 10 | Argument construction visits the supplied files; report discovery checks three fixed names. Finding 4 covers discarded-content buffering. | -| 11 | Glossary evidence covers four files and a fixed-size digest input. Finding 4 covers the additional whole-report read. | -| 12 | Synthetic transcript size is fixed. Preflight uses one native invocation and invocation-scoped temporary files. | -| 13 | Sequential downstream checks are explicitly selected. Requirement processing uses map lookups rather than comparing every requirement with every binding. | -| 14 | The runner performs one post-preparation reprojection over the fixed canonical stage set; the new hook does not repeat it before every stage. | -| 15 | Validation loads one manifest and resolves four prepared documents; it does not resolve live vocabulary or run preparation. | -| 16 | Consumer binding changes use existing resolvers. Examples and source-ID rejection add no new growing algorithm. | -| 17 | Compatibility checks use explicit local inputs and controlled providers. Catalog fixture copying visits each file once. | -| 18 | Documentation changes add no runtime algorithm. | -| 19 | Reviewed the assembled paths and focused recovery tests. No additional asymptotic issue was identified in the newly added orchestration. | - -Focused glossary, configuration, artifact-policy, artifacts, stage, preflight, -Audita-adapter, and application tests passed with Go 1.27.4. Complexity findings -come from the implemented loops and allocation paths; no real-world performance -measurements or paid provider calls were used. The proposed refactorings retain -native ConfigKit semantics, required ordering, content verification, and the -selected preflight policy.