Skip to content

Feat/config change groups#1882

Draft
moshloop wants to merge 12 commits intomainfrom
feat/config-change-groups
Draft

Feat/config change groups#1882
moshloop wants to merge 12 commits intomainfrom
feat/config-change-groups

Conversation

@moshloop
Copy link
Copy Markdown
Member

No description provided.

moshloop added 12 commits April 13, 2026 17:51
Add QueryLogEntry struct and QueryLog collector that can be attached
to a context via WithQueryLog(). When present, QueryTimer.End()
appends query metadata (name, args, count, duration, error, summary)
to the collector for downstream consumption.
Introduces strongly-typed structs for different change detail categories (deployment, backup, pipeline, scaling, etc.) with automatic kind injection during JSON marshaling. Adds constants for all change type values and generates OpenAPI schema for validation.
…ource selectors

Extract repeated parent node lookup into findNearestAncestor helper. Add support for semicolon-delimited searches in resource selectors to enable union queries. Include Pretty field in query log entries for formatted output.
…ated union

Replace reflective schema generation with handwritten kind-discriminated union schema. Adds UnmarshalChangeDetails for runtime deserialization. Introduces new detail types (Approval, Source, Environment, Event, Test, Promotion, PipelineRun, Change, ConfigChange, Restore, Backup, Dimension, Scale, GroupMembership) and removes old details types (DeploymentDetails, PromotionDetails, ApprovalDetails, RollbackDetails, BackupDetails, PlaybookExecutionDetails, ScalingDetails, CertificateDetails, CostChangeDetails, PipelineRunDetails).

BREAKING CHANGE: restructure config change schema to kind-discriminated union
Support static bearer token authentication for Azure connections when client credentials are not provided. Implements TokenCredential interface with a static token provider that defaults expiration to 1 hour.
Enables filtering hierarchical properties by key prefix while maintaining precedence order (CLI/env > local > parent chain > global DB). Returned keys have the prefix stripped for easier consumption.
Add NewGormFromPool to share pgxpool between GORM and direct pgx users, enabling server-side RAISE NOTICE/WARNING messages to flow through ConnConfig.OnNotice. Add ApplySessionProperties to route context properties to Postgres SET LOCAL commands.
…umentation

Add alias normalization before edge detection to match trigger behavior. Pre-soft-delete live losers before inserting winners to prevent unique index violations. Fix external_role_id selection in config_access view. Add comprehensive debug logging infrastructure for troubleshooting merge operations.
…y merges

Include loser ids in the alias union when merging entities so that future lookups by the old id can recover the winner. Applies to users, groups, and roles. Also refactors alias merging to use parametrized queries and left-joins both temp and live tables.
Implements a rule-based engine to automatically group correlated config_changes into logical change_groups. Supports time-windowed grouping (pod startups), fan-out detection (deployments), temporary access tracking, and incident correlation. Includes explicit group creation and optional periodic closure based on inactivity windows.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@moshloop has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 24 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 50 minutes and 24 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2ed7f27e-8c26-412d-8b7b-dee813095cbe

📥 Commits

Reviewing files that changed from the base of the PR and between a0bbb03 and ff4d322.

📒 Files selected for processing (40)
  • .gitignore
  • changegroup/closer.go
  • changegroup/engine.go
  • changegroup/errors.go
  • changegroup/explicit.go
  • changegroup/merge.go
  • changegroup/merge_test.go
  • changegroup/pseudo.go
  • changegroup/pseudo_test.go
  • changegroup/rule.go
  • changegroup/upsert.go
  • connection/azure.go
  • connection/merge_test.go
  • context/properties.go
  • db.go
  • hack/generate-schemas/main.go
  • models/change_group.go
  • models/changes.go
  • models/config.go
  • query/change_groups.go
  • query/config_changes.go
  • query/config_tree.go
  • query/query_logger.go
  • query/resource_selector.go
  • rbac/objects.go
  • schema/config.hcl
  • schema/openapi/change-types.schema.json
  • tests/change_groups_test.go
  • tests/fixtures/dummy/all.go
  • tests/fixtures/dummy/application_data.go
  • tests/fixtures/dummy/config_changes.go
  • types/config_change_groups.go
  • types/config_change_groups_test.go
  • types/config_changes.go
  • types/config_changes_test.go
  • types/resource_selector.go
  • views/030_config_changes.sql
  • views/038_config_access.sql
  • views/045_merge_external_entities.sql
  • views/047_change_groups.sql
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/config-change-groups
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/config-change-groups

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Benchstat (RLS)

