Skip to content

test: remove check tail assertion from correctness test #55

Merged
quettabit merged 1 commit into
mainfrom
qb/correctness-fix
May 18, 2026
Merged

test: remove check tail assertion from correctness test #55
quettabit merged 1 commit into
mainfrom
qb/correctness-fix

Conversation

@quettabit

Copy link
Copy Markdown
Member

No description provided.

@quettabit quettabit requested a review from a team as a code owner May 18, 2026 18:24
@greptile-apps

greptile-apps Bot commented May 18, 2026

Copy link
Copy Markdown

Greptile Summary

Removes the post-run check_tail assertion (tail.seq_num == TOTAL_RECORDS) from the concurrent producer/consumer correctness test. As clarified in the prior thread, this assertion was unsound because retried appends can leave duplicate records on a persistent stream, causing tail.seq_num to exceed TOTAL_RECORDS and spuriously fail the test.

  • The remaining consumer-side assertions (last_seq_num == TOTAL_RECORDS - 1, observed_records == TOTAL_RECORDS, highest_contiguous_index == TOTAL_RECORDS - 1, and per-record gapless seq_num checks) are sufficient to validate that exactly 1024 records were read back without gaps, which is the core correctness guarantee the test is designed to prove.
  • No logic changes to production code; test-only diff.

Confidence Score: 5/5

Safe to merge — removes one assertion from a test file with no production code changes.

The deleted check_tail assertion was logically incorrect on persistent streams where retry-driven duplicates push tail.seq_num beyond TOTAL_RECORDS. The remaining consumer-side assertions still fully cover the gapless-read invariant the test was designed to verify, so no coverage gap is introduced.

No files require special attention.

Important Files Changed

Filename Overview
tests/test_correctness.py Removed post-run check_tail assertion whose equality condition was incorrect when retries cause duplicate records on the stream; remaining consumer-side assertions still fully validate gapless read correctness.

Sequence Diagram

sequenceDiagram
    participant Test as Test (TaskGroup)
    participant Producer as append_records()
    participant Consumer as read_records()
    participant Stream as S2Stream

    par concurrent tasks
        Producer->>Stream: "producer.submit(Record(body=str(i))) x 1024"
        Stream-->>Producer: ticket (per record)
        Producer->>Stream: await ticket x 1024
        Stream-->>Producer: "ack.seq_num >= 0"

        Consumer->>Stream: "read_session(start=SeqNum(0), limit=count(1024), wait=60)"
        Stream-->>Consumer: batches of records
        Consumer->>Consumer: "assert seq_num == last_seq_num + 1 (gapless)"
        Consumer->>Consumer: "assert 0 <= index < 1024 (valid body)"
        Consumer->>Consumer: "assert index <= highest_contiguous_index + 1"
    end

    Note over Test: After TaskGroup completes
    Consumer->>Consumer: "assert highest_contiguous_index == 1023"
    Consumer->>Consumer: "assert last_seq_num == 1023"
    Consumer->>Consumer: "assert observed_records == 1024"
    Note over Test: check_tail assertion removed - tail.seq_num may exceed 1024 when retries produce duplicates
Loading

Reviews (2): Last reviewed commit: "initial commit" | Re-trigger Greptile

Comment thread tests/test_correctness.py
@quettabit

Copy link
Copy Markdown
Member Author

@greptileai addressed your comment. pls review again and update your score.

@quettabit quettabit merged commit 28bb14e into main May 18, 2026
6 checks passed
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