daemon: the evidence store is one JSON string, so a store over ~512 MB fails every check with 'Invalid string length' (DB subset-dedupe, 6 checks on #133)

未關閉
#179 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
javascript, node.js
領域
backend, databases

研究方向

Start with oracle-gaps/evidence.mjs, where diskStore serializes and reads the entire evidence store, then trace its callers in oracle-gaps/check.mjs and oracle-gaps/daemon.mjs. Choose a storage approach that avoids V8's string length limit. Add the test-only size ceiling and e2e history described in the issue; done means the next daemon check completes when that ceiling is reached.

由索引模型根據 Issue 內容生成。

描述

Summary

The daemon's evidence store (diskStore, evidence.mjs) writes the whole store as one JSON.stringify string and reads it back as one string. V8 caps a string at about 512 MB, so a store past that size makes every later check end in an internal error:

RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at Object.flush (oracle-gaps/evidence.mjs:98:37)
    at checkIn (oracle-gaps/check.mjs:2836:24)
    at async Object.check (oracle-gaps/check.mjs:1693:14)
    at async oracle-gaps/daemon.mjs:525:20

The CLI reports oracle-gaps: error Invalid string length: a bug in oracle-gaps, not in your oracle and exits 3.

Trace

TanStack DB 21c52a07, packages/db --source src/query/subset-dedupe.ts (559 units), Arca pool tag r133-dbb4-all. Each variant ran a daemon sequence from an empty state: a first check, 3 unchanged rechecks and 3 one-line-edit rechecks.

CLI Result Store size
main 97a4e7a8 all 7 checks complete 425 MB at the end
#133 head 9bb7c74a, Vitest cache off the 3rd edit recheck (the 7th check) fails 457 MB at the last good flush
#133 head, Vitest cache on (every check recomputes all units) the 2nd unchanged recheck (the 3rd check) and every later check fail 358 MB at the last good flush

Composition

A store after 2 checks with the cache on (#133 head): 1,114 rows, 1 variant each. Each variant has about 481 inputs (52 KB of JSON) and a unit payload of about 83 KB.

Of the inputs, 261,508 are fs: keys (41 MB), 118,996 are env: keys (10 MB) and 22,662 are stat: keys. #133's every-read inputs add about 60% to a variant. Main already sits at 425 MB after 7 checks, so main reaches the ceiling a few edits later on the same suite.

Proposed fix (choose one)

  • Write and read the store one row per line (JSONL), streamed, so no single string holds the whole store.
  • Or store each distinct input list once, by its hash, and have variants name it, since most units share their env: and node_modules inputs.
  • Or both.

A bound on the store's size is a separate design question. The retention law (bounded retention) covers memory, not this file.

Under P9 the fix needs an oracle-first witness: a test-only knob that lowers the store's size ceiling, so that a constructed e2e history reaches the state with a small store and requires that the next daemon check complete.

Authority

R13 (the daemon is the default) and P10 (an internal error is a CLI defect). Found while measuring #133 for M "Vitest cache off, measured".

This issue was written by Isaac.

主要語言
JavaScript
星號
5
分支
1
平均合併
11 小時 18 分鐘
30 天內合併 PR
66

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TanStack/oracles 的其他 Issue

查看 TanStack/oracles 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。