fix(completion): install static script instead of eval at login - #7
Merged
Conversation
The bash/zsh completion install used to append `eval "$(_ORCA_COMPLETE=bash_source orca)"` to the rc file. Each shell startup re-spawned `orca` (which auto-walks ~60 command modules) plus a `bash --version` subprocess from Click's `_check_version()`, costing 1-3 s per login on a developer laptop. A real incident on 2026-04-27 saw hundreds of `orca` processes pile up on a single SSH session, all stuck inside `_check_version()` waiting on their `bash --version` subprocess; the user-visible symptom was a multi-thousand-line traceback after Ctrl-C. `orca completion install bash` (and `zsh`) now generates the completion script once into `\$XDG_DATA_HOME/orca/completion.<shell>` and writes a plain `[ -f ... ] && source ...` line into the rc, matching what fish has always done. Login cost drops to microseconds; no `orca` process is spawned at login. Lazy completion callbacks in `orca_cli/core/completions.py` are unchanged, so tab completion still hits the API on demand with the same per-profile cache. Re-running the install on an older config silently migrates the legacy `eval` line out of the rc, preserving surrounding user content. New tests in `TestInstallCompletionBashZsh` cover the rewrite, idempotency, the legacy-eval migration, and the orca-not-on-PATH error path. See ADR 0010 for the full context, alternatives considered, and migration instructions for upgrading users.
kallioli
force-pushed
the
fix/static-completion-script
branch
from
April 27, 2026 10:11
af33541 to
2350e98
Compare
Vinetos
pushed a commit
to Vinetos/orca-cli
that referenced
this pull request
May 30, 2026
Addresses the remaining high/medium findings from the 2026-04-20 audit: - stackopshq#4 insecure TLS warning + cacert path validation - stackopshq#7 atomic token cache writes - stackopshq#9 publish action pinned to immutable SHA - #13 CI gaps: Poetry cache, poetry build, gitleaks, pip-audit, deploy-docs gated on CI success
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
orca completion install bash(andzsh) used to appendeval "$(_ORCA_COMPLETE=bash_source orca)"to the rc file. Each shellstartup re-spawned
orca(which auto-walks ~60 command modules atimport time) plus a
bash --versionsubprocess from Click's_check_version(), costing 1–3 s per login.A real incident on 2026-04-27 saw hundreds of
orcaprocesses pileup on a single SSH session, all stuck inside
_check_version()waiting on their
bash --versionsubprocess. The user-visible symptomwas a multi-thousand-line traceback after Ctrl-C.
Changes
orca_cli/core/shell_completion.py—install_completion_bashzshnow generates the completion script once into
$XDG_DATA_HOME/orca/completion.<shell>(XDG-spec compliant) andrewrites the rc to source that file. No
orcaprocess is spawnedat login; sourcing a static script is microseconds.
eval "$(_ORCA_COMPLETE=...)"line is detected and replaced onre-install, preserving surrounding rc content. Idempotent.
orca_cli/commands/completion.py—INSTRUCTIONSrewritten forthe manual two-step flow (generate static file + source).
orca_cli/core/completions.pyareunchanged — tab completion still hits the API on demand with the
per-profile cache and 5-minute TTL added in v2.0.1.
docs/adr/0010-static-completion-script.md— full context,decision, alternatives considered, migration instructions.
Tests
TestInstallCompletionBashZshrewritten and extended (5 tests):sourcelineevaltosourcelineorcais not on PATHpytest -q --cov=orca_cli --cov-fail-under=85: 2338 passed, coverage88.42%. ruff + mypy clean.
Risks
the
evalline. Re-runningorca completion install bashmigratessilently; users who never re-run install will keep the slow eval
until they do. Mitigation: documented in CHANGELOG and ADR 0010.
to remove both. Documented in the install message.
Migration