Skip to content

test(e2e): prove the session input lifecycle through a real Gateway - #178985

Merged
jalehman merged 2 commits into
mainfrom
e2e/session-input-lifecycle
Oct 27, 2026
Merged

jalehman merged 2 commits into
mainfrom
e2e/session-input-lifecycle

Conversation

@jalehman

@jalehman jalehman commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

#177698 reworks how a session admits, steers, queues, recovers and settles input. Its proof today is mostly unit tests over internals, plus captures the author ran privately. There is no committed test that drives the public Gateway surface and checks what a user would actually see: whether a correction reached the running turn, whether anything ran twice, and whether any input was left waiting.

Why This Change Was Made

These tests drive real public RPCs (chat.send, chat.abort, agent.wait, chat.history, device.pair.*) and the sessions_send and sessions_spawn tools, against a real Gateway. Only the model is scripted, as a loopback OpenAI Responses server. Assertions read only observable outcomes:

  • what each model request received;
  • which runs executed;
  • the persisted transcript;
  • pendingInputs.

They never read internal state.

A CI policy watch in scripts/lib/ci-policy-test-watch.mts now selects gateway-session-steering.e2e.test.ts on PRs that change the session controller (src/sessions/session-controller*.ts), steer adoption, or the followup queue. Without it, this child-process e2e runs only daily and in Full Release Validation, because the import graph never reaches it. The two-person file stays on that schedule.

  • gateway-session-steering.e2e.test.ts: one out-of-process QA Gateway child for the whole suite.

    • The requester's correction joins the active run exactly once.
    • /followup runs as its own turn after the active run.
    • Stop on the run keeps queued work; Stop on the session cancels it visibly.
    • sessions_send to a busy peer: followup runs as a separate turn and its reply returns to the requester exactly once; steer joins the active run.
    • A subagent result returns to its requester in exactly one announcement.
    • A message sent during an announcement is answered exactly once.
    • A correction sent during recovery compaction reaches the same run exactly once.
  • gateway-session-steering-people.e2e.test.ts: two people (Alice and Bob) signed in through a trusted proxy.

    • Bob's steering is refused without queueing and never reaches the model.
    • With collaborative steering enabled, Bob joins Alice's run and stays the author of his message.
    • After Bob's device is revoked, his queued followup is cancelled before it reaches the model.

    This file boots one in-process Gateway per test. A shared-token Gateway has a single owner identity, and the e2e setup resets in-process runtime state after every test, so these scenarios can't share an in-process Gateway.

The scripted model never sleeps. Where the runtime accepts input asynchronously, the model keeps the run working through real tool boundaries until the input actually arrives, with a hard cap. Every wait is on produced state: model requests, chat and lifecycle events, or agent.wait.

User Impact

None at runtime. The steering and queue contracts in docs/concepts/queue-steering.md and docs/concepts/session-tool.md now have boundary-level regression coverage.

Evidence

Findings from building these tests

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Adds Gateway tests for steering, queued followups, cancellation, compaction recovery, cross-session delivery, and requester identity.

Example: A user sends “Correction sent during compaction.” while recovery compaction is held.

  • Before: The reported baseline executes the correction as a later turn instead of delivering it to the original run.
  • After: The added regression requires delivery to the original run exactly once, one transcript entry, and no pending input.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, coherent boundary coverage with no definite introduced defect; execution evidence is author-reported and the implementation stack remains unmerged.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-only PR is outside the ordinary contributor proof gate; its reported executions use a real Gateway with a scripted HTTP provider, not live-model inference.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Session-input refactoring can regress correction delivery, queued work, cancellation, or requester attribution without a public-boundary regression catching it.
Reason: The maintainer-authored direction is established, and the added scenarios cover observable failures that internal ownership tests alone cannot establish.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this maintainer-authored PR adds useful Gateway-boundary coverage for the unmerged session-input refactor; no definite introduced correctness or security defect was found.

Priority: P3
Reviewed head: 6c5a3e7cbf64d2fed66c9c14111b2b68c6ef6ace

Before merge

Findings

None.

Agent review details

How this fits together

The tests submit public Gateway RPCs and model-issued session tools, then observe provider requests, lifecycle events, transcript history, and pending inputs.

flowchart LR
  A[Test clients] --> B[Gateway RPCs]
  B --> C[Session input owner]
  C --> D[OpenClaw runtime]
  D --> E[Scripted Responses server]
  C --> F[Transcript and pending inputs]
  B --> G[Observable events]
Loading

Technical review

Best possible solution:

Land the session-input implementation and retain these public-boundary regressions through the existing Gateway and provider fixtures.

Do we have a high-confidence way to reproduce the issue?

The author reports a baseline failure and successful stacked-head runs for recovery-compaction steering; this read-only review inspected the scenario without executing target code.

Is this the best way to solve the issue?

The shared fixture exercises real Gateway admission, runtime tools, transport, and persistence while scripting only provider responses; the scenarios protect distinct lifecycle contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f88c60637096.

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +1211. Total +1211 across 3 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 1211 0 +1211
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 1211 0 +1211

Labels

Label changes:

  • add P3: This is test-only regression coverage with no direct runtime behavior change.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is test-only regression coverage with no direct runtime behavior change.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 11:37 PM ET / October 21, 2026, 03:37 UTC.

@enki

enki commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Post-merge test refresh (2026-10-22)

#177698 has landed as f83b7ade15f3aefad7b367bef084ea5ffdbd9f8b. I prepared a minimal refresh of your single three-file test commit onto pinned main 8d6cb3d4d4bbca7ce288fc71c2fefd27d5f1c7f2, without importing the old parent stack:

