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

grep-reader

A deny rule by default: it refuses a definition lookup with a context flag (grep -A40 'func X'), which uses grep to read the body, and names what to run instead.

What it catches

A definition lookup with a context flag (grep -A40 'func X'), which uses grep to read the body.

Why

A context count guesses at a declaration's length: too short cuts the body off and costs another call, too long spends lines on whatever follows. magus refs X --definition --source prints the declaration whole, numbered and checked against the index. Where the index cannot vouch for the name, the deny serves sed -n <first>,<last>p <file> instead, the declaration's own lines from a parse of the file the search reads (a named file or glob, or under a directory the files the index last saw name it). The single-file allowance symbol-search gives grep -n 'func X' f.go does not apply: with -A, -B or -C the search is the read. A deny resting on the index advises instead while the graph describes another tree, as graph-stale; one parsed from a named file does not. It fires only when every alternative is a definition lookup (func X, func (r *T) X, type X, type X struct) and a declaration of each name is found; a search for uses, a case-insensitive one, or one with any text alternative is left to the search rules. A pipe after it is named as not reproduced.

Default and override

By default this rule takes the decision deny. A workspace sets it by name, in its root magusfile, to deny, advise or off:

magus\guard.builtins({"grep-reader": "advise"})

A loosening takes effect once it is committed; a tightening applies at once.

Seeing it

A verdict names its rule in brackets, which is how you got here:

deny [grep-reader]: ...

A workspace that sets this rule to advise sees advise [grep-reader]: ... instead.

magus describe rule grep-reader prints the same entry at a terminal, and magus describe rules lists every rule this workspace enforces.

See also

guardrulesgrep-readerdeny
Last updated (c6a327d5)
Earlier changes on this page (5)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. Workspace in full.

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. Magusfile 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.

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.

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

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.