feat(security): add permission system #448
No reviewers
Labels
No labels
auto/needs-reevaluation
controller-managed
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cleveragents/cleveragents-core!448
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/m7-post-permissions"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Add a namespace/project/plan/skill permission system with role-based access control. Implements four role levels (owner, admin, editor, viewer) with default-deny semantics and configurable allow overrides. Enforcement hooks are applied at CLI/service boundaries and are server-only; local mode returns permissive defaults via
CLEVERAGENTS_SERVER_MODEenvironment variable.Domain model (
permission.py):PermissionRole,PermissionScope, andPermissionActionenums;RoleBinding,PermissionCheck, andPermissionPolicyPydantic models;ROLE_PERMISSIONSmatrix mapping roles to allowed actions per scope;DEFAULT_LOCAL_ROLE_MAPPINGfor local-mode fallback.Service (
permission_service.py):PermissionServiceclass withcheck_permission,get_role_bindings,add_binding,remove_binding, andis_local_modemethods;enforce_permissiondecorator for declarative enforcement at service boundaries; module-level default service pattern withget_default_permission_service().Type of Change
Quality Checklist
Anyunless justified)nox -s typecheckpasses with no errorsnox -s lintpasses with no errorsfeatures/)robot/) if applicablenox -s coverage_report)nox -s security_scan)nox -s dead_code)Testing
43 BDD scenarios in
features/permission_system.featurecovering allow/deny decisions, missing roles, server-disabled local mode, role binding CRUD, scope/action matrix, and decorator enforcement. 18 Robot Framework integration tests inrobot/permission_system.robotwith stubbed server client. Reference documentation indocs/reference/permissions.md.Test Commands Run
Related Issues
Closes #344
Implementation Notes
CLEVERAGENTS_SERVER_MODEenvironment variable. When unset or falsy, all permission checks return allow (local mode).enforce_permissiondecorator extracts scope and action from function arguments and raisesPermissionErrorwhen access is denied in server mode.ROLE_PERMISSIONS.DEFAULT_LOCAL_ROLE_MAPPINGprovides a sensible owner-level binding for local-mode operations so that code paths requiring a role binding still function without a server.e907ffa47344ed1208e4Review Summary
Scope: new permission system domain models + PermissionService + tests/bench/docs. Security-sensitive area reviewed per playbook.
CI status isn’t visible via the API on my side. Please confirm required checks per
docs/development/ci-cd.mdare green (lint, typecheck, security, quality, unit_tests, integration_tests, coverage, build, docker).Findings
P2:should-fix —
PermissionService.check_permission()does not validate/normalizeprincipalorscope_id. RoleBinding trims/validates, but checks accept raw strings, so whitespace or empty values can silently miss bindings. Recommend stripping + empty checks (raise ValueError) or normalizing via a small helper before key lookup.src/cleveragents/application/services/permission_service.py(check_permission)P2:should-fix — Docs and docstrings imply “server-side enforcement deferred” and “hooks at CLI/service boundaries”, but there are no call sites wiring
enforce_permissioninto CLI or services yet. Please align docs with current behavior or add a minimal integration point.docs/reference/permissions.mdsrc/cleveragents/application/services/permission_service.py(module docstring)P3:nit —
docs/reference/permissions.mdisn’t listed in the reference nav. Add it todocs/gen_ref_pages.pyso it shows in the Reference sidebar.Positive Notes
44ed1208e430eee519caApproved!
30eee519ca64af753aabNew commits pushed, approval review dismissed automatically according to repository settings