Skip to content

fix(ai): scope stream replay to the requested run - #7147

Closed
zmuxuny wants to merge 1 commit into
apache:rocketmq-studiofrom
zmuxuny:fix/ai-run-scoped-replay-oct20
Closed

zmuxuny wants to merge 1 commit into
apache:rocketmq-studiofrom
zmuxuny:fix/ai-run-scoped-replay-oct20

Conversation

@zmuxuny

@zmuxuny zmuxuny commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

The run-stream endpoint reads conversation-wide event pages and currently projects every row as the requested run. Other turns' answers and statuses enter its replay; a previous COMPLETED event can suppress the correct synthetic FAILED terminal for a reaped run.

Start replay at the later of the caller's cursor and the requested run's positive startSeq minus one. Continue advancing the scan cursor across every row, but only matching runId rows enter decoding, projection, terminal detection, and the live deduplication watermark.

Do not cap replay at endSeq: a reaped run may retain its admission-time endSeq while already having persisted text. Null/zero legacy startSeq values retain the zero-floor fallback; those rows cannot receive the old-history skip optimization without trustworthy metadata. SQL, pagination limits, observer registration, and external API shapes are unchanged.

This is same-owner content/status correctness. Normal short-history UI attachment usually supplies a later timeline cursor; the large-history auto-attach path was verified in source, not with a browser deployment. Nearby paging, timing, duration, frontend-continuation, and terminal-publication fixes were checked for overlap. AI assistance was used.

How Did You Test This Change?

Base: rocketmq-studio@127c47b06a268cc74224d5f34c56ec7c36ac0d55.

  • Four initial regressions fail against unchanged production (4 failures, 0 errors): requested middle run isolation, reaped FAILED status, active-run tailing, and 5000 earlier rows exhausting the replay budget.
  • Nine added test instances also cover null/zero startSeq, cursors at/past the requested end, stale reaper endSeq, and a later run appearing between pages without poisoning the requested run's buffered-live watermark.
  • AiRunServiceTest: 42 passed.
  • Final related suites: 415 passed across 9 classes, zero failures/errors/skips; Checkstyle: 0 violations. Independent code/test review and git diff --check passed.

JDK 21.0.12.1 / Maven 3.9.12, from server/:

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: 415, Failures: 0, Errors: 0, Skipped: 0

MAVEN_REPO denotes the configured local repository. The explicit Mockito startup agent avoids unsupported dynamic self-attachment in this container; no project build configuration changed. The final focused run took 8.21 seconds, with approximately 512 MiB sampled combined RSS. Full backend/MySQL integration and frontend suites were not run.

Checklist

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

@zmuxuny

zmuxuny commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

CI follow-up: this backend-only change passes the complete Backend Tests, Backend Build, Frontend Docker Build, and rmqctl jobs in run 39286616653.

The only failing job is the unchanged frontend suite: 1,830 tests pass and ConsumerPage.test.tsx:1456 fails in highlights inconsistent subscriptions and refreshes the check result. This is the same existing polling/mock-response race tracked by #5626; neither that test nor the Consumer page is modified here. Frontend job log.

The local final backend selection passed 415 tests in nine classes, including 42 AiRunService cases. The combined local tree with #7143 and #7153 also passed all 423 selected tests and Checkstyle. I have left the independent Consumer test fix to the existing PR rather than adding unrelated frontend changes here.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 7 days. If you would like to continue working on this, please reopen the PR with updated changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant