Complete safety and transfer remediation verification

This commit is contained in:
2026-12-01 20:47:59 +00:00
parent f59a53e31b
commit 75eddf8adc
27 changed files with 309 additions and 328 deletions

View File

@@ -11,11 +11,11 @@ directory, consolidated into **43 entries: one P1, twelve P2, and thirty P3**.
Every original finding belongs to one catalog entry. Original-entry links retain
the detailed code references, evidence, alternatives, and qualifications.
All entries are open in the source reports. This pass consolidates that recorded
state; it implements no remediation and makes no new runtime-defect claim.
The original source reports retain their historical open statuses and evidence.
The catalog records subsequent verified remediation without changing those reports.
Only audit documents changed between the first audit's code baseline and this
review's baseline. The original evidence therefore concerns the same application
code, but its limits still apply: source-established hazards are distinct from
code as it stood at the audit baseline; its limits still apply: source-established hazards are distinct from
dynamically reproduced failures, and green tests do not disprove unexercised
conditions.
@@ -41,7 +41,8 @@ their scope. Unless assigned otherwise, a finding remains independent audit
remediation. Shared code does not make a refactoring a prerequisite or assign
the whole finding to a roadmap.
All 43 findings remain open. **Planned** identifies an agreed remedy awaiting
Nine entries are closed by the safety and transfer remediation sprint; 34 remain
open. **Planned** identifies an agreed remedy awaiting
implementation. **Potentially eliminated** requires verification that the offending
lifecycle is removed. **Coordinate** identifies shared changes, not a commitment
that the roadmap implements the entire finding. Findings close only after their
@@ -57,8 +58,8 @@ Decisions on [audio generation/size handling](discussion.md#4-keep-downloaded-au
[subprocess completion](discussion.md#5-finish-subprocess-shutdown-before-releasing-its-files),
[publication source lifetimes](discussion.md#6-open-publication-sources-as-they-are-needed),
and [audio selection and naming](discussion.md#7-give-preparation-and-inspection-the-same-audio-selection-rules)
are agreed, with implementation pending. Topic 1 also records approved
cancellation-aware waiting for the workspace lock. Remote checkpoint timing and
are agreed; audio selection remains pending in its separate roadmap. Topic 1
records cancellation-aware workspace lock waiting, now implemented. Remote checkpoint timing and
failure handling are deferred, not decisions blocking publication import.
## Consolidation Decisions
@@ -93,23 +94,25 @@ and cleanup has a separate authorization/lifecycle. See the
### CAT-01 — P1: Coordinate whole-session deletion with active invocations
Status: Open
Status: Closed
**Closure.** The stable workspace lock and command wiring are covered by `internal/artifacts/local_test.go` and `internal/app/clean_lock_test.go`.
**Disposition / owner.** Independent locking remediation — the [agreed direction](discussion.md#1-coordinate-destructive-cleanup-with-other-work)
permits one workspace-wide lock. Restore will use that coordination, but the
[restore roadmap](../session-restore.md) does not own this fix. Cancellation-aware
waiting is agreed; implementation and verification remain pending.
waiting is implemented and verified.
Original findings: [CN-01](04-concurrency.md#cn-01--p1-whole-session-cleaning-bypasses-and-can-dismantle-session-exclusion),
[TE-04](08-testing.md#te-04--p2-whole-session-cleanup-tests-never-contend-with-an-active-invocation).
**Issue.** Manual `session clean` and `--all` bypass session locking and can
**Original issue.** Manual `session clean` and `--all` bypass session locking and can
delete the in-tree lock pathname while a run, restore, or preflight still holds
its inode. A new invocation can then lock a replacement inode and overlap the
original writer. Existing cleanup tests never combine manual deletion with an
active invocation.
**Direction.** Use a stable coordination identity or admission gate that survives
**Agreed remedy.** Use a stable coordination identity or admission gate that survives
deletion, including admission of new sessions during `--all`. Use
cancellation-aware waiting and identify the lock being waited on. Add real-lock,
controlled-interleaving coverage for deletion, a second contender, and cancellation
@@ -145,26 +148,30 @@ Related: [CAT-20](#cat-20--p3-share-typed-publication-control-evidence-across-pr
### CAT-03 — P2: Enforce non-forced session creation at the write boundary
Status: Open
Status: Closed
**Closure.** Exclusive local creation and conditional remote upload are covered by `internal/app/session_init_conflict_test.go`.
Original findings: [CN-02](04-concurrency.md#cn-02--p2-session-initializations-no-overwrite-check-is-not-atomic).
**Issue.** Local stat-then-write and remote Exists-then-unconditional-upload allow
**Original issue.** Local stat-then-write and remote Exists-then-unconditional-upload allow
concurrent `session init` calls to overwrite a destination without `--force`. Both
can report success; local writes can also truncate or mix content.
**Direction.** Use exclusive local creation and the existing remote absence
**Agreed remedy.** Use exclusive local creation and the existing remote absence
precondition for non-forced writes. Keep deliberate forced replacement separate
and test competing creators. A preliminary existence check may inform diagnostics
but cannot authorize the later write.
### CAT-04 — P2: Bind prepared S3 audio bytes to their observed generation
Status: Open
Status: Closed
**Closure.** Response-bound audio identity, replacement, reuse, and rollback are covered by `internal/audio/s3_audio.go` and `internal/stage/prepare_test.go`.
**Disposition / owner.** Independent audio-acquisition remediation — [discussion topic 4](discussion.md#4-keep-downloaded-audio-and-its-source-identity-together)
selects accepting the raw-audio generation actually downloaded; implementation
and verification remain pending. This is separate from the
selects accepting the raw-audio generation actually downloaded; this is implemented
and verified. This is separate from the
[audio-inputs roadmap's discovery changes](../audio-inputs.md#relationship-to-other-work).
The [restore roadmap](../session-restore.md)
relaxes generation-history requirements for imported products, not source identity
@@ -172,11 +179,11 @@ for local audio reuse.
Original findings: [CN-04](04-concurrency.md#cn-04--p2-s3-audio-provenance-can-combine-two-object-generations).
**Issue.** Preparation records listing metadata from generation A but can download
**Original issue.** Preparation records listing metadata from generation A but can download
same-sized generation B. Its checksum then describes B while source provenance
describes A, allowing incorrect reuse after a remote rollback.
**Direction.** Retain metadata from the same opened response as the streamed body.
**Agreed remedy.** Retain metadata from the same opened response as the streamed body.
Accept and record that observed raw-audio generation when the download passes
existing acquisition checks, even if it differs from the earlier listing.
Test replacement between listing and reading, including rollback/reuse. This
@@ -187,23 +194,25 @@ Related: [CAT-06](#cat-06--p2-stop-known-size-downloads-before-oversized-bodies-
### CAT-05 — P2: Retain subprocess and stream ownership through delayed completion
Status: Open
Status: Closed
**Closure.** Waiter joining and delayed output ownership are covered by `internal/adapters/subprocess/execution.go` and `execution_test.go`.
**Disposition / owner.** Independent subprocess remediation — [discussion topic 5](discussion.md#5-finish-subprocess-shutdown-before-releasing-its-files)
selects joining process/output completion after bounded termination escalation,
before releasing resources. Implementation and verification remain pending;
publication import does not remove downstream process ownership.
before releasing resources; this is implemented and verified. Publication import
does not remove downstream process ownership.
Original findings: [CN-03](04-concurrency.md#cn-03--p2-the-exceptional-subprocess-reap-timeout-releases-ownership-too-early),
[TE-05](08-testing.md#te-05--p2-subprocess-lifecycle-tests-do-not-exercise-a-delayed-reap-after-escalation).
**Issue.** The exceptional final reap timeout can return without receiving the
**Original issue.** The exceptional final reap timeout can return without receiving the
wait result. `ProcessState` inspection, redactor flushing, diagnostic closure, and
caller-owned result-file closure can then overlap a still-active waiter or stream
copier. Current tests exercise ordinary shutdown or pre-populated completion, not
delayed completion beyond escalation.
**Direction.** Retain bounded graceful-to-forceful escalation, then join process
**Agreed remedy.** Retain bounded graceful-to-forceful escalation, then join process
and output completion before reading process state, flushing/closing diagnostics,
or returning resource ownership to callers. Add a controlled delayed-wait/stream
test for release ordering and preserved error causes. Exceptional I/O delays can
@@ -212,22 +221,24 @@ ownership handoff is required.
### CAT-06 — P2: Stop known-size downloads before oversized bodies exhaust staging space
Status: Open
Status: Closed
**Closure.** Bounded response streaming and consumer regressions are covered by `internal/adapters/storage/stream_test.go`, `internal/app/restore_commit_test.go`, and `internal/stage/prepare_previous_test.go`.
**Disposition / owner.** Coordinate — the [restore roadmap](../session-restore.md#existing-restore-controls-remain-useful)
touches verified downloads. Transfer-size enforcement remains a separate audit
remediation across all listed callers. [Discussion topic 4](discussion.md#4-keep-downloaded-audio-and-its-source-identity-together)
approves bounded known-size streaming with existing unknown-size behavior;
implementation and verification remain pending.
approves bounded known-size streaming with existing unknown-size behavior; this
is implemented and verified.
Original findings: [RS-02](05-resources.md#rs-02--p2-known-size-downloads-consume-the-full-response-before-rejecting-oversize).
**Issue.** Restore, previous-input hydration, S3 audio, and immutable-object
**Original issue.** Restore, previous-input hydration, S3 audio, and immutable-object
verification can know the expected size yet copy the entire body before rejecting
oversize. Invalid responses can fill temporary storage and hold the session lock
unnecessarily.
**Direction.** Enforce the existing known size during transfer, with correlated
**Agreed remedy.** Enforce the existing known size during transfer, with correlated
response metadata and size-plus-one detection, then close/remove failed staging.
Retain checksum/generation checks and installation ordering. Test early rejection
and destination preservation; a declared zero size is known. Unknown-size audio
@@ -237,7 +248,9 @@ Related: [CAT-04](#cat-04--p2-bind-prepared-s3-audio-bytes-to-their-observed-gen
### CAT-07 — P2: Correct recovery instructions that publish before inspection
Status: Open
Status: Closed
**Closure.** Inspection-first regeneration and the mutating retry are corrected in `docs/troubleshooting.md`; documentation checks pass.
**Disposition / owner.** Coordinate documentation — the [restore roadmap](../session-restore.md#align-policies-and-canonical-documentation)
changes recovery guidance. Explicitly verify the inspection-before-publication
@@ -245,12 +258,12 @@ sequence; a restore documentation rewrite alone does not close this finding.
Original findings: [DOC-01](13-documentation.md#doc-01--p2-recovery-examples-publish-before-the-stated-inspection-step).
**Issue.** Troubleshooting's unsupported-manifest recovery invokes a full run,
**Original issue.** Troubleshooting's unsupported-manifest recovery invokes a full run,
then force publish, while describing inspection before explicit publication. The
first command can already publish and run authorized cleanup. A separate
diagnostics block also includes a mutating forced publish.
**Direction.** For inspection-first recovery, bound regeneration through analyze,
**Agreed remedy.** For inspection-first recovery, bound regeneration through analyze,
inspect, and then publish. Alternatively, describe the full run's
publication/cleanup effects accurately. Move publication retries out of the
inspection-only diagnostics sequence. This is a documentation correction, not a
@@ -258,7 +271,9 @@ new command confirmation or publication restriction.
### CAT-08 — P2: Stream local audio copies instead of buffering whole recordings
Status: Open
Status: Closed
**Closure.** Streaming atomic input copying and replacement behavior are covered by `internal/stage/prepare.go` and `prepare_copy_test.go`.
**Disposition / owner.** Independent copy-resource remediation — coordinate with the
[audio-inputs roadmap](../audio-inputs.md#reuse-and-transport-verification), which
@@ -266,11 +281,11 @@ reuses the copy path. Multi-format discovery does not remove whole-file bufferin
Original findings: [EF-01](02-efficiency.md#ef-01--p2-local-audio-copying-buffers-the-complete-recording).
**Issue.** The changed/missing local-copy path hashes a recording, reads all its
**Original issue.** The changed/missing local-copy path hashes a recording, reads all its
bytes into memory, then writes them atomically. One large speaker file therefore
requires recording-sized auxiliary RAM despite sequential processing.
**Direction.** Use the existing streaming artifact/file-copy mechanism while
**Agreed remedy.** Use the existing streaming artifact/file-copy mechanism while
preserving unchanged-destination checks, naming, workspace modes, atomic
visibility, and recorded checksums. The improvement is O(1) auxiliary buffering
relative to file size, not asymptotically faster I/O. No new audio-size limit is
@@ -278,24 +293,25 @@ required.
### CAT-09 — P2: Bound publication's simultaneously open source descriptors
Status: Open
Status: Closed
**Closure.** Sequential confined source transfers, same-handle uploads, and pointer preservation are covered by `internal/stage/publish_transfer.go` and `publish_lifetime_test.go`.
**Disposition / owner.** Independent publication-resource remediation — coordinate with the
[roadmap's snapshot removal](../session-restore.md#decouple-remote-discovery-from-execution-snapshots).
Removing one manifest source does not bound the remaining descriptors;
[discussion topic 6](discussion.md#6-open-publication-sources-as-they-are-needed)
selects sequential source opening, verification, upload, and closure, accepting
late-source failure after unselected uploads. Implementation and verification
remain pending.
late-source failure after unselected uploads. This is implemented and verified.
Original findings: [RS-01](05-resources.md#rs-01--p2-publication-retains-one-open-descriptor-per-source).
**Issue.** Publication retains descriptors for every run file, previous-cache
**Original issue.** Publication retains descriptors for every run file, previous-cache
source, selected output, and committed manifest until its final defer, although
uploads are sequential. Valid larger inventories can exhaust lower process
descriptor limits before transfer begins.
**Direction.** Plan identities, destinations, and rules upfront; then open,
**Agreed remedy.** Plan identities, destinations, and rules upfront; then open,
verify, upload, and close sources one at a time. Preserve confined regular-file
opening, checksum checks, and hashing/uploading through the same descriptor.
Validating every source before any upload is no longer required. A late invalid
@@ -333,16 +349,18 @@ Related: [CAT-17](#cat-17--p3-centralize-configured-artifact-dependency-queries)
### CAT-11 — P2: Verify the bytes supplied to the production S3 upload adapter
Status: Open
Status: Closed
**Closure.** SDK-boundary upload bytes and reader failures are covered by `internal/adapters/storage/s3_backend_test.go`.
Original findings: [TE-01](08-testing.md#te-01--p2-s3-upload-tests-do-not-verify-the-transmitted-content).
**Issue.** The SDK fake records upload requests without consuming their bodies.
**Original issue.** The SDK fake records upload requests without consuming their bodies.
Replacing the production body with unrelated fixed bytes survived the full suite;
higher-level storage fakes bypass that mapping. This is a demonstrated protection
gap, not a finding that the unmodified adapter sends wrong bytes.
**Direction.** Consume and compare upload bytes in the narrow SDK fake for file
**Agreed remedy.** Consume and compare upload bytes in the narrow SDK fake for file
and conditional-reader uploads, retaining key/precondition assertions and
appropriate stream-error coverage. A local HTTP SDK test is an alternative; live
S3 is unnecessary.
@@ -887,7 +905,7 @@ behavior and wrapper variants survive only through unit tests.
**Direction.** Use one live directory validation path and remove the forwarded
mode, file-only branch, and obsolete wrappers/tests. Preserve confinement,
symlink/root/traversal checks, dry runs, missing targets, and deletion scope. This
simplification does not fix the separate active-session lock hazard.
simplification is separate from the workspace-lock remediation in CAT-01.
Related: [CAT-01](#cat-01--p1-coordinate-whole-session-deletion-with-active-invocations).

View File

@@ -1,6 +1,6 @@
# Safety and Transfer Remediation Implementation Plan
Status: Ready for implementation
Status: Complete
Baseline: `074fe64e12d1b52a5d709469f4bced99be8740d8`.
@@ -422,6 +422,10 @@ claim they are fixed merely by closing descriptors sooner.
## Stage 12: Verify the sprint end state and reconcile the audit catalog
**Complete:** All nine scoped outcomes were reviewed and their catalog entries
closed. Go 1.27.4 tests, race tests, vet, build, and diff checks pass; the
remaining audit entries and deferred roadmaps remain open.
Read this plan's scope table and affected canonical documentation. Use each
original finding's focused evidence section when checking closure.