Coordinate workspace cleanup with active operations

This commit is contained in:
2026-12-01 20:17:27 +00:00
parent 038105ece9
commit 9e3fc25fdd
15 changed files with 358 additions and 32 deletions

View File

@@ -52,7 +52,7 @@ Planner behavior:
directories, symlinks, and other non-regular targets remain conflicts.
For a non-dry-run restore, planning/classification happens only after acquiring
the session lock. Runner manifest/reuse checks acquire that same lock first.
the workspace lock. Runner manifest/reuse checks acquire that same lock first.
Previous-cache readiness is resolved through `previouscache.Resolve` for restore,
prepare, status, and validation. Each requirement selects the unique

View File

@@ -27,14 +27,14 @@ canonical stage sequence through adapter interfaces, while manifests record
progress and artifact services resolve durable inputs and outputs.
The pipeline runner follows one explicit invocation lifecycle: inspect bounded
prerequisites without mutation, prepare the workspace layout, acquire one
session lock, load or create the authoritative session manifest, complete or
prerequisites without mutation, acquire the workspace lock, prepare the workspace
layout, load or create the authoritative session manifest, complete or
reuse selected preparation, check projected downstream work, compose only the
collaborators needed by selected work, execute each selected stage in order, finalize terminal state, release resources, and return a possibly partial
summary with preserved failure causes. Narrow terminal local persistence detaches
cancellation; active work retains the canceled operation context. Cleanup, when
selected, is the ordinary final stage rather than runner finalization work.
The lock remains held from manifest initialization through finalization, and a
The lock remains held from layout preparation through finalization, and a
failed stage or required manifest save prevents later stages from starting.
Standalone preflight shares that lifecycle, runs only preparation, and checks
enabled capabilities while holding the same lock.
@@ -44,7 +44,7 @@ enabled capabilities while holding the same lock.
| Area | Implemented owners | Responsibility |
| --- | --- | --- |
| Executable | `cmd/narratio` | Process entry, standard stream wiring, argument handoff, and exit status. |
| Application orchestration | `internal/app` | Native CommandKit declarations/reporting, lazy configuration selection, secret-file environment loading, production composition, session locking, planning, execution, restore, and user-facing reporting. |
| Application orchestration | `internal/app` | Native CommandKit declarations/reporting, lazy configuration selection, secret-file environment loading, production composition, workspace locking, planning, execution, restore, and user-facing reporting. |
| Configuration | [`internal/config`](configuration.md) | Typed ConfigKit results and lifecycle defaults, imports/overlays, canonical party loading, separate catalog/player/publication derivation, session templating, and validation. |
| Pipeline stages | `internal/stage` | Canonical stage registry, shared stage contract, execution dependencies, and implemented stage behavior. |
| Glossaries | `internal/glossary` | Native vocabulary resolution, schema validation, party projection, and deterministic documents. |

View File

@@ -37,7 +37,7 @@ discovery, and discovery issues produce warnings. Findings survive independent
failures and cancellation stops new work.
Probe files use invocation-scoped destinations under `runs/`, protected by the
session lock through report consumption, reference verification, and terminal
workspace lock through report consumption, reference verification, and terminal
persistence. A later authorized cleanup can remove those files without removing
durable prepared inputs. See [workspace internals](workspace.md),
[CLI](../cli.md#preflight), and [operations](../operations.md#prompt-requirements-preflight).

View File

@@ -46,11 +46,14 @@ session run-history cleanup, and are excluded from publish and restore enumerati
## Locking
`artifacts.LocalStore` enforces the single-writer session lock via an
operating-system lock held on `.lock` (`ErrLockConflict` on contention). The
`artifacts.LocalStore` enforces single-writer workspace access via an
operating-system lock held on `<workspace.root>/.lock` (`ErrLockConflict` on contention). The
file retains owner metadata after release or process death; its existence is
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.
not evidence that a lock is active. Runs, preflight, mutating restore, and
manual cleanup acquire it before creating or changing managed session state.
Initialization targeting managed work also acquires it. They wait only while
their context remains active and report a release failure. Read-only inspection
and dry runs do not acquire it; separate workspaces remain independent.
Standalone preflight holds the same lock through preparation, readiness probes,
and finalization, keeping active probe files outside concurrent cleanup.
Preparation uses ordinary manifest transitions and invalidation.