Done. I ran two evidence-gathering audits (a bug/agent-issue hunt and a DRY/latency hunt), triaged by severity, and fixed the high-value items with tests — no quality dropped. It's committed and pushed to PR #7.
Real bugs fixed (P1 — these were genuine correctness/agent failures):
- Loop-guard broke strict backends. When the loop guard caught a repeated tool call, it pushed only a nudge — leaving the assistant's
tool_call with no paired tool result, which makes strict fable-compatible backends return 400 on the next turn. It now pairs a tool result before nudging.
- Long turns died from scattered stalls.
chatTransportRetries was a session-wide counter, so three transient network stalls anywhere in a 40-iteration turn exhausted the budget and killed it. Retries are now budgeted per chat request.
- Quiet-giveup nudge was blind to gate failures. The all-failed-batch detector never saw PreToolUse-deny, permission-deny, or pro/read/TDD gate blocks, so a batch that failed entirely through gates wouldn't trigger the recovery nudge. Those paths now record into the batch tracker.
- Work With Me could leak a grant across projects. The session was a single global singleton reading one global file with no workspace check — switching projects could inherit another project's active window access. It's now keyed per workspace (Map + per-workspace state file), and load only restores a grant whose
workspaceRoot matches.
- A truncated SSE frame aborted the whole turn. The streaming parser did an unguarded
JSON.parse on data: frames; one bad frame killed the stream. It now skips malformed frames.
Intelligence/correctness (P2): overtime harness-guidance gates were checking maxIterations, so strict-gate, perseverance, auto-verify, checklist, self-review and steering all silently stopped firing during granted overtime — now they use effectiveMaxIterations. The system-prompt cache key used the length of the preferences JSON (two different payloads of equal length collided into a stale prompt) — now a djb2 content hash.
Debloat: removed the dead unreachable POST /cursor branch and its unused inMemory var in the overlay server.
Speed/latency (matters for local models): rg --version and the ffmpeg/ffprobe -version probes were spawnSync'd on every grep/video call — now cached at module scope; the interaction ledger (read on every system-prompt build) got an mtime cache mirroring preferences.
DRY: util/shell-errors.ts isMissingToolError unifies the missing-binary detection that had been coined separately in the computer tool and window enumeration.
Verification: 1465 tests pass (new ones cover SSE resilience, WWM cross-workspace isolation, loop-guard tool-result pairing, and the shell-errors helper), typecheck clean on core/tui-kit/app, exec smoke 10/10.
I deliberately left a few audit findings alone because touching them risked quality: I did not loosen the nudgeBudget stop (5 nudges with zero successful tool calls is genuinely stuck), and I skipped the riskier "share one loadAllSkills across prep" and "defer tool-store writes" refactors since disk there is already mtime-cached and the reread path depends on the eager write — the safe latency wins gave the benefit without the risk.