// Package core holds the pure domain logic of compare.sr.ht: input
// validation (owner/repo/ref names), the compare-spec grammar, and the
// sentinel errors shared across the service. It has no external dependencies
// and never touches the network or the filesystem, so it is cheap to test.
package core

import "errors"

// Sentinel errors. Callers compare with errors.Is; wrapping with %w adds
// human-readable detail without losing the class.
var (
	// ErrNotFound is returned when a repo, ref, or object does not exist —
	// or, for authorization, when the viewer is not allowed to know it
	// exists. Handlers map this to HTTP 404 (never 403, so private-repo
	// existence is not leaked).
	ErrNotFound = errors.New("not found")

	// ErrForbidden marks an operation the viewer is authenticated for but
	// not permitted to perform. Repo visibility deliberately uses
	// ErrNotFound instead; ErrForbidden is reserved for genuine 403 cases.
	ErrForbidden = errors.New("forbidden")

	// ErrBadRef is returned for malformed compare specs or refs that fail
	// check-ref-format validation. Handlers map this to HTTP 400.
	ErrBadRef = errors.New("invalid git ref")

	// ErrTruncated signals that git output exceeded the in-page size cap.
	// The handler renders the file list plus a link to the raw .patch.
	ErrTruncated = errors.New("output truncated")
)
