Skip to content

fix: let write operators control their own sessions through agents - #160296

Merged
VACInc merged 6 commits into
mainfrom
openclaw/why-can-t-it-archive-itself
Sep 28, 2026
Merged

VACInc merged 6 commits into
mainfrom
openclaw/why-can-t-it-archive-itself

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

High Level TLDR

Agents acting for a write operator can archive, restore, and stop sessions that operator created or is assigned to, when normal session access also allows it. Ordinary active-run sends and explicit steering retain the existing sessions_send access rules.

User impact

operator.write users can ask their agents to archive, restore, and Stop eligible sessions. operator.sessions.write alone does not expose these controls. Assignment alone never grants access. Self-archive waits for the current reply to finish; Stop targets another session, with an optional exact run ID. Swarm collectors cannot discover or execute Stop. Existing administrator, private-session, settings, ownership, deletion, and standalone HTTP restrictions remain.

What Problem This Solves

The old discovery gate hid the whole sessions tool behind Gateway administration. This branch carries host-issued operator authority through existing Gateway mutation owners, then rechecks access, creator or assignee, target generation, and current authority at the action boundary.

Earlier PR heads had two send regressions. startSessionsSendAgentRun first applied restricted session-control preparation to every non-owner active-run send, including a message with no mode. Narrowing that guard to explicit mode="steer" still changed the published steering contract: an unrelated write operator who passed the existing send-access check could no longer steer. This head removes the separate control grant and guarded queue path from sessions_send, restoring main's existing send and steering behavior while keeping the new archive/restore/Stop controls restricted. Separately, a projection test waited for facts.kind="unchanged", while assignSessionOwner publishes facts.kind="owner"; the corrected assertion covers the two CI cases that failed on the prior head.

Evidence

  • On head 3cc054c4fc749e396bce34b03cc6fe8f6fc255e0, pnpm test src/gateway/mcp-http.session-controls.test.ts --maxWorkers=1 ran against an isolated loopback MCP server: Test Files 1 passed (1); Tests 10 passed (10); real 23.55s (45.05s on the earlier cold run). Five bearer-bound HTTP tools/call cases and five in-process dispatcher cases passed. The HTTP assertions require status 200, an allowed archive result, and a persisted SQLite archivedAt; unassigned, reassigned, role-revoked, and replaced targets require an error and no archive on the intended target. Reassignment, revocation, and replacement occur after target preparation and before the Gateway write resumes.
  • pnpm test src/gateway/local-request-context.session-archive.test.ts --maxWorkers=1: Test Files 1 passed (1); Tests 13 passed (13); real 55.80s. The assembled sessions_send tool queued explicit steering for both assigned and unrelated targets under operator.write and configured visibility: "all". With the previous PR code restored temporarily, the unrelated case failed with status: "forbidden"; this head passes. The same file also verifies restricted archive/Stop behavior. sessions_send admission and A2A siblings passed 48 tests across two files.
  • pnpm test src/gateway/session-row-projection.worker-read.test.ts --maxWorkers=1: Test Files 1 passed (1); Tests 18 passed (18); real 20.87s, including both cases that failed in the prior CI run.
  • The other affected tool, Gateway, and membership files passed locally. This repair pass ran 199 tests across 11 files, with the changed send and HTTP cases rerun on the final candidate. node scripts/check-changed.mjs -- <changed paths> passed formatting, production and test types, core lint, and guards. Independent P0/P1 autoreview of the final repair delta was clean.

Verification

Measured local wall time for each new or changed test file (pnpm test <file> --maxWorkers=1, one worker):

Test file Wall time
src/agents/tools/sessions-control-authority.test.ts 48.57s
src/agents/tools/sessions-tool.collector.test.ts 11.96s
src/agents/tools/sessions-tool.test.ts 13.26s
src/gateway/local-request-context.session-archive.test.ts 55.80s
src/gateway/mcp-http.archive-authority.test.ts 13.18s
src/gateway/mcp-http.runtime.test.ts 10.29s
src/gateway/mcp-http.session-controls.test.ts 23.55s warm; 45.05s cold
src/gateway/session-membership-projection.test.ts 8.73s
src/gateway/session-row-projection.worker-read.test.ts 20.87s

