Files
weatherreporter/docs/internal/scriptorium-adapter.md

79 lines
2.0 KiB
Markdown
Raw Normal View History

2026-05-29 17:32:57 +00:00
# Scriptorium Adapter Internals
2026-05-29 19:54:22 +00:00
This document describes the subprocess adapter in
`internal/adapters/scriptorium`.
2026-05-29 17:32:57 +00:00
## Purpose
2026-05-29 19:54:22 +00:00
The adapter runs `scriptorium render` for prompt preflight and `scriptorium run`
for Markdown report generation while isolating subprocess details from domain
packages.
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
## Inputs And Outputs
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
Inputs:
2026-05-29 17:32:57 +00:00
- prompt ID
- prompt input data package path
- report output path for `run`
2026-05-29 17:32:57 +00:00
- configured binary, config path, profile, timeout, and extra arguments
2026-05-29 19:54:22 +00:00
Outputs:
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
- argv used for execution
- captured stdout and stderr with truncation flags
2026-05-29 17:32:57 +00:00
- exit code
2026-05-29 19:54:22 +00:00
- report output path for `run`
2026-05-29 17:32:57 +00:00
## Boundaries
2026-05-29 19:54:22 +00:00
- This adapter owns Scriptorium argv construction and subprocess execution.
- It does not choose report types, build prompt input, fetch weather data,
decide workflow order, or persist workflow metadata.
## Config Fields Used
- `scriptorium.binary`
- `scriptorium.config_path`
- `scriptorium.profile`
- `scriptorium.timeout`
- `scriptorium.extra_args`
## External Adapters Used
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
- external `scriptorium` CLI
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
See [Scriptorium integration](../integrations/scriptorium.md) for the external
CLI contract used by this project.
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
## State Or Manifest Behavior
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
`SaveRenderResult` can write render results atomically. The app and state store
own managed preflight paths and metadata links.
2026-05-29 19:54:22 +00:00
## Skip And Resume Behavior
2026-05-29 19:54:22 +00:00
None. Context cancellation and configured timeout stop subprocess execution.
2026-05-29 17:32:57 +00:00
## Failure Behavior
2026-05-29 19:54:22 +00:00
- Missing prompt ID, data package path, or run output path returns an error.
- Subprocess start or context errors are wrapped with operation context.
- Nonzero render and run exits return captured output plus an error containing
exit code and stderr.
- Captured stdout and stderr are size-limited and marked when truncated.
2026-05-29 17:32:57 +00:00
## Tests
Inspect:
- `internal/adapters/scriptorium/runner_test.go`
- `internal/app/app_test.go`
- `internal/cli/root_test.go`
## Invariants
2026-05-29 19:54:22 +00:00
- No shell interpolation is used.
- The Scriptorium input name is `data_package`.
- Scriptorium-specific flags stay inside adapter and config boundaries.