Repository navigation
test(cli): parse suites onto hermetic::try_parse (T56) - #1978
Conversation
Assisted-by: Claude Code:claude-opus-5-5
The cli_parse_* suites and cli_global_args kept four ways to keep ambient SOCKET_* vars out of a parse: four copies of EnvScrub with drifted hand lists, scan's with_clean_env, global_args' save/restore, and nothing at all in list, remove and main (SOCKET_JSON=true failed them). Every parse now goes through hermetic::try_parse, which drops every SOCKET_* var once per process. Tests that set a var use the new common/clap_parse.rs try_parse_with_env and stay #[serial]; get, list, remove and main need no #[serial] at all. The four hand Snap mirrors of GlobalArgs (get and repair missed four fields, vendor nine, vex one) are replaced by one hand-written GlobalArgs literal compared through Debug, so a new global field fails to compile instead of going unchecked. The scrub self-tests, which only tested the deleted lists, are gone. Fixes #1956 Assisted-by: Claude Code:claude-opus-5-5
cli_parse_list and cli_parse_remove call list::run and remove::run in-process on parallel threads. The once-per-process SOCKET_* scrub removed SOCKET_TELEMETRY_DISABLED and SOCKET_NO_CONFIG under them, so those runs could read a developer's socket login and send telemetry. Their parses now go through try_parse_keeping_opt_outs, which keeps and forces hermetic::FORCED_OPT_OUTS on; their default oracle expects no_telemetry true accordingly. cli_global_args' last hand set_var/remove_var pairs move onto try_parse_with_env, so a failed assert no longer leaks a var into later tests, and scan's defaults test compares the whole GlobalArgs against the shared oracle. Assisted-by: Claude Code:claude-opus-5-5
|
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 c211c60. Configure here.
Assisted-by: Claude Code:claude-opus-5-5
|
Ready for review at
Slack announcement didn't go out this run (the Slack send tool wasn't available), so the next run will retry it. Generated by Claude Code |
Final review briefWhat it does: Test-only refactor. Replaces four drifted per-suite Risk: low. It only touches Look here
Verified
Non-blocking notes
Auto-merge is armed, so approving sends it straight to the merge queue. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed c211c60a5a4f735d800865304fe05fb54eb59bdc. Checked hermetic parser initialization, serialized env tests, explicit defaults and whole-argument snapshots. No major correctness issues found. Validation: source and regression-test review plus the available exact-head CI checks; no local test pass is claimed.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1956
Test-only. This implements register row T56 (living document Part 5, tests). Each
cli_parse_*suite andcli_global_argskept the developer's ambientSOCKET_*env out of its parses in its own way:EnvScrubcopies, each with a drifted hand list;with_clean_env;cli_global_args'save_and_clear_global_env;main,SOCKET_JSON=truefails 2 remove tests and 1 list test.Separately, four hand
Snapmirrors ofGlobalArgseach claimed to cover "every parsed field". get and repair missed 4 fields, vendor missed 9 and vex missed 1.Changes
common/hermetic.rstry_parse, which removes everySOCKET_*var once per process.common/clap_parse.rs:try_parse_with_envsets the given vars for one parse and removes them after. It replaces vendor'sparse_vendor_with_envbody, vex'sparse_with_env, scan'sparse_scan_with_envbody, and the handset_var/remove_varblocks in repair andcli_global_args.try_parse_keeping_opt_outsis for list and remove. Those binaries also calllist::run/remove::runin-process on parallel threads, so their scrub keepshermetic::FORCED_OPT_OUTS(SOCKET_NO_CONFIG,SOCKET_NO_UPDATE_CHECK,SOCKET_TELEMETRY_DISABLED) and forces them on. Without that, thoserun()calls could read a realsocket loginand send telemetry;/code-reviewcaught this. As a result their parses expectno_telemetry: true.global_defaults()is a hand-writtenGlobalArgsstruct literal, the independent default oracle. A new global field fails to compile there until its default is written.GlobalscomparesGlobalArgsthroughDebug.EnvScrubstructs and their 4 handSOCKET_ENV_VARSlists;SCAN_ENV_VARSandwith_clean_env;save_and_clear_global_env/restore_global_env;snap, used only by its self-test.Snapmirrors keep their command-local fields pluscommon: Globals, so every global field is compared.Snaphad been used only by its scrub test. Its 5 vex-command tests now compare whole snapshots instead of one field each.no_vlt_install_cleanuptests in get, repair, vendor and vex are now whole-snapshot comparisons.cli_global_argscompare the wholeGlobalArgsagainst the oracle instead of a hand-picked subset.#[serial]: 150 → 105.vendor_appears_in_subcommand_list.cli_global_argskeep#[serial]on every parsing test, because some tests in each binary set aSOCKET_*var and clap reads env during every parse. The issue suggested dropping these too, but that would race.Evidence
SOCKET_JSON=true SOCKET_YES=true SOCKET_STRICT=garbage cargo test -p socket-patch-cli --test 'cli_parse_*' --test cli_global_args: all 11 suites pass (321 tests). Onmainthis fails remove and list.rg 'struct EnvScrub|SOCKET_ENV_VARS' crates/socket-patch-cli/testsfinds nothing.--maven-config nonetoget'slong_yes_sets_yesand leftwantunchanged. It fails now (cli_parse_get.rs:131), and it passes onmain.cargo clippy --workspace --all-features -- -D warningsis clean.cargo clippyover the 11 test targets with-D warningsis clean too.Size
+418 / −1,471, all test code; 0 production lines.
Behavior change
None. The diff touches only test code.
Risk
Low. Only test code changes, and no
cfg(windows)/cfg(unix)code is touched. One thing to know:hermetic.rsis also changed by #1964. This PR doesn't edit it; it only callstry_parse,scrub_process_socket_envandFORCED_OPT_OUTS, which #1964 keeps./code-review high
9 findings. 6 are fixed:
cli_global_argshand set/remove that leaked a var on a panic (2);///(1).3 are not fixed:
Globalscompares viaDebuginstead of a derivedPartialEqonGlobalArgs.src/args.rsis held by Sweep cli args.rs: inline, dedupe tests, trim docs #1842. A derive can replaceGlobalsafter Sweep cli args.rs: inline, dedupe tests, trim docs #1842 lands.min_severitytest setsSOCKET_MIN_SEVERITYby hand aroundoverrides(), which reads env at run time. It leaks only ifoverrides()itself panics.Oncescrub clears ambient values. The hostile-env run above is that check. A per-binary tripwire would just be the deleted self-tests again.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeSfv2chfPtLgeW8LYF
Note
Low Risk
Changes are confined to test code under
socket-patch-cli/tests; no production CLI behavior is modified.Overview
CLI parser contract tests no longer scrub
SOCKET_*env vars per file.cli_global_argsand allcli_parse_*suites now route parses throughcommon/hermetic::try_parse(process-wide scrub) and the newcommon/clap_parse.rshelpers.Added shared helpers:
try_parse_with_envfor env-binding tests (replaces handset_var/remove_varand duplicateEnvScrub/with_clean_env/save_and_clear_global_env);try_parse_keeping_opt_outsfor list and remove, which also callrun()in-process and must keepFORCED_OPT_OUTS(so defaults assertions expectno_telemetry: true);global_defaults()plus aGlobalswrapper for fullGlobalArgssnapshot compares.Removed: four copy-pasted
EnvScrublists, scan’sSCAN_ENV_VARS/with_clean_env, global save/restore helpers, and six “scrub list completeness” self-tests. Snapshot structs nest globals undercommon: Globalsinstead of flattening incomplete hand mirrors.Test hygiene: many
#[serial]attributes drop where parses no longer mutate env (e.g.cli_parse_get); suites that still set env during parse stay serial.cli_parse_mainscrubs beforeparse_argv_with_shortcuts. Default/regression checks compare the whole global surface to the oracle rather than cherry-picked fields.Reviewed by Cursor Bugbot for commit c211c60. Configure here.
Generated by Claude Code