perf(memory): defer to_lowercase in extract_facts until triggers fire#608
Merged
matedev01 merged 2 commits intoJul 6, 2026
Merged
Conversation
4 tasks
Skip the allocating Unicode lowercase view on common no-match utterances (weather, questions, chit-chat) by gating on ASCII case-insensitive marker scans before building the lowercased buffer. Remember-only inputs still take a zero-alloc fast path. Extended the extract_facts regression corpus with mixed-case no-match cases. Co-authored-by: Cursor <cursoragent@cursor.com>
536150e to
7393275
Compare
4 tasks
matedev01
approved these changes
Jul 6, 2026
matedev01
left a comment
Contributor
There was a problem hiding this comment.
LGTM — behavior-preserving (ascii-CI gating = old lowercasing for all-ASCII triggers), extended corpus regression covers no-match case. 826 lib, BFCL 96%.
This was referenced Jul 6, 2026
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.
Summary
Defers the allocating
to_lowercase()inextract_factsuntil an identity, preference, or relationship trigger is present. Common no-match utterances (weather, questions, chit-chat) now skip the lowercase allocation entirely while preserving byte-identical extraction output.Fixes #607
Changes
needs_extract_facts_lower+ ASCII case-insensitive trigger gates over the existing marker sets;to_lowercase()is built only when a gate fires.Remember …with no other triggers still works without allocating a lowercase buffer.extract_benchcommentary.Real Behavior Proof
Tested profile / hardware (check all that apply):
jetsonraspberry_piportable_sbclaptopmacWhat I ran
No local Rust toolchain on this Windows dev machine (
cargonot on PATH). Pushed branch and relied on upstream CI (cargo fmt,cargo clippy -D warnings,cargo test) for correctness proof. Theextract_facts_corpus_regressionintegration test guards byte-identical output across identity, preference, relationship, remember, and no-match inputs including mixed case.What I observed
Awaiting CI on push. Prior PRs (#562, #575) on the same repo validated the CI-only path; this change is confined to
extract_factswith the existing differential corpus extended.Test plan
cargo test -p genie-core extract_facts_corpus_regressioncargo test -p genie-core extract_cargo test -p genie-core --release --ignored --nocapture bench_extract_factsand compareno-matchper-call latency before/afterNotes for reviewers
The trigger gates mirror the existing lowercase substring checks from #495; only the order changes (gate before alloc, not after). Relationship still uses the
"my "marker gate already present inextract_relationships.