Documentation
¶
Overview ¶
Package stack executes the shared upgrade plan with a durable recovery journal.
Index ¶
- func ExecutionPlan() []plan.Step
- func RestartCommand(snapshot string) string
- func RestoreCommand(backupID string) string
- func ResumeStep(j *Journal) string
- func VerifyCommand(backupID string) string
- func WithExitClass(err error) error
- type Backend
- type Journal
- type Options
- type Runtime
- func (r *Runtime) Backup(ctx context.Context, j *Journal) error
- func (r *Runtime) CheckPreviousImages(ctx context.Context, j *Journal) error
- func (r *Runtime) CountRows(ctx context.Context) (map[string]int64, error)
- func (r *Runtime) RestartPrevious(ctx context.Context, j *Journal) error
- func (r *Runtime) Restore(ctx context.Context, j *Journal) error
- func (r *Runtime) Run(ctx context.Context, name string, j *Journal) error
- func (r *Runtime) StopServices(ctx context.Context, j *Journal) error
- func (r *Runtime) VerifyBackup(ctx context.Context, j *Journal) error
- type Step
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecutionPlan ¶
ExecutionPlan adapts the shared plan to stack execution after pins are updated. Inputs: shared DefaultSteps. Outputs: backup, pull, build, start and checks. Constraints: plugin and CLI pin application remain owned by update --yes.
func RestartCommand ¶
RestartCommand restarts the pinned previous images and removes orphans, never volumes. Inputs: snapshot path. Outputs: executable compose command.
func RestoreCommand ¶
RestoreCommand quotes an exact retained backup id for an operator shell command. Inputs: backup id. Outputs: executable restore guidance. Constraints: shell metacharacters in backup identifiers cannot execute commands.
func ResumeStep ¶
ResumeStep reports the operation a real invocation would attempt next. Inputs: validated journal. Outputs: next step name or empty for blocked recovery. Constraints: completed and recovered runs begin a fresh backup on the next run.
func VerifyCommand ¶
VerifyCommand quotes the command that re-checks a retained backup. Inputs: backup id. Outputs: executable verify guidance.
func WithExitClass ¶
WithExitClass binds the stack failure class ahead of any nested process exit. Inputs: structured stack error with its original cause. Outputs: explicit exit error. Constraints: E139 remains exit 2 and E403 remains exit 4 in both output modes.
Types ¶
type Backend ¶
type Backend interface {
Backup(context.Context, *Journal) error
VerifyBackup(context.Context, *Journal) error
Run(context.Context, string, *Journal) error
CheckPreviousImages(context.Context, *Journal) error
StopServices(context.Context, *Journal) error
Restore(context.Context, *Journal) error
RestartPrevious(context.Context, *Journal) error
CountRows(context.Context) (map[string]int64, error)
}
Backend connects ordered plan execution to existing project operations. Inputs: context and durable journal. Outputs: operation errors and backup proof. Constraints: operations must be idempotent; never delete backups or volumes.
type Journal ¶
type Journal struct {
RunID string `json:"run_id"`
StartedAt time.Time `json:"started_at"`
Status string `json:"status"`
Prod bool `json:"prod"`
BackupID string `json:"backup_id,omitempty"`
BackupSHA256 string `json:"backup_sha256,omitempty"`
BackupCreatedAt time.Time `json:"backup_created_at,omitempty"`
BackupVerifiedAt time.Time `json:"backup_verified_at,omitempty"`
PreviousCompose string `json:"previous_compose,omitempty"`
PreviousComposeSHA256 string `json:"previous_compose_sha256,omitempty"`
BeforeRows map[string]int64 `json:"before_rows,omitempty"`
AfterRows map[string]int64 `json:"after_rows,omitempty"`
Steps []Step `json:"steps"`
}
Journal preserves every fact needed to resume or recover a stack update. Inputs: completed operation evidence. Outputs: atomic project state. Constraints: production classification cannot change during resume.
type Options ¶
Options selects the project and authorizes mutations. Inputs: caller-resolved environment and confirmation callback. Outputs: execution policy. Constraints: dry runs never call the backend.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns the adapters for one consented stack update.
func NewRuntime ¶
NewRuntime prepares adapters without reading or mutating the project.
func (*Runtime) CheckPreviousImages ¶
CheckPreviousImages proves every pinned previous image still exists locally. Inputs: journal snapshot. Outputs: error naming the first missing image. Constraints: read only (`docker image inspect`); runs before anything is stopped.
func (*Runtime) CountRows ¶
CountRows records exact database counts with the existing backup count oracle.
func (*Runtime) RestartPrevious ¶
RestartPrevious starts only the immutable snapshot and removes services it lacks. Inputs: verified snapshot. Outputs: restart or health error. Constraints: `up -d --remove-orphans` removes containers, never volumes.
func (*Runtime) Restore ¶
Restore refuses production independently of caller policy and restores only pg.
func (*Runtime) StopServices ¶
StopServices stops every current app service so no new-image process writes during restore. Inputs: the current project Compose manifest. Outputs: stop error. Constraints: `compose stop` only; postgres stays up, no container or volume is removed.
type Step ¶
type Step struct {
Name string `json:"name"`
Result string `json:"result"`
DurationMS int64 `json:"duration_ms"`
}
Step records one execution result for human and JSON output. Inputs: plan name and measured execution. Outputs: resumable step state. Constraints: names and order are checked when loading a journal.