Repository navigation
WIP: design+fix(api): Session env-boundary inventory + InvocationShape construction (#2084, #2130) - #2324
Merged
Conversation
…e census Refs #2084, Refs #2130. Successor section to the frozen 1.5.0 Session API design: full inventory of process-global write points in a Session's lifetime with per-row adjudications (restore / scope / documented contract), the disposition snapshot-restore mechanism, and the #2130 read-point census for the four shape carriers with migrate/projection/host verdicts per site.
Refs #2084 The entry policy (SIGPIPE reset, rubash#1333; SIGQUIT ignore, sig.c:102 -> sig.c:333; fatal handlers, rubash#1475) was applied once per process and never restored: a library Session that ran and dropped left the host process with the shell's dispositions, so a child spawned afterwards inherited an ignored SIGQUIT and showed `trap -- '' SIGQUIT` (the #2084 evidence). - capture_entry_and_policy splits into one-shot entry *facts* (ENTRY_IGNORED) and a re-appliable entry *policy* (ENTRY_POLICY_APPLIED): install_fatal_handlers re-reads the current dispositions as chain targets, so re-application after a restore is consistent. - acquire_session_policy/release_session_policy (kill.rs-level wrappers session_dispositions_acquire/release): root executors hold counted shares behind the process-state lock; the first share of an era snapshots the full sigaction structs of every managed signal plus the fatal quartet, the last release reinstalls them verbatim and rewinds the recorded-state words (foreign handlers record state 3, which never equals a reconcile target, so later eras always re-apply honestly).
Refs #2130 GNU keeps the invocation shape in process-local globals (shell.c:497-503 login_shell, shell.c:540-549 interactive_shell); rubash carried it in __RUBASH_INTERACTIVE / __RUBASH_LOGIN_SHELL env-table entries that any script assignment could forge and every decision point had to re-read from the table. - New construction surface: rubash::api::InvocationShape { interactive, login, respawn: RespawnSource { Fresh, EngineChild } } with SessionBuilder::invocation_shape and Session::invocation_shape. The per-flag builder methods (login_shell / interactive) now also declare the shape, so build() applies it authoritatively (previously the interactive flag never reached the executor at all). - Typed state: ShellState::invocation_interactive / invocation_login with Executor::invocation_interactive() / invocation_login() / set_invocation_shape(). The set_env/remove_env funnels write through, so every existing host seed (builder, main.rs argv classification, mark_login_shell, restore_shell_env via sync_invocation_state_from_table) keeps state and projection in step. Script assignments write the table directly, so they now forge only the projection, never a decision. - Read-point census (docs/design/session-env-boundary.md §2): ~50 carrier reads across 20 files; every decision point migrated (command_dispatch/execute/prepare, temporary_assignments, pwd_loop_builtins, job_builtins, parameter_errors, trap_exec, compound_exec, expand_word, prompt_expansion, bind_builtins, external_inner, printf_path_builtins, script_driver, public_accessors' diagnostic-prefix family). Zero unexplained residuals: the remaining table reads are projections ($-/option faces), two builtin-ABI readers whose contract is the env map itself (kill.rs trap reconcile, set.rs error prefix, both named in the census), the host's own classification reads in main.rs, and test seeds. One recorded tightening: decision points use value semantics (== "1" via the field); no production writer writes anything but "1"/remove. - Session::source_startup_files is a no-op for RespawnSource::EngineChild (execute_cmd.c:1576: a forked subshell never re-sources) — the API form of main.rs's respawn door. - Executor gains the #2084 process-state fields (owns_session_process_state / birth_process_umask / session_set_umask, declared here; wiring lands in the next commit), and Executor::drop releases the signal-policy share and conditionally restores a session-set umask. - Pins (src/api/consumer_tests.rs): issue2130_invocation_shape_reaches_executor_state, issue2130_forged_carrier_assignment_does_not_flip_decisions, issue2130_engine_child_shape_skips_startup_files, issue2084_session_end_restores_host_process_state.
Refs #2084 Wires the kill.rs signal-policy ownership (previous commit) and the umask restore into the executor lifecycle: - new_inner: a root executor that outlives its construction (every Executor::new that is not the process-exit form) takes a policy share BEFORE the mailbox registration applies the entry policy, so the era snapshot is the host's own dispositions; it also records its birth process umask. The process-exit form holds no share (its dispositions die with the process, unobservable — the CLI form is unchanged), and command-substitution fork copies hold no share and journal no umask. - execute_umask journals the value whenever the builtin changes __RUBASH_UMASK; the root Drop restores the birth mask only when the process still carries this session's setting (the G-03 conditional discipline: a later writer is never overridden). The #1907 fork-saved umask precedent covers the subshell boundary; this covers the session boundary.
caomengxuan666
marked this pull request as ready for review
October 31, 2026 08:25
…inery, route interactivity reads through invocation_interactive()
This was referenced Oct 31, 2026
SpookyWaste
pushed a commit
to SpookyWaste/rubash
that referenced
this pull request
Nov 12, 2026
…, Refs unixwin#2130) Collector pairing for unixwin#2324: the typed InvocationShape / RespawnSource family it published in rubash::api is recorded in the ledger (header addendum, §2.1 api row, §4 tier row, §6 symbol block: 2 items, 2 variants, 8 methods), staged ahead of host adoption like the kill-hook records before it. niubash consumes none of it yet; its consumption today is the engine's own build path, the migrated carrier reads, and the in-tree consumer tests. check-api-ledger: 186 symbols present (was 174); --niu completeness green, no new warnings.
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.
Joint contract cluster for #2084 + #2130 (unfrozen 2026-10-31; milestone 1.5.0).
Design first —
docs/design/session-env-boundary.md(successor section; the frozen 1.5.0 text is untouched):InvocationShape { interactive, login, respawn: RespawnSource }on the Session builder; typed invocation state on the Executor with write-through funnels (set_env/remove_env/mark_login_shell/whole-table restore), so host seeds keep working bit-for-bit while in-session script assignments to the carriers lose decision power; the read-point census (~45 sites) migrated per the table in the design doc, with named reasons for every residual carrier read.Hard gates: #2129 pins, #2072 pins, startup-file chain tests — unchanged expectations; the CLI binary form constructs its session with the shape its argv implies (its existing
set_envseeds write through).Ledger flags for the collector (docs/api-ledger.md NOT edited here — byte-identity across repos is the collector's pairing): new symbols
rubash::api::InvocationShape,rubash::api::RespawnSource,method rubash::api::SessionBuilder::invocation_shape,method rubash::api::Session::invocation_shape,method rubash::executor::Executor::invocation_interactive,method rubash::executor::Executor::invocation_login.Refs #2084 / Refs #2130 (per-commit).