Conversation
Refactors backend mutation flows to use Prisma transactions where multiple writes must stay consistent, and propagates `tx` through services/db-services (including `AuditService` and `AuditLogService`) so audit rows can participate atomically. Adds missing mutation audit events across API keys, workflows, benchmark promotion/apply flows, and HITL/session actions; updates related tests and documents the transaction/audit rules plus compliance status in `docs-md`.
kmandryk
requested review from
NoorChasib,
alex-struk,
antsand and
dbarkowsky
as code owners
July 3, 2026 18:18
Remove explicit `content_hash: null` assignments when creating documents so the model relies on the current document shape/defaults, and align related service/spec code with that change. The rest of the diff is mostly import ordering and formatting cleanup around audit logging, transactions, and service test setup.
Comprehensive audit coverage pass across training, dataset, benchmark, classifier, confusion-profile, template-model, HITL, document upload/update, and workflow delete. Also fixes multi-write paths that were missing Prisma transactions (benchmark definition revision, run delete, ground-truth job start/processJob, template-model labels/upload, hitl-dataset version creation). Updates AUDIT.md with new event-type tables and marks all rescan items as done in TRANSACTION_AND_AUDIT_AUDIT.md.
Adds missing mutation auditing for benchmark schedule configuration and workflow head reversion, including wiring actor identity through the controller/service path. Also wraps Temporal OCR result upsert + document status update in a single Prisma transaction to keep writes consistent, updates related tests for transaction mocking, and documents the new audit events and compliance status.
Adjusted backend and temporal tests to match updated method signatures that now pass actor/user IDs through controllers and services. Also updated audit-log service expectations to include the optional transaction argument (`undefined`) and applied minor formatting cleanup in the OCR upsert test.
dbarkowsky
approved these changes
Jul 6, 2026
dbarkowsky
left a comment
Collaborator
There was a problem hiding this comment.
No major concerns.
In some cases, I noticed the actorId was optional. Are we okay to accept audit records with a null actor?
Collaborator
Author
Null actor_id is intentional only for system-initiated actions (e.g. training poller). For user-facing mutations, AuditService now backfills actor_id from request context when not passed explicitly |
AuditService now falls back to `requestContext.actorId` when `actor_id` is not provided, ensuring user-initiated events keep actor attribution. Tests were updated to cover context fallback and explicit-actor precedence. API key deletion was simplified by removing a redundant second not-found check after the initial lookup, and AUDIT docs now clarify that `actor_id` should be null only for system-initiated actions with no HTTP identity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors backend mutation flows to use Prisma transactions where multiple writes must stay consistent, and propagates
txthrough services/db-services (includingAuditServiceandAuditLogService) so audit rows can participate atomically. Adds missing mutation audit events across API keys, workflows, benchmark promotion/apply flows, and HITL/session actions; updates related tests and documents the transaction/audit rules plus compliance status indocs-md.Summary
AI-1148
Changes
Testing
Checklist
By submitting this pull request, I acknowledge that I have attempted to meet the following: