Audit history
Codemeta OS persists an audit entry for every mutation of an entity,
containing a JSON patch according to RFC 6902.
The patch describes the change as a sequence of add/remove/replace operations.
What does an audit entry contain?
Every entry contains:
entityId– the UUID of the entity that was changed.entitySchema– e.g.ticket,kb_article.operation–create,update,delete,restore.patch– the RFC 6902 JSON patch.actor– who triggered the change (user ID or system).at– timestamp in ISO 8601 format.tenantId– naturally.
Example patch
From an update that sets a ticket’s priority from normal to high
and appends a new tag:
[
{ "op": "replace", "path": "/priority", "value": "high" },
{ "op": "add", "path": "/tags/-", "value": "escalation" }
]
The patch is executable such that applyPatch(prevState, patch) === nextState
holds. You can therefore deterministically reconstruct the state before and after every change
by applying the patches in the correct order.
Retrieve the audit trail
Each entity has a timeline route. With ?filter=history you get only
the audit entries:
curl "https://os.codemeta.de/api/v1/tickets/<id>/timeline?filter=history" \
-H "X-Tenant-Id: $TENANT" \
-b cookies.txt
The timeline is in descending chronological order; the oldest entries are at the end.
Paging is done by cursor via meta.nextCursor — see
Pagination.
Why a patch at all?
- Auditability – every change is traceable without you having to store all versions of an entity.
- Low storage – patches are compact; a full snapshot would be expensive.
- Reproducibility – you can reconstruct the state of an entity at any point in time by applying all patches up to that point.