From 9867d6eb12b000eb9178e93da74469bc95f7a652 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Wed, 25 Nov 2026 17:37:57 +0000 Subject: [PATCH] Document HTTP maintenance scope and remediation --- docs/api.md | 8 +++++++- docs/internal/adapters.md | 5 ++++- docs/internal/overview.md | 3 +-- docs/internal/sources.md | 7 +++++-- docs/operations.md | 13 +++++++++---- docs/policy/architecture.md | 3 +++ docs/roadmap/implementation.md | 12 +++++++++++- internal/adapter/http/handler_test.go | 7 +++++++ 8 files changed, 47 insertions(+), 11 deletions(-) diff --git a/docs/api.md b/docs/api.md index 4f98aed..7993378 100644 --- a/docs/api.md +++ b/docs/api.md @@ -6,7 +6,8 @@ This is the canonical public HTTP contract for Scriptorium. `POST /v1/runs` runs one prompt request and returns generated output, validation, and metadata. The service has no built-in authentication or -authorization; deploy it behind appropriate network and authentication controls. +authorization. Its maintenance scope is trusted hosts on a trusted network; +see [HTTP deployment](operations.md#http-deployment-and-shutdown). The service address and HTTP limits are configured as described in the [configuration reference](config.md). `serve` invocation is defined in the @@ -62,6 +63,8 @@ it is rejected with `400 artifact_not_allowed`. This lexical check does not resolve symlinks: the operating system follows symlinks inside the root, including ones that target outside it. Keep the root narrow and inaccessible to untrusted writers. +Pathname whitespace is significant. File inputs must resolve to regular files; +other file types are rejected as `400 artifact_read_failed`. The optional `model` object accepts `endpoint`, `model`, `temperature`, `max_tokens`, `top_p`, `timeout_seconds`, `service_tier`, @@ -72,6 +75,9 @@ Explicit zero values for the numeric fields are overrides; zero `timeout_seconds` disables the per-attempt generation deadline only, retaining the request context and configured transport cap. The timeout layers are defined in the [PromptKit outbound integration contract](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/docs/integrations/openai-compatible-chat.md#timeout-and-cancellation). +JSON numbers in `extra_params`, including nested values, are passed without +the HTTP decoder rounding them through floating-point conversion; provider +parameter semantics remain owned by PromptKit and the provider. Raw API-key values are not accepted. `api_key`, the removed `prompt_version`, and any other unknown field cause `400 invalid_json`. Prompt and profile IDs diff --git a/docs/internal/adapters.md b/docs/internal/adapters.md index 52f092b..f6178ea 100644 --- a/docs/internal/adapters.md +++ b/docs/internal/adapters.md @@ -49,6 +49,9 @@ owns preparation, credentials, admission, retries, repairs, and content validati outcomes, preserving causes while keeping provider payloads out of terminal explanations. A returned completed validation failure remains a domain outcome; an unexpected nil successful result is an integration failure. +Run and serve share application-configuration diagnostic adaptation. Listener +failures include the selected address and a safe typed category while retaining +the cause; framework capture explanations remain generic pending upstream support. `delivery.go` submits the actual RunResult to the invocation reporter with a reusable artifact-byte text template. The optional file renders that same value @@ -69,7 +72,7 @@ mapping to PromptKit requests. Its Runner interface is a consumer-side external boundary using native values. Request controls do not mutate shared engine defaults; shared backend capacity accounting remains in that engine. -HTTP optional reports use one per-request `internal/report.Collector`, attached +HTTP optional reports use one per-request adapter-local collector, attached only for opted-in requests. It copies terminal aggregates, not event history, and is never the CLI result report. Success/error attachment and encoded-size handling retain the [HTTP contract](../api.md#execution-report). Reader sentinel diff --git a/docs/internal/overview.md b/docs/internal/overview.md index 82cdb44..4423119 100644 --- a/docs/internal/overview.md +++ b/docs/internal/overview.md @@ -8,10 +8,9 @@ public behavior belongs in the linked contracts. | --- | --- | --- | | `cmd/scriptorium` | ReleaseKit version handoff to CommandKit, signal-aware context, native status-to-process exit. | [CLI](../cli.md), [adapters](adapters.md) | | `internal/adapter/cli` | CommandKit composition, ckconfig/ckprompt acquisition, application loading, native request mapping, run/report effects, and HTTP process lifecycle. | [CLI](../cli.md), [adapters](adapters.md), [sources](sources.md) | -| `internal/adapter/http` | Routes, strict DTO decoding, transport limits, public request/result/error mapping, and restricted artifact reader. | [HTTP API](../api.md), [adapters](adapters.md), [sources](sources.md) | +| `internal/adapter/http` | Routes, strict DTO decoding, transport limits, public request/result/error mapping, terminal report projection, and restricted artifact reader. | [HTTP API](../api.md), [adapters](adapters.md), [sources](sources.md) | | `internal/config` | Shared ConfigKit schema, secrets bootstrap, discovery/selection, and application definition callbacks. | [Configuration](../config.md), [sources](sources.md) | | `internal/defaults` | Application and HTTP default constants. | [Configuration](../config.md) | -| `internal/report` | HTTP terminal-observation metadata projection. It is not used for CLI native result reports. | [HTTP execution report](../api.md#execution-report), [adapters](adapters.md) | CommandKit, ckconfig, ckprompt, ConfigKit, PromptKit, and ReleaseKit are released upstream dependencies, not local framework packages. There is no custom CLI formatter diff --git a/docs/internal/sources.md b/docs/internal/sources.md index 46ebe5f..f42ef98 100644 --- a/docs/internal/sources.md +++ b/docs/internal/sources.md @@ -39,8 +39,11 @@ upstream-owned. The reader accepts inline content without a root. File references need a root; relative paths resolve below it and absolute paths must be lexically contained. -Traversal outside is rejected and the configured file byte limit applies, with -zero unlimited. Reads preserve native artifact metadata and honor cancellation. +Traversal outside is rejected without trimming pathname whitespace. The reader +checks for regular files before and after opening, and enforces the configured +byte limit while reading (zero means unlimited). It checks cancellation before +acquisition, around reads, and before returning success; synchronous filesystem +calls are not guaranteed to stop immediately. Reads retain artifact metadata. Containment does not resolve symlinks. The OS may follow a symlink inside the root to an outside target; this is not a filesystem sandbox or a defense against diff --git a/docs/operations.md b/docs/operations.md index 1cefaf0..48caa38 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -77,8 +77,9 @@ It increases encoded response size and remains subject to the configured limit. ## HTTP Deployment And Shutdown -The service has no built-in authentication/authorization. Deploy on a trusted -network or behind appropriate authenticated proxy/gateway controls. Use a narrow, +The HTTP adapter is maintained for trusted hosts on a trusted network; it has +no built-in authentication/authorization. Broader exposure is outside the +current maintenance scope, even when a gateway is present. Use a narrow, dedicated artifact root with controlled ownership and permissions when accepting file inputs; this is lexical containment, not a symlink sandbox. @@ -102,10 +103,14 @@ waiting; engine defaults and per-request overrides belong to [configuration](config.md) and the [CLI](cli.md)/[HTTP](api.md) contracts. Whole-operation budgets are distinct from per-attempt generation timeouts. They remain cooperative and do not include configuration/setup or delivery. +The HTTP server has a header-read timeout, but no separate body-read, idle, or +response-delivery deadline. The engine operation budget is not a whole-request +deadline. Request-body, per-file, response, and backend limits do not constitute +an aggregate input or memory budget. Before increasing HTTP byte limits, measure representative requests/artifacts/ -responses, confirm memory/network/provider capacity, retain authentication and -upstream request controls, and test a representative workload. Do not widen the +responses, confirm memory/network/provider capacity and existing deployment +controls, and test a representative workload. Do not widen the artifact root just to make an arbitrary host path accessible. For failures, capture diagnostics without publishing sensitive data. Verify diff --git a/docs/policy/architecture.md b/docs/policy/architecture.md index 010b9bf..e4c396b 100644 --- a/docs/policy/architecture.md +++ b/docs/policy/architecture.md @@ -135,6 +135,9 @@ request after correcting inputs, configuration, or environment. conversation management, or multi-step workflow orchestration. ## Trust Boundaries And Threat Scope +The HTTP adapter is maintained for use by trusted hosts on a trusted network; +broader exposure is outside its current maintenance scope. + Ordinary CLI file loading belongs to Promptkit. For untrusted inbound HTTP artifact references, Scriptorium injects a restricted `promptkit.ArtifactReader`. It denies file references without an artifact diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index a77ea64..cb5e64b 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -2,7 +2,8 @@ Prepared 2026-11-25 for a Luna coding agent. Baseline: `e67633b9f48b42c5b0d14782c6e8e1d4c78fcdd5`. -Status: implementation in progress. +Status: complete; upstream capture-diagnostic adoption and conditional HTTP +future work remain deferred as described below. ## Scope And Execution @@ -329,6 +330,15 @@ 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 diff --git a/internal/adapter/http/handler_test.go b/internal/adapter/http/handler_test.go index 6a4ff2e..883f91e 100644 --- a/internal/adapter/http/handler_test.go +++ b/internal/adapter/http/handler_test.go @@ -71,6 +71,13 @@ func TestHandlerCancellationDuringRestrictedArtifactAcquisition(t *testing.T) { } } +func TestHandlerRejectsDirectoryArtifact(t *testing.T) { + h := newArtifactRootHandler(t, t.TempDir()) + w := httptest.NewRecorder() + h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","inputs":{"input":{"type":"file","uri":"."}}}`))) + assertHTTPErrorCode(t, w, http.StatusBadRequest, "artifact_read_failed") +} + func (run runnerFunc) Run(ctx context.Context, req promptkit.RunRequest) (*promptkit.RunResult, error) { return run(ctx, req) }