Skip to content

fix(audit-logs): list an organization's audit log through its single scope predicate again - #9438

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/audit-log-listing-single-scope
Oct 29, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/audit-log-listing-single-scope

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Restores the organization audit-log listing to its pre-#9419 single scope predicate.

  • perf(db): cut hot-path database work and close copilot cleanup gaps #9419 read a page's ids as one keyset scan per org workspace plus the organization-level rows. That bounds an unfiltered listing, but with a filter the workspace keyset index can't apply in order (action, resource, actor), each workspace's scan becomes a bitmap AND of the workspace's whole history with the filter's index plus a sort, once per workspace. For a busy organization a filtered listing got many times slower than the single predicate, which scans the filter's index once
  • The listing, export and v1 route go back to the single buildOrgScopeCondition predicate (as before perf(db): cut hot-path database work and close copilot cleanup gaps #9419); the org-level partial index from perf(audit-logs): index organization-level rows and read them as two keyset parts #9437 (0444) stays, since migrations are forward-only and the predicate's organization-level rows can use it
  • list-scope.integration.ts (mixed workspace, org-level, foreign and departed rows, sub-millisecond ties, byte budget) now runs against the restored signature; the per-workspace plan test described the reverted shape and is removed
  • Bounding the unfiltered listing for very busy organizations is a follow-up that has to hold up under every filter

Type of Change

  • Bug fix

Testing

  • Audit-logs and data-drain integration suites pass in migrate and push modes; audit-logs, v1 audit-logs and data-drain source unit tests pass
  • bun run lint, type-check, check:audits, check-test-types

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…scope predicate again

#9419 read a listing's page ids as one keyset scan per organization workspace plus the
organization-level rows. That bounds an unfiltered listing, but a filter the workspace
keyset index cannot apply in order (an action, a resource, an actor) turns each
workspace's scan into a bitmap AND of that workspace's whole history with the filter's
index, then a sort, once per workspace. For a busy organization a filtered listing went
from one scan of the filter's index to many times that, and slow replica reads are what
recovery conflicts cancel.

Restore the listing to the single organization-scope predicate it used before, which lets
the planner pick the filter's index, keep the org-level index from 0444 (the predicate's
organization-level rows can use it), and keep the scope integration test against the
restored signature. The per-workspace plan test described the reverted shape and goes.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 29, 2026 7:24am UTC

Request Review

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found.

Summary

Restores organization audit-log listing and export to one scope predicate instead of separate workspace scans.

  • Organization audit logs use one scoped query across listing and export paths.

No actionable issues were found. This review checked code and tests without running the suites.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[List, export, and v1 callers] --> B[Build organization scope]
  B --> C[Combine scope, filters, and cursor]
  C --> D[Read one ordered page]
  D --> E[Rows and next cursor]
Loading

Reviews (1) · Last reviewed commit: "fix(audit-logs): list an organization's ..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 8a14967 into staging Oct 29, 2026
57 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/audit-log-listing-single-scope branch October 29, 2026 07:30

This branch was previously deployed

1 inactive deployment
Preview — 0c98c856 Deployed Oct 29, 2026 by vercel[bot]
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