task_detail.go 1.4 KB

12345678910111213141516171819202122232425262728
  1. package model
  2. import "time"
  3. // TaskDetail stores a single operation within a task execution.
  4. // Every search query, URL crawl, snippet extraction, and merchant callback is recorded,
  5. // making the entire task fully reproducible and debuggable.
  6. //
  7. // Key fields for traceability:
  8. // - Depth: 0 = serper result, 1 = crawled from serper link, 2 = sub-page from depth-1, etc.
  9. // - ParentURL: which page led to this operation (trace the discovery chain)
  10. // - Input: raw content received (snippet text, page HTML summary, message text)
  11. // - Output: what was extracted/decided (usernames, classification, cleaned data)
  12. type TaskDetail struct {
  13. ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
  14. TaskID uint `gorm:"index;not null" json:"task_id"`
  15. Seq int `gorm:"not null" json:"seq"`
  16. Action string `gorm:"size:50;not null;index" json:"action"`
  17. URL string `gorm:"size:2048" json:"url"`
  18. ParentURL string `gorm:"size:2048" json:"parent_url"`
  19. Depth int `gorm:"default:0" json:"depth"`
  20. Input string `gorm:"type:mediumtext" json:"input"`
  21. Output string `gorm:"type:mediumtext" json:"output"`
  22. Status string `gorm:"size:20;not null;default:'ok'" json:"status"`
  23. Duration int `gorm:"default:0" json:"duration_ms"`
  24. Extra string `gorm:"type:text" json:"extra"`
  25. CreatedAt time.Time `json:"created_at"`
  26. }