| name | ari-hash-chain-auditor |
| description | Verify and manage ARI's SHA-256 hash-chained audit trail |
| triggers | ["verify audit chain","check audit integrity","audit hash verification","validate audit trail"] |
ARI Hash Chain Auditor
Purpose
Verify and manage ARI's tamper-evident SHA-256 hash-chained audit trail (ADR-002).
Hash Chain Structure
Genesis Block (0x00...00)
↓
Event 1: hash = SHA256(previousHash + eventData)
↓
Event 2: hash = SHA256(event1.hash + eventData)
↓
Event N: hash = SHA256(eventN-1.hash + eventData)
Audit File Location
~/.ari/audit.json
Verification Commands
npx ari audit verify
npm run audit:verify
Integrity Checks
- Chain Continuity: Each event's previousHash matches prior event's hash
- Hash Validity: Recalculate hash matches stored hash
- Genesis Validity: First event's previousHash is genesis (0x00...00)
- No Gaps: Sequential event IDs with no missing entries
- Timestamp Order: Events are chronologically ordered
When to Use
- After system recovery or restart
- Before any security-sensitive operations
- When investigating suspicious activity
- During compliance audits
- As part of quality gates
Verification Workflow
async verifyAuditChain(): Promise<VerificationResult> {
const audit = await loadAuditFile();
let previousHash = GENESIS_HASH;
for (const event of audit.events) {
if (event.previousHash !== previousHash) {
return { valid: false, error: 'Chain broken', event };
}
const computed = sha256(previousHash + JSON.stringify(event.data));
if (computed !== event.hash) {
return { valid: false, error: 'Hash mismatch', event };
}
previousHash = event.hash;
}
return { valid: true, eventCount: audit.events.length };
}
Security Alerts
If verification fails:
- DO NOT proceed with normal operations
- LOG the failure with full details
- ALERT via EventBus:
security:audit_tampered
- REQUIRE manual investigation
- BLOCK all sensitive operations
Integration with ARI Governance
- Overseer quality gate requires audit integrity
- Arbiter constitutional rule: audit_immutable
- All governance decisions must pass through verified audit