How ArchGuard 2.0 Uses LLMs to Dynamically Generate Architecture Governance Functions

This article explains how ArchGuard 2.0 leverages large language models to transform tacit architectural knowledge into dynamic, DSL‑based governance functions, detailing the challenges of traditional tools, the design of the Co‑mate system, and the practical implementation using Kotlin REPL.

phodal
phodal
phodal
How ArchGuard 2.0 Uses LLMs to Dynamically Generate Architecture Governance Functions

Standard + Pattern Toolization

ArchGuard 2.0 adopts a “standard + pattern” approach: explicit architectural standards serve as the primary factor for AI‑driven design, while existing implementations provide the secondary context.

Limitations of Traditional Governance Tools

Conventional tools cannot capture tacit design aspects such as evolving “as‑is” vs. “to‑be” architectures, non‑standard layered structures, or heterogeneous technology stacks. Small governance teams (3‑5 people) often have to manage large code bases manually.

ArchGuard Co‑mate Overview

Co‑mate enables large language models (LLMs) to understand these tacit designs and dynamically generate governance functions based on the LLM’s atomic capabilities.

LLM‑driven Ability Map

Classification : LLM analyses API documentation and categorises endpoints by URI, HTTP action, security, etc.

Logical Reasoning : LLM derives regular‑expression rules for URI construction and produces human‑readable examples.

Extraction : LLM extracts key information from API specifications across multiple dimensions.

Summarisation : LLM highlights aspects difficult to codify, such as security concerns.

Dynamic Function Generation Example

rest_api {
    uri_construction {
        rule("/api\\/[a-zA-Z0-9]+\\/v[0-9]+\\/[a-zA-Z0-9\\/\\-]+")
        example("/api/petstore/v1/pets/dogs")
    }
    http_action("GET", "POST", "PUT", "DELETE")
    status_code(200,201,202,204,400,401,403,404,500,502,503,504)
    security("""Token Based Authentication (Recommended) ...""")
    misc("""...""")
}

The API specification is split into five dimensions: HttpActionRule, StatusCodeRule, UriConstructionRule, MiscRule, and SecurityRule. Traditional rule checkers handle the first three; MiscRule and SecurityRule are processed by LLMs.

Architecture governance dimensions
Architecture governance dimensions

Runtime Implementation

Co‑mate combines a domain‑specific language (DSL) with a Kotlin REPL runtime. The DSL is built using Kotlin type‑safe builders, and the REPL is powered by the Kotlin Jupyter runtime, allowing direct invocation of generated functions.

Governance DSL : Kotlin‑based type‑safe builders that express governance rules.

Kotlin REPL : Jupyter‑style runtime that loads Co‑mate dependencies for on‑the‑fly execution.

After extracting API definitions, remaining analysis is delegated to LLM prompts, which act as black‑box functions. Prompt debugging can be painful, but this approach lets LLMs orchestrate governance logic with minimal coding effort.

Conclusion

LLMs can effectively extract, classify, and compose architecture‑governance functions, handling complex tacit design knowledge that traditional tools miss.

Source repository: https://github.com/archguard/co-mate

architectureDSLLLMKotlinAPIGovernance
phodal
Written by

phodal

A prolific open-source contributor who constantly starts new projects. Passionate about sharing software development insights to help developers improve their KPIs. Currently active in IDEs, graphics engines, and compiler technologies.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.