aboutsummaryrefslogtreecommitdiff
path: root/src/integration/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/integration/tests.rs')
-rw-r--r--src/integration/tests.rs117
1 files changed, 73 insertions, 44 deletions
diff --git a/src/integration/tests.rs b/src/integration/tests.rs
index 78b728f9..076a22b6 100644
--- a/src/integration/tests.rs
+++ b/src/integration/tests.rs
@@ -2667,8 +2667,7 @@ fn bundled_integration_assets_report_session_refs() {
assert!(PI_EXTENSION_ASSET.contains("pane.report_agent\""));
assert!(PI_EXTENSION_ASSET.contains("pi.on(\"agent_start\""));
assert!(PI_EXTENSION_ASSET.contains("pi.on(\"agent_settled\""));
- assert!(PI_EXTENSION_ASSET.contains("pane.release_agent"));
- assert!(PI_EXTENSION_ASSET.contains("pi.on(\"session_shutdown\""));
+ assert!(!PI_EXTENSION_ASSET.contains("pi.on(\"session_shutdown\""));
assert!(OMP_EXTENSION_ASSET.contains("agent_session_path"));
assert!(OMP_EXTENSION_ASSET.contains("agent_session_id"));
assert!(OMP_EXTENSION_ASSET.contains("ctx?.hasUI !== true"));
@@ -2676,7 +2675,6 @@ fn bundled_integration_assets_report_session_refs() {
assert!(OMP_EXTENSION_ASSET.contains("pane.report_agent\""));
assert!(OMP_EXTENSION_ASSET.contains("pi.on(\"agent_start\""));
assert!(OMP_EXTENSION_ASSET.contains("pi.on(\"agent_end\""));
- assert!(OMP_EXTENSION_ASSET.contains("pane.release_agent"));
assert!(OMP_EXTENSION_ASSET.contains("pi.on(\"session_shutdown\""));
assert!(
CLAUDE_HOOK_ASSET.contains("agent_session_id")
@@ -2718,6 +2716,7 @@ fn bundled_integration_assets_report_session_refs() {
assert!(KIMI_HOOK_ASSET.contains("source\": \"herdr:kimi"));
assert!(KIMI_HOOK_ASSET.contains("agent_session_id"));
assert!(KIMI_HOOK_ASSET.contains("method = \"pane.report_agent_session\""));
+ assert!(KIMI_HOOK_ASSET.contains("params[\"session_start_source\"] = \"startup\""));
assert!(KIMI_HOOK_ASSET.contains("method = \"pane.report_agent\""));
assert!(KIMI_HOOK_ASSET.contains("params[\"state\"] = action"));
assert!(!KIMI_HOOK_ASSET.contains("pane.release_agent"));
@@ -2743,10 +2742,13 @@ fn bundled_integration_assets_report_session_refs() {
assert!(KILO_PLUGIN_ASSET.contains("SOURCE = \"herdr:kilo\""));
assert!(KILO_PLUGIN_ASSET.contains("AGENT = \"kilo\""));
assert!(KILO_PLUGIN_ASSET.contains("pane.report_agent_session"));
+ assert!(KILO_PLUGIN_ASSET.contains("session_start_source: \"startup\""));
assert!(KILO_PLUGIN_ASSET.contains("reportState"));
assert!(!KILO_PLUGIN_ASSET.contains("pane.release_agent"));
assert!(HERMES_PLUGIN_INIT_ASSET.contains("session_id = _session_id(kwargs)"));
assert!(HERMES_PLUGIN_INIT_ASSET.contains("agent_session_id"));
+ assert!(HERMES_PLUGIN_INIT_ASSET.contains("pane.report_agent_session\","));
+ assert!(HERMES_PLUGIN_INIT_ASSET.contains("\"session_start_source\": \"startup\""));
assert!(HERMES_PLUGIN_INIT_ASSET.contains("pane.report_agent\","));
assert!(HERMES_PLUGIN_INIT_ASSET.contains("on_session_end"));
assert!(!HERMES_PLUGIN_INIT_ASSET.contains("on_session_finalize"));
@@ -2768,33 +2770,30 @@ fn bundled_integration_assets_report_session_refs() {
assert!(!CURSOR_HOOK_ASSET.contains("\"state\":"));
assert!(!CURSOR_HOOK_ASSET.contains("pane.release_agent"));
assert!(MASTRACODE_HOOK_ASSET.contains("HERDR_INTEGRATION_ID=mastracode"));
- assert!(MASTRACODE_HOOK_ASSET.contains("HERDR_INTEGRATION_VERSION=1"));
+ assert!(MASTRACODE_HOOK_ASSET.contains("HERDR_INTEGRATION_VERSION=2"));
assert!(MASTRACODE_HOOK_ASSET.contains("session_id"));
assert!(!MASTRACODE_HOOK_ASSET.contains("run_id"));
assert!(MASTRACODE_HOOK_ASSET.contains("agent_session_id"));
+ assert!(MASTRACODE_HOOK_ASSET.contains("pane.report_agent_session"));
+ assert!(MASTRACODE_HOOK_ASSET.contains("session_start_source"));
assert!(MASTRACODE_HOOK_ASSET.contains("pane.report_agent"));
- assert!(MASTRACODE_HOOK_ASSET.contains("pane.release_agent"));
}
#[test]
-fn pi_extension_releases_only_for_quit_session_shutdown() {
- let release_policy = PI_EXTENSION_ASSET
- .find("function shouldReleaseOnSessionShutdown")
- .expect("pi extension should centralize session shutdown release policy");
- let quit_check = PI_EXTENSION_ASSET
- .find("reason === \"quit\"")
- .expect("pi extension should release only for true quit shutdowns");
- let shutdown_handler = PI_EXTENSION_ASSET
- .find("pi.on(\"session_shutdown\", async (event)")
- .expect("pi extension should inspect the session_shutdown event");
- let guarded_release = PI_EXTENSION_ASSET[shutdown_handler..]
- .find("if (shouldReleaseOnSessionShutdown(event))")
- .expect("pi extension should guard releaseAgent by shutdown reason");
-
- assert!(release_policy < shutdown_handler);
- assert!(release_policy < quit_check);
- assert!(quit_check < shutdown_handler);
- assert!(guarded_release > 0);
+fn process_owned_integration_assets_do_not_report_release() {
+ for (name, asset) in [
+ ("pi", PI_EXTENSION_ASSET),
+ ("omp", OMP_EXTENSION_ASSET),
+ ("mastracode", MASTRACODE_HOOK_ASSET),
+ ("kimi", KIMI_HOOK_ASSET),
+ ("kilo", KILO_PLUGIN_ASSET),
+ ("hermes", HERMES_PLUGIN_INIT_ASSET),
+ ] {
+ assert!(
+ !asset.contains("pane.release_agent"),
+ "{name} process exit should own lifecycle release"
+ );
+ }
}
#[test]
@@ -2818,27 +2817,6 @@ fn pi_extension_refreshes_session_ref_before_agent_start_state() {
}
#[test]
-fn omp_extension_releases_only_for_quit_session_shutdown() {
- let release_policy = OMP_EXTENSION_ASSET
- .find("function shouldReleaseOnSessionShutdown")
- .expect("omp extension should centralize session shutdown release policy");
- let quit_check = OMP_EXTENSION_ASSET
- .find("reason === \"quit\"")
- .expect("omp extension should release only for true quit shutdowns");
- let shutdown_handler = OMP_EXTENSION_ASSET
- .find("pi.on(\"session_shutdown\", async (event)")
- .expect("omp extension should inspect the session_shutdown event");
- let guarded_release = OMP_EXTENSION_ASSET[shutdown_handler..]
- .find("if (shouldReleaseOnSessionShutdown(event))")
- .expect("omp extension should guard releaseAgent by shutdown reason");
-
- assert!(release_policy < shutdown_handler);
- assert!(release_policy < quit_check);
- assert!(quit_check < shutdown_handler);
- assert!(guarded_release > 0);
-}
-
-#[test]
fn omp_extension_refreshes_session_ref_before_agent_start_state() {
let agent_start = OMP_EXTENSION_ASSET
.find("pi.on(\"agent_start\", (_event, ctx)")
@@ -3354,6 +3332,57 @@ fn install_mastracode_writes_hook_and_updates_hooks_json() {
}
#[test]
+fn install_mastracode_removes_v1_lifecycle_hooks() {
+ let _lock = integration_env_lock();
+ let base = unique_base();
+ let original_home = std::env::var_os("HOME");
+ let mastracode_dir = base.join(".mastracode");
+ let hook_path = mastracode_dir
+ .join("hooks")
+ .join(MASTRACODE_HOOK_INSTALL_NAME);
+ fs::create_dir_all(&mastracode_dir).unwrap();
+ fs::write(
+ mastracode_dir.join("hooks.json"),
+ serde_json::to_string(&json!({
+ "SessionStart": [{
+ "type": "command",
+ "command": format!("bash '{}' idle", hook_path.display()),
+ "timeout": MASTRACODE_HOOK_TIMEOUT_MS
+ }],
+ "SessionEnd": [{
+ "type": "command",
+ "command": format!("bash '{}' release", hook_path.display()),
+ "timeout": MASTRACODE_HOOK_TIMEOUT_MS
+ }]
+ }))
+ .unwrap(),
+ )
+ .unwrap();
+ std::env::set_var("HOME", &base);
+
+ install_mastracode().unwrap();
+
+ let hooks_file: Value =
+ serde_json::from_str(&fs::read_to_string(mastracode_dir.join("hooks.json")).unwrap())
+ .unwrap();
+ let hooks = hooks_file.as_object().unwrap();
+ assert!(!hooks.contains_key("SessionEnd"));
+ let session_start = hooks["SessionStart"].as_array().unwrap();
+ assert_eq!(session_start.len(), 1);
+ assert!(session_start[0]["command"]
+ .as_str()
+ .unwrap()
+ .ends_with("session"));
+
+ if let Some(home) = original_home {
+ std::env::set_var("HOME", home);
+ } else {
+ std::env::remove_var("HOME");
+ }
+ let _ = fs::remove_dir_all(base);
+}
+
+#[test]
fn install_mastracode_is_idempotent_for_hook_entries() {
let _lock = integration_env_lock();
let base = unique_base();