21 KiB
Audit Remediation Discussion
Status: Discussion in progress
Purpose
Work through the seven topics raised in the catalog review before preparing a remediation roadmap. Section numbers match that review and the operator's responses. They are discussion topics, not implementation stages or catalog IDs.
The catalog remains the findings inventory. Its original audit links own the detailed evidence. This document records decisions, explains consequences, and distinguishes recommendations from approved scope. No remediation has been implemented by this document.
The operator has settled the main direction for topics 1, 2, 3, and 4. Topics 5, 6, and 7 need discussion. Each open topic ends with a question and space for a response. Implementation details can be settled during planning after the operator-facing behavior is clear.
1. Coordinate destructive cleanup with other work
Status: Simplified locking direction agreed; contention behavior proposed
Finding: CAT-01.
What goes wrong today
A run holds a lock inside its session directory. Manual whole-session cleanup can delete that directory, including the lock's filename, while the run is still active. Another run can create a replacement lock file and start working against the same paths. The first process still owns its original lock, but it no longer coordinates access to the replacement file.
The final pipeline cleanup stage is different: it already runs under invocation locking and preserves the session root.
Agreed direction
Concurrent sessions are not a goal or known use case. Use one workspace-wide lock if that is the simplest design. Serializing work on different sessions is acceptable. A shared/exclusive admission hierarchy and per-session concurrency are unnecessary for this scope.
The coordination file must survive the directory deletions it protects. All participating operations must use the same identity, including whole-workspace session cleanup and creation of a new session's working state. This is local process coordination for a workspace, not a distributed lock across machines.
Remaining recommendation
Use cancellation-aware waiting, consistent with existing invocation locking, and identify the lock being waited on. An immediate busy error is a viable alternative if the operator prefers to retry manually. Waiting is a recommendation, not an already approved behavior.
The roadmap should identify the mutating command participants explicitly. Pure inspection and unrelated workspaces need no new serialization requirement.
Operator response:
Optional: confirm waiting or prefer an immediate busy error.
2. Import published artifacts and retain local resume
Status: Scope agreed; remote execution checkpoints deferred
Finding: CAT-02.
Separate publication from execution recovery
Publication and remote execution recovery are independent capabilities:
- Store completed artifacts for publication and later use. Publication locks preserve selected published files.
- Store execution checkpoints so a saved session can later be restored and resumed, retaining its manifest, fingerprints, and applicable provenance.
The operator has selected publication import for this development scope and deferred remote execution checkpoints. Local execution checkpoints and ordinary resume remain supported.
The current session manifest is Narratio's local progress ledger. It records completed work and evidence used to decide whether that work can be reused. The remote publication commit separately identifies published files. The current restore flow combines these records in a way that can mix different generations.
Concrete example
- Generate transcript A and publish it.
- Lock the published transcript because A is the distributed, canonical copy.
- Regenerate locally, producing transcript B. The local manifest describes B.
- Publish again. The lock correctly keeps A in the remote publication.
- Restore that publication into an empty workspace.
The audit reproduced this result:
| Item | Restored value |
|---|---|
| Transcript file | A |
| Manifest's recorded transcript checksum | Checksum of B |
| Manifest's completion evidence | Generation B |
| Restore command | Reports success |
| Subsequent normal transcript resolution | Rejects the checksum mismatch |
The lock correctly retained A. The failure comes from combining publication's A with execution's manifest describing B.
Agreed direction: published artifacts
Published artifacts are finished products available for consumption. They can be imported as inputs to a subsequent session or a fresh run of the same session.
Publication import uses file identity and location to select the requested product. Transfer-integrity checks, such as verifying downloaded bytes against a checksum, are separate from generation history.
Generation fingerprints, historical inputs, prompts, models, settings, and generation provenance are irrelevant to using these published products. Import does not require reconstructing historical completion records or evaluating whether the original producer would be reusable under today's configuration. An imported artifact is a supplied input; it does not assert that its producer executed in the receiving workspace.
Published products may come from different generations. This direction adds no requirement for a publication-wide coherent pipeline generation.
Agreed operator workflows
The immediate scope supports three distinct workflows:
- Start from original sources: supply campaign/session configuration and raw audio in a fresh workspace, then generate transcripts and artifacts.
- Start from published products: select and import finished transcripts or artifacts as supplied inputs, then execute the downstream work that consumes them. This starts new execution rather than recovering historical execution.
- Continue local work: rerun against the existing workspace and use its local manifest and files to retain completed speaker/artifact work and retry unfinished work under normal resume checks.
For the failed-transcription example, the existing local workspace already preserves completed speaker work. Remote backup is unnecessary for that ordinary retry. Recovering unpublished progress after workspace loss or moving execution to another machine is a separate capability without an established immediate operational need.
The import workflow is a real gap. Previous-session published-artifact consumption already exists, but starting a fresh same-session execution from a published transcript needs explicit support. Current bounded starts require preceding manifest stage records; copying files into place and selecting a downstream range does not provide the agreed workflow. Imported inputs should enable their consuming work without inventing upstream stage-completion history.
In the A/B example, publication import retrieves A and makes it usable as a supplied input. The local workspace containing B can continue independently through normal local resume. Recovering B's execution after losing that workspace is deferred.
Consequences for remediation
Use the publication inventory to select imported products and verify their transfer, independently of a remotely saved execution manifest. The earlier proposal to reconstruct historical producer evidence for publication import is superseded by this decision.
Current remote-state loading, restore, status, and previous-session acquisition depend on the uploaded session-manifest snapshot. The roadmap should remove that coupling for publication consumption and review which snapshot-publication and execution-recovery machinery becomes unnecessary. Preserve the configuration inputs needed for the selected workflow. Previous-session artifact selection already uses the publication inventory and should follow the import semantics above.
Physical layout, command syntax, and storage formats remain implementation-planning matters. This discussion does not select a new CLI or treat the current mixed restore behavior as the target contract.
This decision preserves local execution checkpoints and normal resume behavior. It adds no requirement for publication imports to carry or satisfy the original producer's fingerprints or generation provenance.
Deferred capability: remote execution checkpoints
Remote checkpoint upload and recovery are outside the immediate scope. Upload timing, cancellation behavior, transfer-failure handling, and retry machinery are therefore deferred rather than open decisions blocking this remediation.
If a future operational need warrants remote checkpoints, design that recovery workflow separately from publication import. A resumable checkpoint would need the saved execution ledger and matching files, with ordinary resume validation; a publication lock could not substitute an older product for a checkpoint output.
Operator response:
Approved: defer remote execution checkpoints, retain local resume, and focus on importing published artifacts.
3. Inspect S3 when planning and preflighting
Status: Read-only S3 checks agreed
Finding: CAT-13.
What goes wrong today
Execution can compare current S3 audio identities with preparation's recorded identities. The planning projection omits that storage collaborator and can translate its absence into "inputs changed." It can therefore predict work that execution would correctly reuse.
Agreed direction
Planning should make a read-only S3 check. Preflight should make the relevant read-only S3 check as well. Use existing storage capabilities and share the identity interpretation with execution where practical.
The S3 identity check is read-only. This decision does not redefine the entire preflight command as read-only. The current preflight workflow prepares or reuses inputs, may download files and update the manifest, and checks downstream providers. Preserve those responsibilities unless separately changed.
Follow-through for the roadmap
Verify which S3 checks preflight already performs through preparation and reuse that work rather than adding redundant calls. Observe unchanged, changed, and unavailable sources through both commands. An access or connectivity failure should be identified as such rather than reported as proven content change. Use existing command failure/reporting conventions where they fit. The lookup does not guarantee that S3 remains unchanged between planning and execution.
Operator response:
Read-only S3 checks approved; no further product choice identified here.
4. Keep downloaded audio and its source identity together
Status: Both decisions agreed; implementation pending
Concrete example
Narratio lists a speaker recording in S3 and sees version A. Before the download, an ordinary uploader replaces that key with version B of the same size. Narratio downloads B but records A's listed source identity alongside B's checksum.
If S3 later contains A again, Narratio can conclude that its local copy is current: the remote identity matches the recorded A identity, and the local bytes match the recorded B checksum. Both checks pass individually, but they describe different versions. Narratio can reuse the wrong recording.
Here "version" means an observed object generation/identity; this does not require enabling S3 bucket versioning. The existing read operation already provides metadata associated with the returned body. The audio download path currently loses that association.
Agreed direction: audio source identity
Use the metadata returned with the actual download as the identity of the bytes accepted. If B is a valid recording satisfying the acquisition rules, record B and continue. This accommodates ordinary uploads without claiming that the earlier directory listing froze all the session's audio.
If the observed response cannot satisfy the applicable checks, fail clearly. The earlier listing does not require rejecting an otherwise acceptable replacement. This adds no automatic retry-until-stable loop or session-wide snapshot protocol.
Agreed direction: known-size transfers
Restore and other downloads already reject content that differs from a known expected size, but only after writing the complete response. Stop an oversized response during transfer instead. This applies an existing acceptance condition earlier; it introduces no universal maximum recording size.
Use a bounded streaming transfer: for an expected N bytes, reading at most N plus one byte distinguishes an exact-sized response from an oversized one. Retain existing short-response and checksum validation. On failure, close the response, remove partial staging, preserve the canonical destination, and identify the responsible transfer and expected size in the error.
For committed products, the committed size is authoritative. If audio adopts B instead of A, the response identity and size boundary must both describe B. The byte count remains checked rather than trusting response metadata alone. Unknown-size input retains its existing behavior and remains distinct from a known zero-byte declaration. The change does not reserve disk space or prevent every disk-full condition.
For raw audio, the observed download supplies the accepted identity. For published products, the selected publication inventory supplies the expected identity; different content is rejected rather than silently adopted. Transfer verification is separate from historical generation provenance for imported products.
Operator response:
Approved: accept and record the raw-audio generation actually downloaded, using metadata from the same response; enforce known expected sizes while streaming, without a universal audio-size cap. Both findings remain open pending implementation and verification.
5. Finish subprocess shutdown before releasing its files
Status: Open
Finding: CAT-05.
What goes wrong today
When a downstream command times out or is cancelled, Narratio requests graceful termination and then forceful termination. A separate waiter observes process exit and completion of output copying.
On an exceptional path, the final wait timer expires before that waiter finishes. Narratio can return an error and start closing log or result files while the waiter or output copier still uses them. Issuing a kill request is not the same as observing completion of every resource user.
The audit established this ordering from source. It did not reproduce a dynamic race. Normal cancellation and subprocess tests passed.
Recommendation
Keep the bounded graceful-to-forceful escalation, then join process/output completion before releasing the associated resources or returning their ownership to callers. Exercise the delayed-completion branch with a controlled test.
Ordinary cancellation should still terminate promptly. In an exceptional blocked filesystem write or kernel operation, resource completion can take longer than the escalation windows. There is no straightforward absolute return-time guarantee for arbitrary blocked I/O.
Viable alternative
Return before completion using an explicit ownership handoff. A remaining supervisor would have to own every resource still in use, including output destinations normally owned by the caller. This is more complex than starting a background waiter and is justified only if returning promptly despite unfinished I/O is an actual operational requirement.
Question for discussion
Is it acceptable to wait for safe resource completion after forceful termination, even when exceptional blocked I/O outlasts the escalation timers? I recommend yes, with accurately scoped timeout documentation.
Operator response:
Pending discussion.
6. Open publication sources as they are needed
Status: Open
Finding: CAT-09.
What goes wrong today
Publication opens every selected local source before uploading and keeps all those handles open until the stage ends. Each open file consumes an operating system descriptor. A large inventory can exhaust that resource even though uploads occur one at a time. Closing the handles at the end prevents an ordinary leak but does not prevent excessive simultaneous use.
The audit established this scaling from source; it did not reproduce exhaustion or establish a failure threshold for a production deployment.
Why the current approach exists
Opening and validating sources up front catches invalid sources before uploading. Retaining a verified handle also avoids substituting a later pathname lookup for the file that was checked. Those are separate concerns from retaining every handle throughout the entire attempt.
Remote publication becomes current only when the final pointer is updated. An earlier failure may already leave immutable uploads that were never selected as current. Preserving the old current pointer is the important existing commit boundary; failure does not promise that no remote bytes were uploaded.
Recommendation
Keep complete destination planning, then open, verify, upload, and close each source using a bounded number of handles. Retain confinement and regular-file checks and use the verified handle for the transfer. Accept that a later invalid source may be discovered after earlier immutable uploads, while leaving the previous current publication selected.
This relaxes the documented all-sources-rejected-before-upload behavior. Record that relaxation expressly if approved. It adds no artifact-count cap and requires no copies of every source solely to pin its original generation.
Viable alternatives
- Run a bounded upfront validation pass, then reopen and revalidate sources for transfer. This preserves early detection of initially invalid sources but adds work; later changes can still fail during transfer.
- Make verified disk-backed snapshots before uploading. This can preserve stronger source pinning with fewer descriptors, at the cost of disk space, I/O, and temporary-file management. No known use case currently establishes that need.
Question for discussion
May publication discover an invalid later source after earlier immutable uploads, provided it leaves the previous publication current? I recommend yes and a simple one-source-at-a-time transfer lifecycle.
Operator response:
Pending discussion.
7. Give preparation and inspection the same audio selection rules
Status: Open
Finding: CAT-12.
Concrete example
The operator selects first/speaker.flac and second/speaker.flac. Preparation
accepts these distinct recordings and gives the prepared copies distinct names.
Inspection rejects them because their basenames match. A status command can
therefore report unavailable audio for a session preparation can process.
The duplicate implementations also differ on selecting the exact same file twice and on file eligibility. Preparation's initial file check rejects directories; inspection requires a regular file. A named pipe or device can pass the former check but fail the latter. The audit does not establish successful end-to-end support for those non-regular sources.
Recommendation
Share read-only selection rules. Accept distinct local recordings with matching basenames and retain preparation's rejection of duplicate resolved source paths. Keep destination naming in preparation. Keep the separately selected S3 basename rule distinct from local selection.
For the remaining eligibility choice, I recommend ordinary regular recording files as the supported file-input surface. That fits repeated reading, hashing, and resume. Requiring a regular file consistently would narrow preparation's current initial check, so it needs approval. It does not by itself establish a new blanket symlink prohibition; existing path/confinement rules remain separate.
Viable alternative
Fix the demonstrated basename disagreement and share preparation's existing selection behavior without tightening file eligibility. This minimizes behavior changes. Unusual non-regular sources may then fail later during reading or transcription rather than at discovery. The broader acceptance should not be presented as evidence that streaming pipes and devices are supported end to end.
Question for discussion
Should the shared discovery contract require regular recording files, or preserve preparation's broader initial eligibility check? I recommend regular files, with no additional filesystem restrictions bundled into that choice.
Operator response:
Pending discussion.
After Discussion
Record approved answers here, then prepare a remediation roadmap against the catalog. The roadmap should distinguish agreed behavior changes from internal refactoring, retain the audit evidence links, and include focused regression coverage. This document does not authorize implementing unresolved recommendations or replacing existing policies before those choices are settled.