Skip to content

fix(broker): serve .servicedef.v2 via a v2-first combined loader (soldr#2364) - #905

Merged
zackees merged 1 commit into
mainfrom
fix/2364-v2-servicedef-loader
Aug 9, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/2364-v2-servicedef-loader

Conversation

@zackees

@zackees zackees commented Aug 9, 2026

Copy link
Copy Markdown
Owner

The bug (Phase 2 of forge-ci/soldr#2361, soldr#2364)

The shared broker's serve path (serve_launching_backends / HelloRouter) read
only v1 .servicedef files, but soldr — and every consumer that installs via
protocol_v2::write_service_definition_v2 — writes .servicedef.v2 files.
So a real Hello against a live soldr broker serve came back
Refused { "service definition was not found" } even though the servicedef was
on disk: it was under the v2 extension the v1 loader never looks for. This was
the last blocker to a real broker-mediated compile reaching Negotiated instead
of Refused.

The fix

CombinedServiceDefinitionLoader tries the v2 file first, falls back to the v1
file, and returns the v1 ServiceDefinition type the whole downstream launch
chain (check_version_allowed, BrokerInstanceKey::from_service_definition,
BackendLaunchRequest, …) already consumes. v2 is a strict superset of v1 —
identical field numbers 1–8, plus the v2-only optional http_server at field 10 —
so the down-conversion (service_definition_v2_to_v1) is lossless for everything
the launch path reads (the aggregator-facing http_server hint is dropped; the
launch path never reads it).

Why a trait, not a concrete type swap

Swapping HelloRouter's loader field to the v2 loader directly produces 7
E0308 mismatched-type errors, because ServiceDefinition is a separately
generated prost type per protocol version and every downstream consumer takes
the v1 type by signature. Instead, HelloRouter now takes its loader as
&dyn ServiceDefinitionSource. Both the bare v1 ServiceDefinitionLoader and
the new combined loader implement the trait, and &ServiceDefinitionLoader
unsize-coerces to the trait object at every existing call site — so the ~15
HelloRouter::new / with_lifecycle_monitor calls across tests/broker/*.rs
(which install v1 files) compile and pass unchanged. serve.rs switches its
two loader constructions to the combined loader.

Fallback safety

A missing v2 file (only) falls back to v1. Any other v2 error — insecure
directory, decode failure, service-name mismatch — surfaces as-is, so a genuinely
broken v2 install is loud rather than silently served from a stale v1 file.

Testing

  • 6 new combined_service_def_loader unit tests: v2 load+convert, v1 fallback,
    v2-preferred-when-both-present, missing-both → Io(NotFound), corrupt-v2
    surfaced (not masked), and conversion drops http_server while carrying every
    shared field.
  • broker::server lib suite (46 tests), hello_router:: (14) +
    instance_isolation integration tests, clippy -p running-process --features client -- -D warnings, and fmt --check: all clean.

Downstream

Once merged, soldr's _vender/running-process submodule pin (currently being
bumped for the #904 Frame-wrap fix in forge-ci/soldr#2382) bumps again to include
this, which should let a real SOLDR_USE_BROKER=1 cold compile negotiate through
the broker end-to-end. I'll validate that on soldr's Linux Docker harness after
the bump.

…ader (soldr#2364)

The shared broker's serve path (serve_launching_backends / HelloRouter) read
only v1 `.servicedef` files, but soldr — and every consumer that installs via
write_service_definition_v2 — writes `.servicedef.v2`. So a real Hello was
Refused { "service definition was not found" } even though the file was on
disk: it was under the v2 extension the v1 loader never looks for. This is the
last blocker to a real broker-mediated compile reaching Negotiated in Phase 2
of soldr#2361.

Adds `CombinedServiceDefinitionLoader`: it tries the v2 file first, falls back
to the v1 file, and returns the v1 `ServiceDefinition` type the whole downstream
launch chain (check_version_allowed, BrokerInstanceKey::from_service_definition,
BackendLaunchRequest, ...) already consumes. v2 is a strict superset of v1
(identical field numbers 1-8 plus the v2-only optional http_server at field 10),
so the down-conversion is lossless for everything the launch path reads.

To keep the existing v1-installing unit/integration tests working unchanged,
HelloRouter now takes its loader as `&dyn ServiceDefinitionSource` instead of a
concrete `&ServiceDefinitionLoader`. Both the bare v1 loader and the combined
loader implement the trait, and `&ServiceDefinitionLoader` unsize-coerces to the
trait object at every existing call site — so the ~15 `HelloRouter::new`/
`with_lifecycle_monitor` calls in tests/broker/*.rs compile untouched. serve.rs
switches its two loader constructions to the combined loader.

A missing v2 file (only) falls back to v1; any other v2 error (insecure dir,
decode failure, name mismatch) surfaces as-is so a genuinely broken v2 install
is never masked by a stale v1 fallback.

Testing: 6 new combined_service_def_loader unit tests (v2 load+convert, v1
fallback, v2-preferred, missing-both NotFound, corrupt-v2-surfaced,
conversion-drops-http_server); 46 broker::server lib tests, 14 hello_router +
instance_isolation integration tests, clippy (client), and fmt all pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@codecov

codecov Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.67925% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/src/broker/server/combined_service_def_loader.rs 87.75% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@zackees
zackees merged commit 500dd60 into main Aug 9, 2026
34 of 36 checks passed
zackees added a commit that referenced this pull request Aug 9, 2026
…soldr#2364) (#907)

Adds serve_launching_backends_negotiates_with_a_v2_servicedef: a cold Hello
against a real serve_launching_backends broker whose service is installed as a
.servicedef.v2 file (the soldr/v2-consumer default) now negotiates a backend
instead of returning Refused { "service definition was not found" }.

This is the integration-level acceptance proof for Phase 2 of soldr#2361: it
exercises the full fixed path -- client-side Frame-wrapped Hello (#904) through
the CombinedServiceDefinitionLoader's v2-first lookup (#905) to a Negotiated
reply -- against the real accept loop, not a stub. Existing v1-servicedef serve
tests continue to pass via the loader's v1 fallback.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

1 participant