Skip to content

feat(openclaw-id): member roles come from gateway.roles.definitions - #197739

Merged
jalehman merged 8 commits into
mainfrom
ocf-518-member-roles-from-definitions
Nov 14, 2026
Merged

jalehman merged 8 commits into
mainfrom
ocf-518-member-roles-from-definitions

Conversation

@jalehman

@jalehman jalehman commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Gateway hardcodes what the OpenClaw ID member roles operator and viewer allow, so an owner cannot change them or add a role of their own.

User Impact

User impact: an owner can edit what Operator and Viewer members may do, and can define more member roles, by editing gateway.roles.definitions. OpenClaw ID is a Labs feature and is off by default; with it off, nothing here runs.

Changes an owner will notice:

  • Turning on OpenClaw ID, or starting a Gateway with it on, writes missing operator and viewer definitions into the config file. It writes no default, so the claw's other sign-ins behave as before. This rewrites the config file as JSON and removes JSON5 comments, as every config write does.
  • Viewer members are limited to conversations (operator.sessions.read). They no longer read logs or the user directory.
  • A member whose role has no definition cannot connect. Deleting a definition cuts off its members until an owner gives them another role.
  • A member role has no ceiling in code. A definition that includes operator.admin or operator.pairing gives its members those scopes. No preset includes them.
  • users.setRole with a role name is refused for an OpenClaw ID member's profile. A member's role comes from membership.

Known limit: a Viewer cannot open the Access page, because loading plugin pages needs operator.read.

Why This Change Was Made

  • A member's role name is looked up in the current gateway.roles.definitions on every admission and authority check: WebSocket connect, Gateway HTTP, the tunnel API, retained and recovered runs, sandbox streams and session continuations. Editing or deleting a definition closes the affected members' connections and stops their retained work.
  • The membership role takes precedence over any named role, default role or GitHub mapping on the member's profile.
  • Presets are ordinary definitions. They are written only when missing, never overwrite an edited preset, and are not written again after an owner deletes one until OpenClaw ID is next turned on or the Gateway restarts.
  • At startup the presets are installed before the runtime config is published, so existing members keep access after upgrade in every reload mode. If a running Gateway cannot apply the saved definitions (gateway.reload.mode: "off"), the OpenClaw ID status says a restart is needed.

Evidence

  • New tests cover: edited presets and custom roles; unknown role refused on all surfaces; Viewer can read conversations and cannot read logs, list users or send; a custom admin role gets admin scopes; live eviction when a definition is edited or deleted; retained runs and sandbox streams losing an edited role's authority; preset writing on activation and at startup, with existing definitions, default and assignments preserved; nothing written with OpenClaw ID off; users.setRole refused for members.
  • One unmocked Gateway test proves that turning on OpenClaw ID does not refuse a device-token-only reconnect.
  • Focused runs: 281 backend tests in 21 files and 85 UI tests in 4 files for the first commit; 61 tests in 6 files for the second. Targeted typechecks, lint, format and ratchets pass.
  • Independent review of the first commit found no P0, one P1 and two P2. The second commit fixes the P1 (with config reload off, presets written at startup could reach disk without reaching the running Gateway, leaving existing members refused until another restart) and one P2 (a profile merge during users.setRole could skip the member check). The other P2 is the comment removal stated above. A second review of the fix commit found nothing.

Test lines: this PR adds 1,824 net test lines, 1,424 over the 400-line allowance. The allocation record is config/test-lines-allocations/member-role-definitions.txt. The tests cover separate transport, retained-authority and config-lifecycle boundaries, each of which can fail on its own.

Rebased onto main after #197697 and #197712 merged; eight commits. The fourth adapts to main: it keeps the membership role when the access policy is re-evaluated during a transient failure (regression test added, seen failing first), follows main's newer publication grant call, and gives delegated-ingress fixtures an explicit catalog. After the rebase: 601 of 603 tests passed across 55 files, and the two failures plus one follow-up fixture failure were repaired and rerun green with their affected suites (26 tests in 3 files). The 55-file run was not repeated as a whole after the repairs.

