Skip to content

feat(#348): citation & source attribution system - #396

Merged
ajianaz merged 3 commits into
developfrom
feat/348-citations
Jun 19, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/348-citations

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #348. Adds provenance tracking via source + source_type columns (schema v10).

  • Schema migration v9→v10 (ALTER TABLE, backward compatible)
  • Memory struct: source/source_type fields with serde defaults
  • Uteke::set_source() for post-insert updates
  • CLI: --source and --source-type flags on remember
  • Import auto-tags source_type='import'
  • ExportEntry preserves source for round-trip

254 tests pass, clippy clean.

Add provenance tracking to every memory via source + source_type columns.

Core:
  - Schema v9→v10 migration: ALTER TABLE memories ADD COLUMN source TEXT,
    source_type TEXT NOT NULL DEFAULT 'unknown'
  - Memory struct: source: Option<String>, source_type: String fields
  - SourceType variants: user, url, file, import, derived, system, unknown
  - Uteke::set_source(id, source, source_type) for post-insert updates
  - ExportEntry gains optional source field for round-trip preservation
  - Import auto-sets source_type='import', source='import:<filename>'
  - Default for new memories: source=None, source_type='user'

CLI:
  - 'uteke remember --source <URL> --source-type url' flags
  - Server mode forwards source/source_type in POST /remember body

Tests: +1 new (set_source round-trip). Schema version assertions
updated from v9 to v10.

Closes #348
@ajianaz ajianaz added this to the v0.2.1 — DX & Ecosystem milestone Jun 19, 2026
@ajianaz ajianaz added enhancement New feature or request scope:core Core engine work scope:cli CLI and UX type:feature New feature labels Jun 19, 2026
@github-actions

github-actions Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-core/src/import_export.rs:92 — In the import path, source is set with Some(format!("import:{}", entry.source.unwrap_or_default())). This no longer preserves the exported source value that export_memories_json writes into ExportEntry.source. For rows that already had a real provenance value such as a URL or file path, import rewrites it to import:<old source> instead of restoring the original source, so export/import is not actually a round-trip for provenance.
  • crates/uteke-cli/src/commands/remember.rs:193 — The command first stores the memory, prints success, and only afterwards calls uteke.set_source(&stored_id, source, st). If set_source fails, the command returns Failed to set source, but the memory has already been persisted without the requested provenance. This creates a partial-write bug where the user sees the operation fail even though data was inserted.

Review powered by cora-cli · BYOK · MIT

CodeCora #396: set_source used uteke.list(None, 1, 0, ns) to find the
latest memory by namespace. In concurrent contexts, another memory could
be inserted between remember() and the lookup, causing source attribution
to be applied to the wrong memory.

Fix: capture the ID returned by remember() / remember_with_contradiction()
in a hoisted stored_id variable, and pass it directly to set_source().
CodeCora #396 r2: 'let _ = uteke.set_source(...)' silently ignored
database errors, so the CLI could report success even when --source
was never persisted.

Fix: use '?;' to propagate the error as a user-facing failure.
}
}
}

@ajianaz
ajianaz merged commit 05c1a5a into develop Jun 19, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/348-citations branch July 9, 2026 14:28
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat(#348): citation & source attribution system

Add provenance tracking to every memory via source + source_type columns.

Core:
  - Schema v9→v10 migration: ALTER TABLE memories ADD COLUMN source TEXT,
    source_type TEXT NOT NULL DEFAULT 'unknown'
  - Memory struct: source: Option<String>, source_type: String fields
  - SourceType variants: user, url, file, import, derived, system, unknown
  - Uteke::set_source(id, source, source_type) for post-insert updates
  - ExportEntry gains optional source field for round-trip preservation
  - Import auto-sets source_type='import', source='import:<filename>'
  - Default for new memories: source=None, source_type='user'

CLI:
  - 'uteke remember --source <URL> --source-type url' flags
  - Server mode forwards source/source_type in POST /remember body

Tests: +1 new (set_source round-trip). Schema version assertions
updated from v9 to v10.

Closes #348

* fix(#348): use stored ID for set_source, not latest-memory lookup

CodeCora #396: set_source used uteke.list(None, 1, 0, ns) to find the
latest memory by namespace. In concurrent contexts, another memory could
be inserted between remember() and the lookup, causing source attribution
to be applied to the wrong memory.

Fix: capture the ID returned by remember() / remember_with_contradiction()
in a hoisted stored_id variable, and pass it directly to set_source().

* fix(#348): propagate set_source errors instead of ignoring

CodeCora #396 r2: 'let _ = uteke.set_source(...)' silently ignored
database errors, so the CLI could report success even when --source
was never persisted.

Fix: use '?;' to propagate the error as a user-facing failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request scope:cli CLI and UX scope:core Core engine work type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: citation & source attribution system

2 participants