Plan audit remediation implementation

This commit is contained in:
2026-11-25 17:21:45 +00:00
parent e67633b9f4
commit 6beddde313
2 changed files with 466 additions and 214 deletions

View File

@@ -1,12 +1,13 @@
# Audit Remediation Roadmap
Prepared 2026-11-25. Status: planned; implementation has not started.
Baseline: `f040f6906ca14cdfea4162ae31f9dfb18e7667e1`.
Reviewed baseline: `e67633b9f48b42c5b0d14782c6e8e1d4c78fcdd5`.
This roadmap implements the accepted [audit discussion](audit/discussion.md).
The [catalog](audit/catalog.md) and original reports retain the detailed evidence
and reproductions. This document owns the target state, work sequence, and
implementation status; it does not introduce new runtime contracts.
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
@@ -25,237 +26,125 @@ ConfigKit, PromptKit, and CommandKit retain the responsibilities established by
HTTP stays in maintenance mode, suitable only for exposure to trusted hosts on
a trusted network. The rest of the application remains actively developed.
Maintenance work includes the accepted report relocation because it makes that
boundary clearer; it does not expand HTTP reporting or deployment capabilities.
The accepted report relocation makes that boundary clearer without expanding
HTTP reporting or deployment capabilities.
At completion of the local work:
## HTTP Input Handling
- Provider parameters reach PromptKit without numeric precision loss, and file
references retain their pathname identity.
- Restricted acquisition uses ordinary regular-file semantics, cooperatively
observes cancellation, and preserves the existing lexical and byte limits.
- Tests detect the demonstrated application regressions without pinning
incidental representations or error prose.
- HTTP terminal reporting and its focused tests live within the HTTP adapter;
CLI reporting continues to use native upstream results and presentation.
- Listener failures carry useful native explanations. Framework capture
diagnostics follow the supported upstream route or remain explicitly tracked
pending upstream support, as specified in stage 4.
- Current contracts and internal documentation reflect the delivered changes,
and deferred HTTP work remains visible in [future.md](future.md).
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.
## Scope And Disposition
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.
Numbers refer to the [audit catalog](audit/catalog.md). Status for every stage
below is **not started**.
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.
| Catalog entries | Disposition | Stage |
| --- | --- | --- |
| 1–3 | Correct cancellation/non-regular acquisition, numeric precision, and pathname identity. | 1 |
| 9 | Replace self-referential artifact-hash expectations alongside reader work. | 1 |
| 4, 7, 11–13 | Strengthen server lifetime/failure coverage, test cleanup, removed-flag rejection, and error assertions. | 2 |
| 10, 16 | Move HTTP report implementation and tests into the adapter; strengthen accounting assertions. | 3 |
| 8 | Improve listener explanations; verify native capture-diagnostic support and integrate or prepare an upstream request. | 4 |
| 15 | Consolidate the small CLI diagnostic bridge where it reduces maintenance effort. | 4 |
| 5, 6 | Retain existing transport and capacity controls; document limitations and defer additional controls. | 5 |
| 14 | Defer standalone handler decomposition; permit a small useful extraction beside corrective work. | 1, 5 |
| 17 | Permit the nil-aware mapping simplification beside request changes; leaving current correct behavior is acceptable. | 1, 5 |
## Effective Behavioral Protection
## Stage 1: Correct HTTP Input Handling
Tests protect demonstrated failure modes at their application-owned boundaries
rather than incidental representations or error prose:
Work primarily in
[artifact_reader.go](../../internal/adapter/http/artifact_reader.go),
[handler.go](../../internal/adapter/http/handler.go), and their existing tests.
- 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.
1. Enable the request decoder's `UseNumber` capability. Preserve strict unknown
field handling, typed numeric validation, and trailing-token rejection.
Replace the concrete-float64 test expectation with lossless behavior checks.
Use a representative HTTP-to-real-engine-to-loopback-provider case with a
large integer and nested values; do not decode expected and actual values
through float64. Consolidate the old mapping scenario only after retaining
its meaningful JSON-shape protection.
2. Remove request-path whitespace trimming while retaining lexical cleaning
and containment. Keep configured artifact-root normalization separate.
Verify padded and unpadded filenames with distinct contents and preserve
body and metadata identity checks.
3. Pass context through file acquisition. Reject unsupported non-regular input
before opening; align opened-file checks with ordinary upstream semantics.
Check cancellation during reading and before successful return. Preserve
the configured byte limit during acquisition, including oversize detection,
and retain causes through the existing artifact-error mapping.
4. Replace hash expectations derived from the production helper with independent
expected digests for fixed, differing contents. A suitable public upstream
comparison is an alternative when checking interoperability.
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.
Cover cancellation after acquisition starts and unsupported non-regular input
with deterministic, bounded, platform-appropriate tests and reliable cleanup.
Retain a representative real-engine or HTTP path. A small controlled read seam
may be used where needed; no general fault-injection framework is required.
## HTTP Report Ownership
These changes do not add streaming input support, resolve symlinks for
containment, promise immediate interruption of synchronous filesystem calls,
or abandon blocked reads in background goroutines. Existing symlink behavior
remains unchanged. Ordinary CLI artifact loading remains upstream-owned.
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.
If request mapping is touched, calling the existing nil-aware model converter
unconditionally is permitted. Preserve omitted/null versus explicit-empty
objects and numeric presence. Do not turn this into a standalone cleanup task
or a broad handler rewrite.
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.
**Completion evidence:** focused regressions establish lossless provider values,
correct file identity, cooperative cancellation and non-regular handling, and
independently checked hashes while existing containment and size tests pass.
## Startup Diagnostics And CLI Maintenance
## Stage 2: Protect Server Composition And Failure Boundaries
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.
Use the existing CLI server harness in
[lifecycle_test.go](../../internal/adapter/cli/lifecycle_test.go) and the relevant
HTTP/CLI test owners.
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.
- Consolidate the shared-capacity scenario at actual server composition.
Configure capacity one with no queue, hold the first provider call, and
verify rejection of a second request without a second provider dispatch.
Release the first request and check completion. The test must exercise the
server's engine lifetime rather than inject the lifetime it intends to prove.
- Register cancellation, release, and worker joining before launching work;
bound the second request and retain one owner of channel closure. Test bounds
are cleanup mechanisms, not production deadlines. Remove the lower-level
duplicate only after equivalent protection exists; retain distinct privacy
and retry checks.
- Cover a resolved configuration that fails engine construction on a missing
message file or malformed template. Assert the typed cause, nonzero outcome,
and absence of a listen attempt. Do not require new diagnostic wording or
move message capture into configuration inspection.
- Give removed-flag tests otherwise-valid invocations. Distinguish rejection
of the removed flag using native typed evidence where available or a minimal
flag-specific fragment. Keep hard-cutover protection.
- Replace exact noncontractual HTTP error sentences with status/code/precedence,
usable nonempty-message, and private-cause exclusion assertions. Retain exact
wording only where expressly contractual.
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.
**Completion evidence:** tests protect server-owned shared admission and startup
ordering, fail for the intended invalid flag, and tolerate harmless error
rewording. Concurrency-test failure paths release and join their owned work.
## Deferred Work And Operating Limits
## Stage 3: Consolidate HTTP Terminal Reporting
The following remain conditional future work in [future.md](future.md), not
delivery commitments:
Move [internal/report](../../internal/report/report.go) and its focused tests
into dedicated files in `internal/adapter/http`. Make implementation names
private where practical, update handler/DTO references, and remove the obsolete
package. Package reduction is a consequence; the purpose is to place HTTP-only
functionality behind the maintenance-mode adapter boundary.
- 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.
Carry the accounting-test correction with the move: use distinct cached-token
and cache-write-token values and meaningful known/complete combinations. Assert
the required JSON member names and values instead of only counting members.
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.
Preserve existing wire shapes, opt-in and absence semantics, success/error
attachment, terminal-only observation, detached snapshots, unknown/incomplete
counts, request isolation, and response-limit handling. Retain representative
real-engine observation coverage. This work does not add accounting fields,
change CLI reports, or create a shared reporting framework.
## Scope Coverage
**Completion evidence:** existing HTTP report behavior and strengthened projection
tests pass from the new location; production imports no longer reference the
removed package. Update the component inventory and adapter documentation with
the move. This stage is required, not deferred HTTP work.
Numbers refer to the [audit catalog](audit/catalog.md).
## Stage 4: Improve Startup Diagnostics And CLI Maintenance
| 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. |
In [server.go](../../internal/adapter/cli/server.go), add a deliberate native
CommandKit explanation identifying the selected listen address and a useful
failure category from typed error information where available. Preserve the
cause and existing status. Cover representative operator-correctable failures
without making the entire error sentence contractual.
## Documentation End State
Consolidate the genuinely shared run/serve ConfigKit evidence selection and
adaptation into a small private CLI helper where useful. Preserve successful
result versus wrapped load-error evidence selection, distinct headings and
explanations, bootstrap reporting, and timeout/configuration precedence.
Flatten nested failure selection when clearer. Retain short duplication if
sharing would require extra options or abstractions. Native inspection already
owns its presentation and must not receive duplicate application diagnostics.
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.
Handle PromptKit capture diagnostics as a separate workstream:
1. Verify the selected public PromptKit and ckprompt APIs against missing-file
and malformed-template cases. Determine whether they supply safe structured
resource identity/configuration location and a useful explanation.
2. Where supported, use the native integration for application and native
PromptKit commands. Preserve typed causes, statuses, and capture lifecycle.
3. If support is missing, prepare an upstream feature request covering both
diagnostic evidence and native presentation, and record the dependency and
deferred adoption explicitly. Do not invent an API or select an unreleased
dependency in this roadmap. A later supported release can enable adoption.
Do not parse formatted errors, print arbitrary causes, import upstream internals,
or construct an application-owned framework-error interpreter. These capture
errors are not repaired merely by sharing the ConfigKit diagnostic helper.
**Completion evidence:** local listener explanations and existing diagnostic
precedence/privacy tests pass. The capture workstream has either verified native
delivery with representative coverage or a concrete upstream request and tracked
deferral. In the latter case, report capture presentation as deferred, not fixed.
That dependency does not block stages 1–3 or local listener improvements.
## Stage 5: Align Documentation And Preserve Deferred Work
Update canonical documents with delivered behavior rather than duplicating their
contracts here:
- [Operations](../operations.md) and, where applicable, the
[architecture policy](../policy/architecture.md): make the selected trusted-host,
trusted-network maintenance scope clear. Do not imply that a gateway makes
broader exposure supported by this remediation or require one for current use.
- [HTTP API](../api.md) and [source internals](../internal/sources.md): describe
corrected input behavior and regular-file acquisition without stronger
cancellation or filesystem guarantees.
- [Component overview](../internal/overview.md) and
[adapter internals](../internal/adapters.md): reflect report ownership and
delivered diagnostic handling. Preserve upstream ownership and CLI reporting.
- Operations: briefly clarify that existing transport deadlines and per-file,
request, response, and backend controls are not aggregate-memory or
whole-HTTP-request lifetime guarantees. Retain the operation-budget and
shutdown contracts. No new resource controls are part of this work.
Maintain the already-started **Deferred HTTP Adapter Work** entry in
[future.md](future.md). It must retain every HTTP deferral from this review:
additional body-read/idle/response-delivery deadlines; aggregate input/memory
controls; standalone handler decomposition; and optional model-mapping cleanup
if left unchanged. Revisit controls only when workloads or operating needs
justify them; no benchmark project or memory-control feature request is required.
Keep possible public upstream artifact-reader reuse there as separate follow-up.
Investigate whether it can remove ordinary reading/metadata duplication while
preserving access policy and byte enforcement during acquisition. Neither this
investigation nor an upstream release delays the local reader correction.
Report-package relocation must not appear as deferred. Preserve other existing
future directions, including broader HTTP review and additional accounting.
**Completion evidence:** current documentation matches the implemented scope;
every deferred HTTP item has a durable disposition in future.md. Record any
pending framework-diagnostic dependency separately so it is not mistaken for
HTTP-only work or an implemented fix.
## Validation And Completion
Follow the [development baseline](../development.md#baseline-validation) and
[testing policy](../policy/testing.md) for implementation changes: ordinary and
race-enabled tests, vet, build, formatting, whitespace, and affected documentation
and example checks. Use real internal collaborators and controlled local providers;
the default suite remains offline and independent of live credentials.
Focused tests should extend or replace the existing behavior owners. Preserve
meaningful protection before removing duplicate scenarios. Do not add coverage
quotas, exhaustive upstream matrices, mandatory mutation-testing infrastructure,
or new release gates. The audit's experiments guide regression selection; they
do not require a new ongoing test platform.
Track each stage's actual completion and any upstream-dependent deferral. Local
remediation is complete when stages 1–5 have their stated evidence, including
documentation and future-work tracking. Do not mark upstream capture presentation
delivered if only its feature request is complete.
All seven scope decisions are settled. Remaining API investigation and conditional
deferral follow the accepted ownership decision; they do not reopen application
policy. No additional significant open decision is identified at this baseline.
`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.