Remove recent changes from prompt execution

This commit is contained in:
2026-08-01 19:22:11 +00:00
parent 8be9b020d4
commit 5ddd3ee19c
19 changed files with 35 additions and 177 deletions

View File

@@ -7,7 +7,6 @@ import (
"fmt"
"time"
"gitea.maximumdirect.net/eric/weatherreporter/internal/changes"
"gitea.maximumdirect.net/eric/weatherreporter/internal/fileutil"
"gitea.maximumdirect.net/eric/weatherreporter/internal/module"
"gitea.maximumdirect.net/eric/weatherreporter/internal/report"
@@ -16,7 +15,7 @@ import (
"gopkg.in/yaml.v3"
)
const SchemaVersion = "weatherreporter.data_package.v3"
const SchemaVersion = "weatherreporter.data_package.v4"
const (
metadataStanza = "metadata"
@@ -52,9 +51,8 @@ var briefingStanzaCategories = map[string]string{
}
type BuildRequest struct {
Metadata Metadata
Modules module.Snapshot
RecentChanges []changes.Change
Metadata Metadata
Modules module.Snapshot
}
type Metadata struct {
@@ -73,7 +71,6 @@ type Package struct {
RunID string `json:"runId" yaml:"run_id"`
Report Report `json:"report" yaml:"report"`
Briefing BriefingStanzas `json:"briefing" yaml:"briefing"`
RecentChanges RecentChanges `json:"recentChanges" yaml:"recent_changes"`
SourceWarnings []weatherdata.SourceWarning `json:"sourceWarnings,omitempty" yaml:"source_warnings,omitempty"`
}
@@ -92,20 +89,11 @@ type BriefingStanzas struct {
Values map[string]any `json:"-" yaml:"-"`
}
type RecentChanges struct {
Items []changes.Change `json:"items" yaml:"items"`
}
func Build(req BuildRequest) (Package, error) {
localDate, err := currentLocalDate(req.Metadata.GeneratedAt, req.Metadata.Timezone)
if err != nil {
return Package{}, err
}
items := make([]changes.Change, len(req.RecentChanges))
copy(items, req.RecentChanges)
if items == nil {
items = []changes.Change{}
}
pkg := Package{
SchemaVersion: SchemaVersion,
RunID: req.Metadata.RunID,
@@ -119,7 +107,6 @@ func Build(req BuildRequest) (Package, error) {
ValidPeriod: req.Metadata.ValidPeriod,
},
Briefing: stanzasFromSnapshot(req.Modules),
RecentChanges: RecentChanges{Items: items},
SourceWarnings: append([]weatherdata.SourceWarning(nil), req.Metadata.SourceWarnings...),
}
if err := Validate(pkg); err != nil {

View File

@@ -34,9 +34,6 @@ func TestBuildDailyDataPackage(t *testing.T) {
if got := pkg.Briefing.Values["current_conditions"].(map[string]string)["condition_text"]; got != "Partly cloudy" {
t.Fatalf("current_conditions.condition_text = %q, want Partly cloudy", got)
}
if pkg.RecentChanges.Items == nil || len(pkg.RecentChanges.Items) != 0 {
t.Fatalf("RecentChanges.Items = %#v, want empty slice", pkg.RecentChanges.Items)
}
}
func TestBuildCurrentLocalDateUsesReportTimezone(t *testing.T) {
@@ -181,7 +178,7 @@ func TestMarshalYAMLIsDeterministicAndGroupsNamedStanzas(t *testing.T) {
if string(first) != string(second) {
t.Fatalf("YAML output changed between marshals:\n%s\n---\n%s", string(first), string(second))
}
if !strings.Contains(string(first), "schema_version: weatherreporter.data_package.v3") ||
if !strings.Contains(string(first), "schema_version: weatherreporter.data_package.v4") ||
!strings.Contains(string(first), "briefing:\n") ||
!strings.Contains(string(first), " applicable_risk_products:\n") ||
!strings.Contains(string(first), " derived_summaries:\n") ||
@@ -191,6 +188,9 @@ func TestMarshalYAMLIsDeterministicAndGroupsNamedStanzas(t *testing.T) {
!strings.Contains(string(first), " condition_text: Partly cloudy") {
t.Fatalf("YAML output missing expected grouped stanzas:\n%s", string(first))
}
if strings.Contains(string(first), "recent_changes") {
t.Fatalf("YAML output contains removed recent_changes stanza:\n%s", string(first))
}
for _, pair := range []struct {
before string
after string
@@ -289,7 +289,7 @@ func TestMarshalYAMLRejectsUncategorizedStanza(t *testing.T) {
func TestLoadYAMLRejectsMisplacedStanza(t *testing.T) {
data := []byte(`
schema_version: weatherreporter.data_package.v3
schema_version: weatherreporter.data_package.v4
run_id: 20260529T100000Z_daily
report:
id: daily
@@ -306,8 +306,6 @@ briefing:
raw_data:
alert_digest:
checked: true
recent_changes:
items: []
`)
_, err := LoadYAML(data)
@@ -325,10 +323,10 @@ func TestLoadYAMLRejectsOldSchemaVersion(t *testing.T) {
if err != nil {
t.Fatalf("MarshalYAML() error = %v", err)
}
data = []byte(strings.Replace(string(data), "weatherreporter.data_package.v3", "weatherreporter.data_package.v2", 1))
data = []byte(strings.Replace(string(data), "weatherreporter.data_package.v4", "weatherreporter.data_package.v3", 1))
_, err = LoadYAML(data)
if err == nil || !strings.Contains(err.Error(), "schemaVersion must be weatherreporter.data_package.v3") {
if err == nil || !strings.Contains(err.Error(), "schemaVersion must be weatherreporter.data_package.v4") {
t.Fatalf("LoadYAML() error = %v, want current schema version error", err)
}
}