qwen-code/docs/developers/daemon
jinye 4615f84d73
fix(serve): allow bounded reads of large text files (#7947)
* fix(serve): allow bounded reads of large text files

* fix(serve): bound large-text reads by scan cost, not by which knob was set

Follow-up to the bounded large-text read path. Three changes:

Gate on any explicit window argument, not on `limit`. Gating on `limit`
had the cost model backwards in both directions: `{ line: 900_000_000,
limit: 20 }` was admitted despite walking the whole file, while
`{ maxBytes: 4096 }` — satisfiable from the first 4 KiB — was refused. A
read with no window argument at all still fails, since a caller that
believes it holds the whole file may write it back truncated.

Add MAX_TEXT_SCAN_BYTES (8 MiB). MAX_READ_BYTES caps what a read
returns; nothing capped what it cost. Line offsets are resolved by
scanning from byte 0, so a query param could turn into an
uninterruptible multi-second scan of an arbitrarily large file — and on
Windows hold a read handle for that span, blocking renames and deletes.
Past the budget the read is refused with `file_too_large` pointing at
readBytes, which reaches any offset in O(1).

Tolerate appends on streamed windows. Requiring whole-file size/mtime
stability after reading a prefix rejected reads whose returned bytes
were still valid, and the case it rejected — tailing a live log — is the
one this path exists for. Streamed windows now assert inode identity
plus "did not shrink"; truncation and replacement are still rejected.

Also: non-UTF-8 large text now returns `binary_file` rather than
`file_too_large`, so a client retrying on 413 with a smaller window
can't loop forever; and `readFileWithLineAndLimit` throws instead of
silently ignoring a caller-supplied `fileHandle` on the by-path
fallback.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(serve): harden large text range snapshots

Treat caller-owned file handles as bounded streaming reads, cap them to the captured file size, and reuse the chunk buffer.

Restore strict Serve snapshot stability and align returned-slice metadata with the full-snapshot path.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(serve): make large text ranges snapshot-safe

* fix(serve): harden large-text ctime tests and document buffer reuse (#7947)

Address review feedback on the large-text range read PR:

- Pause before restoring mtime in the two ctime-dependent mutation tests so the change-time advances past the pre-read snapshot even on coarse-resolution filesystems, removing a latent flake in the same-size-overwrite precondition. The assertions are unchanged.

- Document at the readFileHandleChunks yield site that the 512 KiB buffer is reused across iterations, so yielded views must be decoded or copied before advancing the generator.

* docs(serve): soften same-size rewrite guarantee to coarse-clock best-effort (#7947)

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Qwen Code Autofix <qwen-code-autofix@users.noreply.github.com>
2026-07-29 07:49:51 +00:00
..
00-index.md docs(serve): Close multi-workspace hardening gaps (#7019) 2026-07-16 17:33:53 +00:00
01-architecture.md feat(cli): Enable multi-workspace session routing (#6511) 2026-07-08 10:06:31 +00:00
02-serve-runtime.md feat(serve): make ACP initialize handshake timeout configurable (#7246) 2026-07-20 23:07:51 +00:00
03-acp-bridge.md fix(acp-bridge): raise live journal caps and expose as daemon config (#7715) 2026-07-25 14:14:09 +00:00
04-permission-mediation.md docs(daemon): refresh daemon docs for recent PRs (wave 2) (#5954) 2026-06-28 08:36:30 +00:00
05-mcp-transport-pool.md docs(serve): Close multi-workspace hardening gaps (#7019) 2026-07-16 17:33:53 +00:00
06-mcp-budget-guardrails.md docs(serve): Close multi-workspace hardening gaps (#7019) 2026-07-16 17:33:53 +00:00
07-workspace-filesystem.md fix(serve): allow bounded reads of large text files (#7947) 2026-07-29 07:49:51 +00:00
08-session-lifecycle.md feat(web-shell): add monitor task details (#7817) 2026-07-27 12:30:17 +00:00
09-event-schema.md fix: Make chat recording failures durable and visible (#6743) 2026-07-12 10:52:26 +00:00
10-event-bus.md fix: Make chat recording failures durable and visible (#6743) 2026-07-12 10:52:26 +00:00
11-capabilities-versioning.md feat(web-shell): add monitor task details (#7817) 2026-07-27 12:30:17 +00:00
12-auth-security.md feat(serve): support multi-workspace rewind and shell (#6826) 2026-07-13 15:32:44 +00:00
13-sdk-daemon-client.md feat: support workspace display names (#7179) 2026-07-20 15:16:44 +00:00
14-cli-tui-adapter.md fix: Make chat recording failures durable and visible (#6743) 2026-07-12 10:52:26 +00:00
15-channel-adapters.md feat(channels): GitHub polling adapter with notification-as-wakeup architecture (#7632) 2026-07-25 09:31:50 +00:00
16-vscode-ide-adapter.md feat(cli): Enable multi-workspace session routing (#6511) 2026-07-08 10:06:31 +00:00
17-configuration.md fix(serve): allow bounded reads of large text files (#7947) 2026-07-29 07:49:51 +00:00
18-error-taxonomy.md fix(serve): allow bounded reads of large text files (#7947) 2026-07-29 07:49:51 +00:00
19-observability.md feat(cli): Add bounded daemon log rotation (#6969) 2026-07-18 16:18:58 +00:00
20-quickstart-operations.md feat(serve): make ACP initialize handshake timeout configurable (#7246) 2026-07-20 23:07:51 +00:00
_meta.ts docs(daemon): Refresh daemon docs in English (#5144) 2026-06-15 22:38:01 +08:00