-
Notifications
You must be signed in to change notification settings - Fork 105
[hyperactor] mesh: define resource::Resource, and mesh::Mesh in terms of it
#1841
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ms of it
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
This was referenced Nov 12, 2025
mariusae
added a commit
that referenced
this pull request
Nov 12, 2025
…ms of it
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
ghstack-source-id: 322844163
Pull Request resolved: #1841
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 12, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)! ghstack-source-id: 322864676
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 12, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 322871728 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 13, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 322923564 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 13, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323030040 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 13, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323103587 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 14, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323206577 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 14, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323217208 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 14, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323217472 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 14, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323321906 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
…Mesh in terms of it"
We formalize a resource controller behavior:
```
/// A trait that bundles a set of types that together define a resource.
pub trait Resource {
/// The spec specification for this resource.
type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
/// The state for this resource.
type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug;
}
// A behavior defining the interface for a mesh controller.
hyperactor::behavior!(
Controller<R: Resource>,
CreateOrUpdate<R::Spec>,
GetState<R::State>,
Stop,
);
```
Anything that is a controller should behave-as a `resource::Controller`.
We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh:
```
impl<M: Mesh> Resource for M {
type Spec = Spec<M::Spec>;
type State = State<M::State>;
}
```
This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert.
Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/)
**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
[ghstack-poisoned]
mariusae
added a commit
that referenced
this pull request
Nov 14, 2025
…ms of it Pull Request resolved: #1841 We formalize a resource controller behavior: ``` /// A trait that bundles a set of types that together define a resource. pub trait Resource { /// The spec specification for this resource. type Spec: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; /// The state for this resource. type State: Named + Serialize + for<'de> Deserialize<'de> + Send + Sync + std::fmt::Debug; } // A behavior defining the interface for a mesh controller. hyperactor::behavior!( Controller<R: Resource>, CreateOrUpdate<R::Spec>, GetState<R::State>, Stop, ); ``` Anything that is a controller should behave-as a `resource::Controller`. We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing `Resource` for any mesh: ``` impl<M: Mesh> Resource for M { type Spec = Spec<M::Spec>; type State = State<M::State>; } ``` This resolves to the same set of bindings and aliases (except we use `resource::Controller<Mesh>` rather than `mesh::Controller<Mesh>`) -- the existing behaviors continue to assert. ghstack-source-id: 323322438 Differential Revision: [D86905562](https://our.internmc.facebook.com/intern/diff/D86905562/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D86905562/)!
|
This pull request has been merged in cc7ccf8. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
resource::Resource, and mesh::Mesh in terms of it #1841We formalize a resource controller behavior:
Anything that is a controller should behave-as a
resource::Controller.We then formalize the mesh controller behavior as a specialization of a resource controller, by implementing
Resourcefor any mesh:This resolves to the same set of bindings and aliases (except we use
resource::Controller<Mesh>rather thanmesh::Controller<Mesh>) -- the existing behaviors continue to assert.Differential Revision: D86905562
NOTE FOR REVIEWERS: This PR has internal Meta-specific changes or comments, please review them on Phabricator!