| 1 | package autoresearch |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | const ( |
| 6 | StatusRunning = "running" |
| 7 | StatusBlocked = "blocked" |
| 8 | StatusComplete = "complete" |
| 9 | StatusStopped = "stopped" |
| 10 | StatusInvalid = "invalid" |
| 11 | ) |
| 12 | |
| 13 | type Task struct { |
| 14 | ID string |
| 15 | Root string |
| 16 | Spec TaskSpec |
| 17 | // CreateToken is an opaque ownership proof for the directory reserved by |
| 18 | // CreateTask. Rollback helpers must pass it to RemoveTask so a failed |
| 19 | // transaction cannot delete a task directory another creator reserved. |
| 20 | CreateToken string |
| 21 | } |
| 22 | |
| 23 | type CreateOptions struct { |
| 24 | Now func() time.Time |
| 25 | // CreateToken optionally supplies the ownership proof written during task |
| 26 | // reservation. Durable parent transactions persist it before calling |
| 27 | // CreateTask so crash recovery can find and remove an uncommitted task. |
| 28 | CreateToken string |
| 29 | Scope []string |
| 30 | NonGoals []string |
| 31 | AllowedOperations AllowedOperations |
| 32 | SuccessCriteria []SuccessCriterion |
| 33 | } |
| 34 | |
| 35 | type AllowedOperations struct { |
| 36 | Write bool `json:"write"` |
| 37 | Network bool `json:"network"` |
| 38 | Publish bool `json:"publish"` |
| 39 | } |
| 40 | |
| 41 | type SuccessCriterion struct { |
| 42 | ID string `json:"id"` |
| 43 | Description string `json:"description"` |
| 44 | Required bool `json:"required"` |
| 45 | EvidenceIDs []string `json:"evidence_ids"` |
| 46 | } |
| 47 | |
| 48 | type TaskSpec struct { |
| 49 | TaskID string `json:"task_id"` |
| 50 | Goal string `json:"goal"` |
| 51 | Scope []string `json:"scope"` |
| 52 | NonGoals []string `json:"non_goals"` |
| 53 | AllowedOperations AllowedOperations `json:"allowed_operations"` |
| 54 | SuccessCriteria []SuccessCriterion `json:"success_criteria"` |
| 55 | } |
| 56 | |
| 57 | type Progress struct { |
| 58 | Status string `json:"status"` |
| 59 | Iteration int `json:"iteration"` |
| 60 | CurrentDirection string `json:"current_direction"` |
| 61 | StaleCount int `json:"stale_count"` |
| 62 | PivotCount int `json:"pivot_count"` |
| 63 | BlockedReason string `json:"blocked_reason"` |
| 64 | UpdatedAt time.Time `json:"updated_at"` |
| 65 | } |
| 66 | |
| 67 | const ( |
| 68 | FindingKindCommand = "command" |
| 69 | FindingKindFile = "file" |
| 70 | FindingKindTest = "test" |
| 71 | FindingKindBenchmark = "benchmark" |
| 72 | FindingKindManual = "manual" |
| 73 | FindingKindReview = "review" |
| 74 | ) |
| 75 | |
| 76 | const ( |
| 77 | FindingSourceCommand = "command" |
| 78 | FindingSourceFile = "file" |
| 79 | FindingSourceManual = "manual" |
| 80 | ) |
| 81 | |
| 82 | type Finding struct { |
| 83 | ID string `json:"id"` |
| 84 | Kind string `json:"kind"` |
| 85 | Summary string `json:"summary"` |
| 86 | Source string `json:"source"` |
| 87 | Command string `json:"command,omitempty"` |
| 88 | Paths []string `json:"paths,omitempty"` |
| 89 | Accepted bool `json:"accepted"` |
| 90 | CreatedAt time.Time `json:"created_at"` |
| 91 | } |
| 92 | |
| 93 | const ( |
| 94 | HeartbeatStartingTurn = "starting_turn" |
| 95 | HeartbeatTurnDone = "turn_done" |
| 96 | HeartbeatWarning = "warning" |
| 97 | ) |
| 98 | |
| 99 | type Heartbeat struct { |
| 100 | Status string `json:"status"` |
| 101 | Iteration int `json:"iteration"` |
| 102 | Message string `json:"message,omitempty"` |
| 103 | CreatedAt time.Time `json:"created_at"` |
| 104 | } |
| 105 | |
| 106 | type Direction struct { |
| 107 | Summary string |
| 108 | AcceptedEvidenceIDs []string |
| 109 | Now time.Time |
| 110 | } |
| 111 | |
| 112 | type DirectionTried struct { |
| 113 | Fingerprint string `json:"fingerprint"` |
| 114 | Summary string `json:"summary"` |
| 115 | FirstSeenIteration int `json:"first_seen_iteration"` |
| 116 | LastSeenIteration int `json:"last_seen_iteration"` |
| 117 | Count int `json:"count"` |
| 118 | } |
| 119 | |
| 120 | type ProgressPatch struct { |
| 121 | Status *string |
| 122 | CurrentDirection *string |
| 123 | BlockedReason *string |
| 124 | } |
| 125 | |
| 126 | type CriterionSummary struct { |
| 127 | ID string `json:"id"` |
| 128 | Description string `json:"description"` |
| 129 | Required bool `json:"required"` |
| 130 | EvidenceCount int `json:"evidence_count"` |
| 131 | Status string `json:"status"` |
| 132 | } |
| 133 | |
| 134 | type Summary struct { |
| 135 | TaskID string `json:"task_id"` |
| 136 | Goal string `json:"goal"` |
| 137 | Status string `json:"status"` |
| 138 | Iteration int `json:"iteration"` |
| 139 | CurrentDirection string `json:"current_direction"` |
| 140 | StaleCount int `json:"stale_count"` |
| 141 | PivotCount int `json:"pivot_count"` |
| 142 | PivotRequired bool `json:"pivot_required"` |
| 143 | LastHeartbeatAt time.Time `json:"last_heartbeat_at,omitempty"` |
| 144 | FindingCount int `json:"finding_count"` |
| 145 | OpenCriteria []CriterionSummary `json:"open_criteria"` |
| 146 | Blocker string `json:"blocker"` |
| 147 | TaskPath string `json:"task_path"` |
| 148 | NextRequiredAction string `json:"next_required_action"` |
| 149 | } |
| 150 | |
| 151 | type ReadinessReport struct { |
| 152 | Ready bool `json:"ready"` |
| 153 | MissingCriteria []string `json:"missing_criteria"` |
| 154 | BlockedReason string `json:"blocked_reason"` |
| 155 | Errors []string `json:"errors"` |
| 156 | } |
| 157 | |
| 158 | type ValidationError struct { |
| 159 | File string `json:"file"` |
| 160 | Field string `json:"field"` |
| 161 | Error string `json:"error"` |
| 162 | } |
| 163 | |
| 164 | type ValidationReport struct { |
| 165 | Valid bool `json:"valid"` |
| 166 | Errors []ValidationError `json:"errors"` |
| 167 | } |
| 168 |