Governance

Memory audit trails, compliance scanning, and executive dashboards.

Overview

BrainstormRouter provides governance APIs that give teams visibility into what the AI agent knows, how memory changes over time, and whether it complies with data policies. No other AI gateway offers this.

Memory audit trail

Every memory operation is logged with a full before/after diff:

const audit = await client.governance.audit({
  limit: 50,
  operation: "append", // or "replace", "delete", "pin", "evict"
  since: Date.now() - 7 * 24 * 60 * 60 * 1000, // last 7 days
});

for (const entry of audit.entries) {
  console.log(`${entry.timestamp} ${entry.operation} [${entry.block}]`);
  console.log(`  before: ${entry.fact_before}`);
  console.log(`  after:  ${entry.fact_after}`);
  console.log(`  actor:  ${entry.actor}`);
}

Operations tracked:

  • append — new fact added to memory
  • replace — existing fact updated
  • delete — fact removed by user or API
  • pin / unpin — fact protected from eviction
  • evict — fact removed automatically (block full, sleep-time cleanup)

Compliance scanning

Scan memory for PII and policy violations:

const result = await client.governance.compliance();

console.log(`Entries scanned: ${result.total_entries}`);
console.log(`Compliant: ${result.compliant}`);

if (!result.compliant) {
  for (const v of result.violations) {
    console.log(`[${v.block}] ${v.fact_preview} — ${v.issues.join(", ")}`);
  }
}

Detected patterns: email, phone, SSN, credit card numbers, API keys.

Sleep-time refinement report

Track what the autonomous sleep-time process changes in memory:

const report = await client.governance.sleepTimeReport();

console.log(`Consolidations: ${report.consolidations}`); // facts merged
console.log(`Extractions: ${report.extractions}`); // new facts extracted
console.log(`Evictions: ${report.evictions}`); // stale facts removed

Sleep-time runs during idle periods to refine memory quality — consolidating duplicate facts, extracting implicit knowledge, and evicting stale entries.

Executive summary

A single endpoint that combines memory health, compliance, and recent activity:

const summary = await client.governance.summary();

// Memory health
console.log(`Total entries: ${summary.memory.total_entries}`);
console.log(`Pinned: ${summary.memory.pinned_entries}`);
console.log(`PII violations: ${summary.memory.pii_violations}`);
console.log(`Compliant: ${summary.memory.compliant}`);

// Block utilization
for (const block of summary.memory.blocks) {
  console.log(`${block.block}: ${block.utilization}% (${block.entries}/${block.limit})`);
}

// Last 24h activity
console.log(`Activity:`, summary.activity_24h);
// { append: 12, replace: 3, delete: 1 }

Audit stats

Get operation counts by type for a time period:

const { stats } = await client.governance.stats({
  since: Date.now() - 30 * 24 * 60 * 60 * 1000, // last 30 days
});
// { append: 342, replace: 87, delete: 15, pin: 8, evict: 23 }