Internal

internal/core/session

Package session defines the append-only evidence ledger and replay model.

import "github.com/nilstate/scafld/v2/internal/core/session"

Package session defines the append-only evidence ledger and replay model.

Constants

Source: internal/core/session/model.go:10

const (
	// EntryWorkspaceBaseline records dirty workspace state before task execution begins.
	EntryWorkspaceBaseline = "workspace_baseline"
)

Functions

func FirstWorkspaceBaseline(s Session) (Entry, bool)

Source: internal/core/session/model.go:112

FirstWorkspaceBaseline returns the first captured task workspace baseline.

func New(taskID string, now string) Session

Source: internal/core/session/model.go:57

New creates an empty session ledger for taskID.

func OrderedCriterionIDs(s Session) []string

Source: internal/core/session/model.go:102

OrderedCriterionIDs returns criterion state keys in deterministic order.

func Replay(s Session) Session

Source: internal/core/session/model.go:70

Replay rebuilds derived criterion and phase state from session entries.

func WorkspaceBaselineSnapshot(entry Entry) []string

Source: internal/core/session/model.go:122

WorkspaceBaselineSnapshot decodes the raw changed-file snapshot from an entry.

Types

type Entry

Source: internal/core/session/model.go:25

Entry is one append-only evidence event in a session ledger.

type Entry struct {
	ID          string `json:"id,omitempty"`
	Type        string `json:"type"`
	RecordedAt  string `json:"recorded_at"`
	CriterionID string `json:"criterion_id,omitempty"`
	PhaseID     string `json:"phase_id,omitempty"`
	Status      string `json:"status,omitempty"`
	Reason      string `json:"reason,omitempty"`
	Provider    string `json:"provider,omitempty"`
	Command     string `json:"command,omitempty"`
	ExitCode    int    `json:"exit_code,omitempty"`
	Output      string `json:"output,omitempty"`
	Path        string `json:"path,omitempty"`
}
Fields
  • ID string `json:"id,omitempty"`
  • Type string `json:"type"`
  • RecordedAt string `json:"recorded_at"`
  • CriterionID string `json:"criterion_id,omitempty"`
  • PhaseID string `json:"phase_id,omitempty"`
  • Status string `json:"status,omitempty"`
  • Reason string `json:"reason,omitempty"`
  • Provider string `json:"provider,omitempty"`
  • Command string `json:"command,omitempty"`
  • ExitCode int `json:"exit_code,omitempty"`
  • Output string `json:"output,omitempty"`
  • Path string `json:"path,omitempty"`

type Session

Source: internal/core/session/model.go:14

Session is the durable task evidence ledger plus replayed state indexes.

type Session struct {
	SchemaVersion   int                    `json:"schema_version"`
	TaskID          string                 `json:"task_id"`
	CreatedAt       string                 `json:"created_at,omitempty"`
	UpdatedAt       string                 `json:"updated_at,omitempty"`
	Entries         []Entry                `json:"entries"`
	CriterionStates map[string]StateRecord `json:"criterion_states,omitempty"`
	PhaseBlocks     map[string]StateRecord `json:"phase_blocks,omitempty"`
}
Fields
  • SchemaVersion int `json:"schema_version"`
  • TaskID string `json:"task_id"`
  • CreatedAt string `json:"created_at,omitempty"`
  • UpdatedAt string `json:"updated_at,omitempty"`
  • Entries []Entry `json:"entries"`
  • CriterionStates map[string]StateRecord `json:"criterion_states,omitempty"`
  • PhaseBlocks map[string]StateRecord `json:"phase_blocks,omitempty"`

func WithEntry(entry Entry) Session

Source: internal/core/session/model.go:49

WithEntry returns a replayed copy of the session with entry appended.

type StateRecord

Source: internal/core/session/model.go:41

StateRecord is the replayed state for a criterion or phase.

type StateRecord struct {
	Status    string `json:"status"`
	Reason    string `json:"reason,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
	SourceID  string `json:"source_id,omitempty"`
}
Fields
  • Status string `json:"status"`
  • Reason string `json:"reason,omitempty"`
  • UpdatedAt string `json:"updated_at,omitempty"`
  • SourceID string `json:"source_id,omitempty"`