Skip to content

feat(core): rejected-value tombstone, so a value forgotten as wrong cannot be written again - #1627

Merged
ajianaz merged 2 commits into
developfrom
feat/rejected-value-tombstone
Nov 1, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/rejected-value-tombstone

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

What

A rejected-value tombstone (schema v23): a value forgotten as wrong cannot be written again.

  • Creating one. uteke forget <id> --reason wrong (or wrong: <note>), supersede --reason wrong, DELETE /forget?id=..&reason=.. (LAB) and the MCP uteke_forget reason record the SHA-256 of the normalised text in rejected_values. Normalisation is NFKC, lowercase, whitespace collapsed, and invisible characters removed (zero-width, BOM, soft hyphen, variation selectors, tag characters). An ordinary forget records nothing.
  • Checking. The check runs in commit_memory, the write tail of remember, room remember, import and consolidation, and also early in remember (before the embedding work), in update, and in import --full.
    • A hit is Error::RejectedValue. HTTP answers 409 {"error": "rejected_value", "reason": ...} (never the value), and MCP returns a rejected_value: tool error.
    • import skips and counts the row (rejected_tombstone). import --full also skips its room links, edges and timeline events.
  • Restoring. uteke tombstone list and uteke tombstone remove <hash-prefix|memory-id>. uteke promote removes the tombstone of the text it restores.
  • Lifetime. Tombstones survive prune and travel with export --full / import --full.
  • Docs. Design note docs/plans/2026-11-01-rejected-value-tombstone-1597.md, CLI reference ("Rejecting a wrong value", uteke tombstone), architecture schema history, both skill copies, CHANGELOG.

Why

Closes #1597 (Atlas findings 1 and 9, tracked in #1601). Forgetting was not durable:

The owner decided on 2026-11-01 (recorded on the issue):

  • a tombstone only on reason wrong;
  • refuse with a typed error;
  • import skips and counts the row;
  • exact match after normalisation, with no vector similarity.

CORE contract. POST /remember, /room/remember, /import and /consolidate/pair gain the 409, and /import gains rejected_tombstone when it is non-zero. A store with no wrong forget behaves exactly as before. Contract issue: uteke-cloud#437 (Gitea), opened before this PR; its answer (whether Cloud adopts the semantics) does not block OSS, but the release pre-flight should read it.

Testing

  • cargo test --workspace: 1397 passed, 0 failed. cargo clippy --workspace --all-targets -D warnings and cargo fmt --check clean. cargo run -p docgen leaves the generated docs unchanged.

  • Core (tombstone.rs).

    • Normalisation: case, whitespace, zero-width, full-width digits, BOM, NBSP, variation selector and tag character; and the wrong reason parser.
    • Refusal on remember, room remember and update.
    • An ordinary forget records nothing, and supersede wrong records inside its transaction.
    • The tombstone survives a real prune of the row.
    • Removal by promote (also when a duplicate recorded the tombstone) and by hash prefix.
    • Import skips and counts.
    • --full round trip, including a rejected row that has a room link, an edge and events (no foreign-key abort, no orphans).
  • Server.

    • reason=wrong%3A+... on DELETE /forget, then 409 on /remember (case and spacing changed, value not echoed), PUT /memory and /room/remember.
    • /import count; an ordinary forget and an import with no tombstone leave the responses unchanged.
  • Forget request and MCP. percent_decode on the reason only (ids keep the old rule; invalid and trailing escapes, multibyte). MCP: uteke_forget with a reason, then a rejected_value: error.

  • Manual (debug build). remember, forget --reason "wrong: it is 8767", then remember with different case is refused with the reason; tombstone list shows it, tombstone remove <id>, and remember works again.

  • Review. Local cora review found an unchecked hash slice in tombstone list (fixed). A separate reviewer agent found three bugs, all fixed with tests:

    • import --full aborted on a rejected row with dependents;
    • the supersede tombstone was written outside its transaction;
    • promote missed a tombstone recorded by a duplicate.

    Cora is clean after the fixes.

…annot be written again

A forget or supersede with the reason 'wrong' (or 'wrong: <note>') records
the sha256 of the normalised text (NFKC, case folding, whitespace collapsed,
invisible characters removed) in the new rejected_values table (schema v23).
commit_memory, the write tail of remember, room remember, import and
consolidation, refuses that text with Error::RejectedValue, as do update and
import --full; import skips and counts the row (rejected_tombstone).

HTTP answers 409 rejected_value with the recorded reason, never the value;
MCP a rejected_value: tool error. DELETE /forget and uteke_forget take a
reason. Tombstones survive prune, travel with export/import --full, and are
managed with uteke tombstone list|remove; promote removes the tombstone of
the memory it restores. Ordinary forgets record nothing.

Owner decisions and design: docs/plans/2026-11-01-rejected-value-tombstone-1597.md.
CORE contract issue: uteke-cloud#437.

Closes #1597
- import --full skips the room links, edges and timeline events of a row it
  rejects (the junctions have a foreign key on memories, so the whole import
  used to roll back); a graph node keeps its entity without the memory link.
  A database error during the check is no longer counted as a rejection.
- supersede records the tombstone inside its transaction.
- promote removes the tombstone by the restored text, so one recorded by a
  duplicate memory goes too.
- normalise also drops variation selectors and tag characters.
- restored tombstones must carry a SHA-256; tombstone list slices safely.
Tests for each, plus percent_decode and 409 on PUT /memory and
/room/remember.
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit eb6b681 into develop Nov 1, 2026
15 checks passed
@ajianaz
ajianaz deleted the feat/rejected-value-tombstone branch November 1, 2026 11:55
ajianaz added a commit that referenced this pull request Nov 8, 2026
… (#1690)

* fix(import): import a live row whose content was only forgotten (#1689)

A plain forget soft-deletes (deprecated=1) and is recoverable; only
forget --reason writes rejected_values and rejects (#1627, untouched).
#1633/#1636 made import skip any row whose content matched a soft-deleted
one, so re-importing after a forget (restored backup, the LongMemEval
harness forgetting after each question) dropped the rows.

An anonymous live row over a forgotten copy now inserts as a new live row.
Still skipped: a row carrying the forgotten memory's own id, a row marked
deprecated in the file, and exact duplicates of live rows.

* bench: LongMemEval-S 500Q receipts for the import tombstone-skip fix (#1689)

Full 500-question run on Modal (10 shards, strategy default, binary built
from 32a5cf3, ORT lib from v0.23.0), app ap-HNerZq2X0lO17WJ0CytCfb, 28129s
wall clock. any@5 0.9820, strict@5 0.8800, misses@50 0, strict@5 flips
-0/+0 vs the committed v0.20.0 baseline - all audit gates of #1689 pass.

---------

Co-authored-by: ajianaz <[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.

design(core): rejected-value tombstone, so a forgotten wrong value cannot be written again

1 participant