Referential integrity for saved answers
Use this checker on this device to find saved answers, history entries, tags, pins, courses, notes, and deadlines that point at a missing record, clean only the dangling references, and stop a new orphan before a save is accepted.
What counts as an orphan
An orphan is a record that points at a record that is no longer present. The checker below reads the device store only. It creates no workspace record and it changes no college record.
| Record | Required reference | Orphan test | Cleanup |
|---|---|---|---|
| Saved answer | One collection in the same store, with collection id present in the collections list | Collection id is blank or not in the collections list | Move the answer to the Unfiled collection. Do not delete the answer |
| History entry | One saved answer id in the same store | History answer id matches no saved answer | Remove the history entry only. Keep the saved answer list unchanged |
| Tag entry | One saved answer id in the same store | Tag key matches no saved answer | Remove the tag entry only |
| Pin entry | One saved answer id in the same store | Pin key matches no saved answer | Remove the pin entry only |
| Course entry | One saved answer id in the same store | Course key matches no saved answer | Remove the course entry only |
| Study note entry | One saved answer id in the same store | Note key matches no saved answer | Remove the study note entry only |
| Deadline entry | One saved answer id in the same store | Deadline key matches no saved answer | Remove the deadline entry only |
| Sourced answer | Source title present means source link present and starting with http or https | Source title present with a blank or invalid source link | Flag for review. Do not delete the answer and do not invent a link |
| Workspace question, answer, attachment, user and role records in the signed-in app | This workspace, one assistant, one owner office and approval by a different person where the guides state it | A record points at another workspace, a missing assistant, a missing owner office, or an inactive member | Reassign or supersede in the signed-in app. This page does not delete a workspace record |
Run the check on this device
Nothing entered here is sent to a server. The check reads campus-answers:my-answers:v1 and campus-answers:my-library:v1 on this device only. It runs on load, on a storage change, and once each minute while this page is open. The last checked time is shown after each run.
No check has run on this page yet.
Last checked: not recorded.
Cleanup removes history, tag, pin, course, note, and deadline entries that point at a missing answer, and moves an answer with a missing collection to Unfiled. It never deletes a saved answer.
Block a new orphan before save
The same validation runs before a save in My Answers and on this page. A save that would create an orphan is refused with the field that needs attention, and the entered text stays in the form.
- Title is present and within the field limit stated on My Answers
- Collection exists in the store, or the save creates the named collection once before the answer is saved
- Source link, when present, starts with http or https
- Workspace and assistant labels are kept as stored, and a blank label is shown as Not recorded instead of a guessed name
- History, tags, pin, course, notes, and deadlines are written only for an answer id that was saved in the same write
var result = window.CampusIntegrity.validateBeforeSave(item, store);
if (result.ok === false) { showErrors(result.errors); keepFormText(); return; }
saveAnswer(item); writeHistoryAndTags(item.id);
For workspace records in the signed-in app, the equivalent block is the same rule in server code: every write filters by tenant_id from the session, checks that every referenced id exists in that tenant, and refuses the write with a field error when a reference is missing. No record is written with a dangling reference.
Checks before you rely on a saved list
- The integrity check shows zero orphans, or each remaining orphan is listed as flagged for review with no deletion
- Counts on My Answers match the saved answer count after cleanup, with history, tags, pin, course, notes, and deadlines pointing only at saved answers
- An answer moved to Unfiled still opens, still shows its sources, and still shows its workspace and assistant labels as stored
- Import of my-answers.json runs the same check after import and reports orphans before the list is shown
Keep saved lists free of orphans
Run the check, clean dangling references, and confirm zero orphans before you export or share a list.