# Pillar 2: Audit & Inventory (P2)
### 👁️ The Ledger of Truth

[![AI SAFE²](https://img.shields.io/badge/AI_SAFE%C2%B2-v3.1-F6921E?style=flat-square)](../README.md)
[![Layer](https://img.shields.io/badge/Layer-Pillar_2-820F1A?style=flat-square)](./README.md)
[![Status](https://img.shields.io/badge/Status-Current-808080?style=flat-square)](../EVOLUTION.md)

[Framework Home](../README.md) | [Cross-Pillar Governance](../00-cross-pillar/README.md) | [AISM](../AISM/) | [NEXUS](../NEXUS/) | [Dashboard](https://cyberstrategyinstitute.github.io/ai-safe2-framework/dashboard/)

**Previous:** [← Pillar 1: Sanitize & Isolate](../01-sanitize-isolate/README.md) | **Next:** [Pillar 3: Fail-Safe & Recovery →](../03-fail-safe-recovery/README.md)

---

## Technology evidence and incident reconstruction

A log-producing technology `evidences` a control; it does not automatically
`enforce` it. Apply the [Evidence Assurance rubric](../AISM/EVIDENCE-ASSURANCE.md)
to individual claims with provenance, collection gaps, and tested boundaries.
The [incident evidence guide](../AISM/INCIDENT-EVIDENCE.md) covers reconstruction,
affected-party uncertainty, custodianship, retention/hold decisions, and notification
ownership. Preserve evidence outside the governed component's authority where
required; hashes alone do not establish truth or independent validation.

## 🎯 The Problem. The Realization. The Solution.

**Problem:** AI agents make decisions continuously. Most of those decisions leave no traceable record. When an agent produces a wrong answer, behaves unexpectedly, or causes a downstream failure, the question "what actually happened?" has no answer. The execution is a black box. Post-mortems take weeks. Compliance audits produce evidence for what was supposed to happen, not what did.

**Realization:** Observability for agentic systems requires more than API logs. It requires capturing the reasoning chain, the retrieved context, every memory read and write, every tool call with its parameters and result, and the conditions that led to each decision. Without this, debugging is archaeology. With it, debugging is replay.

**Solution:** Pillar 2 defines the complete audit and inventory architecture for agentic AI. It covers semantic execution tracing, model lineage provenance, RAG corpus integrity, agent state registries, and the dynamic ownership model that ensures every agent in production has an accountable human behind it.

> **What you get:** Full replay capability for any agent execution. Correlation between behavioral changes and system changes. A compliance evidence package that exists before the auditor asks.

---

## 🏗️ Topic 3: Audit (P2.T3)
*Verification, Accountability, Tracking, Compliance*

### Core Controls (v2.0)

- **[P2.T3.1] Real-Time Activity Logging:** Log all activities with timestamps; capture prompts and API calls; ensure tamper-proof storage.
- **[P2.T3.2] Model Performance Monitoring:** Monitor accuracy and precision; detect data and concept drift.
- **[P2.T3.3] Behavior Verification:** Establish baselines; detect deviations and anomalies; flag unusual patterns.
- **[P2.T3.4] Explainability Tracking:** Log decisions (SHAP/LIME); track reasoning paths; enable post-hoc analysis.
- **[P2.T3.5] Bias & Fairness Monitoring:** Measure bias across demographics; track fairness metrics; detect discrimination.
- **[P2.T3.6] Compliance Validation:** Map controls to SOC2/ISO/NIST; track implementation; conduct periodic audits.
- **[P2.T3.7] Decision Traceability:** Track provenance from input to output; document data sources; maintain chain of custody.
- **[P2.T3.8] User Interaction Logging:** Log prompts and feedback; track satisfaction metrics; analyze behavior.
- **[P2.T3.9] Change Tracking:** Log configuration changes; track model updates and retraining; version control artifacts.
- **[P2.T3.10] Vulnerability Scanning:** Conduct regular scans; assess threats (MITRE ATLAS); correlate with CVEs.

### 🚀 v2.1 Advanced Gap Fillers

- **[P2.T1.1_ADV] NHI Activity Logging:**
  - **Action Logging:** Log all actions by service accounts and agents
  - **Credential Usage:** Track where and when NHI credentials are used
  - **SIEM Integration:** Forward NHI logs for correlation

- **[P2.T1.2_ADV] Agent Behavior Verification:**
  - **Consensus Validation:** Verify multi-agent voting mechanisms
  - **Context Tracking:** Track memory state across interactions
  - **State Verification:** SHA-256 hashing of agent state

- **[P2.T1.3_ADV] Supply Chain Audit:**
  - **Signature Verification:** Verify OpenSSF OMS signatures
  - **SBOM Auditing:** Validate completeness against actual dependencies

- **[P2.T1.4_ADV] Memory Poisoning Detection:**
  - **RAG Auditing:** Audit knowledge bases for poisoned content
  - **Trigger Detection:** Detect adversarial trigger phrases

### ⚡ v3.0 New Controls

> These controls were introduced in v3.0 and remain part of the current [AI SAFE² v3.1 framework](../README.md). Current implementation resources are available through the [AI SAFE² toolkit](https://cyberstrategyinstitute.com/ai-safe2/).

| Control | Name | Priority | What It Solves |
| :--- | :--- | :--- | :--- |
| **[A2.3]** | Model Lineage Provenance Ledger | 🟠 HIGH | Cryptographic chain of custody from base model through every fine-tuning stage to production; extends OpenSSF OMS |
| **[A2.4]** | Dynamic Agent State Inventory | 🟠 HIGH | Real-time registry of every deployed agent with owner_of_record, ACT tier, tool authorizations, and control_plane_id |
| **[A2.5]** | Semantic Execution Trace Logging | 🔴 CRITICAL | Captures the full execution trace: reasoning chain, every tool call, every memory operation; append-only and agent-immutable |
| **[A2.6]** | RAG Corpus Diff Tracking | 🟠 HIGH | Hash-verified change log for retrieval layer; correlates behavioral changes to corpus changes automatically |

---

## 🏗️ Topic 4: Inventory (P2.T4)
*Asset Mapping, Dependencies, Documentation*

### Core Controls (v2.0)

- **[P2.T4.1] AI System Registry:** Catalog all LLMs, RAGs, and Agents; document owners and criticality.
- **[P2.T4.2] Model Catalog:** Inventory base and fine-tuned models; track versions and training sets.
- **[P2.T4.3] Agent Capability Doc:** Document agent autonomy levels, tools, and decision authority.
- **[P2.T4.4] Data Source Mapping:** Map data lineage; track refresh rates; identify RAG dependencies.
- **[P2.T4.5] API Inventory:** Catalog all APIs and MCP endpoints; document auth methods and rate limits.
- **[P2.T4.6] Tool Registry:** Maintain registry of tools and plugins; track permissions and usage.
- **[P2.T4.7] Dependency Tracking:** Track libraries and frameworks; identify transitive dependencies; cross-reference CVEs.
- **[P2.T4.8] Architecture Doc:** Document RAG and MCP architectures and data flows.
- **[P2.T4.9] Risk Registers:** Centralized threat register; link risks to components; track mitigation.
- **[P2.T4.10] Configuration Baselines:** Establish baselines; track deviations; drift detection.
- **[P2.T4.11] SBOM Generation:** Generate SBOMs for all models and apps; correlate with CVEs.

### 🚀 v2.1 Advanced Gap Fillers

- **[P2.T2.1_ADV] NHI Registry:**
  - **Automated Discovery:** Scan cloud and on-prem for NHI
  - **Lifecycle Tracking:** Track creation through decommissioning
  - **Fingerprinting:** Track NHI credentials per deployment

- **[P2.T2.2_ADV] Agent Architecture Inventory:**
  - **Swarm Topology:** Document multi-agent communication patterns
  - **Orchestration Tracking:** Track frameworks (AutoGen, CrewAI, LangGraph)

- **[P2.T2.3_ADV] Supply Chain Inventory:**
  - **Artifact Registry:** Catalog models with cryptographic fingerprints
  - **Signing Certificates:** Track certificates used for attestation

---

## 📊 Pillar 2 GRC Mapping

| Framework | Control | Mapping |
| :--- | :--- | :--- |
| OWASP AIVSS v0.8 | Risk #9 Untraceability | A2.5 Semantic Execution Trace |
| OWASP AIVSS v0.8 | Risk #8 Supply Chain | A2.3 Model Lineage Provenance |
| NIST AI RMF | MAP function | A2.3, A2.4 |
| ISO/IEC 42001 | Sec 8.2.4 | A2.3 provenance |
| SOC 2 | CC.7.1, CC.7.2, CC.8.1 | P2.T3, A2.5 |
| ISO 27001 | A.12.4 Audit Logging | A2.5 |
| CIS Controls v8 | CIS-1 Inventory | A2.4 |
| SEC Disclosure | Incident evidence | CP.6 + A2.5 |

---

## 🔗 Navigation

| Previous | Current | Next |
| :--- | :--- | :--- |
| [Pillar 1: Sanitize & Isolate](../01-sanitize-isolate/README.md) | **Pillar 2: Audit & Inventory** | [Pillar 3: Fail-Safe & Recovery](../03-fail-safe-recovery/README.md) |

[Framework Home](../README.md) | [Cross-Pillar Governance](../00-cross-pillar/README.md) | [AISM](../AISM/) | [NEXUS](../NEXUS/) | [Dashboard](https://cyberstrategyinstitute.github.io/ai-safe2-framework/dashboard/) | [Toolkit](https://cyberstrategyinstitute.com/ai-safe2/)

---

*AI SAFE² v3.1 · [Cyber Strategy Institute](https://cyberstrategyinstitute.com/ai-safe2/)*
