Skip to content

New command: expose --cache-cleanup=overlay base cache cleaning #4082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 25, 2025

Conversation

d10c
Copy link
Contributor

@d10c d10c commented Jul 21, 2025

Add new command "CodeQL: Trim Overlay Base Cache" that returns a database to the state prior to overlay evaluation, leaving only base predicates and types that may later be referenced during overlay evaluation.

  • Requires a recent enough query server. So the command is hidden behind a version check.
  • Tested locally and with unit tests.

@d10c d10c force-pushed the d10c/cache-cleanup-overlay branch 3 times, most recently from 66df4c2 to 82df605 Compare July 23, 2025 09:33
@d10c d10c marked this pull request as ready for review July 23, 2025 10:30
@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 10:30
@d10c d10c requested review from a team as code owners July 23, 2025 10:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new command "CodeQL: Trim Overlay Base Cache" to expose the --cache-cleanup=overlay functionality for cleaning base cache data. The command allows users to return a database to the state prior to overlay evaluation, keeping only base predicates and types needed for future overlay evaluation.

Key Changes:

  • Implements new trimOverlayBaseCache command with corresponding message type and query server method
  • Adds UI integration through command registration and handler implementation
  • Updates package.json to expose the command in VS Code's command palette

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
extensions/ql-vscode/src/query-server/query-runner.ts Adds trimOverlayBaseCacheInDatabase method to handle the new cache trimming operation
extensions/ql-vscode/src/query-server/messages.ts Defines the trimOverlayBaseCache request type for communication with the query server
extensions/ql-vscode/src/databases/local-databases-ui.ts Registers command and implements handler for the new trim overlay base cache functionality
extensions/ql-vscode/src/common/commands.ts Adds type definition for the new command
extensions/ql-vscode/package.json Exposes the new command in VS Code's command palette
extensions/ql-vscode/CHANGELOG.md Documents the new feature addition

@d10c d10c force-pushed the d10c/cache-cleanup-overlay branch from 4922bbf to 380277d Compare July 23, 2025 14:05
@d10c d10c requested a review from cklin July 23, 2025 14:44
@koesie10
Copy link
Member

  • Requires a recent enough query server. Should I hide this command behind a version check, or just let it fail on an older CLI?

I think it would make sense to add this command behind a version check, although it would be even better to hide it behind a CLI feature (one that is returned in codeql version --format json). I see that the CLI PR hasn't been merged yet, so I think it would be best to add the feature in there. Then I think the best way to check this feature would be using something like:

cliServer.addVersionChangedListener((version) => {
  void app.commands.execute(
    "setContext",
    "codeQL.cliFeatures.yourFeatureName",
    version?.features?.yourFeatureName ?? false,
  );
});

You can then access this context in the when expression in package.json.

  • I've tested this locally using a compatible build that hasn't been released yet. I suppose it means I can't add automated tests until that build is released. Should I add tests?

If you can add tests, I think that would make sense. Once your PR is included in the nightly build, you should already be able to test it there, and based on when the PR is merged you can probably also determine which actual version it will be part of to add an actual version check.

@d10c d10c force-pushed the d10c/cache-cleanup-overlay branch from 380277d to 135be43 Compare July 24, 2025 12:26
@d10c
Copy link
Contributor Author

d10c commented Jul 24, 2025

I've added a VSCode context variable for all the CLI features, but if that's too complicated, I can change it back to just the new CLI feature that we use.

@d10c
Copy link
Contributor Author

d10c commented Jul 24, 2025

I'm fine with merging the query server changes first, so that we can include an integration test in this PR.

@d10c d10c force-pushed the d10c/cache-cleanup-overlay branch from 135be43 to 816f23c Compare July 25, 2025 07:43
Copy link
Member

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

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

The code looks good to me. I think adding tests might be nice, but since the command is just sending a request to the query server, I don't think it's critical.

@d10c d10c force-pushed the d10c/cache-cleanup-overlay branch from 816f23c to 0c4fc07 Compare July 25, 2025 09:24
Copy link
Contributor

@cklin cklin left a comment

Choose a reason for hiding this comment

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

Looks fine from the CodeQL CLI interaction perspective 👍

@d10c d10c merged commit a426f82 into github:main Jul 25, 2025
33 of 34 checks passed
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.

3 participants