Skip to content

Tests, cleanup and bug fixes (Nov 2026 audit, 1 of 2) - #10

Merged
cycle-five merged 3 commits into
masterfrom
cleanup/tests-and-fixes-2026-11
Nov 3, 2026
Merged

cycle-five merged 3 commits into
masterfrom
cleanup/tests-and-fixes-2026-11

Conversation

@cycle-five

Copy link
Copy Markdown
Owner

First maintenance pass since April 2026. Full write-up of the audit lands in PR 2 (docs/AUDIT-2026-11.md, stacked on this branch).

Headline

The test suite did not run in a clean environment: app.main builds Settings() at import time, so collection died with a pydantic ValidationError unless ADMIN_PASSWORD / ADMIN_SECRET_KEY / LAVALINK_PASSWORD were set — and with no CI, nothing noticed.

Tests: 30 -> 161, coverage 49% -> 94%

  • admin/tests/conftest.py: supplies test env before any app import (setdefault, real env wins), resets the global config lock per test, lifespan-free client/authed_client fixtures (no APScheduler / Docker log tail in tests).
  • New coverage: StateStore, docker_ctl, OAuth rotation, the /healthz contract (Lavalink critical, cipher/pot advisory), HTTP-level login/middleware flow, config-router conditional writes, track tester branches, log filters, tokens masking/status, cipher/pot/lavalink services, settings, and a contract test pinning the shipped application.yml paths that setup.sh (indentation-keyed sed) and the PoT/OAuth writers depend on.
  • pyproject.toml: pytest testpaths + asyncio fixture loop scope pinned, pytest-cov in dev deps.

Bugs the new tests caught (fixed here)

  1. StateStore._ensure_dir crashed on a bare-filename state path (os.makedirs("")).
  2. docker_ctl.stream_logs had a dead except docker.errors.NotFound branch — a missing container reported "Stream interrupted" instead of "not found".
  3. write_config_to_disk left a partial .tmp behind when the YAML dump itself failed.
  4. log_watcher: extracted process_log_line() from the infinite loop as a testable seam; unused imports removed across app/tests (pyflakes clean).

Held back from this PR

.github/workflows/ci.yml (pytest+coverage, pyflakes, docker compose config -q, terraform fmt -check — all verified locally) could not be pushed: the Muse GitHub App lacks the workflows permission on this repo, so GitHub rejects any tree containing .github/workflows/*. It will be added as a follow-up commit the moment that permission is granted (same grant as the kharon app needed).

Verification

161 passed in a clean env (no env vars set), coverage 94%; pyflakes clean; docker compose config -q and terraform fmt -check pass with the real binaries.

PR 2 (stacked on this branch) carries the dependency/config changes from the same audit: youtube-plugin 1.18.2, LavaSrc 4.8.3, Lavalink pinned 4.2.2, yt-cipher IAS variant.

- conftest.py makes the suite runnable in a clean environment (it
  previously died at collection without ADMIN_*/LAVALINK_* env); suite
  goes 30 -> 161 tests, coverage 49% -> 94%
- New tests: StateStore, docker_ctl, oauth rotate, /healthz contract,
  HTTP login/middleware flow, config router, track tester, log filters,
  tokens, cipher/pot/lavalink services, shipped application.yml contract
- Fixes: StateStore bare-filename crash, dead NotFound branch in
  stream_logs, .tmp litter on YAML dump failure
- log_watcher: extract process_log_line() testable seam; unused imports
  removed (pyflakes clean)
…rraform fmt)

Pushed via the cycle-five-muse-personal app: the built-in Meta Muse
app does not request the workflows permission, so it could not push
.github/workflows/* (403). Verified locally before push: 161 tests
pass in a clean env, pyflakes clean, compose config and terraform
fmt checks pass.
…path

test_get_settings_and_get_state_are_cached called the real get_state(),
which makedirs /state (the production state_path default). Passed
locally as root; PermissionError on the GitHub runner (160/161 passed
in run 41576335082). The test is now hermetic: tmp state path +
cache_clear around the check. test_settings_defaults still pins the
/state default. Local re-run: 161 passed, no /state created.
@cycle-five-muse-personal

Copy link
Copy Markdown
Contributor

CI is now on this PR — and green.

Correction to the PR description: .github/workflows/ci.yml could not be added by granting the built-in Meta Muse app a permission — that app's permission set is Meta's, and it does not request workflows. It was instead pushed through Lothrop's new personal-account app cycle-five-muse-personal (same pattern as the CycleFive-org app used for kharon):

  • d49c5d4 adds .github/workflows/ci.yml (authored by cycle-five-muse-personal[bot]).
  • First CI run caught one real environment bug: test_get_settings_and_get_state_are_cached called the real get_state(), which makedirs /state (the production default) — fine as root locally, PermissionError on the runner (160/161). 7c6a52c makes that test hermetic (tmp state path + cache clear); test_settings_defaults still pins the /state default.
  • Run 41576549737: all three jobs pass — admin tests (161, 94% coverage), compose config, terraform fmt.

@cycle-five
cycle-five added this pull request to stack #12 November 3, 2026 04:44
@cycle-five
cycle-five merged commit fce6849 into master Nov 3, 2026
3 checks passed
@cycle-five-muse-personal
cycle-five-muse-personal Bot deleted the cleanup/tests-and-fixes-2026-11 branch November 3, 2026 04:51
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.

1 participant