Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/reborn_group_extensions/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ mod reborn_support;
#[path = "../support/mod.rs"]
mod support;

// Scenario modules, declared alphabetically because rustfmt reorders `mod`
// declarations. The execution order — install → remove → activate — is set by
// the `report.record(...)` call sequence in `extensions_group_e2e` below, not
// by declaration order.
mod scenario_activate_then_active_cross_thread;
mod scenario_install_then_visible_cross_thread;
mod scenario_remove_then_absent_cross_thread;

Expand Down Expand Up @@ -47,5 +52,15 @@ async fn extensions_group_e2e() {
scenario_remove_then_absent_cross_thread::run(&g).await,
);

// Scenario 3: install in thread A → activate in thread B → search in thread C
// confirms the extension reports `installation_phase:active` over the shared
// store. Closes the `extension_activate` int-tier gap. Independent of
// Scenarios 1 & 2: it uses "web-access" (the only credential-free bundled
// extension), untouched by "github"/"notion", so it is self-contained.
report.record(
"activate_then_active_cross_thread",
scenario_activate_then_active_cross_thread::run(&g).await,
);

report.assert_all_passed();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
//! Scenario 3 (HEADLINE): install an extension in thread A, ACTIVATE it in
//! thread B (a DIFFERENT conversation), and confirm thread C (yet another
//! conversation) observes the extension as ACTIVE — not merely installed — over
//! the shared store. This closes the `extension_activate` int-tier gap: install,
//! search, and remove already have cross-thread coverage; activation did not.
//!
//! Uses "web-access" (NOT "github"/"notion") for two reasons. First, it is the
//! only bundled extension that activates WITHOUT credentials / without raising an
//! auth gate, so activation reaches a SUCCESS result (`activated:true`) in this
//! harness rather than blocking on a credential gate. "github" et al. require
//! credentials and would return an auth gate (confirmed by the unit test
//! `local_dev_extension_activate_returns_auth_gate_for_missing_extension_credentials`
//! in `extension_lifecycle_capabilities.rs`). Second, it is untouched by Scenario
//! 1 ("github") and Scenario 2 ("notion"), so a fresh install→activate cycle here
//! observes a real lifecycle transition over the shared store rather than an
//! already-installed/activated no-op.
//!
//! Key behaviours asserted (from `extension_lifecycle.rs::commit_activation` and
//! `search_installation_phase`): a successful activate yields `"activated":true`
//! plus a `visible_capability_ids` array of the now-published capability ids; and
//! `extension_search` renders an ACTIVE extension as `"installation_phase":"active"`
//! versus `"installed"` for an installed-but-not-yet-activated one.
//!
//! Because all three conversations use different conversation IDs but the same
//! `Arc<HostRuntimeCapabilityHarness>`, asserting that thread C sees
//! `installation_phase:active` proves cross-thread ACTIVATION persistence: an
//! activate in thread B is durably visible to thread C, and the extension's
//! capability surface (e.g. `web-access.search`) has come online.

use super::reborn_support::group::{HarnessResult, RebornIntegrationGroup};
use super::reborn_support::reply::RebornScriptedReply;
use serde_json::json;

