depsweep

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package depsweep converges the ecosystem on the dependency plan computed by project-dependency-graph: it pulls the machine-readable release-overview plan, turns it into deterministic "depbump" tasks (executor.TaskTypeDepBump) chained by the plan's own DAG, and lets the queue's scheduling replace wave arithmetic. Releases are tagged (and, when configured, pushed) by the executor; consumers bump exact pins and verify before committing.

The plan JSON is the ONLY seam to depgraph — this package never imports it. That keeps the contract explicit (a versioned wire format both tools pin in tests) and the dependency graph of the queue itself untouched.

Loop safety mirrors the prioritize sweeper's structural rules: depbump tasks are never journal-triggered (the sweeper runs on a timer or on demand), and every mint carries a dedup key hashing the exact work spec, so an unchanged plan never mints twice. A permanently failed task lands in the DLQ and its dedup key suppresses remints until the plan changes — the DLQ is the human surface, same ruling as dead prioritize batches.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWork

func BuildWork(modules []PlanModule, cfg SweeperConfig) ([]WorkSpec, []Skip)

BuildWork turns plan modules into per-repo work specs. Rules (ported from the verified reference driver, ~/projects/scripts/depgraph-upgrade-sweep.sh):

  • stale builds release (verify+tag): their newer pins are already committed in the working tree — the work is NOT go get.
  • consumers bump exact pins, grouped one spec per consumer repo.
  • never-released modules skip (v0.1.0 is a human decision).
  • major bumps and major release suggestions skip (import-path migration is agent/human work, never scripted).
  • targets must be stable semver strictly newer than the current pin (the plan carries dev-version and downgrade traps).

Types

type DepgraphSource

type DepgraphSource struct {
	Bin       string
	Dir       string
	ExtraArgs []string
	Timeout   time.Duration
}

DepgraphSource runs the project-dependency-graph binary and parses its release-overview JSON. Bin defaults to "project-dependency-graph"; ExtraArgs lets callers pin flags (e.g. an org prefix) without a struct per flag.

func (DepgraphSource) Plan

func (s DepgraphSource) Plan(ctx context.Context) ([]PlanModule, error)

Plan runs the binary: <bin> release-overview --dir <dir> --format json.

type PlanConsumer

type PlanConsumer struct {
	Key            string `json:"key"`
	Dir            string `json:"dir"`
	CurrentVersion string `json:"currentVersion"`
	TargetVersion  string `json:"targetVersion"`
	DependencyKey  string `json:"dependencyKey"`
	IsMajorBump    bool   `json:"isMajorBump"`
}

PlanConsumer is one outdated consumer of a released module.

type PlanDepKey

type PlanDepKey struct {
	Key string `json:"key"`
}

PlanDepKey names one dependency module of a plan module.

type PlanModule

type PlanModule struct {
	Key   string `json:"key"`
	Label string `json:"label"`
	Dir   string `json:"dir"`

	HasUnreleasedWork bool   `json:"hasUnreleasedWork"`
	CurrentVersion    string `json:"currentVersion"`
	NextVersion       string `json:"nextVersion"`
	SuggestedBump     string `json:"suggestedBump"`

	HasOutdatedConsumers bool           `json:"hasOutdatedConsumers"`
	OutdatedConsumers    []PlanConsumer `json:"outdatedConsumers"`
	StaleBuild           bool           `json:"staleBuild"`
	StaleDeps            []PlanStaleDep `json:"staleDeps"`
	Wave                 int            `json:"wave"`
	ConsumerCount        int            `json:"consumerCount"`
	Dependencies         []PlanDepKey   `json:"dependencies"`
}

PlanModule is one own module in the release-overview JSON contract (subset the sweeper acts on; unknown fields are ignored on decode).

func ParsePlan

func ParsePlan(data []byte) ([]PlanModule, error)

ParsePlan decodes a release-overview JSON payload.

type PlanSource

type PlanSource interface {
	Plan(ctx context.Context) ([]PlanModule, error)
}

PlanSource produces the current plan. The interface keeps the sweeper testable against fixture plans and lets future sources (the depgraph daemon socket, a cached file) slot in without touching sweep logic.

type PlanStaleDep

type PlanStaleDep struct {
	Key        string `json:"key"`
	OldVersion string `json:"oldVersion"`
	NewVersion string `json:"newVersion"`
}

PlanStaleDep documents why a build is stale (informational: the release task does not re-apply these — they are already in the working tree).

type Skip

type Skip struct {
	Repo   string
	Reason string
}

Skip records one skipped plan row and why (surfaced in stats and logs — skips are the human-facing to-do of the sweep).

type SweepStats

type SweepStats struct {
	// Minted counts fresh tasks enqueued.
	Minted int
	// Known counts mints whose task already existed (dedup hit).
	Known int
	// Skips carries every skipped plan row with its reason.
	Skips []Skip
}

SweepStats summarizes one sweep pass.

type Sweeper

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

Sweeper mints depbump tasks from plan states. Safe for concurrent use.

func NewSweeper

func NewSweeper(store queue.Store, cfg SweeperConfig) *Sweeper

NewSweeper returns a sweeper minting into store.

func (*Sweeper) Sweep

func (s *Sweeper) Sweep(ctx context.Context) (SweepStats, error)

Sweep pulls one plan and converges the queue onto it: every work spec becomes one depbump task (idempotent via dedup keys), wired to its plan dependencies' tasks. Call periodically; dedup makes repeated calls free.

type SweeperConfig

type SweeperConfig struct {
	// Source supplies the plan. Required.
	Source PlanSource
	// PushReleases makes release payloads push master+tag after tagging,
	// which is what unblocks consumer bumps (they resolve the tag through
	// the module proxy). Default false: tags stay local and a human pushes
	// — consumers then retry until the tag lands (bounded by the retry
	// ladder; the DLQ is the surface if the push never comes).
	PushReleases bool
	// IncludeUnreleased also releases modules whose ONLY work is
	// unreleased feature commits (the release-suggestions lens). Default
	// false: the sweep converges dependency state; feature releases carry
	// version decisions a human should see. Stale builds always release —
	// their content is dependency pins that are already committed.
	IncludeUnreleased bool
	// Log receives one line per mint/skip. nil logs nothing.
	Log *slog.Logger
}

SweeperConfig controls one Sweeper.

type WorkSpec

type WorkSpec struct {
	// Repo is the module key (task project + dedup identity).
	Repo string
	// Dir is the absolute module directory (payload Repo field).
	Dir string
	// Bumps are the exact pins to apply (consumer work).
	Bumps []executor.DepBump
	// Release is the tag to cut after verification (release work).
	Release *executor.DepBumpRelease
	// DepRepos are plan dependency repo keys whose tasks this spec's task
	// must wait for (the plan DAG becomes the queue DAG).
	DepRepos []string
	// DedupKey makes minting idempotent per exact work spec.
	DedupKey string
}

WorkSpec is one repo's deterministic work for one plan state.

Jump to

Keyboard shortcuts

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