Skip to content

feat: let admins share specific projects with restricted roles - #203470

Merged
jalehman merged 6 commits into
mainfrom
projects/role-grants
Nov 23, 2026
Merged

jalehman merged 6 commits into
mainfrom
projects/role-grants

Conversation

@jalehman

@jalehman jalehman commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

On a multi-user Gateway, people with restricted roles (for example guest or collaborator) can only see agent workspaces and projects whose origin is a public GitHub repository. An admin has no way to share a specific private repository with them short of granting operator.write, which also unlocks folder browsing, arbitrary working directories and cloning by URL. In practice, a collaborator opening New Session sees no projects at all.

User Impact

User impact: admins can share chosen registered projects with a named role by adding projects to its definition ("*" for every registered project, or a list of project IDs). People in that role then see and can start sessions in those projects. Roles without the field behave exactly as before. Sharing or unsharing takes effect on the next request without disconnecting anyone or stopping their runs.

Admins can also rename a registered project with the new projects.rename method (admin only).

Why This Change Was Made

Project access is decided in one place (project-access.ts), and roles already carry similar allow lists (agents, workerProfiles). This adds a matching projects list and passes the caller's current grant to every project-access check: project listing, checkout options, project skills, session creation, subagent spawns, inherited worktrees, GitHub publication and PR workspace prep, and project icons.

  • Additive and backward compatible: a grant is added on top of the existing public-GitHub rule and never widens anything else (folders, cwd, cloning by URL, remote search). Hidden projects still look like unknown IDs.
  • Read live, not snapshotted: grants are not part of the role-policy change that reconnects clients. They are read from current config for the caller's current profile, including runs that were admitted earlier, so revoking a grant denies the next use. A profile that has since been merged into another profile does not inherit that profile's grants.
  • Isolation: when someone can use a project only because of a grant, their sessions and spawns always get a new worktree, even if the client asked for none.

Known gap, deliberately unchanged for backward compatibility: a restricted caller can still open a public-GitHub project as a direct checkout without a worktree, as on main today.

This is the core half of a two-PR stack; the Control UI Projects tab that edits these grants follows on top of this branch.

Evidence

  • New tests cover an unset grant (old behavior), "*", a listed private project, an unlisted private project staying hidden, full access being unchanged, a forced worktree for grant-only access (and none for public access), and projects.rename (authorization, validation, kept ID).
  • Real sessions.create, projects.list and checkoutOptions integration tests share and unshare a private project. They show revocation denying it again, a retained restricted run following grant edits without a restart, and a merged profile not picking up another profile's grant.
  • A reload test checks that a grant-only config edit closes no sockets, aborts no runs and triggers no recovery restart, for both write-scoped and restricted roles.
  • Independent reviews found a stale-grant issue with retained runs and a profile-merge widening; both were fixed with regression tests and re-reviewed clean.
  • Real Gateway, upgrade and fresh install (proof comment): stable 2026.11.7 state upgrades in place and behaves identically for a role without projects. Sharing a private project lists it and opens it in a managed worktree, revoking it denies the next request, rename survives a restart, and a fresh install works.
  • Inherited test fix carried here: refactor(gateway): check session mutation authority once at admission #203488 (6ff7a062e54e) stopped re-checking requester authority after a request is admitted, but left four stale mid-request rows in server.sessions.create.projects.test.ts. That test fails identically on main, and this PR's diff makes CI select it. Commit 6b490a1d removes those rows the same way refactor(gateway): check session mutation authority once at admission #203488 handled its other tests, and keeps the parent-source-change row. Bisect: passes at e0c7c74ae20d, fails at 6ff7a062e54e.
  • Inherited failures from main, not caused by this PR: CI tests this branch merged with current main, and this diff makes it select these files. Each fails identically on main 515a93c6725b without our commits, and the first three pass on this branch without refactor(agents): drop mid-run operator authority re-reads (R6c part 4c) #204155:
  • Test lines: +455 net against the 400 allowance. The 55-line allocation covers authorization regressions for a permission boundary (retained-run revocation and profile-merge fencing).
