From ApprenticeLog · Code and result
Approval is a state transition, not a badge.
- Problem
- An edited record could appear approved after the approved content had changed.
- Decision
- Version every edit and withdraw approval when reviewed content changes.
- Result
- The visible state and audit history continue to describe the same record.
export function editEntry(
entry: WorkEntry,
patch: EntryEdit,
now = new Date().toISOString(),
): WorkEntry {
const nextVersion = entry.contentVersion + 1;
const changedAfterApproval = entry.status === "approved";
return {
...entry,
...patch,
status: changedAfterApproval ? "submitted" : entry.status,
contentVersion: nextVersion,
updatedAt: now,
history: changedAfterApproval
? [...entry.history, {
id: createId("history"),
action: "approval-withdrawn",
fromStatus: "approved",
toStatus: "submitted",
occurredAt: now,
contentVersion: nextVersion,
}]
: entry.history,
};
}Working state model
Version 4The work is approved and its audit history is intact.
- Status
- approved
- History events
- 3
- Data retained
- Yes



