Skip to content

test: cover wal.rs's canonical_bytes_of_line and non-NotFound error arms - #595

Merged
t0k0sh1 merged 2 commits into
mainfrom
587-wal-untested-branches
Aug 12, 2026
Merged

test: cover wal.rs's canonical_bytes_of_line and non-NotFound error arms#595
t0k0sh1 merged 2 commits into
mainfrom
587-wal-untested-branches

Conversation

@t0k0sh1

@t0k0sh1 t0k0sh1 commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • canonical_bytes_of_line's None return had zero coverage at any of its three call sites (shippable_records, parse_log's interior loop, tail_record_is_complete) — confirmed by grep, no test in the repository ever exercised it. Adds one test per call site, each forcing a distinct way the byte-exact ,"crc": marker search can fail to find a field that genuinely parsed.
  • reset/replay/replay_readonly previously had only their NotFound-tolerant arm tested; adds the non-NotFound propagation arm for all three (injected for reset, a real directory-in-place-of-file OS error for the two fs::read-based ones, since that call is intentionally outside the fault-injection choke point).
  • Strengthens the two existing heal-failure tests (a_truncate_heal_failure_is_fatal_not_a_shrug, a_newline_heal_failure_is_fatal_not_a_shrug) to also assert the outer "could not heal ..." wrapper message, not just the injected cause underneath it.
  • Adds a characterization test pinning that shippable_records does NOT dedupe a repeated seq, unlike parse_log's later-wins resolution — intentional per its own doc comment ("shipping is a byte transport, not the trust boundary"), not a gap.
  • The mutation gate found one missed mutant in parse_log's tail branch (segments.len() + 1* 1, its own line-number computation, distinct from the interior loop's index + 1): the new tail-position marker test asserted the error message body but not the reported line number. Fixed by pinning it there too (commit a2773d9).

Part of #587 (untested-branches audit from #533). Refs #587.

Test plan

  • cargo fmt
  • cargo clippy --bin taguru --tests (clean)
  • cargo test (full suite green, 1544 passed)
  • Pre-PR mutation gate (cargo mutants --in-diff): 0 mutants (test-only diff)
  • cargo mutants --file src/wal.rs: 93 tested, 65 caught, 28 unviable, 0 missed (fix verified across two independent runs — unviable count matched both times, ruling out snapshot corruption)

https://claude.ai/code/session_013NPb5cDU8ojZAKGJaq8rYy

Issue #587 (#533 persistence audit): canonical_bytes_of_line's three
call sites (shippable_records, parse_log's interior loop,
tail_record_is_complete) had zero coverage of its None return —
issue text confirmed by grep, no test in the repo ever exercised it.
Also covers reset/replay/replay_readonly's non-NotFound error arms
(previously only the NotFound-tolerant path was tested), strengthens
the two existing heal-failure tests to check the outer "could not
heal" wrapper message rather than only the injected cause, and adds
a characterization test pinning that shippable_records does not
dedupe a repeated seq (unlike parse_log's later-wins resolution) —
intentional per its own doc comment, not a gap.

Refs #587
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f7ff0d9-263e-463d-ade8-c6cca9c4eff4

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba0960 and d4c0ef2.

📒 Files selected for processing (1)
  • src/wal.rs

📝 Walkthrough

Walkthrough

WALのCRC検証、重複sequence処理、末尾修復、およびファイルI/Oエラー伝播を検証するテストを追加しました。

Changes

WAL検証とエラー処理

Layer / File(s) Summary
レコード検証テスト
src/wal.rs
shippable_records が不正なCRC形式を拒否し、重複sequenceを保持することを検証します。CRCマーカーを復元できない内部レコードも InvalidData として拒否することを検証します。
末尾修復とI/Oエラー伝播テスト
src/wal.rs
CRCマーカーや改行の修復失敗時に外側のエラーを返すことを検証します。resetreplayreplay_readonly が非NotFoundエラーを伝播することを検証します。

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related issues

Possibly related PRs

  • t0k0sh1/taguru#589src/wal.rsのWAL解析、末尾破損、切り詰め処理のテストに直接関連します。
  • t0k0sh1/taguru#523 — WALの破損復旧とファイルサイズ処理のテストに関連します。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、wal.rs の未カバー分岐と非 NotFound エラー処理のテスト追加という主な変更を明確に示しています。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 587-wal-untested-branches

Comment @coderabbitai help to get the list of available commands.

…r loop's

The pre-PR mutation gate found one missed mutant: parse_log's tail
branch computes its 1-indexed line number as segments.len() + 1
(distinct from the interior loop's index + 1) — replacing + with *
was unobserved because the new tail-position marker test never
asserted on the reported line number, only the message body.

Refs #587
@t0k0sh1
t0k0sh1 merged commit f7840f6 into main Aug 12, 2026
15 checks passed
@t0k0sh1
t0k0sh1 deleted the 587-wal-untested-branches branch August 12, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant