Files
orca/internal/model/job.go
T
Jon Chery f9a9873341 feat(P03): task execution engine with HCL specs, jobs, tasks, WaitDelay
Implements Phase 3 of v0.1 Foundation:
- internal/model/job.go: Job + Task models with status state machines
- internal/store/migrations/0002_jobs_tasks.sql: jobs + tasks tables with FK
- internal/store/job_task_repo.go: JobRepo + TaskRepo with CRUD and lifecycle updates
- internal/jobspec/spec.go: HCL parser using hashicorp/hcl/v2 hclsimple
- internal/jobspec/spec_test.go: 4 tests for parser
- internal/engine/executor.go: parallel task executor using os/exec with Go 1.25
  WaitDelay for clean process shutdown
- internal/cli/job.go: orca job {run,list,stop,logs} wired to executor
- testdata/hello.hcl, testdata/fail.hcl: smoke test fixtures

Verified: job run executes commands, captures stdout/stderr, persists state,
job stop transitions status, job logs displays captured output. All tests
pass with -race.

---ci---
project: orca
phase: 3
milestone: v0.1
status: execute
req_covered:
  - REQ-004
  - REQ-006
  - REQ-009
  - REQ-018
  - REQ-020
  - REQ-021
---/ci---
2026-06-03 12:45:20 +00:00

51 lines
1.4 KiB
Go

package model
import "time"
type JobStatus string
const (
JobStatusPending JobStatus = "pending"
JobStatusRunning JobStatus = "running"
JobStatusComplete JobStatus = "complete"
JobStatusFailed JobStatus = "failed"
JobStatusStopped JobStatus = "stopped"
)
type Job struct {
ID string `json:"id"`
Name string `json:"name"`
Spec string `json:"spec"`
Status JobStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
ExitCode int `json:"exit_code"`
}
type TaskStatus string
const (
TaskStatusPending TaskStatus = "pending"
TaskStatusRunning TaskStatus = "running"
TaskStatusComplete TaskStatus = "complete"
TaskStatusFailed TaskStatus = "failed"
TaskStatusKilled TaskStatus = "killed"
)
type Task struct {
ID string `json:"id"`
JobID string `json:"job_id"`
Command string `json:"command"`
Args []string `json:"args"`
Env []string `json:"env,omitempty"`
PID int `json:"pid"`
ExitCode int `json:"exit_code"`
Status TaskStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
}