Repository navigation
fix: running sessions follow the permission mode from Settings - #1930
Merged
Merged
Conversation
Running sessions kept launch policies, and overlapping settings refreshes could publish an older allow policy after a newer prompt policy. Profile read failures were also treated as missing settings, reopening the gate. Refresh before decisions, version refresh publication, and copy the validated policy snapshot under the same lock. Propagate profile read and JSON errors so failed refreshes retain the previous policy. Reuse immutable settings and factory allow policies; clarify that only clarification conversations follow the parent gate, while ordinary task workers use fixed allow. Tests: reproduced stale publication, profile failures and repeated factory compilation red before fixing them. Focused approval and posture tests pass, including three race-detector runs across session, command and config packages. Factory unchanged builds drop from 10 allocations to zero; the settings-gate benchmark retains 29 allocations per build. Build and formatting checks pass. Validation limits: make test-quick was run once and fails on an unchanged factory reportCancel vet warning. Remaining gates also expose existing manual retrieval, help and structural-law failures. The original manual reproduces the retrieval failures. Changelog validation flags existing entries and this change's draft PR-0 entry; no pull request is opened by this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cause: starting a competing refresh invalidated a tool's successful prompt build before a replacement was published. The tool could then fall back to the previous allow policy and run without consent. Fix: hold the existing session mutex across settings Build, publication and immutable decision snapshot selection. Posture builds and explicit policy pushes share that mutex. Remove approvalVersion and stale-publication branches, preserving conversation overrides, failed-read retention and the content-keyed settings cache. Update the manual, change entry and performance documentation to describe serialized refreshes. Tests: reproduce the consent bypass before fixing it. Channel-controlled Builds cover both completion orders and both posture/refresh orders, with a mutex-ownership assertion that detects the old design deterministically. The final regressions fail against the original implementation in all three runs. Focused approval, posture, consent, clarification, settings-read and cache-reuse tests pass via make test-focus, including -race -count=3 across session, command and config packages. Focused source and packed manual checks and git diff --check pass. Standards and spec reviews have no findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cause: refreshApprovalGate and SetApprovalPosture held the general Agent.mu across gate.Build filesystem work, so a stalled read blocked Interrupt, StopWork, consent resolution and Close. Fix: serialize builds, publication, explicit policy pushes and snapshot selection with approvalMu. Hold Agent.mu only for state reads and writes, and document approvalMu-before-mu ordering. Preserve refresh ordering, failed-build retention and immutable decision snapshots. Update the manual, change entry and performance documentation. Tests: first reproduce all four refresh/posture and Interrupt/StopWork combinations with channel-blocked Builds, without sleeps. All pass after the fix and confirm cancellation before Build is released. Run 105 focused approval, consent and related tests via make test-focus across internal/session and cmd/codeaf with -race -count=3; both packages pass. Existing approval ordering tests remain, with their ownership assertion using approvalMu. Focused session/TUI manual gates and source/packed permission checks pass. Full manual checks reproduce the same three retrieval assertion failures at the starting commit. Changelog check reports 228 identical baseline/candidate metadata violations. git diff --check passes. Standards and spec reviews report no findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 changes
A running conversation now follows Settings > Permissions (
tools.approvalMode:promptorallow) on its next tool decision, in both directions, without a relaunch.Correctness
allowover a newerprompt, and a decision never falls back to an old policy while a newer refresh is unfinished.allow.Validation
make test-focuswith-race -count=3oninternal/sessionand thecmd/codeafapproval tests: pass.Known pre-existing failures (also on app/v3)
go vetcontext-leak report atinternal/factory/run/chatstage.go:402, both unchanged by this branch.🤖 Generated with Claude Code