Internal

internal/app/harden

Package harden opens and completes spec hardening rounds.

import "github.com/nilstate/scafld/v2/internal/app/harden"

Package harden opens and completes spec hardening rounds.

Variables

Source: internal/app/harden/harden.go:23

var (
	// ErrMissingSpecStore is returned when hardening has no spec store.
	ErrMissingSpecStore = errors.New("missing spec store")
	// ErrNoHardenRound is returned when marking pass without an open round.
	ErrNoHardenRound = errors.New("no harden round exists")
	// ErrSpecNotDraft is returned when hardening a non-draft spec.
	ErrSpecNotDraft = errors.New("harden only operates on drafts")
	// ErrInvalidHardenEvidence is returned when a hardening round has unverified citations.
	ErrInvalidHardenEvidence = errors.New("invalid harden evidence")
)

Functions

func Run(ctx context.Context, store SpecStore, clock Clock, input Input) (Output, error)

Source: internal/app/harden/harden.go:79

Run opens a hardening round or marks the latest round passed.

Types

type Clock

Source: internal/app/harden/harden.go:43

Clock supplies hardening timestamps.

type Clock interface {
	Now() time.Time
}
Methods
  • Now func() time.Time

type Input

Source: internal/app/harden/harden.go:53

Input describes a hardening operation.

type Input struct {
	TaskID          string
	MarkPassed      bool
	Root            string
	Prompt          string
	Provider        Provider
	ContextMaxBytes int
}
Fields
  • TaskID string
  • MarkPassed bool
  • Root string
  • Prompt string
  • Provider Provider
  • ContextMaxBytes int

type Output

Source: internal/app/harden/harden.go:63

Output describes the opened or completed hardening round.

type Output struct {
	TaskID       string            `json:"task_id"`
	Path         string            `json:"path"`
	HardenStatus spec.HardenStatus `json:"harden_status"`
	RoundID      string            `json:"round_id"`
	MarkedPassed bool              `json:"marked_passed"`
	NextCommand  string            `json:"next_command"`
	Prompt       string            `json:"prompt"`
	Verdict      string            `json:"verdict,omitempty"`
	Summary      string            `json:"summary,omitempty"`
	Provider     string            `json:"provider,omitempty"`
	Model        string            `json:"model,omitempty"`
	Warnings     []string          `json:"warnings"`
}
Fields
  • TaskID string `json:"task_id"`
  • Path string `json:"path"`
  • HardenStatus spec.HardenStatus `json:"harden_status"`
  • RoundID string `json:"round_id"`
  • MarkedPassed bool `json:"marked_passed"`
  • NextCommand string `json:"next_command"`
  • Prompt string `json:"prompt"`
  • Verdict string `json:"verdict,omitempty"`
  • Summary string `json:"summary,omitempty"`
  • Provider string `json:"provider,omitempty"`
  • Model string `json:"model,omitempty"`
  • Warnings []string `json:"warnings"`

type Provider

Source: internal/app/harden/harden.go:48

Provider is the external hardening provider port.

type Provider interface {
	Invoke(context.Context, coreharden.Request) (coreharden.Dossier, error)
}
Methods
  • Invoke func(context.Context, coreharden.Request) (coreharden.Dossier, error)

type SpecStore

Source: internal/app/harden/harden.go:37

SpecStore is the spec persistence port used by hardening.

type SpecStore interface {
	Load(context.Context, string) (spec.Model, string, error)
	Save(context.Context, string, spec.Model) error
}
Methods
  • Load func(context.Context, string) (spec.Model, string, error)
  • Save func(context.Context, string, spec.Model) error