Files
scriptorium/docs/roadmap/audit/catalog.md

359 lines
20 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Consolidated Audit Findings
Consolidated on 2026-11-24 at repository revision
`5f194da734f478f5c34102c02c5f666f5da25b97`.
## Scope And Ordering
This catalog covers all ten audit reports currently in this directory. It
contains **17 consolidated entries**, merging repeated underlying issues and
including the associated regression-test gaps with the production defects
they protect. Separate problems within a combined original finding remain
distinguishable here. The original reports retain their detailed evidence,
reproductions, alternatives, and limitations.
Order reflects recommended attention: confirmed production defects first,
protection of the shared-engine constraint next, then deployment decisions,
test reliability/operator diagnostics, remaining test weaknesses, and optional
refactoring. Original priority labels are retained where applicable; ordering
does not establish release gates or promote optional proposals into requirements.
Deployment exposure can change the relative urgency of entries 5 and 6.
Application and tool sources have not changed between the first audit's
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.
ConfigKit owns resolved configuration, PromptKit owns preparation/execution
and backend admission, CommandKit and its integrations own native operator
workflows, and ReleaseKit owns release mechanics. Local packages own process
and server composition, application schema/defaults, HTTP adaptation and
artifact-access policy, CLI report-file effects, and HTTP terminal-report
projection. The server shares one engine; requests and collectors are local
to each invocation. See the [component overview](../../internal/overview.md).
## 1. Restricted File Acquisition Can Ignore Cancellation And Stall
**Classification:** Confirmed production defect; P2.
The restricted HTTP reader checks context only on entry, then calls file
helpers without it. An existing FIFO can block acquisition beyond client
cancellation or the operation budget, retaining pending work until another
filesystem participant releases it. The reader can then return success despite
cancellation. The concurrency/resource/error audits describe the same defect,
not additional bugs.
Carry context through acquisition, check it cooperatively during reads and
before success, and align unsupported-file handling with the ordinary upstream
reader. Add bounded post-start cancellation/non-regular-input regression
coverage with reliable cleanup and a representative engine or HTTP path.
Preserve lexical containment and byte limits; this does not call for a symlink
sandbox, abandoned-read goroutines, or immediate interruption guarantees.
**Original entries:** [Correctness §3](01-correctness.md#3-restricted-file-reads-discard-cancellation-and-can-stall-on-fifos-p2),
[Concurrency §1](04-concurrency.md#1-file-acquisition-can-outlive-request-cancellation-p2-previously-known),
[Resources: previously recorded cleanup](05-resources.md#previously-recorded-cleanup-findings-still-apply),
[Error handling: previously recorded failures](06-error-handling.md#previously-recorded-failure-path-findings),
[Testing §1: acquisition coverage](08-testing.md#1-known-correctness-defects-lack-their-decisive-boundary-cases).
The [efficiency assessment](02-efficiency.md#scope-and-results) also carries
this existing finding forward without a new algorithmic finding.
## 2. HTTP Provider Parameters Lose Large Integer Precision
**Classification:** Confirmed production defect and coupled test weakness; P2.
HTTP decoding of `model.extra_params` into untyped values rounds integers
through float64 before PromptKit sees them, including nested values. The
existing small-number fixture misses the corruption and its concrete-float64
assertion rejects the proposed lossless representation.
Use the existing decoder's `UseNumber` capability, or another lossless handoff
supported by PromptKit. Consolidate extra-parameter mapping protection with an
HTTP-to-engine-to-loopback-provider regression using large nested integers.
Replace the incidental Go-type expectation with lossless semantic/wire checks;
do not normalize expected and actual values through float64. Retain strict
decoding, typed numeric validation, and trailing-token rejection.
**Original entries:** [Correctness §1](01-correctness.md#1-http-provider-parameters-lose-large-integer-precision-p2),
[Testing §1: numeric boundary coverage](08-testing.md#1-known-correctness-defects-lack-their-decisive-boundary-cases),
[Testing §7: numeric-representation assertion](08-testing.md#7-remove-incidental-representation-and-prose-assertions).
## 3. Filename Trimming Can Select The Wrong Input Artifact
**Classification:** Confirmed production defect; P3.
`resolveLexicalPath` trims significant filename whitespace. If padded and
unpadded names both exist, a valid request can silently read the other file;
otherwise the intended file may fail to load. Existing containment tests lack
the decisive identity case.
Preserve the request pathname through lexical cleaning/containment checks and
verify distinct padded/unpadded files with different content. Keep configured
artifact-root normalization separate. No stronger filesystem policy is needed.
**Original entries:** [Correctness §2](01-correctness.md#2-file-reference-whitespace-can-select-a-different-artifact-p3),
[Testing §1: filename-identity coverage](08-testing.md#1-known-correctness-defects-lack-their-decisive-boundary-cases).
## 4. Shared Engine Lifetime Is Not Protected At Server Composition
**Classification:** Behavioral test gap; P2 for shared admission. Current
production construction is correct.
The handler capacity test injects one engine itself, while server tests do not
overlap capacity-limited runs. A deliberately defective per-request-engine
overlay passed the full suite, showing that the tests miss the lifetime-owning
boundary despite the accepted shared-engine constraint.
Move/consolidate the representative capacity scenario into the real server
harness: hold one provider call under a capacity-one/no-queue configuration
and observe rejection without a second provider dispatch. Retain distinct
privacy/retry checks and the cleanup protections in entry 7. Remove the
lower-level duplicate only once the stronger scenario subsumes it.
**Original entry:** [Testing §4: shared-engine lifetime](08-testing.md#4-server-tests-miss-the-lifetime-owning-composition-boundary).
## 5. HTTP Connection Lifetimes Need A Deployment Decision
**Classification:** Deployment-dependent resource weakness; additional policy
choice, not a violated timeout guarantee.
The header timeout does not bound stalled request bodies, idle connections,
or response delivery. The execution budget starts after decoding and excludes
delivery. A real-server diagnostic confirmed a stalled body retained work
beyond the header timeout; idle/write implications were assessed statically.
Select appropriate gateway controls or consider configurable application
phase deadlines for direct deployments. Defaults and exposure assumptions
need agreement. A short global write timeout can truncate legitimate inference;
a context deadline alone does not interrupt a blocking body read. Keep the
operation budget and shutdown contract unchanged unless separately decided.
**Original entry:** [Resources §1](05-resources.md#1-http-connections-can-retain-resources-outside-the-execution-budget).
## 6. Per-File Limits Do Not Establish An Aggregate Memory Budget
**Classification:** Deployment/capacity-planning decision; not a broken
per-file limit or an admission-ordering defect.
A small request can reference many individually permitted files, whose
materialized bodies and rendering/delivery copies accumulate. Backend
admission already covers ordinary input acquisition, but one admitted run can
still consume much more than one file cap. The source audit used a tiny
two-file diagnostic, not a large-memory saturation test.
Size the full deployment envelope using inputs, rendering expansion, admitted
runs, and delivery buffers. If harder bounds are needed, decide explicitly on
aggregate acquisition/request admission, using native PromptKit capabilities
or upstream extensions where appropriate. A gateway request-size cap alone
cannot infer referenced-file bytes. Do not introduce unapproved rejection
rules, duplicate orchestration, or per-request engines.
**Original entry:** [Resources §2](05-resources.md#2-existing-byte-limits-are-not-an-aggregate-memory-budget).
## 7. Capacity-Test Failure Paths Can Leak Workers Or Hang The Suite
**Classification:** Confirmed test-lifetime weakness; P3, test only.
`TestHandlerSharesBackendCapacityAcrossConcurrentRequests` releases/joins its
first worker only after assertions. Early failure bypasses cleanup, and a
regression admitting the synchronous second call can trap the test before
release. Happy-path timers do not bound that middle call.
Register test-controlled cancellation/release/join before launching workers,
bound the second request, and keep channel closure single-owner. If entry 4
replaces this test, carry the protections into its replacement instead of
maintaining two scenarios. No production time limit is implied.
**Original entries:** [Concurrency §2](04-concurrency.md#2-shared-capacity-test-does-not-own-workers-on-failure-paths-p3-test-only),
[Resources: previously recorded cleanup](05-resources.md#previously-recorded-cleanup-findings-still-apply),
[Error handling: previously recorded failures](06-error-handling.md#previously-recorded-failure-path-findings),
[Testing §6](08-testing.md#6-failure-cleanup-in-the-capacity-test-is-incomplete).
## 8. CLI Startup Failures Hide Actionable Resource Context
**Classification:** Operator-diagnostic weakness; P3, not a broken typed cause
or a requirement to disclose arbitrary errors.
Malformed message templates, missing message files, and unusable listen
addresses produce generic terminal explanations. Useful context survives in
`Outcome.Cause`, but the executable returns only status and native presentation
does not print causes automatically. These constructor failures are not
ConfigKit LoadErrors; sharing the existing diagnostic helper alone will not
fix them.
Provide deliberate safe context through native explanations. Prefer
upstream-supported structured capture diagnostics for native PromptKit
workflows, requesting upstream support if necessary. Retain privacy, typed
causes, and current statuses. Do not print arbitrary causes, parse error prose,
or move template/resource capture into ordinary configuration inspection.
The constructor test gap in entry 11 is related but independently addressable.
**Original entry:** [Error handling §1](06-error-handling.md#1-actionable-cli-startup-context-survives-only-in-the-returned-cause-p3).
## 9. Artifact Hash Tests Reuse The Production Implementation As Oracle
**Classification:** Behavioral test weakness; P3. No current hash defect was
demonstrated.
The contained-file reader test computes its expected digest through the same
`artifactHash` helper used by production. A constant-hash overlay passed the
full suite. Use an independent expected digest for fixed content or an
appropriate public upstream comparison, with different content and meaningful
expectations. Keep body/URI/containment checks; no new hash-uniqueness guarantee
or exhaustive cryptographic testing is needed.
**Original entry:** [Testing §2](08-testing.md#2-the-artifact-hash-assertion-uses-its-own-implementation-as-the-oracle).
## 10. Collector Fixtures Cannot Detect Swapped Cache Usage Fields
**Classification:** Behavioral test weakness; P3. No current projection defect
was demonstrated.
Cached-token and cache-write-token fixture values are both zero, and JSON
assertions count members rather than checking their names and values. A swap
of those mappings passed the full suite. Use distinct counts and meaningful
Known/Complete combinations; assert the required `value`, `known`, and
`complete` semantics. Preserve zero/unknown/incomplete distinctions without
duplicating upstream billing tests. These tests move with the collector if
entry 16 is adopted.
**Original entry:** [Testing §3](08-testing.md#3-collector-fixtures-do-not-distinguish-all-usage-fields).
## 11. Server Engine-Construction Failure Lacks Boundary Coverage
**Classification:** Behavioral test gap; P3. Distinct from shared engine lifetime
and from the diagnostic design proposal.
Server failure tests cover load/validation/listener failures, but not a resolved
configuration whose engine construction fails on a missing message file or
malformed template. Cover the typed failure, nonzero status, and absence of a
listen attempt. Do not manufacture unreachable LoadErrors for coverage, move
capture into configuration inspection, or freeze new diagnostic wording before
entry 8's presentation approach is selected.
**Original entry:** [Testing §4: constructor failure](08-testing.md#4-server-tests-miss-the-lifetime-owning-composition-boundary).
## 12. Removed-Flag Tests Can Pass Because The Prompt Operand Is Missing
**Classification:** Behavioral test weakness; P3.
The `run` rows in `TestRemovedSourceAndSchemaFlagsAreRejected` omit the required
prompt and check only Usage/status 2. Reintroducing a no-op `--schema-dir` flag
still passed the full suite because the command was invalid for another reason.
Use otherwise-valid invocations and distinguish the removed-flag rejection
with native typed evidence or a minimal flag-specific fragment. Keep the
selected hard-cutover protection rather than deleting the test.
**Original entry:** [Testing §5](08-testing.md#5-a-removed-flag-test-can-pass-for-the-wrong-usage-error).
## 13. HTTP Error-Mapping Tests Pin Noncontractual Prose
**Classification:** Incidental test coupling; P3.
Full-message equality caused five failures for a harmless generation-error
rewording while status, code, shape, and privacy were unchanged. Replace exact
noncontractual sentences with status/code/precedence, usable nonempty-message,
and private-cause exclusion assertions. Retain any wording actually promised
by a contract. This is the prose part of the original combined finding; its
numeric-representation part is consolidated into entry 2.
**Original entry:** [Testing §7: error-prose assertions](08-testing.md#7-remove-incidental-representation-and-prose-assertions).
## 14. HTTP Handler Responsibilities Are Hard To Review Independently
**Classification:** Optional maintainability improvement; originally medium.
`ServeHTTP` mixes routing, strict decoding, validation, request mapping,
observation, execution, error selection, and response projection. Extract a
few cohesive private decoding/mapping/projection helpers while retaining one
clear request lifecycle and existing behavioral tests. Preserve transport and
presence semantics; fix entry 2 explicitly rather than preserving its bug.
No middleware framework or interface-per-phase is warranted.
**Original entry:** [Complexity §1](03-complexity.md#1-separate-the-http-handlers-request-and-response-phases).
## 15. CLI Diagnostic Adaptation Is Duplicated And Failure Selection Is Nested
**Classification:** Optional maintainability improvement; originally medium.
`runPrompt` and `serveWithListener` repeat ConfigKit result/error evidence
selection, native adaptation, and queuing. `frameworkFailure` has related
adaptation with a distinct heading/composition, and `requestFailure` nests
ordered classifications. Give the repeated bridge one small CLI-local helper
and flatten selection if helpful, preserving typed evidence, causes,
bootstrap delivery, and timeout/configuration precedence.
The equivalence audit confirms the bridge's shared behavioral requirement;
it does not establish equivalence of every failure path. Keep native
inspection presentation with ckconfig/ckprompt to avoid duplicate diagnostics.
No shared CLI/HTTP classifier, cache, or reconstructed configuration model is
needed. This cleanup does not itself resolve entry 8.
**Original entries:** [Complexity §2](03-complexity.md#2-consolidate-cli-configuration-diagnostics-and-flatten-failure-selection),
[Equivalence §1](10-equivalence.md#1-share-the-cli-application-load-diagnostic-bridge).
## 16. HTTP Terminal-Report Ownership Spans Two Packages
**Classification:** Optional package-boundary refinement; low priority, not an
import violation or dead-code finding.
`internal/report` owns HTTP-shaped JSON projection/collection while its sole
production consumer is the HTTP adapter. Co-locate it and its focused tests
with that consumer, or retain the isolated package while clarifying its
HTTP-specific purpose. Either choice can be reasonable; preserve wire shapes,
terminal-only observation, detached snapshots, and request isolation. Keep CLI
native reports distinct and avoid a speculative shared reporting framework.
**Original entries:** [Complexity §3](03-complexity.md#3-co-locate-the-http-only-execution-projection-with-its-consumer),
[Boundaries §1](11-boundaries.md#1-make-http-execution-report-ownership-explicit).
## 17. Optional Model Mapping Has Redundant Nil Handling
**Classification:** Optional local cleanup; low priority, not a runtime defect.
The HTTP converter handles nil input, but its only caller first excludes nil,
making the helper's nil branch unreachable. Prefer calling the nil-aware
converter unconditionally rather than imposing a new non-nil precondition.
Preserve omitted/null versus explicit empty-object behavior and field presence;
verify these distinctions when changing the mapping. No functionality needs
to be removed.
**Original entry:** [Dead code §1](12-deadcode.md#1-consolidate-optional-model-mapping-into-its-nil-aware-converter).
## Source Coverage And Consolidation Check
| Audit | Coverage in this catalog |
| --- | --- |
| [01 Correctness](01-correctness.md) | Findings 1–3 map to catalog entries 2, 3, and 1. |
| [02 Efficiency](02-efficiency.md) | No new finding; existing correctness findings are carried forward, not duplicated. |
| [03 Complexity](03-complexity.md) | Findings 1–3 map to entries 14–16. |
| [04 Concurrency](04-concurrency.md) | Findings 1–2 map to entries 1 and 7. |
| [05 Resources](05-resources.md) | New findings 1–2 map to entries 5–6; repeated cleanup findings map to 1 and 7. |
| [06 Error handling](06-error-handling.md) | New finding 1 maps to entry 8; repeated failure findings map to 1 and 7. |
| [08 Testing](08-testing.md) | Finding 1 is folded into 1–3; 2→9; 3→10; 4 is split into 4 and 11; 5→12; 6→7; 7 is split between 2 and 13. |
| [10 Equivalence](10-equivalence.md) | Finding 1 corroborates the diagnostic-bridge portion of entry 15. |
| [11 Boundaries](11-boundaries.md) | Finding 1 corroborates entry 16. |
| [12 Dead code](12-deadcode.md) | Finding 1 maps to entry 17. |
Investigated non-findings remain non-findings. In particular, no algorithmic
rewrite, extra layer, coverage quota, broad compatibility removal, general
secret filter, forced handler drain, or new resource cap is selected here.
The deadcode-reported `NewHandler` constructor has a concrete test-support
purpose and is not a deletion task. Optional navigation cleanups mentioned
under rejected/non-action sections are not promoted into standalone findings.
## Validation
Read all reports, checked finding-to-entry coverage and duplicate groupings,
verified relative links and section anchors, and checked whitespace. The
working baseline contains no intervening application/tool changes. Earlier
test/diagnostic results remain evidence in their original reports; tests and
experiments were not rerun for this documentation-only consolidation. No
source report, production code, test, dependency, or policy was changed.