Skip to content

feat(#293): structured memory — JSON content support (schema v6) - #331

Merged
ajianaz merged 1 commit into
developfrom
feat/v020-293-structured-memory
Jun 14, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/v020-293-structured-memory

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #293

Changes

Schema v6

  • New column: content_type TEXT NOT NULL DEFAULT 'text'
  • Migration v5→v6: ALTER TABLE ADD COLUMN

JSON content support

  • Auto-detect: remember() detects JSON input (starts with { or [), sets content_type='json'
  • Flatten for embedding: {"name":"Alice","role":"CTO"} → "name: Alice, role: CTO" for semantic search
  • remember_json(): validated wrapper that ensures valid JSON before storing

CLI flags

  • --where key=value: filter JSON memories by field (supports string, number, bool, null)
  • --content-format json: pretty-print JSON content in output

Backward compatible

  • All existing text memories get content_type='text'
  • No breaking changes to existing API

Tests

  • cargo test --workspace ✅ (146 passed, 5 ignored for ONNX)
  • 12 new tests (JSON detection, flattening, storage, migration)
  • cargo clippy --workspace -- -D warnings ✅
  • cargo fmt --all ✅

- Auto-detect JSON content in remember() — sets content_type='json'
- Schema v6: content_type TEXT NOT NULL DEFAULT 'text'
- Flatten JSON for embedding: {"name":"Alice"} → "name: Alice"
- CLI: --where key=value filters JSON memories by field
- CLI: --content-format json pretty-prints JSON in output
- remember_json() validated wrapper method
- Backward compatible: existing text memories get content_type='text'
- 12 new tests (JSON detection, flattening, storage, migration)

Closes #293
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-core/src/memory/schema.rs:159 — The migration loop now matches 6 => self.migrate_v5_to_v6()?, but the helper is explicitly a v5→v6 migration. In a standard versioned migration flow, a database currently at version 5 must execute this step before being marked as version 6. With the current match arm, a store opened at schema version 5 will skip migrate_v5_to_v6() entirely, because only version 6 triggers it. That leaves existing v5 databases without the content_type column while the code now issues queries that select/insert content_type.
  • crates/uteke-cli/src/commands/recall.rs:177 — The new content_format flag is only applied inside the if cli.json branch. In the non-JSON branch, the code still unconditionally calls output::print_recall_human(&filtered);, so --content-format json has no effect for normal terminal output even though the CLI help describes it as a general content display format. This creates a visible behavior mismatch for users.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 612dd1e into develop Jun 14, 2026
9 checks passed
@ajianaz
ajianaz deleted the feat/v020-293-structured-memory branch June 14, 2026 05:01
ajianaz added a commit that referenced this pull request Aug 13, 2026
- Auto-detect JSON content in remember() — sets content_type='json'
- Schema v6: content_type TEXT NOT NULL DEFAULT 'text'
- Flatten JSON for embedding: {"name":"Alice"} → "name: Alice"
- CLI: --where key=value filters JSON memories by field
- CLI: --content-format json pretty-prints JSON in output
- remember_json() validated wrapper method
- Backward compatible: existing text memories get content_type='text'
- 12 new tests (JSON detection, flattening, storage, migration)

Closes #293
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📦 Feature: Structured memory — nested JSON content instead of flat text

1 participant