Commands
  • pnpm tsgo:core, pnpm tsgo:test:src (22 shards): pass
  • oxlint on changed files, line-cap ratchet, protocol since check, format:docs:check: pass
  • Rebased onto main 1601f86def0c. pnpm check:baseline-ratchets --base origin/main (12/12), protocol:check, gateway:validators:check: pass
  • Targeted batch (19 files): gateway 276/276, gateway-client 5/5, infra 14/14, runtime-config 64/64, spawn production-boundary 139/139
  • Regenerated: gateway validators, protocol, config docs baseline

🦞 Made with OpenClaw

@clawsweeper

clawsweeper Bot commented Nov 22, 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 agents Agent runtime and tooling size: XL labels Nov 22, 2026
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: a2e74e607e8db7996fe566ecfff12bb8126aab37
  • Maintainer: @jalehman
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/methods/core-descriptors.appended.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-role-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-role-source-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Adds role-specific project sharing, isolated worktrees for grant-only access, and an administrator-only project rename method.

Example: An administrator grants the guest role projects: ["private-handbook"].

  • Before: The guest cannot list or open private-handbook without broader operator.write access.
  • After: The guest can list it and create a session in a managed worktree; removing the grant denies subsequent requests.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful and supported by real Gateway and upgrade evidence, with no actionable introduced defect found; failing CI remains a landing gate.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Public terminal traces exercise real isolated Gateways through projects.list, projects.checkoutOptions, sessions.create, and projects.rename, including grant, revoke, managed checkout, restart persistence, fresh install, and v2026.11.7 upgrade with IDs and sessions retained; the core exercised implementation is unchanged at the reviewed head, and authenticated private-GitHub transport is explicitly outside the supplied scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Administrators cannot share a selected private project with restricted collaborators without also granting broad filesystem and repository capabilities.
Reason: Maintainer-authored direction addresses a concrete permission gap, preserves existing defaults, and stages its administration UI separately.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds a useful capability absent from current main, with no introduced correctness or security defect identified; the CI gate remains red.

Priority: P2
Reviewed head: a2e74e607e8db7996fe566ecfff12bb8126aab37

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway project admission combines authenticated scopes, current role grants, and repository visibility to return discoverable projects or authorize checkout creation.

flowchart TD
  A[Authenticated requester] --> B[Current role and scopes]
  B --> C[Project access policy]
  D[Project registry] --> C
  E[GitHub visibility] --> C
  C --> F[Project listing and metadata]
  C --> G[Session and child worktrees]
Loading

Technical review

Best possible solution:

Retain the existing project-access owner for explicit role grants and land the core capability with its companion administration UI after the CI gate is resolved.

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

This is a feature request implemented by the PR; current-main source confirms the missing selective-sharing capability, and supplied Gateway traces exercise the new behavior without running target code during review.

Is this the best way to solve the issue?

