Repository navigation
feat(core): seal personal data in scheduled commands and dead letters, cancelled by forget - #221
Open
benatespina wants to merge 1 commit into
Open
benatespina wants to merge 1 commit into
benatespina wants to merge 1 commit into
Conversation
…, cancelled by forget A command's payload takes personal() and person() as an event's does. Wherever the command is stored, scheduled with delay, retried or dead-lettered, its marked fields are sealed with the key of the person it names, and the handler still receives them as the schema gives them. forget cancels the person's scheduled commands and removes their dead letters in its transaction, and PersonalDataForgotten names them.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the gap that
forgetleft: the payloads of scheduled commands and of their dead letters were stored in the clear and out of its reach.What changes
payloadreceivespersonalandperson(CommandPayloadArgs), as an event's does.personaltypes the field as the schema gives it, never| null: a command whose person is forgotten never runs, so its handler keeps receivingT. A query'sPayloadArgsstill has none.delay(with the key of the person it names, created on first use, before any transaction opens). Retries keep the sealed payload, and a dead letter inherits it with the entry'spersons, so nothing is sealed twice and no key is created on the way to a dead letter. A command dispatched at once is unchanged.app.deadLettersshows payloads opened (forgotten fields asnull) and refuses to retry a letter whose person was forgotten (DeadLetterNotRetriableError).forgetcancels the scheduled commands and then removes the dead letters whosepersonsname the person.PersonalDataForgottennow carries{ personId, cancelledCommands: { commandId, type }[], removedDeadLetters: { id, commandType }[] }.forgetovertakes finds its claim lost and writes nothing, events or dead letter. Cancelling before removing letters closes the PostgreSQL interleaving; a storage-transaction contract case races the two on every store.forget; the guide says so.ScheduledCommand,ScheduleArgsandDeadLettergain optionalpersons;SchedulerandDeadLetterStoregainforget(person), answering what they removed inlistorder. Both tables get apersonscolumn, with a GIN (jsonb_path_ops) index in PostgreSQL next to fix: close what the review of idempotency, snapshots and personal data found #220's. The memory transaction removes at once and puts back on failure, as it does keys.byFirstFailurejoins@bounda-dev/core/adapter/sql.+typesPayloadArgsiscore.CommandPayloadArgs; fixtures regenerated,test-typescover the marks, the handler'sT, and the new payload shape.personal-dataguide gets "In a command's payload", describes whatforgetcancels and the races, and its "does not reach" paragraph now names only what app code writes (logs, error messages) and unmarked payloads. Concept page, limitations, dead-letters guide and errors reference updated. The pendingpersonal-datachangeset gains a paragraph.No migration for existing tables, per the no-production-users policy: a database created by an earlier release lacks the
personscolumns.Checks
pnpm checkgreen (Docker up for PostgreSQL), after rebasing on fix: close what the review of idempotency, snapshots and personal data found #220./code-reviewapplied: key cache per person inopenCommandPayload, a test for a policy scheduling a delayed personal command, and the guide naming handler error messages among whatforgetdoes not reach.