Files
narratio/docs/roadmap/session-restore.md

369 lines
20 KiB
Markdown

# Session Restore from Published Artifacts
Status: Proposed; core behavior agreed, open decisions listed below
## Goal
Define `narratio session restore ID` as retrieving the identified session's
published artifacts and making them usable as inputs to subsequent work.
Restore constructs local manifest completion state from the products available
after import. Completion means that a stage's work is satisfied by those
products; it does not assert that the stage executed in this workspace.
The operator can start from original audio, start downstream work from published
products, or continue interrupted work in an existing local workspace. Remote
execution-checkpoint upload and recovery are deferred.
This is a feature roadmap, not a staged implementation plan. It incorporates
the decisions in the [audit discussion](audit/discussion.md) and the subsequent
agreement to synthesize stage completion using a small stage/output mapping.
That agreement supersedes earlier suggestions that restore must reconstruct
historical producer evidence or avoid marking covered upstream stages complete.
## Current Baseline
Reviewed against `d8bc99b17efdddd0a728ef519b2e5a1d25f85fa9`.
- Publication writes immutable objects, a remote commit inventory, and a current
pointer. The inventory already identifies sources, exact object keys, sizes,
checksums, and storage generations. It also includes a session-manifest snapshot.
- Remote-state discovery requires that snapshot and decodes its execution ledger.
Restore uses it to map products, rebase producer-machine paths, and install a
local manifest after downloading files.
- Publication locks can retain output A while the local execution ledger describes
replacement B. Current restore can install A alongside B's completion evidence,
report success, and leave normal artifact resolution rejecting the result.
- Built-in, extraction, and configured-artifact resolution depend on recorded
producer success or generation evidence. Files copied into canonical locations
alone are insufficient.
- Bounded runs require preceding stage statuses. A full run additionally applies
semantic and content resume checks, so merely writing `succeeded` would not
establish a durable restored baseline under the current validators.
- Prepare combines stable reference materialization, audio acquisition, and
previous-session inputs. Session validation requires an audio source. These
responsibilities currently obstruct a fresh artifact-only workflow.
- Previous-session artifact selection already uses the publication inventory,
but its shared discovery and local cache still require the execution snapshot.
- Local speaker and analysis checkpoints already retain completed work after
ordinary failures. They do not need remote backup to support local retry.
Implemented mechanics are documented in [restore](../internal/command-restore.md),
[artifacts](../internal/artifacts.md), [manifests](../internal/manifest.md),
[prepare](../internal/stage-prepare.md), and [publication](../internal/stage-publish.md).
The original defect and test gap are linked from
[CAT-02](audit/catalog.md#cat-02--p2-make-restored-carried-products-agree-with-manifest-authority).
Their historical-evidence remediation direction is replaced by this roadmap's
product-import model.
## Operator Workflows
### Start from original sources
Supply the authored campaign/session inputs and raw audio in a fresh workspace.
Run Narratio normally. Processing stages generate their products and record
ordinary local progress and reuse evidence.
### Start from published products
Run `narratio session restore ID` using the selected campaign and remote storage.
Restore retrieves that session's published products, places them in the local
workspace, and constructs the corresponding completion baseline.
Then select downstream stages, or run the ordinary full pipeline. Covered work
is reused; remaining work proceeds in canonical order when its actual inputs
are available. Required campaign/session configuration and references remain
inputs to the new work. Restoring a transcript does not reconstruct all authored
configuration or make unrelated inputs appear.
For example, a restored final trimmed JSON transcript should allow extraction
and analysis without raw audio, per-speaker transcripts, or earlier combined
transcripts. The selected work still needs its configured party, glossary, and
other required inputs. A partial publication's interaction with render is an
open decision below.
### Continue local work
Rerun Narratio against the existing local workspace. Ordinary local checkpoints
retain completed speakers/artifacts, and normal local resume decides what work
remains. Restore is unnecessary for this workflow.
## Targeted End State
### Publication is the import authority
Restore selects published products through the current pointer and its publication
inventory, including exact older declarations preserved by publication locks.
It uses source identities and Narratio's local product-path definitions rather
than a remote execution manifest to place and register products.
Imported products are accepted as supplied inputs. Their historical prompts,
models, configuration, generation fingerprints, producer run IDs, and generation
provenance are unnecessary for acceptance and use. Existing transfer-integrity,
content, and destination checks remain distinct from generation history.
The product inventory remains useful for selecting and verifying files. A remote
session-progress snapshot is not a prerequisite for publication consumption.
Products from different generations can coexist in one publication.
### Restore synthesizes a local completion baseline
Use a small, centrally owned mapping of stages to products and the ultimate
products that satisfy earlier transcript work. Use the existing artifact
identities and fixed pipeline rather than a configurable workflow graph.
Illustrative coverage:
| Restored product | Work satisfied for continuation |
| --- | --- |
| Base JSON transcript | Transcription and merge |
| Polished JSON transcript | The transcript chain through polish |
| Final normalized JSON transcript | The transcript chain through normalize |
| Final trimmed JSON transcript | The transcript chain through trim |
| Rendered Markdown products | Their render output work; they do not substitute for JSON inputs |
| Extraction products | Corresponding extraction output availability and aggregate coverage when its required products are present |
| Configured analysis artifacts | Their individual artifact work; unrelated missing artifacts remain work |
This mapping is about satisfaction, not reconstruction. A final trimmed
transcript can cover earlier stages even though their intermediate files are
absent. The manifest records actual imported files and marks covered stages
complete without inventing output records for files that do not exist.
Keep independent products independent. A transcript does not prove that
extraction, analysis, or rendering completed. Render and extract remain sibling
consumers. Bounds are separately available only when their actual product is
present. Prepared campaign references and previous-session inputs also need
their actual documents; transcript coverage does not supply them.
The baseline is durable across invocations. Its representation must be accepted
by manifest loading, resolution, planning, and execution without fabricating
historical fingerprints or satisfying irrelevant per-speaker records. Use only
the local bookkeeping needed to express coverage and actual product availability.
The manifest representation is an implementation choice.
Import does not authorize publish or cleanup by synthesizing their successful
execution metadata. Those actions retain their own lifecycle and authorization.
### Resume respects the supplied baseline
A normal full run and a bounded downstream run honor restored completion.
Absent audio, missing superseded intermediate transcripts, changed original
model settings, and unavailable historical fingerprints do not by themselves
regenerate covered work.
Preparing references for new downstream work must likewise preserve the supplied
transcript baseline rather than invalidate it for lacking the new preparation's
generation history. Locally generated dependents still follow their ordinary
input-change and invalidation rules.
Existing checks on actual required inputs still apply. If a consumer requests an
intermediate product that was not restored, completion coverage does not make
that file available. Report the missing input through the normal command path;
the operator can supply it, select different downstream work, or regenerate its
producer with the needed inputs.
Force retains its existing stage/range and artifact-target meaning. Explicit
regeneration requires the inputs actually consumed by that operation; restoring
a final transcript does not supply audio for forced transcription. Newly executed
work receives ordinary local checkpoints and semantic reuse evidence. The relaxed
import rules do not disable normal local retry or freshness behavior for that work.
Partial analysis imports must remain usable individually. Additions to the current
artifact selection can schedule missing work without requiring all published
artifacts to have historical analyze fingerprints. Existing explicit-target versus
prerequisite force behavior remains unchanged.
### Preparation and readiness support artifact-only execution
Make the stable references needed by remaining work available without requiring
audio acquisition or execution of covered transcript producers. Relax unconditional
audio-source requirements where necessary for this workflow, while validating
audio configuration and availability when audio processing is actually needed.
Use ConfigKit's completed configuration and existing Narratio domain projections.
Separate the needed preparation responsibilities narrowly; this is not a second
configuration system or a general input scheduler.
Planning, automatic downstream readiness, and adapter composition must agree with
the restored coverage. A covered producer is not projected to rerun merely to
recover historical evidence. Standalone preflight retains its own documented
capability checks; it must accommodate the artifact-only input context without
rebuilding covered transcript work.
### Existing restore controls remain useful
Retain dry-run reporting, ordinary file conflicts, explicit forced replacement,
workspace path handling, transfer verification, and retry after partial restore.
Dry run reports planned imports and resulting stage coverage without installing
files or a manifest. Existing optional published-audio handling can remain an
input import; it is not execution-checkpoint recovery.
Install or update the local baseline after the corresponding imports have been
accepted. Preserve the existing partial-restore recovery mechanism rather than
adding whole-workspace rollback or stronger crash/power-loss guarantees.
Behavior in a workspace with existing local progress is an open decision below.
## Required Changes
### Decouple remote discovery from execution snapshots
Change the shared current-state reader to expose publication identity and
declared products without requiring, decoding, or validating a historical session
manifest. Update restore, remote status, artifact inspection, configuration
fallback consumers, and previous-session acquisition accordingly.
Stop emitting execution-ledger snapshots solely for the deferred checkpoint
purpose. Remove execution-snapshot rebasing and recovery code that no longer
serves the chosen workflow. Preserve the authored or standalone prepared session
configuration used for remote configuration acquisition: that document is distinct
from the session progress manifest. Keep required reference/input material under
its existing purpose rather than preserving a backup feature implicitly.
Reuse the current publication inventory and storage primitives where they fit.
Existing inventories can contain historical execution-snapshot declarations;
product import should not interpret those declarations as execution authority.
This scope does not require a new remote checkpoint protocol or historical
generation reconstruction.
Primary areas: `internal/artifacts/current_state*.go`,
`internal/artifacts/remote_commit.go`, `internal/previouscache`,
`internal/stage/publish*.go`, and application remote/configuration consumers.
### Build and consume restore-defined completion
Replace downloaded-ledger installation with local baseline construction from
the product mapping. Extend manifest handling and artifact availability so
built-ins, extraction lanes, and configured artifacts can be supplied by restore
without historical producer evidence.
Apply the same coverage interpretation to full-run decisions, bounded
prerequisites, stage resume validators, and analysis reconciliation. Merely
writing existing success statuses while leaving current validators unchanged
would not implement the feature. Source resolution must continue distinguishing
actual products from earlier stages satisfied only by an ultimate output.
Update publication's local-source resolution as well: an imported product should
not become unusable merely because the operator later selects publication.
Existing remote publication locks remain authoritative.
Primary areas: `internal/app/restore*.go`, bounded prerequisites and runner
decisions, `internal/manifest`, `internal/artifacts` resolution/catalog/evidence,
and stage-owned resume/checkpoint handling.
### Adapt preparation and operator reporting
Review unconditional session audio validation, prepare materialization and reuse,
and readiness/composition for actual remaining work. Preserve local per-speaker
and per-artifact retry behavior while allowing restored completion to bypass
irrelevant generation checks.
Status, plan, restore reports, and command help should explain which work is
satisfied by restored products and which actual inputs or products are missing.
Reporting local restored completion is administrative state, not a requirement
to recover generation provenance.
Primary areas: `internal/config/validate_core.go`, `internal/stage/prepare*`,
`internal/app/plan.go`, runner/readiness composition, and report projections.
### Align policies and canonical documentation
Update [architecture policy](../policy/architecture.md) provisions that currently
equate stage completion and product availability exclusively with recorded local
generation, require remote manifest installation, or imply historical resume
evidence for every restored product. Define restore-created completion positively
as satisfaction by supplied products, alongside ordinary executed completion.
Update [CLI](../cli.md), [operations](../operations.md), troubleshooting, and the
focused restore, artifact, manifest, prepare, publication, and affected stage
documents when implementation lands. Include the three operator workflows and
explain that remote execution-checkpoint recovery is deferred. Keep upstream
library behavior linked to its canonical documentation.
Audit records remain evidence of the baseline; they are not policy constraints
requiring the old restore semantics. Other audit remediations, including the
workspace-wide locking redesign, remain separate work rather than prerequisites
for a publication-import framework.
## Validation Outcomes
Use focused offline behavioral tests and representative assembled workflows:
- Publish A, lock it, generate B locally, republish, and restore into a fresh
workspace. A resolves and supports downstream work without importing B's
fingerprints or requiring the execution snapshot's contents to be readable.
Cover a transcript and a configured artifact.
- Restore an ultimate transcript with no audio and no superseded intermediate
transcript files. Persist and reload the synthesized manifest, then compare
planning and actual downstream execution. Covered producers make no adapter
calls; required references are prepared or supplied normally.
- Re-run the full pipeline after restore and demonstrate coverage reuse plus
execution of genuinely remaining work, under the missing-input choice below.
No restored publish/cleanup success is fabricated.
- Import extraction and partial analysis products, consume them through normal
source IDs, and generate additional selected artifacts without reconstructing
historical tool settings. Preserve meaningful force behavior.
- Continue a locally failed transcription or analysis invocation and retain its
previously checkpointed completions. This remains independent of restore.
- Read previous-session products and remote status from publication inventory
alone. Preserve configuration acquisition from the distinct session document.
- Retain representative dry-run, conflicting-target, invalid-transfer, failed
baseline-save, and partial-restore retry coverage. Choose tests for observable
risks, not exact helper structure or incidental wording.
The implementation plan should select checks proportionately under the
[testing policy](../policy/testing.md). This planning pass implements no behavior.
## Scope Boundaries
Keep the fixed pipeline and existing command name. New command families, arbitrary
workflow graphs, continuous remote backup, checkpoint upload timing/failure
machinery, and historical generation reconciliation are outside this scope.
Local resume remains a supported feature.
Preserve selected transfer, path, conflict, and publication behavior without
turning incidental implementation choices into additional guarantees. This
roadmap introduces no publication-wide same-generation requirement, new data-size
cap, requirement to publish every intermediate file, or compatibility/migration
framework. New restrictions or stronger guarantees need an explicit decision.
## Open Decisions
### Restore into a workspace that already has local progress
**Recommendation:** Merge restored product records and derived completion into
the existing local manifest, preserving unrelated local progress. Retain ordinary
file conflict handling; `--force` permits the existing eligible replacements.
When an imported replacement changes an input of locally generated work, apply
the existing local dependent-invalidation rules. Do not copy remote stage history
or discard unrelated speaker/artifact checkpoints.
This fits the existing conflict-oriented restore workflow and preserves the
agreed local-resume feature, but needs careful affected-record reconciliation.
**Alternative:** Restrict restore to a fresh workspace and construct a replacement
baseline there. This is simpler and avoids merging local progress, but adds an
operator restriction not yet requested. Operators would need a separate workspace
or an explicit cleanup before importing published products. Adopt that narrower
workflow only with approval.
### Remaining render work when only the final trimmed JSON is published
Current render produces both untrimmed and trimmed Markdown and requires both
JSON inputs. The agreed ultimate-output mapping can satisfy normalize through
the trimmed transcript while leaving the untrimmed JSON absent. A full run can
therefore reach render with only one of its two inputs.
**Recommendation:** Allow render to produce the independently available transcript
variants in this restored-input workflow and leave the unavailable variant
explicitly unavailable. This lets a full run continue from the ultimate transcript
without regenerating its unneeded ancestors or requiring extra publication.
It is an additional render behavior change requiring approval, not an implicit
consequence of marking earlier stages complete. It does not require incremental
Notarius lane execution or a general partial-stage framework.
**Alternative:** Preserve render's current two-input contract. A full run reports
the missing input; the operator can restore/publish both JSON variants, disable
render, or choose an extract/analyze-only range. This minimizes implementation
scope and avoids partial render semantics, but makes the final-transcript-only
workflow less convenient for ordinary full runs. Neither choice should pretend
the absent untrimmed JSON exists or automatically regenerate the covered chain.