pub async fn run(g: &RebornIntegrationGroup) -> HarnessResult<()> {
// ── Thread A: installer ─────────────────────────────────────────────────
// Install "web-access" so there is an installed-but-inactive extension to
// activate. The install persists to the shared HostRuntimeCapabilityHarness
// filesystem so the activator thread sees it immediately.
let installer = g
.thread("ext-activate-phase-install")
.script([
RebornScriptedReply::tool_call(
"builtin.extension_install",
json!({"extension_id": "web-access"}),
),
RebornScriptedReply::text("installed"),
])
.build()
.await?;
installer.submit_turn("install web-access").await?;
installer
.assert_tool_invoked("builtin.extension_install")
.await?;
// Confirm the install succeeded: output carries `"installed":true`.
installer
.assert_tool_result_contains("\"installed\":true")
.await?;

// ── Thread B: activator (DIFFERENT conversation, SAME shared store) ──────
// A distinct conversation_id → distinct binding/thread scope, but the same
// `HostRuntimeCapabilityHarness`, so the activator can see and activate the
// installation Thread A just wrote. "web-access" needs no credentials, so
// activation reaches a SUCCESS result instead of an auth gate.
let activator = g
.thread("ext-activate-phase-activate")
.script([
RebornScriptedReply::tool_call(
"builtin.extension_activate",
json!({"extension_id": "web-access"}),
),
RebornScriptedReply::text("activated"),
])
.build()
.await?;
activator.submit_turn("activate web-access").await?;
activator
.assert_tool_invoked("builtin.extension_activate")
.await?;
// Direct effect: activation succeeded → output carries `"activated":true`.
// Assert the VALUE, not just the key, so an `activated:false` / auth-gate
// outcome cannot satisfy this.
activator
.assert_tool_result_contains("\"activated\":true")
.await?;
// Capability surfaces: the activate payload's `visible_capability_ids` array
// carries the now-published capability ids. `web-access.search` coming online
// is the observable proof that activation published the extension's tool
// surface (mere install does NOT publish capabilities).
activator
.assert_tool_result_contains(r#""web-access.search""#)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Verify the post-activation tool surface

This assertion only checks the extension_activate result payload for web-access.search; that field is derived from the package's visible_capability_ids, so it can still be present even if activation updates the lifecycle state but fails to publish the tool into the model-visible surface for later turns. In that scenario Thread C would still see installation_phase:"active", so the scenario would pass while the advertised capability is not actually available. Please assert the post-activation surface itself, e.g. by having a later turn verify/invoke web-access.search or otherwise inspect the advertised provider tools after activation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not valid for this code path. In commit_activation (extension_lifecycle.rs:552-579), active_extensions.publish(&active_package) runs before the success payload is built; if publish fails it rolls back (disable + restore previous activation state) and returns Err. So activated:true and visible_capability_ids are only ever emitted after publish succeeds — the failure mode described here (lifecycle state advanced but tool not published) short-circuits to an error and never produces this payload. The web-access.search assertion therefore already gates on publish success.

Asserting later-turn invocability of the published tool would test the publish→model-visible-surface wiring end-to-end, which is a distinct invariant from the cross-thread activation persistence this scenario covers (and is out of scope for this coverage PR). Keeping the assertion as-is.

.await?;

// ── Thread C: viewer (DIFFERENT conversation, SAME shared store) ─────────
// A third distinct conversation_id over the Arc-cloned store. Searching for
// "web-access" must now report it as ACTIVE — observing Thread B's activation
// across threads.
let viewer = g
.thread("ext-activate-phase-viewer")
.script([
RebornScriptedReply::tool_call(
"builtin.extension_search",
json!({"query": "web-access"}),
),
RebornScriptedReply::text("searched"),
])
.build()
.await?;
viewer
.submit_turn("search web-access after activation")
.await?;
viewer
.assert_tool_invoked("builtin.extension_search")
.await?;
// Cross-thread activation persistence: the search result carries
// `installation_phase:"active"` only because Thread B's activation enabled the
// installation in the shared store. Assert the VALUE so a still-`installed`
// phase cannot satisfy this.
viewer
.assert_tool_result_contains(r#""installation_phase":"active""#)
.await?;

// Discriminating guard: an extension that was installed but NOT activated
// renders `installation_phase:"installed"`. Its ABSENCE here proves the phase
// genuinely advanced past install — a no-op activate (leaving the extension
// inactive) would surface `"installed"` and trip this guard.
if viewer
.assert_tool_result_contains(r#""installation_phase":"installed""#)
.await
.is_ok()
{
return Err(
"web-access still shows installation_phase:installed after a cross-thread activate; \
builtin.extension_activate did not advance the lifecycle through the shared store"
.into(),
);
}

// Non-vacuity guard: "web-access" must still appear in the catalog search
// result, proving the search actually ran and returned a catalog entry. The
// presence of `installation_phase:active` is therefore meaningful — not a
// symptom of an empty or errored result.
if viewer
.assert_tool_result_contains("\"web-access\"")
.await
.is_err()
{
return Err(
"non-vacuity guard failed: web-access catalog entry must appear in search results \
after activation; the active-phase assertion would otherwise be vacuous"
.into(),
);
}

Ok(())
}
Loading