Documentation
¶
Index ¶
- Constants
- Variables
- func ForgeFailureCause(err error) string
- func GenerateName(taken func(string) bool) string
- func NewForgeFailure(kind error, cause string, err error) error
- func NormalizeRepoKey(remote string) (string, error)
- func ParseUntrackedStatusV2(output []byte) ([]string, error)
- func ReclamationEligible(branch, recordedNamespace string, createdBranch bool) bool
- func RunBranchName(namespace, taskSlug, runID string) string
- func RunWorktreeName(taskSlug, runID string) string
- func SanitizeName(value string) string
- type AgentActivity
- type BranchOutcome
- type CapabilityDiagnostic
- type CapabilityGate
- type CatalogEvent
- type CatalogEventKind
- type CreateOptions
- type DerivedNames
- type DetailedListing
- type DiscoveredWorktree
- type EventSink
- type ExitAction
- type ExitActionPlan
- type ExitActionRequest
- type ExitActionResult
- type ExitCTA
- type ExitCleanupEvidence
- type ExitCommitScope
- type ExitEventPayload
- type ExitOperation
- type ExitPRPrefill
- type ExitPhase
- type ExitPlan
- type ExitStepResult
- type ExitTerminalEventSink
- type ForgeCapabilities
- type ForgeChecks
- type ForgeFailure
- type ForgePRRequest
- type ForgePRResult
- type ForgeProvider
- type ForgeStatus
- type ForgeStatusRequest
- type GitIndexRunner
- type GitInputRunner
- type GitOutput
- type GitOutputHandler
- type GitOutputStream
- type GitRunner
- type GitStatus
- type GitTimeoutRunner
- type GitWorktree
- type HookDispatcher
- type HookPreRemovePayload
- type HookRequest
- type HookVerdict
- type HookWorktree
- type Inspection
- type LifecycleEvent
- type Listing
- type ManagedDeliverySessions
- type Numstat
- type Option
- func WithCapabilityGate(gate *CapabilityGate) Option
- func WithClock(now func() time.Time) Option
- func WithConfig(value config.WorktreesConfig, resolvedRoot string) Option
- func WithEvents(sink EventSink) Option
- func WithForge(provider ForgeProvider) Option
- func WithHooks(dispatcher HookDispatcher) Option
- func WithIDGenerator(generator func(string) (string, error)) Option
- func WithLogger(logger *slog.Logger) Option
- func WithManagedDeliverySessions(guard ManagedDeliverySessions) Option
- func WithPullRequests(service *PullRequestService) Option
- func WithRepositoryLocks(locks *RepositoryLocks) Option
- func WithSessionGuard(guard SessionGuard) Option
- func WithWorkspaceResolver(resolver WorkspaceResolver) Option
- type Origin
- type ParseError
- type PendingPhase
- type PendingUpdate
- type PullRequestEntry
- type PullRequestKey
- type PullRequestService
- func (s *PullRequestService) Close()
- func (s *PullRequestService) DefaultBranchNames(ctx context.Context, root string) []string
- func (s *PullRequestService) IsDefaultBranch(ctx context.Context, root, branch string) bool
- func (s *PullRequestService) Read(ctx context.Context, keys []PullRequestKey) map[PullRequestKey]PullRequestEntry
- func (s *PullRequestService) Refresh(ctx context.Context, key PullRequestKey) (PullRequestEntry, error)
- func (s *PullRequestService) RepoKey(ctx context.Context, root string) (string, error)
- func (s *PullRequestService) RequestRefresh(key PullRequestKey)
- type PullRequestStore
- type RealGitRunner
- func (r *RealGitRunner) Run(ctx context.Context, dir string, args ...string) ([]byte, []byte, error)
- func (r *RealGitRunner) RunStreaming(ctx context.Context, dir string, onOutput GitOutputHandler, args ...string) ([]byte, []byte, error)
- func (r *RealGitRunner) RunWithIndex(ctx context.Context, dir, index string, args ...string) ([]byte, []byte, error)
- func (r *RealGitRunner) RunWithInput(ctx context.Context, dir, input string, args ...string) ([]byte, []byte, error)
- func (r *RealGitRunner) RunWithTimeout(ctx context.Context, dir string, timeout time.Duration, args ...string) ([]byte, []byte, error)
- type ReclaimOutcome
- type RefusalError
- type RemovalRefusal
- type RemovalRisk
- type RemoveDiscoveredOptions
- type RepoState
- type RepositoryLocks
- type RunWorktreeRequest
- type Service
- func (s *Service) AcquireBindingUsage(ctx context.Context, workspaceID, ref string) (*Worktree, func(), error)
- func (s *Service) AcquireUsage(ctx context.Context, workspaceID string, ref string) (*Worktree, func(), error)
- func (s *Service) Adopt(ctx context.Context, profileID, workspaceID, candidatePath string) (*Worktree, error)
- func (s *Service) CancelCreate(ctx context.Context, workspaceID, ref string) error
- func (s *Service) CancelExitAction(ctx context.Context, workspaceID, ref, opID string) error
- func (s *Service) Capability(ctx context.Context) (CapabilityDiagnostic, error)
- func (s *Service) Close()
- func (s *Service) CommitsAheadOf(ctx context.Context, workspaceID, worktreeID, base string) (int, error)
- func (s *Service) Create(ctx context.Context, workspaceID string, options CreateOptions) (*Worktree, error)
- func (s *Service) CreateAccepted(ctx context.Context, workspaceID string, options CreateOptions) (*Worktree, error)
- func (s *Service) CreateReady(ctx context.Context, workspaceID string, options CreateOptions) (*Worktree, error)
- func (s *Service) DeleteLocalBranch(ctx context.Context, workspaceID string, id string, force bool) (BranchOutcome, error)
- func (s *Service) Dismiss(ctx context.Context, workspaceID, id string) error
- func (s *Service) ExitPlan(ctx context.Context, workspaceID, id string) (*ExitPlan, error)
- func (s *Service) ExitPlanForPaths(ctx context.Context, workspaceID, ref string, paths []string) (*ExitPlan, error)
- func (s *Service) Get(ctx context.Context, workspaceID, ref string) (*Worktree, error)
- func (s *Service) Inspect(ctx context.Context, workspaceID, ref string) (*Inspection, error)
- func (s *Service) List(ctx context.Context, workspaceID string, refresh bool) (*Listing, error)
- func (s *Service) ListAggregate(ctx context.Context, scope store.ReadScope) (*DetailedListing, error)
- func (s *Service) ListDetails(ctx context.Context, workspaceID string, refresh bool) (*DetailedListing, error)
- func (s *Service) MaterializeForRun(ctx context.Context, workspaceID string, request RunWorktreeRequest) (*Worktree, error)
- func (s *Service) ObserveForgeStatus(ctx context.Context, workspaceID, id string) (*ForgeStatus, error)
- func (s *Service) PrepareExitPlan(ctx context.Context, workspaceID, id string) (*ExitPlan, error)
- func (s *Service) Reconfigure(value config.WorktreesConfig, resolvedRoot string)
- func (s *Service) RecoverCreations(ctx context.Context) error
- func (s *Service) RecoverManagedDeliveries(ctx context.Context) error
- func (s *Service) Remove(ctx context.Context, workspaceID string, id string, force bool) (*RemovalRefusal, error)
- func (s *Service) RemoveDiscovered(ctx context.Context, workspaceID string, path string, ...) (*RemovalRefusal, error)
- func (s *Service) Resolve(ctx context.Context, workspaceID, ref string) (*Worktree, error)
- func (s *Service) ResolveCommit(ctx context.Context, path, ref string) (string, error)
- func (s *Service) RollbackRunMaterialization(ctx context.Context, workspaceID string, worktreeID string, runID string) error
- func (s *Service) RunExitAction(ctx context.Context, workspaceID string, id string, request ExitActionRequest) (string, error)
- func (s *Service) Status(ctx context.Context, workspaceID, id string, refresh bool) (*Status, error)
- func (s *Service) StatusDetails(ctx context.Context, workspaceID, id string, refresh, refreshForge bool) (*StatusDetails, error)
- func (s *Service) SubmitManagedDelivery(ctx context.Context, workspaceID, ref, sessionID string, ...) (string, error)
- func (s *Service) SubscribeWorktreeCatalogEvents(ctx context.Context) (<-chan CatalogEvent, func(), error)
- func (s *Service) VerifyReviewCandidate(ctx context.Context, workspaceID, worktreeID string, paths []string, ...) (bool, error)
- type SessionGuard
- type SetupState
- type State
- type Status
- type StatusDetails
- type Store
- type StreamingGitRunner
- type Workspace
- type WorkspaceResolver
- type Worktree
Constants ¶
const ( BranchKeptNoBranch = "no_branch" BranchKeptAbsent = "branch_absent" BranchKeptCheckoutPresent = "checkout_present" BranchKeptRootCheckout = "root_checkout_branch" BranchKeptDefaultBranch = "default_branch" BranchKeptRegistrationPresent = "registration_present" BranchKeptCheckedOutElsewhere = "checked_out_elsewhere" BranchKeptNotFullyMerged = "not_fully_merged" BranchKeptDeleteFailed = "delete_failed" )
Branch outcome reasons explain why an opted-in local branch deletion kept the branch.
const ( EventPreCreate = "worktree.pre_create" EventPreRemove = "worktree.pre_remove" EventCreated = "worktree.created" EventAdopted = "worktree.adopted" EventRemoved = "worktree.removed" EventMissing = "worktree.missing" EventDismissed = "worktree.dismissed" EventCreationCanceled = "worktree.creation_canceled" EventCreationFailed = "worktree.creation_failed" EventSetupFailed = "worktree.setup_failed" EventStatusRefreshed = "worktree.status_refreshed" EventBranchReclaimed = "worktree.branch_reclaimed" EventExitActionStarted = "worktree.exit_action_started" EventExitActionStep = "worktree.exit_action_step" EventExitHookOutput = "worktree.exit_hook_output" EventExitActionCompleted = "worktree.exit_action_completed" EventExitActionFailed = "worktree.exit_action_failed" EventExitActionCanceled = "worktree.exit_action_canceled" )
const ( EventTeardownOutput = "worktree.teardown_output" EventTeardownFailed = "worktree.teardown_failed" )
Variables ¶
var ( ErrGitVersionUnsupported = errors.New("worktree_git_version_unsupported") ErrWorkspaceNotGitBacked = errors.New("workspace_not_git_backed") ErrNameTaken = errors.New("worktree_name_taken") ErrPathExists = errors.New("worktree_path_exists") ErrBranchHeld = errors.New("branch_held_by_worktree") ErrBranchCheckedOutAtRoot = errors.New("branch_checked_out_at_root") ErrBaseRefNotFound = errors.New("base_ref_not_found") ErrRepoHasNoCommits = errors.New("repo_has_no_commits") ErrNotFound = errors.New("worktree_not_found") ErrNotReady = errors.New("worktree_not_ready") ErrPending = errors.New("worktree_pending") ErrMissing = errors.New("worktree_missing") ErrRefInvalid = errors.New("worktree_ref_invalid") ErrAdoptionMainCheckout = errors.New("adoption_main_checkout") ErrAdoptionForeignRepo = errors.New("adoption_foreign_repository") ErrAdoptionUnreadable = errors.New("adoption_unreadable") ErrDiscoveredRegistered = errors.New("worktree_registered") ErrDiscoveredChanged = errors.New("worktree_discovered_changed") ErrOperationInProgress = errors.New("worktree_operation_in_progress") ErrSessionActive = errors.New("worktree_session_active") ErrStatusUnreadable = errors.New("worktree_status_unreadable") ErrDirtyRequiresForce = errors.New("worktree_dirty_requires_force") ErrUnpushedRequiresForce = errors.New("worktree_unpushed_requires_force") ErrSafetyCheckFailed = errors.New("worktree_safety_check_failed") ErrRemovalFailed = errors.New("worktree_removal_failed") // ErrCheckoutOrphaned names a checkout directory whose .git link is gone // while Git still registers it, usually after an interrupted removal. ErrCheckoutOrphaned = errors.New("worktree_checkout_orphaned") ErrPerRunMaterialization = errors.New("per_run_materialization_failed") ErrConfigInvalid = errors.New("worktree_config_invalid") ErrDeniedByHook = errors.New("worktree_denied_by_hook") ErrNotPending = errors.New("worktree_not_pending") ErrForge = errors.New("forge_error") ErrExitActionInvalid = errors.New("worktree_exit_action_invalid") )
Functions ¶
func ForgeFailureCause ¶
func GenerateName ¶
func NormalizeRepoKey ¶
NormalizeRepoKey strips transport and credentials; identity never contains secrets.
func ParseUntrackedStatusV2 ¶
ParseUntrackedStatusV2 returns the exact untracked additions from a porcelain-v2 snapshot. Ignored records are deliberately absent from the result.
func ReclamationEligible ¶
func RunBranchName ¶
func RunWorktreeName ¶
RunWorktreeName returns the readable per-run name without its branch namespace.
func SanitizeName ¶
Types ¶
type AgentActivity ¶
type AgentActivity string
const ( AgentActivityIdle AgentActivity = "idle" AgentActivityRunning AgentActivity = "running" )
type BranchOutcome ¶
BranchOutcome reports an opt-in local branch deletion that followed a cleanup. Kept branches carry a stable Reason; Detail holds bounded Git diagnostics.
type CapabilityDiagnostic ¶
type CapabilityGate ¶
type CapabilityGate struct {
// contains filtered or unexported fields
}
func NewCapabilityGate ¶
func NewCapabilityGate(runner GitRunner) *CapabilityGate
func NewCapabilityGateWithLookPath ¶
func NewCapabilityGateWithLookPath(runner GitRunner, lookPath func(string) (string, error)) *CapabilityGate
func (*CapabilityGate) Check ¶
func (g *CapabilityGate) Check(ctx context.Context) (CapabilityDiagnostic, error)
type CatalogEvent ¶
type CatalogEvent struct {
Kind CatalogEventKind
WorkspaceID string
WorktreeID string
Error string
}
type CatalogEventKind ¶
type CatalogEventKind string
const ( CatalogEventUpserted CatalogEventKind = "upserted" CatalogEventDeleted CatalogEventKind = "deleted" CatalogEventFailed CatalogEventKind = "failed" )
type CreateOptions ¶
type DerivedNames ¶
func DeriveNames ¶
func DeriveNames(value string) DerivedNames
type DetailedListing ¶
type DetailedListing struct {
Worktrees []Inspection
Discovered []DiscoveredWorktree
Repo RepoState
}
type DiscoveredWorktree ¶
type EventSink ¶
type EventSink interface {
PublishWorktreeEvent(context.Context, LifecycleEvent) error
}
type ExitAction ¶
type ExitAction string
const ( ExitActionDeliver ExitAction = "deliver" ExitActionCommit ExitAction = "commit" ExitActionCommitPush ExitAction = "commit_push" ExitActionPush ExitAction = "push" ExitActionOpenPR ExitAction = "open_pr" ExitActionViewPR ExitAction = "view_pr" )
type ExitActionPlan ¶
type ExitActionRequest ¶
type ExitActionRequest struct {
DeliveryID string `json:"delivery_id,omitempty"`
ExpectedHead string `json:"expected_head,omitempty"`
IncludePaths []string `json:"include_paths,omitempty"`
ExpectedScope string `json:"expected_scope,omitempty"`
Action ExitAction `json:"action"`
Message string `json:"message,omitempty"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Draft bool `json:"draft,omitzero"`
Base string `json:"base,omitempty"`
}
type ExitActionResult ¶
type ExitActionResult struct {
OperationID string `json:"op_id"`
Action ExitAction `json:"action"`
Steps []ExitStepResult `json:"steps"`
CTA *ExitCTA `json:"cta,omitzero"`
}
type ExitCTA ¶
type ExitCTA struct {
Action ExitAction `json:"action"`
Label string `json:"label"`
URL string `json:"url,omitempty"`
}
type ExitCleanupEvidence ¶
type ExitCleanupEvidence struct {
ForgeState string `json:"forge_state,omitempty"`
Stale bool `json:"stale,omitzero"`
Safe bool `json:"safe"`
Source string `json:"source,omitempty"`
Summary string `json:"summary,omitempty"`
Blocker string `json:"blocker,omitempty"`
Downgraded bool `json:"downgraded,omitzero"`
}
type ExitCommitScope ¶
type ExitCommitScope struct {
IncludePaths []string `json:"include_paths,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Complete bool `json:"complete,omitzero"`
ChangedFiles int `json:"changed_files"`
Insertions int `json:"insertions"`
Deletions int `json:"deletions"`
UntrackedFiles []string `json:"untracked_files"`
UntrackedTotal int `json:"untracked_total"`
UntrackedTruncated bool `json:"untracked_truncated,omitzero"`
}
type ExitEventPayload ¶
type ExitEventPayload struct {
CommitScope *ExitCommitScope `json:"commit_scope,omitzero"`
OperationID string `json:"op_id"`
Action ExitAction `json:"action"`
Phases []ExitPhase `json:"phases,omitempty"`
Phase ExitPhase `json:"phase,omitempty"`
State string `json:"state,omitempty"`
Result *ExitActionResult `json:"result,omitzero"`
Message string `json:"message,omitempty"`
Cause string `json:"cause,omitempty"`
Stream string `json:"stream,omitempty"`
Chunk string `json:"chunk,omitempty"`
}
type ExitOperation ¶
type ExitPRPrefill ¶
type ExitPlan ¶
type ExitPlan struct {
WorktreeID string `json:"worktree_id"`
Primary ExitAction `json:"primary,omitempty"`
Actions []ExitActionPlan `json:"actions"`
GlobalPauseCause string `json:"global_pause_cause,omitempty"`
CommitScope ExitCommitScope `json:"commit_scope"`
BrowserURL string `json:"browser_url,omitempty"`
Forge *ForgeCapabilities `json:"forge,omitzero"`
ForgeStatus *ForgeStatus `json:"forge_status,omitzero"`
PRPrefill *ExitPRPrefill `json:"pr_prefill,omitzero"`
Cleanup ExitCleanupEvidence `json:"cleanup"`
Base string `json:"base,omitempty"`
RemoteURLs []string `json:"remote_urls,omitempty"`
}
type ExitStepResult ¶
type ExitStepResult struct {
IncludePaths []string `json:"include_paths,omitempty"`
Phase ExitPhase `json:"phase"`
State string `json:"state"`
Reason string `json:"reason,omitempty"`
Output string `json:"output,omitempty"`
SHA string `json:"sha,omitempty"`
Upstream string `json:"upstream,omitempty"`
PRStatus string `json:"pr_status,omitempty"`
PRNumber int `json:"pr_number,omitzero"`
URL string `json:"url,omitempty"`
}
type ExitTerminalEventSink ¶
type ExitTerminalEventSink interface {
FinishExitOperationWithEvent(
context.Context,
string,
string,
string,
string,
time.Time,
LifecycleEvent,
) (bool, error)
}
ExitTerminalEventSink commits an exit operation's terminal state and replay event together. The production store implements this boundary transactionally.
type ForgeCapabilities ¶
type ForgeChecks ¶
type ForgeFailure ¶
func (*ForgeFailure) Error ¶
func (e *ForgeFailure) Error() string
func (*ForgeFailure) Unwrap ¶
func (e *ForgeFailure) Unwrap() []error
type ForgePRRequest ¶
type ForgePRResult ¶
type ForgeProvider ¶
type ForgeProvider interface {
Capabilities(context.Context, []string) (*ForgeCapabilities, error)
Status(context.Context, ForgeStatusRequest) (*ForgeStatus, error)
CreatePR(context.Context, ForgePRRequest) (*ForgePRResult, error)
}
type ForgeStatus ¶
type ForgeStatusRequest ¶
type GitIndexRunner ¶
type GitInputRunner ¶
type GitOutput ¶
type GitOutput struct {
Stream GitOutputStream
Chunk []byte
}
type GitOutputHandler ¶
type GitOutputHandler func(GitOutput)
type GitOutputStream ¶
type GitOutputStream string
const ( GitOutputStdout GitOutputStream = "stdout" GitOutputStderr GitOutputStream = "stderr" )
type GitStatus ¶
type GitStatus struct {
Branch string
Upstream string
HeadSHA string
Detached bool
DirtyFiles int
HasUpstream bool
Ahead *int
Behind *int
}
func ParseStatusV2 ¶
type GitTimeoutRunner ¶
type GitTimeoutRunner interface {
RunWithTimeout(context.Context, string, time.Duration, ...string) ([]byte, []byte, error)
}
GitTimeoutRunner runs one command under its own budget instead of the runner default, for operations whose duration scales with the checkout.
type GitWorktree ¶
type GitWorktree struct {
Path string
HeadSHA string
Branch string
Main bool
Detached bool
Bare bool
Locked bool
LockReason string
Prunable bool
PrunableReason string
}
func ParseWorktreeList ¶
func ParseWorktreeList(output []byte) ([]GitWorktree, error)
type HookDispatcher ¶
type HookDispatcher interface {
DispatchWorktreeHook(context.Context, HookRequest) (HookVerdict, error)
}
type HookPreRemovePayload ¶
type HookPreRemovePayload struct {
Worktree HookWorktree `json:"worktree"`
Force bool `json:"force"`
Risk RemovalRisk `json:"risk"`
Discovered bool `json:"discovered,omitempty"`
}
type HookRequest ¶
type HookVerdict ¶
type HookWorktree ¶
type HookWorktree struct {
ProfileID string `json:"profile_id,omitempty"`
WorktreeID string `json:"worktree_id"`
WorkspaceID string `json:"workspace_id"`
WorkspaceRoot string `json:"workspace_root,omitempty"`
Name string `json:"name"`
Branch string `json:"branch"`
Path string `json:"path"`
Origin Origin `json:"origin"`
RunID string `json:"run_id,omitempty"`
}
type Inspection ¶
type Inspection struct {
Worktree Worktree
Status *Status
ForgeStatus *ForgeStatus
Repo RepoState
AgentActivity AgentActivity
}
type LifecycleEvent ¶
type Listing ¶
type Listing struct {
Worktrees []Worktree
Discovered []DiscoveredWorktree
Repo RepoState
}
type ManagedDeliverySessions ¶
type ManagedDeliverySessions interface {
AcquireDeliveryFence(context.Context, string, string, string) (func(), error)
StopDeliverySession(context.Context, string) error
}
ManagedDeliverySessions is implemented by the runtime owner. The returned fence blocks new/resumed sessions until all Git and forge effects settle.
type Option ¶
type Option func(*Service)
func WithCapabilityGate ¶
func WithCapabilityGate(gate *CapabilityGate) Option
func WithConfig ¶
func WithConfig(value config.WorktreesConfig, resolvedRoot string) Option
func WithEvents ¶
func WithForge ¶
func WithForge(provider ForgeProvider) Option
func WithHooks ¶
func WithHooks(dispatcher HookDispatcher) Option
func WithLogger ¶
func WithManagedDeliverySessions ¶
func WithManagedDeliverySessions(guard ManagedDeliverySessions) Option
func WithPullRequests ¶
func WithPullRequests(service *PullRequestService) Option
func WithRepositoryLocks ¶
func WithRepositoryLocks(locks *RepositoryLocks) Option
func WithSessionGuard ¶
func WithSessionGuard(guard SessionGuard) Option
func WithWorkspaceResolver ¶
func WithWorkspaceResolver(resolver WorkspaceResolver) Option
type ParseError ¶
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type PendingPhase ¶
type PendingPhase string
const ( PhaseNone PendingPhase = "" PhaseBranch PendingPhase = "branch" PhaseCheckout PendingPhase = "checkout" PhaseCopy PendingPhase = "copy" PhaseSetup PendingPhase = "setup" )
type PendingUpdate ¶
type PullRequestEntry ¶
type PullRequestEntry struct {
Key PullRequestKey
Facts *ForgeStatus
LookupState, LookupCause string
AttemptAt, RetryAfter *time.Time
FailureCount int
Stale bool
}
type PullRequestKey ¶
type PullRequestKey struct{ WorkspaceID, RepoKey, Branch string }
type PullRequestService ¶
type PullRequestService struct {
// contains filtered or unexported fields
}
PullRequestService is the sole writer of canonical display observations. Exact delivery evidence never enters this cache.
func NewPullRequestService ¶
func NewPullRequestService( ctx context.Context, store PullRequestStore, forge ForgeProvider, runner GitRunner, changed func(string), ) *PullRequestService
func (*PullRequestService) Close ¶
func (s *PullRequestService) Close()
func (*PullRequestService) DefaultBranchNames ¶
func (s *PullRequestService) DefaultBranchNames(ctx context.Context, root string) []string
DefaultBranchNames shares the cached local origin HEAD with display filtering.
func (*PullRequestService) IsDefaultBranch ¶
func (s *PullRequestService) IsDefaultBranch(ctx context.Context, root, branch string) bool
IsDefaultBranch uses the local origin HEAD; absent metadata falls back to the conventional names. It never contacts the remote and caches each root briefly.
func (*PullRequestService) Read ¶
func (s *PullRequestService) Read(ctx context.Context, keys []PullRequestKey) map[PullRequestKey]PullRequestEntry
func (*PullRequestService) Refresh ¶
func (s *PullRequestService) Refresh(ctx context.Context, key PullRequestKey) (PullRequestEntry, error)
func (*PullRequestService) RequestRefresh ¶
func (s *PullRequestService) RequestRefresh(key PullRequestKey)
type PullRequestStore ¶
type PullRequestStore interface {
ReadPullRequests(context.Context, []PullRequestKey) (map[PullRequestKey]PullRequestEntry, error)
SavePullRequest(context.Context, PullRequestEntry) error
}
type RealGitRunner ¶
type RealGitRunner struct {
// contains filtered or unexported fields
}
func NewRealGitRunner ¶
func NewRealGitRunner(timeout time.Duration) (*RealGitRunner, error)
func (*RealGitRunner) RunStreaming ¶
func (r *RealGitRunner) RunStreaming( ctx context.Context, dir string, onOutput GitOutputHandler, args ...string, ) ([]byte, []byte, error)
func (*RealGitRunner) RunWithIndex ¶
func (*RealGitRunner) RunWithInput ¶
type ReclaimOutcome ¶
type RefusalError ¶
func (*RefusalError) Error ¶
func (e *RefusalError) Error() string
func (*RefusalError) Unwrap ¶
func (e *RefusalError) Unwrap() error
type RemovalRefusal ¶
type RemovalRefusal struct {
Code string
Risk RemovalRisk
Downgrade bool
}
type RemovalRisk ¶
type RemoveDiscoveredOptions ¶
type RemoveDiscoveredOptions struct {
// Force acknowledges dirty or unpushed loss on a live checkout.
Force bool
// ExpectStale freezes a confirmation that only clears a stale Git entry:
// a checkout that is live again is refused instead of removed.
ExpectStale bool
}
RemoveDiscoveredOptions carries the caller's acknowledgements for one target.
type RepositoryLocks ¶
type RepositoryLocks struct {
// contains filtered or unexported fields
}
func NewRepositoryLocks ¶
func NewRepositoryLocks(maxWaiters int) *RepositoryLocks
type RunWorktreeRequest ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AcquireBindingUsage ¶
func (s *Service) AcquireBindingUsage(ctx context.Context, workspaceID, ref string) (*Worktree, func(), error)
AcquireBindingUsage excludes checkout mutation during a session binding change. Unlike runtime usage, this also permits leaving a missing checkout.
func (*Service) AcquireUsage ¶
func (s *Service) AcquireUsage( ctx context.Context, workspaceID string, ref string, ) (*Worktree, func(), error)
AcquireUsage keeps a ready worktree available until the returned release function runs.
func (*Service) Adopt ¶
func (s *Service) Adopt(ctx context.Context, profileID, workspaceID, candidatePath string) (*Worktree, error)
Adopt validates a discovered checkout under the repository lock before registering it for this profile or restoring its existing missing record.
func (*Service) CancelCreate ¶
func (*Service) CancelExitAction ¶
func (*Service) Capability ¶
func (s *Service) Capability(ctx context.Context) (CapabilityDiagnostic, error)
Capability reports whether the Git dependency required by worktree mutations is ready.
func (*Service) CommitsAheadOf ¶
func (s *Service) CommitsAheadOf(ctx context.Context, workspaceID, worktreeID, base string) (int, error)
CommitsAheadOf fails closed: an unreadable base must never authorize cleanup.
func (*Service) CreateAccepted ¶
func (s *Service) CreateAccepted( ctx context.Context, workspaceID string, options CreateOptions, ) (*Worktree, error)
CreateAccepted durably inserts a pending worktree and continues materialization after the request ends. Callers observe phases through the catalog stream and canonical lifecycle events.
func (*Service) CreateReady ¶
func (s *Service) CreateReady( ctx context.Context, workspaceID string, options CreateOptions, ) (*Worktree, error)
CreateReady inserts a visible pending worktree, waits for materialization, and returns only after the worktree is ready for session binding.
func (*Service) DeleteLocalBranch ¶
func (s *Service) DeleteLocalBranch( ctx context.Context, workspaceID string, id string, force bool, ) (BranchOutcome, error)
DeleteLocalBranch deletes the recorded local branch of a removed or dismissed worktree. It refuses the root checkout's HEAD and default branches, never touches a path that reappeared, and uses Git's merged-only delete unless force is set. Refusals are outcomes; errors are reserved for unreadable state, and errors after the record is read still return the outcome with its branch name.
func (*Service) Dismiss ¶
Dismiss hides a missing, removed, or failed record while retaining its history. It excludes active use, fences concurrent state changes, and is repeat-safe; no filesystem or Git operation runs, even if the saved path has reappeared.
func (*Service) ExitPlanForPaths ¶
func (*Service) Inspect ¶
Inspect returns durable registry and cached derived state. It probes only repository capability; status, discovery, and forge reads remain cached.
func (*Service) List ¶
List combines registered and discovered checkouts, reconciling vanished ready rows without overwriting concurrent lifecycle changes or guessing on stat errors.
func (*Service) ListAggregate ¶
func (s *Service) ListAggregate(ctx context.Context, scope store.ReadScope) (*DetailedListing, error)
ListAggregate reads stored worktree state without invoking Git discovery or refresh.
func (*Service) ListDetails ¶
func (s *Service) ListDetails( ctx context.Context, workspaceID string, refresh bool, ) (*DetailedListing, error)
ListDetails returns the registry/discovery merge plus cached status, forge, and live activity. Git status is refreshed only when refresh is explicit.
func (*Service) MaterializeForRun ¶
func (*Service) ObserveForgeStatus ¶
func (s *Service) ObserveForgeStatus(ctx context.Context, workspaceID, id string) (*ForgeStatus, error)
ObserveForgeStatus reads fresh delivery evidence without consulting the display cache.
func (*Service) PrepareExitPlan ¶
PrepareExitPlan resolves provider capabilities only for an explicit delivery gesture.
func (*Service) Reconfigure ¶
func (s *Service) Reconfigure(value config.WorktreesConfig, resolvedRoot string)
Reconfigure applies global worktree settings to future operations. Existing registry rows retain their persisted paths and lifecycle state.
func (*Service) RecoverManagedDeliveries ¶
RecoverManagedDeliveries repairs receipts without replaying unknown or terminal intents.
func (*Service) RemoveDiscovered ¶
func (s *Service) RemoveDiscovered( ctx context.Context, workspaceID string, path string, options RemoveDiscoveredOptions, ) (*RemovalRefusal, error)
RemoveDiscovered deletes a linked worktree that Git lists but no registry row owns. Stale entries only lose their admin metadata. Live checkouts keep the dirty and unpushed refusals of registered removal, and branches stay untouched.
func (*Service) Resolve ¶
Resolve returns the canonical registry record for an ID-or-name reference without probing repository capability or derived status caches.
func (*Service) ResolveCommit ¶
ResolveCommit pins a ref using the service's configured Git runner and repository lock.
func (*Service) RollbackRunMaterialization ¶
func (s *Service) RollbackRunMaterialization( ctx context.Context, workspaceID string, worktreeID string, runID string, ) error
RollbackRunMaterialization removes the exact per-run worktree produced for a session that could not be bound under its active task-run lease.
func (*Service) RunExitAction ¶
func (*Service) StatusDetails ¶
func (*Service) SubmitManagedDelivery ¶
func (s *Service) SubmitManagedDelivery( ctx context.Context, workspaceID, ref, sessionID string, request ExitActionRequest, ) (string, error)
SubmitManagedDelivery accepts an idempotent daemon-owned handoff. sessionID must come from validated transport identity, never from the request body.
func (*Service) SubscribeWorktreeCatalogEvents ¶
func (s *Service) SubscribeWorktreeCatalogEvents( ctx context.Context, ) (<-chan CatalogEvent, func(), error)
type SessionGuard ¶
type SetupState ¶
type SetupState string
const ( SetupNone SetupState = "none" SetupOK SetupState = "ok" SetupFailed SetupState = "failed" )
type Status ¶
type StatusDetails ¶
type StatusDetails struct {
WorktreeID string
Status *Status
ForgeStatus *ForgeStatus
}
type Store ¶
type Store interface {
RemoveMissing(context.Context, string, string, time.Time) (bool, error)
Insert(context.Context, Worktree) error
Get(context.Context, string, string) (*Worktree, error)
GetByPath(context.Context, string, string) (*Worktree, error)
// PathOwnedByAnyWorkspace reports whether a live record in any workspace owns the path.
PathOwnedByAnyWorkspace(context.Context, string) (bool, error)
List(context.Context, string) ([]Worktree, error)
ListRecoverable(context.Context) ([]Worktree, error)
DeletePending(context.Context, string, string) error
DeleteRunMaterialization(context.Context, string, string, string) error
UpdatePending(context.Context, string, string, PendingUpdate) error
CompleteCreate(context.Context, string, string, SetupState, string, time.Time) error
// FailCreate moves a pending row to failed and records the creation cause
// and, when its rollback is incomplete, the rollback error.
FailCreate(context.Context, string, string, string, string, time.Time) error
// CompleteFailedCreateRollback clears a failed row's incomplete rollback.
CompleteFailedCreateRollback(context.Context, string, string, time.Time) error
CompareAndSwapState(context.Context, string, string, State, State, time.Time) (bool, error)
SetState(context.Context, string, string, State, time.Time) error
SaveStatus(context.Context, string, string, Status) error
GetStatus(context.Context, string, string) (*Status, error)
InsertExitOperation(context.Context, ExitOperation) error
FinishExitOperation(context.Context, string, string, string, string, time.Time) (bool, error)
ListRunningExitOperations(context.Context) ([]ExitOperation, error)
FailRunningExitOperations(context.Context, time.Time) error
}
Store owns workspace-predicated persistence for the worktree domain.
type StreamingGitRunner ¶
type WorkspaceResolver ¶
type Worktree ¶
type Worktree struct {
ID string
ProfileID string
ProfileName string
ProfileColor string
ProfileIcon string
ProfileEmoji string
ProfileArchived bool
WorkspaceID string
Name string
Branch string
Path string
GitDir string
State State
PendingPhase PendingPhase
Origin Origin
SetupState SetupState
SetupError string
// CreateError keeps the redacted cause of a failed creation until dismissal.
CreateError string
// CreateRollbackError is non-empty while that creation's rollback is
// incomplete; boot reconciliation retries it until it clears.
CreateRollbackError string
BaseRef string
CreatedBranch bool
RunNamespace string
CreatedHead string
RunID string
CreatedAt time.Time
UpdatedAt time.Time
}
func (Worktree) CreateFailure ¶
CreateFailure reports a failed creation's cause and, while it is incomplete, its rollback error.
Source Files
¶
- adopt.go
- aggregate.go
- bootstrap.go
- branch_delete.go
- capability.go
- catalog_stream.go
- create.go
- create_async.go
- create_branch.go
- create_checkout.go
- create_recovery.go
- create_rollback.go
- delivery_commit_tree.go
- discovery.go
- dismiss.go
- events.go
- exit_action_commit.go
- exit_actions.go
- exit_browser.go
- exit_cleanup.go
- exit_commit_scope.go
- exit_contracts.go
- exit_plan.go
- exit_refresh.go
- exit_terminal.go
- forge.go
- git_metadata.go
- git_porcelain.go
- git_runner.go
- inspection.go
- lock.go
- managed_delivery.go
- managed_delivery_commit.go
- managed_delivery_journal.go
- managed_delivery_push.go
- managed_delivery_recovery.go
- naming.go
- pr_template.go
- pull_request_identity.go
- pull_requests.go
- reclaim.go
- reconcile.go
- remove.go
- remove_discovered.go
- remove_missing.go
- remove_orphaned.go
- remove_risk.go
- resolve.go
- review_candidate.go
- run_materialization.go
- service.go
- status.go
- status_details.go
- subagent_facts.go
- teardown.go
- usage.go
- value_helpers.go
- worktree.go