Help us shape the future of Go! Take the 2026 Go Developer Survey

forge_lib_git_allocation

package
v0.57.28 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AllocationTypeID is the world object type identifier for a Git Worktree allocation.
	AllocationTypeID = "forge/lib/git/worktree-allocation"
)

Variables

View Source
var (
	// PredExecutionToAllocation links a Forge Execution to a Git Worktree allocation.
	PredExecutionToAllocation = quad.IRI("forge/git/execution-allocation")
	// PredJobToAllocation links a Forge Job to its retained Git allocation.
	PredJobToAllocation = quad.IRI("forge/git/job-allocation")
	// PredPassToAllocation links a Forge Pass to a Git Worktree allocation.
	PredPassToAllocation = quad.IRI("forge/git/pass-allocation")
	// PredAllocationToRepo links an allocation to the owning Git Repo object.
	PredAllocationToRepo = quad.IRI("forge/git/allocation-repo")
	// PredAllocationToWorktree links an allocation to the allocated Git Worktree object.
	PredAllocationToWorktree = quad.IRI("forge/git/allocation-worktree")
)

Functions

func BindJobAllocations

func BindJobAllocations(ctx context.Context, ws world.WorldState, jobKey, executionKey string) error

BindJobAllocations grants an Execution use of its Job's retained checkouts. The caller must establish the Execution's Job membership in the same transaction.

func BuildObjectKey

func BuildObjectKey(ownerObjectKey, repoObjectKey, baseCommitHash, pathFamily string) string

BuildObjectKey builds a deterministic allocation object key.

func ListAllocationRepos

func ListAllocationRepos(ctx context.Context, ws world.WorldState, allocationKeys ...string) ([]string, error)

ListAllocationRepos lists Repo object keys linked to allocations.

func ListAllocationWorktrees

func ListAllocationWorktrees(ctx context.Context, ws world.WorldState, allocationKeys ...string) ([]string, error)

ListAllocationWorktrees lists Worktree object keys linked to allocations.

func ListExecutionAllocations

func ListExecutionAllocations(ctx context.Context, ws world.WorldState, executionKeys ...string) ([]string, error)

ListExecutionAllocations lists allocation object keys linked to Executions.

func ListJobAllocations

func ListJobAllocations(ctx context.Context, ws world.WorldState, jobKeys ...string) ([]string, error)

ListJobAllocations returns the checkout allocations retained by the Jobs.

func ListPassAllocations

func ListPassAllocations(ctx context.Context, ws world.WorldState, passKeys ...string) ([]string, error)

ListPassAllocations lists allocation object keys linked to Passes.

func NewAllocationBlock

func NewAllocationBlock() block.Block

NewAllocationBlock constructs an empty Allocation block.

func ReleaseJobAllocations

func ReleaseJobAllocations(ctx context.Context, ws world.WorldState, jobKey string) error

ReleaseJobAllocations removes a settled Job's private Worktrees and Workdirs. Shared repository objects and commits remain. The caller owns the transaction and must drain the Job's Executions before releasing their filesystems.

func ResolveMount

func ResolveMount(ctx context.Context, ws world.WorldState, key string) (peer.ID, *unixfs_world.UnixfsRef, error)

ResolveMount returns the allocation's authorized identity and live Workdir. Job allocations survive individual Execution completion until ReleaseJobAllocations.

Types

type Allocation

type Allocation struct {
	// JobObjectKey is the Job retaining this checkout across its Executions.
	JobObjectKey string `json:"jobObjectKey,omitempty"`
	// PeerID is the external World identity authorized to operate a Job checkout.
	PeerID string `json:"peerId,omitempty"`
	// ExecutionObjectKey is the owning Forge Execution object key.
	ExecutionObjectKey string `json:"executionObjectKey,omitempty"`
	// PassObjectKey is the optional owning Forge Pass object key.
	PassObjectKey string `json:"passObjectKey,omitempty"`
	// RepoObjectKey is the Git Repo object key.
	RepoObjectKey string `json:"repoObjectKey,omitempty"`
	// WorktreeObjectKey is the allocated Git Worktree object key.
	WorktreeObjectKey string `json:"worktreeObjectKey,omitempty"`
	// WorkdirObjectKey is the mutable Workdir UnixFS object linked to the Worktree.
	WorkdirObjectKey string `json:"workdirObjectKey,omitempty"`
	// BaseCommitHash is the pinned base commit used for branch allocation.
	BaseCommitHash string `json:"baseCommitHash,omitempty"`
	// BranchRef is the branch/ref assigned to the allocation.
	BranchRef string `json:"branchRef,omitempty"`
	// PathFamily is the normalized visible path family that triggered allocation.
	PathFamily string `json:"pathFamily,omitempty"`
	// EvidenceObjectKey points at raw allocation Evidence when present.
	EvidenceObjectKey string `json:"evidenceObjectKey,omitempty"`
	// Status is the allocator lifecycle state.
	Status string `json:"status,omitempty"`
	// CollisionState records branch/key collision handling state.
	CollisionState string `json:"collisionState,omitempty"`
	// StaleBaseState records whether the pinned base is current for allocation.
	StaleBaseState string `json:"staleBaseState,omitempty"`
	// CleanupState records cleanup lifecycle for the allocated Worktree.
	CleanupState string `json:"cleanupState,omitempty"`
	// Cleanup records the terminal runtime cleanup receipt, set by RecordCleanup.
	Cleanup *forge_runtime.CleanupReceipt `json:"cleanup,omitempty"`
	// Timestamp is the allocation timestamp.
	Timestamp *timestamp.Timestamp `json:"timestamp,omitempty"`
}

Allocation records provenance for one Forge-owned Git Worktree allocation.

func CreateOrReuse