The fifth commit fixes the first CI run: the users.setRole handler export is renamed to avoid a name collision, a perf script passes the new options object, and five fixtures with OpenClaw ID members gain role definitions. No assertion changed. 666 tests in 62 files pass with the static checks and ratchets.

Later commits:

  • GitHub publication keeps a member's authority. The stored publication request gains an optional member identity; publication is checked against the membership role, as admission is, and membership and current permissions are rechecked at publication and when stored requests are restored. Requests stored before this change carry no identity and behave as before, including retries. An older build rejects records that carry the new field.
  • Test fixtures for newer main: an explicit operator definition for the node wake suite and a test-owned reload-recovery owner for the role-reload suite. No assertion changed.

Reviews: two findings from independent exact-head reviews, both in GitHub publication for a Gateway that combines a visitor default role with OpenClaw ID members, are fixed by the commits above. A final review of head 093e77158ad5 found no P0-P2. It notes that a request stored before this change identifies a profile, not a specific member, so it keeps running under its original stored grant while that grant is valid; that is unchanged behavior.

Live proof (isolated Gateway, staging testnet): all ten checks passed on 8d8aa19b21aa; see the proof comment. Changes after that head are the publication retry fix, test fixtures and a rebase in which the earlier commits are patch-identical. GitHub publication was not exercised live. The Gateway was restarted once after enabling OpenClaw ID, because enabling it without a restart leaves the Access page unloaded; that behavior is the same on main.

CI on 093e77158ad5: all checks pass.

Not run: the full repository suite locally, a real GitHub publication, and an in-place upgrade of an installed Gateway.

@clawsweeper

clawsweeper Bot commented Nov 12, 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 app: web-ui App: web-ui gateway Gateway runtime plugin: openclaw-id-access size: XL labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR resolves OpenClaw ID member permissions from gateway.roles.definitions and installs editable Operator and Viewer presets.

Example: An owner changes the operator definition to grant only operator.sessions.read.

  • Before: Operator members retain hardcoded write permissions.
  • After: Operator members receive the configured conversation-read permission.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The feature has a coherent owner and useful harness coverage, but affected regression fixtures remain invalid and required runtime and upgrade evidence is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Owners cannot customize OpenClaw ID member permissions because the Gateway hardcodes their role definitions.
Reason: Maintainer-authored direction establishes the product choice, and the implementation reuses the existing role catalog.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-directed feature open; the role-definition cutover leaves existing HTTP and automation regression fixtures invalid.

Priority: P2
Reviewed head: e2b02c186150b9ace2c3adf3ea94ecb29ebfdd25

Before merge

  • Update existing member fixtures for definition-based admission (P2) - Requiring a configured definition also changes existing consumers outside the edited suites. tools-invoke-http.abort.test.ts:381 and the member case in openai-compatible-agent-run.test.ts:128 configure only reader but authenticate an operator member, so their expected successful HTTP requests are now refused. The two OCID cases in server-methods/cron-creator-transports.integration.test.ts likewise configure no operator definition and fail while capturing run authority. Install an explicit operator definition in these fixtures and run all three suites, preserving their existing execution and revocation assertions.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Update existing member fixtures for definition-based admission — src/gateway/openclaw-id/tunnel-principal.ts:200-201

Tests

  • Missing end-to-end proof: Provide redacted Gateway output exercising member activation and definition edits, plus a latest-stable upgrade preserving existing role settings and data; redact credentials, IPs, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The Gateway maps authenticated OpenClaw ID membership to role definitions, then applies those permissions to connections, HTTP requests, retained work, and session continuations.

flowchart TD
  A[Authenticated tunnel peer] --> B[Membership authority]
  B --> C[Configured role definition]
  C --> D[Connection and HTTP admission]
  C --> E[Required access policy]
  D --> F[Agent and session work]
  E --> F
  C --> G[Recovered and scheduled work]
Loading

Technical review

Best possible solution:

Keep one configured member-role owner, complete the affected fixture cutover, and preserve existing settings and data through activation and upgrade.

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

Source inspection establishes that four existing positive regression cases lack the operator definition now required for admission; no target code or tests were executed.

