core

package
v0.0.0-...-84a9851 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 47 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultProject = `` /* 254-byte string literal not displayed */
View Source
const ProjectFile = ".config/async-commit-hook.toml"
View Source
const ReleaseIdentity = "https://github.com/delinoio/oss/.github/workflows/release-async-commit-hook.yml@refs/heads/main"
View Source
const SchemaVersion = 1
View Source
const Version = "0.1.1"

Variables

View Source
var AgentGuide string

Functions

func AtomicCreate

func AtomicCreate(path string, b []byte, mode os.FileMode) error

func AtomicCreateOwned

func AtomicCreateOwned(root *os.Root, path string, b []byte, mode os.FileMode) error

func AtomicWrite

func AtomicWrite(path string, b []byte, mode os.FileMode) error

func Detached

func Detached(c *exec.Cmd)

func Discover

func Discover(ctx context.Context, path string) (common, root, branch string, err error)

func E

func E(code, message string, exit int) error

func Encode

func Encode(v any) []byte

func Fingerprint

func Fingerprint(p Project, env map[string]string) string

func Git

func Git(ctx context.Context, path string, args ...string) (result string, err error)

func Hash

func Hash(b []byte) string

func ID

func ID() string

func PrivateDir

func PrivateDir(path string) error

func PrivateFile

func PrivateFile(path string) error

func ProcessAlive

func ProcessAlive(p Process) bool

func PublicEnvironment

func PublicEnvironment(p Project) (map[string]string, error)

func ReadOwned

func ReadOwned(root, relative string, limit int64) ([]byte, error)

func ReconcileProcess

func ReconcileProcess(p Process) error

func Redact

func Redact(b []byte, secrets []string) []byte

func ResolveCommit

func ResolveCommit(ctx context.Context, path, ref string) (commit string, err error)

func SafeRelative

func SafeRelative(p string) bool

func SupportedTarget

func SupportedTarget() bool

func SystemEnvironment

func SystemEnvironment() map[string]string

func ValidID

func ValidID(id string) bool

func ValidateSource

func ValidateSource(ctx context.Context, path, sha string) error

func VerifyReleaseFile

func VerifyReleaseFile(path, bundlePath string) error

func Wrap

func Wrap(code string, err error) error

Types

type API

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

func (*API) Pair

Pair remains only as a v1 wire tombstone. Local UI access no longer pairs browsers.

type Branch

type Branch struct {
	Name   string `json:"name"`
	Commit string `json:"commit"`
}

func BranchPage

func BranchPage(ctx context.Context, path, cursor string, limit int) (result []Branch, next string, err error)

BranchPage streams raw refs, retaining one bounded page. Use lexical keysets rather than Git's newer --start-after option to support Ubuntu 22.04's Git.

type Changes

type Changes struct {
	Base      string `json:"base"`
	Head      string `json:"head"`
	MergeBase string `json:"merge_base"`
	Diff      string `json:"diff"`
	Truncated bool   `json:"truncated"`
}

func Diff

func Diff(ctx context.Context, path, ref, base string) (out Changes, e error)

type Check

type Check struct {
	ID            string       `json:"id"`
	Name          string       `json:"name"`
	State         State        `json:"state"`
	Optional      bool         `json:"optional"`
	Shell         Shell        `json:"shell"`
	Group         string       `json:"group"`
	Policy        Policy       `json:"policy"`
	ExitCode      *int         `json:"exit_code,omitempty"`
	Process       Process      `json:"process"`
	StartedAt     *time.Time   `json:"started_at,omitempty"`
	FinishedAt    *time.Time   `json:"finished_at,omitempty"`
	Log           Evidence     `json:"log"`
	Reports       []Evidence   `json:"reports"`
	Failures      []Failure    `json:"failures"`
	Diagnostics   []Diagnostic `json:"diagnostics"`
	InheritedFrom string       `json:"inherited_from,omitempty"`
}

type Command

type Command struct {
	Command     string             `toml:"command" json:"command"`
	DependsOn   []string           `toml:"depends_on" json:"depends_on"`
	OS          []string           `toml:"os" json:"os"`
	Shell       Shell              `toml:"shell" json:"shell"`
	Optional    bool               `toml:"optional" json:"optional"`
	Policy      Policy             `toml:"policy" json:"policy"`
	Group       string             `toml:"group" json:"group,omitempty"`
	Environment []EnvironmentInput `toml:"environment" json:"environment"`
	Reports     []Report           `toml:"reports" json:"reports"`
}

