Repository navigation
WIP: redundancy cleanup B+C — dead machinery removal and copy convergence - #1429
Merged
Merged
Conversation
…late with zero consumers Redundancy audit R3: ConstexprMap/make_constexpr_map were defined in src/container/constexpr_map.cppm and re-exported by container.cppm, but a repo-wide grep over src/ + tests/ finds no instantiation or reference outside the definition file and the aggregator (unlike small_vector, which has dozens of consumers). Uninstantiated, it cost no runtime, but every TU importing container parsed the template and the tree carried it like a live subsystem. Remove the partition file, its export from container.cppm, and its entry in the per-command executable source list (the winuxcmd-commands target globs src/**/*.cppm, so it needs no list edit).
…in every built layout)
Redundancy audit R2: dir and vdir each carried a full external fallback
(build_*_command_line quoting + resolve_child_command execvp-semantics
resolution + CreateProcessW of an external ls.exe) behind
!CommandRegistry::hasCommand("ls").
That condition cannot fire in any layout this tree builds:
- The only multiplexer image is winuxcmd.exe, which links the
winuxcmd-commands static library built from a glob of ALL
src/commands/*.cpp (CMakeLists.txt:386,412); ls.cpp's REGISTER_COMMAND
is therefore always in the same image as dir/vdir.
- The per-command standalone-executable macro that could have produced a
split-applet dir.exe (CMakeLists.txt:564) is defined but never invoked.
- Shipped layouts (usr\\bin hardlinks, wpm shim layout) all run that same
multiplexer image.
Reachable behaviour is unchanged: the in-process dispatch path is
untouched. The unreachable branch keeps the fallback's failure shape
("dir: failed to execute ls" / exit 1) instead of the spawn machinery.
…e of truth in core
Redundancy audit R1: the 8-name literal-argument set {echo, yes, test, [,
true, false, printf, expr} was hand-copied in two places - main.cpp's
top-level --version pre-scan and dispatcher.cppm's abbreviation-expansion
exclusion - kept in sync only by a comment. The copies already drifted
once: #1215 (main's copy missed "expr").
core:dispatcher now owns the table behind the exported
is_literal_arg_command(); both consumers call it. The sets were
byte-identical at convergence time, so behaviour is unchanged; the
#1215 history moves into the shared function's comment so the next
addition edits exactly one table.
…ne shared helper on ctx.raw_args Redundancy audit R5: diff (diff_command_tail), diff3 and sdiff (two verbatim-identical last_raw_argument lambdas) each re-ran CommandLineToArgvW on GetCommandLineW() to rebuild operand text GNU echoes in -r/-l headers and in "missing operand after '%s'" - even though the dispatcher already parsed the same command line and hands it to every command as ctx.raw_args, with argv[0] and the multiplexer verb token already dropped (exactly the tokens the three copies dropped by hand). One shared implementation now lives in diff_engine.h (the header all three already include): command_tail_from_raw_args and last_raw_argument, both computed from the raw_args span. Behaviour on both entry forms (multiplexer verb and <command>.exe hardlink) is identical by construction; under a host process (FFI DLL form) the old code read the host's command line, the new code reads the command's own arguments.
… live function remains Redundancy audit R4: utils:path re-exported the native_path surface under shorter names. Per-function consumer grep over src/ + tests/ (qualified path:: calls, no using-directive for the namespace exists anywhere in the tree): zero call sites: normalize_path, get_parent_path, get_filename, get_stem, get_extension, exists, is_directory, is_regular_file, create_directory, create_directories, current_path, current_path_w, get_executable_path, join (both overloads each) - 24 of 25 exports. The tree had already voted with its feet: applets call native_path:: directly (normalize_api_operand / make_api_path_operand alone have 250+ call sites). sole live export: get_executable_name (src/Main/main.cpp:514). The 24 dead wrappers are deleted; the partition keeps the one live function. Callers of the removed names would not compile - the grep above is the proof there are none.
…red/argv_adapters.h) Redundancy audit R6: the argv-adapter rule (awk/gawk payloads get " -v BINMODE=3" spliced ahead of their arguments, niubash#467) was hand-copied in two binaries that cannot share a module: the package shim kept a wide-char table (kArgvAdapters), the multiplexer rewrote the same rule in narrow char (opt_forward_argv_prefix), and each file's comment pointed at the other as the copy to mirror. The table and both width lookups now live once in src/shared/argv_adapters.h, which both files include; the full BINMODE rationale moved into that header, and each consumer keeps a pointer comment. The prefix bytes and the name set are unchanged. One theoretical delta, noted for the record: the shim's old lookup lowered the payload name with towlower, under which a name containing U+212A (KELVIN SIGN) would fold to 'k' and could match "awk"; the shared lookup is ASCII case-insensitive, so such a name no longer matches. No real payload name contains a Kelvin sign.
…adapter name set Follow-up to the previous commit, found by its residue grep: src/commands/wpm.cpp kept its own spelling of the same fact (lowered == "awk" || lowered == "gawk"), with a comment saying it mirrored the shim table and main's helper. It now asks the shared table in src/shared/argv_adapters.h like everyone else, so the awk/gawk set exists exactly once in the tree.
…e consumer was its own demo) CI configure caught what the audit's src/+tests/ grep scope missed: examples/container/constexpr_map_example.cpp did instantiate make_constexpr_map, and examples/container/CMakeLists.txt compiled the partition into its demo library. That does not make the template a live subsystem: the example exists solely to demonstrate ConstexprMap - it is part of the dead apparatus, not a consumer of it (same shape as a dead feature kept alive only by its own tests). No product target, command, or test references it. Remove the example file and its CMake entry together with the partition, and record the correction here and in the PR body: the audit's 'zero consumers' held for src/ + tests/; the examples/ demo was the one exception, removed with its subject.
…annot textually include <string_view> Windows CI (run 40693168816) failed in the winuxcmd-commands unity TU: once any amalgamated file has done `import std`, a later textual <string_view> include (pulled in by argv_adapters.h through wpm.cpp) redefines the std module's entities (C2953/C2371 cascade in iosfwd). This tree's command TUs take std from the PCH + `import std` only - project headers like diff_engine.h include nothing but pch/pch.h. The shared header now speaks plain C types: table entries are const char*/const wchar_t*, lookups take (pointer, length) and return const wchar_t* or nullptr. It includes only <stddef.h>. The three callers pass .data()/.size() and wrap the pointer. Semantics unchanged; the header's comment records why the API looks this way. (main.cpp's TU had compiled with the std:: API - it is not unity-built - but all three consumers now use the one safe form.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redundancy cleanup from the 2026-10-28 three-repo redundancy audit (WinuxCmd REPORT items R1–R6), classes B (dead machinery) + C (hand-copied duplicates), user-ruled for construction on 2026-10-28. Freeze exception by the user's direct order. Draft — not to be merged from the cluster side; the merge gate is this PR's Windows CI, now green (see CI accounting).
One commit per item. Net: +175 / −489 across 15 files (plus the B1b example removal).
B1 —
container:constexpr_mapdeleted (audit R3)171-line exported template (
ConstexprMap,make_constexpr_map); repo-wide grep over src/ + tests/ found zero instantiations outside the definition file and thecontainer.cppmaggregator (contrastsmall_vector: dozens of consumers). Removed: the partition file, itsexport importline, and its entry in the per-command executable source list (the winuxcmd-commands target globssrc/**/*.cppm, no list edit needed there).Correction to the audit premise, caught by CI: the audit's "zero consumers" scope was src/ + tests/.
examples/container/constexpr_map_example.cppdid instantiate it andexamples/container/CMakeLists.txtcompiled the partition — first CI run failed at configure on exactly that. The example exists solely to demonstrate the template, i.e. it is part of the dead apparatus rather than a consumer of it (same shape as a dead feature kept alive only by its own tests). Removed together with its subject in commit B1b; full-tree grep forConstexprMap|constexpr_map|make_constexpr_mapis now zero hits.B2 — dir/vdir external-spawn
lsfallback deleted (audit R2)Each file carried ~65 lines of fallback behind
!CommandRegistry::hasCommand("ls"): command-line quoting builder +resolve_child_commandexecvp-semantics resolution +CreateProcessWof an external ls.exe.Unreachability evidence chain, re-verified at this tip (d28a920):
src/commands/*.cpp(CMakeLists.txt:386, 412) —ls.cpp'sREGISTER_COMMANDis always in the same image as dir/vdir.create_command_executable, CMakeLists.txt:564) is defined but never invoked.Reachable behaviour unchanged (the in-process dispatch path is untouched); the unreachable branch keeps the fallback's failure shape (
dir: failed to execute ls, exit 1) minus the spawn machinery.C1 — literal-argument command table: one source of truth (audit R1)
The 8-name set
{echo, yes, test, [, true, false, printf, expr}was hand-copied insrc/Main/main.cpp(top-level--versionpre-scan) andsrc/core/dispatcher.cppm(abbreviation-expansion exclusion), synced only by a comment; it already drifted once (#1215: main's copy missedexpr).core:dispatchernow owns the table behind the exportedis_literal_arg_command(); both consumers call it. Post-change grep:kLiteralArgCommandsexists exactly once in the tree.Before/after, same input (code walk): the two tables were byte-identical at convergence time, so
winuxcmd expr 1 --version,winuxcmd printf '%s\n' --version,expr --heletc. take the same branches before and after — now by construction rather than by copy discipline. Corroboration: full ctest + GNU master differential both green (below).C2 — diff family: one raw-args helper, no more re-parsing the process command line (audit R5)
diff's
diff_command_tail(), diff3's and sdiff'slast_raw_argument()lambdas (the latter two verbatim duplicates) each re-ranCommandLineToArgvW(GetCommandLineW())to rebuild operand text — although the dispatcher already parsed the same command line and hands it to every command asctx.raw_args, with argv[0] and the multiplexer verb token already dropped (exactly the tokens the three copies dropped by hand).One shared implementation now lives in
diff_engine.h(already included by all three):command_tail_from_raw_argsandlast_raw_argument, computed from the raw_args span.CommandLineToArgvWno longer appears in any of the three files.Before/after, same inputs (code walk):
winuxcmd diff -r a b→ old tail tokens[−r, a, b]after hand-dropping the verb, new tail from raw_args[−r, a, b]→ identical"diff -r a b";diff3 x(missing operand) → old last tokenx, newraw_args.back()=x; empty-args → program name in both. Side benefit: under a host process (FFI DLL form) the old code read the host's command line; the new code reads the command's own arguments. The two helpers were also extracted verbatim from the header and logic-tested under g++ (−Wall −Wextra −Werror): tail join, empty-args, last-arg and fallback cases all pass.C3 —
utils:pathdead exports deleted (audit R4)Per-function consumer grep over src/ + tests/ (qualified
path::calls; nousing namespace pathexists anywhere in the tree):normalize_path,get_parent_path,get_filename,get_stem,get_extension,exists,is_directory,is_regular_file,create_directory,create_directories,current_path,current_path_w,get_executable_path,join(both overloads each where present).get_executable_name—src/Main/main.cpp:514.The tree had already voted with its feet: applets call
native_path::directly (normalize_api_operand/make_api_path_operandalone have 250+ call sites). Any caller of a removed name would fail to compile; the grep is the proof there are none. The partition remains as a one-function shell (full retirement — foldingget_executable_nameinto native_path — is a possible follow-up, out of this batch's scope).C4 — argv adapter table: one shared header (audit R6) — and a third copy the audit missed
The awk/gawk →
-v BINMODE=3rule (niubash#467) was hand-copied per binary: wide-char table in the shim (kArgvAdapters), narrow rewrite in the multiplexer (opt_forward_argv_prefix), each pointing at the other in comments. The table + both-width lookups now live once insrc/shared/argv_adapters.h; the BINMODE rationale moved into that header; consumers keep pointer comments.Residue grep after the first convergence found a third copy the audit had not catalogued:
wpm.cpp'sopt_forward_adapted()hardcodedlowered == "awk" || lowered == "gawk"with a "mirrors…" comment. It now queries the shared table too (commit C4b). The awk/gawk adapter set now exists exactly once in the tree (remaining"awk"hits in find.cpp are-printfformat-style names, unrelated).Before/after, same input: table contents byte-identical (
awk,gawk→L" -v BINMODE=3"), ASCII case-insensitive matching at all three sites; the header was logic-tested under g++ (−Wall −Wextra −Werror) in both API forms: exact/case-variant matches, non-matches, empty name, and prefix-truncation (awkxwith length 3 matches, with length 4 does not) all pass. One theoretical delta, noted for the record: the shim's old lookup lowered withtowlower, under which a payload name containing U+212A (KELVIN SIGN) would fold tokand could matchawk; the shared lookup is ASCII-only, so such a name no longer matches. No real payload name contains a Kelvin sign.Implementation lesson from CI (commit C4c): the header's first form used
std::string_view, and wpm.cpp's textual include of it inside the unity-built commands TU — after other amalgamated files had doneimport std— redefined the std module's entities (C2953/C2371 cascade). This tree's command TUs take std from the PCH +import stdonly. The header therefore speaks plain C types (pointer + length in,const wchar_t*or nullptr out, only<stddef.h>included); callers pass.data()/.size().Explicitly out of scope (per the ruling)
classify_args_for_dispatchdual getopt walk — audit item P1, undecided class, not approved.No user-visible message text is added, removed, or altered by any commit → no i18n catalog impact (AGENTS.md sync rule not triggered).
CI accounting
examples/container/CMakeLists.txtreferenced the deleted partition. Fixed by B1b.<string_view>(see C4c). Fixed by the std-free header.