Repository navigation
feat(core): add author_type (human|agent) to memory records - #1084
Merged
Merged
Conversation
Schema v16: ALTER TABLE with DEFAULT 'agent' + index, backfills existing rows. Memory struct + validate_author_type. set_author_type() on Store and Uteke facade (invalid values -> Validation error). Server /remember accepts optional author_type, 400 on invalid. All memory SELECTs now include source/source_type/author_type (previously dropped on read). Version asserts in tests use CURRENT_SCHEMA_VERSION instead of hardcoded numbers.
| error!("Failed to set source for {id}: {e}"); | ||
| } | ||
| } | ||
| // Set author type after storage (#1083). Validate before |
Collaborator
Author
There was a problem hiding this comment.
Dismissed as false positive after manual verification in 850507c: the first finding (persist-before-validate) was real and fixed — validation now runs before any insert. This follow-up claim is incorrect: set_author_type sits in the shared Ok(id) arm of match result, which both the remember and remember_with_contradiction paths reach (both map to id before the match). Verified against handlers.rs:224-227.
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-code · BYOK · MIT |
…1083) Cora review finding: /remember inserted the memory before validating author_type, so an invalid value left a persisted record while the client got a 400 (partial-write). Validation now runs before any insert. Regenerates docs/api-reference.md (API Docs Fresh check).
This was referenced Aug 26, 2026
ajianaz
added a commit
that referenced
this pull request
Aug 26, 2026
…1106) (#1108) POST /remember and uteke remember --json stored author_type correctly but never echoed it, so clients couldn't confirm what was recorded. The CLI didn't even expose the field (#1084 shipped HTTP-only). - HTTP /remember response now includes author_type (default mirrors the schema default 'agent', #1083) - CLI: new --author-type flag (human|agent), validated BEFORE any write so invalid values fail loudly without leaving a stored row; echoed in --json on both remember paths (contradiction + plain) - run_via_server path forwards the flag in the HTTP body Verified empirically in isolated stores: explicit human -> echo human + DB human; default -> echo agent + DB agent; invalid 'robot' -> loud error / HTTP 400, zero rows written. Closes #1106 Co-authored-by: ajianaz <[email protected]>
What
Add an
author_typediscriminator (human|agent) to memory records, defaulting toagent, filterable and sync-safe.Why
Corin's agent-managed positioning and uteke-mobile quick-capture (human input) need to distinguish who authored a memory. Existing
authorcolumns onroom_memories/documentsare free-text names, not a type discriminator. Closes #1083.Changes
ALTER TABLE memories ADD COLUMN author_type TEXT NOT NULL DEFAULT 'agent'+idx_memories_author_type; existing rows backfill toagentMemory.author_type(serde default/skip),validate_author_type()(invalid → Validation error),Store::set_author_type()+Uteke::set_author_type()facade (nonexistent id → false)/rememberaccepts optionalauthor_type; validated before write → 400 on invalidget_by_id/get_by_idsand all full-row SELECTs droppedsource/source_typeon read (mapper silently defaulted) — all now select the full column setCURRENT_SCHEMA_VERSIONinstead of hardcoded numbersTesting
cargo test -p uteke-core --lib: 493 passed, 0 failed, 25 ignoredcargo test -p uteke-server: 6 passedcargo clippy -p uteke-core -p uteke-server uteke-mcp --all-features: cleanagent; sethuman/agent+ invalid rejected + missing id → false; simulated v15 DB migrates to v16 with legacy row backfilled