You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chinawch007 (via GitHub)" <gi...@apache.org> on 2026/09/18 17:31:32 UTC

[PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

chinawch007 opened a new pull request, #5495:
URL: https://github.com/apache/maka/pull/5495

   ## Summary
   
   Keep the parent Swarm session's sidebar indicator active after it yields to folded child agents, through queued supervisor work and final summary generation. Show attention when child work needs user input or is blocked, and clear the indicator once work settles.
   
   Project Host-owned background activity into Owner and Guest session catalogs without changing completed Turns or inventing running Turn IDs. Reject stale refresh results, recover failed Guest refreshes, and prevent failed terminal projections from leaving a stale running indicator.
   
   Fixes #5334
   
   ## Verification
   
   - Clean root build, lint, format check, typecheck, and knip for Desktop and UI: passed. The six contribution-guide gates were also verified with the pinned npm 11.19.0.
   - Protocol compatibility guard against `upstream/main`: passed (164 → 165).
   - Full workspace tests: Runtime 3,550 passed (14 skipped), Desktop 2,777 passed, Core 887 passed, and UI 527 passed. Host 1,990 passed (12 skipped). Total: 9,731 passed, 26 skipped.
   - Host full-suite command: `node --test --test-concurrency=4 --test-timeout=300000 'dist/**/*.test.js'` from `packages/runtime-host`. This final run passed after timeouts in the initial default-parallelism run. The two production Swarm/Agent Graph scenarios also passed separately.
   - Regression coverage includes three-child yield/resume/final-summary flow, pending interactions, reconnects, failed terminal projections, and catalog invalidations during in-flight reads. The four P2 regression cases were confirmed to fail without their fixes.
   - UI evidence uses the real sidebar component with deterministic data: a completed parent Turn and three running, folded children. The before case uses the previous catalog shape; the after case receives Host-owned background activity.
   
   <img width="1380" height="770" alt="image" src="https://github.com/user-attachments/assets/410e2a96-47d9-41c9-b80b-00a99ea02529" />
   <img width="1380" height="770" alt="image" src="https://github.com/user-attachments/assets/9f5a1c34-b761-4fef-ab80-3d4f63a902cd" />
   
   
   The full Desktop Electron E2E suite, live-provider checks, and packaged cross-platform checks were not run locally.
   
   ## Breaking change
   
   Bump the Runtime Host compatibility epoch from 164 to 165. Older closed catalog decoders reject the new field, so Hosts and Clients must use matching versions.
   
   ## AI use
   
   Select exactly one:
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: Codex — implementation, regression tests, code review and fixes, validation, and PR preparation. All three commits include `Generated-by: Codex`; retain the trailer when squash-merging.
   
   ## Checklist
   
   - [x] Tests cover the change and fail without it
   - [x] Lint, format, typecheck and the affected suites pass locally
   
   Does this PR entail a change in behavior?
   
   - [x] Yes — described under Summary above
   - [ ] No
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5495:
URL: https://github.com/apache/maka/pull/5495#discussion_r4116989716


##########
apps/desktop/src/main/session-local-service.ts:
##########
@@ -285,28 +335,43 @@ export class DesktopSessionLocalService {
       return;
     const client = target.client;
     const revision = this.store.revision;
-    const task = client
-      .listSessions()
+    const invalidationVersion = connection.invalidationVersion;
+    let freshnessRevoked = false;
+    const task = abortable(() => client.listSessions(), connection.controller.signal)
       .then((sessions) => {
-        if (!this.#current(target)) return;
+        if (!this.#currentCatalogConnection(target, connection)) return;
+        if (connection.invalidationVersion !== invalidationVersion) return;

Review Comment:
   P2: any invalidation during the read discards the whole result, and `finally` re-reads. Under a steady stream of Swarm child events, with a round trip longer than the gap between events, this never lands, so the sidebar stays cached and loses the running indicator during delegated work. Consider saving the result when it is fresher than the current cached one and then re-reading, or bounding the retries.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5495:
URL: https://github.com/apache/maka/pull/5495#discussion_r4221992845


##########
packages/runtime-host/src/protocol/index.ts:
##########
@@ -104,7 +104,10 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1 as const;
 export const RUNTIME_HOST_PROTOCOL_VERSION = 0 as const;
 // Increment when the same protocol version no longer guarantees safe Client-Host
 // interoperability. Mismatches are rejected before domain commands are admitted.
-export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 206 as const;
+export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 208 as const;

Review Comment:
   **P3:** This conflicts with main, which is already at 208 (#5709), and open #3700 claims 207. `protocol-epoch-check --base origin/main` fails. Neither field has landed, so please collapse 207 and 208 into one bump at the next free epoch after rebasing. 209, 210 and 211 are claimed or suggested by #5548, #5969 and #5980, so that is 212 if those hold. Keep one history line covering both `backgroundActivity` and `backgroundActivityVersion`.



##########
packages/runtime-host/src/server/session-background-activity.ts:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import type {
+  SessionBackgroundActivity,
+  SessionBackgroundActivitySnapshot,
+} from '@maka/core/session';
+
+/**
+ * One read projection for initial catalog queries and subsequent invalidations.
+ * The execution coordinators own the facts; this only remembers the last
+ * published value so handoffs between Graph and supervisor do not churn lists.
+ * Its lifetime is one Host epoch and it never persists a running flag.
+ */
+export class SessionBackgroundActivityProjection {
+  readonly #published = new Map<string, SessionBackgroundActivity>();
+  #revision = 0;
+
+  constructor(
+    private readonly sources: {
+      hostGeneration: string;
+      graph(sessionId: string): SessionBackgroundActivity;
+      supervisor(sessionId: string): SessionBackgroundActivity;
+      publish(sessionId: string): void;
+    },
+  ) {}
+
+  read(sessionId: string): SessionBackgroundActivity {
+    const graph = this.sources.graph(sessionId);
+    const supervisor = this.sources.supervisor(sessionId);
+    if (graph === 'waiting_for_user' || supervisor === 'waiting_for_user')
+      return 'waiting_for_user';
+    // A supervisor may be handling a failed child without needing the user.
+    if (graph === 'running' || supervisor === 'running') return 'running';
+    if (graph === 'blocked' || supervisor === 'blocked') return 'blocked';
+    return 'idle';
+  }
+
+  snapshot(sessionId: string): SessionBackgroundActivitySnapshot {
+    return {
+      backgroundActivity: this.read(sessionId),
+      backgroundActivityVersion: {
+        hostGeneration: this.sources.hostGeneration,
+        revision: this.#revision,
+      },
+    };
+  }
+
+  changed(sessionId: string): void {
+    const next = this.read(sessionId);
+    const previous = this.#published.get(sessionId) ?? 'idle';
+    if (previous === next) return;
+    // One Host-wide clock orders observations even after an idle Session is
+    // removed from the deduplication map, without retaining per-Session clocks.
+    this.#revision += 1;

Review Comment:
   **P3 (observation):** This counter is Host-wide and is published in the shared (Guest) catalog projection. A Guest can therefore watch it advance for activity changes in Sessions it cannot see. The leak is small. A per-Session revision, or one kept only while a Session is non-idle, would avoid it.



##########
apps/desktop/src/main/session-local-service.ts:
##########
@@ -255,60 +286,122 @@ export class DesktopSessionLocalService {
       .targets()
       .filter((target) => !this.#revoked.has(target.partition))
       .map((target) => {
+        const connection = this.#observeCatalogConnection(target);
         const fresh = this.#catalogFresh.get(target.partition);
-        const authoritative = !!target.client && fresh?.epoch === target.client.hostEpoch;
+        const authoritative = !this.#closed && !!target.client && fresh?.connection === connection;
         const sessions = this.store
           .sessions(target.partition)
           .map((session) =>
             this.store.creation(target.partition, session.id)
               ? { ...session, localState: 'pending' as const }
               : authoritative
                 ? session
-                : { ...session, runningTurnIds: undefined, localState: 'cached' as const },
+                : { ...session, runningTurnIds: undefined, backgroundActivity: undefined, backgroundActivityVersion: undefined, localState: 'cached' as const },
           );
         if (
           target.client &&
-          (!fresh || fresh.epoch !== target.client.hostEpoch || Date.now() - fresh.at > 5000)
+          (!authoritative || !fresh ||
+            fresh.invalidationVersion !== connection.invalidationVersion ||
+            Date.now() - fresh.at > 5000)
         )
-          this.#refreshCatalog(target);
+          this.#refreshCatalog(target, connection);
         return { scope: target.scope, sessions, authoritative };
       });
   }
 
-  #refreshCatalog(target: DesktopSessionLocalTarget): void {
-    if (
-      !target.client ||
-      this.#catalogTasks.has(target.partition) ||
-      this.#catalogTasks.size >= 2 ||
-      this.#closed
-    )
-      return;
-    const client = target.client;
+  #observeCatalogConnection(target: DesktopSessionLocalTarget): SessionCatalogConnection {
+    const previous = this.#catalogConnections.get(target.partition);
+    if (previous && previous.client === target.client &&
+      previous.hostEpoch === target.client?.hostEpoch &&
+      previous.targetEpoch === target.scope.targetEpoch) return previous;
+    const connection: SessionCatalogConnection = {
+      client: target.client,
+      hostEpoch: target.client?.hostEpoch,
+      targetEpoch: target.scope.targetEpoch,
+      controller: new AbortController(),
+      invalidationVersion: 0,
+    };
+    this.#catalogConnections.set(target.partition, connection);
+    this.#catalogFresh.delete(target.partition);
+    // A retired read must not occupy a current connection's catalog slot.
+    // Its finally handler also checks task identity before releasing that slot.
+    this.#catalogTasks.delete(target.partition);
+    this.#catalogPending.delete(target.partition);
+    previous?.controller.abort(new Error('Owner Session catalog connection changed'));
+    return connection;
+  }
+
+  #currentCatalogConnection(target: DesktopSessionLocalTarget, connection: SessionCatalogConnection): boolean {
+    if (this.#closed || this.#revoked.has(target.partition) || connection.controller.signal.aborted)
+      return false;
+    const current = this.deps.targets().find(({ partition }) => partition === target.partition);
+    return !!current?.client && this.#observeCatalogConnection(current) === connection;
+  }
+
+  #refreshCatalog(target: DesktopSessionLocalTarget, connection: SessionCatalogConnection): void {
+    if (!target.client || this.#closed || this.#catalogTasks.has(target.partition)) return;
+    // Map insertion order gives waiting partitions a turn before a busy
+    // partition's next trailing read. Repeated requests share one queue entry.
+    this.#catalogPending.set(target.partition, { target, connection });
+    this.#drainCatalogRefreshes();
+  }
+
+  #drainCatalogRefreshes(): void {
+    for (const [partition, { target, connection }] of this.#catalogPending) {
+      if (this.#closed || this.#catalogTasks.size >= 2) return;
+      this.#catalogPending.delete(partition);
+      if (!this.#currentCatalogConnection(target, connection) || this.#catalogTasks.has(partition))
+        continue;
+      this.#startCatalogRefresh(target, connection);
+    }
+  }
+
+  #startCatalogRefresh(target: DesktopSessionLocalTarget, connection: SessionCatalogConnection): void {
+    const client = target.client!;
     const revision = this.store.revision;
-    const task = client
-      .listSessions()
+    const invalidationVersion = connection.invalidationVersion;
+    let freshnessRevoked = false;
+    let locallyInvalidated = false;
+    const task = abortable(() => client.listSessions(), connection.controller.signal)
       .then((sessions) => {
-        if (!this.#current(target)) return;
+        if (!this.#currentCatalogConnection(target, connection)) return;
         // A late catalog cannot erase a Session created/removed while it read.
-        if (this.store.revision !== revision) return;
+        if (this.store.revision !== revision) {

Review Comment:
   **P3 (unreproduced):** `store.revision` is global, and every partition's `saveCatalog` bumps it. A partition with frequent invalidations and fast reads can therefore keep fencing a slower partition's read in flight. The slow partition requeues each time and keeps its last authoritative activity until the busy one goes quiet. The requeue is already better than dropping the read. A per-partition revision would scope the fence to the local create/remove race it is meant to guard.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-5894709929

   Thanks for the detailed review. I reproduced the P2 and have addressed it in [a889be974](https://github.com/apache/maka/pull/5495/commits/a889be974ef8004b4a6e1afea89622f0952e170a).
   
   Ordinary Host notifications now mark the Owner catalog as needing refresh without revoking the last successful observation from the current connection. A successful full-catalog read is published even when more notifications arrived during the read; those notifications coalesce into one trailing read. This allows progress under sustained invalidation and convergence once the notifications stop. It deliberately allows an observation to lag a concurrent Host change while the next refresh is pending.
   
   Connection/Host-generation changes, authority removal, and local-store mutation fences remain in place. Read failures still revoke live activity and notify the live-to-cached transition, including when a trailing retry is needed. The earlier failed-TTL-refresh fix is preserved.
   
   The regression test injects multiple invalidations during each of eight consecutive reads, checks that every successful observation is published, and checks that refreshing stops after the final clean read. It fails on the previous implementation. Tests also cover coalescing, failure notification, local deletion protection, connection replacement and TTL failure/recovery.
   
   For the five non-blocking P3 items, I would prefer to keep them outside this update:
   
   - **Refresh concurrency cap:** This is a real limitation of the existing Owner catalog scheduler and predates this PR. A fair pending-partition queue should be a separate scheduler change. This P2 fix does not address starvation caused by the global cap.
   - **Restart recovery:** The wake recovery path processes unsettled wakes before retryable wakes, including the waiting-permission case. Interaction restart recovery also settles orphaned pending requests and refreshes the activity projection. Losing the in-memory counts alone therefore does not establish that a still-valid wait is permanently lost. I have not verified every restart timing window, so I am leaving a broader recovery audit out of this indicator change.
   - **Needs-attention recovery/UX:** The indicator projects existing execution conditions. Coordinator exceptions have existing error/drain handling, and graph state has reconciliation paths; introducing a separate UI action for every failure would expand this into a recovery-workflow change. I am deferring that work rather than claiming every blocked state already has a sufficient user-facing exit.
   - **Shadow graph state:** I agree that the cached activity projection adds maintenance cost. The current tests exercise dispatch, completion, pending interactions and recovery, and the review identifies no current divergence. I would keep consolidation with the graph read model as a separate refactor instead of combining it with the refresh-liveness fix.
   - **Independent background-activity ordering:** Agreed that neither the Session revision nor the run epoch independently orders this field. The P2 fix provides progress for full Owner refreshes; it does not establish a total order across targeted `getSession` and full-list observations. I am not relying on an assertion that the Desktop main process serializes all of those paths. Adding an activity revision and defining its merge semantics across these paths is deferred as a separate catalog-contract change. The status may transiently lag; this update does not claim to eliminate every cross-path regression.
   
   I also rebased onto current `main`, retained its supervisor-wake exhaustion behavior, and advanced the existing protocol compatibility epoch from 198 to 199 for this PR's activity field. This does not add an independent activity-ordering version.
   
   Validation: 302 relevant Desktop, Runtime and Runtime Host tests passed on the final build. `npm run build`, `npm run typecheck`, `npm run lint`, `npm run format:check`, both Desktop/UI `knip` checks, and the protocol epoch guard passed. GUI E2E was not run; the Electron binary download failed in this environment.
   
   This update and reply were prepared with OpenAI Codex; the implementation commits include `Generated-by` attribution.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-5808741694

   Thanks for catching this. Fixed in commit 0326988cb.
   When a catalog refresh fails on the current Owner connection, we now revoke its freshness and notify consumers to reload the cached state. The catalog then returns authoritative: false and localState: 'cached', with backgroundActivity and runningTurnIds cleared from the returned rows.
   We retain the previous state while a refresh is pending and emit the downgrade notification only once, preventing repeated failures from creating a notification/retry loop. A successful retry restores authoritative state.
   Added regression tests for both running and waiting-for-user activity, covering repeated failures and successful recovery. Both tests failed before the fix and pass afterward. All 395 focused tests passed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-5905184801

   Thanks for taking another look. For context, these points have already been discussed in the earlier review rounds, and I’ve replied to them individually:
   - The stale activity after a failed Owner catalog refresh was fixed and documented in [this reply](https://github.com/apache/maka/pull/5495#issuecomment-5808741694).
   - The merge conflicts and presentation-read failure isolation were addressed in [this reply](https://github.com/apache/maka/pull/5495#issuecomment-5859519440). That reply also explains why I retained the intermediate running publication after a permission response.
   - The sustained-invalidation P2 was fixed in the subsequent update. [This reply](https://github.com/apache/maka/pull/5495#issuecomment-5894709929) also addresses all five non-blocking P3 observations individually, including the remaining limitations and why I’m keeping the broader changes outside this PR.
   I’ve now rebased onto main at 0aa2707b5, resolved the conflicts, and retained all previously reviewed fixes and regression tests. The current head is 88ff409fa, and the PR description now reflects the correct compatibility epoch, 199 → 200, and the latest validation results.
   Local checks passed within the documented coverage limits; CI for the new head is still running. If there is a remaining concern that the earlier replies do not address, please point me to the specific scenario so I can follow up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #5495:
URL: https://github.com/apache/maka/pull/5495#discussion_r4144025535


##########
packages/runtime-host/src/protocol/index.ts:
##########
@@ -104,7 +104,8 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1 as const;
 export const RUNTIME_HOST_PROTOCOL_VERSION = 0 as const;
 // Increment when the same protocol version no longer guarantees safe Client-Host
 // interoperability. Mismatches are rejected before domain commands are admitted.
-export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 199 as const;
+export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 200 as const;

Review Comment:
   [P1] Current `main` already assigns epoch 200 to Agent Graph operator output, but this branch assigns 200 to a different strict catalog field. The merge conflicts here. Keeping 200 after conflict resolution would advertise incompatible wire contracts under the same handshake epoch. Please rebase and advance beyond the current base epoch, preserving both compatibility notes, then run the merge-result epoch guard.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-6063702170

   Thanks for the follow-up review. The refresh scheduling and activity ordering issues are addressed in [`5fb3881b0`](https://github.com/apache/maka/commit/5fb3881b0cd7c2be366fc913ee854ab0f3020576), after rebasing onto `main` at `49e01b157`.
   
   **Refresh concurrency and stale authority**
   
   I reproduced the stale-authority concern with a third Owner partition while two catalog reads occupied the available slots. The existing trailing path releases its own slot before synchronously requesting another read, so that was not the dropped-request case I could reproduce. A new refresh for another partition could be dropped, leaving its last activity authoritative until another renderer read.
   
   Refreshes now enter a deduplicated FIFO queue while retaining the two-read limit. A released slot admits a waiting partition automatically, ahead of a busy partition's next trailing read. Reads fenced by a local store revision change also requeue; queued entries are retired with their connection or authority. This preserves successful observations during continuous invalidation and convergence after events stop.
   
   Regression tests cover the stale third partition without an extra renderer read, fairness against trailing work, bounded concurrency, local mutation fences, and connection replacement.
   
   **Independent activity ordering**
   
   This follow-up also addresses the previously deferred ordering issue. The Host now projects `backgroundActivityVersion` with its process generation and a monotonic activity revision. The renderer merges activity independently of the Session revision and Turn epoch, so a late list or targeted-row response cannot replace a newer `idle` with an older `running`, or discard a newer rename or Turn update.
   
   Both Owner and Guest paths carry the version and strip it with cached activity. Revisions are compared only within one Host generation; a restarted Host can start from a lower counter. Tests cover both response orders, independent metadata/Turn updates, cache downgrade, and generation changes.
   
   The seven new queue/order regression scenarios all fail against the implementation before this follow-up and pass after it.
   
   **Compatibility and the other observations**
   
   Current main has advanced to epoch 206. This branch now uses 208, preserving the main history and distinguishing the activity field from the subsequent ordering-field change. The guard passes against current main (206 → 208) and for the follow-up commit (207 → 208). The merge result will still need the guard against whatever main contains at merge time, including changes from #5753.
   
   I retained the permission-response `running` transition because it represents asynchronous reconciliation; aggregate activity publication is already deduplicated. The restart path also processes persisted `waiting_permission` wakes before retryable delivery, so loss of the in-memory attention map alone does not establish a permanently lost wait. This update leaves those semantics intact rather than suppressing the transition or adding a second recovery mechanism.
   
   **Validation**
   
   Full build, workspace typecheck, lint, format check, both Desktop/UI knip checks, and the protocol guard passed. Desktop passed 3,337 tests, excluding the two packaged Electron cryptography tests because the binary was unavailable; UI passed 713. All 261 targeted Runtime and Runtime Host tests passed, including the production three-child Swarm yield/resume/final-summary case. Three UDS startup tests timed out during parallel execution and passed when rerun in isolation.
   
   Renderer architecture, build freshness, Windows test inventory, E2E budget and diff checks passed. GUI E2E, packaged cross-platform checks, live cross-machine Guest transport and the full Runtime/Runtime Host suites were not run in this update.
   
   This implementation and reply were prepared with OpenAI Codex; the commit includes `Generated-by` attribution.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-5857219994

   Freshness update after the review above: `main` advanced immediately afterward to `fffc19fb5ead391e5c432c9d9961a50e20b22785` via #5741. The PR head is still `cf2ab03302db899788c8453ff2cbe726c4be2cc9`, but a fresh merge-tree now has content conflicts in `packages/core/src/session.ts`, Runtime Host catalog protocol/coordinator files, and adjacent catalog tests. The code findings in the exact-head review remain bound to that head, but the PR is not currently merge-ready; resolve the conflicts and revalidate the resulting head.
   
   > **Automated review notice:** This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 merged PR #5495:
URL: https://github.com/apache/maka/pull/5495


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-6068014984

   Thanks for the follow-up review. All actionable findings in this review have now been addressed.
   As you confirmed, fa11c8f1c fixes the epoch conflict, cross-partition refresh starvation, and Guest-visible activity-version leakage. The remaining description issue is also resolved: it now references head fa11c8f1c, base 74094c63, and the compatibility change 208 → 212, with a reminder to rerun the epoch guard against main at merge time.
   The test check for this exact head has also passed. Thanks for checking the fixes and validating the regression tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "chinawch007 (via GitHub)" <gi...@apache.org>.
chinawch007 commented on PR #5495:
URL: https://github.com/apache/maka/pull/5495#issuecomment-5859519440

   Thanks for the detailed review. We addressed **P1 and P2** in [`01c614fe2`](https://github.com/apache/maka/pull/5495/commits/01c614fe25177b8fa897300f066e7311e603534e). For **P3**, we reviewed the state transitions and notification path, but do not think suppressing the intermediate publication is appropriate as proposed.
   
   ### P1 — Merge conflicts and outdated compatibility information
   
   We merged `main` at `542f04a4f` and resolved the conflicts in the Session model, catalog coordinator, protocol epoch, and related tests.
   
   The resolution preserves both sets of changes: main’s live-run epoch/Host-generation fields and this PR’s Host-owned background-activity projection. Since the merged main already uses compatibility epoch **196**, we advanced this PR to **197**, rather than retaining the previous branch value of 193.
   
   We also updated the PR description to remove the stale **164 → 165** information and distinguish current validation from earlier results. The protocol compatibility guard passes against the merged main, and GitHub now reports the PR as conflict-free.
   
   ### P2 — Isolate presentation failures from canonical interaction processing
   
   Agreed. The newly added activity refresh could reject before canonical continuity refresh and WorkHub notification ran. On answer-processing paths, that could also prevent the subsequent application of an already-committed answer.
   
   We fixed this at the `SessionInteractionActivityProjection` boundary:
   
   - Refresh failures are caught and reported, rather than propagated into canonical interaction processing.
   - Cached counts for the affected Session are invalidated on failure. Reads return **unknown**, rather than retaining stale pending-interaction counts or incorrectly reporting zero.
   - The cache invalidation notifies the activity observer when a cached projection actually existed; repeated read failures do not repeatedly invalidate an already-unknown projection.
   - Observer and diagnostic callback failures are also isolated.
   - A later successful refresh restores the projection.
   
   The refresh remains awaited under the existing Session admission, preserving its ordering on the successful path. We did not move it into an untracked asynchronous operation or add a broad catch around canonical processing itself.
   
   Three new regression tests cover failures from each of the two pending-request stores, plus observer/diagnostic failures. They verify that canonical publication, WorkHub notification, and answer application continue, and cover cache invalidation, repeated failures, and recovery. **All three fail against the pre-fix implementation and pass with the fix.**
   
   ### P3 — Retain the intermediate `running` publication
   
   We agree that unnecessary catalog notifications are worth avoiding. However, we do not currently see sufficient evidence that this transition is incorrect, for the following reasons.
   
   **1. `running` represents real work after the permission response.**
   
   After the user answers, the coordinator reconciles the wake: it acquires the activity lease, inspects unsettled attempts, and may schedule a supervisor retry. That work is asynchronous and is not guaranteed to complete immediately.
   
   A transition such as:
   
   ```text
   waiting_for_user → running → idle
   ```
   
   can therefore accurately mean “waiting for an answer → processing/resuming after the answer → finished.” Its short duration alone does not make it a spurious state.
   
   **2. Suppressing the publication can leave clients displaying stale attention.**
   
   If the coordinator changes to `running` internally but does not publish that change, catalog-only clients may continue displaying `waiting_for_user` until a later notification, even though the user has already answered and reconciliation is underway.
   
   Keeping the internal attention state unchanged instead would introduce a different problem: it would mask actual in-flight work. Either approach needs a more specific justification than eliminating an intermediate transition.
   
   **3. The notification path already has two levels of deduplication.**
   
   The supervisor publishes only when its activity value changes. The Host’s combined graph/supervisor projection then publishes a catalog invalidation only when the **aggregate** activity changes.
   
   For example, if graph activity remains `waiting_for_user`, a supervisor transition to `running` does not change the aggregate projection and does not generate a catalog invalidation through this path. Similarly, a permission response received while the effective state is already `running` need not produce a new running-state notification.
   
   Consequently, a permission response does not necessarily produce every state transition or client notification described in P3.
   
   **4. This is an intentional existing contract, not merely incidental behavior.**
   
   The parked-wake retry regression explicitly checks that activity becomes `running` immediately after `notifyPermissionResponse()`, then returns to `idle` after processing completes. That test is not, by itself, proof that the design cannot improve, but it documents the intended visibility of reconciliation work.
   
   For these reasons, **we have left P3 unchanged**. If there is a concrete scenario demonstrating redundant aggregate catalog invalidations or visible flicker, we would be happy to evaluate targeted notification coalescing while preserving the visibility of legitimate running work.
   
   ### Validation
   
   The [CI run for the exact updated head](https://github.com/apache/maka/actions/runs/36346269197) completed successfully, including workspace and Runtime Host tests, Desktop E2E, Storybook smoke, transcript geometry checks, and CLI release-candidate validation. Local rerun results and their caveats are documented separately in the PR description.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(desktop): preserve Swarm session activity during delegated work [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #5495:
URL: https://github.com/apache/maka/pull/5495#discussion_r4152853604


##########
packages/runtime-host/src/protocol/index.ts:
##########
@@ -104,7 +104,8 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1 as const;
 export const RUNTIME_HOST_PROTOCOL_VERSION = 0 as const;
 // Increment when the same protocol version no longer guarantees safe Client-Host
 // interoperability. Mismatches are rejected before domain commands are admitted.
-export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 202 as const;
+export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 203 as const;

Review Comment:
   **P3 (merge coordination):** Epoch 203 is also claimed by open #5753 (`fix(transcript): recover from oversized invocations`, head `4ee3709d`, whose line 108 reads `// 203: Transcript omission notes ...`). Current `main` is 202, so either PR is correct on its own. Once one lands, though, the other must move to 204 and keep both history lines. If a conflict resolver keeps 203 for both, peers with different strict catalog/transcript decoders would pass the same epoch handshake. Please coordinate the merge order, and rebase and bump if #5753 lands first.



##########
apps/desktop/src/main/session-local-service.ts:
##########
@@ -285,30 +342,45 @@ export class DesktopSessionLocalService {
       return;
     const client = target.client;
     const revision = this.store.revision;
-    const task = client
-      .listSessions()
+    const invalidationVersion = connection.invalidationVersion;
+    let freshnessRevoked = false;
+    const task = abortable(() => client.listSessions(), connection.controller.signal)
       .then((sessions) => {
-        if (!this.#current(target)) return;
+        if (!this.#currentCatalogConnection(target, connection)) return;
         // A late catalog cannot erase a Session created/removed while it read.
         if (this.store.revision !== revision) return;
         this.store.saveCatalog(target.partition, sessions.map(toDesktopHostSessionSummary));
-        this.#catalogFresh.set(target.partition, { epoch: client.hostEpoch, at: Date.now() });
+        // Publish successful observations even under continuous Host events.
+        // The captured version keeps this observation dirty if another change
+        // arrived while reading, so one trailing refresh can converge.
+        this.#catalogFresh.set(target.partition, { connection, at: Date.now(), invalidationVersion });
         this.deps.changed(target.scope);
       })
       .catch((error: unknown) => {
-        if (!this.#current(target)) return;
+        if (!this.#currentCatalogConnection(target, connection)) return;
         if (error instanceof RuntimeHostOperationError && error.code === 'unauthorized')
           this.purge(target, true);
-        else this.deps.onError(error);
+        else {
+          // A failed refresh cannot keep old execution activity authoritative.
+          // Notify only on the live-to-cached transition so repeated failures
+          // cannot drive a renderer notification/retry loop.
+          freshnessRevoked = this.#catalogFresh.delete(target.partition);
+          this.deps.onError(error);
+        }
       })
       .finally(() => {
-        this.#catalogTasks.delete(target.partition);
+        if (this.#catalogTasks.get(target.partition) === task)
+          this.#catalogTasks.delete(target.partition);
+        if (!this.#currentCatalogConnection(target, connection)) return;
         if (
-          this.#current(target) &&
-          !this.#catalogFresh.has(target.partition) &&
-          this.store.revision !== revision
+          freshnessRevoked ||
+          (!this.#catalogFresh.has(target.partition) && this.store.revision !== revision)
         )
           this.deps.changed(target.scope);
+        if (connection.invalidationVersion !== invalidationVersion) {
+          // Consume all changes received during this read with one request.
+          this.#refreshCatalog(target, connection);

Review Comment:
   **P3:** This trailing refresh still goes through the global `#catalogTasks.size >= 2` cap (line 339), which can return without scheduling anything. Before this PR, a Host change deleted `#catalogFresh`, so a dropped refresh left the row `cached` with activity stripped. Now `changed()` only bumps `invalidationVersion`, and `catalog()` decides `authoritative` from `fresh.connection === connection` alone. A dropped trailing refresh therefore keeps the last observation (for example `backgroundActivity: 'running'` after children have finished) authoritative until another renderer `catalog()` call finds a free slot. This needs at least three Owner partitions refreshing at once, so it is rare. Consider exempting trailing refreshes from the cap or rescheduling them, or treat `fresh.invalidationVersion !== connection.invalidationVersion` as non-authoritative once the read has settled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org