refactor: make the CLI-to-config mapping total and fix three error-handling gaps - #7
Open
ctxswitch wants to merge 1 commit into
Open
Conversation
…ndling gaps ServeArgs::config assigned twenty fields over the defaults Config::new had just written, so a newly added Config field was silently left at its default with no compile error. It now returns a struct literal naming every field, which makes an omission a compile failure and turns the clone_from calls into moves. Config::new gains a comment recording that clap owns the operator-facing defaults. The elided empty object in the prefetch pass propagated its write failure with ?, aborting the whole pass and contradicting the per-object tolerance documented three lines below; it is now tolerated per object, without counting a failed write as a local hit. The ephemeral cache's remove_dir_all is best-effort like prune_stale_files, so cleanup failure after a fully successful build no longer exits non-zero into Go's build cache. A match with an empty catch-all arm becomes the let-chain used elsewhere in the codebase.
3 tasks
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
Fifth of six phases. Based on
cleanup/phase-4b-extractor-negotiator(#6).ServeArgs::config()assigned twenty fields over the defaultsConfig::newhad justwritten, so a newly added
Configfield was silently left at its default with nocompile error. It now returns a
Config { … }literal naming all 21 fields indeclaration order, which makes an omission a compile failure and turns the six
clone_fromcalls and thedata_dircopy into moves.main.rscapturesdata_dirand
foreground_concurrencybefore the move, matching the existinglistencapture.The 18 defaults still exist twice — once in
#[arg(default_value_t)]and once inConfig::new— which is left alone as agreed.Config::newgains a doc commentrecording that clap owns the operator-facing defaults, that
ServeArgs::configbypasses
Config::newentirely, and that the two sets must change together.Three error-handling fixes:
?,aborting the entire pass and contradicting the per-object tolerance documented three
lines below. Now tolerated per object.
remove_dir_allis best-effort likeprune_stale_files, so acleanup failure after a fully successful build no longer exits non-zero — which Go
surfaces as a build-cache error.
matchwith an empty_ => {}arm becomes the let-chain form used elsewhere inthis codebase.
Verification
make ciclean, includingclippy --all-targets -- -D warnings.New:
serve_arguments_map_onto_the_configuration(tests/integration/cli.rs). Thestruct literal makes a missing field a compile error but not a crossed one — low
and high watermark swapped would still compile. The test parses a serve invocation
with a distinct value per flag and asserts each lands on the right
Configfield, soa crossed mapping fails. No default value appears in it; it is not a restatement of
the defaults.
The
cacheprogchanges are covered bysrc/cacheprog/cacheprog_test.rsandtests/integration/build_cache.rs.make ciOperational impact
The build-cache helper no longer exits non-zero when post-build cleanup of the
ephemeral cache directory fails. Previously a successful build could still be reported
to Go as a build-cache error. Cleanup failures are now silent, matching
prune_stale_files.A prefetch pass no longer aborts because one elided empty object failed to write. The
remaining objects in the pass now proceed, which is what the surrounding code already
documented.
No configuration, storage format, route, metric, or security boundary changes. The
CLI accepts exactly the same arguments and produces the same
Configfor them.Review notes
The
config()rewrite is the substance; the rest is small. Worth confirming the fieldmapping by eye against
Config's declaration order, since that is the one thing thecompiler cannot check and the new test exists precisely to cover.
One plan item was declined because its premise does not hold. The plan carried
forward a report that
put_referenceandput_artifactare "sibling routes withinconsistent error-response policy" —
api_errorJSON bodies versus bare statuscodes. On reading, the split is not per-handler inconsistency but a consistent
per-route-family policy: every channel-management and every reference handler returns
api_errorJSON (put_reference,get_reference, anddelete_referenceall returninvalid_referenceJSON on the same parse failure, andget_referencereturns a JSONbody on success), while every byte-stream route —
put_artifact,get_artifact, thebuild-cache and Bazel routes — returns bare status codes to clients that never parse
an envelope.
docs/operations.md:211-213codifies exactly that: "Errors from channel managementuse a JSON body with
codeandmessagefields. Data and protocol routes may returnan empty body when their client protocol does not use that error envelope." No test
pins these bodies, so the change was available — it was declined because the current
state is the coherent one, and either direction would have broken a documented
contract.
Incidental, not changed:
ServeArgsstill derivesClone, which has no caller nowthat
config()consumesself. Clippy does not flag it and it is a public type.