Skip to content

fix(gateway): restore missing-admission refusal and update 3 gateway tests broken on main - #196702

Merged
obviyus merged 3 commits into
mainfrom
fix/main-gateway-test-regressions
Nov 11, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/main-gateway-test-regressions

Conversation

@obviyus

@obviyus obviyus commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: 8 gateway tests in two files fail on main (a ninth, in server.sessions.create-worktree-spawn.test.ts, was since fixed on main by #196889). Main CI only runs tests affected by each change, so they went red unnoticed and now block unrelated PRs (seen on #196480). One of them covers a fail-closed check that #196337 removed.

User Impact

User impact: none visible today. The restored check refuses a cloud worker turn whose input is already persisted but has no readable canonical admission, before credentials, tunnel or launch. Real-path testing (below) shows current input paths never reach that state, so this restores defense in depth rather than closing a reachable hole. The other changes update tests to intended behavior.

Why This Change Was Made

Each failure was bisected between 802ddc7 (all pass) and main (all fail); each culprit passes on its parent and fails on the commit.

  • worker-turn-detached-context.test.ts, first bad d7aaafe (fix: let input policy hooks inspect prepared images #196337): production fix. Removing the early legacy-worker persistence path also dropped the no readable canonical user admission check. Restored for already-persisted input, before credentials (worker-turn-user-message.ts, +4 lines). Unpersisted input is still admitted after the policy gate, as fix: let input policy hooks inspect prepared images #196337 intends. The other 6 tests in that file encoded the old ordering: the gate now needs prepared images, so credentials and tunnel come first. Their authority-change probes now hook the transcript open that unpersisted input uses; all still refuse credentials, tunnel and launch.
  • sessions-rewind.storage.test.ts, first bad d53921a (fix(gateway): shared-session runs lose access after session list updates #194129): test update. Retained sharing facts now survive the broad sessions notification, so the commit guard refuses with the more specific SESSION_PARTICIPATION_REQUIRED (still a SessionMutationAuthorizationChangedError, storage unchanged).

Evidence

Unit and integration:

  • The affected files plus server.sessions.create-worktree-spawn, worker-turn-admission and worker-turn-execution: 137/137 pass (clean env, rebased on 240d0ac). Before: 8 failures on current main.
  • The culprits' own test files pass. Format, lint, tsgo:core, tsgo:core:test and the test-lines ratchet pass.

Real paired-node path (new qa/scenarios/runtime/cloud-worker-admission-authority.yaml): isolated QA Gateway, mock-openai provider, a real paired node, real worker bundle install, supervisor and worker process, managed-worktree session. Credentials, tunnel, dispatch and launch are production code; the proof only holds frames and calls public RPCs. Mode worker-turn-admission-v1:

validStaged         ok     launch=1 cancel=0  receipt=completed, process started  model=1  user+assistant  cursor null→2
validChannel        ok     launch=1 cancel=0  receipt=completed, process started  model=1  user+assistant  cursor 2→4
runCancelled        error  launch=1 cancel=2  receipt=cancelled, no process       model=0  cursor 4→4
placementReclaimed  error  launch=1 cancel=2  receipt=cancelled, no process       model=0  cursor 4→4  → reclaimed

Revocation is applied while the node holds the turn's worker.launch.v1 frame (chat.abort for the run, or sessions.reclaim); the Gateway sends its own worker.cancel.v1, and the stale launch then reaches the real node handler without starting a process or a model request.

Not reachable on the real path, without adding production test seams:

  • Persisted input without a receipt. Both chat.send and qa-channel input are staged, not written, for a session placed on a worker (reply-input-placement.ts sets stagedWorkerInput; chat.history read while the launch frame is held shows no user row in every case). recorder.hasPersisted() is therefore false when readWorkerTurnInputContext runs. The state only arises from a user row that commits off the active path between commit and anchor read (resolveCommittedUserTurnTranscript), a window inside the Gateway that no RPC can pause. That is why this PR describes the check as defense in depth.
  • Legacy (non-admission) protocol mode. The Gateway's expected worker build always includes worker-turn-admission-v1 (WORKER_PROTOCOL_FEATURES in server-worker-environment-startup.ts), and admission.ts rejects any worker whose features differ, so no accepted worker runs the !workerAdmission branch.

For the #196337 author: the restored check also applies to modern worker-admission turns, which previously skipped it, so a persisted modern turn without a receipt now fails closed. Separately, persistWorkerTurnInput still falls back to ?? baseLeafId when post-gate persistence yields no receipt; the old legacy path rejected there. Left unchanged here.

@clawsweeper

clawsweeper Bot commented Nov 10, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 10, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR rejects already-persisted worker input without a canonical admission receipt, updates stale Gateway expectations, and adds paired-node QA coverage.

Example: A worker turn carries the persisted message "current request" but no canonical admission receipt.

  • Before: The context reader continues toward credential acquisition and worker launch.
  • After: The context reader refuses the turn before credential acquisition or tunnel creation.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has no identified correctness defect; readiness remains limited by behavior-proof coverage.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stale Gateway test expectations block unrelated changes, and a retained defensive admission invariant is missing.
Reason: The collaborator-authored direction is established, and the focused repair preserves the reasons behind the earlier changes.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it repairs concrete Gateway test regressions and restores a focused admission invariant without undoing intended policy ordering.

Priority: P2
Reviewed head: 3fa0518586c936abb270a90df181438c8bc4d4ba

Before merge

  • Add real behavior proof - Authority-chain proof required: retain the supplied isolated Gateway and real paired-node success, cancellation, and reclaim output, but the prior request remains unresolved because both input paths are staged and can pass with the restored check removed; provide redacted production-owner output showing persisted input without a canonical receipt stops before credential acquisition or launch, without production test seams, and redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied paired-node runs do not exercise persisted input without a canonical receipt through production owners before credential acquisition or launch.
Agent review details

How this fits together

The Gateway worker-input owner combines a turn's recorder and transcript admission into model history and a launch base; worker execution then acquires credentials, opens a tunnel, and dispatches the turn.

flowchart TD
  A[Chat or channel input] --> B[Transcript recorder]
  B --> C[Worker input context]
  C --> D[Credentials and tunnel]
  D --> E[Paired node supervisor]
  E --> F[Worker admission and model]
  F --> G[Transcript and reply]
Loading

Technical review

Best possible solution:

Keep the refusal in the existing worker-input owner and retain the test updates that follow the merged sharing, worktree, and policy contracts.

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

Current-main source lacks the refusal exercised by the existing missing-admission regression; the PR reports bisected test failures, but this read-only review ran no target code and establishes no reachable user-path bypass.

Is this the best way to solve the issue?

The four-line guard is the smallest production repair using the existing owner, and the expectation changes preserve the intended contracts of the merged changes.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Worker input admission keeps the original intent (d7aaafe: Move legacy input persistence after the prepared-image policy gate; the missing-admission check disappeared with the early persistence path.)
  • Detached-context test ordering keeps the original intent (d7aaafe: Unpersisted input now opens its transcript before later policy-approved persistence, requiring authority-change probes to intercept that read.)
  • Sharing refusal expectations keeps the original intent (d53921a: Benign broad session notifications retain sharing facts while actual membership changes remain enforced.)
  • Cloned-project spawn expectations keeps the original intent (97e91a1: New sessions using OpenClaw-cloned projects always receive managed worktrees to keep scratch out of shared clones.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3a342c5 adds src/gateway/worker-environments/worker-turn-user-message.ts:170 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3a342c570186; files: src/gateway/worker-environments/worker-turn-user-message.ts)
  • Josh Avant: Raw commit d7aaafe adds src/gateway/worker-environments/worker-turn-user-message.ts:175 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d7aaafe92edf; files: src/gateway/worker-environments/worker-turn-user-message.ts)

PR surface

Source +4, Tests +555, Other +29. Total +588 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 4 0 +4
Tests 4 589 34 +555
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 29 0 +29
Total 6 622 34 +588

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: canonical
Canonical: #196702
Summary: The temporary test-only split was closed in favor of this combined repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is bounded Gateway test repair and defensive admission hardening, with no demonstrated user outage or reachable authorization bypass.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show the missing-admission refusal through production owners before credential acquisition or launch, with sensitive values redacted.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-10T14:42:25.136Z sha 3792244 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T15:46:53.131Z sha 9dcd1ba9b0697cb9ad4e1512c728d3bc4b1c7b33 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T15:54:45.824Z sha 9dcd1ba9b0697cb9ad4e1512c728d3bc4b1c7b33 :: needs real behavior proof before merge. :: none

Reviewed November 10, 2026, 12:25 PM ET / 17:25 UTC (Revision 4).

@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 Nov 10, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@obviyus obviyus changed the title fix(gateway): restore missing-admission refusal and update 3 gateway tests broken on main fix(gateway): restore missing-admission refusal for persisted worker turn input Nov 10, 2026
@obviyus
obviyus marked this pull request as draft November 10, 2026 16:39
@obviyus
obviyus force-pushed the fix/main-gateway-test-regressions branch from 9dcd1ba to 3fa0518 Compare November 10, 2026 17:18
@obviyus obviyus changed the title fix(gateway): restore missing-admission refusal for persisted worker turn input fix(gateway): restore missing-admission refusal and update 3 gateway tests broken on main Nov 10, 2026
@obviyus
obviyus marked this pull request as ready for review November 10, 2026 17:18
@obviyus

obviyus commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 Nov 10, 2026
obviyus and others added 3 commits November 11, 2026 08:17
Since d53921a (#194129), a broad sessions catalog notification no longer invalidates retained sharing facts; the commit guard rereads membership and refuses the fork with SESSION_PARTICIPATION_REQUIRED, matching the writer-fault variant. The fork still fails with SessionMutationAuthorizationChangedError and leaves storage unchanged.

Co-authored-by: obviyus <[email protected]>
d7aaafe (#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate.

Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read.

Co-authored-by: obviyus <[email protected]>
…e path

Add a QA script scenario that dispatches a managed-worktree session to a
proof-owned paired-node worker through an isolated Gateway and exercises the
production credential, transport and launch path:

- chat.send and qa-channel turns with a readable admission launch once, reach
  the mock model once and commit their reply;
- cancelling the run or reclaiming the placement while the launch frame is held
  on the node makes the Gateway cancel the launch before the node handles it:
  no worker process starts, the model sees no request and no worker transcript
  or live event is acknowledged.

Co-authored-by: obviyus <[email protected]>
@obviyus
obviyus force-pushed the fix/main-gateway-test-regressions branch from 3fa0518 to ecf9170 Compare November 11, 2026 02:52
@obviyus
obviyus merged commit e212ede into main Nov 11, 2026
129 of 130 checks passed
@obviyus
obviyus deleted the fix/main-gateway-test-regressions branch November 11, 2026 03:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…tests broken on main (openclaw#196702)

* test(gateway): expect participation refusal after retained sharing facts

Since 4d6df47 (openclaw#194129), a broad sessions catalog notification no longer invalidates retained sharing facts; the commit guard rereads membership and refuses the fork with SESSION_PARTICIPATION_REQUIRED, matching the writer-fault variant. The fork still fails with SessionMutationAuthorizationChangedError and leaves storage unchanged.

Co-authored-by: obviyus <[email protected]>

* fix(gateway): reject worker turns with persisted input but no admission

1acafee (openclaw#196337) deferred legacy worker input persistence until after the policy gate and dropped the missing-admission check with the early persistence path. Input that the runtime already persisted without a readable canonical anchor then acquired credentials, started a tunnel and launched from the stale leaf. Restore the fail-closed check before credentials for already-persisted input; unpersisted input is still admitted after the gate.

Update the detached-context fixtures for the intended ordering: unpersisted input reads its prefix through the transcript open, so the authority-change probes hook that read.

Co-authored-by: obviyus <[email protected]>

* test(qa): prove worker turn admission and authority on the paired-node path

Add a QA script scenario that dispatches a managed-worktree session to a
proof-owned paired-node worker through an isolated Gateway and exercises the
production credential, transport and launch path:

- chat.send and qa-channel turns with a readable admission launch once, reach
  the mock model once and commit their reply;
- cancelling the run or reclaiming the placement while the launch frame is held
  on the node makes the Gateway cancel the launch before the node handles it:
  no worker process starts, the model sees no request and no worker transcript
  or live event is acknowledged.

Co-authored-by: obviyus <[email protected]>

---------

Co-authored-by: obviyus <[email protected]>
steipete added a commit that referenced this pull request Nov 11, 2026
Adopt the original repair from #196487 while preserving its branch history.
Carry forward the independently validated context reader, focused regression
proof, documentation, and synthetic timing/allocation measurements.

The final tree matches 68aac2c exactly.
Keep the current admission and unrelated Gateway test repairs already landed
through #196702 and #196889. No runtime source change was added in adoption.

Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Expose the exact prepared image snapshot to input policy hooks across embedded, CLI, and Gateway worker runners. Reuse CLI prepared input across retries and isolate hook mutations from submitted input.

Release adaptation: retain the existing hook type owner and runtime generation scope. Include the required missing-admission refusal from #196702, selected-branch recorder hydration from #196487, and deferred context-admission assertions from #197210. Do not import unrelated session rewind, prompt continuity, or cold-start owners.

Selected source commits:
(cherry picked from commit d7aaafe)
(partial companion from commit e212ede)
(partial companion from commit ebf6c06)
(partial companion from commit eafa247)

Co-authored-by: obviyus <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant