AAnvio
Security

Soul Gate Policy

How Anvio parses SOUL.md into an enforceable policy — trust zones, approvers, blocked users, and mandate — for the channel harness.

5 min read

The Soul Gate (Phase G, packages/soul-gate) enforces harness policy defined in a Hermes/slaude-style SOUL.md file — trust boundaries, approvers, allowed channels, and mandate. It is the policy source that Authorization enforces at runtime via resolveTrustTier(), isUserBlocked(), isManagerUser(), and the approval gate.

Two things named "Soul" — don't conflate them

FilePurpose
souls/<slug>/SOUL.mdIdentity layer — values, personality, goals (Hermes-style)
Root or channel SOUL.mdPolicy gate for the harness (slaude-style) — trust zones, approvers, mandate

Both are markdown. In practice, a single SOUL.md file (e.g. workspace/souls/architect-soul/SOUL.md) typically carries both identity and policy sections — the parser (parseSoulMd) extracts whichever sections are present. YAML souls remain supported for legacy workspaces.

Section-to-field mapping

parseSoulMd (regex-first parser, packages/soul-gate/src/soul-md-parser.ts) extracts these policy fields from a SOUL.md:

SOUL.md sectionPolicy field
Identityname, role, voice
Reportingmanager, backupManager
Allowed channelsallowedZones
Trusted channelstrustedZones
BlockedblockedUsers
Approversapprovers
RedactionredactPatterns
Mandatemandate

Worked example — architect-soul/SOUL.md

# Architect Soul — identity + harness policy

## Identity
- Name: Architect Soul
- Role: Senior Software Architect
- Description: Long-term architectural thinking partner

## Reporting
- Manager: cli:local-user

## Approvers
- cli:local-user: anything ; catchall

## Approval timeout
- seconds: 3600

## Values
- simplicity
- maintainability
- honesty

## Personality
- thoughtful
- structured

## Preferences
- conversation: professional
- diagrams: when helpful

## Communication
- Tone: professional and thoughtful
- Format: structured with clear rationale

## Long-term goals
- help the user build maintainable systems
- improve architecture over time

## Behavioral tendencies
- consider tradeoffs before recommending
- prefer simplicity over cleverness

## Mandate
- Help the team ship maintainable systems.
- Request human approval before mutating production or shared infrastructure.

This soul has one approver (cli:local-user), marked catchall (can approve anything, not scoped to a specific action type), a manager of cli:local-user, and a 3600-second (1 hour) approval timeout. The mandate's second line — "Request human approval before mutating production or shared infrastructure" — is the natural-language trigger that the harness's tool-call policy checks against before invoking the approval gate.

Parsing approvers

parseApproversSection() (packages/soul-gate/src/verifier.ts) extracts channel-qualified IDs from each non-empty, non-comment line:

export function extractIdsFromLine(line: string): string[] {
  // matches "slack:U123", "telegram:456", "cli:local-user", etc.
  // also matches raw Slack-style IDs: <@U123>, U123ABC, C123ABC, G123ABC, or bare numeric IDs (5+ digits)
}

A line is flagged catchall if it contains the word "catchall" or "anything" (case-insensitive) — this is exactly how cli:local-user: anything ; catchall becomes an unrestricted approver in the example above. Otherwise, the text after the second : (or after the first : for non-channel-prefixed lines) becomes the approver's scope string, matched against future approval-request summaries.

Import and validate

anvio soul import path/to/SOUL.md
anvio soul validate-policy path/to/SOUL.md

Verified policies are cached under workspace/souls/_cache/ (see packages/soul-gate/src/policy-cache.ts, hashSoulSource / readCachedPolicy / writeCachedPolicy) — the source file is hashed so a re-parse only happens when the SOUL.md content actually changes.

Verbatim ID verification (anti-hallucination guard)

Because packages/soul-gate/src/soul-policy-llm.ts (extractSoulPolicy) can use an LLM-assisted extraction path for less rigidly formatted souls, verifyPolicyIds() runs as a mandatory post-processing step:

export function verifyPolicyIds(source: string, policy: SoulPolicy): SoulPolicy {
  const verified = structuredClone(policy);
  verified.blockedUsers = verified.blockedUsers.filter((u) => source.includes(u.userId));
  verified.approvers = verified.approvers.filter((a) => source.includes(a.userId));
  if (verified.manager && !source.includes(verified.manager.userId)) verified.manager = undefined;
  // ...same for backupManager, allowedZones, trustedZones
  return verified;
}

Any ID that doesn't literally appear in the source SOUL.md text is dropped from the final policy. This prevents an LLM extraction pass from inventing an approver or trusted-zone ID that was never actually written by a human in the policy file — a real security property, not just a formatting nicety.

Channel engagement profiles

Trust zones determine whether the harness will act; channel profiles (workspace/harness/channel-profiles.yaml) determine when it engages at all per channel type:

apiVersion: anvio.io/v1
kind: HarnessChannelProfiles
metadata:
  name: default
spec:
  profiles:
    - name: slack-like
      channels: [slack]
      engageOn: mention
      disengageOn: mention_other
      dmPolicy: manager_only
    - name: telegram-like
      channels: [telegram]
      engageOn: mention
      disengageOn: never
      dmPolicy: anyone
    - name: web-like
      channels: [web-chat, rest]
      engageOn: always
      disengageOn: never
      dmPolicy: anyone
    - name: cli-like
      channels: [cli]
      engageOn: always
      disengageOn: never
      dmPolicy: anyone

Note that Slack is the one profile with dmPolicy: manager_only by default — a DM to the agent on Slack only gets a response if the sender is the soul's manager or backup manager, per canAccessRestrictedZone() in Authorization. Telegram, Discord, web chat, and CLI default to dmPolicy: anyone.

Harness defaults tie it together

# workspace/harness/defaults.yaml
apiVersion: anvio.io/v1
kind: HarnessDefaults
metadata:
  name: default
spec:
  enabled: true
  soulSlug: architect-soul
  suppressRawOutput: true
  idleMinutes: 15
  resumeSessions: true
  connectBroker:
    enabled: true
    encryptionKeyEnv: ANVIO_CONNECTION_ENCRYPTION_KEY
    defaultTtlSeconds: 3600

soulSlug: architect-soul points the harness at the soul whose policy (approvers, zones, mandate) governs every channel interaction workspace-wide, unless overridden per-channel.

Edit on GitHub

Last updated on

On this page