The authority, assembled Gateway, and cold HTTP files exceed 30s wall time because their import or transform graph is large; the Gateway and HTTP files also exercise real queue or bearer binding, Gateway mutation, and persisted SQLite final effects. Those contracts cannot be established by a cheaper helper-only test. Exact-head CI on 3cc054c4fc749e396bce34b03cc6fe8f6fc255e0 ran as CI run 36435123465 and did not pass. The PR context and evidence gate passed after this body gained its required authored section headings. Two unrelated test shards failed:

  • checks-ui-e2e (6/9): ui/src/e2e/chat-user-bubble-disclosure.e2e.test.ts timed out in Playwright locator.screenshot while waiting for the element to stabilize after restoring the desktop viewport. The exact file passed locally on this head, 32/32 in 40.82s, including that case. The passing replay does not explain or fix the CI timeout. A local --shard 6/9 run used a different file map and did not select this file; it also ended with three unrelated real-Gateway suite setup failures because this host's Node 25.9.0 is rejected by the repository's node:sqlite guard (73 files and 350 tests passed). It is not a successful CI-shard replay.
  • checks-windows-node-test-5: src/daemon/schtasks.env-case.real.test.ts expected live child argv but one CIM read returned null after child readiness. This PR does not change the Windows launcher or CIM owner. This Linux worktree cannot replay the native Windows case; the cause remains unproven.

Neither failed file nor its owning UI/daemon path changes in this PR. No speculative timeout, retry, assertion, or baseline change was made. These failures leave exact-head CI red. ClawSweeper's revision 5 found no discrete code defect. The session-access owner approved the exact-head operator.write archive, restore, and Stop grant, including clearing queued follow-ups for eligible created or assigned sessions; the new exact-head ClawSweeper review is pending.

What was not tested

No live Gateway, real user channel, or deployed service was used. The user barred live infrastructure changes; the isolated bearer-bound HTTP server and SQLite readback are the closest permitted transport and final-effect proof. No before/after runtime latency benchmark was run: the baseline has no corresponding non-admin archive/Stop flow, and this send repair restores main's queue path. The session-access owner approved the new archive/restore/Stop grant on this head; this PR is not merged or deployed.

Contributor credit

Reported and requested by @VACInc.

roboclaw-bot and others added 2 commits September 28, 2026 08:36
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 0fc82ef1-734a-4429-8fad-403e03085288
@clawsweeper

clawsweeper Bot commented Sep 28, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Sep 28, 2026
@VACInc
VACInc marked this pull request as ready for review September 28, 2026 08:40
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 3cc054c4fc749e396bce34b03cc6fe8f6fc255e0
  • Maintainer: @roboclaw-bot
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/tools/sessions-control-authority.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/server-methods/chat-abort-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 11:09 AM ET / 15:09 UTC (Revision 7).

ClawSweeper review

What this changes

The branch lets agents acting for write operators archive, restore, and stop eligible sessions through Gateway controls, while preserving existing session-send behavior.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still lacks these agent session controls, and the session-access owner approved the permission boundary for this exact head. The earlier steering finding is resolved; I found no new blocking code defect.

Priority: P2
Reviewed head: 3cc054c4fc749e396bce34b03cc6fe8f6fc255e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The branch has strong production-boundary proof and a coherent authority design, though the change spans several session and Gateway owners.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports exact-head runs of an isolated bearer-bound HTTP archive flow with SQLite readback and in-process Stop checks; inspected tests cover allowed targets and forbidden or stale authority before final effects. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports exact-head runs of an isolated bearer-bound HTTP archive flow with SQLite readback and in-process Stop checks; inspected tests cover allowed targets and forbidden or stale authority before final effects. No stored-data contract changes.
Evidence reviewed 9 items Current-main capability boundary: At the fetched main revision, the sessions action list has no Stop action; non-owner discovery also retains the owner-only sessions deny. The central change remains necessary.
Introduced authority boundary: The introduced code checks host-issued operator authority, session generation, current profile and sharing access, and creator or human-assignee relationship.
Final-effect guard: The tool carries its target assertion into the in-process Gateway mutation guard; transport fallback rejects guarded controls. Stop additionally binds cancellation to the admitted session identity.
Findings None None.
Security None None.

How this fits together

The agent sessions tool receives an operator’s request and sends authorized actions to the Gateway. The Gateway checks current session access before changing session state or stopping active and queued work.

flowchart LR
A[Write operator] --> B[Agent sessions tool]
B --> C{Current operator grant and session access}
C --> D{Creator or human assignee}
D --> E[Gateway archive restore or Stop]
E --> F[Session state and queued work]
C --> G[Denied]
D --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +588, Tests +1520, Docs +1. Total +2109 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 20 786 198 +588
Tests 9 1521 1 +1520
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 2310 201 +2109

