Document Scriptorium preflight and native integration
This commit is contained in:
@@ -1,80 +1,53 @@
|
||||
# Integration: Scriptorium
|
||||
|
||||
## Purpose
|
||||
Define the Scriptorium adapter contract used by `analyze` and trim-bounds generation in `trim`.
|
||||
## Boundary
|
||||
|
||||
## External Boundary
|
||||
Narratio uses the independently installed Scriptorium v0.16.0 native CLI for
|
||||
trim bounds and configured analysis artifacts. It invokes `run PROMPT_ID` for
|
||||
generation, `promptkit show prepared PROMPT_ID` for optional preview, and
|
||||
`promptkit requirements show PROMPT_ID` for early discovery. Scriptorium owns
|
||||
prompt, profile, backend, and private configuration resolution. The
|
||||
[upstream CLI migration guide](https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/consumers/upgrading-cli.md)
|
||||
and [subprocess contract](https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/integrations/subprocess.md)
|
||||
own the native interface and deployment migration.
|
||||
|
||||
Narratio invokes Scriptorium as a subprocess in these modes:
|
||||
Generation selects artifact-only text output. Preview and requirements use
|
||||
native JSON. Narratio forwards selected configuration and profile identifiers,
|
||||
sorted repeated `--input-file NAME=PATH` bindings where files are needed, and
|
||||
repeated `--var KEY=VALUE` assignments. Commas and later equals signs remain
|
||||
literal. Discovery supplies no input paths and makes no model call. Narratio's
|
||||
supervisor deadline covers each invocation; generation also forwards the same
|
||||
duration as `--run-timeout`, separate from Scriptorium's per-attempt timeout.
|
||||
|
||||
- `scriptorium run`
|
||||
- `scriptorium render`
|
||||
## Streams And Outcomes
|
||||
|
||||
The request timeout and parent cancellation bound each invocation. Internal
|
||||
runner composition is documented in
|
||||
[the adapter implementation guide](../internal/adapters.md).
|
||||
Narratio captures stdout directly into the run-local artifact or preview, or
|
||||
into memory for discovery. Result bytes are preserved and limited to 64 MiB;
|
||||
they are not diagnostic logs and are not redacted. Treat generated artifacts
|
||||
and prepared previews as potentially sensitive. Stderr remains separately
|
||||
bounded and redacted. A capture failure aborts the supervised subprocess.
|
||||
|
||||
## Request Contract
|
||||
Both request types carry:
|
||||
- binary/config/prompt/profile IDs;
|
||||
- input map and vars map;
|
||||
- output path;
|
||||
- timeout;
|
||||
- generated config + stdout/stderr log paths;
|
||||
- optional list of already-resolved credential references;
|
||||
- optional working directory.
|
||||
A successful generation or preview must produce a nonempty result; preview must
|
||||
also be valid JSON. Narratio validates the result before stage-owned canonical
|
||||
promotion. A nonzero outcome or delivery failure remains an error even if
|
||||
stdout contains bytes. Native exit status 4 identifies completed generated
|
||||
content validation failure; status 2 is a usage or configuration failure.
|
||||
Invocation records describe the actual arguments and stdout destination.
|
||||
|
||||
## Result Contract
|
||||
`ArtifactResult` returns:
|
||||
- output/log/generated-config paths;
|
||||
- exit code and duration;
|
||||
- command mode (`run` or `render`);
|
||||
- prompt/profile provenance;
|
||||
- `ValidationFailed` marker;
|
||||
- metadata map.
|
||||
Requirements discovery returns the native inventories, identities,
|
||||
completeness, and structured issues. A successful partial report is distinct
|
||||
from a process or decoding failure. Narratio compares the reported requirements
|
||||
with its intended bindings; discovery does not establish future file availability
|
||||
or guarantee a later model call. See [preflight internals](../internal/preflight.md)
|
||||
and the [upstream requirements contract](https://forge.maximumdirect.net/base-layer/commandkit/src/commit/0b53a63648c536afe50c46f948159116f776adae/docs/cli.md#promptkit-requirements).
|
||||
|
||||
## Validation and Failure Semantics
|
||||
Request validation fails for:
|
||||
- missing binary, prompt id, or output path;
|
||||
- non-positive timeout;
|
||||
- empty input/var names;
|
||||
- empty input path values;
|
||||
- unresolved or empty selected credential references.
|
||||
## Credentials And Configuration
|
||||
|
||||
Both modes use the shared credential forwarding used by Audita and Notarius:
|
||||
selected names and captured values augment the minimal child environment, and
|
||||
all selected values are registered for captured-stream redaction. The adapter
|
||||
does not reread the parent environment or override Scriptorium's provider
|
||||
selection with `--api-key-env`. Generated invocation records and result metadata
|
||||
contain `credential_env_names`, never credential values. This does not scan or
|
||||
redact files written directly by Scriptorium. Selection semantics belong in
|
||||
[Scriptorium credentials](../config.md#scriptorium-credentials).
|
||||
|
||||
Run behavior:
|
||||
- subprocess errors propagate with context;
|
||||
- `run` exit code `2` is mapped to `ValidationFailed=true`;
|
||||
- successful subprocess still fails if output file is missing or empty.
|
||||
|
||||
Each artifact result is limited to 64 MiB and must be a regular file without
|
||||
symlinked path components.
|
||||
|
||||
Render behavior:
|
||||
- subprocess errors propagate;
|
||||
- output file must exist and be non-empty.
|
||||
|
||||
## Deterministic Behavior
|
||||
- input and var maps are sorted into deterministic `--input` and `--var` CLI args.
|
||||
- stage wiring adds `session_id=narratio-session-<session_id>` to every Scriptorium request for sticky upstream routing, overriding any configured `vars.session_id`.
|
||||
- generated invocation YAML (`scriptorium.generated.v1`) is emitted when requested.
|
||||
- adapter is stateless and does not own artifact-selection policy.
|
||||
|
||||
## Configuration
|
||||
|
||||
Operator-selected values are defined under `pipeline.scriptorium.*`, including
|
||||
per-artifact settings under `pipeline.scriptorium.artifacts.*`, in the
|
||||
[configuration reference](../config.md#pipeline).
|
||||
|
||||
Maintained examples with Scriptorium config:
|
||||
|
||||
- [Full annotated pipeline](../../examples/pipeline.full.annotated.yml)
|
||||
- [Production-shaped pipeline](../../examples/pipeline.production.yml)
|
||||
Selected ConfigKit secret references are forwarded by exact environment name
|
||||
for discovery, preview, and generation. Their captured values are registered
|
||||
for stderr diagnostic redaction, while invocation records retain names only.
|
||||
Narratio does not choose the provider or pass a direct API-key override. This
|
||||
does not scrub arbitrary result content or files written by Scriptorium. See
|
||||
[Scriptorium credentials](../config.md#scriptorium-credentials) and
|
||||
[artifact entries](../config.md#scriptorium-artifact-entries) for Narratio's
|
||||
configuration and binding semantics.
|
||||
|
||||
Reference in New Issue
Block a user