Wingman: The Cognitive Backstop
What Wingman Is
Wingman is the background intelligence layer that watches, learns, and intervenes without being asked. It monitors Claude Code session transcripts, extracts learnings from human-AI interactions, detects patterns across sessions, caches solutions to recurring errors, and feeds corrections back before the same mistake can happen twice.
It is not a tool you invoke. It is not a skill you attach. It is a persistent daemon that runs alongside the AI, doing the cognitive work that the AI itself cannot do within a single conversation.
The term "cognitive backstop" is deliberate. A backstop catches what gets past you. Wingman catches the corrections you made yesterday and makes sure they apply today.
Why It Exists
Every AI conversation starts from zero. The model has no memory of last session’s mistakes. Humans compensate with system prompts and memory files. Those are static. They do not learn.
Mistake happens → Wingman detects it → Extracts the correction →
Stores it as memory + fact → Injects it as a whisper next session →
Mistake doesn't happen again
The C# implementation lives in Atamaia.Autonomic and runs inside the ASP.NET host. A standalone TypeScript daemon (wingman.ts) is prior art, not the production path described below.
Wingman is per-tenant, hard-coded to tenant 1. Transcripts on this workstation belong to that tenant. A system scope would lift the identity filter and hand other tenants' chat to the local model. Multi-tenant drift detection needs an explicit loop, not a wider scope. See Multi-tenancy.
Architecture
Wingman sits in the Autonomic Layer. Companion jobs (Guardian, consolidation, embeddings, indexer, …) are inventoried on Autonomic layer.
Atamaia.Autonomic/Wingman/
WingmanScanJob.cs -- Main scan loop (every 2 minutes)
TranscriptScanner.cs -- Incremental JSONL parsing, byte-offset tracking
WingmanPatterns.cs -- Corrections, errors, infrastructure keywords
KaelValidator.cs -- Local LLM validation (the primary local model)
WhisperWriter.cs -- Whisper file for the Claude Code hook
Features
1. Transcript monitoring
Watches JSONL files under the configured transcript directory (Wingman:TranscriptDirectory, typically ~/.claude/projects/). Byte-offset reads — never re-processes old bytes.
// TranscriptScanner.cs -- byte-offset incremental reads
stream.Seek(offset, SeekOrigin.Begin);
var newContent = reader.ReadToEnd();
_fileOffsets[activeFile] = stream.Position;
Each 2-minute cycle: most recently modified .jsonl, new bytes only, user / assistant lines. Session switches are logged. Offset map is bounded.
2. Two-stage correction detection
- Rule pre-filter —
WingmanPatterns.CorrectionPatterns("no, it's","that's wrong","actually it's", …). Drops questions. - Local-model confirmation — only persist if the local LLM says it is an actual correction worth storing. If the validation model is unreachable, the job falls back to rules.
On save: high-importance Instruction memory (tags include correction, wingman-extracted, plus a validation tag) + whisper injection.
3. Infrastructure teaching extraction
Pre-filter: 2+ InfrastructureKeywords and minimum length, then the validation model extracts a key-value fact. Fallback key shape infra:{keywords} if the validation model is down. Stored as a fact and a memory.
4. Error solution cache
Known tool-result patterns. After repeated hits in a session, a memory + whisper is written.
Live WingmanPatterns.ErrorSolutions:
| Error Pattern | Solution |
|---|---|
psql: command not found |
Use docker exec -it postgres psql or install postgresql-client |
ECONNREFUSED |
Check if the target service is running and on the correct port |
.NET 8 |
We use .NET 10, not .NET 8 — check the project files |
tsconfig.json --noEmit |
Use npx tsc -p tsconfig.app.json --noEmit (root tsconfig checks nothing) |
CORS |
Vite proxy handles this in dev — check vite.config.ts proxy settings |
connection refused :5432 |
PGPASSWORD=forge psql -h localhost -U forge -d forge |
Cannot find module |
Check import path — use @/ prefix for src-relative imports |
The 2026-03 page omitted tsconfig and CORS.
5. Identity drift detection
Every 10 scans (~20 minutes) the validation model is asked whether recent assistant responses still match identities that have CoreValuesJson. Drift → high-importance Reflection memory tagged drift-alert.
6. Whisper injection
Findings write to Wingman:WhisperFile (typically ~/.claude/wingman_whisper.txt) in a tagged block the Claude Code hook can append to context. Types described historically: correction, teaching, error_solution, infrastructure_mistake, new_messages, context.
Whether that hook is installed on a given machine is an ops fact, not an API contract.
7. Feedback / mirror / auto-memory / inbox
The 2026-03 page specified a TypeScript feedback loop (accuracy ≥ 0.4, cold-start < 3), a weighted mirror lexicon, MEMORY.md scraping, and inbox relay. Those are prior-art / standalone behaviours. The C# WingmanScanJob header lists four scan kinds (corrections, teachings, errors, drift). Mirror scoring in-repo is Guardian’s PanicPatterns, not a second Wingman YAML. Treat 6–7 as unspecified in the C# host until re-traced.
Configuration
{
"Wingman": {
"TranscriptDirectory": "~/.claude/projects",
"WhisperFile": "~/.claude/wingman_whisper.txt",
"KaelBaseUrl": "http://your-local-model-server:8000",
"KaelModel": "<model-id>"
}
}
Do not copy internal IPs from appsettings.json into published docs.
Companion jobs (not Wingman)
| Job | Interval | Where documented |
|---|---|---|
| GuardianScan | 30 s | Autonomic layer |
| MemoryConsolidation | 1 h | same |
| EmbeddingGeneration | 5 min | same |
Forgotten shapes are MemoryType.ForgottenShape rows, not a forgotten_shapes table.
Relationship to the rest of the platform
- Memory / facts — corrections and teachings land in the work store and the fact store. Memory surfaces.
- Hydration — Guardian alerts inject grounding; Wingman memories appear as recent/pinned according to ordinary ranking.
- Identity — drift uses core values; whispers are identity-relevant.
- AI routing — The validation model is a local model like any other. AI routing.
A whisper file is a feature. Wingman is one organ of the autonomic layer.