iiisight 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. iiisight-0.1/.gitignore +35 -0
  2. iiisight-0.1/.gitlab-ci.yml +76 -0
  3. iiisight-0.1/.readthedocs.yaml +26 -0
  4. iiisight-0.1/CHANGELOG.md +39 -0
  5. iiisight-0.1/CLAUDE.md +122 -0
  6. iiisight-0.1/CONTRIBUTING.md +90 -0
  7. iiisight-0.1/LICENSE +201 -0
  8. iiisight-0.1/NOTICE +4 -0
  9. iiisight-0.1/PKG-INFO +210 -0
  10. iiisight-0.1/PLAN.md +374 -0
  11. iiisight-0.1/README.md +172 -0
  12. iiisight-0.1/docs/_static/.gitkeep +0 -0
  13. iiisight-0.1/docs/_templates/.gitkeep +0 -0
  14. iiisight-0.1/docs/changelog.md +2 -0
  15. iiisight-0.1/docs/conf.py +48 -0
  16. iiisight-0.1/docs/contributing.md +2 -0
  17. iiisight-0.1/docs/guide/auth.md +69 -0
  18. iiisight-0.1/docs/guide/content-state.md +52 -0
  19. iiisight-0.1/docs/guide/fetching.md +125 -0
  20. iiisight-0.1/docs/guide/images.md +74 -0
  21. iiisight-0.1/docs/guide/model.md +83 -0
  22. iiisight-0.1/docs/guide/search.md +54 -0
  23. iiisight-0.1/docs/guide/tolerance.md +75 -0
  24. iiisight-0.1/docs/index.md +65 -0
  25. iiisight-0.1/docs/installation.md +34 -0
  26. iiisight-0.1/docs/quickstart.md +94 -0
  27. iiisight-0.1/docs/reference/api.md +87 -0
  28. iiisight-0.1/iiisight/__init__.py +129 -0
  29. iiisight-0.1/iiisight/auth.py +215 -0
  30. iiisight-0.1/iiisight/client.py +339 -0
  31. iiisight-0.1/iiisight/content_state.py +149 -0
  32. iiisight-0.1/iiisight/diagnostics.py +46 -0
  33. iiisight-0.1/iiisight/errors.py +36 -0
  34. iiisight-0.1/iiisight/image.py +98 -0
  35. iiisight-0.1/iiisight/language.py +73 -0
  36. iiisight-0.1/iiisight/lint.py +75 -0
  37. iiisight-0.1/iiisight/model.py +412 -0
  38. iiisight-0.1/iiisight/normalize.py +575 -0
  39. iiisight-0.1/iiisight/py.typed +0 -0
  40. iiisight-0.1/iiisight/search.py +58 -0
  41. iiisight-0.1/iiisight/transport.py +45 -0
  42. iiisight-0.1/iiisight/upgrade.py +301 -0
  43. iiisight-0.1/iiisight.egg-info/PKG-INFO +210 -0
  44. iiisight-0.1/iiisight.egg-info/SOURCES.txt +69 -0
  45. iiisight-0.1/iiisight.egg-info/dependency_links.txt +1 -0
  46. iiisight-0.1/iiisight.egg-info/requires.txt +18 -0
  47. iiisight-0.1/iiisight.egg-info/scm_file_list.json +66 -0
  48. iiisight-0.1/iiisight.egg-info/scm_version.json +8 -0
  49. iiisight-0.1/iiisight.egg-info/top_level.txt +1 -0
  50. iiisight-0.1/pyproject.toml +71 -0
  51. iiisight-0.1/scripts/validate_realworld.py +166 -0
  52. iiisight-0.1/setup.cfg +4 -0
  53. iiisight-0.1/tests/conftest.py +28 -0
  54. iiisight-0.1/tests/fixtures/README.md +25 -0
  55. iiisight-0.1/tests/fixtures/image/v2/info.json +21 -0
  56. iiisight-0.1/tests/fixtures/image/v3/info.json +17 -0
  57. iiisight-0.1/tests/fixtures/presentation/imperfect/v3-lossy-manifest.json +32 -0
  58. iiisight-0.1/tests/fixtures/presentation/v2/minimal-manifest.json +41 -0
  59. iiisight-0.1/tests/fixtures/presentation/v3/minimal-manifest.json +43 -0
  60. iiisight-0.1/tests/test_auth.py +229 -0
  61. iiisight-0.1/tests/test_client.py +203 -0
  62. iiisight-0.1/tests/test_content_state.py +107 -0
  63. iiisight-0.1/tests/test_image.py +232 -0
  64. iiisight-0.1/tests/test_language.py +42 -0
  65. iiisight-0.1/tests/test_lint.py +35 -0
  66. iiisight-0.1/tests/test_normalize_details.py +289 -0
  67. iiisight-0.1/tests/test_normalize_v3.py +100 -0
  68. iiisight-0.1/tests/test_search.py +170 -0
  69. iiisight-0.1/tests/test_smoke.py +27 -0
  70. iiisight-0.1/tests/test_tolerance.py +73 -0
  71. iiisight-0.1/tests/test_upgrade.py +308 -0
