statepaths

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package statepaths composes cr-specific data and cache paths.

Index

Constants

View Source
const (
	// Tool is the binary/tool name used with cli-common statedir resolvers.
	Tool = "cr"
	// AppDir is the config/credential service directory name. It is retained
	// for config-scope callers; data/cache roots use Tool directly.
	AppDir = "codereview"
)

Variables

This section is empty.

Functions

func CacheRoot

func CacheRoot() (string, error)

CacheRoot resolves cr's per-binary cache root without creating it.

func CacheRootEnsured

func CacheRootEnsured() (string, error)

CacheRootEnsured resolves and creates cr's per-binary cache root.

func DataRoot

func DataRoot() (string, error)

DataRoot resolves cr's per-binary data root without creating it.

func DataRootEnsured

func DataRootEnsured() (string, error)

DataRootEnsured resolves and creates cr's per-binary data root.

func Encode

func Encode(value string) string

Encode percent-encodes every rune outside [A-Za-z0-9._-].

func FormatAttempt

func FormatAttempt(attempt int) (string, error)

FormatAttempt returns the run attempt path segment. Attempts below 1000 are zero-padded for readability; lexicographic sorting is not guaranteed after that because the design intentionally does not cap attempt numbers at 999.

func KeyHash

func KeyHash(prKey, headSHA, baseSHA, profile, postingIdentity string) string

KeyHash returns the 12-character hash over the full resume-key tuple.

func LegacyCacheRoot added in v0.1.40

func LegacyCacheRoot(layout Layout) string

LegacyCacheRoot returns the historical nested cache root for layout.

func LegacyDataRoot added in v0.1.40

func LegacyDataRoot(layout Layout) string

LegacyDataRoot returns the historical nested data root for layout.

func LegacyDataRootExists added in v0.1.40

func LegacyDataRootExists(layout Layout) (bool, error)

LegacyDataRootExists reports whether layout still has unmigrated legacy data.

func MigrateLegacyCacheRoot added in v0.1.40

func MigrateLegacyCacheRoot(layout Layout) error

MigrateLegacyCacheRoot moves cache written by releases that nested state under the per-binary root's historical AppDir child.

func MigrateLegacyDataRoot added in v0.1.40

func MigrateLegacyDataRoot(layout Layout) error

MigrateLegacyDataRoot moves data written by releases that nested state under the per-binary root's historical AppDir child.

func PRKey

func PRKey(host, owner, repo string, number int) (string, error)

PRKey returns the encoded PR key path segment.

func ResumeScope

func ResumeScope(profile, postingIdentity string) (string, error)

ResumeScope returns the encoded profile/posting-identity path segment.

Types

type Layout

type Layout struct {
	DataRoot  string
	CacheRoot string
}

Layout composes paths under resolved cr data/cache roots.

func DefaultLayout

func DefaultLayout() (Layout, error)

DefaultLayout resolves the current process data/cache layout without creating directories.

func DefaultLayoutEnsured

func DefaultLayoutEnsured() (Layout, error)

DefaultLayoutEnsured resolves and creates the current process data/cache app roots.

func NewLayout

func NewLayout(dataRoot, cacheRoot string) Layout

NewLayout returns a path layout rooted at dataRoot and cacheRoot.

func (Layout) HTTPCacheDir

func (l Layout) HTTPCacheDir() string

HTTPCacheDir returns the disposable git-provider HTTP cache directory.

func (Layout) LedgerDB

func (l Layout) LedgerDB() string

LedgerDB returns the ledger database path.

func (Layout) LockFile

func (l Layout) LockFile(spec LockSpec) (string, error)

LockFile returns the advisory run-lock path for spec's resume key.

func (Layout) Run

func (l Layout) Run(spec RunSpec) (RunPaths, error)

Run returns artifact and lock paths for spec.

type LockSpec

type LockSpec struct {
	Host            string
	Owner           string
	Repo            string
	PRNumber        int
	HeadSHA         string
	BaseSHA         string
	Profile         string
	PostingIdentity string
}

LockSpec identifies one review resume key's lock file.

type RunPaths

type RunPaths struct {
	Dir            string
	DiffPatch      string
	SlicesDir      string
	FindingsJSON   string
	RollupMarkdown string
	AgentLogsDir   string
	LockFile       string
}

RunPaths contains all per-run artifact paths.

func (RunPaths) AgentLog

func (p RunPaths) AgentLog(agentID string) (string, error)

AgentLog returns the tailable JSONL log path for an agent.

func (RunPaths) SlicePatch

func (p RunPaths) SlicePatch(agentID, filePath string) (string, error)

SlicePatch returns the artifact path for an agent/file diff slice.

type RunSpec

type RunSpec struct {
	Host            string
	Owner           string
	Repo            string
	PRNumber        int
	HeadSHA         string
	BaseSHA         string
	Profile         string
	PostingIdentity string
	Attempt         int
}

RunSpec identifies one review attempt's path tuple.

Jump to

Keyboard shortcuts

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