Skip to content

feat(api): add governance query operation#4329

Merged
gergely-kurucz-konghq merged 6 commits into
mainfrom
feat/governance-v3
May 12, 2026
Merged

feat(api): add governance query operation#4329
gergely-kurucz-konghq merged 6 commits into
mainfrom
feat/governance-v3

Conversation

@tothandras

@tothandras tothandras commented May 9, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added a Governance API to evaluate customer feature access in bulk with per-customer results, timestamps, and partial error info
    • Exposed governance endpoints and tags on the public API surface
    • Introduced reusable cursor-based pagination for queries
  • Documentation

    • Added a shared generic inline error model for consistent per-item/partial-error reporting
  • Refactor

    • Consolidated product-catalog validation errors to reuse the shared inline error model

Review Change Stack

@tothandras tothandras added the release-note/misc Miscellaneous changes label May 9, 2026
@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a Governance bulk-access query API, a shared generic BaseError<T>, extracts a reusable cursor-pagination page model, defines governance request/response types and enums, wires endpoints into konnect/openmeter, updates a product-catalog error model to use the base error, and adds an unimplemented server route handler.

Changes

Governance API Feature

Layer / File(s) Summary
Shared Error Base and Metadata
api/spec/packages/aip/src/shared/errors.tsp, api/spec/packages/aip/src/shared/index.tsp, api/spec/packages/aip/src/shared/consts.tsp
Introduces Shared.BaseError<T> generic model (code, message, attributes), re-exports errors, and adds GovernanceTag/GovernanceDescription.
Pagination Model Extraction
api/spec/packages/aip/src/common/pagination.tsp
Adds CursorPaginationQueryPage (size, after, before) and updates CursorPaginationQuery.page to reference it while preserving @query(... style: "deepObject").
Governance Domain Models
api/spec/packages/aip/src/governance/governance.tsp
Adds governance filters, GovernanceQueryRequest/Response, per-customer GovernanceQueryResult, GovernanceFeatureAccess and denied-reason types, and partial error enums.
Governance Operations Interface
api/spec/packages/aip/src/governance/index.tsp, api/spec/packages/aip/src/governance/operations.tsp
Adds GovernanceOperations with a cursor-paginated query operation (POST /query) accepting GovernanceQueryRequest and returning `GovernanceQueryResponse
API Endpoint Integration
api/spec/packages/aip/src/konnect.tsp, api/spec/packages/aip/src/openmeter.tsp
Imports governance module, registers @tagMetadata for governance, and wires GovernanceEndpoints at /openmeter/governance tagged with Shared.GovernanceTag.
Existing Model Refactors
api/spec/packages/aip/src/productcatalog/plan.tsp
Changes ProductCatalogValidationError to extend Shared.BaseError<string> (keeps field).
Server Route Handler
api/v3/server/routes.go
Adds QueryGovernanceAccess handler that forwards to unimplemented.QueryGovernanceAccess.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

area/api

Suggested reviewers

  • turip
🚥 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 PR title accurately summarizes the main change—adding a new governance query operation to the API specification and implementation.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/governance-v3

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@tothandras
tothandras marked this pull request as ready for review May 10, 2026 02:14
@tothandras
tothandras requested a review from a team as a code owner May 10, 2026 02:14

@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: 2

🤖 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 `@api/spec/packages/aip/src/common/pagination.tsp`:
- Around line 13-29: Update the documentation comment on the
CursorPaginationQueryPage model to remove the resource-specific term "customer
rows" and make it generic; change the description for the size property in
CursorPaginationQueryPage to something like "Maximum number of items to include
in the response" so it accurately reflects that this pagination model applies to
any resource type.
🪄 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

Run ID: 61f0b954-a05c-47cb-93a7-b60a3e811888

📥 Commits

Reviewing files that changed from the base of the PR and between b2e7c9d and a0bab75.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (12)
  • api/spec/packages/aip/src/common/pagination.tsp
  • api/spec/packages/aip/src/governance/governance.tsp
  • api/spec/packages/aip/src/governance/index.tsp
  • api/spec/packages/aip/src/governance/operations.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/productcatalog/plan.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/spec/packages/aip/src/shared/errors.tsp
  • api/spec/packages/aip/src/shared/index.tsp
  • api/v3/api.gen.go
  • api/v3/server/routes.go

Comment thread api/spec/packages/aip/src/common/pagination.tsp
Comment thread api/v3/server/routes.go
Comment thread api/spec/packages/aip/src/governance/governance.tsp Outdated
Comment thread api/spec/packages/aip/src/governance/governance.tsp

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

🧹 Nitpick comments (1)
api/spec/packages/aip/src/governance/governance.tsp (1)

17-17: ⚡ Quick win

Consider clarifying the summary to match the field's dual purpose.

The field accepts both customer keys and subject keys (as noted in lines 13-14), but the summary only mentions "Customer usage attribution keys". Something like "Customer or subject keys" might be clearer for API consumers.

📝 Suggested improvement
-  `@summary`("Customer usage attribution keys")
+  `@summary`("Customer or subject keys")
🤖 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 `@api/spec/packages/aip/src/governance/governance.tsp` at line 17, Update the
`@summary` for the field that currently reads `@summary`("Customer usage attribution
keys") so it explicitly reflects the field's dual purpose (accepts both customer
keys and subject keys); replace the summary text with a concise phrase like
"Customer or subject usage attribution keys" or similar to clarify intent for
API consumers in the governance.tsp definition.
🤖 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 `@api/spec/packages/aip/src/governance/governance.tsp`:
- Line 17: Update the `@summary` for the field that currently reads
`@summary`("Customer usage attribution keys") so it explicitly reflects the
field's dual purpose (accepts both customer keys and subject keys); replace the
summary text with a concise phrase like "Customer or subject usage attribution
keys" or similar to clarify intent for API consumers in the governance.tsp
definition.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 080d349b-ad87-44a5-94de-48beba0663a5

📥 Commits

Reviewing files that changed from the base of the PR and between b2c8e96 and 4019f74.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (12)
  • api/spec/packages/aip/src/common/pagination.tsp
  • api/spec/packages/aip/src/governance/governance.tsp
  • api/spec/packages/aip/src/governance/index.tsp
  • api/spec/packages/aip/src/governance/operations.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/productcatalog/plan.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/spec/packages/aip/src/shared/errors.tsp
  • api/spec/packages/aip/src/shared/index.tsp
  • api/v3/api.gen.go
  • api/v3/server/routes.go
✅ Files skipped from review due to trivial changes (3)
  • api/spec/packages/aip/src/governance/index.tsp
  • api/spec/packages/aip/src/shared/index.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
🚧 Files skipped from review as they are similar to previous changes (7)
  • api/v3/server/routes.go
  • api/spec/packages/aip/src/common/pagination.tsp
  • api/spec/packages/aip/src/governance/operations.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/shared/errors.tsp
  • api/spec/packages/aip/src/productcatalog/plan.tsp

Comment thread api/spec/packages/aip/src/governance/governance.tsp Outdated
Comment thread api/spec/packages/aip/src/governance/governance.tsp
Comment thread api/spec/packages/aip/src/governance/governance.tsp Outdated

@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

♻️ Duplicate comments (1)
api/spec/packages/aip/src/governance/governance.tsp (1)

18-20: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Please align filter limits with the agreed public API cap (50).

These are currently @maxItems(1000) for both customer and feature keys, but the previous review thread agreed to cap both at 50. Keeping 1000 here risks contract drift and heavier backend load.

Suggested tweak
-  `@maxItems`(1000)
+  `@maxItems`(50)
   keys: string[];
...
-  `@maxItems`(1000)
+  `@maxItems`(50)
   keys: string[];

Also applies to: 34-36

🤖 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 `@api/spec/packages/aip/src/governance/governance.tsp` around lines 18 - 20,
The maxItems constraint for the keys arrays is too high; update both occurrences
of the annotated property (the lines that declare "keys: string[]" with
`@minItems`(1) and `@maxItems`(1000)) to use `@maxItems`(50) instead so the customer
and feature keys comply with the agreed public API cap; locate the two "keys:
string[]" declarations in governance.tsp (the one around the customer keys and
the one around the feature keys) and change their `@maxItems` value from 1000 to
50.
🤖 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 `@api/spec/packages/aip/src/governance/governance.tsp`:
- Line 17: Update the `@summary` for the schema property named "keys" in
governance.tsp to accurately reflect that it accepts both customer keys and
usage-attribution subject keys; locate the "keys" declaration and change the
summary string from "Customer usage attribution keys" to a clearer phrase like
"Customer and usage-attribution subject keys" or similar that explicitly
mentions both types.

---

Duplicate comments:
In `@api/spec/packages/aip/src/governance/governance.tsp`:
- Around line 18-20: The maxItems constraint for the keys arrays is too high;
update both occurrences of the annotated property (the lines that declare "keys:
string[]" with `@minItems`(1) and `@maxItems`(1000)) to use `@maxItems`(50) instead so
the customer and feature keys comply with the agreed public API cap; locate the
two "keys: string[]" declarations in governance.tsp (the one around the customer
keys and the one around the feature keys) and change their `@maxItems` value from
1000 to 50.
🪄 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

Run ID: fddd39cf-89e0-4bfb-bb91-088659fbe4a7

📥 Commits

Reviewing files that changed from the base of the PR and between 4019f74 and 93a2182.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (12)
  • api/spec/packages/aip/src/common/pagination.tsp
  • api/spec/packages/aip/src/governance/governance.tsp
  • api/spec/packages/aip/src/governance/index.tsp
  • api/spec/packages/aip/src/governance/operations.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/productcatalog/plan.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/spec/packages/aip/src/shared/errors.tsp
  • api/spec/packages/aip/src/shared/index.tsp
  • api/v3/api.gen.go
  • api/v3/server/routes.go
✅ Files skipped from review due to trivial changes (2)
  • api/spec/packages/aip/src/shared/index.tsp
  • api/spec/packages/aip/src/governance/index.tsp
🚧 Files skipped from review as they are similar to previous changes (6)
  • api/spec/packages/aip/src/common/pagination.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/v3/server/routes.go
  • api/spec/packages/aip/src/governance/operations.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/shared/errors.tsp

Comment thread api/spec/packages/aip/src/governance/governance.tsp Outdated
@tothandras
tothandras enabled auto-merge (squash) May 12, 2026 12:08
@tothandras
tothandras disabled auto-merge May 12, 2026 15:01
chrisgacsal
chrisgacsal previously approved these changes May 12, 2026
@gergely-kurucz-konghq
gergely-kurucz-konghq merged commit 617c9e6 into main May 12, 2026
29 checks passed
@gergely-kurucz-konghq
gergely-kurucz-konghq deleted the feat/governance-v3 branch May 12, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants