Remove completed roadmap and audit documents
This commit is contained in:
@@ -1,151 +0,0 @@
|
|||||||
# Audit Remediation Roadmap
|
|
||||||
|
|
||||||
Prepared 2026-11-25.
|
|
||||||
Pre-implementation baseline: `e67633b9f48b42c5b0d14782c6e8e1d4c78fcdd5`.
|
|
||||||
|
|
||||||
This roadmap captures the target state and scope selected in the accepted
|
|
||||||
[audit discussion](audit/discussion.md). The [catalog](audit/catalog.md) and
|
|
||||||
original reports retain the detailed evidence and reproductions.
|
|
||||||
[implementation.md](implementation.md) owns execution steps and implementation
|
|
||||||
status. This document does not introduce new runtime contracts.
|
|
||||||
|
|
||||||
## Baseline And Target
|
|
||||||
|
|
||||||
At the pre-implementation baseline, all audited production and test findings
|
|
||||||
were unresolved, and application and tool sources had not changed since the
|
|
||||||
correctness audit. The dependency versions selected by this roadmap remain
|
|
||||||
those in [go.mod](../../go.mod): PromptKit v0.25.0, ConfigKit v1.4.0,
|
|
||||||
CommandKit v0.8.0, ckconfig v0.11.0, ckprompt v0.12.0, and ReleaseKit v0.10.0.
|
|
||||||
No dependency upgrade is selected by this roadmap.
|
|
||||||
|
|
||||||
The target is a thin application with corrected HTTP input handling, effective
|
|
||||||
tests at application-owned boundaries, useful startup diagnostics from the
|
|
||||||
appropriate owner, and HTTP-specific reporting consolidated within its adapter.
|
|
||||||
ConfigKit, PromptKit, and CommandKit retain the responsibilities established by
|
|
||||||
[ADR 0006](../adr/0006-adopt-commandkit-native-operator-interfaces.md) and the
|
|
||||||
[architecture policy](../policy/architecture.md).
|
|
||||||
|
|
||||||
HTTP stays in maintenance mode, suitable only for exposure to trusted hosts on
|
|
||||||
a trusted network. The rest of the application remains actively developed.
|
|
||||||
The accepted report relocation makes that boundary clearer without expanding
|
|
||||||
HTTP reporting or deployment capabilities.
|
|
||||||
|
|
||||||
## HTTP Input Handling
|
|
||||||
|
|
||||||
Provider parameters reach PromptKit without numeric precision loss, and file
|
|
||||||
references retain their pathname identity. Strict unknown-field handling,
|
|
||||||
typed numeric validation, and trailing-token rejection remain unchanged.
|
|
||||||
|
|
||||||
Restricted acquisition uses ordinary regular-file semantics: unsupported
|
|
||||||
non-regular inputs are rejected before opening, opened files are checked, and
|
|
||||||
cancellation is observed cooperatively during acquisition and before success.
|
|
||||||
Lexical containment and configured byte limits remain enforced during reading.
|
|
||||||
Errors retain their identities through existing PromptKit/HTTP mappings.
|
|
||||||
|
|
||||||
This does not introduce streaming input support, immediate interruption of
|
|
||||||
synchronous filesystem operations, abandoned-read goroutines, or a symlink
|
|
||||||
sandbox. Existing OS-followed symlinks to regular files remain supported.
|
|
||||||
Ordinary CLI artifact loading remains upstream-owned.
|
|
||||||
|
|
||||||
## Effective Behavioral Protection
|
|
||||||
|
|
||||||
Tests protect demonstrated failure modes at their application-owned boundaries
|
|
||||||
rather than incidental representations or error prose:
|
|
||||||
|
|
||||||
- Lossless provider values, whitespace-significant file identity, post-start
|
|
||||||
cancellation, unsupported file types, and independently checked hashes.
|
|
||||||
- Shared engine admission at actual server composition, with reliable test
|
|
||||||
cancellation, release, and joining on failure paths.
|
|
||||||
- Engine-construction failures after successful configuration resolution and
|
|
||||||
before listening, retaining typed causes and nonzero outcomes.
|
|
||||||
- Specific rejection of removed flags on otherwise-valid invocations.
|
|
||||||
- HTTP status/code/precedence, usable messages, and cause privacy without
|
|
||||||
freezing noncontractual error sentences.
|
|
||||||
- Distinct cache-accounting fields and their required value/known/complete
|
|
||||||
members, including zero versus unknown and incomplete-count semantics.
|
|
||||||
|
|
||||||
Existing behavior owners are extended or consolidated, preserving meaningful
|
|
||||||
protection before duplicate cases are removed. No coverage quota, exhaustive
|
|
||||||
upstream matrix, mandatory mutation-testing platform, or new release gate is
|
|
||||||
selected.
|
|
||||||
|
|
||||||
## HTTP Report Ownership
|
|
||||||
|
|
||||||
The terminal collector, HTTP projection, and their focused tests belong within
|
|
||||||
`internal/adapter/http`; the obsolete `internal/report` package is removed.
|
|
||||||
Implementation names are private where practical. Package reduction is a
|
|
||||||
consequence, not the goal.
|
|
||||||
|
|
||||||
Existing wire shapes, opt-in and absence semantics, success/error attachment,
|
|
||||||
terminal-only observation, detached snapshots, unknown/incomplete counts,
|
|
||||||
request isolation, and response limits remain unchanged. CLI reporting remains
|
|
||||||
on native upstream results and presentation. Additional accounting fields and
|
|
||||||
a shared reporting framework are outside this remediation.
|
|
||||||
|
|
||||||
## Startup Diagnostics And CLI Maintenance
|
|
||||||
|
|
||||||
Application-owned listener failures provide the selected address and a useful
|
|
||||||
failure category through native CommandKit explanations, preserving the cause
|
|
||||||
and existing status. Short, genuinely shared application configuration
|
|
||||||
diagnostic adaptation is consolidated where it improves maintainability;
|
|
||||||
native evidence selection, headings, bootstrap reporting, and failure precedence
|
|
||||||
remain intact. Small cleanup does not justify additional abstraction machinery.
|
|
||||||
|
|
||||||
PromptKit owns safe structured diagnostics for resource capture and template
|
|
||||||
compilation; ckprompt owns native presentation. At the selected versions,
|
|
||||||
capture failures preserve causes but lack the supported structured diagnostic
|
|
||||||
handoff needed for that improvement. An upstream-ready consumer feature request
|
|
||||||
and explicit adoption deferral are therefore the local outcome. A later
|
|
||||||
supported release can enable adoption for both application and native PromptKit
|
|
||||||
commands. This dependency does not delay other local remediation.
|
|
||||||
|
|
||||||
Generic capture explanations remain until upstream support is available. The
|
|
||||||
application does not parse formatted errors, print arbitrary causes, import
|
|
||||||
upstream internals, or build a framework-error interpreter. Configuration
|
|
||||||
inspection retains its existing lifecycle without capturing message resources.
|
|
||||||
|
|
||||||
## Deferred Work And Operating Limits
|
|
||||||
|
|
||||||
The following remain conditional future work in [future.md](future.md), not
|
|
||||||
delivery commitments:
|
|
||||||
|
|
||||||
- Additional body-read, idle, and response-delivery deadlines.
|
|
||||||
- Aggregate input/memory controls.
|
|
||||||
- Standalone HTTP handler decomposition.
|
|
||||||
- Optional model-mapping simplification if it is not useful alongside the fixes.
|
|
||||||
- Public upstream artifact-reader reuse that preserves access policy and byte
|
|
||||||
enforcement during acquisition, independently of the local reader correction.
|
|
||||||
|
|
||||||
Existing request, per-file, response, and backend controls remain; they do not
|
|
||||||
establish an aggregate-memory budget or whole-HTTP-request lifetime guarantee.
|
|
||||||
The operation budget and shutdown contract remain unchanged. No gateway
|
|
||||||
requirement or broader supported exposure is introduced. Additional controls
|
|
||||||
can be reconsidered when actual workloads or operating needs justify them.
|
|
||||||
Report relocation is accepted local work, not a deferral.
|
|
||||||
|
|
||||||
## Scope Coverage
|
|
||||||
|
|
||||||
Numbers refer to the [audit catalog](audit/catalog.md).
|
|
||||||
|
|
||||||
| Catalog entries | Target disposition |
|
|
||||||
| --- | --- |
|
|
||||||
| 1–3, 9 | Correct acquisition, precision, and file identity; independently verify hashes. |
|
|
||||||
| 4, 7, 11–13 | Strengthen server/test lifetime, startup boundaries, flag rejection, and error assertions. |
|
|
||||||
| 10, 16 | Consolidate HTTP reports and strengthen accounting protection. |
|
|
||||||
| 8 | Improve listener explanations; retain an explicit upstream capture-diagnostic dependency. |
|
|
||||||
| 15 | Simplify genuinely shared CLI diagnostic adaptation where useful. |
|
|
||||||
| 5, 6 | Document existing limits and defer additional controls. |
|
|
||||||
| 14 | Defer standalone restructuring; allow a small adjacent extraction when useful. |
|
|
||||||
| 17 | Allow the nil-aware converter simplification alongside mapping fixes; otherwise defer. |
|
|
||||||
|
|
||||||
## Documentation End State
|
|
||||||
|
|
||||||
Canonical current-state documentation reflects delivered input behavior,
|
|
||||||
report ownership, diagnostic handling, trusted-network maintenance scope, and
|
|
||||||
existing limit boundaries. It preserves upstream ownership and does not imply
|
|
||||||
stronger cancellation, filesystem, shutdown, or resource guarantees.
|
|
||||||
|
|
||||||
`future.md` describes potential future work only. Pending framework-diagnostic
|
|
||||||
adoption is recorded separately from HTTP-only deferrals and is not represented
|
|
||||||
as an implemented fix. All seven audit scope decisions are settled; no
|
|
||||||
significant product decision remains open.
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
# Functional Correctness Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`90f80ef2b7e93fcd83b22b880fb450e969949941`.
|
|
||||||
|
|
||||||
## Scope And Results
|
|
||||||
|
|
||||||
Reviewed local production functions and their interactions across the process
|
|
||||||
entrypoint, native CLI composition, configuration discovery/resolution handoff,
|
|
||||||
request mapping, result/report delivery, HTTP decoding and responses, artifact
|
|
||||||
reading, terminal observations, and server cancellation. Checked behavior
|
|
||||||
against the configuration, CLI, HTTP, operations, and architectural contracts.
|
|
||||||
Also checked the small ReleaseKit launcher/profile and adopted workflow wiring.
|
|
||||||
This is an application audit, not an exhaustive audit of upstream libraries.
|
|
||||||
|
|
||||||
Three reproducible findings warrant remediation consideration. Ordinary
|
|
||||||
configuration, execution, report delivery, error mapping, and shared-server
|
|
||||||
tests passed; passing tests do not cover the boundary cases below.
|
|
||||||
|
|
||||||
## 1. HTTP Provider Parameters Lose Large Integer Precision (P2)
|
|
||||||
|
|
||||||
**Relevant code:** `Handler.ServeHTTP` in
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go), lines 58–60, and
|
|
||||||
`modelOverrideRequestDTO.ExtraParams` in
|
|
||||||
[dto.go](../../../internal/adapter/http/dto.go), line 38.
|
|
||||||
|
|
||||||
**Circumstances:** An HTTP request supplies a provider-specific integer that
|
|
||||||
is not exactly representable as a `float64` inside `model.extra_params`.
|
|
||||||
Nested maps and arrays have the same issue. The
|
|
||||||
[HTTP contract](../../api.md) accepts these provider parameters using
|
|
||||||
PromptKit's JSON-compatible value semantics.
|
|
||||||
|
|
||||||
For example, a request to a configured prompt includes:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{"prompt_id":"selected","model":{"extra_params":{"seed":9007199254740993}}}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Expected:** The provider receives the supplied integer unchanged, provided
|
|
||||||
it is supported by the selected provider. PromptKit accepts this value through
|
|
||||||
its public API as either `int64` or `json.Number` and preserves it on the wire.
|
|
||||||
|
|
||||||
**Actual:** The request decoder does not use `UseNumber`, so decoding into
|
|
||||||
`map[string]any` first converts the number to `float64`. The handler returns
|
|
||||||
HTTP 200, but the local OpenAI-compatible provider receives
|
|
||||||
`9007199254740992`. This silently changes a provider setting such as a seed;
|
|
||||||
the later request mapping cannot recover the original value.
|
|
||||||
|
|
||||||
**Evidence:** A temporary diagnostic used the real HTTP handler, ConfigKit
|
|
||||||
load, PromptKit engine, and a loopback provider. The HTTP path produced the
|
|
||||||
rounded value. Direct calls to the same engine with `int64(9007199254740993)`
|
|
||||||
and `json.Number("9007199254740993")` both sent the exact original integer.
|
|
||||||
Existing `TestHandlerModelOverrideAcceptsJSONCompatibleExtraParams` exercises
|
|
||||||
only small exactly representable numbers, so it passes despite this defect.
|
|
||||||
|
|
||||||
**Potential remediation:** Enable `UseNumber` on the existing request decoder
|
|
||||||
before decoding the DTO. The selected PromptKit version accepts `json.Number`,
|
|
||||||
so the HTTP adapter can preserve the number without a new numeric-conversion
|
|
||||||
layer. Alternatively, retain raw JSON for provider parameters and decode it
|
|
||||||
losslessly before handoff. Preserve strict unknown-field handling, typed
|
|
||||||
numeric-field validation, and trailing-token rejection. Regression coverage
|
|
||||||
should include large integers in nested provider values and the outgoing
|
|
||||||
provider request, not just the intermediate Go map's concrete types.
|
|
||||||
|
|
||||||
## 2. File-Reference Whitespace Can Select A Different Artifact (P3)
|
|
||||||
|
|
||||||
**Relevant code:** `restrictedArtifactReader.resolveLexicalPath` in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go),
|
|
||||||
line 101.
|
|
||||||
|
|
||||||
**Circumstances:** An HTTP file reference names a valid file whose pathname
|
|
||||||
begins or ends with whitespace. The reader applies `strings.TrimSpace` to
|
|
||||||
the request URI before lexical path resolution. Filename whitespace is
|
|
||||||
significant; cleaning path components does not require removing it.
|
|
||||||
|
|
||||||
**Expected:** Resolve the requested pathname beneath the artifact root while
|
|
||||||
preserving its identity, or report a read failure if that file does not exist.
|
|
||||||
The [HTTP file-reference contract](../../api.md) specifies lexical containment,
|
|
||||||
not a whitespace-stripping filename convention. Configuration's documented
|
|
||||||
artifact-root normalization is a separate operation.
|
|
||||||
|
|
||||||
**Actual:** With both ` padded.txt` and `padded.txt` beneath the configured
|
|
||||||
root, requesting ` padded.txt` reads `padded.txt` successfully. The resulting
|
|
||||||
body, URI, size, and hash describe the wrong input. If only the whitespace-
|
|
||||||
named file exists, the otherwise valid reference fails instead.
|
|
||||||
|
|
||||||
**Evidence:** A temporary diagnostic created the two files with distinct
|
|
||||||
contents and invoked the real restricted reader. The requested
|
|
||||||
`" padded.txt"` contained `selected-content`, but the returned body was
|
|
||||||
`different-content` from `padded.txt`. PromptKit's ordinary file reader uses
|
|
||||||
the supplied URI without this trimming.
|
|
||||||
|
|
||||||
**Potential remediation:** Preserve `rawPath` when applying `filepath.Clean`
|
|
||||||
and the existing lexical containment checks. Keep configured-root
|
|
||||||
normalization and the existing empty-URI handling separate. Verify file
|
|
||||||
identity with distinct whitespace/non-whitespace names; this needs no new
|
|
||||||
symlink-resolution or filesystem-sandbox policy.
|
|
||||||
|
|
||||||
## 3. Restricted File Reads Discard Cancellation And Can Stall On FIFOs (P2)
|
|
||||||
|
|
||||||
**Relevant code:** `restrictedArtifactReader.Read`, `readFileArtifact`, and
|
|
||||||
`readArtifactFile` in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go),
|
|
||||||
lines 52–64, 84–96, and 123–148.
|
|
||||||
|
|
||||||
**Circumstances:** Cancellation or an operation deadline occurs after the
|
|
||||||
reader's initial context check. The context is not passed into either file
|
|
||||||
helper. `os.Open` and `io.ReadAll` then run without further cancellation checks
|
|
||||||
or file-kind validation. On Linux, an existing FIFO beneath an allowed root
|
|
||||||
blocks in `os.Open` until a writer connects, even with a positive byte limit.
|
|
||||||
No symlink race, privileged filesystem modification, or real provider is
|
|
||||||
needed to encounter this case.
|
|
||||||
|
|
||||||
**Expected:** File acquisition participates in cooperative cancellation and
|
|
||||||
does not remain indefinitely pending on an unsupported input source. The
|
|
||||||
[source internals](../../internal/sources.md) say reads honor cancellation;
|
|
||||||
the [HTTP contract](../../api.md) includes artifact preparation within the
|
|
||||||
engine operation budget. This does not require forced interruption of every
|
|
||||||
synchronous filesystem operation or an immediate-stop guarantee.
|
|
||||||
|
|
||||||
**Actual:** Canceling an in-flight FIFO read leaves it blocked. After an
|
|
||||||
external writer supplies data and closes, the reader returns a successful
|
|
||||||
artifact with a nil error despite the canceled context. In the actual engine
|
|
||||||
path, a 30 ms operation budget remained pending at 150 ms and completed with
|
|
||||||
an operation-timeout error only after the diagnostic connected a writer.
|
|
||||||
Without that external action, the request can remain stuck.
|
|
||||||
|
|
||||||
**Evidence:** Reproduced directly through the restricted reader and through
|
|
||||||
`Engine.Run` with `WithArtifactReader`, a FIFO input, and an operation budget.
|
|
||||||
Both diagnostic goroutines were released after observation. Existing
|
|
||||||
`TestRestrictedArtifactReaderRejectsCanceledAndMalformedReferences` checks an
|
|
||||||
already-canceled context, not cancellation during acquisition. The selected
|
|
||||||
PromptKit ordinary reader already checks regular-file status before opening
|
|
||||||
and checks context between read chunks; replacing it loses those behaviors.
|
|
||||||
|
|
||||||
**Potential remediation:** Pass the context through file acquisition and
|
|
||||||
perform cooperative checks during reading and before returning the artifact.
|
|
||||||
Align unsupported-file handling with the upstream regular-file reader, which
|
|
||||||
avoids opening an existing FIFO, while retaining the application's lexical
|
|
||||||
root and byte-limit behavior. If streaming/non-regular inputs are intended,
|
|
||||||
they need an explicit cancellation-aware acquisition design instead. Do not
|
|
||||||
introduce an unrelated symlink sandbox, a forced-interruption promise, or a
|
|
||||||
goroutine wrapper that merely abandons a permanently blocked read.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
- Go 1.27.4: uncached `go test ./...` and `go test -race ./...` passed.
|
|
||||||
- `go vet ./...`, a temporary application build, launcher version/shell checks,
|
|
||||||
and whitespace checks passed. The copied delivery workflow still matches
|
|
||||||
the selected upstream template.
|
|
||||||
- Used temporary standalone Go diagnostics and synthetic files/FIFOs with a
|
|
||||||
loopback provider to substantiate all three findings. No new repository
|
|
||||||
tests or production code were introduced; no paid APIs, real credentials,
|
|
||||||
production releases, or external publication were used.
|
|
||||||
- No additional substantiated functional defect was found in the reviewed
|
|
||||||
CLI/configuration/reporting/lifecycle paths. This is not a guarantee that
|
|
||||||
other defects do not exist or that production hosted delivery was tested.
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
# Algorithmic Efficiency Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`7e8eb57c9a05207892fafccdaab6571f5b496a83`.
|
|
||||||
|
|
||||||
## Scope And Results
|
|
||||||
|
|
||||||
Reviewed application-owned production algorithms across configuration loading
|
|
||||||
and validation, native CLI composition, HTTP request mapping, artifact reading,
|
|
||||||
reporting, and server lifecycle. Used the code graph to locate loops, calls,
|
|
||||||
and recursion candidates, then checked their source and data dependencies.
|
|
||||||
Upstream library implementations were outside this application audit.
|
|
||||||
|
|
||||||
No avoidable quadratic algorithm, other substantiated asymptotic inefficiency,
|
|
||||||
or additional correctness issue was discovered within the requested scope.
|
|
||||||
No algorithmic refactoring is recommended by this pass. The three existing
|
|
||||||
findings in the [functional correctness audit](01-correctness.md) remain open;
|
|
||||||
in particular, the artifact cancellation/FIFO finding also affects concurrent
|
|
||||||
request capacity. Those findings are not new discoveries of this audit.
|
|
||||||
|
|
||||||
## Complexity Review
|
|
||||||
|
|
||||||
These estimates describe local work, not the cost of upstream resolution,
|
|
||||||
provider requests, or native rendering. Map operations use expected constant
|
|
||||||
time; string and payload processing also depend on their byte lengths.
|
|
||||||
|
|
||||||
- Configuration validation visits each collection, backend, and profile once:
|
|
||||||
O(C + B + P), plus diagnostic path construction. Collection iteration passes
|
|
||||||
each collection's own resource lists to the validator; it does not rescan all
|
|
||||||
resources for every collection. Raw-key checks are map lookups, not searches.
|
|
||||||
See [document.go](../../../internal/config/document.go).
|
|
||||||
- Override assembly, bootstrap-report bookkeeping, and diagnostic queuing use
|
|
||||||
a constant number of passes over their respective entries. They do not nest
|
|
||||||
growing-list searches or rebuild the configuration for each entry. CLI flag
|
|
||||||
declaration loops operate on fixed-size application lists. See
|
|
||||||
[load.go](../../../internal/config/load.go),
|
|
||||||
[bootstrap.go](../../../internal/adapter/cli/bootstrap.go), and
|
|
||||||
[native_run.go](../../../internal/adapter/cli/native_run.go).
|
|
||||||
- HTTP input mapping is expected O(I) for I inputs and allocates O(I) map
|
|
||||||
entries. Path normalization and lexical containment checks use a constant
|
|
||||||
number of path-length-dependent operations, not filesystem tree searches.
|
|
||||||
Reading and hashing N acquired artifact bytes takes amortized O(N) time and
|
|
||||||
O(N) body storage. The cancellation defect linked above is separate from
|
|
||||||
these byte-processing costs. See
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go) and
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go).
|
|
||||||
- The report collector keeps one fixed-schema terminal snapshot, rather than
|
|
||||||
accumulating observation history. Observation and snapshot work are constant
|
|
||||||
in the number of execution events; retained string sizes depend on their
|
|
||||||
contents. The HTTP server constructs one shared engine before serving, not
|
|
||||||
a new catalog or engine per request. See
|
|
||||||
[report.go](../../../internal/report/report.go) and
|
|
||||||
[server.go](../../../internal/adapter/cli/server.go).
|
|
||||||
|
|
||||||
## Selected Designs And Limits
|
|
||||||
|
|
||||||
The documented single-load/shared-engine lifecycles, complete artifact bodies,
|
|
||||||
complete-response JSON encoding before size enforcement, and compact error
|
|
||||||
fallback were expressly selected designs and were not reconsidered. The JSON
|
|
||||||
error fallback is bounded for the application's fixed string-only error
|
|
||||||
envelope; the apparent call-graph cycle is not data-growing recursion.
|
|
||||||
Standard JSON encoding can sort map keys; no additional application-level
|
|
||||||
quadratic serialization loop was found.
|
|
||||||
|
|
||||||
This was a static complexity and correctness review, not a performance study.
|
|
||||||
No benchmarks or production measurements were collected. No application code
|
|
||||||
or tests changed; documentation links and whitespace were checked. These
|
|
||||||
results do not guarantee the absence of defects or runtime bottlenecks.
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
# Maintainability And Complexity Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`8e31004270f52211e2c7f05d257c1237f1512ea1`.
|
|
||||||
|
|
||||||
## Scope And Method
|
|
||||||
|
|
||||||
Reviewed application-owned functions, file responsibilities, package boundaries,
|
|
||||||
and representative integration tests. Used codebase-memory-mcp's function and
|
|
||||||
method inventory, cyclomatic/cognitive estimates, and call/import information
|
|
||||||
to locate candidates, then checked the source. Graph resolution can confuse
|
|
||||||
identically named symbols; source imports and actual calls determined package
|
|
||||||
relationships. Separate `gocyclo`, `gocognit`, and `golangci-lint` commands were
|
|
||||||
not installed. No performance measurements or empirical testing were needed.
|
|
||||||
|
|
||||||
The following production hotspots illustrate the graph's estimates. These are
|
|
||||||
navigation aids, not standardized measurements, refactoring requirements, or
|
|
||||||
proposed complexity limits.
|
|
||||||
|
|
||||||
| Function | Source lines | Cyclomatic estimate | Cognitive estimate |
|
|
||||||
| --- | ---: | ---: | ---: |
|
|
||||||
| CLI `requestFailure` | 36 | 16 | 51 |
|
|
||||||
| HTTP `ServeHTTP` | 143 | 22 | 31 |
|
|
||||||
| HTTP `mapRunError` | 34 | 16 | 31 |
|
|
||||||
| CLI `queueDiagnostics` | 18 | 7 | 17 |
|
|
||||||
| Configuration `validateDocument` | 35 | 11 | 14 |
|
|
||||||
|
|
||||||
Three opportunities warrant consideration: two within adapter packages and
|
|
||||||
one across the HTTP/report package boundary. They are maintainability
|
|
||||||
improvements, not release blockers or findings that the architecture needs
|
|
||||||
replacement. No additional correctness bug was discovered. The three existing
|
|
||||||
findings in [01-correctness.md](01-correctness.md) remain open and take priority
|
|
||||||
over optional cleanup.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
Scriptorium remains a thin CLI/HTTP executable. ConfigKit resolves the shared
|
|
||||||
application document; PromptKit owns definitions, preparation, and execution;
|
|
||||||
CommandKit and its integrations own native CLI workflows and presentation.
|
|
||||||
The HTTP service shares one engine and adds transport/deployment policy.
|
|
||||||
ReleaseKit owns release mechanics. There is no application framework facade
|
|
||||||
or durable execution workflow. See the
|
|
||||||
[component overview](../../internal/overview.md) and
|
|
||||||
[adapter internals](../../internal/adapters.md).
|
|
||||||
|
|
||||||
## 1. Separate The HTTP Handler's Request And Response Phases
|
|
||||||
|
|
||||||
**Priority:** Medium. **Scope:** Within `internal/adapter/http`.
|
|
||||||
|
|
||||||
**Evidence:** `Handler.ServeHTTP`, lines 43–185 of
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go), combines routing,
|
|
||||||
limited strict JSON decoding, trailing-token checks, request validation,
|
|
||||||
PromptKit request construction, observer setup, execution, context-sensitive
|
|
||||||
error classification, and success DTO construction. The response literal alone
|
|
||||||
maps artifact, validation, metadata, usage, and optional report/output fields.
|
|
||||||
Decode failures repeat the same size-versus-invalid-JSON response selection.
|
|
||||||
|
|
||||||
**Why this matters:** Independent transport and projection changes all touch
|
|
||||||
the orchestration method. A reader must distinguish pre-execution failures
|
|
||||||
from execution failures while also reviewing field-by-field mapping. This
|
|
||||||
mixes responsibilities beyond the necessary complexity of the HTTP contract.
|
|
||||||
|
|
||||||
**Potential refactoring:** Extract a few cohesive private helpers for strict
|
|
||||||
request decoding, validated DTO-to-RunRequest mapping, and RunResult-to-response
|
|
||||||
projection. Keep `ServeHTTP` as the readable request lifecycle, including one
|
|
||||||
execution and optional collector attachment. Move pure projection helpers out
|
|
||||||
of the orchestration file if that improves navigation; avoid an interface or
|
|
||||||
generic middleware pipeline for every phase.
|
|
||||||
|
|
||||||
Preserve the existing wire format, numeric presence, native validation handoff,
|
|
||||||
context/error precedence, report opt-in, and complete-response size handling.
|
|
||||||
The earlier precision finding should be fixed explicitly rather than preserved
|
|
||||||
as incidental decoding behavior. Existing HTTP behavioral tests remain the
|
|
||||||
primary protection; extraction alone does not justify duplicate helper tests.
|
|
||||||
|
|
||||||
## 2. Consolidate CLI Configuration Diagnostics And Flatten Failure Selection
|
|
||||||
|
|
||||||
**Priority:** Medium. **Scope:** Within `internal/adapter/cli`, at its ConfigKit
|
|
||||||
handoff.
|
|
||||||
|
|
||||||
**Evidence:** `runPrompt`, lines 77–89 of
|
|
||||||
[native_run.go](../../../internal/adapter/cli/native_run.go), and
|
|
||||||
`serveWithListener`, lines 23–35 of
|
|
||||||
[server.go](../../../internal/adapter/cli/server.go), repeat the same evidence
|
|
||||||
selection: read sources/findings from a successful result, prefer a wrapped
|
|
||||||
`configkit.LoadError` when present, adapt diagnostics, then queue them.
|
|
||||||
`frameworkFailure` in
|
|
||||||
[outcomes.go](../../../internal/adapter/cli/outcomes.go) performs related native
|
|
||||||
error adaptation. The same file's `requestFailure` nests configuration-error
|
|
||||||
classification and a second sentinel switch inside the default of the initial
|
|
||||||
timeout/cancellation switch.
|
|
||||||
|
|
||||||
**Why this matters:** Several entry points independently implement the same
|
|
||||||
configuration-evidence bridge. Maintaining safe diagnostics and precedence
|
|
||||||
requires inspecting multiple command paths. The nested failure selection adds
|
|
||||||
mental bookkeeping even though its intended priority is an ordered sequence.
|
|
||||||
This is a drift risk, not evidence of a newly demonstrated behavior mismatch.
|
|
||||||
|
|
||||||
**Potential refactoring:** Give the repeated result/error evidence selection
|
|
||||||
and native adaptation one small CLI-local helper, then let callers queue its
|
|
||||||
diagnostics and use its explanation. Reuse that extraction where appropriate
|
|
||||||
for engine-construction errors while retaining their distinct heading and
|
|
||||||
explanation composition. Flatten `requestFailure` into an ordered selection
|
|
||||||
with configuration classification after timeout/cancellation and before the
|
|
||||||
remaining PromptKit failure cases.
|
|
||||||
|
|
||||||
Keep the actual ConfigKit result and typed errors, their causes, safe native
|
|
||||||
writers, and current classification precedence. Leave resolution in
|
|
||||||
`internal/config` and standard inspection in ckconfig/ckprompt. This does not
|
|
||||||
call for another load, cache, reconstructed evidence model, acquisition
|
|
||||||
framework, or combined CLI/HTTP error classifier. The adapters intentionally
|
|
||||||
have different outcome policies.
|
|
||||||
|
|
||||||
## 3. Co-locate The HTTP-Only Execution Projection With Its Consumer
|
|
||||||
|
|
||||||
**Priority:** Low; optional package-boundary simplification.
|
|
||||||
**Scope:** Across `internal/report` and `internal/adapter/http`.
|
|
||||||
|
|
||||||
**Evidence:** [report.go](../../../internal/report/report.go) is 104 lines and
|
|
||||||
exposes `Collector`, `Execution`, `Usage`, and `TokenCount` plus their collection
|
|
||||||
API. The package defines HTTP JSON field names, millisecond conversions,
|
|
||||||
and bounded outcome/failure vocabulary. Its only production consumer is the
|
|
||||||
HTTP adapter: [dto.go](../../../internal/adapter/http/dto.go) embeds the report
|
|
||||||
type in success and error responses, and `ServeHTTP` creates and reads the
|
|
||||||
collector. CLI delivery uses the native RunResult rather than this package.
|
|
||||||
|
|
||||||
**Why this matters:** This is not a complex algorithm. It is an opportunity to
|
|
||||||
reduce conceptual surface: one HTTP representation spans a general-sounding
|
|
||||||
package, an exported cross-package API, and the adapter's DTOs. HTTP report
|
|
||||||
changes require following that boundary even though there is no second
|
|
||||||
production consumer.
|
|
||||||
|
|
||||||
**Potential refactoring:** Move the collector, projection, and focused tests
|
|
||||||
into a dedicated HTTP adapter file, keeping implementation types private where
|
|
||||||
practical. Retain existing JSON shapes, terminal-only collection, unknown-value
|
|
||||||
handling, detached snapshots, and per-request ownership. Update the component
|
|
||||||
inventory if the package is removed. No public HTTP change or CLI reporting
|
|
||||||
redesign is needed.
|
|
||||||
|
|
||||||
Keeping the small separate package is also reasonable if its isolated
|
|
||||||
responsibility is judged more valuable than reducing the boundary. Current
|
|
||||||
usage does not justify adding a shared reporting interface or speculative
|
|
||||||
multi-adapter framework.
|
|
||||||
|
|
||||||
## Candidates That Do Not Warrant Additional Refactoring Now
|
|
||||||
|
|
||||||
- `mapRunError` is already a flat, ordered mapping of distinct public errors.
|
|
||||||
Its branch count mostly represents necessary HTTP policy. Replacing it with
|
|
||||||
a registry or universal classifier would obscure precedence without a clear
|
|
||||||
maintenance benefit. `queueDiagnostics` similarly expresses four distinct
|
|
||||||
native delivery choices directly.
|
|
||||||
- Configuration validation contains short domain checks and resource loops;
|
|
||||||
it does not need a validator framework or generalized visitor.
|
|
||||||
- `handler_test.go` is large (1,948 lines), and lifecycle tests have high graph
|
|
||||||
estimates. Source review shows much of that complexity comes from explicit
|
|
||||||
assertions, cancellation coordination, and meaningful integration phases.
|
|
||||||
Grouping HTTP tests into behavior-focused files is a reasonable navigation
|
|
||||||
cleanup when those areas change, but size alone does not justify rewriting
|
|
||||||
them or hiding synchronization in a fixture framework.
|
|
||||||
- The remaining CLI composition/loading helpers, terminal projection logic,
|
|
||||||
process entrypoint, and ReleaseKit launcher are small and direct. Preserve
|
|
||||||
the existing native ownership and shared-server lifecycle rather than adding
|
|
||||||
layers solely to reduce a metric.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
This pass changes only this audit document. Source locations, package consumers,
|
|
||||||
documentation links, and whitespace were checked. No application tests or
|
|
||||||
benchmarks were run, and no refactor was implemented. The findings are scoped
|
|
||||||
recommendations, not a guarantee that other maintainability or correctness
|
|
||||||
issues do not exist.
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
# Concurrency Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`900d956aee54eb1e471358211107b3a132ffa6c8`.
|
|
||||||
|
|
||||||
## Scope And Results
|
|
||||||
|
|
||||||
Reviewed application-owned shared state, goroutine/channel ownership,
|
|
||||||
cancellation, shutdown, CLI acquisition/delivery, and concurrency-sensitive
|
|
||||||
tests. Used codebase-memory-mcp to locate concurrency primitives, state, and
|
|
||||||
their callers, then checked source and the relevant library contracts.
|
|
||||||
Checked PromptKit's public concurrency/observer contract in the selected
|
|
||||||
v0.25.0 module, rather than assuming a local upstream checkout matched it.
|
|
||||||
This was not an exhaustive audit of upstream library implementations.
|
|
||||||
|
|
||||||
Two findings warrant consideration: the existing production artifact-reader
|
|
||||||
cancellation defect, reconfirmed across an actual HTTP connection, and a
|
|
||||||
test-only worker-lifetime weakness. No additional production data race,
|
|
||||||
deadlock, or unsafe channel operation was substantiated. Passing race tests
|
|
||||||
do not establish cancellation or liveness correctness.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
ConfigKit resolves configuration before engine construction. CommandKit and
|
|
||||||
its integrations own native CLI acquisition and presentation; PromptKit owns
|
|
||||||
execution, retries, admission, and backend queues. The HTTP service constructs
|
|
||||||
one engine and shares it across requests. Handler options and restricted-reader
|
|
||||||
settings are initialized before serving; execution inputs and optional report
|
|
||||||
collectors are request-local. ReleaseKit owns release mechanics. See the
|
|
||||||
[component overview](../../internal/overview.md) and
|
|
||||||
[adapter internals](../../internal/adapters.md).
|
|
||||||
|
|
||||||
## 1. File Acquisition Can Outlive Request Cancellation (P2, Previously Known)
|
|
||||||
|
|
||||||
**Relevant code:** `restrictedArtifactReader.Read`, `readFileArtifact`, and
|
|
||||||
`readArtifactFile` in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go),
|
|
||||||
lines 52–67, 84–96, and 123–148; their invocation through
|
|
||||||
`Handler.ServeHTTP` in
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go).
|
|
||||||
|
|
||||||
**Circumstances:** A file read starts while its context is live, then the
|
|
||||||
client disconnects, an operation budget expires, or shutdown cancels the
|
|
||||||
request. The reader checks context only on entry and does not pass it to the
|
|
||||||
file helpers. An existing FIFO inside the allowed root can block opening or
|
|
||||||
remain in `io.ReadAll` while a writer keeps it open without completing input.
|
|
||||||
The configured byte limit does not bound that wait.
|
|
||||||
|
|
||||||
**Consequences:** The HTTP handler/engine invocation can remain pending after
|
|
||||||
the request context is canceled, retaining a request goroutine and potentially
|
|
||||||
an open file until an external filesystem participant releases it. Repeated
|
|
||||||
abandoned requests can accumulate pending work in a long-running server. The
|
|
||||||
reader can subsequently return successful data despite cancellation. This is
|
|
||||||
not a claim that input preparation has already acquired a backend admission
|
|
||||||
slot, or that every synchronous filesystem call must stop immediately.
|
|
||||||
|
|
||||||
**Evidence:** A temporary standalone diagnostic used the real HTTP handler and
|
|
||||||
restricted reader with a small Runner stub, a loopback HTTP connection, and a
|
|
||||||
synthetic FIFO. Opening its writer established that acquisition had passed the
|
|
||||||
initial context check. Canceling the HTTP client canceled the server request
|
|
||||||
context, but the handler was still pending after a bounded 200 ms observation.
|
|
||||||
Only writing and closing the FIFO released it; the reader returned a nil error
|
|
||||||
with `ctx.Err() == context.Canceled`. The diagnostic then joined the handler,
|
|
||||||
client, and server and completed under the race detector without a race report.
|
|
||||||
The real-engine operation-budget manifestation is already documented in
|
|
||||||
[finding 3 of the correctness audit](01-correctness.md#3-restricted-file-reads-discard-cancellation-and-can-stall-on-fifos-p2).
|
|
||||||
This is the same unresolved defect, not a second independent production bug.
|
|
||||||
|
|
||||||
**Potential remediation:** Thread the context through acquisition and check it
|
|
||||||
during reads and before successful completion. Align unsupported-file handling
|
|
||||||
with the selected upstream ordinary reader, which avoids opening an existing
|
|
||||||
FIFO as a regular artifact. If non-regular streaming sources are intended,
|
|
||||||
their acquisition needs an explicitly cancellation-aware design. Preserve the
|
|
||||||
existing lexical-root and byte-limit policy. A goroutine wrapper that merely
|
|
||||||
abandons a blocked read would conceal, rather than fix, the lifetime problem.
|
|
||||||
No symlink sandbox, forced-interruption guarantee, or graceful-drain guarantee
|
|
||||||
is needed to address this defect.
|
|
||||||
|
|
||||||
## 2. Shared-Capacity Test Does Not Own Workers On Failure Paths (P3, Test Only)
|
|
||||||
|
|
||||||
**Relevant code:** `TestHandlerSharesBackendCapacityAcrossConcurrentRequests`,
|
|
||||||
particularly lines 1087–1118 of
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go), and its
|
|
||||||
`blockingLLMClient.Generate`, lines 437–456.
|
|
||||||
|
|
||||||
**Circumstances:** The first handler runs in a goroutine with an uncancelable
|
|
||||||
request context. Its fake generator waits for `client.release` or context
|
|
||||||
cancellation. The test closes `release` only on the successful path, after
|
|
||||||
several assertions. An earlier `t.Fatal` bypasses that release and the normal
|
|
||||||
join. Separately, if a capacity regression admits the second request to the
|
|
||||||
blocking client, the test's synchronous second `ServeHTTP` call waits for the
|
|
||||||
release that the test will perform only after that call returns. That call has
|
|
||||||
no test-controlled deadline or cancellation.
|
|
||||||
|
|
||||||
**Consequences:** A failing assertion can leave the first worker pending;
|
|
||||||
a capacity regression can stall the test instead of producing a bounded,
|
|
||||||
useful failure. The first-start and first-completion timers do not protect
|
|
||||||
the intervening synchronous call. This affects test reliability and regression
|
|
||||||
diagnosis, not production capacity enforcement.
|
|
||||||
|
|
||||||
**Evidence:** Source inspection of the failure/control-flow paths. The current
|
|
||||||
successful path passed both the full race suite and five focused repetitions;
|
|
||||||
those runs do not exercise the missing failure cleanup. No capacity regression
|
|
||||||
was introduced to force this test to fail.
|
|
||||||
|
|
||||||
**Potential remediation:** Give the requests test-controlled cancellable
|
|
||||||
contexts, register cleanup before launching the first worker, and cancel and
|
|
||||||
join owned work on failure as well as success. Bound the second request so
|
|
||||||
unexpected admission cannot trap the test before its cleanup runs. Keep one
|
|
||||||
clear owner for closing `release`, and retain the existing behavioral checks
|
|
||||||
for capacity rejection, shared peak concurrency, and response privacy. This
|
|
||||||
needs focused cleanup, not a new fixture framework or production time limit.
|
|
||||||
|
|
||||||
## Other Ownership And Ordering Checks
|
|
||||||
|
|
||||||
- **Server shutdown:** In `serveWithListener`, lines 57–64 of
|
|
||||||
[server.go](../../../internal/adapter/cli/server.go), the AfterFunc callback
|
|
||||||
writes `cancellationCloseErr` before closing `closed`. If stopping the callback
|
|
||||||
succeeds, it cannot run; otherwise the serving goroutine receives from
|
|
||||||
`closed` before reading the error. This supplies the required synchronization
|
|
||||||
without a mutex. Callback ownership and channel closure are single-owner.
|
|
||||||
`Server.Close` intentionally closes connections without joining arbitrary
|
|
||||||
context-ignoring handler work; that is the selected
|
|
||||||
[shutdown contract](../../operations.md#http-deployment-and-shutdown), not an
|
|
||||||
additional finding.
|
|
||||||
- **Shared engine and reader:** One engine is constructed before serving;
|
|
||||||
request overrides do not rewrite its defaults. PromptKit supports concurrent
|
|
||||||
runs and owns backend synchronization. Restricted-reader settings are
|
|
||||||
read-only during service, with per-call handles and bodies. Existing tests
|
|
||||||
protect cross-request admission, retry sharing, and canceled capacity waits.
|
|
||||||
- **Report observation:** Each opted-in request creates its own
|
|
||||||
[collector](../../../internal/report/report.go). PromptKit delivers observer
|
|
||||||
callbacks synchronously; the handler snapshots only after Run returns.
|
|
||||||
No collector is shared between requests or handed to an application-owned
|
|
||||||
background goroutine. Its lack of a mutex is not a race in this lifecycle.
|
|
||||||
- **CLI and configuration:** The bootstrap sink belongs to its invocation.
|
|
||||||
Server acquisition occurs before listening; native comparison effects are
|
|
||||||
sequential. The process environment is deliberately shared under ConfigKit's
|
|
||||||
native bootstrap semantics, not a per-request credential snapshot. No
|
|
||||||
concurrent reload path was found. Delivery is sequential and report-file
|
|
||||||
rendering occurs outside reporter callbacks, avoiding reentrant rendering.
|
|
||||||
Caller-owned output paths have no cross-process serialization contract.
|
|
||||||
- **Process and tests:** Signal-context registration is released with its
|
|
||||||
deferred stop function. Reviewed lifecycle tests use cancellation, channel
|
|
||||||
handoffs, and atomic counters; response/buffer reads follow completion on
|
|
||||||
their normal paths. The specific missing failure cleanup is identified above.
|
|
||||||
No parallel tests changing cwd/environment were found. The local release
|
|
||||||
launcher introduces no separate background-worker ownership.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
- Go 1.27.0 on Linux/amd64: `go test -race -count=1 ./...` passed.
|
|
||||||
- Five race-enabled repetitions of the existing server cancellation/bootstrap,
|
|
||||||
concurrent-report isolation, shared backend capacity, retry-capacity, and
|
|
||||||
canceled-capacity-wait tests passed.
|
|
||||||
- `go vet ./...` passed. Documentation links and whitespace were checked.
|
|
||||||
- The temporary cancellation diagnostic used no provider, credentials, or
|
|
||||||
external service; all its pending work was released and joined.
|
|
||||||
- No production code or repository tests were changed or added. Race detection
|
|
||||||
covers executed paths, not all schedules; this audit does not establish a
|
|
||||||
universal absence of races, deadlocks, or leaks in dependencies or unexercised
|
|
||||||
paths.
|
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
# Resource Management Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`029cb863280c37cb9688162e4542ddd5cba23ef4`.
|
|
||||||
|
|
||||||
## Scope And Results
|
|
||||||
|
|
||||||
Reviewed application-owned memory/buffer lifetimes, file handles, network
|
|
||||||
connections, timers, goroutines, cancellation, error cleanup, and resource
|
|
||||||
limits. Used codebase-memory-mcp to locate acquisitions and their callers,
|
|
||||||
checked the source and contracts, and ran relevant existing tests and small
|
|
||||||
standalone diagnostics. Checked the selected PromptKit v0.25.0 handoff where
|
|
||||||
resource ownership crosses the application/library boundary; this was not an
|
|
||||||
exhaustive audit of upstream implementations.
|
|
||||||
|
|
||||||
Two additional deployment-dependent resource-budget gaps warrant consideration:
|
|
||||||
HTTP connection/body lifetimes and aggregate input memory. Neither violates an
|
|
||||||
existing promise that these resources have a fixed bound. Two unresolved
|
|
||||||
cleanup findings from the concurrency audit also apply here. No additional
|
|
||||||
ordinary file-close leak, unowned recurring timer, or persistent application
|
|
||||||
result-history retention was substantiated.
|
|
||||||
|
|
||||||
The proposed controls below are options for an explicit deployment/product
|
|
||||||
decision, not new mandatory limits or guarantees established by this audit.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
ConfigKit owns acquisition through resolved configuration; PromptKit owns
|
|
||||||
execution, backend admission, retries, and provider clients. CommandKit owns
|
|
||||||
native CLI workflows and presentation. Scriptorium owns its inbound HTTP
|
|
||||||
transport, restricted artifact policy, CLI report-file effects, and process
|
|
||||||
lifecycle. The server retains one engine; requests have separate inputs,
|
|
||||||
results, and optional terminal collectors. ReleaseKit owns release mechanics.
|
|
||||||
See the [component overview](../../internal/overview.md) and
|
|
||||||
[adapter internals](../../internal/adapters.md).
|
|
||||||
|
|
||||||
## 1. HTTP Connections Can Retain Resources Outside The Execution Budget
|
|
||||||
|
|
||||||
**Classification:** Deployment-dependent weakness; additional lifetime controls
|
|
||||||
require a policy choice.
|
|
||||||
|
|
||||||
**Relevant code:** `serveWithListener`, particularly lines 47–51 of
|
|
||||||
[server.go](../../../internal/adapter/cli/server.go), and `Handler.ServeHTTP`,
|
|
||||||
lines 53–78 and 128–185 of
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go).
|
|
||||||
|
|
||||||
**Circumstances:** The server sets ReadHeaderTimeout but leaves ReadTimeout,
|
|
||||||
IdleTimeout, and WriteTimeout unset. A client can send complete headers and
|
|
||||||
then stall partway through a body below MaxRequestBytes. The JSON decoder
|
|
||||||
continues waiting before Engine.Run starts. Idle keep-alive connections and
|
|
||||||
response writes have no configured application-side lifetime bound either.
|
|
||||||
In Go's server, zero IdleTimeout falls back to ReadTimeout, also zero here.
|
|
||||||
The engine operation budget intentionally excludes decoding and delivery.
|
|
||||||
|
|
||||||
**Consequences:** A stalled upload can hold a connection descriptor, handler
|
|
||||||
goroutine, and decoding state without consuming a backend admission slot.
|
|
||||||
Many such clients can exhaust resources independently of model concurrency
|
|
||||||
settings. Idle clients retain connection resources; a reader that stops
|
|
||||||
consuming a sufficiently large response can also retain a pending write and
|
|
||||||
its encoded buffer. Byte limits bound sizes, not these lifetimes. This matters
|
|
||||||
when clients can reach the listener without corresponding gateway controls,
|
|
||||||
including malfunctioning clients on an otherwise trusted network.
|
|
||||||
|
|
||||||
**Evidence:** A temporary diagnostic launched the actual `serve` command on
|
|
||||||
loopback with normal defaults. It sent complete HTTP headers, a declared
|
|
||||||
1,024-byte body, and an incomplete JSON prefix containing a one-second run
|
|
||||||
timeout. The connection remained pending through an 11-second observation,
|
|
||||||
beyond the configured 10-second header timeout. Closing the connection and
|
|
||||||
canceling the command released the diagnostic server. This establishes the
|
|
||||||
body-read case; idle/write implications follow from the server fields and the
|
|
||||||
installed Go standard-library documentation, not a separate saturation test.
|
|
||||||
|
|
||||||
**Potential remediation:** For gateway deployments, explicitly select and
|
|
||||||
document body-progress/read, idle, response-delivery, and connection/request
|
|
||||||
controls at that boundary as appropriate. For direct deployments, consider
|
|
||||||
application-owned configurable timeouts or phase-specific read/write deadlines
|
|
||||||
through standard net/http APIs. Values and defaults need an explicit decision;
|
|
||||||
a short global WriteTimeout can incorrectly cut off legitimate long inference
|
|
||||||
because it starts before response delivery. Merely adding a context deadline
|
|
||||||
around a blocking body decoder does not establish an underlying read deadline.
|
|
||||||
Keep the engine operation budget's existing meaning and the selected shutdown
|
|
||||||
contract; this finding does not request a new graceful-drain guarantee.
|
|
||||||
|
|
||||||
## 2. Existing Byte Limits Are Not An Aggregate Memory Budget
|
|
||||||
|
|
||||||
**Classification:** Capacity-planning weakness; additional budgeting is an
|
|
||||||
optional deployment/product decision, not a misimplemented per-file limit.
|
|
||||||
|
|
||||||
**Relevant code:** `Handler.ServeHTTP` input mapping in
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go), `readArtifactFile` in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go), and
|
|
||||||
the handoff through `newEngine` in
|
|
||||||
[engine.go](../../../internal/adapter/cli/engine.go).
|
|
||||||
|
|
||||||
**Circumstances:** The request limit counts encoded references, whereas the
|
|
||||||
artifact limit applies independently to each referenced file. PromptKit
|
|
||||||
materializes the supplied artifacts for rendering. A small request can name
|
|
||||||
many individually permitted files, and the same file can appear under distinct
|
|
||||||
input names. Consequently, neither the encoded request cap nor the per-file
|
|
||||||
cap bounds the sum of acquired file bodies to that configured byte value.
|
|
||||||
|
|
||||||
**Consequences:** For N files of up to B bytes, materialized input alone can
|
|
||||||
approach N × B, before rendering and other copies. Fifty permitted 16 MiB
|
|
||||||
files can therefore require 800 MiB of input bodies for one run. Simultaneous
|
|
||||||
admitted runs add their working sets. This can exhaust a modest host even
|
|
||||||
though each individual request and file meets its documented limits.
|
|
||||||
|
|
||||||
**Evidence:** A temporary diagnostic used the real application ConfigKit load,
|
|
||||||
PromptKit engine, restricted reader, and a synthetic in-process model client.
|
|
||||||
With a six-byte per-file limit and backend concurrency one, one successful
|
|
||||||
run read two six-byte files: twelve acquired bytes. Only tiny synthetic files
|
|
||||||
were used; no large-memory workload or performance benchmark was run.
|
|
||||||
Selected-library source inspection also confirmed that ordinary Engine.Run
|
|
||||||
acquires backend admission before loading the input bodies. Backend limits
|
|
||||||
therefore do protect that phase for limited backends; this is not an
|
|
||||||
admission-ordering defect. They do not make one admitted run's footprint
|
|
||||||
equal to a single-file cap.
|
|
||||||
|
|
||||||
**Potential remediation:** Document and size the complete resource envelope:
|
|
||||||
number/size of inputs, rendering expansion, admitted runs, and delivery buffers.
|
|
||||||
Choose appropriate existing file and backend limits for the deployment. If a
|
|
||||||
harder memory envelope is needed, consider an explicit aggregate artifact
|
|
||||||
budget and whole-HTTP-request admission, using a native PromptKit capability
|
|
||||||
or an upstream extension for library-owned acquisition where appropriate.
|
|
||||||
A gateway can bound requests/connections but cannot infer referenced-file
|
|
||||||
bytes from the encoded request size alone. Any additional rejection policy
|
|
||||||
needs agreement; preserve valid definition semantics and avoid recreating
|
|
||||||
PromptKit's orchestration or constructing separate per-request engines.
|
|
||||||
|
|
||||||
## Previously Recorded Cleanup Findings Still Apply
|
|
||||||
|
|
||||||
- **Canceled file reads (production, P2):**
|
|
||||||
[Concurrency finding 1](04-concurrency.md#1-file-acquisition-can-outlive-request-cancellation-p2-previously-known)
|
|
||||||
covers `Read`/`readArtifactFile` in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go).
|
|
||||||
Cancellation after entry can leave a FIFO read pending, retaining its
|
|
||||||
goroutine and potentially an open descriptor until external input releases
|
|
||||||
it. The deferred Close cannot run until the read returns. Thread context
|
|
||||||
through acquisition, perform cooperative checks, and align unsupported-file
|
|
||||||
handling with the ordinary upstream reader. This remains the confirmed
|
|
||||||
cleanup defect, not merely a proposal for new resource caps.
|
|
||||||
- **Capacity-test failure cleanup (test only, P3):**
|
|
||||||
[Concurrency finding 2](04-concurrency.md#2-shared-capacity-test-does-not-own-workers-on-failure-paths-p3-test-only)
|
|
||||||
covers `TestHandlerSharesBackendCapacityAcrossConcurrentRequests` and its
|
|
||||||
blocking client in [handler_test.go](../../../internal/adapter/http/handler_test.go).
|
|
||||||
Early failures bypass the successful-path release/join, and unexpected
|
|
||||||
second-request admission can stall the test. Add test-controlled cancellation,
|
|
||||||
failure-path cleanup/join, and a bound on the second request. No production
|
|
||||||
limit change is needed. These are the existing findings, not new discoveries.
|
|
||||||
|
|
||||||
## Other Lifecycle Checks And Selected Tradeoffs
|
|
||||||
|
|
||||||
- Ordinary restricted file reads defer Close immediately after a successful
|
|
||||||
Open, including stat, size-limit, and read-error returns. The max-plus-one
|
|
||||||
read detects oversize data without integer overflow. The cancellation case
|
|
||||||
above is the outstanding exception to timely cleanup, not a missing defer.
|
|
||||||
- CLI `writeNativeReport` closes its file after native rendering and joins
|
|
||||||
rendering/close errors. Resultless failures do not open the report. Main
|
|
||||||
streams and output retention remain caller-owned; nontransactional writes
|
|
||||||
and partial files are documented choices, not handle leaks.
|
|
||||||
- The server closes listeners/connections on cancellation and unexpected exit,
|
|
||||||
and stops or joins its AfterFunc callback. Signal registration has a deferred
|
|
||||||
stop. There is no application-owned recurring ticker or background work queue.
|
|
||||||
- Collectors retain only one terminal metadata snapshot per opted-in request.
|
|
||||||
The application adds no cross-request result cache or execution history.
|
|
||||||
Configuration diagnostics/bootstrap writers are invocation-local; server
|
|
||||||
configuration/engine lifetime is process-scoped rather than per request.
|
|
||||||
- Complete artifact bodies and JSON response encoding before size enforcement
|
|
||||||
are selected designs. The response cap is a wire-size policy, not a bound on
|
|
||||||
provider output or peak encoding memory. This audit does not propose silently
|
|
||||||
replacing those designs with custom streaming/serialization. Their working
|
|
||||||
sets belong in the capacity envelope discussed above.
|
|
||||||
- Provider connection pooling, engine timers, and framework source handles are
|
|
||||||
upstream-owned. The application does not create a new engine/client per HTTP
|
|
||||||
request. The ReleaseKit launcher uses exec, and its adopted delivery workflow
|
|
||||||
registers cleanup for its temporary bootstrap directory.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
- Go 1.27.0 on Linux/amd64: uncached focused HTTP limit/artifact-reader, CLI
|
|
||||||
delivery/failure, and terminal-collector tests passed.
|
|
||||||
- Both temporary diagnostics completed under the race detector. They used
|
|
||||||
loopback or in-process collaborators, no paid provider, and no credentials;
|
|
||||||
their controlled connections/work were released.
|
|
||||||
- Confirmed no application/tool code changes since the preceding audit; its
|
|
||||||
successful full race suite and vet results remain applicable evidence for
|
|
||||||
unchanged paths, not new resource-leak coverage.
|
|
||||||
- Documentation links and whitespace were checked. Only this audit document
|
|
||||||
was added; no production code or repository tests were changed.
|
|
||||||
- No memory/descriptor saturation, production measurements, or performance
|
|
||||||
benchmarks were conducted. No diagnostic attempts to prove that all possible
|
|
||||||
resource leaks or exhaustion cases are absent.
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
# Error-Handling Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`8cfe330194ea0a4d06ede98655d886ede0dcc4e1`.
|
|
||||||
|
|
||||||
## Scope And Results
|
|
||||||
|
|
||||||
Reviewed error detection, wrapping, classification, diagnostics, serialization
|
|
||||||
fallbacks, file/output failures, configuration/bootstrap failures, cancellation,
|
|
||||||
and shutdown across application packages and their dependency boundaries.
|
|
||||||
Used codebase-memory-mcp for discovery and source inspection, checked contracts
|
|
||||||
and existing tests, and ran standalone diagnostics against the real CLI.
|
|
||||||
Checked the selected PromptKit v0.25.0 and CommandKit v0.8.0 behavior where it
|
|
||||||
determines what the executable actually reports. This was not an exhaustive
|
|
||||||
audit of upstream library implementations.
|
|
||||||
|
|
||||||
One additional operator-diagnostic weakness warrants consideration. The existing
|
|
||||||
canceled-file-read defect and test failure-cleanup weakness also remain relevant.
|
|
||||||
No other substantiated error-handling defect was found in the reviewed paths.
|
|
||||||
The diagnostic recommendation below does not establish a requirement to render
|
|
||||||
all causes, change exit classifications, or expose sensitive internal details.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
ConfigKit owns resolved configuration and native load diagnostics; PromptKit
|
|
||||||
owns definitions, preparation, execution, and framework errors. CommandKit and
|
|
||||||
its integrations own CLI outcomes and presentation finalization. Scriptorium
|
|
||||||
maps these values into application CLI effects and HTTP responses, owns server
|
|
||||||
lifecycle, and shares one engine across HTTP requests. HTTP errors are deliberately
|
|
||||||
coarse and omit wrapped causes. ReleaseKit owns release mechanics. See the
|
|
||||||
[component overview](../../internal/overview.md) and
|
|
||||||
[adapter internals](../../internal/adapters.md).
|
|
||||||
|
|
||||||
## 1. Actionable CLI Startup Context Survives Only In The Returned Cause (P3)
|
|
||||||
|
|
||||||
**Relevant code:** `newEngine` in
|
|
||||||
[engine.go](../../../internal/adapter/cli/engine.go), `runPrompt` in
|
|
||||||
[native_run.go](../../../internal/adapter/cli/native_run.go), `frameworkFailure`
|
|
||||||
and `requestFailure`, lines 23–68 of
|
|
||||||
[outcomes.go](../../../internal/adapter/cli/outcomes.go), listener failure at
|
|
||||||
lines 52–54 of [server.go](../../../internal/adapter/cli/server.go), and the
|
|
||||||
status-only process handoff at line 26 of
|
|
||||||
[main.go](../../../cmd/scriptorium/main.go).
|
|
||||||
|
|
||||||
**Failure conditions:** An otherwise resolved configuration contains a malformed
|
|
||||||
message template or an unavailable `content_file`; alternatively, the configured
|
|
||||||
HTTP listen address cannot be used. These are plausible operator-correctable
|
|
||||||
startup failures, not provider-payload errors.
|
|
||||||
|
|
||||||
**Expected improvement:** Preserve current failure classification and privacy
|
|
||||||
choices while giving operators focused, useful context about the affected
|
|
||||||
resource and failure category. The operations workflow depends on captured
|
|
||||||
diagnostics to locate and correct faults. This is an actionability weakness,
|
|
||||||
not a violation of a promise that arbitrary error causes appear on stderr.
|
|
||||||
|
|
||||||
**Actual behavior and evidence:** A temporary program called the real
|
|
||||||
`cli.Execute` with synthetic configurations and captured both streams and its
|
|
||||||
returned Outcome. All failing cases below returned status 1 with empty stdout.
|
|
||||||
|
|
||||||
| Condition | Terminal explanation | Useful information retained only in Cause |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Message content `{{` | Could not initialize PromptKit configuration. | `/promptkit/prompts/0/messages/0`, invalid template syntax, unclosed action. |
|
|
||||||
| Missing message file | Could not initialize PromptKit configuration. | The `content_file` configuration path, unavailable filename, and not-found cause. |
|
|
||||||
| Invalid listen address | Could not listen for HTTP requests. | The selected address and address-syntax failure. |
|
|
||||||
|
|
||||||
The template/file cases behaved the same for `run` and `serve`; verbose mode
|
|
||||||
did not add the cause. Debug mode added dispatch/outcome tracing, but still
|
|
||||||
omitted the useful failure context. Native `promptkit list prompts` also failed
|
|
||||||
with a generic list explanation because its engine factory encountered the
|
|
||||||
same capture error. The complete wrapped cause remained available to the Go
|
|
||||||
caller throughout, so error identity and Go-level propagation are not broken.
|
|
||||||
The executable returns only the outcome's Status, making that cause unavailable
|
|
||||||
to its operator.
|
|
||||||
|
|
||||||
CommandKit deliberately separates Cause from operator-facing Explanation; it
|
|
||||||
does not automatically render causes. The constructor errors in these examples
|
|
||||||
match PromptKit's ErrInvalidConfig but are not ConfigKit LoadErrors, so the
|
|
||||||
existing `frameworkFailure` diagnostic adapter does not enrich them. Merely
|
|
||||||
routing `run` through that helper would not resolve these examples.
|
|
||||||
Ordinary `config validate` correctly succeeded for the template/file fixtures:
|
|
||||||
configuration inspection deliberately does not capture message resources or
|
|
||||||
compile templates. Moving that work into configuration inspection would change
|
|
||||||
an established lifecycle, not repair the reporting gap.
|
|
||||||
|
|
||||||
**Potential remediation:** Add deliberate, safe operator-facing context for
|
|
||||||
application-owned startup failures, using native Explanation/details rather
|
|
||||||
than relying on WithCause to print it. For listener failures, the application
|
|
||||||
already has the selected address and typed network error context. For framework
|
|
||||||
capture failures, prefer upstream-supported structured diagnostics and their
|
|
||||||
native ckprompt presentation; request upstream support if the public API lacks
|
|
||||||
the necessary safe resource/category information. Keep native workflows and
|
|
||||||
typed causes intact. Do not parse formatted error strings, import upstream
|
|
||||||
internals, or indiscriminately print Cause: those approaches risk exposing
|
|
||||||
provider payloads, prompt content, or credentials. Changing status 1 to status 2
|
|
||||||
is not part of this recommendation.
|
|
||||||
|
|
||||||
## Previously Recorded Failure-Path Findings
|
|
||||||
|
|
||||||
- **Canceled file reads (production, P2):** `Read` checks context only before
|
|
||||||
entering file helpers in
|
|
||||||
[artifact_reader.go](../../../internal/adapter/http/artifact_reader.go).
|
|
||||||
Expected cooperative handling would carry cancellation through acquisition
|
|
||||||
and avoid successful completion after it has been observed. Actual FIFO
|
|
||||||
acquisition can remain blocked after cancellation and later return a nil
|
|
||||||
reader error; an engine timeout may be reported only after external input
|
|
||||||
releases the read. Thread context through the helpers, check it during reads
|
|
||||||
and before success, and align unsupported-file handling with the ordinary
|
|
||||||
upstream reader. See
|
|
||||||
[correctness finding 3](01-correctness.md#3-restricted-file-reads-discard-cancellation-and-can-stall-on-fifos-p2)
|
|
||||||
and the [HTTP cancellation evidence](04-concurrency.md#1-file-acquisition-can-outlive-request-cancellation-p2-previously-known).
|
|
||||||
This does not require immediate interruption of every synchronous operation.
|
|
||||||
- **Capacity-test failure cleanup (test only, P3):** The shared-capacity test in
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go) releases and
|
|
||||||
joins its first worker only after several assertions. An early fatal failure
|
|
||||||
bypasses cleanup, and an incorrectly admitted second synchronous request can
|
|
||||||
stall before release. Expected failure cleanup would cancel and join owned
|
|
||||||
workers regardless of assertion outcome. Use test-controlled cancellation,
|
|
||||||
cleanup registered before launch, and a bounded second request. See
|
|
||||||
[concurrency finding 2](04-concurrency.md#2-shared-capacity-test-does-not-own-workers-on-failure-paths-p3-test-only).
|
|
||||||
|
|
||||||
These are unresolved existing findings, not additional discoveries of this pass.
|
|
||||||
|
|
||||||
## Deliberate Behavior And Checks That Do Not Justify New Requirements
|
|
||||||
|
|
||||||
- **Ignored reporter returns:** Report/Info/Warning/Progress delivery failures
|
|
||||||
are retained by CommandKit and considered during native finalization, even
|
|
||||||
when the immediate return is ignored. Existing partial-output and failed-
|
|
||||||
diagnostic-writer tests exercise this. Adding a parallel failure accumulator
|
|
||||||
would duplicate upstream behavior.
|
|
||||||
- **Wrapping and mapping:** Configuration, engine, and file wrappers preserve
|
|
||||||
causes with `%w`; report rendering/close failures are joined. HTTP uses typed
|
|
||||||
identities, including specific artifact errors before broader categories.
|
|
||||||
Operation timeout, parent cancellation, and provider-only timeout retain
|
|
||||||
their documented precedence. Completed invalid content remains a delivered
|
|
||||||
domain result, not an operational error.
|
|
||||||
- **HTTP explanations and writes:** Generic messages intentionally protect
|
|
||||||
internal causes. After a response write fails or is partial, another JSON
|
|
||||||
response cannot reliably repair the connection. No contract requires a new
|
|
||||||
logging channel or retry of the already executed prompt. Success is not
|
|
||||||
retroactively reclassified because cancellation races with formatting.
|
|
||||||
- **Serialization fallback:** Marshal failure selects a fixed string-only
|
|
||||||
internal-error envelope; encoded overflow selects the compact response-too-
|
|
||||||
large envelope. That fallback is intentionally not re-limited and does not
|
|
||||||
carry an execution report. No recursive fitting algorithm is needed.
|
|
||||||
- **Partial delivery and state:** A requested report is attempted after main
|
|
||||||
output failure, close/render errors survive, and an existing nonzero domain
|
|
||||||
status is retained on report-file failure. Partial/truncated files and
|
|
||||||
resultless failures leaving old reports untouched are documented choices,
|
|
||||||
not missing rollback. ConfigKit owns native secrets-bootstrap environment
|
|
||||||
effects; later failure does not imply an application rollback requirement.
|
|
||||||
- **Cleanup and lifecycle:** Read-only file Close is best-effort; report-file
|
|
||||||
Close errors are reported. Shutdown joins its cancellation callback and keeps
|
|
||||||
Serve/Close/cancellation causes, without promising arbitrary handler drain.
|
|
||||||
The release launcher propagates host-tool failures and exec status; the
|
|
||||||
adopted workflow fails its explicit checks. No local retry/recovery framework
|
|
||||||
or publication rollback was inferred from those paths.
|
|
||||||
|
|
||||||
The [CLI](../../cli.md), [HTTP API](../../api.md),
|
|
||||||
[source internals](../../internal/sources.md), and
|
|
||||||
[subprocess contract](../../integrations/subprocess.md) remain the owners of
|
|
||||||
these established behaviors. Other earlier correctness/resource findings are
|
|
||||||
not reclassified as new error-handling defects here.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
- Go 1.27.0 on Linux/amd64: uncached repository-wide tests selected by
|
|
||||||
`Failure|Error|Invalid|Reject|Cancellation|Deadline|Timeout|Partial|TooLarge`
|
|
||||||
passed. These include error mapping/privacy, malformed inputs, bootstrap
|
|
||||||
failure, partial delivery, report failure, and cancellation/timeout cases.
|
|
||||||
- Standalone CLI diagnostics for template capture, missing content files,
|
|
||||||
native inspection, verbose/debug reporting, and listener failure completed
|
|
||||||
under the race detector. They used only synthetic data and no provider or
|
|
||||||
credentials.
|
|
||||||
- Application/tool code remains unchanged from the preceding audits; their
|
|
||||||
successful full race-suite/vet checks were not repeated as unrelated new
|
|
||||||
coverage. Documentation links and whitespace were checked.
|
|
||||||
- Only this document was added. No production code or repository tests were
|
|
||||||
modified. Passing tests and these diagnostics do not establish correct error
|
|
||||||
handling for every dependency failure or unexercised path.
|
|
||||||
@@ -1,279 +0,0 @@
|
|||||||
# Test Coverage And Effectiveness Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`cb04d324c1aafc348ca368c23a3d7a953af33a1f`.
|
|
||||||
|
|
||||||
## Scope And Assessment
|
|
||||||
|
|
||||||
Evaluated both missing behavioral protection and unnecessary test coupling
|
|
||||||
against the [testing policy](../../policy/testing.md), especially test ownership,
|
|
||||||
independent assertions, regression protection, proportional integration tests,
|
|
||||||
and removal of incidental change detectors. Reviewed the graph inventory of
|
|
||||||
118 top-level test functions across 18 test files, relevant source/contracts,
|
|
||||||
and representative assertions and fixtures. Coverage and targeted compiler
|
|
||||||
overlays supplied additional evidence; they did not replace source review.
|
|
||||||
|
|
||||||
The suite predominantly follows the policy: real ConfigKit/PromptKit/CommandKit
|
|
||||||
collaborators, temporary files, controlled loopback providers, useful presence
|
|
||||||
and error/privacy checks, and representative CLI/HTTP/process integration.
|
|
||||||
However, high statement coverage coexists with demonstrated behavioral blind
|
|
||||||
spots and assertions that reject harmless implementation changes.
|
|
||||||
|
|
||||||
The architecture remains a thin executable: ConfigKit resolves configuration,
|
|
||||||
PromptKit owns execution/admission, CommandKit owns native CLI presentation,
|
|
||||||
and Scriptorium owns HTTP adaptation, report-file effects, and process lifecycle.
|
|
||||||
One server engine is shared; request inputs and terminal collectors are local
|
|
||||||
to each request. ReleaseKit owns release mechanics. See the
|
|
||||||
[component overview](../../internal/overview.md).
|
|
||||||
|
|
||||||
## Coverage And Effectiveness Evidence
|
|
||||||
|
|
||||||
The unchanged baseline passed:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go test -count=1 -coverpkg=./... -coverprofile=/tmp/scriptorium-testing-audit.BmISwp/coverage.out ./...
|
|
||||||
go tool cover -func=/tmp/scriptorium-testing-audit.BmISwp/coverage.out
|
|
||||||
```
|
|
||||||
|
|
||||||
The merged cross-package profile covers 484 of 521 statements: **92.9%**.
|
|
||||||
Repeated profile blocks were merged by source location; these are not the
|
|
||||||
cross-instrumented percentages printed separately by each test binary.
|
|
||||||
|
|
||||||
| Production package | Covered / total statements | Coverage |
|
|
||||||
| --- | ---: | ---: |
|
|
||||||
| `cmd/scriptorium` | 4 / 5 | 80.0% |
|
|
||||||
| `internal/adapter/cli` | 241 / 262 | 92.0% |
|
|
||||||
| `internal/adapter/http` | 173 / 188 | 92.0% |
|
|
||||||
| `internal/config` | 49 / 49 | 100.0% |
|
|
||||||
| `internal/report` | 17 / 17 | 100.0% |
|
|
||||||
|
|
||||||
The root and adapter-guard packages contain tests without production statements;
|
|
||||||
defaults introduce no executable statements. No coverage threshold is proposed.
|
|
||||||
For example, the thin `main` wrapper's missing coverage does not justify another
|
|
||||||
test when process identity/status and signal behavior already have protection.
|
|
||||||
|
|
||||||
Six temporary Go compiler overlays changed only files outside the worktree:
|
|
||||||
|
|
||||||
| Control | Result | What it demonstrates |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Hash every artifact as the empty input | Full suite passed | Expected hashes reuse the production helper. |
|
|
||||||
| Swap collector cached-token/cache-write-token mappings | Full suite passed | Distinct usage fields lack distinct test data/assertions. |
|
|
||||||
| Rebuild the HTTP engine per request, retaining startup validation | Full suite passed | Tests do not establish engine lifetime at server composition. |
|
|
||||||
| Reintroduce a no-op `--schema-dir` flag on `run` | Full suite passed | A missing operand masks acceptance of the removed flag. |
|
|
||||||
| Decode untyped numbers with `UseNumber` | Selected HTTP tests failed | An assertion pins `float64`, not JSON numeric behavior. |
|
|
||||||
| Reword the generic model-generation failure message | Error-mapping tests failed | Full error prose is pinned despite unchanged status/code/privacy. |
|
|
||||||
|
|
||||||
The first four are deliberately defective controls, not current production
|
|
||||||
defects. The last two preserve the relevant external semantics; their failures
|
|
||||||
are evidence of incidental coupling. These probes are not an exhaustive
|
|
||||||
mutation score. Overlays apply to packages compiled by the test invocation;
|
|
||||||
separate subprocess builds can use the original tree.
|
|
||||||
|
|
||||||
## Important Behavioral Gaps
|
|
||||||
|
|
||||||
### 1. Known Correctness Defects Lack Their Decisive Boundary Cases
|
|
||||||
|
|
||||||
**Priority:** P2 for precision/cancellation; P3 for filename identity.
|
|
||||||
**Policy:** Previously observed regressions, boundary conditions, data integrity,
|
|
||||||
and cancellation deserve focused protection.
|
|
||||||
|
|
||||||
The following existing tests pass despite the defects already reproduced in
|
|
||||||
the [correctness audit](01-correctness.md):
|
|
||||||
|
|
||||||
- `TestHandlerModelOverrideAcceptsJSONCompatibleExtraParams` in
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go), lines
|
|
||||||
1375–1417, uses only small exactly representable numbers and a recording
|
|
||||||
Runner. It never checks that a large integer reaches the provider unchanged.
|
|
||||||
Add a representative HTTP-to-real-engine-to-loopback-provider case with
|
|
||||||
`9007199254740993`, including nested values. Compare losslessly rather than
|
|
||||||
decoding the observed request back through float64.
|
|
||||||
- `TestRestrictedArtifactReaderReadsContainedFiles` in
|
|
||||||
[artifact_reader_test.go](../../../internal/adapter/http/artifact_reader_test.go)
|
|
||||||
covers cleaning, absolute paths, and traversal, but no whitespace-significant
|
|
||||||
filename. Add distinct padded/unpadded files with different contents and
|
|
||||||
verify that the requested file's identity and bytes survive resolution.
|
|
||||||
- `TestRestrictedArtifactReaderRejectsCanceledAndMalformedReferences` checks
|
|
||||||
contexts canceled before acquisition. Generation/retry/capacity deadline
|
|
||||||
tests exercise other collaborators, not the injected reader. Add bounded,
|
|
||||||
platform-appropriate coverage for cancellation after acquisition begins and
|
|
||||||
for unsupported non-regular inputs, with cleanup that always releases owned
|
|
||||||
work. Retain a representative real-engine or HTTP cancellation check. Follow
|
|
||||||
the selected remediation rather than requiring streaming FIFO support or
|
|
||||||
immediate interruption of every filesystem operation.
|
|
||||||
|
|
||||||
Extend the existing owners rather than creating a general input-format matrix.
|
|
||||||
These cases protect established contracts; they do not introduce new resource
|
|
||||||
caps or a symlink sandbox.
|
|
||||||
|
|
||||||
### 2. The Artifact-Hash Assertion Uses Its Own Implementation As The Oracle
|
|
||||||
|
|
||||||
**Priority:** P3. **Relevant test:**
|
|
||||||
`TestRestrictedArtifactReaderReadsContainedFiles`, line 85 of
|
|
||||||
[artifact_reader_test.go](../../../internal/adapter/http/artifact_reader_test.go).
|
|
||||||
|
|
||||||
The expected hash is computed with the same private `artifactHash` helper that
|
|
||||||
the reader uses. A helper returning one fixed hash for all content therefore
|
|
||||||
satisfies the assertion. The constant-hash overlay passed the entire suite,
|
|
||||||
including the real HTTP/server paths. Input identity can regress without a
|
|
||||||
failure even though the hash helper has 100% statement coverage.
|
|
||||||
|
|
||||||
Replace the self-referential assertion with an independent expected digest for
|
|
||||||
fixed test data, or compare the selected upstream ordinary reader's metadata
|
|
||||||
through its public API. Exercise different content with independently meaningful
|
|
||||||
expectations. Keep the reader's body/URI/containment checks. There is no need
|
|
||||||
to test the cryptographic library exhaustively or establish a new global
|
|
||||||
uniqueness guarantee for arbitrary hashes.
|
|
||||||
|
|
||||||
### 3. Collector Fixtures Do Not Distinguish All Usage Fields
|
|
||||||
|
|
||||||
**Priority:** P3. **Relevant test:** `TestCollectorProjectsOnlyTerminalAggregates`,
|
|
||||||
lines 25–66 of [report_test.go](../../../internal/report/report_test.go), and
|
|
||||||
`Collector.Observe` in [report.go](../../../internal/report/report.go).
|
|
||||||
|
|
||||||
The fixture distinguishes prompt, completion, and total counts but leaves both
|
|
||||||
cached-token counts at their identical zero defaults. JSON assertions check
|
|
||||||
only that each count object has three members, not the names/values of all
|
|
||||||
required members. Swapping cached-token and cache-write-token projections passed
|
|
||||||
the full suite despite this package's 100% coverage. Report consumers could
|
|
||||||
receive incorrect accounting while all existing assertions remain satisfied.
|
|
||||||
|
|
||||||
Use distinct nonzero cached/cache-write values and meaningful Known/Complete
|
|
||||||
combinations. Assert each required JSON `value`, `known`, and `complete` member
|
|
||||||
and its semantics. Replace the member-count-only assertion; preserve zero versus
|
|
||||||
unknown and incomplete-count protection. This is local projection testing, not
|
|
||||||
duplication of PromptKit's billing or provider-parser test matrix.
|
|
||||||
|
|
||||||
### 4. Server Tests Miss The Lifetime-Owning Composition Boundary
|
|
||||||
|
|
||||||
**Priority:** P2 for shared admission; P3 for constructor failure.
|
|
||||||
**Relevant tests:** `TestHandlerSharesBackendCapacityAcrossConcurrentRequests`
|
|
||||||
in [handler_test.go](../../../internal/adapter/http/handler_test.go), and
|
|
||||||
`TestServeStartupHTTPAndCancellation` / `TestServeListenAndConfigurationFailures`
|
|
||||||
in [lifecycle_test.go](../../../internal/adapter/cli/lifecycle_test.go).
|
|
||||||
|
|
||||||
The handler capacity test constructs one engine itself and injects it. It proves
|
|
||||||
that this supplied engine shares admission, but cannot establish that `serve`
|
|
||||||
owns and retains one engine. The real-server test verifies generation and
|
|
||||||
cancellation without overlapping capacity-limited runs. An overlay rebuilding
|
|
||||||
the engine per HTTP request passed the full suite, despite violating the
|
|
||||||
explicit [shared-engine constraint](../../policy/architecture.md#definition-support-and-request-state).
|
|
||||||
|
|
||||||
Move or consolidate the representative shared-capacity scenario into the
|
|
||||||
existing server harness: configure one backend with capacity one and no queue,
|
|
||||||
hold the first provider request, and verify the second HTTP request is rejected
|
|
||||||
without a second provider dispatch. Check completion/release after unblocking.
|
|
||||||
Once the stronger scenario subsumes the lower-level case, remove that duplicate
|
|
||||||
case while retaining distinct HTTP error/privacy and retry-override protection.
|
|
||||||
|
|
||||||
Also cover a resolved configuration whose engine construction fails because of
|
|
||||||
a missing message file or malformed template. Current server failure cases
|
|
||||||
cover loading/domain/YAML errors and listener errors, but not this intermediate
|
|
||||||
stage; `frameworkFailure` has 0% coverage. Verify the typed failure, nonzero
|
|
||||||
status, and that listening is not attempted. Do not manufacture an unreachable
|
|
||||||
LoadError merely to cover that helper's branches, move capture into ordinary
|
|
||||||
configuration inspection, or freeze new diagnostic prose from the unapproved
|
|
||||||
[diagnostic recommendation](06-error-handling.md).
|
|
||||||
|
|
||||||
### 5. A Removed-Flag Test Can Pass For The Wrong Usage Error
|
|
||||||
|
|
||||||
**Priority:** P3. **Relevant test:** `TestRemovedSourceAndSchemaFlagsAreRejected`,
|
|
||||||
lines 33–44 of [app_test.go](../../../internal/adapter/cli/app_test.go).
|
|
||||||
|
|
||||||
The `run` cases omit the required prompt operand and check only Usage/status 2.
|
|
||||||
After a temporary overlay reintroduced `--schema-dir` on `run`, the test still
|
|
||||||
passed because the invocation remained invalid for another reason. The full
|
|
||||||
suite also passed that control. Its other command rows do not cover a flag
|
|
||||||
accidentally added only to `run`.
|
|
||||||
|
|
||||||
Use otherwise-valid base invocations, explicit controlled configuration where
|
|
||||||
needed, and an assertion that distinguishes rejection of the removed flag
|
|
||||||
from unrelated usage/configuration errors. Prefer supported typed categories
|
|
||||||
or a minimal flag-specific diagnostic fragment, not a whole-message snapshot.
|
|
||||||
Retain the deliberately selected hard-cutover protection; this is not a reason
|
|
||||||
to delete all removed-interface tests.
|
|
||||||
|
|
||||||
### 6. Failure Cleanup In The Capacity Test Is Incomplete
|
|
||||||
|
|
||||||
**Priority:** P3; previously recorded test defect. **Relevant test:**
|
|
||||||
`TestHandlerSharesBackendCapacityAcrossConcurrentRequests`, lines 1087–1118 of
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go).
|
|
||||||
|
|
||||||
The first worker uses an uncancelable request context; release/join occurs only
|
|
||||||
after several assertions. An early fatal failure bypasses cleanup. An incorrectly
|
|
||||||
admitted second synchronous request can wait for a release the test performs
|
|
||||||
only after that request returns. Happy-path timeouts do not bound this middle
|
|
||||||
call. This can obscure the very regression being tested with a hang or leaked
|
|
||||||
worker. See [concurrency finding 2](04-concurrency.md#2-shared-capacity-test-does-not-own-workers-on-failure-paths-p3-test-only).
|
|
||||||
|
|
||||||
Register cancellation/release/join cleanup before launching work, bound the
|
|
||||||
second request, and keep one owner of channel closure. If consolidating the
|
|
||||||
scenario into the server test above, carry these protections into its replacement
|
|
||||||
instead of maintaining two versions or building a generic concurrency fixture.
|
|
||||||
|
|
||||||
## Removal And Consolidation Candidates
|
|
||||||
|
|
||||||
### 7. Remove Incidental Representation And Prose Assertions
|
|
||||||
|
|
||||||
**Priority:** P3. **Policy:** Correct internal refactors should remain inexpensive;
|
|
||||||
exact error wording is appropriate only when contractual.
|
|
||||||
|
|
||||||
- In `TestHandlerModelOverrideAcceptsJSONCompatibleExtraParams`, lines 1407–1415
|
|
||||||
of [handler_test.go](../../../internal/adapter/http/handler_test.go), the deep
|
|
||||||
equality expectation fixes untyped JSON numbers to Go float64. A UseNumber
|
|
||||||
overlay failed this assertion even though `json.Number` preserves JSON numeric
|
|
||||||
semantics and is accepted by the selected PromptKit API. Remove this concrete-
|
|
||||||
type requirement, not the scalar/object/array mapping protection. Replace it
|
|
||||||
with lossless semantic/wire assertions and consolidate it with the precision
|
|
||||||
regression above. Do not normalize both sides through float64 again.
|
|
||||||
- In `TestHandlerPublicErrorMapping`, lines 1690–1748 of the same file, every
|
|
||||||
case repeats a complete message and requires exact equality. Rewording
|
|
||||||
"model generation request failed" to "model generation failed" caused five
|
|
||||||
failures while status, code, JSON shape, and cause privacy remained unchanged.
|
|
||||||
The [HTTP contract](../../api.md#error-responses) does not promise those exact
|
|
||||||
sentences. Remove the repeated prose expectations and equality assertion;
|
|
||||||
retain status/code/precedence, a usable nonempty message, and private-cause
|
|
||||||
exclusion checks. Preserve any wording that is actually contractual.
|
|
||||||
|
|
||||||
No whole test function needs deletion solely because it calls a private helper
|
|
||||||
or overlaps an integration path. The concrete removal opportunities are the
|
|
||||||
assertions above, the self-referential hash expectation, and lower-level cases
|
|
||||||
that become redundant after a stronger owner-boundary test replaces them.
|
|
||||||
In particular, the standalone recording-Runner extra-parameters test can be
|
|
||||||
consolidated into the lossless provider-wire case once it covers the same JSON
|
|
||||||
shapes; the standalone shared-capacity test can be removed after the server-level
|
|
||||||
replacement preserves its meaningful protection. Do not remove either first
|
|
||||||
and leave its behavior unprotected.
|
|
||||||
|
|
||||||
## Useful Protection To Retain And Work Not Justified By This Audit
|
|
||||||
|
|
||||||
- Keep architecture import/removal guards: they protect expressly adopted
|
|
||||||
ownership constraints, rather than arbitrary directory preferences.
|
|
||||||
- Keep actual stdout bytes, numeric presence/zero overrides, status/domain
|
|
||||||
outcomes, report delivery failures, classified-field redaction, terminal
|
|
||||||
collector isolation, source-context selection, and no-provider preparation
|
|
||||||
checks. These protect application contracts even when native libraries do
|
|
||||||
most of the work.
|
|
||||||
- Using the upstream native renderer as the expected report formatter is a
|
|
||||||
valid integration oracle; it is not the same as reusing the local hash helper.
|
|
||||||
- Do not add exhaustive upstream grammar/format matrices, mock internal call
|
|
||||||
choreography, or tests for every uncovered return. Standard library failures
|
|
||||||
and impossible constructor states need no artificial fault-injection layer
|
|
||||||
solely to increase coverage.
|
|
||||||
- Resource-budget proposals and richer diagnostics in earlier audits require
|
|
||||||
decisions first. Their absence is not a reason to create tests that silently
|
|
||||||
establish new timeouts, memory limits, rollback, or disclosure guarantees.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
The normal coverage run and four full-suite defective-overlay runs passed.
|
|
||||||
The two targeted representation/prose controls failed as described; those are
|
|
||||||
intentional audit observations, not baseline failures. No new production bug
|
|
||||||
was introduced or retained. Only this audit document was added to the repository;
|
|
||||||
all overlay sources and coverage artifacts remained outside the worktree, and
|
|
||||||
no repository production code or tests were edited.
|
|
||||||
|
|
||||||
This was a focused policy/effectiveness review, not exhaustive mutation testing
|
|
||||||
or proof that all important behaviors are covered. Prior race-audit results
|
|
||||||
remain evidence for unchanged source; this pass did not rerun the full race
|
|
||||||
suite or propose a coverage/mutation-score gate. Documentation links and
|
|
||||||
whitespace were checked.
|
|
||||||
@@ -1,144 +0,0 @@
|
|||||||
# Behavioral Equivalence And Shared Abstraction Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`be4aebfedc3ded8d834afc0867692bbe448d77b6`.
|
|
||||||
|
|
||||||
## Scope And Method
|
|
||||||
|
|
||||||
Reviewed direct comparisons and repeated behavioral assertions in the CLI,
|
|
||||||
HTTP, configuration, and execution-report tests, then traced the corresponding
|
|
||||||
implementations with codebase-memory-mcp and source inspection. Checked the
|
|
||||||
relationships against the architecture and testing policies and the internal
|
|
||||||
adapter/source documentation. Similar syntax alone was not treated as evidence
|
|
||||||
of a common responsibility.
|
|
||||||
|
|
||||||
One consolidation opportunity warrants consideration. It confirms the
|
|
||||||
configuration-diagnostics portion of
|
|
||||||
[complexity audit finding 2](03-complexity.md#2-consolidate-cli-configuration-diagnostics-and-flatten-failure-selection)
|
|
||||||
with behavioral evidence; it is not a second independent defect or a newly
|
|
||||||
demonstrated runtime mismatch. No production code or tests were changed.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
Scriptorium is a thin CLI/HTTP executable. ConfigKit resolves the shared
|
|
||||||
application/PromptKit document; PromptKit owns definitions, preparation, and
|
|
||||||
execution; CommandKit and its integrations own native CLI inspection,
|
|
||||||
presentation, and outcomes. The HTTP adapter adds transport and deployment
|
|
||||||
policy around a shared engine, with an optional per-request terminal report
|
|
||||||
collector. ReleaseKit owns release mechanics. See the
|
|
||||||
[component overview](../../internal/overview.md),
|
|
||||||
[adapter internals](../../internal/adapters.md), and
|
|
||||||
[source internals](../../internal/sources.md).
|
|
||||||
|
|
||||||
## 1. Share The CLI Application-Load Diagnostic Bridge
|
|
||||||
|
|
||||||
**Scope:** A private helper within `internal/adapter/cli`. This is an optional
|
|
||||||
maintainability improvement, not a reason to introduce a new package or replace
|
|
||||||
the native acquisition workflow.
|
|
||||||
|
|
||||||
### Evidence
|
|
||||||
|
|
||||||
- `TestServeListenAndConfigurationFailures`, lines 206–235 of
|
|
||||||
[lifecycle_test.go](../../../internal/adapter/cli/lifecycle_test.go), runs
|
|
||||||
both `run` and `serve` against the same malformed imported framework file.
|
|
||||||
Both must return status 2 and surface `Application configuration` and
|
|
||||||
`yaml.invalid`. This directly establishes common application-load failure
|
|
||||||
presentation across the two execution paths. It does not require their
|
|
||||||
complete diagnostic output to be byte-identical.
|
|
||||||
- `TestBootstrapDiagnosticsOnFailure`, lines 165–192 of
|
|
||||||
[bootstrap_test.go](../../../internal/adapter/cli/bootstrap_test.go), checks
|
|
||||||
failed loads through application run and native configuration/PromptKit
|
|
||||||
commands. Diagnostics must be present, retain the synthetic credential key
|
|
||||||
name where expected, and omit its secret value. This supports preserving
|
|
||||||
native safe evidence and the existing bootstrap-report route during any
|
|
||||||
extraction; it does not establish a universal sensitive-content filter.
|
|
||||||
- `TestNativeLoadFailureEvidenceOnComparisonSides`, lines 190–205 of
|
|
||||||
[native_config_test.go](../../../internal/adapter/cli/native_config_test.go),
|
|
||||||
independently exercises failed left and right comparison selections. It
|
|
||||||
requires the application validation path, the affected side, and exactly one
|
|
||||||
`validate.error`. This bounds the proposed change: native inspection already
|
|
||||||
owns its evidence presentation and should not acquire an additional
|
|
||||||
application diagnostic pass.
|
|
||||||
|
|
||||||
### Implementation
|
|
||||||
|
|
||||||
`runPrompt`, lines 77–88 of
|
|
||||||
[native_run.go](../../../internal/adapter/cli/native_run.go), and
|
|
||||||
`serveWithListener`, lines 23–34 of
|
|
||||||
[server.go](../../../internal/adapter/cli/server.go), repeat the same bridge:
|
|
||||||
|
|
||||||
1. obtain sources and diagnostics from the returned ConfigKit result;
|
|
||||||
2. prefer evidence from a wrapped `*configkit.LoadError` when present;
|
|
||||||
3. call `ckconfig.AdaptDiagnostics` with the application-configuration heading;
|
|
||||||
4. queue the adapted diagnostics and retain the explanation for failure output.
|
|
||||||
|
|
||||||
Configuration resolution already shares `loadApplication`; native formatting
|
|
||||||
already shares `ckconfig.AdaptDiagnostics`; delivery already shares
|
|
||||||
`queueDiagnostics`. The duplicated responsibility is the selection and
|
|
||||||
adaptation between those existing boundaries, not configuration loading itself.
|
|
||||||
|
|
||||||
`frameworkFailure`, lines 23–31 of
|
|
||||||
[outcomes.go](../../../internal/adapter/cli/outcomes.go), performs related
|
|
||||||
LoadError adaptation after engine construction, but uses a different heading
|
|
||||||
and appends to an existing explanation. Those differences are meaningful;
|
|
||||||
the run/serve equivalence test does not establish equivalence for that entire
|
|
||||||
failure path.
|
|
||||||
|
|
||||||
### Opportunity And Remediation Approaches
|
|
||||||
|
|
||||||
The preferred approach is a small private helper accepting the actual typed
|
|
||||||
ConfigKit result and load error and returning adapted native diagnostics and
|
|
||||||
an explanation. Call it from `runPrompt` and `serveWithListener`; keep queuing
|
|
||||||
and outcome selection explicit in the callers. This gives evidence selection
|
|
||||||
and adaptation one maintenance point, reducing the chance that one command
|
|
||||||
loses findings or handles a wrapped load error differently after a change.
|
|
||||||
|
|
||||||
Alternatively, extract just the source/diagnostic selection and leave adaptation
|
|
||||||
at the call sites. That keeps heading selection visible, but shares less of
|
|
||||||
the duplicated bridge. Reuse with `frameworkFailure` is reasonable only if it
|
|
||||||
stays simple and preserves that caller's distinct heading and explanation
|
|
||||||
composition; it need not be forced into the same control flow.
|
|
||||||
|
|
||||||
### Tradeoffs And Boundaries
|
|
||||||
|
|
||||||
- A CLI-local helper introduces little new coupling because both callers
|
|
||||||
already depend on the same native types. A cross-adapter package, generic
|
|
||||||
acquisition framework, or universal error classifier would add unnecessary
|
|
||||||
coupling and mix different presentation policies.
|
|
||||||
- Preserve typed causes, current evidence-selection precedence, and the
|
|
||||||
existing bootstrap-report path. Do not rebuild an effective document,
|
|
||||||
reconstruct evidence, cache loads, or move CLI presentation into
|
|
||||||
`internal/config`.
|
|
||||||
- Do not make `loadApplication` queue these diagnostics unconditionally.
|
|
||||||
Native ckconfig/ckprompt consumers already own presentation, including
|
|
||||||
comparison-side context; doing so risks duplicate output.
|
|
||||||
- Keep the command-level tests independent of the extracted helper. They
|
|
||||||
should continue asserting observable outcomes and native evidence rather
|
|
||||||
than calculating expected output with the same helper as production.
|
|
||||||
- Retaining this short duplication is viable if extraction would require
|
|
||||||
extra configuration or abstractions. The benefit is a single evidence
|
|
||||||
bridge, not fewer lines at any cost. No broader error-classification rewrite
|
|
||||||
is needed to realize it.
|
|
||||||
|
|
||||||
## Overall Assessment
|
|
||||||
|
|
||||||
The tested preparation/execution and native report-rendering relationships
|
|
||||||
already use upstream implementations rather than competing local copies.
|
|
||||||
Application and focused configuration inspection also share the actual load
|
|
||||||
through the native adapters. The review found no additional test-backed
|
|
||||||
opportunity warranting a shared application package. CLI and HTTP decoding,
|
|
||||||
status mapping, artifact-access policy, and report representations retain
|
|
||||||
intentional boundary-specific responsibilities.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
The following focused tests passed against unchanged application code:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go test -count=1 ./internal/adapter/cli -run 'TestServeListenAndConfigurationFailures|TestBootstrapDiagnosticsOnFailure|TestNativeLoadFailureEvidenceOnComparisonSides|TestNativeScopesAndHelpUseSharedLoading|TestSeparateReportsUseNativeFormats|TestMaintainedCollectionWorkflow'
|
|
||||||
```
|
|
||||||
|
|
||||||
The audit used existing tests and real internal collaborators with controlled
|
|
||||||
local provider boundaries. It did not add tests, mutate implementations, or
|
|
||||||
exhaustively compare all input combinations. Findings are opportunities for
|
|
||||||
review, not new contracts or a guarantee that no other duplication exists.
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
# Package Cohesion And Architectural Boundaries Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`1c88483e1b778815f34c48ad711440d360031f6d`.
|
|
||||||
|
|
||||||
## Scope And Method
|
|
||||||
|
|
||||||
Reviewed all 18 production Go files across the six repository-owned production
|
|
||||||
packages, their exported types and functions, local imports, composition paths,
|
|
||||||
and representative boundary tests. The module root and `internal/adapter` have
|
|
||||||
tests but no production Go files. Third-party implementation packages were not
|
|
||||||
audited.
|
|
||||||
|
|
||||||
Used codebase-memory-mcp for package/symbol discovery and call tracing, then
|
|
||||||
checked actual source imports and `go list` output. Graph-derived edges can
|
|
||||||
confuse identically named functions or include test relationships; they were
|
|
||||||
not treated as authoritative production dependencies. Compared the allocation
|
|
||||||
with the [architecture policy](../../policy/architecture.md), ADRs
|
|
||||||
[0002](../../adr/0002-split-promptkit-from-scriptorium.md),
|
|
||||||
[0004](../../adr/0004-definition-boundary.md),
|
|
||||||
[0005](../../adr/0005-configkit-boundary.md), and
|
|
||||||
[0006](../../adr/0006-adopt-commandkit-native-operator-interfaces.md), and the
|
|
||||||
current internal documentation.
|
|
||||||
|
|
||||||
The production package graph is acyclic and broadly coherent. One optional
|
|
||||||
ownership refinement warrants consideration; no import-direction violation or
|
|
||||||
major overlapping responsibility was found. This is not a proposal to add
|
|
||||||
application layers or expand Scriptorium's product scope.
|
|
||||||
|
|
||||||
## Current Responsibility Allocation
|
|
||||||
|
|
||||||
| Package | Implemented responsibility | Local production dependencies |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `cmd/scriptorium` | Process streams, signal cancellation, version identity handoff, and exit status. | CLI adapter |
|
|
||||||
| `internal/adapter/cli` | Native command composition, input/configuration selection mapping, acquisition callbacks, engine construction, run/report effects, and HTTP server lifecycle. | HTTP adapter, config, defaults |
|
|
||||||
| `internal/adapter/http` | Routing, strict DTO decoding, request/result/error mapping, transport limits, and restricted artifact access. | Defaults, report |
|
|
||||||
| `internal/config` | Application schema, defaults, normalization and validation callbacks, discovery choices, and native shared loading/secrets bootstrap. | Defaults |
|
|
||||||
| `internal/defaults` | Small, shared set of application HTTP/server defaults. | None |
|
|
||||||
| `internal/report` | Terminal observation collection and the HTTP execution-report projection. | None |
|
|
||||||
|
|
||||||
External libraries retain their selected ownership: ConfigKit resolves the
|
|
||||||
configuration document, PromptKit prepares and executes prompts, CommandKit
|
|
||||||
and its integrations supply native operator workflows, and ReleaseKit supplies
|
|
||||||
release mechanics/version identity. Local code composes those public APIs;
|
|
||||||
there is no local framework or durable workflow layer. See the
|
|
||||||
[component overview](../../internal/overview.md) and
|
|
||||||
[adapter internals](../../internal/adapters.md).
|
|
||||||
|
|
||||||
## 1. Make HTTP Execution-Report Ownership Explicit
|
|
||||||
|
|
||||||
**Category:** Fragmented adapter responsibility / optional package-boundary
|
|
||||||
simplification. **Priority:** Low; not a release blocker.
|
|
||||||
|
|
||||||
### Relevant Implementation
|
|
||||||
|
|
||||||
- [internal/report/report.go](../../../internal/report/report.go), lines 6–38,
|
|
||||||
defines `Execution`, `Usage`, and `TokenCount`, including HTTP JSON member
|
|
||||||
names and omission rules. Lines 47–104 select terminal events, convert
|
|
||||||
durations to milliseconds, and bound the outcome/failure vocabulary.
|
|
||||||
- [internal/adapter/http/dto.go](../../../internal/adapter/http/dto.go), lines
|
|
||||||
41–47 and 104–107, embeds `report.Execution` in the success and error
|
|
||||||
envelopes alongside the adapter's other private DTOs.
|
|
||||||
- `Handler.ServeHTTP`, lines 123–132 of
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go), creates the
|
|
||||||
per-request collector, attaches its observer, and obtains the report.
|
|
||||||
`writeRunFailure`, lines 187–193, attaches that same representation to
|
|
||||||
execution failures.
|
|
||||||
- The HTTP adapter is the report package's only production consumer, confirmed
|
|
||||||
by the source imports, `go list`, and inbound call tracing. CLI
|
|
||||||
[delivery.go](../../../internal/adapter/cli/delivery.go) instead sends the
|
|
||||||
native RunResult to CommandKit; it does not use this representation.
|
|
||||||
|
|
||||||
### Basis For The Finding
|
|
||||||
|
|
||||||
The report package is internally cohesive, and its dependency direction is
|
|
||||||
valid. The concern is narrower: a public HTTP representation and its shaping
|
|
||||||
policy are split between the HTTP adapter and a generically named sibling
|
|
||||||
package. The latter's `Execution` comment describes opt-in adapters generally,
|
|
||||||
while its current fields, vocabulary, consumers, and canonical contract are
|
|
||||||
specifically HTTP. HTTP report changes therefore cross a package API even
|
|
||||||
though no second interface needs that API.
|
|
||||||
|
|
||||||
This is not a finding that a single-consumer package is inherently wrong. It is
|
|
||||||
an opportunity to align the ownership of this small, 104-line wire projection
|
|
||||||
with the interface whose contract it implements. It confirms
|
|
||||||
[complexity audit finding 3](03-complexity.md#3-co-locate-the-http-only-execution-projection-with-its-consumer),
|
|
||||||
rather than identifying a separate runtime defect.
|
|
||||||
|
|
||||||
The tests reinforce the existing boundary and behavior to preserve:
|
|
||||||
|
|
||||||
- `TestCollectorProjectsOnlyTerminalAggregates` and
|
|
||||||
`TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate` in
|
|
||||||
[report_test.go](../../../internal/report/report_test.go) exercise the
|
|
||||||
projection, JSON shape, terminal-only selection, unknown values, and detached
|
|
||||||
snapshots.
|
|
||||||
- `TestCollectorReceivesRealEngineTerminalEvent` in the same file checks the
|
|
||||||
observer integration with a real engine.
|
|
||||||
- `TestHandlerExecutionReportOptInAndResultShapes`,
|
|
||||||
`TestHandlerExecutionReportFailureAndAbsence`,
|
|
||||||
`TestHandlerExecutionReportResponseLimit`, and
|
|
||||||
`TestHandlerConcurrentExecutionReportsAreIsolated` in
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go) exercise
|
|
||||||
opt-in attachment, error responses, encoded-size policy, and per-request
|
|
||||||
isolation.
|
|
||||||
|
|
||||||
### Potential Remediation And Tradeoffs
|
|
||||||
|
|
||||||
The preferred simplification, when this area is next changed, is to move the
|
|
||||||
collector, projection types, and focused tests into a dedicated execution-report
|
|
||||||
file pair in `internal/adapter/http`. Make implementation names private where
|
|
||||||
practical and remove the unused sibling package. Keep the HTTP wire format and
|
|
||||||
the existing observer lifecycle unchanged; retain focused projection tests
|
|
||||||
alongside handler integration tests. Update the component inventory and source
|
|
||||||
references if the layout changes.
|
|
||||||
|
|
||||||
This removes a package dependency and puts the complete HTTP representation
|
|
||||||
under one owner. It adds code to an already substantial adapter package, but
|
|
||||||
separate files and focused tests can preserve readability without requiring an
|
|
||||||
exported cross-package API.
|
|
||||||
|
|
||||||
A viable alternative is to retain the isolated projection package and clarify
|
|
||||||
its HTTP-specific purpose in its name/comments and component inventory. That
|
|
||||||
preserves a small testable package with no HTTP transport dependency, at the
|
|
||||||
cost of retaining the boundary and exported internal API. Keeping the current
|
|
||||||
layout is also reasonable if that isolation is judged more useful than
|
|
||||||
co-location. No new shared reporting framework, CLI report conversion, or
|
|
||||||
speculative multi-consumer interface is justified by current usage.
|
|
||||||
|
|
||||||
## Boundaries That Do Not Warrant Reallocation
|
|
||||||
|
|
||||||
- **Configuration and CLI acquisition:** `internal/config` returns the actual
|
|
||||||
ConfigKit result and bootstrap report. CLI `selection.go` maps operator
|
|
||||||
choices to load options/overrides; `bootstrap.go` and `outcomes.go` present
|
|
||||||
evidence. Application definition callbacks remain in config, and native
|
|
||||||
inspection remains upstream-owned. This is a coherent processing/presentation
|
|
||||||
split, not fragmented effective-configuration ownership.
|
|
||||||
- **CLI and HTTP composition:** CLI `server.go` constructs the restricted reader,
|
|
||||||
one engine, handler, and listener for `serve`. HTTP owns request handling and
|
|
||||||
artifact-access policy; it does not import CLI or config. CLI-to-HTTP wiring
|
|
||||||
is application composition, not a transport dependency cycle. Moving this
|
|
||||||
small lifecycle into a new service package or adding a reusable Scriptorium
|
|
||||||
engine facade is not warranted.
|
|
||||||
- **Restricted artifact access:** The file reader has filesystem mechanics,
|
|
||||||
but its root/limit policy and error identities serve the HTTP deployment
|
|
||||||
boundary. Its placement in the HTTP adapter is deliberate. Configuration
|
|
||||||
path normalization and request-artifact path handling have different
|
|
||||||
purposes; similar filesystem operations do not establish shared ownership.
|
|
||||||
- **Defaults and adapter mappings:** The defaults package is small and supplies
|
|
||||||
application HTTP/server values to config and construction sites without
|
|
||||||
importing either adapter. CLI outcomes and HTTP statuses, DTOs, and usage
|
|
||||||
projections have different contracts. They do not need a common error or
|
|
||||||
result model. The duplicated CLI diagnostic bridge recorded in
|
|
||||||
[10-equivalence.md](10-equivalence.md) is a within-package helper opportunity,
|
|
||||||
not evidence for another package.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
`go test -count=1 ./...` passed, including `TestApplicationBoundary`, its import
|
|
||||||
scanner tests, and the collector/HTTP integration tests. The architecture guard
|
|
||||||
checks forbidden framework imports and removed implementation families; it does
|
|
||||||
not by itself prove that every responsibility has an appropriate owner.
|
|
||||||
|
|
||||||
This audit changes only this document. No new tests or production changes were
|
|
||||||
made. Package imports, source locations, linked documents, and whitespace were
|
|
||||||
checked. The assessment concerns current implemented responsibilities, not
|
|
||||||
hypothetical future consumers or a guarantee that no other design opportunity
|
|
||||||
exists.
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
# Dead Code And Obsolete Functionality Audit
|
|
||||||
|
|
||||||
Reviewed on 2026-11-24 at source revision
|
|
||||||
`a42fe635064124325a35bdf972c4fa65dcda7aff`.
|
|
||||||
|
|
||||||
## Scope And Method
|
|
||||||
|
|
||||||
Reviewed repository-owned Go declarations, command registration and callbacks,
|
|
||||||
configuration fields, optional HTTP/report paths, validation branches, and
|
|
||||||
retained migration-related checks. Also checked the release launcher/profile,
|
|
||||||
hosted workflow, and example scripts for disconnected entry points. No
|
|
||||||
production code, tests, or functionality were changed.
|
|
||||||
|
|
||||||
Used codebase-memory-mcp discovery/reference searches, source inspection, and
|
|
||||||
Go's package inventory. Cross-checked the earlier package review against the
|
|
||||||
unchanged production sources. Used `golang.org/x/tools/cmd/deadcode` v0.52.0,
|
|
||||||
matching the selected tools module version, to analyze the executable's call
|
|
||||||
graph for both release targets, Linux amd64 and arm64. Also analyzed the native
|
|
||||||
test executables. Results were filtered to Scriptorium-owned packages.
|
|
||||||
|
|
||||||
The inventory contains 18 production Go files in six packages, with no ignored
|
|
||||||
Go files or cgo files in the current package selections. Inspected tracked Go
|
|
||||||
files and build/directive searches for additional constrained or generated
|
|
||||||
entry points. JSON/YAML field use, native command/definition callbacks,
|
|
||||||
interface dispatch, and observer callbacks were accounted for rather than
|
|
||||||
classified solely by direct call counts.
|
|
||||||
|
|
||||||
One low-priority redundant branch warrants consideration. No abandoned
|
|
||||||
subsystem, obsolete compatibility implementation, or wholly unused function
|
|
||||||
was identified after accounting for tests and registered execution paths.
|
|
||||||
|
|
||||||
## Current Architecture
|
|
||||||
|
|
||||||
Scriptorium remains a thin executable: the process entrypoint delegates to the
|
|
||||||
CLI, which composes native commands and starts the HTTP service. Configuration
|
|
||||||
loading/schema callbacks, HTTP transport and restricted artifact access,
|
|
||||||
application defaults, and HTTP terminal-report projection have local owners.
|
|
||||||
ConfigKit, PromptKit, CommandKit and its integrations, and ReleaseKit own their
|
|
||||||
respective upstream mechanisms. See the
|
|
||||||
[component overview](../../internal/overview.md) and
|
|
||||||
[boundary audit](11-boundaries.md).
|
|
||||||
|
|
||||||
## 1. Consolidate Optional Model Mapping Into Its Nil-Aware Converter
|
|
||||||
|
|
||||||
**Priority:** Low; optional local cleanup, not a runtime defect.
|
|
||||||
|
|
||||||
**Implementation and evidence:** `Handler.ServeHTTP`, lines 104–107 of
|
|
||||||
[handler.go](../../../internal/adapter/http/handler.go), initializes a nil
|
|
||||||
model override and calls `executionTargetOverrideFromModelOverrideDTO` only
|
|
||||||
when `req.Model != nil`. That converter, lines 195–211 of the same file,
|
|
||||||
immediately handles nil input by returning nil. Reference inspection finds
|
|
||||||
only this one call site, with no direct test calls or registration of the
|
|
||||||
converter. Its nil-return branch is consequently unreachable through current
|
|
||||||
callers, and the two layers independently express the same omission handling.
|
|
||||||
|
|
||||||
**Potential remediation:** Call the nil-aware converter unconditionally and
|
|
||||||
use its result in `RunRequest.Execution`. This removes the redundant outer
|
|
||||||
branch and gives the existing converter's nil path a purpose. Preserve the
|
|
||||||
distinction between an omitted/null model (nil override) and an explicitly
|
|
||||||
supplied empty model object (non-nil override), along with all pointer-based
|
|
||||||
field presence and explicit-zero behavior.
|
|
||||||
|
|
||||||
An alternative is to retain the caller guard and remove the converter's nil
|
|
||||||
check. That also removes the unreachable branch, but makes the private helper
|
|
||||||
require non-nil input. The unconditional nil-aware conversion is simpler and
|
|
||||||
avoids introducing that extra precondition. This does not justify changing
|
|
||||||
validation, external request fields, or the upstream request model.
|
|
||||||
|
|
||||||
**Existing verification:** `TestHandlerModelOverrideMapsAllSupportedExecutionFields`,
|
|
||||||
`TestHandlerModelOverridePreservesReasoningEffortPresence`,
|
|
||||||
`TestHandlerModelOverrideExplicitZeroTemperatureMapsAsPresent`, and
|
|
||||||
`TestHandlerModelOverrideOmittedTemperatureMapsAsAbsent` in
|
|
||||||
[handler_test.go](../../../internal/adapter/http/handler_test.go) protect
|
|
||||||
supplied-model mapping and individual-field presence. A future cleanup should
|
|
||||||
also verify the whole-model omission/null/empty-object distinction; these
|
|
||||||
field-presence tests alone do not establish all three cases.
|
|
||||||
|
|
||||||
## Investigated Candidates That Should Be Retained
|
|
||||||
|
|
||||||
- **`NewHandler`:** Production-only deadcode analysis reports this constructor
|
|
||||||
at [handler.go](../../../internal/adapter/http/handler.go), lines 32–37, on
|
|
||||||
both release targets. The server uses `NewHandlerWithOptions` to receive
|
|
||||||
resolved configuration, while numerous HTTP tests and fixture builders use
|
|
||||||
`NewHandler` to select application defaults. It therefore has a concrete
|
|
||||||
test-support purpose, not an abandoned consumer API. Analysis including tests
|
|
||||||
reports no unreachable repository functions. Retain it; production-only
|
|
||||||
reachability is insufficient grounds for deletion.
|
|
||||||
- **Native callbacks and interfaces:** CLI parsers, command handlers, ConfigKit
|
|
||||||
definition callbacks, `Handler.ServeHTTP`, the restricted reader's `Read`,
|
|
||||||
and the report observer are live through registration or interface/function
|
|
||||||
values. Graph nodes with few or no direct edges are not deletion candidates.
|
|
||||||
- **Migration checks and aliases:** `validateDocument` rejects retired
|
|
||||||
framework selectors and raw API-key fields; it does not load the old formats.
|
|
||||||
`TestDocumentRejectsRetiredAndInvalidShapes` and
|
|
||||||
`TestNativeSettingsExtensionsAndRawKeyBoundary` in
|
|
||||||
[document_test.go](../../../internal/config/document_test.go) exercise those
|
|
||||||
checks. Current CLI aliases are documented supported spellings, not dormant
|
|
||||||
legacy dispatch. See the [CLI contract](../../cli.md) and
|
|
||||||
[migration guide](../../consumers/upgrading-cli.md). Removing either would
|
|
||||||
change selected behavior rather than delete unused compatibility machinery.
|
|
||||||
- **Optional and operational functionality:** Separate CLI report files, HTTP
|
|
||||||
terminal reports, explicit zero/unlimited limits, reader sentinels, and
|
|
||||||
cancellation/error fallbacks remain connected to supported paths. The report
|
|
||||||
package's sole production consumer does not make it dead; its potential
|
|
||||||
co-location is already covered by the boundary audit. Maintainer tool
|
|
||||||
dependencies, the root release launcher, hosted workflow, and prepared-preview
|
|
||||||
example scripts have non-runtime roles and are not obsolete merely because
|
|
||||||
the executable does not invoke them.
|
|
||||||
|
|
||||||
## Validation And Limits
|
|
||||||
|
|
||||||
Successful checks:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go run golang.org/x/tools/cmd/deadcode@v0.52.0 -filter='^gitea.maximumdirect.net/eric/scriptorium(/|$)' ./cmd/scriptorium
|
|
||||||
go run -exec 'env GOOS=linux GOARCH=arm64' golang.org/x/tools/cmd/deadcode@v0.52.0 -filter='^gitea.maximumdirect.net/eric/scriptorium(/|$)' ./cmd/scriptorium
|
|
||||||
go run golang.org/x/tools/cmd/deadcode@v0.52.0 -test -filter='^gitea.maximumdirect.net/eric/scriptorium(/|$)' ./...
|
|
||||||
go test -count=1 ./...
|
|
||||||
go vet ./...
|
|
||||||
```
|
|
||||||
|
|
||||||
The arm64 check ran the analyzer on the host with an arm64 package-loading
|
|
||||||
environment; it did not execute an arm64 application binary. Standalone
|
|
||||||
`staticcheck` and `golangci-lint` were not installed. Function reachability does
|
|
||||||
not prove individual branches or fields are necessary; those were assessed
|
|
||||||
through source, references, tests, and documented purposes. Uncovered defensive
|
|
||||||
branches were not presumed dead. No guarantee is made about every possible
|
|
||||||
input, custom build selection, or future upstream behavior.
|
|
||||||
|
|
||||||
Document links and whitespace were checked. No tool dependency was added to
|
|
||||||
the repository.
|
|
||||||
@@ -1,358 +0,0 @@
|
|||||||
# 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.
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
# Audit Remediation Discussion
|
|
||||||
|
|
||||||
Created 2026-11-24; updated 2026-11-25. Status: topics 1–7 accepted.
|
|
||||||
No remediation implementation is 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.
|
|
||||||
|
|
||||||
HTTP remains in maintenance mode, suitable only for exposure to trusted hosts
|
|
||||||
on a trusted network. Favor clear bug fixes and proportionate maintenance;
|
|
||||||
broader HTTP deployment capabilities are outside this remediation.
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
||||||
**Roadmap requirement — accepted 2026-11-25:** Preserve every HTTP-related
|
|
||||||
deferral from this review under **Deferred HTTP Adapter Work** in
|
|
||||||
[future.md](../future.md). The entry has been started with the agreed deferrals;
|
|
||||||
the remediation roadmap must carry it forward and complete it as remaining
|
|
||||||
decisions and implementation dispositions are settled. Record deferred work as
|
|
||||||
conditional future consideration, not a delivery commitment. Keep upstream
|
|
||||||
reader reuse separate from the accepted local reader fixes. Report-package
|
|
||||||
relocation is accepted remediation work under topic 7, not a deferral.
|
|
||||||
|
|
||||||
## 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 | Accepted 2026-11-25: lossless numbers, pathname identity, regular-file acquisition with cooperative cancellation; upstream reader reuse is separate follow-up. |
|
|
||||||
| 2. Strengthen existing behavioral protection | 4, 7, 9–13 | Accepted 2026-11-25: strengthen tests at application boundaries, consolidate redundant scenarios, and remove incidental assertions without new runtime requirements. |
|
|
||||||
| 3. Improve startup diagnostics at the owning boundary | 8 | Accepted 2026-11-25: native explanations for listener failures, upstream-owned capture diagnostics, and independent delivery of the two improvements. |
|
|
||||||
| 4. Select HTTP connection-lifetime policy | 5 | Accepted 2026-11-25: retain existing transport behavior for trusted hosts on a trusted network; defer new timeout controls and impose no gateway requirement. |
|
|
||||||
| 5. Establish whether additional memory controls are needed | 6 | Accepted 2026-11-25: retain existing limits and document the known aggregate-memory limitation; additional controls are deferred. |
|
|
||||||
| 6. Select proportionate local cleanup | 14, 15, 17 | Accepted 2026-11-25: defer standalone HTTP restructuring, permit small adjacent simplifications, and accept a focused CLI diagnostic cleanup where it reduces maintenance effort. |
|
|
||||||
| 7. Decide whether to move HTTP report ownership | 16 | Accepted 2026-11-25: move the HTTP collector, projection, and focused tests into the HTTP adapter to make its maintenance-mode boundary explicit. |
|
|
||||||
|
|
||||||
## 1. Correct The Production Defects
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Make narrow fixes with focused 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.
|
|
||||||
|
|
||||||
**Reader scope:** Adopt upstream's ordinary regular-file acquisition and
|
|
||||||
cooperative cancellation semantics. Reject unsupported non-regular inputs
|
|
||||||
before opening; streaming input support is outside this remediation. Retain
|
|
||||||
lexical containment and enforce byte limits during acquisition. The existing
|
|
||||||
symlink policy remains unchanged: the OS may follow symlinks to regular files.
|
|
||||||
Do not introduce abandoned-read goroutines, a symlink sandbox, or an
|
|
||||||
immediate-interruption guarantee.
|
|
||||||
|
|
||||||
**Separate upstream follow-up:** 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. Investigate whether a supported reusable
|
|
||||||
reader would reduce duplication. Any proposal must retain Scriptorium's access
|
|
||||||
policy and enforce byte limits during acquisition, not only after reading.
|
|
||||||
Do not import or copy upstream internals. This investigation and any upstream
|
|
||||||
release are not prerequisites for correcting the local defect.
|
|
||||||
|
|
||||||
## 2. Strengthen Existing Behavioral Protection
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Strengthen protection for existing behavior
|
|
||||||
without new product requirements. Replace weak or redundant assertions rather
|
|
||||||
than broadly expanding the test inventory.
|
|
||||||
|
|
||||||
| Catalog entries | Accepted 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 known digests for fixed content. A suitable upstream public comparison remains an alternative when interoperability is the purpose. |
|
|
||||||
| [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, using native typed evidence where available or a minimal flag-specific diagnostic fragment. 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. |
|
|
||||||
|
|
||||||
Preserve distinct privacy and retry checks when consolidating capacity tests.
|
|
||||||
Retain exact wording assertions only where wording is expressly contractual;
|
|
||||||
constructor-failure coverage must not prescribe new diagnostic wording.
|
|
||||||
The numeric representation assertion belongs with the precision correction in
|
|
||||||
topic 1. Avoid coverage quotas, exhaustive upstream test matrices, new runtime
|
|
||||||
limits, and tests that silently establish resource or disclosure guarantees.
|
|
||||||
|
|
||||||
## 3. Improve Startup Diagnostics At The Owning Boundary
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Address
|
|
||||||
[catalog entry 8](catalog.md#8-cli-startup-failures-hide-actionable-resource-context)
|
|
||||||
through the component that owns each failure.
|
|
||||||
|
|
||||||
- Application-owned listener failures: identify the selected address and a
|
|
||||||
useful failure category through native CommandKit explanations, using typed
|
|
||||||
error information where available. Deliver this improvement independently
|
|
||||||
of framework diagnostic support.
|
|
||||||
- PromptKit capture failures: seek upstream-provided resource identity or
|
|
||||||
configuration location and a useful explanation. PromptKit owns the supported
|
|
||||||
diagnostic representation and safe content; ckprompt supplies native
|
|
||||||
presentation. Native PromptKit commands should benefit alongside application
|
|
||||||
commands.
|
|
||||||
|
|
||||||
**Upstream follow-up:** Verify whether the selected public APIs can supply the
|
|
||||||
structured capture information and ckprompt can present it. If support is
|
|
||||||
missing, prepare an upstream feature request and defer that portion until
|
|
||||||
supported. The exact upstream API remains to be determined; do not build a
|
|
||||||
Scriptorium-owned framework-error interpreter.
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** For
|
|
||||||
[catalog entry 5](catalog.md#5-http-connection-lifetimes-need-a-deployment-decision),
|
|
||||||
retain existing transport behavior and defer additional body-read, idle, and
|
|
||||||
response-delivery timeout controls. HTTP remains in maintenance mode for
|
|
||||||
trusted hosts on a trusted network. No gateway, new configuration surface, or
|
|
||||||
additional lifetime guarantee is required by this remediation.
|
|
||||||
|
|
||||||
Document the existing timeout boundaries and intended operating model. The
|
|
||||||
absence of additional deadlines remains a known limitation, not a bug fix
|
|
||||||
promised by this work. Preserve the engine operation budget and shutdown
|
|
||||||
contract. Proceed with the confirmed correctness fixes and their focused
|
|
||||||
regression coverage; reconsider transport controls only if operating needs
|
|
||||||
change.
|
|
||||||
|
|
||||||
## 5. Establish Whether Additional Memory Controls Are Needed
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Treat
|
|
||||||
[catalog entry 6](catalog.md#6-per-file-limits-do-not-establish-an-aggregate-memory-budget)
|
|
||||||
as a known limitation with additional controls deferred, consistent with HTTP
|
|
||||||
maintenance mode. Retain existing request, per-file, response, and backend
|
|
||||||
capacity controls.
|
|
||||||
|
|
||||||
Briefly document that those controls do not establish an aggregate memory
|
|
||||||
budget; operators size trusted workloads accordingly. The finding does not
|
|
||||||
demonstrate a broken per-file limit, incorrect backend admission, or production
|
|
||||||
exhaustion incident. Add no aggregate-input setting, request-admission layer,
|
|
||||||
or new memory guarantee. No new benchmark project or upstream feature request
|
|
||||||
is warranted at this stage. Reconsider only if actual workloads expose a problem
|
|
||||||
or HTTP's operating model expands.
|
|
||||||
|
|
||||||
## 6. Select Proportionate Local Cleanup
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Keep cleanup proportionate to maintenance
|
|
||||||
needs; none is a prerequisite for fixing the defects.
|
|
||||||
|
|
||||||
- [14: HTTP handler](catalog.md#14-http-handler-responsibilities-are-hard-to-review-independently):
|
|
||||||
defer a standalone handler refactor. Make the correctness fixes directly;
|
|
||||||
permit a small private helper extraction only when it materially clarifies
|
|
||||||
the affected code. Preserve the request lifecycle and behavioral tests.
|
|
||||||
- [15: CLI diagnostics](catalog.md#15-cli-diagnostic-adaptation-is-duplicated-and-failure-selection-is-nested):
|
|
||||||
consolidate the genuinely shared run/serve diagnostic bridge into a private
|
|
||||||
CLI helper and flatten failure selection where it improves readability.
|
|
||||||
Preserve distinct explanations, typed causes, precedence, and native
|
|
||||||
inspection ownership. Retain short duplication if sharing would require
|
|
||||||
extra options or abstractions. This does not solve the capture-diagnostic gap.
|
|
||||||
- [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. Leaving the
|
|
||||||
current correct implementation alone is acceptable; this is not a standalone
|
|
||||||
remediation task.
|
|
||||||
|
|
||||||
No middleware framework, universal classifier, or interface for every phase is
|
|
||||||
warranted. Carry deferred HTTP cleanup into the future-work entry above.
|
|
||||||
|
|
||||||
## 7. Decide Whether To Move HTTP Report Ownership
|
|
||||||
|
|
||||||
**Decision — accepted 2026-11-25:** Implement the relocation proposed in
|
|
||||||
[catalog entry 16](catalog.md#16-http-terminal-report-ownership-spans-two-packages).
|
|
||||||
Move the HTTP terminal collector, projection types, and focused tests from
|
|
||||||
`internal/report` into dedicated files within `internal/adapter/http`; make
|
|
||||||
implementation names private where practical and remove the obsolete package.
|
|
||||||
Update affected imports and internal documentation, and carry the accepted
|
|
||||||
accounting-test corrections with the implementation.
|
|
||||||
|
|
||||||
This consolidates HTTP-specific functionality behind the adapter's
|
|
||||||
maintenance-mode boundary and distinguishes it from the actively evolving
|
|
||||||
application. Maintenance mode does not preclude a focused refactor that makes
|
|
||||||
that ownership clearer. This work belongs in the remediation roadmap, not
|
|
||||||
Deferred HTTP Adapter Work.
|
|
||||||
|
|
||||||
Preserve HTTP wire behavior, terminal-only observation, detached snapshots,
|
|
||||||
and request isolation. CLI reporting remains on the native upstream path;
|
|
||||||
introduce no shared reporting framework or HTTP reporting expansion.
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
@@ -12,7 +12,8 @@ prompt's message file or compiling its template. The application `run` and
|
|||||||
`serve` commands then report a generic initialization failure; native
|
`serve` commands then report a generic initialization failure; native
|
||||||
`promptkit list prompts` reports a generic listing failure. Operators cannot
|
`promptkit list prompts` reports a generic listing failure. Operators cannot
|
||||||
identify the resource or correct the failure from those explanations alone.
|
identify the resource or correct the failure from those explanations alone.
|
||||||
The [audit evidence](audit/06-error-handling.md) records the retained causes.
|
The [audit evidence](https://forge.maximumdirect.net/eric/scriptorium/src/commit/fc1846f84c369419bdd20d5e58f1b3130506912e/docs/roadmap/audit/06-error-handling.md)
|
||||||
|
in Git history records the retained causes.
|
||||||
|
|
||||||
Please provide supported public diagnostic evidence for capture failures that
|
Please provide supported public diagnostic evidence for capture failures that
|
||||||
identifies the affected resource and configuration location, classifies the
|
identifies the affected resource and configuration location, classifies the
|
||||||
|
|||||||
@@ -1,402 +0,0 @@
|
|||||||
# Audit Remediation Implementation Plan
|
|
||||||
|
|
||||||
Prepared 2026-11-25 for a Luna coding agent.
|
|
||||||
Baseline: `e67633b9f48b42c5b0d14782c6e8e1d4c78fcdd5`.
|
|
||||||
Status: complete; upstream capture-diagnostic adoption and conditional HTTP
|
|
||||||
future work remain deferred as described below.
|
|
||||||
|
|
||||||
## Scope And Execution
|
|
||||||
|
|
||||||
Implement the accepted [remediation target](audit-remediation.md), using the
|
|
||||||
[audit catalog](audit/catalog.md) for evidence and the accepted
|
|
||||||
[discussion](audit/discussion.md) for decision rationale. Catalog numbers below
|
|
||||||
identify findings, not additional requirements. All 17 entries have a selected
|
|
||||||
disposition; optional cleanups and deferred controls are not mandatory features.
|
|
||||||
|
|
||||||
Follow stages in order. Each stage is sized as a focused Luna assignment in one
|
|
||||||
end-to-end sprint. Intermediate stages need not compile or leave a coherent
|
|
||||||
repository; validation listed for a stage describes the evidence required by
|
|
||||||
sprint completion, not an additional per-stage green-build gate. Run focused
|
|
||||||
checks when feasible and the complete baseline once the sprint is integrated.
|
|
||||||
Record actual stage completion and any pending upstream dependency here.
|
|
||||||
Follow the repository's existing local commit policy; do not push by default.
|
|
||||||
|
|
||||||
Start with [development](../development.md) and the applicable policies:
|
|
||||||
[agents](../policy/agents.md), [architecture](../policy/architecture.md),
|
|
||||||
[testing](../policy/testing.md), and [documentation](../policy/documentation.md).
|
|
||||||
Use the canonical [HTTP](../api.md), [CLI](../cli.md),
|
|
||||||
[operations](../operations.md), [adapter](../internal/adapters.md), and
|
|
||||||
[source](../internal/sources.md) documents for existing contracts.
|
|
||||||
|
|
||||||
Keep selected dependencies unchanged: PromptKit v0.25.0, ConfigKit v1.4.0,
|
|
||||||
CommandKit v0.8.0, ckconfig v0.11.0, ckprompt v0.12.0, and ReleaseKit v0.10.0.
|
|
||||||
No library implementation, application configuration migration, new public
|
|
||||||
command, or new HTTP feature is selected. Preserve the single resolved ConfigKit
|
|
||||||
handoff, upstream execution/admission, and native CLI inspection/reporting.
|
|
||||||
|
|
||||||
## Stage 1: Preserve HTTP Provider Numbers
|
|
||||||
|
|
||||||
**Status: complete.** The provider-boundary test exposed rounding before the
|
|
||||||
decoder change and passes with lossless JSON numbers. The optional model-mapping
|
|
||||||
cleanup was left unchanged.
|
|
||||||
|
|
||||||
**Finding:** 2; optional adjacent cleanup from 17.
|
|
||||||
**Files:** `internal/adapter/http/handler.go` and `handler_test.go`.
|
|
||||||
|
|
||||||
1. Call `UseNumber` on the existing JSON decoder before decoding the request.
|
|
||||||
Keep `DisallowUnknownFields`, trailing-token rejection, request-size handling,
|
|
||||||
and typed numeric fields unchanged. Pass resulting `json.Number` values
|
|
||||||
directly through existing `ExtraParams` plumbing; PromptKit supports them.
|
|
||||||
2. Replace the concrete-float64 assertion in
|
|
||||||
`TestHandlerModelOverrideAcceptsJSONCompatibleExtraParams` with JSON-value
|
|
||||||
behavior checks. Consolidate its shape coverage into a real-engine test
|
|
||||||
rather than maintaining redundant scenarios when the stronger test covers it.
|
|
||||||
3. Exercise HTTP handler → real PromptKit engine → loopback provider with a
|
|
||||||
valid prompt/profile and `9007199254740993` at top level and in a nested
|
|
||||||
object/array. Include representative string, boolean, null, and array/object
|
|
||||||
values. Decode observed provider bytes with `UseNumber` or `RawMessage` and
|
|
||||||
compare with independent expected values, never float64-rounded expectations.
|
|
||||||
Assert successful execution and unchanged provider values. Numeric spelling
|
|
||||||
is not a new general-purpose serialization guarantee.
|
|
||||||
4. The nearby redundant `req.Model != nil` guard may be removed by calling
|
|
||||||
`executionTargetOverrideFromModelOverrideDTO(req.Model)` directly. Preserve
|
|
||||||
omission/null versus explicit-empty objects and explicit numeric zeros.
|
|
||||||
This optional simplification requires no new abstraction or standalone work.
|
|
||||||
|
|
||||||
**Evidence:** the new provider-boundary case fails without `UseNumber` and passes
|
|
||||||
with it; strict JSON, reserved parameters, typed timeout/retry validation, and
|
|
||||||
model-presence tests retain their behavior. No precision-conversion layer is added.
|
|
||||||
|
|
||||||
## Stage 2: Preserve File Identity And Independently Check Hashes
|
|
||||||
|
|
||||||
**Status: complete.** Whitespace-sensitive file identities and fixed SHA-256
|
|
||||||
expectations are covered; the identity test failed with URI trimming in place.
|
|
||||||
|
|
||||||
**Findings:** 3 and 9.
|
|
||||||
**Files:** `internal/adapter/http/artifact_reader.go` and
|
|
||||||
`artifact_reader_test.go`.
|
|
||||||
|
|
||||||
1. In `resolveLexicalPath`, clean the supplied URI without trimming whitespace.
|
|
||||||
Retain existing absolute/relative resolution, lexical containment, and
|
|
||||||
empty-URI behavior. Leave configured artifact-root normalization unchanged.
|
|
||||||
2. Extend the contained-file test with whitespace-padded and unpadded filenames
|
|
||||||
containing different fixed contents. Verify the requested bytes, name, URI,
|
|
||||||
size, and hash identify the intended file. Cover meaningful leading/trailing
|
|
||||||
whitespace with platform-appropriate fixtures, not a new filename grammar.
|
|
||||||
3. Replace expected hashes computed using production `artifactHash` with
|
|
||||||
independently known SHA-256 digests for at least two fixed contents. Keep
|
|
||||||
ordinary body/metadata and containment assertions. This checks the reader's
|
|
||||||
existing metadata, not a new global hash-uniqueness or upstream hash contract.
|
|
||||||
|
|
||||||
**Evidence:** file-identity cases fail with URI trimming, and fixed independent
|
|
||||||
expectations detect a constant-hash implementation. Existing containment,
|
|
||||||
absolute-path, inline, symlink, and byte-limit scenarios remain protected.
|
|
||||||
|
|
||||||
## Stage 3: Make Restricted Acquisition Cooperatively Cancellable
|
|
||||||
|
|
||||||
**Status: complete.** Acquisition checks cancellation around filesystem reads,
|
|
||||||
rejects non-regular files, and retains streaming size enforcement. Controlled
|
|
||||||
reader, directory, Linux FIFO, and real-engine HTTP cancellation tests pass.
|
|
||||||
|
|
||||||
**Finding:** 1, including its regression protection.
|
|
||||||
**Files:** the HTTP artifact reader/tests; a Linux-specific FIFO test file if
|
|
||||||
needed, and focused handler integration coverage.
|
|
||||||
|
|
||||||
1. Thread `context.Context` from `Read` through `readFileArtifact` and
|
|
||||||
`readArtifactFile`. Check it before filesystem acquisition, between reads,
|
|
||||||
after reads, and before returning a successful artifact.
|
|
||||||
2. Use `os.Stat` before opening and reject non-regular targets. Use `Stat` on
|
|
||||||
the opened file and reject a non-regular opened target as well. `os.Stat`
|
|
||||||
follows symlinks, preserving existing symlink behavior. Treat unsupported
|
|
||||||
file kinds as ordinary artifact-read errors through the existing HTTP
|
|
||||||
`400 artifact_read_failed` mapping; no new public status/code is needed.
|
|
||||||
3. Retain `os.Open` with deferred close, opened-file size checks, MIME fallback,
|
|
||||||
metadata, and hashing. Retain during-read byte enforcement: zero remains
|
|
||||||
unlimited, positive limits read at most limit-plus-one for oversize detection,
|
|
||||||
and `math.MaxInt64` must not overflow. Do not replace enforcement with a
|
|
||||||
post-read-only size check.
|
|
||||||
4. Use a small private context-aware `io.Reader` wrapper around the file,
|
|
||||||
retaining `io.LimitReader` and `io.ReadAll`. Check context before and after
|
|
||||||
the wrapped read and explicitly before artifact success, including the EOF
|
|
||||||
path. Wrap read errors with `%w` so context and filesystem identities survive.
|
|
||||||
Keep this local; no generic acquisition framework or background-read worker.
|
|
||||||
5. Test post-start cancellation deterministically using a controlled reader
|
|
||||||
that cancels during a read, including data returned together with EOF. Test
|
|
||||||
the same wrapper/read path production uses, not a parallel test algorithm.
|
|
||||||
A small private body-reading helper is sufficient if needed to combine the
|
|
||||||
wrapper, limit, and final cancellation check for these tests.
|
|
||||||
6. Cover non-regular rejection with a portable directory case and a
|
|
||||||
platform-appropriate FIFO case. On Linux use a `_linux_test.go` file and
|
|
||||||
`syscall.Mkfifo`. Bound the test and arrange cleanup to release a FIFO-open
|
|
||||||
regression before joining workers; cancellation alone cannot unblock the
|
|
||||||
old implementation. If the worker remains pending, a bounded nonblocking
|
|
||||||
writer-open retry (`O_WRONLY|O_NONBLOCK`) can meet the waiting reader; close
|
|
||||||
that writer to supply EOF before joining. Do not leave a diagnostic
|
|
||||||
goroutine pending on failure.
|
|
||||||
7. Retain a representative real-engine HTTP cancellation path with the
|
|
||||||
restricted reader injected. A test reader decorator can cancel the request
|
|
||||||
as acquisition starts and then delegate to the actual restricted reader.
|
|
||||||
Verify context identity survives PromptKit wrapping, the HTTP cancellation
|
|
||||||
classification is retained, and no provider dispatch occurs. The controlled
|
|
||||||
reader test separately proves cancellation during reading.
|
|
||||||
|
|
||||||
**Evidence:** pre-cancel and post-start/EOF cancellation return no successful
|
|
||||||
artifact; FIFO/directory input is rejected without waiting for content; size
|
|
||||||
limits and typed mappings still work. These are cooperative checks, not a
|
|
||||||
promise to interrupt synchronous calls immediately or defend against concurrent
|
|
||||||
privileged filesystem replacement. Do not add symlink resolution, streaming
|
|
||||||
support, copied upstream implementation, or abandoned-read goroutines.
|
|
||||||
|
|
||||||
## Stage 4: Protect Shared Admission At Real Server Composition
|
|
||||||
|
|
||||||
**Status: complete.** A real configured server holds one provider call while a
|
|
||||||
second receives a private capacity rejection without another dispatch.
|
|
||||||
|
|
||||||
**Findings:** 4 and 7.
|
|
||||||
**Files:** `internal/adapter/cli/lifecycle_test.go` and existing HTTP capacity
|
|
||||||
tests/helpers in `internal/adapter/http/handler_test.go`.
|
|
||||||
|
|
||||||
1. Reuse the real `serveWithListener` harness and native configuration loading.
|
|
||||||
Configure a loopback provider backend with concurrency limit one, queue
|
|
||||||
capacity zero, and no additional transient retries. Do not inject an engine
|
|
||||||
whose lifetime the test itself has selected.
|
|
||||||
2. Start the server and first HTTP run. Wait for an explicit provider-entry
|
|
||||||
signal and hold that call. While it is held, send a bounded second request;
|
|
||||||
require `503 capacity_exceeded`, no `Retry-After`, no backend/cause disclosure,
|
|
||||||
and no second provider dispatch. Track dispatches without blocking an
|
|
||||||
accidentally admitted second provider call forever.
|
|
||||||
3. Release the first call and require its successful completion. Cancel the
|
|
||||||
server invocation and join server/client/provider work. Register cleanup
|
|
||||||
before launching workers: request/server cancellation, idempotent single-owner
|
|
||||||
release, response-body closing, and bounded joins. Avoid reading buffers
|
|
||||||
while their owners may still write. Synchronize with channels rather than
|
|
||||||
sleep-based admission assumptions.
|
|
||||||
4. Once the stronger scenario preserves its meaningful assertions, remove
|
|
||||||
`TestHandlerSharesBackendCapacityAcrossConcurrentRequests` and helpers used
|
|
||||||
only by that scenario. Keep distinct deadline/capacity-wait and retry-slot
|
|
||||||
scenarios and independent error/privacy protection.
|
|
||||||
|
|
||||||
**Evidence:** the real server rejects the second call before dispatch under the
|
|
||||||
held first call, and owned workers are released on assertion-failure paths.
|
|
||||||
A per-request-engine construction would violate this test. No production engine
|
|
||||||
lifetime change is required; the current server already shares one engine.
|
|
||||||
|
|
||||||
## Stage 5: Correct Startup, Removed-Flag, And Error Test Blind Spots
|
|
||||||
|
|
||||||
**Status: complete.** Native engine capture fails before listening with typed
|
|
||||||
causes, removed flags are identified in otherwise-valid invocations, and HTTP
|
|
||||||
error tests retain classification and privacy without pinning generic prose.
|
|
||||||
|
|
||||||
**Findings:** 11–13.
|
|
||||||
**Files:** `internal/adapter/cli/lifecycle_test.go`, `app_test.go`, and HTTP
|
|
||||||
error/timeout/report tests in `handler_test.go`.
|
|
||||||
|
|
||||||
1. Add server startup coverage for a successfully resolved configuration with
|
|
||||||
either a missing message `content_file` or malformed template. Use native
|
|
||||||
loading and actual engine construction. Assert `ErrInvalidConfig`, the
|
|
||||||
underlying filesystem identity where applicable, status 1, empty stdout,
|
|
||||||
and no listen attempt through the existing listener seam. Do not fabricate
|
|
||||||
a ConfigKit `LoadError` or move capture into configuration validation.
|
|
||||||
2. Correct `TestRemovedSourceAndSchemaFlagsAreRejected`: give `run` its required
|
|
||||||
prompt operand and every base invocation a valid controlled configuration
|
|
||||||
and otherwise-valid arguments. Check Usage/status 2 plus the rejected flag
|
|
||||||
name in supported structured evidence or a minimal diagnostic fragment.
|
|
||||||
Keep all existing command/removed-flag rows; do not pin complete sentences.
|
|
||||||
3. Review assertions affected by generic HTTP model-generation/error prose,
|
|
||||||
including `TestHandlerPublicErrorMapping`, timeout cases, and report-bearing
|
|
||||||
failures. Assert HTTP status, machine code, precedence, a usable nonempty
|
|
||||||
message, and private-cause exclusion. Preserve intentionally contractual
|
|
||||||
distinctions without requiring exact noncontractual sentences. Do not weaken
|
|
||||||
privacy checks merely to make a rewording pass.
|
|
||||||
|
|
||||||
**Evidence:** engine construction fails before listening, flag tests fail for
|
|
||||||
the removed flag rather than a missing operand, and harmless generation-error
|
|
||||||
rewording does not break unrelated cases. Typed/status/privacy behavior remains
|
|
||||||
protected. The numeric assertion correction is already owned by stage 1.
|
|
||||||
|
|
||||||
## Stage 6: Move HTTP Report Implementation Into Its Adapter
|
|
||||||
|
|
||||||
**Status: complete.** HTTP owns the terminal report projection and its real-engine
|
|
||||||
tests; distinct cache-token fields and their encoded presence are verified.
|
|
||||||
|
|
||||||
**Findings:** 10 and 16.
|
|
||||||
**Files:** `internal/report/report.go`, `report_test.go`, HTTP `handler.go` and
|
|
||||||
`dto.go`; destination `internal/adapter/http/execution_report.go` and
|
|
||||||
`execution_report_test.go`.
|
|
||||||
|
|
||||||
1. Move the collector/projection and focused tests into the HTTP adapter,
|
|
||||||
retaining the native terminal observer. Use private names such as
|
|
||||||
`executionReport`, `executionUsage`, `executionTokenCount`,
|
|
||||||
`executionCollector`, and `newExecutionCollector`. Qualify short projection
|
|
||||||
helpers if needed to avoid package-name collisions. Preserve exported JSON
|
|
||||||
fields/tags required for encoding.
|
|
||||||
2. Update handler/DTO type references and all imports, then remove the obsolete
|
|
||||||
`internal/report` package. Keep CLI delivery on native `RunResult` reporting;
|
|
||||||
do not create a replacement shared report package.
|
|
||||||
3. Strengthen the moved `TestCollectorProjectsOnlyTerminalAggregates` fixture
|
|
||||||
with distinct nonzero cached-token and cache-write-token values and meaningful
|
|
||||||
known/complete combinations. Assert each of the five required usage fields'
|
|
||||||
`value`, `known`, and `complete` members and values, not just object length.
|
|
||||||
Retain known-zero, unknown, and incomplete-total cases.
|
|
||||||
4. Preserve terminal-only observation, detached snapshots, absent-event behavior,
|
|
||||||
unknown outcome/failure mapping, identifiers, zero/omission semantics, request
|
|
||||||
isolation, success/error attachment, and encoded response-size behavior.
|
|
||||||
Move the representative real-engine observation test rather than replacing
|
|
||||||
it with only hand-built events. Do not expose reasoning/cost/cache-ratio
|
|
||||||
fields; those remain future work.
|
|
||||||
|
|
||||||
**Evidence:** report tests and HTTP integration tests pass from the new owner,
|
|
||||||
swapped cache fields are detectable, and production imports no longer reference
|
|
||||||
`internal/report`. Existing wire behavior is unchanged.
|
|
||||||
|
|
||||||
## Stage 7: Improve Listener Explanations And Simplify CLI Diagnostics
|
|
||||||
|
|
||||||
**Status: complete.** Listener failures identify the selected address and safe
|
|
||||||
error category, and run/serve share application-configuration diagnostics.
|
|
||||||
|
|
||||||
**Findings:** the local portion of 8, and 15.
|
|
||||||
**Files:** `internal/adapter/cli/server.go`, `native_run.go`, `outcomes.go`, and
|
|
||||||
focused lifecycle/diagnostic tests.
|
|
||||||
|
|
||||||
1. Enrich listener-failure native explanations with the selected address and a
|
|
||||||
deliberately selected category. Use `errors.As` for `*net.AddrError` or
|
|
||||||
`*net.DNSError`, and `errors.Is` for ordinary address-in-use/permission errors
|
|
||||||
where applicable. Fall back to a generic listener-setup category for other
|
|
||||||
errors. Do not render arbitrary error strings. Retain `WithCause(err)`,
|
|
||||||
status 1, no stdout, and native presentation, including quiet-mode failures.
|
|
||||||
2. Extend actual invalid-address coverage and use the existing listener seam
|
|
||||||
for deterministic typed bind failures. Assert the selected address, a minimal
|
|
||||||
useful category, retained cause identity, and status, not whole sentences.
|
|
||||||
3. Extract the duplicated run/serve evidence selection/adaptation into a small
|
|
||||||
private application-configuration diagnostic helper. Select sources/records
|
|
||||||
from the result when present, replacing them with a wrapped nonnil ConfigKit
|
|
||||||
`LoadError`'s evidence when applicable; adapt using the existing application
|
|
||||||
heading and queue native diagnostics. Return the explanation for each caller.
|
|
||||||
Keep framework-specific headings/appended details distinct; share further
|
|
||||||
only if it stays simpler than the short duplication.
|
|
||||||
4. Flatten `requestFailure` into an ordered switch with configuration
|
|
||||||
classification after operation-timeout/canceled/deadline cases and before
|
|
||||||
remaining framework cases. Preserve every current status, cause, detail,
|
|
||||||
and message selection. Keep a single local CLI classifier, not a universal
|
|
||||||
CLI/HTTP abstraction. Native config inspection must not receive duplicate
|
|
||||||
diagnostics, and bootstrap reporting remains on its current path.
|
|
||||||
|
|
||||||
**Evidence:** listener failures expose useful selected context while retaining
|
|
||||||
their causes/statuses; existing bootstrap, load-error, precedence, presentation
|
|
||||||
failure, and provider-privacy tests remain effective. This helper refactor does
|
|
||||||
not fix PromptKit capture diagnostics.
|
|
||||||
|
|
||||||
## Stage 8: Prepare The Upstream Capture-Diagnostic Request
|
|
||||||
|
|
||||||
**Status: complete locally.** The [consumer request](capture-diagnostics.md)
|
|
||||||
is prepared and its reproductions checked. Adoption is deferred pending a
|
|
||||||
supported PromptKit release and ckprompt presentation; no upstream submission
|
|
||||||
or diagnostic implementation is claimed.
|
|
||||||
|
|
||||||
**Finding:** the upstream-dependent portion of 8.
|
|
||||||
**Deliverable:** `docs/roadmap/capture-diagnostics.md`, an upstream-ready consumer
|
|
||||||
request and pending-adoption record, not a library implementation.
|
|
||||||
|
|
||||||
The planning review checked the selected public APIs and the audit's native
|
|
||||||
failure evidence. PromptKit v0.25.0 preserves constructor causes but does not
|
|
||||||
provide a structured capture-diagnostic value. ckprompt v0.12.0 adapts ConfigKit
|
|
||||||
`LoadError` evidence, not these ordinary capture errors. Config validation can
|
|
||||||
succeed before engine capture fails. Select the already-approved request and
|
|
||||||
deferral path; do not leave Luna to design a local workaround or choose an upgrade.
|
|
||||||
|
|
||||||
1. Describe Scriptorium's missing-file and malformed-template operator failures
|
|
||||||
and the need for resource identity/configuration location, failure category,
|
|
||||||
and a useful safely displayable explanation through a supported public API.
|
|
||||||
Preserve typed causes and classification, with native ckprompt presentation
|
|
||||||
benefiting alongside application `run` and `serve`.
|
|
||||||
2. Supply minimal synthetic reproductions using existing fixtures, including
|
|
||||||
application commands and native `promptkit list prompts`. Record observed
|
|
||||||
status and cause identities. Explain why ordinary config inspection is not
|
|
||||||
the capture lifecycle and why raw causes cannot be indiscriminately shown.
|
|
||||||
Reuse stage 5 evidence where applicable; no paid provider is required.
|
|
||||||
3. Request public diagnostic evidence from PromptKit and native presentation
|
|
||||||
through ckprompt from the consumer perspective. Do not prescribe upstream
|
|
||||||
internals, invent an API, or copy implementations. Keep the document local
|
|
||||||
for upstream submission; no sibling repository change, submission, or push
|
|
||||||
is needed to complete this sprint.
|
|
||||||
4. Mark adoption pending a supported released API and presentation integration.
|
|
||||||
Preserve the current generic capture explanations, statuses, and causes.
|
|
||||||
Record this stage as request prepared/adoption deferred, never diagnostics
|
|
||||||
implemented. Keep this cross-CLI dependency separate from HTTP-only deferrals.
|
|
||||||
|
|
||||||
**Evidence:** a concrete request identifies both upstream responsibilities,
|
|
||||||
reproductions, desired consumer behavior, and the release dependency. The
|
|
||||||
unsupported presentation improvement does not block other local completion.
|
|
||||||
|
|
||||||
## Stage 9: Align Canonical Documentation And Validate The Sprint
|
|
||||||
|
|
||||||
**Status: complete.** Canonical HTTP, operations, architecture, and internal
|
|
||||||
documentation reflects the delivered behavior and maintenance scope; future
|
|
||||||
HTTP work remains in `future.md`. The optional model-mapping simplification was
|
|
||||||
not taken. The upstream request was prepared, not implemented or submitted.
|
|
||||||
The full normal and race test suites, vet, formatting, local documentation link
|
|
||||||
targets, and diff checks passed. The build passed with a temporary output path
|
|
||||||
to preserve a pre-existing ignored root binary. The request's synthetic CLI
|
|
||||||
commands were exercised without a provider.
|
|
||||||
|
|
||||||
**Findings:** 5, 6, 14, and 17 dispositions, plus documentation for delivered work.
|
|
||||||
|
|
||||||
1. Update [operations](../operations.md) with trusted-host/trusted-network HTTP
|
|
||||||
maintenance scope. Replace wording implying a gateway makes broader exposure
|
|
||||||
supported by this work; impose no gateway requirement for current use.
|
|
||||||
Reflect that scope briefly in the [architecture policy](../policy/architecture.md)
|
|
||||||
and align [API service guidance](../api.md#service-and-route).
|
|
||||||
2. In operations, distinguish the existing header timeout and engine operation
|
|
||||||
budget from body-read/idle/response-delivery deadlines. Explain briefly that
|
|
||||||
request, per-file, response, and backend limits are not an aggregate-memory
|
|
||||||
budget. Retain existing shutdown, timeout, cancellation, and capacity behavior;
|
|
||||||
no new timeout setting, admission layer, memory cap, benchmark project, or
|
|
||||||
mandatory authenticated gateway is part of remediation.
|
|
||||||
3. Update the HTTP API's application-specific input guidance for lossless provider
|
|
||||||
numbers, significant pathname whitespace, and regular-file input rejection.
|
|
||||||
Update [source internals](../internal/sources.md) for cooperative acquisition,
|
|
||||||
lexical/byte limits, and unchanged symlink behavior. Link upstream for native
|
|
||||||
features instead of reproducing library documentation. Do not promise immediate
|
|
||||||
interruption of filesystem calls or a whole-request deadline.
|
|
||||||
4. Update [component inventory](../internal/overview.md) and
|
|
||||||
[adapter internals](../internal/adapters.md) for HTTP-local reporting and
|
|
||||||
delivered listener/diagnostic handling. Remove obsolete package references
|
|
||||||
from current-state docs. Keep audit evidence and accepted decision history
|
|
||||||
intact; historical references are not stale implementation documentation.
|
|
||||||
5. Preserve all conditional HTTP deferrals under **Deferred HTTP Adapter Work**
|
|
||||||
in [future.md](future.md): additional transport deadlines, aggregate input/
|
|
||||||
memory controls, standalone handler decomposition, and upstream artifact-reader
|
|
||||||
reuse that retains access policy and acquisition-time limits. Keep optional
|
|
||||||
model-mapping cleanup only if it remains undone; keep other existing future
|
|
||||||
directions. Report relocation is delivered work, not future work. Keep
|
|
||||||
`future.md` future-only, and track pending capture-diagnostic adoption in
|
|
||||||
`capture-diagnostics.md` rather than folding it into the HTTP entry.
|
|
||||||
6. Format changed Go files and run the existing development baseline:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
go test ./...
|
|
||||||
go test -race ./...
|
|
||||||
go vet ./...
|
|
||||||
go build ./cmd/scriptorium
|
|
||||||
git diff --check
|
|
||||||
```
|
|
||||||
|
|
||||||
Check affected links/examples and any changed documented commands. Do not
|
|
||||||
commit the local build artifact. No new release gate or coverage quota is
|
|
||||||
introduced. The suite stays offline with controlled local providers.
|
|
||||||
7. Record stage results here, including optional cleanup dispositions and the
|
|
||||||
upstream request/adoption distinction. Review the full diff for unintended
|
|
||||||
dependency, configuration, public-interface, or guarantee changes. Follow
|
|
||||||
local staging/commit policy and report checks, commits, and remaining deferrals.
|
|
||||||
|
|
||||||
**Completion:** all local fixes/refactors and their regression evidence are
|
|
||||||
delivered, canonical documentation matches them, every catalog entry has its
|
|
||||||
accepted disposition, and only the explicitly deferred upstream/HTTP work
|
|
||||||
remains pending. Preparing the upstream request completes its local workstream,
|
|
||||||
not delivery of upstream capture presentation.
|
|
||||||
|
|
||||||
## Open Questions
|
|
||||||
|
|
||||||
None requiring a user decision. The accepted scope and pinned-API review select
|
|
||||||
the upstream request/deferred-adoption outcome for capture diagnostics; a later
|
|
||||||
released capability can be evaluated separately.
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
# Post-Implementation Review Findings
|
|
||||||
|
|
||||||
Reviewed 2026-11-25 at `a949f23a87dc581e6beff400f440e09afcb23969`, against
|
|
||||||
the nine stages in [implementation.md](implementation.md) and the accepted
|
|
||||||
[remediation target](audit-remediation.md). Changes reviewed begin after
|
|
||||||
`6beddde`. The review itself implemented no fixes; subsequent remediation is
|
|
||||||
recorded by the completion markers below.
|
|
||||||
|
|
||||||
## 1. Non-Generation HTTP Errors Still Pin Noncontractual Sentences (P3)
|
|
||||||
|
|
||||||
**Status: complete.** Removed complete-sentence expectations from the HTTP error
|
|
||||||
mapping table while retaining status/code/precedence, usable-message, and
|
|
||||||
private-cause checks. Normal and race-enabled full suites, vet, build, formatting,
|
|
||||||
and whitespace checks passed. The harmless artifact-error rewording overlay now
|
|
||||||
passes the full mapping table. Runtime messages are unchanged.
|
|
||||||
|
|
||||||
**Type:** incomplete stage 5 test cleanup; unnecessary test-level contract.
|
|
||||||
**Location:** `TestHandlerPublicErrorMapping` in
|
|
||||||
[handler_test.go](../../internal/adapter/http/handler_test.go).
|
|
||||||
|
|
||||||
The revised table exempts only `llm_failed` from exact message comparison.
|
|
||||||
Artifact, profile, prompt, capacity, and other rows still require complete
|
|
||||||
sentences even though the [HTTP contract](../api.md#error-responses) defines
|
|
||||||
status/code meanings and concise cause-safe messages, not those exact sentences.
|
|
||||||
Stage 5 explicitly selects semantic assertions rather than noncontractual prose;
|
|
||||||
its completion summary currently overstates that cleanup.
|
|
||||||
|
|
||||||
**Evidence:** a temporary Go compiler overlay changed only the
|
|
||||||
`artifact_read_failed` message in `mapRunError` from “failed to read input
|
|
||||||
artifact” to “could not read the requested input artifact.” The artifact row
|
|
||||||
failed at line 1748 despite unchanged status, machine code, error precedence,
|
|
||||||
and private-cause exclusion. The overlay did not change repository files.
|
|
||||||
|
|
||||||
**Required remediation:** remove the remaining complete-sentence expectations
|
|
||||||
where wording is not expressly contractual. Retain status/code/precedence,
|
|
||||||
nonempty usable messages, and cause-privacy assertions; use a minimal semantic
|
|
||||||
fragment only where it protects a selected distinction. Do not change runtime
|
|
||||||
messages or make their current wording a public guarantee to satisfy the tests.
|
|
||||||
|
|
||||||
## 2. The Feature Roadmap Still Claims Implementation Has Not Started (P3)
|
|
||||||
|
|
||||||
**Status: complete.** Removed the stale preparation-time implementation status
|
|
||||||
and made the baseline explicitly historical. `implementation.md` remains the
|
|
||||||
owner of current stage status. Pending capture-diagnostic adoption and
|
|
||||||
conditional HTTP deferrals are unchanged. Documentation links and whitespace
|
|
||||||
checks passed.
|
|
||||||
|
|
||||||
**Type:** stage 9 documentation consistency gap.
|
|
||||||
**Location:** the opening status in
|
|
||||||
[audit-remediation.md](audit-remediation.md), line 3.
|
|
||||||
|
|
||||||
The roadmap still says “Status: planned; implementation has not started,” while
|
|
||||||
the committed implementation plan records completed local work and the code
|
|
||||||
contains that work. The baseline discussion also uses present-tense language
|
|
||||||
about unchanged application sources, making the current-versus-historical
|
|
||||||
distinction unnecessarily ambiguous.
|
|
||||||
|
|
||||||
**Required remediation:** remove or clearly historicize the preparation-time
|
|
||||||
status and describe the baseline explicitly as pre-implementation evidence.
|
|
||||||
Keep actual stage status in `implementation.md`, which the roadmap already
|
|
||||||
identifies as its owner. Preserve the pending capture-diagnostic adoption and
|
|
||||||
conditional HTTP deferrals; neither is delivered by the completed local sprint.
|
|
||||||
|
|
||||||
## Stage-By-Stage Review
|
|
||||||
|
|
||||||
| Stage | Assessment |
|
|
||||||
| --- | --- |
|
|
||||||
| 1: provider numbers | `UseNumber` preserves nested provider values through the real engine. Removing it in an overlay makes the regression test fail. Strict decoding and typed overrides remain intact; optional model cleanup was correctly left deferred. |
|
|
||||||
| 2: file identity/hashes | Request-path trimming is removed independently of configured-root normalization. Distinct filenames and fixed independent digests protect identity and metadata. |
|
|
||||||
| 3: acquisition | Context reaches file/body reads; regular-file checks precede and follow opening; acquisition-time byte limits remain. Controlled cancellation, HTTP cancellation, and non-regular tests cover the selected behavior. Removing regular-file checks makes the FIFO test fail and its cleanup releases the blocked reader. |
|
|
||||||
| 4: shared admission | The real configured server owns its engine. An overlay constructing a new engine per request makes the server-composition test fail with a second provider dispatch, and cleanup completes. Distinct retry/wait scenarios remain. |
|
|
||||||
| 5: test blind spots | Startup capture fails before listening with retained causes; removed-flag invocations include complete run inputs and identify the rejected flag. Prose relaxation remains incomplete as described in finding 1. |
|
|
||||||
| 6: HTTP reports | Projection and focused tests moved into the HTTP adapter; the old package is gone. The move preserves runtime behavior, and a cache-field swap overlay is detected by the strengthened assertions. |
|
|
||||||
| 7: diagnostics | Listener explanations select address/category without dumping causes. Shared application diagnostic adaptation and flattened failure selection preserve native ownership and precedence. |
|
|
||||||
| 8: upstream request | The local request is present and accurately records deferred adoption. Missing-file and malformed-template reproductions each yield successful config validation and status-1 capture failures for run, serve, and native listing. No upstream implementation/submission is claimed. |
|
|
||||||
| 9: documentation/validation | Canonical API, operations, architecture, and internal documents reflect the changes and selected limits; future work remains conditional. The roadmap status needs the correction in finding 2. |
|
|
||||||
|
|
||||||
## Architecture And Scope
|
|
||||||
|
|
||||||
The application retains a single ConfigKit resolution handoff to PromptKit;
|
|
||||||
native CommandKit integrations own standard operator workflows. The HTTP server
|
|
||||||
shares one engine and its backend admission state across requests. Restricted
|
|
||||||
artifact access and terminal-report projection now both live in the HTTP adapter.
|
|
||||||
The separate `internal/report` package is removed; CLI reports remain native
|
|
||||||
upstream results. ReleaseKit continues to own release mechanics. Dependency
|
|
||||||
versions are unchanged.
|
|
||||||
|
|
||||||
No production correctness defect or unintended runtime restriction/guarantee was
|
|
||||||
identified in the reviewed changes. Regular-file acquisition, trusted-network
|
|
||||||
maintenance scope, and deferred transport/memory controls match the accepted
|
|
||||||
decisions. Finding 1 concerns incidental wording still frozen by tests, not a
|
|
||||||
new public API promise. Immediate filesystem interruption, symlink sandboxing,
|
|
||||||
aggregate-memory limits, broader HTTP exposure, and new reporting fields remain
|
|
||||||
outside this work.
|
|
||||||
|
|
||||||
## Validation
|
|
||||||
|
|
||||||
- Uncached normal and race-enabled full test suites passed.
|
|
||||||
- `go vet ./...`, a build to a temporary output path, Go formatting checks, and
|
|
||||||
whitespace checks passed. The existing ignored root binary was not replaced.
|
|
||||||
- Targeted compiler overlays demonstrated the four regression detections in
|
|
||||||
the stage table and the harmless prose failure in finding 1. These were
|
|
||||||
temporary review diagnostics, not a new required test platform.
|
|
||||||
- The request's eight synthetic CLI invocations were exercised without a
|
|
||||||
provider or credentials. Only this findings document was added to the repository.
|
|
||||||
|
|
||||||
These checks support the reviewed scope; they are not an exhaustive audit of
|
|
||||||
upstream libraries or a new release certification.
|
|
||||||
Reference in New Issue
Block a user