Skip to content

test(storage): model write-path lineage interleavings - #2798

Merged
Sinity merged 3 commits into
masterfrom
feature/fanout/write-model
Jul 12, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/fanout/write-model

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Add a Hypothesis stateful property test for archive write-path interleavings.

Problem

The existing lifecycle state machine does not model full replacement, append windows, prefix-sharing lineage, stale writes, variants, or dangling branch points—the combinations most likely to hide write-path regressions.

Solution

Add tests/property/test_write_path_state_machine.py. It writes ParsedSession data through write_parsed_session_to_archive and reads through read_archive_session_envelope; it also checks actual session_links and FTS docsize tables. The model covers parent/child replay, edited full replacement, merge append with variants, stale replacement, and one hard-deleted branch point.

For the known 4ts.6 behavior, an incomplete lineage is required to be a non-overextending suffix of the modeled transcript.

Acceptance criteria

  • Six operation classes and five requested invariants are exercised.
  • Default and CI Hypothesis profiles finish in seconds.
  • No production divergence was found; no follow-up bead is proposed.

Verification

  • devtools test tests/property/test_write_path_state_machine.py — 1 passed in 6.32s
  • HYPOTHESIS_PROFILE=ci devtools test tests/property/test_write_path_state_machine.py — 1 passed in 5.32s
  • ruff format --check tests/property/test_write_path_state_machine.py && ruff check tests/property/test_write_path_state_machine.py && mypy --strict tests/property/test_write_path_state_machine.py — formatted, lint-clean, and Success: no issues found in 1 source file

Anti-vacuity: every rule exercises the production SQLite writer and composed archive reader, then queries production session_links and messages_fts_docsize; no mock or test-only write model is used.

Ref polylogue-g9f2.

Add a real-writer Hypothesis state machine for replace, append, stale\nreplacement, prefix-sharing lineage, variants, and dangling branch points.\n\nThe machine checks composed transcript semantics, tail-only physical storage,\nlegal topology statuses, and FTS docsize parity.\n\nRef polylogue-g9f2.\n\nCo-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 74267c77-4ef4-41d3-b0f0-dfb266f78731

📥 Commits

Reviewing files that changed from the base of the PR and between 901825e and 19d3807.

📒 Files selected for processing (1)
  • tests/property/test_write_path_state_machine.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fanout/write-model

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.

Model spawned-fresh and child-before-parent lineage writes, asserting\nexact session-link transitions and tail extraction after resolution.\n\nExercise the public repository get_messages route against a scratch\nsplit-file archive.\n\nRef polylogue-g9f2.\n\nCo-Authored-By: Claude <[email protected]>
@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 1

Findings and fixes:

  • Real gap: the model tested the sync envelope but not the public SessionRepository.get_messages route. Fixed in b08afa9b5 with a real split-file scratch archive under /realm/tmp.
  • Real gap: only prefix-sharing children were generated. Added a known-parent, zero-shared-prefix rule and exact spawned-fresh/null-branch-point assertions.
  • Real gap: link checking was a permissive status-set check and never exercised deferred resolution. Added child-before-parent plus late-parent rules, asserting the exact unresolved-to-prefix-sharing transition and physical tail extraction.

What survived scrutiny: FTS docsize parity still compares the production docsize table with text-bearing stored blocks; dangling-branch behavior remains constrained to a non-overextending suffix.

Borderline recorded: this bounded state machine covers the dangling-branch 4ts.6 path; existing focused lineage tests own the depth-limit path.

Cover full-replace sibling variants, exact FTS docid parity, and the\nasync resolver's cyclic-link quarantine path.\n\nRef polylogue-g9f2.\n\nCo-Authored-By: Claude <[email protected]>
@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 2

Findings and fixes:

  • Real gap: variants were append-only. Added a full-replace same-position sibling-variant rule with exact (position, variant_index) assertions.
  • Real gap: quarantine was unreachable. Added a real async resolver cycle test that requires status=quarantined, no resolved destination, and cycle-rejection evidence.
  • Borderline fixed: FTS parity now compares exact docid sets (messages_fts_docsize.id versus indexable blocks.rowid), not only cardinality.

What survived scrutiny: spawned-fresh and deferred parent resolution remain exact-link assertions; the public repository composed-read test remains real-route coverage.

Verification: the quarantine selector passed (1 passed; 6.96s test call). The pre-push quick gate passed format, lint, and mypy; GitHub Actions remains the known account-init failure pattern.

@Sinity
Sinity merged commit f6dd70e into master Jul 12, 2026
3 of 12 checks passed
@Sinity
Sinity deleted the feature/fanout/write-model branch July 12, 2026 23:28
Sinity added a commit that referenced this pull request Jul 12, 2026
…803,2787,2798

013x (search-coverage, PR #2803) and g9f2 (write-model, PR #2798) fully
satisfied — closed. y8s5 (distribution, PR #2779), ttu (docs-ia, PR #2778),
kwsb (PR #2799), and n4hb/c52g/znwj (test-hardening, PR #2787) partially
satisfied — noted with disposition, left open per closure-discipline.

Co-Authored-By: Claude <[email protected]>
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