func (Command) Applies

func (c Command) Applies(osName string) bool

func (Command) SelectedShell

func (c Command) SelectedShell(osName string) Shell

type Commit

type Commit struct {
	ID      string   `json:"id"`
	Parents []string `json:"parents"`
	Subject string   `json:"subject"`
}

func Commits

func Commits(ctx context.Context, path, ref string, offset int) (result []Commit, err error)

type Comparison

type Comparison struct {
	Available  bool      `json:"available"`
	Reason     string    `json:"reason,omitempty"`
	RunID      string    `json:"run_id"`
	PreviousID string    `json:"previous_id,omitempty"`
	New        []Failure `json:"new"`
	Continuing []Failure `json:"continuing"`
	Resolved   []Failure `json:"resolved"`
}

type Component

type Component struct {
	ID         string  `json:"id"`
	Kind       string  `json:"kind"`
	Process    Process `json:"process"`
	ConfigHash string  `json:"config_hash"`
	StateDir   string  `json:"state_dir"`
}

type Credential

type Credential struct {
	Env  string `toml:"env" json:"env,omitempty"`
	File string `toml:"file" json:"file,omitempty"`
}

type Diagnostic

type Diagnostic struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Hint    string `json:"hint,omitempty"`
}

type EnvironmentInput

type EnvironmentInput struct {
	Name       string `toml:"name" json:"name"`
	Secret     bool   `toml:"secret" json:"secret"`
	Credential string `toml:"credential" json:"credential,omitempty"`
	Required   bool   `toml:"required" json:"required"`
}

type Error

type Error struct {
	Diagnostic
	Exit int `json:"-"`
}

func (*Error) Error

func (e *Error) Error() string

type Evidence

type Evidence struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

type Failure

type Failure struct {
	ID      string `json:"id"`
	Check   string `json:"check"`
	Test    string `json:"test,omitempty"`
	Command string `json:"command"`
	Message string `json:"message"`
	File    string `json:"file,omitempty"`
	Line    int    `json:"line,omitempty"`
	LogID   string `json:"log_id"`
}

func Failures

func Failures(r Run) []Failure

func ParseReport

func ParseReport(kind ReportKind, b []byte, check, command, logID string) ([]Failure, error)

type Gate

type Gate struct {
	Passed      bool         `json:"passed"`
	State       State        `json:"state"`
	Commit      string       `json:"commit"`
	RunID       string       `json:"run_id,omitempty"`
	Reason      string       `json:"reason"`
	Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}

type InstallResult

type InstallResult struct {
	Installed bool   `json:"installed"`
	Path      string `json:"path"`
	Manual    string `json:"manual,omitempty"`
	Backup    string `json:"backup,omitempty"`
	Example   string `json:"example,omitempty"`
}

type Installation

type Installation struct {
	ID        string `json:"id"`
	Path      string `json:"path"`
	Hash      string `json:"hash"`
	Original  []byte `json:"original,omitempty"`
	Kind      string `json:"kind"`
	Entry     string `json:"entry,omitempty"`
	SkillPath string `json:"skill_path,omitempty"`
	SkillHash string `json:"skill_hash,omitempty"`
}

type Lock

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

func TryLock

func TryLock(path string) (*Lock, error)

func (*Lock) Close

func (l *Lock) Close()

type LogPage

type LogPage struct {
	Text       string `json:"text"`
	NextOffset int64  `json:"next_offset"`
	Complete   bool   `json:"complete"`
}

type MCPInput

type MCPInput struct {
	Repo           string `json:"repo,omitempty" jsonschema:"Registered worktree path; defaults to current directory"`
	Commit         string `json:"commit,omitempty" jsonschema:"Exact Git commit or local ref; defaults to HEAD"`
	RunID          string `json:"run_id,omitempty" jsonschema:"Receipt UUID v7"`
	Check          string `json:"check,omitempty" jsonschema:"Check name or ID belonging to the run"`
	PreviousID     string `json:"previous_id,omitempty" jsonschema:"Optional explicit comparison run"`
	Cursor         string `json:"cursor,omitempty"`
	Offset         int64  `json:"offset,omitempty"`
	Limit          int    `json:"limit,omitempty"`
	TimeoutSeconds int    `json:"timeout_seconds,omitempty" jsonschema:"Wait only; never an execution timeout"`
	FailedOnly     bool   `json:"failed_only,omitempty"`
}

