Skip to content

feat(import): opt-in LLM fact extraction (--extract) - #477

Merged
ajianaz merged 3 commits into
codecoradev:developfrom
gnoviawan:feat/import-llm-extraction
Jun 27, 2026
Merged

ajianaz merged 3 commits into
codecoradev:developfrom
gnoviawan:feat/import-llm-extraction

Conversation

@gnoviawan

Copy link
Copy Markdown
Contributor

What

Adds uteke import --extract: an opt-in flag that distills noisy source text into atomic facts via an OpenAI-compatible chat-completions endpoint, storing one memory per fact instead of importing raw text verbatim.

Why

Raw source material (chat transcripts, long notes, exported dumps) is full of greetings, filler, and boilerplate. Importing it verbatim pollutes recall: a query matches a "thanks bro" line as easily as a real fact. Extraction turns a messy transcript into clean, self-contained statements that actually retrieve well.

Example, a noisy transcript in:

halo bro apa kabar
oke jadi bootcamp batch 1 jadwalnya 4-31 Juli 2026, online, tiap Sabtu Minggu, total 8 sesi.
makasih ya
mentornya ada Aji Anaz spesialis Hermes.

facts out (one memory each):

- Bootcamp batch 1 runs 4-31 July 2026.
- Bootcamp batch 1 is held online every Saturday and Sunday.
- Bootcamp batch 1 has 8 sessions in total.
- Aji Anaz is a Hermes specialist.

