Repository navigation
WIP: /proc truthfulness — A period (#1917 registry + enumeration, #1918 PPid, PEB cmdline, #1900 exe/cwd) - #1922
Conversation
…rubash#1917) A0/A3 of the #1917 A period (design: vfs-1917-design/DESIGN.md §3.0/§3.3): - special_paths: new SpecialPathClass::SyntheticLink for the readlink-type /proc entries (exe/cwd), classified after FdAlias and ahead of SyntheticProc per the design's canonical order. Admission is the closed kernel entry-name set; a miss falls through to the real filesystem and fails loudly (ENOENT), never a silent wrong answer. The classify battery gains the link spellings and a link-query-vs-classify agreement check. - proc_vfs: the entry name tables (top-level files, per-pid content files, per-pid link files) now live in one module with the generators, plus proc_dir_entries — the single enumeration source (root = file table + self + list_pids(); per-pid = entry table, live pids only). list_pids gains its first consumer. ToolHelp snapshot sites route through one counted helper so the §4.2 call-count budget is assertable in tests (enumeration leg pinned here: root = exactly 1 snapshot, self dir = 0). - glob: glob_vector_expand asks the registry enumeration for synthetic /proc directories (directory probe, stat fast path, and scan), and the trailing-slash directory check in glob_filename_expand accepts them — /proc/*, /proc/self/*, /proc/*/status now expand on Windows. Regression pins: proc_vfs table/generator agreement + enumeration budget (unit), tests/regression.rs issue_1917 A-1 (version shape), A-7 (dead pid directory vanish), A3 (glob enumeration). procfs content has no GNU contract; expectations are the Linux procfs shapes, per the design §6.1. Refs rubash#1917
…ash#1918)
pid_status answered PPid 0 for /proc/self/status and the shell's own
pid for every other process, while the ToolHelp walk that located the
process was already carrying PROCESSENTRY32W.th32ParentProcessID and
throwing it away. Process-tree consumers (the dsh-ops restricted
mode's tree cleanup is the named one) built on those values would
prune the wrong tree.
- snapshot_entry now returns {image, parent_pid} from the one walk.
- pid_status takes the PPid as a parameter and invents nothing.
- The /proc/self face is snapshot-free (rubash#1917 §4.2): status and
cmdline resolve through direct self queries; the own parent pid is
asked once via NtQueryInformationProcess (the executor $PPID
technique) with the snapshot as fallback, and cached — it is
recorded at process creation and cannot change.
Pins: unit — self face costs zero snapshots after warm-up, and the
rendered PPid equals the snapshot record exactly for self and for
another live pid; regression issue_1918 A-3 — a known parent/child
pair (this shell + a spawned child shell) where the child's
self-reported PPid must equal the parent's $$ (fails pre-fix on
Windows: the child read the fabricated 0).
Refs rubash#1918
Refs rubash#1917
The ToolHelp snapshot only ever knew each process's image name, so /proc/<pid>/cmdline answered "prog.exe\0" for every process — ps, /proc-walkers and anything keying on real command lines were reading a fiction. - Other pids: OpenProcess(query + VM read) → NtQueryInformationProcess → PEB → ProcessParameters.CommandLine, the same technique WinuxCmd's ps.cpp uses. The raw command line is split with CommandLineToArgvW — the OS's own argv derivation — and emitted as NUL-terminated UTF-8 fields, the procfs byte shape. Sanity rails (non-empty, even UTF-16 length, bounded size, non-null buffer) void a mis-addressed read; any failure falls back to the image-name shape: content degrades, shape never does. - Self: GetCommandLineW direct (no snapshot, no PEB walk). - Cross-bitness reads (64-bit shell, 32-bit target) address the wrong parameter layout and land on the fallback — the design's accepted coverage edge (§7.1), recorded rather than papered over. Pins: unit — self cmdline's argv[0] ends with the image name, the field count exceeds the lone fallback field, and the PEB route for the shell's own pid derives bytes identical to the fast path; regression A-2 — a marker argument placed on the shell's own command line must appear in /proc/self/cmdline (absent pre-fix on Windows). Refs rubash#1917
/proc/<pid>/exe and /proc/<pid>/cwd did not exist in the simulation: every face fell through to a filesystem that has no such names on Windows, so test -e /proc/self/exe was false and the files could not be read. Slice 1 of this branch registered them as the registry's SyntheticLink class; this slice resolves and serves them. - proc_vfs::proc_link_target: self/exe is the running image; <pid>/exe is asked of the OS per process (QueryFullProcessImageNameW); self/cwd is the caller's SESSION cwd in both spellings — the process-global cwd is never consulted (G-02 anchoring, rubash#1887); <pid>/cwd reads the target's PEB CurrentDirectory.DosPath. A dead or protected pid resolves to None: the link dangles exactly when its process does. - Open ladder (shell_options) and the internal cat face gain the link arm between fd-alias and synthetic content, opening/reading the resolved target; the two command_input_scope decline points decline link paths alongside synthetic content. - test/[[]] gains ONE facts hook (builtins/test.rs, so the conditional face is covered through the same eval_unary): answers come from proc_vfs::proc_unary_facts — registry tables + pid liveness, never a constant table (the rubash#1902 lesson; the old virtual_device_test constants are untouched and never see these names). -w/-x on synthetic entries still fall through. Pins: unit — session-cwd pass-through in both spellings, self/exe ends with the running image name, content entries are not links, dead-pid dangles, facts agree with classification; regression A-4 — test -e/-L/-f on exe, -e/-d on cwd, and reading /proc/self/exe produces the image's own magic (MZ on Windows); A-5 — after cd into a subdirectory, /proc/self/cwd still tests as an existing directory. Refs rubash#1900 Refs rubash#1917
…rnals cmdline_fallback_shape_is_image_plus_nul and link_targets_and_facts used a runtime `if cfg!(windows)` while calling cfg(windows)-only functions (image_cmdline_fallback, self_image_name) — name resolution does not honor a runtime cfg, so the lib test target failed to compile on every non-Windows target (CI cross-target, macOS and Linux Rust-test jobs). Same shape as the snapshot_entry test fixed earlier in this branch; the remaining if-cfg tests only call stubbed cross-platform queries and are unaffected. Refs rubash#1917 Refs rubash#1900
…warning proc_link_target / proc_unary_facts were written against helper names that do not exist in this module (proc_pid_ref / proc_file_name / a PidRef::Root variant) — the module's actual shared parse is parse_pid_spelling, returning (PidRef, tail) with SelfPid/Pid only. The error was invisible to every local check (the functions are cfg(windows); the local windows-gnu check is blocked by the psm build script's C-compiler requirement) and surfaced only in the Windows CI job. Both functions are rewritten on the real API: liveness via pid_ref_alive, tails matched against the entry tables, top-level files routed by the parse's non-numeric-head rejection. Also: the TOOLHELP_SNAPSHOTS doc comment cannot attach to a thread_local! invocation (unused-doc-comment warning on Windows, which the -D warnings gate would reject) — demoted to a plain comment. Refs rubash#1900 Refs rubash#1917
The Windows CI link failed with LNK2019 on CommandLineToArgvW only: it lives in shell32, outside the default link set (every other extern this slice uses is kernel32/ntdll and resolved). The extern block is split and attributed per library, following the tree's #[link(name = "kernel32")] precedent (src/builtins/stty.rs). Refs rubash#1917
… count cmdline_is_true_argv_for_self failed on Windows CI — instructively: the true read worked (argv[0] came back as the full invocation path D:\a\...\rubash-<hash>.exe, not the fallback's bare image name), but the goldens job's library-test step invokes the test binary with no arguments, so the "harness passes arguments, fields > 1" premise was false. The pin now discriminates on what always holds — the true argv[0] is a path, the fallback's only field is the bare name — and keeps the PEB-route vs fast-path byte-equality check. Multi-argument truth stays pinned end-to-end by regression A-2, which places a known marker argument on the shell's own command line. Refs rubash#1917
…; A-3 pin split Windows CI (run for 3fb34e4) ran the regression pins for the first time: lib 983/983, but A-1 (read < /proc/version) and A-4 (read /proc/self/exe) failed — the read builtin's own target resolution translates the shell spelling to a Windows path and gates on ITS metadata, which never exists for synthetic spellings; the registry slurp further down was unreachable on Windows (the same ladder-skip family as rubash#1904's $(<file) face). read_io now asks the registry on the shell spelling first: content slurps exactly as the existing serve does, and a synthetic link continues through the ordinary file flow at its resolved native target (session cwd for self/cwd, per G-02). A-3 (issue_1918): the child's PPid on Windows names an interposed spawn process (8404), not the parent shell (2344) — truth is "the real creator", which the unit pin proves value-for-value against the snapshot record. The script pin now asserts exact equality only where the spawn is a direct fork/exec (Unix), plus the platform-invariant death of the fabricated 0 everywhere. Refs rubash#1917 Refs rubash#1900 Refs rubash#1918
Diagnostic pin set for the A-1 failure: simple-read (top-level and per-pid content), the internal cat face, the exec numbered-fd face and the compound redirect face each read synthetic /proc content in their own invocation, so the failing face names itself in CI. Refs rubash#1917
Root cause of the A-1/A-4 Windows CI failures, found by elimination after the trace route was blocked: reject_invalid_redirects validates every plain Input redirect by opening the MAPPED Windows path (probe_input_redirect_gate = a raw File::open). Its skip list covers the null device, fd aliases, net targets and procsub — but not the registry classes. A synthetic /proc spelling's mapped path never exists on Windows, so the gate condemned every live /proc target with a spurious `No such file or directory` and the command never ran: `read line < /proc/version` left the variable unset. Faces that bypass this gate (the comsub quick-read, compound redirect binds) worked all along, which is what masked the defect. GNU redir.c do_redirections opens the target through the shell's own path resolution; here that resolution IS the registry, so registry classes are validated by the open ladder that serves them (probe_input_redirect on the shell spelling), not by a raw-path probe. The ReadWrite arm had the same hole (with an O_CREAT side effect on the mapped path) and gets the same skip; the <> serve for synthetic classes remains its open face's own question. With this, the read faces line up: the gate skips, execute_read's probe classifies, and read_input_for_command serves content/links through the registry (the read_io arm added earlier). Refs rubash#1917 Refs rubash#1900
485d06f to
b08dc98
Compare
|
A-period landing update — head is now b08dc98 (history rebuilt to drop temporary trace commits; content identical plus the gate fix below). Read-face root cause found (the A-1/A-4 failures at 3fb34e4): CI status, honestly: the last CI-verified head is 92f91e5 (lib 993/993 on Windows; regression failures = A-1/A-3/A-4 only, all three addressed since). Since ~07:30Z, pushes from this session's shell no longer trigger Actions runs (6 consecutive pushes incl. a fresh PR opened event produced zero runs, while other branches trigger normally and workflow_dispatch works — an identity-side suppression, not a code issue). The final head b08dc98 is compile-verified locally ( |
…ture) The local Linux run falsified the pin's remaining premise: even off Windows, the child's reported PPid is not the invoking shell's $$. Ground truth via ps: a THIS_SH child of the shell's own binary runs IN-PROCESS on Linux (a single OS process — the status it reads is the shell's own, whose PPid is the shell's parent), and on Windows a real child is created through an interposed spawn process. Parentage equality is therefore not a property of PPid truth under this engine's spawn architecture on either platform; the pin keeps the platform-invariant assertions (never the fabricated 0; own PPid a real third party) and leaves exact-value truth to the proc_vfs unit pin (rendered PPid == the snapshot record). Wrong-pin doctrine: fix the pin, not the product. Refs rubash#1918
|
Final head: 6a41c4b. Local gates are now complete on the final tree (Linux, artifacts verified in-place):
One pin changed shape since the last comment: A-3 no longer asserts any script-level parentage equality on ANY platform. The local Linux run falsified the Unix half of the premise — a THIS_SH child of the shell's own binary runs in-process (ps-verified single OS process; the status it reads is the shell's own), just as the Windows child is created through an interposed spawn process. PPid exact-value truth stays with the proc_vfs unit pin (== snapshot record, already green on Windows CI). Fix-the-pin, not the product. Still outstanding, unchanged: one CI run for the final head (this session's pushes still do not trigger Actions — rechecked at 6a41c4b, zero check runs). Expected when it runs: all jobs green, regression 142/142. Full account in the cluster REPORT.md. |
…sh#1917) The in-process comsub `cat` file-operand shortcut in expand_command_substitution_inner read the mapped Windows path directly with fs::read, the one shell-internal face that never asked the special-path registry — so on Windows `$(cat /proc/version)` reported a live synthetic file as ENOENT (A-1b's cat-face; the diagnostic `cat: '<path>': No such file or directory` is unique to this shortcut). GNU routes every substitution body through execution that opens the operand (subst.c:7143 command_substitute), where the open ladder serves /proc spellings from the registry. Fix by mechanism, matching the quick-read ($( <file)) and external_cat order: synthetic content first (synthetic_proc_content), then SyntheticLink resolution (synthetic_link_target with the session cwd's forms, read the native target), then the plain filesystem read unchanged. Same family, second face: the timed comsub `cat` arm (timed_command_substitution_inner, reached via $(time cat ...)) read the filesystem the same way and silently swallowed the miss. It now consults the registry in the same order; only the content source changes — its existing semantics (failed read silently skipped, status stays 0) are preserved exactly. Tests: A-1b stays mandatory and unchanged. New pin issue1917_a1c_comsub_cat_registry_faces covers the timed arm (content + status faces) and a mixed link-then-content face through the plain shortcut. A direct /proc/self/exe capture face is deliberately absent (whole-image capture through a substitution takes ~40s on a debug binary, over the harness timeout; exe link reading end to end is A-4's pin). Local gates (Linux; real procfs masks the defect, Windows CI is the proof): lib 904 passed / 1 failed (the pristine-same ownership_unary_operators_check_existing_file) / 3 ignored; regression 167 passed / 4 failed (the four stock Linux-face names); diffcorpus 306/306; cargo check --lib with -D warnings clean; rustfmt clean and CR=0 on the changed files. GNU differential probe (script file, both shells): stdout identical on all four faces.
…he /proc registry (rubash#1917)
CI run 40664679537 for the cat-face fix proved that fix (a1b's
cat-face and the new a1c pass on Windows) and unmasked the next
never-before-reached face of the same test: a1b asserts its faces in
order and panics at the first failure, so the exec-fd face had never
run on Windows. `exec 9</proc/version` failed with
`/proc/version: No such file or directory` and the descriptor never
bound (`9: Bad file descriptor` on the following read).
Root cause, same family as the reject gate / read_io / comsub cat
ladder-skips: execute_stdio_only_exec_redirect's Input arm opened
the mapped Windows path directly (FileFd::open_read) with no
registry consultation — procsub, /dev/stdin spellings and net
targets had arms, synthetic /proc did not. GNU redir.c
do_redirection_internal opens the target through the same ladder
every other face uses.
The arm's plain-read branch now consults the registry in the
established order: synthetic content binds the generated snapshot
bytes through the fd byte channel (set_fd_input_bytes — procfs
static-snapshot semantics, the shape the arm's own
process-substitution fallback binds), a SyntheticLink resolves
through synthetic_link_target (session cwd for self/cwd) and opens
the native target, and only then does the plain filesystem open
run. The `<>` branch is untouched (the synthetic ReadWrite face is
a recorded residual with no service face).
Same shape, neighboring face: open_compound_numbered_input_redirects
(`{ ...; } 9</proc/version`) opened the mapped path the same way;
its Input branch gets the identical consultation. No test drove
that face on Windows yet; fixing it here keeps the category closed
rather than leaving the next latent red of the same shape.
Local gates (Linux; Windows CI is the proof): lib 904/1 (the
pristine-same ownership name), regression 167/4 (the four stock
Linux-face names), diffcorpus 306/306 on the rebuilt binary,
-D warnings lib check clean, rustfmt clean / CR=0 on changed files.
Manual probe on the new binary: exec-fd and compound-9 faces both
read the version line.
|
cat-face 定点修复已落地(主会话改判「修产品、钉保持强制」),CI 全绿,证据账见
本代理不自合,请主会话裁合并。 |
A-period implementation for the /proc minimal emulation, per the unified
design (vfs-1917-design/DESIGN.md, four issues collected: #1917/#1900/#1903/#1905;
this PR is the A period only — engine-internal /proc fidelity).
Slices (one commit per issue where the design splits them):
SyntheticLinkregistry class; one entry-nametable for content/link/enumeration faces in proc_vfs;
list_pids()gains its first consumer via the glob enumeration face.
(today self answers 0 and other pids answer the shell's own pid —
both fabricated); /proc/self zero-snapshot fast path.
WinuxCmd ps.cpp), image-name fallback shape unchanged on failure;
self cmdline via GetCommandLineW.
G-02 session cwd, never the process-global cwd), wired into the open
ladder, the internal cat face, and the test/[[ ]] predicate face.
Acceptance is Windows-truth comparison (process snapshot / PEB raw data);
there is no GNU oracle for /proc content (design §6.1). MSYS2/Cygwin/Git Bash
are same-machine references only.
Refs rubash#1917
Refs rubash#1900
Refs rubash#1918
Landing note (2026-10-28): merged master e1a2488 (c25358d) — the zero-CI cause was the tests/regression.rs conflict (mergeable_state=dirty ⇒ no merge ref ⇒ no pull_request CI), resolved by whole-module union; CI now runs (run 40661180534: Windows lib 993/0, all jobs green except goldens). Sole remaining red is A-1b's cat-face, and recheck HALTED its planned #[ignore]/#1905 disposition: the CI diagnostic
cat: '/proc/version': No such file or directory(quoted form) comes verbatim from the in-process comsub cat shortcut at src/executor/command_substitution.rs:1030, which fs::reads the mapped path without consulting synthetic_proc_content — a shell-internal (A-period) registry bypass, not an external-cat/materialization face. No product code changed, pin left mandatory, awaiting main-session re-ruling; full evidence in ~/workspace/vfs-1917-impl-a/REPORT.md landing appendix.