Skip to content

feat: store changelog diff for feature flag compositions#3068

Open
JivusAyrus wants to merge 4 commits into
mainfrom
suvij/eng-9859-controlplane-store-schema-changelogdiff-for-feature-flag
Open

feat: store changelog diff for feature flag compositions#3068
JivusAyrus wants to merge 4 commits into
mainfrom
suvij/eng-9859-controlplane-store-schema-changelogdiff-for-feature-flag

Conversation

@JivusAyrus

@JivusAyrus JivusAyrus commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Feature-flag compositions now include feature-flag-aware schema composition and persist schema versions accordingly.
    • Added support for retrieving the latest feature-flag schema version to power composition changelog generation.
  • Bug Fixes
    • Schema changelog/diff behavior for feature-flag compositions is corrected to compare against the correct previous feature-flag baseline (instead of skipping diff/changelog when certain config is present).
    • Re-composing an unchanged feature-flag schema now reports an empty changelog.
  • Tests
    • Added integration tests covering feature-flag changelog additions and zero-change scenarios.

Checklist

Open Source AI Manifesto

This project follows the principles of the Open Source AI Manifesto. Please ensure your contribution aligns with its principles.

@JivusAyrus JivusAyrus requested a review from a team as a code owner July 10, 2026 13:24
…59-controlplane-store-schema-changelogdiff-for-feature-flag
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f482b8b2-cf8a-4e27-9fdb-5d0fa1b86843

📥 Commits

Reviewing files that changed from the base of the PR and between 69953b2 and 4460cb6.

📒 Files selected for processing (2)
  • controlplane/src/core/composition/composer.ts
  • controlplane/src/core/repositories/FeatureFlagRepository.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • controlplane/src/core/repositories/FeatureFlagRepository.ts

Walkthrough

Feature-flag schema history is now used when composing and diffing feature-flag graphs. FeatureFlagRepository is wired through proposal, schema-check, and composition-service flows, with integration tests covering changed and unchanged schemas.

Changes

Feature-flag composition changelog

Layer / File(s) Summary
Feature-flag schema lookup
controlplane/src/core/repositories/FeatureFlagRepository.ts, controlplane/src/core/composition/composer.ts
Adds retrieval of the latest eligible feature-flag schema version and injects the repository into Composer.
Feature-flag changelog computation
controlplane/src/core/composition/composer.ts
Uses the feature-flag schema baseline for feature-flag compositions and permits changelog generation when required composition metadata is available.
Composition pipeline wiring and validation
controlplane/src/core/bufservices/proposal/*, controlplane/src/core/bufservices/subgraph/fixSubgraphSchema.ts, controlplane/src/core/repositories/SubgraphRepository.ts, controlplane/src/core/services/CompositionService.ts, controlplane/test/composition/getCompositionDetails.test.ts
Passes FeatureFlagRepository through composition entry points and adds tests for schema additions and unchanged recompositions.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly matches the main change: enabling changelog diff storage for feature-flag compositions.
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 docstrings
  • Create stacked PR
  • Commit on current branch

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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)
controlplane/src/core/repositories/FeatureFlagRepository.ts (1)

1621-1655: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

New method looks correct; consider consolidating with similar "latest valid flag composition" queries.

getLatestFeatureFlagSchemaVersion is logically sound: it scopes by schemaVersion.targetId + featureFlagId, requires isFeatureFlagComposition/isComposable, excludes rows with deployment/admission errors, and orders by graphCompositions.createdAt desc — correctly isolating the prior valid feature-flag composition per federated graph. Org-scoping is preserved transitively via the schemaVersion.organizationId filter.

This query is structurally near-identical to getLatestValidFlagCompositionClientSchema (lines 1523-1563) and shares most of its predicate logic with getFeatureFlagSchemaVersionByBaseSchemaVersion (lines 1567-1619). Three separate near-duplicate implementations of "the latest valid feature-flag-composed schema version" increase the risk that a future change to the composability rules (e.g., adding another error condition) is applied inconsistently across them.

🤖 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 `@controlplane/src/core/repositories/FeatureFlagRepository.ts` around lines
1621 - 1655, Consolidate getLatestFeatureFlagSchemaVersion with the existing
getLatestValidFlagCompositionClientSchema and
getFeatureFlagSchemaVersionByBaseSchemaVersion query logic by extracting shared
predicates or a reusable helper for selecting the latest valid feature-flag
composition. Preserve each method’s distinct filters and return shape while
centralizing composability and error-condition rules so future changes remain
consistent.
🤖 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 `@controlplane/src/core/composition/composer.ts`:
- Around line 489-490: Update the comment above the guard in the composition
flow to remove the outdated reference to feature-flag compositions, accurately
documenting only that changelogs are skipped when the router execution config or
composed schema version ID is unavailable.

---

Nitpick comments:
In `@controlplane/src/core/repositories/FeatureFlagRepository.ts`:
- Around line 1621-1655: Consolidate getLatestFeatureFlagSchemaVersion with the
existing getLatestValidFlagCompositionClientSchema and
getFeatureFlagSchemaVersionByBaseSchemaVersion query logic by extracting shared
predicates or a reusable helper for selecting the latest valid feature-flag
composition. Preserve each method’s distinct filters and return shape while
centralizing composability and error-condition rules so future changes remain
consistent.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fafaccd6-3c10-4ae5-89d5-c4c3837d4fde

📥 Commits

Reviewing files that changed from the base of the PR and between 935b792 and 69953b2.

📒 Files selected for processing (8)
  • controlplane/src/core/bufservices/proposal/createProposal.ts
  • controlplane/src/core/bufservices/proposal/updateProposal.ts
  • controlplane/src/core/bufservices/subgraph/fixSubgraphSchema.ts
  • controlplane/src/core/composition/composer.ts
  • controlplane/src/core/repositories/FeatureFlagRepository.ts
  • controlplane/src/core/repositories/SubgraphRepository.ts
  • controlplane/src/core/services/CompositionService.ts
  • controlplane/test/composition/getCompositionDetails.test.ts

Comment thread controlplane/src/core/composition/composer.ts Outdated
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.05%. Comparing base (1affda0) to head (4460cb6).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...src/core/bufservices/subgraph/fixSubgraphSchema.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3068      +/-   ##
==========================================
+ Coverage   61.66%   71.05%   +9.38%     
==========================================
  Files         261      335      +74     
  Lines       30649    49325   +18676     
  Branches        0     6033    +6033     
==========================================
+ Hits        18901    35046   +16145     
- Misses      10222    14253    +4031     
+ Partials     1526       26    -1500     
Files with missing lines Coverage Δ
...ne/src/core/bufservices/proposal/createProposal.ts 78.98% <100.00%> (ø)
...ne/src/core/bufservices/proposal/updateProposal.ts 76.32% <100.00%> (ø)
controlplane/src/core/composition/composer.ts 65.75% <100.00%> (ø)
...ane/src/core/repositories/FeatureFlagRepository.ts 93.01% <100.00%> (ø)
...lplane/src/core/repositories/SubgraphRepository.ts 91.66% <100.00%> (ø)
...ntrolplane/src/core/services/CompositionService.ts 87.98% <100.00%> (ø)
...src/core/bufservices/subgraph/fixSubgraphSchema.ts 1.05% <0.00%> (ø)

... and 589 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant