The kg_modifications table already exists in the schema but has no code that writes to it. This task implements the write path so every KG edge creation, update, and deletion is recorded with before/after state, contradictions found, and approval status — enabling rollback and audit.
_record_kg_modification() helper function written in scidex/core/db_writes.pyinsert_knowledge_edge() logs a 'create' entry to kg_modificationsupdate_knowledge_edge() logs an 'update' entry with before/after statedelete_knowledge_edge() logs a 'delete' entry with before state/api/rollback/{edit_id} logs a 'rollback' entry to kg_modificationsactor_id, reason, source, and timestamps_record_kg_modification() helper in scidex/core/db_writes.pyinsert_knowledge_edge(), update_knowledge_edge(), and delete_knowledge_edge()kg_modifications logging to the /api/rollback/{edit_id} handler for knowledge_edge content_typekg_modifications), index exists (idx_kg_mods_created)insert_knowledge_edge, update_knowledge_edge, delete_knowledge_edge in db_writes.py do NOT log to kg_modificationskg_modifications_record_kg_modification() helper to scidex/core/db_writes.pyinsert_knowledge_edge() to call helper on createupdate_knowledge_edge() to call helper on update with before/after statedelete_knowledge_edge() to call helper on delete with before state/api/rollback/{edit_id} to log rollback entriesResult: PASS
Verified by: minimax:63 via task t-kg-modification-log
The current passing state is produced by:
30fdef44a — Add kg_modifications audit log to KG edge operations [task:t-kg-modification-log] (verified on origin/main)30fdef44a is present on origin/main (verified via git show origin/main:...)kg_modifications) was created in a prior migration (api.py lines 1678-1693)_record_kg_modification helper) due to API context; this is acceptable_record_kg_modification uses ctx.agent_id from journal context as fallback for actor_id