Skip to content

test(e2e): retry empty TUI chat event captures - #4255

Merged
cv merged 2 commits into
mainfrom
fix/tui-correlation-empty-event-retry
May 26, 2026
Merged

cv merged 2 commits into
mainfrom
fix/tui-correlation-empty-event-retry

Conversation

@cv

@cv cv commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Retries the OpenClaw TUI chat correlation live repro only when an accepted-send attempt captures zero chat events, which matches the dominant harness flake. The strict correlation assertions remain unchanged for empty finals, duplicate turns, missing replies with observed events, and uncorrelated replies.

Changes

  • Add a one-time retry path for zero-event live TUI/webchat correlation captures with a fresh session key.
  • Add per-attempt diagnostics to the failure summary, including sent runs, event counts, and compact history messages.
  • Add a unit regression check that the retry predicate applies only to the zero-chat-events case and does not mask empty final events.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela [email protected]

Summary by CodeRabbit

  • Tests
    • Improved test infrastructure with per-run unique session identifiers.
    • Added detection for a specific event-capture failure mode and a retry wrapper to rerun repros when that condition occurs.
    • Enhanced failure reporting to include richer diagnostic context and aggregated attempt data.
    • Increased live-test timeout and added a unit test validating the event-capture failure classifier.

Review Change Stack

@cv cv self-assigned this May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 20a72d7e-3745-41ff-b5b9-0496b79f7a4f

📥 Commits

Reviewing files that changed from the base of the PR and between 76bd808 and 749bc90.

📒 Files selected for processing (1)
  • test/openclaw-tui-chat-correlation.test.ts

📝 Walkthrough

Walkthrough

This test update adds intelligent retry logic for chat event capture failures in Issue 2603 live reproduction. A new session key generation scheme with UUID suffixes ensures per-run uniqueness, detection logic identifies zero-event failure modes, and a retry wrapper conditionally re-executes the test. Failure reporting now captures attempt histories and trace-derived metrics.

Changes

Issue 2603 Event Capture Resilience

Layer / File(s) Summary
Dependencies and data model
test/openclaw-tui-chat-correlation.test.ts
Import randomUUID from node:crypto and define LiveIssue2603Run type to bundle a single repro trace with an ordered list of all attempts.
Failure reporting pipeline
test/openclaw-tui-chat-correlation.test.ts
Add compactHistoryMessages and summarizeAttempt helpers; extend buildFailureSummary to accept optional trace and attempt list so emitted failure JSON includes expectations, trace-derived event counts, and per-attempt summaries.
Event capture retry mechanism
test/openclaw-tui-chat-correlation.test.ts
Update session key generation to include UUID suffix; introduce looksLikeEventCaptureFailure classifier to detect zero-captured-events scenarios; add runLiveIssue2603ReproWithEventCaptureRetry wrapper to conditionally retry on capture failure and return both final repro and all attempts.
Test coverage and integration
test/openclaw-tui-chat-correlation.test.ts
Add unit test validating event-capture failure classifier behavior, and update live sandbox regression test to invoke retry wrapper, pass trace and attempts to failure summary builder, and increase timeout allowance.

Sequence Diagram

sequenceDiagram
  participant LiveTest as Live Sandbox Test
  participant RetryWrapper as runLiveIssue2603ReproWithEventCaptureRetry
  participant ReproExec as Live Repro Execution
  participant Classifier as looksLikeEventCaptureFailure
  participant Reporting as buildFailureSummary

  LiveTest->>RetryWrapper: trigger with UUID session key
  RetryWrapper->>ReproExec: run repro (attempt 1)
  ReproExec-->>RetryWrapper: repro trace
  RetryWrapper->>Classifier: analyze trace for zero captured events
  alt Capture failure detected
    RetryWrapper->>ReproExec: run repro (attempt 2)
    ReproExec-->>RetryWrapper: repro trace
  end
  RetryWrapper-->>LiveTest: return {repro, attempts}
  LiveTest->>Reporting: pass trace + attempts
  Reporting-->>LiveTest: enriched failure JSON
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble logs and chase each missing trace,
UUID tails keep every run in place,
When captures vanish, I hop back to try,
Two runs recorded, then the summaries fly—
A rabbit's cheers for tests that don't say die.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(e2e): retry empty TUI chat event captures' directly and specifically describes the main change: adding retry logic for empty TUI chat event captures in end-to-end tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tui-correlation-empty-event-retry

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: None
Optional E2E: openclaw-tui-chat-correlation-e2e