The approach fits the existing owners: role configuration supplies grants, project-access.ts decides visibility and admission, and the registry worker handles rename without adding another store or manager.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Restricted project discovery and source handoff changes intended behavior with a stated reason (95363ce: Prevent restricted roles from discovering or obtaining administrator-registered private repositories without authorization.)
  • Managed-clone and grant-only checkout isolation keeps the original intent (97e91a1: Keep session scratch and work out of shared maintenance clones while preserving accepted direct checkouts.)
  • Live role-policy reload keeps the original intent (6b4ebc0: Apply live policy changes without replacing unaffected runtimes; the PR extends this treatment to grants read on subsequent project requests.)
  • Removal of obsolete mid-request authority test rows keeps the original intent (6ff7a06: Check request authority once at admission while retaining Stop and session-source data fences; the remaining parent-source test preserves that distinction.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still lacks project grants: Fetched main permits restricted callers to use workspace projects or public GitHub repositories; it has neither ProjectGrant nor the role-grant branch. (src/gateway/project-access.ts, e2973f933f10)
  • Explicit sharing preserves the existing boundary: The introduced policy adds registered-project grants while repository URLs retain their public-only rule; grant-only access is classified separately for worktree isolation. (src/gateway/project-access.ts:212, a2e74e607e8d)
  • Live grants remain tied to the admitted person: Grant resolution reads current role configuration and refuses to borrow grants from a different canonical profile after a merge; creation and inherited-child tests cover retained callers. (src/gateway/operator-role-policy.ts:360, a2e74e607e8d)
  • Real Gateway and upgrade evidence: The complete proof comment shows stable v2026.11.7 state upgraded in place, preserved project IDs and sessions, grant/revoke behavior, forced worktree creation, administrator-only rename surviving restart, and fresh-install operation; its private-origin fixture uses GitHub 404 visibility and a local Git transport rewrite. (2ee9ad108450)
  • Runtime proof remains applicable: GitHub blob identities at the proof revision match the reviewed project-access policy, role schema, session-project resolver, project handlers, registry writer, and checkout-options owner; the added live-grant resolver also matches by source inspection. (src/gateway/project-access.ts:212, 2ee9ad108450)
  • Rename reuses existing storage ownership: Rename updates existing projects.display_name and updated_at_ms through the checkout-leased worker transaction, preserving the project ID and existing schema. (src/projects/project-registry.kernel.ts:164, a2e74e607e8d)

PR surface

Source +277, Tests +427, Docs +47, Generated 0, Other +2. Total +753 across 45 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 29 938 661 +277
Tests 10 615 188 +427
Docs 3 55 8 +47
Config 0 0 0 0
Generated 2 3 3 0
Other 1 2 0 +2
Total 45 1613 860 +753

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
Configuration and protocol additions 1 optional role setting; 1 administrator RPC; 0 schema migrations The projects allowlist is opt-in, projects.rename uses existing registry fields, and omitted grants preserve existing access.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • 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.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Useful, opt-in project sharing for multi-user Gateways with limited blast radius and no demonstrated urgent regression.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-22T11:20:53.646Z sha 1855a93 :: blocked before merge. :: none

Reviewed November 23, 2026, 2:59 PM ET / 19:59 UTC (Revision 2).

@jalehman

Copy link
Copy Markdown
Contributor Author

Real-Gateway upgrade and behavior proof

Real Gateways ran on this host with an isolated HOME/state/config and their own ports. Stable [email protected] (the npm latest tag) seeded the state, then this branch (2ee9ad108450) was started on the same state directory. The restricted user is a real trusted-proxy identity ([email protected]) whose guest role has only session read/write scopes. The private origin is a GitHub URL with no token configured, so the visibility lookup returns 404, the same outcome as a real private repo seen without a token. Paths and the owner password are redacted.

  • Upgrade: the branch migrates stable's state in place and loads the unchanged config. Registry rows keep their IDs and the stable session is still listed. A restricted role without projects behaves exactly as on stable: the private project is hidden, "unknown project id" is returned, and the public project still opens as a direct checkout.
  • Grant: adding projects: ["private-handbook"] hot-reloads without a restart. The project is listed, checkoutOptions offers only a worktree, and sessions.create without worktree: true returns a managed worktree.
  • Revoke: after the grant is removed, the next request gets "unknown project id" and the project is hidden. The already-granted session keeps its checkout.
  • Rename: a guest is refused (missing scope: operator.admin). The owner's rename survives a Gateway restart, and all sessions are still listed.
  • Fresh install: the branch starts on an empty state directory, and projects.list, register and rename work.
  • Not covered: a real private GitHub repository with a token-backed visibility lookup.
Stable 2026.11.7 seeds the state (01-stable-2026.11.7-seed.txt)
# Phase 1: latest stable (npm openclaw@latest) creates state

$ stable --version
OpenClaw 2026.11.7 (e31bbf0)

# Role config (no projects field):
{
  "default": "guest",
  "definitions": {
    "guest": {
      "agents": [
        "main"
      ],
      "scopes": [
        "operator.sessions.read",
        "operator.sessions.write"
      ],
      "sessions": {
        "others": "none"
      }
    }
  }
}

# Private origin: GitHub API answers 404 for the unauthenticated visibility lookup (no token configured):
$ curl -s -o /dev/null -w '%{http_code}' https://api.github.com/repos/openclaw-proof-nonexistent/role-grants-private
404

# Owner (shared password, operator.admin) registered both checkouts; re-registering returns the same IDs:

$ owner_call stable 28791 projects.register {"path":"<proof>/repos/private","name":"private-handbook"}
{
  "id": "private-handbook",
  "displayName": "private-handbook",
  "repoRoot": "<proof>/repos/private",
  "source": "registered",
  "originUrl": "https://github.com/openclaw-proof-nonexistent/role-grants-private.git"
}

$ owner_call stable 28791 projects.register {"path":"<proof>/repos/public","name":"public-site"}
{
  "id": "public-site",
  "displayName": "public-site",
  "repoRoot": "<proof>/repos/public",
  "source": "registered",
  "originUrl": "https://github.com/openclaw/openclaw.git"
}

$ git -C <proof>/repos/private remote get-url origin
https://github.com/openclaw-proof-nonexistent/role-grants-private.git

$ git -C <proof>/repos/public remote get-url origin
https://github.com/openclaw/openclaw.git

$ guest_call 28791 projects.list
{
 "projects": [
  {
   "id": "public-site",
   "displayName": "public-site",
   "source": "registered"
  },
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

$ guest_call 28791 sessions.create {"agentId":"main","projectId":"private-handbook"}
{"ok":false,"code":"INVALID_REQUEST","message":"unknown project id: private-handbook"}

# Earlier, the guest created a direct (non-worktree) session on the public project:

$ guest_call 28791 sessions.list {"limit":10}
{
 "sessions": [
  {
   "key": "agent:main:dashboard:e88f4e38-3ff0-4dc5-a325-e10379456756",
   "label": "stable public session",
   "displayName": "stable public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  }
 ]
}
Branch upgrades the same state in place (02-branch-upgrade-load.txt)
# Phase 2: branch build on the same state dir (stable state upgraded in place)

$ branch --version
OpenClaw 2026.11.7 (2ee9ad1)

# Gateway log: state upgrade + ready on the unchanged config
[state/upgrade] Upgrading state to 2026.11.7: state/openclaw.sqlite v36, agents/main/agent/openclaw-agent.sqlite v38
[state/upgrade] State upgrade retained 0 retired backup file(s), 0 bytes; cleanup remains with the operator or Doctor.
[state/upgrade] State upgraded to 2026.11.7 by migration chain; previous files kept as *.pre-2026.11.7-2ee9ad108450-2026-11-23T15-20-06.150Z.

# Existing registry rows load unchanged (re-register returns the stored records):

$ owner_call branch 28791 projects.register {"path":"<proof>/repos/private","name":"ignored"}
{
  "id": "private-handbook",
  "displayName": "private-handbook",
  "repoRoot": "<proof>/repos/private",
  "source": "registered",
  "originUrl": "https://github.com/openclaw-proof-nonexistent/role-grants-private.git"
}

# Restricted role without projects: identical to stable (private hidden, unknown id)

$ guest_call 28791 projects.list
{
 "projects": [
  {
   "id": "public-site",
   "displayName": "public-site",
   "source": "registered"
  },
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

$ guest_call 28791 sessions.create {"agentId":"main","projectId":"private-handbook"}
{"ok":false,"code":"INVALID_REQUEST","message":"unknown project id: private-handbook"}

# Existing session created on stable is still listed:

$ guest_call 28791 sessions.list {"limit":10}
{
 "sessions": [
  {
   "key": "agent:main:dashboard:e88f4e38-3ff0-4dc5-a325-e10379456756",
   "label": "stable public session",
   "displayName": "stable public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  }
 ]
}

# Public-fallback path unchanged: a direct checkout, no forced worktree

$ guest_call 28791 sessions.create {"agentId":"main","projectId":"public-site","label":"branch public session"}
{
 "ok": true,
 "key": "agent:main:dashboard:9929d322-b018-40c7-a330-97c4ceeacd14",
 "projectId": "public-site",
 "sessionRoot": "<proof>/repos/public",
 "spawnedCwd": "<proof>/repos/public",
 "worktree": null
}
Grant, isolated worktree, revoke (03-branch-grant-isolated-worktree-revoke.txt)
# Phase 2 (grant/revoke), same running branch Gateway.
# Git transport for the fake private origin: the isolated HOME's gitconfig rewrites it to a local bare repo,
# so the GitHub API still answers 404 (private) while 'git ls-remote origin' succeeds:

$ git config --global --get-regexp ^url\.
url.file://<proof>/repos/private-remote.git.insteadof https://github.com/openclaw-proof-nonexistent/role-grants-private.git

$ git -C <proof>/repos/private ls-remote origin HEAD
4c34b5943b4a8c817867817dcb4d85ff3670ac60	HEAD

# Grant the private project to the role (config hot reload, no restart):
guest role: {"agents":["main"],"scopes":["operator.sessions.read","operator.sessions.write"],"sessions":{"others":"none"},"projects":["private-handbook"]}

$ guest_call 28791 projects.list
{
 "projects": [
  {
   "id": "private-handbook",
   "displayName": "Private Handbook",
   "source": "registered"
  },
  {
   "id": "public-site",
   "displayName": "public-site",
   "source": "registered"
  },
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

$ guest_call 28791 projects.checkoutOptions {"agentId":"main","projectId":"private-handbook"}
{
 "current": false,
 "worktree": true
}

# Client does not ask for a worktree; grant-only access gets an isolated managed worktree:

$ guest_call 28791 sessions.create {"agentId":"main","projectId":"private-handbook","label":"granted private session"}
{
 "ok": true,
 "key": "agent:main:dashboard:af36c3b6-663f-4905-a69f-26d40b9712f7",
 "projectId": "private-handbook",
 "sessionRoot": "<proof>/upgrade/state/worktrees/54c59c0923b2bbe2/granted-private-session-e946bd",
 "spawnedCwd": "<proof>/upgrade/state/worktrees/54c59c0923b2bbe2/granted-private-session-e946bd",
 "worktree": {
  "id": "e946bd00-05d3-4755-a772-744f6d585997",
  "path": "<proof>/upgrade/state/worktrees/54c59c0923b2bbe2/granted-private-session-e946bd",
  "branch": "openclaw/granted-private-session-e946bd"
 }
}

# Revoke the grant: the next request is denied and the project is hidden again
guest role: {"agents":["main"],"scopes":["operator.sessions.read","operator.sessions.write"],"sessions":{"others":"none"}}

$ guest_call 28791 sessions.create {"agentId":"main","projectId":"private-handbook"}
{"ok":false,"code":"INVALID_REQUEST","message":"unknown project id: private-handbook"}

$ guest_call 28791 projects.list
{
 "projects": [
  {
   "id": "public-site",
   "displayName": "public-site",
   "source": "registered"
  },
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

# The session created under the grant keeps its checkout:

$ guest_call 28791 sessions.list {"limit":10}
{
 "sessions": [
  {
   "key": "agent:main:dashboard:af36c3b6-663f-4905-a69f-26d40b9712f7",
   "label": "granted private session",
   "displayName": "granted private session",
   "projectId": "private-handbook",
   "spawnedCwd": "<proof>/upgrade/state/worktrees/54c59c0923b2bbe2/granted-private-session-e946bd"
  },
  {
   "key": "agent:main:dashboard:9929d322-b018-40c7-a330-97c4ceeacd14",
   "label": "branch public session",
   "displayName": "branch public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  },
  {
   "key": "agent:main:dashboard:e88f4e38-3ff0-4dc5-a325-e10379456756",
   "label": "stable public session",
   "displayName": "stable public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  }
 ]
}
Rename persists across restart (04-rename-persists-across-restart.txt)
# Rename (operator.admin) and verify after a Gateway restart

$ owner_call branch 28791 projects.rename {"projectId":"private-handbook","name":"Private Handbook"}
{
  "id": "private-handbook",
  "displayName": "Private Handbook",
  "repoRoot": "<proof>/repos/private",
  "source": "registered",
  "originUrl": "https://github.com/openclaw-proof-nonexistent/role-grants-private.git"
}

$ guest_call 28791 projects.rename {"projectId":"public-site","name":"Guest Rename"}
{
  "ok": false,
  "code": "FORBIDDEN",
  "message": "missing scope: operator.admin"
}

# Phase 2b: after Gateway restart (same state dir)
2026-11-23T07:32:26.330-08:00 [gateway] ready

$ owner_call branch 28791 projects.register {"path":"<proof>/repos/private","name":"ignored"}
{
  "id": "private-handbook",
  "displayName": "Private Handbook",
  "repoRoot": "<proof>/repos/private",
  "source": "registered",
  "originUrl": "https://github.com/openclaw-proof-nonexistent/role-grants-private.git"
}

$ guest_call 28791 sessions.list {"limit":10}
{
 "sessions": [
  {
   "key": "agent:main:dashboard:af36c3b6-663f-4905-a69f-26d40b9712f7",
   "label": "granted private session",
   "displayName": "granted private session",
   "projectId": "private-handbook",
   "spawnedCwd": "<proof>/upgrade/state/worktrees/54c59c0923b2bbe2/granted-private-session-e946bd"
  },
  {
   "key": "agent:main:dashboard:9929d322-b018-40c7-a330-97c4ceeacd14",
   "label": "branch public session",
   "displayName": "branch public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  },
  {
   "key": "agent:main:dashboard:e88f4e38-3ff0-4dc5-a325-e10379456756",
   "label": "stable public session",
   "displayName": "stable public session",
   "projectId": "public-site",
   "spawnedCwd": "<proof>/repos/public"
  }
 ]
}
Fresh install (05-fresh-install.txt)
# Phase 3: fresh install - branch build on an empty state dir

$ branch --version
OpenClaw 2026.11.7 (2ee9ad1)

# Empty state dir at first start; the Gateway created its databases:
2026-11-23T07:32:32.099-08:00 [gateway] startup phase: ready 394.4ms total=7559.

$ ls <proof>/fresh/state/state
openclaw-quarantine.sqlite
openclaw.sqlite
openclaw.sqlite-shm
openclaw.sqlite-wal

$ owner_call branch 28792 projects.list
{
  "projects": [
    {
      "id": "workspace:main",
      "displayName": "workspace",
      "source": "workspace",
      "agentId": "main"
    }
  ],
  "recents": []
}

$ guest_call 28792 projects.list
{
 "projects": [
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

$ owner_call branch 28792 projects.register {"path":"<proof>/repos/public","name":"fresh-public"}
{
  "id": "fresh-public",
  "displayName": "fresh-public",
  "repoRoot": "<proof>/repos/public",
  "source": "registered",
  "originUrl": "https://github.com/openclaw/openclaw.git"
}

$ owner_call branch 28792 projects.rename {"projectId":"fresh-public","name":"Fresh Public"}
{
  "id": "fresh-public",
  "displayName": "Fresh Public",
  "repoRoot": "<proof>/repos/public",
  "source": "registered",
  "originUrl": "https://github.com/openclaw/openclaw.git"
}

$ guest_call 28792 projects.list
{
 "projects": [
  {
   "id": "fresh-public",
   "displayName": "Fresh Public",
   "source": "registered"
  },
  {
   "id": "workspace:main",
   "displayName": "workspace",
   "source": "workspace"
  }
 ]
}

Add an optional `projects` field ("*" or registry project IDs) to Gateway
role definitions. Restricted operators (no operator.write) keep the
public-GitHub fallback and additionally reach the granted projects in
projects.list, checkout options, project skills, sessions.create,
background spawns, inherited child checkouts, icon reads and publication
paths. Requesters carry the grant from their current role policy; runs use
the admitted authority's prepared role policy or the creator's live role.
A project reached only through a grant always opens in an isolated managed
worktree. Grants never widen cwd, folder browsing, projectGitUrl or remote
search; unknown IDs are ignored.

Add the admin-scoped projects.rename RPC for registry projects.
Project grant edits no longer count as a role source-policy change, so they do not reconnect clients or stop runs. Background runs and spawns resolve the driving operator's (or creator's) current grant live instead of a prepared snapshot, keeping revocation immediate for new uses and out of run-recovery snapshots.
Retained connections and admitted-run synthetic clients carried the admission-time role into project access, so a revoked grant kept working and a new one was missed. Project grants now always come from the caller's canonical profile and current role after the ordinary role boundary (OpenClaw ID owner, member and node principals included), for clients, run authorities, spawns and publication paths.
A merge redirects an admitted profile to another person's role. Live grant resolution now requires the current canonical profile to equal the admitted one, so retained runs, spawns and publication paths grant nothing after such a merge, while prepared aliases still resolve their canonical profile's grant.
…child test

#203488 made sessions.create check requester authority once at admission and
removed the mid-request hasCurrentClientAuthority re-checks. The repository
child test still flipped that callback before and during the parent copy and
expected "Gateway requester authority changed"; the request now proceeds to
the label check instead. Remove those four rows, as #203488 did for the other
mid-request refusal tests, and keep the parent-source data fence row.
@jalehman
jalehman force-pushed the projects/role-grants branch from 6b490a1 to a2e74e6 Compare November 23, 2026 18:25
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 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. labels Nov 23, 2026
@jalehman
jalehman merged commit 4a775a0 into main Nov 23, 2026
151 of 157 checks passed
@jalehman
jalehman deleted the projects/role-grants branch November 23, 2026 20:05
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Nov 23, 2026
Remove unused exports left by #204094, #204178, and #203470. Preserve focused coverage through the existing Windows supervisor and completion-settlement entry points.
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
* fix(tlon): gate group DMs by club approval

* fix(tlon): persist configured club grants

* docs(config): record Tlon club policy surface

* test(tlon): keep sender role cases under lint limit

* fix(tlon): preserve direct settings events

* fix(tlon): narrow settings event records without assertions

(cherry picked from commit 6eb70d4)

Release adaptation: regenerate stable config docs counts/hashes and bundled channel metadata; no source conflicts. Channel count +6, core/plugin unchanged. The assertion ratchet generator confirms the same Tlon-only shrink; unrelated pre-existing UI ratchet entries are excluded.

Companion disposition: #204126 is a missing optional user-facing warning about later club invitees; existing prompts already disclose unverified participant input and future messages. #203928 is not applicable to approval/routing, only image download lifetime. #204219, #203470, #203901 and #203063 overlap only generated/ratchet files, not applicable; regenerate from stable inputs. No later PR or commit-SHA mentions.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…law#203470)

* feat(gateway): grant named roles access to registered projects

Add an optional `projects` field ("*" or registry project IDs) to Gateway
role definitions. Restricted operators (no operator.write) keep the
public-GitHub fallback and additionally reach the granted projects in
projects.list, checkout options, project skills, sessions.create,
background spawns, inherited child checkouts, icon reads and publication
paths. Requesters carry the grant from their current role policy; runs use
the admitted authority's prepared role policy or the creator's live role.
A project reached only through a grant always opens in an isolated managed
worktree. Grants never widen cwd, folder browsing, projectGitUrl or remote
search; unknown IDs are ignored.

Add the admin-scoped projects.rename RPC for registry projects.

* fix(gateway): read project grants live without retiring role work

Project grant edits no longer count as a role source-policy change, so they do not reconnect clients or stop runs. Background runs and spawns resolve the driving operator's (or creator's) current grant live instead of a prepared snapshot, keeping revocation immediate for new uses and out of run-recovery snapshots.

* fix(gateway): read retained run project grants from current config

Retained connections and admitted-run synthetic clients carried the admission-time role into project access, so a revoked grant kept working and a new one was missed. Project grants now always come from the caller's canonical profile and current role after the ordinary role boundary (OpenClaw ID owner, member and node principals included), for clients, run authorities, spawns and publication paths.

* fix(gateway): keep live project grants on the admitted profile

A merge redirects an admitted profile to another person's role. Live grant resolution now requires the current canonical profile to equal the admitted one, so retained runs, spawns and publication paths grant nothing after such a merge, while prepared aliases still resolve their canonical profile's grant.

* chore: allocate test lines for role project grant regressions

* test(gateway): drop stale mid-request authority rows from repository child test

openclaw#203488 made sessions.create check requester authority once at admission and
removed the mid-request hasCurrentClientAuthority re-checks. The repository
child test still flipped that callback before and during the parent copy and
expected "Gateway requester authority changed"; the request now proceeds to
the label check instead. Remove those four rows, as openclaw#203488 did for the other
mid-request refusal tests, and keep the parent-source data fence row.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
Remove unused exports left by openclaw#204094, openclaw#204178, and openclaw#203470. Preserve focused coverage through the existing Windows supervisor and completion-settlement entry points.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime 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.

1 participant