qqeasonchen opened a new pull request, #5346: URL: https://github.com/apache/eventmesh/pull/5346
<!-- Part of #5296 (Architecture Review, "New review questions" 2026-09-07, Q4). Sub-PR D2a of #5302 (A2A onto Runtime). Closes #5340. --> ## A2A TaskExpirer + MetaAgentCardRegistry + failure-mode test (D2a) Q4 asks: are task expiry / reaping, Meta-backed AgentCard persistence, Runtime-dispatch integration, and real Meta / Runtime failure testing complete? Until they are, A2A remains explicitly Experimental. This PR lands **D2a** — four of the five acceptance items from the #5340 issue body. **D2b** (Testcontainers E2E) is a follow-up; the failure-mode test in D2a pins the gateway's contract at the user-facing API, and D2b will exercise the same scenarios end-to-end against a real Meta + broker + multi-instance EM. ### What this PR adds 1. **`eventmesh-runtime/.../a2a/TaskExpirer.java`** — new reaper class with configurable TTL (default 24h) and scan interval (default 60s). Calls `TaskStore.expireStale()` on a daemon-thread `ScheduledExecutor`. Exposes a `scan()` method for tests to drive the reaper synchronously. Idempotent start/shutdown. Wired into `A2AGatewayService` via a new opt-in `setTaskExpirer()` setter; `gateway.start()` starts the reaper, `gateway.shutdown()` stops it. The reaper is opt-in so existing deployments that do not want a background scanner are not affected. 2. **`eventmesh-runtime/.../a2a/MetaAgentCardRegistry.java`** — new cluster-shared `AgentCard` persistence backed by `MetaStore`, using Jackson JSON for the wire value (the `AgentCard` model is already Jackson-friendly via `@Data @Builder`). Per-process cache kept fresh by a Meta watch on `/em/agent-cards/`. Malformed values are logged + ignored so a peer's bad write does not poison the local cache. Same pattern as `ClusterSubscriptionStore` (Sub-PR A). 3. **`eventmesh-runtime/.../a2a/A2AGatewayService.java`** — new `setTaskExpirer()` / `getTaskExpirer()` setter pair (the existing 6-arg ctor is unchanged for backward compatibility). `start()` / `shutdown()` call through to the reaper when it is attached. **Bug fix**: `submitTask` now wraps `taskStore.createTask` in try/catch and returns an exceptionally completed `CompletableFuture` on `RuntimeException` (e.g. `MetaPartitionException` from a Meta-backed `TaskStore`), so the public API is uniformly future-based. Callers no longer have to catch a synchronous throw from `submitTask`. This is the contract the new failure-mode test pins. 4. **`eventmesh-runtime/.../a2a/TaskExpirerTest.java`** — 6 cases: evicts idle tasks, fresh tasks are not evicted, listener receives evicted taskIds, start/shutdown are idempotent, background scan fires on schedule, invalid TTL/interval throws. 5. **`eventmesh-runtime/.../a2a/MetaAgentCardRegistryTest.java`** — 5 cases: register/lookup/remove, wrapper restart, two-instance shared Meta, malformed JSON is logged + ignored, null args are rejected. 6. **`eventmesh-runtime/.../a2a/A2AGatewayFailureModeTest.java`** — 2 cases: `submitTask` surfaces Meta failure to the caller (the returned future completes exceptionally with `MetaPartitionException`, **NOT** hung, **NOT** silently dropped); `submitTask` succeeds after Meta heals. This is the A2A-layer counterpart of the TaskStore-level failure test in `StateStoreDurabilityTest` (issue #5339). 7. **`docs/a2a-readiness-decision.md`** — decision log: keep A2A **Experimental** for the next release. Explicit promotion criteria (D2b Testcontainers E2E must be green for >=1 release, plus a 30-day production-style deployment, plus an updated `docs/a2a-protocol.md`, plus a deprecation note for any legacy A2A path). ### Acceptance status (issue #5340) - [x] `TaskExpirer` reaper lands with a unit test (D2a, this PR). - [x] `MetaAgentCardRegistry` lands with restart-recovery test (D2a, this PR). - [ ] Testcontainers E2E `eventmesh-a2a-e2e` runs in CI on PRs to `eventmesh-a2a/` (**D2b follow-up**, tracked under a new issue). - [x] Failure-mode test (Meta down → A2A surfaces error) exists (D2a, this PR). - [x] Decision recorded: keep A2A Experimental (D2a, this PR, `docs/a2a-readiness-decision.md`). ### Out of scope (D2a explicitly does NOT do) * Testcontainers E2E (D2b follow-up). * A2A auth / RBAC (separate concern; not part of #5296). * A2A load-testing. Part of #5296 Sub-PR of #5302 Closes #5340 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
