close worktree transport and lifecycle contract gaps
This commit is contained in:
@@ -119,13 +119,21 @@ func ValidatePayload(typ string, p map[string]any) error {
|
||||
if err := requiredString("harness_id"); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := p["until_ns"].(float64); !ok {
|
||||
return fmt.Errorf("%w: until_ns required", ErrInvalid)
|
||||
until, untilOK := p["until_ns"].(float64)
|
||||
if ttl, ok := p["ttl"].(float64); ok {
|
||||
if ttl <= 0 {
|
||||
return fmt.Errorf("%w: ttl invalid", ErrInvalid)
|
||||
}
|
||||
} else if !untilOK || until <= float64(time.Now().UnixNano()) {
|
||||
return fmt.Errorf("%w: ttl required", ErrInvalid)
|
||||
}
|
||||
if v, ok := p["expected_version"].(float64); ok && v < 0 {
|
||||
if v, ok := p["expected_version"].(float64); !ok || v < 0 || v != float64(int(v)) {
|
||||
return fmt.Errorf("%w: expected_version invalid", ErrInvalid)
|
||||
}
|
||||
case "TaskReleased":
|
||||
if v, ok := p["anchor_sha"].(string); ok && (len(v) != 40 || strings.TrimSpace(v) != v) {
|
||||
return fmt.Errorf("%w: anchor_sha invalid", ErrInvalid)
|
||||
}
|
||||
if err := requiredString("handoff_ref"); err != nil && p["reason"] == nil {
|
||||
return err
|
||||
}
|
||||
@@ -133,6 +141,11 @@ func ValidatePayload(typ string, p map[string]any) error {
|
||||
if err := requiredString("report_ref"); err != nil {
|
||||
return err
|
||||
}
|
||||
if receipt, ok := p["receipt"]; ok {
|
||||
if m, ok := receipt.(map[string]any); !ok || len(m) == 0 {
|
||||
return fmt.Errorf("%w: receipt invalid", ErrInvalid)
|
||||
}
|
||||
}
|
||||
case "TaskFailed":
|
||||
if err := requiredString("reason"); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user