Skip to content

refactor(core): typed remember request shared by HTTP, MCP and CLI (#1343) - #1425

Merged
ajianaz merged 2 commits into
developfrom
refactor/typed-remember-1343
Oct 12, 2026
Merged

ajianaz merged 2 commits into
developfrom
refactor/typed-remember-1343

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

What

Second slice of #1343 (after recall, #1423): a typed remember request in uteke-core (remember_request.rs: RememberInput, RememberPolicy, RememberRequest, metadata_from_cli_flags) shared by:

  • HTTP POST /remember (RememberRequest::to_input / decode in uteke-server/src/types.rs; the handler no longer validates or builds metadata inline),
  • MCP uteke_remember (decode_remember_args),
  • the CLI-via-server body (RememberInput::to_http_body).

Extraction only. Room remember is untouched. docs/core-contract.json and docs/api-reference.md are byte-identical after cargo run -p docgen.

Why

Each surface parsed, defaulted and validated its own remember arguments. Where they disagree today, the disagreement is now an explicit RememberPolicy value instead of scattered code. No disagreement is resolved here.

Surface disagreements (owner decisions, all preserved as they are)

  1. type omitted: HTTP leaves it to auto-inference; MCP stores fact with no inference; CLI omits it when empty (server then infers).
  2. Unknown type: HTTP 400 at decode (bare message); MCP gets the core error as Failed: Validation error: ....
  3. Content/tags validation: HTTP validates at decode (400, Validation error: ...); MCP defers to the core write (blank content, over-long content and bad tags surface as Failed: ...).
  4. Order of HTTP checks: content/tags, then author_type, then type; MCP has no author_type.
  5. type mirrored into metadata as "type": HTTP yes; MCP no; CLI no.
  6. Metadata: HTTP merges valid_from/valid_until/entity/category and the metadata object (object wins); MCP never sends metadata; CLI folds entity/category/--meta k:v into metadata (pairs without : are silently dropped).
  7. Fields only on HTTP: valid_from, valid_until, detect_contradiction, entity, category, metadata, source, source_type, author_type. Not accepted by MCP.
  8. room / author: MCP-only (routes to the room write). The CLI sends them to /remember, which rejects them as unknown keys (deny_unknown_fields, HTTP v2 write payloads silently ignore wrong keys (e.g. ns instead of namespace) #1251) -> 400. Same for the CLI's --timestamp. Existing bug, encoded as-is; please decide whether the CLI should stop sending them or HTTP should accept them.
  9. Tags wire shape: HTTP rejects non-string tags (400); MCP silently drops them.
  10. Namespace omitted: both leave it to the core default; CLI always sends "default".

Testing

  • New unit tests in remember_request.rs (policy behaviour, error text and order, metadata merge, CLI body encoding), decode_remember_args tests in uteke-mcp, and remember_request_cross_surface_tests in uteke-server (same logical request through the HTTP and MCP decoders gives equal typed fields where they agree; every disagreement above is pinned).
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, cargo test -p uteke-core --no-default-features --features "onnx,vecq" --lib all pass; docgen leaves docs/ clean.
  • Differential check: uteke-serve built from origin/develop and from this branch, each on a fresh UTEKE_HOME with an OpenAI-compatible fake embedder (768 dims), 58 /remember cases (minimal, tags, namespace, all 9 types, bad/empty/mixed-case type, empty/blank/200k content, 500 tags, long/empty/non-string tags, metadata object/string/null/override, entity/category, valid_from/until, source, author_type valid/invalid, detect_contradiction incl. bad type, unknown keys ns/room/author/timestamp, missing/null/non-string content, null/empty namespace, unicode, bad JSON, empty body, array body, text/plain content type) plus a readback of stored memories (POST /list, default and work namespaces, ids/timestamps stripped). Status codes and normalised bodies: 58 cases, 0 differences.
  • Not covered: MCP uteke_remember end to end against a store (only its decoder is tested; the write call is unchanged) and CLI via server against a live server (body encoding is unit-tested and decoded by the HTTP side).

Refs #1343

🤖 Generated with Claude Code

…1343)

Extract /remember, uteke_remember and the CLI-via-server body into
uteke-core's remember_request module (RememberInput, RememberPolicy,
RememberRequest), following the recall slice. No wire behaviour change.

Refs #1343

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…ember-1343

# Conflicts:
#	crates/uteke-server/src/types.rs
@ajianaz
ajianaz merged commit af3da99 into develop Oct 12, 2026
15 checks passed
@ajianaz
ajianaz deleted the refactor/typed-remember-1343 branch October 12, 2026 06:22
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.

1 participant