Is this the best way to solve the issue?

Reusing gateway.roles.definitions is a coherent minimal design, but its existing HTTP and automation consumers must receive valid fixtures together.

Full review comments:

  • [P2] Update existing member fixtures for definition-based admission — src/gateway/openclaw-id/tunnel-principal.ts:200-201
    Requiring a configured definition also changes existing consumers outside the edited suites. tools-invoke-http.abort.test.ts:381 and the member case in openai-compatible-agent-run.test.ts:128 configure only reader but authenticate an operator member, so their expected successful HTTP requests are now refused. The two OCID cases in server-methods/cron-creator-transports.integration.test.ts likewise configure no operator definition and fail while capturing run authority. Install an explicit operator definition in these fixtures and run all three suites, preserving their existing execution and revocation assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Member-role permissions changes intended behavior with a stated reason (59b8a11: Tunnel membership supplied built-in Operator and Viewer ceilings while owner devices retained owner authority.)
  • Required access-policy plugins keeps the original intent (552b54b: Role-bound access policies must remain required when their plugin or grant is unavailable.)
  • Connection reconciliation changes intended behavior with a stated reason (a91f7cd: fix(gateway): preserve connections and turns on harmless role reloads #175251 preserved unrelated connections and harmless scope edits; this PR explicitly reconnects members when their editable definition changes.)
  • Session-principal continuation keeps the original intent (d777e01: Profiles without named roles require their recorded authenticated source to resume bounded work.)
  • Profile role assignment changes intended behavior with a stated reason (53dcaae: Named roles attach to durable profiles; this PR explicitly makes membership authoritative for OpenClaw ID member connections.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/gateway/tools-invoke-http.abort.test.ts src/gateway/openai-compatible-agent-run.test.ts src/gateway/server-methods/cron-creator-transports.integration.test.ts --maxWorkers=1
  • pnpm exec oxfmt --check src/gateway/tools-invoke-http.abort.test.ts src/gateway/openai-compatible-agent-run.test.ts src/gateway/server-methods/cron-creator-transports.integration.test.ts
  • git diff --check

What I checked:

  • Pinned introduction and current main: The introduced diff replaces the built-in member policy table; fetched main still hardcodes Operator and Viewer permissions. (src/gateway/openclaw-id/tunnel-principal.ts:197, e2b02c186150)
  • HTTP fixtures omitted from the cutover: tools-invoke-http.abort.test.ts and the member case in openai-compatible-agent-run.test.ts publish only a reader definition while expecting an operator member to authenticate successfully. (src/gateway/tools-invoke-http.abort.test.ts:381, e2b02c186150)
  • Automation fixtures omitted from the cutover: The two OCID automation-creation cases capture an operator member under configuration with no role definitions; the changed current-principal check now rejects that source. (src/gateway/server-methods/cron-creator-transports.integration.test.ts:195, e2b02c186150)
  • Persisted configuration boundary: Activation writes missing operator and viewer definitions through the canonical config writer, preserving existing definitions, default, and assignments; this changes persisted configuration and requires upgrade compatibility evidence. (src/gateway/openclaw-id/member-role-presets.ts:72, e2b02c186150)
  • Full body and discussion: The complete REST body matches the supplied content identified by sourceRevision c377433ee61da1dad5cde9a709c79529c876548e5a69cf343cc89c03943b3eee. It supplies test results and explicitly excludes live Gateway, relay, and browser E2E execution; comments contain review-status messages only. (e2b02c186150)
  • Recorded product tradeoffs: The supplied maintainer-authorship fact establishes direction; the body explicitly accepts editable administrative scopes, narrower Viewer access, preset installation removing JSON5 comments, and affected-member reconnection after definition edits. Public docs: docs/concepts/experimental-features.md. (docs/concepts/experimental-features.md:273, e2b02c186150)

Likely related people:

  • Josh Lehman: Raw commit 59b8a11 adds src/gateway/openclaw-id/tunnel-principal.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 59b8a114bf6d; files: src/gateway/openclaw-id/tunnel-principal.ts)
  • Peter Steinberger: Raw commit a91f7cd adds src/gateway/server/ws-origin-policy.ts:94 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a91f7cd52cb3; files: src/gateway/server/ws-origin-policy.ts)
  • Vincent Koc: Raw commit 5b3ff07 adds src/gateway/server/ws-origin-policy.ts:101 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 5b3ff077dcbd; files: src/gateway/server/ws-origin-policy.ts)

