feat(security): enforce read-only actions #436
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
3 participants
Notifications
Due date
No due date set.
Blocks
#322 feat(security): enforce read-only actions
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core!436
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/m4-security-readonly"
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
Closes #322. Tightens read-only enforcement across ToolRuntime, ChangeSet builder, and CLI commands.
_enforce_capabilities()to block ANY tool withwrites=Truewhenplan_read_onlyis set, removing thenot cap.read_onlyloophole. Tool name always included in error.read_onlyflag andReadOnlyViolationError; write-capable tools are rejected when wrapping on a read-only planplan executeandplan applyabort before calling the service layer ifplan.read_only=Trueenforce_write_guard()already correctly includes tool name; no changes neededFiles Changed
src/cleveragents/tool/lifecycle.pysrc/cleveragents/tool/builtins/changeset.pysrc/cleveragents/cli/commands/plan.pyfeatures/security_readonly.featurefeatures/steps/security_readonly_steps.pydocs/reference/read_only_actions.mdrobot/security_readonly.robotrobot/helper_security_readonly.pybenchmarks/security_readonly_bench.pyQuality
Dependencies
a8a290e7764bc7313a34Code Review — PR #436: feat(security): enforce read-only actions
Reviewer: @brent.edwards | Review type: Comment-only
Nice work on the multi-layer framing and the breadth of tests/benchmarks. I found a few issues that should be addressed before merge, plus some test/doc gaps.
P1:must-fix — Unrelated CLI regressions slipped into this PR
src/cleveragents/cli/commands/plan.pyremoves theplan errorsandplan resumecommands and strips DoD/resume metadata from CLI output (dod_evaluation,last_completed_step,last_checkpoint_id). These are breaking changes unrelated to read-only enforcement. Please restore them or move the removal into a separate, explicitly-scoped PR with docs/tests updated.P1:must-fix — Read-only enforcement not wired to the execution path
The new enforcement lives in
ToolRuntime._enforce_capabilitiesandChangeSetCapture.read_only, but the production execute path doesn’t appear to propagateplan.read_onlyinto either:ToolRuntime._enforce_capabilitiesrelies onToolExecutionContext.plan_read_only(src/cleveragents/tool/lifecycle.py), but I can’t find any production instantiation ofToolExecutionContextwithplan_read_onlyset (only tests create it).ChangeSetCaptureis created insrc/cleveragents/application/services/plan_executor.pywithoutread_only, so the new guard never triggers in runtime.Net: the new guard logic is only exercised by unit tests, not by the plan execution path (
PlanExecutionContext+ToolRunner). Please wireplan.read_onlythrough the execution context or enforce at the service layer so this actually blocks writes in real execution.P2:should-fix — Tests are stubbing the behavior instead of exercising code paths
features/steps/security_readonly_steps.pyuses local exceptions instead of calling the real code paths in several scenarios:plan applycheck is simulated with a manualBusinessRuleViolation, not by invokingplan lifecycle-applyorPlanLifecycleService.ValueError, but I can’t find production validation enforcing this anywhere insrc/cleveragents.ToolExecutionContextdirectly; it doesn’t verify runtime wiring.These tests will pass even if enforcement is missing. Consider replacing with integration tests that exercise the CLI/service and real validation paths.
P2:should-fix — Doc claims don’t match implementation
docs/reference/read_only_actions.mdclaims Action→Skill compatibility validation and propagation throughToolExecutionContext+ChangeSetCapture, but I don’t see those hooks in production code. Either implement the missing wiring or update the doc to reflect current behavior. Also, the test command uses rawpython3 -m behave; repo convention is to run vianoxsessions.Happy to re-review after those are addressed.
6c46ee37cb8578cfdeadNew commits pushed, approval review dismissed automatically according to repository settings
8578cfdead03677318c2Thanks for the thorough review @brent.edwards. Pushed
17c5fe59addressing all points.P1 #1 — CLI regressions in
plan.pyFalse positive. I re-examined the diff for
plan.pyand it is purely additive: +16 lines, 0 deletions. Theplan errorscommand,plan resumecommand, and all DoD/resume metadata fields (dod_evaluation,last_completed_step,last_checkpoint_id) are present and unchanged. No lines were removed. The diff only adds the two read-only fail-fast guards. You may have been looking at a stale diff or a different branch state.P1 #2 — Read-only enforcement not wired to execution path
Fixed. Added
read_only: bool = Falsekwarg toExecuteStubActor.execute(), which now passesread_only=read_onlyto theChangeSetCaptureconstructor.PlanExecutor._run_execute_with_stub()readsplan.read_onlyviagetattr(plan, "read_only", False)and forwards it. This wires the guard through the actual plan execution path.P2 #1 — Tests stubbing behavior instead of exercising code paths
Fixed. Replaced the stubbed tests:
ExecuteStubActorintegration test that usesunittest.mock.patchto spy onChangeSetCapture.__init__and verifyread_onlyis propagated through real code.SkillContext.enforce_write_guardtests that exercise the real production code path.P2 #2 — Doc claims don't match implementation
Fixed. Updated
docs/reference/read_only_actions.md:ExecuteStubActorwiring description showing howplan.read_onlypropagates toChangeSetCapture.python3 -m behavetonox -s unit_tests.All 18 scenarios / 86 steps pass, lint clean. Ready for re-review.
17c5fe5979dd2a77f30add2a77f30a09a485c4b4Approved!
09a485c4b4493e5cf8a1