Skip to content

feat: Add configurable history modes (shared/session/private) - #65

Closed
caomengxuan666 wants to merge 113 commits into
masterfrom
agentteams/typed-provenance
Closed

caomengxuan666 wants to merge 113 commits into
masterfrom
agentteams/typed-provenance

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Problem: In the default shared history mode, pressing arrow keys to navigate command history becomes unstable when multiple shell windows are open - entries from other shells appear and disrupt navigation.

Solution: Add WINUXSH_HISTORY_MODE environment variable with three modes:

  • shared (default): Live cross-shell sharing, arrow-key navigation may jump to entries from other sessions
  • session: Stable navigation snapshot at startup + own commands, while builtins see live updates from other shells
  • private: Complete isolation - only this session's commands are visible

Implementation:

  • Add HistoryMode enum to config.rs (Shared/Session/Private)
  • Rewrite history.rs to support both shared (delegated to FileBackedHistory) and fixed modes (in-memory nav with fd-lock append on Windows)
  • Add fd-lock 4.0 dependency for Windows file locking
  • Update shell.rs to read WINUXSH_HISTORY_MODE from environment
  • Update repl.rs to pass history mode to LiveFileBackedHistory
  • Add comprehensive unit tests for all three modes

Documentation:

  • Add History Mode section to docs/src/advanced-usage.md
  • Add reference in README.md Configuration section

All 206 runtime library tests pass.

GNU redir.c feeds raw bytes from input redirection targets to the reading owner. Rubash read_io.rs, read_redirected_fd.rs, and the trap_exec.rs fd-input registrations used strict fs::read_to_string, so invalid-UTF-8 records aborted exec 3<file or dropped read records to an EOF-style empty assignment.

Add substitution_metadata::read_shell_input_file (bytes -> RAW_BYTE_MARKER shell text) and route all five sites through it. Pipeless probes now match GNU Bash 5.2.37 byte-for-byte (printf hi\377 > f; read x < f; printf %s  > out => 68 69 ff), including procsub materialized inputs and exec-persistent fds replayed through redirected files.

Remaining seams are documented in issue-suite-diff-analysis.md: pipeline stage text mirror, cmdsub scalar assignment carrier, coproc record lossy conversion, and builtin write-path decoders.
In-process pipeline stages converted capture buffers with String::from_utf8_lossy and fed child stdin plus final output with plain as_bytes, so builtin stages emitting raw bytes (printf format escapes, marker-decoded read records) were corrupted to U+FFFD before external consumers.

Pipeline producers now encode once via substitution_metadata::bytes_to_shell_text (printf/trap/builtin/function/compound/lastpipe captures, external child stdout/stderr, host externals, cat file reads) and byte-boundary consumers decode once via the new inverse shell_text_to_raw_bytes (child stdin feeds, write_pipeline_output payload, stderr sinks).

All seven handoff byte probes now match GNU Bash 5.2.37 byte-for-byte, including p3 command-substitution assignment replayed through a pipe. Full executor_tests failure set is identical to stashed HEAD (39 pre-existing); two new transport regressions pass in part_047 (37 total). New out-of-scope defect recorded: cmdsub-spawned cat cannot open absolute Windows paths while head -c can.
…idence

Categorized arithmetic word-expansion errors now carry ExecuteError::ExpansionFailure: function frames absorb it as an early return, capture boundaries map it to status, and GNU-shaped diagnostics cover logical-RHS literal assignments and empty ternary branches. Rewrites four stale continue-expectation regression tests against live bash 5.2.37 probes; grand probe parity 19/24 with remaining brace-group/next-line/if-condition edges documented in docs/issue-suite-diff-analysis.md.
GNU Bash 5.2.37 probes y1/y3: the group tail is abandoned while the following command still runs with the carried status. Keep Break/Return/IoError propagation untouched.
GNU probe f4: a failing function call inside an if/elif condition must not be absorbed by the function frame; instead the entire if command is abandoned and the outer list continues. Gate frame absorption on inside_compound_condition.
y1/y3 brace frames and f4 if-condition abandonment are closed; z1/z2 deferred with hang-attribution notes from the reverted incremental file-feeder attempt.
Replaces the pre-session handoff: records the six pushed commits, raw-byte and arithmetic-fatality family closures with probe IDs, current gate numbers (363/12 cli, 33 arith, 37 part_047, 277 lib), open owner boundaries incl. deferred z1/z2 retry design, and new failed-experiment entries.
@caomengxuan666

Copy link
Copy Markdown
Member Author

Closing this accidentally associated PR. The history mode change belongs to unixwin/niubash#66; this Rubash branch contains unrelated work and must not be merged here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant