Skip to content

fix: patterns can be deleted; a deleted observation leaves no trace in patterns - #75

Open
alexeybe1kin wants to merge 5 commits into
mainfrom
fix/pattern-forgetting
Open

alexeybe1kin wants to merge 5 commits into
mainfrom
fix/pattern-forgetting

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

Hunt finding memorygate-1 F28 (forgetting; Claude-written, one security review: no defect).

Before this change:

  • Nothing deleted a pattern except a full reset.
  • DELETE /observation/{id} removed only the row. Its lineage links, its id in other observations' related_observation_ids_json, and patterns built from it with their derived text all stayed.

Now:

  • DELETE /pattern/{id} deletes a pattern of the calling agent (404 for another agent's) with its lineage links, and writes a pattern deletion receipt.
  • Deleting an observation removes its links (each with a link receipt), its id in other observations and in patterns, and any pattern left with no observation (with its own pattern receipt).
  • Recovery replay of observation and pattern receipts removes the same set from a restored backup. It is idempotent in either receipt order.
  • The link and id-list helpers move to services/lineage_forgetting.py; the entity delete (fix: deleting an entity removes its history, events, edges, links and ids #63) uses them unchanged.

Limit: a pattern that still has other observations keeps its text.

Tests: tests/test_pattern_forgetting.py (3, all failing on main): route delete, another agent's 404, replay into a restored copy. Locally: every observation, pattern, recovery, deletion, forgetting, lineage, entity and reset test, 101 passed; ruff, types, sizes and package boundaries ok.

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