From b21cdae3410ee7c42b42350c005afb87811c36f1 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Thu, 2 Jul 2026 23:45:53 +0800 Subject: [PATCH] style: format worker/main.ts and remove its prettier carve-out #180 excluded worker/main.ts from prettier because tests/worker-visual-capture.test.ts asserts on its exact source text, and prettier line-wrapping broke one assertion. Instead of a permanent carve-out, format the file and make that one assertion formatting-agnostic (match two stable substrings), so worker/main.ts is covered by the format gate like every other source file. Only 3 lines reformat (prettier is deterministic, whitespace only); only the structuredProfile source-guard assertion needed loosening. The file's other source guards are unaffected. Full worker-visual-capture suite passes. Co-Authored-By: Claude Fable 5 --- .prettierignore | 4 ---- tests/worker-visual-capture.test.ts | 5 ++--- worker/main.ts | 19 ++++++++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.prettierignore b/.prettierignore index f08ea3e5e7..aefbc2e0b0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,10 +13,6 @@ public/demo-documents/ scratch/ .claude/worktrees/ .impeccable/ -# tests/worker-visual-capture.test.ts asserts on the exact source text of this -# file (line-level guards on redaction/normalization order); prettier's -# line-wrapping would break those assertions, so it owns its own layout. -worker/main.ts # Generated by `supabase gen types`; keep the generator's formatting so # regeneration stays churn-free. src/lib/supabase/database.types.ts diff --git a/tests/worker-visual-capture.test.ts b/tests/worker-visual-capture.test.ts index 1e61e0f100..5b90343d6e 100644 --- a/tests/worker-visual-capture.test.ts +++ b/tests/worker-visual-capture.test.ts @@ -74,9 +74,8 @@ describe("worker visual capture hardening", () => { expect(workerSource).toContain("const classification = redactImageClassification(args.classification);"); expect(workerSource).toContain("let classification = redactImageClassification(resolved.classification);"); expect(workerSource).toContain("caption: classification.caption"); - expect(workerSource).toContain( - "const structuredProfile = normalizeStructuredVisualProfile(redactCaptionMetadataValue(metadata.structured_visual_profile), {", - ); + expect(workerSource).toContain("const structuredProfile = normalizeStructuredVisualProfile("); + expect(workerSource).toContain("redactCaptionMetadataValue(metadata.structured_visual_profile)"); }); it("computes perceptual duplicate groups before caption budget selection", () => { diff --git a/worker/main.ts b/worker/main.ts index 922dfc62eb..29cd7d21d3 100644 --- a/worker/main.ts +++ b/worker/main.ts @@ -752,7 +752,9 @@ async function getCachedImageClassification(ownerId: string | null, imageHash: s : "unclear"; const score = Number(metadata.clinical_relevance_score); const labels = cachedImageLabels(metadata.labels); - const cachedCaption = redactCaptionIdentifiers(cleanString(String(data.caption || "").trim() || "Extracted source image.")); + const cachedCaption = redactCaptionIdentifiers( + cleanString(String(data.caption || "").trim() || "Extracted source image."), + ); const assessment = assessClinicalImageUse({ imageType, searchable: Boolean(metadata.searchable), @@ -761,10 +763,13 @@ async function getCachedImageClassification(ownerId: string | null, imageHash: s labels, skipReason: typeof metadata.skip_reason === "string" ? metadata.skip_reason : null, }); - const structuredProfile = normalizeStructuredVisualProfile(redactCaptionMetadataValue(metadata.structured_visual_profile), { - fallbackText: cachedCaption, - fallbackConfidence: score, - }); + const structuredProfile = normalizeStructuredVisualProfile( + redactCaptionMetadataValue(metadata.structured_visual_profile), + { + fallbackText: cachedCaption, + fallbackConfidence: score, + }, + ); return { image_type: imageType, @@ -813,8 +818,8 @@ async function setCachedImageClassification(args: { clinical_signal_score: classification.clinical_signal_score, admin_signal_score: classification.admin_signal_score, structured_visual_profile: (classification as ImageClassificationWithVisualProfile).structured_visual_profile, - structured_extraction_confidence: - (classification as ImageClassificationWithVisualProfile).structured_extraction_confidence, + structured_extraction_confidence: (classification as ImageClassificationWithVisualProfile) + .structured_extraction_confidence, image_policy_version: clinicalImagePolicyVersion, visual_intelligence_version: visualIntelligenceVersion, image_caption_cache_version: imageCaptionCacheVersion,