Skip to content

Support remote project rules through repo metadata standing results#11460

Merged
moirahuang merged 6 commits into
masterfrom
moira/remote-project-rules
Jun 5, 2026
Merged

Support remote project rules through repo metadata standing results#11460
moirahuang merged 6 commits into
masterfrom
moira/remote-project-rules

Conversation

@moirahuang
Copy link
Copy Markdown
Contributor

@moirahuang moirahuang commented May 21, 2026

Description

  • Extend project-rule support to remote sessions while using the same discovery, cache, and lookup flow as local sessions.
  • Read local and remote WARP.md / AGENTS.md paths from RepoMetadataModel standing-query results. ProjectContextModel listens for repository and standing-result changes, then updates its shared path_to_rules cache for either a local repository or a host-qualified remote repository.
  • Keep file I/O at the app boundary: the app-provided read_project_rule_contents function reads local files with async_fs and remote files through RemoteServerManager. ProjectContextModel owns refresh ordering and reconciliation, including per-repository generation checks so an older asynchronous read cannot overwrite a newer refresh.
  • Preserve LocalOrRemotePath throughout rule lookup, agent context, and the Rules UI so identical remote paths on different hosts remain distinct. Global rules and persisted rule records remain local-only.
  • Existing behavior preserved: Manually adding any workspace explicitly requests its initial project-rule indexing before WorkspaceAdded is emitted. If the workspace is a standalone folder that is not already tracked, that indexing call first registers it with RepoMetadataModel; an already-detected repository skips registration but still receives the explicit initial refresh.
  • New behavior in this PR: Initial hydration now discovers rule paths from RepoMetadataModel standing-query results and uses the same shared ProjectContextModel refresh path as later metadata events. Subsequent rule changes refresh from metadata events for both local and remote repositories.
  • Remove the separate remote-rule reconciliation model. Also remove lookup helpers that silently treated Path values as local and replace the stored optional Arc<dyn Fn> reader with a stateless function pointer passed to refresh operations.

Linked Issue

No issue

Testing

Screenshot 2026-06-04 at 4.03.28 PM.png

  • ./script/format
  • cargo check -p ai -p warp --all-targets
  • cargo nextest run -p ai project_context::model::tests — 28 passed
  • cargo nextest run -p warp ai::metadata_project_rules::tests — 3 passed
  • cargo nextest run -p warp ai::blocklist::context_model::tests — 11 passed
  • cargo clippy -p ai -p warp --all-targets -- -D warnings
  • git diff --check
  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-IMPROVEMENT: Remote sessions now discover and apply project rules such as WARP.md and AGENTS.md.

Co-Authored-By: Oz oz-agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label May 21, 2026
Copy link
Copy Markdown
Contributor Author

moirahuang commented May 21, 2026

