Documentation
¶
Overview ¶
Package command implements the `command` rule type (spec §5): the interim escape hatch for toolchain gates that cannot be expressed declaratively. It runs an external command at the repository root and interprets its exit code (and optionally its output). It is a heavy, whole-run rule: a failure to execute the tool is an engine error (exit 2), never a silent pass (spec §11). Every command rule is enumerated by `formwork lint` (spec §9).
The tool runs with the caller's environment INHERITED UNCHANGED — that is the escape hatch's contract, and this package removes nothing from it. It refuses two states instead, both in ensureRepositoryAgreement, and refusing is what lets the contract stand: nothing is deleted from the tool's environment.
- an ambient POINTER variable (GIT_DIR, GIT_WORK_TREE, GIT_COMMON_DIR) naming a repository other than the one the engine is checking — the one state an identity comparison can SEE (#177);
- any of the OBJECT-STORE family being set at all, which moves which commits and objects git answers from INSIDE the right repository and so is invisible to that comparison (#213).
Both are exit 2, never a finding, and both are lifted by FORMWORK_GIT_ENV= inherit — the same hatch internal/vcs uses, so an operator who has already taken that decision does not meet a second refusal spelled differently.
roottoken.go — the engine owns the tree a detector reads (#28).
A command rule used to name its tree with a path relative to the caller's working directory. `--root ../../..` is correct under `check`, where the cwd is the repository; under `test` the fixture runner makes the fixture tree the cwd and the same three segments land on the repository again, so the fixture judged the real tree. Nothing in the rule distinguished the two planes, because the rule was not the party that knew which plane it was in.
The engine is. It walked or created every tree it evaluates, so it substitutes them:
{{root}} — the tree UNDER EVALUATION: the repository under check, the
fixture tree under test, a scratch under a mutation run.
{{repo}} — the corpus's own tree, so a detector that lives in the
repository is reachable while judging a fixture. The canonical
shape is `go -C {{repo}}/scripts/dev/x run . --root {{root}}`.
Under check the two are the same directory, which is why {{repo}} falls back to Root when the caller set no Repo: a caller that predates the field substitutes the tree it is evaluating rather than an empty path, and an empty path would have made the detector read the filesystem root.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCompiledBinary ¶
func WithCompiledBinary(c rules.Checker, binary string, progArgs []string, workDir string) (rules.Checker, bool)
WithCompiledBinary returns a checker that runs binary with progArgs instead of the original go-run argv. workDir, when non-empty, overrides FinalizeContext.Root as the subprocess cwd (needed for go -C shapes). Returns false when c is not a command checker — callers fall back to the original argv.
Used only by fixturetest compile-once. The formwork check path never calls this, so production evaluation keeps cold go-run semantics. The returned checker collapses non-zero exits to match `go run` (exit 1 + "exit status N" on CombinedOutput) so formwork test and formwork check observe the same codes.
Types ¶
This section is empty.