Skip to content

Share the zsh/bash bound evaluation between the status read and the write - #208

Merged
bcourbage merged 1 commit into
mainfrom
cleanup/setup-shared-evaluation
Nov 8, 2026
Merged

bcourbage merged 1 commit into
mainfrom
cleanup/setup-shared-evaluation

Conversation

@bcourbage

Copy link
Copy Markdown
Owner

What

CommandLineSetupCoordinator.boundEvaluation (the status and preview read) and permitsMutation (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 call CommandLineSetupBound.evaluateExistingFile. Those steps are now one function, evaluateShellFile(contents:resolvedPath:shellPath:env:defaults:), and both call it.

What stays separate

  • The write path still reads its own snapshot and content in one read (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.
  • The fish branches are left alone: fishEvaluation reports reasons and does not check metadata, while permitsMutation'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 (including test_permitsMutation_appliesFullBoundToGuardingContents) are the contract.

Verified

Compiles on Heracles. Three local make test runs 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

…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>
@bcourbage
bcourbage merged commit b055653 into main Nov 8, 2026
2 checks passed
@bcourbage
bcourbage deleted the cleanup/setup-shared-evaluation branch November 8, 2026 16:47
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