ErrorsPersonal data · rule
data.person_removal_across_stores
Something other than erasure would remove a person another store refers to, and nothing would apply what that reference's erase: says.
Area 15, Personal data; not declinable; the next step is usually the human's.
Why Jadpo refuses it
A reference to a person from another store isn't a foreign key. No database
can apply it, so only erasing the person does, after their own commit. If the
person's record went any other way, by a hard delete, a retention: or a
purge:, their records in the other store would stay, holding an id no
record has, and no later erasure could find them, because there is nobody left
to erase.
Jadpo won't guess whether those records should go too or be kept, so it asks you to choose how the person goes.
What it looks like
app.jadpo:
domains/accounts/entities/user.jadpo:
entity User { id: Uuid email: Email { personal: PersonalData.contact } policy: { delete: [Access.public] } person: true}
use accounts/entities { User }entity OldNote { id: Uuid owner_id: User.id { erase: Erasure.deleted } store: archive}
domains/accounts/actions/remove.jadpo:
use accounts/entities { User, UserNotFound }/// Removes someone.action remove(id: User.id) fails UserNotFound -> Unit { attempt User.delete(id)}
error User.delete would delete a User that OldNote.owner_id refers to from another store
--> domains/accounts/actions/remove.jadpo:5:13
|5 | attempt User.delete(id) | ^^^^^^^^^^^ deletes outside erasure
- reason
OldNote.owner_idisn't a foreign key: only erasing aUserapplies what itserase:says, after the commit, in its store. Deleted any other way, theUserwould be gone and theOldNoterecords would stay, out of reach of any erasure.- next
- Call
User.erase, or giveUsera lifecycle whosedeletetransition hides them (human) - rule
- data.
person_ removal_ across_ stores - help
- https://jadpo.
dev/docs/errors/data. person_ removal_ across_ stores
(human) at the end of the next: line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides how a person leaves your app.
How to fix it
The question is what removing this person should mean.
If removing them means forgetting them, call <User>.erase(id), here
User.erase, which applies the reference. It needs an erasure log:
use accounts/entities { User, UserNotFound }/// Removes someone.action remove(id: User.id) fails UserNotFound -> Unit { attempt User.erase(id)}
Removing someone now erases them, and their old notes go after the commit.
If removing them should keep them findable, give User a lifecycle whose
delete transition hides them, with no purge::
entity User { id: Uuid decline data.personal_unread: "Read by code this example leaves out" email: Email { personal: PersonalData.contact } deleted_at: Instant? lifecycle: { visible: deleted_at == none transitions: { delete: { when: deleted_at == none set: { deleted_at: clock.now } } } } policy: { read: [Access.public] delete: [Access.public] } person: true}
User.delete now hides them, and a later erasure still finds them and their
old notes.
If they must go on a schedule, keep the other entity in the person's store,
where the reference is a foreign key and says on_delete:, and a retention:
or a purge: takes it into account:
use accounts/entities { User }entity OldNote { id: Uuid owner_id: User.id { on_delete: OnDelete.cascade }}
An ordinary delete now takes the person's old notes with them, in one statement.
Related
Markdown for agents: /docs/errors/data.person_removal_across_stores.md.Built from Jadpo's main branch at commit 9080dc3.