fix: inline regex flags ((?i)) silently killed 50 of 57 instincts - #35
Open
juanparisma wants to merge 1 commit into
Open
fix: inline regex flags ((?i)) silently killed 50 of 57 instincts#35juanparisma wants to merge 1 commit into
(?i)) silently killed 50 of 57 instincts#35juanparisma wants to merge 1 commit into
Conversation
`(?i)` is Python/PCRE syntax. JavaScript has no inline flags, so
`new RegExp("(?i)foo")` throws "Invalid group" -- and both activators compiled
patterns inside a try/catch whose handler was a bare `continue`. An instinct
written that way was dropped in total silence: valid JSON, right level, sensible
inject, and it never fired once for the rest of its life.
Nothing surfaced it. The index looked healthy, /dream reported the pattern only
as the generic "invalid_regex", and the occurrence counter simply stayed at zero
-- which is indistinguishable from an instinct whose trigger just never came up.
The patterns are authored by the model when an instinct is created, and `(?i)`
is the reflex spelling for anyone used to grep or Python, so this accumulates
quietly. On the index that surfaced it, 50 of 57 instincts were dead this way;
the seven survivors were simply the ones nobody had prefixed. Sorting by
occurrences made it unmistakable -- every instinct with real activity lacked the
prefix, every prefixed one sat at zero or held a count from before it was added.
Fixes, in the order they matter:
- Both activators normalise inline flag groups before compiling. Stripping `(?i)`
is lossless here because they already pass the "i" flag -- it was redundant on
top of being fatal. Other groups map to real flags where JS has an equivalent
and are dropped otherwise, which still beats losing the whole instinct. This
revives existing indexes without asking anyone to edit their data.
- A pattern that genuinely cannot compile is now logged as BAD_PATTERN with the
instinct id and the engine's message, instead of vanishing. Silence is what let
this run for months.
- /dream distinguishes "inline_flag_group" from "invalid_regex" and carries a
Detail column, so the report points at the cause instead of a category.
- commands/analyze-session.md says not to write inline flags when authoring a
trigger, so new instincts stop arriving broken.
tests/test-inline-regex-flags.sh pins all of it: that JS really does reject the
syntax, that a `(?i)` instinct fires, that an uncompilable one is logged, and
that /dream separates the two causes. Verified to fail 4/5 against the unpatched
activators and pass 5/5 with them, so the tests are not passing for their own
reasons.
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 bug
(?i)is Python/PCRE syntax. JavaScript has no inline flags:Both activators compile trigger patterns inside a
try/catchwhose handler is abare
continue:So an instinct written with
(?i)is dropped in total silence. It stays in theindex looking perfectly healthy — valid JSON, right level, sensible
inject— andnever fires once for the rest of its life.
Why it went unnoticed
Nothing surfaced it. The index was valid,
/dreamreported only the genericinvalid_regex, and the occurrence counter stayed at0— which is exactly what aninstinct whose trigger simply never came up also looks like.
Trigger patterns are authored by the model when an instinct is created, and
(?i)isthe reflex spelling for anyone used to grep or Python. So it accumulates quietly, one
instinct at a time.
On the index that surfaced this, 50 of 57 instincts were dead. Sorting by
occurrences made it unmistakable:
(?i)env-vars-never-hardcode(?i)error-handling-explicit(?i)git-push-rebase-shared-repo(?i)git-commit-conventional(?i)memory-md-index-only(?i)verify-numbers-at-source(?i)The survivors were simply the ones nobody had prefixed.
There is a second-order hazard worth flagging: because everything looked
never_activated,/dream's staleness module marked ~50 instincts asarchive_candidate. Following that advice would have archived a knowledge base whoseonly problem was a syntax error.
The fixes
(?i)is lossless here — they already pass the
"i"flag, so it was redundant on top ofbeing fatal. Other groups map to real flags where JS has an equivalent and are
dropped otherwise, which still beats losing the whole instinct. This revives
existing indexes in place, without asking anyone to edit their data.
BAD_PATTERNwith theinstinct id and the engine's message. Silence is what let this run for months.
/dreamdistinguishesinline_flag_groupfrominvalid_regexand carries aDetailcolumn, so the report names the cause instead of a category.commands/analyze-session.mdtells the author not to write inline flags, so newinstincts stop arriving broken.
_passive-activator.shgets the same treatment. The shipped rules are clean today,but they are hand-written like the instincts — the next one is one
(?i)away fromvanishing the same way.
Verification
tests/test-inline-regex-flags.shpins all of it: that JS really does reject thesyntax, that a
(?i)instinct fires, that an uncompilable pattern is logged, and that/dreamseparates the two causes.stashing the fix, so the tests are not passing for their own reasons.
a038b50(16 existing + the newone, which is wired into
.github/workflows/tests.yml).Scope
6 files. No data migration: users' indexes keep their existing patterns and start
working again on the next tool use.