@moirahuang moirahuang force-pushed the moira/skills branch 2 times, most recently from 7038a4a to 1ba7f81 Compare May 21, 2026 18:56
@moirahuang moirahuang changed the base branch from moira/skills to graphite-base/11460 May 22, 2026 23:45
@moirahuang moirahuang force-pushed the graphite-base/11460 branch from 1ba7f81 to a2f59d3 Compare May 23, 2026 00:39
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from c6a0eaa to c880386 Compare May 23, 2026 00:39
@moirahuang moirahuang changed the base branch from graphite-base/11460 to moira/skills May 23, 2026 00:39
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from c880386 to c4e9f90 Compare May 27, 2026 18:46
@moirahuang moirahuang changed the base branch from moira/skills to master May 27, 2026 18:46
@moirahuang moirahuang changed the base branch from master to graphite-base/11460 May 29, 2026 00:27
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from c4e9f90 to eae0db2 Compare May 29, 2026 19:56
@moirahuang moirahuang changed the base branch from graphite-base/11460 to moira/skills-ui-output-locations May 29, 2026 19:56
@moirahuang moirahuang force-pushed the moira/skills-ui-output-locations branch from 5e6b798 to 477221e Compare May 29, 2026 23:17
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch 2 times, most recently from d4b8589 to 8f15075 Compare May 29, 2026 23:59
@moirahuang moirahuang force-pushed the moira/skills-ui-output-locations branch 3 times, most recently from 556a682 to 085de16 Compare May 30, 2026 01:24
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from 8f15075 to b70ba1c Compare May 30, 2026 01:24
@moirahuang moirahuang force-pushed the moira/skills-ui-output-locations branch from 085de16 to 356c1d5 Compare May 30, 2026 01:50
@graphite-app graphite-app Bot changed the base branch from moira/skills-ui-output-locations to graphite-base/11460 May 30, 2026 01:50
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from b70ba1c to 5969b7d Compare May 30, 2026 02:00
@moirahuang moirahuang changed the title Support remote project rules Unify local and remote project rule discovery May 30, 2026
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from 5a3fa42 to ffe55c1 Compare June 3, 2026 03:05
@moirahuang moirahuang changed the base branch from graphite-base/11460 to moira/remote-project-skill-symlinks June 3, 2026 03:05
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from ffe55c1 to 969dfcf Compare June 3, 2026 04:56
@moirahuang moirahuang changed the title Remote project rules Support remote project rules through repo metadata standing results Jun 3, 2026
@moirahuang moirahuang force-pushed the moira/remote-project-skill-symlinks branch from 87fc220 to abc3a4b Compare June 3, 2026 22:26
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from 969dfcf to 617b784 Compare June 3, 2026 22:26
@moirahuang moirahuang force-pushed the moira/remote-project-skill-symlinks branch from abc3a4b to 7f2c34d Compare June 3, 2026 22:36
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from 617b784 to cee7204 Compare June 3, 2026 22:36
@moirahuang moirahuang force-pushed the moira/remote-project-skill-symlinks branch from 8da6468 to b4f0407 Compare June 4, 2026 04:02
@graphite-app graphite-app Bot changed the base branch from moira/remote-project-skill-symlinks to graphite-base/11460 June 4, 2026 04:30
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from cee7204 to d51751f Compare June 4, 2026 22:03
moirahuang and others added 2 commits June 4, 2026 15:05
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@moirahuang moirahuang force-pushed the graphite-base/11460 branch from b4f0407 to 3fe0616 Compare June 4, 2026 22:07
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from d51751f to 38aa924 Compare June 4, 2026 22:07
@moirahuang moirahuang changed the base branch from graphite-base/11460 to master June 4, 2026 22:07
@moirahuang moirahuang removed the request for review from kevinyang372 June 4, 2026 22:08
Co-Authored-By: Oz <oz-agent@warp.dev>
@moirahuang moirahuang force-pushed the moira/remote-project-rules branch from 38aa924 to 34f37c3 Compare June 4, 2026 22:40

use crate::remote_server::manager::RemoteServerManager;

pub(crate) fn read_project_rule_contents(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aka ProjectRuleContentReader

/// App-provided transport for reading the exact rule paths discovered by repository metadata.
///
/// This remains injected because remote file reads are implemented in the app crate.
pub type ProjectRuleContentReader = fn(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aka read_project_rule_contents which is used to read the actual project rule contents

.get(&project_root)
.cloned()
.unwrap_or_default();
let rule_paths = standing_project_rule_paths(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

converts standing query results into local or remote values

} else {
None
};
let project_rules = current_working_directory_location
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we're already typed, that simplifies this logic here

ProjectRule {
path: file_path.clone(),
// Global rule sources are watched under the local home directory.
path: LocalOrRemotePath::Local(file_path.clone()),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

purposefully keeping local

@moirahuang moirahuang requested a review from kevinyang372 June 4, 2026 23:03
}

#[cfg(feature = "local_fs")]
fn apply_project_rules(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is pulling out the logic from the original callsite

Comment thread app/src/ai/blocklist/context_model.rs
Comment thread app/src/terminal/view/init_project/model.rs
Comment thread crates/ai/src/project_context/model.rs
},
);

let remote_repo_ids = RepoMetadataModel::as_ref(ctx)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will we even have any remote repos on app startup (this is called on initialize_app yeah?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Usually there will not be remote repos on a cold startup, but RepoMetadataModel is registered before ProjectContextModel, and a remote snapshot can arrive before ProjectContextModel subscribes to metadata events. Refreshing already-tracked remote IDs closes that race and hydrates any preexisting snapshots. I added a comment explaining this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

^added this comment

Comment thread crates/ai/src/project_context/model.rs
Comment thread crates/ai/src/project_context/model.rs
@moirahuang moirahuang merged commit 8e1b7e9 into master Jun 5, 2026
26 checks passed
@moirahuang moirahuang deleted the moira/remote-project-rules branch June 5, 2026 06:07
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