fix: enrich image failure audit metadata

This commit is contained in:
kdletters
2026-05-28 14:50:13 +08:00
parent c8b36cf799
commit 771b0411a3
18 changed files with 234 additions and 20 deletions

View File

@@ -1085,6 +1085,7 @@ pub(crate) fn attach_puzzle_level_asset_bundle(
pub(crate) async fn generate_puzzle_initial_ui_background_required(
state: &PuzzleApiState,
request_context: &RequestContext,
owner_user_id: &str,
session_id: &str,
draft: &PuzzleResultDraftRecord,
@@ -1093,6 +1094,7 @@ pub(crate) async fn generate_puzzle_initial_ui_background_required(
let prompt = resolve_puzzle_initial_ui_background_prompt(draft, target_level);
let generated = generate_puzzle_ui_background_image(
state,
request_context,
owner_user_id,
session_id,
target_level.level_name.as_str(),
@@ -1104,6 +1106,7 @@ pub(crate) async fn generate_puzzle_initial_ui_background_required(
pub(crate) async fn generate_puzzle_level_asset_bundle_required(
state: &PuzzleApiState,
request_context: &RequestContext,
owner_user_id: &str,
session_id: &str,
target_level: &PuzzleDraftLevelRecord,
@@ -1111,6 +1114,7 @@ pub(crate) async fn generate_puzzle_level_asset_bundle_required(
) -> Result<GeneratedPuzzleLevelAssetBundle, AppError> {
generate_puzzle_level_asset_bundle(
state,
request_context,
owner_user_id,
session_id,
target_level.level_name.as_str(),
@@ -1175,6 +1179,7 @@ pub(crate) fn find_puzzle_level_for_initial_asset_check<'a>(
pub(crate) async fn compile_puzzle_draft_with_initial_cover(
state: &PuzzleApiState,
request_context: &RequestContext,
session_id: String,
owner_user_id: String,
prompt_text: Option<&str>,
@@ -1195,6 +1200,7 @@ pub(crate) async fn compile_puzzle_draft_with_initial_cover(
})?;
let mut target_level = select_puzzle_level_for_api(&draft, None)?;
let fallback_level_name = target_level.level_name.clone();
let (_, profile_id) = build_stable_puzzle_work_ids(&compiled_session.session_id);
let image_prompt = resolve_puzzle_draft_cover_prompt(
prompt_text,
&target_level.picture_description,
@@ -1209,6 +1215,7 @@ pub(crate) async fn compile_puzzle_draft_with_initial_cover(
let mut candidates = generate_puzzle_image_candidates(
state,
owner_user_id.as_str(),
Some(profile_id.as_str()),
&compiled_session.session_id,
&target_level.level_name,
&image_prompt,
@@ -1262,6 +1269,7 @@ pub(crate) async fn compile_puzzle_draft_with_initial_cover(
{
let asset_bundle = generate_puzzle_level_asset_bundle_required(
state,
request_context,
owner_user_id.as_str(),
compiled_session.session_id.as_str(),
&target_level,
@@ -1369,7 +1377,6 @@ pub(crate) async fn compile_puzzle_draft_with_initial_cover(
Err(error)
}
})?;
let (_, profile_id) = build_stable_puzzle_work_ids(&compiled_session.session_id);
match state
.spacetime_client()
.update_puzzle_work(PuzzleWorkUpsertRecordInput {
@@ -1441,6 +1448,7 @@ pub(crate) async fn compile_puzzle_draft_with_initial_cover(
pub(crate) async fn compile_puzzle_draft_with_uploaded_cover(
state: &PuzzleApiState,
request_context: &RequestContext,
session_id: String,
owner_user_id: String,
prompt_text: Option<&str>,
@@ -1544,6 +1552,7 @@ pub(crate) async fn compile_puzzle_draft_with_uploaded_cover(
.await?;
let asset_bundle = generate_puzzle_level_asset_bundle_required(
state,
request_context,
owner_user_id.as_str(),
compiled_session.session_id.as_str(),
&target_level,