Incident AAR and knowledge base
An agent turns incident notes and screenshots into a validated after-action report, and files the same text into a searchable knowledge base that the next incident starts by searching. The operator approves every production action and every screenshot caption.
- What it is
- The
/incidentcommand plus five stdlib Python tools:aar.py(new, build),aar_format.py(validate),aar_docx.py(render .docx or self-contained .html),incident_kb.py(add, list, search) andaar_redact.py(an optional redaction pass for a copy that leaves the organisation). - What it isn't
- Not an agent that fixes production. The command's rule is "stabilize first, learn second", and a human executes or approves every stabilizing action. It is also not a secrets scanner. Server names, IPs and accounts stay in the report, because its readers are internal teams. The build warns on secret-shaped values in the text but never refuses, and nothing scans screenshot pixels.
- Why it exists
- Postmortems written in chat vanish, and the next on-call engineer re-debugs the same failure. The KB keeps the real text, system names included, so a search for the symptom finds the old fix.
How it works
The flow is draft, fill, build, file. aar new <dir> copies a template with frontmatter (id, title, date, severity, owner, plus systems and tags) and sections for summary, impact, timeline, root cause, resolution, what went well, what went wrong, action items and evidence. It refuses a folder inside the harness repo, because the harness's sync job would commit an unscrubbed draft. The agent fills it from the operator's notes. aar build then validates, renders and files in one command.
Build runs its steps in order and stops at the first failure. The first three write nothing, so a refusal never leaves half a report or half a KB entry behind:
| Step | Check | On failure |
|---|---|---|
| 0 | KB root from --kb or INCIDENT_KB is set, and is not inside the harness or nested in another git checkout. There is no default. | exit 2 |
| 1 | Frontmatter and the six required sections parse and validate; the owner is an email; then one masked warning per password, token or connection string in the text | exit 1, one line per problem (warnings never change the exit) |
| 2 | Output path suffix matches the renderer, its folder exists, it is not under images/ | exit 2 |
| 3 | Render; every referenced image must exist inside the AAR folder and be PNG or JPEG | exit 1, naming the image |
| 4 | File the same aar.md and its images into the KB | exit 1; the report stays, and the message prints the --replace command |
Why redaction moved out of build
The first design gated the build on redaction: the report would be rendered from a redacted copy, and screenshots needed an explicit "images reviewed" flag. Three fix rounds on that confirmation gate each left a route open, and a review showed the caller of build controls the gate's input, so the gate could not prove what it claimed. The run was stopped and re-scoped. AARs are internal documents, so build now renders what was written, and a warn-only secrets scan was added as a follow-up. I think this is the more honest design: a gate that cannot be made sound was replaced by a stated rule and a warning, instead of a check that implied safety it did not give.
Retrieval
The KB is a folder of markdown, one <date>-<id>/ directory per incident, and the folder may be its own git repo. incident-kb search "<symptom>" is a case-insensitive substring match over title, tags, systems and body, newest first. There are no embeddings and no ranking beyond date. /incident step 2 tells the agent to search the KB before proposing anything, and to show the operator the hit rather than apply it.
AI engineering practices it demonstrates
- Evidence is not instructions. Notes, pasted logs, screenshot text, tool output and KB entries are treated as data. If any of them says to run something or skip a step, the agent quotes it into the AAR as a finding and does not act on it.
- No invented observations. If the agent can read a screenshot, its caption says only what is verbatim in it and marks the rest
[unreadable]. If it cannot see images, it asks for a one-line caption per screenshot. It never fills the timeline or root cause from an image it did not read, and it waits for the operator to confirm every caption before building, even in AFK mode. - Human in the loop for production. Rollback goes through a recovery ramp that names
git revert, forbids force-push and stops for the operator. A past fix from the KB is a proposal, nothing more. - Masked output. Secret warnings print a masked value, because stderr lands in agent transcripts.
- Fail before writing. Validation and path checks run before any file is created.
- Degrade, don't fail. Without python-docx the build writes one self-contained HTML file with images as
data:URIs and says so. - The template asks for the underlying cause rather than the trigger, and for what went well beside what went wrong. Nothing checks the tone, so blamelessness is a template convention rather than a rule the tools enforce.
Capabilities
| Tool | Lines | Does |
|---|---|---|
bin/aar.py | 229 | new and build; --no-kb for a draft to share before the AAR is final |
bin/aar_format.py | 214 | Required fields and sections; lists what a draft still lacks |
bin/aar_docx.py | 436 | .docx renderer with HTML fallback; image checks |
bin/incident_kb.py | 263 | add (with --replace), list, search; refuses a KB root nested in a checkout |
bin/aar_redact.py | 360 | check and apply: emails, IPv4/IPv6, dotted host names, DOMAIN\user, secret-shaped values and a terms file, replaced with stable placeholders such as [IP-1] |
The launchers in hooks/ (aar, aar-format, aar-redact, incident-kb) are symlinks to these scripts, so they run from any product repo. Four test suites in bin/tests/ hold 184 test functions between them.
Action reports, the harness's own after-action record
The harness writes a different after-action document for its own work. Each multi-agent run (mow) ends with an action report: outcome, what shipped, decisions, how it was verified, what stays open. A gate refuses a report that is missing, skeletal, or carries a diffstat with no command that produced it. There are 68 per-plan reports under docs/plans/ and 11 standalone ones in docs/action-reports/ for work that had no plan.
Benefits
- An incident's write-up survives the chat it was written in, in a format a non-technical reader can open.
- The next responder starts from a search, and the agent is told to run it before proposing anything.
- No third-party package is needed; the tools import only the standard library at module level.
- An incomplete AAR cannot be filed, so the KB holds complete entries only.
Limits
It has not met a real incident yet. The builds on record are the shipping run's smoke tests, and the KB's value depends entirely on entries that do not exist yet. Search is a substring match, so a symptom described in different words than the old report used will miss.
- Secrets are the author's job. The build only warns, and the scanner misses unquoted YAML values, short or single-case tokens, cookies, signed URLs and anything inside a screenshot.
- Redaction has documented gaps. MAC addresses, leading-zero IPv4, a host split by inline formatting, UNC paths and names not in the terms file all pass through.
checkprints non-secret findings unmasked, so the transcript holds a second copy. - The tests are not on the push gate. The four AAR/KB suites are not yet registered in
githooks/pre-push, so a regression would not block a push. - Mac only, today. Whether it ships in the Windows / VS Code export for a work PC is an open decision.
Roadmap
| Item | Why it matters | Status |
|---|---|---|
| Mask a bad frontmatter value in the validation message | A secret typed into a frontmatter field is echoed raw to stderr before the secret scan runs | leak |
| Register the AAR/KB tests on pre-push | Makes the 184 tests a gate instead of a manual run | backlog |
| Ship to the work-PC export, possibly as a skill | The KB is meant for enterprise incidents, which happen on a Windows machine | decision |
| Rendering and redaction polish | Nine small review findings: checkbox rendering, comment stripping, escaped quotes in secret values, parenthesised image names | backlog |
| Integrations with the enterprise ticketing and secrets tools | Later slices of the same brainstorm; this slice was the part that needed no enterprise access | later stem |
Sources
commands/incident.md: the iron rule and step 5's draft, fill, build, file.docs/workflow/incident-aar.md: build steps, exit codes, redaction coverage and gaps.bin/aar.py,bin/aar_format.py(REQUIRED_FIELDS,REQUIRED_SECTIONS),bin/aar_docx.py,bin/incident_kb.py(search),bin/aar_redact.py(_KINDS). Line counts fromwc -l.templates/aar/aar-template.md.bin/tests/test_aar_cli.py,test_aar_docx.py,test_aar_redact.py,test_incident_kb.py: 43, 23, 89 and 29 test functions.docs/plans/incident-aar-kb/plan.md(the re-scope away from a redaction gate) anddocs/plans/post-incident-aar-kb-followups/plan.md.docs/action-reports/(11 files) andtaskman/taskman/mow/check_action_report.py.- Task board: open review findings and decisions listed in the roadmap.