MCPcopy Create free account
hub / github.com/compozy/agh / readExtractorFailure

Function readExtractorFailure

internal/daemon/memory_runtime.go:416–447  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

414}
415
416func 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
449func (f extractorFailure) Candidates() ([]memcontract.Candidate, error) {
450 scanner := bufio.NewScanner(strings.NewReader(f.Report.Content))

Callers 1

loadFailuresMethod · 0.85

Calls 6

parseMemoryTimeFunction · 0.85
failureCandidateMetadataFunction · 0.85
firstNonEmptyStringFunction · 0.70
ReadFileMethod · 0.65
IsZeroMethod · 0.45
NowMethod · 0.45

Tested by

no test coverage detected