Repository navigation
feat(broker-v2): ServiceDefinitionBuilder + write_service_definition_v2 (slice 22b of zccache#782) - #522
Merged
Conversation
…v2 (slice 22b of zccache#782) Adds the v2 consumer-side I/O surface that mirrors v1's \`broker::builders::ServiceDefinitionBuilder\`, \`broker::server::service_definition_dir\`, and \`broker::server::write_service_definition\`. Unblocks zccache#782 slice 21 (zccache's \`cli/commands/service_definition.rs\` migration) — the zccache CLI can now build + install a v2 \`.servicedef.v2\` file with a single \`ServiceDefinitionBuilder::shared_broker(name, path).install()\` call, mirroring the existing v1 surface byte-for-byte at the call site. ## What ships \`broker::protocol_v2::io\` (new submodule, re-exported from \`protocol_v2\`): - \`SERVICE_DEF_V2_EXTENSION = "servicedef.v2"\` — distinct from v1's \`servicedef\` so a v1 broker never accidentally decodes a v2 file. - \`service_definition_dir_v2()\` — returns the same per-OS dir as v1 (the two extensions cohabit; the broker picks based on its mode). - \`service_definition_path_v2(root, name)\` — validates the service name + computes the \`.servicedef.v2\` path. - \`write_service_definition_v2(root, def)\` — ensures the dir exists + has private permissions, writes the encoded bytes, returns the installed path. - \`ServiceDefinitionBuilder\` with constructors mirroring v1's (\`shared_broker\`, \`private_broker\`, \`explicit_instance\`), chainable setters (\`per_version_binary_dir\`, \`min_version\`, \`version_allow_list\`, \`label\`), and terminal calls (\`build\`, \`install_in\`, \`install\`). ## What's intentionally NOT here - Loader (\`ServiceDefinitionLoader\` equivalent): the v2 broker owns the load path; this PR is consumer-side write + layout only. A v2 loader lands when the v2 broker binary needs to consume these files. ## Tests 11 inline tests covering: - Extension constant + path computation (with v1 \`validate_service_name\` enforcement) - Each constructor (\`shared_broker\`, \`private_broker\`, \`explicit_instance\`) - Chainable setters propagate to the underlying \`ServiceDefinition\` - \`install_in\` round-trips through disk + decode - Name validation fires on bad service names - Parent dir auto-create when nested target doesn't exist - Full-field round-trip via the builder's \`install_in\` (every field the builder can set survives encode → write → read → decode) ## Test plan - [x] \`soldr cargo test -p running-process --features client --lib broker::protocol_v2\` — 20 passed (11 new + 9 existing) - [x] \`soldr cargo clippy --all-targets --features client -- -D warnings\` clean Closes the second upstream prerequisite for zccache#782 slice 21. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
9 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
3 tasks done
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the v2 consumer-side I/O surface that mirrors v1's
builders::ServiceDefinitionBuilder,server::service_definition_dir, andserver::write_service_definition. Unblocks zccache#782 slice 21 — zccache'scli/commands/service_definition.rsmigration. With this landed the consumer-side rewrite is a literal s/broker::builders::/broker::protocol_v2::/ exercise.What ships
broker::protocol_v2::io(new submodule, re-exported fromprotocol_v2):SERVICE_DEF_V2_EXTENSION = "servicedef.v2"— distinct from v1'sservicedefso a v1 broker never accidentally decodes a v2 file.service_definition_dir_v2()— returns the same per-OS dir as v1 (extensions cohabit).service_definition_path_v2(root, name)— validates the service name + computes the path.write_service_definition_v2(root, def)— ensures the dir exists + has private permissions, writes the encoded bytes, returns the installed path.ServiceDefinitionBuilderwith constructors mirroring v1 (shared_broker,private_broker,explicit_instance), chainable setters, and terminal calls (build,install_in,install).What's intentionally NOT here
A v2 loader. The v2 broker owns the load path; this PR is consumer-side write + layout only. A loader lands when the v2 broker binary needs to consume these files (separate slice).
Tests
11 inline tests in
broker::protocol_v2::io::testscovering:service_definition_path_v2uses correct extensionisolationvalueServiceDefinition(every field)install_inround-trips through disk → decodewrite_service_definition_v2rejects invalid namesinstall_inTest plan
soldr cargo test -p running-process --features client --lib broker::protocol_v2— 20 passed (11 new + 9 existing).soldr cargo clippy --all-targets --features client -- -D warningsclean.Closes the second upstream prerequisite for zccache#782 slice 21.