Skip to content

fix: allow guests to notify owned child sessions - #162986

Merged
shakkernerd merged 1 commit into
mainfrom
fix/owned-child-notify
Oct 1, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/owned-child-notify

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Operators limited to operator.sessions.write, including guests, cannot notify their own child sessions with sessions_send(mode: "notify"). The child passes the tool's visibility checks, but the notification adapter then authorizes it as the broader agent operation and rejects it with missing scope: operator.write.

Fixes #162924.

User Impact

An authorized guest can queue context for an owned child without starting a new run or receiving broad write permission. The notification keeps its existing process-local lifetime. Foreign-owned sessions remain denied, and loss of the original source authority or a role change during preparation prevents enqueueing. Already-accepted input keeps its existing queue semantics.

This change requires no configuration, protocol or stored-data migration. It does not change guest roles, the general agent RPC, active-run steering, shared publishing, or sandbox setup.

Why This Change Was Made

The existing in-process mutation helper now takes the operation being authorized. Notifications select sessions.send, which already supports narrow session-write authority. The adapter translates its session key to that operation's key field, so admission and the final guard authorize the actual target. It retains the existing original/selected requester capture, current-authority assertions and session mutation fences. Local notification admission also requires an existing admitted target: the normal send RPC can create a session, but notifications cannot queue for a target removed during preparation.

The helper's only other caller, active-run steering, explicitly retains agent authorization and its existing custody/settlement behavior. Keeping both callers on the same authorization owner avoids a second notification permission path. The session-tool documentation now describes the narrow notification behavior.

Evidence

An isolated Linux regression uses the real session tool, in-process Gateway authorization, SQLite-backed ownership and system-event queue. With a fresh owned-child fixture, original production code at b66471a fails for missing operator.write. A second comparison completes canonical target deletion and then demonstrates an incorrectly queued notification when only the admitted-target guard is removed. Restoring the guard makes the current six-case suite pass through the existing database-worker test route:

  • Guest and ordinary write-scoped operators enqueue to the intended owned child without starting a run; accepted input remains queued after source revocation.
  • A visible foreign-owned child is denied without a queued event.
  • Source revocation and role narrowing during awaited authorization prevent enqueueing.
  • Canonical target deletion completes before authorization resumes; notification then fails and leaves the queue empty.

pnpm test src/gateway/local-request-context.session-notify.test.ts --maxWorkers=1 passed all six cases in 47.74 seconds wall time, including 16.58 seconds of worker preparation; the test bodies took 11.15 seconds. On the exact-head hosted CI job, all six cases passed with 6.118 seconds of test-body time; job setup is excluded from that figure. This boundary needs the real authorization and persistence owners: mocking either would miss the incorrect operation, target-field mapping or lifecycle admission. The test reuses the existing isolated Gateway fixture and broker-backed suite, with no per-test server process or real timer.

Formatting, full lint, structural/generated-contract checks, documentation checks, security checks and production/test compiler coverage passed, retaining earlier results for unchanged inputs. Package-boundary compilation passed for all 127 plugins, and its negative canary passed. The full build passed in 9m 3s. The selected Gateway plan passed all 25 files and 364 tests, including notification, steering, authority and continuation coverage. The complete native affected run passed all 68 selected files and 2,369 tests (one existing skipped case), across 12 plans in 734.57 seconds. It also passed a real-Gateway initial-setup smoke covering exactly-once handling of queued browser and sessions_send input. Independent source review and separate P0/P1 autoreview are clean. ClawSweeper reviewed the exact head at Platinum with no findings; all hosted checks passed on the same head. All runtime proof used isolated fixtures; no existing live Gateway was changed.

@shakkernerd shakkernerd self-assigned this Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 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: M labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 4:45 PM ET / 20:45 UTC.

ClawSweeper review

What this changes

The PR lets guests notify their authorized owned child sessions without broad write permission, preserves steering authorization, and adds boundary regressions and documentation.

Merge readiness

✅ Ready for maintainer review

This repair remains necessary: current main still requires broad write authority for notifications. The patch uses the existing narrow session-send policy while preserving final authorization checks; no actionable introduced defect was found.

Priority: P2
Reviewed head: d55f81c5c54baa6a7021ab02000b8b22396b7e5b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful production-boundary regressions and documented execution evidence; source review found no blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its reported isolated Linux execution exercises the real notification tool, Gateway authorization, SQLite ownership, and final queue for allowed, foreign-owned, revoked, role-narrowed, and deleted-target cases; source inspection supports those safeguards without a remaining material authority uncertainty. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its reported isolated Linux execution exercises the real notification tool, Gateway authorization, SQLite ownership, and final queue for allowed, foreign-owned, revoked, role-narrowed, and deleted-target cases; source inspection supports those safeguards without a remaining material authority uncertainty. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction: Reviewed the merge-base-to-head delta supplied by the host. Notification delivery selects sessions.send; steering explicitly retains agent. The helper translates sessionKey to key and rejects notifications without an admitted existing target.
Still necessary on main: Fetched main still hardcodes agent authorization in the local session mutation helper. It therefore lacks this notification-specific repair.
Existing narrow authorization contract: sessions.send already accepts operator.sessions.write and targets key; agent targets sessionKey. Reusing this contract avoids broadening guest roles or creating a competing permission owner.
Findings None None.
Security None None.

