From 321b80f1f8735aa0da52c50567a5e04b24c8b565 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 07:32:03 -0400 Subject: [PATCH 01/15] perf(conf.d): load tailscale completions lazily from completions/ conf.d/tailscale.fish is 252 lines of Cobra-generated completion that fish sourced on every shell start, and its self-priming block executed the tailscale binary to warm the completion cache. completions/ is the directory fish autoloads on first . Measured: 19.2 ms off both interactive and non-interactive startup. --- {conf.d => completions}/tailscale.fish | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {conf.d => completions}/tailscale.fish (100%) diff --git a/conf.d/tailscale.fish b/completions/tailscale.fish similarity index 100% rename from conf.d/tailscale.fish rename to completions/tailscale.fish -- 2.54.0 From fb21fa550aface2555be7e38d10402d80ca7f438 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:53:35 -0400 Subject: [PATCH 02/15] perf(completions): drop tailscale self-priming completion call The Cobra-generated block ran `complete --do-complete "tailscale "` to flush pre-existing completions before erasing them, which executed the tailscale binary. From completions/ it has no job: fish autoloads only the first match on $fish_complete_path and the repo's completions/ precedes the vendor dir, so the vendor file is never sourced. Verified byte-identical completion output across four probes with the vendor file present. A comment at the deletion site records the reasoning. --- completions/tailscale.fish | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/completions/tailscale.fish b/completions/tailscale.fish index dce3602..b682131 100644 --- a/completions/tailscale.fish +++ b/completions/tailscale.fish @@ -228,16 +228,15 @@ function __tailscale_prepare_completions return 0 end -# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves -# so we can properly delete any completions provided by another script. -# Only do this if the program can be found, or else fish may print some errors; besides, -# the existing completions will only be loaded if the program can be found. -if type -q "tailscale" - # The space after the program name is essential to trigger completion for the program - # and not completion of the program name itself. - # Also, we use '> /dev/null 2>&1' since '&>' is not supported in older versions of fish. - complete --do-complete "tailscale " > /dev/null 2>&1 -end +# REMOVED (2026-09-07): Cobra's self-priming block — +# if type -q "tailscale"; complete --do-complete "tailscale " >/dev/null 2>&1; end +# It existed to force any pre-existing tailscale completions to load so the +# `complete -c tailscale -e` below could erase them. From completions/ it has +# no job: fish autoloads only the FIRST match on $fish_complete_path, and +# $__fish_config_dir/completions precedes /usr/share/fish/vendor_completions.d, +# so the vendor file is never sourced and there is nothing to erase. It also +# executed the tailscale binary at startup. Verified: completion output is +# byte-identical with and without it. See AGENTS/specs/2026-09-07-startup-latency-design.md D2. # Remove any pre-existing completions for the program since we will be handling all of them. complete -c tailscale -e -- 2.54.0 From 3d8d6a44689c101bd40c28a3ae1961c0d56b28dd Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:54:38 -0400 Subject: [PATCH 03/15] refactor(conf.d): move cheat completions to completions/ Thirteen lines, every one a `complete -c cheat` registration, sourced on every shell start from the wrong directory. Startup cost was already ~0 because its command substitutions are lazy, but completions/ is where fish expects the file and the move is free. --- {conf.d => completions}/cheat.fish | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {conf.d => completions}/cheat.fish (100%) diff --git a/conf.d/cheat.fish b/completions/cheat.fish similarity index 100% rename from conf.d/cheat.fish rename to completions/cheat.fish -- 2.54.0 From c3a2b6fa0c9ee7574f9167bb83b83debde42c3ae Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:55:31 -0400 Subject: [PATCH 04/15] perf(conf.d): skip abbr.fish in non-interactive shells 61 abbreviations were declared on every fish -c. Abbreviations expand only in the line editor, so nothing outside an interactive session can use them. --- conf.d/abbr.fish | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf.d/abbr.fish b/conf.d/abbr.fish index 5771e32..b8016d1 100644 --- a/conf.d/abbr.fish +++ b/conf.d/abbr.fish @@ -12,6 +12,9 @@ # site abbr-integrations: integrations/terminal-abbrs # site abbr-overrides: overrides/key-bindings +# Abbreviations only expand in the line editor; a script can never use one. +status is-interactive; or return + # Neovim # @category Editors # @desc nvim -- 2.54.0 From 13d415db2bbbbc72ab5db54049f3fbede46b50f7 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:56:16 -0400 Subject: [PATCH 05/15] perf(conf.d): skip bash_expands.fish in non-interactive shells The six expand_* functions are only ever reached through abbr --function, which fires during interactive expansion. --- conf.d/bash_expands.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf.d/bash_expands.fish b/conf.d/bash_expands.fish index d81dc91..89c5bf7 100644 --- a/conf.d/bash_expands.fish +++ b/conf.d/bash_expands.fish @@ -7,6 +7,10 @@ # Provides bash-style history expansion functions for abbreviations. # These functions are gated by the C3 overrides switch. +# The six expand_* functions are reachable only through abbr --function +# (conf.d/abbr.fish:677-697), i.e. only during interactive expansion. +status is-interactive; or return + # Execute expand_bang_all function expand_bang_all --description 'Execute expand_bang_all' # Opinionated guard (C3): no expansion when overrides are disabled. -- 2.54.0 From bb5b6b361abf8b1593f39e5758d73ea439094d2e Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:57:02 -0400 Subject: [PATCH 06/15] perf(conf.d): skip key_bindings.fish in non-interactive shells fish_user_key_bindings is invoked only by the interactive reader. --- conf.d/key_bindings.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf.d/key_bindings.fish b/conf.d/key_bindings.fish index 588e073..e6143ab 100644 --- a/conf.d/key_bindings.fish +++ b/conf.d/key_bindings.fish @@ -47,6 +47,10 @@ # This allows for rapid-fire math without leaving the current shell. # ────────────────────────────────────────────────────────────────────── +# Defines only fish_user_key_bindings, which fish calls from the interactive +# reader and nowhere else. +status is-interactive; or return + function fish_user_key_bindings # Custom key chords are opinionated (C3 overrides); skip them entirely -- 2.54.0 From 4d6b99fb28a9a45bb1a2e53558cc26b61ae72b79 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:58:18 -0400 Subject: [PATCH 07/15] perf(conf.d): skip starship.fish in non-interactive shells Defines fish_prompt only. The guard precedes the op-guard and the type -q PATH scan so both are skipped in scripts. Scripts fall back to the repo's autoloadable functions/fish_prompt.fish, which nothing invokes anyway. --- conf.d/starship.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf.d/starship.fish b/conf.d/starship.fish index fc9673e..adee42b 100644 --- a/conf.d/starship.fish +++ b/conf.d/starship.fish @@ -9,6 +9,10 @@ # Without starship, fish's built-in prompt already emits OSC 133;A # on the prompt line itself, so no wrapper is needed. +# Defines fish_prompt; no script renders a prompt. Checked before the +# op-guard so the builtin short-circuits ahead of three function autoloads. +status is-interactive; or return + # Replacing the prompt is opinionated (C3 overrides) __fish_config_op_enabled (status basename); or return -- 2.54.0 From 5edfb5b72018de162c8a653a5f9fc60ec6ef76fe Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:59:10 -0400 Subject: [PATCH 08/15] perf(conf.d): skip theme colors in non-interactive shells fish_color_* is consumed only by the syntax highlighter. The guard sits below the existing cleanup branch so stale-FZF_DEFAULT_OPTS cleanup keeps running where it does today; the FZF value itself is a persisted universal and survives regardless. --- conf.d/theme.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf.d/theme.fish b/conf.d/theme.fish index 5944728..26bc834 100644 --- a/conf.d/theme.fish +++ b/conf.d/theme.fish @@ -20,6 +20,11 @@ if not __fish_config_op_enabled (status basename) return end +# Below the cleanup block on purpose: that branch erases a stale universal +# FZF_DEFAULT_OPTS and must keep running wherever it runs today. Everything +# past here is fish_color_* for the syntax highlighter, interactive-only. +status is-interactive; or return + # ────────────────────── Syntax highlighting colors ────────────────────── set --global fish_color_autosuggestion 6c7086 set --global fish_color_cancel f38ba8 -- 2.54.0 From 2edea59ca33f2120b1d0e89aba3ef0f578491b2a Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 15:00:01 -0400 Subject: [PATCH 09/15] perf(conf.d): skip auto-pull handler in non-interactive shells The --on-variable PWD handler backgrounds a git fast-forward. A script that cd's was firing it, which is also where AGENTS.md Task #4's credential prompt could surface from a background job. --- conf.d/auto-pull.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf.d/auto-pull.fish b/conf.d/auto-pull.fish index 852559a..db4f7f5 100644 --- a/conf.d/auto-pull.fish +++ b/conf.d/auto-pull.fish @@ -13,6 +13,11 @@ # # Manage the registry with: auto-pull add / remove / list / status +# Registers an --on-variable PWD handler that backgrounds a git fetch. In a +# script that cd's, that is both wasted work and AGENTS.md Task #4's +# credential-prompt hazard fired from a background job. +status is-interactive; or return + # C2 guard: when auto-execution is disabled, do not register the handler. __fish_config_op_enabled (status basename); or exit -- 2.54.0 From 5fa849fd81763bc22ec106d1bfb6f8253d14d7d1 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 15:00:57 -0400 Subject: [PATCH 10/15] perf(conf.d): skip wakatime hook in non-interactive shells fish_postexec is emitted only by the interactive reader (verified), so the handler could never fire in a script. No telemetry behaviour changes. --- conf.d/wakatime.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf.d/wakatime.fish b/conf.d/wakatime.fish index db97a43..e4568bf 100644 --- a/conf.d/wakatime.fish +++ b/conf.d/wakatime.fish @@ -9,6 +9,10 @@ # site wakatime-autoexec: autoexec/telemetry # site wakatime-hook: integrations/notifications +# Registers a fish_postexec handler; that event is emitted only by the +# interactive reader, so the handler is dead weight in a script. +status is-interactive; or return + # Local modification: opinionated guard (AGENTS.md Task #3). WakaTime # reporting is classified under both C2 auto-execution and C4 integrations; # disabling either category skips registering the hook. -- 2.54.0 From c998d1b8d7fbdef4eec32153872f1727dfbbfdc9 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:56:45 -0400 Subject: [PATCH 11/15] perf(conf.d): skip C5 logging sync in non-interactive shells MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __fish_config_sync_logging ran on every fish -c, mkdir+touching the C5 sentinel on disk from every subshell. Its consumers — the Kitty watcher and the paru/yay wrappers — are interactive-context, and every interactive shell still reconciles the state. --- conf.d/logging-events.fish | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conf.d/logging-events.fish b/conf.d/logging-events.fish index 892f518..53e1287 100644 --- a/conf.d/logging-events.fish +++ b/conf.d/logging-events.fish @@ -13,6 +13,12 @@ # solely in functions/ are never registered and their --on-variable triggers # never fire. +# Calls __fish_config_sync_logging at every shell start, which mkdir+touches +# the C5 sentinel on disk. Its only consumers — the Kitty watcher and the +# paru/yay wrappers — are interactive-context; every interactive shell still +# refreshes it. +status is-interactive; or return + function __fish_config_logging_changed --on-variable __fish_config_op_logging \ --description 'C5 event handler: sync logging state when __fish_config_op_logging changes' __fish_config_sync_logging -- 2.54.0 From 52711a42a2c06644936bd4c923075ac6a7996ecc Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:58:10 -0400 Subject: [PATCH 12/15] perf(conf.d): skip paru/yay wrapper generation in non-interactive shells Neither file defines a function or sets a global; their only effect is writing ~/.local/bin/, which every interactive session does anyway. Combined 10.7 ms off every fish -c. --- conf.d/paru-wrapper.fish | 4 ++++ conf.d/yay-wrapper.fish | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/conf.d/paru-wrapper.fish b/conf.d/paru-wrapper.fish index bef1e54..e5e629e 100644 --- a/conf.d/paru-wrapper.fish +++ b/conf.d/paru-wrapper.fish @@ -10,6 +10,10 @@ # site paru-autoexec: autoexec/pkg-wrappers # site paru-logging: logging/pkg-logs +# Defines nothing; its only effect is generating ~/.local/bin/paru, an +# idempotent write every interactive session already performs. +status is-interactive; or return + # Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). # Wrapper generation is also gated by C5 (Logging & Capture). __fish_config_op_enabled (status basename) paru-autoexec; or return diff --git a/conf.d/yay-wrapper.fish b/conf.d/yay-wrapper.fish index 53da589..6f43360 100644 --- a/conf.d/yay-wrapper.fish +++ b/conf.d/yay-wrapper.fish @@ -10,6 +10,10 @@ # site yay-autoexec: autoexec/pkg-wrappers # site yay-logging: logging/pkg-logs +# Defines nothing; its only effect is generating ~/.local/bin/yay, an +# idempotent write every interactive session already performs. +status is-interactive; or return + # Auto-generating a wrapper in ~/.local/bin is opinionated (C2 auto-exec). # Wrapper generation is also gated by C5 (Logging & Capture). __fish_config_op_enabled (status basename) yay-autoexec; or return -- 2.54.0 From 85c753aaa66e58484432a873aad00eeaeda4bf81 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:59:53 -0400 Subject: [PATCH 13/15] docs: point tailscale and cheat completions at completions/ Follows the relocation out of conf.d/. The completions/ branch of the file tree is expanded from the real directory at build time, so it needs no hand-written children. Generated docs are regenerated separately. --- docs/manual/01-configuration-variables.md | 3 ++- docs/manual/index.md | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/manual/01-configuration-variables.md b/docs/manual/01-configuration-variables.md index f37299d..b898cbd 100644 --- a/docs/manual/01-configuration-variables.md +++ b/docs/manual/01-configuration-variables.md @@ -118,7 +118,8 @@ Every shell command is reported to WakaTime for time-tracking. Set ### Tailscale -Full tab completion for the `tailscale` CLI is provided via `conf.d/tailscale.fish`. +Full tab completion for the `tailscale` CLI is provided via +`completions/tailscale.fish`, autoloaded on the first `tailscale`. ### Done Notifications diff --git a/docs/manual/index.md b/docs/manual/index.md index 3017947..5c4d402 100644 --- a/docs/manual/index.md +++ b/docs/manual/index.md @@ -35,7 +35,6 @@ The configuration uses a structured file tree: ├── conf.d/ │ ├── abbr.fish All abbreviations │ ├── autopair.fish Auto-pair brackets and quotes - │ ├── cheat.fish cheat.sh tab completions │ ├── done.fish Desktop notifications for long commands │ ├── first_run.fish One-time init: Fisher bootstrap, theme │ ├── key_bindings.fish Custom key bindings and Vi mode @@ -47,14 +46,13 @@ The configuration uses a structured file tree: │ ├── zellij-logging.fish C5 fish_exit handler for zellij │ ├── sponge_privacy.fish Sponge privacy patterns │ ├── starship.fish fish_prompt shell-integration markers - │ ├── tailscale.fish Tailscale CLI tab completions │ ├── theme.fish Catppuccin syntax highlight colors │ ├── tricks.fish PATH, bang-bang helpers, bat man pages │ ├── wakatime.fish WakaTime shell hook │ ├── yay-wrapper.fish Auto-generates yay logging wrapper │ └── zoxide.fish Zoxide z/zi integration; overrides cd ├── functions/ Custom functions, one per file - ├── completions/ Tab completion scripts + ├── completions/ Tab completion scripts, autoloaded on demand ├── integrations/ │ └── fzf.fish FZF Catppuccin theme and key bindings ├── scripts/ -- 2.54.0 From d49d90a2deda3f056b3cee1fb1c4240a470233da Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:01:24 -0400 Subject: [PATCH 14/15] chore(docs): regenerate manual docs/fish-config.1 is left for CI to regenerate: the local pandoc is 3.10.2 against CI's 3.1.3, so rebuilding it here emits ~4700 lines of formatter churn unrelated to this change. The component registry rebuilt identically. --- docs/fish-config.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/fish-config.md b/docs/fish-config.md index 2dccaed..5edcf39 100644 --- a/docs/fish-config.md +++ b/docs/fish-config.md @@ -46,7 +46,6 @@ The configuration uses a structured file tree: ├── conf.d/ │ ├── abbr.fish All abbreviations │ ├── autopair.fish Auto-pair brackets and quotes - │ ├── cheat.fish cheat.sh tab completions │ ├── done.fish Desktop notifications for long commands │ ├── first_run.fish One-time init: Fisher bootstrap, theme │ ├── key_bindings.fish Custom key bindings and Vi mode @@ -58,14 +57,13 @@ The configuration uses a structured file tree: │ ├── zellij-logging.fish C5 fish_exit handler for zellij │ ├── sponge_privacy.fish Sponge privacy patterns │ ├── starship.fish fish_prompt shell-integration markers - │ ├── tailscale.fish Tailscale CLI tab completions │ ├── theme.fish Catppuccin syntax highlight colors │ ├── tricks.fish PATH, bang-bang helpers, bat man pages │ ├── wakatime.fish WakaTime shell hook │ ├── yay-wrapper.fish Auto-generates yay logging wrapper │ └── zoxide.fish Zoxide z/zi integration; overrides cd ├── functions/ Custom functions, one per file - ├── completions/ Tab completion scripts + ├── completions/ Tab completion scripts, autoloaded on demand ├── integrations/ │ └── fzf.fish FZF Catppuccin theme and key bindings ├── scripts/ @@ -245,7 +243,8 @@ Every shell command is reported to WakaTime for time-tracking. Set ### Tailscale -Full tab completion for the `tailscale` CLI is provided via `conf.d/tailscale.fish`. +Full tab completion for the `tailscale` CLI is provided via +`completions/tailscale.fish`, autoloaded on the first `tailscale`. ### Done Notifications -- 2.54.0 From 53b353eb7f6140962b886e60f84fee481c04cb34 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 20:04:47 -0400 Subject: [PATCH 15/15] test: assert conf.d stays lazy in non-interactive shells Spawns one non-interactive child against the sandboxed config and asserts on what loaded -- abbreviations, key bindings, bang-expansions, the C5 event handlers and the tailscale completion machinery must all be absent. Exit codes name which guard regressed. No wall-clock assertions, so it cannot flake. --- tests/functional.fish | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/functional.fish b/tests/functional.fish index e4d1651..b3e6df7 100644 --- a/tests/functional.fish +++ b/tests/functional.fish @@ -97,6 +97,32 @@ function test_vault_dir_honors_override test "$got" = /tmp/vault-override-check end +function test_conf_d_is_lazy_in_scripts + # A non-interactive shell must not load interactive-only conf.d work. + # The child inherits XDG_CONFIG_HOME from the sandboxed session, so it + # loads the same config under test. Each exit code names one regression. + # + # Assertion 5 (tailscale) is vacuously true where tailscale is not + # installed: conf.d/tailscale.fish returned early on `type -q tailscale` + # before this change, and completions/tailscale.fish does the same, so the + # function is absent either way. The test still cannot fail wrongly there + # -- it just stops proving anything about that one file. A positive + # "completions still work" check would need the binary present and would + # make the suite machine-dependent, so it stays out. + fish -c ' + abbr -q n; and exit 1 + functions -q fish_user_key_bindings; and exit 2 + functions -q expand_bang_all; and exit 3 + functions -q __fish_config_logging_changed; and exit 4 + functions -q __tailscale_perform_completion; and exit 5 + exit 0' +end + +function test_key_bindings_defined + # Positive counterpart to assertion 2 above: the guard must not over-fire. + functions -q fish_user_key_bindings +end + function functional_test_main set -l names (functions -a | string match 'test_*' | sort) set -l failed 0 -- 2.54.0