fix(cliffs): port fixImpossibleCells' self-retry (#18) - #78
Merged
Conversation
Decompiling CellEdgeCliffCrossingArray::fixImpossibleCells whole shows
its `bool` is not a caller-supplied mode but a retry flag the function
sets on ITSELF. On reaching a cell it cannot fix, the tail does
uVar10 = param_2 & 1; param_2 = 1;
if (uVar10 != 0) { log(...); return; }
goto <top of function>;
turning the flag on and restarting the entire pass, which now begins by
zeroing the eight outer edges of the chunk's four corner cells; a second
failure abandons the rest of the chunk. The restart re-sweeps the arrays
as already mutated by the abandoned pass, not the raw crossings.
The note in cliffs-NOTES.md said this step "never runs in this path at
all", reasoning from crossingsForChunk passing `false`. That is the
general error worth naming: a parameter's value at the call site says
what the caller wants, not what the function does with it.
Everything else in the sweep already matched. The engine counts non-zero
edges and consults the orientation table only when the count is below 3;
that is pure optimisation, since all 20 placing codes have one or two
crossings, so checking the table directly is equivalent.
DOES NOT FIX #18, and the numbers say so rather than an argument. The
retry fires once in 512 chunks over the committed captures - one chunk
of Vulcanus [1500,1500], zero across both Nauvis seeds and the other two
Vulcanus regions - and changes not one placed cell: 335 / 1065 / 375
before and after, recall, precision and the orientation count all
identical. This is correctness, not progress.
Because the integration fixtures barely execute the branch, it gets a
dedicated spec that constructs a stuck corner directly (L = +1, T = -1
at cell (0,0) is code 0x4C, illegal, with both crossings on edges the
sweep may not clear). Disabling the retry fails 3 of its 5 tests; the
other 2 are the setup assertion and a control that the corner step does
NOT fire on a healthy chunk, since it clears eight edges unconditionally
and would delete real cliffs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013eczw9uoWDfN6Wc6kA7UBY
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.
The last surviving candidate from #77, decompiled whole. It turned up a real unported behaviour - and, honestly, one that does not move #18.
The
boolis a retry flag the function sets on itselfCellEdgeCliffCrossingArray::fixImpossibleCells(bool)at0x10160c550. On reaching a cell it cannot fix, the tail does:It turns the flag on and restarts the entire pass, which now begins by zeroing the eight outer edges of the chunk's four corner cells. A second failure abandons the rest of the chunk. The restart re-sweeps the arrays as already mutated by the abandoned pass, not the raw crossings.
cliffs-NOTES.mdsaid this step "never runs in this path at all", reasoning fromcrossingsForChunkpassingfalse. That is the general error worth naming: a parameter's value at the call site says what the caller wants, not what the function does with it.Everything else in the sweep already matched -
L, T, R, Border, the same boundary guards, the same legality set. The engine counts non-zero edges and consults the orientation table only when the count is below 3; that is pure optimisation, since all 20 placing codes have one or two crossings.It does not fix #18, and the numbers say so
[0,0]placed[1500,1500]placed[-1200,800]placedThe retry fires once in 512 chunks over the committed captures - one chunk of Vulcanus
[1500,1500], zero across both Nauvis seeds and the other two Vulcanus regions - and changes not one placed cell. This is correctness, not progress.So it needs its own test
Because the integration fixtures barely execute the branch,
test/fixImpossibleCellsRetry.spec.tsconstructs a stuck corner directly:L = +1,T = -1at cell(0,0)is code0x4C, illegal, with both crossings on edges the sweep is forbidden to clear. Disabling the retry fails 3 of its 5 tests. The other two are the setup assertion (proving the constructed cell really is stuck and illegal) and a control that the corner step does not fire on a healthy chunk - it clears eight edges unconditionally, so firing spuriously would delete real cliffs.Where #18 stands now
Everything upstream is eliminated and the rule is now read end to end -
generateCliffs,tryToAddCliff,crossingsForChunk,fixImpossibleCells. 12.5% of shared cells still carry the wrong crossings (29.8% at[0,0]), with 125 of 175 differing in exactly two edges. I do not have a next candidate from the disassembly; the code as read matches the port.pnpm run verifygreen: 305 files checked, 1284 tests.🤖 Generated with Claude Code
https://claude.ai/code/session_013eczw9uoWDfN6Wc6kA7UBY