Document and verify published product imports
This commit is contained in:
@@ -189,13 +189,9 @@ restore, status and validation checks, and previous-cache planning.
|
||||
`LoadCurrentInventory` reads and verifies the pointer-selected commit without
|
||||
fetching an execution snapshot. Status, publication inspection, and session
|
||||
configuration acquisition and previous-session acquisition use that inventory.
|
||||
The existing restore path still uses the snapshot reader until its cutover.
|
||||
|
||||
The selected session manifest is accepted only with
|
||||
`schema_version: narratio.session-manifest.v2` and complete stage identity.
|
||||
An unsupported local or downloaded manifest must be replaced by regeneration,
|
||||
verified restore, or republication; artifact resolution never fills in missing
|
||||
authority markers.
|
||||
Restore uses the same inventory. Obsolete execution-snapshot declarations are
|
||||
ignored without reading their contents; unsupported local progress must be moved
|
||||
aside before creating a new local baseline.
|
||||
|
||||
For a new-protocol current state, the pointer-selected immutable commit is the
|
||||
complete restore authority. Callers receive its declared object identities and
|
||||
@@ -207,10 +203,9 @@ Only this declaration type may refer to an earlier run; other declared objects
|
||||
remain confined to the selected commit's run.
|
||||
|
||||
The reader opens each small control object directly and enforces owner-specific
|
||||
limits before decoding: 64 KiB for the mutable commit pointer, 4 MiB for the
|
||||
immutable commit manifest, and 8 MiB for the selected session manifest. These
|
||||
are exposed as `MaxCurrentCommitPointerBytes`,
|
||||
`MaxRemoteCommitManifestBytes`, and `MaxRemoteSessionManifestBytes`.
|
||||
limits before decoding: 64 KiB for the mutable commit pointer and 4 MiB for the
|
||||
immutable commit manifest. These are exposed as `MaxCurrentCommitPointerBytes`
|
||||
and `MaxRemoteCommitManifestBytes`.
|
||||
|
||||
Each read uses the generation and size metadata returned with its opened body.
|
||||
Actual bytes remain subject to a limit-plus-one read even if size metadata is
|
||||
|
||||
@@ -2,129 +2,69 @@
|
||||
|
||||
## Purpose
|
||||
|
||||
Explain the implemented restore discovery, planning, installation, and
|
||||
reporting flow in `internal/app`. User invocation belongs in
|
||||
[CLI](../cli.md#session-restore), and the operator recovery procedure and
|
||||
physical restore scope belong in
|
||||
[Operations](../operations.md#restore-workflow).
|
||||
Restore imports products declared by the selected publication inventory into a
|
||||
local session. The [CLI](../cli.md#session-restore) describes invocation and
|
||||
[Operations](../operations.md#restore-workflow) describes operator recovery.
|
||||
The session progress manifest stays local; publication is not a checkpoint backup.
|
||||
|
||||
Restore separates remote authority, local conflict policy, and filesystem
|
||||
mutation so each remains testable independently.
|
||||
## Discovery and planning
|
||||
|
||||
The public command supplies production defaults to one private,
|
||||
invocation-scoped dependency value. Discovery, planning, and execution use that
|
||||
same value, so focused sequencing tests can replace one boundary without
|
||||
mutable package hooks.
|
||||
`internal/artifacts` validates the current pointer and its immutable commit,
|
||||
including campaign, session, run, checksum, size, generation, and namespace.
|
||||
Discovery binds the plan to that inventory. Obsolete execution-snapshot
|
||||
declarations are ignored without reading their bodies. Authored session YAML
|
||||
remains a separate configuration input.
|
||||
|
||||
## Discovery Contract
|
||||
The planner maps each recognized published source through the built-in product
|
||||
registry or current concrete configured definitions. Local products use flat
|
||||
canonical paths regardless of remote destination names. Exact immutable keys,
|
||||
checksums, sizes, and generations remain attached to actions, including products
|
||||
carried from earlier publications by locks. Supported prepared documents and,
|
||||
with `--include-audio`, audio retain their input paths. Prepared glossary inputs
|
||||
include the four individual envelopes and the combined glossary. Previous-session
|
||||
requirements use the shared prerequisite-inclusive collector and exact
|
||||
published-output declarations; execution diagnostics and remote progress
|
||||
snapshots are not imported.
|
||||
|
||||
Discovery delegates current-state pointer and manifest loading to
|
||||
`internal/artifacts`, then validates the result against the resolved request:
|
||||
Each target is classified as `download`, `skip_same`, or `conflict` beneath the
|
||||
session root. Symlinked or non-regular ancestors and leaves remain conflicts;
|
||||
`--force` authorizes replacement of differing regular files only. Duplicate
|
||||
local destinations fail planning. Dry runs perform no durable session writes and
|
||||
report imports plus projected work using the normal read-only assessment for
|
||||
preserved local progress. Product coverage is conditional on successful
|
||||
verification of planned downloads; unavailable local assessment is conservative.
|
||||
|
||||
- campaign must match;
|
||||
- session ID must match.
|
||||
- run ID must match the pointer-selected committed run.
|
||||
## Installation and local baseline
|
||||
|
||||
Restore treats any missing or invalid remote current state as a command error.
|
||||
A non-dry run acquires the same workspace lock used by runners before loading
|
||||
local state and classifying files. It writes an incomplete-restore marker before
|
||||
installation. Transfers use confined sibling temporary files and verify the
|
||||
inventory's content and object identity before replacement. Installed products
|
||||
are checked against their canonical paths, content rules, sizes, and checksums.
|
||||
|
||||
## Planning Contract
|
||||
Restore merges accepted products into a clone of local state and saves the local
|
||||
manifest last. Identical content with valid local generation evidence keeps that
|
||||
authority. Other accepted products receive typed supplied records. Changed
|
||||
products invalidate dependent local work using the existing stage relations;
|
||||
unrelated checkpoints and locally recorded diagnostics remain. Co-published
|
||||
products need no shared generation history. The resulting coverage satisfies
|
||||
work without inventing intermediate files or successful publish, notify, or
|
||||
cleanup execution.
|
||||
|
||||
Restore planner action kinds:
|
||||
Failure leaves the marker and any already-installed files. A retry reclassifies
|
||||
those files, verifies them, and saves the merged baseline; the marker is removed
|
||||
after that save succeeds. This is not a whole-workspace rollback guarantee.
|
||||
|
||||
- `download`;
|
||||
- `skip_same`;
|
||||
- `conflict`.
|
||||
## Reporting and ownership
|
||||
|
||||
Planner behavior:
|
||||
Reports identify publication identity, actions, counts, and failures. Actual
|
||||
attempts persist under the restore run's logs. `restore --force` governs file
|
||||
replacement and is independent of pipeline force.
|
||||
|
||||
- prepared campaign, session, party, and all four glossary inputs are restored
|
||||
from declared immutable run objects to their canonical local input paths;
|
||||
- a new-protocol restore uses only the selected commit's declared artifact set;
|
||||
each action carries that artifact's immutable key, checksum, size, and
|
||||
generation;
|
||||
- remote-to-local mapping is traversal-safe;
|
||||
- actions are sorted by local relative path and then remote key;
|
||||
- planning opens the selected session root and inspects every target by its
|
||||
normalized session-relative path. Missing ancestors produce a missing target;
|
||||
an ancestor or leaf symlink is a non-regular conflict and is never opened for
|
||||
hashing;
|
||||
- force converts differing eligible regular files from conflicts to downloads;
|
||||
directories, symlinks, and other non-regular targets remain conflicts.
|
||||
|
||||
For a non-dry-run restore, planning/classification happens only after acquiring
|
||||
the workspace lock. Runner manifest/reuse checks acquire that same lock first.
|
||||
|
||||
Restore uses the default enabled targets and their full prerequisite closure to
|
||||
collect previous requirements as described in [Artifact Internals](artifacts.md#previous-requirement-collection).
|
||||
Previous-cache readiness is resolved through `previouscache.Resolve` for restore,
|
||||
prepare, status, and validation. Each requirement selects the unique
|
||||
`published_output` for its canonical source in the pointer-selected commit,
|
||||
then strips only that run's immutable `published/` prefix for its safe local
|
||||
cache path. It never probes candidate objects or derives paths from manifests,
|
||||
configuration, or basenames.
|
||||
|
||||
## Execution Contract
|
||||
|
||||
Execution order and safety:
|
||||
|
||||
- non-manifest downloads happen before manifest install;
|
||||
- `manifest.json` installs last;
|
||||
- downloads use sibling temp files, validate the complete object, then use an
|
||||
atomic rename;
|
||||
- manifest replacement is validated before rename;
|
||||
- each committed object is verified against its declared checksum, size, and
|
||||
generation before installation;
|
||||
- installation reopens the selected session root, creates only validated
|
||||
missing directory components with workspace modes, and rejects symlinked or
|
||||
non-regular ancestors and leaves before replacement;
|
||||
- a committed manifest already verified during discovery is retained for the
|
||||
matching restore action and revalidated before installation, avoiding a
|
||||
second body transfer;
|
||||
- failed installs do not roll back files already written in the same execution.
|
||||
- a durable `.restore-incomplete.json` marker is written before installation.
|
||||
It blocks runners until a restore retry completes all verified installs and
|
||||
the local manifest replacement, at which point it is removed.
|
||||
- restored manifest local references are rebased beneath the selected local
|
||||
session root. Unsafe relative references and producer-machine absolute paths
|
||||
outside the manifest's producer session root are rejected; producer-local
|
||||
run-local diagnostic references are not restored as
|
||||
authority. Cleanup remains ordinary restored stage state and is not reset or
|
||||
synthesized by restore.
|
||||
|
||||
Audio restore path:
|
||||
|
||||
- uses `audio.MaterializeS3Audio`;
|
||||
- restores selected audio directly into the prepared session audio directory;
|
||||
- reuses a prepared copy only when manifest identity and its content checksum
|
||||
match; otherwise downloads to a verified temporary sibling before installation.
|
||||
|
||||
## Reporting Contract
|
||||
|
||||
- dry-run mode prints a summary, performs no durable session writes, and may
|
||||
read remote current-state or object-identity data to produce that summary;
|
||||
- execution mode persists the canonical restore report described in
|
||||
[Operations](../operations.md#restore-workflow);
|
||||
- report includes plan counts, per-action status, and execution failures.
|
||||
|
||||
## Invariants
|
||||
|
||||
- restore uses committed remote current state as authority;
|
||||
- one restore or status inspection observes the single pointer-selected commit
|
||||
loaded at discovery; later pointer changes cannot add objects or substitute a
|
||||
different run into its plan;
|
||||
- a verified `current/commit-pointer.json` and its selected immutable commit
|
||||
establish remote commitment; when absent, republish the session;
|
||||
- restore does not execute pipeline stages.
|
||||
|
||||
## Implementation And Tests
|
||||
|
||||
- Discovery: `internal/app/restore_discovery.go`
|
||||
- Planning: `internal/app/restore_plan.go`, `internal/previouscache`
|
||||
- Execution: `internal/app/restore_execute.go`
|
||||
- Reporting and command coordination: `internal/app/restore_report.go`,
|
||||
`internal/app/restore.go`
|
||||
- Tests: `internal/app/restore_discovery_test.go`,
|
||||
`internal/app/restore_plan_test.go`,
|
||||
`internal/app/restore_execution_test.go`,
|
||||
`internal/app/restore_recovery_test.go`,
|
||||
`internal/app/restore_workflow_test.go`
|
||||
Discovery is in `internal/app/restore_discovery.go`, planning and coverage in
|
||||
`internal/app/restore_plan.go`, transfers in `internal/app/restore_execute.go`,
|
||||
local baseline installation in `internal/app/restore_manifest_paths.go`, and
|
||||
command coordination/reporting in `internal/app/restore_command.go` and
|
||||
`internal/app/restore_report.go`. The restore, import-workflow, artifact, and
|
||||
recovery tests cover source mapping, identity, conflicts, preservation, retry,
|
||||
and carried products.
|
||||
|
||||
@@ -25,10 +25,10 @@ structure; artifact helpers check the recorded path and actual content. A
|
||||
separate coverage helper derives transcript work satisfied by valid supplied
|
||||
transcripts without creating records for absent intermediate products. Planning
|
||||
and execution use that coverage to reuse satisfied transcript work without
|
||||
historical producer evidence. Restore installation is described in its roadmap
|
||||
until the inventory cutover is implemented.
|
||||
historical producer evidence. Restore merges verified records into local progress
|
||||
as described in [restore internals](command-restore.md).
|
||||
|
||||
Session, campaign, and run identities in local and downloaded manifests must be
|
||||
Session, campaign, and run identities in local manifests must be
|
||||
portable opaque segments. Unsafe legacy identities are rejected with migration
|
||||
guidance rather than being normalized into a different workspace or remote
|
||||
namespace.
|
||||
@@ -43,8 +43,8 @@ cleanup entry in `stages`.
|
||||
Every persisted session manifest has a non-nil `stages` map. Each entry is
|
||||
non-nil and its embedded `name` exactly matches its map key; loading never
|
||||
invents either marker. A missing or unsupported schema version, or incomplete
|
||||
stage identity, is unsupported local state: move it aside before regenerating it
|
||||
or restoring a supported committed snapshot when that is authoritative.
|
||||
stage identity, is unsupported local state: move it aside before regenerating
|
||||
or importing published products into a new local baseline.
|
||||
|
||||
Prepare records independent `party` and `players` input checksums. In canonical
|
||||
party mode, the party record retains its campaign source identity while the
|
||||
@@ -175,7 +175,7 @@ be non-successful, but every completed artifact checkpoint remains reusable.
|
||||
|
||||
## Remote Commit Manifest
|
||||
|
||||
`artifacts.RemoteCommitManifest` is a separate, versioned remote snapshot
|
||||
`artifacts.RemoteCommitManifest` is a separate, versioned publication inventory
|
||||
contract. It is not a serialized session manifest and contains no local
|
||||
post-publication assertion such as `current_pointer_written`. A remote commit
|
||||
identifies one campaign, session, and run and declares its immutable artifact
|
||||
@@ -189,7 +189,7 @@ unknown fields, version mismatches, pointer/commit identity mismatches, and
|
||||
objects that do not match their declaration.
|
||||
|
||||
An absent commit pointer means no remote state is published. Republish to
|
||||
establish a current immutable snapshot.
|
||||
establish a current immutable publication.
|
||||
|
||||
## Persistence Semantics
|
||||
|
||||
@@ -302,7 +302,7 @@ evidence and focused durable validators:
|
||||
|
||||
| Work | Reuse authority | Focused owners |
|
||||
| --- | --- | --- |
|
||||
| prepare | aggregate semantic fingerprint | [prepare](stage-prepare.md) |
|
||||
| prepare | aggregate semantic fingerprint plus durable-copy and current-source validation | [prepare](stage-prepare.md) |
|
||||
| transcribe speakers | aggregate semantic fingerprint plus per-speaker input/output reconciliation | [transcribe](stage-transcribe.md), [WhisperX](../integrations/whisperx.md) |
|
||||
| merge | aggregate semantic fingerprint | [merge](stage-merge.md), [Seriatim](../integrations/seriatim.md) |
|
||||
| polish | aggregate semantic fingerprint | [polish](stage-polish.md), [Audita](../integrations/audita.md) |
|
||||
@@ -370,7 +370,8 @@ where the last session transition can require operator interpretation.
|
||||
## Invariants
|
||||
|
||||
- stage resume/skip decisions are session-manifest driven.
|
||||
- semantic fingerprint comparison precedes stage-specific resume validation.
|
||||
- ordinary local semantic fingerprint comparison precedes stage-specific resume
|
||||
validation; valid supplied coverage is assessed independently.
|
||||
- only successful and intentional-skipped results promote current semantic
|
||||
evidence.
|
||||
- running, failed, and self-skipped stages do not retain result payloads from
|
||||
@@ -394,9 +395,9 @@ where the last session transition can require operator interpretation.
|
||||
|
||||
## Prepared Glossary Evidence
|
||||
|
||||
Preparation records four distinct glossary input kinds with canonical paths,
|
||||
checksums, sizes, and provenance. Polish records the resolved glossary identity
|
||||
evidence used for its result; preflight itself records no stage success. Publish
|
||||
and restore carry the prepared inputs using their declared manifest identities.
|
||||
Preparation records the party, campaign, setting, spells, and combined glossary
|
||||
documents with canonical paths, checksums, sizes, and provenance. Audita's polish
|
||||
request consumes the four individual envelopes. Publish includes recorded
|
||||
prepared documents, and restore selects their declared immutable objects.
|
||||
See [prepare](stage-prepare.md), [polish](stage-polish.md), and
|
||||
[artifact internals](artifacts.md).
|
||||
|
||||
@@ -78,10 +78,11 @@ Supported source families:
|
||||
JSON payload and no map serialization. Configured artifacts are fingerprinted
|
||||
in deterministic dependency order.
|
||||
- fingerprints the normalized artifact key, prompt and profile identifiers,
|
||||
effective render-debug behavior, session-relative output identity, sorted
|
||||
session-relative output identity, sorted
|
||||
dependency keys, ordered input declarations and semantic identities,
|
||||
validated current dependency-output identities, and sorted effective
|
||||
Scriptorium variables (including Narratio's sticky session variable).
|
||||
Render-debug is diagnostic and does not affect the fingerprint.
|
||||
- provides read-only reconciliation that classifies each configured record as
|
||||
supplied, current, stale, missing, failed, or otherwise non-resumable, and
|
||||
separately identifies manifest records removed from current configuration.
|
||||
@@ -193,8 +194,8 @@ Supported source families:
|
||||
visible only inside Scriptorium—such as a file privately loaded by its config
|
||||
path—requires an explicit forced regeneration.
|
||||
- output provenance and metadata are deterministic per execution.
|
||||
- a canonical file without current per-artifact manifest evidence is never
|
||||
promoted to current state.
|
||||
- a canonical file without current per-artifact evidence or a validated
|
||||
supplied-product record is never promoted to current state.
|
||||
- an ordinary retry after interruption or partial failure reuses every valid
|
||||
earlier checkpoint and schedules only failed, stale, missing, or otherwise
|
||||
non-current work in dependency order.
|
||||
|
||||
@@ -20,6 +20,11 @@ recording success. The original bundle and optional domain auxiliaries stay in
|
||||
the producing run until authorized cleanup removes run history. Positive native
|
||||
fallback counts are recorded and reported.
|
||||
|
||||
An imported lane is individually available from its validated supplied record
|
||||
without historical Notarius metadata. Extraction is satisfied by supplied
|
||||
products only when all configured lanes are available. Executing a missing
|
||||
bundle regenerates the complete configured set and retires its supplied records.
|
||||
|
||||
## Resume Validation
|
||||
|
||||
Resume checks the direct transcript identity, configured pipeline and lane
|
||||
|
||||
@@ -67,7 +67,8 @@ cache path, then validates the committed checksum, size, and generation.
|
||||
|
||||
## Invariants
|
||||
|
||||
- only `prepare` hydrates canonical `inputs/previous/` state.
|
||||
- prepare and restore hydrate canonical `inputs/previous/` state from exact
|
||||
declared previous-session products.
|
||||
- managed previous artifacts are stored under `inputs/previous/artifacts/**` without
|
||||
duplicate `artifacts/artifacts/` nesting.
|
||||
- managed `inputs/previous/` state represents only the current requirement set.
|
||||
@@ -77,13 +78,13 @@ cache path, then validates the committed checksum, size, and generation.
|
||||
|
||||
Prepare records a versioned semantic-configuration fingerprint for the
|
||||
resolved campaign/session selection, local-versus-S3 audio mode and canonical
|
||||
audio names, stable-input ownership/presence, previous-session identity, and
|
||||
the party mode plus canonical players projection version, and the effective
|
||||
audio names, stable-input presence, previous-session identity, the canonical
|
||||
players projection version, and the effective
|
||||
previous-artifact requirement set. A change reruns prepare and
|
||||
stales its fixed descendants. Existing successful records without this
|
||||
evidence rerun once when selected.
|
||||
|
||||
Workspace placement are not semantic when logical selection,
|
||||
Source ownership and workspace placement are not semantic when logical selection,
|
||||
canonical names, and effective bytes are equivalent.
|
||||
The fingerprint deliberately does not read or rehash large audio. Prepared
|
||||
input checksums remain the content provenance. Before reusing success, prepare
|
||||
|
||||
@@ -6,7 +6,7 @@ Upload run/session outputs to object storage and atomically advance remote curre
|
||||
|
||||
## Inputs
|
||||
|
||||
- successful preceding stages from the [canonical stage set](overview.md#pipeline-stage-set)
|
||||
- ordinary preceding stage evidence or valid supplied product availability
|
||||
- declared run-local diagnostic files
|
||||
- resolved publish output rules
|
||||
- independent per-source remote lock objects read at planning start
|
||||
@@ -44,7 +44,8 @@ supports remote loading when no authored session override is available. The
|
||||
the session manifest records success. Enablement and upload policy are
|
||||
fingerprinted, so changing either automatically makes the prior result
|
||||
non-resumable.
|
||||
- validates prerequisite stage success and object-store availability.
|
||||
- validates ordinary prerequisites or valid supplied availability and requires
|
||||
an object store. Every selected source is independently resolved and checked.
|
||||
- derives a deterministic run-archive allowlist from the session manifest's
|
||||
declared current-run outputs, logs, and generated configurations. References
|
||||
outside the current run root, including canonical session files and prior-run
|
||||
@@ -57,12 +58,13 @@ supports remote loading when no authored session override is available. The
|
||||
the same confinement and regular-file checks.
|
||||
- resolves publish output sources through runtime artifact catalog and
|
||||
manifest-aware resolution. Configured Scriptorium outputs are publishable
|
||||
only from validated `current` per-artifact analyze evidence; an incidental
|
||||
from validated `current` per-artifact analyze evidence or a valid supplied
|
||||
product; an incidental
|
||||
canonical file, aggregate output, stale/failed/unselected record, or
|
||||
mismatched path, size, or checksum remains unavailable. Built-in and
|
||||
extraction sources likewise require their own current manifest evidence.
|
||||
- includes the four manifest-backed prepared glossary documents with their
|
||||
declared input identities for restore;
|
||||
extraction sources likewise require their own current local or supplied evidence.
|
||||
- includes the four individual prepared glossary documents and the combined
|
||||
glossary with their declared input identities for restore;
|
||||
- publishes extraction lanes only through explicit configured output rules;
|
||||
original Notarius bundles are not scanned or uploaded wholesale. Historical
|
||||
run-local references are not required for later publication.
|
||||
|
||||
@@ -22,12 +22,12 @@ records that may consume rendered transcripts.
|
||||
|
||||
- uses `pipeline.render` settings (enabled/variants/format/title/booleans).
|
||||
- resolves and renders only selected variants; duplicate selections have no effect.
|
||||
- resolves inputs only from verified manifest output evidence.
|
||||
- resolves inputs from verified local output evidence or supplied records.
|
||||
- writes run-local outputs first, then materializes canonical session outputs.
|
||||
- records input provenance, output paths, adapter metadata, logs, and generated config refs.
|
||||
- when `pipeline.render.enabled=false`, completes successfully with no outputs
|
||||
and records explanatory metadata. This is not an explicit self-skip: both
|
||||
manifests record success. Because enablement is fingerprinted, enabling
|
||||
and records explanatory metadata. This is not an explicit self-skip: the
|
||||
local manifest records success. Because enablement is fingerprinted, enabling
|
||||
render later automatically makes the prior result non-resumable.
|
||||
|
||||
## Failure Semantics
|
||||
|
||||
Reference in New Issue
Block a user