Repository navigation
Open
Labels
agent:claimedagent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)priority:p3refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code
Description
[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register comment.
Kind: refactor. Register ID: T55 (follows T51/#1941, which covers tests/apply).
Problem
Suites that already include tests/common still keep their own copies of its helpers:
has_command, 9 copies besidecommon::has_commandL57:e2e_npm.rsL42,e2e_gem.rsL47,e2e_scan.rsL66,e2e_hosted_production.rsL275,e2e_vendored_production.rsL291,e2e_redirect_rush_sim.rsL97,e2e_redirect_yarn_berry_build.rsL118,e2e_yarn4_pnpm_linker_build.rsL113,e2e_yarn4_workspaces_build.rsL113. The common one has 2 users.sha256_hex, 16 copies besidecommon::sha256_hexL136, e.g. e2e_redirect_cargo_build.rs L135,``mode_migration_cargo.rsL128, `e2e_vex_lockfile/{maven,nuget,poetry,uv}.rs`, `maven_build_common`, `hosted_maven_common`, `vlt_e2e_common`, `jvm_fixture_repo`. `update_fixture::sha256_file` and `update_fixture::real_binary` duplicate `sha256_hex` and `oracle::binary` too.git_sha256_fileandassert_run_ok, 4 copies each, andnpm_run, 3 copies, ine2e_npm,e2e_gem,e2e_scanande2e_pypi: the filescommonwas extracted from.common::npm_runandcommon::env_maphave 0 users.stderr_chatter, 5 byte-identical copies (md5 equal):cli_apply_silent.rsL49-L59,cli_scan_silent.rsL69,apply/apply_silent_staging_errors.rsL30,rollback/cli_rollback_silent.rsL43,vendor/vendor_silent_errors.rs. The same filter is also inlined 6× incli_remove_silent.rs(L77-L84). The filter is dead:--silentmutes theSOCKET_API_TOKENnotice in core (utils/notice.rsL51-L58). Removing the clauses leaves all tests green incli_apply_silent(7),cli_scan_silent(6) andcli_remove_silent(10) (executed). So it should be deleted, not centralised: it can only hide a regression.rollback_jsonre-implementsenvelope:events(L16-L21),```warning_codes(L162), `events_with_mode` (= `envelope::mode_events`) and `assert_rollback_envelope` L174-L199.```` The last has drifted from `envelope::assert_envelope_invariants` L193: it requires `skipped ==` the event count where envelope allows `<=`, accepts 3 statuses instead of 10, and skips the `error`/`dryRun` checks. 20 of its 22 includers already have `common::envelope`.
Proposed change
- Delete the local
has_command,sha256_hex,git_sha256_file,assert_run_okandnpm_runcopies and callcommon::*. For files that don't includecommon/mod.rs(e.g.docker_e2e_pypi), includecommon/oracle.rs, or movesha256_hexthere. - Delete
stderr_chatterand the inline filter. Assert directly onstderr. - Make
rollback_jsonre-exportenvelope::{events, warning_codes, mode_events}. Expressassert_rollback_envelopeasassert_envelope_invariants(v, "rollback")plus its rollback-only checks. - Delete the dead
common::env_mapandupdate_fixture::{raw_asset, delay_asset}.
Size
About 35 test files. About −400 / +30 lines, all mechanical.
Acceptance criteria
grep -rn "fn has_command\|fn sha256_hex\|fn stderr_chatter" crates/socket-patch-cli/testsfinds only thecommondefinitions.- Every suite stays green. Any rollback test that fails under
assert_envelope_invariantsis a real envelope finding, to be reported, not masked.
Metadata
Metadata
Assignees
Labels
agent:claimedagent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)priority:p3refactorStructural change: duplicated code or logic, missing abstraction, layering, dead code
Activity
mikolalysenko commentedon Nov 1, 2026
[agent] Triage:
priority:p3(test-only helper reuse). No duplicate or open PR found. Follows #1941 (tests/applyfixtures, open PR #1944), which does not cover these suites.Generated by Claude Code
mikolalysenko commentedon Nov 25, 2026
[agent] Claiming this for the architecture refactor routine (highest-scoring free structural item; test-only, low risk). Branch: arch-refactor/1959-test-common-helpers. Claim-ID: 2026-11-25T14:59:42Z-205b3d
First slice: the
has_command,sha256_hex,git_sha256_file,assert_run_ok,npm_runandstderr_chattercopies plus the deadcommonhelpers, skipping files that open PRs change (e2e_bazel_build/*,e2e_redirect_gem_build.rs,maven_build_common,rollback/cli_rollback_silent.rs). Therollback_jsonstep waits for a later slice.Generated by Claude Code
mikolalysenko commentedon Nov 25, 2026
[agent] Slice 1 is #2241. It deletes 6
has_command, 4git_sha256_file, 9sha256_hexand 4stderr_chattercopies, plus the deadcommon::{env_map, npm_run}andupdate_fixture::{raw_asset, delay_asset}.What remains:
rollback/cli_rollback_silent.rs(stderr_chatter) ande2e_redirect_gem_build.rs(sha256_hex), once the open fixer PRs that change them land. The same goes fore2e_bazel_build/*andmaven_build_common/.sha256_hexin the shared modules that don't includecommon(vex_pypi_real_common,vex_pipenv_pip_real,hosted_maven_common,jvm_fixture_repo,e2e_artifactory_mirror): move it tocommon/oracle.rsand re-export it there.npm_run/assert_run_okine2e_npm/e2e_scan/e2e_gem/e2e_pypi. Each localassert_run_okwraps the file's ownrun, and the localnpm_runstripsSOCKET_*, whichcommon::run_toolchaindoesn't. Sorun_toolchainneeds the strip first.rollback_json→envelope(step 3).cli/shared_helper_copies.rstohas_command/sha256_hex.A pre-existing problem /code-review turned up, not changed by #2241:
common::has_commandprobes withCommand::new(cmd), nothermetic::tool_command(cmd). On Windows thenpm/yarn/corepack.cmdshims therefore read as missing, soe2e_scan'srequire_npmpanics and the other suites skip. The rush suites' private copies already usetool_command.Generated by Claude Code