Update Task and Execution Structures for Enhanced Traceability

- Revised the Task struct in DESIGN.md to include an Input field for natural language descriptions and a Source field to indicate task origin (auto, human, event).
- Updated the Execution struct in TECHNICAL.md to add an Input field for storing original trigger input, improving traceability of task execution.
- Enhanced documentation for both structs to clarify their roles and improve overall understanding of the agent's task management and execution processes.
This commit is contained in:
Max 2026-01-14 15:56:08 +08:00
parent 0cf0671503
commit 27bb499fbc
2 changed files with 34 additions and 12 deletions

View file

@ -299,8 +299,9 @@ P2 Agent reads Goals markdown and breaks into executable tasks:
```go
type Task struct {
ID string // unique task ID
GoalRef string // reference to goal in markdown (e.g., "Goal 1")
Description string // what to do
Input string // natural language description
GoalRef string // reference to goal (e.g., "Goal 1")
Source TaskSource // auto | human | event
ExecutorType ExecutorType // assistant | mcp | process
ExecutorID string // agent ID or mcp tool name
Args []any // arguments for executor

View file

@ -1181,7 +1181,6 @@ type Execution struct {
MemberID string `json:"member_id"` // robot member ID
TeamID string `json:"team_id"`
TriggerType TriggerType `json:"trigger_type"` // clock | human | event
TriggerData interface{} `json:"trigger_data,omitempty"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Status ExecStatus `json:"status"`
@ -1191,6 +1190,9 @@ type Execution struct {
// Job integration (each Execution = 1 job.Job)
JobID string `json:"job_id"` // corresponding job.Job ID
// Trigger input (stored for traceability)
Input *TriggerInput `json:"input,omitempty"` // original trigger input
// Phase outputs
Inspiration *InspirationReport `json:"inspiration,omitempty"` // P0: markdown
Goals *Goals `json:"goals,omitempty"` // P1: markdown
@ -1206,6 +1208,22 @@ type Execution struct {
robot *Robot `json:"-"`
}
// TriggerInput - stored trigger input for traceability
type TriggerInput struct {
// For human intervention
Action InterventionAction `json:"action,omitempty"` // task.add, goal.adjust, etc.
Description string `json:"description,omitempty"` // user's original input
UserID string `json:"user_id,omitempty"` // who triggered
// For event trigger
Source EventSource `json:"source,omitempty"` // webhook | database
EventType string `json:"event_type,omitempty"` // lead.created, etc.
Data map[string]interface{} `json:"data,omitempty"` // event payload
// For clock trigger
Clock *ClockContext `json:"clock,omitempty"` // time context when triggered
}
// CurrentState - current executing goal and task
type CurrentState struct {
Task *Task `json:"task,omitempty"` // current task being executed
@ -1228,19 +1246,22 @@ type Goals struct {
}
// Task - planned task (structured, for execution)
// P2 Agent parses Goals markdown and generates these
type Task struct {
ID string `json:"id"`
GoalRef string `json:"goal_ref"` // reference to goal in markdown (e.g., "Goal 1")
Description string `json:"description"`
ID string `json:"id"`
Input string `json:"input"` // natural language description
GoalRef string `json:"goal_ref,omitempty"`// reference to goal (e.g., "Goal 1")
Source TaskSource `json:"source"` // auto | human | event
// Executor
ExecutorType ExecutorType `json:"executor_type"`
ExecutorID string `json:"executor_id"`
Args []any `json:"args,omitempty"`
Status TaskStatus `json:"status"`
Order int `json:"order"` // execution order (0-based, lower = first)
Source TaskSource `json:"source"` // how task was created
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
// Runtime
Status TaskStatus `json:"status"`
Order int `json:"order"` // execution order (0-based)
StartTime *time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
}
// TaskSource - how task was created