{
  "id": 14591797,
  "title": "Designing an Audit Trail for Attendance Edits Without Overwriting Source Events",
  "url": "https://urgent.news/2026/10/15/designing-an-audit-trail-for-attendance-edits-without-overwriting",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-15T02:25:19.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/insacheck/designing-an-audit-trail-for-attendance-edits-without-overwriting-source-events-19dk"
  },
  "original_language": "en",
  "account": "Attendance corrections often appear as simple database updates, but they erase crucial context: what was initially recorded, who requested the change, supporting evidence, approval status, and the value used before the modification. In systems impacting payrolls, this missing context creates a design flaw. To address this, treat the original clock event as immutable and create a separate, reviewable audit trail for corrections.\n\nAttendance software typically contains two types of truths: observed truth—the raw event from devices, browsers, or administrator imports—and operational truth—the approved interpretation used for schedules, overtime, and pay. Both facts should be preserved, even if they disagree. For instance, an employee could clock out at 18:47, but an approved work end time of 18:00 may reflect someone forgetting to clock out after changing clothes.\n\nWhen creating an attendance event, include metadata that identifies its origin and the server's receipt time. Device time is insufficient as phones can be inaccurate or synchronize later. Design the `attendance_events` table to encode these details.\n\nCorrections should not be treated as new clock events. Instead, they are proposals to interpret one or more source events differently. Create a dedicated `attendance_corrections` table for this purpose. Each correction should reference the affected source events and capture essential information like the employee's ID, date, requested clock times, reason for correction, requestor's ID, timestamp, status, decision-maker's ID, decision note, and any additional details. The correction workflow should reference source events through a join table to handle scenarios like duplicate scans, missing clock-outs, or shifts crossing midnight.\n\nWhen calculating the effective attendance record, combine raw events with the latest approved correction and the policy version used for interpretation. This approach allows for dynamic adjustments to rules without altering existing data. It is crucial to maintain policy version information, as changing rules should not silently affect previously calculated records.\n\nImplement state transitions explicitly, defining legal transitions between correction statuses (pending, approved, rejected, cancelled) in a domain function. This ensures that only valid transitions are allowed and prevents unauthorized modifications. If an approved correction is found to be incorrect, create a new correction instead of editing the original one to maintain the integrity of the audit trail. This approach avoids ambiguity and preserves the chronological record of decisions.\n\nConcurrency issues may arise when multiple users attempt to approve the same pending correction simultaneously. Use optimistic locking or conditional updates to handle these situations gracefully. Ensure that only one update can succeed at a time, and if an update fails due to another user's modification, the system should refresh the client rather than pretend the approval was successful. This protects the consistency and reliability of the attendance record management workflow.",
  "summary": "+09:00' WHERE id = 8412 ; That query fixes the current row, but it also destroys the answer to several questions: What was recorded first? Who requested the correction? What evidence supported it? Who approved it? Which value was used for payroll before the change? For systems…",
  "key_points": [
    "Original clock events remain immutable, preserving crucial context.",
    "Separate audit trail for corrections maintains transparency and accountability.",
    "Combine raw events with latest approved correction for dynamic attendance records."
  ],
  "editors_take": "Treating original clock events as immutable data preserves the necessary distinction between raw observed facts and the approved operational truths required for accurate payroll and compliance auditing.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}