Skip to content

feat(frontier)!: move CreatePlan and UpdatePlan to AdminService and add ListAllPlans - #496

Open
rohilsurana wants to merge 2 commits into
mainfrom
feat/admin-plan-apis
Open

feat(frontier)!: move CreatePlan and UpdatePlan to AdminService and add ListAllPlans#496
rohilsurana wants to merge 2 commits into
mainfrom
feat/admin-plan-apis

Conversation

@rohilsurana

Copy link
Copy Markdown
Member

What

Move the plan write APIs to AdminService and add a new ListAllPlans API.

  • CreatePlan and UpdatePlan move from FrontierService to AdminService.
  • New ListAllPlans on AdminService. It returns every plan, including disabled ones.
  • ListPlans and GetPlan stay on FrontierService and are unchanged. ListPlans still returns active plans only.

The request and response messages for CreatePlan and UpdatePlan stay in frontier.proto and are reused by the admin RPCs, so admin.proto now imports frontier.proto.

Why

Plan writes are admin only. Today they sit on FrontierService and are gated to platform superusers by the server. Moving them to AdminService puts them on the admin surface where they belong.

The billing reconcile flow in Frontier needs to read every plan for export, including disabled ones. ListPlans returns active plans only, so it cannot see a disabled plan. ListAllPlans fills that gap.

Breaking change

CreatePlan and UpdatePlan are removed from FrontierService. Any client that calls them there must switch to AdminService. buf breaking still passes because proton checks at the WIRE level, and moving an RPC does not break the wire format of the messages. In Frontier, the e2e billing tests call FrontierService.CreatePlan today and will move to the admin client in the follow up.

Follow up in Frontier

  • Bump the proton pin to this commit and regenerate.
  • Wire the CreatePlan, UpdatePlan, and ListAllPlans handlers on the admin service.
  • Point the billing plan reconcile kind at ListAllPlans for export.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Validate / validate (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped✅ passed✅ passedJul 31, 2026, 10:10 AM

@rohilsurana
rohilsurana marked this pull request as ready for review July 31, 2026 09:52
@rohilsurana
rohilsurana force-pushed the feat/admin-plan-apis branch from 51559d3 to ae6d5a6 Compare July 31, 2026 09:53
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rohilsurana, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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 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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 095f517a-c9d2-49a8-a2c9-e9bf7fe02bee

📥 Commits

Reviewing files that changed from the base of the PR and between ae6d5a6 and fc68fa3.

📒 Files selected for processing (1)
  • raystack/frontier/v1beta1/admin.proto
📝 Walkthrough

Walkthrough

The protobuf contract moves plan creation and update operations from FrontierService to AdminService. AdminService now also provides ListAllPlans with optional state filtering. New request and response messages define plan product, interval, credit, trial, state, and metadata fields. Interval values are limited to day, week, month, or year. Create requests require a body, and update requests require a plan ID. FrontierService retains plan listing and retrieval.

Suggested reviewers: amangit07

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes moving CreatePlan and UpdatePlan to AdminService and adding ListAllPlans.
Description check ✅ Passed The description directly explains the API moves, the new ListAllPlans method, the breaking change, and planned follow-up work.

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.

@rohilsurana
rohilsurana marked this pull request as draft July 31, 2026 09:54

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

🧹 Nitpick comments (2)
raystack/frontier/v1beta1/admin.proto (2)

441-444: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Restrict state to known values.

The comment documents that valid values are "active" or "disabled", or empty for all plans. The field has no validation enforcing this. An unrecognized value silently returns an empty result instead of surfacing an error. Add a buf.validate.field constraint, similar to the interval field on PlanRequestBody.

♻️ Proposed validation
 message ListAllPlansRequest {
   // filter by plan state, e.g. "active" or "disabled". an empty value returns all plans
-  string state = 1;
+  string state = 1 [(buf.validate.field).string = {
+    in: [
+      "",
+      "active",
+      "disabled"
+    ]
+  }];
 }
🤖 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 `@raystack/frontier/v1beta1/admin.proto` around lines 441 - 444, Update
ListAllPlansRequest.state with a buf.validate.field string constraint limiting
values to "active", "disabled", or the empty string, following the validation
pattern used by PlanRequestBody.interval. Preserve empty state as the request
for all plans and reject unrecognized values during validation.

450-471: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Apply the same validation rigor to state, on_start_credits, and trial_days.

interval (line 457) restricts input to a known set of values, but state (line 468) accepts any string with no constraint, so it has the same silent-mismatch risk as ListAllPlansRequest.state. Additionally, on_start_credits and trial_days (lines 465-466) accept negative int64 values with no lower-bound check, even though negative credits or negative trial days are not meaningful business values.

♻️ Proposed validation
   int64 on_start_credits = 6;
-  int64 trial_days = 7;
+  int64 trial_days = 7 [(buf.validate.field).int64.gte = 0];

-  string state = 8;
+  string state = 8 [(buf.validate.field).string = {
+    in: [
+      "active",
+      "disabled"
+    ]
+  }];
🤖 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 `@raystack/frontier/v1beta1/admin.proto` around lines 450 - 471, Update
PlanRequestBody fields state, on_start_credits, and trial_days to add validation
consistent with the existing request validation: constrain state to the
supported plan-state values using the established state validation, and require
on_start_credits and trial_days to be non-negative. Keep the existing field
types and interval validation unchanged.
🤖 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.

Nitpick comments:
In `@raystack/frontier/v1beta1/admin.proto`:
- Around line 441-444: Update ListAllPlansRequest.state with a
buf.validate.field string constraint limiting values to "active", "disabled", or
the empty string, following the validation pattern used by
PlanRequestBody.interval. Preserve empty state as the request for all plans and
reject unrecognized values during validation.
- Around line 450-471: Update PlanRequestBody fields state, on_start_credits,
and trial_days to add validation consistent with the existing request
validation: constrain state to the supported plan-state values using the
established state validation, and require on_start_credits and trial_days to be
non-negative. Keep the existing field types and interval validation unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b2e103a-8583-4771-80ec-ad38b1912a78

📥 Commits

Reviewing files that changed from the base of the PR and between 91eaffc and ae6d5a6.

📒 Files selected for processing (2)
  • raystack/frontier/v1beta1/admin.proto
  • raystack/frontier/v1beta1/frontier.proto
💤 Files with no reviewable changes (1)
  • raystack/frontier/v1beta1/frontier.proto

@rohilsurana
rohilsurana marked this pull request as ready for review July 31, 2026 10:06
@rohilsurana

Copy link
Copy Markdown
Member Author

Applied both validation nits in fc68fa3: ListAllPlansRequest.state and PlanRequestBody.state are constrained to the known states, and on_start_credits/trial_days are now gte 0. One tweak: I kept "" in the allowed set for PlanRequestBody.state so an omitted state stays valid (the server defaults it to active on create and update, and CreatePlan callers omit it today).

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.

2 participants