Skip to content

test(storage): cover assertion overlay parity (#1883) - #2078

Merged
Sinity merged 3 commits into
masterfrom
feature/feat/assertion-overlay-parity-1883
Jun 18, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/feat/assertion-overlay-parity-1883

Conversation

@Sinity

@Sinity Sinity commented Jun 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds public-surface assertion parity coverage for #1883 and fixes the verification harness gap that surfaced while running the default baseline. The storage tests now prove blackboard writes through Polylogue.post_blackboard_note() preserve assertion metadata, and they prove ordinary session tags/session metadata remain the intentional table-backed user metadata exception rather than lifecycle assertions.

Problem

#1883 had helper-level assertion write-through coverage and readiness audit coverage, but the durable public-facade proof was incomplete for two important cases: blackboard assertion metadata and the explicit tags/metadata exception. While validating the branch, devtools verify selected a very large pytest-testmon set, ran for 45 minutes, then timed out at 82%. Because pytest-json-report never flushed, verify reported report_path: null and lost node-level failure evidence despite many visible failures. That made the broad gate hard to act on.

Solution

  • Extend tests/unit/storage/test_user_state_contracts.py with public-facade assertions for blackboard author/evidence/staleness/context-policy metadata.
  • Add explicit table-backed coverage for Polylogue.add_tag() and Polylogue.set_metadata(), matching Unify user overlays as evidence-linked assertions #1883's current design: simple tag/metadata rows are user metadata, not assertion lifecycle claims.
  • Add devtools.pytest_progress_plugin, loaded by every devtools verify pytest lane, which writes per-test call outcomes incrementally to .cache/verify/current-pytest-events.jsonl.
  • Persist captured pytest stdout/stderr to .cache/verify/current-pytest-output.log and expose both paths in verify metadata so timeout/stall terminations leave usable evidence.

Verification

  • nix develop --command devtools test tests/unit/storage/test_user_state_contracts.py -> 9 passed.
  • nix develop --command devtools test tests/unit/devtools/test_verify.py tests/unit/storage/test_user_state_contracts.py -> 52 passed.
  • nix develop --command devtools verify --quick -> exit_code: 0 at 8c0a2e94.
  • Attempted default nix develop --command devtools verify before the harness fix: static gates passed, pytest-testmon timed out after 2700s at 82% with report_path: null. This PR fixes that evidence-loss path; I did not rerun another 45-minute default baseline after the harness patch.

Ref #1883
Ref #2006

Summary by CodeRabbit

  • Tests

    • Expanded test coverage for assertion metadata persistence and user state validation.
    • Added verification for test execution artifact tracking and metadata propagation.
  • Chores

    • Enhanced test execution monitoring with improved artifact generation for diagnostics.

Sinity added 2 commits June 18, 2026 04:17
Problem: #1883 still needed public-surface evidence for assertion-backed overlay parity and for the explicit tag/metadata table-backed exception. Helper-level tests covered much of the substrate, but they did not prove the Polylogue facade paths preserve assertion metadata.

What changed: add user-state contract tests for public blackboard writes carrying author/evidence/staleness/context policy into NOTE assertions, and for tag/metadata mutations remaining table-backed user metadata rather than lifecycle assertions.

Verification:
- nix develop --command devtools test tests/unit/storage/test_user_state_contracts.py
- nix develop --command devtools verify --quick

Ref #1883
Problem: default devtools verify can terminate a long pytest-testmon run before pytest-json-report or JUnit flushes, leaving report_path null and no node-level evidence for failures observed before timeout.

What changed: load a small pytest plugin during verify pytest lanes that writes per-test call outcomes to .cache/verify/current-pytest-events.jsonl, persist captured pytest output to .cache/verify/current-pytest-output.log, expose both paths in verify metadata, and clear stale artifacts before each pytest step.

Verification:
- nix develop --command devtools test tests/unit/devtools/test_verify.py tests/unit/storage/test_user_state_contracts.py
- nix develop --command devtools verify --quick

Ref #2006
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

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

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ 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.

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 credits.

🚦 How do rate limits work?

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

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a0e066e6-575e-4b05-bc4a-1771fbe6c563

📥 Commits

Reviewing files that changed from the base of the PR and between 8c0a2e9 and 011b828.

📒 Files selected for processing (2)
  • devtools/pytest_progress_plugin.py
  • tests/unit/devtools/test_pytest_progress_plugin.py
📝 Walkthrough

Walkthrough

Adds devtools/pytest_progress_plugin.py, a new pytest hook that streams per-test JSONL events to a file path from POLYLOGUE_PYTEST_EVENTS_PATH. devtools/verify.py gains two artifact path constants, cleanup/write helpers, subprocess env propagation, plugin registration, and step metadata fields. Tests in test_verify.py assert the new behavior; test_user_state_contracts.py adds two async tests for blackboard and session persistence in user.db.

Changes

Pytest Progress Plugin and Verify Artifacts

Layer / File(s) Summary
Progress plugin implementation and verify wiring
devtools/pytest_progress_plugin.py, devtools/verify.py
New pytest_progress_plugin appends JSONL test_report events per test call; verify.py adds PYTEST_EVENTS_PATH/PYTEST_OUTPUT_PATH constants, artifact cleanup and write helpers, -p devtools.pytest_progress_plugin in the pytest command, POLYLOGUE_PYTEST_EVENTS_PATH env var for the subprocess, output-file persistence after heartbeat collection, and events_path/output_path in step metadata.
Test assertions for new artifact metadata and env propagation
tests/unit/devtools/test_verify.py
Imports new path constants; asserts events_path/output_path metadata in terminal-fallback, structured JSON, and budget-termination test scenarios; checks POLYLOGUE_PYTEST_EVENTS_PATH subprocess env propagation; validates live-progress JSON fields and output artifact file contents.

User State Storage Contract Tests

Layer / File(s) Summary
Blackboard and session persistence contract tests
tests/unit/storage/test_user_state_contracts.py
Imports AssertionKind and list_assertions_for_target; adds two async tests verifying assertion metadata mirroring from user.db via post_blackboard_note and correct session tag/metadata persistence without producing generic assertions rows.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A plugin hops in, JSON lines it writes,
Each test call recorded through long verify nights.
The output log captured, the paths all declared,
No progress goes missing, no artifact unshared.
Session tags persist and assertions do mirror—
The rabbit's devtools grow ever the clearer! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title focuses narrowly on test coverage for assertion overlay parity (#1883), but the PR also includes a significant harness fix for timeout evidence-loss in devtools verify. Consider a title that encompasses both the assertion parity test coverage and the devtools verify harness improvements (e.g., 'test(storage): cover assertion overlay parity and fix verify timeout evidence loss').
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description comprehensively covers all required sections: Summary, Problem, Solution, and Verification, with clear explanations of both the storage test additions and harness fixes.
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 feature/feat/assertion-overlay-parity-1883

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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c0a2e945e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread devtools/pytest_progress_plugin.py Resolved

@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 `@devtools/pytest_progress_plugin.py`:
- Around line 37-39: The file write operations for the event ledger
(path.parent.mkdir and path.open with handle.write) can raise OSError which will
cause the pytest hook to fail entirely. Wrap these write operations in a
try-except block that catches OSError and handles it gracefully by logging the
error without re-raising the exception, ensuring that telemetry failures do not
cause the pytest run to fail.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a0e07f46-315a-4ba8-b2d8-6617fc6f016b

📥 Commits

Reviewing files that changed from the base of the PR and between f16c8c2 and 8c0a2e9.

📒 Files selected for processing (4)
  • devtools/pytest_progress_plugin.py
  • devtools/verify.py
  • tests/unit/devtools/test_verify.py
  • tests/unit/storage/test_user_state_contracts.py

Comment thread devtools/pytest_progress_plugin.py Resolved
Problem: review found that the new verify event ledger missed setup/teardown failures and could let optional telemetry write failures escape from the pytest hook.

What changed: record failed setup/teardown reports in addition to normal call reports, make event-file writes best-effort on OSError, and add direct plugin tests for setup failure capture and write-failure containment.

Verification:
- nix develop --command devtools test tests/unit/devtools/test_verify.py tests/unit/devtools/test_pytest_progress_plugin.py
- nix develop --command devtools verify --quick

Ref #2006
@Sinity

Sinity commented Jun 18, 2026

Copy link
Copy Markdown
Owner Author

Addressed both review findings in 011b828: the pytest event plugin now records failed setup/teardown reports as well as call reports, and event-ledger writes are best-effort on OSError so telemetry cannot fail pytest. Added direct plugin tests for both behaviors. Pre-push quick gate passed at 011b828.

@Sinity
Sinity merged commit 22c17e3 into master Jun 18, 2026
11 checks passed
@Sinity
Sinity deleted the feature/feat/assertion-overlay-parity-1883 branch June 18, 2026 03:19
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 55.F028 / P2: fixed-already at the checked revision: Phase recording admits setup, call, and teardown reports (devtools/pytest_progress_plugin.py:375) and preserves failed long representations before writing the event. Fixture/setup failures therefore produce node-level evidence without needing a call report.

Only the rows listed above are dispositioned. Held findings remain open.

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