Files
narratio/docs/roadmap/remediation.md

92 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Safety and Transfer Sprint Review
Reviewed implementation: `75eddf8adcdd23e2dd7a95acc56eab9d36445655`.
Comparison baseline: `a92a117`.
## Required Remediation
### R1 — P3: Identify workspace-lock contention while the command waits
Status: Complete
**Resolution.** All four application acquisition paths use a shared helper that
reports the workspace lock path at progress visibility before waiting. Existing
locking, cancellation, and quiet-mode behavior remain unchanged.
`TestCleanReportsWorkspaceLockBeforeWaiting` captures native CLI diagnostics
while a real lock is held, observes contention, then verifies cancellation and
absence of managed-state mutation. The test enables native `--progress` visibility.
Remediation verification passed: `go test ./...`, uncached race-enabled lock and
command regression tests, `go vet ./internal/app`, and documentation/diff checks
with Go 1.27.4.
Plan: [Stage 2](implementation.md#stage-2-introduce-one-stable-workspace-lock),
item 3, and the command wiring in Stage 3. The approved behavior includes
identifying the waited-on lock through existing diagnostics.
**Original review evidence.** `AcquireWorkspaceLockContext` in
[local.go](../../internal/artifacts/local.go), lines 202–224, retries contention
silently. The workspace path is included only when cancellation returns an error.
The callers in [runner.go](../../internal/app/runner.go), lines 67–69,
[clean_command.go](../../internal/app/clean_command.go), lines 88–94,
[restore_command.go](../../internal/app/restore_command.go), and managed
initialization likewise enter the wait without reporting it. Existing lock tests
verify exclusion and cancellation, but do not verify a diagnostic during the wait.
This is established from source; exclusion itself is implemented correctly.
**Impact.** A mutating invocation can wait indefinitely with no indication that
it is queued behind another invocation or which workspace lock is responsible.
Workspace-wide serialization makes this relevant even when the two commands
target different sessions. Cancelling reveals the path too late to explain an
ongoing wait.
**Required outcome.** Use the existing operator reporting mechanism to identify
workspace lock acquisition/waiting before the blocking wait completes. Keep the
shared coordination semantics and cancellation causes. One concise acquisition
or contention diagnostic is sufficient; no polling log stream, new command
option, fairness rule, or lock-holder inspection subsystem is needed.
**Verification.** Hold a real workspace lock, start a contending command with
captured diagnostics, and verify the lock path is reported while the holder
still owns it. Then cancel the waiter and verify cancellation and absence of
managed-state mutation. Coordinate the observation with a barrier or reporter
signal rather than asserting exact message wording or elapsed time.
## Stage-by-Stage Assessment
| Stage | Review result |
| --- | --- |
| 1 | SDK upload tests consume and compare payload bytes; recovery instructions bound regeneration before publication. |
| 2 | Stable workspace lock, cancellation, independent roots, and persistent coordination identity implemented; R1 now supplies acquisition diagnostics. |
| 3 | Runner layout, preflight, mutating restore, manual cleanup, and managed initialization use the shared gate and report lock acquisition. |
| 4 | Exclusive local creation and provider-conditioned remote creation enforce non-forced conflicts at the write boundary. |
| 5 | Subprocess shutdown joins waiter/output completion before returning ownership, with delayed-completion regressions. |
| 6 | Shared response-bound streaming enforces known sizes, preserves unknown-size operation, closes responses, and retains failure causes. |
| 7 | Audio materialization records the downloaded response identity; replacement, reuse, and rollback tests cover the intended behavior. |
| 8 | Restore, previous-input hydration, and immutable verification use bounded streams with consumer-level oversized-response tests. |
| 9 | Changed local copies use existing atomic streaming and installed-byte checksums. |
| 10 | Publication mapping uses confined source descriptors rather than retaining all open handles. |
| 11 | Sources are transferred and closed sequentially; same-handle use, late failure, and pointer-last selection remain protected. |
| 12 | Original audit reports remain unchanged and only the nine scoped catalog entries are closed; R1 follow-through is complete. |
No additional correctness defect or inadvertently strengthened requirement was
identified in this sprint's scope. Workspace serialization, delayed shutdown
completion, and late publication-source failure follow the operator's approved
choices. Session-restore redesign, multi-format discovery, and the remaining
catalog findings remain separate pending work.
## Verification Performed
Passed with Go 1.27.4:
- `go test ./...`;
- `go test -race -count=1 ./...`;
- `go vet ./...`;
- `go build ./...`;
- uncached focused tests for storage, artifacts, audio, stages, subprocesses, and
documentation; and
- `git diff --check`.
Those checks describe the original review. The remediation adds the shared
acquisition diagnostic and command-level regression above; focused verification
is recorded with the fixing commit. No live external services were invoked.