Skip to content

test(parquet): proptest the compaction row-conservation invariant (RFC0009.2) - #120

Merged
jensholdgaard merged 1 commit into
mainfrom
test/compaction-row-conservation-proptest
Jun 5, 2026
Merged

test(parquet): proptest the compaction row-conservation invariant (RFC0009.2)#120
jensholdgaard merged 1 commit into
mainfrom
test/compaction-row-conservation-proptest

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented Jun 5, 2026

Copy link
Copy Markdown
Owner

What

First of the epic #94 compaction leftovers: a property test for row conservation (RFC0009.2), compaction's core promise — "preserving every stored row."

Why

compact_partition only had example-based tests (2 files → fixed rows). The invariant — any set of records across any split of files comes back exactly — deserves a property test (CLAUDE.md §6.2: "property tests for anything with an invariant... the Parquet writer").

How

compaction_conserves_every_row: generate 2–5 files of 1–15 records each (varying template id, in-hour timestamp, severity, one param value over the clean-round-trip record shape), write them via the real Writer, compact_partition, then read the consolidated file back via Reader::open_partition and assert:

  • outcome.rows == total input count, and
  • the sorted multiset of read records equals the input (full-record ==, so content is preserved, not just the count).

Introduces proptest as an ourios-parquet dev-dependency (first adopter of the §6.2-mandated tool). Capped at 48 cases — each builds + compacts + re-reads a store — keeping the test ~3s.

Verification

cargo test --workspace, cargo clippy --workspace --all-targets --all-features -D warnings, cargo fmt --all --check all green. The property held across all cases.

Part of epic #94. Follow-ups: the compaction crash-recovery / atomic-swap test (RFC0009.3) and the ourios.compaction.backlog UpDownCounter.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Enhanced test coverage with property-based testing framework.
    • Added validation tests for parquet file consolidation operations.

@jensholdgaard
jensholdgaard requested a review from Copilot June 5, 2026 11:59
@jensholdgaard

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jensholdgaard, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 46 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 479b5006-29a3-46fd-ba5a-9e57048a0c71

📥 Commits

Reviewing files that changed from the base of the PR and between a6c326c and 5e960e1.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/ourios-parquet/Cargo.toml
  • crates/ourios-parquet/src/compaction.rs
📝 Walkthrough

Walkthrough

This PR adds a property-based test to validate compaction row-conservation. It introduces the proptest dev-dependency and implements a test that generates randomized record distributions across multiple files, executes compaction, and verifies the consolidated output contains the same rows.

Changes

Compaction row-conservation property test

Layer / File(s) Summary
Proptest dev-dependency
crates/ourios-parquet/Cargo.toml
Adds proptest = "1" as a dev-dependency to enable property-based testing.
Row-conservation property test and utilities
crates/ourios-parquet/src/compaction.rs
Introduces HOUR10_START constant and prop_rec helper to generate test records; implements a proptest that validates RFC0009.2 row-conservation by generating randomized input-file splits, running compact_partition, and asserting exact row multiset preservation in the consolidated live file.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • jensholdgaard/ourios#94: The PR directly implements the RFC0009-described compaction test requirement by adding a property-based test that validates row-conservation semantics.

Possibly related PRs

  • jensholdgaard/ourios#93: The new property test directly validates RFC0009.2 row-conservation semantics documented in the retrieved PR.
  • jensholdgaard/ourios#97: The proptest builds on the RFC0009 sealed-partition compact_partition implementation from the retrieved PR.
  • jensholdgaard/ourios#110: The new property test exercises compact_partition's committed output behavior, directly tied to the committed-compaction flow modified in the retrieved PR.

Poem

🐰 A test springs forth with properties grand,
To prove that compaction follows the land,
Where rows unite in a single file so tight,
Proptest hops through each split-and-recombine delight! 📦

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'test(parquet): proptest the compaction row-conservation invariant (RFC0009.2)' accurately describes the main change—adding a property test for the row-conservation invariant.
Description check ✅ Passed The PR description is comprehensive, covering what/why/how, verification steps, and RFC reference. The template sections (Summary, Related, Checklist) are all addressed or appropriately filled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/compaction-row-conservation-proptest

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jensholdgaard
jensholdgaard force-pushed the test/compaction-row-conservation-proptest branch from cc912f4 to a6c326c Compare June 5, 2026 12:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a proptest-based property test to ourios-parquet to validate RFC0009.2’s compaction invariant: compaction must conserve the full multiset of rows (count + content) across arbitrary splits of records into multiple input files.

Changes:

  • Introduce compaction_conserves_every_row property test that writes 2–5 Parquet files, runs compact_partition, then asserts row-count and record-multiset equality after reading back the consolidated output.
  • Add proptest as a dev-dependency for ourios-parquet.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
crates/ourios-parquet/src/compaction.rs Adds a property test asserting compaction preserves every stored row across randomized multi-file inputs.
crates/ourios-parquet/Cargo.toml Adds proptest under dev-dependencies to support the new property test.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/ourios-parquet/src/compaction.rs Outdated
Comment thread crates/ourios-parquet/src/compaction.rs Outdated
Comment thread crates/ourios-parquet/src/compaction.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ourios-parquet/src/compaction.rs`:
- Around line 680-691: The proptest generators in compaction.rs currently use
half-open ranges (1..15usize and 2..5usize) which produce 1–14 records and 2–4
files; update those ranges in the proptest::collection::vec calls to inclusive
bounds (use 1..=15usize for records and 2..=5usize for files) so the test covers
1–15 records and 2–5 files as described; locate the proptest::collection::vec
invocation in compaction.rs and change the two range literals accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e691513-8737-4bc3-87da-87956dbe7538

📥 Commits

Reviewing files that changed from the base of the PR and between 0e4fefd and a6c326c.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/ourios-parquet/Cargo.toml
  • crates/ourios-parquet/src/compaction.rs

Comment thread crates/ourios-parquet/src/compaction.rs
…C0009.2)

Epic #94 leftover. Compaction's core promise (RFC0009.2 — "preserving
every stored row") had only example-based coverage. Add a property test:
for any split of records across ≥2 files in one partition, the
consolidated file holds exactly the same multiset of rows — count and
content (reordering aside).

The strategy varies the fields the invariant exercises (template id,
in-hour timestamp, severity, one param value) on the clean-round-trip
record shape, so equality reflects compaction, not codec edge cases. It
writes each file via the real Writer, runs compact_partition, reads the
consolidated file back via Reader::open_partition, and asserts row count
== input and (sorted) full-record equality.

Introduces `proptest` as an ourios-parquet dev-dependency (CLAUDE.md §6.2
mandates property tests for invariants; this is the first adopter).
Capped at 48 cases (each builds + compacts + re-reads a store) to keep
the suite fast (~3s).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jensholdgaard
jensholdgaard force-pushed the test/compaction-row-conservation-proptest branch from a6c326c to 5e960e1 Compare June 5, 2026 12:12
@jensholdgaard
jensholdgaard requested a review from Copilot June 5, 2026 12:12
@jensholdgaard

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

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.

2 participants