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.

  • Human in the loop
  • Retrieval
  • Prompt-injection hygiene
  • Data handling
What it is
The /incident command 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) and aar_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.

aar-redact optional, by hand Refused exit 1 · nothing written Incident human stabilizes aar.md new · fill · captions aar build validate · warn secrets Report .docx, or .html fallback Incident KB <date>-<id>/aar.md + images Next incident incident-kb search draft approved render file same aar.md invalid copy leaving org symptom matches proposal to human
Redaction sits beside the pipeline, not in it. The report and the KB entry are built from the same unredacted text. Redaction is a separate step run by hand on the rare copy that leaves the organisation.

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:

StepCheckOn failure
0KB 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
1Frontmatter 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 textexit 1, one line per problem (warnings never change the exit)
2Output path suffix matches the renderer, its folder exists, it is not under images/exit 2
3Render; every referenced image must exist inside the AAR folder and be PNG or JPEGexit 1, naming the image
4File the same aar.md and its images into the KBexit 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

ToolLinesDoes
bin/aar.py229new and build; --no-kb for a draft to share before the AAR is final
bin/aar_format.py214Required fields and sections; lists what a draft still lacks
bin/aar_docx.py436.docx renderer with HTML fallback; image checks
bin/incident_kb.py263add (with --replace), list, search; refuses a KB root nested in a checkout
bin/aar_redact.py360check 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

Where it loses

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. check prints 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

ItemWhy it mattersStatus
Mask a bad frontmatter value in the validation messageA secret typed into a frontmatter field is echoed raw to stderr before the secret scan runsleak
Register the AAR/KB tests on pre-pushMakes the 184 tests a gate instead of a manual runbacklog
Ship to the work-PC export, possibly as a skillThe KB is meant for enterprise incidents, which happen on a Windows machinedecision
Rendering and redaction polishNine small review findings: checkbox rendering, comment stripping, escaped quotes in secret values, parenthesised image namesbacklog
Integrations with the enterprise ticketing and secrets toolsLater slices of the same brainstorm; this slice was the part that needed no enterprise accesslater 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 from wc -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) and docs/plans/post-incident-aar-kb-followups/plan.md.
  • docs/action-reports/ (11 files) and taskman/taskman/mow/check_action_report.py.
  • Task board: open review findings and decisions listed in the roadmap.

Facts as of 2026-10-08. Line and test counts read from source on that date.