id: db-write-boundary
language: ts
severity: error
message: Blocking database write outside allowed server write layers
note: '{"severity":"high","category":"convention","resolution":"Blocking rule: keep db.insert/db.update/db.delete calls in src/server/db/queries/**, src/server/domain/**, or workflow command handlers under src/server/workflows/**. Move writes from other directories behind query/domain/workflow boundaries."}'
files:
  - '**/src/server/**/*.ts'
ignores:
  - '**/src/server/db/queries/**/*.ts'
  - '**/src/server/domain/**/*.ts'
  - '**/src/server/workflows/**/*.ts'
  - '**/src/server/testing/factory/**/*.ts'
rule:
  any:
    - pattern: db.insert($ARGS)
    - pattern: db.update($ARGS)
    - pattern: db.delete($ARGS)
    - pattern: $CTX.db.insert($ARGS)
    - pattern: $CTX.db.update($ARGS)
    - pattern: $CTX.db.delete($ARGS)
