Skip to content

Allow every object type as a dependency key (L8)#57

Merged
gmr merged 1 commit into
mainfrom
fix/dependency-schema-keys
Jul 7, 2026
Merged

Allow every object type as a dependency key (L8)#57
gmr merged 1 commit into
mainfrom
fix/dependency-schema-keys

Conversation

@gmr

@gmr gmr commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Closes the last substantive item from the review-findings audit (L8).

Problem

ObjectType::from_plural_key (src/constants.rs) already recognizes all 25 object types, but schemata/dependencies.yml listed only nine plural keys under additionalProperties: false. Because per-object validation runs before the dependencies block is stripped, a dependencies: block naming an aggregate, collation, event_trigger, materialized_view, publication, server, subscription, user, or user_mapping was rejected at validation — you could depend on views but not materialized_views. Carried over from Python's OBJ_KEYS; per the maintainer, 2.0 need not preserve that limitation.

Change

  • Add the nine missing keys to schemata/dependencies.yml (schema-qualified schema.name pattern for the schema-scoped types; bare pattern for the schemaless ones), alphabetized with the existing keys.
  • Add a validate test asserting the widened keys validate and unknown keys are still rejected by additionalProperties: false.

Resolution already works end-to-end for these types: the loader's index_key normalizes the namespace to None for schemaless types on both insert and lookup, and from_plural_key maps the keys — so no loader change is needed. (propertyNames on a type: array is a JSON-Schema no-op, matching the existing entries, so the patterns are cosmetic; additionalProperties is the functional gate.)

Validation

  • just check — fmt, clippy -D warnings, all tests pass (new dependencies_schema_accepts_every_object_type).
  • just gates — round-trip + all three deploy gates pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Expanded support for more dependency categories, including aggregates, collations, materialized views, publications, servers, subscriptions, user mappings, and users.
  • Tests

    • Added coverage to confirm the schema accepts the broader set of dependency object types.
    • Verified unknown dependency types are still rejected.

`ObjectType::from_plural_key` already recognized all 25 object types, but
schemata/dependencies.yml listed only nine plural keys under
`additionalProperties: false`, so a `dependencies:` block naming an
aggregate, collation, event_trigger, materialized_view, publication,
server, subscription, user, or user_mapping was rejected at validation
before the loader ever saw it — you could depend on `views` but not
`materialized_views`. This was carried over from Python's OBJ_KEYS; per
the maintainer, 2.0 need not preserve that limitation.

Add the nine missing keys (schema-qualified pattern for the schema-scoped
types, bare for the schemaless ones). Resolution already works: the
loader's `index_key` normalizes the namespace to None for schemaless
types on both insert and lookup, and `from_plural_key` maps the keys. A
new validate test confirms the widened keys pass and unknown keys are
still rejected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f1d6fae9-ed16-472e-bef7-c9c6d9ba1664

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR expands the JSON Schema for PostgreSQL dependency objects to include new top-level properties (aggregates, collations, materialized_views, publications, servers, subscriptions, user_mappings, users) and adds a unit test validating the widened schema and rejection of unknown keys.

Changes

Dependencies schema expansion

Layer / File(s) Summary
Schema property definitions
schemata/dependencies.yml
Adds new array-backed properties for aggregates, collations, materialized_views, publications, servers, subscriptions, user_mappings, and users, and repositions domains, event_triggers, and sequences, each with regex-constrained propertyNames.
Schema validation test
src/project/validate.rs
Adds a unit test that validates a dependency object using all supported plural keys with no errors, and confirms an unknown key is still rejected under additionalProperties: false.

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

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: expanding dependency keys to allow all object types.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dependency-schema-keys

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

@gmr

gmr commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

🤖 This comment was posted by Claude on behalf of @gmr

CI is green and there are no open review threads, but the CodeRabbit status check is still pending. Re-triggering a review.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

@gmr Got it, kicking off a fresh review now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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

🧹 Nitpick comments (1)
src/project/validate.rs (1)

129-159: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test correctly exercises validator_for/iter_errors, but silently doesn't catch the propertyNames-on-array schema gap.

The test data uses arrays of plain strings for every widened key (e.g. "aggregates": ["test.agg"]), which is exactly the instance shape for which propertyNames in dependencies.yml is a no-op. As a result this test only verifies that the keys are accepted (which they would be even with malformed names like "aggregates": ["not-a-schema-qualified-name"]) — it does not actually verify name-format enforcement. Once the propertyNames/items issue in schemata/dependencies.yml is fixed, consider adding a negative case here with a malformed item value (e.g. "aggregates": ["missing_dot"]) to confirm the pattern constraint is enforced.

🤖 Prompt for 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.

In `@src/project/validate.rs` around lines 129 - 159, The dependencies validation
test in validate::dependencies_schema_accepts_every_object_type only checks that
widened keys pass validator_for/iter_errors, but it never verifies item-name
pattern enforcement because the schema gap is on array items rather than the
keys themselves. Update this test to add a negative case using a malformed
dependency name value for one of the widened keys, and assert
validator.iter_errors returns an error so the pattern constraint is actually
exercised alongside the existing accepted/unknown-key checks.
🤖 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 `@schemata/dependencies.yml`:
- Around line 7-22: Update the dependency array schemas in the dependencies
definition so the string validation applies to array elements instead of object
keys; in the affected dependency entries like aggregates, collations, domains,
and event_triggers, replace propertyNames-based validation with items-based
pattern validation, and make the same change for the other dependency arrays in
this file so each dependency string is actually checked.

---

Nitpick comments:
In `@src/project/validate.rs`:
- Around line 129-159: The dependencies validation test in
validate::dependencies_schema_accepts_every_object_type only checks that widened
keys pass validator_for/iter_errors, but it never verifies item-name pattern
enforcement because the schema gap is on array items rather than the keys
themselves. Update this test to add a negative case using a malformed dependency
name value for one of the widened keys, and assert validator.iter_errors returns
an error so the pattern constraint is actually exercised alongside the existing
accepted/unknown-key checks.
🪄 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: CHILL

Plan: Pro Plus

Run ID: f9b6b7da-6744-445c-9966-7697f5da12a5

📥 Commits

Reviewing files that changed from the base of the PR and between 31d3485 and af752b0.

📒 Files selected for processing (2)
  • schemata/dependencies.yml
  • src/project/validate.rs

Comment thread schemata/dependencies.yml
@gmr

gmr commented Jul 7, 2026

Copy link
Copy Markdown
Owner Author

PR monitoring complete — ready to merge.

  • CI: green (test suite success)
  • Review threads: 0 unresolved. CodeRabbit's propertyNames suggestion was declined with rationale and the thread resolved — the propertyNames patterns on type: array are a JSON-Schema no-op that this PR merely extends from the pre-existing entries; additionalProperties: false is the functional gate, and rewriting them into items.pattern would reject valid array contents.
  • Reviewers: CodeRabbit reviewed current HEAD (af752b0).

No code changes were needed this session beyond addressing review feedback.

@gmr gmr merged commit 2a88cee into main Jul 7, 2026
2 checks passed
@gmr gmr deleted the fix/dependency-schema-keys branch July 7, 2026 21:43
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