From 2763890ffc1565fba57b6205cd5fec93ab038cb9 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Tue, 1 Dec 2026 01:50:29 +0000 Subject: [PATCH] Document audit remediation discussion points --- docs/roadmap/audit/discussion.md | 416 +++++++++++++++++++++++++++++++ 1 file changed, 416 insertions(+) create mode 100644 docs/roadmap/audit/discussion.md diff --git a/docs/roadmap/audit/discussion.md b/docs/roadmap/audit/discussion.md new file mode 100644 index 0000000..3b053c9 --- /dev/null +++ b/docs/roadmap/audit/discussion.md @@ -0,0 +1,416 @@ +# 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](catalog.md) 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 and 3. Topics 2, 4, 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](catalog.md#cat-01--p1-coordinate-whole-session-deletion-with-active-invocations). + +### 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. Restore a locked publication with truthful completion records + +Status: Open + +Finding: [CAT-02](catalog.md#cat-02--p2-make-restored-carried-products-agree-with-manifest-authority). + +### The two records involved + +The session manifest is Narratio's local progress ledger. It records which +outputs completed, their checksums, and evidence used to decide whether they can +be reused. A checksum identifies bytes. Other completion evidence describes the +inputs and settings under which an output was generated. + +The remote publication commit identifies the files selected for publication. +A remote lock preserves an already published product, even when a newer local +version exists. Locking publication does not prevent local regeneration. + +### Concrete example + +1. Generate transcript A and publish it. +2. Lock the published transcript because A is the distributed, canonical copy. +3. Regenerate locally, producing transcript B. The local manifest describes B. +4. Publish again. The lock correctly keeps A in the remote publication. +5. 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 problem is not that the lock retained A. The problem is that the restored +ledger describes a different file from the one restored. + +### Why changing the checksum is insufficient + +Suppose an analysis artifact was generated from B. Replacing the transcript +checksum with A's checksum does not establish that the analysis artifact was +generated from A. Likewise, retaining B's producer fingerprint would incorrectly +claim that A was generated using B's inputs and settings. + +A publication may intentionally contain products from different generations. +There is no existing requirement that all published products come from one +coherent pipeline generation. The repair needs truthful per-product evidence; +it does not require inventing that stronger publication rule. + +### Recommendation + +Treat the selected remote publication as authoritative for the bytes restored. +Make those products usable through normal resolution with truthful origin +information. Assess producer reuse and dependent completion separately, using +the evidence actually available for those generations. + +This means distinguishing "this published file is available" from "this producer +can be skipped under the current inputs and configuration." Where historical +generation evidence exists, reuse it. Where it does not, report that limitation +without fabricating completion evidence. + +Before choosing a representation, work through both a built-in transcript and +a configured analysis artifact, including a dependent generated from B. The +existing remote declarations must be examined to determine which historical +evidence can be recovered. The exact manifest projection or model change remains +an implementation-analysis question, not an approved redesign. + +### Viable alternative + +Use a conservative restore that retains the published bytes but explicitly marks +affected work unavailable for normal pipeline reuse until regeneration. This can +reduce the model change, but limits the usefulness of restore: an operator may +need to regenerate work before consuming an otherwise valid published file. +Such a restriction would need to be stated clearly and approved. + +### Question for discussion + +Should a restored locked publication be immediately usable as an input, with +producer freshness evaluated separately, or is regeneration before pipeline use +acceptable? I recommend immediate input availability with truthful provenance. + +Operator response: + +_Pending discussion._ + +## 3. Inspect S3 when planning and preflighting + +Status: Read-only S3 checks agreed + +Finding: [CAT-13](catalog.md#cat-13--p2-give-s3-session-planning-the-evidence-needed-for-truthful-reuse-decisions). + +### 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](../../operations.md#prompt-requirements-preflight) 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: Open + +Findings: [CAT-04](catalog.md#cat-04--p2-bind-prepared-s3-audio-bytes-to-their-observed-generation) +and [CAT-06](catalog.md#cat-06--p2-stop-known-size-downloads-before-oversized-bodies-exhaust-staging-space). + +### 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. + +### Recommendation + +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. +There is no need for an automatic retry-until-stable loop or a session-wide +snapshot protocol. + +### Viable alternative + +Require the downloaded generation to match the earlier listing and stop on any +change. This is easy to explain and preserves the listing as the selected identity, +but an operator must retry preparation after an otherwise acceptable replacement. + +### Related size-bound question + +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. + +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 remains distinct from a known zero-byte declaration. + +### Question for discussion + +When audio changes between listing and downloading, should Narratio accept and +record the valid generation actually downloaded, or stop and ask for a retry? +I recommend accepting the observed generation. Do you also agree with stopping +known-size invalid transfers early? + +Operator response: + +_Pending discussion._ + +## 5. Finish subprocess shutdown before releasing its files + +Status: Open + +Finding: [CAT-05](catalog.md#cat-05--p2-retain-subprocess-and-stream-ownership-through-delayed-completion). + +### 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](catalog.md#cat-09--p2-bound-publications-simultaneously-open-source-descriptors). + +### 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](catalog.md#cat-12--p2-share-audio-discovery-and-accept-valid-same-basename-recordings-in-inspection). + +### 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.