Skip to content

feat(broker-v2): extend ServiceDefinition with v1 launcher/isolation fields (slice 22 of zccache#782) - #521

Merged
zackees merged 1 commit into
mainfrom
feat/v2-servicedef-extend-with-v1-fields
Jun 20, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/v2-servicedef-extend-with-v1-fields

Conversation

@zackees

@zackees zackees commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Unblocks zccache#782 slice 21 (service_definition.rs migration) by porting the v1 `ServiceDefinition` launcher/isolation field set into the v2 envelope. zccache cannot move its `ServiceDefinitionBuilder::shared_broker` / `ServiceDefinitionLoader` call sites to v2 without these fields existing on the v2 schema.

What changed

`broker_v2_service_def.proto` gains 7 fields (numbers 2–8 deliberately mirror v1's for diff legibility) + the `BrokerIsolation` enum:

field v1 source type purpose
2 `binary_path` `string` canonical path to backend binary
3 `isolation` `BrokerIsolation` PRIVATE_BROKER / SHARED_BROKER / EXPLICIT_INSTANCE
4 `explicit_instance` `string` when isolation == EXPLICIT_INSTANCE
5 `per_version_binary_dir` `string` allow-list root
6 `min_version` `string` semver floor
7 `version_allow_list` `repeated string` optional strict pin
8 `labels` `map<string,string>` arbitrary deploy hints

The v2-only `http_server` field stays at 10. New v2-only fields grow upward from there.

Forward-compat

Pre-#522 v2 brokers ignore the new fields per proto3 semantics — the envelope still round-trips. The brokers start honoring them when their loader / launcher learns to read them (separate slice; not in this PR's scope).

Tests

3 new round-trip tests in `broker::protocol_v2::tests`:

  1. `service_definition_v1_fields_round_trip` — populates every new field plus a 2-entry `labels` map and a 2-entry `version_allow_list`; asserts every value survives encode + decode.
  2. `broker_isolation_enum_values_round_trip` — pins each `BrokerIsolation` variant's proto-int value so a future variant addition forces an explicit test update.
  3. `service_definition_explicit_instance_round_trips_with_any_isolation` — documents that the proto encoder is permissive; the broker enforces the gating between `isolation` and `explicit_instance`.

Pre-existing 6 tests adapted to `..Default::default()` so they survive the field-count change.

Test plan

  • `soldr cargo test -p running-process --features client --lib broker::protocol_v2` — 9 passed (3 new + 6 existing).
  • `soldr cargo clippy --all-targets --features client -- -D warnings` clean.

Coordinated with zccache#782 (consumer-side burn-down). zccache slice 21 will land as its own PR once this merges + a release ships.

Closes the upstream prerequisite called out in zccache#782 (slice 22 row).

…fields (slice 22 of zccache#782)

zccache's v1 → v2 broker migration (zccache#782) is gated on the v2
ServiceDefinition envelope carrying the launcher / isolation policy
fields v1 has used since #228. Without them, every consumer that uses
\`broker::builders::ServiceDefinitionBuilder::shared_broker(name, path)\`
or \`broker::server::ServiceDefinitionLoader\` has to keep importing v1
types just to express "spawn this binary under shared isolation,
pinned to this version" — defeating the migration entirely.

This slice ports the v1 fields verbatim into the v2 \`ServiceDefinition\`
message (field numbers 2–8 deliberately mirror v1's so the per-field
migration is mechanical):

- \`binary_path\` (field 2)
- \`isolation\` (field 3) — new \`BrokerIsolation\` enum mirrors v1's
- \`explicit_instance\` (field 4)
- \`per_version_binary_dir\` (field 5)
- \`min_version\` (field 6)
- \`version_allow_list\` (field 7)
- \`labels\` (field 8)

The v2-only \`http_server\` field stays at 10 (unchanged) and new v2-only
fields grow upward from there. Pre-#522 v2 brokers that already speak
this schema ignore the new fields per proto3 forward-compat semantics;
the brokers will start honoring them once their loader/launcher learns
to read them.

Tests:
- \`service_definition_v1_fields_round_trip\` — every new field survives
  prost encode + decode end-to-end, including a populated \`labels\` map
  and a 2-entry \`version_allow_list\`.
- \`broker_isolation_enum_values_round_trip\` — pins each enum variant's
  proto-int value so a future variant addition forces an explicit test
  update instead of silently misclassifying as the zero value.
- \`service_definition_explicit_instance_round_trips_with_any_isolation\`
  — documents that the proto encoder is permissive about the gating
  between \`isolation\` and \`explicit_instance\`; the broker enforces the
  semantic relationship, not the schema.
- Pre-existing 6 tests adapted to use \`..Default::default()\` so they
  survive the field-count change.

Closes the upstream prerequisite for zccache#782 slice 21
(service_definition.rs migration) + downstream zccache#782 slice 24
(BackendHandle / DaemonProcess — needs the same launcher metadata).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 82615fa into main Jun 20, 2026
54 of 57 checks passed
@zackees
zackees deleted the feat/v2-servicedef-extend-with-v1-fields branch June 20, 2026 18:28
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zackees added a commit that referenced this pull request Jun 20, 2026
…v2 extensions (#524)

Auto-Release will publish this version to crates.io + PyPI on push to main.

## Since 4.5.5

**Broker v2 client hardening (#520)** — closes #517, #518, #519
- \`DEFAULT_HELLO_DEADLINE\` + \`connect_with_deadline\` (3s; mirrors v1)
- \`BrokerV2Error::Refused\` promotes \`retry_after_ms\` to top-level
- \`SocketCleanup\` RAII guard on \`spawn_stub_broker\` test helper

**ServiceDefinition v2 schema extension (#521)**
- v2 envelope now carries v1's launcher/isolation field set
  (binary_path, isolation, explicit_instance, per_version_binary_dir,
  min_version, version_allow_list, labels) — unblocks consumer-side
  v2 migrations
- New \`BrokerIsolation\` enum mirrors v1's
- 3 new round-trip tests (every new field + every enum variant +
  explicit_instance survives all isolation modes)

**ServiceDefinition v2 consumer I/O (#522)**
- \`protocol_v2::io::ServiceDefinitionBuilder\` mirrors v1's builder API
- \`write_service_definition_v2\`, \`service_definition_dir_v2\`,
  \`SERVICE_DEF_V2_EXTENSION\` (\`.servicedef.v2\`)
- 11 new tests including full builder→install→decode round-trip

Unblocks downstream forge-ci/zccache#782 slices 21-25 (consumer-side
v1 → v2 migration burn-down) and forge-ci/zccache#840 (bincode wire
retirement, which independently needs these v2 surfaces to be stable
in a published release before zccache can drop its git+rev patch pin).

Co-authored-by: Claude Opus 4.7 (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