fix(storage): validate page refs on update_page to block dangling graph links#468
fix(storage): validate page refs on update_page to block dangling graph links#468RealDiligent wants to merge 3 commits into
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
update_page lacked the graph-integrity ref checks that put_page and update_claim already enforce. Vault-edit approvals could land pages citing claims deleted between propose and approve. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Follow-up commit: \�pprove()\ now calls _payload_block_reason()\ before writing, so single-approve paths (web console, MCP) get a clean \ProposalError\ instead of a raw \ValueError\ when refs go stale between propose and approve. Batch CLI already had this via \check_approvable(); this closes the drift. Storage-layer _validate_page_refs()\ in \update_page()\ remains as defense-in-depth (same pattern as \update_claim()). |
…paths Batch CLI already calls check_approvable(); web/MCP approve() did not, so stale vault-edit refs surfaced as ValueError instead of ProposalError. Defense-in-depth alongside update_page ref validation. Co-authored-by: Cursor <cursoragent@cursor.com>
approve() now runs _payload_block_reason before delete, so the error message uses referenced by instead of still referenced by. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Root cause:
update_page()— used when approving vault-edit proposals for existing pages — did not re-validate graph references before persisting.put_page()andupdate_claim()already enforce ref integrity, but page updates could land with danglingclaims/entities/sourceslinks if a referenced artifact was deleted between propose and approve.Fix: Extract
_validate_page_refs()(mirroring_validate_claim_refs) and call it from bothput_page()andupdate_page().update_page()also round-trips throughPage.model_validate()likeupdate_claim()does for model invariants.Impact: Vault-sync and other page-edit approvals can no longer silently corrupt the KB graph. Operators get a clear
ValueErrorinstead of durable dangling references thatvouch lintwould only catch later.Reproduction
Regression tests:
test_update_page_rejects_dangling_claim_ref,test_approve_page_update_rejects_stale_claim_ref.Risk / tradeoffs
Test plan
test_update_page_rejects_dangling_claim_reftest_approve_page_update_rejects_stale_claim_reftests/test_storage.py+tests/test_vault_sync.pypass