Structural code quality metrics for agent-written programs.
Project description
Structural code quality metrics for agent-written programs.
Docs ·
Quick Start ·
MCP Server ·
Issues
Topos is an operating layer for AI agents that provides structural (geometric & topological) metrics computed over program graphs, surfacing deep architectural debt that conventional linters can't compute. It delivers complexity, coupling, and security metrics for your agents to wield as tools, establishing a precise, medal-scored (SLOP → GOLD) feedback loop to autonomously write clean, highly composable code.
Quick Start
curl -fsSL https://docs.krv.ai/topos/install.sh | sh
topos evaluate src/ -r
evaluate -r scores every file in src/ and prints a ranked digest: which pillars pass, the worst-scoring files, and the cheapest fixes to flip a failing pillar. Add -h to any command for help, or --json for CI.
Other install paths (PyPI, source checkout) and the full command tour live at docs.krv.ai/topos/installation.
What you get
Topos checks three independent pillars and awards a Code Quality Medal for how many pass:
- SIMPLE — avoids unnecessary complexity (AST entropy & CFG cyclomatic complexity)
- COMPOSABLE — cleanly decoupled from other modules (MDG Martin instability via GitNexus)
- SECURE — free of dangerous API reachability and taint paths (CPG analysis)
| Medal | Criteria |
|---|---|
| 🥇 GOLD | Passes all 3 (SIMPLE + COMPOSABLE + SECURE) |
| 🥈 SILVER | Passes 2 of 3 |
| 🥉 BRONZE | Passes 1 of 3 |
| ❌ SLOP | Passes 0 (or fails to parse) |
COMPOSABLE needs a cross-file dependency graph, which the CLI does not build automatically:
npm install -g gitnexus
topos depgraph generate
topos evaluate src/ -r --gitnexus-dir .gitnexus
Other commands: topos inspect for per-file metrics, topos compare for AST edit distance between two versions, topos coverage for structural test coverage, and --preferences simple,composable,secure to tell agents which pillar to protect first when 🥇 GOLD isn't reachable. Full reference: docs.krv.ai/topos/cli.
MCP server (for agents)
Give any MCP-compatible agent — Claude Code, Cursor, Gemini CLI, Windsurf — a live feed of Topos verdicts so it can evaluate and iterate on its own output.
claude mcp add --transport stdio topos -- topos mcp
Setup for Cursor, VS Code, Gemini CLI, Codex, and Windsurf, plus troubleshooting and the full MCP tool list: docs.krv.ai/topos/agents.
How it works
Topos measures code along the three pillars above and maps the result to an 8-element evaluation lattice — the three pillars are pairwise incomparable, and 🥇 GOLD is their intersection.
Evaluation lattice diagram
graph BT
SLOP["❌ SLOP<br/>No Medal"]
SIMPLE["🥉 BRONZE<br/>Simple"]
COMPOSABLE["🥉 BRONZE<br/>Composable"]
SECURE["🥉 BRONZE<br/>Secure"]
SC["🥈 SILVER<br/>S ∧ C"]
SSc["🥈 SILVER<br/>S ∧ Sc"]
CSc["🥈 SILVER<br/>C ∧ Sc"]
IDEAL["🥇 GOLD<br/>Quality Code"]
SLOP --> SIMPLE
SLOP --> COMPOSABLE
SLOP --> SECURE
SIMPLE --> SC
SIMPLE --> SSc
COMPOSABLE --> SC
COMPOSABLE --> CSc
SECURE --> SSc
SECURE --> CSc
SC --> IDEAL
SSc --> IDEAL
CSc --> IDEAL
style SLOP fill:#f8d7da,stroke:#842029,color:#000
style SIMPLE fill:#cd7f32,stroke:#5c3a1e,color:#fff
style COMPOSABLE fill:#cd7f32,stroke:#5c3a1e,color:#fff
style SECURE fill:#cd7f32,stroke:#5c3a1e,color:#fff
style SC fill:#c0c0c0,stroke:#4a4a4a,color:#000
style SSc fill:#c0c0c0,stroke:#4a4a4a,color:#000
style CSc fill:#c0c0c0,stroke:#4a4a4a,color:#000
style IDEAL fill:#ffd700,stroke:#856404,color:#000
Set your Preferences (e.g. simple,composable,secure) to tell your coding agent which pillars to prioritize when aiming for GOLD under token and time budgets, and how to relax that goal when GOLD isn't reachable. Details: docs.krv.ai/topos/preferences · docs.krv.ai/topos/measures · docs.krv.ai/topos/concepts.
Contributing
Topos is used internally at Krv Labs to manage AI agent code output. We welcome bugs, ideas, and contributions.
- Bug? Open an Issue
- Idea? Start a Discussion or open a PR
- Collaborate? team@krv.ai
Full Documentation · Measures & Metrics · Category Theory Concepts · Engineering notes
Built with ❤️ by Krv Labs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file topos_mcp-0.3.11.tar.gz.
File metadata
- Download URL: topos_mcp-0.3.11.tar.gz
- Upload date:
- Size: 793.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2caa20f8ce556aaf798a2b7434220eb9a821f83df7b9a7b520355d0c4d69c01
|
|
| MD5 |
23f19aa18562f17e2073b4bfbb246de9
|
|
| BLAKE2b-256 |
aba26d56e6e3946bf60b64d2d639867ca3592ed7b54c8e9ce52a9422a265af3c
|
Provenance
The following attestation bundles were made for topos_mcp-0.3.11.tar.gz:
Publisher:
release.yml on Krv-Labs/topos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
topos_mcp-0.3.11.tar.gz -
Subject digest:
d2caa20f8ce556aaf798a2b7434220eb9a821f83df7b9a7b520355d0c4d69c01 - Sigstore transparency entry: 2167737843
- Sigstore integration time:
-
Permalink:
Krv-Labs/topos@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Branch / Tag:
refs/tags/v0.3.11 - Owner: https://github.com/Krv-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Trigger Event:
push
-
Statement type:
File details
Details for the file topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 661.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc80e572acde6b3ad7c0fcd56fd52609c13775b8331d8a27c2ff9e6f7d23c446
|
|
| MD5 |
b33e7f0a6fc6958bbbaa2d9f035dacc8
|
|
| BLAKE2b-256 |
68bb3bff05817d9a69287c915a72558a6d87eaa3628b68e68a7b18c055ba58bd
|
Provenance
The following attestation bundles were made for topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on Krv-Labs/topos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
bc80e572acde6b3ad7c0fcd56fd52609c13775b8331d8a27c2ff9e6f7d23c446 - Sigstore transparency entry: 2167737855
- Sigstore integration time:
-
Permalink:
Krv-Labs/topos@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Branch / Tag:
refs/tags/v0.3.11 - Owner: https://github.com/Krv-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Trigger Event:
push
-
Statement type:
File details
Details for the file topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 661.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b8ed2e9e28c33d6e582f2ecd7b8b72e2dc5094eb67857006c8a0c59b45e2b53
|
|
| MD5 |
3398ea149b542217d08d6833fee65340
|
|
| BLAKE2b-256 |
9138628c396594ae0ad7fe984c625efbeebc305bc01e96ac6985b417ee46e9ad
|
Provenance
The following attestation bundles were made for topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on Krv-Labs/topos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
topos_mcp-0.3.11-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
6b8ed2e9e28c33d6e582f2ecd7b8b72e2dc5094eb67857006c8a0c59b45e2b53 - Sigstore transparency entry: 2167737848
- Sigstore integration time:
-
Permalink:
Krv-Labs/topos@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Branch / Tag:
refs/tags/v0.3.11 - Owner: https://github.com/Krv-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Trigger Event:
push
-
Statement type:
File details
Details for the file topos_mcp-0.3.11-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: topos_mcp-0.3.11-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 955.4 kB
- Tags: CPython 3.12, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce8869c80e26c6697cd5b34341e9ad4701942c29126f588dd2ff2cb32328b5fe
|
|
| MD5 |
d60136569a8293d9f8afbec449124c9c
|
|
| BLAKE2b-256 |
b436b2b87be30684c3b3a8bf94c9e05a1c6218b57a1784d3083c0327de631f9a
|
Provenance
The following attestation bundles were made for topos_mcp-0.3.11-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on Krv-Labs/topos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
topos_mcp-0.3.11-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
ce8869c80e26c6697cd5b34341e9ad4701942c29126f588dd2ff2cb32328b5fe - Sigstore transparency entry: 2167737853
- Sigstore integration time:
-
Permalink:
Krv-Labs/topos@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Branch / Tag:
refs/tags/v0.3.11 - Owner: https://github.com/Krv-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@478da352ce2e9a0bf9eb11cdfbe0d348f505a93a -
Trigger Event:
push
-
Statement type: