298 lines
16 KiB
Markdown
298 lines
16 KiB
Markdown
# Adopt Scriptorium v0.16 and prompt requirements discovery
|
|
|
|
**Status: Implemented.** The [integration contract](../integrations/scriptorium.md)
|
|
describes current behavior; the baseline below records the prior implementation.
|
|
|
|
## Purpose
|
|
|
|
Adopt Scriptorium's native CLI for trim-bounds generation and analysis. Use its
|
|
prompt requirements discovery to identify missing Narratio input bindings before
|
|
expensive upstream work, including when the eventual input files do not exist.
|
|
|
|
This roadmap defines the target and required changes. The
|
|
[implementation plan](implementation.md) owns the ordered implementation steps.
|
|
The Audita and session workspace roadmaps remain separate scopes.
|
|
|
|
## Reviewed Baseline
|
|
|
|
Narratio was reviewed at commit
|
|
`9fa1797`. The reviewed Scriptorium v0.16.0 release identifies commit
|
|
`0fa538c336fd64be51bc355fd53d3ca19f104d68`.
|
|
|
|
The following upstream documents own Scriptorium's behavior:
|
|
|
|
- [Release notes][release].
|
|
- [CLI reference][cli] and [CLI migration guide][migration].
|
|
- [Subprocess integration contract][subprocess].
|
|
- [Configuration][configuration] and [PromptKit migration guidance][prompts].
|
|
- [Native requirements contract][requirements].
|
|
|
|
Scriptorium implements the previously requested early requirements inspection.
|
|
It exposes native PromptKit findings through CommandKit, including exact input
|
|
names, requirement classifications, variable presence, selected identities,
|
|
discovery completeness, and structured issues. Further upstream changes are
|
|
unnecessary for this capability. Richer capture diagnostics for malformed
|
|
templates remain separate upstream work.
|
|
|
|
## Reviewed Narratio Behavior
|
|
|
|
The [Scriptorium integration](../integrations/scriptorium.md) owns the current
|
|
contract. Its adapter serves both `trim` and `analyze`, including optional
|
|
render-debug calls.
|
|
|
|
- Generation uses the former `run --prompt`, file-valued `--input`, `--timeout`,
|
|
and `--out` interface. Preview uses the former `render` command.
|
|
- The adapter classifies exit status 2 as generated-content validation failure.
|
|
- Scriptorium writes an output file that Narratio validates before promotion.
|
|
The existing artifact limit is 64 MiB.
|
|
- Shared subprocess execution captures stdout and stderr as bounded, redacted
|
|
diagnostics. It has no separate stdout product destination.
|
|
- Configuration validation checks Narratio's artifact sources and dependencies.
|
|
It does not ask Scriptorium which prompt input names or variables are required.
|
|
- Analysis planning expands character families and computes prerequisite closure.
|
|
`session plan` currently invokes no stage-execution adapters.
|
|
- Scriptorium credentials use the same explicit forwarding and diagnostic
|
|
redaction boundary as Audita and Notarius.
|
|
|
|
The current adapter is incompatible with the new CLI. Scriptorium is a separately
|
|
installed executable; this adoption is an integration and deployment migration,
|
|
rather than a new Go module dependency.
|
|
|
|
## Targeted End State
|
|
|
|
### Native generation and preview
|
|
|
|
Use Scriptorium v0.16's native commands for both trim and analyze:
|
|
|
|
| Existing invocation behavior | Target behavior |
|
|
| --- | --- |
|
|
| `run --prompt ID` | `run ID` |
|
|
| File bindings through `--input NAME=PATH` | Repeated `--input-file NAME=PATH` |
|
|
| `render --prompt ID` | `promptkit show prepared ID`, using its native structured output |
|
|
| `--out PATH` | Narratio captures stdout to its run-local destination |
|
|
| Former duration-valued `--timeout` | Narratio's existing supervisor deadline remains authoritative; generation may also pass `--run-timeout` for the engine budget |
|
|
| Content-validation failure at status 2 | Content-validation failure at status 4; status 2 retains native usage/configuration meaning |
|
|
|
|
Preserve the distinction between the whole-invocation deadline and native
|
|
per-attempt provider timeouts. Existing duration settings retain their Narratio
|
|
meaning. This migration adds no per-attempt timeout setting.
|
|
|
|
Capture generation in automatic/text format so the output file contains artifact
|
|
bytes, rather than the full native result envelope. Capture prepared preview in
|
|
the native JSON format. Keep diagnostics separate from these result streams.
|
|
Invocation records describe the actual native commands and retain credential
|
|
names only.
|
|
|
|
Keep current stage output validation, successful promotion, failure handling,
|
|
resume, force, and dependency behavior. A partially delivered stdout file or a
|
|
file produced with a nonzero outcome does not establish stage completion.
|
|
Preserve existing treatment of older completed outputs after failed replacement.
|
|
|
|
### Early prompt requirements inspection
|
|
|
|
Add an adapter operation for:
|
|
|
|
```sh
|
|
scriptorium promptkit requirements show PROMPT_ID --format json
|
|
```
|
|
|
|
Supply the same effective configuration, prompt, profile, applicable variables,
|
|
and session context as the eventual generation request. Preserve qualified IDs
|
|
and upstream selection semantics. Discovery, preview, and generation share
|
|
request-context construction so character-specific variables and session routing
|
|
agree. Preserve Narratio's existing `session_id=narratio-session-<session_id>`
|
|
template variable, including its precedence over configured `vars.session_id`.
|
|
Do not supply a direct `--session-id`: that native option bypasses the prompt's
|
|
session template and would change routing ownership. Existing downstream
|
|
selectors remain authoritative; this work does not introduce another
|
|
configuration-resolution layer.
|
|
|
|
Inspect named requirements before generated files exist. Discovery reads
|
|
configuration and prompt resources and makes no model call. ConfigKit's native
|
|
bootstrap and configuration acquisition still apply. Discovery does not require
|
|
future artifact payloads or prove execution credentials are ready.
|
|
|
|
Narratio compares required prompt input names with the keys in its effective
|
|
binding map. For example, a source named
|
|
`narratio.transcript.final_trimmed_markdown` can satisfy the prompt input
|
|
`transcript` when explicitly bound under that name. Source identity and binding
|
|
name remain distinct.
|
|
|
|
A configured binding does not guarantee that its source will be available.
|
|
Narratio omits unavailable optional sources from the eventual request. When a
|
|
prompt requires such an input and availability is unknown, report the uncertainty
|
|
as a warning without rejecting the configuration or changing the binding's
|
|
optionality. A missing required binding is a definite error; unknown future
|
|
source availability is not. Existing runtime input resolution remains
|
|
authoritative.
|
|
|
|
Use native variable-presence findings, including explicit empty values. Associate
|
|
findings with the affected trim prompt or concrete analysis artifact. Retain
|
|
existing Narratio source validation and dependency planning as their respective
|
|
authorities.
|
|
|
|
Inspection covers relevant trim generation and effective selected analysis
|
|
targets, including character-family expansion and required prerequisite work.
|
|
Use the existing planner to skip work it can establish will be reused and inspect
|
|
work that may execute under the projected plan. Earlier stages may produce
|
|
outputs that change later reuse decisions, so preflight does not promise exact
|
|
prediction of pending work. Actual execution remains authoritative; do not add a
|
|
second planner or simulation system. Unselected integrations remain unaffected.
|
|
The inspection policies below define entry points and handling of findings.
|
|
|
|
### Native findings and their limits
|
|
|
|
Consume the native report directly. Use structured fields for decisions and
|
|
upstream explanations for display. Preserve exact names, classifications,
|
|
nullable metadata, empty inventories, and false values.
|
|
|
|
A complete report describes discovery coverage. Narratio separately determines
|
|
whether bindings satisfy the discovered requirements. Partial discovery can
|
|
return status zero and still contain useful findings. An empty partial inventory
|
|
does not establish that the prompt needs no inputs.
|
|
|
|
Native nonzero outcomes and stderr supply invocation-failure information. Attach
|
|
Narratio context without parsing diagnostic prose for stable categories. The
|
|
native report has no Scriptorium-specific schema-version envelope or per-input
|
|
schema contract; this migration adds neither.
|
|
|
|
Concrete `promptkit requirements validate` remains a separate upstream operation
|
|
for when files exist. Automatic concrete validation and provider smoke tests are
|
|
outside this scope. Discovery is an early configuration aid, not a guarantee of
|
|
later preparation or generation success.
|
|
|
|
## Required Changes
|
|
|
|
### Subprocess and adapter boundary
|
|
|
|
Extend the existing subprocess boundary proportionately to support stdout result
|
|
capture alongside its current diagnostic-only use. Product and machine-readable
|
|
report capture must preserve result bytes. Diagnostic redaction and its 8 MiB
|
|
capture policy must not truncate or transform artifact payloads. Retain the
|
|
existing artifact-size guard, cancellation, owned-process cleanup, credential
|
|
forwarding, and contextual errors.
|
|
|
|
Keep other adapters' existing diagnostic capture behavior unchanged. Use the
|
|
same supervised execution machinery for generation, preview, and requirements
|
|
inspection. Reuse result capture for native reports without introducing a
|
|
separate limit setting.
|
|
|
|
Update Scriptorium argument construction, exit classification, preview handling,
|
|
invocation metadata, adapter doubles, and trim/analyze wiring. Required discovery
|
|
data and transport behavior belong behind the adapter; Narratio's binding and
|
|
selection decisions belong in the application layer.
|
|
|
|
### Preflight integration
|
|
|
|
Add `internal/preflight` to coordinate prompt requirements checks. Automatic
|
|
preflight and `session validate` use the same checking paths and consume the same
|
|
findings and errors. Their target selection follows the inspection policies
|
|
below; command handlers own presentation, with validation able to show fuller
|
|
warning and informational detail without changing finding severity.
|
|
|
|
Reuse existing production machinery for effective artifact definitions, planning,
|
|
request-context construction, and adapter execution. Share or extract existing
|
|
helpers where needed rather than copying them into preflight. Keep code specific
|
|
to preflight limited to coordinating inspection and assessing intended bindings
|
|
against native findings. Avoid a second artifact graph, prompt parser,
|
|
configuration loader, or persistent discovery cache. A per-invocation inspection
|
|
result is sufficient; inspect different variable contexts independently where
|
|
needed.
|
|
|
|
Add contextual operator findings for definite missing bindings and discovery
|
|
limitations. Preserve unsuccessful inspection as an error in both entry points;
|
|
successful partial discovery remains distinct from invocation or report-decoding
|
|
failure. Apply the inspection policies without altering unrelated stage
|
|
selection, manifest transitions, or ordinary configuration inspection.
|
|
|
|
### Deployment and documentation
|
|
|
|
Coordinate adapter adoption with the installed Scriptorium executable and its
|
|
native configuration/prompt definitions. Review removed directory settings,
|
|
native imports, profile identities, source-relative resources, and validation
|
|
repair budgets through the upstream migration guides. Preserve explicit
|
|
configuration-path forwarding and existing exact-name credential forwarding.
|
|
|
|
Target the native interface directly. Version probing, legacy command fallbacks,
|
|
and automatic downstream configuration conversion are outside this scope.
|
|
Narratio does not acquire ownership of Scriptorium's backend or prompt settings.
|
|
|
|
When implementation lands, update the integration contract and focused adapter,
|
|
preflight, trim, and analyze internal documentation. Update CLI, configuration,
|
|
operations, and troubleshooting documentation where preflight affects operator behavior.
|
|
Link upstream for native command and configuration details; document Narratio's
|
|
binding decisions, execution boundary, and failure context locally.
|
|
|
|
Keep preview placement consistent with the existing debug workflow until the
|
|
[workspace roadmap](workspace.md) changes it. Its latest-attempt views and layout
|
|
rules remain owned by that work. The [Audita adoption](audita.md) is independently
|
|
implementable.
|
|
|
|
## Verification and Completion
|
|
|
|
Use focused offline tests at the subprocess, adapter, preflight, and orchestration
|
|
boundaries. Cover the consequential migration risks:
|
|
|
|
- File bindings use native file flags; positional prompt selection and preview
|
|
commands match the selected upstream release.
|
|
- Artifact stdout is byte-preserving and separate from redacted diagnostics,
|
|
including payloads larger than the diagnostic capture limit.
|
|
- Native exit classifications, cancellation, capture failures, partial delivery,
|
|
and output validation retain correct stage-completion behavior.
|
|
- Discovery works without generated files and identifies mismatched names,
|
|
required variables, conditional inputs, and incomplete findings; uncertain
|
|
optional-source availability warns without changing binding policy.
|
|
- Discovery, preview, and generation agree on effective request context,
|
|
including expanded families and variable-based session routing.
|
|
- Inspection covers projected work and required prerequisites, including disabled
|
|
prerequisites, while skipping work the planner establishes will be reused.
|
|
- Preflight failures precede stage attempts and preserve completed outputs;
|
|
`session plan` remains subprocess-free and inspection makes no model calls.
|
|
- Automatic preflight and `session validate` agree on findings for the same
|
|
targets and context. Both stop on unsuccessful inspection or definite missing
|
|
requirements; discovery incompleteness and warnings alone do not fail.
|
|
|
|
Default tests use subprocess doubles and temporary filesystems. They remain
|
|
independent of sibling checkouts, installed downstream tools, real credentials,
|
|
and paid providers. A controlled compatibility check against the selected
|
|
Scriptorium release can supplement those tests.
|
|
|
|
Completion means trim generation, analysis generation, and optional preview use
|
|
the native CLI; requirements inspection implements the policies below; and
|
|
local integration and operator documentation describe the landed behavior.
|
|
|
|
## Inspection Policies
|
|
|
|
### Automatic inspection entry points
|
|
|
|
Inspect applicable projected Scriptorium work before stage attempts begin, and
|
|
include requirements findings in `session validate`.
|
|
Keep ordinary `session plan` independent of subprocess inspection for this scope.
|
|
An unsuccessful inspection or definite missing requirement stops the affected
|
|
execution or validation with ordinary contextual error reporting. Warnings and
|
|
informational findings alone do not stop automatic execution. Early preflight
|
|
failure does not invalidate previously completed outputs. Unrelated stage-only
|
|
invocations remain unaffected.
|
|
|
|
Scriptorium must consequently be available earlier for an invocation whose
|
|
projected work needs it. Validation inspects enabled trim and analysis definitions
|
|
and their required prerequisites, including disabled prerequisites. Execution
|
|
uses its selected projected work and prerequisite closure as described above.
|
|
|
|
### Incomplete or conditional discovery
|
|
|
|
Fail for definite missing required bindings or required variables. Display
|
|
incomplete-discovery issues and unresolved conditional requirements as warnings
|
|
while allowing execution to proceed when no definite missing requirement is
|
|
established. This uses native findings without making
|
|
static analyzability a new validity requirement for prompts. Later preparation
|
|
and generation remain authoritative for actual requests.
|
|
|
|
[release]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/releases/v0.16.0.md
|
|
[cli]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/cli.md
|
|
[migration]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/consumers/upgrading-cli.md
|
|
[subprocess]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/integrations/subprocess.md
|
|
[configuration]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/config.md
|
|
[prompts]: https://forge.maximumdirect.net/eric/scriptorium/src/tag/v0.16.0/docs/consumers/upgrading-promptkit.md
|
|
[requirements]: https://forge.maximumdirect.net/base-layer/commandkit/src/commit/0b53a63648c536afe50c46f948159116f776adae/docs/cli.md#promptkit-requirements
|