Base: a0bbb0307e731afcebc2e77f7863ab04b1ac9d59
Head: ff4d322331cadacc754828013657ccc7fd526fda

📊 3 minor regression(s) (all within 5% threshold)

Benchmark Base Head Change p-value
RLS/Sample-15000/analyzer_types/With_RLS-4 3.253m 3.329m +2.34% 0.026
RLS/Sample-15000/config_summary/With_RLS-4 633.4m 639.7m +0.99% 0.002
RLS/Sample-15000/config_detail/With_RLS-4 109.3m 110.2m +0.87% 0.041
✅ 3 improvement(s)
Benchmark Base Head Change p-value
RLS/Sample-15000/config_names/With_RLS-4 110.9m 109.2m -1.57% 0.002
RLS/Sample-15000/catalog_changes/With_RLS-4 114.3m 113.1m -1.04% 0.002
RLS/Sample-15000/change_types/Without_RLS-4 4.488m 4.456m -0.72% 0.026
Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 9V74 80-Core Processor                
                                               │ bench-base.txt │          bench-head.txt           │
                                               │     sec/op     │   sec/op     vs base              │
RLS/Sample-15000/catalog_changes/Without_RLS-4     4.443m ±  2%   4.457m ± 2%       ~ (p=0.394 n=6)
RLS/Sample-15000/catalog_changes/With_RLS-4        114.3m ±  0%   113.1m ± 0%  -1.04% (p=0.002 n=6)
RLS/Sample-15000/config_changes/Without_RLS-4      4.425m ±  2%   4.500m ± 4%       ~ (p=0.093 n=6)
RLS/Sample-15000/config_changes/With_RLS-4         113.1m ±  0%   112.6m ± 2%       ~ (p=0.180 n=6)
RLS/Sample-15000/config_detail/Without_RLS-4       3.413m ±  1%   3.440m ± 1%       ~ (p=0.699 n=6)
RLS/Sample-15000/config_detail/With_RLS-4          109.3m ±  1%   110.2m ± 1%  +0.87% (p=0.041 n=6)
RLS/Sample-15000/config_names/Without_RLS-4        11.98m ±  2%   12.17m ± 4%       ~ (p=0.180 n=6)
RLS/Sample-15000/config_names/With_RLS-4           110.9m ±  2%   109.2m ± 0%  -1.57% (p=0.002 n=6)
RLS/Sample-15000/config_summary/Without_RLS-4      58.20m ± 16%   56.07m ± 7%       ~ (p=0.093 n=6)
RLS/Sample-15000/config_summary/With_RLS-4         633.4m ±  1%   639.7m ± 2%  +0.99% (p=0.002 n=6)
RLS/Sample-15000/configs/Without_RLS-4             6.418m ±  1%   6.411m ± 9%       ~ (p=0.818 n=6)
RLS/Sample-15000/configs/With_RLS-4                110.5m ±  1%   109.1m ± 2%       ~ (p=0.065 n=6)
RLS/Sample-15000/analysis_types/Without_RLS-4      3.343m ±  3%   3.382m ± 1%       ~ (p=0.180 n=6)
RLS/Sample-15000/analysis_types/With_RLS-4         3.402m ±  2%   3.378m ± 5%       ~ (p=0.093 n=6)
RLS/Sample-15000/analyzer_types/Without_RLS-4      3.201m ±  1%   3.207m ± 1%       ~ (p=0.699 n=6)
RLS/Sample-15000/analyzer_types/With_RLS-4         3.253m ±  3%   3.329m ± 1%  +2.34% (p=0.026 n=6)
RLS/Sample-15000/change_types/Without_RLS-4        4.488m ±  2%   4.456m ± 1%  -0.72% (p=0.026 n=6)
RLS/Sample-15000/change_types/With_RLS-4           4.432m ±  3%   4.448m ± 1%       ~ (p=0.394 n=6)
RLS/Sample-15000/config_classes/Without_RLS-4      2.818m ±  1%   2.804m ± 2%       ~ (p=0.818 n=6)
RLS/Sample-15000/config_classes/With_RLS-4         109.7m ±  2%   109.6m ± 1%       ~ (p=0.699 n=6)
RLS/Sample-15000/config_types/Without_RLS-4        3.422m ±  1%   3.429m ± 2%       ~ (p=0.937 n=6)
RLS/Sample-15000/config_types/With_RLS-4           109.2m ±  0%   109.4m ± 1%       ~ (p=0.310 n=6)
geomean                                            16.79m         16.80m       +0.01%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Benchstat (Other)

