CI gate (authoritative): generalize the dangling-reference test in StamdataValidationTests
into a declared, extensible reference list ("every declared reference into a stamdata key
resolves against the currently-valid stamdata"), starting with Diploma.Opleiding →
professions.program. Removing/renaming a referenced program, or expiring it while current
data still references it, fails the PR build (ADR-0004). Editor (fast feedback): confirm
before delete (warns a referenced row fails CI) and, for temporal tables, a "Sluiten per
vandaag" action that closes validity (geldigTot) — steering to expire over hard delete.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
WP-48 — Stamdata deletion protection (referential integrity)
Status: done Phase: 8 — platform/DX/showcase
Why
Deleting a stamdata row that something relies on (e.g. a professions.program a diploma maps
through) would silently break behaviour. Stamdata is config-as-code (PR-applied, CI-gated), so the
authoritative guard belongs at the build gate; the editor gets a fast-feedback nudge.
Decisions (locked with the user)
- CI gate (authoritative) + editor warning (fast feedback).
- Steer temporal rows toward expiring (set
geldigTot) over hard delete.
Outcome
- CI gate: generalized the dangling-reference test in
StamdataValidationTestsinto a declared, extensible reference list (StamdataRefrecords) — "every declared reference into a stamdata key resolves against the currently-valid stamdata." Today one entry:Diploma.Opleiding → professions.program (valid today). Resolvers use the "valid today" view (Professions.ByProgram), so removing/renaming a referenced program OR expiring it while current data still references it fails the PR build; expiring once nothing current relies on it passes. Adding a future FK is one list entry. - Editor (fast feedback):
stamdata-table-editornow confirms before delete (@@beheer.removeConfirm— warns that a referenced row fails CI and, for a dated table, to close validity instead) and, for temporal tables, adds a "Sluiten per vandaag" action that setsgeldigTotto today (reusingCellEdited) — steering to expire over hard delete. CI stays the authority.
Acceptance criteria
- A delete/expire that orphans a declared reference fails the build gate (existing seed passes).
- Editor confirms deletes and offers expire (close validity) for temporal tables.
npm run cigreen (backenddotnet test, localized build).
Deferred (noted)
A per-row "referenced" hint in the editor DTO (server-computed usage) — would let the editor warn on the specific referenced rows rather than a generic confirm. Not needed for the authoritative gate.