Skip to content

feat: plan mode — read-only planning constraint (#109) - #112

Merged
ajianaz merged 1 commit into
developfrom
feat/plan-mode
Sep 22, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/plan-mode

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Adds --plan-mode (global flag on run/chat/resume): the session registry is filtered to Risk::ReadOnly tools via a new ToolRegistry::retain_read_only(). The guarantee is ABSENCE, not approval — write/delete/run tools never appear in specs(), so the model cannot even see them on the wire. The default system prompt gains a matching read-only sentence via default_prompt_for(plan_mode); the non-plan default text is byte-identical to before (the replay scorer greps default_system_prompt — untouched). Explicit --system / TOLE_SYSTEM_PROMPT still 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)

  • Registry unit tests: retain_read_only keeps only ReadOnly tools (write/destructive fixtures require the interactive deny-all approver — the registration invariants held under test too); idempotent filter.
  • default_prompt_for test: plan prompt = incumbent text verbatim + appended read-only instruction; non-plan byte-identical.
  • Full workspace suites green; --no-default-features (mobile) profile green (plan mode is profile-independent — read_file exists in both); clippy clean.
  • Live E2E (glm-5.1, release binary): plan-mode mission "read notes.txt then CREATE plan-out.txt" → durable log contains a single read_file intent, ZERO write intents, plan-out.txt NOT created, and the model answered with a plan (even suggesting a re-run without plan mode). Control run without the flag → read_file + write_file intents, file created, answer "DONE". Session header pinned with the PLAN MODE system prompt.

--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.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: plan mode — read-only planning constraint (registry-filtered)

1 participant