magus v0.4.3 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
2 min read

Told, never guessed

magus does not guess where it runs to change what it does. It does not read CI, GITHUB_ACTIONS or GITLAB_CI, probe for a container, or work out which agent host is calling, and then pick a default, a result, or which provider or feature is on. When a caller needs different behavior, the caller asks for it: a flag, a charm, a key in magus.yaml, or a variable the workflow sets on purpose. The same command does the same work on a laptop, on a runner and inside an agent's shell.

My words, when this was written down: "We should never be doing environment sniffing, ever. Thinking that we're smarter than the developer, or trying to be too clever, is incredibly dangerous."

The danger is the same one No silent defaults names, arriving from the other side. A guess is a setting nobody wrote. It cannot be read in the file the reader is already looking at, it cannot be turned off without first learning it exists, and it is wrong exactly where the environment differs from the one its author pictured: a self-hosted runner that looks hosted, a laptop with CI=true exported by a test harness, an agent host that happens to share a field name with another. A command that passed locally and failed in CI because magus noticed it was in CI is the worst kind of red, because the difference is invisible in both places.

Two things are not guessing. The first is adapting to the terminal in front of the person: whether a stream is a terminal, what kind and how big, whether it is reached over ssh, and which window a once-only notice belongs to. That decides how magus talks to them (color, links, hover, which prompt it can show), never what work it does. The second is reading the input a caller sent: a flag, an argument, the event a hook was handed. NO_COLOR belongs with them: a person set it to say what they want.

An agent host is a caller like any other, so it says who it is. The hook configuration magus describe harness prints names the host explicitly, and a hook invoked without that name is refused rather than defaulted to one host.

Enforced by

  • TestNoEnvironmentSniffing in conventions_test.go fails the build when code reads a CI, hosting or agent-host variable outside a short list of inputs read after the caller chose them, and the failure says to take a flag instead.

Good

The workflow says what it wants, in the file a reader is already looking at:

- run: magus affected ci --plan -o json

Bad

if runningInCI() {
    opts.NoCache = true
}

runningInCI guesses from the environment. Nobody wrote this setting, nobody can see it from the workflow, and a laptop whose test harness exports the variable it reads gets it too.

See also

designjudgmentconfigurationci
Last updated (2df714e8)
Glossary

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Charm

An execution modifier attached with : (lint:rw) that changes how a target runs, not which one; the built-in rw flips a check-only target to mutate in place, and ci always strips it. Charm in full.

Buzz

The language magusfiles are written in (the .buzz engine). Buzz in full.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. Cache in full.

Affected

The set of projects touched by a change; magus affected <target> runs a target only over them. Affected in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

Agent

A model working through an agent host such as Claude Code, Codex, Cursor or OpenCode. magus treats an agent as one more caller of its CLI, MCP tools and console, held to the same checks as a person. Agent in full.

Harness

The deterministic scaffolding around the work on a change, for a person or an agent: compiler errors, formatters, linters, checks, gates, leases and hooks, placed at points a person chose. Around an agent's loop, magus supplies one and keeps it outside. Harness in full.

Window

The terminal a command runs in. It keys fire-once notices for a caller no host gave a session, and is never recorded as a session. Window in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.