Files
Ignacy Łątka f4ff77e9e8 fix(debugger): stop LogFileWriter retaining console lines no reader can reach (#1126)
Fixes #892

**Cause** - when `LogFileWriter`'s file cannot be created, `ready` stays
false for the writer's life (nothing reopens it), so `write()` pushed
every formatted line into `writeBuffer`. Both drains are closed in that
state: `flushBuffer()` returns on `!this.ready`, and `readAll()` returns
`[]` before reaching it. Up to `MAX_ENTRIES` (50 000) lines per wedged
session, unreadable and never freed.

**Fix** - drop the dead buffering path; a line with no file is not
retained. Entry counts, level tallies and clusters are tracked
separately, so `getStats()` / `getClusters()` / `debugger-log-registry`
are unchanged, as is `readAll()`, which already returned `[]` in this
state.

`writeBuffer` / `flushBuffer` existed only in this file - no sibling
writer has the same shape. No docs change: no tool, CLI flag, config
key, flow directive or user-visible behaviour changed.

<details>
<summary>Verification</summary>

New test in `packages/tool-server/test/debugger/log-file-writer.test.ts`
chmods a temp-`HOME` `~/.argent/tmp` to `0555`, writes one entry, and
asserts the writer holds no line array while the counts and clusters
still record it (skipped on Windows and under uid 0).

Without the source fix:

```
FAIL  packages/tool-server/test/debugger/log-file-writer.test.ts > LogFileWriter whose log file cannot be created > keeps no copy of a line it could not write
AssertionError: expected [ '[L:0] 2024-03-09T16:00:00.000Z LOG…' ] to deeply equal []
Tests  1 failed | 19 passed (20)
```

With it:

```
npx tsc --build                                  # clean
npm run typecheck:tests -w @argent/tool-server   # clean
npm test -w @argent/tool-server                  # 368 files, 4833 passed | 1 skipped
npx prettier --write <changed files>             # unchanged
```
</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 23:11:11 +02:00
..