func CreateOrReuse(
	ctx context.Context,
	ws world.WorldState,
	args CreateArgs,
) (*Allocation, string, *bucket.ObjectRef, error)

CreateOrReuse creates an allocation object or returns the existing matching allocation.

func Lookup

func Lookup(ctx context.Context, ws world.WorldState, objKey string) (*Allocation, error)

Lookup loads an Allocation by object key.

func RecordCleanup added in v0.57.2

func RecordCleanup(
	ctx context.Context,
	ws world.WorldState,
	allocationObjectKey string,
	receipt *forge_runtime.CleanupReceipt,
) (*Allocation, *bucket.ObjectRef, error)

RecordCleanup records the terminal runtime cleanup receipt on one allocation. Runtime release stays separate from retention: the Worktree and committed Workdir bytes remain readable after the receipt lands.

func UnmarshalAllocation added in v0.57.2

func UnmarshalAllocation(ctx context.Context, bcs *block.Cursor) (*Allocation, error)

UnmarshalAllocation unmarshals an Allocation from a block cursor.

func (*Allocation) GetBaseCommitHash

func (a *Allocation) GetBaseCommitHash() string

GetBaseCommitHash returns the base commit hash.

func (*Allocation) GetBranchRef

func (a *Allocation) GetBranchRef() string

GetBranchRef returns the branch/ref.

func (*Allocation) GetCleanup added in v0.57.2

func (a *Allocation) GetCleanup() *forge_runtime.CleanupReceipt

GetCleanup returns the terminal runtime cleanup receipt.

func (*Allocation) GetCleanupState

func (a *Allocation) GetCleanupState() string

GetCleanupState returns the cleanup state.

func (*Allocation) GetCollisionState

func (a *Allocation) GetCollisionState() string

GetCollisionState returns the branch/key collision state.

func (*Allocation) GetEvidenceObjectKey

func (a *Allocation) GetEvidenceObjectKey() string

GetEvidenceObjectKey returns the raw Evidence object key.

func (*Allocation) GetExecutionObjectKey

func (a *Allocation) GetExecutionObjectKey() string

GetExecutionObjectKey returns the owning Execution object key.

func (*Allocation) GetJobObjectKey

func (a *Allocation) GetJobObjectKey() string

GetJobObjectKey returns the Job retaining the checkout.

func (*Allocation) GetPassObjectKey

func (a *Allocation) GetPassObjectKey() string

GetPassObjectKey returns the optional owning Pass object key.

func (*Allocation) GetPathFamily

func (a *Allocation) GetPathFamily() string

GetPathFamily returns the visible path family.

func (*Allocation) GetRepoObjectKey

func (a *Allocation) GetRepoObjectKey() string

GetRepoObjectKey returns the Repo object key.

func (*Allocation) GetStaleBaseState

func (a *Allocation) GetStaleBaseState() string

GetStaleBaseState returns the stale-base state.

func (*Allocation) GetStatus

func (a *Allocation) GetStatus() string

GetStatus returns the allocation status.

func (*Allocation) GetTimestamp

func (a *Allocation) GetTimestamp() *timestamp.Timestamp

GetTimestamp returns the allocation timestamp.

func (*Allocation) GetWorkdirObjectKey added in v0.57.2

func (a *Allocation) GetWorkdirObjectKey() string

GetWorkdirObjectKey returns the mutable Workdir object key.

func (*Allocation) GetWorktreeObjectKey

func (a *Allocation) GetWorktreeObjectKey() string

GetWorktreeObjectKey returns the Worktree object key.

func (*Allocation) MarshalBlock

func (a *Allocation) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary.

func (*Allocation) MarshalJSON

func (a *Allocation) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Allocation to JSON without reflection.

func (*Allocation) Reset

func (a *Allocation) Reset()

Reset resets the block.

func (*Allocation) UnmarshalBlock

func (a *Allocation) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block from binary.

func (*Allocation) UnmarshalJSON

func (a *Allocation) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Allocation from JSON without reflection.

func (*Allocation) Validate

func (a *Allocation) Validate() error

Validate validates an Allocation.

type CreateArgs

type CreateArgs struct {
	// ObjectKey overrides the deterministic allocation identity.
	ObjectKey string
	// JobObjectKey retains the checkout for one Job.
	JobObjectKey string
	// PeerID authorizes Workdir writes for a Job allocation.
	PeerID string
	// ExecutionObjectKey selects the Execution owner, exclusive with JobObjectKey.
	ExecutionObjectKey string
	// PassObjectKey identifies the Pass containing the Execution.
	PassObjectKey string
	// RepoObjectKey identifies the shared Git object database.
	RepoObjectKey string
	// WorktreeObjectKey identifies the allocated checkout.
	WorktreeObjectKey string
	// WorkdirRequired requires a mutable Workdir identity.
	WorkdirRequired bool
	// WorkdirObjectKey identifies its mutable filesystem.
	WorkdirObjectKey string
	// BaseCommitHash pins the admitted base commit.
	BaseCommitHash string
	// BranchRef selects the branch, or is empty for a detached Job checkout.
	BranchRef string
	// PathFamily identifies the visible path family.
	PathFamily string
	// EvidenceObjectKey references allocation evidence.
	EvidenceObjectKey string
	// Status sets the allocation status, defaulting to allocated.
	Status string
	// CollisionState sets collision handling, defaulting to none.
	CollisionState string
	// StaleBaseState sets the base observation, defaulting to unchecked.
	StaleBaseState string
	// CleanupState sets cleanup state, defaulting to active.
	CleanupState string
	// Timestamp records creation time, defaulting to now.
	Timestamp *timestamp.Timestamp
}

CreateArgs contains inputs for creating or reusing an allocation.

Jump to

Keyboard shortcuts

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