Skip to content

fix(cliffs): port fixImpossibleCells' self-retry (#18) - #78

Merged
wormeyman merged 1 commit into
mainfrom
fix/fix-impossible-cells-retry
Jul 30, 2026
Merged

fix(cliffs): port fixImpossibleCells' self-retry (#18)#78
wormeyman merged 1 commit into
mainfrom
fix/fix-impossible-cells-retry

Conversation

@wormeyman

Copy link
Copy Markdown
Collaborator

The last surviving candidate from #77, decompiled whole. It turned up a real unported behaviour - and, honestly, one that does not move #18.

The bool is a retry flag the function sets on itself

CellEdgeCliffCrossingArray::fixImpossibleCells(bool) at 0x10160c550. On reaching a cell it cannot fix, the tail does:

uVar10 = param_2 & 1;  param_2 = 1;
if (uVar10 != 0) { log("Unable to remove excess cliff cell edge crossings"); return; }
goto <top of function>;

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.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 - L, T, R, B order, 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

before after
[0,0] placed 335 335
[1500,1500] placed 1065 1065
[-1200,800] placed 375 375
recall / precision / orientation count all identical

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. This is correctness, not progress.

So it needs its own test

Because the integration fixtures barely execute the branch, test/fixImpossibleCellsRetry.spec.ts constructs a stuck corner directly: L = +1, T = -1 at cell (0,0) is code 0x4C, 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 verify green: 305 files checked, 1284 tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_013eczw9uoWDfN6Wc6kA7UBY

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
@wormeyman
wormeyman merged commit a6ad05b into main Jul 30, 2026
2 checks passed
@wormeyman
wormeyman deleted the fix/fix-impossible-cells-retry branch July 30, 2026 23:12
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.

Vulcanus cliffs: 12.5% of matched cells get the wrong cliff_orientation (residual after the placement-count fixes)

1 participant