Skip to content

refactor: replace manual Dict JSON building with Sury schemas in annotation meta builders#488

Merged
BlueHotDog merged 1 commit intomainfrom
issue-487-sury-schema-annotation-meta
Mar 2, 2026
Merged

refactor: replace manual Dict JSON building with Sury schemas in annotation meta builders#488
BlueHotDog merged 1 commit intomainfrom
issue-487-sury-schema-annotation-meta

Conversation

@BlueHotDog
Copy link
Copy Markdown
Collaborator

@BlueHotDog BlueHotDog commented Mar 2, 2026

Summary

  • Replace hand-rolled Dict.make()/Dict.set() with Sury S.object schemas for annotation _meta JSON serialization, giving compile-time field name guarantees instead of stringly-typed keys
  • Define typed schema records (annotationMeta, screenshotMeta, boundingBoxMeta) with S.object and s.field("snake_case", ...) mappings
  • Eliminate code duplication: both makeAnnotationMeta and makeMessageAnnotationMeta now serialize via the same annotationMetaSchema
  • Remove dead helpers (setOpt, boundingBoxToJson, serializeParentToJson)

Notes

  • The recursive parentLocationMeta type uses manual JSON serialization rather than S.recursive due to a Sury v11.0.0-alpha.4 bug where S.dict(S.json) inside S.recursive crashes on reverseConvertToJsonOrThrow. Documented in code comments.
  • Wire format is unchanged — all JSON keys remain snake_case, optional fields are still omitted (not null). Verified by existing test suite (231/231 passing).

Closes #487


Open with Devin

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

File Coverage Missing
All files 53%
frontman_server_web.ex 100%
protocol_schema.ex 50% 37-49
data_case.ex 77% 56-57
conn_case.ex 100%
agent_case.ex 0% 44-91
agent_client_protocol.ex 82% 58 200 210 267-281 294-295 323
json_rpc.ex 97% 68
channel_case.ex 88% 37
frontman_server.ex 0%
model_context_protocol.ex 81% 68-78
agent_client_protocol/content.ex 100%
fixtures/tools.ex 0% 31-64
fixtures/organizations_fixtures.ex 0% 10-34
fixtures/accounts_fixtures.ex 100%
fixtures/json_rpc.ex 95% 169
fixtures/agents.ex 0% 36-99
frontman_server/tasks.ex 83% 243 262-267 296-309 322 375-377 417 453
frontman_server/application.ex 44% 20 76-110
frontman_server/repo.ex 0%
frontman_server/providers.ex 59% 39 65-71 79-83 104-107 112 123-126 228 288 308-318 327-331 352-355 427 441-484
frontman_server/organizations.ex 83% 123 185-188 249 308-310
frontman_server/release.ex 0% 9-28
frontman_server/mailer.ex 0%
frontman_server/onboarding.ex 0% 32-38
frontman_server/image.ex 92% 163-167
frontman_server/accounts.ex 91% 298-307
frontman_server/tools.ex 100%
frontman_server/vault.ex 75% 27
frontman_server/finch_logger.ex 77% 32-38
frontman_server/accounts/user.ex 88% 61 80 116
frontman_server/accounts/user_identity.ex 100%
frontman_server/accounts/user_notifier.ex 100%
frontman_server/accounts/user_token.ex 95% 154
frontman_server/accounts/scope.ex 75% 45
frontman_server/accounts/workos.ex 7% 31-119 130 135-136 160-310
frontman_server/accounts/workos/auth_error.ex 0% 29-31
frontman_server/encrypted/binary.ex 0%
frontman_server/notifications/discord.ex 0% 18-80
frontman_server/observability/console_handler.ex 0% 18-241
frontman_server/observability/swarm_otel_handler.ex 62% 115 151 166 206-223 297 314 341 369 376-456 482 500 526-533 562 571-604 606-611 613-618 627 630 634-635 644-646 650 658-659 663 671-672 682
frontman_server/observability/otel_handler.ex 87% 79-80 89
frontman_server/observability/telemetry_events.ex 100%
frontman_server/observability/events.ex 100%
frontman_server/organizations/membership.ex 85% 43
frontman_server/organizations/organization.ex 100%
frontman_server/providers/oauth_token.ex 83% 44
frontman_server/providers/anthropic_oauth.ex 20% 73-153 166-167
frontman_server/providers/user_key_usage.ex 66% 42
frontman_server/providers/api_key.ex 75% 42
frontman_server/providers/chatgpt_oauth.ex 34% 33-262 293 318-328 338
frontman_server/providers/resolved_key.ex 100%
frontman_server/tasks/task.ex 33% 27-42
frontman_server/tasks/execution.ex 66% 88 180 204-210 263-264 271-291 305 314-318 337 363-366 375 391-397 400 416 429-450 459-495
frontman_server/tasks/title_generator.ex 1% 54-72 90-247
frontman_server/tasks/todos.ex 80% 45-48 107-109 122 125 130
frontman_server/tasks/stream_cleanup.ex 94% 115
frontman_server/tasks/interaction_schema.ex 64% 106-111 150-153 168-173 178-183 188-191 196
frontman_server/tasks/interaction.ex 51% 87-91 113 119 141 147 174-214 241-260 425 448-450 464-475 485 498-512 529 572 611-656 690-695 825-830 865-869 886 919-920 949 970 979 983-1031 1063 1072 1118 1133 1142 1147-1190 1197-1214 1223-1251 1268 1280-1300 1327 1331 1338-1341 1350-1384 1393 1448 1460-1490
frontman_server/tasks/task_schema.ex 87% 65
frontman_server/tasks/execution/root_agent.ex 86% 98-100
frontman_server/tasks/execution/framework.ex 100%
frontman_server/tasks/execution/llm_client.ex 41% 28 65 120 126-225 246-269 278-307 315-321 347 351-374 378-379
frontman_server/tasks/execution/prompts.ex 87% 151 178 199 222
frontman_server/tasks/execution/tool_executor.ex 89% 111-115 252-255 306 312
frontman_server/tools/todo_remove.ex 100%
frontman_server/tools/todo_list.ex 100%
frontman_server/tools/backend.ex 100%
frontman_server/tools/todo_add.ex 88% 86
frontman_server/tools/todo_update.ex 88% 75
frontman_server/tools/mcp.ex 100%
frontman_server_web/user_auth.ex 98% 92
frontman_server_web/endpoint.ex 0%
frontman_server_web/telemetry.ex 80% 22
frontman_server_web/gettext.ex 0%
frontman_server_web/router.ex 50% 16 27 40-47 53-62 101-103 111 152
frontman_server_web/channels/user_socket.ex 0% 16-59
frontman_server_web/channels/task_channel.ex 72% 69 83-104 142 155 167-168 210 221-233 289-290 313 326-354 376 380 403-405 412 417 425 432 442-448 484 490 560 577-583 632 660-664 684-691 702-703 717 752-755
frontman_server_web/channels/tasks_channel.ex 86% 35 44 178-185 203 208-217
frontman_server_web/channels/task_channel/mcp_initializer.ex 53% 113-145 208 221-234 268 280-324
frontman_server_web/components/layouts.ex 100%
frontman_server_web/components/core_components.ex 51% 107-109 187-249 337-394 476 502 504
frontman_server_web/controllers/oauth_html.ex 0%
frontman_server_web/controllers/user_registration_html.ex 0%
frontman_server_web/controllers/models_controller.ex 100%
frontman_server_web/controllers/user_api_key_controller.ex 73% 19 38-40
frontman_server_web/controllers/error_html.ex 100%
frontman_server_web/controllers/oauth_controller.ex 13% 13-47 60-125 144 148
frontman_server_web/controllers/user_registration_controller.ex 0% 8-29
frontman_server_web/controllers/error_json.ex 100%
frontman_server_web/controllers/chatgpt_oauth_controller.ex 0% 40-180
frontman_server_web/controllers/page_html.ex 0%
frontman_server_web/controllers/socket_token_controller.ex 0% 5-13
frontman_server_web/controllers/user_session_controller.ex 96% 16
frontman_server_web/controllers/health_controller.ex 0% 7-18
frontman_server_web/controllers/page_controller.ex 40% 10-13
frontman_server_web/controllers/user_me_controller.ex 0% 5-6
frontman_server_web/controllers/user_settings_controller.ex 100%
frontman_server_web/controllers/user_session_html.ex 0%
frontman_server_web/controllers/anthropic_oauth_controller.ex 0% 14-128
frontman_server_web/controllers/user_settings_html.ex 0%
frontman_server_web/plugs/cors.ex 81% 36 44
frontman_server_web/plugs/fetch_organization.ex 0% 17-36
frontman_server_web/protocols/acp_history.ex 100%
frontman_server_web/protocols/acp_history_impl.ex 100%
mix/tasks/debug_task.ex 0% 50-488
req_llm/fixture_path.ex 0% 31-70
req_llm/test/vcr.ex 0% 47-339
req_llm/test/transcript.ex 0% 40-517
req_llm/test/fixtures.ex 50% 38 56 63-67 86 95-101

Minimum allowed coverage is 75%

Generated by 🐒 cobertura-action against 3b06b92

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

…tation meta builders

Replace hand-rolled Dict.make()/Dict.set() with Sury S.object schemas for
annotation _meta JSON serialization. This gives compile-time field name
guarantees instead of stringly-typed keys.

- Define annotationMeta, screenshotMeta, boundingBoxMeta schema types
- Rewrite makeAnnotationMeta and makeMessageAnnotationMeta to use
  S.reverseConvertToJsonOrThrow with annotationMetaSchema
- Replace inline screenshotMeta construction in both content block builders
- Remove dead helpers: setOpt, boundingBoxToJson, serializeParentToJson
- parentLocationMeta uses manual JSON serialization due to a Sury bug
  with S.recursive + S.dict(S.json) in reverseConvertToJson

Closes #487
@BlueHotDog BlueHotDog force-pushed the issue-487-sury-schema-annotation-meta branch from 5415e68 to 3b06b92 Compare March 2, 2026 14:07
@BlueHotDog BlueHotDog merged commit 453bcd5 into main Mar 2, 2026
28 of 32 checks passed
@BlueHotDog BlueHotDog deleted the issue-487-sury-schema-annotation-meta branch March 2, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: replace manual Dict JSON building with Sury @schema in annotation meta builders

1 participant