Brand (Trust)

Hash-chained. Append-only. Tamper-evident.

Overview

Brand maintains a hash-chained audit ledger. Every proxy request gets an entry with a SHA-256 hash linking it to the previous entry. This creates a tamper-evident log that proves no entries have been modified or deleted.

Audit Ledger

# View the audit ledger
curl http://localhost:4200/api/trust/ledger?limit=10

# Verify chain integrity
curl http://localhost:4200/api/trust/ledger/verify

Policies

# List policies
curl http://localhost:4200/api/trust/policies

# Create a block policy
curl -X POST http://localhost:4200/api/trust/policies \
  -d '{"name":"block-pii-output","type":"block","pattern":"(SSN|\\d{3}-\\d{2}-\\d{4})"}'

Policy types: block (reject the request), warn (log and continue), log (record silently).

Evidence Export

# Export evidence packs for compliance
curl http://localhost:4200/api/trust/evidence

See the Trust product page for the ledger visualization.

Audit Ledger

Brand maintains a hash-chained, append-only ledger of every LLM interaction. Each entry is linked to the previous via SHA-256, making tampering detectable:

curl "http://localhost:4200/api/trust/ledger?limit=5" \
  -H "Authorization: Bearer sy_admin_..."
{
  "entries": [{
    "id": "le_abc123",
    "seq": 1247,
    "timestamp": "2026-02-28T14:30:00Z",
    "hash": "a1b2c3d4...",
    "prev_hash": "e5f6a7b8...",
    "event": "chat_completion",
    "model": "gpt-4o",
    "user_id": "usr_abc",
    "trace_id": "tr_abc123",
    "verdict": "pass"
  }],
  "chain_valid": true
}

Brand Policies

Create policies that block, warn, or log based on content rules:

curl -X POST http://localhost:4200/api/trust/policies \
  -H "Authorization: Bearer sy_admin_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "No PII in outputs",
    "action": "block",
    "rules": [{
      "field": "response.content",
      "pattern": "\\b\\d{3}-\\d{2}-\\d{4}\\b",
      "description": "Block SSN patterns in LLM output"
    }]
  }'

Policy actions: block rejects the request, warn logs a warning but allows it through, log records silently.

Managing Policies

# List all policies
curl http://localhost:4200/api/trust/policies \
  -H "Authorization: Bearer sy_admin_..."

# Update a policy
curl -X PUT http://localhost:4200/api/trust/policies/pol_id \
  -H "Authorization: Bearer sy_admin_..." \
  -H "Content-Type: application/json" \
  -d '{"action": "warn"}'

# Delete a policy
curl -X DELETE http://localhost:4200/api/trust/policies/pol_id \
  -H "Authorization: Bearer sy_admin_..."

Compliance Configuration

Configure compliance logging in stockyard.yaml:

# stockyard.yaml
apps:
  trust:
    retention_days: 90
    hash_algorithm: "sha256"
    log_request_body: true
    log_response_body: true
    redact_pii: true
Retention: Ledger entries older than retention_days are automatically pruned. Set to 0 to retain indefinitely. Hash chain integrity is preserved even after pruning.

Common Patterns

Typical compliance setup for regulated environments:

# 1. Enable full audit logging
curl -X PUT http://localhost:4200/api/proxy/modules/compliancelog \
  -H "Authorization: Bearer sy_admin_..." \
  -d '{"enabled": true}'

# 2. Block sensitive content in outputs
curl -X POST http://localhost:4200/api/trust/policies \
  -H "Authorization: Bearer sy_admin_..." \
  -H "Content-Type: application/json" \
  -d '{"name": "No financial advice", "action": "block", "rules": [{"field": "response.content", "pattern": "you should (buy|sell|invest)", "description": "Block financial advice patterns"}]}'

# 3. Enable secret detection in inputs
curl -X PUT http://localhost:4200/api/proxy/modules/secretscan \
  -H "Authorization: Bearer sy_admin_..." \
  -d '{"enabled": true}'

Chain Verification

The hash chain ensures ledger integrity. Each entry’s hash includes the previous entry’s hash, creating a tamper-evident chain similar to a blockchain:

entry[n].hash = SHA256(entry[n].data + entry[n-1].hash)

The chain_valid: true field in the ledger response confirms the chain is intact. Any tampering breaks the chain and is immediately detectable.

Feedback Capture

The feedbackloop module captures user feedback (thumbs up/down, ratings) and links it to the original trace. This data powers quality tracking and model evaluation over time.

# Enable feedback capture
curl -X PUT http://localhost:4200/api/proxy/modules/feedbackloop \
  -H "Authorization: Bearer sy_admin_..." \
  -d '{"enabled": true}'

Regulatory Compliance

Brand is designed for regulated environments requiring audit trails:

RequirementHow Stockyard Helps
SOC 2 audit trailHash-chained ledger with immutable entries
GDPR right to deletionRetention policies with automatic pruning
HIPAA loggingPII redaction in logs, encrypted storage
Financial compliancePolicy rules blocking financial advice patterns
Export: Use /api/config/export to create snapshots of your compliance configuration for auditors.

Full Configuration Example

# stockyard.yaml — full Brand configuration
apps:
  trust:
    enabled: true
    retention_days: 90
    hash_algorithm: "sha256"
    log_request_body: true
    log_response_body: true
    redact_pii: true
    verify_on_read: true

modules:
  compliancelog:
    enabled: true
  feedbackloop:
    enabled: true
  secretscan:
    enabled: true
    config:
      patterns:
        - "aws_access_key"
        - "github_token"
        - "ssn"
        - "credit_card"

This configuration enables full audit logging with PII redaction, secret scanning, and 90-day retention. The hash chain is verified on every read to detect tampering.

API Summary

MethodPathDescription
GET/api/trust/ledgerQuery audit entries with filters
GET/api/trust/policiesList active policies
POST/api/trust/policiesCreate new policy
PUT/api/trust/policies/{id}Update policy rules or action
DELETE/api/trust/policies/{id}Remove policy

Exporting Audit Data

Export ledger entries for external compliance tools or long-term archival:

# Export last 30 days of audit data
curl "http://localhost:4200/api/trust/ledger?days=30&limit=10000" \
  -H "Authorization: Bearer sy_admin_..." > audit-export.json

The exported data includes full hash chain information, allowing independent verification of chain integrity by auditors or compliance tools.

For automated compliance workflows, combine Brand exports with Lookout cost data and Trading Post config snapshots to build a complete audit package.

For the full Brand API reference, see API Reference: Brand.

Explore: Model aliasing · Why SQLite · vs LiteLLM