Skip to content

Simplify dereference string processing#51

Merged
islas merged 2 commits into
releases/1.1.0from
deref_simplify_track_hist
Jun 9, 2026
Merged

Simplify dereference string processing#51
islas merged 2 commits into
releases/1.1.0from
deref_simplify_track_hist

Conversation

@islas

@islas islas commented Jun 9, 2026

Copy link
Copy Markdown
Owner

The dereference regex (both full string detection and bracket indexing) originally has two near identical copies to account for any number of repeating sub-references and a final fully formed attribute. If the regex has to be modified for new syntax it must be updated in both locations.

To fix this the regex now expects one or more fully formed attribute expressions that are delimited by '.' character. To avoid duplication of the regex again using lookbehind constructs the expression does allow ending a reference string with '.' which is technically malformed.

The logic for processing reference strings consisted of comparing the set of matches and their spans to see if they are roughly equivalent. This was both inefficient, overly complicated, and lacked checking for cycles greater than one step (A->A->A).

An improvement on this is to instead keep a history of each full set of substitutions made in a list, and after the first pass check if the new processed string is within the history. This method both greatly simplifies the check condition if a string is done processing (i.e. it did not change on the next pass therefore no more substitution can be made) and if a complex cycle was encountered (e.g. appears in the history that is not the latest change).

A side benefit to this is our logging info can now include the full breakdown of substitutions per iteration by repeating that history back until the final output, which may be useful for debugging. This info is not controllable at the moment, but may be considered for toggling if it begins to clutter logs.

A reference string with malformed ending ('.') is allowed and produces a warning message, with corrections to the string made in situ during processing.

Tests are included to ensure that this simplification addresses previous issues and is an overall improvement.

islas added 2 commits June 8, 2026 16:46
The dereference regex (both full string detection and bracket indexing)
originally has two near identical copies to account for any number of
repeating sub-references and a final fully formed attribute. If the
regex has to be modified for new syntax it must be updated in both
locations.

To fix this the regex now expects one or more fully formed attribute
expressions that are delimited by '.' character. To avoid duplication
of the regex again using lookbehind constructs the expression *does*
allow ending a reference string with '.' which is technically malformed.

The logic for processing reference strings consisted of comparing the
set of matches and their spans to see if they are roughly equivalent.
This was both inefficient, overly complicated, and lacked checking for
cycles greater than one step (A->A->A).

An improvement on this is to instead keep a history of each full set of
substitutions made in a list, and after the first pass check if the new
processed string is within the history. This method both greatly
simplifies the check condition if a string is done processing (i.e. it
did not change on the next pass therefore no more substitution can be
made) and if a complex cycle was encountered (e.g. appears in the
history that is not the latest change).

A side benefit to this is our logging info can now include the full
breakdown of substitutions per iteration by repeating that history back
until the final output, which may be useful for debugging. This info is
not controllable at the moment, but may be considered for toggling if it
begins to clutter logs.

A reference string with malformed ending ('.') is allowed and produces
a warning message, with corrections to the string made in situ during
processing.
Test for edge cases of complex cycles and malformed but accepted strings
@islas islas changed the title Deref simplify track hist Simplify dereference string processing Jun 9, 2026
@islas islas merged commit 4d2b999 into releases/1.1.0 Jun 9, 2026
8 checks passed
@islas islas mentioned this pull request Jun 15, 2026
islas added a commit that referenced this pull request Jun 15, 2026
# Official release

Includes the following PRs:
* #38
* #39
* #40
* #41
* #42 
* #43 
* #44 
* #45 
* #46 
* #47 
* #48 
* #49 
* #50 
* #51 
* #52 
* #53 
* #54 
* #55
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