Repository navigation
Replies: 2 comments
|
Following up on the UTF-8 polling-boundary finding in this discussion: I reproduced it on A real Node child, launched through
Validation on macOS / Node 26.7.0:
These are source-level tests with real local child processes and a mocked SSH transport. Installed Desktop, a complete model/session replay, native Windows/Linux, a real remote SSH host, and full repository build/typecheck/lint/doc-sync/CI were not run. I used an isolated Vitest configuration with this repository's source aliases and standard-decorator transform; the reported count is not the full workspace suite. The patch is scoped to this issue only. The test files are included so it can be reviewed and integrated into the owning suites. Reference patch (implementation, regression tests, and bilingual docs)diff --git a/packages/ssh/subprocess-ssh/src/index.ts b/packages/ssh/subprocess-ssh/src/index.ts
index 9e84765..31d3229 100644
--- a/packages/ssh/subprocess-ssh/src/index.ts
+++ b/packages/ssh/subprocess-ssh/src/index.ts
@@ -64,6 +64,7 @@ class RemoteProcess implements SubprocessHandle {
finalized = final
collector = new OutputCollector(mode.maxBytes, name, undefined)
collector.push(bytes)
+ if (final) collector.seal()
base = snapshot.totalBytes - bytes.length
total = snapshot.totalBytes
}
diff --git a/packages/ssh/subprocess-ssh/tests/process-behavior.spec.ts b/packages/ssh/subprocess-ssh/tests/process-behavior.spec.ts
index 2b34fb0..aefc9c3 100644
--- a/packages/ssh/subprocess-ssh/tests/process-behavior.spec.ts
+++ b/packages/ssh/subprocess-ssh/tests/process-behavior.spec.ts
@@ -206,6 +206,19 @@ describe('SSH ordinary process behavior', () => {
expect(handle.collected.stdout!.readFrom(8)).toEqual({ text: 'ij', nextOffset: 10, lossy: false, spillPath: '/remote/spill' })
})
+ it('flushes an unfinished UTF-8 character from the final collected snapshot', async () => {
+ const test = await setup()
+ const handle = test.runtime.spawn({ ...spec, stdio: { stdin: 'ignore', stdout: { maxBytes: 4 }, stderr: { maxBytes: 4 } } })
+ await test.started
+ test.finished.resolve({ ...emptyResult, collected: {
+ stdout: { tail: Buffer.from([0xe4, 0xb8]).toString('base64'), totalBytes: 2 },
+ stderr: { tail: '', totalBytes: 0 },
+ } })
+ await handle.done
+ expect(handle.collected.stdout!.readFrom(0)).toEqual({ text: '\ufffd', nextOffset: 2, lossy: false })
+ expect(handle.collected.stdout!.readFrom(2)).toEqual({ text: '', nextOffset: 2, lossy: false })
+ })
+
it.each([
{ tail: '12345', total: 5, error: 'invalid collected output coordinates' },
{ tail: 'abcd', total: 3, error: 'invalid collected output coordinates' },
diff --git a/packages/subprocess/subprocess-local/README.i18n.yaml b/packages/subprocess/subprocess-local/README.i18n.yaml
index e5827af..87e626d 100644
--- a/packages/subprocess/subprocess-local/README.i18n.yaml
+++ b/packages/subprocess/subprocess-local/README.i18n.yaml
@@ -24,8 +24,8 @@
en: b770dddf2a9c3d1e
zh: f5cb27e63a589a1b
/deepseek-ai-dsh-subprocess-local/use-this-package/collecting-output:
- en: 8dc283e0b25399c9
- zh: 9c129dce09e36c91
+ en: 5095f868a23bb3ad
+ zh: b7194d478d9b4fdd
/deepseek-ai-dsh-subprocess-local/use-this-package/control-transport:
en: 7f14cd108b614c98
zh: da54e49e2b1896d2
diff --git a/packages/subprocess/subprocess-local/README.md b/packages/subprocess/subprocess-local/README.md
index 0e5423a..a523211 100644
--- a/packages/subprocess/subprocess-local/README.md
+++ b/packages/subprocess/subprocess-local/README.md
@@ -46,6 +46,8 @@ Windows ordinary subprocesses start the private Job runner with `windowsHide` an
Collect mode keeps the last `maxBytes` of a stream in memory — errors and final results cluster at the end — and, when a `spill` cap is configured, appends the complete stream to a private file under a per-process directory in the OS temp dir (a `0700` directory, `0600` random-named files). A stream larger than the spill cap discards its incomplete spill and returns only the marked truncated tail. Spilling is best-effort: when the spill file cannot be opened or appended (the per-process directory removed by a temporary-file cleaner, `EACCES`, `EMFILE`, `ENOSPC`), the collector discards the spill, logs one `error` through the plugin logger, and keeps collecting the in-memory tail, so the result is truncated with no spill path. Reads are offset-based and non-consuming, so background and batch readers coexist before and after exit.
+Live reads withhold up to three trailing bytes of an unfinished UTF-8 character and leave `nextOffset` before those bytes. Once the character is complete, every reader can decode it independently. `seal()` marks EOF and flushes any remaining incomplete sequence as replacement text; adapters must seal their final snapshot before exposing it as settled output. Raw snapshots and spill files retain the original bytes.
+
The `./output` export shares this collector and retained-spill storage with process adapters. `snapshot()` returns the retained raw bytes and total byte count, allowing remote adapters to preserve offsets without forwarding the complete stream.
### Control transport
diff --git a/packages/subprocess/subprocess-local/README.zh.md b/packages/subprocess/subprocess-local/README.zh.md
index 32a1b93..71f5ffb 100644
--- a/packages/subprocess/subprocess-local/README.zh.md
+++ b/packages/subprocess/subprocess-local/README.zh.md
@@ -46,6 +46,8 @@ Windows 普通子进程通过 `windowsHide` 启动私有 Job runner,并为原
收集模式在内存中保留一条流的最后 `maxBytes`——错误与最终结果通常聚集在末尾——并在配置了 `spill` 上限时把完整流追加到 OS 临时目录下每进程目录中的私有文件(`0700` 目录、`0600` 随机命名文件)。某条流大于 spill 上限时,会丢弃不完整的 spill,只返回带截断标记的尾部。spill 是尽力而为:当 spill 文件无法打开或追加(每进程目录被临时文件清理工具删除、`EACCES`、`EMFILE`、`ENOSPC`)时,收集器丢弃该 spill,通过插件 logger 记录一条 `error`,并继续收集内存尾部,因此结果带截断标记且没有 spill 路径。读取基于偏移量且从不消费,因此后台读取与批量读取在退出前后都可以共存。
+实时读取会暂留未完成 UTF-8 字符末尾的最多三个字节,并将 `nextOffset` 留在这些字节之前。字符完整后,每个读取方都能独立解码。`seal()` 标记流结束,并将剩余的不完整序列输出为替换字符;适配器必须先封存最终快照,再将其作为已结束的输出提供。原始快照与 spill 文件保留原始字节。
+
`./output` 导出向进程适配器共享该收集器与保留 spill 的存储。`snapshot()` 返回保留的原始字节及总字节数,使远程适配器能够保留偏移量,而无需转发完整的流。
### 控制传输
diff --git a/packages/subprocess/subprocess-local/src/output.ts b/packages/subprocess/subprocess-local/src/output.ts
index 837d9e1..035329d 100644
--- a/packages/subprocess/subprocess-local/src/output.ts
+++ b/packages/subprocess/subprocess-local/src/output.ts
@@ -28,6 +28,30 @@ export interface SpillOptions {
let spillCounter = 0
let defaultSpillDir: string | undefined
+/**
+ * Locate the decodable prefix, withholding only a valid unfinished UTF-8 sequence.
+ * @param bytes - retained bytes for one incremental read.
+ * @returns the exclusive byte boundary before any unfinished character.
+ */
+function completeUtf8Prefix(bytes: Buffer): number {
+ // A UTF-8 character can leave at most three bytes pending at a live boundary.
+ for (let start = bytes.length - 1; start >= Math.max(0, bytes.length - 3); start--) {
+ const lead = bytes[start]!
+ if ((lead & 0xc0) === 0x80) continue
+ const width = lead >= 0xc2 && lead <= 0xdf ? 2
+ : lead >= 0xe0 && lead <= 0xef ? 3
+ : lead >= 0xf0 && lead <= 0xf4 ? 4 : 0
+ if (width === 0 || bytes.length - start >= width) return bytes.length
+ const second = bytes[start + 1]
+ if (second !== undefined && (
+ (lead === 0xe0 && second < 0xa0) || (lead === 0xed && second >= 0xa0)
+ || (lead === 0xf0 && second < 0x90) || (lead === 0xf4 && second >= 0x90)
+ )) return bytes.length
+ return start
+ }
+ return bytes.length
+}
+
/**
* The default spill location: a private (0700) per-process directory under
* the OS tmpdir, created lazily. Predictable world-readable paths would let
@@ -135,6 +159,7 @@ export class OutputCollector {
private spillDisabled: boolean
/** Total bytes ever pushed (not just retained). */
private total = 0
+ private sealed = false
/**
* @param maxBytes - in-memory tail cap in bytes.
@@ -254,7 +279,9 @@ export class OutputCollector {
* Incremental read in whole-stream byte coordinates: returns everything
* pushed since `fromByte`. When `fromByte` has already slid out of the
* in-memory tail window, the read is `lossy` — it returns the whole
- * retained tail and the gap is only recoverable from the spill file.
+ * retained tail and the gap is only recoverable from the spill file. A live
+ * read keeps the next offset before an unfinished UTF-8 suffix, so a later
+ * read can decode it once its remaining bytes arrive; seal flushes it at EOF.
* @param fromByte - whole-stream offset to resume from (a prior read's `nextOffset`; 0 for the first read).
* @returns the delta text, the offset for the next read, the `lossy` flag, and the spill path when one was created.
*/
@@ -263,9 +290,10 @@ export class OutputCollector {
const buffer = Buffer.concat(this.chunks)
const lossy = fromByte < windowStart
const slice = lossy ? buffer : buffer.subarray(fromByte - windowStart)
+ const end = this.sealed ? slice.length : completeUtf8Prefix(slice)
return {
- text: slice.toString('utf8'),
- nextOffset: this.total,
+ text: slice.subarray(0, end).toString('utf8'),
+ nextOffset: this.total - (slice.length - end),
lossy,
...this.spillFile !== undefined ? { spillPath: this.spillFile } : {},
}
@@ -287,6 +315,7 @@ export class OutputCollector {
* never point at a still-open file.
*/
seal(): void {
+ this.sealed = true
if (this.spillFd === undefined) return
try {
closeSync(this.spillFd)
diff --git a/packages/subprocess/subprocess-local/tests/output-utf8.spec.ts b/packages/subprocess/subprocess-local/tests/output-utf8.spec.ts
new file mode 100644
index 0000000..055acfd
--- /dev/null
+++ b/packages/subprocess/subprocess-local/tests/output-utf8.spec.ts
@@ -0,0 +1,107 @@
+import { spawn } from 'node:child_process'
+import { once } from 'node:events'
+import { describe, expect, it } from 'vitest'
+import { OutputCollector } from '../src/output.ts'
+import { spawnSubprocess } from '../src/spawn.ts'
+
+describe('incremental UTF-8 output', () => {
+ for (const character of ['é', '中', '😀']) {
+ const bytes = Buffer.from(character)
+ for (let split = 1; split < bytes.length; split++) {
+ it(`preserves ${character} split after byte ${split}`, () => {
+ const collector = new OutputCollector(100, 'test', undefined)
+ collector.push(Buffer.concat([Buffer.from('path: '), bytes.subarray(0, split)]))
+ const first = collector.readFrom(0)
+ expect(first).toEqual({ text: 'path: ', nextOffset: 6, lossy: false })
+ expect(collector.readFrom(first.nextOffset)).toEqual({ text: '', nextOffset: 6, lossy: false })
+ collector.push(Buffer.concat([bytes.subarray(split), Buffer.from('.txt')]))
+ const second = collector.readFrom(first.nextOffset)
+ expect(first.text + second.text).toBe(`path: ${character}.txt`)
+ expect(second.nextOffset).toBe(Buffer.byteLength(`path: ${character}.txt`))
+ expect(collector.readFrom(0).text).toBe(`path: ${character}.txt`)
+ })
+ }
+ }
+
+ it('keeps independent reader offsets when one reader polls every byte', () => {
+ const text = '\uFEFF报告:完成 😀 café\n'
+ const collector = new OutputCollector(100, 'test', undefined)
+ let offset = 0
+ let incremental = ''
+ for (const byte of Buffer.from(text)) {
+ collector.push(Buffer.from([byte]))
+ const read = collector.readFrom(offset)
+ incremental += read.text
+ offset = read.nextOffset
+ expect(read.lossy).toBe(false)
+ }
+ expect(incremental).toBe(text)
+ expect(collector.readFrom(0).text).toBe(text)
+ expect(offset).toBe(Buffer.byteLength(text))
+ })
+
+ it.each([[0xc3], [0xe4, 0xb8], [0xf0, 0x9f, 0x98]])('flushes unfinished bytes on seal: %j', (...bytes) => {
+ const collector = new OutputCollector(100, 'test', undefined)
+ collector.push(Buffer.from(bytes))
+ const live = collector.readFrom(0)
+ expect(live).toEqual({ text: '', nextOffset: 0, lossy: false })
+ collector.seal()
+ const final = collector.readFrom(live.nextOffset)
+ expect(final).toEqual({ text: Buffer.from(bytes).toString('utf8'), nextOffset: bytes.length, lossy: false })
+ expect(collector.readFrom(final.nextOffset).text).toBe('')
+ expect(collector.finalize().text).toBe(final.text)
+ })
+
+ it.each([[0xc0], [0x80], [0xe0, 0x80], [0xed, 0xa0], [0xf0, 0x80], [0xf4, 0x90], [0xf5]])('does not withhold invalid UTF-8: %j', (...bytes) => {
+ const collector = new OutputCollector(100, 'test', undefined)
+ collector.push(Buffer.from(bytes))
+ expect(collector.readFrom(0)).toEqual({ text: Buffer.from(bytes).toString('utf8'), nextOffset: bytes.length, lossy: false })
+ })
+
+ it('keeps loss reporting and absolute offsets after tail eviction', () => {
+ const collector = new OutputCollector(5, 'test', undefined)
+ collector.push(Buffer.from('discarded中'))
+ const first = collector.readFrom(0)
+ expect(first).toEqual({ text: 'ed中', nextOffset: 12, lossy: true })
+ collector.push(Buffer.from('😀').subarray(0, 2))
+ const pending = collector.readFrom(first.nextOffset)
+ expect(pending).toEqual({ text: '', nextOffset: 12, lossy: false })
+ collector.push(Buffer.from('😀').subarray(2))
+ expect(collector.readFrom(pending.nextOffset)).toEqual({ text: '😀', nextOffset: 16, lossy: false })
+ })
+
+ it.each(['stdout', 'stderr'] as const)('preserves real child %s split across two reads', async (channel) => {
+ let firstChunk: Promise<unknown[]> | undefined
+ const handle = spawnSubprocess({ argv: [process.execPath, '-e', `
+ const bytes = Buffer.from('报告😀\\n');
+ process.${channel}.write(bytes.subarray(0, 1));
+ process.stdin.once('data', () => {
+ process.${channel}.write(bytes.subarray(1));
+ process.stdin.destroy();
+ });
+ `], cwd: process.cwd(), graceMs: 100,
+ stdio: { stdin: 'pipe', stdout: { maxBytes: 100 }, stderr: { maxBytes: 100 } },
+ }, { spawn(program, args, options) {
+ const child = spawn(program, args, options)
+ const output = child[channel]
+ if (output === null) throw new Error('Expected a collected child stream')
+ firstChunk = once(output, 'data')
+ return child
+ } })
+ try {
+ expect(firstChunk).toBeDefined()
+ await firstChunk
+ const reader = handle.collected[channel]!
+ const first = reader.readFrom(0)
+ handle.stdin!.end('continue')
+ expect((await handle.done).exitCode).toBe(0)
+ const second = reader.readFrom(first.nextOffset)
+ expect(first.text + second.text).toBe('报告😀\n')
+ expect(reader.readFrom(0).text).toBe('报告😀\n')
+ } finally {
+ handle.terminate()
+ await handle.done
+ await handle.waitForExit()
+ }
+ })
+}) |
|
Not a claim about your findings — an addition to them: one criterion, the shape of a scan that finds it, and the readings from running it. Three parts, and the last one is the only part I think is actually missing. The criterion, stated so it can be judged: a call site whose cost is not visible from its name — a read or accessor that constructs or re-scans an O(N) container on every call. Three shapes we have seen in the wild:
Where that criterion lands — without filing anything new: the The scanner (the actually missing piece — in a quick search of the 16 discussions I have read,
Numbers, re-run just now on a local checkout (2026-10-05, the Boundaries. One deployment, one tree, and these three candidates are not claims of bugs — a No patch offered — the repository does not accept external PRs. If the shape is useful I can also describe the sibling scan we paired with it (flagging cache keys derived from |
Uh oh!
There was an error while loading. Please reload this page.
I ran a full-repo audit of
deepseek-harnessat99f6f02(0.1.0-rc.7), building from source on Node 24 and takingpnpm run build+pnpm run testgreen as the baseline (13507 passed / 816 files). Everything below is therefore a defect that the current suite does not cover.I have reproduced and patch-validated the first item. The rest are reported with the mechanism traced in source; I have flagged my confidence honestly on each.
Reporting here because
CONTRIBUTING.mdstates external PRs are not accepted and Issues are disabled. Happy to hand over patches in whatever form is useful.1.
terminal-bashscrollback is quadratic — every PTY chunk blocks the event loop (critical)packages/terminal/terminal-bash/src/session.ts:26utf8Tail()re-scans the entire retained buffer on every append:BoundedTextBuffer.append()(:49) calls it unconditionally, andappendOutput()(:416) feeds two such buffers on everyonTerminalDataevent:scrollback(scrollbackMaxBytes= 4 MiB) and the per-send viewport (maxReadBytes= 256 KiB, no line cap). Once each buffer sits at its cap, the cost is paid in full per chunk.The
maxLinespre-trim only helps newline-dense output. With long lineslines.lengthstays 1 and the full cost lands.I benchmarked verbatim copies of
utf8Tail/BoundedTextBufferat shipped defaults, feeding 8 KiB chunks after the buffers pass their caps (Node 24, M-series):jq -c)That is synchronous main-loop time. While it runs, nothing else in the harness progresses: no LLM streaming, no timers, no other tool call, no abort handling.
pollIntervalMs,idleSilenceMs, andtimeoutMsare all timer-driven and cannot fire.Trigger: any
terminal_sendwhose command emits a few MB without newlines —cata minified bundle,base64 /dev/urandom | head -c 100000000,jq -c . big.json. A 5 MB file stalls the harness for over a minute.Fix — keep the bound in bytes and cut on a UTF-8 lead byte instead of walking characters:
Validation: differential-tested against the original across 32,800 cases (ASCII, CJK, 4-byte emoji, mixed 1/2/3/4-byte, lengths 0–200 × caps 0–40) — 0 divergences.
packages/terminal/terminal-bashsuite: 69/69 passing, run twice. Measured 27× faster on the long-line path (144.6 ms → 5.3 ms combined per chunk).This is still O(n) per append because the whole string is re-encoded. If you want the real fix,
BoundedTextBuffershould retainBufferchunks with a running byte total and trim from the head, makingappendO(chunk). I kept the patch above minimal so it drops in without touching the class contract.2. Sticky
max-tokensends the turn after tools run, so the model never sees the results (high)packages/core/agent-loop/src/agent.ts:290,:295,:299turnEndsserves two purposes at once: the durableturn/endreason, and the "nothing is owed, stop" flag.step()returnsnullexactly when tools ran and did not conclude the turn — i.e. another model request is owed (:399). The sticky guard refuses to overwritemax-tokens, so thatnullis discarded and the two conditions readturnEndsas truthy and break.Sequence:
max-tokens(:391returns before any tool dispatch) →turnEnds = {kind:'max-tokens'}.next-step, so the turn continues. Shipped producers: a blockingStophook callingagent.steer(...)fromagent/turn-stopping(packages/hooks/hooks-claude-code/src/index.ts:270, same inhooks-codex), oragent.inject()fromuser-approval/src/index.ts:230.{concluded:false}→step()returnsnull.max-tokens;nextStepis empty → break.turn/end {kind:'max-tokens'}. The tools ran with their side effects and no model request ever consumed the results. Headless one-shot terminates with no final answer.loop.spec.ts:983covers max-tokens → completed step and:1054covers "does not dispatch tool calls from a max-tokens-truncated step". Neither covers max-tokens → tool-calling step.Fix — separate "work owed" from "reason to record":
3. Auto-compaction deletes the runtime-context snapshot from the very request it is compacting for (high)
packages/core/agent-loop/src/agent.ts:233, withpackages/compaction/compaction-basic/src/index.ts:147andpackages/core/agent-loop/src/runtime-context.ts:50preStep()computes the runtime-context candidate before the waterfall runs, then closes over it:project()returnsundefinedwhen the rendered snapshot equals the retained one.BasicCompactionEngineregisters anagent/pre-steplistener that compacts beforenext(). A landed compaction appends auser/messagewithsurfaceOp: {op:'replace'}shadowing the seqs, which drivesRuntimeContextProjectionto setretained = null. Butcontextwas bound toundefinedalready, so the defaultenteradds nothing. Listener order is irrelevant — the value is bound before the chain starts.Result: with
dsh-base(compaction-basicmountedauto: true), on the turn where compaction lands, the request carries no runtime-context message at all — the model is not told the sandbox mode or the approval policy. Restored only at step N+1, which in a headless one-shot run never happens.loop.spec.ts:413guards this class but performs the replacement between turns, so the in-waterfall ordering is untested.Fix: re-project inside the default arm instead of capturing, so it re-reads
retainedafter the waterfall.4. SDK JSON-RPC transport never listens for output errors — stdout EPIPE kills the harness (critical)
packages/sdk/protocol/src/transport.ts:76-82,:260start()attaches'data'/'error'/'end'tothis.inputonly. Nothing is ever attached tothis.output, andwrite()is a barethis.output.write(...)with no callback.packages/sdk/server/src/index.ts:55wiresconfig.output ?? process.stdoutstraight in, whileHarnessSdkJsonRpcServersubscribes four event streams that callnotify()continuously.A
writefailure therefore surfaces only as an'error'onprocess.stdoutwith zero listeners →throw er; // Unhandled 'error' event.installFailLoudregistersunhandledRejectiononly, neveruncaughtException.Trigger: the SDK client dies.
runner.ts:51gets stdin EOF and startsawait ctx.fiber.dispose()(async: persistence flush, agent teardown, child shutdown). During that window the still-live subscriptions write to a broken pipe and the runtime dies mid-dispose — truncating the durable JSONL session log and orphaning spawned children.Two signals this is a real gap: the ACP bridge writes through
Writable.toWeb(process.stdout)(packages/acp/acp/src/index.ts:445), which does contain EPIPE; and the SDK server's own test has to addoutput.on('error', ...)(tests/plugin-apply.spec.ts:100) to keep the test process alive.Fix: attach
this.output.on('error', ...)instart()(removed inclose()), routing throughfailPending()so pending requests reject instead of the process dying.Related, same file (
:148,:260):request()wraps the send intry/catch, butWritable.write()does not throw on a broken stream — it returnsfalseand reports asynchronously. The catch arm is unreachable for real transport failures, so the pending entry is never settled. Combined withHarnessClientswallowing stdin errors (packages/sdk/client/src/client.ts:223) andrequestTimeoutMshaving no default,await harness.run(...)can hang forever with no diagnostic. Pass a write callback and reject the matching pending entry.5.
SqliteSessionPersistenceturns a recoverable schema mismatch into a process exit (high)packages/session/session-persistence-sqlite/src/index.ts:133Every backend hook does
await this.ready, but nothing awaits it at construction: there is no[Service.init], and the only same-turn consumer iteratesctx.sessions.list(), empty on cold boot.openDbawaitsmkdirbeforeopenDatabasecan throw, so the rejection settles a full event-loop turn later with no handler attached.The sibling backend does exactly the right thing and says why —
packages/storage/storage-sqlite/src/index.ts:72:The session backend omits that one line. Result: a
SCHEMA_VERSIONmismatch after an upgrade/downgrade becomesproc.exit(1)at an arbitrary point after boot, instead of each persistence call rejecting with the intended diagnostic.Fix: add
this.ready.catch(() => {})after line 133.Smaller items, same audit
packages/subprocess/subprocess-local/src/spawn.ts:207—readFromdecodes each byte range independently with noStringDecoderand returns a raw bytenextOffset, so a multi-byte character split across a poll boundary becomes three U+FFFD. Hits the background-job read path (bash-local/src/index.ts:290) deterministically for non-ASCII output. The foreground path is safe (singlereadFrom(0)).spawn.ts:397/index.ts:153— every settled subprocess starts a permanent 15 ms poll; on Linux, once a backgrounded descendant survives (cmd &), each tick does a full/procreaddir plus areadFileSyncper numeric entry, forever. The ref'd timer also blocks natural process exit.spawn.ts:89— spill files and themkdtempspill dir are never removed. WithmaxOutputBytes64 KB /maxSpillBytes64 MiB, a working session can leave GBs under$TMPDIR, invisible to the harness.spawn.ts:362—collectStreamattaches no'error'listener tochild.stdout/stderr, while the symmetric stdin case four lines below is handled with a comment. An unhandled'error'on these takes the whole process down.packages/llm/llm-deepseek/src/sse.ts:39— a cleanly-closed truncated stream throwsSTREAM_CLOSED, which is absent fromDEFAULT_RETRYABLE_CODES; the same truncation delivered as a socket reset becomesTRANSPORTand is retried. The sibling adapter takes the opposite view explicitly (llm-pi-ai/src/stream.ts:52: "this is a transport truncation, not a model-level error"). Retrying is provably safe here — the loop re-sends a byte-identical body and commits noassistant/messagefor the failed attempt.packages/llm/llm-deepseek/src/translate.ts:152— tool-call deltas are keyed on the raw wirecall.indexwith no validation. Against an OpenAI-compatible endpoint that omitsindex, every parallel tool call collapses into one block with concatenated argument strings.baseURLis user-configurable, andAGENTS.md:115lists "model/tool JSON" and "wire boundaries" as places validation is required.packages/mcp/mcp-client/src/tools.ts:152—do { ... } while (cursor)trusts an external MCP server'snextCursorwith no repeat detection and no page cap, inside a chain thatdispose()awaits. A constant cursor wedges plugin disposal permanently.packages/client/connection/src/rpc-host.ts:108— configuredmaxRequestBodyBytesis threaded into the/apiroute but never intoHostConnectionService, so every genericconnection.rpc.handle(...)channel silently keeps the 160 MiB default.Full reproduction details, the differential-test harness, and patches for each are available if the team wants them. Nothing here needs a key to reproduce — the benchmark in item 1 is standalone, and items 2–5 are traceable in source.
All reactions