diff --git a/docs/roadmap/audit/catalog.md b/docs/roadmap/audit/catalog.md index e7e1766..00a05b5 100644 --- a/docs/roadmap/audit/catalog.md +++ b/docs/roadmap/audit/catalog.md @@ -24,6 +24,9 @@ baseline and this revision. No finding is marked remediated by this catalog. This is a consolidation of recorded evidence, not a fresh runtime audit or an implementation plan. +The [remediation discussion](discussion.md) provides an ordered agenda of +recommendations, open questions, and decisions to record against these findings. + ## Current Architecture Scriptorium is a thin CLI/HTTP executable with six production packages. diff --git a/docs/roadmap/audit/discussion.md b/docs/roadmap/audit/discussion.md new file mode 100644 index 0000000..6f8c698 --- /dev/null +++ b/docs/roadmap/audit/discussion.md @@ -0,0 +1,196 @@ +# Audit Remediation Discussion + +Created 2026-11-24. Status: recommendations for discussion; no remediation +decisions or implementation completion are recorded yet. + +This document gives maintainers an ordered agenda for working through the +[audit catalog](catalog.md). The catalog and its source reports own the findings +and evidence; this document owns the proposed disposition, open questions, and +subsequent decisions. It is not an implementation plan or a new audit. + +## Overall Assessment + +The findings support Scriptorium's existing direction: a thin executable that +delegates configuration, execution, operator interfaces, and release mechanics +to the upstream libraries. No broad architectural redesign is indicated. + +The catalog distinguishes production defects, behavioral test weaknesses, +deployment choices, and optional cleanup. Its 17 entries should not become +17 mandatory implementation tasks. The defective-overlay experiments provide +useful evidence of test blind spots; statement coverage alone missed them. + +Recommended sequence: settle the narrow corrective work first, then diagnostic +ownership and deployment questions, then optional cleanup. Deployment decisions +need not delay confirmed bug fixes. Retain the boundaries in the +[architecture policy](../../policy/architecture.md) and the proportionality +required by the [testing policy](../../policy/testing.md). + +## Discussion Order And Decision Record + +Work through the sections below in order. Record accepted scope, deferrals, and +any necessary follow-up in this table as decisions are made. Pending entries +are proposals, not authorization to introduce new behavior. + +| Topic | Catalog entries | Decision | +| --- | --- | --- | +| 1. Correct the production defects | 1–3 | Pending | +| 2. Strengthen existing behavioral protection | 4, 7, 9–13 | Pending | +| 3. Improve startup diagnostics at the owning boundary | 8 | Pending | +| 4. Select HTTP connection-lifetime policy | 5 | Pending | +| 5. Establish whether additional memory controls are needed | 6 | Pending | +| 6. Select proportionate local cleanup | 14, 15, 17 | Pending | +| 7. Decide whether to move HTTP report ownership | 16 | Pending | + +## 1. Correct The Production Defects + +**Recommendation:** Proceed with narrow fixes and associated regression +coverage for [catalog entries 1–3](catalog.md#1-restricted-file-acquisition-can-ignore-cancellation-and-stall). + +- Preserve large and nested provider numbers through the existing decoder's + `UseNumber` support. Verify the outgoing provider request losslessly through + a real engine and loopback provider; avoid a new numeric conversion layer. +- Preserve significant pathname whitespace. Test distinct padded and unpadded + files, keeping configured-root normalization separate. +- Carry context through artifact acquisition and check cancellation during + reading and before success. Follow upstream's regular-file behavior so an + existing FIFO cannot block opening. Context checks after `os.Open` alone do + not resolve that case. + +**Technical question before implementing the reader fix:** Confirm that ordinary +regular-file acquisition is the intended scope. Recommendation: follow upstream +and do not add streaming/non-regular input support. Keep cooperative cancellation, +lexical containment, and byte limits; do not introduce abandoned-read goroutines, +a symlink sandbox, or an immediate-interruption guarantee. + +**Separate upstream opportunity:** The restricted reader mixes legitimate HTTP +access policy with ordinary reading and metadata mechanics. The inspected +PromptKit implementation already handles relevant cancellation behavior, but +that reader implementation is internal. Consider whether a supported reusable +reader would reduce duplication. Any proposal must retain Scriptorium's access +and byte-limit policy; do not import or copy upstream internals, and do not make +this investigation a prerequisite for correcting the local defect. + +## 2. Strengthen Existing Behavioral Protection + +**Recommendation:** Proceed without new product requirements. Prefer replacing +weak or redundant assertions over expanding the test inventory. + +| Catalog entries | Recommended disposition | +| --- | --- | +| [4 and 7](catalog.md#4-shared-engine-lifetime-is-not-protected-at-server-composition) | Consolidate shared-capacity protection at the real server boundary. Register cancellation, release, and joining before launching workers; bound the second request. Remove the lower-level duplicate only when its meaningful protection is covered. | +| [9](catalog.md#9-artifact-hash-tests-reuse-the-production-implementation-as-oracle) | Replace the production-helper oracle with independently meaningful digest expectations. | +| [10](catalog.md#10-collector-fixtures-cannot-detect-swapped-cache-usage-fields) | Use distinct accounting values and check required field names and value/known/complete semantics. | +| [11](catalog.md#11-server-engine-construction-failure-lacks-boundary-coverage) | Cover a resolved configuration whose engine construction fails: typed cause, nonzero status, and no listen attempt. This need not wait for topic 3's diagnostic design. | +| [12](catalog.md#12-removed-flag-tests-can-pass-because-the-prompt-operand-is-missing) | Supply otherwise-valid invocations and verify rejection of the removed flag specifically. Retain the selected hard-cutover protection. | +| [13](catalog.md#13-http-error-mapping-tests-pin-noncontractual-prose) | Assert status, code, precedence, usable messages, and cause privacy without freezing noncontractual sentences. | + +The numeric representation assertion belongs with the precision correction in +topic 1. Avoid coverage quotas, exhaustive upstream test matrices, and tests +that silently establish new resource or disclosure guarantees. + +## 3. Improve Startup Diagnostics At The Owning Boundary + +**Recommendation:** Split [catalog entry 8](catalog.md#8-cli-startup-failures-hide-actionable-resource-context) +into two responsibilities rather than designing one universal error renderer. + +- Application-owned listener failures: provide deliberate, safe address and + failure-category context through native CommandKit explanations. +- PromptKit capture failures: establish a supported structured diagnostic path + through PromptKit and ckprompt, requesting upstream support if needed. Native + PromptKit commands should benefit alongside application commands. + +**Open questions:** + +1. Which resource identifiers and failure categories should operators receive? +2. Can the selected public APIs supply and render that information safely, or + is an upstream extension needed? +3. Should the local listener improvement proceed independently while framework + support is investigated? Recommendation: yes. + +Retain typed causes and current statuses. Do not parse error prose, print +arbitrary causes, or move resource capture into configuration inspection. +Sharing the existing ConfigKit diagnostic helper does not itself solve these +constructor failures. + +## 4. Select HTTP Connection-Lifetime Policy + +[Catalog entry 5](catalog.md#5-http-connection-lifetimes-need-a-deployment-decision) +requires a deployment decision, not an automatic timeout patch. + +**Open questions:** + +1. Which supported deployments rely on gateway controls, and which need + Scriptorium to bound body reads, idle connections, or response delivery? +2. If application controls are needed, which phases, configurable values, and + defaults should they cover? + +**Recommendation:** Prefer existing gateway controls where appropriate. A trusted +network alone does not prevent stalled clients. For direct deployments needing +controls, use standard HTTP deadlines chosen for the relevant phases. A short +global write timeout can cut off legitimate inference; a context deadline alone +does not interrupt a blocked body read. Keep the engine operation budget and +shutdown contract unchanged unless separately decided. + +## 5. Establish Whether Additional Memory Controls Are Needed + +[Catalog entry 6](catalog.md#6-per-file-limits-do-not-establish-an-aggregate-memory-budget) +demonstrates a distinction between per-file and aggregate limits, not a measured +production exhaustion problem or a need for new orchestration. + +**Open questions:** + +1. Is the objective capacity planning, an aggregate input cap, or a stronger + memory guarantee? +2. Which representative workloads and deployment sizes justify additional + controls beyond existing file and backend limits? +3. If acquisition limits are warranted, what belongs in PromptKit rather than + Scriptorium? + +**Recommendation:** Start with representative workloads and the full resource +envelope: inputs, rendering expansion, admitted runs, output, and delivery +buffers. An aggregate input cap alone would not bound process memory. A gateway +cannot infer referenced-file bytes from request size. Prefer upstream support +for library-owned acquisition controls, and do not add a parallel admission +system or arbitrary rejection rules without an agreed requirement. + +## 6. Select Proportionate Local Cleanup + +**Recommendation:** Consider these changes when adjacent corrective work makes +their benefit concrete; none is a prerequisite for fixing the defects. + +- [14: HTTP handler](catalog.md#14-http-handler-responsibilities-are-hard-to-review-independently): + extract a few cohesive private decoding, mapping, or projection helpers while + retaining a clear request lifecycle and existing behavioral tests. +- [15: CLI diagnostics](catalog.md#15-cli-diagnostic-adaptation-is-duplicated-and-failure-selection-is-nested): + share the small run/serve evidence-selection bridge and flatten failure + selection where helpful. Preserve native inspection ownership and error + precedence; do not force distinct failure paths into one abstraction. +- [17: Optional model mapping](catalog.md#17-optional-model-mapping-has-redundant-nil-handling): + call the existing nil-aware converter unconditionally when touching request + mapping, preserving omitted/null versus explicit-empty behavior. + +**Decision to record:** Which cleanups are useful in the corrective work, and +which should remain deferred? No middleware framework, universal classifier, +or interface for every phase is warranted. + +## 7. Decide Whether To Move HTTP Report Ownership + +[Catalog entry 16](catalog.md#16-http-terminal-report-ownership-spans-two-packages) +offers two coherent choices: co-locate the collector/projection with the HTTP +adapter, or retain the isolated package with its HTTP-specific purpose clear. + +**Recommendation:** Defer moving it unless adjacent report work makes the +maintenance benefit concrete. Package count alone is insufficient justification. +The accounting-test correction in topic 2 can proceed in either location. + +**Decision to record:** Retain the current boundary or move the implementation +and focused tests together. Either choice should preserve HTTP wire behavior, +terminal-only observation, detached snapshots, and request isolation, while +keeping CLI native reports distinct. No shared reporting framework is needed. + +## Review Basis + +These recommendations consolidate the catalog review, supporting reports, and +selected application and pinned PromptKit source inspection. The review did +not rerun the recorded experiments or tests. Decisions and implementation +status should be added explicitly rather than inferred from these proposals.