Skip to content

Commit 9d76655

Browse files
feat(resource): add runtime protocol SDK and semantic invalidations (#392)
* refactor(resource): extract runtime protocol crate agent-identity: dev3.direct.omp.2cshu64q agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.0.9 agent-runtime: OMP 18.0.9 tooling-profile: dotfiles@b607597 * feat(resource): make resync DING subjects actionable agent-identity: dev3.direct.omp.2cshu64q agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.0.9 agent-runtime: OMP 18.0.9 tooling-profile: dotfiles@b607597 * feat(resource): publish semantic invalidation facts agent-identity: dev3.direct.omp.2cshu64q agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.0.9 agent-runtime: OMP 18.0.9 tooling-profile: dotfiles@b607597 * test(resource): assert structured invalidations agent-identity: dev3.direct.omp.2cshu64q agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.0.9 agent-runtime: OMP 18.0.9 tooling-profile: dotfiles@b607597 * test(resource): assert semantic resync messages agent-identity: dev3.direct.omp.2cshu64q agent-persona: generalist agent-supervisor: unavailable agent-tool: OMP agent-tool-version: 18.0.9 agent-runtime: OMP 18.0.9 tooling-profile: dotfiles@b607597
1 parent f700d1f commit 9d76655

14 files changed

Lines changed: 1861 additions & 786 deletions

File tree

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# `package.version` out of this file as the single source of truth for the
33
# build, and a virtual root has no `[package]` to read.
44
[workspace]
5-
members = ["crates/agent-spec", "crates/st2-wire", "crates/demo-resolver-wasm"]
6-
default-members = [".", "crates/agent-spec", "crates/st2-wire"]
5+
members = ["crates/agent-spec", "crates/st2-resource-protocol", "crates/st2-wire", "crates/demo-resolver-wasm"]
6+
default-members = [".", "crates/agent-spec", "crates/st2-resource-protocol", "crates/st2-wire"]
77

88
[package]
99
name = "st2"
@@ -33,6 +33,7 @@ notify = "8"
3333
serde = { version = "1", features = ["derive"] }
3434
serde_json = "1"
3535
sha2 = "0.10"
36+
st2-resource-protocol = { path = "crates/st2-resource-protocol" }
3637
st2-wire = { path = "crates/st2-wire" }
3738
tempfile = "3"
3839
toml = "0.9"

crates/agent-spec/src/profile.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub const AGENT_GOAL_SCHEME: &str = "dev.schickling.agent-goal";
3636
/// Maximum resolver module bytes admitted by both catalog transactions and the wasm runtime.
3737
pub const DEFAULT_MODULE_LIMIT_BYTES: usize = 16 * 1024 * 1024;
3838
/// Descriptor ABI implemented by this host.
39-
pub const PROFILE_DESCRIPTOR_ABI_VERSION: u32 = 2;
39+
pub const PROFILE_DESCRIPTOR_ABI_VERSION: u32 = 3;
4040
/// Maximum canonical compact JSON bytes accepted for one binding selector.
4141
pub const DEFAULT_SELECTOR_LIMIT_BYTES: usize = 16 * 1024;
4242

@@ -1091,7 +1091,7 @@ mod tests {
10911091
use super::*;
10921092

10931093
const VALID_DESCRIPTOR_JSON: &str = r#"{
1094-
"abiVersion": 2,
1094+
"abiVersion": 3,
10951095
"capabilities": ["resolve", "read", "observe"],
10961096
"selectorSchema": {
10971097
"type": "object",
@@ -1157,7 +1157,7 @@ mod tests {
11571157
}
11581158

11591159
#[test]
1160-
fn valid_v2_descriptor_and_nested_selector_validate() {
1160+
fn valid_v3_descriptor_and_nested_selector_validate() {
11611161
let descriptor = valid_descriptor();
11621162
assert_eq!(descriptor.abi_version, PROFILE_DESCRIPTOR_ABI_VERSION);
11631163
assert_eq!(descriptor.runtime.topology, RuntimeTopology::Shared);
@@ -1171,7 +1171,7 @@ mod tests {
11711171

11721172
#[test]
11731173
fn descriptor_rejects_unknown_abi_capability_and_fields() {
1174-
let unknown_abi = VALID_DESCRIPTOR_JSON.replace("\"abiVersion\": 2", "\"abiVersion\": 9");
1174+
let unknown_abi = VALID_DESCRIPTOR_JSON.replace("\"abiVersion\": 3", "\"abiVersion\": 9");
11751175
assert!(
11761176
ProfileDescriptor::from_json(unknown_abi.as_bytes())
11771177
.unwrap_err()
@@ -1187,7 +1187,7 @@ mod tests {
11871187
);
11881188

11891189
let unknown_field =
1190-
VALID_DESCRIPTOR_JSON.replace("\"abiVersion\": 2,", "\"abiVersion\": 2, \"extra\": true,");
1190+
VALID_DESCRIPTOR_JSON.replace("\"abiVersion\": 3,", "\"abiVersion\": 3, \"extra\": true,");
11911191
assert!(
11921192
ProfileDescriptor::from_json(unknown_field.as_bytes())
11931193
.unwrap_err()

crates/agent-spec/tests/profile_wasm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn descriptor_module(payload: &[u8], reported_len: usize) -> WasmResolver {
7474
}
7575

7676
const VALID_DESCRIPTOR: &str = r#"{
77-
"abiVersion": 2,
77+
"abiVersion": 3,
7878
"capabilities": ["resolve", "read", "observe"],
7979
"selectorSchema": {
8080
"type": "object",
@@ -112,12 +112,12 @@ fn current_rss_bytes() -> u64 {
112112
}
113113

114114
#[test]
115-
fn valid_v2_descriptor_executes_and_resolve_only_module_stays_passive() {
115+
fn valid_v3_descriptor_executes_and_resolve_only_module_stays_passive() {
116116
let descriptor = descriptor_module(VALID_DESCRIPTOR.as_bytes(), VALID_DESCRIPTOR.len())
117117
.describe_once()
118118
.expect("describe call succeeds")
119119
.expect("descriptor is present");
120-
assert_eq!(descriptor.abi_version, 2);
120+
assert_eq!(descriptor.abi_version, 3);
121121

122122
assert!(
123123
WasmResolver::load(Path::new(DEMO_WASM_PATH))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "st2-resource-protocol"
3+
version = "0.1.0"
4+
edition = "2024"
5+
description = "Resource Profile runtime wire types, framing, and codecs shared by st2 hosts and runtimes."
6+
license = "MIT"
7+
8+
[dependencies]
9+
serde = { version = "1", features = ["derive"] }
10+
serde_json = "1"
11+
sha2 = "0.10"

0 commit comments

Comments
 (0)