Network-AI
Governance

Audit Log Schema

Audit log field reference, event types, and denial scoring data.

Source file: AUDIT_LOG_SCHEMA.md

Audit Log Schema — Network-AI

Network-AI writes a JSONL audit trail during permission management and swarm execution. This document describes every field and event type.


File Location

data/audit_log.jsonl

One JSON object per line. The file is append-only. Each entry is a complete, self-contained record — no dependencies between lines.

The CLI provides direct access without inspecting the file manually:

network-ai audit log            # print all entries (add --limit <n> to cap output)
network-ai audit tail           # live-stream new entries as they are appended
network-ai audit clear          # reset the log (irreversible)
network-ai --json audit log     # machine-readable output

Envelope (all events)

Every log entry uses the same outer structure:

{
  "timestamp": "2026-02-28T14:32:01.123456+00:00",
  "action":    "<event_type>",
  "details":   { ... }
}
FieldTypeDescription
timestampISO 8601 UTC stringWhen the event occurred
actionstringEvent type — see table below
detailsobjectEvent-specific payload — see per-event schemas

Event Types

actionEmitted byTrigger
permission_requestcheck_permission.pyAgent requests access to a resource
permission_grantedcheck_permission.pyRequest passes weighted scoring; token issued
permission_deniedcheck_permission.pyRequest fails scoring threshold
permission_revokedrevoke_token.pyToken explicitly revoked
ttl_cleanuprevoke_token.pyExpired tokens pruned from active_grants.json
budget_initializedswarm_guard.pyFederatedBudget ceiling set for a session
handoff_allowedswarm_guard.pyAgent-to-agent handoff passes all checks
handoff_blockedswarm_guard.pyAgent-to-agent handoff blocked by guard
safety_shutdownswarm_guard.pySwarm halted due to budget ceiling breach
initcontext_manager.pyProject context file created
update_decisionscontext_manager.pyArchitecture decision recorded
milestone_completecontext_manager.pyMilestone marked as completed
milestone_addcontext_manager.pyMilestone added to a bucket
update_stackcontext_manager.pyTech stack entry updated
update_goalscontext_manager.pyProject goal added
update_bannedcontext_manager.pyBanned approach recorded
update_projectcontext_manager.pyProject metadata updated

Per-Event details Schemas

permission_request

{
  "agent_id":      "data_analyst",
  "resource_type": "DATABASE",
  "justification": "Need customer order history for Q1 sales report",
  "scope":         "read"
}
FieldTypeNotes
agent_idstringRequesting agent identifier
resource_typestringDATABASE, PAYMENTS, API, FILESYSTEM, EMAIL, CUSTOMER_DATA, INTERNAL_SERVICES
justificationstringFree-text justification, scored before grant
scopestring \nullOptional scope restriction (e.g. read, write)

permission_granted

{
  "token":         "grant_a1b2c3d4e5f67890abcdef1234567890ab",
  "agent_id":      "data_analyst",
  "resource_type": "DATABASE",
  "scope":         "read",
  "expires_at":    "2026-02-28T14:37:01.123456+00:00",
  "restrictions":  ["read-only", "no-schema-changes"],
  "granted_at":    "2026-02-28T14:32:01.123456+00:00"
}
FieldTypeNotes
tokenstringgrant_ + 32 hex chars (UUID4, no dashes)
agent_idstringAgent the token was issued to
resource_typestringResource access was granted for
scopestring \nullScope restriction, if provided
expires_atISO 8601 UTCToken expiry (default: 5 minutes from grant)
restrictionsstring[]Resource-type-specific restrictions applied
granted_atISO 8601 UTCSame as envelope timestamp

permission_denied

{
  "agent_id":      "untrusted_bot",
  "resource_type": "PAYMENTS",
  "reason":        "Combined evaluation score (0.31) below threshold (0.5).",
  "scores": {
    "justification": 0.25,
    "trust":         0.40,
    "risk":          0.90,
    "weighted":      0.31
  }
}
FieldTypeNotes
agent_idstringRequesting agent
resource_typestringResource that was denied
reasonstringHuman-readable denial reason
scores.justificationfloat 0–1Justification quality score (40% weight)
scores.trustfloat 0–1Agent trust level (30% weight)
scores.riskfloat 0–1Resource risk score (30% weight, inverted)
scores.weightedfloat 0–1Final combined score; threshold = 0.50

permission_revoked

{
  "token":    "grant_a1b2c3d4e5f67890abcdef1234567890ab",
  "agent_id": "data_analyst",
  "reason":   "manual revocation"
}

ttl_cleanup

{
  "removed_tokens": ["grant_abc...", "grant_def..."],
  "count":          2
}

budget_initialized

{
  "ceiling": 5000,
  "unit":    "tokens"
}

handoff_allowed

{
  "from_agent": "orchestrator",
  "to_agent":   "implementer",
  "task":       "implement payment service",
  "budget_remaining": 4120
}

handoff_blocked

{
  "from_agent": "implementer",
  "to_agent":   "orchestrator",
  "reason":     "budget_exceeded",
  "budget_used": 5100,
  "budget_ceiling": 5000
}

safety_shutdown

{
  "reason":         "budget_ceiling_breached",
  "budget_used":    5100,
  "budget_ceiling": 5000,
  "agent":          "rogue_agent"
}

Scoring Reference

Permission decisions use a three-factor weighted score:

FactorWeightSource
Justification quality40%Scored by score_justification() — checks specificity, context, action verbs, structural coherence, 16 prompt-injection patterns
Agent trust level30%Lookup in DEFAULT_TRUST_LEVELS dict; unknown agents default to 0.5
Resource risk (inverted)30%Base risk per resource type; high-risk resources require higher total score

Approval threshold: 0.50. Requests below this are logged as permission_denied.


Node.js Layer (TypeScript package)

When using the network-ai npm package directly, the SecureAuditLogger class in security.ts produces HMAC-SHA256-signed entries with the same envelope format plus a signature field. This is separate from the Python script layer described above.


Retention & Privacy

  • The log is append-only. There is no built-in rotation — implement log rotation at the infrastructure level (e.g. logrotate, S3 lifecycle policy).
  • No PII is logged by default. Justification text is logged as-provided — avoid including PII in justification strings.
  • No API keys, tokens in cleartext, or sensitive resource content are logged.