Skip to content

feat: SDK version-compat gate, health version surface, upgrade nudge#52

Merged
kj-podonos merged 1 commit into
mainfrom
kj-podonos/version-checks
Jun 18, 2026
Merged

feat: SDK version-compat gate, health version surface, upgrade nudge#52
kj-podonos merged 1 commit into
mainfrom
kj-podonos/version-checks

Conversation

@kj-podonos

Copy link
Copy Markdown
Contributor

Summary

Adds SDK version-compatibility handling, a richer onepin health, and a soft upgrade nudge.

  • Required-version gate (hard). Reads X-OnePin-Required-Version off API responses (and maps a server HTTP 426) → when the installed onepin is below the floor, the CLI stops with a yellow, copy-paste upgrade message + exit 1. Works for the CLI and for programmatic users via onepin.make_client(...) (a version-gated OnePinClient that also corrects a stale baked User-Agent). The raw auth path (login/whoami) surfaces 426 too. Server-supplied versions are PEP 440-validated before being interpolated into the pip command (no copy-paste injection).
  • onepin health live/ready now report status, SDK version (local), API version (server), and the recommended/required versions. --json supported; unknown sources render unknown.
  • Recommended nudge (soft). Hidden onepin upgrade-check (PyPI source, daily/dual-TTL cache, escalating snooze, --disable, --mark-upgrading) drives a recurring upgrade prompt via the /onepin agent skill. The CLI itself never nags on stderr.

Regen-safety

src/onepin/_version_gate.py is preserved via .fernignore and re-exported through fern/generators.yml additional_init_exports, so from onepin import make_client survives fern generate. CLI startup stays SDK-free (deferred imports; fast-startup test passes).

Backend dependency (graceful degradation)

The gate is inert until the API emits the data — no header / offline PyPI / absent backend all degrade to no-ops, so this is safe to merge ahead of the server work. To activate: the API adds an X-OnePin-Required-Version response header (from a live-editable config value) and returns 426 with {error.code:"sdk_upgrade_required", required_version, upgrade_url} when the User-Agent version is below the floor. recommended needs no backend — it's the newest release on PyPI.

Test Coverage

New: tests/unit/test_version_gate.py, tests/unit/test_update_check.py, tests/cli/test_cli_health.py — gate logic (compare/validate/header parse, injection guard), make_client hook + UA, upgrade-check cache/snooze/disable/marker, health human + JSON, required-stop via header and 426, auth-path 426.

Reviews

  • Claude code-review: 0 critical/high after fixes.
  • Codex review: GATE PASS (PEP 440 injection guard + reachable JUST_UPGRADED addressed).

Test plan

  • uv run pytest — 295 passed
  • ruff check + ruff format --check clean
  • mypy -p onepin._cli clean
  • python -m build — wheel + sdist OK

🤖 Generated with Claude Code

@kj-podonos kj-podonos added the enhancement New feature or request label Jun 17, 2026
@kj-podonos kj-podonos self-assigned this Jun 17, 2026
Required-version gate via the X-OnePin-Required-Version header (and HTTP 426) for the CLI
and programmatic SDK (onepin.make_client); server versions are PEP 440-validated before being
pinned into the pip command, and the raw auth path surfaces 426 too.

onepin health live/ready now report status + SDK/API/recommended/required versions.

Hidden 'onepin upgrade-check' (PyPI source, dual-TTL cache, escalating snooze, --disable,
--mark-upgrading) drives a gstack-style /onepin agent-skill upgrade prompt; the CLI never
nags on stderr. AGENTS.md records the new hand-rolled module + the __init__ re-export patch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kj-podonos kj-podonos force-pushed the kj-podonos/version-checks branch from 537163e to 05661bb Compare June 17, 2026 11:18

@kdh-podonos kdh-podonos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kj-podonos kj-podonos merged commit e61a07d into main Jun 18, 2026
18 checks passed
@kj-podonos kj-podonos deleted the kj-podonos/version-checks branch June 18, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants