Match Vode statuses and rule keys exactly, not by prefix - #94
Merged
Conversation
Ruleset.filter matched a status with re.match, so the pattern "init" also
fired for "initialise"; Vode.set interpolated the key as "{key}.*", so
set("u", ...) fired a rule written for "u2" and then skipped the fallback
that stores "u" itself.
cemde
force-pushed
the
fix/69-vode-prefix-matching
branch
from
August 9, 2026 18:23
e909bd8 to
45a1eda
Compare
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.
Bug
Two regexes in
_vode.pywere anchored only at their start, so both matched by prefix where they meant to match the whole string.Ruleset.filterusedre.match(pattern, status). The built-in ruleset registers its forward-init rules under the pattern"init", sore.matchaccepted any status beginning withinit.Vode.setbuilt its rule pattern asf"...<-\s*({key}.*)". The trailing.*means the key group matched any rule whose right-hand side merely starts with the key.Impact
A user who names a phase
initialiseorinit_weightssilently gets theh, u <- urule, which copies the prediction into the node value. The prediction error, and therefore the energy, is identically zero for that whole phase.For keys the damage is doubled. A node with two incoming activations,
ufrom the layer above andu2from a skip connection, hasu2's rule fire withu's value. And because a rule matched, thelen(rules) == 0fallback never runs, souis never stored under its own name at all. With ruleset("z <- u2",),set("u", 7.0)leftcache["z"] == 7.0andcache["u"]unset.Fix
Both matches become
re.fullmatch, and the key group gains an explicit optional tail for the:transformationsuffix:fullmatchrestores the documented meaning of the patterns as regexes:.*is the way to say "any status", which was meaningless while every pattern carried an implicit one.(?::.*)?is non-capturing, so_match.group(1, 2)still yields the same targets and transformation.Why not a trailing
$$also matches immediately before a trailing newline, so it is strictly weaker thanfullmatch. It would also leaveRuleset.filterapplying whole-string matching to its status argument and prefix matching to its rule argument, with the anchoring obligation pushed into an undocumented caller convention thatVode.getdoes not follow.Closes #69