Skip to content

feat(pdk): define VCS provider API - #2650

Open
lamalex wants to merge 1 commit into
moonrepo:develop-2.5from
lamalex:vcs/pdk-api
Open

feat(pdk): define VCS provider API#2650
lamalex wants to merge 1 commit into
moonrepo:develop-2.5from
lamalex:vcs/pdk-api

Conversation

@lamalex

@lamalex lamalex commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds the PDK contract for version control system (VCS) provider plugins.
This PR does not load or run VCS plugins.

Changes

  • Add provider registration and metadata types.
  • Add workspace detection types.
  • Add types for a fixed repository observation.
  • Add exact state IDs and movable VCS references.
  • Add current, recorded, and baseline states.
  • Add repository and client metadata.
  • Add working and submission impact requests.
  • Add file change masks and result completeness states.
  • Add optional hook environment types.
  • Add protocol version checks for host and provider compatibility.
  • Add serialization tests for the wire contract.

A provider must keep one fixed observation for each plugin instance. Later queries must use that observation. They must not read newer repository state.

Purpose

This contract lets Moon support VCS providers without hard-coded provider logic.
Later PRs will add the plugin host, provider runtime, Git provider, and Jujutsu provider.

@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 39.97%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 21 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime get_file_hashes[100] 1.8 ms 1.2 ms +46.49%
WallTime get_file_hashes[1000] 6.3 ms 4.7 ms +33.75%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing lamalex:vcs/pdk-api (c126e71) with develop-2.5 (dac2d61)

Open in CodSpeed

Comment thread crates/pdk-api/src/vcs.rs
api_struct!(
/// Opaque provider-defined identity for an exact repository state.
#[serde(transparent)]
pub struct VcsStateId(pub String);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe just type StateId = String since it doesn't provide any new functionality?

Comment thread crates/pdk-api/src/vcs.rs
api_struct!(
/// Opaque provider expression that resolves to a repository state.
#[serde(transparent)]
pub struct VcsReference(pub String);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here.

Comment thread crates/pdk-api/src/vcs.rs
api_struct!(
/// Provider metadata returned by `register_vcs`.
#[serde(default)]
pub struct VcsPluginMetadata {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

RegisterVcsOutput

Comment thread crates/pdk-api/src/vcs.rs
/// establish an observation. User configuration controls whether a plugin
/// is selected at all; there is no second enabled state after observation.
#[serde(default)]
pub struct DetectVcsOutput {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It needs to provide the working/worktree dir, and repository root paths, as VirtualPaths.

Comment thread crates/pdk-api/src/vcs.rs
/// Provider metadata and exact states pinned by `observe_vcs`.
pub struct VcsObservation {
/// Stable provider kind, such as `git` or `jj`.
pub provider: Id,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is called client on the moon side.

Comment thread crates/pdk-api/src/vcs.rs
/// Version of the source-control client used by the provider.
pub client_version: Option<String>,
/// Absolute or virtual path to the repository root.
pub repository_root: String,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All path fields need to be VirtualPath.

Comment thread crates/pdk-api/src/vcs.rs
pub context: MoonContext,
/// Canonical path to Moon's hooks directory, relative to the workspace.
pub hooks_dir: String,
/// Provider-native hook names that Moon intends to install.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

moon is always lowercase

Comment thread crates/pdk-api/src/vcs.rs
/// Keys use `/` separators and must be non-empty, must not contain `.`,
/// `..`, empty components, backslashes, NULs, or names invalid on the
/// host platform, and must not be absolute.
pub changes: BTreeMap<String, VcsChangeMask>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use PathBuf for the key.

Comment thread crates/pdk-api/src/vcs.rs
}
);

api_struct!(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread crates/pdk-api/src/vcs.rs

api_struct!(
/// Provider metadata and exact states pinned by `observe_vcs`.
pub struct VcsObservation {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still a bit confused when the observation triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants