Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .prettierignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
5 changes: 2 additions & 3 deletions tests/worker-visual-capture.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -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", () => {
Expand Down
19 changes: 12 additions & 7 deletions worker/main.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -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),
Expand All@@ -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,
Expand DownExpand Up@@ -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,
Expand Down
Loading