Repository navigation
feat(webui): session-event transport unification and web-app run-completion notifications #8010
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
Open
BenKurrek
wants to merge
28
commits into
main
Choose a base branch
from
feat/session-events-run-completion-notifications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7b6c6e2
docs(design): define web-app run notifications
BenKurrek 64569c3
docs(design): unify WebUI session event transport
BenKurrek 5e3017c
docs(plans): add web-app run-notifications implementation plan
BenKurrek 548806e
feat(contracts): type the product stream selector and event envelopes
BenKurrek babc6ef
feat(webui): ticketed session WebSocket over a shared stream driver
BenKurrek 3afc071
feat(webui): app-root SessionEventClient with SSE fallback and shared…
BenKurrek 539e7be
test(integration): whole-path session-socket streaming evidence
BenKurrek b908bc9
chore(arch): re-pin ironclaw_product_contracts size ceiling for the s…
BenKurrek e1c351c
feat(assistant): run-completion notice store, stream, ingest, operati…
BenKurrek 6d29249
feat(composition,webui): wire run-completion observer, coordinator, a…
BenKurrek 654ee33
feat(outbound): typed RunCompletion push vocabulary and the web-app v…
BenKurrek dbfaf74
feat(assistant,composition): local_os validation and the authorized W…
BenKurrek acdb72b
feat(webui-frontend): run-completion notices, arbitration client, and…
BenKurrek 76605a7
test(assistant): coordinator arbitration tests; carry the grant count…
BenKurrek 93b671d
feat(assistant,composition,webui-frontend): reconcile run completions…
BenKurrek f566fb2
fix(gates): satisfy post-rebase architecture and lint gates
BenKurrek e204c25
fix(ci): panic-baseline safety rationales and CI-tolerant socket test…
BenKurrek cb936bb
fix(tests,gates): order-independent socket test; composition budget r…
BenKurrek cc6eb68
fix,test: address PR #8010 review round
BenKurrek 5815dc6
fix: second review-wave items — grant param struct, retained causes, …
BenKurrek 0bdfbbd
style: crate-qualified path for the cross-module NewGrant reference
BenKurrek d42ff78
Merge remote-tracking branch 'origin/main' into feat/session-events-r…
BenKurrek c046f2b
fix(run-completions,webui): review round 3 — evidence gating, replay …
BenKurrek 0df129d
Merge origin/main into feat/session-events-run-completion-notifications
BenKurrek 6bfa24f
docs(assistant): drop the aliased run_completion_store_error charter …
BenKurrek 41d89df
fix(run-completions,webui): review round 4 — arbitration bound, curso…
BenKurrek 5268187
test(run-completions,webui): cover the stream selector, push fail-clo…
BenKurrek 39dbc75
feat(webui): replace the session WebSocket with one session SSE stream
BenKurrek 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
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
108 changes: 108 additions & 0 deletions
108
crates/app/ironclaw_composition/src/run_completion_observer.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,108 @@ | ||
| //! Journal-commit adapter for run-completion notifications (2026-08-13 | ||
| //! design §5.2, §13). | ||
| //! | ||
| //! Composition owns the kernel-facing half: it filters committed process | ||
| //! batches to terminal successful `Completed` top-level agent-turn | ||
| //! processes with an owner user and a thread scope, then hands typed | ||
| //! observations to the product-owned `RunCompletionIngest`. Keeping the | ||
| //! `ironclaw_processes` vocabulary here preserves the §13 seam — when | ||
| //! `AgentExecution::subscribe` becomes the canonical observation facade, a | ||
| //! new adapter maps onto the same ingest port and nothing downstream moves. | ||
| //! | ||
| //! Retry contract: `Err` is returned only for retryable ingest failures, so | ||
| //! the journal store's durable observer cursor holds position and replays. | ||
| //! Ineligible and permanently-unresolvable runs return `Ok` (sanitized | ||
| //! anomaly metrics only) — one malformed historical run must not wedge the | ||
| //! shared cursor forever. | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use async_trait::async_trait; | ||
| use ironclaw_assistant::run_completions::ingest::{ | ||
| CompletionIngestOutcome, CompletionObservation, RunCompletionIngest, | ||
| }; | ||
| use ironclaw_host_api::resource::SYSTEM_RESERVED_ID; | ||
| use ironclaw_host_api::turn::{TurnRunId, TurnScope}; | ||
| use ironclaw_processes::{ProcessJournalCommit, ProcessJournalCommitObserver, ProcessJournalKind}; | ||
|
|
||
| pub(crate) struct RunCompletionJournalObserver { | ||
| ingest: Arc<RunCompletionIngest>, | ||
| } | ||
|
|
||
| impl RunCompletionJournalObserver { | ||
| pub(crate) fn new(ingest: Arc<RunCompletionIngest>) -> Self { | ||
| Self { ingest } | ||
| } | ||
|
|
||
| fn observation(commit: &ProcessJournalCommit) -> Option<CompletionObservation> { | ||
| // Terminal successful commit only — `Stopped` projects to a | ||
| // cancelled turn kind and never notifies. | ||
| if commit.kind != ProcessJournalKind::Completed { | ||
| return None; | ||
| } | ||
| if commit.state.process_kind != ironclaw_processes::ProcessKind::AgentTurn { | ||
| return None; | ||
| } | ||
| // Top-level only: subagents always carry parent/root process ids. | ||
| if commit.state.parent_process_id.is_some() || commit.state.root_process_id.is_some() { | ||
| return None; | ||
| } | ||
| let owner_user_id = commit.state.owner_user_id.clone()?; | ||
| if owner_user_id.as_str() == SYSTEM_RESERVED_ID | ||
| || commit.state.scope.user_id.as_str() == SYSTEM_RESERVED_ID | ||
| { | ||
| return None; | ||
| } | ||
| // Thread-backed only; system inference and detached maintenance | ||
| // work never carry a thread scope. | ||
| let thread_id = commit.state.scope.thread_id.clone()?; | ||
| let scope = TurnScope::new_with_owner( | ||
| commit.state.scope.tenant_id.clone(), | ||
| commit.state.scope.agent_id.clone(), | ||
| commit.state.scope.project_id.clone(), | ||
| thread_id, | ||
| Some(owner_user_id.clone()), | ||
| ); | ||
| Some(CompletionObservation { | ||
| run_id: TurnRunId::from_uuid(commit.state.process_id.as_uuid()), | ||
| scope, | ||
| owner_user_id, | ||
| // The journal's per-commit occurrence instant when recorded | ||
| // (post-#7700); snapshot creation time for older commits. | ||
| completed_at: commit.occurred_at.unwrap_or(commit.state.created_at), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
|
BenKurrek marked this conversation as resolved.
Resolved
|
||
| impl ProcessJournalCommitObserver for RunCompletionJournalObserver { | ||
| fn process_observer_id(&self) -> &'static str { | ||
| "web-app-run-completion-observer-v1" | ||
| } | ||
|
|
||
| async fn observe_process_commit(&self, commit: ProcessJournalCommit) -> Result<(), String> { | ||
| let Some(observation) = Self::observation(&commit) else { | ||
| return Ok(()); | ||
| }; | ||
| match self.ingest.ingest(observation).await { | ||
| Ok( | ||
| CompletionIngestOutcome::NoticeCreated | ||
| | CompletionIngestOutcome::AlreadyRecorded | ||
| | CompletionIngestOutcome::Ineligible | ||
| | CompletionIngestOutcome::NoFinalReply, | ||
| ) => Ok(()), | ||
| Err(error) if error.retryable => Err(error.to_string()), | ||
| Err(error) => { | ||
| // Terminal ingest failure: advancing is deliberate — the | ||
| // sanitized reason is already recorded, and wedging the | ||
| // shared cursor would starve every later completion. | ||
| tracing::debug!( | ||
| target: "ironclaw::reborn::run_completions", | ||
| error = %error, | ||
| "terminal run-completion ingest failure; advancing observer cursor", | ||
| ); | ||
| Ok(()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
104 changes: 104 additions & 0 deletions
104
crates/app/ironclaw_composition/src/run_completion_push.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,104 @@ | ||
| //! Composition half of run-completion external presentation (2026-08-13 | ||
| //! design §6.1, §7.9): the host-owned web-app enrollment probe the | ||
| //! `local_os` policy consults. | ||
| //! | ||
| //! The probe reads the SAME host-owned delivery registrations the delivery | ||
| //! coordinator resolves for actual pushes, so "Enrolled" here can never | ||
| //! diverge from what a push would use. Browser-instance correlation rides | ||
| //! inside the registration's channel-opaque `document` (interpreted only | ||
| //! where it is used, mirroring the web-app adapter's own parsing rule); | ||
| //! records that predate correlation degrade to profile-level presence. | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use async_trait::async_trait; | ||
| use ironclaw_assistant::run_completions::push::{WebAppEnrollmentProbe, WebAppEnrollmentSnapshot}; | ||
| use ironclaw_assistant::run_completions::store::RunCompletionOwner; | ||
| use ironclaw_host_api::ids::ExtensionId; | ||
| use ironclaw_product_contracts::delivery::{ | ||
| DeliveryRegistrationScope, DeliveryRegistrationService, | ||
| }; | ||
|
|
||
| pub(crate) struct RegistrationEnrollmentProbe { | ||
| registrations: Arc<dyn DeliveryRegistrationService>, | ||
| extension_id: ExtensionId, | ||
| } | ||
|
|
||
| impl RegistrationEnrollmentProbe { | ||
| pub(crate) fn new( | ||
| registrations: Arc<dyn DeliveryRegistrationService>, | ||
| extension_id: ExtensionId, | ||
| ) -> Self { | ||
| Self { | ||
| registrations, | ||
| extension_id, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl WebAppEnrollmentProbe for RegistrationEnrollmentProbe { | ||
| async fn enrollment( | ||
| &self, | ||
| owner: &RunCompletionOwner, | ||
| ) -> Result<WebAppEnrollmentSnapshot, String> { | ||
| let scope = DeliveryRegistrationScope { | ||
| tenant_id: owner.tenant_id.clone(), | ||
| user_id: owner.user_id.clone(), | ||
| extension_id: self.extension_id.clone(), | ||
| }; | ||
| let registrations = self | ||
| .registrations | ||
| .list(&scope) | ||
| .await | ||
| .map_err(|error| error.to_string())?; | ||
| let mut snapshot = WebAppEnrollmentSnapshot::default(); | ||
| for registration in registrations { | ||
| match browser_instance_of(®istration.document) { | ||
| Some(instance_id) => snapshot.instance_ids.push(instance_id), | ||
| None => snapshot.uncorrelated += 1, | ||
| } | ||
| } | ||
| Ok(snapshot) | ||
| } | ||
| } | ||
|
|
||
| /// The optional `browser_instance_id` a correlated enrollment document | ||
| /// carries. A malformed document counts as uncorrelated rather than | ||
| /// failing the probe — the adapter prunes it on its own path. | ||
| fn browser_instance_of(document: &str) -> Option<String> { | ||
| #[derive(serde::Deserialize)] | ||
| struct CorrelatedDocument { | ||
| #[serde(default)] | ||
| browser_instance_id: Option<String>, | ||
| } | ||
| serde_json::from_str::<CorrelatedDocument>(document) | ||
| .ok() | ||
| .and_then(|document| document.browser_instance_id) | ||
| .filter(|id| !id.is_empty() && id.len() <= 128) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
|
|
||
| #[test] | ||
| fn correlated_document_yields_instance_id() { | ||
| let document = r#"{"keys":{"p256dh":"k","auth":"a"},"browser_instance_id":"bi-1"}"#; | ||
| assert_eq!(browser_instance_of(document).as_deref(), Some("bi-1")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn legacy_and_malformed_documents_are_uncorrelated() { | ||
| assert_eq!( | ||
| browser_instance_of(r#"{"keys":{"p256dh":"k","auth":"a"}}"#), | ||
| None | ||
| ); | ||
| assert_eq!(browser_instance_of("not json"), None); | ||
| assert_eq!( | ||
| browser_instance_of(r#"{"browser_instance_id":""}"#), | ||
| None, | ||
| "empty ids never correlate" | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.