Files
narratio/docs/roadmap/implementation.md

462 lines
25 KiB
Markdown

# Import Published Products: Implementation Plan
Status: Pending
## Scope and working rules
Implement [Session Restore from Published Artifacts](session-restore.md).
That roadmap owns user intent, boundaries, and the three operator workflows.
This plan replaces the completed CAT-10 plan. CAT-10 and CAT-13 remain implemented.
Read the roadmap completely, then [Development](../development.md) and the
applicable agent, architecture, testing, and documentation policies. For the
original defect, read only [CAT-02](audit/catalog.md#cat-02--p2-make-restored-carried-products-agree-with-manifest-authority)
and its linked FC-02/TE-02 sections. Original audit reports remain historical
evidence; their historical-contract remedy is superseded by the roadmap.
Complete stages in order. Each stage is a focused coding-agent prompt; split
commits within a stage where independently reviewable. Keep the build and
focused tests usable while introducing shared foundations. The inventory,
publication, and restore stages form one coordinated cutover: record any expected
cross-stage test failures against the named pending stage, and resolve them
before declaring the cutover complete. Keep affected-owner tests meaningful;
do not weaken assertions to conceal unfinished integration. Transitional private
code may connect stages, but remove the old execution-snapshot workflow by
completion. Intermediate commits are not a finished release. Update owned
current-behavior documentation when each capability becomes implemented.
This is a planning document. This pass changes no application code or policy.
Implementation commits use plain-English messages under agent policy; pushing
and releasing require separate authorization.
## Implementation decisions
### Durable supplied products and coverage
Add an optional, typed supplied-product collection to the local manifest, with
a collection version and records keyed by canonical source ID. Each record
contains its session-relative canonical path, checksum, size, and product
contract information needed for content interpretation. This is local acceptance
and availability evidence. Historical producer IDs, prompts, models, extraction
provenance, and generation fingerprints are not required fields.
Keep existing executed-stage, speaker, and analysis checkpoint representations.
The additive collection leaves existing local manifests usable without a
migration. Maintain one authoritative accepted record per supplied source.
A successful local replacement retires the supplied record for that source and
uses ordinary local evidence thereafter. Stage transitions must not accidentally
reactivate an older supplied record after an authorized replacement attempt.
Place supplied-product validation and the fixed stage/product coverage helper
in `internal/artifacts`; serialization belongs in `internal/manifest`, and
orchestration belongs in `internal/app`. Validate actual bytes with existing
content and confinement rules. Coverage is derived from valid supplied records,
not directory scanning or fabricated outputs.
| Supplied product | Transcript work satisfied |
| --- | --- |
| Base multi-speaker JSON | transcribe, merge |
| Polished JSON | transcribe through polish |
| Normalized/final JSON | transcribe through normalize |
| Final trimmed JSON | transcribe through trim |
Prepare remains responsible for actual needed references; a supplied transcript
satisfies the audio-generation prerequisite, not missing reference documents.
Markdown satisfies only selected render outputs. Bounds, extraction products,
configured artifacts, and previous inputs require their actual files.
No supplied record creates publish, notify, or cleanup execution authority.
Use the same assessment for restore reports, bounded prerequisites, planning,
resume, readiness, and execution. Supplied products are independent inputs;
do not infer their historical relationships from co-publication. Ordinary local
dependents still use current input identities and existing invalidation rules.
Reference preparation preserves the supplied transcript baseline. Explicit
pipeline force retains its existing stage/range and artifact-target meaning;
it overrides relevant supplied completion and requires real generation inputs.
### Render selection
Add `render.variants`, a list containing `normalized` and/or `trimmed`.
The absent-field default is both. Treat the list as a set; duplicate entries
need not fail. An explicit empty/null selection requests no variants, and the
existing `render.enabled` control remains available. Reject unknown variant
names as unsupported. Use native ConfigKit schema/default handling and a single
domain variant-to-input/output mapping.
### Publication and restore
Retain the current pointer and publication inventory format and transfer checks.
Readers bind to the selected inventory; they do not fetch or decode execution
snapshots. Existing inventories may contain obsolete snapshot declarations,
which readers ignore as execution authority. New publication stops emitting
those snapshots. Authored/standalone session configuration and needed reference
documents retain their distinct input purpose.
Restore plans from source identities, the product registry, and current concrete
artifact definitions. Keep local flat product placement independent of remote
publish destinations. Retain current supported source/path handling; do not add
historical-manifest or basename searches to discover products.
Restore merges into local state under the existing workspace lock. File
replacement requires existing conflict/force rules. Identical content preserves
existing valid local execution evidence; a fresh or otherwise unrecorded
accepted product receives a supplied record. Changed replacements invalidate
affected locally generated work through existing relations, preserve unrelated
checkpoints, and then install the products supplied by this import as its
baseline. There is no same-generation test between imported products.
Restore's `--force` authorizes file replacement, independently of pipeline
regeneration flags.
Install the merged local manifest after accepted imports and retain the
incomplete-restore marker/retry mechanism. Dry runs report imports and resulting
coverage without installing durable products or a manifest. No rollback,
background checkpoint service, compatibility framework, or new safety limit is
part of this work.
## Stage 1: Introduce durable supplied-product records and fixed coverage
Status: Complete
Read `internal/manifest/manifest.go`, manifest validation/store code,
`internal/artifactmodel`, and transcript/product registries.
1. Revise the architecture policy's completion, resume, and restore constraints
to permit satisfaction by supplied products and inventory-based import, as
expressly selected in the roadmap. State the boundary positively and preserve
ordinary local generation and safety rules. These constraints govern the
following stages; implemented-behavior references advance with their code.
2. Add the typed optional collection described above and extend strict manifest
decoding/validation and cloning. Preserve existing local state contracts.
3. Implement narrow helpers to validate a supplied record against the canonical
path and actual bytes and to derive fixed transcript coverage. Reuse existing
source registries and content checks.
4. Represent actual products separately from satisfied producer stages. A
trimmed transcript must not create pretend base, polished, normalized, or
bounds artifact records.
5. Test round-trip persistence, absent supplied collections on ordinary
manifests, missing/tampered supplied products, and each coverage boundary.
Cover Markdown and independent products not implying transcript coverage.
Validation: `go test ./internal/manifest ./internal/artifacts`.
## Stage 2: Implement variant-selectable rendering
Status: Complete
Read `internal/config` render schema/default/validation, `stage/render.go`,
and render portions of `semantic_contracts_refinement.go`.
1. Implement the selected `render.variants` contract and central mapping. Update
render to resolve and convert only selected JSON inputs, retaining canonical
filenames and existing conversion/materialization behavior.
2. Make semantic evidence describe selected variants and their input/output
identities. Preserve the both-variant default and disablement behavior.
Deliberately revise render's semantic contract version if its changed payload
requires it; do not bump unrelated stage contracts.
3. Test trimmed-only without normalized JSON, normalized-only without trimmed
JSON, omitted selection, explicit empty selection, unknown names, and missing
selected inputs. Verify changes in selection affect reuse and later coverage.
4. Update configuration reference and a maintained example for the new field.
Validation: `go test ./internal/config ./internal/stage ./internal/doccheck`.
## Stage 3: Resolve supplied built-in and extraction products
Status: Complete
Read `artifact_resolver.go`, `prepared_input.go`, `extraction_evidence.go`,
`extraction_input.go`, and catalog/bootstrap code under `internal/artifacts`.
1. Let normal source resolution and catalogs consume valid supplied built-ins,
configured product records, and extraction products. Preserve ordinary
generation-evidence validation for locally generated products.
2. Supplied extraction products need their actual payload/content contract, not
old Notarius metadata or an original transcript fingerprint. Partial imports
remain individually available; extract completion requires its current
required product set. Executing extraction retains the existing full-bundle
behavior rather than adding per-lane generation checkpoints.
3. Make supplied configured products available through their existing canonical
source IDs without inventing analyze fingerprints or producer runs.
4. Ensure coverage alone cannot resolve an absent intermediate file. Test
supplied trimmed JSON, separately supplied bounds, partial extraction, and
configured outputs after manifest reload.
5. Cover publication's local-source resolver using supplied products. Remote
publication locks and local content/path validation remain unchanged.
Validation: `go test ./internal/artifacts ./internal/stage`.
## Stage 4: Integrate supplied products into incremental analysis
Status: Complete
Read `analyze_reconciliation.go`, `analyze_fingerprint.go`,
`analyze_plan.go`, and analysis execution/checkpoint handling.
1. Classify valid supplied configured artifacts before evaluating their
historical generation inputs/fingerprints. Avoid the current eager
fingerprint pass demanding absent old inputs for an accepted supplied result.
2. Reuse supplied targets and prerequisites individually. Generate missing
selected work in normal dependency order and compute its ordinary fingerprints
using actual resolved input identities.
3. Preserve explicit-target force versus prerequisite reuse. A local replacement
transitions its source to local checkpoint evidence; failures retain the
existing retry/retention policy without reviving superseded imported evidence.
4. Permit mixed supplied and locally generated artifact collections. Keep the
original target set separate from the prerequisite closure.
5. Test partial import plus a new target, a supplied disabled prerequisite,
changed historical model/prompt settings, forced target replacement, and an
ordinary partial local failure/retry. No blanket bypass of local freshness.
Validation: `go test ./internal/stage ./internal/artifacts ./internal/manifest`.
## Stage 5: Share supplied completion across planning and execution
Status: Complete
Read `internal/app/semantic_resume.go`, `plan.go`,
`runner_stage_execution.go`, `run_control.go`, bounded prerequisites, and
stage resume validators.
1. Consult validated supplied coverage before requiring historical semantic or
per-speaker evidence for covered transcript work. Recheck actual supplied
files; invalid/missing products cannot sustain completion.
2. Make full-run and bounded-run decisions agree. In a restored context, missing
independent render/extract work does not block selected analysis unless its
actual required sources need those products. Do not mark unrelated stages
complete simply to satisfy the old all-prefix status check.
3. Keep actual consumer input checks: a request for absent intermediate JSON
still fails with actionable guidance. Use the fixed mapping and existing
input declarations rather than a configurable stage DAG.
4. Honor selected force and existing dependent invalidation. A supplied
completion shortcut must not defeat an explicit regeneration request.
5. Project decisions on cloned manifests without workspace writes, execution
adapters, or readiness probes. Retain CAT-13's relevant read-only S3 checks
for actual raw-audio preparation reuse.
6. Test full and bounded plans against real execution with missing superseded
transcripts, changed historical settings, and forced work.
Validation: `go test ./internal/app ./internal/stage`.
## Stage 6: Separate reference preparation from audio acquisition
Status: Pending
Read `config/validate_core.go`, `stage/prepare*.go`, and preparation semantic
evidence. Preserve ConfigKit's completed-configuration boundary.
1. Allow absent audio selection in configuration; retain validation of any
supplied audio mode and existing mutual-exclusion/path rules. Require audio
when selected remaining work actually consumes it, including forced
transcription or ordinary uncovered source-based execution.
2. Separate stable-reference/history materialization from audio acquisition
through narrow preparation helpers. Reuse existing renderers and CAT-10's
prerequisite-inclusive history collector, not another input scheduler.
3. Persist honest preparation evidence for the work actually performed. Reference
preparation does not certify audio or manufacture missing documents. Retain
ordinary prepared-copy/source checks and reuse for raw-audio sessions.
4. Test reference-only preparation with supplied transcript coverage, absent or
invalid required references, and source-based preparation without audio.
Reference refresh preserves supplied transcript records and unrelated local
checkpoints. Keep the current raw-audio workflow covered.
Validation: `go test ./internal/config ./internal/stage ./internal/artifacts`.
## Stage 7: Wire artifact-only preparation into commands and readiness
Status: Pending
Read runner acquisition/composition, `session_readiness.go`, bounded
prerequisites, `plan.go`, and downstream readiness request builders.
1. Determine supplied coverage before rejecting absent audio or missing old
prefix statuses. Under the workspace lock, make required references/history
available before downstream input checks, including bounded runs that start
after prepare. Reference-only work preserves supplied transcript coverage.
2. Compose adapters from remaining work. Standalone preflight keeps its enabled
capability checks and provider probes, but uses artifact-only references
without rebuilding covered transcript producers.
3. Project this preparation honestly without writes in `session plan`. A missing
real consumer input is still reported; coverage is not file reconstruction.
4. Verify full and bounded artifact-only execution with real references, no
audio, and no superseded transcripts. Check preflight, planning/execution
agreement, missing-reference/history diagnostics, and forced transcription.
Reuse CAT-10/CAT-13 checks for unchanged acquisition behavior.
Validation: `go test ./internal/app ./internal/stage ./internal/config`.
## Stage 8: Separate publication inventory reads from execution snapshots
Status: Pending
Read `artifacts/current_state*.go`, `remote_commit.go`, application remote
discovery/status/configuration consumers, and their tests.
1. Extract the shared pointer/inventory reader so publication identity and
declarations are available without requesting a session-manifest object.
Retain pointer/commit identity, namespace, checksum, size, generation, and
bounded-read checks.
2. Expose campaign/session/run publication identity from the inventory. It is
remote publication identity, not proof of local stage execution.
3. Update remote status, published-artifact inspection, and distinct session
configuration acquisition to use inventory evidence. Retain the authored
session configuration's own acquisition/validation.
4. Add tests for an inventory without a snapshot, and an existing inventory whose
obsolete snapshot body is missing, malformed, or unsupported. These cases
must not obstruct publication inspection or configuration acquisition.
5. Keep any temporary old restore-reader wiring private until Stage 11's
cutover. The completed workflow has one inventory reader and no ledger-fetch
fallback.
Validation: `go test ./internal/artifacts ./internal/app`.
## Stage 9: Use inventory-only history and stop publishing execution ledgers
Status: Pending
Read `internal/previouscache`, `stage/prepare_previous.go`,
`publish*.go`, and consumers of remote manifest fields.
1. Resolve previous-session products from exact published-output declarations
using the inventory reader. Remove the mandatory previous execution-manifest
transfer and its prepared-input record; retain actual history products and
required/optional handling.
2. Remove snapshot production, declaration, upload, and snapshot-only archive
paths from publication. Review run-file selection so diagnostic archives do
not accidentally reintroduce a remote progress-backup feature.
3. Preserve independently useful authored/prepared input publication, including
the session configuration used for remote acquisition. Keep product inventory,
immutable object transfer, lock carry-forward, pointer-last commit, and
cleanup authorization intact.
4. Keep old snapshot declaration recognition only as needed to read existing
inventories; never download or interpret their contents as authority.
5. Test previous history with no snapshot, locked carry-forward declarations,
optional absence versus access/integrity errors, and new publication with
no execution-ledger payload. Retain CAT-10 closure coverage.
Validation: `go test ./internal/previouscache ./internal/stage ./internal/artifacts`.
## Stage 10: Plan product imports and synthesized completion
Status: Pending
Read `internal/app/restore_plan.go`, product-path mapping, restore reports,
and the source registries/current concrete artifact catalog.
1. Replace manifest-based product mapping with inventory source-to-canonical-path
mapping. Published remote destination names do not dictate local product
names. Preserve supported reference/audio import handling and `--include-audio`.
2. Import publication products, not arbitrary execution diagnostics or historical
output records. Resolve configured product locations through current concrete
definitions and existing product rules; preserve flat products and collision
detection. No remote producer paths or old configuration are required.
3. Classify downloads, identical files, and conflicts using existing filesystem
and force rules. Retain exact transfer declarations, including carried older
immutable objects.
4. Build a candidate local baseline from accepted products plus preserved local
evidence. Use the shared coverage helper and render selection; no publish or
cleanup success is synthesized.
5. Extend dry-run reports with actual imports and resulting satisfied/remaining
work. Do not fetch snapshots or write products/manifests to produce the report.
6. Test source-based mapping, configured remote rename, partial product sets,
collision/conflict behavior, and trimmed-only rendering coverage.
Validation: `go test ./internal/app ./internal/artifacts`.
## Stage 11: Install and merge local baselines under the existing lock
Status: Pending
Read `restore_execute.go`, restore recovery/marker code, manifest persistence,
and the existing shared workspace-lock lifecycle.
1. Cut restore discovery/execution over to the inventory plan. Load existing
local progress under lock or create a fresh local manifest; never install a
downloaded execution ledger.
2. Install and verify selected files through existing confined sibling-temp
transfers. Update supplied records only for accepted installed/identical
products. Merge per-source changes, preserving unrelated stage evidence,
speaker records, analysis checkpoints, and local diagnostics.
3. For changed products, apply existing local dependent invalidation, then
register the supplied products in this import without checking historical
cross-product generation consistency. Preserve valid local authority for
identical files rather than gratuitously replacing it with supplied authority.
4. Save the merged baseline last; retain the incomplete-restore marker until
installation and save succeed. Retry after partial transfer or save failure
must converge without whole-workspace rollback.
5. Remove producer-path rebasing, downloaded-manifest install/classification,
and temporary dual-reader wiring. Update restore reports to describe local
import completion rather than restoration of a remote execution run.
6. Test fresh restore, existing local progress, identical/conflicting/forced
replacements, unrelated checkpoint preservation, cancellation, failed final
save, and retry. Reuse existing path and transfer tests for unchanged risks.
Validation: `go test ./internal/app ./internal/manifest ./internal/artifacts`.
## Stage 12: Prove the three operator workflows end to end
Status: Pending
Use real internal collaborators, temporary files, and fake external storage,
subprocess, and generation boundaries. Avoid post-restore manifest repairs.
1. Publish A, lock it, generate local B, republish, then import into a fresh
workspace. Verify A resolves and supports downstream work. Cover a built-in
transcript and configured artifact; make the old snapshot unavailable.
2. Restore final trimmed JSON without audio or superseded transcripts. Reload
the saved manifest, compare plan and execution for full and bounded runs,
and generate extraction/analysis with required references. Covered transcript
producers make no adapter calls.
3. Cover trimmed-only rendering; default both-variant selection still reports
a missing normalized JSON when that selected input is needed. Selecting
another unavailable source reports absence rather than inventing a file.
4. Import partial analysis/extraction products, consume their ordinary source
IDs, add a new selected analysis artifact, and republish supplied products.
Verify local replacements establish normal checkpoints and semantic evidence.
5. Restore into local progress and demonstrate preservation, ordinary conflicts,
authorized replacement, and local-dependent invalidation. Demonstrate failed
local speaker/artifact work still resumes normally without remote restore.
6. Verify forced transcription requires audio; reference-only preparation keeps
the supplied baseline; standalone preflight retains its distinct probes.
Missing selected inputs/references remain errors.
7. Consolidate obsolete snapshot-based tests into these workflow and narrower
boundary tests. Keep meaningful lock, transfer, conflict, and recovery coverage.
Validation: run focused workflow tests uncached, then `go test ./...`.
## Stage 13: Align policy, documentation, and audit disposition
Status: Pending
1. Finalize and check the Stage 1 architecture policy adaptations: completion
can express executed work or satisfaction by supplied products; product
acceptance uses actual local
records; remote publication authority is the inventory. Remove requirements
for downloaded execution ledgers and historical fingerprints on supplied
products. Preserve ordinary generation evidence and safety boundaries.
2. Update canonical CLI, configuration, operations, troubleshooting, and focused
manifest/artifact/prepare/render/analyze/extract/publish/restore internals.
Explain original-source runs, product imports, and local resume. Include
render selection, local merge/conflicts, force distinctions, and deferred
remote execution recovery. Keep upstream library documentation linked.
3. Update maintained examples and affected example-loading tests. Remove
obsolete snapshot terminology and dead snapshot/rebasing helpers or fields
only where this cutover made them unused; preserve distinct session YAML.
4. Run all checks with the maintained toolchain:
```sh
GOTOOLCHAIN=go1.27.4 go test ./...
GOTOOLCHAIN=go1.27.4 go test -race ./...
GOTOOLCHAIN=go1.27.4 go vet ./...
GOTOOLCHAIN=go1.27.4 go build ./...
```
5. Check every validation outcome in the feature roadmap against tests/current
behavior. Review for invented generation claims, new publication-wide
consistency rules, blanket checkpoint resets, or new migration machinery.
6. Close CAT-02 only after its round trips pass. Review other roadmap-assigned
findings individually: close only those whose offending lifecycle was removed
or remediation verified. Keep independent P3 work open and original audit
reports unchanged. Update discussion/catalog links and counts accordingly.
7. Mark implementation stages and feature status complete only after the entire
supplied-product workflow, documentation, and validation are complete.