Dispatch hint: openclaw-tui-chat-correlation-e2e

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • None. No merge-blocking E2E is required because this PR changes only an existing test file/E2E harness and cannot affect NemoClaw runtime behavior or real user flows. The directly affected E2E is recommended as optional to validate the harness change itself.

Optional E2E

  • openclaw-tui-chat-correlation-e2e (high): Optional confidence check for the modified live E2E harness and retry behavior. This is the directly affected existing job and runs test/e2e/test-openclaw-tui-chat-correlation.sh, which invokes test/openclaw-tui-chat-correlation.test.ts with NEMOCLAW_ISSUE_2603_LIVE=1.

New E2E recommendations

  • None.

Dispatch hint

  • Workflow: nightly-e2e.yaml
  • jobs input: openclaw-tui-chat-correlation-e2e

@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

E2E Scenario Advisor Recommendation

Required scenario E2E: None
Optional scenario E2E: None

Workflow run

Full scenario advisor summary

E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required scenario E2E

  • None. No scenario workflow, scenario metadata, scenario runtime, or validation-suite files changed.

Optional scenario E2E

  • None.

Relevant changed files

  • None.

@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 2 prior items resolved, 0 still apply, 0 new items found

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@cv cv added the v0.0.51 label May 26, 2026
@cv

cv commented May 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed the review advisor note in 749bc90 by adding source-boundary and removal-criteria context next to the retry helper. The comment now documents that the tolerated zero-event state is a live repro observability race at the pinned OpenClaw gateway/websocket boundary, that this PR keeps the strict #2603/#3145 assertions intact, and when to remove the guard.

Verification re-run:

  • npx vitest run test/openclaw-tui-chat-correlation.test.ts --reporter=verbose
  • npx prek run --all-files

