Skip to main content

Architecture

Technical reference for the Vectimus evaluation pipeline. This document covers component responsibilities, data flow and integration schemas.

Evaluation flow

AI Agent (tool call) -> Shim (stdin JSON) -> Normaliser -> Cedar PolicyEngine -> Decision
                                                                                    |
                                                                              Audit Log (JSONL)

The MVP path is entirely local. Command hooks read JSON from stdin, evaluate via cedarpy and return a decision via exit code. No server, no network, no daemon.

The optional HTTP server (vectimus server start) exists for enterprise centralised policy management.

Data models

All models use Pydantic v2 BaseModel. See src/vectimus/core/models.py for the full definitions.

VectimusEvent is the normalised event that Cedar policies evaluate. Key fields:

  • source (SourceInfo) — where the event came from (tool name, version, session)
  • identity (IdentityInfo) — who triggered it (principal, persona, groups)
  • action (ActionInfo) — what is being attempted (action_type, command, file_path, etc.)
  • context (ContextInfo) — environmental context (repo, branch, cwd)

Decision is the governance result:

  • decision — “allow”, “deny” or “escalate”
  • reason — human-readable explanation (mandatory for deny)
  • suggested_alternative — what the agent should try instead (mandatory for deny)
  • matched_policy_ids — which policies triggered

AuditRecord pairs a VectimusEvent with its Decision for the audit log.

Action types

Normalised across all tools:

Action typeExamples
shell_commandBash, terminal, shell execution
file_writeWrite, Edit, MultiEdit, file creation
file_readRead, Grep, Glob, file access
web_requestWebFetch, curl, HTTP calls
mcp_toolAny MCP server tool invocation
package_operationnpm, pip, cargo, yarn
git_operationgit push, commit, branch operations
infrastructureterraform, kubectl, docker, cloud CLI
agent_spawnTask, subagent creation

Shell commands are further classified: commands starting with terraform/kubectl/docker map to infrastructure, npm/pip/cargo/yarn to package_operation, git to git_operation.

Normaliser input schemas

The normaliser accepts tool-specific JSON and produces VectimusEvent objects. New tools are added by registering a normaliser function.

Claude Code

{
  "tool_name": "Bash",
  "tool_input": { "command": "rm -rf /tmp/build" },
  "tool_use_id": "uuid",
  "session_id": "uuid",
  "cwd": "/home/user/project",
  "hook_event_name": "PreToolUse"
}

Tool name mapping:

Tool nameAction type
Bashshell_command
Write, Edit, MultiEditfile_write
Read, Grep, Globfile_read
WebFetch, WebSearchweb_request
Taskagent_spawn
mcp__*mcp_tool

Cursor

{
  "conversation_id": "uuid",
  "generation_id": "uuid",
  "command": "rm -rf /tmp/build",
  "cwd": "/home/user/project",
  "hook_event_name": "beforeShellExecution",
  "workspace_roots": ["/home/user/project"]
}

Event mapping: beforeShellExecution -> shell_command, beforeMCPExecution -> mcp_tool, beforeReadFile -> file_read, afterFileEdit -> file_write.

GitHub Copilot / VS Code

{
  "timestamp": "2026-03-08T14:30:00.000Z",
  "cwd": "/home/user/project",
  "sessionId": "uuid",
  "hookEventName": "PreToolUse",
  "tool_name": "Bash",
  "tool_input": { "command": "rm -rf /tmp/build" }
}

Cedar schema

The Cedar schema defines entity types, actions and context shapes. See src/vectimus/core/schemas.py for the full definition.

Entity types: User, Agent, Tool.

Each action type (shell_command, file_write, etc.) applies to [User, Agent] principals and Tool resources with a context containing a parameters record.

Cedar policy conventions

Every policy rule must have:

  • @id("vectimus-base-NNN") or @id("owasp-NNN") — unique identifier
  • @description("...") — human-readable explanation
  • @incident("...") — real-world incident reference (where applicable)
  • @controls("...") — compliance controls it satisfies (where applicable)

See Writing policies for the full guide.

Server endpoints (enterprise, opt-in)

Activated via vectimus server start. Not part of the default MVP flow.

MethodPathPurpose
POST/evaluateEvaluate a tool event against policies
GET/policiesList loaded policies with metadata
GET/healthServer status, policy count, uptime
GET/eventsSSE stream of real-time evaluation events

The /evaluate endpoint accepts an X-Vectimus-Source header to identify the source tool. For Claude Code HTTP hooks, the response includes hookSpecificOutput with permissionDecision and permissionDecisionReason.

Configuration

Locations (in order of precedence):

  1. ./vectimus.toml (project-level)
  2. ~/.vectimus/config.toml (user-level)
  3. Environment variables: VECTIMUS_POLICY_DIR, VECTIMUS_SERVER_URL, VECTIMUS_LOG_DIR
[policies]
dir = "./policies"

[logging]
dir = "~/.vectimus/logs"
format = "jsonl"

[identity]
resolver = "git"    # "git", "env" or "system"
default_persona = "default"