Files
weatherreporter/docs/internal/app-orchestration.md

2.2 KiB

Application Orchestration Internals

internal/app owns stateless report generation, batch execution, atomic output publication, and notification coordination after internal/cli has parsed arguments and loaded configuration. The user contract is owned by the CLI reference and operations guide.

Single-Report Flow

GenerateDetailed resolves the requested report and output destination, then initializes an optional explicit debug writer. It validates the exact Promptkit prompt and selected profile before collecting weather data. The resolved profile, backend, and model are carried in the active result.

The workflow builds facts, a module snapshot, briefing metadata, and the YAML prompt package in memory. It executes Promptkit, validates the returned generated text, builds a render context, and renders Markdown. fileutil atomically writes the completed Markdown to the selected output path. Only after that write succeeds does single-report notification run.

Failures return an active partial result with safe identity, profile, warning, validation, debug, and output information when available. A failure before publication leaves an existing destination unchanged. A notification failure retains the newly published output.

Batches

RunBatchDetailed captures one output directory, creates at most one explicit debug writer, and uses one executor. Before collection it validates the prompt and profile candidates for the selected batch. It collects once, calculates the data-dependent plan, and invokes the same generation core sequentially for each planned report.

Each item has an independent result. A failed item does not stop later items; successful items retain their published output paths. Per-report notification is suppressed during a batch. Batch notification runs only after every planned report has published successfully. It is skipped when any item failed.

Boundaries And Verification

The package does not parse flags, load YAML, implement transport, construct provider SDKs, or define report-period policy. Prompt, profile, weather, and Distributor implementations remain behind project-owned contracts.

Focused checks:

go test ./internal/app ./internal/collect