@cv
cv requested a review from ericksoa May 26, 2026 18:21
@cv cv added v0.0.52 and removed v0.0.51 labels May 26, 2026
@cv
cv merged commit 4bb00d3 into main May 26, 2026
28 checks passed
@cv
cv deleted the fix/tui-correlation-empty-event-retry branch May 27, 2026 21:16
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure bug-fix PR fixes a bug or regression and removed fix labels Jun 3, 2026
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 8, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 8, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 22, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 22, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 24, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
abhi-0906 added a commit to abhi-0906/NemoClaw that referenced this pull request Jun 25, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
jyaunches pushed a commit to abhi-0906/NemoClaw that referenced this pull request Jun 25, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
jyaunches pushed a commit to abhi-0906/NemoClaw that referenced this pull request Jun 25, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
jyaunches pushed a commit to abhi-0906/NemoClaw that referenced this pull request Jun 25, 2026
The OpenClaw gateway websocket broadcasts chat events from every
session, and the zero-event capture retry added in NVIDIA#4255 reuses the
same gateway with identical reply tokens. When slow inference pushes
the first attempt's runs past the reply deadline, those orphaned runs
complete or get aborted during the retry attempt, whose capture then
misreads the stale events as uncorrelated replies (NVIDIA#4742, NVIDIA#4637) or as
aborted runs that defeat the retry classifier (NVIDIA#4881). No correlation
regression actually occurred in those nightlies.

- Scope chat-event analysis and the in-sandbox reply wait to the
  attempt's own sessionKey, fail-open for events without one, and
  surface excluded events as foreignSessionChatEvents diagnostics.
- Reclassify capture failure as "no chat event references a submitted
  run or reply token" so stale aborted events cannot defeat the retry,
  and fail with an explicit infrastructure classification when every
  attempt is a capture failure (NVIDIA#4198 acceptance criterion).
- Record per-attempt sessionKey and sent run ids in the failure
  summary so cross-attempt contamination is visible in CI logs.
- Export the in-sandbox gateway log on failure and upload it as a CI
  artifact before sandbox cleanup destroys it.

Fixes NVIDIA#4881

Signed-off-by: Abhimanyu Kumar <[email protected]>
cv added a commit that referenced this pull request Jul 8, 2026
## Summary

Root-causes and fixes the recurring `openclaw-tui-chat-correlation-e2e`
nightly flake. The OpenClaw gateway websocket broadcasts chat events
from **every** session, but the zero-event capture retry added in #4255
reuses the same gateway with identical reply tokens. When slow inference
pushes the first attempt's runs past the reply deadline, those orphaned
runs complete or get aborted *during* the retry attempt, whose websocket
capture then misreads the stale events as a correlation regression. No
#2603/#3145 regression actually occurred in those nightlies — the test
was catching its own retry's echo.

## Related Issue

Fixes #4881

Same contamination signature, previously closed as intermittent: #4742,
#4637. Advances umbrella issue #4198 (acceptance criterion: "failure is
classified clearly as infrastructure/setup rather than a product
regression").

## Root cause (evidence)

Across the 7 failed nightly runs I pulled, the failures split into two
families, both downstream of the global event stream + retry
interaction:

- **#4881 (run 27047055659):** attempt 1 timed out with 0 chat events;
during attempt 2, attempt 1's 3 orphaned runs were **aborted** by the
gateway (its client had disconnected). Attempt 2 captured those 3
`aborted` events — foreign run IDs, empty text — which both failed the
assertions and prevented the retry classifier from re-firing.
- **#4742 / #4637 (e.g. run 26790528855):** attempt 1's orphaned runs
*finished* during attempt 2 and broadcast
`A2603-REPLY`/`B2603-REPLY`/`C2603-REPLY` under attempt 1's run IDs.
Attempt 2's own session history showed its prompts still mid-flight,
proving the captured "replies" were ghosts from attempt 1.

The gateway's chat events already carry a `sessionKey` (the NemoClaw
chat.send patch sets it), but the harness never filtered on it.

The `oom_score_adj` permission-denied line in #4881 is unrelated noise
from the sandbox shell profile — the exec succeeded and produced
`A2603-REPLY` anyway.

## Changes

- **Session-scope the capture.** `analyzeIssue2603Trace` and the
in-sandbox reply-wait/empty-final checks now only consider chat events
whose `sessionKey` matches the attempt's own session. Events without a
`sessionKey` are kept (fail-open) so the assertions can never be
silently blinded by a payload-shape change. Excluded events are surfaced
as `foreignSessionChatEvents` diagnostics.
- **Harden the retry classifier.** `looksLikeEventCaptureFailure` now
means "no chat event references a submitted run ID or a reply token," so
stale `aborted` events for foreign runs no longer defeat the retry (the
#4881 trap).
- **Explicit infrastructure verdict.** When every attempt is a capture
failure, the live test now throws a clearly-labelled `INFRASTRUCTURE
CAPTURE FAILURE` instead of a generic correlation assertion, so a red
nightly is unambiguous.
- **Better forensics.** Per-attempt `sessionKey` and sent run IDs are
recorded in the failure summary; the in-sandbox gateway log is exported
on failure and uploaded as a CI artifact before sandbox cleanup destroys
it.
- **Unit tests** for foreign-session exclusion, fail-open without
`sessionKey`, and the #4881 stale-aborted classification.

The strict #2603/#3145 correlation assertions are unchanged for events
within the attempt's own session — a genuine mis-correlation still fails
the test.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)

## Verification

- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] `npx prek run --all-files` passes — *prek/shellcheck/shfmt not
runnable on my Windows host; `bash -n` passes on the shell script*
- [ ] `npm test` passes — *full suite not run locally on Windows; the
changed test file (6 unit tests), `test/e2e-script-workflow.test.ts`,
`test/validate-e2e-coverage.test.ts`, and `npm run typecheck:cli` all
pass. The live `it.runIf(...)` path needs a real sandbox + NVIDIA API
key and is best validated by a maintainer nightly dispatch.*

Suggested validation: dispatch the nightly against this branch —
`gh workflow run nightly-e2e.yaml --ref <branch> -f
jobs=openclaw-tui-chat-correlation-e2e`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Improved chat-event correlation to be session-scoped: excludes
foreign-session noise from correlation metrics while still fail-opening
events without session keys.
* Added/expanded coverage for stale/aborted scenarios and updated
live-repro failure messaging with clearer summaries to distinguish
capture vs infrastructure issues.
* **Chores**
* Enhanced CI/E2E failure diagnostics: the test runner now captures the
Vitest result code and, on failure, exports the relevant gateway log for
troubleshooting.
  * CI now uploads additional logs together when E2E fails.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Abhimanyu Kumar <[email protected]>

---------

Signed-off-by: Abhimanyu Kumar <[email protected]>
Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Julie Yaunches <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Co-authored-by: abhi-0906 <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
## Summary

Root-causes and fixes the recurring `openclaw-tui-chat-correlation-e2e`
nightly flake. The OpenClaw gateway websocket broadcasts chat events
from **every** session, but the zero-event capture retry added in NVIDIA#4255
reuses the same gateway with identical reply tokens. When slow inference
pushes the first attempt's runs past the reply deadline, those orphaned
runs complete or get aborted *during* the retry attempt, whose websocket
capture then misreads the stale events as a correlation regression. No
NVIDIA#2603/NVIDIA#3145 regression actually occurred in those nightlies — the test
was catching its own retry's echo.

## Related Issue

Fixes NVIDIA#4881

Same contamination signature, previously closed as intermittent: NVIDIA#4742,
NVIDIA#4637. Advances umbrella issue NVIDIA#4198 (acceptance criterion: "failure is
classified clearly as infrastructure/setup rather than a product
regression").

## Root cause (evidence)

Across the 7 failed nightly runs I pulled, the failures split into two
families, both downstream of the global event stream + retry
interaction:

- **NVIDIA#4881 (run 27047055659):** attempt 1 timed out with 0 chat events;
during attempt 2, attempt 1's 3 orphaned runs were **aborted** by the
gateway (its client had disconnected). Attempt 2 captured those 3
`aborted` events — foreign run IDs, empty text — which both failed the
assertions and prevented the retry classifier from re-firing.
- **NVIDIA#4742 / NVIDIA#4637 (e.g. run 26790528855):** attempt 1's orphaned runs
*finished* during attempt 2 and broadcast
`A2603-REPLY`/`B2603-REPLY`/`C2603-REPLY` under attempt 1's run IDs.
Attempt 2's own session history showed its prompts still mid-flight,
proving the captured "replies" were ghosts from attempt 1.

The gateway's chat events already carry a `sessionKey` (the NemoClaw
chat.send patch sets it), but the harness never filtered on it.

