Repository navigation
openconceptlab 0.2.0: the API client as an importable core package - #14
Conversation
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
…eptlab core package Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
…eme, headers, timeout Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
… failed; raise the httpx error after retries Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
…anker Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
…ersions Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
…IError.body, error docs, CI permissions Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
|
Codex review, pass 1 (codex-cli 0.163.0, commit 5169185): clean, no findings. It reviewed the full diff against the ticket's acceptance criteria, the repository's conventions and its tests. The full pass is on the tracking ticket. |
|
Simplification review (Claude subagent, commit 5169185): two possible test cuts, both declined. One is the check that the exported |
…rigin A request hook on the httpx client refuses any request outside base_url's origin and path, including URLs taken from API responses, so the Authorization header only ever goes to the API. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH
|
Adversarial review of token handling (Claude subagent, commit 5169185): one issue was fixed in this PR, and one hardening item is deferred.
The full report is on the tracking ticket. A Codex check of a544126 follows. |
|
Adversarial re-verification (commit a544126): no material issues. The origin guard closes the cross-host finding, and legitimate requests still work. Four low-severity hardening notes about the hook are recorded on the tracking ticket as candidates for a later patch release. |
Linked Issue
Closes OpenConceptLab/ocl_online#507
Summary
The API client that
ocluses becomes an importable package,openconceptlab, so other tools can use it without the CLI. It ships in the same PyPI distribution,openconceptlab. Theoclcommand and its output don't change. Version 0.2.0.ruff check src testswas failing, with 16 errors. They're fixed: import sorting and unused imports, plus one unused variable. A new workflow runs ruff and pytest on every PR, on Python 3.10 and 3.13, with a read-only token.src/ocl_cli/api_client.pytosrc/openconceptlab/client.py, which doesn't import Click.openconceptlabexportsOCLAPIClient,APIErrorand__version__.ocl_cli.api_clientis now a two-name shim, so the command modules and their tests don't change.pyproject.tomlis the only source. Before,ocl_cli/__init__.pyhardcoded 0.1.0 while the package was 0.1.1.OCLAPIClient(base_url=None, token=None, *, auth_scheme="Token", client_name=None, headers=None, timeout=30.0).client_namesetsX-OCL-CLIENTand the User-Agent. It defaults toopenconceptlab/<version>, and the CLI passesocl-cli/<version>, as before.auth_scheme="Bearer"sends an OIDC access token instead of an API token.headersare added to every request and override the defaults, whatever the case of the header names.base_url's origin and path, including URLs taken from API responses, so the Authorization header only ever goes to the API.APIError.bodyholds the error response's parsed JSON, or its text when it isn't JSON.detail, the message andto_dict()are unchanged, because the CLI prints them.$matchcould run twice. GET, PUT, PATCH and DELETE retry as before.httpx.ReadTimeoutand so on), nottenacity.RetryError.match_conceptstakesrows, full$matchrows with properties such asconcept_class,datatypeorsynonyms, andreranker=True.list_expansion_conceptslists the concepts in a collection version's expansion, a page at a time. It uses the version's default expansion unless an expansion ID is given.changelogcalls$changelogfor two versions of a source or collection. While OCL is still computing it, it returns{"status": "pending", ...}: HTTP 202 after OCL's own wait, or 409 when the same request is already queued.Test Plan
pytest -q: 49 passed, up from 24. The newtests/test_core_package.pyandtests/test_client.pyuse pytest-httpx.ruff check src tests: all checks passed.import openconceptlabandocl --versionboth work there.Notes
v0.2.0happen after merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01QvHhCgtEqAD6xKyJAbToDH