How this fits together

The session-send tool lets agents coordinate with other sessions. Notification delivery passes through Gateway authorization before placing context in the target’s process-local queue without starting a run.

flowchart TD
 A[Agent notification request] --> B[Session visibility checks]
 B --> C[Gateway session-send authorization]
 C --> D[Current authority and target checks]
 D --> E{Authorized existing target?}
 E -->|Yes| F[Process-local notification queue]
 E -->|No| G[Reject without enqueue]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +11, Tests +218, Docs +2. Total +231 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 19 8 +11
Tests 2 218 0 +218
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 239 8 +231

Review metrics

Metric Value Why it matters
Boundary test cost Reported 47.74 s wall; 11.15 s test time The new authorization suite documents its measured cost and explains why real persistence and authorization owners are required.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #162924
Summary: This PR directly implements the notification authorization repair described by the linked open issue.

Members:

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

Technical review

Best possible solution:

Keep notification admission with the existing session-send authorization owner and retain synchronous current-authority and target checks before enqueue.

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

Yes, source establishes the path: an operator holding only operator.sessions.write reaches notification delivery, which current main authorizes as agent and rejects for missing broad write scope. The reported failing Linux regression was not independently executed here.

Is this the best way to solve the issue?

Yes, selecting the existing session-send policy and translating its target field is a narrow repair; steering retains its previous authorization and queue custody.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The repair restores one context-only coordination mode for narrowly authorized operators without evidence of a broader runtime outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: The MEMBER-authored PR is exempt from ordinary contributor proof. Its reported isolated Linux execution exercises the real notification tool, Gateway authorization, SQLite ownership, and final queue for allowed, foreign-owned, revoked, role-narrowed, and deleted-target cases; source inspection supports those safeguards without a remaining material authority uncertainty. No stored-data contract changes.

Label justifications:

  • P2: The repair restores one context-only coordination mode for narrowly authorized operators without evidence of a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its reported isolated Linux execution exercises the real notification tool, Gateway authorization, SQLite ownership, and final queue for allowed, foreign-owned, revoked, role-narrowed, and deleted-target cases; source inspection supports those safeguards without a remaining material authority uncertainty. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction: Reviewed the merge-base-to-head delta supplied by the host. Notification delivery selects sessions.send; steering explicitly retains agent. The helper translates sessionKey to key and rejects notifications without an admitted existing target. (src/gateway/server-plugin-in-process-dispatch.ts:231, d55f81c5c54b)
  • Still necessary on main: Fetched main still hardcodes agent authorization in the local session mutation helper. It therefore lacks this notification-specific repair. (src/gateway/server-plugin-in-process-dispatch.ts:231, d457b2c61131)
  • Existing narrow authorization contract: sessions.send already accepts operator.sessions.write and targets key; agent targets sessionKey. Reusing this contract avoids broadening guest roles or creating a competing permission owner. (src/shared/session-method-scopes-base.ts:57, d55f81c5c54b)
  • Final-effect authority safeguards: The adapter checks captured caller and source authority, admitted target existence, and current mutation authorization immediately before synchronous enqueue. The shared mutation owner rechecks creator identity, session incarnation, sharing access, agent access, and required sandbox provenance. (src/gateway/server-plugin-in-process-dispatch.ts:262, d55f81c5c54b)
  • Queue boundary regression coverage: Six cases invoke the real session tool and authorization owner with SQLite-backed ownership. They inspect successful owned-child enqueue, broad-write compatibility, foreign-target denial, source revocation, role narrowing, and completed target deletion. The preparation spy gates execution but delegates to production authorization; queue emptiness verifies rejection before the final effect. (src/gateway/local-request-context.session-notify.test.ts:135, d55f81c5c54b)
  • Captured execution evidence: The supplied complete PR body reports the original missing-scope failure, a deletion-guard negative comparison, and six passing after-fix cases on isolated Linux: 47.74 seconds wall and 11.15 seconds test time. These reported executions were checked against the committed scenarios but were not independently rerun during this read-only review. (src/gateway/local-request-context.session-notify.test.ts:135, d55f81c5c54b)

Likely related people:

  • Peter Steinberger: 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.

@shakkernerd
shakkernerd merged commit d73741d into main Oct 1, 2026
149 checks passed
@shakkernerd
shakkernerd deleted the fix/owned-child-notify branch October 1, 2026 20:57
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: guests can notify their owned child sessions while current authority and target checks remain enforced.

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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

sessions_send notify requires broad write for an owned guest session

1 participant