The `oom_score_adj` permission-denied line in NVIDIA#4881 is unrelated noise
from the sandbox shell profile — the exec succeeded and produced
`A2603-REPLY` anyway.

## Changes

- **Session-scope the capture.** `analyzeIssue2603Trace` and the
in-sandbox reply-wait/empty-final checks now only consider chat events
whose `sessionKey` matches the attempt's own session. Events without a
`sessionKey` are kept (fail-open) so the assertions can never be
silently blinded by a payload-shape change. Excluded events are surfaced
as `foreignSessionChatEvents` diagnostics.
- **Harden the retry classifier.** `looksLikeEventCaptureFailure` now
means "no chat event references a submitted run ID or a reply token," so
stale `aborted` events for foreign runs no longer defeat the retry (the
NVIDIA#4881 trap).
- **Explicit infrastructure verdict.** When every attempt is a capture
failure, the live test now throws a clearly-labelled `INFRASTRUCTURE
CAPTURE FAILURE` instead of a generic correlation assertion, so a red
nightly is unambiguous.
- **Better forensics.** Per-attempt `sessionKey` and sent run IDs are
recorded in the failure summary; the in-sandbox gateway log is exported
on failure and uploaded as a CI artifact before sandbox cleanup destroys
it.
- **Unit tests** for foreign-session exclusion, fail-open without
`sessionKey`, and the NVIDIA#4881 stale-aborted classification.

The strict NVIDIA#2603/NVIDIA#3145 correlation assertions are unchanged for events
within the attempt's own session — a genuine mis-correlation still fails
the test.

## Type of Change

- [x] Code change (feature, bug fix, or refactor)

## Verification

- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] `npx prek run --all-files` passes — *prek/shellcheck/shfmt not
runnable on my Windows host; `bash -n` passes on the shell script*
- [ ] `npm test` passes — *full suite not run locally on Windows; the
changed test file (6 unit tests), `test/e2e-script-workflow.test.ts`,
`test/validate-e2e-coverage.test.ts`, and `npm run typecheck:cli` all
pass. The live `it.runIf(...)` path needs a real sandbox + NVIDIA API
key and is best validated by a maintainer nightly dispatch.*

Suggested validation: dispatch the nightly against this branch —
`gh workflow run nightly-e2e.yaml --ref <branch> -f
jobs=openclaw-tui-chat-correlation-e2e`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Tests**
* Improved chat-event correlation to be session-scoped: excludes
foreign-session noise from correlation metrics while still fail-opening
events without session keys.
* Added/expanded coverage for stale/aborted scenarios and updated
live-repro failure messaging with clearer summaries to distinguish
capture vs infrastructure issues.
* **Chores**
* Enhanced CI/E2E failure diagnostics: the test runner now captures the
Vitest result code and, on failure, exports the relevant gateway log for
troubleshooting.
  * CI now uploads additional logs together when E2E fails.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Abhimanyu Kumar <[email protected]>

---------

Signed-off-by: Abhimanyu Kumar <[email protected]>
Signed-off-by: Carlos Villela <[email protected]>
Co-authored-by: Julie Yaunches <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Co-authored-by: abhi-0906 <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants