refactor: consolidate permission boundaries into permission.ask hook#29
Merged
Merged
Conversation
Loops are autonomous and cannot answer permission prompts. The previous approach patched subagent session permissions after session.created fired, which had race conditions and mutated session state for observability only. Replace it with a synchronous decision at opencode's permission.ask plugin hook so the loop's session ruleset and the hook agree by construction. Permission boundaries - Add evaluatePermissionRuleset(rules, request) returning allow/deny/ask by finding the last matching rule (mirrors opencode session-level semantics) - Add createLoopPermissionAskHook factory that resolves the active loop via sessionLoopResolver and sets output.status based on buildLoopPermissionRuleset() - Wire 'permission.ask' into the plugin hooks in src/index.ts - Remove createLoopPermissionRejectHook patching path and PATCHED_SESSIONS cache; drop redundant patcher tests, add unit and integration tests for the new hook Plan metadata + loop name editing - Unify plan title and loop name extraction into a single metadata helper - Allow editing the loop name from the execute plan dialog, persisting through tui-execution-preferences and loops-repo - Add migration 131_add_loop_model_variants.sql for model variant storage Housekeeping - Bump version to 0.4.6 - Refresh README, docs/api, docs/architecture, docs/modules to match - Add tui-models helpers and tui-client variants tests
…n boundaries refactor
- Delete unused src/utils/plan-patch.ts and src/utils/session-stats.ts - Remove unused zod and @opentui/keymap dependencies - Drop unused exports: truncateMiddle, formatDuration (format.ts), resolveCurrentGitBranch, fetchLoopByName - Shrink barrel re-exports in src/loop/index.ts, src/storage/index.ts, src/hooks/index.ts; consumers import from source modules directly - Drop LOOP_BLOCKED_TOOLS and extractPlanTitle re-exports in plan-approval.ts - Drop unused Phase type alias in src/loop/state.ts - Drop ModelUsage and LoopSessionOutput re-exports in loop-format.ts - Add test/utils/tui-client-variants.test.ts to vitest include so buildPromptModelSelection coverage actually runs - Update docs/modules.md to drop references to deleted files Reduces fallow dead-code findings from 127 to 67.
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.
Summary
Loops are autonomous and cannot answer permission prompts. The previous approach patched subagent session permissions after
session.createdfired, which had race conditions and mutated session state for observability only.This PR replaces it with a synchronous decision at opencode's
permission.askplugin hook. The policy is consolidated into a pureevaluatePermissionRulesethelper so the loop's session-level ruleset and the new hook agree by construction.It also unifies plan title and loop name extraction into a single metadata helper, allows editing the loop name from the execute plan dialog, and adds model variant storage migration.
Changes
evaluatePermissionRuleset(rules, request)returningallow/deny/ask;createLoopPermissionAskHookfactory; remove oldsession.updatepatcher path andPATCHED_SESSIONScache.131_add_loop_model_variants.sql;tui-models.tshelpers; extended execute plan panel for variant state.Tests
evaluatePermissionRulesetandcreateLoopPermissionAskHook.Verification
bun run typecheck— cleanbun run lint— pre-existing warnings only