Repository navigation
feat(gateway): role definitions no longer turn on named-role enforcement without a default - #197712
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR makes gateway.roles.default the switch for named-role enforcement, allowing role definitions to exist without enabling it. Example: Configure a guest role with sessions.others set to none, agents set to [], and scopes set to [], without gateway.roles.default.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: the maintainer-directed feature has a clear purpose, but the enforcement cutover leaves Doctor and cron replay inconsistent with runtime admission. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway configuration feeds authentication, profile admission, session authorization, scheduled execution, and bundled plugins; these owners turn authenticated requests into permitted operations. flowchart TD
A[Gateway configuration] --> B[Named role enforcement switch]
B --> C[Sign in and pairing]
B --> D[Profile and role policy]
D --> E[Session and tool authorization]
B --> F[Scheduled execution]
B --> G[Bundled plugins]
Technical reviewBest possible solution: Use the same enforcement predicate across runtime admission, Doctor, and replay while preserving default-enabled authorization and independent OpenClaw ID membership policy. Do we have a high-confidence way to reproduce the issue? Source establishes that main rejects definitions without default and that the patch makes runtime owner admission disagree with Doctor for an existing non-owner profile; no execution was performed. Is this the best way to solve the issue? A shared enforcement predicate is a reasonable minimal design, but its consumers must include diagnostics and replay so they describe the same authorization behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b48d16bf6e98. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +109, Tests +296, Docs +10, Generated 0, Other +1. Total +416 across 59 files. Added test files: 2. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 12, 2026, 7:10 AM ET / 12:10 UTC. |
8723304 to
82b2811
Compare
0aa7acd to
effd75b
Compare
|
Use gateway.roles.default as the named-role enforcement switch, keeping definitions-only catalogs from changing other sign-ins. Preserve OpenClaw ID membership policy and existing default-enabled authorization.
Give enforcement fixtures explicit valid defaults so definitions-only config continues to test its separate unrestricted contract without weakening any assertion.
Recognize the exact qualified Gateway core/client selection when inventory packing combines them. Move role assignment validation to its profile-access owner without changing lazy config reads, keeping users.ts within the line-growth ratchet.
effd75b to
433d3c3
Compare
Live proof on the staging testnet —
|
| Configuration and check | Result |
|---|---|
| No role configuration: shared-token owner receives a device token; device-only reconnect works | pass |
| No role configuration: another browser pairs by code and connects | pass |
| Role definitions without a default: config validates; original browser reconnects | pass |
| Definitions without a default: new browser code pairing works | pass |
| Definitions without a default: setup-code operator connect works | pass |
| Definitions without a default: named role assignment is refused, null clearing works, no effective role is listed | pass; refusal explicitly names gateway.roles.default |
| Assignment map without a default | correctly rejected by CLI validation |
| Definitions without a default: new throwaway claw, owner/operator/viewer connect over the real tunnel | pass; owner has admin, operator does not, viewer has only operator.read |
| Add a restrictive default: original device-only connect is refused, shared-token owner still works | pass; AUTH_VERIFIED_USER_REQUIRED |
| Restrictive default: browser-code pairing start | correctly refused with HTTP 409 identity_required |
| Restrictive default: identity-linked owner/operator/viewer | pass; scopes unchanged |
| Remove the default again | original browser reconnects using device-token auth, without re-pairing |
The throwaway claw was roleproof516b-h23m1.crabd.xyz. Immediately after the run, it was retired: no claw, member, relay-key or live-hostname rows remain. All three test-account issuer sessions were revoked and sign-out verified. Browsers closed; the isolated Gateway process tree, state, checkout and recovery kit were removed. No shared claw or Gateway was changed.
This was a model-free authentication proof, not a chat or full-CI run. The empty fixture's owner model-setup page shows a Codex-detection error; that is separate from the successful connection and scope receipts. Evidence includes all 12 structured results and 13 inspected screenshots. No deployment or merge was performed.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…ent without a default (openclaw#197712) * feat(gateway): separate role definitions from enforcement Use gateway.roles.default as the named-role enforcement switch, keeping definitions-only catalogs from changing other sign-ins. Preserve OpenClaw ID membership policy and existing default-enabled authorization. * test: enable named-role enforcement in policy fixtures Give enforcement fixtures explicit valid defaults so definitions-only config continues to test its separate unrestricted contract without weakening any assertion. * fix: preserve compact test capacity and bound role handler size Recognize the exact qualified Gateway core/client selection when inventory packing combines them. Move role assignment validation to its profile-access owner without changing lazy config reads, keeping users.ts within the line-growth ratchet.
What Problem This Solves
A Gateway cannot hold role definitions without also switching on named-role enforcement for every operator sign-in. The presence of
gateway.rolesrefuses device-token and setup-code sign-ins that have no verified identity, turns off browser-code pairing and owner ingress, and caps Tailscale and trusted-proxy users at the default role. OpenClaw ID needs role definitions on a personal claw without changing how its other sign-ins behave.User Impact
User impact: none for existing Gateways. Every valid config already has
gateway.roles.default, so it keeps enforcement exactly as before.gateway.roles.defaultis now optional. A config withdefinitionsand nodefaultdefines roles as data and otherwise behaves like a Gateway with nogateway.roles.Required action to be aware of: removing
defaultfrom a team Gateway's config now turns named-role enforcement off, where it used to fail validation.assignments.byGithubLoginwithout a default is a validation error.Why This Change Was Made
gateway.roles.defaultis set. One helper,src/gateway/operator-role-enforcement.ts, answers that question, and every enforcement gate that tested forgateway.rolesnow uses it: sign-in and pairing, owner and person ingress, HTTP profile requirements, session sharing, cron, web push,send, questions, tool invocation, and the bundledmcp-relayandvisitor-accessplugins.gateway.roles.definitions.gateway.rolesobject, so adding or removing a default reloads and re-checks connections.users.setRolewith a role name is refused and namesgateway.roles.default; clearing withnullworks in every state.Evidence
users.setRoleis refused andusers.listshows no effective role; config validation accepts definitions alone and rejects an unknown default and assignments without a default.defaultis no longer required: the schema rejection of definitions alone, role resolution with no default (denied to none), and two fixtures that gained an explicit default.gateway.rolesacross 66 files and found no missed or wrongly switched enforcement gate, and no P0 or P1.Known gap, found by that review (P2): two Doctor checks in
src/commands/doctor/cron/execution-context-check.tsand the replay scriptscripts/dev/cron-context-replay.mtsstill test for the presence ofgateway.roles. With definitions and no default, Doctor can wrongly report that an automation will lose owner access. It only reports; it repairs nothing. #197785, later in this stack, fixes it.Follow-up after first CI run:
users.tstousers-profile-access.tsto stay under the line cap, with unchanged behavior.Live proof: 12 of 12 checks passed on head
433d3c32c5f6in an isolated Gateway against the staging testnet (see the proof comment below).Inherited CI failure:
checks-node-compact-small-9-1fails intest/scripts/ci-workflow-guards.test.ts(5 cases, UI end-to-end ownership counts). The CI merge base97611bd5fb39had two duplicate Home registrations intest/vitest/vitest.ui-paths.mjs, fixed on main by #198391. The test passes on this head alone (220), on current main (225) and on this head merged with current main (225); the CI base alone reproduces the same 5 failures. This PR touches neither file.Not run: the full repository suite.