Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

brink fix

brink fix is cargo fix/eslint --fix for brink diagnostics: it applies every fixer the project’s policy admits, re-analyzes, and repeats until the project reaches a fixpoint (or a round cap). It shares its batching engine (brink_ide::fix) with the Studio’s “Fix all safe” and the LSP’s source.fixAll.brink, so the three surfaces never disagree about what a batch does — see docs/autofix-spec.md for the full model (tiers, batching algorithm, policy).

brink fix <PATH> [--dry-run] [--diff [FILE]] [--suggested [CODES]] \
                  [--placeholder] [--code CODES] [--max-rounds N]

PATH is an entry file — an .ink or .brink source — addressed exactly like brink compile: a brink.toml is discovered from its directory and INCLUDEs (or the native module graph) are followed to build the whole project. A bare file with no discovered brink.toml is the same code path, not a separate mode — it just resolves every fixer’s policy to its tier default (see Tiers below).

Tiers

Every fixer declares a tier, and the tier decides whether brink fix may apply it without being told to:

TierMeaningDefault policy
SafeObservably equivalent to the original — batched unconditionallyAlways applied
SuggestedProbably what the author meant, but changes meaning or loses textApplied only when the project (or --suggested) promotes the code
PlaceholderLeaves a hole the author must fill by handNever applied — --placeholder only lists these

A project’s brink.toml [fix] table promotes or withdraws individual codes:

[fix]
E033 = "auto"   # promote a Suggested fixer to batch in this project
E014 = "off"    # never offer this fixer here

Options

FlagDefaultDescription
--dry-runoffPrint the report; write nothing to disk.
--diff [FILE]offEmit a git apply-able unified diff instead of writing — to stdout, or to FILE if given. Implies no disk write, like --dry-run. Composes with --dry-run rather than one silently overriding the other: the diff still goes to its destination, and the report is printed to stderr (never stdout, which must stay a clean patch). A capped run (exit 1) always prints the report to stderr too, with or without --dry-run, so the exit code is never unexplained.
--suggested [CODES]offPromote the Suggested tier to batchable for this run only. Bare, it promotes every Suggested-tier fixer except one the project’s [fix] table set to "off" (off still means off — a codeless flag isn’t the explicit action that widens it); --suggested E025,E080 names codes explicitly and so wins over [fix] for those, even over an "off" entry (CLI beats file, like -D/--warn/--allow beat [lints]).
--code CODESevery codeRestrict the run to these diagnostic codes (comma-separated, e.g. E025,E080). An unrecognized code is a hard error, not a silent no-op.
--placeholderoffAlso report every Placeholder-tier fix available, on stderr — never applied, since a Placeholder fix always leaves a hole. Written to stderr (not stdout) so it never lands inside a --diff patch piped to git apply. Useful with --dry-run to see where an author still needs to fill something in.
--max-rounds N5Round cap for the fixpoint loop. A fixer that never discharges its own diagnostic surfaces as a cap breach naming it, rather than looping forever.

With none of --dry-run/--diff given, brink fix writes every file the batch actually changed and prints a short report.

Exit codes

CodeMeaning
0The fixpoint was reached — every admitted fix converged within the round cap.
1The round cap was hit, or a fixer failed to discharge its own diagnostic (the report names it either way).
2Usage error (a bad path, an unrecognized --code/--suggested code, an I/O failure).

Examples

# Apply every Safe fix (and anything the project's [fix] table promotes),
# write the files.
brink fix story.ink

# See what would change, without writing anything.
brink fix story.ink --dry-run

# Get a patch instead of a write — pipe straight into `git apply`.
brink fix story.ink --diff | git apply

# Preview the patch AND see the report, without piping into git apply —
# --diff composes with --dry-run: stdout stays a clean patch, the report
# (fix count, and why a capped run exited 1) goes to stderr.
brink fix story.ink --diff --dry-run

# Promote every Suggested fixer for one run, without editing brink.toml.
brink fix story.ink --suggested

# Promote just E025 (missing-import) for one run.
brink fix story.ink --suggested E025

# Restrict the batch to one code, e.g. while triaging a specific diagnostic.
brink fix story.ink --code E025

# See where an author still has to fill in a required attribute by hand.
brink fix story.ink --dry-run --placeholder