feat(projects): record task and project edits in the audit trail (PMS-184) #155

Merged
longjacksonle merged 1 commit from feat/pms-184-task-edit-history into main 2026-06-11 04:05:30 +02:00

What

Backend half of PMS-184: task and project edits now leave a real change-history record, so the project detail page can show a task's edit history with an "edited" marker.

Changes

  • update_task and update_project now run as a transaction that snapshots the row before and after with to_jsonb and writes an in-transaction audit_log entry (entity_type = tasks / projects, entity_id set, before/after JSON), mirroring the established update_ticket pattern. A rollback drops the audit row with the change.
  • Previously these mutations only produced the audit middleware's coarse, entity_id-less row, so the per-record history endpoint had nothing to attribute to a specific task or project. Now every edit is captured with the exact columns that moved.

Pairs with

The per-record history read endpoint (GET /api/v1/audit-log/entity/{type}/{id}, PR #154) already whitelists tasks and projects, so this lights up their detail-page history feeds. The SPA half is a separate mokosh-apps PR.

Tests

task_and_project_edits_write_audit_rows: create a project + task, PUT a new task title and a new project name, then assert (directly against audit_log) that each produced an entity-scoped update row whose old/new snapshots carry the changed value. Asserted against the table rather than the read endpoint so this PR stays independent of #154.

🤖 Generated with Claude Code

## What Backend half of PMS-184: task and project edits now leave a real change-history record, so the project detail page can show a task's edit history with an "edited" marker. ## Changes - `update_task` and `update_project` now run as a transaction that snapshots the row before and after with `to_jsonb` and writes an in-transaction `audit_log` entry (`entity_type` = `tasks` / `projects`, `entity_id` set, before/after JSON), mirroring the established `update_ticket` pattern. A rollback drops the audit row with the change. - Previously these mutations only produced the audit middleware's coarse, `entity_id`-less row, so the per-record history endpoint had nothing to attribute to a specific task or project. Now every edit is captured with the exact columns that moved. ## Pairs with The per-record history read endpoint (`GET /api/v1/audit-log/entity/{type}/{id}`, PR #154) already whitelists `tasks` and `projects`, so this lights up their detail-page history feeds. The SPA half is a separate mokosh-apps PR. ## Tests `task_and_project_edits_write_audit_rows`: create a project + task, PUT a new task title and a new project name, then assert (directly against `audit_log`) that each produced an entity-scoped `update` row whose old/new snapshots carry the changed value. Asserted against the table rather than the read endpoint so this PR stays independent of #154. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(projects): record task and project edits in the audit trail (PMS-184)
All checks were successful
E2E (staging) / Playwright against staging (pull_request) Successful in 41s
Check / fmt + clippy + compile + tests (pull_request) Successful in 3m18s
Create release / Create release from merged PR (pull_request) Has been skipped
Build OCI container / Build and push mokosh-api image (push) Successful in 7m33s
f123889cb3
Wrap update_task and update_project in a transaction that snapshots the row before and after with to_jsonb and writes an in-transaction audit_log entry (entity_type tasks/projects, entity_id set, before/after JSON), mirroring the tickets path. Previously these mutations only left the entity_id-less middleware row, so the per-record change-history endpoint had nothing to show; now every task and project edit is captured with the exact columns that moved. The change-history read endpoint (added separately) already whitelists tasks and projects, so this lights up their detail-page history feeds. Adds a test asserting both edits write an entity-scoped audit row carrying the old/new field values.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
longjacksonle deleted branch feat/pms-184-task-edit-history 2026-06-11 04:05:30 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!155
No description provided.