arch

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package arch is a one-way reader of a sibling tool's (archlint, github.com/muhammetsafak/archlint) public architecture.json config. It discovers and parses the file at the repo root and renders a compact, deterministic natural-language summary of the declared layers and their allowed/forbidden dependency edges — the "architecture context block" — so a CommitBrief review can be made architecture-aware (ADR-0030): the LLM is told the project's import-boundary rules and can flag a diff that crosses one (e.g. "this adds domain → db, which the architecture forbids").

This package NEVER lints — it does not walk the import graph or enforce anything; archlint owns enforcement. CommitBrief only consumes the config as prose for the prompt. A missing or malformed file is a transparent no-op (Context == "", err == nil for the "absent" case) so it can never break a review.

Index

Constants

View Source
const DefaultFilename = "architecture.json"

DefaultFilename is archlint's conventional config file name, looked up at the repo root when no explicit path is configured.

Variables

This section is empty.

Functions

func Summarize

func Summarize(data []byte) string

Summarize parses architecture.json bytes and renders the deterministic context block. Returns "" when the file is malformed JSON or declares no layers — in both cases there is nothing useful to tell the model, and an empty string keeps the cache key byte-identical to a no-architecture run.

Exported so the prompt assembler / tests can render a block from in-memory bytes without touching disk.

Types

type Result

type Result struct {
	Context string
	Path    string
	Found   bool
}

Result is the outcome of a discovery+parse. Context is the rendered block (empty when there is nothing useful to inject); Path is the file that was read (for diagnostics); Found reports whether a config file existed at all.

func Discover

func Discover(repoRoot, configuredPath string) (Result, error)

Discover looks for an architecture.json and renders its context block.

  • configuredPath != "": that exact path is used (relative paths resolve against repoRoot). A configured-but-missing file is reported as an error so a typo in config surfaces instead of silently disabling the feature.
  • configuredPath == "": repoRoot/architecture.json is probed; ABSENCE is a clean no-op (Found=false, no error) — the common case for repos that don't use archlint.

A malformed or empty file is ALSO a no-op (Found=true, empty Context, no error): the contract is "never break a review", and a broken architecture file is the archlint repo's problem to surface, not CommitBrief's. The caller may inspect Found to emit an info line, but must not fail on it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL