8.7 KiB
テスト妥当性レビュー: tools
- 評価: 混在
確認範囲
- Workspace:
/home/hare/Projects/yoi - Crate:
tools - 確認対象:
crates/tools/Cargo.tomlcrates/tools/src/{lib,scoped_fs,tracker,read,write,edit,glob,grep,bash,web,error}.rscrates/tools/tests/{integration,edge_cases}.rs
- この crate は以下の built-in tool の挙動を担っている:
- filesystem tools:
Read,Write,Edit,Glob,Grep - process tool:
Bash - network tools:
WebSearch,WebFetch - 共有 safety primitives:
ScopedFs,Tracker,ToolsError
- filesystem tools:
現在のテストがよくカバーしていること
主要な機能テストのカバレッジは広く、概ね適切な対象に向いている。
ScopedFstests は中核的な read/write scope enforcement をカバーしている:- absolute-path requirement
- missing files と directory targets
- out-of-scope と read-only paths
- write 時の parent creation
- symlink-to-file behavior
- symlink escape diagnostics
- clone 間での動的な
SharedScopeupdates
Trackertests は重要な read-before-edit invariant をカバーしている:- record 後の clean verify
NotRead- externally modified hash mismatch
- clone-shared state
- symlink variants の canonical key collapse
- recent-file LRU behavior
- per-file mutation guard serialization と different-file parallelism
Read/Write/Edittests は期待される user-facing contract をカバーしている:- Read が history を記録する
- Write は read なしで new files を作成できる
- 既存ファイルへの Write/Edit は prior Read を要求する
- external modification が検出される
- unique replacement、
replace_all、missing string、non-unique string
GlobとGrepは user-visible options を多くカバーしている:- glob matching、hidden files、mtime ordering、invalid pattern
- grep output modes、line numbers、context、multiline、glob/type filters、pagination、binary skip、invalid regex/type
- scope-denied results が filter される
Bashtests は重要な runtime behavior をカバーしている:- stdout/stderr merge
- nonzero exit summary
- stateless cwd
- timeout
- long output spill と tail rendering
- drop 時の spill cleanup
- background job non-hang regression
WebFetch/WebSearchには有用な local-server tests がある:- disabled tools が network requests を行わない
- private address blocking
- redirect handling
- Brave request shaping と secret ref use
- oversized Brave response rejection
- HTML fallback、local reader extraction、navigation inclusion/omission、output truncation
2つの integration test files は価値がある。core_builtin_tools() factory wiring と、cross-tool sharing of ScopedFs / Tracker を exercise しており、これはこの crate の中心的 invariant の1つである。
不足 / 疑問のあるテスト
default の crate test command は現在 green ではない。cargo test -p tools は doctests のみで失敗する。理由は、tracker.rs の documentation example がまだ core_builtin_tools(fs, tracker, bash_outputs, None) を呼んでいる一方で、実際の関数は現在3引数を取るためである。これは test-suite validity issue である。機能テストは通っているが、開発者が実行する default command は failure を報告する。
実質的に最も大きな gap は web_builtin_tools() 周辺である。core tool factory は integration-tested だが、web factory については registration names、metadata/schema presence、実際の Tool trait object 経由の disabled behavior、public tool surface との parity が確認されていない。
いくつかの領域は happy-path や string-fragment checks でテストされているが、boundary behavior はテストされていない:
Read- invalid UTF-8 / binary-ish content rendering behavior の直接的な coverage がない
- offset-beyond-EOF や
limit = 0behavior test がない - trailing newline / CRLF line-count semantics が固定されていない
Write/Edit- mutation serialization はテストされているが、
write_then_edit_same_file_same_batch_uses_call_orderは脆く見える。coordinator は path ごとに serialize するが、test name は call-index ordering を示唆している。この test は ordering invariant を証明するというより、polling order によって通っている可能性が高い。 old_string == new_string、emptyold_string、non-UTF-8 edit target の明示的な test がない- write/edit の broken symlink handling は read/symlink escape より直接的な coverage が少ない
- mutation serialization はテストされているが、
Glob- result cap at 1000 がテストされていない
- relative explicit
path、non-directorypath、out-of-scope explicitpathが直接カバーされていない - symlink directory behavior は
Globでカバーされているが、direct path としてのみである
Grep- description では
.gitignoreを honor するとされているが、直接的な.gitignoreregression test は見当たらなかった -n: false、個別の-A/-B、zerohead_limit、context lines 付き content-mode pagination がカバーされていないGlobtest と同様の symlink-directory rejection がカバーされていない
- description では
Bash- timeout behavior は確認されているが、process-tree cleanup や partial output を伴う timed-out command は確認されていない
- tail read budget を超える very large output と partial UTF-8 tail boundaries がカバーされていない
- unusual shell syntax を含む multiline commands などの command wrapping edge cases は、間接的にしか軽くカバーされていない
WebFetch- URL parser constraints の coverage が不足している: non-http schemes、embedded credentials、missing host
- content-type rejection、binary body rejection、invalid UTF-8、JSON/XML/text rendering、
Content-Lengthなしの response-size truncation、redirect limit exceeded、redirect-to-private blocking が直接カバーされていない - private-address tests は有用だが必然的に local であり、DNS/rebinding-style behavior はここでは深くテストできない
一部の tests は exact または near-exact な diagnostic strings を assert している。remediation-focused user diagnostics に対しては正当化できるが、invariant-focused checks よりもいくつかの tests を脆くしてもいる。
追加提案
-
tracker.rsの stale doctest を修正するか、意図的に mark する。cargo test -p toolsが今日失敗するため、これは最初の test-suite maintenance item として扱うべきである。 -
小さな
web_builtin_tools_registers_full_setintegration test を追加する:WebSearchとWebFetchを期待する- non-empty descriptions と object schemas を verify する
- trait object 経由で disabled tools を execute し、no-network disabled error を assert する
-
focused boundary tests を追加する:
Readoffset beyond EOF、limit = 0、CRLF/trailing newline behaviorEditemptyold_string、identical strings、non-UTF-8 targetGlobexplicit relative/out-of-scope/non-directory path と 1000-result capGrep.gitignore、-n: false、個別の-A/-B、symlink directory rejection、zero/lowhead_limitBashpartial output 付き timeout とTAIL_READ_BUDGETを超える huge outputWebFetchunsupported scheme、credentials in URL、unsupported content-type、binary body、invalid UTF-8、redirect limit、redirect-to-private
-
write_then_edit_same_file_same_batch_uses_call_orderを作り直すか rename する。call-index ordering が intended invariant なら、implementation と test がそれを deterministic にすべきである。same-file serialization のみが intended なら、test name と assertion は ordering guarantees を示唆しないようにすべきである。
実行したコマンド
-
cargo test -p tools- Result: failed.
- Unit/integration portions passed:
- lib tests:
99 passed tests/edge_cases.rs:10 passedtests/integration.rs:14 passed
- lib tests:
- Doctest failed:
crates/tools/src/tracker.rs - tracker (line 29)- error
E0061:core_builtin_toolsは現在3引数を取るが、doctest は4引数を渡している。
-
cargo test -p tools --lib --tests- Result: passed.
99lib tests、10edge-case tests、14integration tests が passed。
-
cargo test -p tools --doc- Result: 同じ stale
tracker.rsdoctest error で failed。
- Result: 同じ stale