mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
Three narrow link tables landed with the visit record, which is a step away from the one-shared-service direction the polymorphic-linking work argues for. This bounds that step to a single module: every caller now speaks one vocabulary — a source, a target kind, a list of target ids — so replacing the storage underneath later is a change in one file rather than a sweep across every route that files something. The document-condition links move behind the same signature, so there are two families and one call surface. Behaviour is unchanged and the existing vault tests are the proof; where a test double had to follow the new query shape, it says why in the diff. The rules that used to live at each call site now live in the module and are proven against real Postgres rather than a fake that ignores a where clause: both ends re-read scoped to the owner before a row is written, a repeated link is a success that changes nothing, a call is capped at a hundred targets, and a tombstoned record is not linkable on either end. Unlinking one deliberately still works after a delete, or a filing nobody can clear would be left behind. Reads return a resolved label and date rather than a bare id, so a client rendering a list never re-derives what the server already knows. The restore is the one documented exemption and writes the tables directly: it rebuilds an account rather than filing something in one.