Skip to content

SOCKET_API_CONCURRENCY and SOCKET_WALK_THREADS are undocumented, and no test keeps core-read env vars in CLI_CONTRACT.md #678

Description

[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: register comment.

Kind: refactor (docs + guard test). Source: new finding; register row C40. It is related to review 8.5 F (generated contract) but narrower.

Problem

Two operator-facing environment variables that core reads appear in no documentation at all: not in CLI_CONTRACT.md, the README or docs/.

Its sibling knob SOCKET_API_MAX_RETRIES is documented (CLI_CONTRACT.md#L141). The difference is a guard: GLOBAL_ARG_ENV_VARS and LOCAL_ARG_ENV_VARS (args.rs#L580-L631) and their invariant tests cover only clap-bound variables. Variables that core reads directly through std::env::var have no check, so each one is documented, or not, by hand.

Evidence by execution on 045d7ec, run twice: every "SOCKET_*" literal under crates/socket-patch-{core,cli}/src was checked against CLI_CONTRACT.md. 84 names, 16 missing:

  • the two above, which are operator-facing;
  • 14 test-only hooks (SOCKET_PATCH_FAILPOINT, SOCKET_PATCH_SWITCH_OFF, SOCKET_TEST_PEER_*, *_GOLDEN, *_FSIZE_CHILD, and SOCKET_PATCH_GIT_SHA/SOCKET_PATCH_TARGET, which are build-time env!).

The reverse check finds no phantoms: the four contract-only names are the documented v5.0 removals.

The knobs also disagree on 0: SOCKET_API_MAX_RETRIES=0 disables retries, SOCKET_API_CONCURRENCY=0 is ignored with a --debug note, and SOCKET_WALK_THREADS=0 silently keeps the default. That vocabulary is C19's to unify; this issue only documents current behavior.

Symptoms

#614 (the knob is unreachable for anyone who hasn't read the source). Impact: low risk, small size. Operators behind rate-limiting proxies can't discover the supported throttle.

Proposed change

  1. Add both variables to CLI_CONTRACT.md. SOCKET_API_CONCURRENCY goes in the "Config-layer toggles (env-only)" table, with range, default and the 0 behavior. SOCKET_WALK_THREADS goes in "Internal env vars", unless the maintainers want it public.
  2. Add one guard test in socket-patch-cli/tests/. It collects every "SOCKET_[A-Z0-9_]+" literal from crates/socket-patch-{core,cli}/src, skipping #[cfg(test)] modules or using an explicit allowlist of test hooks, and asserts that each appears in CLI_CONTRACT.md. It should also assert the reverse for names outside the "Removed env vars" section.

This deletes nothing. It is the env-var slice of 8.5 F and needs no generator.

Size and scope

CLI_CONTRACT.md (+2 rows) and one new test of about 60 lines. Out of scope: renaming or re-parsing any variable (C19, #615).

Acceptance criteria

  • grep -c SOCKET_API_CONCURRENCY crates/socket-patch-cli/CLI_CONTRACT.md ≥ 1, and the same for SOCKET_WALK_THREADS.
  • The new guard test fails if a new std::env::var("SOCKET_NEW_KNOB") is added to core without a contract row. Check this locally once.
  • The existing GLOBAL_ARG_ENV_VARS/LOCAL_ARG_ENV_VARS invariant tests stay green.

Dependencies

None. Related: C19 (env vocabulary), C33 (generated contract) and #614.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent: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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions