layout

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package layout audits and safely cleans local clone placement under a projects root. Canonical clones live at {root}/{owner}/{repository}.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanFailed

func CleanFailed(report CleanReport) bool

CleanFailed reports whether clean had errors or leftover skips that need attention when apply was requested. Dry-run never fails solely for planned removals.

func Failed

func Failed(report Report) bool

Failed reports whether an audit found layout problems.

func OriginSlug

func OriginSlug(ctx context.Context, path string) (string, error)

OriginSlug returns owner/repository from path's origin remote.

Types

type CleanAction

type CleanAction struct {
	Path       string `json:"path" yaml:"path"`
	OriginSlug string `json:"origin_slug,omitempty" yaml:"origin_slug,omitempty"`
	Status     string `json:"status" yaml:"status"` // removed, planned, skipped, error
	Reason     string `json:"reason" yaml:"reason"`
}

CleanAction is one planned or applied cleanup.

type CleanOptions

type CleanOptions struct {
	Apply                 bool
	AllowMissingCanonical bool
}

CleanOptions controls safe removal of top-level clones.

type CleanReport

type CleanReport struct {
	SchemaVersion int           `json:"schema_version" yaml:"schema_version"`
	ProjectsRoot  string        `json:"projects_root" yaml:"projects_root"`
	DryRun        bool          `json:"dry_run" yaml:"dry_run"`
	Actions       []CleanAction `json:"actions" yaml:"actions"`
}

CleanReport summarizes a clean run.

func Clean

func Clean(ctx context.Context, projectsRoot string, options CleanOptions) (CleanReport, error)

Clean removes safe top-level clones. Without Apply it only plans.

func (CleanReport) Markdown

func (report CleanReport) Markdown() string

Markdown renders a clean plan/result.

type Finding

type Finding struct {
	Path            string `json:"path" yaml:"path"`
	Kind            Kind   `json:"kind" yaml:"kind"`
	PathSlug        string `json:"path_slug,omitempty" yaml:"path_slug,omitempty"`
	OriginSlug      string `json:"origin_slug,omitempty" yaml:"origin_slug,omitempty"`
	ExpectedPath    string `json:"expected_path,omitempty" yaml:"expected_path,omitempty"`
	CanonicalExists bool   `json:"canonical_exists,omitempty" yaml:"canonical_exists,omitempty"`
	Reason          string `json:"reason" yaml:"reason"`
}

Finding is one inspected checkout relative to the projects root.

type Kind

type Kind string

Kind classifies one layout finding.

const (
	KindOK         Kind = "ok"
	KindTopLevel   Kind = "top_level"
	KindMisowned   Kind = "misowned"
	KindNoOrigin   Kind = "no_origin"
	KindUnreadable Kind = "unreadable"
)

type Report

type Report struct {
	SchemaVersion int       `json:"schema_version" yaml:"schema_version"`
	ProjectsRoot  string    `json:"projects_root" yaml:"projects_root"`
	ObservedAt    time.Time `json:"observed_at" yaml:"observed_at"`
	Summary       Summary   `json:"summary" yaml:"summary"`
	Findings      []Finding `json:"findings" yaml:"findings"`
}

Report is the deterministic layout audit index.

func Audit

func Audit(ctx context.Context, projectsRoot string) (Report, error)

Audit walks projectsRoot for canonical, top-level, and misowned clones.

func (Report) Markdown

func (report Report) Markdown() string

Markdown renders a human/agent layout audit index.

type Summary

type Summary struct {
	Inspected  int `json:"inspected" yaml:"inspected"`
	OK         int `json:"ok" yaml:"ok"`
	TopLevel   int `json:"top_level" yaml:"top_level"`
	Misowned   int `json:"misowned" yaml:"misowned"`
	NoOrigin   int `json:"no_origin" yaml:"no_origin"`
	Unreadable int `json:"unreadable" yaml:"unreadable"`
}

Summary counts findings by kind.

func Counts

func Counts(ctx context.Context, projectsRoot string) (Summary, error)

Counts returns summary fields useful for fleet rollups without retaining findings.

Jump to

Keyboard shortcuts

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