Audit, Detection, and Incident Response
Language AI HandbookAll chapters A test account's agent has unexpectedly requested an external write. The responder opens the trace and sees a tool call, but the record leaves two questions unanswered. Which identity authorized it, and did the operation finish? Those answers determine whether to inspect a single approval or temporarily suspend the tool. This chapter shows how to preserve the evidence, distinguish a lead from an incident, and test a narrow containment decision on invented events.
Preventive controls set the conditions under which an operation can proceed. Audit records provide evidence about how those conditions were applied, what the gateway observed, and which facts still need independent confirmation.
That question has three parts, and they map to the three pillars of this chapter.
Auditing designs a record of consequential decisions and outcomes. A chain with a separately protected checkpoint helps detect changes to the committed sequence. Verify coverage and factual accuracy using independent observations.
Detection is about turning those records (and the live stream of events) into signals. It is the "what looks wrong" layer. Its central artifacts are anomaly scores, threshold policies, and the alerts they raise.
Incident response is about what you do once a signal fires or a report arrives. It is the "what we do now" layer. Its central artifacts are a kill switch, an evidence-preservation procedure, a containment and recovery playbook, and a post-incident review that feeds back into detection and prevention.
A chain can verify agreement with the snapshot committed at a protected checkpoint. Investigators still need evidence that an event was recorded and that its fields accurately describe the observed operation.
It is worth pausing on why these three pillars are grouped together in a single chapter rather than treated as three separate concerns. The reason is that they form a closed feedback loop, and a loop only works if every link is engineered to the same standard. Auditing without detection produces records nobody reads. Detection without auditing produces alerts you cannot explain or investigate. Detection without incident response produces signals nobody acts on. And incident response without auditing produces investigations with no evidence to examine. The three are also ordered in a specific way: detection reads the records that auditing produces, and incident response consumes the signals that detection produces, so the quality of each downstream pillar is bounded by the quality of the one before it. A brilliant detection program running on an incomplete audit trail will miss attacks; a disciplined response team working from noisy detectors will spend its energy on false alarms. Improving the pipeline at any point lifts everything that follows, which is why we treat the record design (the first pillar) with the most care.
There is a second reason for the grouping, one that has to do with the economics of security. Preventive controls are binary in the sense that they either block an action or allow it, and once they are deployed they either work or they don't on a given input. They offer no mechanism for getting better after launch, because a filter that blocks an attack today blocks the same attack tomorrow but says nothing about the attacks it has never seen. Detection and response, by contrast, are learning mechanisms. Every incident, every near-miss, every false alarm that a human triages teaches you something about the shape of the attacks your prevention layer missed, and that knowledge can be converted into new signatures, tighter permissions, and improved tests. A defense stack that contains only prevention is a defense stack that is frozen at the moment of its last update. A defense stack that contains prevention plus audit, detection, and response is a defense stack that improves for as long as the team is willing to do the work. That asymmetry is the entire justification for treating these pillars as first-class engineering concerns rather than as an afterthought bolted on for compliance.
These three words are used loosely in practice. Here we fix them:
- Logging is emitting records. Any system logs; it is a precondition, not a property.
- Tracing relates observed operations across components using trace context and, when captured, span or dependency relationships.
- Auditing records consequential actions with enough context for investigation. It requires evidence that records are emitted and protected, and responders use corroboration to establish what happened.
Routine logs can omit records during delivery or include details that should never enter a durable audit store. An audit design defines which events to capture and tests whether each known route emits its expected records.
A trace ID can group retrieval, tool invocation, and completion records associated with the same request. To establish that the tool consumed a particular retrieval result, inspect the recorded dependency and corroborate it with the execution record.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!