command

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 NewChecker added in v0.9.1

func NewChecker(params *yaml.Node) (rules.Checker, error)

NewChecker builds the command checker from a params node. forbidden-pattern census mode delegates to it so a document census keeps this runner — argv, expect, findings-v1, {{root}}/{{repo}}, the git-env refusal — while the rule type stays forbidden-pattern and the wrapper does not declare a cost.

func ParentSegmentArg added in v0.7.1

func ParentSegmentArg(argv []string) (string, bool)

ParentSegmentArg reports the first argument naming a parent directory.

It asks about PATH SEGMENTS, not about the characters `..`: an argument is refused when a `..` stands alone between separators (or at either end), which is what a filesystem reads as "up one". A regex like `a..b`, a version like `x...y`, an ellipsis in a message: none of those is a segment, none is refused. Getting that boundary wrong in the refusing direction would be the worse failure — a corpus that cannot express a pattern is a corpus that reaches for a shell script instead.

func ParentSegmentProblem added in v0.7.1

func ParentSegmentProblem(ruleID, arg string) string

ParentSegmentProblem is the lint finding, and it carries the migration rather than the complaint: the author is one substitution away from the shape that works on every plane.

It is a LINT check rather than a load refusal (#28). Refusing at load makes every corpus written before the tokens unreadable, and the tools that read one are the ones that most need to: the vacuity census loads the corpus as it stood at a change's merge base to tell a new rule from an edited one, and a base it cannot parse is a transition it cannot compute. Lint runs on every pull request, so the shape still cannot merge; what it no longer does is make history unreadable.

func WithCompiledBinary

func WithCompiledBinary(c rules.Checker, binary string, progArgs []string, workDir string) (rules.Checker, bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL