Skip to content

Re-index project rules on startup.#10377

Merged
szgupta merged 3 commits into
masterfrom
suraj/fix-project-rule-loading-based-on-persisted-rules
May 7, 2026
Merged

Re-index project rules on startup.#10377
szgupta merged 3 commits into
masterfrom
suraj/fix-project-rule-loading-based-on-persisted-rules

Conversation

@szgupta
Copy link
Copy Markdown
Member

@szgupta szgupta commented May 7, 2026

Caching rule-paths for indexed repos is problematic because the entries could go stale and prevent re-indexing of the repo. For example, suppose we index a repo that has a root WARP.md file. Later on, the user adds a dir/WARP.md file. Currently, we would not detect the new sub-dir WARP.md file because we wouldn't re-index the repo (because we already have a rule-file for the repo).

If we think this is the correct solution, we should probably get rid of the project_rules sqlite table.

@cla-bot cla-bot Bot added the cla-signed label May 7, 2026
@szgupta szgupta force-pushed the suraj/fix-project-rule-loading-based-on-persisted-rules branch 2 times, most recently from 2ab78ec to 4729a5d Compare May 7, 2026 16:14
@szgupta szgupta force-pushed the suraj/fix-project-rule-loading-based-on-persisted-rules branch from 4729a5d to 991af4a Compare May 7, 2026 16:15
@szgupta szgupta changed the title Don't rely on persisted rule paths. Re-index project rules on startup. May 7, 2026
@szgupta szgupta requested a review from kevinyang372 May 7, 2026 17:47
@szgupta szgupta marked this pull request as ready for review May 7, 2026 17:47
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 7, 2026

@szgupta

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This change re-scans project rules instead of treating persisted rule paths as proof that a repository is already indexed, and it persists added or modified rule paths from repository watcher updates.

Concerns

  • Re-indexing now also registers an additional repository subscriber each time index_and_store_rules runs for a root that is already loaded, which can duplicate update processing and leak subscribers.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

root_path: PathBuf,
ctx: &mut ModelContext<Self>,
) -> Result<()> {
if self.path_to_rules.contains_key(&root_path) {
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.

⚠️ [IMPORTANT] Removing this guard makes every re-scan call register_watcher_for_path again; startup loading already registers watchers for persisted roots, and repeated indexing will leave duplicate repository subscribers processing each update. Split re-scan from watcher registration or dedupe registrations per root.

@szgupta szgupta enabled auto-merge (squash) May 7, 2026 18:32
@szgupta szgupta merged commit 3019671 into master May 7, 2026
24 checks passed
@szgupta szgupta deleted the suraj/fix-project-rule-loading-based-on-persisted-rules branch May 7, 2026 20:52
trungtai1805 pushed a commit to trungtai1805/warp that referenced this pull request May 9, 2026
Caching rule-paths for indexed repos is problematic because the entries
could go stale and prevent re-indexing of the repo. For example, suppose
we index a repo that has a root `WARP.md` file. Later on, the user adds
a `dir/WARP.md` file. Currently, we would not detect the new sub-dir
WARP.md file because we wouldn't re-index the repo (because we already
have a rule-file for the repo).

If we think this is the correct solution, we should probably get rid of
the `project_rules` sqlite table.
zhangyu1818-bot pushed a commit to zhangyu1818/warply that referenced this pull request May 10, 2026
Caching rule-paths for indexed repos is problematic because the entries
could go stale and prevent re-indexing of the repo. For example, suppose
we index a repo that has a root `WARP.md` file. Later on, the user adds
a `dir/WARP.md` file. Currently, we would not detect the new sub-dir
WARP.md file because we wouldn't re-index the repo (because we already
have a rule-file for the repo).

If we think this is the correct solution, we should probably get rid of
the `project_rules` sqlite table.

(cherry picked from commit 3019671)
tungd pushed a commit to tungd/warp that referenced this pull request May 11, 2026
Caching rule-paths for indexed repos is problematic because the entries
could go stale and prevent re-indexing of the repo. For example, suppose
we index a repo that has a root `WARP.md` file. Later on, the user adds
a `dir/WARP.md` file. Currently, we would not detect the new sub-dir
WARP.md file because we wouldn't re-index the repo (because we already
have a rule-file for the repo).

If we think this is the correct solution, we should probably get rid of
the `project_rules` sqlite table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants