From 321b80f1f8735aa0da52c50567a5e04b24c8b565 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 07:32:03 -0400 Subject: [PATCH 01/25] 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 From fb21fa550aface2555be7e38d10402d80ca7f438 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:53:35 -0400 Subject: [PATCH 02/25] 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 From 3d8d6a44689c101bd40c28a3ae1961c0d56b28dd Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:54:38 -0400 Subject: [PATCH 03/25] 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 From c3a2b6fa0c9ee7574f9167bb83b83debde42c3ae Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:55:31 -0400 Subject: [PATCH 04/25] 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 From 13d415db2bbbbc72ab5db54049f3fbede46b50f7 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:56:16 -0400 Subject: [PATCH 05/25] 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. From bb5b6b361abf8b1593f39e5758d73ea439094d2e Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:57:02 -0400 Subject: [PATCH 06/25] 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 From 4d6b99fb28a9a45bb1a2e53558cc26b61ae72b79 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:58:18 -0400 Subject: [PATCH 07/25] 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 From dd672ded3b3ba1d034739b92d62fb29f189ab616 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:59:05 -0400 Subject: [PATCH 08/25] fix(tests): isolate the vault suite from the live config and universal variables The suite ran under a plain `fish`, which loads the user's real ~/.config/fish and their universal variables -- this repo doubles as that config. A test manipulating a guard variable could erase a real universal variable out of the running shell. Override XDG_CONFIG_HOME/XDG_DATA_HOME and pass --no-config. HOME stays real on purpose: overriding it makes the suite's two hermeticity assertions vacuous. Reasoning recorded at the call site. Vault suite still 317/317 with byte-identical stderr. --- tests/run-tests.fish | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/run-tests.fish b/tests/run-tests.fish index 59bc260..35336af 100755 --- a/tests/run-tests.fish +++ b/tests/run-tests.fish @@ -93,11 +93,43 @@ end # the suite builds its own throwaway git repos and binds the vault, claude # and agy roots to them, so it needs no loaded config and must never see # the real ~/.claude. +# +# HOME is deliberately NOT overridden here. Read this before "improving" it. +# +# Overriding XDG_CONFIG_HOME/XDG_DATA_HOME plus --no-config is what makes +# this run isolated: the universal-variable file fish can reach is a fresh +# empty one, and no config.fish/conf.d is loaded. Without that, an +# "isolated" suite runs against the user's LIVE config and real universal +# variables -- this repo doubles as a real ~/.config/fish -- so a test +# doing `set -e __fish_config_op_logging` would erase a real universal +# variable out of the running shell. Measured: +# $__fish_config_op_registry_keys has 65 entries under a plain `fish`, 0 +# under `fish --no-config`. +# +# `env -i HOME=$sandbox` was tried and REJECTED. It looks strictly more +# hermetic, but test-agents-vault.fish's hermeticity floor snapshots the +# real $HOME/.claude/memory and $HOME/.gemini/antigravity-cli and asserts +# them unchanged at the end. Point HOME at a sandbox and both snapshots +# read "absent" before and after: the assertions still pass while +# asserting nothing. A change that turns a real assertion into a tautology +# without turning anything red is the worst failure mode a test harness +# has. Keeping HOME real is what keeps those two assertions biting. +# +# Overriding XDG_DATA_HOME is a hermeticity gain on top of the isolation: +# _agents_vault_dir falls back to +# ${XDG_DATA_HOME:-$HOME/.local/share}/agent-vault, so a vault path that +# no test overrode lands in a temp dir instead of the user's real +# ~/.local/share/agent-vault. echo "" echo "== Vault helper tests ==" -fish $repo_root/tests/test-agents-vault.fish +set -l vault_xdg (mktemp -d) +env XDG_CONFIG_HOME=$vault_xdg/cfg XDG_DATA_HOME=$vault_xdg/data \ + fish --no-config $repo_root/tests/test-agents-vault.fish if test $status -ne 0 set overall_failed 1 end +# `command rm`, not bare `rm`: this driver runs under the config it tests, +# which shadows rm/cp/cat. See the Phase 2 note for the full reasoning. +command rm -rf $vault_xdg exit $overall_failed From 5edfb5b72018de162c8a653a5f9fc60ec6ef76fe Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 14:59:10 -0400 Subject: [PATCH 09/25] 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 From 2edea59ca33f2120b1d0e89aba3ef0f578491b2a Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 15:00:01 -0400 Subject: [PATCH 10/25] 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 From 8fc27fa9c276f9a43a54747873016cce7d410fe8 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 15:00:10 -0400 Subject: [PATCH 11/25] fix(tests): route the runner's utilities through command run-tests.fish executes under the config it tests, which shadows cp, rm and cat. The real hazard is cp: the config aliases it to 'cp -i', which on a non-empty destination reads EOF in a non-interactive runner, silently skips the copy and exits 0 -- a sandbox missing config files, reported as success. rm -rf and cat were measured and behave correctly as-is (the rm wrapper bails to command rm on any non-recursive flag, so -rf really deletes and does not trash). Prefixed anyway: a test runner must not depend on the configuration under test. --- tests/run-tests.fish | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/run-tests.fish b/tests/run-tests.fish index 35336af..4ebb2d1 100755 --- a/tests/run-tests.fish +++ b/tests/run-tests.fish @@ -53,12 +53,22 @@ mkdir -p $sandbox_cfg # no-op on missing paths), so give it $HOME/.local/bin to find. mkdir -p $sandbox/home/.local/bin -cp $repo_root/config.fish $sandbox_cfg/ +# Every utility below goes through `command`. This driver runs under the +# very config it tests, which shadows these: `cp` is an alias for `cp -i`, +# `rm` is a trash wrapper, `cat` resolves to bat. Only `cp` is an actual +# hazard today -- `-i` on a non-empty destination reads EOF in a +# non-interactive runner and SILENTLY SKIPS the copy while exiting 0, +# which would leave the sandbox missing config files and report success. +# `rm -rf` and `cat` were measured and behave correctly as-is (the rm +# wrapper bails to `command rm` on any non-recursive flag, so -rf really +# deletes and does not trash). Prefixed anyway: a test runner must not +# depend on the configuration under test. +command cp $repo_root/config.fish $sandbox_cfg/ test -f $repo_root/fish_plugins -and cp $repo_root/fish_plugins $sandbox_cfg/ +and command cp $repo_root/fish_plugins $sandbox_cfg/ for d in functions conf.d completions integrations themes data test -d $repo_root/$d - and cp -r $repo_root/$d $sandbox_cfg/ + and command cp -r $repo_root/$d $sandbox_cfg/ end set -l err_file (mktemp) @@ -72,8 +82,8 @@ env -i \ 2>$err_file set -l functional_status $status -set -l stderr_out (cat $err_file) -rm -rf $sandbox $err_file +set -l stderr_out (command cat $err_file) +command rm -rf $sandbox $err_file if test -n "$stderr_out" # Diagnostic only, not a gate: on machines with vendor fish configs From 5fa849fd81763bc22ec106d1bfb6f8253d14d7d1 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 15:00:57 -0400 Subject: [PATCH 12/25] 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. From c998d1b8d7fbdef4eec32153872f1727dfbbfdc9 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:56:45 -0400 Subject: [PATCH 13/25] 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 From 52711a42a2c06644936bd4c923075ac6a7996ecc Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:58:10 -0400 Subject: [PATCH 14/25] 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 From d3028d770389f314c00b7fece724a8980490a117 Mon Sep 17 00:00:00 2001 From: Rootiest Date: Mon, 7 Sep 2026 19:59:23 -0400 Subject: [PATCH 15/25] refactor(tests): extract the shared assertion core into tests/lib.fish check/section/report and the counters move out of the vault suite unchanged. report also writes its counts to $FISH_CONFIG_TEST_COUNTS so a driver can aggregate without parsing stdout, and ends on an explicit boolean per AGENTS.md item 5. All 317 vault assertions and every fixture helper are untouched. --- tests/lib.fish | 62 ++++++++++++++++++++++++++++++++++++ tests/test-agents-vault.fish | 21 ++---------- 2 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 tests/lib.fish diff --git a/tests/lib.fish b/tests/lib.fish new file mode 100644 index 0000000..2edfc91 --- /dev/null +++ b/tests/lib.fish @@ -0,0 +1,62 @@ +#!/usr/bin/env fish +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# Shared assertion and reporting core for tests/test-*.fish. +# +# One assertion: `check