feat(security): add safety profile enforcement #518
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!518
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/m7-post-safety"
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?
Summary
Implements safety profile resolution and enforcement in the tool execution pipeline, replacing the
NotImplementedErrorstub with working precedence logic and runtime safety checks.Closes #345
Changes
Core Implementation
resolve_safety_profile()— plan > action > project > global precedence; returnsDEFAULT_SAFETY_PROFILEwith GLOBAL provenance when all levels are NoneToolExecutionContext.safety_profile— optional field carrying the resolved profileToolRuntime._enforce_capabilities()— extended with:allow_unsafe_toolsvsToolCapability.unsafe)allowed_skill_categoriesvstool_skill_categorymetadata)ToolSafetyViolationError— new error class in the tool error hierarchyFiles Modified
src/cleveragents/domain/models/core/safety_profile.pyNotImplementedErrorstub with resolution logicsrc/cleveragents/tool/context.pysafety_profilefield toToolExecutionContextsrc/cleveragents/tool/lifecycle.pyToolSafetyViolationError, extend_enforce_capabilities()src/cleveragents/tool/__init__.pyToolSafetyViolationErrorFiles Added
features/safety_profile_enforcement.featurefeatures/steps/safety_profile_enforcement_steps.pyrobot/safety_profile_enforcement.robotrobot/helper_safety_profile_enforcement.pybenchmarks/safety_profile_bench.pydocs/reference/safety_profiles.mdTest Updates
features/safety_profile.feature— replacedNotImplementedErrorstub test with 5 resolution precedence scenarios (30 total)features/steps/safety_profile_steps.py— added resolution step definitionsVerification
nox -e typechecknox -e unit_testsnox -e coverage_reportnox -e integration_testsnox -e benchmarkBackward Compatibility
When no
SafetyProfileis set onToolExecutionContext(the default), the new enforcement checks are skipped entirely. All existing tool execution paths are unaffected.e09201af295e247d05e2Review — PR #518
feat(security): add safety profile enforcementVerdict: APPROVED with comments
The implementation is well-structured.
resolve_safety_profile()implements cleanplan > action > project > globalprecedence with keyword-only args and tuple return. The_enforce_capabilities()extension adds 8 ordered checks (read-only, checkpoint, unsafe gating, skill category, sandbox, human approval, cost limits, retry limits) with a clear error hierarchy (ToolSafetyViolationError,ToolSandboxRequiredError,ToolHumanApprovalRequiredError,ToolCostLimitExceededError,ToolRetryLimitExceededError— all inheriting fromToolRuntimeError). TheSafetyProfilemodel is frozen/immutable with field and cross-field validators. New types are properly re-exported intool/__init__.py. TheToolExecutionContext.safety_profilefield is optional (None= no enforcement), preserving backward compatibility. BDD scenarios are comprehensive with stub tool instances.No P0 or P1 findings.
P2:should-fix
Missing PR label — Per
CONTRIBUTING.md, every PR must carry exactly oneType/label. This PR has no labels. The linked issue #345 carriesType/Feature.Missing PR milestone — Per
CONTRIBUTING.md, the PR milestone must match the linked issue. This PR has no milestone set. Issue #345 is assigned to milestonev3.6.0.Commit footer uses
Refs: #345instead of a closing keyword — PerCONTRIBUTING.md, every commit must reference the issue with a closing keyword (e.g.ISSUES CLOSED: #345). The PR body correctly saysCloses #345, but the commit footer only hasRefs: #345, which will not auto-close the issue on merge.Scenario count mismatch in PR body — The PR description claims "11 BDD scenarios" in
safety_profile_enforcement.feature, but the file actually contains 24 scenarios (verified by countingScenario:/Scenario Outline:entries plus theirExamplesexpansions). Please update the PR body to reflect the correct count.P3:nit
nox -e(not a valid nox flag) instead ofnox -sin all entries.P2 items should be addressed in a follow-up within 3 business days.
5e247d05e257a99f252157a99f2521809fcd223bApproved. No notes.
809fcd223bb4b96d213c