CLI Reference
CLI commands
Section titled “CLI commands”The gov command provides three subcommands:
# Run a governed buildgov run -- cmake --build . --parallel 16
# Run without auto-starting governor (fail if not running)gov run --no-start -- ninja -j 8
# Check governor status (tokens, leases, commit charge)gov status
# Show helpgov helpgov run
Section titled “gov run”Wraps a build command with governed cl.exe and link.exe:
- Locates the published wrapper directory (searches multiple candidate paths)
- Checks if the governor is running (connects via named pipe with 500 ms timeout)
- If not running and
--no-startis not set, starts the governor and waits up to 2 s - Prepends the wrapper directory to
PATHand setsGOV_ENABLED=1 - Auto-detects real
cl.exeandlink.exeviavswhere(or falls back to PATH search, skipping the wrapper directory) - Runs the build command via
cmd /cso the modified PATH is respected
gov status
Section titled “gov status”Connects to the governor’s named pipe and displays:
- Token pool: available / total
- Active lease count
- System commit charge (ratio and absolute values)
- Recommended parallelism level (
-jvalue)
If the governor is not running, prints “Governor: not running” and exits with code 1.
Setup scripts
Section titled “Setup scripts”| Script | Requires Admin | Purpose |
|---|---|---|
scripts\enable-autostart.ps1 | No | User-level setup — installs wrappers in PATH |
scripts\install-service.ps1 | Yes | Windows Service — always-on protection |
scripts\uninstall-service.ps1 | Yes | Remove the Windows Service |
Environment variables
Section titled “Environment variables”| Variable | Description |
|---|---|
GOV_REAL_CL | Path to real cl.exe (auto-detected via vswhere if not set) |
GOV_REAL_LINK | Path to real link.exe (auto-detected if not set) |
GOV_ENABLED | Set by gov run to indicate governed mode |
GOV_SERVICE_PATH | Path to Gov.Service.exe for auto-start (checked first by the auto-start locator) |
GOV_DEBUG | Set to “1” for verbose auto-start and idle-timeout logging |
Gov.Service flags
Section titled “Gov.Service flags”The governor service accepts these command-line flags:
| Flag | Description |
|---|---|
--background | Run in background mode with 30-minute idle auto-shutdown |
--service | Run as Windows Service (quiet output) |
Without flags, the governor runs in foreground mode with full console output (memory status, GPU info, token pool details).
Project structure
Section titled “Project structure”build-governor/├── src/│ ├── Gov.Protocol/ # Shared DTOs (NuGet: Gov.Protocol)│ ├── Gov.Common/ # Windows metrics, classifier, GPU metrics,│ │ # process monitoring, auto-start (NuGet: Gov.Common)│ ├── Gov.Service/ # Background governor + token pool│ ├── Gov.Wrapper.CL/ # cl.exe shim│ ├── Gov.Wrapper.Link/ # link.exe shim│ └── Gov.Cli/ # gov command├── scripts/│ ├── enable-autostart.ps1│ ├── install-service.ps1│ └── uninstall-service.ps1└── bin/ ├── wrappers/ # Published shims ├── service/ # Published service └── cli/ # Published CLI