Skip to content

build: v0.5.8 packaging foundations - #591

Merged
dodjer88 merged 14 commits into
developfrom
build/v058-packaging-foundations
Oct 10, 2026
Merged

dodjer88 merged 14 commits into
developfrom
build/v058-packaging-foundations

Conversation

@yevheniidehtiar

Copy link
Copy Markdown
Owner

Why

These are the packaging and foundation stories of v0.5.8 Bring Your Own App (SDD docs/specs/bring-your-own-app.md, sections E, B.5 and C.3). Today a clean pip install hyper-admin cannot import the package: it creates an aiosqlite engine at import time and relies on undeclared transitive dependencies. hyperadmin.auth registers its hyperadmin_* tables as soon as anything under it is imported. CI installs whatever resolves on the day and does not run on PRs to develop.

Changes

  • st-v058-byoa-11, chore(deps): runtime dependency audit
    • Added pydantic-settings>=2.14.2. It includes the GHSA-4xgf-cpjx-pc3j fix, so that pip-audit ignore is removed.
    • Moved aiosqlite to runtime (zero-config demo mode needs it) and added tzdata on Windows.
    • Dropped appnope. Moved uvicorn and httpx to dev. fastapi[standard] became fastapi.
    • Removed the duplicate python-multipart, added argon2-cffi>=23.1.0, and commented each non-obvious dependency.
  • st-v058-byoa-12, build: committed uv.lock
    • CI installs with uv sync --locked. test.yml runs uv lock --check in every job, and its lowest-direct rows re-resolve.
    • ci.yml runs on push and PR to master and develop (it pointed at a non-existent main).
    • Dependabot uses the uv ecosystem, and uv.lock is excluded from the large-file hook.
  • st-v058-byoa-17, refactor(auth): lazy exports
    • hyperadmin.auth loads its exports lazily (PEP 562). Importing hyperadmin.auth or hyperadmin.auth.middleware no longer registers hyperadmin_* tables.
    • New hyperadmin.auth.metadata() returns only the hyperadmin_* tables, for Alembic users of built-in auth.
  • st-v058-byoa-20, refactor(db): lazy default engine
    • Importing hyperadmin.db creates no engine.
    • get_default_engine(settings) builds the engine from settings.database_url on first use and caches it per URL.
    • from hyperadmin.db import engine still works and emits a DeprecationWarning.
    • New helpers: create_tables, resolve_bind and is_sqlite_url.

Verification

  • uv run poe lint: pass.
  • Unit tests: 981 passed. New test files: test_packaging_dependencies.py, test_ci_lockfile.py, test_auth_lazy_imports.py, test_db_lazy_engine.py.
  • E2E (-n 4): 136 passed. poe vulnerability-check: clean.
  • A built wheel installed in a fresh venv imports Admin; before this change it failed on aiosqlite.
  • With a stale lock, uv sync --locked and uv lock --check both exit 1.
  • Known issue: Python 3.10 lowest-direct was already red on the base branch (pydantic_settings was not installed). It now fails only on a fastapi 0.116.0 / pydantic 2.7.0 InlineModelSpec annotation error, tracked as a follow-up.

Manual test scenarios

  1. In a fresh venv, run uv build --wheel && pip install dist/hyper_admin-*.whl, then python -c "from hyperadmin import Admin". Expect exit 0.
  2. Run python -W error::DeprecationWarning -c "import hyperadmin". Expect no warning and no engine created.
  3. Run python -c "from hyperadmin.db import engine". Expect a DeprecationWarning naming get_default_engine.
  4. Run python -c "import hyperadmin.auth.middleware; from sqlmodel import SQLModel; print([t for t in SQLModel.metadata.tables if t.startswith('hyperadmin_')])". Expect [].
  5. Run python -c "import hyperadmin.auth as a; print(sorted(a.metadata().tables))". Expect only hyperadmin_* tables.
  6. Add a dependency to pyproject.toml without re-locking, then run uv sync --locked. Expect it to fail with a hint to run uv lock.
  7. Open a draft PR against develop. Expect both the CI and Test workflows to run.

🤖 Generated with Claude Code

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@yevheniidehtiar
yevheniidehtiar force-pushed the build/v058-packaging-foundations branch from de0f369 to a81631b Compare October 9, 2026 22:10
dodjer88
dodjer88 previously approved these changes Oct 9, 2026
Claude Code added 13 commits October 10, 2026 01:06
… failure

- loadtest extra: asyncpg>=0.30. 0.29.0 has no CPython 3.13 wheels and
  fails to compile, breaking the 3.13 lowest-direct leg on develop.
- test.yml: upload tests/e2e/snapshots/**/*.actual.png and *.diff.png
  when the push job fails, so drifted baselines (list-375px, 2.9% on
  every ubuntu leg) can be refreshed from the CI runner's own rendering.
The pre-commit ruff hook on develop runs with --fix-only, so poe lint never
reported these; the CI workflow's plain `ruff check .` does.

- N818: rename InlineRowNotOwned -> InlineRowNotOwnedError (unreleased).
- PERF203: move the try/except around the inline save loop.
- PLR0912: extract _parse_list_filters and _validate_inline_formsets from
  list_view and create_view (pure moves, no behaviour change).
