afscp

package
v0.4.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitSuccess         = 0
	ExitInternal        = 1
	ExitInvalidArgument = 2
	ExitMetadata        = 3
	ExitLocked          = 4
	ExitStorage         = 5
)
View Source
const ContractVersion = "jvs.afscp.direct.v1"

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) int

Types

type CloneEvidence

type CloneEvidence struct {
	Operation  string `json:"operation"`
	Phase      string `json:"phase"`
	Engine     string `json:"engine"`
	Status     string `json:"status"`
	StartedAt  string `json:"started_at"`
	FinishedAt string `json:"finished_at"`
	DurationMs int64  `json:"duration_ms"`
}

type CloneResult

type CloneResult struct {
	SourceRepoID          string          `json:"source_repo_id"`
	TargetRepoID          string          `json:"target_repo_id"`
	SavePointID           string          `json:"save_point_id"`
	SavePointsCopiedCount int             `json:"save_points_copied_count"`
	CloneEvidence         []CloneEvidence `json:"clone_evidence,omitempty"`
}

type Command

type Command string
const (
	CommandSave    Command = "save"
	CommandList    Command = "list"
	CommandRestore Command = "restore"
	CommandClone   Command = "clone"
	CommandStatus  Command = "status"
	CommandDoctor  Command = "doctor"
)

type DoctorResult

type DoctorResult struct {
	Healthy       bool                `json:"healthy"`
	RepoID        string              `json:"repo_id"`
	Findings      []FindingProjection `json:"findings"`
	MetadataState string              `json:"metadata_state"`
	Journal       string              `json:"journal"`
	Recovery      string              `json:"recovery"`
}

type Envelope

type Envelope struct {
	Contract string  `json:"contract"`
	Command  Command `json:"command"`
	OK       bool    `json:"ok"`
	Status   Status  `json:"status"`
	Data     any     `json:"data"`
	Error    *Error  `json:"error"`
}

func ErrorEnvelope

func ErrorEnvelope(command Command, err error) Envelope

func SuccessEnvelope

func SuccessEnvelope(command Command, data any) Envelope

type Error

type Error struct {
	Code      ErrorCode `json:"code"`
	Message   string    `json:"message"`
	Retryable bool      `json:"retryable"`
}

func NewError

func NewError(code ErrorCode, message string, retryable bool) *Error

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string
const (
	ErrorCodeInvalidArgument         ErrorCode = "JVS_INVALID_ARGUMENT"
	ErrorCodeLocked                  ErrorCode = "JVS_LOCKED"
	ErrorCodeMetadataInvalid         ErrorCode = "JVS_METADATA_INVALID"
	ErrorCodeSavePointNotFound       ErrorCode = "JVS_SAVE_POINT_NOT_FOUND"
	ErrorCodeCloneUnavailable        ErrorCode = "JVS_CLONE_UNAVAILABLE"
	ErrorCodeCloneFailed             ErrorCode = "JVS_CLONE_FAILED"
	ErrorCodeJournalRecoveryRequired ErrorCode = "JVS_JOURNAL_RECOVERY_REQUIRED"
	ErrorCodeInternal                ErrorCode = "JVS_INTERNAL"
)

type FindingProjection

type FindingProjection struct {
	Code      ErrorCode `json:"code,omitempty"`
	Severity  string    `json:"severity"`
	Message   string    `json:"message"`
	Retryable bool      `json:"retryable"`
}

type ListResult

type ListResult struct {
	HistoryHead   *string     `json:"history_head"`
	SavePoints    []SavePoint `json:"save_points"`
	MetadataState string      `json:"metadata_state"`
}

type Request

type Request struct {
	Selector       Selector
	TargetSelector Selector
	Message        string
	Purpose        string
	SavePointID    string
}

type ResolvedSelector

type ResolvedSelector struct {
	ControlRoot string
	Home        string
}

func ValidateMetadataSelector

func ValidateMetadataSelector(selector Selector) (ResolvedSelector, error)

func ValidateNewTargetSelector

func ValidateNewTargetSelector(source ResolvedSelector, selector Selector) (ResolvedSelector, error)

func ValidateSelector

func ValidateSelector(selector Selector) (ResolvedSelector, error)

type RestoreResult

type RestoreResult struct {
	RestoredSavePointID string          `json:"restored_save_point_id"`
	PreviousHead        *string         `json:"previous_head"`
	NewHead             string          `json:"new_head"`
	CloneEvidence       []CloneEvidence `json:"clone_evidence,omitempty"`
}

type SavePoint

type SavePoint struct {
	SavePointID string `json:"save_point_id"`
	CreatedAt   string `json:"created_at,omitempty"`
	Message     string `json:"message,omitempty"`
	Purpose     string `json:"purpose,omitempty"`
	HistoryHead bool   `json:"history_head,omitempty"`
}

type SaveResult

type SaveResult struct {
	SavePointID   string          `json:"save_point_id"`
	CreatedAt     string          `json:"created_at"`
	Message       string          `json:"message"`
	Purpose       string          `json:"purpose,omitempty"`
	HistoryHead   string          `json:"history_head"`
	CloneEvidence []CloneEvidence `json:"clone_evidence,omitempty"`
}

type Selector

type Selector struct {
	ControlRoot string
	Home        string
}

type Service

type Service struct{}

func NewService

func NewService() *Service

func (*Service) Clone

func (s *Service) Clone(ctx context.Context, request Request) (any, error)

func (*Service) Doctor

func (s *Service) Doctor(ctx context.Context, request Request) (DoctorResult, error)

func (*Service) List

func (s *Service) List(ctx context.Context, request Request) (ListResult, error)

func (*Service) Restore

func (s *Service) Restore(ctx context.Context, request Request) (any, error)

func (*Service) Save

func (s *Service) Save(ctx context.Context, request Request) (any, error)

func (*Service) Status

func (s *Service) Status(ctx context.Context, request Request) (StatusResult, error)

type Status

type Status string
const (
	StatusAccepted         Status = "accepted"
	StatusRunning          Status = "running"
	StatusSucceeded        Status = "succeeded"
	StatusFailed           Status = "failed"
	StatusRecoveryRequired Status = "recovery_required"
)

type StatusResult

type StatusResult struct {
	RepoID          string  `json:"repo_id"`
	HistoryHead     *string `json:"history_head"`
	ActiveOperation string  `json:"active_operation"`
	MetadataState   string  `json:"metadata_state"`
	Recovery        string  `json:"recovery"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL