Documentation
¶
Overview ¶
Package magus is the high-level library for the magus build orchestrator.
Entry points: Open returns a Magus for build/test cycles, Inspect for read-only commands. A Magus runs work via Magus.Run (one target), Magus.RunCI (the configured CI pipeline), and Magus.RunAffected (only projects touched since a baseline). Behavior is tuned with Option values passed to Open/Inspect (e.g. WithLimiter). Limiter caps concurrent spell executions and can be shared across daemon workspaces.
Boundary: the library links the engine-agnostic interp surface and the Buzz VM, but deliberately not the host bindings (interp/bindings) or the Buzz engine backend — cmd/magus blank-imports those. So a script-driven backend (e.g. the spell-backed remote backend) reaches the library only through registered hooks such as cache.RegisterRemoteBackendOpener, never a direct import.
Index ¶
- Constants
- func ApplyUnionSandbox(ctx context.Context, roots []string) error
- func ComposeGraph(ws types.WorkspaceRepository, opts ...ComposeOption) types.GraphOutput
- func DefaultConcurrency() int
- func FindRoot(dir string) (string, error)
- func IgnoreGlob(pattern string) types.IgnorePattern
- func IgnoreLiteral(pattern string) types.IgnorePattern
- func IgnoreRegex(pattern string) types.IgnorePattern
- func Inspect(ctx context.Context, root string, opts ...Option) (types.WorkspaceRepository, error)
- func TargetLabel(targets []types.Target, source string) string
- func WithWorkspaceRegistryContext(ctx context.Context, reg *WorkspaceRegistry) context.Context
- type BindingOption
- type ComposeOption
- type Limiter
- type Magus
- func (m *Magus) Affected(ctx context.Context, base string) (*types.AffectedResult, error)
- func (m *Magus) AffectedFromPaths(ctx context.Context, paths []string) (*types.AffectedResult, error)
- func (m *Magus) Affinity(ctx context.Context, opts types.InsightOptions) (types.AffinityOutput, error)
- func (m *Magus) All() []*types.Project
- func (m *Magus) CleanCache(ctx context.Context, projects ...*types.Project) error
- func (m *Magus) CleanOutputs(ctx context.Context, projects []*types.Project, dryRun bool) ([]string, error)
- func (m *Magus) Close() error
- func (m *Magus) DescribeEvaluatedProjects() types.EvaluatedProjectsOutput
- func (m *Magus) DescribeGraph() types.TargetGraphOutput
- func (m *Magus) DescribeProjects() types.ProjectsOutput
- func (*Magus) DescribeSpells() types.SpellsOutput
- func (m *Magus) DescribeTarget(t types.Target) (types.EvaluatedTargetsOutput, error)
- func (m *Magus) DescribeTargets() types.TargetsOutput
- func (m *Magus) DescribeWorkspaces(cfg types.WorkspaceConfig) types.WorkspacesOutput
- func (m *Magus) ExpandAffected(ctx context.Context, target string, baseRef string) (targets []types.Target, source string, fellBack bool, err error)
- func (m *Magus) ExpandCwd(t types.Target) (targets []types.Target, found bool, err error)
- func (m *Magus) ExpandPath(t types.Target) ([]types.Target, error)
- func (m *Magus) ExportCache(ctx context.Context, w io.Writer) error
- func (m *Magus) FindOutputOwner(absPath string) *types.Project
- func (m *Magus) Get(path string) *types.Project
- func (m *Magus) Graph() (*types.Graph, error)
- func (m *Magus) Hotspots(ctx context.Context, opts types.InsightOptions) (types.HotspotOutput, error)
- func (m *Magus) ImportCache(ctx context.Context, r io.Reader) error
- func (m *Magus) LogScope(label, source string)
- func (m *Magus) Ownership(ctx context.Context, opts types.InsightOptions) (types.OwnershipOutput, error)
- func (m *Magus) Plan(ctx context.Context, target string, opts PlanOptions) (types.ShardPlan, error)
- func (m *Magus) PruneCache(ctx context.Context, cutoff time.Time, dryRun bool) (removed int, freed int64, err error)
- func (m *Magus) PruneRemoteCache(ctx context.Context, olderThan time.Duration, keepLast int, dryRun bool) error
- func (m *Magus) ResolveProjects(targets []types.Target) []*types.Project
- func (m *Magus) Root() string
- func (m *Magus) Run(ctx context.Context, targets []types.Target, opts ...RunOption) error
- func (m *Magus) RunAffected(ctx context.Context, target string, opts ...RunOption) error
- func (m *Magus) RunCI(ctx context.Context, targets []types.Target, opts ...RunOption) error
- func (m *Magus) SetGraphObserver(o types.Observer)
- func (m *Magus) Stream(ctx context.Context, r io.Reader, target string, errFn func(error), ...) error
- func (m *Magus) TailLog(projectPath, target string) (logPath string, err error)
- func (m *Magus) Trend(ctx context.Context, opts types.InsightOptions) (types.TrendOutput, error)
- func (m *Magus) VCSOptions() types.VCSOptions
- func (m *Magus) Where(dir string) (*types.Project, bool)
- type Option
- type PlanOptions
- type ProjectOption
- func WithDependsOn(paths ...string) ProjectOption
- func WithExclusive() ProjectOption
- func WithOutputs(paths ...string) ProjectOption
- func WithSpell(name string, opts ...BindingOption) ProjectOption
- func WithTarget(name string, opts ...TargetOption) ProjectOption
- func WithWatchIgnore(patterns ...types.IgnorePattern) ProjectOption
- type ReportWriter
- type RunOption
- func WithBaseRef(ref string) RunOption
- func WithCharms(charms ...string) RunOption
- func WithDryRun() RunOption
- func WithExtraArgs(args []string) RunOption
- func WithNoFlakeRetry() RunOption
- func WithRace() RunOption
- func WithRaceReplay() RunOption
- func WithReport(rw *ReportWriter) RunOption
- func WithReportWriter(w io.Writer) RunOption
- func WithSpellFilter(name string) RunOption
- func WithStep() RunOption
- func WithTargetNameNormalizer(n types.TargetNameNormalizer) RunOption
- func WithWrite() RunOption
- type StreamOption
- type TargetHandler
- type TargetOption
- type WorkspaceRegistry
Examples ¶
Constants ¶
const StreamAllSentinel = "\x00ALL"
StreamAllSentinel is a stream-batch marker that triggers a full-workspace selection. The NUL prefix ensures it cannot collide with a real file path.
Variables ¶
This section is empty.
Functions ¶
func ApplyUnionSandbox ¶
ApplyUnionSandbox unions the landlock policies of every workspace root and applies the combined ruleset to the current process exactly once. Roots whose config disables the sandbox still contribute filesystem rules but no binding-layer policy (MGS2011). It is a no-op (returns nil) when no root requests kernel sandboxing.
This is the multi-workspace (daemon) counterpart to the per-workspace sandbox that Run applies. It lives in the library so callers — the CLI daemon in particular — never import internal/sandbox directly: policy assembly and application stay behind one seam, so the two paths cannot drift.
func ComposeGraph ¶
func ComposeGraph(ws types.WorkspaceRepository, opts ...ComposeOption) types.GraphOutput
ComposeGraph assembles the structured graph view. Edges to unknown projects are dropped.
func DefaultConcurrency ¶
func DefaultConcurrency() int
DefaultConcurrency returns the concurrency cap used when no explicit cap is set, resolved by precedence: the MAGUS_CONCURRENCY env var if set to a positive int, then 4 on GitHub-hosted runners (GITHUB_ACTIONS=true and RUNNER_ENVIRONMENT is not self-hosted), then min(NumCPU, 8).
func IgnoreGlob ¶
func IgnoreGlob(pattern string) types.IgnorePattern
IgnoreGlob constructs a doublestar-glob ignore pattern.
func IgnoreLiteral ¶
func IgnoreLiteral(pattern string) types.IgnorePattern
IgnoreLiteral constructs a literal ignore pattern matching any path segment at any depth.
func IgnoreRegex ¶
func IgnoreRegex(pattern string) types.IgnorePattern
IgnoreRegex constructs a Go-regexp ignore pattern.
func Inspect ¶
Inspect discovers the workspace without opening the cache (for introspection commands).
Example ¶
ExampleInspect shows how to discover projects in a workspace without opening the cache. Inspect is the right entry point for read-only commands (list, graph, describe) where cache overhead is unnecessary.
// Create a minimal workspace with one project for illustration.
root, err := os.MkdirTemp("", "magus-example-*")
if err != nil {
fmt.Println("setup error:", err)
return
}
defer os.RemoveAll(root)
// A directory is a project if it contains a magusfile.buzz.
projDir := filepath.Join(root, "myapp")
if err := os.MkdirAll(projDir, 0o755); err != nil {
fmt.Println("setup error:", err)
return
}
if err := os.WriteFile(filepath.Join(projDir, "magusfile.buzz"), []byte(""), 0o644); err != nil {
fmt.Println("setup error:", err)
return
}
ws, err := Inspect(context.Background(), root)
if err != nil {
fmt.Println("inspect error:", err)
return
}
for _, p := range ws.All() {
fmt.Println(p.Path)
}
Output: myapp
func TargetLabel ¶
TargetLabel returns a one-line summary of a target slice suitable for log headers.
func WithWorkspaceRegistryContext ¶
func WithWorkspaceRegistryContext(ctx context.Context, reg *WorkspaceRegistry) context.Context
WithWorkspaceRegistryContext installs reg in ctx so interpreters can retrieve it.
Types ¶
type BindingOption ¶
type BindingOption = workspace.BindingOption
BindingOption mutates a spell Binding at registration time.
func WithClaim ¶
func WithClaim(globs ...string) BindingOption
WithClaim extends the spell's declared claims with additional globs.
func WithClaimWeight ¶
func WithClaimWeight(weight int) BindingOption
WithClaimWeight sets the binding's claim weight; higher weight wins on overlap, ties go last-wins.
func WithoutClaim ¶
func WithoutClaim(globs ...string) BindingOption
WithoutClaim removes globs from a spell's effective claims.
type ComposeOption ¶
type ComposeOption func(*compose)
ComposeOption configures a ComposeGraph call.
func WithComposeRoots ¶
func WithComposeRoots(paths ...string) ComposeOption
WithComposeRoots restricts the graph to the listed project paths.
func WithComposeSpell ¶
func WithComposeSpell(name string) ComposeOption
WithComposeSpell limits the graph to projects that use the named spell.
func WithGraphHistory ¶
func WithGraphHistory(h *forecast.History, target string) ComposeOption
WithGraphHistory enables per-node DurationMs prediction in ComposeGraph using adaptive CI history for the given target (typically "ci" or "test").
func WithGraphInput ¶
func WithGraphInput(g *types.Graph) ComposeOption
WithGraphInput enables blast-radius enrichment.
func WithUpstream ¶
func WithUpstream() ComposeOption
WithUpstream switches graph direction to upstream (dependents instead of dependencies).
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter is a weighted semaphore that caps concurrent spell executions. Obtain one with NewLimiter and share it across daemon workspaces via WithLimiter.
func NewLimiter ¶
NewLimiter creates a Limiter with capacity n. n ≤ 0 defaults to DefaultConcurrency.
type Magus ¶
type Magus struct {
// contains filtered or unexported fields
}
Magus is the high-level orchestrator. Not safe for concurrent use. Inspect-constructed workspaces have no cache.
func Open ¶
Open opens a Magus orchestrator rooted at root with cache and telemetry. It evaluates magusfiles first, so project registration and any remote-cache wiring are set up before the cache is built. Use Inspect for read-only callers that need no cache.
Example ¶
ExampleOpen shows the canonical entry point: open a Magus orchestrator rooted at "." and run a target across every project.
m, err := Open(context.Background(), ".")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
targets, err := m.ExpandPath(types.Target{Name: "build"})
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
if err := m.Run(context.Background(), targets); err != nil {
fmt.Fprintln(os.Stderr, err)
}
func (*Magus) AffectedFromPaths ¶
func (m *Magus) AffectedFromPaths(ctx context.Context, paths []string) (*types.AffectedResult, error)
AffectedFromPaths computes the affected set from an explicit file list.
func (*Magus) Affinity ¶
func (m *Magus) Affinity(ctx context.Context, opts types.InsightOptions) (types.AffinityOutput, error)
Affinity is the temporal-coupling lens: projects that change together, with the pairs that lack any declared dependency between them flagged as hidden affinity.
func (*Magus) CleanCache ¶
CleanCache removes all cached build entries for the given projects. Pass no projects to clear the entire cache.
func (*Magus) CleanOutputs ¶
func (m *Magus) CleanOutputs(ctx context.Context, projects []*types.Project, dryRun bool) ([]string, error)
CleanOutputs removes files matched by each project's declared Outputs globs. It returns the list of removed absolute file paths. When dryRun is true, no files are deleted — only the matched paths are collected and returned.
func (*Magus) Close ¶
Close releases workspace resources (VM pools); cache and limiter are caller-owned.
func (*Magus) DescribeEvaluatedProjects ¶
func (m *Magus) DescribeEvaluatedProjects() types.EvaluatedProjectsOutput
DescribeEvaluatedProjects returns the fully-evaluated project inventory.
func (*Magus) DescribeGraph ¶
func (m *Magus) DescribeGraph() types.TargetGraphOutput
DescribeGraph returns the target dependency graph of each project, extracted statically from its magusfile (no target body is evaluated). Buzz magusfiles are supported; a project on any other engine yields an engine-tagged entry with no nodes until that extractor lands.
func (*Magus) DescribeProjects ¶
func (m *Magus) DescribeProjects() types.ProjectsOutput
DescribeProjects returns the project inventory of the workspace.
func (*Magus) DescribeSpells ¶
func (*Magus) DescribeSpells() types.SpellsOutput
DescribeSpells returns the catalog of registered spells, sorted by name.
func (*Magus) DescribeTarget ¶
DescribeTarget returns the fully-evaluated dispatch plan for t.
func (*Magus) DescribeTargets ¶
func (m *Magus) DescribeTargets() types.TargetsOutput
DescribeTargets enumerates targets known in the workspace.
func (*Magus) DescribeWorkspaces ¶
func (m *Magus) DescribeWorkspaces(cfg types.WorkspaceConfig) types.WorkspacesOutput
DescribeWorkspaces returns the single-entry view of m's workspace. A *Magus is always exactly one workspace; the CLI's `describe workspaces` merges these across the daemon's declared roots when daemon.workspaces is set.
func (*Magus) ExpandAffected ¶
func (m *Magus) ExpandAffected(ctx context.Context, target string, baseRef string) (targets []types.Target, source string, fellBack bool, err error)
ExpandAffected resolves targets for VCS-affected projects; falls back to all projects on VCS failure. fellBack is true precisely when the VCS couldn't compute a definitive set and every project was selected as a safety net — a typed signal callers can act on (e.g. annotate the plan) rather than parsing the free-text source string, which on the fallback path carries the underlying error message.
Example ¶
ExampleMagus_ExpandAffected shows how to compute the VCS-diff affected project set, with automatic fallback to all projects when the VCS command is unavailable (shallow clone, missing binary, etc.).
m, err := Open(context.Background(), ".")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
targets, source, _, err := m.ExpandAffected(context.Background(), "test", "")
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
fmt.Printf("[%s]\n", source)
for _, t := range targets {
fmt.Println(" ", t.Path)
}
func (*Magus) ExpandCwd ¶
ExpandCwd resolves t for the project containing cwd; found=false when cwd is not inside any project.
func (*Magus) ExpandPath ¶
ExpandPath resolves the target pattern to concrete per-project targets; empty or "/" fans out to all.
func (*Magus) ExportCache ¶
ExportCache writes the entire cache to w as a gzip-compressed tar archive. Returns types.ErrNoCache on Inspect workspaces.
func (*Magus) FindOutputOwner ¶
FindOutputOwner returns the first project whose declared Outputs globs match absPath. absPath must be an absolute filesystem path. Returns nil when no project claims the path.
func (*Magus) Hotspots ¶
func (m *Magus) Hotspots(ctx context.Context, opts types.InsightOptions) (types.HotspotOutput, error)
Hotspots is the churn × complexity lens. The project view is the dependency graph heat-coloured by churn (with authors, recency, blast radius, and CI duration on each node); --files ranks individual files by edit frequency weighted by complexity.
func (*Magus) ImportCache ¶
ImportCache extracts a gzip-compressed tar archive produced by Magus.ExportCache. Returns types.ErrNoCache on Inspect workspaces.
func (*Magus) LogScope ¶
LogScope emits a scope header through the cache logger. No-op on Inspect workspaces.
func (*Magus) Ownership ¶
func (m *Magus) Ownership(ctx context.Context, opts types.InsightOptions) (types.OwnershipOutput, error)
Ownership is the knowledge-risk lens: author concentration, bus factor, and abandonment (projects gone quiet in the recent half of the window).
func (*Magus) Plan ¶
Plan computes a provider-neutral CI shard plan for the affected project set using target as the CI target (typically "ci"). Adaptive sharding is applied when runtime history is available at the resolved HistoryPath.
func (*Magus) PruneCache ¶
func (m *Magus) PruneCache(ctx context.Context, cutoff time.Time, dryRun bool) (removed int, freed int64, err error)
PruneCache removes entries older than cutoff and GC-collects orphaned blobs.
func (*Magus) PruneRemoteCache ¶
func (m *Magus) PruneRemoteCache(ctx context.Context, olderThan time.Duration, keepLast int, dryRun bool) error
PruneRemoteCache evicts entries from the configured remote cache backend per a retention policy (age and/or newest-N). Errors when no remote backend is wired, the backend can't prune, or it's inactive here. Scalar args keep this public facade free of the internal cache.RetentionPolicy type.
func (*Magus) ResolveProjects ¶
ResolveProjects resolves targets to project records; unmatched targets are silently dropped.
func (*Magus) Run ¶
Run executes targets against their projects. Independent pairs run concurrently up to the limiter budget. "ci" is an ordinary magusfile target (compose its pipeline with magus.needs); magus no longer hardcodes a CI chain.
func (*Magus) RunAffected ¶
RunAffected computes the VCS-diff target set and runs target on it.
func (*Magus) RunCI ¶
RunCI runs the ci target(s) with write mode forced off. "ci" is an ordinary magusfile-defined target; magus keeps it only as the affected-set anchor, not a hardcoded preflight...test chain. The magusfile composes the pipeline order via magus.needs.
func (*Magus) SetGraphObserver ¶
SetGraphObserver installs an observer on the workspace; pass nil to clear.
func (*Magus) Stream ¶
func (m *Magus) Stream(ctx context.Context, r io.Reader, target string, errFn func(error), opts ...StreamOption) error
Stream reads file-path batches from r and runs target on the affected projects. Builds run synchronously; batches arriving during a build are merged and run after. StreamAllSentinel triggers a full-workspace build. Per-batch errors go to errFn.
func (*Magus) TailLog ¶
TailLog returns the log-file path of the most recent cache entry for projectPath, optionally restricted to target. Wraps fs.ErrNotExist when not found; types.ErrNoCache on Inspect.
func (*Magus) Trend ¶
func (m *Magus) Trend(ctx context.Context, opts types.InsightOptions) (types.TrendOutput, error)
Trend is the rising/cooling lens: each project's churn in the recent vs earlier half of the window.
func (*Magus) VCSOptions ¶
func (m *Magus) VCSOptions() types.VCSOptions
type Option ¶
Option configures Open or Inspect.
func WithConfigFile ¶
WithConfigFile causes the constructor to load magus.yaml from path instead of <root>/magus.yaml.
func WithLimiter ¶
WithLimiter injects a pre-built Limiter (e.g. shared across daemon workspaces). When omitted, Open constructs a private limiter from magus.yaml/Concurrency.
func WithLoadedConfig ¶
WithLoadedConfig injects an already-parsed configuration, bypassing the default magus.yaml discovery. Env-var and flag overrides should be applied before calling this.
func WithWorkspaceRegistry ¶
func WithWorkspaceRegistry(reg *WorkspaceRegistry) Option
WithWorkspaceRegistry injects a pre-built WorkspaceRegistry, replacing the default one.
type PlanOptions ¶
type PlanOptions struct {
// MaxShards caps the number of CI shards. -1 = unlimited; 0 uses the
// value from magus.yaml (CI.MaxShards).
MaxShards int
// RunnerPoolBudget limits cross-shard concurrency. 0 = unlimited.
RunnerPoolBudget int
// HistoryPath overrides the configured history_path when non-empty.
HistoryPath string
}
PlanOptions configures a Magus.Plan call.
type ProjectOption ¶
type ProjectOption = workspace.ProjectOption
ProjectOption mutates a Project at registration time. A non-nil error aborts Open.
func WithDependsOn ¶
func WithDependsOn(paths ...string) ProjectOption
WithDependsOn adds upstream project paths as dependencies (repo-relative or project-relative).
func WithExclusive ¶
func WithExclusive() ProjectOption
WithExclusive marks a project as must-not-run-alongside-peers (also serializes multi-spell fan-out).
func WithOutputs ¶
func WithOutputs(paths ...string) ProjectOption
WithOutputs declares the project-relative file globs this project produces.
func WithSpell ¶
func WithSpell(name string, opts ...BindingOption) ProjectOption
WithSpell registers a built-in spell by name; multiple calls fan out in parallel (sequential with WithExclusive).
func WithTarget ¶
func WithTarget(name string, opts ...TargetOption) ProjectOption
WithTarget attaches a behavioural policy to the named target; multiple calls are merged.
func WithWatchIgnore ¶
func WithWatchIgnore(patterns ...types.IgnorePattern) ProjectOption
WithWatchIgnore appends patterns to the project's watch ignore list; malformed patterns error at Open.
type ReportWriter ¶
type ReportWriter struct {
// contains filtered or unexported fields
}
ReportWriter is an async JSONL event sink for run telemetry. Create one with NewReportWriter, pass it to Run via WithReport, and close it after the run completes.
func NewReportWriter ¶
func NewReportWriter(dst io.Writer, filter []string) (*ReportWriter, error)
NewReportWriter constructs a ReportWriter that writes JSONL events to dst. filter is an optional list of event-type terms; an empty or nil slice disables filtering (all events pass through).
func (*ReportWriter) Close ¶
func (rw *ReportWriter) Close() error
Close flushes and closes the writer. Must be called after the run finishes.
func (*ReportWriter) GraphObserver ¶
func (rw *ReportWriter) GraphObserver() types.Observer
GraphObserver returns an types.Observer that records graph-traversal events to this writer. Pass the result to Magus.SetGraphObserver.
func (*ReportWriter) RecordShardTotal ¶
RecordShardTotal appends a shard-level wall-clock observation (job start → last project end) for adaptive CI forecast. Call after the run completes when running in a CI matrix; shardID and nShards come from --shard / --n-shards.
type RunOption ¶
type RunOption func(*run)
RunOption configures a Magus.Run, Magus.RunCI, or Magus.RunAffected invocation.
func WithBaseRef ¶
WithBaseRef overrides MAGUS_VCS_BASE_REF for RunAffected invocations.
func WithCharms ¶
WithCharms sets execution charms propagated to spells via context.
func WithDryRun ¶
func WithDryRun() RunOption
WithDryRun prints what would run without invoking any handler.
func WithExtraArgs ¶
WithExtraArgs forwards args to spells via project.WithExtraArgs.
func WithNoFlakeRetry ¶
func WithNoFlakeRetry() RunOption
WithNoFlakeRetry disables the flake auto-retry logic.
func WithRace ¶
func WithRace() RunOption
WithRace enables race-condition diagnostics (MGS4001/4002/4004). Diagnostic only.
func WithRaceReplay ¶
func WithRaceReplay() RunOption
WithRaceReplay enables determinism replay (MGS4003). Compose with WithRace for MGS4001/4002/4004.
func WithReport ¶
func WithReport(rw *ReportWriter) RunOption
WithReport attaches rw to receive one JSONL event per executed target. Mutually exclusive with WithReportWriter.
func WithReportWriter ¶
WithReportWriter streams one JSONL event per target to w; the run engine constructs and closes the report.Writer around it.
func WithSpellFilter ¶
WithSpellFilter restricts Run to projects that have the named spell.
func WithStep ¶
func WithStep() RunOption
WithStep enables per-subprocess stepping mode; forces Concurrency=1.
func WithTargetNameNormalizer ¶
func WithTargetNameNormalizer(n types.TargetNameNormalizer) RunOption
WithTargetNameNormalizer overrides how exported-function identifiers are converted to target names. Defaults to kebab-case via lo.KebabCase.
type StreamOption ¶
type StreamOption func(*streamOpts)
StreamOption configures a [Stream] invocation.
func WithStreamDryRun ¶
func WithStreamDryRun() StreamOption
WithStreamDryRun prints what would run without invoking handlers.
func WithStreamExtraArgs ¶
func WithStreamExtraArgs(args []string) StreamOption
WithStreamExtraArgs forwards args to spells via project.WithExtraArgs.
func WithStreamNull ¶
func WithStreamNull() StreamOption
WithStreamNull expects NUL-separated paths and double-NUL batch boundaries.
type TargetHandler ¶
TargetHandler runs one target on one resolved project. It is the single executor seam the run pipeline schedules: the same handler serves both a real run and a dry run - types.WithTrace(ctx) switches it, so under a tracing context the effect boundary (proc/run.Exec, fs, net) records each op's intent and skips it instead of executing. One path, two modes: no separate dry-run executor, just a tracing context over this one contract. (The in-browser evaluator in internal/dry is a different thing - it takes raw source, never a resolved *Project, so it sits before this seam and cannot implement it; see that package's doc.)
type TargetOption ¶
type TargetOption = workspace.TargetOption
TargetOption sets a per-target execution-policy field at registration time.
func Exclusive ¶
func Exclusive() TargetOption
Exclusive runs the target alone — no other target runs concurrently while it does.
func FailOnDrift ¶
func FailOnDrift() TargetOption
FailOnDrift enables the drift gate: fail if the working tree is dirty after the target.
func RetryOnFlake ¶
func RetryOnFlake() TargetOption
RetryOnFlake enables flake detection and auto-retry for this target.
type WorkspaceRegistry ¶
type WorkspaceRegistry = workspace.WorkspaceRegistry
WorkspaceRegistry holds project-option overrides and target policies for a single Open.
Example (WithSpell) ¶
ExampleWorkspaceRegistry_withSpell shows the recommended way to attach a spell to a project using the string-name API. The registry is passed to Inspect or Open via WithWorkspaceRegistry.
reg := NewWorkspaceRegistry()
reg.RegisterProject(
"api",
WithSpell("go"),
)
// pass reg to Inspect or Open:
// Inspect(ctx, root, WithWorkspaceRegistry(reg))
func NewWorkspaceRegistry ¶
func NewWorkspaceRegistry() *WorkspaceRegistry
NewWorkspaceRegistry returns an empty WorkspaceRegistry.
func WorkspaceRegistryFromContext ¶
func WorkspaceRegistryFromContext(ctx context.Context) *WorkspaceRegistry
WorkspaceRegistryFromContext returns the WorkspaceRegistry from ctx, or nil.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
buzz-playground
command
Command buzz-playground is the browser entry point for the Buzz playground.
|
Command buzz-playground is the browser entry point for the Buzz playground. |
|
coverage-badge
command
coverage-badge renders a badge SVG to stdout from a label, message, and color via github.com/narqo/go-badge.
|
coverage-badge renders a badge SVG to stdout from a label, message, and color via github.com/narqo/go-badge. |
|
langservice-manifest
command
Command langservice-manifest regenerates internal/langservice/manifest_data.go: a build-time snapshot of the magus host module surface (every module, with its fields and methods and rendered Buzz signatures) that the browser playground's completion and hover read.
|
Command langservice-manifest regenerates internal/langservice/manifest_data.go: a build-time snapshot of the magus host module surface (every module, with its fields and methods and rendered Buzz signatures) that the browser playground's completion and hover read. |
|
magus
command
Command magus is the magus CLI: a standalone build orchestrator and content-addressed cache for multi-language monorepos, and an evolution of Mage.
|
Command magus is the magus CLI: a standalone build orchestrator and content-addressed cache for multi-language monorepos, and an evolution of Mage. |
|
magus-configdocs
command
Command magus-configdocs generates the magus.yaml configuration reference from the code-generated schema inventory.
|
Command magus-configdocs generates the magus.yaml configuration reference from the code-generated schema inventory. |
|
magus-docs
command
Command magus-docs generates Markdown documentation for every module registered in the host package.
|
Command magus-docs generates Markdown documentation for every module registered in the host package. |
|
magus-manpage
command
Command magus-manpage generates magus man pages from the CLI registry.
|
Command magus-manpage generates magus man pages from the CLI registry. |
|
magus-spelldocs
command
Command magus-spelldocs generates Markdown reference documentation for every built-in spell in the internal/spell registry.
|
Command magus-spelldocs generates Markdown reference documentation for every built-in spell in the internal/spell registry. |
|
magus-utils
command
Subcommand `bindings` emits per-VM trampoline code from std.Module declarations.
|
Subcommand `bindings` emits per-VM trampoline code from std.Module declarations. |
|
magus/gen
Code generated by magus-utils config; DO NOT EDIT.
|
Code generated by magus-utils config; DO NOT EDIT. |
|
Package host is the host↔Buzz boundary: it owns how the std host-binding descriptors (std.Module/Method/Field) project onto the Buzz VM, in both directions and at both build and run time.
|
Package host is the host↔Buzz boundary: it owns how the std host-binding descriptors (std.Module/Method/Field) project onto the Buzz VM, in both directions and at both build and run time. |
|
internal
|
|
|
audit
Package audit detects cross-project writes: when a spell's downward walk crosses into a descendant project.
|
Package audit detects cross-project writes: when a spell's downward walk crosses into a descendant project. |
|
cache
Package cache implements magus's content-addressed build cache.
|
Package cache implements magus's content-addressed build cache. |
|
cache/reflink
Package reflink copies regular files using the most efficient mechanism the host platform and filesystem provide, transparently falling back to a plain userspace copy where no acceleration is available.
|
Package reflink copies regular files using the most efficient mechanism the host platform and filesystem provide, transparently falling back to a plain userspace copy where no acceleration is available. |
|
ci
Package ci computes provider-agnostic fan-out plans for CI systems from a magus workspace.
|
Package ci computes provider-agnostic fan-out plans for CI systems from a magus workspace. |
|
ci/flake
Package flake provides Wilson-score flakiness prediction and auto-retry for magus test runs.
|
Package flake provides Wilson-score flakiness prediction and auto-retry for magus test runs. |
|
ci/forecast
Package forecast picks an adaptive CI shard count using a USL model (N* = sqrt(W/α)) and packs projects via LPT bin-packing.
|
Package forecast picks an adaptive CI shard count using a USL model (N* = sqrt(W/α)) and packs projects via LPT bin-packing. |
|
codec
Package codec provides the serialization and compression primitives magus uses for cache manifests and report streams: pluggable streaming JSON encoders/decoders and zstd/xz compressors.
|
Package codec provides the serialization and compression primitives magus uses for cache manifests and report streams: pluggable streaming JSON encoders/decoders and zstd/xz compressors. |
|
config
Package config holds the magus configuration schema and yaml-based loader.
|
Package config holds the magus configuration schema and yaml-based loader. |
|
config/gen
Code generated by magus-utils config; DO NOT EDIT.
|
Code generated by magus-utils config; DO NOT EDIT. |
|
depgraph
Package depgraph constructs the project dependency DAG, translating path strings to node IDs.
|
Package depgraph constructs the project dependency DAG, translating path strings to node IDs. |
|
describe
Package describe extracts a magusfile's target dependency graph statically, without evaluating any target body.
|
Package describe extracts a magusfile's target dependency graph statically, without evaluating any target body. |
|
docs
Package docs holds the shared rendering helpers the docs generators (cmd/magus-docs, cmd/magus-spelldocs) use to emit the committed Markdown under docs/**.
|
Package docs holds the shared rendering helpers the docs generators (cmd/magus-docs, cmd/magus-spelldocs) use to emit the committed Markdown under docs/**. |
|
doctor
Package doctor validates a magus workspace and reports health checks.
|
Package doctor validates a magus workspace and reports health checks. |
|
dry
Package dry is the in-process, non-executing magus evaluator: it runs Buzz source and magusfiles with every host effect (subprocess, filesystem, network) replaced by an in-memory tracer, then reports the project graph and the dry-run op trace instead of running anything.
|
Package dry is the in-process, non-executing magus evaluator: it runs Buzz source and magusfiles with every host effect (subprocess, filesystem, network) replaced by an in-memory tracer, then reports the project graph and the dry-run op trace instead of running anything. |
|
file
Package file provides filesystem primitives used across the magus module.
|
Package file provides filesystem primitives used across the magus module. |
|
file/diff
Package diff provides mtime+size snapshot diffing for attributing concurrent file writes.
|
Package diff provides mtime+size snapshot diffing for attributing concurrent file writes. |
|
file/watch
Package watch provides a cross-platform filesystem watcher with recursive directory tracking, debouncing, and ignore filtering.
|
Package watch provides a cross-platform filesystem watcher with recursive directory tracking, debouncing, and ignore filtering. |
|
interactive
Package interactive provides project scoring and session-state persistence for the magus x shorthand command.
|
Package interactive provides project scoring and session-state persistence for the magus x shorthand command. |
|
interactive/tty
Package tty is a minimal interactive list picker for the magus CLI.
|
Package tty is a minimal interactive list picker for the magus CLI. |
|
interp
Package interp compiles and runs magusfile sources via the Buzz scripting backend.
|
Package interp compiles and runs magusfile sources via the Buzz scripting backend. |
|
interp/bindings
Package bindings registers the Go-backed modules (magus, std: os, platform, fs, vcs, env, crypto, json, log, http, archive) available to every magusfile script.
|
Package bindings registers the Go-backed modules (magus, std: os, platform, fs, vcs, env, crypto, json, log, http, archive) available to every magusfile script. |
|
interp/engine
Package engine defines the Engine and Session interfaces that all scripting engine implementations must satisfy, along with the engine registry.
|
Package engine defines the Engine and Session interfaces that all scripting engine implementations must satisfy, along with the engine registry. |
|
interp/engine/buzz
Package buzz adapts the standalone Buzz interpreter (magus/gopherbuzz) to magus's engine.Engine/engine.Session interfaces and registers it under the "buzz" key.
|
Package buzz adapts the standalone Buzz interpreter (magus/gopherbuzz) to magus's engine.Engine/engine.Session interfaces and registers it under the "buzz" key. |
|
langservice
Package langservice provides editor language features - completion and hover - for Buzz magusfiles, driven by a build-time snapshot of the magus host module surface (see cmd/langservice-manifest and manifest_data.go).
|
Package langservice provides editor language features - completion and hover - for Buzz magusfiles, driven by a build-time snapshot of the magus host module surface (see cmd/langservice-manifest and manifest_data.go). |
|
manpage
Writer (this file) emits the groff_man(7) subset that magus's man pages use; the Escape* helpers handle roff special characters.
|
Writer (this file) emits the groff_man(7) subset that magus's man pages use; the Escape* helpers handle roff special characters. |
|
mcp/auth
Package auth manages the shared-secret bearer token that guards the magus MCP HTTP endpoint and provides the HTTP middleware that enforces it.
|
Package auth manages the shared-secret bearer token that guards the magus MCP HTTP endpoint and provides the HTTP middleware that enforces it. |
|
mcp/origin
Package origin carries agent origin metadata across goroutines via context.
|
Package origin carries agent origin metadata across goroutines via context. |
|
observability
Package observability provides OpenTelemetry instrumentation for magus.
|
Package observability provides OpenTelemetry instrumentation for magus. |
|
playground
Package playground is the browser front end for the Buzz playground: the terminal Console (command dispatch, completion, history, rendering to HTML rows), editor syntax Highlight, and the Share deep-link codec.
|
Package playground is the browser front end for the Buzz playground: the terminal Console (command dispatch, completion, history, rendering to HTML rows), editor syntax Highlight, and the Share deep-link codec. |
|
proc
Package proc implements the magus "process adoption" mechanism: child magus processes detect MAGUS_DAEMON_SOCKET and forward work over a Unix-domain socket RPC, sharing the parent's cache, logger, and concurrency budget.
|
Package proc implements the magus "process adoption" mechanism: child magus processes detect MAGUS_DAEMON_SOCKET and forward work over a Unix-domain socket RPC, sharing the parent's cache, logger, and concurrency budget. |
|
proc/run
Package run is the shared subprocess helper for magus spells.
|
Package run is the shared subprocess helper for magus spells. |
|
race
Package race detects filesystem race conditions across concurrently executing projects.
|
Package race detects filesystem race conditions across concurrently executing projects. |
|
render
Package render contains graph presentation helpers: ASCII tree, DOT, and Mermaid formatters.
|
Package render contains graph presentation helpers: ASCII tree, DOT, and Mermaid formatters. |
|
report
Package report writes per-task JSONL events for post-processing.
|
Package report writes per-task JSONL events for post-processing. |
|
retry
Package retry provides exponential-backoff retry helpers: Do runs an arbitrary operation with capped, context-aware backoff, and NewHTTPClient wraps an http.Client so idempotent requests retry on transport errors and 5xx responses (honouring Retry-After).
|
Package retry provides exponential-backoff retry helpers: Do runs an arbitrary operation with capped, context-aware backoff, and NewHTTPClient wraps an http.Client so idempotent requests retry on transport errors and 5xx responses (honouring Retry-After). |
|
sandbox
Package sandbox confines spell code to a workspace-bounded filesystem and environment.
|
Package sandbox confines spell code to a workspace-bounded filesystem and environment. |
|
sandbox/apply
Package apply builds per-workspace sandbox policies from config and owns the process-wide landlock application state.
|
Package apply builds per-workspace sandbox policies from config and owns the process-wide landlock application state. |
|
sandbox/env
Package env holds the environment half of a sandbox policy: the allowlist of variable names a child process may inherit and the scrubbing logic.
|
Package env holds the environment half of a sandbox policy: the allowlist of variable names a child process may inherit and the scrubbing logic. |
|
sandbox/filesystem
Package filesystem holds the filesystem half of a sandbox policy: the path allowlist (Ruleset) and path-shape checks consulted before touching the filesystem.
|
Package filesystem holds the filesystem half of a sandbox policy: the path allowlist (Ruleset) and path-shape checks consulted before touching the filesystem. |
|
selfupdate
Package selfupdate downloads, verifies, and installs magus release binaries.
|
Package selfupdate downloads, verifies, and installs magus release binaries. |
|
service
Package service supervises long-running shared services and their lifecycle.
|
Package service supervises long-running shared services and their lifecycle. |
|
serviceaudit
Package serviceaudit bridges magus's resolved projects to the pure near-duplicate detector in internal/serviceident.
|
Package serviceaudit bridges magus's resolved projects to the pure near-duplicate detector in internal/serviceident. |
|
serviceident
Package serviceident derives the identity of a long-running service from its resolved process command, for two purposes:
|
Package serviceident derives the identity of a long-running service from its resolved process command, for two purposes: |
|
spell
Package spell holds the engine-agnostic spell types and the built-in spell registry: the Descriptor / Target / Charm value types the Buzz spell engine speaks, kept free of engine imports so the type package stays a neutral boundary.
|
Package spell holds the engine-agnostic spell types and the built-in spell registry: the Descriptor / Target / Charm value types the Buzz spell engine speaks, kept free of engine imports so the type package stays a neutral boundary. |
|
ward
Package ward runs "kind-coherence" checks on a resolved op: it verifies that the op's argv does not contradict the op's declared kind.
|
Package ward runs "kind-coherence" checks on a resolved op: it verifies that the op's argv does not contradict the op's declared kind. |
|
workspace
Package workspace holds the shared building blocks for opening a workspace: the WorkspaceRegistry and the project, spell, and target option constructors that a magusfile's register(...) calls produce, plus the Load accumulator for Open/Inspect.
|
Package workspace holds the shared building blocks for opening a workspace: the WorkspaceRegistry and the project, spell, and target option constructors that a magusfile's register(...) calls produce, plus the Load accumulator for Open/Inspect. |
|
libs
|
|
|
diagnostics
module
|
|
|
gopherbuzz
module
|
|
|
Package project discovers projects within a workspace via magusfile presence and exposes spell-based source/output/dep inference over the types in magus/types.
|
Package project discovers projects within a workspace via magusfile presence and exposes spell-based source/output/dep inference over the types in magus/types. |
|
Package schema provides a code-generated, zero-reflection schema for the magus Config struct.
|
Package schema provides a code-generated, zero-reflection schema for the magus Config struct. |
|
gen
Code generated by magus-utils config; DO NOT EDIT.
|
Code generated by magus-utils config; DO NOT EDIT. |
|
Package std is the single source of truth for host-binding APIs that magusfiles call into.
|
Package std is the single source of truth for host-binding APIs that magusfiles call into. |
|
Package types holds magus's pure domain types.
|
Package types holds magus's pure domain types. |
|
Package vcs provides a VCS interface and built-in implementations for git, hg (Mercurial), and jj (Jujutsu).
|
Package vcs provides a VCS interface and built-in implementations for git, hg (Mercurial), and jj (Jujutsu). |