Files
weatherreporter/docs/internal/prompt-input.md

70 lines
2.0 KiB
Markdown
Raw Normal View History

2026-05-29 17:32:57 +00:00
# Prompt Input Internals
2026-05-29 19:54:22 +00:00
This document describes prompt input data package construction.
2026-05-29 17:32:57 +00:00
## Purpose
2026-05-29 19:54:22 +00:00
`internal/promptinput` converts a structured briefing package and optional
Recent Changes into the `data_package` JSON passed to Scriptorium prompts.
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
2026-05-29 19:54:22 +00:00
- `briefing.Package`
- optional `[]changes.Change`
2026-05-29 17:32:57 +00:00
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
- `promptinput.Package` containing schema version, RunID, report metadata,
briefing content, Recent Changes, and source warnings. Briefing content
includes configured location context, current conditions when available,
discussion key messages, and short/long-term AFD narratives when the Weather
API provides them.
- report metadata includes `currentLocalDate`, the generation date formatted as
`YYYY-MM-DD` in the effective report timezone.
2026-05-29 19:54:22 +00:00
- optional JSON file written by `promptinput.Save`
2026-05-29 17:32:57 +00:00
## Boundaries
2026-05-29 19:54:22 +00:00
- This package owns the prompt input schema and validation.
- It does not fetch weather data, derive forecast summaries, find prior
snapshots, compare changes, or invoke Scriptorium.
2026-05-29 17:32:57 +00:00
2026-05-29 19:54:22 +00:00
## Config Fields Used
2026-05-29 17:32:57 +00:00
None directly. Config-derived values, including timezone and prompt location
context, are already present in briefing metadata before this package runs.
2026-05-29 19:54:22 +00:00
## External Adapters Used
None.
## State Or Manifest Behavior
`promptinput.Save` writes JSON atomically. Managed workspace paths are owned by
`internal/state`.
## Skip And Resume Behavior
None. Recent Changes is always present as an `items` list and may be empty.
2026-05-29 17:32:57 +00:00
## Failure Behavior
2026-05-29 19:54:22 +00:00
Validation fails before render preflight when required top-level or briefing
metadata fields are missing or inconsistent, or when no report content is
present. Save failures include filesystem operation and path context.
2026-05-29 17:32:57 +00:00
## Tests
Inspect:
- `internal/promptinput/package_test.go`
- `internal/app/app_test.go`
## Invariants
2026-05-29 19:54:22 +00:00
- Scriptorium receives structured `data_package` JSON.
2026-05-29 17:32:57 +00:00
- Briefing metadata and top-level report metadata must agree.
2026-05-29 19:54:22 +00:00
- Recent Changes are not inferred from rendered report text.