The candidate preserves your original author/date and links this PR and 6c5a3e7cbf64d2fed66c9c14111b2b68c6ef6ace. Its only adaptation waits for the already-observed announcement execution to settle before checking the answer: an accepted human steer's receipt can finish before that execution does. The existing one-announcement assertion is moved earlier; no behavioral assertion is removed or relaxed.

All twelve original public-RPC Gateway scenarios passed unchanged against this main baseline. After the timing correction, the affected nine-scenario file passes again; the three unchanged people scenarios retain their passing run. Owning E2E types, scoped typed lint, formatting and fresh P0–P2 source review pass. This uses isolated synthetic state and a scripted local HTTP model, not a fresh native-Codex or external-model capture.

The cases preserve the adjudicated boundary: compatible human steering into active work, with peer followup retaining a separate turn and its correlated reply. The production code is unchanged.

Your branch and base are untouched, and I have not opened a duplicate PR. The candidate is available to replay onto main and retarget this existing PR, avoiding the old stack's unrelated ancestry. The separate restart-before-recovery/new-input issue described below is still not claimed fixed by this test refresh.

Historical parent validation and separate restart investigation

The parent repair is now pushed at 223d8959a0d02c4daab9076c037cfedf282d3a3f (#177698), including upstream conflict resolution and the fixture-only correction from c879cc97b939dc4534d33c75b89b5deae36a9975.

I inspected the full failing lint job rather than relying on annotations. Its actual four errors were inherited from the parent: three asynchronous no-op onCompactionHookMessages fixtures and one await of that now-void callback. The max-lines annotations were warnings. The parent now fixes those fixtures while retaining their assertions; the affected typed lint and type graphs pass.

I materialized your three test files unchanged from 6c5a3e7cbf64d2fed66c9c14111b2b68c6ef6ace, ran the canonical isolated QA build, and ran all twelve public-RPC Gateway scenarios against the updated parent's production code: all twelve pass (54.50s). The earlier run also passed all twelve before the upstream integration. Both runs use synthetic state and the scripted HTTP model; neither is a new live native-Codex capture. The temporary files were removed afterward and were not folded into the parent.

Please refresh the stack base/test branch from the updated parent to inherit the fixture repair. I have left your branch and base untouched, preserving your request to keep this separate and retarget to main after #177698 lands. Compatible human steering into an already visible result-required announcement is intentional and is now explicit in the parent docs and custody regression table; optional promotion remains a separate policy proposal.

Separate restart/new-input investigation

I exercised an isolated Gateway process with synthetic task text and a scripted HTTP model: hold an original request, interrupt the Gateway, restart it with its retained state, connect as Control UI, assert recovery has not yet reached the model, and immediately submit new input. The test then requires that exact new input to reach the model and its pending receipt to settle.

On consolidation 223d8959a0d02c4daab9076c037cfedf282d3a3f, the crash and shutdown variants each passed when run separately. On upstream 20d2826d7c6466b000a48a62067b787e69dcd556, the crash/shutdown sequence exposed the shutdown stall twice: two pending inputs and no post-restart model request within the 30-second observation. Shutdown alone passed once; a later crash attempt encountered a separate startup SessionRecoverySourceChangedError. These timing/order qualifications mean the candidate is not established as fixing this separate bug.

The second stalled trace narrows the boundary: the foreground input is selected, the other input stays waiting, and recovery-predecessor repeatedly reserves a new source and restores the foreground claim about five seconds later, without selecting the actual waiting resend. This matches the anonymous placeholder in reconcileOrWaitForReplyRecovery: it waits for recovery progress, retires the placeholder, and restores foreground custody. That code and the predecessor helper are identical on both heads.

The scheduling lead is to hand off to the exact already-admitted resend when it is present, retaining its original dispatcher and authority, instead of inserting another placeholder ahead of it. Such a joined input must never be retired by the foreground caller. The trace does not yet establish which operation/effect causes reconciliation to decline; a queued source alone is not proof of an active-owner guard. I have made no production patch or new main-PR change. Your original failing fixture/tracking link would help pin the precise admission state before choosing the repair.

@jalehman
jalehman force-pushed the e2e/session-input-lifecycle branch from 6c5a3e7 to 0a079e6 Compare October 22, 2026 23:46
@jalehman
jalehman requested a review from a team as a code owner October 22, 2026 23:46
@jalehman
jalehman changed the base branch from stack/pr-177698 to main October 22, 2026 23:46
@jalehman
jalehman force-pushed the e2e/session-input-lifecycle branch from 0a079e6 to 45df133 Compare October 27, 2026 01:24
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts labels Oct 27, 2026
Drive steering, queued followups, Stop, recovery compaction, cross-session
delivery, subagent completion and two-person steering through public
Gateway RPCs with a scripted model. Assertions read what the model
received, which runs executed, the persisted transcript and pending
inputs.
@jalehman
jalehman force-pushed the e2e/session-input-lifecycle branch from 45df133 to f62368d Compare October 27, 2026 04:17
@jalehman
jalehman enabled auto-merge (squash) October 27, 2026 04:24
@jalehman
jalehman merged commit 20ef85f into main Oct 27, 2026
116 of 118 checks passed
@jalehman
jalehman deleted the e2e/session-input-lifecycle branch October 27, 2026 04:27
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…penclaw#178985)

* test(e2e): prove the session input lifecycle through a real Gateway

Drive steering, queued followups, Stop, recovery compaction, cross-session
delivery, subagent completion and two-person steering through public
Gateway RPCs with a scripted model. Assertions read what the model
received, which runs executed, the persisted transcript and pending
inputs.

* ci: run session steering e2e when session lifecycle owners change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants