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

A copy can be the right answer

Merge duplicates only when they share semantics, policy knobs, and bugs: a bug in one is a bug in the other. Otherwise keep them apart, with one line saying why. Share small things (a type, a classification) before sharing loops.

Code shared only because it looks alike couples parts that change for different reasons. That coupling grows until one change breaks something far away. This prevents the abstraction that is cheap to write and costly to change, and it is why a deliberate copy carries its reason beside it.

Enforced by

  • Review. The duplication lens of magus\insight() finds functions that call the same symbols in the same proportions; it reports and never decides.

Good

A copy with its reason beside it, from docs/lib/design.buzz:

// A design page's title is plain text; a quoted one loses only its quotes, since the
// conventions check that would unescape it imports this file.
fun unquoted(v: str) > str {

Bad

// parseConfig handles both magus.yaml and the job store.
func parseConfig(path string, strict, jsonLines, allowUnknown bool) (any, error)

Two formats with different rules now share one function and four flags. A fix for the job store changes how magus.yaml reads, and every caller has to know which flags its format needs.

See also

designprinciplecode
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.

Buzz

The language magusfiles are written in (the .buzz engine). Buzz 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.

Insight

The reports magus derives over the graph and history (hotspots, affinity, ownership, trend, volatility, unreferenced). Insight in full.

Job

The unit of delegated work, and one row of the job store: what an orchestrating agent handed out, with its goal, the checkpoint it was cut against, the paths it may write or must not touch, and the one check it runs. A job's holder is either a session, for work an orchestrator handed out, or the daemon, for its own maintenance. The store records; the agent guard is what reads those facts back when grading a write. Job in full.

Conventions

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