Gates API
Run DiffRules via runGates / PluginHost gates for path classification and mutation holds.
What you will learn
- Import gates
- runGates on a diff
- Interpret GateReport
Prerequisites
Surface
| Imports | @tmrxjd/agent-governance-system/gates · @tmrxjd/agent-governance-system/plugin |
|---|---|
| MCP | governance_toc |
What this feature does
`runGates(host, opts)` evaluates DiffRules registered on PluginHost. Gates classify paths, block illegal mutations, and feed semantic-diff reports. MCP hosts expose gate results through engine enforces; call runGates in custom integrations and hooks.
How to call it
Call these MCP tools through your AGS / tower-gov host — governance_toc.. Prefer scan/get before validate/diff, and enforce only when the change set is ready.
- Load host with plugins
- runGates on changed paths
- Fix issues
- Proceed to staging_enforce
import { createPluginHost } from '@tmrxjd/agent-governance-system/plugin'
import { runGates } from '@tmrxjd/agent-governance-system/gates'
const host = createPluginHost({ repoRoot })
const report = runGates(host, {
paths: ['src/auth/session.ts'],
intent: 'add refresh helper',
})
if (!report.ok) throw new Error(report.issues.map(i => i.message).join('\n'))What success looks like
GateReport.ok true
Issues empty or warnings only
Common failure modes
Empty diffRules on host
Ignoring mutation-gate holds
Running gates after commit instead of before