doctor

package
v1.233.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Overview

Package doctor diagnoses authored project inputs without executing configuration.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOptions      = errors.New("invalid doctor options")
	ErrChanged      = errors.New("doctor source changed since inspection")
	ErrVerification = errors.New("doctor semantic verification failed")
	// ErrRecoveryManifest reports a backup manifest value that cannot be read.
	ErrRecoveryManifest = errors.New("invalid doctor recovery manifest")
	// ErrNoConfiguration reports that no Atmos configuration could be located for the project.
	ErrNoConfiguration = errors.New("no project Atmos configuration found")
)
View Source
var ErrMonorepoVersion = errors.New("component version cannot be resolved to a tag")

ErrMonorepoVersion reports a source whose version cannot be checked against a single tag.

Functions

func SummarizePaths

func SummarizePaths(paths []string) string

summarizePaths lists at most maxListedPaths paths and counts the rest.

Types

type Check

type Check struct {
	ID     string `json:"id"`
	Status string `json:"status"`
	Files  int    `json:"files"`
	Reason string `json:"reason,omitempty"`
}

Check records coverage separately from findings, including incomplete checks.

type DependencyTargetReporter

type DependencyTargetReporter interface {
	DependencyTargets(context.Context, *schema.AtmosConfiguration, StackInputs) (map[dependency.ComponentRef][]dependency.ComponentRef, error)
}

DependencyTargetReporter reports the dependencies the runtime would select for each component, so a repair can be shown not to change the dependency graph.

type DependencyValidator

type DependencyValidator interface {
	ValidateDependencies(context.Context, *schema.AtmosConfiguration, StackInputs) error
}

DependencyValidator checks the production dependency graph without evaluating configuration.

type Engine

type Engine struct {
	FS           filesystem.FileSystem
	Repositories RepositoryChecker
	BackupDir    func() (string, error)
	Observe      func(Event)
	Stacks       StackValidator
	// Monorepo proves that a component moved out of the archived monorepo has identical files.
	Monorepo monorepo.Verifier
}

Engine dependencies are injectable to test writes and network failures.

func (*Engine) Run

func (e *Engine) Run(ctx context.Context, o Options) (Report, error)

Run diagnoses a project using an invocation-local options snapshot.

type Event

type Event struct {
	Finding *Finding
	Phase   string
	Label   string
	Index   int
	Total   int
	Done    bool
	Status  string
}

Event communicates progress without coupling checks to terminal rendering.

type Finding

type Finding struct {
	RuleID        string              `json:"rule_id"`
	Category      string              `json:"category"`
	Severity      validation.Severity `json:"severity"`
	File          string              `json:"file,omitempty"`
	Path          string              `json:"path,omitempty"`
	Line          int                 `json:"line,omitempty"`
	Column        int                 `json:"column,omitempty"`
	Message       string              `json:"message"`
	Remediation   string              `json:"remediation,omitempty"`
	Documentation string              `json:"documentation,omitempty"`
	Status        string              `json:"status"`
	Fixable       bool                `json:"fixable"`
	Reason        string              `json:"reason,omitempty"`
}

Finding contains a diagnostic and the explicit repair decision.

type GitHubRepositoryChecker

type GitHubRepositoryChecker struct{}

GitHubRepositoryChecker reuses Atmos's authenticated, host-scoped GitHub client.

func (GitHubRepositoryChecker) Check

type Options

type Options struct {
	UnverifiedInputs []string
	Root             string
	ConfigFiles      []string
	ConfigDirs       []string
	Profiles         []string
	BasePath         string
	Fix              bool
	DryRun           bool
	Offline          bool
	Only             []string
	Exclude          []string
	Selected         []string
	// SelectedRoot is the absolute directory that Selected paths are relative to,
	// typically the Git worktree root. Empty means Selected is relative to Root.
	SelectedRoot string
	Affected     bool
	// contains filtered or unexported fields
}

Options selects project inputs and the repair policy.

type RecoveryEntry

type RecoveryEntry struct {
	Path   string       `json:"path"`
	Copy   string       `json:"copy"`
	Mode   RecoveryMode `json:"mode"`
	Before string       `json:"before_sha256"`
	After  string       `json:"after_sha256"`
}

RecoveryEntry records enough information to restore the exact original bytes.

type RecoveryMode

type RecoveryMode uint32

RecoveryMode is a file's permission bits. It is written as the octal string chmod accepts, for example "0644", and reads both that form and the decimal number older manifests recorded.

func (RecoveryMode) MarshalJSON

func (m RecoveryMode) MarshalJSON() ([]byte, error)

MarshalJSON writes the mode as an octal string.

func (*RecoveryMode) UnmarshalJSON

func (m *RecoveryMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads an octal string, or the decimal number written by older manifests.

type Report

type Report struct {
	// SourceRoot resolves project-relative locations for human source excerpts.
	SourceRoot       string    `json:"-"`
	Version          int       `json:"version"`
	Findings         []Finding `json:"findings"`
	Checks           []Check   `json:"checks"`
	ChangedFiles     []string  `json:"changed_files"`
	Backup           string    `json:"backup,omitempty"`
	Recovery         string    `json:"recovery,omitempty"`
	Fix              bool      `json:"fix"`
	DryRun           bool      `json:"dry_run"`
	OperationalError string    `json:"operational_error,omitempty"`
}

Report is the complete machine-readable run result.

func (*Report) ExitCode

func (r *Report) ExitCode(threshold string) int

ExitCode evaluates remaining findings. Operational failures cannot be suppressed, and neither can a requested repair that failed verification: a fix run that did not deliver what was asked for exits 1 whatever the severity threshold. A dry run applies nothing, so it only applies the threshold.

func (*Report) ValidationReport

func (r *Report) ValidationReport() validation.Report

ValidationReport adapts findings to Atmos's existing rich and SARIF renderers.

type RepositoryChecker

type RepositoryChecker interface {
	Check(context.Context, string) RepositoryHealth
}

RepositoryChecker inspects repository metadata without cloning or installing tools.

type RepositoryHealth

type RepositoryHealth struct {
	Status  string
	Message string
}

RepositoryHealth deliberately distinguishes inaccessible repositories from missing ones.

type Rule

type Rule struct {
	ID          string `json:"id"`
	Category    string `json:"category"`
	Description string `json:"description"`
}

Rule describes a built-in check. Replacement prose is never executable.

func Rules

func Rules() []Rule

Rules is the stable, built-in check catalog.

type SourceReader

type SourceReader interface {
	ReadFile(path string) ([]byte, error)
}

SourceReader reads stack manifests as doctor sees them: current content, or a repair candidate while one is verified.

type StackInputs

type StackInputs struct {
	// Files are the top-level manifests, as slash paths relative to the stacks base path, after
	// stacks.included_paths and stacks.excluded_paths are applied.
	Files []string
	// Reader supplies the content of each manifest and of everything it imports.
	Reader SourceReader
}

StackInputs are the static stack manifests captured for the stack consumers.

type StackValidator

type StackValidator interface {
	Validate(context.Context, *schema.AtmosConfiguration, StackInputs) error
}

StackValidator checks static inputs with the production stack consumers.

Directories

Path Synopsis
Package monorepo is a generated GoMock package.
Package monorepo is a generated GoMock package.

Jump to

Keyboard shortcuts

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