# internal/core/gate

Package gate defines deterministic failure payloads for lifecycle gates.

## New

```go
func New(cause error, failure Failure) Error
```

New returns an error that can be matched with errors.Is/As and rendered by automation-facing adapters.

## Error

```go
type Error struct {
	Cause   error
	Failure Failure
}
```

Error wraps a cause with a deterministic gate failure payload.

- `Cause: error`: 
- `Failure: Failure`: 

## Error

```go
func (e Error) Error() string
```

Error returns the human-readable cause plus gate reason.

## Unwrap

```go
func (e Error) Unwrap() error
```

Unwrap exposes the underlying cause for errors.Is.

## Failure

```go
type Failure struct {
	Gate         string        `json:"gate"`
	Status       string        `json:"status,omitempty"`
	Reason       string        `json:"reason"`
	Evidence     []string      `json:"evidence,omitempty"`
	Expected     string        `json:"expected,omitempty"`
	Actual       string        `json:"actual,omitempty"`
	Blockers     []string      `json:"blockers,omitempty"`
	Next         string        `json:"next,omitempty"`
	RepairAction *RepairAction `json:"repair_action,omitempty"`
}
```

Failure is the machine-readable repair contract for a blocked gate.

- `Gate: string` (json:"gate"): 
- `Status: string` (json:"status,omitempty"): 
- `Reason: string` (json:"reason"): 
- `Evidence: []string` (json:"evidence,omitempty"): 
- `Expected: string` (json:"expected,omitempty"): 
- `Actual: string` (json:"actual,omitempty"): 
- `Blockers: []string` (json:"blockers,omitempty"): 
- `Next: string` (json:"next,omitempty"): 
- `RepairAction: *RepairAction` (json:"repair_action,omitempty"): 

## RepairAction

```go
type RepairAction struct {
	ArtifactPath     string `json:"artifact_path,omitempty"`
	RequiredEdit     string `json:"required_edit,omitempty"`
	CommandAfterEdit string `json:"command_after_edit,omitempty"`
	Fallback         string `json:"fallback,omitempty"`
}
```

RepairAction is the machine-readable operator action for salvaging a provider packet that scafld rejected for transport or schema shape.

- `ArtifactPath: string` (json:"artifact_path,omitempty"): 
- `RequiredEdit: string` (json:"required_edit,omitempty"): 
- `CommandAfterEdit: string` (json:"command_after_edit,omitempty"): 
- `Fallback: string` (json:"fallback,omitempty"):
