Repository navigation
WIP: 2036 S3 dispatch tables project from the registry + KD-2 source alignment - #2080
Conversation
…KD-2)
GNU's special-builtin table is name-based: special_builtins[]
(builtins/mkbuiltins.c:148-154) lists 16 names with `source`
included as the synonym spelling of `.`, and the SPECIAL flag is
applied by name wherever it appears (mkbuiltins.c:819-820). The
executor's is_posix_special_builtin named only 15 — the registry's
SPECIAL_BUILTINS (S2, report side) already had 16 — so in POSIX
mode the `source` spelling escaped every execution-side special
treatment its synonym got:
- defining `source() { ...; }` was accepted where `.` errors
fatally ("`source': is a special builtin", exit 2;
function_calls.rs definition gate);
- a pre-defined `source` function shadowed the builtin at the
simple-command face (execute_cmd.c:4657-4676: special builtins
are found before functions) while `.` was precluded;
- a failed readonly assignment before `source` merely discarded
the list where before `.` it exits the shell
(execute_cmd.c:4693 tempenv arm, subst.c:11169-11180);
- assignment persistence (execute_cmd.c:4893) was held up by a
one-off `|| command == "source"` workaround in
variable_state::keeps_temporary_assignments.
Fix: add `source` to the predicate (single classification
point), flip the registry row's function_shadow to
PosixSpecialBlock, remove the variable_state workaround, and
move the two registry pins that carried the difference at
exactly {"source"} (now: sets equal, 16 names). Behavior pins in
tests/issue2036_s3_posix_source_special.rs run both spellings
through definition rejection, invocation shadowing, assignment
persistence, readonly fatality and the missing-file matrix, all
with GNU bash 5.3.20 expectations measured by script-file
probes.
Refs #2036.
#2036 S3) The four hand-maintained dispatch matches (audit M3-M6: command_dispatch_primary, command_dispatch_late, command_no_alias, command_no_alias_late) now take their name sets from the single registry: command_registry gains a typed slot table per entry (PRIMARY_DISPATCH / LATE_DISPATCH / CMD_PRIMARY_DISPATCH / CMD_LATE_DISPATCH — each entry's claim set, sorted for binary search) and the four dispatch functions match on slots instead of string literals. Every per-name body moved verbatim, and the match-arm order is preserved where it is semantic: - the late table's function guard arm keeps its position between the ordinary slots and the hidden fast-path slots (uname/arch/stty, rubash#154) — a function still wins over the hidden claims and loses to the ordinary builtins at this layer, exactly as before; - the per-arm `enable -n` checks (audit R4) stay per-arm, inside the bodies; - `sudo` is not a registry claim (host elevation capability, issue #759): its cfg(windows) handler check becomes an explicit pre-check ahead of the table in the primary and `command` tables, with the historical fall-throughs (Ok(None) / late-table external) preserved; - the late table's `((` arm is the tables' single unregistered entry — a parser pseudo-word, not a claimable name — and is listed as such in the pin. Performance contract (audit §5 C1/C2): the tables are const slices of plain data; lookup is one binary search over at most 43 short strings (the builtin_names shape). No runtime-mutable registry, no locks, no hash maps, no added syscalls; the stand-down judgment is untouched. The T7 consistency pin is reworked accordingly: equality is now proven on the dispatch data itself (table names == row claims per entry, sortedness, the hidden-slot set == HiddenFastpath rows), and the old source scan survives as a one-directional shadow-arm guard (a dispatch file may not reintroduce a claim its entry does not project). The S1 probe battery passes 20/20 with expectations unchanged. Refs #2036.
|
S3 cluster final state (main-session merge adjudication): CI: all green on head Local gates (build slot): Two items for the main session (full text in the cluster REPORT §3/§5):
|
WIP: #2036 S3 — four dispatch tables project from the single registry; KD-2 execution side closed
Refs #2036. Does not close it (S4–S6 remain). Base: master
b587937f(S1 #2050 + S2 #2075 in).Item 1 — the four dispatch tables project from the registry (behavior-preserving)
command_registrygains one typed slot table per dispatch entry (PRIMARY_DISPATCH/LATE_DISPATCH/CMD_PRIMARY_DISPATCH/CMD_LATE_DISPATCH— each is its entry's registry claim set, sorted const data), and the four dispatch functions (command_dispatch_primary,command_dispatch_late,command_no_alias,command_no_alias_late) match on slots instead of string literals. Lookup is one binary search over ≤43 short strings (thebuiltin_namesshape): const data only — no runtime-mutable registry, no locks/hash maps, no added syscalls, stand-down judgment untouched (audit §5 C1/C2).Every per-name body moved verbatim; arm order is preserved where semantic:
uname/arch/stty, [enhancement] 身份人设:uname/arch 转内置 + RUBASH_IDENTITY 环境变量切换(默认 MSYS 兼容或原生待拍板)——修生态脚本的非 MSYS 环境退出断裂 #154) — R1 position semantics intact;enable -nchecks stay per-arm inside the bodies (R4);sudois not a registry claim (host elevation capability, builtin divergences:dirs -lshape,shiftbad-operand status, 3 non-bash builtins (setopt/unsetopt), and 17 more #759): itscfg(windows)handler check becomes an explicit pre-check ahead of the lookup in the primary andcommandtables, with the historical fall-throughs (Ok(None)/ late-table external) preserved;((is the tables' single unregistered entry (parser pseudo-word, no row exists) and is listed as the exception in the pin.T7 is reworked to prove equality on the dispatch data itself (table names == row claims per entry, sortedness/uniqueness, hidden slots == HiddenFastpath rows, lookup/table agreement); the old source scan survives as a one-directional shadow-arm guard. The S1 well-formedness pin (no row yields to a resolved real body) is unchanged — this slice changes no stand-down value.
Item 2 — KD-2 execution-side residual (the one sanctioned behavior change)
GNU's special-builtin table is name-based (
builtins/mkbuiltins.c:148-154, 16 names,sourceincluded; flag applied by name at 819-820), butsupport_names::is_posix_special_builtinnamed 15. In POSIX mode thesourcespelling therefore escaped the definition rejection (fatal, exit 2), the invocation preclusion (execute_cmd.c:4657-4676), and the readonly-tempenv fatality (execute_cmd.c:4693) that.gets; assignment persistence hung on a|| command == "source"workaround invariable_state. The predicate gainssource(single classification point), the registry row'sfunction_shadowflips toPosixSpecialBlock, the workaround is removed, and the two pins that carried the difference at exactly{"source"}now assert equality at 16.New behavior pins:
tests/issue2036_s3_posix_source_special.rs(5 tests, both spellings, GNU bash 5.3.20 script-file probe expectations: definition rejection / invocation shadowing / assignment persistence / readonly fatality / missing-file matrix incl. thecommandexemption).Item 3 — stand_down two-axis adjudication table
Delivered as a table in the cluster REPORT (§裁定表), no behavior changed: every row with a stand-down face, its current two-axis values, the WinuxCmd/GNU sync face, the impact and performance cost of flipping it, and a recommendation per row — including the non-standard cells (pipeline sed
InvertedSed,yesHashStandin, the per-face comsub basenameUncheckedcell, the timed-consumer sleep non-consult, tput's separate hash record). Awaiting main-session adjudication cell by cell.Gates
CI (this PR): the full set — the reworked registry pins (18 consistency tests incl. T7) run in the lib test jobs;
-D warningsvia the niu canary check.Local (build slot, this tree):
cargo check --locked+RUSTFLAGS=-D warnings: clean.issue2036_precedence_introspection_regressions: 20/20, expectations unchanged.sourcespelling diverged on definition/invocation/readonly exactly as analyzed, post-fix byte-identical to GNU.Adjacent findings (recorded, NOT fixed here — separate homes requested in the cluster report)
eval/./sourcefunctions all run as pipeline stages in POSIX mode; GNU runs the builtin). Class-wide, not asourcegap; the pipeline face's effective route does not consult the predicate.:/./source/evalwith<&9; GNU exits viaexecute_cmd.c:4869EX_REDIRFAIL). Again class-wide and predicate-independent.