Design

  • Opt-in and offline-first. Without --extract, import makes zero network calls and behaves exactly as before. The [extraction] config is inert unless the flag is passed. This is the only feature that ever makes an outbound LLM call.
  • Follows the existing embedding-backend pattern: reqwest blocking client, bearer auth, base_url + endpoint_path, URL validation, mirroring embed/openai.rs. Nothing new conceptually, the project already speaks to OpenAI-compatible endpoints for embeddings.
  • No new dependencies. Uses reqwest + serde_json already in the tree.
  • Config resolution per field: CLI flag (--extract-*) > UTEKE_EXTRACTION_* env > [extraction] config > built-in default. The API key falls back to the embedding / OPENAI_API_KEY credential so an existing setup needs no duplicate key.
  • Works with OpenAI, Ollama (http://localhost:11434/v1), vLLM, or any OpenAI-compatible gateway.

Relates to #46

#46 ("import from external knowledge sources") was partially landed for structured/Obsidian inputs. This completes the goal for the messy free-form case: noisy transcripts and dumps that need distillation, not just parsing. Happy to adjust scope or framing if you'd rather this live behind a feature flag or as a separate subcommand.

Tests

  • 9 new unit tests for the extraction module (response parsing across clean JSON, code-fenced JSON, object arrays, line fallback, dedup; endpoint normalization; empty-key rejection).
  • Full suite green: cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (39 cli + 274 core, 0 failures).
  • Verified end-to-end against a live OpenAI-compatible endpoint: a noisy transcript distilled into clean atomic facts, stored and recalled correctly.

Docs

  • CHANGELOG.md (Unreleased)
  • docs/cli-reference.md (new uteke import section + extraction flags)
  • docs/configuration.md (new [extraction] section + UTEKE_EXTRACTION_* env vars)

Raw source material (chat transcripts, long notes, exported dumps) is
noisy and pollutes recall when imported verbatim. `uteke import --extract`
distills the input into atomic facts via an OpenAI-compatible
chat-completions endpoint and stores one memory per fact.

Opt-in and offline-first: without --extract the importer makes no network
calls and behaves exactly as before. Settings resolve CLI flag >
UTEKE_EXTRACTION_* env > [extraction] config > default, and the API key
falls back to the embedding/OPENAI_API_KEY credential so an existing
OpenAI-compatible setup needs no duplication.

Follows the existing embedding-backend pattern (reqwest blocking, bearer
auth, base_url/endpoint_path, URL validation). No new dependencies.

Relates to codecoradev#46 (Obsidian/CSV import was partially landed; this completes
the "import from external knowledge sources" goal for noisy free-form text).
extract_model: Option<String>,
/// Override the extraction API key (else config / UTEKE_EXTRACTION_API_KEY / OPENAI_API_KEY)
#[arg(long)]
extract_api_key: Option<String>,
pub(crate) struct ExtractOpts<'a> {
pub enabled: bool,
pub model: Option<String>,
pub api_key: Option<String>,
let opts = maintenance::ExtractOpts {
enabled: *extract,
model: extract_model.clone(),
api_key: extract_api_key.clone(),

Ok(Self {
client,
api_key: api_key.to_string(),
…ifiers

CodeCora's static scanner flags struct fields and CLI flags named
`api_key` / `extract_api_key` as "hardcoded password or secret", but
these are identifiers populated at runtime from env/config/CLI input,
never literal secrets. Mirrors the existing `embed/openai.rs` api_key
field. Adds a suppression rule following the same pattern already used
for the SQL-injection false positive.
@ajianaz
ajianaz merged commit 3dd2f2d into codecoradev:develop Jun 27, 2026
7 of 8 checks passed
ajianaz added a commit that referenced this pull request Jun 27, 2026
* feat: configurable embedding endpoint path (#473) (#474)

* feat: configurable embedding endpoint path (#473)

Add endpoint_path config field and UTEKE_EMBEDDING_ENDPOINT_PATH env var
for OpenAI-compatible backends that use non-standard paths (e.g. CodeCora
Embed uses /embed instead of /embeddings).

Changes:
- openai.rs: add endpoint_path field, DEFAULT_ENDPOINT_PATH constant,
  normalize leading slash, update all tests
- config.rs: add endpoint_path to EmbeddingConfig, TOML merge, ENV override
- lib.rs: add endpoint_path to EmbeddingSettings, resolve_with_defaults,
  pass to OpenAiEmbedder::new() in ensure_embedder

Zero breaking change: defaults to /embeddings (OpenAI standard).
Cora review: clean.

* fix: add missing endpoint_path to EmbeddingSettings literals

- main.rs: CLI EmbeddingSettings construction
- lib.rs: 3 test struct literals
- cargo fmt applied

CI failures expected: missing field, format.

* fix: restore original test credential values corrupted by patch

The fuzzy patch tool replaced real credential-like test strings (sk-*-config,
sk-config-only) with literal '***'. Restore original values to fix CI test
failures.

---------

Co-authored-by: ajianaz <[email protected]>

* feat: default max_seq_length 256→2048 for ONNX embedding (#472) (#475)

- engine.rs: MAX_SEQ_LEN constant 256→2048
- config.rs: EmbeddingConfig default 256→2048
- Add UTEKE_MAX_SEQ_LENGTH env var override
- Update 4 test assertions for new default

Aligns with CodeCora Embed Modal API and practical use cases.
Zero breaking change for explicit config users.

Closes #472

Co-authored-by: ajianaz <[email protected]>

* docs: update CHANGELOG and configuration.md for #474 & #475 (#476)

- Add Unreleased section in CHANGELOG for:
  - #473: configurable embedding endpoint_path + ENV override
  - #472: max_seq_length 256→2048 default + ENV override
- Fix docs/configuration.md:
  - max_seq_length default: 256 → 2048
  - Add endpoint_path config field and table row
  - Add UTEKE_EMBEDDING_ENDPOINT_PATH env var
  - Add UTEKE_MAX_SEQ_LENGTH env var

Co-authored-by: ajianaz <[email protected]>

* fix(cora): add ignore.rules for hardcoded secret false positives (#478)

Cora LLM flags struct field declarations named api_key as
'Hardcoded password or secret in variable' — these are identifiers,
not hardcoded values. rules field (soft LLM instruction) is insufficient;
add deterministic ignore filter that matches on issue title.

Also remove the non-effective LLM-only rule that was added
attempting to suppress the same issue.

Co-authored-by: ajianaz <[email protected]>

* feat(import): opt-in LLM fact extraction (--extract) (#477)

* feat(import): add opt-in LLM fact extraction (--extract)

Raw source material (chat transcripts, long notes, exported dumps) is
noisy and pollutes recall when imported verbatim. `uteke import --extract`
distills the input into atomic facts via an OpenAI-compatible
chat-completions endpoint and stores one memory per fact.

Opt-in and offline-first: without --extract the importer makes no network
calls and behaves exactly as before. Settings resolve CLI flag >
UTEKE_EXTRACTION_* env > [extraction] config > default, and the API key
falls back to the embedding/OPENAI_API_KEY credential so an existing
OpenAI-compatible setup needs no duplication.

Follows the existing embedding-backend pattern (reqwest blocking, bearer
auth, base_url/endpoint_path, URL validation). No new dependencies.

Relates to #46 (Obsidian/CSV import was partially landed; this completes
the "import from external knowledge sources" goal for noisy free-form text).

* chore(cora): suppress false-positive secret findings on api_key identifiers

CodeCora's static scanner flags struct fields and CLI flags named
`api_key` / `extract_api_key` as "hardcoded password or secret", but
these are identifiers populated at runtime from env/config/CLI input,
never literal secrets. Mirrors the existing `embed/openai.rs` api_key
field. Adds a suppression rule following the same pattern already used
for the SQL-injection false positive.

---------

Co-authored-by: Anaz S. Aji <[email protected]>

* chore(cora): suppress false-positive command injection on subprocess pattern (#480)

subprocess.run(cmd) in __init__.py.tmpl uses controlled args
(self._bin + hardcoded literals), not dynamic user input.
Add context rule + ignore rule to prevent Cora/CodeCora false positives.

Co-authored-by: ajianaz <[email protected]>

* feat(init): add Hermes memory-provider plugin (--memory-provider) (#479)

Adds `uteke init --agent hermes --memory-provider`, which installs a
MemoryProvider plugin to ~/.hermes/plugins/uteke/ that makes uteke
Hermes's default long-term memory:

- automatic recall prefetched + injected into the prompt each turn
- opt-in LLM fact extraction on session end / pre-compress
- direct subprocess to the uteke binary (no uteke-serve daemon)
- circuit breaker so a bad endpoint never blocks the agent

Plugin templates live in extensions/hermes-memory-provider/ and are
embedded via include_str! so the generated plugin always matches the
binary. Complements the existing uteke-tool plugin (manual HTTP actions)
rather than replacing it.

Docs: docs/integrations/hermes.md documents both modes (tool vs
memory-provider). Zero new dependencies.

Co-authored-by: Anaz S. Aji <[email protected]>

* docs: update CHANGELOG, roadmap, and getting-started for v0.5.0 (#481)

- CHANGELOG: add store() accessor (#466) and rusqlite 0.40 upgrade
- Roadmap: add v0.4.x and v0.5.0 entries (previously stuck at v0.3.0)
- Getting started: mention --extract flag and Hermes memory-provider

Co-authored-by: ajianaz <[email protected]>

* docs: add marketing assets + fix install URL + test count (#483)

* docs: add marketing assets + fix install URL + test count

README updates:
- Add banner image (docs/assets/uteke-banner.png)
- Add architecture diagram (docs/assets/uteke-architecture.png)
  with HNSW + FTS5 + RRF pipeline description
- Add comparison infographic (docs/assets/uteke-comparison.png)
- Fix install URL: raw.githubusercontent → codecora.dev/install
  (CF Worker redirect, cleaner)
- Fix test count: 295 → 312 unit tests (verified)

README.id.md: same install URL + test count fixes.

* docs: update test count 312 → 327

---------

Co-authored-by: ajianaz <[email protected]>

* chore: bump status badge v0.4.3 → v0.5.0 (#484)

Co-authored-by: ajianaz <[email protected]>

* release: v0.5.0 (#485)

* release: bump version to v0.5.0

Features:
- Hermes memory-provider plugin (--memory-provider)
- LLM-backed fact extraction on import (--extract)
- Configurable embedding endpoint path
- Default max_seq_length 256 → 2048
- Public store() accessor
- rusqlite 0.31 → 0.40

* release: bump inter-crate dependency versions to 0.5.0

---------

Co-authored-by: ajianaz <[email protected]>

---------

Co-authored-by: ajianaz <[email protected]>
Co-authored-by: Ginanjar Noviawan <[email protected]>
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat(import): add opt-in LLM fact extraction (--extract)

Raw source material (chat transcripts, long notes, exported dumps) is
noisy and pollutes recall when imported verbatim. `uteke import --extract`
distills the input into atomic facts via an OpenAI-compatible
chat-completions endpoint and stores one memory per fact.

Opt-in and offline-first: without --extract the importer makes no network
calls and behaves exactly as before. Settings resolve CLI flag >
UTEKE_EXTRACTION_* env > [extraction] config > default, and the API key
falls back to the embedding/OPENAI_API_KEY credential so an existing
OpenAI-compatible setup needs no duplication.

Follows the existing embedding-backend pattern (reqwest blocking, bearer
auth, base_url/endpoint_path, URL validation). No new dependencies.

Relates to #46 (Obsidian/CSV import was partially landed; this completes
the "import from external knowledge sources" goal for noisy free-form text).

* chore(cora): suppress false-positive secret findings on api_key identifiers

CodeCora's static scanner flags struct fields and CLI flags named
`api_key` / `extract_api_key` as "hardcoded password or secret", but
these are identifiers populated at runtime from env/config/CLI input,
never literal secrets. Mirrors the existing `embed/openai.rs` api_key
field. Adds a suppression rule following the same pattern already used
for the SQL-injection false positive.

---------

Co-authored-by: Anaz S. Aji <[email protected]>
ajianaz added a commit that referenced this pull request Aug 13, 2026
* feat: configurable embedding endpoint path (#473) (#474)

* feat: configurable embedding endpoint path (#473)

Add endpoint_path config field and UTEKE_EMBEDDING_ENDPOINT_PATH env var
for OpenAI-compatible backends that use non-standard paths (e.g. CodeCora
Embed uses /embed instead of /embeddings).

Changes:
- openai.rs: add endpoint_path field, DEFAULT_ENDPOINT_PATH constant,
  normalize leading slash, update all tests
- config.rs: add endpoint_path to EmbeddingConfig, TOML merge, ENV override
- lib.rs: add endpoint_path to EmbeddingSettings, resolve_with_defaults,
  pass to OpenAiEmbedder::new() in ensure_embedder

Zero breaking change: defaults to /embeddings (OpenAI standard).
Cora review: clean.

* fix: add missing endpoint_path to EmbeddingSettings literals

- main.rs: CLI EmbeddingSettings construction
- lib.rs: 3 test struct literals
- cargo fmt applied

CI failures expected: missing field, format.

* fix: restore original test credential values corrupted by patch

The fuzzy patch tool replaced real credential-like test strings (sk-*-config,
sk-config-only) with literal '***'. Restore original values to fix CI test
failures.

---------

Co-authored-by: ajianaz <[email protected]>

* feat: default max_seq_length 256→2048 for ONNX embedding (#472) (#475)

- engine.rs: MAX_SEQ_LEN constant 256→2048
- config.rs: EmbeddingConfig default 256→2048
- Add UTEKE_MAX_SEQ_LENGTH env var override
- Update 4 test assertions for new default

Aligns with CodeCora Embed Modal API and practical use cases.
Zero breaking change for explicit config users.

Closes #472

Co-authored-by: ajianaz <[email protected]>

* docs: update CHANGELOG and configuration.md for #474 & #475 (#476)

- Add Unreleased section in CHANGELOG for:
  - #473: configurable embedding endpoint_path + ENV override
  - #472: max_seq_length 256→2048 default + ENV override
- Fix docs/configuration.md:
  - max_seq_length default: 256 → 2048
  - Add endpoint_path config field and table row
  - Add UTEKE_EMBEDDING_ENDPOINT_PATH env var
  - Add UTEKE_MAX_SEQ_LENGTH env var

Co-authored-by: ajianaz <[email protected]>

* fix(cora): add ignore.rules for hardcoded secret false positives (#478)

Cora LLM flags struct field declarations named api_key as
'Hardcoded password or secret in variable' — these are identifiers,
not hardcoded values. rules field (soft LLM instruction) is insufficient;
add deterministic ignore filter that matches on issue title.

Also remove the non-effective LLM-only rule that was added
attempting to suppress the same issue.

Co-authored-by: ajianaz <[email protected]>

* feat(import): opt-in LLM fact extraction (--extract) (#477)

* feat(import): add opt-in LLM fact extraction (--extract)

Raw source material (chat transcripts, long notes, exported dumps) is
noisy and pollutes recall when imported verbatim. `uteke import --extract`
distills the input into atomic facts via an OpenAI-compatible
chat-completions endpoint and stores one memory per fact.

Opt-in and offline-first: without --extract the importer makes no network
calls and behaves exactly as before. Settings resolve CLI flag >
UTEKE_EXTRACTION_* env > [extraction] config > default, and the API key
falls back to the embedding/OPENAI_API_KEY credential so an existing
OpenAI-compatible setup needs no duplication.

Follows the existing embedding-backend pattern (reqwest blocking, bearer
auth, base_url/endpoint_path, URL validation). No new dependencies.

Relates to #46 (Obsidian/CSV import was partially landed; this completes
the "import from external knowledge sources" goal for noisy free-form text).

* chore(cora): suppress false-positive secret findings on api_key identifiers

CodeCora's static scanner flags struct fields and CLI flags named
`api_key` / `extract_api_key` as "hardcoded password or secret", but
these are identifiers populated at runtime from env/config/CLI input,
never literal secrets. Mirrors the existing `embed/openai.rs` api_key
field. Adds a suppression rule following the same pattern already used
for the SQL-injection false positive.

---------

Co-authored-by: Anaz S. Aji <[email protected]>

* chore(cora): suppress false-positive command injection on subprocess pattern (#480)

subprocess.run(cmd) in __init__.py.tmpl uses controlled args
(self._bin + hardcoded literals), not dynamic user input.
Add context rule + ignore rule to prevent Cora/CodeCora false positives.

Co-authored-by: ajianaz <[email protected]>

* feat(init): add Hermes memory-provider plugin (--memory-provider) (#479)

Adds `uteke init --agent hermes --memory-provider`, which installs a
MemoryProvider plugin to ~/.hermes/plugins/uteke/ that makes uteke
Hermes's default long-term memory:

- automatic recall prefetched + injected into the prompt each turn
- opt-in LLM fact extraction on session end / pre-compress
- direct subprocess to the uteke binary (no uteke-serve daemon)
- circuit breaker so a bad endpoint never blocks the agent

Plugin templates live in extensions/hermes-memory-provider/ and are
embedded via include_str! so the generated plugin always matches the
binary. Complements the existing uteke-tool plugin (manual HTTP actions)
rather than replacing it.

Docs: docs/integrations/hermes.md documents both modes (tool vs
memory-provider). Zero new dependencies.

Co-authored-by: Anaz S. Aji <[email protected]>

* docs: update CHANGELOG, roadmap, and getting-started for v0.5.0 (#481)

- CHANGELOG: add store() accessor (#466) and rusqlite 0.40 upgrade
- Roadmap: add v0.4.x and v0.5.0 entries (previously stuck at v0.3.0)
- Getting started: mention --extract flag and Hermes memory-provider

Co-authored-by: ajianaz <[email protected]>

* docs: add marketing assets + fix install URL + test count (#483)

* docs: add marketing assets + fix install URL + test count

README updates:
- Add banner image (docs/assets/uteke-banner.png)
- Add architecture diagram (docs/assets/uteke-architecture.png)
  with HNSW + FTS5 + RRF pipeline description
- Add comparison infographic (docs/assets/uteke-comparison.png)
- Fix install URL: raw.githubusercontent → codecora.dev/install
  (CF Worker redirect, cleaner)
- Fix test count: 295 → 312 unit tests (verified)

README.id.md: same install URL + test count fixes.

* docs: update test count 312 → 327

---------

Co-authored-by: ajianaz <[email protected]>

* chore: bump status badge v0.4.3 → v0.5.0 (#484)

Co-authored-by: ajianaz <[email protected]>

* release: v0.5.0 (#485)

* release: bump version to v0.5.0

Features:
- Hermes memory-provider plugin (--memory-provider)
- LLM-backed fact extraction on import (--extract)
- Configurable embedding endpoint path
- Default max_seq_length 256 → 2048
- Public store() accessor
- rusqlite 0.31 → 0.40

* release: bump inter-crate dependency versions to 0.5.0

---------

Co-authored-by: ajianaz <[email protected]>

---------

Co-authored-by: ajianaz <[email protected]>
Co-authored-by: Ginanjar Noviawan <[email protected]>
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.

3 participants