Trace till debug: agentic self-check by logs
The very first principle I followed was trace till debug. It was included in AGENTS.md, so the harness should leave enough trace to find a fault from the application logs. The system checks its own correctness by its logs, and when a check fails, an agent debugs it by the same logs:
- Logs follow the requirements. Every requirement is an operation: it turns inputs into outputs, and the code that implements it is marked with its id. Every event that code writes carries the same id, so the log of a scenario is its subtree in the requirements tree, whichever files wrote the events.
- The model checks the logs. Metrics and alerts are defined in the model, and their values are computed from the events of the running code. A value outside its target, a failed acceptance check or an error in a scenario becomes a task, with the scenario and its trace attached.
- Quiet by default. Each node of the tree declares how detailed its events are, and its children inherit it. In normal operation, the system writes little.
- The agent turns on branch logging while the system runs. The agent that takes the task finds the failing chain of operations in the trace and turns on detailed logging for that branch only, on one host, for a limited time. The running code picks up the change within seconds: no redeploy, no restart. The next run records the inputs and outputs of every step; the agent reads them and writes up the bug with evidence. Then detailed logging switches off by itself.
The theory. In control theory, Rudolf Kálmán called a system observable when its internal state can be inferred from its outputs. Charity Majors brought the word to software: answering new questions about a system without shipping new code. Changing log levels at runtime is not new either. Our innovative approach redefines the control you have. It links each feature to its own logging, through what we call hierarchical logging: you switch logging on for a feature, not for a file, and an agent does the switching.
The price. If you keep a current model of your system, you get these fantastic capabilities practically for free: the requirements tree and the code marked with its elements are already there. The one strict rule: every piece of code must be marked with its element, because unmarked code is invisible to the checks.