Remove historical inspection commands
This commit is contained in:
@@ -13,13 +13,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MetadataSchemaVersionV1 = "weatherreporter.metadata.v1"
|
||||
MetadataSchemaVersion = "weatherreporter.metadata.v2"
|
||||
MetadataSchemaVersion = "weatherreporter.metadata.v2"
|
||||
)
|
||||
|
||||
// Metadata is the durable record used for report discovery and inspection.
|
||||
// V1 fields remain internal compatibility values and are emitted only for V1
|
||||
// records; V2 records have no legacy aliases in their JSON representation.
|
||||
// Metadata is the durable record used by the transitional state package.
|
||||
type Metadata struct {
|
||||
SchemaVersion string `json:"schemaVersion"`
|
||||
RunID string `json:"runId"`
|
||||
@@ -45,39 +42,32 @@ type Metadata struct {
|
||||
GeneratedTextRawPath string `json:"generatedTextRawPath,omitempty"`
|
||||
GeneratedTextPath string `json:"generatedTextPath,omitempty"`
|
||||
RenderContextPath string `json:"renderContextPath,omitempty"`
|
||||
|
||||
// These paths are retained only to read legacy V1 records. They are never
|
||||
// emitted in V2 metadata.
|
||||
PreflightPath string `json:"-"`
|
||||
GeneratedTextResultPath string `json:"-"`
|
||||
}
|
||||
|
||||
type metadataJSON struct {
|
||||
SchemaVersion string `json:"schemaVersion"`
|
||||
RunID string `json:"runId"`
|
||||
ReportID report.ID `json:"reportId"`
|
||||
Variant string `json:"variant,omitempty"`
|
||||
PromptID string `json:"promptId"`
|
||||
GeneratedAt time.Time `json:"generatedAt"`
|
||||
Timezone string `json:"timezone"`
|
||||
ValidPeriod timeutil.Period `json:"validPeriod"`
|
||||
Location *briefing.LocationContext `json:"location,omitempty"`
|
||||
SourceLocationID string `json:"sourceLocationId,omitempty"`
|
||||
SourceLocation string `json:"sourceLocation,omitempty"`
|
||||
Sources []briefing.SourceMetadata `json:"sources,omitempty"`
|
||||
SourceWarnings []weatherdata.SourceWarning `json:"sourceWarnings,omitempty"`
|
||||
ModuleSnapshotPath string `json:"moduleSnapshotPath"`
|
||||
DataPackagePath string `json:"dataPackagePath"`
|
||||
PreparationPath string `json:"preparationPath,omitempty"`
|
||||
ExecutionPath string `json:"executionPath,omitempty"`
|
||||
PreflightPath string `json:"preflightPath,omitempty"`
|
||||
NotificationPath string `json:"notificationPath,omitempty"`
|
||||
RenderedReportPath string `json:"renderedReportPath,omitempty"`
|
||||
GeneratedTextSchemaID string `json:"generatedTextSchemaId,omitempty"`
|
||||
GeneratedTextRawPath string `json:"generatedTextRawPath,omitempty"`
|
||||
GeneratedTextResultPath string `json:"generatedTextResultPath,omitempty"`
|
||||
GeneratedTextPath string `json:"generatedTextPath,omitempty"`
|
||||
RenderContextPath string `json:"renderContextPath,omitempty"`
|
||||
SchemaVersion string `json:"schemaVersion"`
|
||||
RunID string `json:"runId"`
|
||||
ReportID report.ID `json:"reportId"`
|
||||
Variant string `json:"variant,omitempty"`
|
||||
PromptID string `json:"promptId"`
|
||||
GeneratedAt time.Time `json:"generatedAt"`
|
||||
Timezone string `json:"timezone"`
|
||||
ValidPeriod timeutil.Period `json:"validPeriod"`
|
||||
Location *briefing.LocationContext `json:"location,omitempty"`
|
||||
SourceLocationID string `json:"sourceLocationId,omitempty"`
|
||||
SourceLocation string `json:"sourceLocation,omitempty"`
|
||||
Sources []briefing.SourceMetadata `json:"sources,omitempty"`
|
||||
SourceWarnings []weatherdata.SourceWarning `json:"sourceWarnings,omitempty"`
|
||||
ModuleSnapshotPath string `json:"moduleSnapshotPath"`
|
||||
DataPackagePath string `json:"dataPackagePath"`
|
||||
PreparationPath string `json:"preparationPath,omitempty"`
|
||||
ExecutionPath string `json:"executionPath,omitempty"`
|
||||
NotificationPath string `json:"notificationPath,omitempty"`
|
||||
RenderedReportPath string `json:"renderedReportPath,omitempty"`
|
||||
GeneratedTextSchemaID string `json:"generatedTextSchemaId,omitempty"`
|
||||
GeneratedTextRawPath string `json:"generatedTextRawPath,omitempty"`
|
||||
GeneratedTextPath string `json:"generatedTextPath,omitempty"`
|
||||
RenderContextPath string `json:"renderContextPath,omitempty"`
|
||||
}
|
||||
|
||||
func (m Metadata) MarshalJSON() ([]byte, error) {
|
||||
@@ -92,53 +82,24 @@ func (m Metadata) MarshalJSON() ([]byte, error) {
|
||||
GeneratedTextSchemaID: m.GeneratedTextSchemaID, GeneratedTextRawPath: m.GeneratedTextRawPath,
|
||||
GeneratedTextPath: m.GeneratedTextPath, RenderContextPath: m.RenderContextPath,
|
||||
}
|
||||
switch m.SchemaVersion {
|
||||
case MetadataSchemaVersionV1:
|
||||
w.PreflightPath = m.PreflightPath
|
||||
w.GeneratedTextResultPath = m.GeneratedTextResultPath
|
||||
case MetadataSchemaVersion:
|
||||
w.PreparationPath = m.PreparationPath
|
||||
w.ExecutionPath = m.ExecutionPath
|
||||
default:
|
||||
if m.SchemaVersion != MetadataSchemaVersion {
|
||||
return nil, fmt.Errorf("unsupported metadata schema version %q", m.SchemaVersion)
|
||||
}
|
||||
w.PreparationPath = m.PreparationPath
|
||||
w.ExecutionPath = m.ExecutionPath
|
||||
return json.Marshal(w)
|
||||
}
|
||||
|
||||
func (m *Metadata) UnmarshalJSON(data []byte) error {
|
||||
var header struct {
|
||||
SchemaVersion string `json:"schemaVersion"`
|
||||
}
|
||||
if err := json.Unmarshal(data, &header); err != nil {
|
||||
type metadataWire Metadata
|
||||
var decoded metadataWire
|
||||
if err := json.Unmarshal(data, &decoded); err != nil {
|
||||
return err
|
||||
}
|
||||
if header.SchemaVersion != MetadataSchemaVersionV1 && header.SchemaVersion != MetadataSchemaVersion {
|
||||
return fmt.Errorf("unsupported metadata schema version %q", header.SchemaVersion)
|
||||
}
|
||||
var w metadataJSON
|
||||
if err := json.Unmarshal(data, &w); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = Metadata{
|
||||
SchemaVersion: w.SchemaVersion, RunID: w.RunID, ReportID: w.ReportID,
|
||||
Variant: w.Variant, PromptID: w.PromptID, GeneratedAt: w.GeneratedAt,
|
||||
Timezone: w.Timezone, ValidPeriod: w.ValidPeriod, Location: w.Location,
|
||||
SourceLocationID: w.SourceLocationID, SourceLocation: w.SourceLocation,
|
||||
Sources: w.Sources, SourceWarnings: w.SourceWarnings,
|
||||
ModuleSnapshotPath: w.ModuleSnapshotPath, DataPackagePath: w.DataPackagePath,
|
||||
NotificationPath: w.NotificationPath, RenderedReportPath: w.RenderedReportPath,
|
||||
GeneratedTextSchemaID: w.GeneratedTextSchemaID, GeneratedTextRawPath: w.GeneratedTextRawPath,
|
||||
GeneratedTextPath: w.GeneratedTextPath, RenderContextPath: w.RenderContextPath,
|
||||
}
|
||||
if w.SchemaVersion == MetadataSchemaVersionV1 {
|
||||
m.PreflightPath = w.PreflightPath
|
||||
m.GeneratedTextResultPath = w.GeneratedTextResultPath
|
||||
m.PreparationPath = w.PreflightPath
|
||||
m.ExecutionPath = w.GeneratedTextResultPath
|
||||
} else {
|
||||
m.PreparationPath = w.PreparationPath
|
||||
m.ExecutionPath = w.ExecutionPath
|
||||
if decoded.SchemaVersion != MetadataSchemaVersion {
|
||||
return fmt.Errorf("unsupported metadata schema version %q", decoded.SchemaVersion)
|
||||
}
|
||||
*m = Metadata(decoded)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -155,18 +116,12 @@ func (m Metadata) Validate() error {
|
||||
if strings.TrimSpace(m.MetadataPath) == "" {
|
||||
return fmt.Errorf("metadata path is required")
|
||||
}
|
||||
switch m.SchemaVersion {
|
||||
case MetadataSchemaVersionV1:
|
||||
if strings.TrimSpace(m.PreflightPath) == "" {
|
||||
return fmt.Errorf("metadata preflight path is required")
|
||||
}
|
||||
case MetadataSchemaVersion:
|
||||
if strings.TrimSpace(m.PreparationPath) == "" {
|
||||
return fmt.Errorf("metadata preparation path is required")
|
||||
}
|
||||
default:
|
||||
if m.SchemaVersion != MetadataSchemaVersion {
|
||||
return fmt.Errorf("unsupported metadata schema version %q", m.SchemaVersion)
|
||||
}
|
||||
if strings.TrimSpace(m.PreparationPath) == "" {
|
||||
return fmt.Errorf("metadata preparation path is required")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user