Base: a0bbb0307e731afcebc2e77f7863ab04b1ac9d59
Head: ff4d322331cadacc754828013657ccc7fd526fda

⚠️ 4 regression(s) detected (threshold: >5%)

Benchmark Base Head Change p-value
ResourceSelectorConfigs/name_and_type-4 231.3µ 247.4µ +6.97% 🔴 0.002
ResourceSelectorConfigs/name-4 212.3µ 223.3µ +5.17% 🔴 0.002
ResourceSelectorConfigs/tags-4 31.20m 32.21m +3.24% 0.009
ResourceSelectorQueryBuild/name-4 45.15µ 45.82µ +1.48% 0.009
✅ 1 improvement(s)
Benchmark Base Head Change p-value
ResourceSelectorQueryBuild/tags-4 18.00µ 17.84µ -0.88% 0.002

Failed: 2 benchmark(s) regressed by more than 5%:
ResourceSelectorConfigs/name_and_type-4: 231.3µ -> 247.4µ (+6.97%)
ResourceSelectorConfigs/name-4: 212.3µ -> 223.3µ (+5.17%)

Full benchstat output
goos: linux
goarch: amd64
pkg: github.com/flanksource/duty/bench
cpu: AMD EPYC 7763 64-Core Processor                
                                                       │ bench-base.txt │          bench-head.txt           │
                                                       │     sec/op     │   sec/op     vs base              │
InsertionForRowsWithAliases/external_users.aliases-4        604.1µ ± 5%   611.1µ ± 9%       ~ (p=0.132 n=6)
InsertionForRowsWithAliases/config_items.external_id-4      1.138m ± 8%   1.146m ± 9%       ~ (p=0.937 n=6)
ResourceSelectorConfigs/name-4                              212.3µ ± 2%   223.3µ ± 1%  +5.17% (p=0.002 n=6)
ResourceSelectorConfigs/name_and_type-4                     231.3µ ± 3%   247.4µ ± 5%  +6.97% (p=0.002 n=6)
ResourceSelectorConfigs/tags-4                              31.20m ± 3%   32.21m ± 2%  +3.24% (p=0.009 n=6)
ResourceSelectorQueryBuild/name-4                           45.15µ ± 1%   45.82µ ± 1%  +1.48% (p=0.009 n=6)
ResourceSelectorQueryBuild/name_and_type-4                  65.78µ ± 1%   65.38µ ± 2%       ~ (p=0.394 n=6)
ResourceSelectorQueryBuild/tags-4                           18.00µ ± 2%   17.84µ ± 0%  -0.88% (p=0.002 n=6)
geomean                                                     294.3µ        300.6µ       +2.13%

@moshloop moshloop marked this pull request as draft April 16, 2026 07:01
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