(path string)
| 414 | } |
| 415 | |
| 416 | func readExtractorFailure(path string) (extractorFailure, error) { |
| 417 | data, err := os.ReadFile(path) |
| 418 | if err != nil { |
| 419 | return extractorFailure{}, fmt.Errorf("daemon: read extractor failure %q: %w", path, err) |
| 420 | } |
| 421 | var report extractorFailureReport |
| 422 | if err := json.Unmarshal(data, &report); err != nil { |
| 423 | return extractorFailure{}, fmt.Errorf("daemon: decode extractor failure %q: %w", path, err) |
| 424 | } |
| 425 | createdAt := parseMemoryTime(report.RecordedAt) |
| 426 | if createdAt.IsZero() { |
| 427 | if info, statErr := os.Stat(path); statErr == nil { |
| 428 | createdAt = info.ModTime().UTC() |
| 429 | } |
| 430 | } |
| 431 | if createdAt.IsZero() { |
| 432 | createdAt = time.Now().UTC() |
| 433 | } |
| 434 | sessionID, workspaceID, agentName := failureCandidateMetadata(report.Content) |
| 435 | return extractorFailure{ |
| 436 | Payload: contract.MemoryExtractorFailurePayload{ |
| 437 | ID: strings.TrimSuffix(filepath.Base(path), ".json"), |
| 438 | SessionID: sessionID, |
| 439 | WorkspaceID: workspaceID, |
| 440 | AgentName: agentName, |
| 441 | Reason: firstNonEmptyString(report.Error, report.Stage), |
| 442 | Path: path, |
| 443 | CreatedAt: createdAt, |
| 444 | }, |
| 445 | Report: report, |
| 446 | }, nil |
| 447 | } |
| 448 | |
| 449 | func (f extractorFailure) Candidates() ([]memcontract.Candidate, error) { |
| 450 | scanner := bufio.NewScanner(strings.NewReader(f.Report.Content)) |
no test coverage detected