Repository navigation
Share the zsh/bash bound evaluation between the status read and the write - #208
Merged
Merged
Conversation
…rite boundEvaluation (the status and preview read) and permitsMutation (the write's re-check on its own guarding read) each repeated the same steps: parse the whole file, find the text before the begin marker and parse it, check metadata, and match ownership, then call evaluateExistingFile. Move those steps into one function, evaluateShellFile, that both call. The write path still reads its own snapshot and content together and still re-evaluates the bound on exactly those bytes before it writes; only the evaluation is shared, so the two cannot drift apart. The calls into the environment happen in the same order as before. The fish branches differ (the status read reports reasons, the write also checks metadata) and are left as they were. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
CommandLineSetupCoordinator.boundEvaluation(the status and preview read) andpermitsMutation(the write's re-check) each repeated the same zsh/bash steps: parse the whole file, take the text before the begin marker and parse it, check metadata, match ownership, then callCommandLineSetupBound.evaluateExistingFile. Those steps are now one function,evaluateShellFile(contents:resolvedPath:shellPath:env:defaults:), and both call it.What stays separate
snapshotWithContents) and re-evaluates the bound on exactly those bytes before writing; only the evaluation is shared. The identity guard on the replace is untouched.fishEvaluationreports reasons and does not check metadata, whilepermitsMutation's fish branch returns a Bool and does. Unifying them would change behavior.Behavior
Unchanged. The environment calls happen in the same order as before (whole-file parse, prefix parse, metadata, then ownership during evaluation), and the Bound rules themselves are not touched.
Size
Production +17/-21, one file. No test files touched; the existing
CommandLineSetup*tests (includingtest_permitsMutation_appliesFullBoundToGuardingContents) are the contract.Verified
Compiles on Heracles. Three local
make testruns hung before the runner connected ("test runner hung before establishing connection", no test ran), so CI is the verification of the test suite for this PR.🤖 Generated with Claude Code