Skip to content

fix(fault): restore a cutting fault before the fault it cuts - #427

Merged
lachlangrose merged 3 commits into
masterfrom
fix/restore-cutting-faults-first
Nov 26, 2026
Merged

lachlangrose merged 3 commits into
masterfrom
fix/restore-cutting-faults-first

Conversation

@lachlangrose

Copy link
Copy Markdown
Member

Problem

A fault created with faults=[A] is faulted by the younger fault A, so A must be restored first. But features keep their faults newest first (FeatureRelationshipManager.add_faults walks reversed(features)), and A must exist before the fault it cuts, so A always comes after the fault it cuts in every list. restore_through then applies the cut fault first:

  • its frame restores every point through A again inside each of its steps (nested apply_to_points), and the work multiplies at every level of a chain of cutting faults;
  • the result near the intersection is different from restoring A first.

Measured on a 5-fault test model with a chain of cuts (2000 points): 3460 fault calls, 14.2 s in the current order; 5 calls, 0.034 s with the cutting faults first. About 2 % of the points differ, by up to 72 m (max displacement 112 m), all near intersections. Deeper chains grow roughly 20× per level.

Fix

restore_through orders the faults with cutters_first: a cutting fault (from the fault frame builders, or the frame members once built) comes before every fault of the list that it cuts. Faults without such a relation keep the order of the list, so models without faulted faults do not change. Moving points forward (reverse=True) puts the cutting fault last and otherwise keeps the list order. The feature builder rotates data vectors in the same order. A cycle of relations keeps the list order.

The global convention for unrelated faults (newest first) is unchanged here; that is a separate decision.

Tests

  • tests/unit/modelling/test_cut_fault_restore_order.py: the ordering helper (cutter first, unrelated order kept, forward order unchanged without relations), and a model with OLD cut by YOUNG: a feature restores young then old, with 2 fault calls and the same points as restoring by hand. On master that model makes 14 fault calls, restores old first and differs by up to the full slip (0.12 in a unit box).
  • Full pytest tests: 2914 passed, 31 skipped. Ruff: no new findings.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx

lachlangrose and others added 2 commits November 26, 2026 20:30
A fault created with faults=[A] is faulted by the younger fault A, so A
must be restored first. Features keep their faults newest first, and A
must exist before the fault it cuts, so A came after it in every list:
restore_through applied the cut fault first, its frame restored every
point through A again inside each step, and the result near the
intersection differed. In a chain of cutting faults the work multiplied
at each level (a 5-fault test model: 3460 fault calls and 14.2 s for 2000
points; restored cutters first: 5 calls and 0.034 s).

restore_through now orders the faults so that a cutting fault comes
before every fault of the list that it cuts (cutters_first); faults with
no such relation keep the order of the list, so models without faulted
faults do not change. Moving points forward (reverse) puts the cutting
fault last. The builder rotates data vectors in the same order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
_cutters read the members by index, which calls __getitem__ of any
fault-like object in a list (a test double asserts its key). The members
are in StructuralFrame.features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose added a commit that referenced this pull request Nov 26, 2026
#427 (open against master) restores a cutting fault before the fault it
cuts, so a fault frame displaced by a younger fault no longer restores
every point through it again at each step. It is the same commit as on
the PR branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose added a commit that referenced this pull request Nov 26, 2026
…feat/003-fault-evaluation-performance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
lachlangrose added a commit that referenced this pull request Nov 26, 2026
…fter #427 (C-021)

#427 restores a cutting fault before the fault it cuts. In cutting_faults
the frame of fault_1 is faulted by fault_0, so fault_0 is now restored
first and the frame of fault_1 makes no nested restoration. The 5
changed outputs of cutting_faults (group_0 value and gradient, the
surface at 50 and the unit boundary distances; the model ids do not
change) come from master 315dff4 with #425 and #427; the spec branch
gives the same bits for all 970 golden arrays.

The counts of cutting_faults follow: evaluate_model 2 fault calls (22),
group_0 gradient 9 (29), none nested; the value call keeps one batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
A fault applied through a list that names only its direct cutters (a
fault frame builder, or a feature with faults=[C]) restored through C
alone. The frame of C was built in the space restored through its own
cutter B, so C restored every point through B again at each step, and B
through A: the nesting gained one level for each link of a chain, and the
cost multiplied (build of a 5-fault chain: 272.7 s and 44850 fault calls).

restore_through now adds, transitively, the faults that cut a fault of
the list (with_cutters) and restores them in one pass, youngest first,
each told what is already restored. A fault frame cut by B is then also
moved by the younger faults that cut B, where their displacement reaches
it. The same 5-fault chain builds in 7.0 s (1923 fault calls); a 6-fault
chain in 15 s. The builder rotates data vectors through the same faults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
@lachlangrose

lachlangrose commented Nov 26, 2026 •

Copy link
Copy Markdown
Member Author

Follow-up in commit 79f66bf: restore the whole chain of cutting faults in one pass (with_cutters).

Ordering within a list was not enough: a fault frame builder, or a feature with faults=[C], names only the direct cutter C. C's frame was built in the space restored through its own cutter B, so C restored every point through B again at each step, and B through A — one more nesting level per link, so the cost multiplied along a chain.

restore_through now also restores, transitively, the faults that cut a fault of the list, in one pass, youngest first. A frame cut by B is then also moved by the younger faults that cut B, where their displacement reaches it (decided with the maintainer: "whole chain of cutters").

Build time of a cutting chain (one fault cut by the previous one):

chain depth before after
3 20.7 s (6411 fault calls) 4.3 s (776)
4 272.7 s (44850) 7.0 s (1923)
5 not finished 15.0 s (3825)

New test test_a_chain_of_cuts_is_restored_in_one_pass: applying the oldest fault of a 3-fault chain nests at most 2 deep (3 before). Full pytest tests: 2914 passed, 31 skipped.

lachlangrose added a commit that referenced this pull request Nov 26, 2026
…to feat/003-fault-evaluation-performance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
@lachlangrose
lachlangrose merged commit ef6389e into master Nov 26, 2026
37 checks passed
@lachlangrose
lachlangrose deleted the fix/restore-cutting-faults-first branch November 26, 2026 22:23
lachlangrose added a commit that referenced this pull request Nov 26, 2026
…o feat/003-fault-evaluation-performance

The branch already had the same fixes as merges of their PR branches.
Two conflicts: _fault_segment.py keeps the branch's placement of the #425
fallback (after the frame gradient of _evaluate_frame), and
test_cut_fault_step_direction.py keeps the branch's version that turns
the shared frame lookup off for the NaN-rule test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XADRvHhG72666JkYNHtzUx
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