- add pydantic-settings>=2.14.2 (imported by core/settings.py; bound
  includes the GHSA-4xgf-cpjx-pc3j fix, so the pip-audit ignore is dropped)
- move aiosqlite to runtime (zero-config demo mode uses sqlite+aiosqlite)
- add tzdata on win32 for zoneinfo
- drop appnope; move uvicorn and httpx to dev; fastapi[standard] -> fastapi
  (dev keeps fastapi[standard] for the fastapi dev CLI used in docs)
- dedupe python-multipart; bound argon2-cffi>=23.1.0
- justify non-obvious runtime deps inline (CONSTITUTION 6)
- annotate loop var in core/introspection.py for mypy 2.4
- stop ignoring uv.lock (!uv.lock after the *.lock rule) and commit it
- ci.yml: uv sync --locked; run on push and pull_request to master and develop
  (it targeted the non-existent main branch)
- test.yml: uv lock --check in every job; highest rows use uv sync --locked,
  lowest-direct rows re-resolve (a lowest-direct install cannot be locked)
- pages/qa/scheduled/release: uv sync --locked
- dependabot: uv ecosystem so dev bumps update pyproject and uv.lock together
- pre-commit: exclude uv.lock from check-added-large-files
…8-byoa-17)

hyperadmin.auth now resolves its exports through PEP 562 __getattr__, so
importing hyperadmin.auth or auth.middleware no longer imports auth.models
and no longer registers hyperadmin_* tables. from hyperadmin.auth import User
keeps working. auth.metadata() returns a MetaData copy holding only the
hyperadmin_* tables for Alembic users of built-in auth.
…-v058-byoa-20)

hyperadmin.db no longer creates an engine at import time.
get_default_engine(settings) builds the demo-mode engine from
settings.database_url on first use and caches it per URL. The module
attribute engine still resolves through __getattr__, with a
DeprecationWarning. core/app.py drops its top-level db import and only
builds the default engine when no engine= is passed.

Adds the DDL helpers the lifecycle work needs: create_tables(engine,
tables), resolve_bind(session_factory) and is_sqlite_url(url).
Raise pydantic floor to 2.10.1 on Python < 3.13 (2.7-2.9 cannot resolve the
InlineModelSpec forward ref; 2.10.0 breaks sqlmodel default factories) and add
sqlalchemy>=2.0.31 on Python >= 3.13 (older releases fail to import there).
SDD Open Question 1: pydantic-settings>=2.14.2 keeps Python 3.10 lowest-direct
green once the pydantic floor is fixed (984 unit tests pass on a real
lowest-direct env for 3.10 and 3.13). Guard an Optional inspect() result that
basedpyright flags against the SQLAlchemy 2.0.14 stubs.
lowest-direct rows re-locked at highest on the first plain uv run, so lint,
unit and e2e never ran on the declared floors. After the lowest-direct sync,
restore the committed uv.lock and export UV_NO_SYNC=1 (nested uv run in
pre-commit hooks included). poe deps:bump does the same, restoring the freshly
upgraded lock from a backup. The security audit runs on the locked highest set
only, since old floor releases carry known advisories by definition. Document
the Dependabot uv dependency-type caveat (dependabot-core#13202).
SDD B.5: auth.metadata() logs a WARNING when an Admin in bridge mode has
already been built in the process. The bridge story sets the flag through
hyperadmin.auth._note_bridge_admin_constructed().
Demo mode now reads settings.database_url, which can point at the host's own
database. Skip startup create_all there unless the URL is SQLite or
create_tables was set explicitly, and log the SDD C.2 WARNING. Also drop the
module-level db -> core.settings import (CONSTITUTION section 2 cycle); the
settings default is resolved inside get_default_engine.
…8-byoa-12)

The Python 3.10 lowest-direct leg hung in 'Test package' until GitHub's
6-hour limit (not reproducible locally: 993 tests in 39s on the same
resolution). faulthandler_timeout makes the next hang print every
thread's stack; timeout-minutes stops a hang from burning a runner.
@yevheniidehtiar
yevheniidehtiar force-pushed the build/v058-packaging-foundations branch from 268cc8f to a6b79c1 Compare October 10, 2026 06:57
…it (st-v058-byoa-11)

aiosqlite 0.22 moved its worker off threading.Thread, so SQLAlchemy's
`connection.daemon = True` no longer applies and a pooled connection keeps
the interpreter alive after the last test (lowest-direct CI hung after
'1127 passed' until the job timeout). SQLAlchemy 2.0.46 stops the worker via
aiosqlite's stop() (sqlalchemy/sqlalchemy#13039). This also supersedes the
separate 2.0.31 floor for Python 3.13.
@dodjer88
dodjer88 merged commit d6c2a67 into develop Oct 10, 2026
18 checks passed
@dodjer88
dodjer88 deleted the build/v058-packaging-foundations branch October 10, 2026 08:29
dodjer88 pushed a commit that referenced this pull request Oct 11, 2026
Done (#590, #591, #592): st-v058-byoa-10..14, 16..20, 53.
In progress (wave 1): 15, 21, 23, 25, 33, 34.
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.

3 participants