Add Daily recent changes comparison

This commit is contained in:
2026-05-29 17:53:03 +00:00
parent b17a3591e0
commit 53a4abd508
12 changed files with 602 additions and 12 deletions

66
docs/internal/changes.md Normal file
View File

@@ -0,0 +1,66 @@
# Changes Internals
This document describes the implemented structured change comparison boundary.
## Purpose
`internal/changes` compares current and prior structured briefing snapshots and
produces compact change records for prompt input data packages.
## Inputs and Outputs
Inputs:
- prior Daily briefing package
- current Daily briefing package
- configured Recent Changes thresholds
Output:
- ordered `changes.Change` records with type, message, previous value, and
current value where useful
## Boundaries
- This package compares structured briefing data only.
- It does not read state directly, render Markdown, invoke `scriptorium`, or
compare generated report text.
## Config Fields Used
The app maps these config fields into comparison thresholds:
- `recent_change.temperature_degrees`
- `recent_change.precip_probability_points`
- `recent_change.wind_gust_miles_per_hour`
- `recent_change.precip_timing_shift_minutes`
## Behavior
Daily comparison currently detects:
- temperature changes crossing configured thresholds
- precipitation probability and timing changes
- alert additions and removals
- peak wind gust changes
- snow, ice, and thunder risk changes
When no prior comparable snapshot exists, the app sends an empty Recent Changes
section in the data package.
## Failure Behavior
Daily comparison requires both inputs to contain Daily briefing content.
## Tests
Inspect:
- `internal/changes/daily_test.go`
- `internal/app/app_test.go`
## Invariants
- Recent Changes are based on structured snapshots, not Markdown report text.
- Comparison thresholds come from configuration.
- The comparison output remains compact enough for prompt input.

View File

@@ -16,7 +16,7 @@ Input:
Output:
- `promptinput.Package` JSON with report metadata, briefing content, source
warnings, RunID, and an empty Recent Changes section.
warnings, RunID, and a Recent Changes section.
## Boundaries
@@ -30,8 +30,8 @@ Output:
- `promptinput.Validate` rejects missing or inconsistent required fields before
render preflight.
- `promptinput.Save` writes JSON atomically where practical.
- Recent Changes is present as an empty `items` list until structured comparison
is implemented.
- Recent Changes is present as an `items` list. It is empty when no prior
comparable snapshot exists or no meaningful changes are detected.
## Failure Behavior
@@ -43,6 +43,7 @@ the filesystem operation and path context.
Inspect:
- `internal/promptinput/package_test.go`
- `internal/changes/daily_test.go`
- `internal/app/app_test.go`
## Invariants

View File

@@ -26,6 +26,7 @@ Outputs:
- Markdown report path
- metadata JSON
- prior Daily snapshot metadata when available
- prior Daily briefing package when loaded by path
## Boundaries
@@ -49,7 +50,8 @@ Workspace subdirectories must be relative paths that stay under
Managed artifact names use RunID, which is generated from report generation time
and report ID. Daily metadata is stored beside Daily briefing snapshots by valid
local date. Prior Daily snapshot lookup reads metadata for the same valid local
date and returns the latest earlier run. The store prepares the managed Markdown
date and returns the latest earlier run. The store can load a briefing snapshot
by path for structured comparison. The store prepares the managed Markdown
report path before `scriptorium run` writes it.
## Failure Behavior