PR surface

Source +250, Tests +1305, Docs +70, Other +4. Total +1629 across 47 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 25 356 106 +250
Tests 19 1317 12 +1305
Docs 2 70 0 +70
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 0 +4
Total 47 1747 118 +1629

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.

Review metrics

Metric Value Why it matters
Production versus tests Production +356/-106; tests +1317/-12 The growth covers distinct admission, persistence, reload, and recovery boundaries; existing consumer fixtures still need migration.
Existing configuration and defaults Two presets installed automatically; no new configuration key Activation persists missing operator/viewer definitions and changes the Viewer preset to operator.sessions.read.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a scoped Labs authorization feature with source-reproducible regression-test failures and no demonstrated urgent production incident.
  • merge-risk: 🚨 compatibility: The maintainer-directed change automatically writes role definitions and deliberately narrows Viewer permissions.
  • merge-risk: 🚨 security-boundary: Owner-authored definitions become authoritative for member privileges, including explicitly configured administrative and pairing scopes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • 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 November 12, 2026, 8:17 AM ET / 13:17 UTC.

@jalehman
jalehman force-pushed the ocf-516-roles-enforcement-split branch from 0aa7acd to effd75b Compare November 12, 2026 23:57
@jalehman
jalehman force-pushed the ocf-518-member-roles-from-definitions branch from e2b02c1 to ec6da85 Compare November 12, 2026 23:58
@jalehman
jalehman force-pushed the ocf-516-roles-enforcement-split branch from effd75b to 433d3c3 Compare November 13, 2026 18:19
Base automatically changed from ocf-516-roles-enforcement-split to main November 13, 2026 19:11
@jalehman
jalehman force-pushed the ocf-518-member-roles-from-definitions branch from ec6da85 to 2b648ec Compare November 13, 2026 20:06
@openclaw-barnacle openclaw-barnacle Bot removed scripts Repository scripts commands Command implementations plugin: visitor-access plugin: mcp-relay labels Nov 13, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Live proof at 8d8aa19b21aa5874c5d882021f77dd4d8931eb21: all ten original checks passed, along with the separate restart-only Access check, using one isolated staging claw.

Startup with OpenClaw ID off leaves the config unchanged. Enabling it writes the expected Operator/Viewer presets without adding a default, and the original browser reconnects using only its device token. I used the known isolated-Gateway restart workaround after enabling; Access then appeared in the same owner browser without a reload or another config edit.

Owner, Operator and Viewer connected through the real tunnel with the expected allowed and denied methods. Editing Operator's approvals permission closes its live connection and removes that permission on reconnect. Deleting/restoring Viewer cuts off/restores admission. Startup preserves existing role definitions and a configured default while adding only a missing preset; a later restart preserves member access and permission boundaries.

Custom-role publication now succeeds in staging: the snapshot write returned HTTP 204, and authenticated HTTP 200 readback showed auditor. The custom-role connection received only its configured permissions. The previously incomplete profile-role check also passed: the test identified the member profile across its join, and users.setRole returned “This member's role is managed on the Access page.”

The additional removal check proved that removing a member through Access closes the open connection and makes reconnect fail with relay_denied (not authorized). Re-invitation reached the owner's pending-approval list, but the test helper timed out waiting for a manual sign-in state before it clicked Approve. The reused browser also showed a reset/replaced message. Restored access after approval is therefore not proven; this was not a failed post-approval admission assertion.

Cleanup is complete: the throwaway claw was retired with all four database counts verified zero; all three account sessions were revoked and verified signed out; the isolated processes, port, state, checkout and recovery kit were removed. No real GitHub publication was attempted, so this proof does not validate that write path. Nothing was deployed or posted.

