refactor: share repeated helpers in the root module - #1325
Conversation
| let spill_dir = @fs.tmpdir(prefix~) | ||
| // Reclaimed when the group ends — after every job it spawned has | ||
| // terminated — the same group-defer shape `build_tools` uses above. | ||
| group.add_defer(() => { |
There was a problem hiding this comment.
why such change in a refactoring?
There was a problem hiding this comment.
Fair, and reverted. mbtx_fixture no longer registers a group defer for the
spill directory, and all twelve tests reclaim it at the end of their own body
again, exactly as before.
You are right that it does not belong in a refactor: moving cleanup from
end-of-test to end-of-group runs it later, and also runs it on
assertion-failure paths where the old trailing rmdir was never reached. My
own review of this sweep had flagged it as the single hunk that was not
behaviour-preserving, so your question is the right verdict on it. If the
better lifetime is wanted, it should be its own change with that as the stated
point.
The wait_until poller and the table-driven registry test stay: neither
changes anything observable.
| end : Int, | ||
| matches : (String) -> Bool, | ||
| ) -> Bool { | ||
| for index in start..<end { |
There was a problem hiding this comment.
for arg in words[start:end]?
There was a problem hiding this comment.
Applied. any_arg_before_ddash iterates words[start:end] directly, so the
index binding is gone.
This is the half that needs a careful read: these hunks add or remove something SHARED, so correctness depends on code outside the hunk you are looking at. What to check, hardest first: 1. **An extracted helper must be equivalent at every call site it replaced.** The trap is a call site that passed a different argument, or read state at a different moment, than its neighbours. 2. **A merged or-pattern arm must have had identical bodies.** 3. **A reshaped loop must keep its iteration order and its early exits.** The purely local rewrites these were mixed with have been split into a separate pull request, so everything left here is shared-surface change. Verified on this branch alone, with no other part of the refactor applied: `moon fmt --check`, `moon check --target native --deny-warn`, `moon check --target js --deny-warn`, and the full native and JS test suites. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JiBNGzCsZpN6e5Y4p9pXdn
b113d79 to
6a2eb89
Compare
This half needs a careful read. Every hunk here adds or removes something
SHARED, so correctness depends on code outside the hunk you are looking at. The
purely in-function rewrites this was mixed with have moved to a separate pull
request, so what is left is all shared-surface change.
What to check, hardest first:
The trap is a call site that passed a different argument, or read state at a
different moment, than its neighbours.
differed and the difference moved inside the arm, the fold buys less than it
appears to.
Scope: the root module. The shared pieces are
any_arg_before_ddashfor the git-policy option scans,realpath_or_sameandfirst_protected_workspace_sourcein the shell sandbox, the viz app's filter and card helpers, andarray_fieldacross the eval harness.Review comments addressed
mbtx_fixture— reverted. Thefixture no longer registers a group defer for the spill directory, and all
twelve tests reclaim it at the end of their own body as before. That hunk
moved cleanup from end-of-test to end-of-group, which runs it later and also
on assertion-failure paths where the old tail was never reached. It may be an
improvement, but it is a behaviour change and does not belong in a refactor.
wait_untiland the table-driven registry test, which change nothingobservable, stay.
for arg in words[start:end]? — applied.any_arg_before_ddashiteratesthe slice directly instead of indexing.
Verified on this branch alone
moon fmt --check,moon check --target native --deny-warn,moon check --target js --deny-warn, and both full test suites, with no other part of therefactor applied. No
.mbtichanged.The refactor is split so each pull request asks one kind of question. Every file
appears in exactly one of them, each was verified on its own branch with no
other part applied, so they merge in any order.
desktop/editor/🤖 Generated with Claude Code
https://claude.ai/code/session_01JiBNGzCsZpN6e5Y4p9pXdn