ref

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ref looks up which task a lookaround command is about, one cascade for every noun: an explicit id, then the branch name, then this session's run state. Without a prefix from facts only an explicit reference is taken, since no rule can tell a task number in a branch name from any other number.

Index

Constants

View Source
const (
	FinishQueued  = "queued"
	FinishRunning = "running"
)

The states a DriveFinish records.

View Source
const (
	OriginExplicit = "explicit"
	OriginBranch   = "branch"
	OriginSession  = "session"
)

Where a looked-up reference came from, so an error or a caller can name it.

View Source
const (
	AfterKey       = "f10-after"
	AfterBranchKey = "f10-after-branch"
	LandedKey      = "f10-landed"
	MovedKey       = "f10-base-moved"
	TipKey         = "f10-base-tip"
)

What `f10 start --after` records beside TaskKey. Finish swaps the After keys for LandedKey so the next step brings the default branch in first; MovedKey is drive's note that the base's head moved past the dependent, for the next catchup, which clears both. TipKey is the base commit the dependent was last built on: a catchup rebases onto from it once the base's history is rewritten (squash-merged or rebased).

View Source
const (
	ModelKey = "f10-model"
	AgentKey = "f10-agent"
)

ModelKey is the model older starts recorded; AgentKey is the whole profile (kind:model:effort) a start or drive gave the branch's agent, read back on a rerun. Both absent for the kind's default.

View Source
const FinishKey = "f10-finish"

FinishKey is `f10 drive`'s record, beside TaskKey, of where its finish of the branch stands. Whether the drive still runs is its task's lease, never this record: finish removes it with the branch, drive clears it on any end.

View Source
const RidersKey = "f10-tasks"

RidersKey is the key, beside TaskKey, that lists a bundle's riders, space-separated: the tasks one branch ships beside its lead.

View Source
const Separator = "+"

Separator joins a bundle's ids, `ABC-1+ABC-2`, lead first.

View Source
const TaskKey = "f10-task"

TaskKey is the local config key under `branch.<name>.` linking a branch to its task: a branch picked up from a PR need not carry the id in its name, and a bundle's branch links its lead.

Variables

View Source
var ErrNoReference = errors.New("no task reference given")

ErrNoReference means the cascade ran out. It is wrapped with what each tier had to offer: "none found" alone sends a reader to the wrong tier, most often a session tier a human's prompt never had.

Functions

func Match added in v0.33.0

func Match(prefix, text string) string

Match is the task id in text (a branch name, a PR title, a commit subject), anchored on a non-word boundary rather than the start since the id sits in any position and case (`feature/abc-123-fix-bug`).

func Matcher added in v0.40.0

func Matcher(prefix string) func(text string) string

Matcher is Match with the pattern compiled once, for a caller matching many texts against one prefix.

func Members added in v0.36.0

func Members(prefix, branch string) []string

Members is the bundle a branch name spells in its first segment, `ABC-1+ABC-2/slug`, lead first, or nil for a name that spells none.

func SplitSuffix

func SplitSuffix(token string) (string, string)

SplitSuffix separates a salted reference into the reference and its suffix. A token without one, or a url, comes back whole with "".

Types

type DriveFinish added in v0.45.0

type DriveFinish struct {
	State  string // FinishQueued or FinishRunning
	Action string // "" for none
}

A DriveFinish is FinishKey's value.

func ParseDriveFinish added in v0.45.0

func ParseDriveFinish(s string) (DriveFinish, bool)

ParseDriveFinish reads FinishKey's value; false for one that is empty or malformed. A leading pid, as an older drive wrote, is skipped.

func (DriveFinish) Format added in v0.45.0

func (d DriveFinish) Format() string

Format is the value FinishKey holds: `queued`, `running: merging #204`.

func (DriveFinish) Running added in v0.45.0

func (d DriveFinish) Running() bool

Running reports finish itself at work, not queued behind ship or a base.

type Lookup added in v0.26.0

type Lookup struct {
	Prefix string // id prefix from facts ("ABC", "GH"); empty where nothing declares or implies one
	Dir    string // checkout root - the branch is read from here
	// NoSession stops the cascade at the branch: a commit's trailer names the
	// branch's task or none, never one this session happens to have recorded
	NoSession bool
}

A Lookup answers references for one checkout.

func (Lookup) Find added in v0.26.0

func (r Lookup) Find(ctx context.Context, explicit string) (Ref, error)

Find walks the cascade. An explicit reference that does not parse is an error, not a fallthrough, since a typo'd id should say so instead of opening whatever the branch names; any bundle member comes back with the whole bundle, so reading a rider reads the rider and Head finds the branch.

type Ref

type Ref struct {
	ID     string // "GH-22": the prefix and number in the project's format
	Number string // "22": what a host CLI wants
	Origin string
	// Bundle is the bundle's every id, lead first; nil for a task shipping alone
	Bundle []string
}

A Ref is one looked-up task reference.

func (Ref) Head added in v0.36.0

func (r Ref) Head() Ref

Head is the reference a branch is looked up by: the bundle's lead, or the task itself. Plan, agent, run state and ledger all key on it.

func (Ref) Label added in v0.36.0

func (r Ref) Label() string

Label is the reference as typed at an entry point: `ABC-1+ABC-2`, or the id.

func (Ref) MemberRefs added in v0.36.0

func (r Ref) MemberRefs() []Ref

MemberRefs is every member as a reference of its own, the lead first.

func (Ref) Members added in v0.36.0

func (r Ref) Members() []string

Members is every id the reference ships: the bundle, or the task alone.

func (Ref) Riders added in v0.36.0

func (r Ref) Riders() []string

Riders is the bundle's ids after its lead, or nil.

Jump to

Keyboard shortcuts

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