server: read the verdict from where the schema puts it
Every uploaded run showed "not recorded" in the web UI because the meta extractor read summary.verdict. Schema §7.3 calls that field summary.overall; "verdict" is the per-category field one level down. So the verdict was never stored, and the UI faithfully reported a gap that was this parser's doing rather than the document's. The test encoded the same mistake — its fixture posted summary.verdict:"warn" — so it passed throughout against a parser that read a field nothing writes. Corrected to summary.overall, and to a verdict that exists: §7.3 defines green|yellow|red|inconclusive, and "warn" was never one of them. The eleven runs already stored had their meta backfilled from the documents, which are kept byte-for-byte and still carry the real value. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d5b1bab577
commit
987b2ceb47
@@ -158,7 +158,11 @@ func (s *Store) Put(deviceID string, body []byte, linked bool) (Meta, error) {
|
||||
} `json:"run"`
|
||||
Findings []json.RawMessage `json:"findings"`
|
||||
Summary struct {
|
||||
Verdict string `json:"verdict"`
|
||||
// measurement-schema.md §7.3 calls this "overall"; "verdict" is the per-category
|
||||
// field one level down. Reading the wrong one stored an empty verdict on every run
|
||||
// ever uploaded, which the UI showed as "not recorded" — a claim about the document
|
||||
// that was really a bug in this parser.
|
||||
Overall string `json:"overall"`
|
||||
} `json:"summary"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &doc); err != nil || doc.Run.ID == "" {
|
||||
@@ -192,7 +196,7 @@ func (s *Store) Put(deviceID string, body []byte, linked bool) (Meta, error) {
|
||||
meta := Meta{
|
||||
ID: id, DeviceID: deviceID, UploadedAt: time.Now().UTC(),
|
||||
StartedAt: doc.Run.StartedAt, Anonymization: level,
|
||||
SizeBytes: int64(len(body)), Verdict: doc.Summary.Verdict,
|
||||
SizeBytes: int64(len(body)), Verdict: doc.Summary.Overall,
|
||||
FindingCount: len(doc.Findings),
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(devDir, id+".meta.json"), mustJSON(meta), 0o600); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user