Auditability in AGISystem2 means every reasoning step can be traced back to its inputs and rules. The AuditLog component records all operations with timestamps and provenance, creating an immutable trail for debugging, compliance, and trust.

Query ASK "Dog IS_A ?" Reasoning Steps 1. Lookup Dog → vector v₁ 2. Find containment → Animal 3. Return result Result Animal (0.95) Audit Log Entries #001 | 2024-01-15T10:30:00Z | QUERY_START input: "ASK Dog IS_A ?" | context: layer=base | mask=full #002 | 2024-01-15T10:30:00Z | CONTAINMENT_CHECK Dog.center ∈ Animal.diamond → TRUE | distance=42 | threshold=100 #003 | 2024-01-15T10:30:01Z | QUERY_RESULT result: Animal | confidence: 0.95 | steps: 2 | duration: 1ms Audit Features Immutable log Hash chains Replay capability Export (JSON/CSV)

Every query creates audit log entries that record the input, each reasoning step, and the final result. The log is immutable with hash chains for integrity. Any decision can be replayed to verify correctness or investigate issues.

What Gets Logged

Event TypeData RecordedPurpose
QUERY_START Input, context, active layers, mask Reproduce initial conditions
CONCEPT_LOOKUP Name, vector hash, retrieval time Track data access
CONTAINMENT_CHECK Concepts, distance, threshold, result Explain IS_A decisions
BIAS_MASK_APPLIED Mask dimensions, context Fairness compliance
THEORY_PUSH/POP Layer name, facts added Counterfactual tracking
QUERY_RESULT Output, confidence, duration Performance and correctness

Log Entry Structure

{
  "id": "a1b2c3d4",
  "timestamp": "2024-01-15T10:30:00.123Z",
  "event": "CONTAINMENT_CHECK",
  "data": {
    "subject": "Dog",
    "predicate": "IS_A",
    "object": "Animal",
    "distance": 42,
    "threshold": 100,
    "result": true
  },
  "context": {
    "queryId": "q789",
    "layer": "base",
    "mask": "full"
  },
  "prevHash": "abc123...",
  "hash": "def456..."
}

Query Replay

Any logged query can be replayed to verify it produces the same result:

// Get original query from audit log
const entry = auditLog.getEntry("q789");

// Replay with same context
const replayResult = reasoner.replay(entry);

// Verify deterministic behavior
assert(replayResult.equals(entry.result));
// If not equal, something changed (data, code, or corruption)

Compliance Export

Audit logs can be exported for regulatory compliance:

// Export all entries for a time range
auditLog.export({
  format: "json",        // or "csv"
  from: "2024-01-01",
  to: "2024-01-31",
  events: ["BIAS_MASK_APPLIED", "QUERY_RESULT"],
  output: "/reports/january-audit.json"
});

Integrity Verification

Hash chains ensure the log hasn't been tampered with:

// Verify entire log integrity
const valid = auditLog.verifyChain();
// Returns: { valid: true } or { valid: false, brokenAt: "entry#123" }

// Each entry's hash includes previous hash
hash(entry) = SHA256(entry.data + entry.prevHash)

Related Documentation