24 KiB
Audit Remediation Discussion
Status: Decisions agreed; assigned safety, transfer, and feature work implemented
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.
Problem descriptions below record the original audit baseline. The catalog owns current finding status and closure evidence; consult it for remaining work.
The operator has settled the direction for all seven topics, including cancellation-aware waiting for lock contention. Publication import and the audio-inputs feature are implemented. The catalog retains the remaining independent work and its closure evidence.
1. Coordinate destructive cleanup with other work
Status: Implemented and verified
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.
Agreed contention behavior
Use cancellation-aware waiting, consistent with existing invocation locking, and identify the lock being waited on. A contending invocation waits for the workspace lock and can be cancelled while waiting.
The roadmap should identify the mutating command participants explicitly. Pure inspection and unrelated workspaces need no new serialization requirement.
Operator response:
Approved: use cancellation-aware waiting for the workspace lock. CAT-01 is closed, including the acquisition-diagnostic review follow-up.
2. Import published artifacts and retain local resume
Status: Publication import implemented; 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: Implemented and verified
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.
Completion
The source diagnostic, planning composition, and preflight verification implement the decision. The catalog closure links the regression coverage and validation.
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 implemented and verified
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. CAT-04 and CAT-06 are closed.
5. Finish subprocess shutdown before releasing its files
Status: Implemented and verified
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.
Agreed direction
Keep the bounded graceful-to-forceful escalation, then join process/output completion before releasing the associated resources or returning their ownership to callers. Read process state and flush/close diagnostics after completion is joined. Preserve the original timeout or cancellation cause. Exercise the delayed-completion branch with a controlled test of resource-release ordering.
Ordinary cancellation should still terminate promptly. In an exceptional blocked filesystem write or kernel operation, resource completion can take longer than the escalation windows. The invocation may remain in shutdown and continue holding its workspace lock while resource ownership completes.
Document the timeout as starting command shutdown, not guaranteeing that every resource is released at that instant. Retain bounded escalation without an absolute return-time guarantee for arbitrary blocked I/O. Use the existing supervisor and standard process-waiting mechanisms; an early-return ownership handoff or background cleanup service is unnecessary for this fix.
Operator response:
Approved: retain bounded termination escalation, then wait for process and output completion before releasing resources, even when exceptional I/O delays outlast the escalation timers. CAT-05 is closed.
6. Open publication sources as they are needed
Status: Implemented and verified
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.
Agreed direction
Keep complete destination planning, then open, verify, upload, and close each source in sequence using a bounded number of handles. Retain confinement, regular-file and checksum checks, and use the verified handle for hashing and transfer. Close each source when its transfer and verification finish rather than retaining all sources until the stage ends.
An invalid later source may be discovered after earlier immutable uploads. Such a failure leaves the prior publication current; the new attempt is not selected. On a first publication, failure leaves no newly selected publication. Keep the current-pointer write last, after all required publication work succeeds.
This explicitly relaxes the documented all-sources-rejected-before-upload behavior. Planning identities, destinations, and rules remains upfront; opening and validating every source before any upload is no longer required.
Use the existing sequential transfer mechanism. This decision adds no artifact-count cap, descriptor-limit tuning, disk-backed source snapshots, or upload-concurrency framework. Unselected objects from unsuccessful attempts do not require a new cleanup subsystem as part of this fix. Existing publication locks retain their semantics, including carrying locked remote products without opening their local replacements.
Verify bounded source-handle lifetimes with a growing inventory and a late-source failure that leaves current publication unchanged. Retain the existing source validation and pointer-ordering coverage.
Operator response:
Approved: plan destinations upfront, then open, verify, upload, and close one source at a time. A later invalid source may leave an unselected remote attempt; the current publication must remain unchanged on failure. CAT-09 is closed.
7. Give preparation and inspection the same audio selection rules
Status: Implemented and verified
Finding: CAT-12.
Roadmap owner: Multi-Format Audio Inputs and Shared Discovery.
Concrete example
At the audit baseline, 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.
Agreed direction
Share read-only selection rules. Accept distinct local recordings with matching basenames and retain preparation's rejection of duplicate resolved source paths. Keep materialization and checkpoint transitions with preparation and reporting with inspection. Preserve the existing prepared-name disambiguation and keep the separately selected S3 basename rule distinct from local selection.
Local recording sources must resolve to regular files. This supports repeated reading, hashing, and resume. Existing path and symlink rules remain separate.
Accept multiple audio formats. Automatic directory and S3-prefix scans use one shared, broad, case-insensitive extension filter; nonmatching sidecars are ignored. The roadmap owns the extension set and its application to preparation, inspection, reuse, and transcription fallback. Explicit local file selections and manifest-registered audio remain extension-agnostic. Backend decoding determines actual codec support; selection adds no transcoding or format-probing requirement.
Preserve stem-based speaker IDs. After existing prepared-name disambiguation, reject remaining same-stem collisions across extensions during shared discovery, identify both sources, and ask the operator to select one encoding or rename the recordings. Distinct same-full-basename local recordings remain supported. This moves the existing transcription ambiguity failure earlier without adding automatic cross-extension renaming or content-based deduplication.
The roadmap extends CAT-12's shared-discovery remediation with the subsequently approved multi-format behavior. Audio generation identity and transfer bounds remain the separate corrections agreed under topic 4. Publication import is independent of raw-audio discovery; the implemented features have separate scopes.
Operator response:
Approved: regular-file selection, shared broad audio-extension filtering for automatic discovery, extension-agnostic explicit inputs, and early rejection of unresolved speaker-stem collisions. CAT-12 is closed after implementation and verification.
After Discussion
Prepare remediation plans for the catalog's remaining open entries. Distinguish agreed behavior changes from internal refactoring, retain the audit evidence links, and include focused regression coverage. Build on the completed safety, transfer, publication-import, and audio-input work. Recording an approved direction alone does not close its finding; pending work still requires implementation and verification.