Review metrics

Metric Value Why it matters
Approved operator control surface 3 limited controls: archive, restore, Stop The approved write-operator grant includes session-wide Stop, which can clear queued follow-ups.

Technical review

Best possible solution:

Retain the approved, target-bound controls in the existing Gateway mutation paths, with session-send steering continuing under its established access rules.

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

Not applicable as a bug reproduction: current main documents and enforces an owner-gated sessions tool, while the branch adds an approved operator capability.

Is this the best way to solve the issue?

Yes. The branch uses the existing Gateway mutation owners and checks live caller, access, relationship, and target identity before effects, without changing the established steering contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 741c9cb56bde.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded improvement to operator session management, with no demonstrated urgent regression on the current head.
  • merge-risk: 🚨 message-delivery: The approved session-wide Stop action can clear queued follow-ups for an eligible session.
  • merge-risk: 🚨 security-boundary: The approved change expands which authenticated operators can archive, restore, or stop sessions through agents.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports exact-head runs of an isolated bearer-bound HTTP archive flow with SQLite readback and in-process Stop checks; inspected tests cover allowed targets and forbidden or stale authority before final effects. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports exact-head runs of an isolated bearer-bound HTTP archive flow with SQLite readback and in-process Stop checks; inspected tests cover allowed targets and forbidden or stale authority before final effects. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • VACInc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RoboClaw: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-28T08:47:02.741Z sha 65b1917 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-28T12:26:28.944Z sha fb02b7b :: needs real behavior proof before merge. :: [P1] Preserve existing non-owner active-run sends
  • reviewed 2026-09-28T12:55:03.032Z sha 62b5310 :: needs real behavior proof before merge. :: [P1] Preserve existing non-owner active-run sends | [P3] Report measured cost for the new boundary tests
  • reviewed 2026-09-28T13:46:34.065Z sha bfca7c0 :: blocked before merge. :: [P1] Preserve existing non-owner steering by default
  • reviewed 2026-09-28T14:39:35.909Z sha 3cc054c :: blocked before merge. :: none
  • reviewed 2026-09-28T14:50:17.068Z sha 3cc054c :: blocked before merge. :: none

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 6dac9f04-6b73-412a-9c7d-89ba9c437d07
@roboclaw-bot roboclaw-bot changed the title fix: let non-admin operators ask agents to archive sessions fix: let write operators control their own sessions through agents Sep 28, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 04add422-6ba1-46e1-a45e-87520b6afcbf
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 28, 2026
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

Head bfca7c0 preserves ordinary active-run sends and fixes the CI publication assertion. Focused tests, bearer-bound HTTP final effects, and changed checks passed. The PR body has the redacted proof and measured test costs.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed P1 High-priority user-facing bug, regression, or broken workflow. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper clawsweeper Bot added the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Sep 28, 2026
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

Head 3cc054c restores the existing sessions_send steering admission and removes its separate control guard. The assembled Gateway steering regression fails on the previous head and passes now; bearer-bound HTTP final-effect cases pass on this head. The PR body has current proof and test costs. Human approval of the new archive/restore/Stop grant remains pending.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

@clawsweeper re-review

Maintainer decision (session-access owner): approved. The expanded operator.write session-control grant is the intended trust model for head 3cc054c4fc749e396bce34b03cc6fe8f6fc255e0.

Accepted boundary: an agent acting with operator.write may archive, restore, and Stop (including clearing queued follow-ups) only sessions it created or is assigned to. Sessions owned by others and owner-only sessions remain out of reach; owner-level authority is unchanged. Steering keeps the existing sessions_send access checks already on main.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@VACInc VACInc self-assigned this Sep 28, 2026
@VACInc
VACInc merged commit dc08740 into main Sep 28, 2026
207 of 254 checks passed
@VACInc
VACInc deleted the openclaw/why-can-t-it-archive-itself branch September 28, 2026 15:55
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160296)

* fix: let non-admin operators ask agents to archive sessions

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

* fix: let non-admin operators ask agents to archive sessions

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 0fc82ef1-734a-4429-8fad-403e03085288

* fix: let write operators control their own sessions through agents

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 6dac9f04-6b73-412a-9c7d-89ba9c437d07

* fix: let write operators control their own sessions through agents

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: 04add422-6ba1-46e1-a45e-87520b6afcbf

* fix(sessions): preserve ordinary active-run sends

* fix(sessions): retain established active-run steering

---------

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL 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.

2 participants