Skip to content

fix(autohooks): close ariel connections on the success path too - #198

Merged
Cipher208 merged 2 commits into
masterfrom
fix/autohooks-close-on-success
Nov 13, 2026
Merged

Cipher208 merged 2 commits into
masterfrom
fix/autohooks-close-on-success

Conversation

@Cipher208

Copy link
Copy Markdown
Owner

Problem

Every CLI command branch in autohooks/__main__.py ends with return 0 inside the try block, and a return from a try body skips the else clause entirely — so _close_ariel() never ran on the success path, which is the path every hook takes.

The unclosed aiosqlite connection keeps a non-daemon worker thread alive. threading._shutdown joins it forever: the process prints its output, then hangs until the 120 s watchdog kills it.

Observed impact

autohooks inject (the opencode/ariel session-start hook) hangs 120 s. The hook's spawnSync timeout is 20 s, so the already-printed output is discarded — memory injection was silently lost on every session start. Confirmed in production: only mirror drift surfaced lines in the log, zero injected lines.

Fix

Move the close into finally so both paths are covered, and add the missing success-path regression test. The pre-existing test covered only the exception path — which is exactly why this survived.

Verification

  • autohooks inject: 120 s hang → 2.2 s, rc=0
  • autohooks inject --with-recap: 2.2 s, rc=0
  • Live: system.transform: injected 3280B (with recap) now fires on every session start
  • ruff check . / ruff format --check .: clean
  • mypy over 10 dirs: no issues in 245 source files
  • pytest tests/ -q: 2869 passed

Every CLI command branch ends with 'return 0' inside the try block, and a
return from a try body skips the else clause - so _close_ariel() never ran
on the path every hook takes. The unclosed aiosqlite connection kept a
non-daemon worker thread, threading._shutdown joined it forever, and the
process printed its output then hung until the 120s watchdog killed it.

Observed impact: 'autohooks inject' (the opencode/ariel session-start hook)
hangs 120s; the hook's 20s spawnSync timeout then discards the output, so
memory injection was silently lost on every session start.

Move the close into finally so both paths are covered, and add the missing
success-path regression test (the existing test only covered the exception
path, which is why this survived).

inject: 120s hang -> 2.2s clean exit; full suite 2869 passed, mypy clean.
@github-actions github-actions Bot added the fix label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

typecheck and docs declare setup-python's 'cache: pip' but then install
everything through uv, so /home/runner/.cache/pip is never created and
setup-python's post step fails the job:

    ##[error]Cache folder path is retrieved for pip but doesn't exist on disk

The real steps passed in every run (mypy success, docs build success); only
the cleanup failed, which left every PR blocked on a red check. Jobs that do
use pip (lint, audit, docs.yml) keep the cache.
@Cipher208
Cipher208 merged commit 4d9b721 into master Nov 13, 2026
19 checks passed
@Cipher208
Cipher208 deleted the fix/autohooks-close-on-success branch November 13, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant