Skip to content

fix(server): honor explicit memory type on plain /remember - #1303

Merged
ajianaz merged 2 commits into
developfrom
fix/1302-plain-remember-type
Oct 3, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/1302-plain-remember-type

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

What

  • POST /remember (plain namespace path) now honors the caller's explicit type: when type is present, the handler routes through remember_typed_detailed (the same core path the room path uses) instead of only copying the value into metadata and falling through to auto-inference.
  • type is validated before any write: unknown values get a loud 400 listing the valid vocabulary (fact, procedure, preference, decision, context, note, insight, reference, event) instead of a silent default to fact.
  • No-type requests keep the legacy auto-inference path; the detect_contradiction path (which already forwarded the type) is unchanged.
  • Contract surface updated to match: registry description for /remember, RememberRequest.type schema doc comment, regenerated docs/api-reference.md.

Fixes #1302

Why

A caller that asks for a specific type must be able to trust what it reads back. On the plain path the requested type never reached the core on the default branch of the handler — every explicit type (e.g. decision, unit-pinned in tole #143's argv contract) was silently stored as memory_type: fact, breaking typed recall queries and the write-side data-model contract. The mismatch was invisible at write time (the write reported success). The room path already behaved correctly, so this also removes a path inconsistency. Loud rejection over silent fallback matches the house pattern already used for author_type validation (#1083).

Testing

  • cargo test -p uteke-server: 55 passed, 0 failed (includes 3 new contract tests in plain_remember_type_tests: explicit decision stored verbatim + metadata back-compat; unknown type → 400 with vocabulary; no-type → auto-inference unchanged).
  • Live E2E against a freshly built binary on a throwaway store (fresh UTEKE_HOME, isolated port — not prod): issue repro case now stores memory_type: decision verbatim; unknown type returns 400 Unknown memory type 'journal'. Valid types: ...; auto-infer control returns decision for 'we decided ...'; room-path control still honors decision. All 4 checks pass.
  • cargo clippy -p uteke-server --all-targets -- -D warnings clean; cargo fmt --all -- --check clean; cargo run -p docgen regenerated (CI docs-fresh gate).

POST /remember never passed the caller's `type` to the core on the default
(non-contradiction) path — it only copied the value into metadata and fell
through to remember_detailed (auto-inference), so every explicit type was
silently stored as fact: a contract break for typed writers (tole #143,
repro in #1302). The handler now validates `type` against the MemoryType
vocabulary before any write — unknown values get a loud 400 listing the
valid types — and routes explicit types through remember_typed_detailed
(parity with the room path), leaving the no-type auto-inference path and
the contradiction path unchanged. Registry description, request-schema
doc comment, and generated docs updated to match the contract.
0.65,
)
.map(|(outcome, _)| outcome)
} else if let Some(t) = req_data.r#type.as_deref() {
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…1302)

Review follow-up: add a CI-safe contract test proving the #1302 type
validation runs before the branch, so detect_contradiction requests are
equally covered against unknown types. Honoring a valid explicit type on
the contradiction arm was verified by live E2E (the arm forwards the type
to remember_with_contradiction, which uses it as-is).
@ajianaz

ajianaz commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator Author

Re: the contradiction-arm finding — investigated and refuted with a live repro; the contradiction arm is not affected.

The arm forwards the caller's type to the core:

  • crates/uteke-server/src/handlers.rs (contradiction arm): remember_with_contradiction(..., req_data.r#type.as_deref(), true, 0.65) — the type is passed as the memory_type argument.
  • crates/uteke-core/src/consolidate.rs:105: memory_type.unwrap_or("fact") — a Some(decision) is used verbatim; only the absent case defaults to fact, which is the documented auto-infer-free default, not silent normalization of an explicit type.

Live verification against a freshly built binary (throwaway store, UTEKE_HOME isolated):

Case Result
detect_contradiction: true + type: decision stored memory_type: decision verbatim (T5 PASS)
detect_contradiction: true + type: journal (invalid) 400 Unknown memory type 'journal'. Valid types: ... (T6 PASS — pre-branch validation covers the arm)

Additionally pushed f007b24 adding a CI contract test (plain_remember_rejects_unknown_type_even_with_contradiction) pinning the validation-before-branch invariant on the contradiction arm. The pre-existing CI-safe contradiction harness (ContradictionApp) runs without an embedder, which is why the valid-type-on-arm assertion lives in the live E2E table above rather than as a unit test.

No code change was needed for this finding; the new test documents the invariant so it can't regress silently.

@ajianaz
ajianaz merged commit 6307727 into develop Oct 3, 2026
15 checks passed
ajianaz added a commit that referenced this pull request Oct 5, 2026
* chore(release): v0.19.1 - version bump, changelog, docs sync

- Workspace + internal dependency versions 0.19.0 -> 0.19.1 (Cargo.lock synced)
- CHANGELOG: [0.19.1] entry - upgrade-path reliability (#1307 via #1308/#1309/#1310),
  plain /remember explicit-type fix (#1303), committed Hermes plugin package (#1301)
- Bundled uteke-memory skill + .agents canonical copy bumped in lockstep
- README/README.id current-version line synced

* chore(release): regenerate core-contract.json for 0.19.1

docgen embeds the workspace version; the API Docs Fresh gate caught
the stale generated artifact.

---------

Co-authored-by: ajianaz <[email protected]>
@ajianaz
ajianaz deleted the fix/1302-plain-remember-type branch October 13, 2026 00:57
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.

remember (plain path): --type silently normalized to fact — contract break for typed writers

2 participants