Skip to content

components C1: multi-option permission flow wired to the rule engine - #292

Merged
ericleepi314 merged 4 commits into
mainfrom
components/c1-permission-options
Jun 11, 2026
Merged

components C1: multi-option permission flow wired to the rule engine#292
ericleepi314 merged 4 commits into
mainfrom
components/c1-permission-options

Conversation

@ericleepi314

Copy link
Copy Markdown
Collaborator

Summary

  • Phase C1 of the components/ folder parity plan (gap analysis + plan critic-approved; impl critic-approved in two scoped reviews after 2 REQUEST CHANGES rounds)
  • Permission prompts upgrade from binary Allow/Deny to the TS PermissionPrompt option set: allow once / allow always (persisted rule) / deny / deny with feedback — on the TUI modal AND the legacy REPL console menu
  • Un-severs the existing src/permissions/ engine end-to-end:
    • new PermissionAskRequest/Reply protocol replaces the legacy 3-arg handler on all four producers (TUI bridge, REPL, headless auto-deny, subagent share); real tool_input now reaches the modal so per-tool previews render
    • registry applies accepted rules to the live context and persists them via the new .clawcodex/ settings resolver; setup_permissions wired into all three entrypoints so persisted rules load at startup (restart round-trip tested)
    • bash "don't ask again" suggestions ported from TS heuristics (2-word prefix / heredoc / safe-env-vars; no LLM extractor)
  • Engine fixes found en route: multi-word prefix rules never matched (first-token-only comparison); new quote-aware chaining guard — prefix/wildcard rules decline compound commands (re-prompt) since Python matches whole strings where TS matches per-AST-sub-command (documented divergence)
  • Review-driven hardening: Read suggestions removed (would persist rules nothing matches — parked on a path-rule matcher), project settings namespaced .clawcodex/ (.claude/settings*.json is the real harness's file — cross-tool collision), word-boundary matching for exact rules, lone-& detection, persist-failure logging, typed protocol, hermetic test fixture

Test plan

  • 36 new tests: derivation table, chaining-guard matrix, registry ask-flow (allow-once no-persist / always applies+persists / deny-feedback reaches model / restart round-trip via the production loader), REPL menu mapping (always+feedback rows, enable-row numbering), headless production setup block, 6 Textual pilot tests (incl. binding letters while feedback input focused)
  • Full suite: 12 failed / 7564 passed — failure set name-for-name identical to the verified clean-main(0fa986f) baseline (each stash-run-verified pre-existing)
  • Critic reviews: plan APPROVE; impl Review A (protocol/UX/wiring) APPROVE; impl Review B (string heuristics parity) APPROVE

🤖 Generated with Claude Code

ericleepi314 and others added 4 commits June 11, 2026 03:51
Replace the binary Allow/Deny permission surface with the TS
PermissionPrompt option set — allow once / allow always (persisted
rule) / deny / deny with feedback — and un-sever the engine:

- PermissionAskRequest/Reply protocol replaces the legacy 3-arg
  handler on all four producers (TUI bridge, REPL console menu,
  headless auto-deny, subagent share); real tool_input now reaches
  the modal so per-tool previews render
- registry applies chosen updates to the live context and persists
  via the new settings_paths resolver; setup_permissions is wired
  into all three entrypoints so persisted rules load at startup
- bash "don't ask again" suggestions ported from TS heuristics
  (2-word prefix, heredoc, safe env vars; no LLM extractor)
- engine fixes: multi-word prefix rules now match (TS
  bashPermissions.ts:879-882 semantics); new quote-aware chaining
  guard stops prefix/wildcard rules from auto-allowing compound
  commands (documented divergence — Python matches whole strings)

Suite at the verified main-0fa986f baseline (12 pre-existing
failures); +31 new tests incl. the persist→reload→auto-allow
restart round-trip.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Typing y/n/a/d into the focused feedback Input must reach the Input,
not the screen bindings — pilot-verified, now regression-locked.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- no-wildcard rules now match exact-or-word-boundary, closing the
  last-token elongation hole the new exact suggestions activated
- multiline/compound derivation can no longer mint dead rules
  (chained first line -> 2-word prefix or nothing) or bare-shell
  prefixes; heredoc at index 0 yields nothing
- chaining scanner: lone & detected as a separator (redirections
  >&, <&, &> skipped); ANSI-C quoting documented as a non-goal
- env-assign regex pinned to ASCII (JS \w parity); import hoisted
  out of the matcher hot path; __all__ completed; +13 tests locking
  the above incl. the accepted basename-normalization trade-off

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Read "don't ask again" suggestions removed: the engine consults
  content rules only for Bash, so the persisted Read(<dir>/**) rule
  could never match — re-asking right after promising not to is
  worse than no option (path-rule matcher = parked follow-up)
- project/local permission settings move to .clawcodex/ — the
  .claude/settings{,.local}.json names are owned by the real Claude
  Code harness; sharing them would read AND mutate the harness's
  live rules (this worktree's own .claude/settings.local.json
  proved the collision)
- registry apply/persist failures now logged (incl. per-update
  persist result); subagent rebind divergence documented at the
  rebind site; _with_default_suggestions returns a replace() copy
  instead of mutating tool-owned decisions
- protocol surfaces properly typed (TYPE_CHECKING imports); dead
  _preview_tool_input removed; stale doc-gate comment corrected;
  chosen_updates None-safe; defaultMode write-only asymmetry noted
- tests: REPL menu mapping (always/feedback rows, enable-row
  numbering shift, no-cache-on-always, rebind-target identity),
  headless PRODUCTION setup block loads persisted rules, autouse
  user-settings isolation fixture (hermeticity)

Suite re-verified at the main-0fa986f baseline (12, identical set).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@ericleepi314
ericleepi314 merged commit 54fdc99 into main Jun 11, 2026
singlaamitesh pushed a commit to singlaamitesh/clawcodex that referenced this pull request Jul 7, 2026
…-permission-options

components C1: multi-option permission flow wired to the rule engine
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.

1 participant