Skip to content

feat(session-edit): correctness review mark on session_edits#369

Open
you06 wants to merge 1 commit into
mem9-ai:mainfrom
you06:feat/session-correctness-mark
Open

feat(session-edit): correctness review mark on session_edits#369
you06 wants to merge 1 commit into
mem9-ai:mainfrom
you06:feat/session-correctness-mark

Conversation

@you06

@you06 you06 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Add a human review mark (correct | incorrect) to raw session turns,
stored in session_edits. No row exists until a turn is edited or
marked; editing a turn's content auto-marks it correct.

Endpoints (v1alpha2)

  • PUT /session-messages/{id}/mark — set mark {correctness} (400 on invalid value)
  • DELETE /session-messages/{id}/mark — clear mark (removes the row if it had no content edit)

Behavior

  • New session_edits.correctness column (correct|incorrect, NULL = unmarked); auto-migrated onto existing tenants via ensureColumn.
  • A row can be content-edited, marked, or both. edited_content = '' = no content override (mark-only row); real edits are always non-empty.
  • Content edit (PUT /session-messages/{id}) auto-sets correct; tag-only change leaves the mark unchanged.
  • Mark write never touches the content/tag overlay; unmark deletes mark-only rows, keeps content-edited rows.

Reads (surface correctness when set)

  • Session Search (/memories?memory_type=session): in metadata, plus content overlay when edited.
  • Raw browse (/session-messages): correctness field; content stays original.
  • GET /session-messages/{id}/edit: full row.

Tradeoff / scope

  • Never touches sessions / memories, embeddings, or FTS; recall is unaffected.

Tests

  • Mark set/update + version, invalid 400, 404, mark-only surfaces correctness without changing content, content-edit auto-correct, unmark deletes mark-only / preserves content edit, raw browse surfaces correctness. Full suite + vet pass.

Adds a human review mark (correct | incorrect) to the raw-session edit
overlay, stored in session_edits. Default-unmarked turns keep no row;
editing a turn's content auto-marks it correct.

Schema:
- New column correctness VARCHAR(20) NULL (correct|incorrect; NULL =
  unmarked), added to the create DDL and migrated onto existing tenants
  via a new ensureColumn ALTER on connect.
- edited_content keeps NOT NULL; '' is the "no content override"
  sentinel so a row can be mark-only (real edits always have non-empty
  content). A row exists when it has a content/tag edit OR a mark.

API (v1alpha2, X-API-Key + X-Mnemo-Agent-Id):
- PUT /session-messages/{id}/mark {correctness} — set the mark (400 on
  an invalid value); preserves any existing content/tag overlay.
- DELETE /session-messages/{id}/mark — clear the mark; if the row had no
  content override it is removed entirely (back to no record).
- PUT /session-messages/{id} (content edit) now auto-sets correct; a
  tag-only change does not alter the mark.

Reads surface correctness wherever the turn is read, when set:
- Session Search (/memories?memory_type=session) merges correctness into
  metadata (plus the content overlay when the turn was edited);
- raw browse (/session-messages) adds a correctness field but always
  shows original content;
- GET /session-messages/{id}/edit returns the full row.

Repo gains MarkSessionEdit (mark-only upsert preserving content) and
ClearSessionEditMark (clear mark, delete mark-only rows); the overlay
apply logic now gates content override on EditedContentSet so mark-only
rows leave content/tags untouched while still surfacing the mark.

Tests: mark set/update + version, invalid value 400, not-found 404,
mark-only surfaces correctness without changing content, content edit
auto-correct, unmark deletes mark-only row, unmark preserves content
edit, raw browse surfaces correctness with original content. Full suite
+ vet + gofmt green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8bf9fe6e7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +78 to +79
ON DUPLICATE KEY UPDATE
correctness = VALUES(correctness),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve marks when reverting only content edits

When a turn has both a content overlay and a correctness mark, this upsert stores the mark in the same session_edits row that DELETE /session-messages/{id}/edit still removes via DeleteSessionOverlayDeleteSessionEdit. In that scenario, reverting only the edited content also drops the review mark, even though /mark and /edit are separate APIs; the edit-delete path should clear the content/tag override while keeping correctness when it is set, and delete the row only when no mark remains.

Useful? React with 👍 / 👎.

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