package pool import "time" // Result is posted back to the logic goroutine when a task completes. // Results are immutable and contain all information needed to apply // the task outcome to state. type Result struct { TaskID string `json:"task_id"` TaskType TaskType `json:"task_type"` Success bool `json:"success"` Data any `json:"data,omitempty"` Error error `json:"error,omitempty"` Timestamp time.Time `json:"timestamp"` DirPath string `json:"dir_path,omitempty"` FilePath string `json:"file_path,omitempty"` // Added } // IsSuccess returns true if the task completed successfully. func (r Result) IsSuccess() bool { return r.Success && r.Error == nil } // IsError returns true if the task failed. func (r Result) IsError() bool { return !r.Success || r.Error != nil } // IsBrowserResult returns true if this result is for a browser task. func (r Result) IsBrowserResult() bool { switch r.TaskType { case TypeReadDir, TypeBuildIndex, TypeLoadIndex, TypeLoadPages, TypeStatDir: return true default: return false } } // IsFileResult returns true if this result is for a file operation. func (r Result) IsFileResult() bool { switch r.TaskType { case TypeReadFile, TypeWriteFile, TypeStatFile: return true default: return false } } // IsCacheResult returns true if this result is for a cache operation. func (r Result) IsCacheResult() bool { switch r.TaskType { case TypeWriteCache, TypeReadCache, TypeInvalidate: return true default: return false } } // IsStateResult returns true if this result is for state persistence. func (r Result) IsStateResult() bool { switch r.TaskType { case TypeSaveState, TypeSaveUndo: return true default: return false } } // Duration returns the time taken for this result (for benchmarking). func (r Result) Duration() time.Duration { // In production, this would be set by the worker. // For now, returns zero. return 0 }