Skip to content

fix(gateway): keep patch-created sessions visible to their creator - #128774

Merged
steipete merged 1 commit into
mainfrom
steipete/practical-euclid-09346e
Aug 24, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/practical-euclid-09346e

Conversation

@steipete

@steipete steipete commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #128548

What Problem This Solves

Fixes an issue where operators who created a session through sessions.patch immediately lost access to their own session on gateways that hide other users' sessions. Subsequent reads and writes incorrectly failed with Session ... was not found, including when gateway.roles sets sessions.others="none".

Why This Change Was Made

Carry the authenticated operator's existing session-creation provenance through the patch mutation owner and stamp it only when sessions.patch genuinely creates a new session row. This matches sessions.create semantics while preserving the original provenance of existing rows and placeholder aliases.

User Impact

Operators can immediately see, read, and update sessions they create through sessions.patch when session visibility is restricted. Existing sessions keep their original creation provenance.

Evidence

  • node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts src/gateway/sessions-patch.test.ts: 92 tests passed across both focused suites.
  • The new gateway owner-boundary regression was verified to fail before the production fix and now passes while checking creator provenance, visibility, and a subsequent patch.
  • node scripts/check-changed.mjs -- src/gateway/sessions-patch.ts src/gateway/server-methods/sessions-patch-engine.ts src/gateway/server-methods/sessions-mutations.owner.test.ts: passed.
  • Fresh Codex autoreview: clean, with no accepted or actionable findings.
  • AI-assisted change. Validation exercises the real in-process gateway mutation handler; no separate Control UI recording was captured.
  • Exact-head pull-request CI passed for 1441a462b97c799a11fdffd2d6d4a0642c19207e: https://github.com/openclaw/openclaw/actions/runs/32743692221.
  • ClawSweeper independently reran node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts: 4 tests passed, with no actionable correctness or security findings.
  • ClawSweeper merge-risk follow-up: retain the necessary +4 production lines because the mutation owner must resolve the authenticated creation identity and pass it to the existing canonical projection; no clearer net-neutral owner-boundary repair exists.
  • ClawSweeper stored-state follow-up: no schema or migration change applies. The fix writes existing canonical creation fields only for genuinely new rows and never rewrites existing rows or placeholder aliases.
  • ClawSweeper next-step follow-up: exact-head CI is green and the PR is proceeding through the repository-native maintainer review, preparation, and merge gates; no separate repair lane is needed.

…sions

The sessions.patch create path skipped createdVia and createdActor, making the creator own session invisible under createSessionListEntryFilter when gateway.roles sets sessions.others=none.

Thread resolveOperatorSessionCreation through sessions-patch-engine into projectSessionsPatchEntry and stamp only genuinely new rows, mirroring session-create-service. Preserve existing rows and placeholder aliases without restamping their provenance.

Add an owner-boundary regression proving the identified creator can see and update a patch-created session. Follow-up of #128548.
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 15:14
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 24, 2026, 11:20 AM ET / 15:20 UTC.

ClawSweeper review

What this changes

This PR records the authenticated operator as creator when sessions.patch creates a new session, so restricted operators can subsequently see and update that session.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Patch is correct and still necessary: current main creates missing sessions.patch entries without creator provenance, while the role visibility filter requires that provenance. It remains open for normal maintainer merge review; likely related person: steipete (high confidence).

Priority: P1
Reviewed head: 1441a462b97c799a11fdffd2d6d4a0642c19207e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned repair with a boundary regression test and no actionable correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless supplies focused in-process Gateway regression evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless supplies focused in-process Gateway regression evidence.
Evidence reviewed 5 items Current-main defect: Current main resolves the patch projection without a creation value, and its projection creates a missing row with an ID and timestamp but no creator stamp.
Visibility contract: The current role-aware list filter admits a restricted operator only when the entry creator ID matches that operator, so an unstamped new row is hidden.
Proposed owner-boundary repair: The patch resolves the authenticated creation identity once in the mutation owner and applies the canonical creation stamp only when no row previously existed; placeholder aliases and existing rows are preserved.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.tsrunner@runnervm76f27:/tmp/clawsweeper-live-proof-128774-8L9OQ4/target$ no
de scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts
node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128774-8L9OQ4/target

 ✓  gateway-methods  ../../src/gateway/server-methods/sessions-mutations.owner.test.ts (4 tests) 3263ms
     ✓ keeps a newly created session visible to its identified non-admin creator  1312ms
     ✓ records the trusted in-process agent tool caller as the assigning agent  1228ms
     ✓ lets a write-scoped viewer assign a shared session without changing sharing authority  446ms

 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  15:21:40
   Duration  16.83s (transform 11.01s, setup 750ms, import 12.54s, tests 3.26s, environment 0ms)