type Mode

type Mode string
const (
	Daemon   Mode = "daemon"
	OnDemand Mode = "on-demand"
)

type Output

type Output struct {
	SchemaVersion int         `json:"schema_version"`
	Result        any         `json:"result,omitempty"`
	Error         *Diagnostic `json:"error,omitempty"`
}

type Page

type Page struct {
	Runs       []Run  `json:"runs"`
	NextCursor string `json:"next_cursor,omitempty"`
}

type Paths

type Paths struct {
	Config  string
	State   string
	Control string
}

func DefaultPaths

func DefaultPaths() (Paths, error)

type Personal

type Personal struct {
	Version     int                   `toml:"version"`
	Mode        Mode                  `toml:"mode"`
	APIPort     int                   `toml:"api_port"`
	StateDir    string                `toml:"state_dir"`
	Credentials map[string]Credential `toml:"credentials"`
	Retention   Retention             `toml:"retention"`
}

func ReadPersonal

func ReadPersonal(paths Paths) (Personal, error)

func (Personal) CommandEnvironment

func (p Personal) CommandEnvironment(c Command, public map[string]string) ([]string, []string, error)

type Policy

type Policy string
const (
	Parallel Policy = "parallel"
	Queue    Policy = "queue"
	Replace  Policy = "replace"
)

type Process

type Process struct {
	ScopeDir string    `json:"scope_dir,omitempty"`
	PID      int       `json:"pid"`
	Birth    string    `json:"birth"`
	Group    int       `json:"group"`
	Members  []Process `json:"members,omitempty"`
}

func ProcessIdentity

func ProcessIdentity(pid int) (Process, error)

type Project

type Project struct {
	Version  int                `toml:"version" json:"version"`
	DiffBase string             `toml:"diff_base" json:"diff_base,omitempty"`
	PrePush  PushPolicy         `toml:"pre_push" json:"pre_push"`
	Checks   map[string]Command `toml:"checks" json:"checks"`
}

func CommitConfig

func CommitConfig(ctx context.Context, path, sha string) (project Project, err error)

func ParseProject

func ParseProject(b []byte) (Project, error)

func ReadProject

func ReadProject(r io.Reader) (Project, error)

ReadProject bounds allocation before TOML parsing, including growing inputs.

func (Project) Order

func (p Project) Order() ([]string, error)

func (*Project) Validate

func (p *Project) Validate() error

type PruneResult

type PruneResult struct {
	DryRun      bool         `json:"dry_run"`
	RunIDs      []string     `json:"run_ids"`
	Bytes       int64        `json:"bytes"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

type PushPolicy

type PushPolicy string
const (
	PushBlock PushPolicy = "block"
	PushWait  PushPolicy = "wait"
	PushRun   PushPolicy = "run-and-wait"
)

type Receipt

type Receipt struct {
	RunID         string      `json:"run_id"`
	Commit        string      `json:"commit"`
	State         State       `json:"state"`
	StatusCommand string      `json:"status_command"`
	WaitCommand   string      `json:"wait_command"`
	MCP           string      `json:"mcp"`
	Guide         string      `json:"guide"`
	URL           string      `json:"url,omitempty"`
	UICommand     string      `json:"ui_command,omitempty"`
	Diagnostic    *Diagnostic `json:"diagnostic,omitempty"`
}

type Redactor

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

Redactor holds enough suffix bytes to recognize a secret split between writes. Nothing from the held suffix reaches disk until it is known to be safe.

func NewRedactor

func NewRedactor(w io.Writer, secrets []string) *Redactor

func (*Redactor) Close

func (r *Redactor) Close() error

func (*Redactor) Write

func (r *Redactor) Write(b []byte) (int, error)

type Report

type Report struct {
	Kind ReportKind `toml:"kind" json:"kind"`
	Path string     `toml:"path" json:"path"`
}

type ReportKind

type ReportKind string
const (
	JUnit  ReportKind = "junit"
	GoTest ReportKind = "go-test-json"
)

type Repository

type Repository struct {
	ID        string     `json:"id"`
	CommonDir string     `json:"common_dir"`
	Name      string     `json:"name"`
	Worktrees []Worktree `json:"worktrees"`
}

type Retention

type Retention struct {
	MaxAgeDays int   `toml:"max_age_days" json:"max_age_days"`
	MaxBytes   int64 `toml:"max_bytes" json:"max_bytes"`
}

type Run

type Run struct {
	SchemaVersion  int               `json:"schema_version"`
	ID             string            `json:"id"`
	Sequence       int64             `json:"sequence"`
	RepositoryID   string            `json:"repository_id"`
	WorktreeID     string            `json:"worktree_id"`
	Source         string            `json:"source"`
	Branch         string            `json:"branch"`
	Commit         string            `json:"commit"`
	State          State             `json:"state"`
	Config         Project           `json:"config"`
	Environment    map[string]string `json:"environment"`
	Fingerprint    string            `json:"fingerprint"`
	OS             string            `json:"os"`
	Arch           string            `json:"arch"`
	CreatedAt      time.Time         `json:"created_at"`
	FinishedAt     *time.Time        `json:"finished_at,omitempty"`
	AcknowledgedAt *time.Time        `json:"acknowledged_at,omitempty"`
	ParentID       string            `json:"parent_id,omitempty"`
	Checks         []Check           `json:"checks"`
	Diagnostics    []Diagnostic      `json:"diagnostics"`
}

type Service

type Service struct {
	Store    *Store
	Personal Personal
	Paths    Paths
	Log      *slog.Logger
}

func Open

func Open(paths Paths) (*Service, error)

func (*Service) Active

func (s *Service) Active() ([]Component, error)

func (*Service) Agent

func (s *Service) Agent(client, scope, repo string, remove bool) (InstallResult, error)

func (*Service) ApplyUpdate

func (s *Service) ApplyUpdate() error

func (*Service) Close

func (s *Service) Close() error

func (*Service) Compare

func (s *Service) Compare(id, previous string) (Comparison, error)

func (*Service) Doctor

func (s *Service) Doctor(ctx context.Context, path string) []Diagnostic

func (*Service) Enter

func (s *Service) Enter(kind string) (Component, func(), error)

func (*Service) Gate

func (s *Service) Gate(ctx context.Context, path, commit string) (Gate, error)

func (*Service) GateRun

func (s *Service) GateRun(r Run) Gate

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves the immutable UI and local RPCs from one loopback origin. Local processes are trusted; browser isolation is enforced before dispatch.

func (*Service) Hook

func (s *Service) Hook(ctx context.Context, repo string, prePush, remove bool) ([]InstallResult, error)

func (*Service) Init

func (s *Service) Init(ctx context.Context, path string) (Repository, Worktree, error)

func (*Service) Logs

func (s *Service) Logs(run, check string, offset int64, limit int) (LogPage, error)

func (*Service) MCP

func (s *Service) MCP(ctx context.Context) error

func (*Service) Plan

func (s *Service) Plan(ctx context.Context, path, commit string) (Run, error)

func (*Service) PrePush

func (s *Service) PrePush(ctx context.Context, repo string, input io.Reader, override PushPolicy) ([]Gate, error)

func (*Service) Prune

func (s *Service) Prune(dry bool, age int, maxBytes int64) (PruneResult, error)

func (*Service) Receipt

func (s *Service) Receipt(r Run) Receipt

func (*Service) RecoverUpdate

func (s *Service) RecoverUpdate() (map[string]string, error)

func (*Service) Report

func (s *Service) Report(run, id string, offset int64, limit int) (LogPage, error)

func (*Service) RepositoryID

func (s *Service) RepositoryID(ctx context.Context, path string) (string, error)

func (*Service) Rerun

func (s *Service) Rerun(id string, failedOnly bool) (Receipt, error)

func (*Service) RunOne

func (s *Service) RunOne(id string) error

func (*Service) SaveEvidence

func (s *Service) SaveEvidence(run, name string, b []byte) (Evidence, error)

func (*Service) SelfUpdate

func (s *Service) SelfUpdate(ctx context.Context, version string) (map[string]string, error)

func (*Service) Serve

func (s *Service) Serve(ctx context.Context, daemon bool, ready func()) error

func (*Service) Start

func (s *Service) Start(mode Mode) error

func (*Service) Stop

func (s *Service) Stop(force bool) error

func (*Service) Submit

func (s *Service) Submit(ctx context.Context, path, commit string, automatic bool) (Receipt, error)

func (*Service) ValidateEvidence

func (s *Service) ValidateEvidence(run string, c Check) error

func (*Service) Wait

func (s *Service) Wait(ctx context.Context, id string) (Run, error)

func (*Service) WebURL

func (s *Service) WebURL(run string) string

func (*Service) Work

func (s *Service) Work(ctx context.Context, persistent bool, component string) error

func (*Service) Worker

func (s *Service) Worker(ctx context.Context) error

type Shell

type Shell string
const (
	Sh         Shell = "sh"
	Bash       Shell = "bash"
	PowerShell Shell = "powershell"
	Pwsh       Shell = "pwsh"
)

type State

type State string
const (
	Queued      State = "queued"
	Preparing   State = "preparing"
	Running     State = "running"
	Collecting  State = "collecting"
	Passed      State = "passed"
	Failed      State = "failed"
	Blocked     State = "blocked"
	Cancelled   State = "cancelled"
	Replaced    State = "replaced"
	Interrupted State = "interrupted"
	Skipped     State = "skipped"
	Expired     State = "expired"
)

func (State) Terminal

func (s State) Terminal() bool

type Store

type Store struct {
	DB   *sql.DB
	Root string
}

func OpenStore

func OpenStore(root string) (*Store, error)

func (*Store) Ack

func (s *Store) Ack(id string) error

func (*Store) Cancel

func (s *Store) Cancel(id string, reason State) error

func (*Store) Cancellation

func (s *Store) Cancellation(check string) State

func (*Store) Close

func (s *Store) Close() error

func (*Store) EvidencePath

func (s *Store) EvidencePath(run, id string) (string, error)

func (*Store) InsertRun

func (s *Store) InsertRun(r *Run, auto string) (string, error)

func (*Store) List

func (s *Store) List(repo string, inbox bool, cursor string, limit int) (Page, error)

func (*Store) ListFiltered

func (s *Store) ListFiltered(repo, worktree, branch string, detached, inbox bool, cursor string, limit int) (Page, error)

func (*Store) Pending

func (s *Store) Pending() ([]string, error)

func (*Store) Prepare

func (s *Store) Prepare(ctx context.Context, r Run) (string, error)

func (*Store) Register

func (s *Store) Register(common, path, branch string) (Repository, Worktree, error)

func (*Store) Registered

func (s *Store) Registered(common, path string) (Repository, Worktree, error)

func (*Store) Repositories

func (s *Store) Repositories() ([]Repository, error)

func (*Store) RepositoryPage

func (s *Store) RepositoryPage(ctx context.Context, cursor string, limit int) ([]Repository, string, error)

RepositoryPage bounds worktrees, not just repositories: one repository can have many linked worktrees and must not make a single response unbounded.

func (*Store) Run

func (s *Store) Run(id string) (Run, error)

func (*Store) SaveCheck

func (s *Store) SaveCheck(c Check) error

func (*Store) SaveRun

func (s *Store) SaveRun(r Run) error

func (*Store) Transaction

func (s *Store) Transaction(fn func(*sql.Tx) error) error

type UpdateJournal

type UpdateJournal struct {
	Executable     string  `json:"executable"`
	Candidate      string  `json:"candidate"`
	Backup         string  `json:"backup"`
	StateBackup    string  `json:"state_backup"`
	SHA256         string  `json:"sha256"`
	OriginalSHA256 string  `json:"original_sha256"`
	Phase          string  `json:"phase"`
	Parent         Process `json:"parent"`
}

type Worktree

type Worktree struct {
	ID           string `json:"id"`
	RepositoryID string `json:"repository_id"`
	Path         string `json:"path"`
	Branch       string `json:"branch"`
	Available    bool   `json:"available"`
}

Jump to

Keyboard shortcuts

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