Skip to content

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

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

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

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

What

Second slice of #1343 (after recall, #1423): a typed forget request in uteke-core (crates/uteke-core/src/forget_request.rs: ForgetInput, ForgetPolicy, ForgetRequest, resolve_memory_id), used by:

Extraction only. No route, shape, default, id-resolution or error-text change. docs/core-contract.json and docs/api-reference.md are byte-identical after cargo run -p docgen.

Why

Each surface parsed, validated and resolved forget arguments on its own, so the same destructive operation was decided in three places. Where the surfaces disagree today the disagreement is now an explicit ForgetPolicy value instead of an accident. Nothing became more permissive: every check that existed stays on the surface that had it.

Surface disagreements (owner decisions, NOT unified here)

aspect HTTP DELETE /forget MCP uteke_forget CLI via server
id charset check none: % and _ reach the LIKE scan (so id=% is "ambiguous", or resolves when exactly one memory exists, and %<fragment> resolves by substring) hex digits and - only (#1328) sends what the user typed
full UUID kept verbatim (uppercase, no-hyphen, urn:/braced forms then 404 at the existence check) normalised to hyphenated lowercase verbatim, server decides
unknown prefix 404 Memory not found: {id} error No memory matches id prefix '{id}' server's 404
full UUID not stored 404 (existence check, #762) core is called directly, no existence check server's 404
ambiguous prefix 400 with core text error, same core text server's 400
tag target ?tag= plus optional namespace; no namespace means the DEFAULT namespace, not all not offered --tag, namespace default unless --namespace
both id and tag id wins n/a id wins
neither 400 Provide ?id= or ?tag= parameter Missing 'id' local usage error
query values NOT percent-decoded (a tag a%20b is literal) n/a CLI percent-encodes, so a tag containing % or spaces never matches what was typed (pre-existing)
read-only token blocked, 403 (#409) NOT gated (the gate exists only on HTTP; not extended here) server decides
confirmation prompt none none local uteke forget prompts, via-server path ignores --confirm and does not prompt

The read-only gate is a method/path check in the HTTP pipeline, so it cannot be a decode rule; it is recorded as ForgetPolicy::read_only_token_may_forget (HTTP false, MCP true) and pinned by tests.

Testing

  • 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: pass.
  • cargo run -p docgen: docs/ unchanged.
  • New tests (fail without the change: the module and exports do not exist before):
    • core forget_request: query parsing quirks, id-wins-over-tag, per-policy resolution (verbatim vs normalised, existence check, texts), charset check MCP-only, ambiguous text equal on both policies, to_http_path.
    • server forget_route_tests (in-process route()): full id, short prefix, 404/400 texts, id-over-tag, tag namespace semantics, read-only token 403 with nothing deleted, HTTP vs MCP resolve to the same memory.
    • MCP: error texts for missing, non-string, invalid, unknown ids; uppercase UUID normalisation; extra tag/namespace keys never widen the target.
    • CLI: /forget?... URL equals the old format incl. encoding.
  • Differential check: uteke-serve built from origin/develop and from this branch, fresh UTEKE_HOME each, auth token and read-only token, OpenAI-compatible fake embedder (768 dims), same 8 seeded memories (3 namespaces, 6 tags). 69 cases (no token, bad token, read-only token, wrong methods, missing/empty/bad-typed params, wildcards, unknown/ambiguous/absent/uppercase/simple/urn/braced ids, duplicates, id vs tag, tag with/without/wrong namespace, repeat forgets, path variants, final state of all namespaces) compared on status and id-normalised body: 69 compared, 0 differences. MCP and CLI were not differentially tested end to end (covered by the unit tests above).

Refs #1343

🤖 Generated with Claude Code

Add uteke-core ForgetInput / ForgetPolicy / ForgetRequest and
resolve_memory_id: DELETE /forget query parsing, id-or-tag decoding, id
resolution (full UUID, prefix, ambiguity), the existence check and the
CLI-via-server URL now live in one module. HTTP /forget, MCP uteke_forget
(and the shared MCP resolve_id) and the CLI-via-server forget use it.
Extraction only: where the surfaces disagree, each surface's current
behaviour is a policy value; the read-only gate stays HTTP-only.

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

…get-1343

# Conflicts:
#	crates/uteke-core/src/lib.rs
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