Skip to content

fix(ai): publish success after terminal run persistence - #7143

Open
zmuxuny wants to merge 2 commits into
apache:rocketmq-studiofrom
zmuxuny:fix/ai-terminal-publication-order-oct20
Open

zmuxuny wants to merge 2 commits into
apache:rocketmq-studiofrom
zmuxuny:fix/ai-terminal-publication-order-oct20

Conversation

@zmuxuny

@zmuxuny zmuxuny commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

A successful provider ResultMeta currently projects live COMPLETED before the terminal run-row update. An observer can receive success while the stored run is still RUNNING, including when that update subsequently fails.

Record successful results without projecting their terminal pair. Finalize every outcome through the existing ordered path: flush text, persist one terminal timeline event, update the run row and cache, then publish one live terminal using the recorded duration. Preserve success-before-stop and success-before-late-provider-failure precedence.

Carry the terminal event's actual sequence into the delayed publication. A reconnect that already replayed that event must not receive it again, whether its replay has finished or is still buffering live frames. The projector's standalone contract is unchanged.

Scope is live publication consistency. This does not make timeline INSERT and run-row UPDATE transactional for attach replay; the current Studio page waits for event:done before final refetch. Nearby #6385, #7031, #7044, #4999 and #6469 were reviewed for overlap. When combining with #7031, retain terminalSeq separately from any later diagnostic notice's endSeq.

AI assistance was used for investigation, implementation, and regression testing.

How Did You Test This Change?

Base: rocketmq-studio@127c47b06a268cc74224d5f34c56ec7c36ac0d55. JDK 21.0.12.1 / Maven 3.9.12.

  • Unchanged production: both new row-before-wire and failed-terminal-update regressions fail (2 failures, 0 errors), observing one success frame where zero is required.
  • Deliberate incorrect intermediate variant publishing sequence 0: both reconnect-interleaving cases fail. Restored the final production source before the complete focused run.
  • Final AiRunExecutorTest: 26 tests passed, including stop-before-success, stop-after-success, late gateway/runtime failures, absent provider duration, terminal-write failure, and both replay/live handoffs.
  • Final related suites: 412 tests passed across 9 classes, with zero failures/errors/skips; Maven Checkstyle reports 0 violations.

From server/ (Mockito's explicit startup agent avoids this container's unsupported dynamic self-attachment):

MAVEN_OPTS=-Xmx384m mvn -B -ntp test \
  -DforkCount=1 \
  -DargLine="-Xmx256m -javaagent:$MAVEN_REPO/org/mockito/mockito-core/5.23.0/mockito-core-5.23.0.jar" \
  -Dtest=AiRunExecutorTest,AiRunServiceTest,AgentStreamSessionTest,AgentRunRegistryTest,AgentRunHandleStopTest,AgentEventProjectorTest,AiEventSeqAllocationTest,AiEventContractTest,AiEventJsonSerializationTest
# Tests run: 412, Failures: 0, Errors: 0, Skipped: 0
git diff --check

MAVEN_REPO is the configured local Maven repository; proxy and existing system truststore settings were environment-only. Final bounded run took 28.57 seconds and peaked at approximately 885 MiB combined process RSS. Full backend/MySQL integration and frontend suites were not run for this two-file lifecycle fix. Independent code and test review passed.

Checklist

  • One coherent lifecycle change
  • Conventional Commit subject
  • Regression methods use the ...Test suffix
  • No new UI text, dependencies, schema, API fields, or source files
  • Lifecycle documentation/comments updated
  • Full backend/MySQL integration and architecture suite (not run locally)

@zmuxuny

zmuxuny commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Withdrawing this PR from the active review queue until a current consumer impact or an explicit protocol requirement is established. The current Studio page waits for event:done before its final refetch and does not consume the early terminal callback/status in a way shown to affect users. The tests demonstrate internal ordering, while the timeline-event/run-row replay window also remains outside this patch. The patch and branch are preserved for further evidence-driven work.

@zmuxuny zmuxuny closed this Oct 20, 2026
@zmuxuny zmuxuny reopened this Oct 20, 2026
Reuse the five-line ConsumerPage timer isolation from commit
381c5c4, credited to pilichoumao's
apache#6521. Keep production polling, all existing
assertions, and independent automatic-refresh coverage unchanged.

Signed-off-by: zmuxuny <xiahoumuxuan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant