Skip to content

Commit ca3e00b

Browse files
ka1kqiclaude
andcommitted
docs(core): move the audit-log rationale beside the model
The applied migration file is checksummed by prisma migrate, so commenting it after the fact makes every database that already ran it report drift. The schema comment carries the same rationale without touching migration history. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012CLSaVXhLYJxH6DS9mDjiB
1 parent 12a0802 commit ca3e00b

2 files changed

Lines changed: 11 additions & 20 deletions

File tree

frontend/packages/core/prisma/migrations/20260826000000_add_audit_logs/migration.sql

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
-- The audit trail for non-interactive writes.
2-
--
3-
-- Purpose: one append-only row per write that changes account state, recording
4-
-- who (actor_user_id), what (operation, resource, summary), where (workspace/
5-
-- project), and crucially HOW — transport distinguishes a public-API call from
6-
-- an in-app agent action (with its session), because "who" alone no longer
7-
-- identifies the author's intent once machines write on a user's behalf.
8-
--
9-
-- Why this table did not exist before: every write used to be a human in the
10-
-- UI on their own cookie session — the actor was the session, the intent was
11-
-- the click, and the result was on screen. Attribution was structural.
12-
--
13-
-- Why it is needed now: the public write API lets the CLI, the in-app agent,
14-
-- and any credential holder create resources with no human watching. Once a
15-
-- dashboard can appear without anyone having clicked, "where did this come
16-
-- from" must be answerable from storage. Deliberately no foreign keys: audit
17-
-- rows must survive the deletion of everything they describe. UI writes will
18-
-- join this trail (transport "ui") when the cookie routes move to the shared
19-
-- write services.
20-
211
-- CreateTable
222
CREATE TABLE "audit_logs" (
233
"id" VARCHAR NOT NULL,

frontend/packages/core/prisma/schema.prisma

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,17 @@ model Widget {
789789
@@map("widgets")
790790
}
791791

792+
// The audit trail for non-interactive writes: one append-only row per write
793+
// that changes account state — who (actorUserId), what (operation, resource,
794+
// summary), where (workspace/project), and HOW: `transport` distinguishes a
795+
// public-API call from an in-app agent action (with its session id), because
796+
// "who" alone stops identifying intent once machines write on a user's behalf.
797+
// This table is new with the public write paths — before them, every write was
798+
// a human in the UI on their own cookie session, so attribution was structural
799+
// (the actor WAS the session, the result was on screen). Once the CLI, agent,
800+
// and API can create resources with no human watching, provenance has to be
801+
// answerable from storage. UI writes join the trail (transport "ui") when the
802+
// cookie routes migrate onto the shared write services.
792803
// No relations on purpose: audit rows must survive resource deletion (an FK
793804
// cascade would erase history).
794805
model AuditLog {

0 commit comments

Comments
 (0)