Skip to content

CLI Reference

The gov command provides three subcommands:

Terminal window
# Run a governed build
gov 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 help
gov help

Wraps a build command with governed cl.exe and link.exe:

  1. Locates the published wrapper directory (searches multiple candidate paths)
  2. Checks if the governor is running (connects via named pipe with 500 ms timeout)
  3. If not running and --no-start is not set, starts the governor and waits up to 2 s
  4. Prepends the wrapper directory to PATH and sets GOV_ENABLED=1
  5. Auto-detects real cl.exe and link.exe via vswhere (or falls back to PATH search, skipping the wrapper directory)
  6. Runs the build command via cmd /c so the modified PATH is respected

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 (-j value)

If the governor is not running, prints “Governor: not running” and exits with code 1.

ScriptRequires AdminPurpose
scripts\enable-autostart.ps1NoUser-level setup — installs wrappers in PATH
scripts\install-service.ps1YesWindows Service — always-on protection
scripts\uninstall-service.ps1YesRemove the Windows Service
VariableDescription
GOV_REAL_CLPath to real cl.exe (auto-detected via vswhere if not set)
GOV_REAL_LINKPath to real link.exe (auto-detected if not set)
GOV_ENABLEDSet by gov run to indicate governed mode
GOV_SERVICE_PATHPath to Gov.Service.exe for auto-start (checked first by the auto-start locator)
GOV_DEBUGSet to “1” for verbose auto-start and idle-timeout logging

The governor service accepts these command-line flags:

FlagDescription
--backgroundRun in background mode with 30-minute idle auto-shutdown
--serviceRun as Windows Service (quiet output)

Without flags, the governor runs in foreground mode with full console output (memory status, GPU info, token pool details).

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