Skip to content

feat: prevent deletion of seeded entity schemas#21

Draft
themusicman wants to merge 3 commits intomainfrom
feat/prevent-delete-seeded-entities
Draft

feat: prevent deletion of seeded entity schemas#21
themusicman wants to merge 3 commits intomainfrom
feat/prevent-delete-seeded-entities

Conversation

@themusicman
Copy link
Contributor

Summary

  • Add a guard to DeleteEntity that rejects attempts to delete the schema of seeded entity types (people, tasks, notes, links, interests, skills)
  • Add Seeds.seeded_type?/1 helper to check if a type is seeded
  • Add comprehensive tests for both the guard and the helper

Detailed Changes

Backend

  • Brain.Seeds — New seeded_type?/1 function that checks membership against entity_types/0
  • DeleteEntity — Pre-delete guard that blocks schema-targeted deletions (__schema__, schema, type name, <type>.json) for seeded types while still allowing normal entity deletions within those types
  • Brain.Helpers — New :protected_entity_type error formatting with the offending type name

Tests

  • SeedsTestseeded_type?/1 returns true for all 6 seeded types, false for custom types and nil
  • BrainActionsTest — Rejection of seeded schema deletion, successful entity deletion within seeded types, successful deletion in custom types

Test plan

  • seeded_type?/1 returns true for all seeded types
  • seeded_type?/1 returns false for non-seeded values
  • Deleting a seeded type schema target is rejected with clear error
  • Deleting a normal entity within a seeded type still works
  • Deleting entities in custom (non-seeded) types still works

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