Skip to main content
Glama

Enforce Workspace Architectural Layer Rules

enforce_architecture_rules
Read-onlyIdempotent

Validates codebase import graphs against configured layer boundaries, flagging forbidden cross-layer imports and circular dependencies to block architectural erosion in CI and pre-commit checks.

Instructions

Validates codebase import graphs against architectural boundary rules defined in tzero.rules.json, distinguishing from 'manage_architecture_rules' and 'analyze_code_dependencies' by enforcing layer isolation compliance rather than configuring boundary definitions or tracing raw symbol calls.

Parameters:

  • project_root: Repository root directory to inspect; scans all source files against configured architectural rules.

  • strict_mode: When True, treats any forbidden cross-layer import or circular dependency as a critical violation; when False, reports infractions as non-fatal warnings for exploratory audits.

Behavior:

  • Mutability: Strictly read-only; parses import statements across the workspace without altering any files or configurations.

  • Idempotency: Deterministic; identical codebase revisions produce identical violation reports.

  • Privacy & Network: 100% offline local AST parsing; zero cloud telemetry or external network calls.

  • Performance & Resources: Completes in <300ms for 1,000 modules using <40MB RAM; thread-safe with zero rate limits.

  • Auth: Zero authentication or cloud credentials required.

  • Return Structure: Emits structured Markdown compliance audit listing passed layers, detected boundary violations, and exact offending source lines.

  • Error Handling: If tzero.rules.json is missing, applies enterprise standard layer boundaries (presentation -> domain -> persistence) and warns the user.

Usage Guidelines:

  • When to use: Run in CI/CD pipelines, pre-commit hooks, or before merging pull requests to prevent architectural erosion, circular imports, and unauthorized layer coupling.

  • When NOT to use: Do not use for defining, editing, or deleting architectural boundary rules (use 'manage_architecture_rules' instead); do not use for extracting raw caller/callee trees (use 'analyze_code_dependencies' instead).

Returns: Detailed compliance audit report listing passed layer boundaries, identified architectural violations, and remediation guidance.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "enforce_architecture_rules"
  }
}

Input Schema

NameRequiredDescriptionDefault
strict_modeNoWhen True, fails on any boundary infraction; when False, warns without raising errors.
project_rootNoRoot directory of the repository to validate (default: current directory)..

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv7.3.2
  2. Removedv7.0.1
  3. Addedv7.0.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond annotations that already declare read-only, non-destructive, idempotent, and closed-world behavior, the description adds concrete operational details: strict read-only AST parsing, deterministic reports, offline/no telemetry, performance bounds, zero auth, and fallback behavior when tzero.rules.json is missing. It does not contradict the supplied annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The definition is well-structured and front-loads purpose and sibling differentiation, with clear sections for parameters, behavior, and usage guidelines. Some content is redundant, especially the return structure being described in both the Behavior section and a separate Returns line, and the performance metrics add length beyond what an agent needs to select the tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given a two-parameter read-only audit tool with a full schema, rich annotations, and an output schema, the description is complete enough to call correctly. It covers missing-config fallback behavior, auth requirements, and return structure, so no critical operational context is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds useful nuance beyond the schema: strict_mode treats forbidden cross-layer imports or circular dependencies as critical while also supporting non-fatal warnings for exploratory audits, and project_root is said to scan all source files against configured rules. It does not add syntax or enum details, but it meaningfully clarifies parameter intent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: 'Validates codebase import graphs against architectural boundary rules.' It explicitly distinguishes the tool from 'manage_architecture_rules' and 'analyze_code_dependencies' by contrasting enforcement with configuration and raw symbol tracing, so the agent can select it without opening sibling schemas.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides explicit when-to-use guidance for CI/CD pipelines, pre-commit hooks, and pre-merge checks, and explicit when-not-to-use guidance naming the alternative tools for editing rules or tracing caller/callee trees. This leaves little to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.