8.2 KiB
8.2 KiB
テスト妥当性レビュー: pod-registry
- 判定: 概ね良い
確認した範囲
crates/pod-registry/README.mdcrates/pod-registry/Cargo.tomlcrates/pod-registry/src/lib.rscrates/pod-registry/src/table.rscrates/pod-registry/src/conflict.rscrates/pod-registry/src/mutate.rscrates/pod-registry/src/lifecycle.rscrates/pod-registry/src/error.rscrates/pod-registry/src/test_util.rs
pod-registry の責務は、machine-local な live Pod allocation、Pod 名衝突、write-scope / delegation-scope の衝突検出、stale allocation の回収、segment writer の重複防止を pods.json と file lock で調整すること。現状のテストは crate 内 unit test のみで、integration test / cross-process test はありません。
現在のテストがよくカバーしていること
- 中核的な mutation invariants はよくカバーされています:
- top-level registration が write-scope conflicts を拒否すること
- duplicate Pod name の拒否
- read-only scope が write scope と衝突しないこと
- release が allocation を削除し、scope を再度開放すること
- child release / stale reclaim が descendants を reparent すること
- delegated scope が release 後に parent へ戻ること
reclaim_delegated_scopeが存在する/存在しない child allocation を扱い、一致する deny layer を 1 つだけ削除すること
- Delegation behavior は意味のある形でテストされています:
- delegated scope が明示的な
DelegationScopeの subset でなければならないこと - delegation が parent の直接の current effective write set ではなく
DelegationScopeを使うこと - sibling overlap が拒否されること
- effective parent write scope が delegated child regions を除外すること
- delegated scope が明示的な
- Conflict-owner behavior は有用な semantic boundaries でテストされています:
- recursive prefix overlap
- non-recursive direct-child behavior
- 最も深い delegated owner が competitor として報告されること
- restored-parent deny rules が fully denied regions は抑制できるが、partial-deny parent conflicts は抑制しないこと
- Segment-lock behavior は基本的にカバーされています:
register_podが重複するsegment_idを拒否することupdate_segmentが segment ownership を書き換えることupdate_segmentが別の Pod にすでに保持されている target segment を拒否することfind_by_segmentがsegment_id = Noneの pre-adoption placeholder allocations を無視することlookup_segmentが live writer info を返し、guard release 後にはNoneを返すこと
- File-backed table behavior には有用な smoke coverage があります:
- lock file creation
0600file /0700directory permissions- save/reopen roundtrip
- RAII
ScopeAllocationGuardが drop 時に release すること
- Test helpers のスコープは妥当です。
reclaim_stale_withは liveness の決定論的な seam を提供し、RuntimeDirSandboxはこの crate 内で env-var mutation を直列化しています。
ギャップ / 疑問のあるテスト
- 最大のギャップは cross-process/file-lock tests がないことです。この crate の中心的な safety claim は、
flockが無関係な Pod spawn sequences を直列化することですが、現状のテストは一度に 1 つのLockFileGuardを使う単一プロセスしか exercised していません。lock blocking、concurrent registration 下の atomicity、または 2 つのプロセスが同じpods.jsonで race したときの behavior を検証していません。 adopt_allocationには segment-conflict test がありません。register_podとupdate_segmentはどちらも別の Pod にすでに保持されているsegment_idを拒否しますが、adopt_allocationは現状、そのようなテストなしにsegment_idを書き換えます。“one live writer per segment” がすべての allocation entry points に対する invariant であるなら、これは意味のある coverage hole です。- Error-path coverage は薄いです:
- 壊れた
pods.jsonの parse errors がテストされていない - unknown-pod errors は
adopt_allocationではカバーされているが、release_pod/update_segmentではカバーされていない - save failure / permission failure behavior がカバーされていない
reclaim_staleは意図的に save errors を握りつぶしますが、その best-effort behavior は直接テストされていない
- 壊れた
- Path-overlap logic は少数の例でしかテストされていません。この behavior は重要かつ微妙ですが、すべての recursive/non-recursive combinations、equal paths、parent/child/grandchild、siblings、read-vs-write、deny coverage cases に対する table-driven matrix がありません。
register_pod_with_denyには full deny と partial deny behavior のテストがありますが、複数の conflicting owners が同時に存在し、その一部だけが denied されている場合のテストはありません。これはまさにfind_conflict_ownersとall_deniedsemantics が重要になる branch です。manifest::DelegationScopeおよびScopeRulenormalization との integration boundary は軽くしか exercised されていません。upstream code が canonical absolute paths を保証しているなら問題ありませんが、そうでない場合、この crate には relative paths、..、symlinks、trailing separators、または同等だが同一ではない paths に対するテストがありません。- Stale reclaim は real
pid_aliveではなく、注入された liveness predicate 経由でテストされています。これは決定論のためには良いことですが、Unix のkill(pid, 0)semantics は、他のテストで current process id を使う間接的な形を除いて未テストのままです。 - 実際の Pod spawn/restore flows 中にこの registry に依存する caller crates との integration tests がありません。小さな coordination crate としては理解できますが、これはテストが end-to-end runtime safety よりも local invariants を証明していることを意味します。
追加を推奨するテスト
- 2 つの child processes または helper binaries から同じ
pods.jsonを開く小さな cross-process test を追加し、以下を検証する:- 2 つ目の writer が最初の lock が release されるまで block すること、または少なくとも stale unlocked state を observe/write できないこと
- 同じ Pod name / scope / segment を claim する concurrent attempts の結果が成功 1 件だけになること
adopt_allocation_rejects_segment_id_collisiontest を追加する、または adoption がすでに保持されている segment へ overwrite してよい理由を明示的に document し、test する。rules_overlapとcovers_fullyの table-driven tests を追加し、以下をカバーする:- recursive/recursive、recursive/non-recursive、non-recursive/recursive、non-recursive/non-recursive
- equal path、direct child、grandchild、sibling、unrelated path
covers_fullyにおける read/write permission ordering
- 複数 conflict に対する
register_pod_with_denytests を追加する:- all conflicts denied: allowed
- 複数 conflicts のうち 1 つだけ denied: meaningful competitor とともに rejected
- persistence/error tests を追加する:
- invalid JSON が
InvalidDataを返すこと - save されていない
data_mutchanges が永続化されないこと - unknown
release_podと unknownupdate_segmentがUnknownPodを返すこと
- invalid JSON が
- 可能であれば Pod spawn/restore caller path の近くに integration-level test を 1 つ追加し、“no two live Pods write the same session segment” という durable invariant に焦点を当てる。
実行したコマンド
cargo test -p pod-registry- 結果: passed
- 29 unit tests passed
- 0 doc tests
cargo test -p pod-registry; echo EXIT:$?- 結果: passed,
EXIT:0 - 29 unit tests passed
- 0 doc tests
- 結果: passed,