fix: tricks.fish double-source and paru/yay wrapper duplication #136

Merged
rootiest merged 3 commits from fix/tricks-double-source-and-paru-wrapper-dedup into main 2026-09-08 05:31:53 +00:00
Owner

Addresses AGENTS/startup-latency-JOB-BRIEF-FINDINGS.md (Job 1's out-of-scope findings). Independent of the other job branches — based on main.

1. tricks.fish sourced twice on CachyOS (4.55ms/shell)

tricks.fish runs once via the conf.d autoload, then again because config.fish re-sources it to win back over CachyOS's own distro config. The bang-bang functions, aliases, and history override need to re-run on both passes — that's the point of the second source — but the PATH/MANPAGER setup doesn't.

Gates fish_add_path and the type -q bat probe behind a once-per-session global. Nothing else changes; the coupling with config.fish's own cachyos-tricks guard is untouched (deliberately, per the findings doc — replicating that guard inside tricks.fish would create the cross-file coupling the (status basename) convention exists to avoid).

2. paru/yay wrapper generators fight each other

Two generators wrote the same ~/.local/bin/paru/yay files: the canonical version-6 generators in conf.d/paru-wrapper.fish/conf.d/yay-wrapper.fish (PTY-based, progress bars preserved, resolves the real binary via __fish_real_command), and an inferior version-1 copy inside __fish_config_sync_logging (plain tee, no PTY, hard-coded /usr/bin/paru//usr/bin/yay). Whichever ran last won, and toggling C5 logging would flip it back to version 1 every time.

__fish_config_sync_logging now delegates entirely to the canonical generators instead of carrying a copy. One behavior change falls out of that rather than being special-cased: a wrapper is no longer generated when C2 (paru-autoexec/yay-autoexec) is disabled, even if C5 logging is on — the removed copy never checked C2, so it could reinstall a wrapper the user had explicitly turned auto-exec off for.

Adds functions/_fish_source_scoped.fish: both canonical generators return early on several guard checks, and a return inside a sourced file exits the calling function (confirmed with a minimal repro, not assumed) — which would otherwise abort __fish_config_sync_logging after the first source and skip whichever of paru/yay hadn't run yet. This tiny helper runs source inside its own function-call boundary to contain that.

Verification

  • fish -n on every touched file.
  • fish tests/run-tests.fish: 317/317 (this branch doesn't carry the header-help test suite from the other job branches).
  • Manually verified the sync-logging fix end-to-end in an isolated HOME/XDG sandbox with a stubbed paru/yay: enable generates both v6 wrappers, disable removes both and drops the sentinel, re-enable regenerates them and clears the sentinel.
Addresses `AGENTS/startup-latency-JOB-BRIEF-FINDINGS.md` (Job 1's out-of-scope findings). Independent of the other job branches — based on `main`. ## 1. `tricks.fish` sourced twice on CachyOS (4.55ms/shell) `tricks.fish` runs once via the conf.d autoload, then again because `config.fish` re-sources it to win back over CachyOS's own distro config. The bang-bang functions, aliases, and history override need to re-run on both passes — that's the point of the second source — but the PATH/MANPAGER setup doesn't. Gates `fish_add_path` and the `type -q bat` probe behind a once-per-session global. Nothing else changes; the coupling with `config.fish`'s own `cachyos-tricks` guard is untouched (deliberately, per the findings doc — replicating that guard inside `tricks.fish` would create the cross-file coupling the `(status basename)` convention exists to avoid). ## 2. `paru`/`yay` wrapper generators fight each other Two generators wrote the same `~/.local/bin/paru`/`yay` files: the canonical version-6 generators in `conf.d/paru-wrapper.fish`/`conf.d/yay-wrapper.fish` (PTY-based, progress bars preserved, resolves the real binary via `__fish_real_command`), and an inferior version-1 copy inside `__fish_config_sync_logging` (plain `tee`, no PTY, hard-coded `/usr/bin/paru`/`/usr/bin/yay`). Whichever ran last won, and toggling C5 logging would flip it back to version 1 every time. `__fish_config_sync_logging` now delegates entirely to the canonical generators instead of carrying a copy. One behavior change falls out of that rather than being special-cased: a wrapper is no longer generated when C2 (`paru-autoexec`/`yay-autoexec`) is disabled, even if C5 logging is on — the removed copy never checked C2, so it could reinstall a wrapper the user had explicitly turned auto-exec off for. Adds `functions/_fish_source_scoped.fish`: both canonical generators `return` early on several guard checks, and a `return` inside a sourced file exits the *calling* function (confirmed with a minimal repro, not assumed) — which would otherwise abort `__fish_config_sync_logging` after the first `source` and skip whichever of paru/yay hadn't run yet. This tiny helper runs `source` inside its own function-call boundary to contain that. ## Verification - `fish -n` on every touched file. - `fish tests/run-tests.fish`: 317/317 (this branch doesn't carry the header-help test suite from the other job branches). - Manually verified the sync-logging fix end-to-end in an isolated HOME/XDG sandbox with a stubbed `paru`/`yay`: enable generates both v6 wrappers, disable removes both and drops the sentinel, re-enable regenerates them and clears the sentinel.
rootiest added 2 commits 2026-09-08 05:23:04 +00:00
tricks.fish is sourced twice per shell on CachyOS: once by the conf.d
autoload, once forced by config.fish to re-win over the distro's own
tricks.fish (measured 4.55ms for the second pass, see
startup-latency-JOB-BRIEF-FINDINGS.md §1). The bang-bang functions,
aliases, and history override further down need to re-run on both
passes since those are what re-assert over the distro config, but the
PATH/MANPAGER setup does not.

Gates fish_add_path and the type -q bat probe behind a once-per-session
global, guarding only that block. Everything else in the file, and the
coupling with config.fish's own cachyos-tricks guard, is unchanged.
__fish_config_sync_logging carried its own inferior copy of the
paru/yay wrapper generator (tee-based, no PTY, no progress-bar
rendering, hard-coded /usr/bin/paru|yay) alongside the canonical
version-6 generators in conf.d/paru-wrapper.fish and
conf.d/yay-wrapper.fish. Both wrote the same file with different
version markers and the same misattributed provenance comment, so
whichever ran last won and a subsequent C5 toggle would flip it back.
See startup-latency-JOB-BRIEF-FINDINGS.md §2.

__fish_config_sync_logging now delegates entirely to the canonical
generators instead of carrying a copy: they already resolve the real
binary via __fish_real_command (never /usr/bin-assumed) and
independently gate on their own C2/C5 keys, covering both the
enabled-regenerate and disabled-remove cases.

One behavior change falls out of delegating rather than special-casing
around it: a wrapper is no longer generated when C2 (paru-autoexec /
yay-autoexec) is disabled, even if C5 logging is on. The removed
sync-logging copy never checked C2, so it could reinstall a wrapper
the user had explicitly turned auto-exec off for.

Adds functions/_fish_source_scoped.fish: a small helper that runs
source inside its own function-call boundary. source itself runs in
the caller's scope, so a bare return inside a sourced conf.d guard
(both files have several) would otherwise unwind whatever function
called source directly -- verified with a minimal repro before relying
on it. Routing through this helper contains the return to just that
call, so calling paru's generator and then yay's actually reaches the
second call.

Manually verified end-to-end in an isolated HOME/XDG sandbox with a
stubbed paru/yay: enable generates both v6 wrappers, disable removes
both and drops the sentinel, re-enable regenerates them and clears the
sentinel.
rootiest added 1 commit 2026-09-08 05:31:47 +00:00
rootiest merged commit 001c5d3df7 into main 2026-09-08 05:31:53 +00:00
rootiest deleted branch fix/tricks-double-source-and-paru-wrapper-dedup 2026-09-08 05:31:54 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#136