Skip to content

land: audit-u03-shell-watcher-logs - #536

Merged
ualtinok merged 3 commits into
mainfrom
land/audit-u03-shell-watcher-logs
Oct 18, 2026
Merged

ualtinok merged 3 commits into
mainfrom
land/audit-u03-shell-watcher-logs

Conversation

@aft-alfonso

@aft-alfonso aft-alfonso Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Accepted agent delivery; branch-keyed search descriptor included.


Summary by cubic

Hardens bash rewriting, file watching, and logging so shell commands start with a cleaner environment, the watcher stays responsive under event bursts, wide characters render correctly in terminal sessions, and logs redact secrets more reliably.

Performance

  • Parses each rewritten command once and shares the result across all built-in rewrite rules.
  • Bounds permission-arity lookup to two-word table keys instead of scanning the full argument list.
  • Captures open descriptors in the parent and marks only them CLOEXEC (close_range on Linux), so cleanup no longer sweeps unused numbers or depends on the hard descriptor limit.
  • Clones the gitignore snapshot before watcher path filtering so filesystem work never holds the rebuild writer lock.

Correctness

  • PTY rendering now skips continuation columns of wide glyphs instead of inserting stray spaces.
  • GitHub token redaction only scans text containing actual token prefixes (ghp_, gho_, etc.).
  • Terminal-sync log lines are redacted before writing to both the file and stderr.
  • Windows directory-change notifications are decoded from byte slices and use DWORD-aligned buffers, avoiding unaligned struct reads.

Written for commit 838abaf. Summary will update on new commits.

View guided diff Turn on auto-fix

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new blocking issue was established.

Summary

This PR reduces repeated shell parsing, fixes wide-character output, improves log redaction, and updates file watching.

The follow-up changes focus on inherited file descriptors:

  • Permission prefixes find command keys without scanning every argument.
  • Built-in shell rewrite rules share one parse of each command.
  • Child processes mark open descriptors close-on-exec without scanning every descriptor number.
  • Watcher path checks use a gitignore snapshot without holding its lock.
  • Windows file events use aligned buffers and decode notification bytes safely.
  • PTY output renders wide characters without extra spaces.
  • Terminal-sync logs redact secrets before writing to either output.
  • Session-tagged log messages are formatted directly into the output.
  • Watcher documentation and release metadata describe the change and its path-watch contract.

No new actionable issues were established. Both earlier threads were unnumbered and are resolved. The current code addresses their reported causes: fixed descriptor 70_000 is gone, and the fallback no longer scans up to the hard limit.

Reviews (2) · Last reviewed commit: "mason: bound descriptor cleanup to paren..." · Reviewed by Greptile

ualtinok and others added 2 commits October 18, 2026 14:12
Carry 0720c571fbf5 / 59d3c98 / d3a645d; 6c4e1f94b1a3 / 82f1d72 / 1b9d226; 656cbfe92fe4 / a71b33e / e0a305e; 82292630116b / 507700b / d2429a9; fb9909628f75 / e16a7b6 / 1e4b90b; c0cc3bc802e1 / 14688ea / 13c5028.

Reconcile immutable watcher snapshots and shared shell parsing with current root-aware matching, shell semantics and role profiles. Preserve contextual masking and redact terminal-sync output on both sinks. Correct the PTY golden's continuation-cell spaces because its raw input contains adjacent wide glyphs; cursor-gap assertions remain unchanged.

Behavioral and permission-scan/profile/redaction controls fail when neutralized and pass restored; native Windows decoder control exposes the former unaligned-slice abort. Full Linux gate still reports baseline image/fixture failures, recorded in the delivery evidence for head follow-up.

Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
…er-logs

Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
Comment thread crates/aft/src/sandbox_spawn.rs Outdated
Comment thread crates/aft/src/sandbox_spawn.rs Outdated
Address both descriptor review findings on (#536). Enumerate open FDs in the parent with Linux procfs or macOS libproc, retain close_range CLOEXEC on Linux, and make the async-signal-safe fallback visit only captured descriptors. Document atomic CLOEXEC as the invariant for descriptors opened after the snapshot.

Keep the two high-FD test claims and marker assertions, but move inheritable setup into isolated test processes before enumeration and select the FD from the actual hard limit. Cover sparse fcntl work, lower limits, explicit insufficient-limit skips, and late atomic-CLOEXEC opens. Numeric-sweep, fixed-target and cleanup-omission mutations redden their named regressions; restored tests pass on Linux and native macOS, including FD 245744 on macOS.

Focused guards, binary tests and Windows compile pass. Full Rust gate was run and remains red on five environmental or parallel-run checks; three pass individually. No guard assertion was relaxed.

Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
(cherry picked from commit 854f34a37ead09a85ea2267ef158217b375329ec)
@ualtinok
ualtinok added this pull request to the merge queue Oct 18, 2026
Merged via the queue into main with commit 8c176f3 Oct 18, 2026
48 of 49 checks passed
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