feat(metadata): replace aiAutofill boolean with autofillSource enum (#302)

* feat(metadata): replace aiAutofill boolean with autofillSource enum

* fix(agent): validate creation-context metadata and make writes transactional

Address code review feedback on the autofillSource migration:

- Update the agent system prompt to reference the 'metadata' parameter of
  create_file/create_version instead of the removed 'context' parameter,
  which was being silently discarded by the activity
- Write metadata inside the caller's transaction via the new
  metadataService.updateAssetMetadataInTx, keeping metadata rows atomic
  with asset creation instead of opening a separate non-atomic transaction
- Reject metadata keys that are not defined CREATION_CONTEXT fields of the
  project with a non-retryable ApplicationFailure before creating the asset
- Remove dead agentContext handling from autofillAiActivity and its tests,
  and drop the unused ai_autofill i18n keys (paraglide recompiled)
- Derive the DTO autofillSource enum from the AutofillSource const instead
  of a hardcoded z.enum to prevent drift
This commit is contained in:
Yiling-J
2026-08-13 13:41:46 +08:00
committed by GitHub
parent 96493a5493
commit 41b73feeab
57 changed files with 1118 additions and 663 deletions
+2 -4
View File
@@ -450,7 +450,6 @@ model Asset {
transcodeTaskId String? @map("transcode_task_id")
/// [MediaInfo]
media Json?
autofillContext String? @map("autofill_context")
isDeleted Boolean @default(false) @map("is_deleted")
deletedAt DateTime? @map("deleted_at")
sortIndex String? @map("sort_index")
@@ -622,9 +621,8 @@ model MetadataField {
scope MetadataFieldScope?
/// [FieldConfig]
config Json?
readOnly Boolean @default(false) @map("read_only")
aiAutofill Boolean @default(false) @map("ai_autofill")
description String @default("")
readOnly Boolean @default(false) @map("read_only")
description String @default("")
teamId String? @map("team_id")
team Team? @relation("TeamToMetadataField", fields: [teamId], references: [id])