Repository navigation
refactor(core): one RpcError constructor surface, one management dial, typed transport facts - #4056
Merged
Merged
Conversation
RpcError::new, a constructor per code, forbidden and approval_required over two core constants, and with_message, with_details, with_cause and with_causes. Non-test struct literals and the one-line helpers that wrapped them now call these. The serialized form is unchanged.
… in one facts table
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
RpcError constructors carry the wire sentence, and the struct literals they replaced were never scanned.
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.
Why
Batch 1, chunk A of the core untangle (goal: pieces that change together live together, behavior unchanged, so later agent changes read less, break less silently and debug faster).
Four things were spelled many times and could drift apart:
RpcErrorwas built as a struct literal at about 360 non-test sites, with local helpers (closed,invalid_argument,internal, ...) re-spelling the same codes.connect_management,dial_tunnel,open_grant_registry) each built their own iroh endpoint, and the close codes 0x50/0x51/0x52 were bare numbers on both sides of the wire.TransportErrorcarried seven booleans that are not mutually exclusive, andConnectErroranswered "was it replied, retryable, unreached" through six separate predicates.sdk/prepare.rsread a Build refusal from prose even though the refusal carries a typeddetails.capability.DESIGN.md bets touched
Factstable, and every row equals the answer the old predicates gave. No per-target detail was collapsed.kind()is derived from the label's text and keeps unknown labels asOther. Enforcement refusal is read from the Machine's own refusal capability.No red flag is crossed. Wire formats are frozen (Stable promise): RPC error JSON,
TARGET_UNANSWERED_KEYand the UNANSWERED/UNREACHED status text, the label text and the close code values are unchanged.What changed
Four commits, one per fix, in order.
RpcErrorgets one constructor surface inployz-core/src/rpc.rs:new, one named constructor perRpcErrorCode,forbiddenandapproval_requiredoverFORBIDDEN_CODEandAPPROVAL_REQUIRED_CODE, and the builderswith_message,with_details,with_cause,with_causes.causedandunanswered_targetare rewritten overnew. Every non-test literal in ployz, ployzd, ployz-store, ployz-sdk, ployz-core and ployz-testkit migrates, and the local helpers are deleted. The three struct-update sites usewith_details.ployz-store/src/error.rskeeps its helper names; only its privateerror()body changed.build/remote.rsreturns aRefusedcarryingby_enforcement, andcheck_build_capabilitiesreturnsCapabilityCheckError.sdk/prepare.rsreadsRefusedByEnforcementfrom the capability and falls back to theBUILD_REFUSED_BY_ENFORCEMENTtext for old daemons that send nodetails.capability. The constants stay as message text.endpointanddialinconnect/management.rs) used byconnect_management,dial_tunnelandopen_grant_registry.SEGMENTATION_OFFLOADand the three close codes live inployz-core/src/domain/management_capability.rs, besideTUNNEL_FAILED, and both sides use them.ManagementClientLabel::kind()replaces the string checks incluster.rs,handlers/cloud.rs,handlers/server/remove.rsandployzd/src/machine/local_machine.rs.TransportErrorholdsorigin: Origin { Remote, Local, SessionClosed },routed: Option<Routed { Unanswered, Unreached }>,budget_expiredand the two bools that are not part of the exclusive-state problem.From<tonic::Status>is the single decoder.ConnectError::facts()is one exhaustive table that each consumer reads. The old predicates stay as thin delegates, and as the oracle ina_transport_errors_facts_match_the_flags_they_replaced.A fifth commit renames the capability check's failure closure, and a sixth drops comments that restated the names they sat on.
Scope
In: the four fix ids below, in
core/only.Out, on purpose:
#[non_exhaustive]flip) is a later batch. Struct-literal construction still compiles."cloud"parse is left alone.unansweredanddetailedstay bools onTransportError.TUNNEL_FAILED, not in a newployz-core/src/management.rs.Decision-log text
T1-F1 RpcError gets one constructor surface and non-test literals migrate.
T7-F12 Enforcement refusal read by capability.
T3-F8 One management dial.
T3-F3a Typed transport facts.
Tradeoffs
ConnectErrorvariant fails to compile until its row is written.Blast Radius
Mostly mechanical: 71 files, 1373 insertions, 1479 deletions, about 209 of the added lines in tests.
Machine behavior: one change. The grant registry endpoint (
open_grant_registry) now turns UDP segmentation offload off, as the other two management dials already did. Nothing else alters what a Machine does: no daemon, Docker, WireGuard, ZFS, move or deploy path changed, and the daemon-side edits only swap bare close-code numbers and label string checks for the same values read from shared constants. The decision log asks forverify-serveron a cloud-managed dial and a grant registry open. I did not run it. See Verification.Residual, named once (Cloud security bar): none. Nothing here lets a compromised Cloud cross the bar. The
kind()of a label is read on the Machine from the label it already holds.Out-of-scope note: the comment above
CLIENT_REFUSEDandCLIENT_CLEAREDinployzd/src/management/mod.rsnow repeats the shared constants' docs. I left it because trimming it is outside this chunk.Verification
Focused local checks only. CI is the gate.
cargo clippy -p ployz-core -p ployz-store -p ployz-sdk -p ployz -p ployzd -p ployz-testkit --all-targetsis clean at this head.cargo test -p ployz connect::(77 passed),cargo test -p ployzd management(52 passed) andcargo test -p ployz-core value::(22 passed), run before the final rebase onto trunk.ConnectErrorkeeps its facts, anda_management_client_label_names_its_kind.verify-serverfor the grant registry dial. It is a one-setting change on the client's own socket, covered by the unit tests only in that the endpoint builds. A root decision whether it needs real Machines.