Note on the head: this proof ran on 8d8aa19b21aa. The PR head is now 093e77158ad5. Since the proof: a five-line fix so a retry of a publication request stored before this change is still recognised (GitHub publication path only, not exercised live), test fixtures, and a rebase onto main in which the earlier six commits are patch-identical.

@jalehman
jalehman merged commit 4fc7acf into main Nov 14, 2026
161 checks passed
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@jalehman
jalehman deleted the ocf-518-member-roles-from-definitions branch November 14, 2026 05:51
steipete added a commit that referenced this pull request Nov 14, 2026
…#198863)

Make MEMBER_ROLE_PRESETS private and reuse the independent service activation fixture across test consumers. Keep reportStatusScanFailure private after its last external caller moved to the interrupt-aware wrapper.

Fixes unused-export regressions from #197739 (4fc7acf) and #198651 (0640d39). Document the existing worker-GC logging mock isolation exposed by check:changed, introduced in #198857 (1b3e37b).

Production bodies are unchanged; net production LOC 0. Full deadcode scan and 247 focused tests pass. Codex autoreview is scoped-clean through P2.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…penclaw#197739)

* feat: resolve OpenClaw ID member roles from definitions

Persist missing editable presets on activation without enabling named-role enforcement. Apply membership definitions and required access policies to ingress, live connections, retained runs, sandbox streams, and session continuations.

Keep preset writes on the service-owned queue outside managed config publication to avoid recursive secrets-preflight deadlock.

Allocate 634 test lines above the standard 400-line allowance for transport admission, current retained authority, required access policies, and real Gateway activation/reload regressions.

* fix: order member role activation and fence profile merges

Install missing member role presets before the startup runtime snapshot and
managed config reloader. Carry the same activation owner into the service,
preserving visible write failures without retrying the startup edge.
Report saved activation that reload policy cannot apply as restart-required.
Keep runtime reconciliation asynchronous to avoid the publication deadlock.

Retain canonical member-profile authority through membership preparation and
recheck it in the existing role-write commit guard so profile merges cannot
redirect assignments onto members. Preserve nonmember writes and null clears.

Document that installing presets rewrites config as JSON and removes JSON5
comments through the standard config writer.

Test-line allocation: 905 for 1305 cumulative net test lines above the stacked
feature base (400 ordinary allowance). The additional 271 lines prove delayed
startup/reload-off activation and real canonical-profile merge write boundaries.

* fix(gateway): reconcile member-role rebase validation

Adapt linked-owner grant and named-role enforcement fixtures after replaying the member-role stack. Keep role-aware handlers and recovery fixtures within the existing line caps without changing their authority checks or assertions.

* fix(gateway): preserve member authority after main restack

Retain canonical role assignment, grant custody and membership roles during transient policy recovery. Seed ingress fixture catalogs without relaxing assertions. The 945-line allocation covers 1345 net test lines: existing independent authority boundaries plus explicit delegated ingress catalogs and transient member-policy recovery.

* fix(gateway): align member-role callers and CI fixtures

Rename the RPC role handler to avoid an export collision and pass retained authority through the current performance API options. Seed explicit member definitions in omitted transport and recovery fixtures without changing assertions or runtime authorization. Allocate exactly 41 added fixture lines.

* fix(gateway): retain member authority for GitHub publication

* test(gateway): seed member roles and recovery ownership in CI fixtures

* fix(github): retain historical requester grants on retry
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…openclaw#198863)

Make MEMBER_ROLE_PRESETS private and reuse the independent service activation fixture across test consumers. Keep reportStatusScanFailure private after its last external caller moved to the interrupt-aware wrapper.

Fixes unused-export regressions from openclaw#197739 (4085249) and openclaw#198651 (0dd531e). Document the existing worker-GC logging mock isolation exposed by check:changed, introduced in openclaw#198857 (4b33bc7).

Production bodies are unchanged; net production LOC 0. Full deadcode scan and 247 focused tests pass. Codex autoreview is scoped-clean through P2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: openclaw-id-access rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-sensitive-changed 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.

1 participant