[test] passed 1 Vitest shard in 21.45s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128774-8L9OQ4/target$ node scripts/run-vitest.mjs src/gateway/server-methods/sessions-mutations.owner.test.ts
































Assertions:

  • PASS expect_output: Test Files

How this fits together

The Gateway turns authenticated session mutations into persisted session entries. Later Gateway read and mutation paths filter those entries by their recorded creator when a role hides other users’ sessions.

flowchart LR
  A[Authenticated operator] --> B[Gateway patch request]
  B --> C[Session patch projection]
  C --> D[Creator provenance]
  D --> E[Stored session entry]
  E --> F[Role visibility filter]
  F --> G[Read and update access]
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by four net lines for this bug fix; the authenticated creation value must be threaded to the canonical projection and no clearer net-neutral absorption was found.
  • Complete next step (P2) - No repair lane is needed: the source review found no actionable defect, while the maintainer-authored and maintainer-labeled PR awaits normal exact-head CI and merge handling.
Agent review details

Security

None.

PR surface

Source +4, Tests +64. Total +68 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 18 14 +4
Tests 1 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 82 14 +68

Review metrics

Metric Value Why it matters
Production versus regression coverage production +4 net, tests +64 The small production increase carries authenticated creation provenance into the existing canonical session projection, with one owner-boundary regression covering persistence, visibility, and follow-up mutation.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/sessions-mutations.owner.test.ts, serialized state: src/gateway/server-methods/sessions-patch-engine.ts, serialized state: src/gateway/sessions-patch.ts, unknown-data-model-change: src/gateway/server-methods/sessions-mutations.owner.test.ts, unknown-data-model-change: src/gateway/sessions-patch.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Merge the small producer-side repair after exact-head CI, retaining the write-once rule that stamps only genuinely new rows and never rewrites existing or placeholder provenance.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Merge the small producer-side repair after exact-head CI, retaining the write-once rule that stamps only genuinely new rows and never rewrites existing or placeholder provenance.

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

Yes—current main’s missing-row patch path omits createdActor, and the current restricted-role filter rejects entries whose creator does not match the operator. The added focused test exercises that path through the in-process Gateway handler.

Is this the best way to solve the issue?

Yes—the repair belongs at the session-entry producer, reuses the canonical creation-stamp helper, and preserves write-once provenance on existing and placeholder rows.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 70d7fb5771f9.

Labels

Label changes:

  • add P1: Restricted operators can currently create a session but then lose access to that session, breaking a core Gateway workflow.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless supplies focused in-process Gateway regression evidence.

Label justifications:

  • P1: Restricted operators can currently create a session but then lose access to that session, breaking a core Gateway workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless supplies focused in-process Gateway regression evidence.

Evidence

What I checked:

Likely related people:

  • steipete: History attributes the current creator-based visibility filter to this contributor, and the merged related gateway-roles work established the restricted-session behavior this repair completes. (role: introduced the current visibility and provenance area; confidence: high; commits: 8fe2c1b83ca2, 53dcaaedec19; files: src/gateway/session-sharing.ts, src/gateway/server-methods/session-creation-provenance.ts, src/gateway/sessions-patch.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 28ee832 into main Aug 24, 2026
308 checks passed
@steipete
steipete deleted the steipete/practical-euclid-09346e branch August 24, 2026 15:52
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
…sions (openclaw#128774)

The sessions.patch create path skipped createdVia and createdActor, making the creator own session invisible under createSessionListEntryFilter when gateway.roles sets sessions.others=none.

Thread resolveOperatorSessionCreation through sessions-patch-engine into projectSessionsPatchEntry and stamp only genuinely new rows, mirroring session-create-service. Preserve existing rows and placeholder aliases without restamping their provenance.

Add an owner-boundary regression proving the identified creator can see and update a patch-created session. Follow-up of openclaw#128548.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant