[PR #175] A Draft Request to Check a Record: Saving the Moment-of-Sending View and Deleting It on Withdrawal
This server feature lets a customer pick one record in the app and leave a draft asking headquarters to check it. I requested it; Fizz (GPT-6 Luna) wrote the tests first and Claude (a cloud session) implemented it. The log does not give this Claude session’s model version, so model is left out of the post info.
- What was done:
- Saving a draft and listing: A path to save a draft check request about one record, and a path to list a module’s drafts page by page.
- The moment-of-sending view: A draft returns the saved version number together with a snapshot of that version. Even if the record is edited later, the content inside the draft stays as it was.
- Delete on withdrawal: Because the published privacy notice says inquiries are all deleted when a customer withdraws, one deletion line was added to the shared withdrawal function. It runs in the same bundle (a unit where several changes succeed or are cancelled together) as the other deletions.
- Chosen approach and rejected alternatives:
- Reusing existing functions: Finding the record and building the version snapshot use functions the records side already has. Writing new ones would put the same rule in two places.
- Simultaneous sends of the same request: If the same request number arrives twice at once (a double tap), the “value already exists” error is caught and the already-created draft is read again and returned. This is the same approach as creating records. The constraint name was added to the existing list.
- Character count: Counted per character (code point), the same as the database.
- Shared response type left alone: Changing the shared inquiry response type was rejected as outside this work’s scope, so the author information is added only inside the server. The records-side file and the existing database change file were not touched.
- Checks:
- The environment-file check, the shared-part build, the full type check and the server lint (a code-style check) passed.
- This work environment could not start test containers, so the 11 new server tests were not run. They were left to the automatic checks (CI), and the result is not in the log, so I could not confirm it.
At a glance
| What was done | Key method |
|---|---|
| Saving a draft and listing | Save a draft about one record and list a module’s drafts page by page |
| The moment-of-sending view | Save the version number and its snapshot, so later edits do not change the draft |
| Delete on withdrawal | One deletion line in the shared withdrawal function, in the same bundle as other deletions |
| Simultaneous sends of the same request | On a duplicate error, read again and return the draft already created |
Who did what
- I: requested this work.
- Fizz (GPT-6 Luna): wrote the tests first.
- Claude (cloud session): implemented it.
What could not be checked
- The log notes a difference between the response shape the tests look at, the shared type, and the shape the app reads, but how that was settled in this PR could not be confirmed.
- Whether the 11 new server tests actually pass could not be confirmed.
What this taught
- For a request about a record that may change later, save the moment-of-sending view with it. Editing the record does not change what the request contains.
- Put a published promise (inquiries are deleted on withdrawal) in the shared withdrawal function. That prevents one path forgetting to delete.
- For simultaneous sends of the same request, read again after the error and return the same result; if there is already a way of doing it, follow that.