Document durable session cleanup
This commit is contained in:
@@ -282,7 +282,7 @@ Rules:
|
||||
| `pipeline.reference_catalog.settings` | map[string]string | No | setting IDs to source-relative vocabulary files |
|
||||
| `pipeline.reference_catalog.systems` | map[string]string | No | system IDs to source-relative vocabulary files |
|
||||
| `pipeline.workspace.root` | string | No | `/var/lib/narratio` |
|
||||
| `pipeline.workspace.cleanup_after_publish` | bool | No | `false`; selects the published run's workspace target for final cleanup and requires effective `pipeline.publish.enabled=true` and `pipeline.publish.upload_run=true` |
|
||||
| `pipeline.workspace.cleanup_after_publish` | bool | No | `false`; selects the session's entire run history for final cleanup and requires effective `pipeline.publish.enabled=true` and `pipeline.publish.upload_run=true` |
|
||||
| `pipeline.campaigns.root` | string | No | `/usr/local/share/narratio/campaigns` |
|
||||
| `pipeline.campaigns.default_campaign_id` | string | No | empty |
|
||||
| `pipeline.campaigns.session_template_file` | string | No | installation session template; built-in default when absent |
|
||||
|
||||
@@ -31,9 +31,10 @@ its pipeline and confined output directory, and validates each configured
|
||||
`lanes/<lane-id>.json` as a safe regular JSON file. It promotes those required
|
||||
lanes to flat session artifacts and records content evidence. The reported
|
||||
`artifact_count` can include reused or auxiliary results; it is not an inventory.
|
||||
Optional `chunk-map.json` and `evidence-context.json` stay with the retained
|
||||
original bundle. A positive native `fallback_count` remains visible in fresh and
|
||||
reused reports.
|
||||
Optional `chunk-map.json` and `evidence-context.json` stay in the original
|
||||
bundle, which is subject to Narratio cleanup. Selected canonical products and
|
||||
their recorded evidence support reuse without that bundle. A positive native
|
||||
`fallback_count` remains visible in fresh and reused reports.
|
||||
|
||||
Nonzero exit, malformed completion, unsafe output, or a missing required lane
|
||||
fails extraction. Diagnostics and available files remain for investigation; an
|
||||
|
||||
@@ -33,7 +33,7 @@ validator. The focused stage documents own their input/output flow;
|
||||
All formats are validated by strict source-policy rules. Configured artifact and
|
||||
extraction keys use `^[a-z][a-z0-9_]*$`; source parsers never normalize an
|
||||
unrecognized token into a valid source. Extraction sources are registered only
|
||||
from `pipeline.notarius.outputs`; the retained bundle is not a selectable
|
||||
from `pipeline.notarius.outputs`; the original bundle is not a selectable
|
||||
source.
|
||||
|
||||
Prepared stable source IDs are `narratio.input.players`,
|
||||
|
||||
@@ -15,11 +15,13 @@ sibling temporary file, validates the complete result, and passes that file to
|
||||
remote object selection, validation, conflict handling, and temporary-file
|
||||
cleanup.
|
||||
|
||||
Directory bundles are not promoted by `internal/fileops`; extraction retains
|
||||
the original bundle in its run and promotes individual validated products.
|
||||
Directory bundles are not promoted by `internal/fileops`; extraction keeps
|
||||
the original bundle in its run until cleanup and promotes individual validated
|
||||
products.
|
||||
|
||||
Managed latest-attempt links are updated and inspected by fileops. Cleanup uses
|
||||
those validated targets when retaining current diagnostics.
|
||||
Fileops updates, inspects and removes recognized managed latest-attempt links
|
||||
without following their targets, including dangling links. Unrelated entries are
|
||||
left alone and conflicting managed names are rejected.
|
||||
|
||||
## Cleanup Contract
|
||||
|
||||
|
||||
@@ -330,12 +330,11 @@ writes, or run-directory creation. Excluded prefix records are not passed to
|
||||
resume validators. Records after the selected end are not prerequisites and
|
||||
may be made stale by selected work without being scheduled.
|
||||
|
||||
After a publish commits remotely, any configured local cleanup is first recorded
|
||||
as a session-manifest obligation before deletion begins. Each target becomes
|
||||
complete only after its confined deletion (or safe absence check) and a
|
||||
successful manifest save. An incomplete obligation is retried when publish
|
||||
executes again and retains the committed run and remote identity that authorized
|
||||
it; an invocation that does not execute publish does not perform cleanup.
|
||||
Cleanup is an ordinary selected stage. It validates recorded successful
|
||||
publication evidence before deleting local run history, saves its normal stage
|
||||
transition, and retries incomplete work on a later selected invocation without
|
||||
republishing. Historical run-local paths in records are provenance, not a
|
||||
requirement that those files remain present. See [cleanup](stage-cleanup.md).
|
||||
|
||||
Each invocation derives campaign, session, run, local-path, and remote-prefix
|
||||
metadata from the validated resolved configuration as one projection. A persisted
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
# Stage: cleanup
|
||||
|
||||
## Purpose
|
||||
## Purpose And Authorization
|
||||
|
||||
Remove eligible run data only after a successful publish, according to the
|
||||
workspace cleanup policy. Explicit session cleanup is a separate operator action.
|
||||
|
||||
## Authorization And Targets
|
||||
|
||||
`workspace.cleanup_after_publish` enables automatic cleanup. It requires a
|
||||
succeeded upload and matching published run, commit, and pointer evidence.
|
||||
Cleanup confines deletion to that run and protects managed latest log/debug
|
||||
view targets and the original session-durable Notarius bundle. Subprocess state
|
||||
and caches are outside its scope.
|
||||
The final selected cleanup stage removes local run history after successful
|
||||
publication when `workspace.cleanup_after_publish` is enabled. It validates the
|
||||
published run, commit and pointer evidence and configured campaign/session
|
||||
identity. Explicit whole-session cleanup is a separate operator action.
|
||||
|
||||
## Execution And Resume
|
||||
|
||||
Cleanup is idempotent and retries failed deletion without republishing. Retained
|
||||
protected files are intentional and do not trigger endless cleanup. Bounded
|
||||
runs ending before cleanup do not execute it. See [operations](../operations.md#cleanup).
|
||||
Cleanup removes recognized managed stage and restore log/debug links without
|
||||
following them, then deletes the selected session's entire `runs/` directory
|
||||
through a confined workspace root. Missing runs and links are successful;
|
||||
unsafe paths and managed-name conflicts fail. Subprocess state, caches, durable
|
||||
session products and remote objects are outside its scope.
|
||||
|
||||
Resume inspects both the runs directory and managed views without mutation. An
|
||||
empty runs directory, a new attempt, or a dangling managed view requires cleanup
|
||||
again. Deletion is not transactional: a failure can leave partial progress and
|
||||
is recorded as a failed stage. A later selected cleanup retries without another
|
||||
publish. See [operations](../operations.md#cleanup).
|
||||
|
||||
## Implementation And Tests
|
||||
|
||||
`internal/stage/cleanup_plan.go`, `cleanup.go`, `internal/fileops/cleanup.go`
|
||||
and their tests own authorization, protected targets, and confined deletion.
|
||||
`internal/stage/cleanup_plan.go`, `cleanup.go`, `internal/fileops/cleanup.go`,
|
||||
`attempt_views.go`, and their tests own authorization, inspection, managed view
|
||||
removal and confined deletion.
|
||||
|
||||
@@ -17,12 +17,14 @@ successful native completion report for the expected pipeline and confined outpu
|
||||
directory. The stage reads each configured lane JSON, validates its safe path and
|
||||
content, then promotes all required products to flat artifact paths before
|
||||
recording success. The original bundle and optional domain auxiliaries stay in
|
||||
the producing run. Positive native fallback counts are recorded and reported.
|
||||
the producing run until authorized cleanup removes run history. Positive native
|
||||
fallback counts are recorded and reported.
|
||||
|
||||
## Resume Validation
|
||||
|
||||
Resume checks the direct transcript identity, configured pipeline and lane
|
||||
selection, reference identities, and manifest-backed output checksums and sizes.
|
||||
It does not reopen the original bundle or completion report.
|
||||
Cache and debug selection, executable version and private downstream config are
|
||||
not blanket invalidators. Force invokes extraction with cache refresh. A failed
|
||||
replacement is not represented as a current successful extraction.
|
||||
|
||||
@@ -64,7 +64,8 @@ supports remote loading when no authored session override is available. The
|
||||
- includes the four manifest-backed prepared glossary documents with their
|
||||
declared input identities for restore;
|
||||
- publishes extraction lanes only through explicit configured output rules;
|
||||
neither run-local nor durable Notarius bundles are scanned or uploaded wholesale.
|
||||
original Notarius bundles are not scanned or uploaded wholesale. Historical
|
||||
run-local references are not required for later publication.
|
||||
- selected artifact filter applies to configured artifact sources only.
|
||||
- plans every configured output into exactly one source-sorted outcome:
|
||||
`published`, `carried_locked`, `locked_unpublished`, `optional_missing`, or
|
||||
|
||||
@@ -35,14 +35,14 @@ into run-local output space.
|
||||
Polish and extraction write to actual run-local output, log, and debug paths.
|
||||
Each attempt advances managed relative `logs/<stage>` and `debug/<stage>` links;
|
||||
skips do not rotate them. Restore has its own diagnostic attempt. Extraction
|
||||
promotes validated lanes to flat artifacts and retains the original bundle in
|
||||
the producing run. See [Operations](../operations.md#local-state-layout).
|
||||
promotes validated lanes to flat artifacts; the original bundle remains in
|
||||
the producing run until cleanup. See [Operations](../operations.md#local-state-layout).
|
||||
|
||||
Prepared references delivered to Notarius use session-durable paths owned by
|
||||
`internal/artifacts` beneath
|
||||
`inputs/references/<sha256>/<prepared-basename>`. These verified
|
||||
content-addressed snapshots are outside run-local layout, survive ordinary
|
||||
published-run cleanup, and are excluded from publish and restore enumeration.
|
||||
session run-history cleanup, and are excluded from publish and restore enumeration.
|
||||
|
||||
## Locking
|
||||
|
||||
@@ -53,8 +53,8 @@ not evidence that a lock is active. Command and restore flows wait for this
|
||||
lock only while their context remains active, and report a release failure.
|
||||
|
||||
The runner assigns every invocation a run-workspace identity but creates the
|
||||
physical directory only before an executing stage that requires it. Fully
|
||||
reused invocations and cleanup-only invocations therefore do not accumulate
|
||||
physical run directory and its `runs/` parent only when an executing stage
|
||||
requires them. Fully reused invocations and cleanup-only invocations therefore do not accumulate
|
||||
empty run directories.
|
||||
|
||||
## Cleanup Semantics
|
||||
@@ -66,6 +66,7 @@ The canonical cleanup stage:
|
||||
ID, remote commit key, and current commit-pointer key;
|
||||
- consumes the resolved cleanup policy described in
|
||||
[Configuration](../config.md);
|
||||
- removes the entire session run history and recognized managed diagnostic views;
|
||||
- refuses unsafe deletes (root delete, traversal, and out-of-root targets);
|
||||
- treats missing targets as successful, idempotent deletion; and
|
||||
- uses its ordinary failed/succeeded manifest stage record for retry. A later
|
||||
|
||||
@@ -287,7 +287,7 @@ Choose the narrowest workflow that matches the intended replacement:
|
||||
|
||||
| Intent | Command | Preserved and rebuilt state |
|
||||
| --- | --- | --- |
|
||||
| Rebuild analysis only | [`narratio run 2026-04-04 --stage analyze --force`](./cli.md#run) | Preserves transcripts and the current extraction bundle; force-runs selected analysis artifacts and their required analysis prerequisites. |
|
||||
| Rebuild analysis only | [`narratio run 2026-04-04 --stage analyze --force`](./cli.md#run) | Preserves transcripts and current extraction products; force-runs selected analysis artifacts and their required analysis prerequisites. |
|
||||
| Rebuild extraction and analysis | [`narratio artifacts regenerate 2026-04-04`](./cli.md#artifacts-regenerate) | Preserves transcripts; force-runs the complete configured extraction bundle, then selected analysis. `--artifacts` narrows analysis only. |
|
||||
| Continue bounded work normally | [`narratio run 2026-04-04 --from extract --through analyze`](./cli.md#run) | Uses ordinary resume decisions: current extraction and analysis can be skipped, while incomplete or obsolete work runs. |
|
||||
|
||||
@@ -380,7 +380,7 @@ not create a separate workspace or retain a separate current extraction result.
|
||||
Narratio cannot observe edits inside Notarius configuration behind an unchanged
|
||||
selector. Force extraction after such an edit when a replacement is intended.
|
||||
Use `artifacts regenerate` when both extraction and analysis must be rebuilt;
|
||||
use `run SESSION --stage analyze --force` when the existing extraction bundle
|
||||
use `run SESSION --stage analyze --force` when the existing extraction products
|
||||
should be preserved. Field
|
||||
semantics belong in [Configuration](./config.md#notarius-configuration-overlay),
|
||||
with Audita selectors covered under
|
||||
@@ -419,8 +419,8 @@ The final trimmed transcript and content-identified snapshots under
|
||||
|
||||
Successful configured lanes become flat `artifacts/<name>.json` products and
|
||||
`narratio.extraction.<name>` sources. The original bundle remains under the
|
||||
producing run for evidence; it is not implicitly published. A failed replacement
|
||||
does not make the earlier extraction record current. Native fallback counts and
|
||||
producing run until authorized cleanup removes it; it is not implicitly
|
||||
published. A failed replacement does not make the earlier extraction record current. Native fallback counts and
|
||||
readiness warnings remain visible in command reports.
|
||||
|
||||
Narratio can reuse completed extraction without starting Notarius. When extraction
|
||||
@@ -486,7 +486,7 @@ Run-local diagnostics are:
|
||||
Audita reporting is enabled, alongside captured streams and invocation records
|
||||
- `runs/{run_id}/extract/logs/notarius.report.json`
|
||||
- `runs/{run_id}/extract/logs/notarius.stderr.log`
|
||||
- `runs/{run_id}/extract/notarius-output/` for retained original bundles
|
||||
- `runs/{run_id}/extract/notarius-output/` for original bundles until cleanup
|
||||
|
||||
The run upload is an allowlist derived from the session manifest's declared
|
||||
current-run outputs, logs, and generated configurations, not a workspace scan.
|
||||
@@ -495,7 +495,7 @@ declared source is opened without following symlinked ancestors or the leaf,
|
||||
verified as a regular file, and streamed from that verified descriptor.
|
||||
Unlisted files and unsafe entries are never uploaded; a run with no declared
|
||||
current-run diagnostics uploads no run-local files. No distinguished diagnostic
|
||||
file is uploaded. The durable bundle is never scanned for implicit publication;
|
||||
file is uploaded. The original bundle is never scanned for implicit publication;
|
||||
only lanes named by explicit `pipeline.publish.outputs` rules are uploaded.
|
||||
To inspect a published polish report remotely, read its declared object under
|
||||
the run archive's `polish/logs/` prefix. Session restore does
|
||||
@@ -673,8 +673,8 @@ reference snapshots live under `inputs/references/`.
|
||||
Each attempted stage writes actual logs and debug capture beneath its run.
|
||||
`logs/<stage>` and `debug/<stage>` are relative links to the latest attempt,
|
||||
including failed attempts; skipped work does not rotate them. Restore writes its
|
||||
own diagnostic attempt. Original Notarius bundles remain in the producing run.
|
||||
Automatic cleanup retains current view targets and session-durable bundle evidence.
|
||||
own diagnostic attempt. Original Notarius bundles remain in the producing run
|
||||
until authorized cleanup. The `runs/` directory is created on demand.
|
||||
|
||||
Remote audio is downloaded to a temporary sibling and verified before replacing
|
||||
its single prepared `audio/` copy. Restore follows the same layout. Subprocess
|
||||
@@ -727,10 +727,18 @@ Use `narratio session clean SESSION` to remove an entire local session, or
|
||||
`narratio session clean --all` for all local sessions. Add `--dry-run` to inspect
|
||||
planned targets. These commands do not delete subprocess caches or remote data.
|
||||
|
||||
Automatic run cleanup requires `workspace.cleanup_after_publish` and successful
|
||||
publication evidence. It preserves current log/debug targets and retained Notarius
|
||||
bundle evidence. A failed cleanup can be retried without republishing; bounded
|
||||
runs ending before cleanup do not execute it. See [cleanup internals](internal/stage-cleanup.md).
|
||||
Automatic cleanup requires `workspace.cleanup_after_publish=true` and successful
|
||||
publication evidence. When selected, it removes the entire session `runs/` tree,
|
||||
including older failures, restore attempts, probes, logs, debug captures, and
|
||||
original Notarius bundles. Managed stage and restore views are removed as well.
|
||||
Canonical products, prepared inputs, manifests, other sessions, subprocess
|
||||
state and caches, and remote objects remain. Set the option to `false` to keep
|
||||
run history and diagnostics.
|
||||
|
||||
A failed cleanup is reported and may have removed some files already. Retry the
|
||||
cleanup stage or a full run without republishing. Bounded runs ending before
|
||||
cleanup do not execute it; their new attempts remain until a later authorized
|
||||
cleanup. See [cleanup internals](internal/stage-cleanup.md).
|
||||
|
||||
## Operational Caveats
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ merely on incidental files existing on disk.
|
||||
|
||||
A failed or interrupted stage must not be presented as successful. Failure
|
||||
should preserve enough local state and diagnostics for inspection, recovery,
|
||||
and resume. Forcing a stage invalidates succeeded transitive dependents
|
||||
and resume until a later authorized cleanup. Forcing a stage invalidates
|
||||
succeeded transitive dependents
|
||||
according to a fixed application-owned relation that is separate from canonical
|
||||
execution order. The relation is validated against the stage inventory and is
|
||||
not configurable.
|
||||
@@ -264,9 +265,9 @@ transaction boundary.
|
||||
|
||||
Automatic local cleanup is permitted only after a successful publish commit,
|
||||
only when explicitly configured, and only through the path-safety guardrails.
|
||||
It is the final ordinary pipeline stage after `notify`. The stage derives its
|
||||
exact run-scoped targets from validated publish metadata and the configured
|
||||
campaign/session identity; it never infers a target from directory contents or
|
||||
It is the final ordinary pipeline stage after `notify`. The stage derives the
|
||||
selected session's run-history target from validated publish metadata and the
|
||||
configured campaign/session identity; it never infers a target from directory contents or
|
||||
rereads remote storage. A cleanup failure makes the invocation incomplete while
|
||||
leaving publish succeeded and the committed remote snapshot authoritative. A
|
||||
normal later full run reuses valid upstream stages and retries cleanup.
|
||||
@@ -305,9 +306,9 @@ Safe bootstrap diagnostics may identify files and statuses but never values. Dia
|
||||
prompt content unless a deliberate, bounded inspection mechanism requires it.
|
||||
|
||||
Logs, reports, generated invocation files, generated configuration, and render
|
||||
debug files are diagnostics, not canonical pipeline products. They should be
|
||||
durable and discoverable where configured, and manifest references must preserve
|
||||
the distinction between diagnostics and artifacts.
|
||||
debug files are diagnostics, not canonical pipeline products. They remain
|
||||
discoverable until configured cleanup removes their run history. Manifest
|
||||
references must preserve the distinction between diagnostics and artifacts.
|
||||
|
||||
Documentation security rules belong in the
|
||||
[Documentation Policy](documentation.md). Credential supply belongs in
|
||||
|
||||
@@ -36,6 +36,12 @@ in each URL with the intended tag:
|
||||
[COPYRIGHT](https://forge.maximumdirect.net/eric/narratio/src/tag/vMAJOR.MINOR.PATCH/COPYRIGHT) | [LICENSE](https://forge.maximumdirect.net/eric/narratio/src/tag/vMAJOR.MINOR.PATCH/LICENSE) | [ATTRIBUTION](https://forge.maximumdirect.net/eric/narratio/src/tag/vMAJOR.MINOR.PATCH/docs/oss/attribution.md)
|
||||
```
|
||||
|
||||
For the next release note, describe the cleanup retention change: when automatic
|
||||
cleanup is enabled and authorized, it removes the selected session's entire run
|
||||
history, including failed-attempt diagnostics and original Notarius bundles.
|
||||
Operators can retain that material by setting `workspace.cleanup_after_publish`
|
||||
to `false`.
|
||||
|
||||
Retire completed roadmaps as appropriate, preserve pending work, and review the
|
||||
candidate through the ordinary development workflow. Commit the candidate and
|
||||
push it to `origin/main`, then publish from the clean `main` checkout:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Durable Session Cleanup
|
||||
|
||||
Status: Proposed; not implemented.
|
||||
Status: Complete.
|
||||
|
||||
## Goal
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Durable Session Cleanup Implementation Plan
|
||||
|
||||
Status: Planned; implementation has not started.
|
||||
Status: Complete.
|
||||
|
||||
## Scope And Execution
|
||||
|
||||
@@ -301,7 +301,7 @@ without depending on historical run files or changing remote inventory semantics
|
||||
|
||||
## Stage 7: Align Documentation And Verify The Completed Sprint
|
||||
|
||||
Status: Pending.
|
||||
Status: Complete.
|
||||
|
||||
Read the affected canonical documents and the documentation policy. Update:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user