Repository navigation
feat(#349): memory type formalization + pattern-based auto-inference - #386
Merged
Merged
Conversation
Expand MemoryType enum from 5 to 9 variants (add Note, Insight, Reference,
Event) and add zero-LLM pattern-based inference on every remember().
Core (uteke-core):
- MemoryType enum: +Note, +Insight, +Reference, +Event variants
- MemoryType::infer_from_content(): URL prefix → Reference;
decided/chose/will use → Decision; realized/learned/discovered → Insight;
how-to/numbered list → Procedure; always/never/prefer/hate → Preference;
ISO date + time word → Event; fallback → Note
- MemoryType::recall_boost(): per-type additive score boost
(Decision/Preference +0.05, Insight +0.03, Event +0.02, Note -0.02)
- remember_typed() now runs inference when caller passes the default
'fact'. If inference yields Note (ambiguous), keeps Fact for backward
compatibility. Explicit types are honored as-is.
- Helper functions: contains_any, is_numbered_list, has_iso_date
CLI (uteke-cli):
- --type help text documents the full taxonomy + auto-inference
Tests (+13 new, 208 → 221 core tests):
- enum roundtrip + case-insensitive parsing
- per-pattern inference tests (reference, decision, insight, procedure,
preference, event, fallback note)
- recall_boost sign checks
- has_temporal_validity for new variants
- has_iso_date + is_numbered_list helpers
Closes #349
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-cli · BYOK · MIT |
CodeCora #386 flagged two issues: 1. infer_from_content() used lower.starts_with() on the original content for 'ref:' / 'see:' / 'docs:' detection, while the comment said these are line-start signals. Leading whitespace (e.g. ' ref: ...') would miss the Reference classification. Fixed: use first_line.to_lowercase() for line-start signals. 2. Test hardcoded http://example.com — replaced with https:// and added a regression test for the whitespace case.
CodeCora #386: remember_typed reclassified explicit 'fact' values via auto-inference, breaking the API contract — callers passing 'fact' explicitly could get 'Preference' back. Fix: - remember_typed() now honors the caller-chosen type as-is, no override - remember_auto_infer() is the new inference path; explicit_type=None triggers pattern-based inference, Some(t) bypasses it - remember() default path uses remember_auto_infer(None) so content signals drive the type - Shared embed-then-store logic extracted into private remember_embed() Backward compat preserved: ambiguous content still falls back to 'fact'.
CodeCora #386 round 2 found two bugs in infer_from_content: 1. URL detection used first_line.starts_with("http://") on the original (case-sensitive) string. 'HTTPS://example.com' was NOT detected as Reference. Fix: use first_lower for all prefix checks. 2. is_numbered_list used strip_prefix(single_digit) which only stripped ONE leading digit. '10. item' → strip '1' → rest='0. item' → no separator match. Fix: take_while(all_digits) then check separator. Added regression tests for both cases.
CodeCora #386 r2: remember_auto_infer(Some(t)) forwarded the type string directly to remember_embed without validation, bypassing the unknown-type check that remember_typed performs. An invalid type like 'bogus' would silently be stored. Fix: run the same MemoryType::from_str_opt validation before using the explicit type string.
CodeCora #386 r3: when num_str.parse::<u32>() failed (e.g. overflow from '9999999999999999999999999. x'), the code fell through via 'continue' without resetting consecutive/expected. A large-number line between valid numbered lines would not break the sequence. Fix: on parse failure or out-of-order number, reset consecutive=0 and expected=1.
CodeCora #386 r4: is_iso_date_bytes only checked the digit/dash pattern, accepting impossible dates like 2026-99-99 or 2026-13-40 as valid Event triggers. Fix: parse month and day from the digit bytes and validate month is 1-12 and day is 1-31. Added regression tests for invalid dates.
Clippy CI failed: month/day range checks used manual >= && <= instead of RangeInclusive::contains.
CodeCora #386 r5: is_iso_date_bytes validated month 1-12 and day 1-31 globally, accepting impossible dates like 2026-02-31 or 2026-04-31. Fix: lookup max_day per month (31 for Jan/Mar/May/Jul/Aug/Oct/Dec, 30 for Apr/Jun/Sep/Nov, 29 for Feb to accept leap day). Not a full calendar implementation but eliminates the most obvious false positives. Added tests for per-month invalid dates.
| // non-empty line. Use first_line (not lower) so leading whitespace | ||
| // doesn't matter. | ||
| let first_lower = first_line.to_ascii_lowercase(); | ||
| if first_lower.starts_with("http://") |
ajianaz
added a commit
that referenced
this pull request
Aug 13, 2026
…386) * feat(#349): memory type formalization + pattern-based auto-inference Expand MemoryType enum from 5 to 9 variants (add Note, Insight, Reference, Event) and add zero-LLM pattern-based inference on every remember(). Core (uteke-core): - MemoryType enum: +Note, +Insight, +Reference, +Event variants - MemoryType::infer_from_content(): URL prefix → Reference; decided/chose/will use → Decision; realized/learned/discovered → Insight; how-to/numbered list → Procedure; always/never/prefer/hate → Preference; ISO date + time word → Event; fallback → Note - MemoryType::recall_boost(): per-type additive score boost (Decision/Preference +0.05, Insight +0.03, Event +0.02, Note -0.02) - remember_typed() now runs inference when caller passes the default 'fact'. If inference yields Note (ambiguous), keeps Fact for backward compatibility. Explicit types are honored as-is. - Helper functions: contains_any, is_numbered_list, has_iso_date CLI (uteke-cli): - --type help text documents the full taxonomy + auto-inference Tests (+13 new, 208 → 221 core tests): - enum roundtrip + case-insensitive parsing - per-pattern inference tests (reference, decision, insight, procedure, preference, event, fallback note) - recall_boost sign checks - has_temporal_validity for new variants - has_iso_date + is_numbered_list helpers Closes #349 * fix(#349): reference detection with whitespace + drop http:// URL CodeCora #386 flagged two issues: 1. infer_from_content() used lower.starts_with() on the original content for 'ref:' / 'see:' / 'docs:' detection, while the comment said these are line-start signals. Leading whitespace (e.g. ' ref: ...') would miss the Reference classification. Fixed: use first_line.to_lowercase() for line-start signals. 2. Test hardcoded http://example.com — replaced with https:// and added a regression test for the whitespace case. * fix(#349): split remember_typed (explicit) and remember_auto_infer CodeCora #386: remember_typed reclassified explicit 'fact' values via auto-inference, breaking the API contract — callers passing 'fact' explicitly could get 'Preference' back. Fix: - remember_typed() now honors the caller-chosen type as-is, no override - remember_auto_infer() is the new inference path; explicit_type=None triggers pattern-based inference, Some(t) bypasses it - remember() default path uses remember_auto_infer(None) so content signals drive the type - Shared embed-then-store logic extracted into private remember_embed() Backward compat preserved: ambiguous content still falls back to 'fact'. * fix(#349): uppercase URL schemes + multi-digit numbered lists CodeCora #386 round 2 found two bugs in infer_from_content: 1. URL detection used first_line.starts_with("http://") on the original (case-sensitive) string. 'HTTPS://example.com' was NOT detected as Reference. Fix: use first_lower for all prefix checks. 2. is_numbered_list used strip_prefix(single_digit) which only stripped ONE leading digit. '10. item' → strip '1' → rest='0. item' → no separator match. Fix: take_while(all_digits) then check separator. Added regression tests for both cases. * fix(#349): validate explicit_type in remember_auto_infer CodeCora #386 r2: remember_auto_infer(Some(t)) forwarded the type string directly to remember_embed without validation, bypassing the unknown-type check that remember_typed performs. An invalid type like 'bogus' would silently be stored. Fix: run the same MemoryType::from_str_opt validation before using the explicit type string. * fix(#349): reset counter on parse failure in is_numbered_list CodeCora #386 r3: when num_str.parse::<u32>() failed (e.g. overflow from '9999999999999999999999999. x'), the code fell through via 'continue' without resetting consecutive/expected. A large-number line between valid numbered lines would not break the sequence. Fix: on parse failure or out-of-order number, reset consecutive=0 and expected=1. * fix(#349): validate month/day ranges in ISO date detection CodeCora #386 r4: is_iso_date_bytes only checked the digit/dash pattern, accepting impossible dates like 2026-99-99 or 2026-13-40 as valid Event triggers. Fix: parse month and day from the digit bytes and validate month is 1-12 and day is 1-31. Added regression tests for invalid dates. * fix(#349): clippy manual_range_contains in is_iso_date_bytes Clippy CI failed: month/day range checks used manual >= && <= instead of RangeInclusive::contains. * fix(#349): per-month day validation in ISO date detection CodeCora #386 r5: is_iso_date_bytes validated month 1-12 and day 1-31 globally, accepting impossible dates like 2026-02-31 or 2026-04-31. Fix: lookup max_day per month (31 for Jan/Mar/May/Jul/Aug/Oct/Dec, 30 for Apr/Jun/Sep/Nov, 29 for Feb to accept leap day). Not a full calendar implementation but eliminates the most obvious false positives. Added tests for per-month invalid dates.
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.
Closes #349. See CHANGELOG entry for full details.
Summary
infer_from_content) on everyremember()Tests
cargo test --workspace(221 passed, 0 failed), clippy clean, fmt clean.