Document the shared pipeline and verify the cutover

This commit is contained in:
2026-11-30 02:40:17 +00:00
parent 706c1bb7ad
commit 2ec43305da
30 changed files with 394 additions and 866 deletions

View File

@@ -2,53 +2,24 @@
## Purpose
Remove explicitly configured local data for the run selected by a successful
publish commit. Cleanup is the twelfth and final canonical stage, after
`notify`.
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
Cleanup is disabled unless at least one of these policies is true:
- `pipeline.spool.delete_audio_after_publish`
- `pipeline.workspace.cleanup_after_publish`
An enabled cleanup requires the manifest's publish stage to be succeeded with
`uploaded=true`, a canonical `published_run_id`, and the exact remote commit and
current commit-pointer keys for the manifest campaign/session prefix. The
configured campaign and session must match the manifest. Cleanup derives its
only possible targets through the canonical artifact path helpers:
- the published run's session spool-audio directory; and
- the published run's workspace run directory.
It does not scan parent directories, infer the newest run, or read object
storage. Every deletion uses the root-confined file operation, which rejects a
root itself, traversal, symlink escape, and out-of-root 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.
## Execution And Resume
Disabled cleanup records an explicit skipped result. Enabled cleanup removes
targets in deterministic policy order and treats an already-missing target as
success. A successful record contains the published run ID and completed policy
names.
A previous cleanup success is reusable only while its semantic configuration
matches and every selected target remains absent. A recreated target makes the
stage non-resumable. A failure is recorded against cleanup; publish remains
succeeded and remote current state is unchanged. On a later normal full run,
valid upstream stages are skipped and cleanup is retried without republishing.
`narratio run SESSION --stage publish` selects publish only and never invokes cleanup. A bounded run
through `notify` or any earlier endpoint also excludes it. Operators may run
`narratio run <session_id> --stage cleanup` directly; missing, failed, malformed,
or identity-mismatched publication evidence fails before deletion.
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).
## Implementation And Tests
- Planning and evidence validation: `internal/stage/cleanup_plan.go`
- Execution and resume: `internal/stage/cleanup.go`
- Root-confined deletion: `internal/fileops/cleanup.go`
- Focused tests: `internal/stage/cleanup_plan_test.go`,
`internal/stage/cleanup_test.go`, and
`internal/app/cleanup_orchestration_test.go`
`internal/stage/cleanup_plan.go`, `cleanup.go`, `internal/fileops/cleanup.go`
and their tests own authorization, protected targets, and confined deletion.