Skip to content

Fix collection block type validation - #208

Merged
brylie merged 2 commits into
mainfrom
fix/collection-blocktype-invariant
Sep 4, 2026
Merged

Fix collection block type validation#208
brylie merged 2 commits into
mainfrom
fix/collection-blocktype-invariant

Conversation

@brylie

@brylie brylie commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • reject every explicit blockType under a Collection parent in the service layer
  • cover targetless page_link creation and every current block type as Collection-parent regressions
  • assert the CRDT invariant that Collection rows never persist blockType
  • document the create_record parent-kind contract

Validation

  • npx vitest run --project server src/lib/data/records.test.ts src/lib/services/services.test.ts
  • npm run check
  • npx prettier --check src/lib/services/records.ts src/lib/data/records.test.ts src/lib/services/services.test.ts docs/specifications/mcp-tools.md
  • git diff --check

Closes #63

Summary by CodeRabbit

  • Bug Fixes

    • Prevented collection rows from storing document-only block types.
    • Requests that specify a block type under a non-Document parent are now rejected consistently.
    • Added validation for targetless page links and other document block types under Collection parents.
  • Documentation

    • Clarified record-creation rules, including when blockType and properties can be used.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: f95e8183-70a1-45ff-ba22-92511c2efab2

📥 Commits

Reviewing files that changed from the base of the PR and between 81ddca2 and 82230d7.

📒 Files selected for processing (5)
  • .agents/skills/pr-backlog-reflection/SKILL.md
  • docs/specifications/mcp-tools.md
  • src/lib/data/records.test.ts
  • src/lib/services/records.ts
  • src/lib/services/services.test.ts

Included review availability: 1 review is currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.


📝 Walkthrough

Walkthrough

The change validates that explicit blockType values require Document parents. It adds tests for rejected Collection-parent records and for collection rows that omit persisted blockType. MCP documentation and backlog guidance formatting are also updated.

Changes

Record validation and persistence

Layer / File(s) Summary
Document-parent validation and contract
src/lib/services/records.ts, src/lib/services/services.test.ts, docs/specifications/mcp-tools.md
createRecord rejects explicit block types under non-Document parents. Service tests cover targetless page_link and all listed block types. MCP documentation describes the Document and Collection input rules.
Collection-row block type invariant
src/lib/data/records.test.ts
Tests verify that collection rows omit blockType for every requested block type.

Backlog guidance formatting

Layer / File(s) Summary
Classification table formatting
.agents/skills/pr-backlog-reflection/SKILL.md
The classification table was reformatted without changing its content.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 82230

Collection parents now reject explicit block types before records are created, while valid collection rows remain block-type-free. The documented contract and regression coverage align with this behavior, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The .agents/skills/pr-backlog-reflection/SKILL.md table reformat is unrelated to Collection block type validation and the requirements in issue #63. Remove the unrelated formatting change from .agents/skills/pr-backlog-reflection/SKILL.md, or provide an explicit linked requirement that justifies it.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title, "Fix collection block type validation," clearly summarizes the primary change: validating block types for Collection parents.
Linked Issues check ✅ Passed The changes satisfy issue #63. They reject explicit block types under non-Document parents, cover targetless page_link and other Document-only block types, verify that Collection rows do not persist b…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files. (2 skipped: 2 …
  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/collection-blocktype-invariant

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

.agents/skills/pr-backlog-reflection/SKILL.md (added on main via #201)
was unformatted, which was failing this PR's lint check even though the
file is unrelated to this branch's actual changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@brylie
brylie merged commit 77437bf into main Sep 4, 2026
2 checks passed
@brylie
brylie deleted the fix/collection-blocktype-invariant branch September 4, 2026 19:36
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.

Add invariant test: collection-row records never persist blockType

1 participant