Repository navigation
feat: plan mode — read-only planning constraint (#109) - #112
Merged
Merged
Conversation
--plan-mode filters the session registry to Risk::ReadOnly tools via ToolRegistry::retain_read_only(): write/delete/run tools are ABSENT from the wire (the model cannot even see them), not merely approval- gated. The default system prompt gains a matching read-only sentence through default_prompt_for(); the incumbent non-plan text is byte- identical to before, so the replay scorer's grep-based incumbent extraction is unaffected. Explicit --system / TOLE_SYSTEM_PROMPT still win (B2 precedence); the pinned header re-applies on resume. Live E2E (glm-5.1): plan-mode write mission -> zero write intents in the durable log (read_file only), no file created, the answer is a plan; identical mission without the flag -> write_file intent, file created. Registry unit tests cover the filter and its invariants.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This was referenced Sep 22, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (description of the change)
Adds
--plan-mode(global flag on run/chat/resume): the session registry is filtered toRisk::ReadOnlytools via a newToolRegistry::retain_read_only(). The guarantee is ABSENCE, not approval — write/delete/run tools never appear inspecs(), so the model cannot even see them on the wire. The default system prompt gains a matching read-only sentence viadefault_prompt_for(plan_mode); the non-plan default text is byte-identical to before (the replay scorer grepsdefault_system_prompt— untouched). Explicit--system/TOLE_SYSTEM_PROMPTstill win (B2 precedence); the header-pinned prompt re-applies on resume, making plan mode a session-level property.Why (the problem you're solving)
Closes #109. Until now the only safety tiers were the approval gate (Write) and interactive-only registration (Destructive) — there was no way to say "explore and plan, touch nothing". Read-only planning is the cheapest hard constraint (registry filtering, zero new enforcement machinery) and composes with the existing approval gate instead of replacing it. Pattern reference: ZCode's plan-mode-policy (Apache-2.0, pattern only).
Testing (how you verified this works)
retain_read_onlykeeps only ReadOnly tools (write/destructive fixtures require the interactive deny-all approver — the registration invariants held under test too); idempotent filter.default_prompt_fortest: plan prompt = incumbent text verbatim + appended read-only instruction; non-plan byte-identical.--no-default-features(mobile) profile green (plan mode is profile-independent — read_file exists in both); clippy clean.read_fileintent, ZERO write intents,plan-out.txtNOT created, and the model answered with a plan (even suggesting a re-run without plan mode). Control run without the flag →read_file+write_fileintents, file created, answer "DONE". Session header pinned with the PLAN MODE system prompt.