Repository navigation
test(reborn): add extension_activate int-tier scenario (T0-EXTACT) #5433
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2690e00
test(reborn): add extension_activate int-tier scenario (T0-EXTACT)
henrypark133 7e96b50
style(reborn): fmt + clippy for extension_activate scenario (T0-EXTACT)
henrypark133 e54f3d4
style(reborn): match module decl order to comment (T0-EXTACT)
henrypark133 c4cd41f
fix(reborn): correct module-order comment instead of reordering (T0-E…
henrypark133 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
155 changes: 155 additions & 0 deletions
155
tests/reborn_group_extensions/scenario_activate_then_active_cross_thread.rs
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
| 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""#) | ||
| .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(()) | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assertion only checks the
extension_activateresult payload forweb-access.search; that field is derived from the package'svisible_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 seeinstallation_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/invokeweb-access.searchor otherwise inspect the advertised provider tools after activation.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
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 returnsErr. Soactivated:trueandvisible_capability_idsare 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. Theweb-access.searchassertion 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.