Repository navigation
Sweep core api/ blob_fetcher, date, retry, types - #1975
Mikola Lysenko (mikolalysenko) wants to merge 4 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
blob_fetcher: inline format_fetch_result_for into its one public caller, trim history and restating comments, and collapse 11 duplicate format tests into 3 that compare whole output. date: the chronological check asserted on its own loop counter; rename the test to the round trip it really checks. retry: make the client-only helpers and the retry ceiling private, inline the timeout constants (pub only for a tautology test), and cut the module doc that restated the policy field docs. types: delete 10 serialize-side and round-trip tests that the payload-deserialize tests already cover. Assisted-by: Claude Code:claude-opus-5-5
Assisted-by: Claude Code:claude-opus-5-5
scan --json writes BatchPackagePatches verbatim, so its serialized keys are output: compare the whole value instead of the deleted .contains checks. Also unlink a now-private item from the public module doc and pin the documented retry ceiling of 10. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
1 similar comment
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0b99f82. Configure here.
|
Burn-down agent: labeled Ready for review.
Generated by Claude Code |
Final review briefWhat it does: A cleanup of four Risk: Low. Production code changes only in visibility, inlined constants and one inlined formatter, and the inlined formatter gives the same output ( Look here:
Verified: I read the full diff (5 files, +139/−633). I grepped the workspace for every removed or narrowed item and found no outside users. I checked that the inlined formatter is the same code. Changes I made: None. Open questions: Removing public items from Auto-merge is armed, so approving sends this PR straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
This PR is an architecture refactor sweep of
crates/socket-patch-core/src/api/{blob_fetcher,date,retry,types}.rs. It works through the audit notes for those rows incoverage/files.tsvonarch-audit/ledger(discussion #1830, living document Part 4 "structure" and Part 5 "tests"). Behavior, output bytes, JSON and exit codes are unchanged.Changes
blob_fetcher.rs(prod +22/−70, test +39/−253)Inlined
format_fetch_result_forintoformat_fetch_result, its only caller. No other code called it.Removed about 40 comment lines: history (
#571), section banners, a 16-line justification of stage+rename cut to 3 lines, a 9-line doc onblob_hash_matchescut to 2, and a# Argumentsblock that restated the signature.Replaced 11 format tests with 3. Each new test compares the whole output:
format_fetch_result_lists_successes_then_failuresformat_fetch_result_without_failures: present, downloaded-only, all-skipped and mixed resultsa_failure_without_an_error_reads_unknown_errorThe deleted tests duplicated
display_id_abbreviates_only_long_blob_hashes,failures_are_listed_in_sorted_order_regardless_of_input_orderorsuccesses_and_failures_split_cleanly, or used.contains. The twoblob_hash_matchestests only exercisedeq_ignore_ascii_case. The real path is covered byblob_fetcher_edges_e2e's uppercase-hash and mismatch tests.date.rs(prod +3/−10, test +4/−15)parsed_order_is_chronological_in_both_formatsassertedsecs > prev_2822, which compares the loop's own counter with itself. I deleted that assert and renamed the testformatted_instants_parse_back_exactly_in_both_formats, which is what its remainingassert_eqs check.matchwithmap_or.apply_zone's doc, 4 test banners, and a stale "pinned by … below" note.retry.rs(prod +19/−45, test +2/−4)is_retryable_status,is_retryable_transportandparse_retry_afterpub(crate). Onlyclient.rsuses them.MAX_RETRIES_CEILINGprivate. The env doc now says "clamped to 10", andmax_retries_env_parsingassertsSome(10), so the documented value is pinned.API_CONNECT_TIMEOUTandAPI_READ_TIMEOUT. They werepubonly so thatapi_timeout_e2ecould assertconst == literal. Their values moved intoApiTimeouts::default, and their docs moved onto the fields. The e2e test is nowdefault_bounds_are_10s_connect_60s_read.ApiRetryPolicyfield docs and thedelaydoc.types.rs(test +41/−227).containschecks and round trips. The payload-deserialize tests already pin the same field names.scan --jsonwritesBatchPackagePatchesverbatim, so I replaced their serialize checks with one structured test,batch_packages_serialize_with_the_wire_keys, which compares the wholeto_value.published_at_is_per_patch_not_per_packageasserted facts about its own fixture literals. It is nowdeserializes_a_live_by_package_payloadand keeps only the asserts on the parsed values.Evidence
Each mutation below turns the named test red:
format_fetch_resultreturns""when nothing happenedformat_fetch_result_without_failuresApiTimeouts::default().readset to 61 sdefault_bounds_are_10s_connect_60s_readrename_all = "camelCase"dropped fromBatchPatchInfobatch_packages_serialize_with_the_wire_keysOther checks:
cargo clippy --workspace --all-features -- -D warningsis clean.cargo test -p socket-patch-core --lib: 6,976 pass. The 4 that fail are the known root-sandbox failures, which pass in CI:copy_treesymlinked root,vlt_healunremovable lock, and thepypi_poetryandpypi_requirementswire-failure tests.blob_fetcher_edges_e2e,api_timeout_e2eandapi_retry_e2epass.Totals
git diff --stat: 5 files, +139/−633.Not done here
Each of these would change lines that open PRs also change:
on_progress/OnProgressparameter. All production callers passNone, but the call sites are infetch_stage.rs(Sweep bun_preflight, composer_hints, context, fetch_stage #1855, next to a line it changes),repair.rs(Sweep remove.rs and repair.rs #1875) androllback.rs(Sweep hosted_unwind, lock_cli, list, commands/mod (+ rollback dead branch) #1864).BlobFetchResult.successfromerror. Its literals are infetch_stage.rstests (Sweep bun_preflight, composer_hints, context, fetch_stage #1855).OrganizationInfoandapi/client.rsnotes. That file is in One serve GET and one vendor retry loop in api/client.rs (#1869) #1870 and Build: share one test env guard in core (#1889) #1891./code-review highfindings8 findings: 4 fixed, 4 not.
Fixed:
scan --json's batch packages.Not fixed:
pubitems of the published core crate. Nothing outside the workspace is a supported consumer of these internals, and earlier sweeps (Sweep core constants.rs and utils (concurrent, durability, …) #1907, Sweep core utils http, mod and hatch #1914, Sweep json_envelope, update_notifier, main, path_scope #1967) narrowed corepubitems the same way.assert_ne!on twopublishedAtliterals checked the fixture, not the code. Thepublished_atdoc keeps the semantics.apply_zoneinline comment. The function's doc comment says the same thing (RFC 2822 §4.3 →-0000).Behavior change
None.
Risk
Low. The only non-test code changes are visibility, inlined constants and one inlined formatter. No
cfg(windows)/cfg(unix)code changed.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeQX98fpZ3NhqMfqsjr
Note
Low Risk
Changes are mostly docs, test consolidation, and crate-internal visibility; production logic paths are unchanged aside from inlining a formatter and moving timeout literals into
Default.Overview
This PR cleans up four
socket-patch-coreAPI modules (blob_fetcher,date,retry,types) plus the timeout e2e test—no intended behavior, JSON, or CLI output changes.In
blob_fetcher,format_fetch_result_foris inlined intoformat_fetch_result(its only caller), verbose comments are trimmed, and many overlapping format tests are replaced with a few whole-string assertions.In
retry, retry helpers (is_retryable_status,is_retryable_transport,parse_retry_after) becomepub(crate),MAX_RETRIES_CEILINGis private (env doc still says clamp to 10), and the publicAPI_CONNECT_TIMEOUT/API_READ_TIMEOUTconstants are removed in favor of literals onApiTimeouts::default;api_timeout_e2enow asserts those defaults directly. Module docs are shortened.In
types, redundant serde round-trip /.containstests are dropped in favor of payload-shaped deserialize tests and one structuredbatch_packages_serialize_with_the_wire_keystest forscan --jsonwire keys.date.rsgets small comment/test tidy-ups (e.g. RFC2822 prefix viamap_or, a renamed round-trip test without a bogus monotonic assert).Reviewed by Cursor Bugbot for commit 0b99f82. Configure here.
Generated by Claude Code