Repository navigation
Tracking: make CLI_CONTRACT.md a checked reference plus short prose #948
Description
[agent] Filed by the scheduled architecture audit routine (CLI and core). Register: register comment.
Kind: tracking. Source: review 8.3; 8.5 F and I; register row C33.
Problem
CLI_CONTRACT.md is the public surface's only reference, and almost all of it is checked by hand. Measured on 9c43dfc:
- Size:
CLI_CONTRACT.mdhas 1,940 lines and 379 KB. At the review's snapshot (2463257) it had 1,638 lines and 332 KB. 54 lines exceed 1,000 characters, 13 exceed 3,000, and the longest, line 166, has 11,338 characters. - History mixed into reference: 155 lines carry a
v5.0annotation and 29 aMAJOR/BREAKINGmarker. "Vendored JVM support (v5)" sits inside How the contract is enforced. - The enforcement section overstates the guard. It says every item is "locked in" by the
cli_parse_*tests. Those tests assert the parser, not the document. Only two mechanical checks read the contract at all:tests/contract_gradle_codes.rschecks the Gradle/JVM codes;scripts/tests/test_vlt_coverage.pychecks the vlt codes.
- Measured drift: about 43 code-shaped literals in
--jsonemitting positions appear nowhere in the contract (Tracking: emit every --json error code from one typed ErrorCode registry checked against the contract tables #930, An unparseable .socket/manifest.json is reported under five different --json error codes depending on the command #931). Two operator env vars read by core are undocumented (SOCKET_API_CONCURRENCY and SOCKET_WALK_THREADS are undocumented, and no test keeps core-read env vars in CLI_CONTRACT.md #678). - The argument and env-var tables have almost no drift today, but nothing keeps it that way. On a debug build, every
--longflag in the--helpof the nine visible subcommands, and every[env: SOCKET_*], was checked against Global arguments, Per-subcommand arguments and Environment variables. Every one is documented; Pin CLI_CONTRACT.md's argument and env-var tables to Cli::command() with a freshness test #949 lists two small gaps in the env-var lists. The only documented flags missing from--helpare the hidden deprecated spellings (--apply,--vendor,--no-apply) and the removed--redirect/--detached, which exit 2. Both runs gave the same result. docs/testingdoubles as test input (review 8.3).vlt-compatibility.mdtables feedscripts/check-vlt-legs.py, anddocs/testing/vlt-coverage.jsonmaps codes to Rust test function names.
Target design
- A checked reference for the parts that are mechanically derivable: commands and flags from
Cli::command(), env vars (clap-bound and the core-read registry),errorCodetables from the typed registry (Tracking: emit every --json error code from one typed ErrorCode registry checked against the contract tables #930) and exit codes. Each is either generated into the contract or pinned to it by a freshness test that fails in both directions (undocumented and phantom). - Prose that describes current behavior only, in 300 lines or less, linking to per-topic pages under
docs/for the long hosted, vendored and VEX notes. Version history moves todocs/migrating-to-v5.mdand the release notes. - Test inputs live under
tests/, and the docs are rendered from them, not parsed by them.
Children, in order
- 1. Pin the argument and env-var tables to
Cli::command()with a freshness test: Pin CLI_CONTRACT.md's argument and env-var tables to Cli::command() with a freshness test #949. - 2. Document the core-read env vars and add a registry for them, checked by the same test: SOCKET_API_CONCURRENCY and SOCKET_WALK_THREADS are undocumented, and no test keeps core-read env vars in CLI_CONTRACT.md #678.
- 3. Emit every
--jsoncode from one typed registry and check the contract's code tables against it: Tracking: emit every --json error code from one typed ErrorCode registry checked against the contract tables #930 (first child An unparseable .socket/manifest.json is reported under five different --json error codes depending on the command #931). - 4. Pin the exit-code tables (global and
vex's tri-state) to the code that returns them. Not filed yet. - 5. Move version history (
v5.0,MAJOR,BREAKINGannotations, the "Removed in" paragraphs) out of the reference intodocs/migrating-to-v5.md. Docs only. Not filed yet. - 6. Split the long per-ecosystem behavior notes (pnpm/npm/vlt hosted contracts, takeover reconciliation, vendored JVM, Gradle) into
docs/pages and cut the contract's prose to 300 lines or less. Rewrite "How the contract is enforced" to list the real guards. Not filed yet; after 5. - 7. Move
docs/testing/vlt-coverage.jsonand the leg tables' machine data totests/specs/, and render the markdown from them. Not filed yet.
Size and scope
Each child is one reviewable PR. Children 1, 2 and 4 are test plus small doc edits (≤300 lines each). Children 5 and 6 are documentation moves with no code change. Out of scope: changing any flag, env var, code or exit code (those are decisions), and CHANGELOG.md.
Acceptance criteria
- Every child is merged or closed with a reason.
-
CLI_CONTRACT.mdis 300 lines or less of prose plus checked tables, and no line exceeds 1,000 characters. - Each table in the contract is covered by a test that fails on an undocumented entry and on a phantom one.
Dependencies
Child 3 follows #930. Child 6 should follow child 5. It doesn't block other work. C13 (#930) and C40 (#678) are folded in as children.
Consolidated work — backlog review, 2026-10-08
The following standalone issues are now tracked here. Their closure consolidates scheduling; it does not mean their implementation is complete. Original reports and discussion remain linked below.
#678: SOCKET_API_CONCURRENCY and SOCKET_WALK_THREADS are undocumented, and no test keeps core-read env vars in CLI_CONTRACT.md
- Track the remaining scope from SOCKET_API_CONCURRENCY and SOCKET_WALK_THREADS are undocumented, and no test keeps core-read env vars in CLI_CONTRACT.md #678 in this issue. Keep the two missing environment-variable docs and their freshness coverage as a checklist item in the CLI contract tracker.
Preserved scope and acceptance criteria from #678
Proposed change
- Add both variables to
CLI_CONTRACT.md.SOCKET_API_CONCURRENCYgoes in the "Config-layer toggles (env-only)" table, with range, default and the0behavior.SOCKET_WALK_THREADSgoes in "Internal env vars", unless the maintainers want it public. - Add one guard test in
socket-patch-cli/tests/. It collects every"SOCKET_[A-Z0-9_]+"literal fromcrates/socket-patch-{core,cli}/src, skipping#[cfg(test)]modules or using an explicit allowlist of test hooks, and asserts that each appears inCLI_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 forSOCKET_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_VARSinvariant tests stay green.
#949: Pin CLI_CONTRACT.md's argument and env-var tables to Cli::command() with a freshness test
- Track the remaining scope from Pin CLI_CONTRACT.md's argument and env-var tables to Cli::command() with a freshness test #949 in this issue. Explicit CLI-contract freshness-test child; track it inside the parent documentation-contract work.
Preserved scope and acceptance criteria from #949
Proposed change
Add crates/socket-patch-cli/tests/contract_cli_tables.rs, modelled on contract_gradle_codes.rs. It walks socket_patch_cli::Cli::command(), including hidden arguments, and checks:
-
Every non-hidden subcommand appears in the Subcommands table, with its visible aliases.
-
Every global argument (those on
GlobalArgs) has a Global-arguments row naming its--long, its-shortwhen it has one, and itsenvwhen it has one. -
Every local argument of each subcommand appears in backticks in a Per-subcommand row whose first cell names that subcommand. Hidden deprecated spellings must appear too, so their mapping stays documented.
-
Every clap
envbinding appears by its full name in the Environment-variables section. Today four don't. TheSOCKET_VEXrow abbreviatesSOCKET_VEX_PRODUCT,SOCKET_VEX_NO_VERIFY,SOCKET_VEX_DOC_IDandSOCKET_VEX_COMPACTas "theSOCKET_VEX_*knobs (_PRODUCT, …)", and they are spelled out only in the per-subcommand table. Give each one a row. -
Reverse direction: every backticked
--flagin those tables either exists inCli::command()or is on a short explicit list of removed spellings that the test asserts clap rejects (today--redirectand--detached). -
GLOBAL_ARG_ENV_VARS∪LOCAL_ARG_ENV_VARSequals the set of clapenvbindings (hidden subcommands included), so the scrub list can't fall behind the parser. This fails today:scan's clap-boundSOCKET_NO_SOCKET_YMLis in neither list.SOCKET_MIN_SEVERITYis read by scan itself, not by clap, although its help text carries a hand-written[env: SOCKET_MIN_SEVERITY]. It is in neither list either.- So the
with_env_clearedharness clears neither one, and an ambientSOCKET_NO_SOCKET_YML=1can leak into the in-process scan tests that rely on that harness. - An exported-but-empty value is harmless, because both parsers treat empty as unset (checked twice on a debug build).
Add
SOCKET_NO_SOCKET_YMLtoLOCAL_ARG_ENV_VARS. Have the test also require the help-text-only[env: …]names to be on the harness list, soSOCKET_MIN_SEVERITYjoinsLOCAL_ARG_ENV_VARStoo.
Also replace the "How the contract is enforced" bullet that says the parser snapshots lock flag names with one that names this test. Nothing is deleted. Generating the tables is a possible later step; this child only pins them.
Size and scope
One new test file (~200 lines), a line or two in args.rs and a few lines in CLI_CONTRACT.md. Out of scope: core-read env vars (#678), error codes (#930) and exit codes (a later child of #948). It changes no flag, env var or default.
Acceptance criteria
-
cargo test -p socket-patch-cli --test contract_cli_tablespasses onmain. - Removing any row from one of the three tables, or adding a
#[arg(long)]field without documenting it, makes the test fail with a message naming the flag or variable (check locally once each way). - The existing
cli_parse_*,cli_global_argsandhelp_text_hygienetests stay green. - The only production change is the added
LOCAL_ARG_ENV_VARSentries.
Activity
audit-core: C33 tracking #948 + child #949; re-measure Part 8
Re-rank refactor queue (capacity full)