Skip to content

feat(core): v0.5.8 core foundations - #592

Merged
dodjer88 merged 10 commits into
developfrom
feat/v058-core-foundations
Oct 10, 2026
Merged

dodjer88 merged 10 commits into
developfrom
feat/v058-core-foundations

Conversation

@yevheniidehtiar

Copy link
Copy Markdown
Owner

Why

First slice of v0.5.8 "Bring Your Own App" (SDD docs/specs/bring-your-own-app.md): the pure core building blocks that later stories wire into adapters, routing and views. This adds no new routes, templates or middleware. The one runtime change is in the auth timestamps.

Changes

  • st-v058-byoa-13 — core/primary_key.py (SDD A.1): PrimaryKeyInfo codec (parse / to_str / to_json / value_of / path_convertor), InvalidPrimaryKey, DEFAULT_PK. BaseAdapter gains a non-abstract pk (defaults to DEFAULT_PK) and datetime_kind(), so third-party adapters keep working unchanged.
  • st-v058-byoa-14 — core/timezones.py + settings.timezone (A.7): utc_now, is_auto_now_factory, parse_datetime_input (fold=0 in DST gaps), format_datetime_input, to_display. New HYPERADMIN_TIMEZONE (default UTC, validated with ZoneInfo). Runtime dep tzdata; sys_platform == 'win32'.
  • st-v058-byoa-16 — tz-aware auth timestamps (A.8): auth/_types.UTCNaiveDateTime keeps the naive timestamp DDL (no migration) and returns aware UTC values. created_at on User/Group/Permission and User.updated_at use it with default_factory=utc_now. Pinning sa_type keeps the DDL stable on sqlmodel <0.0.45 and >=0.0.45. PydanticForm recognises the new auto-now factory.
  • st-v058-byoa-18 — AdminAuthenticationRequired / AdminAccessDenied + core/csrf.CsrfTokenSigner (D.1): stdlib-only signed double-submit tokens (<nonce>.<hmac>, constant-time checks). Nothing uses it yet.
  • st-v058-byoa-19 — core/filtering.py (D.3): FilterCondition, FilterValueError, coerce_filter_value, parse_filter_params (whitelist; exact / gte / lte / in / isnull; whole-day bounds for dates on datetime fields, localised for aware columns), normalize_filters. Adapters start applying these in st-v058-byoa-24.
  • Chore: annotate a loop variable in core/introspection.py that fails mypy on Python 3.10.

Size note: core/filtering.py is 332 LOC, over the CONSTITUTION §5 ~300-line review trigger. It is kept as one module because it has a single responsibility: turning query params into typed conditions.

Boundaries: the new core/* modules import only the stdlib, pydantic and zoneinfo; tests check this for csrf.py and filtering.py. auth/models.py still imports nothing from core/ directly.

Verification

  • uv run poe lint — passed
  • uv run pytest tests -o addopts="" -q -n 4 --ignore=tests/e2e — 1123 passed
  • uv run pytest tests/e2e -o addopts="" -q -n 4 — 136 passed
  • New unit tests: test_primary_key (33), test_timezones (37), test_auth_datetime_types (18), test_core_csrf (29), test_filtering (71), test_forms (+2). Every story scenario maps to a test with a Given/When/Then docstring.

Manual test scenarios

  1. Auth timestamps are aware UTC
    Given the simple example with built-in auth and a fresh SQLite DB
    When you run hyperadmin createsuperuser and load the user in a Python shell
    Then user.created_at.tzinfo is UTC
    And the SQLite column holds a naive YYYY-MM-DD HH:MM:SS.ffffff UTC string
  2. Existing DB needs no migration
    Given a database created before this branch
    When the admin starts
    Then users still list, and the created_at values are unchanged and now shown as UTC
  3. Invalid timezone fails fast
    Given HYPERADMIN_TIMEZONE=Mars/Olympus
    When the app starts
    Then settings validation fails and the error names timezone
  4. Forms still hide auto timestamps
    Given a model with created_at = Field(default_factory=utc_now)
    When you open its create form
    Then no created_at input is rendered
  5. No behaviour change elsewhere
    When you open the list, detail, create, edit and delete pages for int-pk models in the example app
    Then everything works as before (URLs, filters and popups are unchanged)

🤖 Generated with Claude Code

@yevheniidehtiar
yevheniidehtiar force-pushed the feat/v058-core-foundations branch 2 times, most recently from a05dc9f to b2fc152 Compare October 9, 2026 22:05
@yevheniidehtiar
yevheniidehtiar force-pushed the feat/v058-core-foundations branch from b2fc152 to 37eef22 Compare October 9, 2026 23:05
@dodjer88
dodjer88 merged commit 7c5aeff into develop Oct 10, 2026
10 checks passed
@dodjer88
dodjer88 deleted the feat/v058-core-foundations branch October 10, 2026 08:36
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.

2 participants