Skip to content
KidkenderPublic

About

Give AI a semantic understanding of your codebase.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

ArchMind

Find the routes that forgot to check something — and stop the next refactor from forgetting it again.

ArchMind reads your Laravel, NestJS, Express, Spring Boot or Go/Gin app and builds, for every route, a graph of what it actually checks: authentication, authorization (policy / role / gate), validation, transaction boundaries, tenant scoping. It reports what is missing, fails CI when a check disappears, and gives AI assistants the same evidence over MCP.

Offline. No LLM, no API key, no account.

npx @kidkender/archmind findings --project .
DELETE /api/vaults/{id}
  ! HIGH    missing_authorization
            DELETE /api/vaults/{id} is authenticated but not authorized — any logged-in user can perform this mutation

GET /api/invoices/{id}
  ! HIGH    missing_tenant_scope
            Invoice::find fetches by raw ID with no tenant constraint — any authenticated user can access another tenant's Invoice by guessing the ID

On real open-source apps it has surfaced previously undocumented issues, including an unauthenticated multi-tenant data exposure and an unguarded file endpoint — found because ArchMind records a missing check as an explicit fact (✗ auth_middleware), not as silence.

What it checks

Problem Finding / guard
Logged-in user can change data they shouldn't (no policy, gate or role check) missing_authorization
Policy referenced but the class doesn't exist missing_policy
Record fetched by ID in a multi-tenant route without the tenant filter missing_tenant_scope
Public route that returns business data or sensitive fields exposed_read_endpoint, api_resource_unprotected, sensitive_field_exposed
Event or job dispatched inside a transaction that may roll back event_before_commit
A refactor drops auth middleware, a DB::transaction() or a tenant scope archmind verify fails the build

Detector coverage differs per framework — see Supported frameworks.

Who it's for

  • Teams running multi-tenant SaaS who need every route tenant-scoped and authorized.
  • Reviewers who want a PR comment saying "this PR removed the transaction from POST /orders" instead of reading the diff.
  • AI-assisted development (Claude Code, Cursor, Copilot): the assistant asks ArchMind what a route checks instead of guessing from raw files.

How noisy is it?

Measured on five real Laravel apps (invoiceninja, monica, akaunting, koel, BookStack), no config: 92 findings shown by default across all five, 63 HIGH/CRITICAL (down from 951 in 0.10.0). We read the code behind all 63: 60% were worth a reviewer's attention and 40% were false positives; none is a confirmed vulnerability. Every number, and each false positive, is in research/laravel-scan.

Coming from Enlightn (archived in January 2026)? ArchMind covers a different, complementary area — route-level authorization, tenant isolation and transactions, with a CI regression guard — and runs on Windows, macOS and Linux.


CI: topology guard

ArchMind also runs as a zero-config CI check. It saves a baseline of your execution topology and fails the build if a transaction boundary, auth middleware, or tenant scope disappears from any route.

npm install -g @kidkender/archmind
archmind verify --project .

No AI model. No API key. Works offline.

POST /orders  [before refactor]           POST /orders  [after refactor]
├─ 🔑 auth:sanctum                        ├─ 🔑 auth:sanctum
├─ ⚙ ResolveTenant                        └─ 📋 OrderController::store
├─ 📋 OrderController::store
│   └─ 🔄 DB::transaction          ←   GONE
│       ├─ Order::create
│       └─ OrderCreated (event)
✘ TOPOLOGY REGRESSION: POST /orders
  lost: [transaction_boundary]

If this is intentional, run: archmind verify --project . --update

What it catches

Scenario How it's detected
DB::transaction() removed from a route transaction_boundary lost → CI fails
Auth middleware accidentally dropped authentication_gate lost → CI fails
Tenant scope removed from model query unscoped_write gained → CI fails
Route with auth but no policy/gate missing_authorization finding
Policy class referenced but file missing missing_policy finding

CI Integration

With the GitHub Action:

# .github/workflows/archmind.yml
on: pull_request
jobs:
  archmind:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: Kidkender/archMind@main   # command: verify (default) | findings | diff

Or with plain npm:

# .github/workflows/topology-guard.yml
- uses: actions/setup-node@v4
  with:
    node-version: '20'

- name: Install archmind
  run: npm install -g @kidkender/archmind

- name: Verify topology
  run: archmind verify --project .
  # Fails if DB::transaction, auth middleware, or tenant scope disappears from any route

First-time setup (run once, commit the result):

archmind verify --project . --update
git add .archmind/baselines/
git commit -m "chore: add topology baseline"

MCP Server (Claude Code / AI assistants)

ArchMind ships an MCP server that gives AI assistants structured execution graph access. It supports Laravel, NestJS, Express and Go/Gin; Spring Boot is available in the CLI only for now.

npm install -g @kidkender/archmind-mcp

Add to your MCP settings:

{
  "archmind": {
    "command": "archmind-mcp"
  }
}

Ask Claude: "Why is authorization checked twice on POST /orders?" — it calls archmind_get_execution_graph and reasons over the actual execution path, not a raw file dump.

MCP tools

Tool What it does
archmind_list_entrypoints All routes in the project
archmind_get_execution_graph Execution graph for a specific route (with optional focus pruning)
archmind_get_findings Static detectors — auth gaps, transaction anomalies, isolation issues
archmind_get_dependents Cross-route impact: what breaks if I change OrderService?
archmind_invalidate_cache Force re-parse after source changes

CLI commands

# Trace the execution graph of any route
archmind trace --project . "POST /orders"

# Find security gaps across all routes (CRITICAL / HIGH / MEDIUM; exit 1 on CRITICAL or HIGH)
archmind findings --project .
archmind findings --project . --all    # also LOW (code quality) and INFO notes
archmind findings --project . --json   # machine-readable, all severities

# Save baseline, then verify on every PR
archmind verify --project . --update   # save
archmind verify --project .            # check (exit 1 if regression)

# What routes are affected if I change this service?
archmind deps --project . OrderService

Example: trace output

POST /api/orders
└─ 🔑 auth:sanctum  [authentication_gate]
   └─ ⚙ ResolveTenant::handle  [middleware]
      └─ 📋 OrderController::store  [controller_action]
         ├─ ✅ StoreOrderRequest  [form_request]
         └─ ⚡ OrderService::createOrder  [service_call]
            └─ 🔄 DB::transaction  [transaction_boundary]
               ├─ Order::create  [transactional_write]
               └─ ⚡ OrderCreated → NotifyUser  [transaction_escape]

Example: findings output

POST /api/vaults
  ! HIGH    missing_authorization
            Route is authenticated but has no policy or gate — any logged-in user can create vaults

DELETE /api/vaults/{id}
  ! HIGH    missing_authorization
            Route is authenticated but has no policy or gate — any logged-in user can delete vaults

4 finding(s) across 4 route(s)

Benchmarks: does it help AI assistants?

Naive RAG dumps raw source files into the LLM context. ArchMind retrieves only the nodes relevant to the question — authentication gates, policy checks, transaction boundaries, tenant isolation — and nothing else.

Benchmark results (real repos, hand-verified ground truth, real GPT-4o calls — not simulated)

Benchmark Sample archMind Baseline (raw file dump)
Guest-access / authorization accuracy — 5 real Laravel apps (invoiceninja, monica, akaunting, koel, BookStack) 50 hand-verified entrypoints 66% correct, 98% correct+partial 68% correct, 100% correct+partial
Token cost, same benchmark 50 entrypoints 5.08× fewer prompt tokens (14,517 vs 73,712) baseline
Guest-access / authorization accuracy — 5 fresh, previously-unseen repos across Laravel/Spring Boot/NestJS (panel, attendize, spring-petclinic, SpringBlade, nestjs-boilerplate) 20 entrypoints 90% correct (18/20), 0 incorrect 65% correct (13/20), 5 confidently incorrect
Token cost, same cross-framework set 24 calls 73.4% fewer prompt tokens (7,116 vs 26,764) baseline

Read the accuracy numbers honestly: on Laravel alone, raw accuracy is statistically tied with a naive file dump — the win there is almost entirely token efficiency (same answer quality, 1/5th the context). The larger accuracy edge shows up on the cross-framework sample, and traces to a specific mechanism, not "the LLM likes archMind more": ArchMind's evidence package marks facts as explicitly present or ABSENT (e.g. ✗ auth_middleware), which lets the model correctly infer "no auth required" instead of reading silence as ambiguity — a raw file dump gives the model no equivalent signal to reason from, so it hedges to UNCLEAR far more often (5 of the baseline's misses were exactly this).

ArchMind's accuracy pass has also surfaced real, previously undocumented security issues in the repos it was tested against — including an unauthenticated multi-tenant data exposure and a path-traversal-adjacent unguarded file endpoint — precisely because the graph's explicit absence-marking caught missing auth that a raw-file read past over.

Where it doesn't win: deeper reasoning benchmarks (cross-file causality, multi-turn sessions) show archMind edging ahead but with concrete, documented gaps — transaction-scope flattening (the graph knows a transaction exists but not precisely which downstream calls are inside it) and an accessor-vs-terminal-mutation gap (a relationship accessor is captured as touched, without confirming the chained .delete() on it actually ran). These are IR-granularity ceilings, not retrieval-reach problems, and are being worked on incrementally rather than glossed over.

The difference compounds on large codebases where a single route touches dozens of files.

Go/Gin support is newer and not yet held to the same bar. The numbers above are Laravel/NestJS/Spring Boot only, from hand-verified ground truth compared against real LLM calls. Go/Gin has been validated structurally — full-project parsing against 3 real Gin+GORM codebases with zero crashes and spot-checked node accuracy — but not yet run through the same hand-verified accuracy benchmark. Treat it as functional but less battle-tested until that benchmark exists.

Express support is the newest, measured structurally only. On six projects it had not seen it found every real route (101 of 101) and every transaction-opening route of a production app, and classified 9 of 15 security middleware correctly before fixes made on that same set (15 of 15 after) — see research/express-corpus. It has not been through the LLM accuracy benchmark either.


Supported frameworks

Laravel

  • Route groups with nested middleware inheritance
  • Route::apiResource() / Route::resource() with .only() / .except()
  • Constructor-injected services (PHP 8 promoted properties)
  • DB::transaction() blocks with event dispatches and after-commit listeners
  • Tenant isolation (tenant_id, app('tenant'), whereTenantId)
  • Event → listener tracing via EventServiceProvider::$listen
  • Kernel aliases (Laravel ≤10) and bootstrap/app.php (Laravel 11/12)

Spring Boot

  • HTTP routes (@RestController/@Controller + method-level @*Mapping), including custom stereotypes that skip the standard annotation but still carry method-level mappings (e.g. Spring Boot Admin's @AdminController)
  • Multi-module Maven projects, at arbitrary nesting depth — and Gradle multi-module via settings.gradle
  • Non-HTTP entrypoints: @KafkaListener/@RabbitListener/@JmsListener (queue) and @Scheduled (cron)
  • @PreAuthorize/@Secured/@RolesAllowed and role/permission checks (hasRole, hasAuthority) resolved to both an auth gate and an authorization check
  • SecurityFilterChain rule resolution, scoped per Maven module so an unrelated module's security config can't leak onto your controllers
  • @Transactional resolved through the interface/impl split, scoped per module
  • Unrecognized but auth-shaped custom annotations (e.g. SpringBlade's @PreAuth, Apache Shiro's @RequiresRoles) are surfaced as an explicit "unknown security signal" rather than silently read as no-auth

NestJS

  • Controller decorators and route method mapping
  • @Cron (@nestjs/schedule) jobs as first-class cron entrypoints
  • Route-constants object references resolved in decorator arguments

Go/Gin

  • Route registration spanning multiple function-call layers (main() → a RegisterRoutes() aggregator → per-domain RegisterXRoutes() functions), with group prefix and middleware correctly inherited across each hop
  • Global auth middleware (r.Use(AuthMiddleware())) that exempts specific routes via a runtime method+path skip-list read from inside the middleware's own body — not just its registration site
  • RequireRole/RequireSystemRole-style authorization checks, with Go const role/permission arguments resolved to their declared value
  • ShouldBindJSON/ShouldBindQuery/ShouldBindUri resolved to the bound DTO struct's binding:"..." validation tags
  • GORM db.Transaction(func(tx *gorm.DB) error {...}) closures, including one hop into a directly-called service method (handlers are typically thin; the transaction usually lives in the service layer)
  • Handlers wired as typed parameters (func RegisterX(r gin.IRouter, h *handler.XHandler)) or built as locals (h := handler.NewXHandler(...), h := &handler.XHandler{})
  • Ownership authorization for self-service APIs (see below)
  • Scoped to a Gin + GORM + internal/{handler,service,middleware,model,dto} project layout Tenant/isolation scoping isn't implemented yet.

Ownership authorization (archmind.json)

missing_authorization treats "authorized" as "has a role or policy check". An API that scopes every query to the caller — a game, a personal app — authorizes by ownership instead, and would be flagged on every authenticated mutation. Tell ArchMind which functions resolve the caller's own record:

{
  "authorization": { "ownershipSources": ["currentCharacter", "UserId"] },
  "ignoreFindings": []
}

A handler that calls one of them (directly, or one hop into a helper method on the same receiver) is treated as authorized by ownership. A handler that acts on a URL :id without resolving the caller is still reported — that is the case worth looking at. ignoreFindings drops whole finding types (e.g. ["missing_authorization"]) for a project where the rule does not apply at all.

Express

  • JavaScript and TypeScript; routers mounted across files through require / module.exports and ES modules, router.route() chains, routers mounted from arrays, registrar functions handed the app
  • Middleware chain in Express order (global, path-scoped, per-router, per-route, arrays), classified by package, name and — for project middleware — body: passport / express-jwt / custom JWT checks as auth gates, role checks as authorization, celebrate / express-validator / Joi wrappers as validation, rate limiters, CSRF, optional auth; body parsers, logging, CORS and the like left out
  • Handlers resolved through controller modules, class methods and wrappers (catchAsync); service calls, including class controllers with constructor-injected services
  • Transactions (Sequelize, TypeORM, Prisma, Mongoose, Knex) in the handler or one call below, with the writes inside them
  • Ownership authorization (as above) and guards from archmind.json
  • Not read: decorator-based routing (routing-controllers, tsoa); tenant isolation and side effects are not extracted. Details: packages/express-parser

Requirements

  • Node.js ≥ 18
  • A Laravel (≥8, tested on 10/11/12), NestJS, Spring Boot (Maven or Gradle), Go/Gin, or Express project

License

MIT

About

Give AI a semantic understanding of your codebase.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages