diagnostic

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CheckSessionProjectDirectoryMismatch  = "session_project_directory_mismatch"
	CheckManualSessionNameProjectMismatch = "manual_session_name_project_mismatch"
	CheckSyncMutationRequiredFields       = "sync_mutation_required_fields"
	CheckSQLiteLockContention             = "sqlite_lock_contention"
)
View Source
const (
	StatusOK      = "ok"
	StatusWarning = "warning"
	StatusBlocked = "blocked"
	StatusError   = "error"

	SeverityInfo     = "info"
	SeverityWarning  = "warning"
	SeverityError    = "error"
	SeverityBlocking = "blocking"
)

Variables

View Source
var ErrInvalidCheck = errors.New("invalid diagnostic check")

Functions

func RegisteredCodes

func RegisteredCodes() []string

Types

type CheckResult

type CheckResult struct {
	CheckID              string          `json:"check_id"`
	Result               string          `json:"result"`
	Severity             string          `json:"severity"`
	ReasonCode           string          `json:"reason_code"`
	Message              string          `json:"message"`
	Why                  string          `json:"why"`
	Evidence             json.RawMessage `json:"evidence"`
	SafeNextStep         string          `json:"safe_next_step"`
	RequiresConfirmation bool            `json:"requires_confirmation"`
	Findings             []Finding       `json:"findings,omitempty"`
}

type DetectedProject

type DetectedProject struct {
	Project string `json:"project"`
	Source  string `json:"source"`
	Path    string `json:"path,omitempty"`
}

type DiagnosticCheck

type DiagnosticCheck interface {
	Code() string
	Run(context.Context, Scope) (CheckResult, error)
}

type Finding

type Finding struct {
	CheckID              string          `json:"check_id"`
	Severity             string          `json:"severity"`
	ReasonCode           string          `json:"reason_code"`
	Message              string          `json:"message"`
	Why                  string          `json:"why"`
	Evidence             json.RawMessage `json:"evidence"`
	SafeNextStep         string          `json:"safe_next_step"`
	RequiresConfirmation bool            `json:"requires_confirmation"`
}

type ManualSessionNameProjectMismatchCheck

type ManualSessionNameProjectMismatchCheck struct{}

func (ManualSessionNameProjectMismatchCheck) Code

func (ManualSessionNameProjectMismatchCheck) Run

type ProjectReclassifyAction

type ProjectReclassifyAction struct {
	SessionID      string `json:"session_id"`
	FromProject    string `json:"from_project"`
	ToProject      string `json:"to_project"`
	ReasonCode     string `json:"reason_code"`
	EvidenceSource string `json:"evidence_source,omitempty"`
	EvidencePath   string `json:"evidence_path,omitempty"`
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func DefaultRegistry

func DefaultRegistry() Registry

func NewRegistry

func NewRegistry(checks ...DiagnosticCheck) Registry

func (Registry) Checks

func (r Registry) Checks() []DiagnosticCheck

func (Registry) Lookup

func (r Registry) Lookup(code string) (DiagnosticCheck, error)

type RepairCounts

type RepairCounts struct {
	SessionsPlanned     int64 `json:"sessions_planned"`
	ObservationsPlanned int64 `json:"observations_planned"`
	PromptsPlanned      int64 `json:"prompts_planned"`
	SessionsApplied     int64 `json:"sessions_applied"`
	ObservationsApplied int64 `json:"observations_applied"`
	PromptsApplied      int64 `json:"prompts_applied"`
}

type RepairMode

type RepairMode string
const (
	RepairModePlan   RepairMode = "plan"
	RepairModeDryRun RepairMode = "dry_run"
	RepairModeApply  RepairMode = "apply"
)

type RepairPlan

type RepairPlan struct {
	Project    string                    `json:"project"`
	Check      string                    `json:"check"`
	Mode       RepairMode                `json:"mode"`
	Status     string                    `json:"status"`
	Actions    []ProjectReclassifyAction `json:"actions"`
	Skipped    []RepairSkip              `json:"skipped,omitempty"`
	Counts     RepairCounts              `json:"counts"`
	BackupPath string                    `json:"backup_path,omitempty"`
}

func BuildRepairPlan

func BuildRepairPlan(ctx context.Context, scope Scope, report Report, check string, mode RepairMode) (RepairPlan, error)

type RepairSkip

type RepairSkip struct {
	SessionID  string `json:"session_id,omitempty"`
	ReasonCode string `json:"reason_code"`
	Message    string `json:"message"`
}

type Report

type Report struct {
	Status  string        `json:"status"`
	Project string        `json:"project,omitempty"`
	Summary Summary       `json:"summary"`
	Checks  []CheckResult `json:"checks"`
}

func ErrorReport

func ErrorReport(project string, err error) Report

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner() Runner

func NewRunnerWithRegistry

func NewRunnerWithRegistry(r Registry) Runner

func (Runner) RunAll

func (r Runner) RunAll(ctx context.Context, scope Scope) (Report, error)

func (Runner) RunOne

func (r Runner) RunOne(ctx context.Context, scope Scope, code string) (Report, error)

type SQLiteLockContentionCheck

type SQLiteLockContentionCheck struct{}

func (SQLiteLockContentionCheck) Code

func (SQLiteLockContentionCheck) Run

type Scope

type Scope struct {
	Store                  *store.Store
	Project                string
	Now                    time.Time
	ReadSQLiteLockSnapshot func(context.Context) (store.SQLiteLockSnapshot, error)
	DetectProject          func(string) (DetectedProject, bool)
}

type SessionProjectDirectoryMismatchCheck

type SessionProjectDirectoryMismatchCheck struct{}

func (SessionProjectDirectoryMismatchCheck) Code

func (SessionProjectDirectoryMismatchCheck) Run

type Summary

type Summary struct {
	Total    int `json:"total"`
	OK       int `json:"ok"`
	Warnings int `json:"warnings"`
	Blocked  int `json:"blocked"`
	Errors   int `json:"errors"`
}

type SyncMutationRequiredFieldsCheck

type SyncMutationRequiredFieldsCheck struct{}

func (SyncMutationRequiredFieldsCheck) Code

func (SyncMutationRequiredFieldsCheck) Run

Jump to

Keyboard shortcuts

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