layers

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VendorBinary added in v0.0.4

func VendorBinary(ctx context.Context, client forge.Client, org, binaryPath string) error

VendorBinary uploads a pre-built fullsend binary to .fullsend/bin/fullsend. CI workflows detect this file and use it instead of downloading from GitHub releases, enabling development iteration without cutting a release.

Types

type AgentCredentials

type AgentCredentials struct {
	config.AgentEntry
	PEM      string
	ClientID string
	AppID    int
}

AgentCredentials extends AgentEntry with app credentials.

type ConfigRepoLayer

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

ConfigRepoLayer manages the .fullsend configuration repository. This is the foundational layer — it must be installed before any other layers that depend on the config repo existing.

func NewConfigRepoLayer

func NewConfigRepoLayer(org string, client forge.Client, cfg *config.OrgConfig, printer *ui.Printer, hasPrivate bool) *ConfigRepoLayer

NewConfigRepoLayer creates a new ConfigRepoLayer. Set hasPrivate to true if the org's GitHub plan (team/enterprise) supports workflow_call from private repos. GitHub free tier cannot use workflow_call with private repos, so the config repo must be public on free orgs.

func (*ConfigRepoLayer) Analyze

func (l *ConfigRepoLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks whether the .fullsend repo and config.yaml exist and are valid.

func (*ConfigRepoLayer) Install

func (l *ConfigRepoLayer) Install(ctx context.Context) error

Install creates the .fullsend config repo (if it doesn't exist) and writes config.yaml into it.

Timing note: after CreateRepo with auto_init, the default branch may not be fully materialized yet. The Contents API call to write config.yaml can get transient 404s. The GitHub client's retry-with-backoff in do() handles this, but callers should be aware that the first file write to a newly created repo may take several seconds to succeed.

func (*ConfigRepoLayer) Name

func (l *ConfigRepoLayer) Name() string

func (*ConfigRepoLayer) RequiredScopes

func (l *ConfigRepoLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*ConfigRepoLayer) Uninstall

func (l *ConfigRepoLayer) Uninstall(ctx context.Context) error

Uninstall deletes the .fullsend config repo. Idempotent: if the repo is already gone, this is a no-op.

type DispatchTokenLayer

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

DispatchTokenLayer manages the org-level dispatch mechanism that enrolled repos use to trigger agent workflows on the .fullsend repo via workflow_call.

The mint URL is stored as an org-level variable (FULLSEND_MINT_URL). A repo-level copy is also set on the config repo (.fullsend) because GitHub org variables with "selected" visibility are not accessible to repos whose names start with a dot.

func NewOIDCDispatchLayer added in v0.8.0

func NewOIDCDispatchLayer(org string, client forge.Client, enrolledRepoIDs []int64, dispatcher dispatch.Dispatcher, printer *ui.Printer) *DispatchTokenLayer

NewOIDCDispatchLayer creates a new DispatchTokenLayer in OIDC mode. It uses a dispatch.Dispatcher to provision cloud infrastructure and store the mint URL as an org-level variable.

func (*DispatchTokenLayer) Analyze

func (l *DispatchTokenLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks whether the dispatch mechanism is configured.

func (*DispatchTokenLayer) Install

func (l *DispatchTokenLayer) Install(ctx context.Context) error

Install creates or updates the dispatch mechanism.

func (*DispatchTokenLayer) Name

func (l *DispatchTokenLayer) Name() string

Name returns the layer name.

func (*DispatchTokenLayer) RequiredScopes

func (l *DispatchTokenLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*DispatchTokenLayer) Uninstall

func (l *DispatchTokenLayer) Uninstall(ctx context.Context) error

Uninstall removes the dispatch mechanism.

type EnrollmentLayer

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

EnrollmentLayer monitors workflow-driven enrollment of target repos. Enrollment is performed by the repo-maintenance workflow in .fullsend, which creates PRs with shim workflows in response to config.yaml changes. This layer dispatches that workflow and reports the results.

func NewEnrollmentLayer

func NewEnrollmentLayer(org string, client forge.Client, enabledRepos, disabledRepos []string, printer *ui.Printer) *EnrollmentLayer

NewEnrollmentLayer creates a new EnrollmentLayer.

func (*EnrollmentLayer) Analyze

func (l *EnrollmentLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks which enabled repos have the shim workflow installed and which disabled repos still have it.

func (*EnrollmentLayer) Install

func (l *EnrollmentLayer) Install(ctx context.Context) error

Install dispatches the repo-maintenance workflow to handle enrollment, waits for it to complete, and reports any enrollment PRs created.

func (*EnrollmentLayer) Name

func (l *EnrollmentLayer) Name() string

func (*EnrollmentLayer) RequiredScopes

func (l *EnrollmentLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*EnrollmentLayer) Uninstall

func (l *EnrollmentLayer) Uninstall(_ context.Context) error

Uninstall is a no-op. Individual repo cleanup is not automated — repos keep their shim workflows.

type InferenceLayer added in v0.0.3

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

InferenceLayer manages inference provider credentials in the .fullsend repo.

func NewInferenceLayer added in v0.0.3

func NewInferenceLayer(org string, client forge.Client, provider inference.Provider, printer *ui.Printer) *InferenceLayer

NewInferenceLayer creates a new InferenceLayer.

func (*InferenceLayer) Analyze added in v0.0.3

func (l *InferenceLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks whether inference credentials exist in the .fullsend repo.

func (*InferenceLayer) Install added in v0.0.3

func (l *InferenceLayer) Install(ctx context.Context) error

Install provisions inference credentials and stores them as repo secrets. Secrets are written unconditionally because the GitHub Secrets API does not expose values, so we cannot detect stale entries. The API PUT is an upsert, making repeated writes safe.

func (*InferenceLayer) Name added in v0.0.3

func (l *InferenceLayer) Name() string

Name returns the layer name.

func (*InferenceLayer) RequiredScopes added in v0.0.3

func (l *InferenceLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*InferenceLayer) Uninstall added in v0.0.3

func (l *InferenceLayer) Uninstall(_ context.Context) error

Uninstall is a no-op. Secrets are removed when the .fullsend repo is deleted.

type Layer

type Layer interface {
	// Name returns a human-readable name for this layer.
	Name() string

	// RequiredScopes returns the OAuth scopes this layer needs for the
	// given operation. Scopes are GitHub-flavored strings like "repo",
	// "delete_repo", "workflow". Used by Preflight to fail early when
	// the token is missing required scopes.
	RequiredScopes(op Operation) []string

	// Install creates or configures this layer's concern.
	Install(ctx context.Context) error

	// Uninstall tears down this layer's concern.
	Uninstall(ctx context.Context) error

	// Analyze assesses the current state and reports what would change.
	Analyze(ctx context.Context) (*LayerReport, error)
}

Layer is the interface each installation concern implements. Layers are processed in order for install, reverse order for uninstall.

func NewBothModesDispatchLayer added in v0.8.0

func NewBothModesDispatchLayer(org string, client forge.Client, dispatcher dispatch.Dispatcher, printer *ui.Printer) Layer

NewBothModesDispatchLayer creates a layer that cleans both dispatch modes. The PAT-mode layer is constructed inline for stale secret cleanup only.

type LayerReport

type LayerReport struct {
	Name         string
	Status       LayerStatus
	Details      []string // human-readable detail lines
	WouldInstall []string // what install would create
	WouldFix     []string // what install would fix (for degraded state)
}

LayerReport is the result of analyzing a single layer.

type LayerStatus

type LayerStatus int

LayerStatus represents the current state of a layer.

const (
	StatusNotInstalled LayerStatus = iota
	StatusInstalled
	StatusDegraded // partially installed or misconfigured
	StatusUnknown  // cannot determine
)

func (LayerStatus) String

func (s LayerStatus) String() string

String returns a human-readable description of the status.

type Operation

type Operation int

Operation identifies which action is being performed on a layer.

const (
	OpInstall Operation = iota
	OpUninstall
	OpAnalyze
)

func (Operation) String

func (o Operation) String() string

type PreflightResult

type PreflightResult struct {
	// Required is the set of scopes the operation needs.
	Required []string
	// Granted is the set of scopes the token actually has.
	Granted []string
	// Missing is the set of scopes needed but not granted.
	Missing []string
	// Skipped is true when scope introspection was unavailable
	// (e.g., fine-grained tokens that don't report scopes).
	Skipped bool
}

PreflightResult describes what a preflight check found.

func (*PreflightResult) Error

func (r *PreflightResult) Error() string

Error returns a human-readable error describing missing scopes and how to fix the problem.

func (*PreflightResult) OK

func (r *PreflightResult) OK() bool

OK returns true if no scopes are missing.

type SecretsLayer

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

SecretsLayer manages agent app secrets and variables in the .fullsend repo. When oidcMode is true, Install is a no-op because agent workflows use the OIDC token mint instead of create-github-app-token, so repo secrets (FULLSEND_{ROLE}_APP_PRIVATE_KEY) and variables (FULLSEND_{ROLE}_CLIENT_ID) are not needed.

func NewSecretsLayer

func NewSecretsLayer(org string, client forge.Client, agents []AgentCredentials, printer *ui.Printer) *SecretsLayer

NewSecretsLayer creates a new SecretsLayer.

func (*SecretsLayer) Analyze

func (s *SecretsLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks whether all expected agent secrets and variables exist in the .fullsend repo. In OIDC mode, repo secrets are not required — any present are flagged as stale.

func (*SecretsLayer) Install

func (s *SecretsLayer) Install(ctx context.Context) error

Install stores agent app private keys as repo secrets and client IDs as repo variables in the .fullsend config repo. In OIDC mode this is a no-op because PEMs are stored in GCP Secret Manager and workflows use the mint.

func (*SecretsLayer) Name

func (s *SecretsLayer) Name() string

Name returns the layer name.

func (*SecretsLayer) RequiredScopes

func (s *SecretsLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation. In OIDC mode, Install needs no scopes (it's a no-op) but Analyze still needs "repo" to check for stale secrets via RepoSecretExists.

func (*SecretsLayer) Uninstall

func (s *SecretsLayer) Uninstall(_ context.Context) error

Uninstall is a no-op. Secrets are removed when the .fullsend repo is deleted.

func (*SecretsLayer) WithOIDCMode added in v0.8.0

func (s *SecretsLayer) WithOIDCMode() *SecretsLayer

WithOIDCMode enables OIDC mode and returns the receiver for chaining. In OIDC mode, Install is a no-op because PEMs are stored in GCP Secret Manager and workflows use the OIDC token mint.

type Stack

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

Stack is an ordered collection of layers.

func NewStack

func NewStack(layers ...Layer) *Stack

NewStack creates a new Stack with the given layers in order.

func (*Stack) AnalyzeAll

func (s *Stack) AnalyzeAll(ctx context.Context) ([]*LayerReport, error)

AnalyzeAll runs Analyze on each layer and returns reports.

func (*Stack) CollectRequiredScopes

func (s *Stack) CollectRequiredScopes(op Operation) []string

CollectRequiredScopes returns the deduplicated set of scopes needed by all layers for the given operation.

func (*Stack) InstallAll

func (s *Stack) InstallAll(ctx context.Context) error

InstallAll runs Install on each layer in order. Stops on first error, returning the error and the name of the failed layer.

func (*Stack) Layers

func (s *Stack) Layers() []Layer

Layers returns the layers in order.

func (*Stack) Preflight

func (s *Stack) Preflight(ctx context.Context, op Operation, client forge.Client) (*PreflightResult, error)

Preflight checks that the forge client's token has all the scopes required by the stack's layers for the given operation. It returns a PreflightResult describing what was found.

If the forge doesn't support scope introspection (e.g., fine-grained tokens, GitHub App tokens), Preflight returns a result with OK() == true and logs that scope checking was skipped. We can't validate what we can't see, so we let the operation proceed and fail at the point of use if scopes are actually missing.

func (*Stack) UninstallAll

func (s *Stack) UninstallAll(ctx context.Context) []error

UninstallAll runs Uninstall on each layer in reverse order. Collects all errors rather than stopping on first.

type VendorBinaryLayer added in v0.1.0

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

VendorBinaryLayer manages the vendored development binary in .fullsend/bin/.

When enabled (--vendor-fullsend-binary flag), it calls a VendorFunc callback to cross-compile and upload the binary. When disabled (the default), it checks whether a vendored binary exists and deletes it to prevent a stale binary from shadowing released versions.

func NewVendorBinaryLayer added in v0.1.0

func NewVendorBinaryLayer(org string, client forge.Client, printer *ui.Printer, enabled bool, vendorFn VendorFunc) *VendorBinaryLayer

NewVendorBinaryLayer creates a new VendorBinaryLayer.

func (*VendorBinaryLayer) Analyze added in v0.1.0

func (l *VendorBinaryLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze assesses the current state of the vendored binary.

func (*VendorBinaryLayer) Install added in v0.1.0

func (l *VendorBinaryLayer) Install(ctx context.Context) error

Install either vendors the binary (when enabled) or removes a stale one (when disabled).

func (*VendorBinaryLayer) Name added in v0.1.0

func (l *VendorBinaryLayer) Name() string

func (*VendorBinaryLayer) RequiredScopes added in v0.1.0

func (l *VendorBinaryLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*VendorBinaryLayer) Uninstall added in v0.1.0

func (l *VendorBinaryLayer) Uninstall(_ context.Context) error

Uninstall is a no-op. The vendored binary is removed when the config repo is deleted by the ConfigRepoLayer.

type VendorFunc added in v0.1.0

type VendorFunc func(ctx context.Context, client forge.Client, printer *ui.Printer, org string) error

VendorFunc is a callback that cross-compiles and uploads a vendored binary.

type WorkflowsLayer

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

WorkflowsLayer manages workflow files and CODEOWNERS in the .fullsend config repo. It writes the thin caller workflows, composite actions, and a CODEOWNERS file that grants the installing user ownership of all config-repo contents.

func NewWorkflowsLayer

func NewWorkflowsLayer(org string, client forge.Client, printer *ui.Printer, user string) *WorkflowsLayer

NewWorkflowsLayer creates a new WorkflowsLayer. user is the authenticated user who will own CODEOWNERS entries.

func (*WorkflowsLayer) Analyze

func (l *WorkflowsLayer) Analyze(ctx context.Context) (*LayerReport, error)

Analyze checks which managed files exist in the config repo.

func (*WorkflowsLayer) Install

func (l *WorkflowsLayer) Install(ctx context.Context) error

Install writes the workflow files and CODEOWNERS to the .fullsend repo in a single atomic commit using the Git Trees API. If all files already match the current tree, no commit is created (idempotent).

func (*WorkflowsLayer) Name

func (l *WorkflowsLayer) Name() string

func (*WorkflowsLayer) RequiredScopes

func (l *WorkflowsLayer) RequiredScopes(op Operation) []string

RequiredScopes returns the scopes needed for the given operation.

func (*WorkflowsLayer) Uninstall

func (l *WorkflowsLayer) Uninstall(_ context.Context) error

Uninstall is a no-op. Workflow files are removed when the config repo is deleted by the ConfigRepoLayer.

Jump to

Keyboard shortcuts

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