Repository navigation
Description
We are a research team at MPI-SWS building Daavar, a conformance checker for distributed protocol implementations: it explores every message interleaving of a program written against our message-passing API and compares the behaviours of an implementation with those of a specification program, or of two implementations with each other. We ran it on the A2A specification text and on a2a-java and a2a-rs; this issue is one of the results, with the evidence and the reproduction below.
What happened?
onSubscribeToTask reads the task from the store (DefaultRequestHandler.java L1346), checks for a final state (L1354-L1360) and only then taps the queue (L1365-L1373; EventQueue.java L568-L570). The bus thread commits each event (MainEventBusProcessor.java L284) and distributes it to the children present at that moment (L336, EventQueue L814). Nothing orders the read and the tap against the bus: there is no lock in L1342-L1387. Two consequences:
1. The stream never closes (§3.1.6, L286: "The stream MUST terminate when the task reaches a terminal state"). The read sees a non-final task. Before the tap, the final event is distributed and the last child closes on it (EventConsumer.java L278-L280). The main queue then closes, and its cleanup removes it from the map (InMemoryQueueManager.java L190-L211). The tap finds no queue (IQM L81-L84), and createOrTap (L1372) creates a fresh one. The comment there (L1369-L1370) accepts that "historical events from before queue closed are not available". Two things make this path wrong all the same. First, the fresh queue has no producer: the executor's emitter writes only to the original queue (EventQueue L678), and nothing ever closes the fresh one, so the subscriber holds a non-final Task snapshot and waits forever. Second, the missed events are not historical; they were published after the subscribe's read. If another child keeps the original queue open, a later rejected executor report can still end the stream with an error item. The never-closing case is the one in which nothing more reaches the subscriber's queue.
As calls (one execution of our model):
- A
SendStreamingMessage→ SSETask(SUBMITTED),TaskStatusUpdateEvent(WORKING); A sendsCancelTask. - B
SubscribeToTask: the store read seesWORKING. - Before B's tap, the executor completes. A's stream gets
TaskStatusUpdateEvent(COMPLETED, final)and closes. A'sCancelTask→TaskNotCancelableError;GetTask→COMPLETED. - B's tap lands on a fresh queue. B's stream:
Task(WORKING), then nothing; it never closes.
2. An event published in the window is lost. The event is committed after the read and distributed before the tap, so it is in neither the Task snapshot nor the new stream. §3.1.6, L288 gives the snapshot's purpose: "This prevents a potential loss of information between a call to GetTask and calling SubscribeToTask." The snapshot is the state "at the time of subscription", and we read that sentence as owing every event after that time to the new stream, which is active from the tap. On that reading the event is owed to B and lost; this is the basis of the 2,060 words below. A second argument holds under a different reading: if a stream counts as active from the subscribe (the text does not say when it becomes active), §3.5.2, L668, "Events MUST be broadcast to all active streams for that task", requires the event on B as well.
As calls:
- A
SendStreamingMessage→ SSETask(SUBMITTED). - B
SubscribeToTask: the store read seesSUBMITTED. - Before B's tap, the executor reports working. A's stream gets
TaskStatusUpdateEvent(WORKING); A sendsCancelTask. - After the tap, the executor completes. Both streams get
TaskStatusUpdateEvent(COMPLETED, final)and close. A'sCancelTask→TaskNotCancelableError. - B's stream:
Task(SUBMITTED),TaskStatusUpdateEvent(COMPLETED).WORKINGis lost.
The SDK shows both. Two tests in a new SubscribeWindowTest (server-common, package requesthandlers; in our PR, below) stop onSubscribeToTask at its tap, after the store read saw WORKING, and let the agent publish. eventPublishedBetweenReadAndTap_reachesSnapshotOrStream publishes an artifact in the window, then completes the task, and asserts that the artifact is in the snapshot or on the stream. terminalStateBetweenReadAndTap_closesTheStream completes the task in the window and asserts either a refusal as terminal (UnsupportedOperationError) or a stream that closes within 5 s and shows the completion. Both fail at 369ee867 and on main 3f321f1c: the streams are [Task{WORKING, artifacts=[]}, Status{COMPLETED}] and [Task{WORKING}], the second never closing. Each run also checks that the window was exercised, so a slow agent or a slow bus fails the test rather than letting it pass by timing.
a2a-rs avoids the window: it subscribes the receiver first, then reads the snapshot and its sequence number under one lock, and drops events at or below that number (handler.rs L67-L71, L552). In a2a-java, reading the task and tapping the queue under a new lock in MainEventBusProcessor, which processEvent holds from each event's persist to its distribution, closes both, and both tests pass with it; we will open a PR.
Counts are uncovered words / all words of the checked side; a word is one distinct observation of the visible roles (the client, a second client that subscribes, and the server, server-executor messages included) within a sequential model of each server core and a fixed scenario. The model gives the server one atomic step per message, except SubscribeToTask, which takes two: the store read with the snapshot, then the tap. Races inside one step are not modelled. We ran 15 scenarios: three subscribe timings, each with five executor behaviours (a Message, or a task opened with a Task or a status update, split by how it completes). The third timing, B subscribing at once, adds no distinct window behaviour. Under our abstraction, a subscribe processed before the task is created is refused; one processed later reproduces the counts of the first timing (for example 323 window-loss words, 44 of them late taps, in the scenario of the block below). Of 7,912 words of the a2a-java model, 2,060 are rejected. Every one loses an event published in the window (point 2), and 298 of them also leave the stream open forever (point 1). Model results: a2a-java model of 369ee867 (main after #1353). The subscribe path is unchanged on main (checked at 3f321f1c): onSubscribeToTask, InMemoryQueueManager, MainEventBusProcessor, EventConsumer, and EventQueue's tap() and distributeToChildren. EventQueue's diff touches only the drain wait (awaitDrained).
This issue was prepared with AI assistance and reviewed by us.
Reproduce
Programs and reproduction instructions: benchmarks/a2a-task at f022892 (section "Experiment 4").
git clone --recurse-submodules https://github.com/joulook/daavar.git && cd daavar
git checkout f022892 && git submodule update --init --recursive
(cd traceforge && cargo build --release -p traceforge --bin conf-join)
cd benchmarks/a2a-task/rust && cargo build --release
R=target/release/tf_a2a_task; J=../../../traceforge/target/release/conf-join
(cd ../../../jmc && ./gradlew -q --no-daemon --init-script ../scripts/print-classpath.gradle :core:printTestClasspath)
CP=$(cat ../../../jmc/cp.txt); mkdir -p classes report && javac -d classes -cp "$CP" ../java/bench/a2a_task/*.java
C=n,col-a,part-tasks,done-no
$R export spec --out spec.jsonl --program a2a-task --size $C --threads 16 --model fifo -- spec,$C
java -Xss4m -Xmx2g -cp "classes:$CP" org.mpi_sws.jmc.mp.cli.MpLauncher bench.a2a_task.A2ATaskFixed:impl,$C \
must 0 1 "$PWD/report" "$PWD/java.jsonl" 43200 --split 16 --k 16
$J --decide spec.jsonl java.jsonl > join.out; grep -m1 '^uncovered' join.out # 323 (of 1003 words)
python3 -I ../scripts/classify4.py join.out classes.json
# prints, among its lines:
# blocked-other+v-S286+v-S286-late-tap+v-window 44 <- point 1 (and point 2)
# v-window 279 <- point 2
# total 323Requirements: JDK 17, a Rust toolchain (cargo), and 16 cores (--split 16 runs 16 worker JVMs, each with the launcher's JVM options). The scenario: B subscribes after A's first item, and the executor opens the task with a Task. The specification export has 1,731,323 observations (53 s and 5.9 GiB on 16 threads) and the Java export took about 6 s. The join takes about 3.5 minutes and 20 GiB. classes.json gives each class with an example word.
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity