Skip to content

chore(services): store observed counts in permissionsServer, add LR/LS flags#2929

Merged
miparnisari merged 10 commits intomainfrom
barakmich/ps_counts
Mar 18, 2026
Merged

chore(services): store observed counts in permissionsServer, add LR/LS flags#2929
miparnisari merged 10 commits intomainfrom
barakmich/ps_counts

Conversation

@barakmich
Copy link
Contributor

@barakmich barakmich commented Feb 28, 2026

Description

Add the "lr" and "ls" strings as inputs for --experimental-query-plan. Adds testing for the gRPC routes along with the existing consistency tests. And in so doing, found another bug: we want to combine the caveat both from the wildcard, and the relationship itself, which may or may not have one

Testing

References

@github-actions github-actions bot added area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Feb 28, 2026
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

❌ Patch coverage is 59.93976% with 133 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.82%. Comparing base (0298415) to head (6518157).

Files with missing lines Patch % Lines
internal/services/v1/permissions_queryplan.go 51.77% 97 Missing and 26 partials ⚠️
pkg/query/datastore.go 85.11% 7 Missing ⚠️
internal/services/v1/permissions.go 57.15% 2 Missing and 1 partial ⚠️

❌ Your project check has failed because the head coverage (74.82%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2929      +/-   ##
==========================================
- Coverage   74.88%   74.82%   -0.05%     
==========================================
  Files         498      498              
  Lines       60736    61041     +305     
==========================================
+ Hits        45474    45669     +195     
- Misses      12108    12182      +74     
- Partials     3154     3190      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@barakmich barakmich force-pushed the barakmich/ps_counts branch from e95f9b9 to 0bd1e09 Compare March 2, 2026 18:05
@barakmich barakmich force-pushed the barakmich/ps_counts branch from 0bd1e09 to 01dfa21 Compare March 16, 2026 17:12
@barakmich barakmich marked this pull request as ready for review March 16, 2026 17:13
@barakmich barakmich requested a review from a team as a code owner March 16, 2026 17:13
@barakmich barakmich changed the title chore(services): store observed counts in permissionsServer chore(services): store observed counts in permissionsServer, add LR/LS flags Mar 16, 2026
@github-actions github-actions bot added the area/cli Affects the command line label Mar 16, 2026
// validateQueryPlanLookupSubjects checks that for each resource × subject-type
// pair the query plan handler returns at least the subjects the accessibility
// set defines as directly accessible. Wildcard exclusion checking is omitted
// because the query plan handler does not yet populate ExcludedSubjects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL. is there a ticket tracking this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now

@barakmich barakmich force-pushed the barakmich/ps_counts branch 2 times, most recently from 5914507 to 4fc7de4 Compare March 17, 2026 18:59
Comment on lines +282 to +289
ds, err := memdb.NewMemdbDatastore(0, 0, memdb.DisableGC)
require.NoError(err)
revision, err := ds.ReadWriteTx(context.Background(), func(ctx context.Context, tx datastore.ReadWriteTransaction) error {
return nil
})
require.NoError(err)
ctx := NewLocalContext(context.Background(),
WithRevisionedReader(datalayer.NewDataLayer(ds).SnapshotReader(revision)))
Copy link
Contributor

@miparnisari miparnisari Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, here and below, use a mock instead:

ctrl := gomock.NewController(t)
defer ctrl.Finish()
ds := mock_datalayer.NewMockRevisionedReader(ctrl)

ctx := NewLocalContext(context.Background(), WithRevisionedReader(ds))

also, i'm surprised that the mock is never invoked. And i'm not just talking about this test, i'm saying that in every test here where i did this change, the mock is never invoked. Is this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make a mock when we can just build a real one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of reasons:

  1. mocks are way faster
  2. mocks are way easier to control and inspect (see my observation above)
  3. if the signature of NewMemdbDatastore or of ReadWriteTx changes, you don't have to change anything here

Copy link
Contributor Author

@barakmich barakmich Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(1) In the grand scheme of things, it's a couple extra milliseconds

(3) If the signature changes, I feel I actively want to change something here, to make sure I'm using it right

As for (2), a matter of taste.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, I wonder if I can't obviate it entirely

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, I wonder if I can't obviate it entirely

yes, this is what i pointed out

t.Run("lookup_resources", func(t *testing.T) {
if os.Getenv("TEST_QUERY_PLAN_RESOURCES") == "" {
t.Skip("Skipping IterResources tests: set TEST_QUERY_PLAN_RESOURCES=true to enable")
t.Skip("Skipping IterResources tests due to deprectation: Set TEST_QUERY_PLAN_RESOURCES=true to enable")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused; what deprecation?

@barakmich barakmich force-pushed the barakmich/ps_counts branch from 4fc7de4 to dc23bb5 Compare March 17, 2026 22:23
@barakmich barakmich force-pushed the barakmich/ps_counts branch from dc23bb5 to c2f94b1 Compare March 18, 2026 16:24
@miparnisari miparnisari merged commit ea6c5f2 into main Mar 18, 2026
43 of 45 checks passed
@miparnisari miparnisari deleted the barakmich/ps_counts branch March 18, 2026 17:23
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area/api v1 Affects the v1 API area/cli Affects the command line area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants