Skip to content

fix: fast-path worker-health to skip CLI bootstrap (#1974)#1977

Merged
davidpoblador merged 1 commit into
mainfrom
worktree-fix-worker-health-fastpath
Jun 2, 2026
Merged

fix: fast-path worker-health to skip CLI bootstrap (#1974)#1977
davidpoblador merged 1 commit into
mainfrom
worktree-fix-worker-health-fastpath

Conversation

@davidpoblador

Copy link
Copy Markdown
Member

Summary

Fixes #1974. vibetuner worker-health paid the full CLI/app bootstrap before it ever read the streaq health key. The console script was vibetuner.cli:app, so importing the CLI package eagerly imported every sub-command and ran load_app_config(), which imports the user's entire tune.py (config, BlobService, rate limiter). On a real deploy that bootstrap takes ~5s, so every probe was killed at the scaffolded healthcheck's timeout: 5s (ExitCode -1) before the check logic ran, and a healthy worker flapped to permanently unhealthy.

Fix

This is the issue's suggested fix #1 (lightweight fast path), done at the root cause — the entry point.

  • The console entry is now vibetuner.cli:main. main() dispatches worker-health straight to a lightweight check before the heavy Typer app is imported.
  • New vibetuner/cli/health.py holds the check: it imports only vibetuner.config and a Redis client, then reads the streaq:{queue}:health:* key. Same exit-code contract as before.
  • The full Typer app (every command + the user CLI via load_app_config()) moved to vibetuner/cli/root.py, built lazily. vibetuner.cli.__init__ stays tiny and re-exposes app/AsyncTyper lazily via __getattr__ for existing importers.
  • python -m vibetuner now routes through main() too, so the fast path applies there as well.
  • Template pyproject.toml.j2 entry point bumped to vibetuner.cli:main so new scaffolds get the fast path.

The healthcheck now returns in well under a second, comfortably inside the existing 5s timeout — no timeout bump needed (issue suggestion #2 left untouched).

Verification

  • uv run vibetuner worker-health and python -m vibetuner worker-health complete in ~0.4s; the fast path does not import vibetuner.cli.root, scaffold, or copier (verified via a fresh-interpreter regression test).
  • version and all other commands still build the full app unchanged.
  • Full unit suite green (961 passed), including the existing 4 worker-health tests plus a new fast-path regression test.

Docs

  • cli-reference.md notes the fast-path behavior for ops users tuning healthcheck timeouts.

🤖 Generated with Claude Code

`vibetuner worker-health` paid the full CLI/app bootstrap (sub-command
imports plus load_app_config importing the user's tune.py) before it
ever read the streaq health key. On a real deploy that bootstrap takes
~5s, so every probe was killed at the scaffolded healthcheck's 5s
timeout and a healthy worker flapped to permanently unhealthy.

Move the console entry to a main() that dispatches `worker-health`
straight to a lightweight check (config + Redis client only) before the
heavy Typer app is imported. The full app, with every command and the
user CLI, now lives in vibetuner.cli.root and is still built lazily for
all other invocations. The healthcheck returns in well under a second.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@davidpoblador davidpoblador merged commit ee77f6c into main Jun 2, 2026
2 checks passed
@davidpoblador davidpoblador deleted the worktree-fix-worker-health-fastpath branch June 2, 2026 16:56
davidpoblador pushed a commit that referenced this pull request Jun 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[10.22.4](v10.22.3...v10.22.4)
(2026-06-02)


### Bug Fixes

* fast-path worker-health to skip CLI bootstrap
([#1974](#1974))
([#1977](#1977))
([ee77f6c](ee77f6c))
* load ProjectConfiguration deploy-config from .env
([#1970](#1970))
([#1971](#1971))
([13b67a7](13b67a7))
* negotiate Accept-Language with language-only subtag fallback
([#1973](#1973))
([#1975](#1975))
([0738181](0738181))


### Documentation Updates

* warn that backgrounded SSE tabs drop events and document resync
([#1978](#1978))
([6bb1a91](6bb1a91))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

vibetuner worker-health too slow to finish within a sane healthcheck timeout (CLI bootstrap ~5s)

1 participant