@@ -0,0 +1,35 @@
1
+ # macOS
2
+ .DS_Store
3
+
4
+ # Byte-compiled / optimized
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # Distribution / packaging
10
+ build/
11
+ dist/
12
+ *.egg-info/
13
+ .eggs/
14
+
15
+ # Virtual environments
16
+ .venv/
17
+ venv/
18
+ env/
19
+
20
+ # Docs build output
21
+ docs/_build/
22
+
23
+ # Test / coverage / caches
24
+ .pytest_cache/
25
+ .mypy_cache/
26
+ .ruff_cache/
27
+ .coverage
28
+ htmlcov/
29
+
30
+ # Environments / secrets
31
+ .env
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
@@ -0,0 +1,76 @@
1
+ # CI: test across Python 3.10-3.13, publish to PyPI on a version tag, and
2
+ # rehearse on TestPyPI on a prerelease (rc) tag. Publishing uses GitLab OIDC
3
+ # trusted publishing (no stored token).
4
+ #
5
+ # One-time PyPI setup: add "pending publisher" (GitLab) entries with
6
+ # Namespace: iiiris-org Project: iiisight
7
+ # Top-level pipeline file path: .gitlab-ci.yml (Environment: leave blank)
8
+ # at BOTH:
9
+ # - https://pypi.org/manage/account/publishing/ (for `publish`)
10
+ # - https://test.pypi.org/manage/account/publishing/ (for `publish-testpypi`)
11
+ #
12
+ # Release flow:
13
+ # git tag v0.1rc1 && git push origin v0.1rc1 -> uploads to TestPyPI (rehearsal)
14
+ # git tag v0.1 && git push origin v0.1 -> uploads to PyPI (real release)
15
+
16
+ stages:
17
+ - test
18
+ - deploy
19
+
20
+ variables:
21
+ GIT_DEPTH: "0" # full history so setuptools-scm can see tags
22
+
23
+ test:
24
+ stage: test
25
+ image: python:${PY}
26
+ parallel:
27
+ matrix:
28
+ - PY: ["3.10", "3.11", "3.12", "3.13"]
29
+ script:
30
+ - pip install -e ".[dev]"
31
+ - ruff check .
32
+ - ruff format --check .
33
+ - pytest
34
+
35
+ # Shared publish logic. Exchanges the GitLab OIDC token for a short-lived PyPI
36
+ # API token via the mint endpoint, then uploads. Concrete jobs set the audience,
37
+ # mint URL, and repository URL for PyPI vs. TestPyPI.
38
+ .publish:
39
+ stage: deploy
40
+ image: python:3.12
41
+ script:
42
+ - pip install build twine
43
+ - python -m build
44
+ - twine check dist/*
45
+ - |
46
+ RESPONSE=$(curl -s -X POST "$MINT_URL" -d "{\"token\":\"${PYPI_ID_TOKEN}\"}")
47
+ API_TOKEN=$(echo "$RESPONSE" | python -c "import sys, json; print(json.load(sys.stdin).get('token', ''))")
48
+ if [ -z "$API_TOKEN" ]; then
49
+ echo "OIDC token exchange failed at $MINT_URL."
50
+ echo "Response (no access token — check the trusted publisher config):"
51
+ echo "$RESPONSE"
52
+ exit 1
53
+ fi
54
+ TWINE_USERNAME=__token__ TWINE_PASSWORD="$API_TOKEN" twine upload --repository-url "$REPO_URL" dist/*
55
+
56
+ publish:
57
+ extends: .publish
58
+ rules:
59
+ - if: '$CI_COMMIT_TAG =~ /^v[0-9]+(\.[0-9]+)*$/' # v0.1, v1.2.3 (not prereleases)
60
+ id_tokens:
61
+ PYPI_ID_TOKEN:
62
+ aud: pypi
63
+ variables:
64
+ MINT_URL: https://pypi.org/_/oidc/mint-token
65
+ REPO_URL: https://upload.pypi.org/legacy/
66
+
67
+ publish-testpypi:
68
+ extends: .publish
69
+ rules:
70
+ - if: '$CI_COMMIT_TAG =~ /^v[0-9].*rc/' # v0.1rc1, v1.0rc2 (rehearsal)
71
+ id_tokens:
72
+ PYPI_ID_TOKEN:
73
+ aud: testpypi
74
+ variables:
75
+ MINT_URL: https://test.pypi.org/_/oidc/mint-token
76
+ REPO_URL: https://test.pypi.org/legacy/
@@ -0,0 +1,26 @@
1
+ # Read the Docs build configuration.
2
+ # https://docs.readthedocs.io/en/stable/config-file/v2.html
3
+
4
+ version: 2
5
+
6
+ build:
7
+ os: ubuntu-24.04
8
+ tools:
9
+ python: "3.12"
10
+ jobs:
11
+ post_checkout:
12
+ # setuptools-scm derives the version from tags; fetch them for a clean version.
13
+ - git fetch --tags --unshallow || true
14
+
15
+ sphinx:
16
+ configuration: docs/conf.py
17
+
18
+ python:
19
+ install:
20
+ - method: pip
21
+ path: .
22
+ extra_requirements:
23
+ - docs
24
+
25
+ formats:
26
+ - pdf
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to iiisight are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/), and the project aims to follow
5
+ [Semantic Versioning](https://semver.org/). The version is derived from the git
6
+ tag by setuptools-scm; there is no hand-maintained version string.
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1] - 2026-07-05
11
+
12
+ First public release. iiisight is a tolerant, async (and sync) Python client for
13
+ consuming IIIF. This is a pre-1.0 line — the public API may still change before
14
+ 1.0.
15
+
16
+ ### Added
17
+
18
+ - Tolerant normalization of IIIF Presentation documents into a typed, frozen
19
+ model (`normalize`), with structured `Diagnostic`s for every repair — it never
20
+ raises on spec-imperfect input.
21
+ - Presentation **v2 → v3 upgrade** run before parsing, so v2 and v3 documents
22
+ normalize to one model.
23
+ - Async and sync fetch clients (`AsyncClient` / `Client`) over `httpx`, with
24
+ `fetch` / `fetch_manifest` / `fetch_collection` / `resolve` / `expand`, plus
25
+ module-level convenience functions.
26
+ - **Image API** tile-aware retrieval: `parse_info` (info.json → `ImageService`),
27
+ and `ImageService.url` / `thumbnail_url` / `tile_grid` / `tile_pyramid`, with
28
+ the v2/v3 `full`-vs-`max` size handling. `client.load_info` / `fetch_region`.
29
+ - **Content Search** (`client.search`, `find_search_service`) returning hit
30
+ annotations.
31
+ - **Content State** decode/encode (`iiisight.content_state`).
32
+ - **Authorization Flow 2.0** metadata + non-interactive probe/token exchange
33
+ (`iiisight.auth`, `client.probe`, `client.access_token`).
34
+ - Consumer **lint** over normalization diagnostics (`iiisight.lint`).
35
+ - Generic `Service` model (with preserved `raw` JSON) parsed from resource-level
36
+ `service` blocks.
37
+
38
+ [Unreleased]: https://gitlab.com/iiiris-org/iiisight/-/compare/v0.1...main
39
+ [0.1]: https://gitlab.com/iiiris-org/iiisight/-/tags/v0.1
iiisight-0.1/CLAUDE.md ADDED
@@ -0,0 +1,122 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Current state
6
+
7
+ Working library, pre-1.0. `PLAN.md` tracks the phased build and its status. Implemented today: tolerant Presentation normalization (`normalize`) into a typed frozen model with diagnostics; the v2→v3 upgrade; async + sync fetch clients (`AsyncClient`/`Client`); tile-aware Image API retrieval (`ImageService`, `parse_info`, `client.load_info`/`fetch_region`); Content Search (`client.search`); Content State (`iiisight.content_state`); Auth Flow 2.0 metadata + non-interactive probe/token (`iiisight.auth`); and a consumer lint (`iiisight.lint`). ~116 tests, ~95% coverage. Not yet released to PyPI; the name is reserved-available. Remaining: Image API conformance probe, Change Discovery, an optional CLI, and the first tagged release.
8
+
9
+ ## Project intent
10
+
11
+ **Goal:** a reusable Python package for building applications that *consume* IIIF — the read-side substrate for viewers, search, harvesting, and conformance tooling. iiisight is the engine other people build on, not an end-user application.
12
+
13
+ `iiisight` is a **tolerant, async Python client for *consuming* IIIF** — the read/consume counterpart to the JavaScript ecosystem's `@iiif/parser`. The target deliverable:
14
+ - Fetches a IIIF manifest or collection over HTTP (async).
15
+ - Normalizes Presentation API v2 → v3 so callers work against a single model.
16
+ - Walks the IIIF structure: collections, manifests, canvases, ranges, and annotations.
17
+ - Provides tile-aware image retrieval (Image API), computing region/size/tile requests from a service's `info.json` rather than fetching whole images.
18
+
19
+ Design pillars that should guide decisions: **read-first** (consuming, not authoring), **async-first**, **tolerant** (accept real-world, spec-imperfect documents; degrade rather than raise), **normalized** (hide v2/v3 differences behind one interface), **ergonomic traversal**, and **tile-aware**.
20
+
21
+ **Ecosystem positioning (important for scope decisions).** The premise is *not* "no Python IIIF library exists" — several do, but fragmented by concern and version, and all synchronous:
22
+ - `iiif-prezi3` — the *construction* (write-side) library for Presentation **v3**; loads static v3 JSON but no URL fetch, no v2, no async, no traversal/Image-API helpers.
23
+ - `piffle` — parses/builds Image API URLs and can `from_url()` a manifest and iterate canvases; the closest existing client, but **sync**, no v2→v3 normalization, thin range/annotation traversal, no tile-aware region math.
24
+ - `iiif-prezi` (v2 reference) and `prezi-2-to-3` (standalone v2→v3 upgrade) cover the old version and the upgrade in isolation.
25
+
26
+ iiisight fills the *integration* gap — an async, tolerant, version-agnostic **read** model with tile-aware retrieval. The two capabilities that exist nowhere else in Python — **async fetching** and **tile-aware Image API retrieval** — are the differentiators to protect.
27
+
28
+ **Consolidation principle (overlap is allowed).** Overlapping existing tools is fine when it makes the unified client genuinely better. The test for pulling a capability in is *"does iiisight's existing machinery make the unified version better, and does it stay read-shaped?"* — **not** "does another tool already do it?" By that test an Image API conformance probe and a consumer manifest lint are in-scope future layers, not scope creep. Reuse vs. reinvent is then a pure engineering call (reuse iiif-prezi3's v3 types / prezi-2-to-3's upgrade when the dependency is clean; **own the layer** when sync/write-oriented/low-tolerance constraints would cap quality) — "better in one place" often favors owning more of the stack so tolerance, async, and diagnostics stay first-class.
29
+
30
+ **Design decision — structured diagnostics.** The normalization layer must **record every deviation it repairs as a collectable structured diagnostic** (missing field → assumed default, wrong `type` → coerced, v2 → upgraded, malformed URL → skipped) rather than silently coercing. Client mode ignores them; this is what later unlocks a consumer-oriented manifest **lint** and keeps the door open to an Image API conformance **probe** — both as optional reporting layers over the same tolerant parse, never a stricter default.
31
+
32
+ **Non-goals:** **authoring** (building/serializing new manifests — iiif-prezi3 owns the write side; iiisight stays a consumer) and being an image **server**. Validation/lint/probe modes are *not* excluded — they are welcome optional layers once the core read path is solid.
33
+
34
+ ## Domain context (IIIF)
35
+
36
+ IIIF (International Image Interoperability Framework) has two APIs relevant here:
37
+ - **Presentation API** — the JSON structure describing an object: a `Manifest` contains `Canvas`es (views/pages), which carry `Annotation`s (usually painting an image onto the canvas); `Range`s describe navigation/table-of-contents structure; `Collection`s group manifests. v2 and v3 differ substantially in shape (e.g. `@id`/`@type` vs `id`/`type`, `sequences` removed in v3, `resource` vs `body`), which is the core normalization problem this library solves.
38
+ - **Image API** — an image server endpoint whose `info.json` advertises `tiles`, sizes, and scale factors; tile-aware retrieval means computing region/size requests against that info rather than downloading full-resolution images.
39
+
40
+ When implementing normalization, verify behavior against the official IIIF specs and reference the JS `@iiif/parser` upgrade semantics for v2→v3 as the compatibility target.
41
+
42
+ ## Working here
43
+
44
+ Because no toolchain is committed yet, do not assume build/test/lint commands exist — check for a manifest (`pyproject.toml`, `setup.cfg`, etc.) before running anything. The sections below describe the **intended** toolchain and conventions to adopt when bootstrapping; once the real commands exist, update this file so its description matches reality. Stale guidance here is worse than no guidance.
45
+
46
+ ## Python conventions
47
+
48
+ - Target Python 3.10+ (set `requires-python = ">=3.10"` in `pyproject.toml`; keep it in sync with the trove classifiers when bumping the floor). Confirm the floor when the toolchain is established.
49
+ - `from __future__ import annotations` is unnecessary on 3.10+; prefer native PEP 604 (`X | None`) and PEP 585 (`list[str]`) syntax.
50
+ - Add type hints to all new/edited public functions, methods, and class attributes. Keep them precise — `Any` is a code smell, not a default. This matters especially for a "normalize-anything" parser: the normalized v3 model should be a typed surface callers can rely on.
51
+ - Prefer f-strings over `.format()` / `%`.
52
+ - **Docstrings & comments use [Google style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings)** (`Args:` / `Returns:` / `Raises:` sections, one-line summary first). Every public module, class, and function gets a docstring; comments explain *why*, not *what*. Whenever you touch a function, method, class, or module, create or update its docstring and nearby comments in the same edit. Keep summaries tight — only add `Args:`/`Returns:`/`Raises:` sections where they carry real information.
53
+ - **Async:** the client is async-first. Keep I/O (manifest/collection fetches, `info.json` retrieval, tile requests) non-blocking; do not call blocking network APIs from `async` code paths. Keep pure normalization/parsing logic synchronous and I/O-free so it is trivially testable without a network.
54
+ - Treat the public import paths and the normalized-model attribute names as a **contract** once the package is published. Don't break them without surfacing it first; a break is a MAJOR (semver) event and must be documented for users.
55
+
56
+ ## Formatting & linting
57
+
58
+ - Use `ruff` for both linting and formatting (`ruff check .` and `ruff format .`). No separate `black` / `flake8` / `isort` — `ruff` covers all three.
59
+ - Line length 100. Double quotes. Put the `[tool.ruff]` block in `pyproject.toml` rather than a separate config file.
60
+ - Run `ruff check --fix` before committing; never silence a lint with `# noqa` without a comment explaining why.
61
+
62
+ ## Testing
63
+
64
+ - Use `pytest` with `pytest-asyncio` for coroutine tests, and mock/stub HTTP rather than hitting live IIIF servers so the suite is deterministic and offline.
65
+ - Keep pure normalization (v2→v3) and structural-walk logic covered by fast, network-free unit tests fed real-world manifest fixtures — including deliberately spec-imperfect documents, since **tolerance** is a core requirement.
66
+ - Store manifest/collection/`info.json` fixtures under `tests/` and cover both v2 and v3 inputs plus the v2→v3 upgrade path against the `@iiif/parser` semantics as the compatibility target.
67
+ - Set a coverage gate in `pyproject.toml` (`--cov-fail-under=...`). Any change that drops coverage must add tests or intentionally adjust the gate — never silently lower it.
68
+ - Single test: `pytest tests/test_foo.py::test_bar`.
69
+
70
+ ## Packaging
71
+
72
+ Adopt modern PEP 621 packaging from the start — no `setup.py`, `Pipfile`, `MANIFEST.in`, or `requirements.txt`.
73
+
74
+ - **PEP 621 metadata** lives entirely in `pyproject.toml` under `[project]` (setuptools backend). Restrict the shipped package with `[tool.setuptools.packages.find]` so `tests/` is never packaged.
75
+ - **`setuptools-scm`** derives the version from the git tag (`dynamic = ["version"]`); never hand-write a `__version__`. Any code that needs the version reads `importlib.metadata.version("iiisight")`.
76
+ - **License: Apache-2.0**, declared with the PEP 639 SPDX form (`license = "Apache-2.0"`, `license-files = ["LICENSE", "NOTICE"]`) — which requires `setuptools>=77` in `build-system.requires`. Do **not** add a `License ::` trove classifier (it conflicts with the SPDX field). The `NOTICE` file is the Apache attribution convention; keep the copyright line current.
77
+ - **Build** with `python -m build` (never `setup.py`).
78
+ - **Distribution**: a **pure-Python library on PyPI** — `pip install iiisight` (the name is confirmed available). No compiled extensions → a single universal `py3-none-any` wheel. Library-first: no server/daemon; callers bring their own event loop.
79
+ - **Dependencies**: keep them lean — one runtime dep, `httpx`, under `[project] dependencies`. Optional features go behind extras under `[project.optional-dependencies]`: `dev` (the toolchain: `pytest`, `pytest-asyncio`, `pytest-cov`, `ruff`, `build`, `twine`), `prezi3` (iiif-prezi3 interop), `cli` (a thin command-line front-end). Local/CI dev uses `pip install -e ".[dev]"`.
80
+ - **Optional CLI**: expose the reporting layers as console scripts under `[project.scripts]` (e.g. `iiisight lint <url>`, `iiisight probe <image-service>`), gated behind the `cli` extra so the core import stays dependency-light.
81
+ - Prefer automated releases (GitLab CI building sdist+wheel and publishing to PyPI via OIDC trusted publishing) over `twine upload` from a workstation.
82
+
83
+ ## Build & release
84
+
85
+ The project is hosted on **GitLab** (`gitlab.com/iiiris-org/iiisight`); CI/CD is `.gitlab-ci.yml` (there are no GitHub Actions workflows).
86
+
87
+ **Releases are automated — do not `twine upload` from a workstation.** `.gitlab-ci.yml` has two tag-triggered jobs, both using GitLab OIDC (no stored token — the OIDC id-token is exchanged for a short-lived API token via the provider's `oidc/mint-token` endpoint):
88
+
89
+ - **`publish`** → PyPI, on a clean version tag `vX.Y` / `vX.Y.Z` (regex excludes prereleases). `setuptools-scm` turns `v0.1` → version `0.1`.
90
+ - **`publish-testpypi`** → TestPyPI, on a prerelease tag containing `rc` (e.g. `v0.1rc1`) — the rehearsal path.
91
+
92
+ So the flow is: `git tag v0.1rc1 && git push origin v0.1rc1` (rehearse on TestPyPI), then `git tag v0.1 && git push origin v0.1` (real release).
93
+
94
+ **One-time PyPI setup required** before the first release: add a GitLab "pending publisher" — namespace `iiiris-org`, project `iiisight`, pipeline file path `.gitlab-ci.yml`, environment blank — at **both** https://pypi.org/manage/account/publishing/ and (for the rehearsal) https://test.pypi.org/manage/account/publishing/. "Pending" because the project does not exist on either index yet; it is created on first publish.
95
+
96
+ At release time, rename `## [Unreleased]` in `CHANGELOG.md` to `## [X.Y] - YYYY-MM-DD`, add a fresh empty `## [Unreleased]` above it, and update the link references at the bottom.
97
+
98
+ ## Keeping docs in sync
99
+
100
+ Documentation must stay current with the code — update affected docs in the **same commit** as the change, not as a follow-up. Stale or missing docs on code you changed is not acceptable.
101
+
102
+ - `README.md` is the single source of truth for the readme.
103
+ - `CLAUDE.md` (this file) is the contract for future Claude sessions. When the toolchain, public API surface, testing setup, coverage gate, or file layout changes, update this file so it matches reality.
104
+ - Maintain a `CHANGELOG.md` ([Keep a Changelog](https://keepachangelog.com/) format, newest first): every user-affecting change gets an entry under `## [Unreleased]` in the same commit; breaking changes go under a `Breaking` heading with a migration path and pair with a MAJOR version bump.
105
+
106
+ ### The user documentation (`docs/`, Read the Docs)
107
+
108
+ The Sphinx site under `docs/` (published on Read the Docs, configured by `.readthedocs.yaml`; MyST Markdown + Furo + `sphinx-design` tabs) is the primary user-facing documentation. **As the project evolves, keep it in sync in the same commit as the code** — treat it as part of the change, never a follow-up. Aim for docs that are both **comprehensive** (every public capability is covered) and **user-friendly** (task-oriented, skimmable, welcoming to newcomers).
109
+
110
+ When you change the public API or behavior:
111
+
112
+ - **Add or update the relevant guide page** (`docs/guide/*.md`) — these are task-oriented ("Fetching", "Images & tiles", "Content Search", …). A *new* public capability gets a guide section or page; a changed one gets its section updated. Add a new page to the `toctree` in `docs/index.md`.
113
+ - **The API reference** (`docs/reference/api.md`) is generated from docstrings via `automodule`, so it updates itself — but that means **every public function, class, and attribute needs a clear, current docstring** (Google style). A new public submodule needs its own `automodule` block added there.
114
+ - **Update `docs/quickstart.md`** if the change touches the core happy path.
115
+ - **Reflect user-affecting changes in `CHANGELOG.md`** (see above).
116
+
117
+ Documentation standards to uphold:
118
+
119
+ - **Show examples wherever possible.** Prefer a short, runnable code snippet over prose. Every guide page should lead with a concrete example.
120
+ - **Show both async and sync styles.** iiisight ships `AsyncClient` and a sync `Client`; any example that performs I/O must present both — use a `sphinx-design` tab-set (`::::{tab-set}` with `Async` / `Sync` `:::{tab-item}`s), mirroring the existing pages. Pure, I/O-free calls (`normalize`, `parse_info`, `ImageService.url`, `content_state.decode`, `lint`) are the same in both worlds and need only one snippet.
121
+ - **Cross-reference the API** with MyST roles (`` {class}`~iiisight.Manifest` ``, `` {meth}`~iiisight.ImageService.tile_grid` ``) so guides link into the reference.
122
+ - **Verify the build** before committing: `pip install -e ".[docs]"` then `python -m sphinx -b html --keep-going docs docs/_build/html` must complete with **zero warnings** (broken cross-references and duplicate objects surface as warnings). `docs/_build/` is gitignored.
@@ -0,0 +1,90 @@
1
+ # Contributing to iiisight
2
+
3
+ Thanks for your interest in iiisight. This guide covers the development setup and
4
+ the conventions CI enforces. For the architecture and deeper design rationale,
5
+ see `CLAUDE.md` and `PLAN.md`.
6
+
7
+ ## Development setup
8
+
9
+ Requires Python 3.10+.
10
+
11
+ ```bash
12
+ python -m venv .venv && source .venv/bin/activate
13
+ pip install -e ".[dev]" # installs iiisight + the test/lint/build toolchain
14
+ ```
15
+
16
+ The version is derived from the git tag by `setuptools-scm`; there is no
17
+ hand-maintained version string.
18
+
19
+ ## Everyday commands
20
+
21
+ ```bash
22
+ pytest # run the suite + coverage gate
23
+ pytest tests/test_normalize_v3.py # a single file
24
+ pytest tests/test_image.py::test_tile_grid_scale_factor_8 # a single test
25
+ ruff check . # lint
26
+ ruff format . # auto-format
27
+ ruff format --check . # verify formatting (as CI does)
28
+ ```
29
+
30
+ CI (`.gitlab-ci.yml`) runs `ruff check`, `ruff format --check`, and `pytest`
31
+ across Python 3.10–3.13. All three must pass.
32
+
33
+ ## Conventions
34
+
35
+ - **Coverage gate: 90%** (`--cov-fail-under=90` in `pyproject.toml`). New behavior
36
+ needs tests; if a line is genuinely defensive/unreachable, mark it
37
+ `# pragma: no cover` with a reason rather than lowering the gate.
38
+ - **Tolerance is a core invariant.** `normalize()` must never raise on
39
+ spec-imperfect input — it repairs and records a `Diagnostic`. Every
40
+ normalization path should have a malformed-input test asserting *"does not
41
+ raise, emits the expected diagnostic, yields a usable model."*
42
+ - **The model is pure and I/O-free.** All network access is explicit on the
43
+ client (`fetch`, `expand`, `load_info`, …); never fetch behind attribute access.
44
+ - **Style:** `ruff` for lint + format (line length 100, double quotes). Precise
45
+ type hints on public functions; Google-style docstrings; f-strings. Prefer
46
+ native `X | None` / `list[str]` over `typing`/`from __future__ import`.
47
+ - **Public API is a contract** once released. Keep import paths and the normalized
48
+ model's attribute names stable; a break is a MAJOR-version, `CHANGELOG`-documented
49
+ event.
50
+
51
+ ## Changelog
52
+
53
+ Every user-affecting change gets an entry under `## [Unreleased]` in
54
+ `CHANGELOG.md` (Keep a Changelog format), **in the same commit** as the change.
55
+ Internal-only churn (refactors, test/CI/formatting) does not need an entry.
56
+
57
+ ## Real-world check (optional)
58
+
59
+ `scripts/validate_realworld.py` runs iiisight against live IIIF servers (not part
60
+ of CI — it needs network). Run it when touching normalization, the upgrade, or the
61
+ tile math:
62
+
63
+ ```bash
64
+ python scripts/validate_realworld.py
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ The user documentation is a Sphinx site under `docs/` (MyST Markdown, Furo theme),
70
+ published on Read the Docs. Build it locally with:
71
+
72
+ ```bash
73
+ pip install -e ".[docs]"
74
+ python -m sphinx -b html --keep-going docs docs/_build/html
75
+ open docs/_build/html/index.html
76
+ ```
77
+
78
+ The build must complete with **zero warnings** (broken cross-references show up as
79
+ warnings). When you change the public API or behavior, update the relevant guide
80
+ page under `docs/guide/`, keep every public symbol's docstring current (the API
81
+ reference is generated from them), and show **both async and sync** styles for any
82
+ example that does I/O. See the "Keeping docs in sync" section of `CLAUDE.md` for
83
+ the full policy.
84
+
85
+ ## Releases
86
+
87
+ Releases are automated via GitLab CI and OIDC trusted publishing — see the
88
+ **Build & release** section of `CLAUDE.md`. In short: push a `vX.Y` tag to publish
89
+ to PyPI (or a `vX.Yrc1` tag to rehearse on TestPyPI); do not `twine upload` from a
90
+ workstation.
iiisight-0.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Roger Howard
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
iiisight-0.1/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ iiisight
2
+ Copyright 2026 Roger Howard
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).